diff options
author | heavydemon21 <nielsstunnebrink1@gmail.com> | 2025-01-08 15:33:41 +0100 |
---|---|---|
committer | heavydemon21 <nielsstunnebrink1@gmail.com> | 2025-01-08 15:33:41 +0100 |
commit | ce83df284173cfb4f6e430bf3ed8080ea21204d7 (patch) | |
tree | cb30e6bd44b4cf61ee696b55b46f7b817bf4157a /game/menus/mainmenu/CreditsSubScript.cpp | |
parent | 698628cf1fb1b8a1f68bf6a5672d984bd64be58f (diff) | |
parent | 26fe39ef4e633206a9b202d431c969c66052d2ef (diff) |
Merge branch 'master' into niels/game
Diffstat (limited to 'game/menus/mainmenu/CreditsSubScript.cpp')
-rw-r--r-- | game/menus/mainmenu/CreditsSubScript.cpp | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/game/menus/mainmenu/CreditsSubScript.cpp b/game/menus/mainmenu/CreditsSubScript.cpp new file mode 100644 index 0000000..4224dc8 --- /dev/null +++ b/game/menus/mainmenu/CreditsSubScript.cpp @@ -0,0 +1,58 @@ +#include "CreditsSubScript.h" + +#include "../../Events.h" +#include "../ButtonReplaySubScript.h" +#include "../IFloatingWindowScript.h" + +#include <string> + +#include <crepe/api/Button.h> +#include <crepe/api/Sprite.h> +#include <crepe/api/Text.h> +#include <crepe/types.h> + +using namespace crepe; + +CreditsSubScript::CreditsSubScript(const std::string & tag) { this->tag = tag; } + +void CreditsSubScript::init() { + IButtonScript::init(); + this->subscribe<ButtonPressEvent>([this](const ButtonPressEvent & e) { + return this->on_button_press(e); + }); + this->subscribe<ShowCreditsEvent>([this](const ShowCreditsEvent & e) { + this->enable_all(); + return false; + }); + this->disable_all(); +} + +bool CreditsSubScript::disable_all() { + IFloatingWindowScript::disable_all_sprites(); + RefVector<Button> buttons = this->get_components_by_tag<Button>(this->tag); + for (Button & button : buttons) { + button.active = false; + } + RefVector<Text> texts = this->get_components_by_tag<Text>(this->tag); + for (Text & text : texts) { + text.active = false; + } + return false; +} + +bool CreditsSubScript::enable_all() { + IFloatingWindowScript::enable_all_sprites(); + RefVector<Button> buttons = this->get_components_by_tag<Button>(this->tag); + for (Button & button : buttons) { + button.active = true; + } + RefVector<Text> texts = this->get_components_by_tag<Text>(this->tag); + for (Text & text : texts) { + text.active = true; + } + return false; +} + +bool CreditsSubScript::on_button_press(const ButtonPressEvent & e) { + return this->disable_all(); +} |