git repos / saland

commit 32ae8f61

Poul Sander · 2021-08-09 16:24
32ae8f61a347722193ac6b24f5e47562729b8cf9 patch · browse files
parent 62e1726bea6c16b554a27706a3f5e6bbc7d838f9

Make one method handle label logic

Changed files

M src/saland.cpp before
diff --git a/src/saland.cpp b/src/saland.cpp index 6b5e066..6ee5c12 100644 --- a/src/saland.cpp +++ b/src/saland.cpp
@@ -353,26 +353,34 @@ static void runHelpAbout() {
}
class WorldSelectButton : public Button {
+private:
+ void UpdateLabel() {
+ this->setLabel(SPrintStringF("World: %s", Config::getInstance()->getString("world").c_str()));
+ }
public:
WorldSelectButton() {
- this->setLabel(SPrintStringF("World: %s", Config::getInstance()->getString("world").c_str()));
+ UpdateLabel();
}
virtual void doAction() override {
runWorldSelect();
- this->setLabel(SPrintStringF("World: %s", Config::getInstance()->getString("world").c_str()));
+ UpdateLabel();
}
};
class PlayerSelectButton : public Button {
+private:
+ void UpdateLabel() {
+ this->setLabel(SPrintStringF("Player: %s", Config::getInstance()->getString("player").c_str() ));
+ }
public:
PlayerSelectButton() {
- this->setLabel(SPrintStringF("Player: %s", Config::getInstance()->getString("player").c_str() ));
+ UpdateLabel();
}
virtual void doAction() override {
runPlayerSelect();
- this->setLabel(SPrintStringF("Player: %s", Config::getInstance()->getString("player").c_str() ));
+ UpdateLabel();
}
};