Menu framework in place

This commit is contained in:
Kayne Ruse
2013-06-12 21:56:17 +10:00
parent f3ec4d4d8e
commit 2148c1f13e
8 changed files with 92 additions and 46 deletions
+3 -5
View File
@@ -23,15 +23,13 @@
#include <stdexcept>
Button::Button():
Button(0,0, nullptr, nullptr)
{
Button::Button(Sint16 i, Sint16 j, SDL_Surface* imageSurface, SDL_Surface* fontSurface, std::string s) {
Setup(i, j, imageSurface, fontSurface, s);
}
Button::Button(Sint16 i, Sint16 j, SDL_Surface* imageSurface, SDL_Surface* fontSurface, std::string s) {
void Button::Setup(Sint16 i, Sint16 j, SDL_Surface* imageSurface, SDL_Surface* fontSurface, std::string s) {
x = i;
y = j;
state = State::NORMAL;
SetSurfaces(imageSurface, fontSurface);
+6 -4
View File
@@ -34,9 +34,11 @@ public:
NORMAL, HOVER, PRESSED
};
Button();
Button() = default;
Button(Sint16 x, Sint16 y, SDL_Surface* imageSurface, SDL_Surface* fontSurface, std::string text = "");
void Setup(Sint16 x, Sint16 y, SDL_Surface* imageSurface, SDL_Surface* fontSurface, std::string text = "");
//return the current state
State MouseMotion(SDL_MouseMotionEvent const&);
State MouseButtonDown(SDL_MouseButtonEvent const&);
@@ -69,11 +71,11 @@ public:
private:
State CalcState(Sint16 x, Sint16 y, bool leftPressed);
Sint16 x, y;
Sint16 textX, textY; //prevent recalc every loop
Sint16 x = 0, y = 0;
Sint16 textX = 0, textY = 0; //prevent recalc every loop
Image image;
RasterFont font;
State state;
State state = State::NORMAL;
std::string text;
};