diff options
author | Max-001 <80035972+Max-001@users.noreply.github.com> | 2025-01-10 14:13:46 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-01-10 14:13:46 +0100 |
commit | bb2db93bfb8dd7e080d2708548eae660e6b33913 (patch) | |
tree | 32a54bc4469cb894aa009736e070bdc382e48e76 /game/menus/shop/ShopLoadScript.cpp | |
parent | d20b25828b53af170a6534263e8de114e7fac121 (diff) | |
parent | 8d46ad5a20d1aa5b784291ae323e38d1e0d59351 (diff) |
Merge pull request #122 from lonkaars/jaro/game
Jaro/game
Diffstat (limited to 'game/menus/shop/ShopLoadScript.cpp')
-rw-r--r-- | game/menus/shop/ShopLoadScript.cpp | 131 |
1 files changed, 131 insertions, 0 deletions
diff --git a/game/menus/shop/ShopLoadScript.cpp b/game/menus/shop/ShopLoadScript.cpp new file mode 100644 index 0000000..a9f9bfe --- /dev/null +++ b/game/menus/shop/ShopLoadScript.cpp @@ -0,0 +1,131 @@ +#include "ShopLoadScript.h" +#include <crepe/ValueBroker.h> +#include "api/Button.h" +#include "api/Sprite.h" +#include "Shopconfig.h" +#include "api/Text.h" +#include "manager/SaveManager.h" + +using namespace crepe; +using namespace std; + +void ShopLoadScript::init() { + this->update(); + this->subscribe<ShopUpdate>([this](const ShopUpdate e) { + return this->update(); + }); +} + +bool ShopLoadScript::update(){ + SaveManager & save = this->get_save_manager(); + ValueBroker<int> buy_bullet = save.get<int>(BUY_BULLET_SAVE,0); + ValueBroker<int> buy_bubble = save.get<int>(BUY_BUBBLE_SAVE,0); + + + if(buy_bullet.get()){ + auto sprites = this->get_components_by_tag<Sprite>(BUY_BULLET); + for(auto sprite : sprites){ + sprite.get().active = false; + } + auto buttons = this->get_components_by_tag<Button>(BUY_BULLET); + for(auto btn : buttons){ + btn.get().active = false; + } + auto texts = this->get_components_by_tag<Text>(BUY_BULLET); + for(auto txt : texts){ + txt.get().active = false; + } + auto sprites1 = this->get_components_by_tag<Sprite>(SELECT_BULLET); + for(auto sprite : sprites1){ + sprite.get().active = true; + } + auto buttons1 = this->get_components_by_tag<Button>(SELECT_BULLET); + for(auto btn : buttons1){ + btn.get().active = true; + } + auto texts1 = this->get_components_by_tag<Text>(SELECT_BULLET); + for(auto txt : texts1){ + txt.get().active = true; + } + } + else { + auto sprites = this->get_components_by_tag<Sprite>(SELECT_BULLET); + for(auto sprite : sprites){ + sprite.get().active = false; + } + auto buttons = this->get_components_by_tag<Button>(SELECT_BULLET); + for(auto btn : buttons){ + btn.get().active = false; + } + auto texts = this->get_components_by_tag<Text>(SELECT_BULLET); + for(auto txt : texts){ + txt.get().active = false; + } + auto sprites1 = this->get_components_by_tag<Sprite>(BUY_BULLET); + for(auto sprite : sprites1){ + sprite.get().active = true; + } + auto buttons1 = this->get_components_by_tag<Button>(BUY_BULLET); + for(auto btn : buttons1){ + btn.get().active = true; + } + auto texts1 = this->get_components_by_tag<Text>(BUY_BULLET); + for(auto txt : texts1){ + txt.get().active = true; + } + } + + if(buy_bubble.get()){ + auto sprites = this->get_components_by_tag<Sprite>(BUY_BUBBLE); + for(auto sprite : sprites){ + sprite.get().active = false; + } + auto buttons = this->get_components_by_tag<Button>(BUY_BUBBLE); + for(auto btn : buttons){ + btn.get().active = false; + } + auto texts = this->get_components_by_tag<Text>(BUY_BUBBLE); + for(auto txt : texts){ + txt.get().active = false; + } + auto sprites1 = this->get_components_by_tag<Sprite>(SELECT_BUBBLE); + for(auto sprite : sprites1){ + sprite.get().active = true; + } + auto buttons1 = this->get_components_by_tag<Button>(SELECT_BUBBLE); + for(auto btn : buttons1){ + btn.get().active = true; + } + auto texts1 = this->get_components_by_tag<Text>(SELECT_BUBBLE); + for(auto txt : texts1){ + txt.get().active = true; + } + } + else { + auto sprites = this->get_components_by_tag<Sprite>(SELECT_BUBBLE); + for(auto sprite : sprites){ + sprite.get().active = false; + } + auto buttons = this->get_components_by_tag<Button>(SELECT_BUBBLE); + for(auto btn : buttons){ + btn.get().active = false; + } + auto texts = this->get_components_by_tag<Text>(SELECT_BUBBLE); + for(auto txt : texts){ + txt.get().active = false; + } + auto sprites1 = this->get_components_by_tag<Sprite>(BUY_BUBBLE); + for(auto sprite : sprites1){ + sprite.get().active = true; + } + auto buttons1 = this->get_components_by_tag<Button>(BUY_BUBBLE); + for(auto btn : buttons1){ + btn.get().active = true; + } + auto texts1 = this->get_components_by_tag<Text>(BUY_BUBBLE); + for(auto txt : texts1){ + txt.get().active = true; + } + } + return false; +} |