From 8eb0808fecb8c57eff877fddf38db91b1f067921 Mon Sep 17 00:00:00 2001 From: knolax <1339802534.kk@gmail.com> Date: Tue, 28 Feb 2017 11:07:10 -0500 Subject: initial commit, this is the gfx library which serves as a crappy wrapper for SDL. --- example/Terminus.ttf | Bin 0 -> 423992 bytes example/img/A.bmp | Bin 0 -> 120122 bytes example/img/B.bmp | Bin 0 -> 120122 bytes example/img/C.bmp | Bin 0 -> 120122 bytes example/img/D.bmp | Bin 0 -> 120122 bytes example/img/F.bmp | Bin 0 -> 120122 bytes example/img/back.bmp | Bin 0 -> 768122 bytes example/img/black.bmp | Bin 0 -> 120122 bytes example/img/blue.bmp | Bin 0 -> 120122 bytes example/img/butt.bmp | Bin 0 -> 768122 bytes example/img/orange.bmp | Bin 0 -> 120122 bytes example/img/red.bmp | Bin 0 -> 120122 bytes example/img/white.bmp | Bin 0 -> 120122 bytes example/main | Bin 0 -> 70656 bytes example/main.cpp | 157 +++++++++++++++++++++++++++++++ example/main.h | 4 + example/main.o | Bin 0 -> 48424 bytes example/makefile | 6 ++ gfx.cpp | 152 ++++++++++++++++++++++++++++++ gfx.h | 27 ++++++ gfx.o | Bin 0 -> 9008 bytes gui.cpp | 250 +++++++++++++++++++++++++++++++++++++++++++++++++ gui.h | 72 ++++++++++++++ gui.o | Bin 0 -> 92736 bytes libgfx.a | Bin 0 -> 9470 bytes libgui.a | Bin 0 -> 103782 bytes makefile | 13 +++ 27 files changed, 681 insertions(+) create mode 100644 example/Terminus.ttf create mode 100644 example/img/A.bmp create mode 100644 example/img/B.bmp create mode 100644 example/img/C.bmp create mode 100644 example/img/D.bmp create mode 100644 example/img/F.bmp create mode 100644 example/img/back.bmp create mode 100644 example/img/black.bmp create mode 100644 example/img/blue.bmp create mode 100644 example/img/butt.bmp create mode 100644 example/img/orange.bmp create mode 100644 example/img/red.bmp create mode 100644 example/img/white.bmp create mode 100755 example/main create mode 100644 example/main.cpp create mode 100644 example/main.h create mode 100644 example/main.o create mode 100644 example/makefile create mode 100644 gfx.cpp create mode 100644 gfx.h create mode 100644 gfx.o create mode 100644 gui.cpp create mode 100644 gui.h create mode 100644 gui.o create mode 100644 libgfx.a create mode 100644 libgui.a create mode 100644 makefile diff --git a/example/Terminus.ttf b/example/Terminus.ttf new file mode 100644 index 0000000..3eb75d2 Binary files /dev/null and b/example/Terminus.ttf differ diff --git a/example/img/A.bmp b/example/img/A.bmp new file mode 100644 index 0000000..b6e2f86 Binary files /dev/null and b/example/img/A.bmp differ diff --git a/example/img/B.bmp b/example/img/B.bmp new file mode 100644 index 0000000..852cfde Binary files /dev/null and b/example/img/B.bmp differ diff --git a/example/img/C.bmp b/example/img/C.bmp new file mode 100644 index 0000000..a8b98a6 Binary files /dev/null and b/example/img/C.bmp differ diff --git a/example/img/D.bmp b/example/img/D.bmp new file mode 100644 index 0000000..d8f5b7d Binary files /dev/null and b/example/img/D.bmp differ diff --git a/example/img/F.bmp b/example/img/F.bmp new file mode 100644 index 0000000..b13dce9 Binary files /dev/null and b/example/img/F.bmp differ diff --git a/example/img/back.bmp b/example/img/back.bmp new file mode 100644 index 0000000..97992f5 Binary files /dev/null and b/example/img/back.bmp differ diff --git a/example/img/black.bmp b/example/img/black.bmp new file mode 100644 index 0000000..c36403e Binary files /dev/null and b/example/img/black.bmp differ diff --git a/example/img/blue.bmp b/example/img/blue.bmp new file mode 100644 index 0000000..c36403e Binary files /dev/null and b/example/img/blue.bmp differ diff --git a/example/img/butt.bmp b/example/img/butt.bmp new file mode 100644 index 0000000..7c732ed Binary files /dev/null and b/example/img/butt.bmp differ diff --git a/example/img/orange.bmp b/example/img/orange.bmp new file mode 100644 index 0000000..00f66a2 Binary files /dev/null and b/example/img/orange.bmp differ diff --git a/example/img/red.bmp b/example/img/red.bmp new file mode 100644 index 0000000..d1588c5 Binary files /dev/null and b/example/img/red.bmp differ diff --git a/example/img/white.bmp b/example/img/white.bmp new file mode 100644 index 0000000..f3dca25 Binary files /dev/null and b/example/img/white.bmp differ diff --git a/example/main b/example/main new file mode 100755 index 0000000..02712dc Binary files /dev/null and b/example/main differ diff --git a/example/main.cpp b/example/main.cpp new file mode 100644 index 0000000..67f4487 --- /dev/null +++ b/example/main.cpp @@ -0,0 +1,157 @@ +#include +#include +#include "gfx.h" +#include "main.h" +#include "gui.h" +int loop; +float sum; +butt butts; +tbuff texts; +std::string output; +int main (int argc, char * argv[]) { + //inits program + initgfx(400,600, "SDL calculator"); + //main loop, this is defined in main.h and global + loop = 1; + SDL_Texture * ttp = loadtexture("img/blue.bmp"); + sum = -1; + //adds the gui elements + butts.add(50,400,50,20, "reset"); + butts.add(250,400,100,20, "calculate"); + butts.add(380,0,20,20, "x"); + texts.add(50,50,300,20); + texts.add(50,100,300,20); + texts.add(50,150,300,20); + texts.add(50,200,300,20); + + while(loop) { + //polls events, which are in a buffer + //returns 1 if there is event in buffer + //returns 0 if buffer is empty + SDL_Event event; + while (SDL_PollEvent(&event)) { + switch (event.type) { + //loop is a global defined in main.h + case SDL_QUIT: + printf("loop = 0;\n"); + loop = 0; + break; + //adds to the text input manager + case SDL_TEXTINPUT: + //if the input buffer was empty before, + //make it the text, which is char[] which + //is *char + texts.charin( event.text.text); + printf("text input event\n"); + break; + //this only applies if you're typing in chinese + case SDL_TEXTEDITING: + printf("text editing event\n"); + break; + //for when the moose moves + case SDL_MOUSEMOTION: + butts.hover(event.motion.x, event.motion.y); + texts.hover(event.motion.x, event.motion.y); + break; + //left click only, double clicks cancer out so only odd + case SDL_MOUSEBUTTONDOWN: + if(( event.button.button == SDL_BUTTON_LEFT) && ((event.button.clicks % 2) != 0)) { + butts.press(event.button.x, event.button.y); + texts.press(event.button.x, event.button.y); + } + break; + } + } + //checks the states of the buttons and handles them accordingly + if (butts.state(0) & TOGGLE) { + //returns all the text buffers to "" + texts.reset(); + //toggles the state of the button back to off + butts.unpress(0); + } + //actually calculates + if (butts.state(1) & TOGGLE) { + sum = 0; + //since only error is an exception + try { + sum += stof(texts.buffs[0]); + sum += stof(texts.buffs[1]); + sum += stof(texts.buffs[2]); + sum += stof(texts.buffs[3]); + sum = sum / 4.0; + output = std::to_string(sum); + //I know that sum can be -1, but NULL doesn't work well in cpp + //and I don't want to use a second variable + } catch (std::invalid_argument& a) { + sum = -1; + //untoggles buton + output = "inputs not valid"; + } + butts.unpress(1); + } + //quits the program + if (butts.state(2) & TOGGLE) { + loop = false; + butts.unpress(2); + } + cleargfx(); + //grade score color + SDL_Color outc; + outc.r = 255; + outc.g = 255; + outc.b = 255; + outc.a = 255; + //the text box labesl + drawtext(0,50,"Test1",outc); + drawtext(0,100,"Test2",outc); + drawtext(0,150,"Test3",outc); + drawtext(0,200,"Test4",outc); + //load grade image + SDL_Surface * tsp; + SDL_Texture * ttp; + + //so we don't assign a grade to NOT VALID + if (sum != -1) { + if (sum >= 90) { + tsp = SDL_LoadBMP("img/A.bmp"); + drawtext(100,450,"A",outc); + } else if( sum >= 80) { + tsp = SDL_LoadBMP("img/B.bmp"); + drawtext(100,450,"B",outc); + } else if (sum >= 70){ + tsp = SDL_LoadBMP("img/C.bmp"); + drawtext(100,450,"C",outc); + } else if (sum >= 60){ + tsp = SDL_LoadBMP("img/D.bmp"); + drawtext(100,450,"D",outc); + } else { + tsp = SDL_LoadBMP("img/F.bmp"); + drawtext(100,450,"F",outc); + } + ttp = SDL_CreateTextureFromSurface(renderp, tsp); + drawimg(100,450,50,50,ttp); + SDL_FreeSurface(tsp); + SDL_DestroyTexture(ttp); + } + + + //draws the grade score + drawtext(180,450,output.c_str(),outc); + //draws all buttons + butts.drawbutt(); + //draws text buffer + texts.drawtbuff(); + //updates frame + //since only error is an exception + //all the work is done here + + drawimg(0,0,20,20,"img/red.bmp"); + drawimg(20,20,10,10,ttp); + drawrect(0,20,10,10,255,255,255,50); + updategfx(); + } + SDL_DestroyTexture(ttp); + quitgfx(); + return 0; +} + diff --git a/example/main.h b/example/main.h new file mode 100644 index 0000000..e02ea4b --- /dev/null +++ b/example/main.h @@ -0,0 +1,4 @@ +#ifndef MAIN_H +#define MAIN_H +extern int loop; +#endif diff --git a/example/main.o b/example/main.o new file mode 100644 index 0000000..ca599d7 Binary files /dev/null and b/example/main.o differ diff --git a/example/makefile b/example/makefile new file mode 100644 index 0000000..9643478 --- /dev/null +++ b/example/makefile @@ -0,0 +1,6 @@ +main : main.o + g++ main.o -o main -L/home/knolax/code/cpp/gfx -lgui -lgfx -lSDL2 -lSDL2_ttf +main.o : main.cpp + g++ -c main.cpp -I/home/knolax/code/cpp/gfx +clean : + rm gfx.o main.o gui.o diff --git a/gfx.cpp b/gfx.cpp new file mode 100644 index 0000000..ca597d5 --- /dev/null +++ b/gfx.cpp @@ -0,0 +1,152 @@ +#include "gfx.h" +//all the global variables first set here +SDL_Window *mwindowp; // main window were everything foes +SDL_DisplayMode * screenp; +SDL_Renderer * renderp; +TTF_Font * fontp; +int maxx; +int maxy; +int initgfx(int x, int y,const char * title) { + //initializing SDL 2 + SDL_Init(SDL_INIT_EVERYTHING); + //sets global variables for ease of access later + //they are 100 by 200 for now because DisplayMode takes long to implement + //screen resizes are handled by sdl events + //we're not gonna hcange these for now + maxx = x; + maxy = y; + //makes sdl compatible with opengl(for later use) + SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2); + SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8); + //creates window + mwindowp = SDL_CreateWindow(title, 0, 0, maxx, maxy, SDL_WINDOW_OPENGL); + //renderer to write to + //the int selects which drivers, -1 just selects first applicatble + renderp = SDL_CreateRenderer(mwindowp, -1,SDL_RENDERER_ACCELERATED); + //load truetype font + int err = TTF_Init(); + fontp = TTF_OpenFont("Terminus.ttf",18); + if (fontp == NULL) { + printf("font failed to load\n"); + printf("ttf error %s",TTF_GetError()); + } + return 0; +} +//two draw functions for convenience +int drawimg(int x, int y, int w, int h,SDL_Texture * tex) { + SDL_Rect r; + r.x = x; + r.y = y; + r.w = w; + r.h = h; + //null means entire source texture + SDL_RenderCopy(renderp, tex, NULL, &r); + return 0; + +} +int drawimg(SDL_Rect r, SDL_Texture * tex) { + SDL_RenderCopy(renderp, tex, NULL, &r); + return 0; +} +SDL_Texture * loadtexture(const char * file) { + SDL_Surface * tsp; + SDL_Texture * ttp; + tsp = SDL_LoadBMP(file); + ttp = SDL_CreateTextureFromSurface(renderp, tsp); + SDL_SetTextureBlendMode(ttp, SDL_BLENDMODE_ADD); + SDL_FreeSurface(tsp); + return ttp; +} +int drawimg(int x, int y, int w, int h, const char * file) { + SDL_Texture * ttp = loadtexture(file); + drawimg(x,y,w,h,ttp); + SDL_DestroyTexture(ttp); +} +int drawrect (int x, int y, int w, int h, const char * color) { + std::string str; + str = color; + SDL_Rect r; + r.x = x; + r.y = y; + r.w = w; + r.h = h; + if (!str.compare("red")) { + SDL_SetRenderDrawColor(renderp,255,0,0,255); + } + if (!str.compare("blue")) { + SDL_SetRenderDrawColor(renderp,0,0,255,255); + } + if (!str.compare("orange")) { + SDL_SetRenderDrawColor(renderp,255,180,20,255); + } + if (!str.compare("white")) { + SDL_SetRenderDrawColor(renderp,255,255,255,255); + } + if (!str.compare("black")) { + SDL_SetRenderDrawColor(renderp,0,0,0,255); + } + SDL_RenderFillRect(renderp,&r); + SDL_SetRenderDrawColor(renderp,0,0,0,255); + return 0; +} +int drawrect (int x, int y, int w, int h,int r, int g, int b, int a) { + SDL_Rect rect; + rect.x = x; + rect.y = y; + rect.w = w; + rect.h = h; + SDL_SetRenderDrawColor(renderp,r,g,b,a); + SDL_SetRenderDrawBlendMode(renderp, SDL_BLENDMODE_ADD); + SDL_RenderFillRect(renderp,&rect); + SDL_SetRenderDrawColor(renderp,0,0,0,255); + return 0; +} +//draws text +int drawtext(int x, int y,const char * text, SDL_Color c) { + //surface the font renderer writes to + SDL_Surface * sp; + //color of text + SDL_Color co; + co.r = 100; + co.g = 100; + co.b = 100; + co.a = 100; + //renders text with global font + sp = TTF_RenderText_Solid(fontp, text, c); + //texture to actually draw + SDL_Texture * tp; + tp = SDL_CreateTextureFromSurface(renderp, sp); + //the surface has to be freed because it is only used once and the pointer + //to it was declared in a funcion + SDL_FreeSurface(sp); + //finding the width and height of the text + int w; + int h; + SDL_QueryTexture(tp, NULL, NULL, &w, &h); + //drawing the texture + drawimg(x, y, w, h, tp); + SDL_DestroyTexture(tp); +} +//this is where almost all of the grame code is +int updategfx() { + + //checks the states of the buttons and handles them accordingly + + //clears renderer buffer + + SDL_RenderPresent(renderp); + return 0; +} +int cleargfx() { + SDL_RenderClear(renderp); +} +//quits all the libraries and releases some memory +int quitgfx() { + //release of context + SDL_DestroyRenderer(renderp); + TTF_Quit(); + SDL_Quit(); + return 0; +} diff --git a/gfx.h b/gfx.h new file mode 100644 index 0000000..f2eb889 --- /dev/null +++ b/gfx.h @@ -0,0 +1,27 @@ +#ifndef GFX_H +#define GFX_H +#include +#include +#include +#include +#include +//these are all global variables, +extern SDL_Window *mwindow; // main window were everything foes +extern SDL_DisplayMode * screen; +extern SDL_GLContext context; +extern SDL_Renderer * renderp; +extern TTF_Font * fontp; +extern int maxx; +extern int maxy; +int initgfx(int x, int y, const char * title); +int cleargfx(); +int quitgfx(); +int updategfx(); +int drawimg(SDL_Rect r, SDL_Texture * tex); +int drawimg(int x, int y, int w, int h,SDL_Texture * tex); +int drawimg(int x, int y, int w, int h, const char * file); +SDL_Texture * loadtexture(const char * file); +int drawrect(int x, int y, int w, int h, const char *); +int drawrect (int x, int y, int w, int h,int r, int g, int b, int a); +int drawtext(int x, int y,const char * text, SDL_Color c); +#endif diff --git a/gfx.o b/gfx.o new file mode 100644 index 0000000..485e58e Binary files /dev/null and b/gfx.o differ diff --git a/gui.cpp b/gui.cpp new file mode 100644 index 0000000..30889b9 --- /dev/null +++ b/gui.cpp @@ -0,0 +1,250 @@ +#include "gui.h" +hitbox::hitbox() { + return; +} +int hitbox::add(int x, int y, int w, int h) { + SDL_Rect rr; + rr.x = x; + rr.y = y; + rr.w = w; + rr.h = h; + rs.resize(rs.size()+1); + rs[rs.size() - 1] = rr; + return 0; +} +int hitbox::check(int x, int y) { + int i = 0; + while (i < rs.size()) { + if ((rs[i].x <= x) && (x <= (rs[i].x + rs[i].w))) { + if ((rs[i].y <= y) && (y <= (rs[i].y + rs[i].h))) { + return i; + } + } + i++; + } + return -1; +} +SDL_Rect hitbox::get(int index) { + if ((index >= 0) && (index < rs.size())) { + return rs[index]; + } else { + //if properly managed should never happen + SDL_Rect r; + r.x = -10000; + return r; + } +} +butt::butt() { + return; +} +int butt::add(int x, int y, int w, int h, std::string name) { + boxes.add(x, y, w, h); + names.resize(names.size() + 1); + names[names.size() - 1] = name; + states.resize(states.size() + 1); + //zero means not toggled and not hovered + states[states.size() - 1] = 0; + return 0; +} +int butt::hover(int x, int y) { + int i = 0; + while (i < states.size()) { + //sets hover bit to 0 by AND'ing with the opposite + states[i] = states[i] & (~HOVER); + i++; + } + int c = boxes.check(x, y); + if (c != -1) { + states[c] = states[c] | HOVER; + } + return 0; +} +int butt::press(int x, int y) { + int c = boxes.check(x, y); + if (c != -1) { + states[c] = states[c] ^ TOGGLE; + } + return 0; +} +//doesn't do anything for now because just press will do the trick +int butt::unpress(int index) { + states[index] = states[index] & (~TOGGLE); +} +int butt::drawbutt() { + int i = 0; + while (i < states.size()) { + SDL_Rect r = boxes.get(i); + SDL_Color c; + switch (states[i]) { + case TOGGLE : + drawrect(r.x,r.y,r.w,r.h,140,140,140,255); + c.r = 255; + c.g = 255; + c.b = 255; + c.a = 255; + drawtext(r.x, r.y, names[i].c_str(),c); + break; + case HOVER : + drawrect(r.x,r.y,r.w,r.h,140,140,140,255); + c.r = 255; + c.g = 255; + c.b = 255; + c.a = 255; + drawtext(r.x, r.y, names[i].c_str(),c); + break; + case TOGGLE | HOVER : + drawrect(r.x,r.y,r.w,r.h,140,140,140,255); + c.r = 255; + c.g = 255; + c.b = 255; + c.a = 255; + drawtext(r.x, r.y, names[i].c_str(),c); + break; + default : + drawrect(r.x,r.y,r.w,r.h,140,140,140,255); + c.r = 0; + c.g = 0; + c.b = 0; + c.a = 255; + drawtext(r.x, r.y, names[i].c_str(),c); + break; + } + i++; + } + return 0; +} + +int butt::state(int index){ + if ((index >= 0) && (index < states.size())) { + return states[index]; + } else { + return -1; + } +} +int butt::size() { + return states.size(); +} +//---=[TBUFF]=--- +// +// +// +tbuff::tbuff() { + return; +} +int tbuff::add(int x, int y, int w, int h) { + boxes.add(x, y, w, h); + buffs.resize(buffs.size() + 1); + buffs[buffs.size() - 1] = ""; + states.resize(states.size() + 1); + //zero means not toggled and not hovered + states[states.size() - 1] = 0; + return 0; +} +int tbuff::hover(int x, int y) { + int i = 0; + while (i < states.size()) { + //sets hover bit to 0 by AND'ing with the opposite + states[i] = states[i] & (~HOVER); + i++; + } + int c = boxes.check(x, y); + if (c != -1) { + states[c] = states[c] | HOVER; + } + return 0; +} +int tbuff::press(int x, int y) { + int i = 0; + while (i < states.size()) { + //sets hover bit to 0 by AND'ing with the opposite + states[i] = states[i] & (~TOGGLE); + i++; + } + int c = boxes.check(x, y); + + if (c != -1) { + states[c] = states[c] ^ TOGGLE; + SDL_Rect r = boxes.get(c); + SDL_StartTextInput(); + SDL_SetTextInputRect(&r); + } else { + SDL_StopTextInput(); + } + return 0; +} +//doesn't do anything for now because just press will do the trick +int tbuff::unpress(int index) { + states[index] = states[index] & (~TOGGLE); + SDL_StopTextInput(); +} +int tbuff::drawtbuff() { + int i = 0; + while (i < states.size()) { + SDL_Rect r = boxes.get(i); + SDL_Color c; + switch (states[i]) { + case TOGGLE : + drawrect(r.x,r.y,r.w,r.h,140,140,140,255); + c.r = 255; + c.g = 255; + c.b = 255; + c.a = 255; + drawtext(r.x, r.y, buffs[i].c_str(),c); + break; + case HOVER : + drawrect(r.x,r.y,r.w,r.h,180,180,180,255); + c.r = 0; + c.g = 0; + c.b = 0; + c.a = 0; + drawtext(r.x, r.y, buffs[i].c_str(),c); + break; + case TOGGLE | HOVER : + drawrect(r.x,r.y,r.w,r.h,180,180,180,255); + c.r = 0; + c.g = 0; + c.b = 0; + c.a = 0; + drawtext(r.x, r.y, buffs[i].c_str(),c); + break; + default : + drawrect(r.x,r.y,r.w,r.h,140,140,140,255); + c.r = 0; + c.g = 0; + c.b = 0; + c.a = 255; + drawtext(r.x, r.y, buffs[i].c_str(),c); + break; + } + i++; + } + return 0; +} +int tbuff::reset() { + int i = 0; + while (i < buffs.size()) { + buffs[i] = ""; + i++; + } + return 0; +} +int tbuff::charin(const char *text) { + int i = 0; + while (i < states.size()) { + if (states[i] & TOGGLE) { + buffs[i] = buffs[i] + text; + } + i++; + } + return 0; +} +int tbuff::state(int index){ + if ((index >= 0) && (index < states.size())) { + return states[index]; + } else { + return -1; + } +} +int tbuff::size() { + return states.size(); +} diff --git a/gui.h b/gui.h new file mode 100644 index 0000000..2c72e80 --- /dev/null +++ b/gui.h @@ -0,0 +1,72 @@ +#ifndef GUI_H +#define GUI_H +#include +#include +#include +#include "gfx.h" +//for the states, they can be OR'd together +#define TOGGLE 1 +#define HOVER 2 +//---=[structure of gui elements]=--- +//gfxupdate handles input events and passess to +//butt and textin classesss +//butt and textin have hitbox members for each of their elements that +//they take mouse data to. +class hitbox { + std::vector rs;//vector of Rects to manage + public: + hitbox();//constructor does nothing + int add(int x, int y, int w, int h); // there is an add but no remove + //because this class is not meant to be edited at runtime. the reason + //we don't just pass a vector is for ease of use by parent function + int check(int x, int y);//checks hitbox + SDL_Rect get(int index); +}; +class butt { + std::vector names; // vector of strings that are the names + //of buttons + std::vector states; + hitbox boxes;//manager of the hitboxes of all the buttons + + public : + butt(); // empty constructor + int add(int x, int y, int w, int h, std::string name); // not meant + //to be done during runtime, it's not in the constructor for ease + + //of use handle the three mouseevents from updategfx(), not return + //because they're not going to run into a runtime error the parent + //has to handle + int hover(int x, int y); + int press(int x,int y ); + int unpress(int index); + //as the Renderer is a global var, draw does not take any inputs + int drawbutt(); + //get's the state of a button; + int state(int index); + int size(); +}; +class tbuff { + public : + std::vector buffs; // vector of strings that are the names + //of buttons + std::vector states; + hitbox boxes;//manager of the hitboxes of all the buttons + tbuff(); // empty constructor + int add(int x, int y, int w, int h); // not meant + //to be done during runtime, it's not in the constructor for ease + + //of use handle the three mouseevents from updategfx(), not return + //because they're not going to run into a runtime error the parent + //has to handle + int hover(int x, int y); + int press(int x,int y ); + int unpress(int index); + //as the Renderer is a global var, draw does not take any inputs + int drawtbuff(); + //get's the state of a button; + int state(int index); + int size(); + int reset(); + int charin(const char *); +}; +#endif diff --git a/gui.o b/gui.o new file mode 100644 index 0000000..7032d20 Binary files /dev/null and b/gui.o differ diff --git a/libgfx.a b/libgfx.a new file mode 100644 index 0000000..2964b8d Binary files /dev/null and b/libgfx.a differ diff --git a/libgui.a b/libgui.a new file mode 100644 index 0000000..0b25307 Binary files /dev/null and b/libgui.a differ diff --git a/makefile b/makefile new file mode 100644 index 0000000..8572252 --- /dev/null +++ b/makefile @@ -0,0 +1,13 @@ +main : libgui.a libgfx.a +libgfx.a : gfx.o + ar ru libgfx.a gfx.o + ranlib libgfx.a +gfx.o : gfx.cpp + g++ -c gfx.cpp +libgui.a : gui.o + ar ru libgui.a gui.o + ranlib libgui.a +gui.o : gui.cpp + g++ -c gui.cpp +clean : + rm gfx.a gui.a libgfx.a libgui.a gfx.o gui.o -- cgit v1.1