commit ddceb7e8
Further improvements to the themes menu
Changed files
| M | source/code/MenuSystem.cpp before |
| M | source/code/MenuSystem.h before |
| M | source/code/menudef.cpp before |
diff --git a/source/code/MenuSystem.cpp b/source/code/MenuSystem.cpp
index 1a985a6..803cad6 100644
--- a/source/code/MenuSystem.cpp
+++ b/source/code/MenuSystem.cpp
@@ -156,11 +156,17 @@ void Menu::addButton(Button* b) {
placeButtons();
}
-Menu::Menu(SDL_Renderer* screen) : buttons{std::vector<Button*>(10)}, isSubmenu{true}, screen{screen} {
+Menu::Menu(SDL_Renderer* screen) {
+ buttons = std::vector<Button*>(10);
+ isSubmenu = true;
+ this->screen = screen;
exit.setLabel( _("Back") );
}
-Menu::Menu(SDL_Renderer* screen,bool submenu) : buttons{std::vector<Button*>(0)}, isSubmenu{submenu}, screen{screen} {
+Menu::Menu(SDL_Renderer* screen,bool submenu) {
+ buttons = std::vector<Button*>(0);
+ isSubmenu = submenu;
+ this->screen = screen;
if (isSubmenu) {
exit.setLabel( _("Back") );
}
@@ -169,7 +175,11 @@ Menu::Menu(SDL_Renderer* screen,bool submenu) : buttons{std::vector<Button*>(0)}
}
}
-Menu::Menu(SDL_Renderer* screen, const std::string& title, bool submenu) : buttons{std::vector<Button*>(0)}, isSubmenu{submenu}, screen{screen}, title{title} {
+Menu::Menu(SDL_Renderer* screen, const std::string& title, bool submenu) {
+ buttons = std::vector<Button*>(0);
+ isSubmenu = submenu;
+ this->screen = screen;
+ this->title = title;
if (isSubmenu) {
exit.setLabel(_("Back") );
}
diff --git a/source/code/MenuSystem.h b/source/code/MenuSystem.h
index f9f5dcd..c4db24f 100644
--- a/source/code/MenuSystem.h
+++ b/source/code/MenuSystem.h
@@ -92,15 +92,11 @@ public:
class Menu : public sago::GameStateInterface
{
private:
- std::vector<Button*> buttons; //Vector holder the buttons
- Button exit; //The exit button is special since it does not have a callback function
bool isSubmenu = false; //True if the menu is a submenu
int marked = 0; //The index of the marked button (for keyboard up/down)
bool running = true; //The menu is running. The menu will terminate then this is false
SDL_Renderer *screen = nullptr; //Pointer to the screen to draw to
std::string title;
- void drawSelf(SDL_Renderer* target); //Private function to draw the screen
- void placeButtons(); //Rearanges the buttons to the correct place.
bool bMouseUp = false;
public:
//numberOfItems is the expected numberOfItems for vector initialization
@@ -117,6 +113,11 @@ public:
void Draw(SDL_Renderer* target) override;
void ProcessInput(const SDL_Event& event, bool &processed) override;
void Update() override;
+ void drawSelf(SDL_Renderer* target); //Private function to draw the screen
+ virtual void placeButtons(); //Rearanges the buttons to the correct place.
+
+ std::vector<Button*> buttons; //Vector holder the buttons
+ Button exit; //The exit button is special since it does not have a callback function
};
class FileMenu
diff --git a/source/code/menudef.cpp b/source/code/menudef.cpp
index 2617d26..56a655b 100644
--- a/source/code/menudef.cpp
+++ b/source/code/menudef.cpp
@@ -448,6 +448,18 @@ public:
game = std::make_shared<BlockGameSdl>(1024-500,100,&globalData.spriteHolder->GetDataHolder());
}
+ void placeButtons() {
+ int nextY = 100;
+ int X = 50;
+ for (Button* it : buttons) {
+ it->x = X;
+ it->y = nextY;
+ nextY += standardButton.ysize+10;
+ }
+ exit.x = X;
+ exit.y = nextY;
+ }
+
void Draw(SDL_Renderer* target) override {
Menu::Draw(target);
game->DoPaintJob();