summaryrefslogtreecommitdiff
path: root/gui.h
blob: 2c72e80119aae3f088aa8bb147cf4c7429ddd64d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#ifndef GUI_H
#define GUI_H
#include <SDL2/SDL.h>
#include<vector>
#include <string>
#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<SDL_Rect> 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<std::string> names; // vector of strings that are the names
	//of buttons
	std::vector<int> 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<std::string> buffs; // vector of strings that are the names
		//of buttons
		std::vector<int> 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