-
Notifications
You must be signed in to change notification settings - Fork 0
/
menuButton.h
89 lines (60 loc) · 1.56 KB
/
menuButton.h
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#pragma once
#include <SDL.h>
#include <SDL_image.h>
#include <SDL_ttf.h>
#include <string>
#include "LTexture.h"
#include "macros.h"
#include "Rectangle.h"
#ifndef __MENUBUTTON_H__
#define __MENUBUTTON_H__
class menuButton
{
protected:
//position and dimensions on the screen
SDL_Point mPosition;
SDL_Color DefaultColor;
SDL_Color HoldColor;
SDL_Color HoverColor;
Rectangle hoverBox;
//Button constants
int BUTTON_WIDTH = 300;
int BUTTON_HEIGHT = 100;
std::string buttonText;
LTexture textTexture;
SDL_Texture* ttfTexture = NULL;
TTF_Font *Font = NULL;
protected:
//void loadTexture(SDL_Renderer* Renderer);
public:
int textWidth, textHeight;
//change to true when clicked
bool pressed = false;
bool hovering = false;
bool held = false;
Rectangle displayRect;
SDL_Rect mRect;
SDL_Rect textRect;
public:
menuButton();
menuButton(int x, int y, std::string text);
menuButton(Rectangle oRect, std::string text, SDL_Renderer* Renderer);
void handleEvent(SDL_Event* e);
void setPosition(int x, int y);
bool checkMouse(int x, int y);
bool loadText(SDL_Renderer* Renderer);
bool loadText(SDL_Renderer* Renderer, SDL_Color stagecolor);
bool render(SDL_Renderer* Renderer);
bool render(SDL_Renderer* Renderer, SDL_Color buttonColor);
std::string getText() { return buttonText; }
void changeText(std::string text) { buttonText = text; }
void setDimensions(int w, int h);
void setDimensions(int w, int h, SDL_Renderer* Renderer);
};
class newStageButton : public menuButton
{
public:
newStageButton();
std::string getFileName();
};
#endif