aboutsummaryrefslogtreecommitdiff
path: root/game/mainmenu/ShowPreviewScript.cpp
diff options
context:
space:
mode:
authorJAROWMR <jarorutjes07@gmail.com>2024-12-23 21:17:45 +0100
committerJAROWMR <jarorutjes07@gmail.com>2024-12-23 21:17:45 +0100
commit225e873c8ac9c4c08720a69b8f2c817d22cf0071 (patch)
tree20c1539a7ea7d133fca143e922165fd7533c87fe /game/mainmenu/ShowPreviewScript.cpp
parenta3097a20daaf58e4e3852bfb36315dc5e14d3e52 (diff)
made script reusable to switch scenes
Diffstat (limited to 'game/mainmenu/ShowPreviewScript.cpp')
-rw-r--r--game/mainmenu/ShowPreviewScript.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/game/mainmenu/ShowPreviewScript.cpp b/game/mainmenu/ShowPreviewScript.cpp
new file mode 100644
index 0000000..d015827
--- /dev/null
+++ b/game/mainmenu/ShowPreviewScript.cpp
@@ -0,0 +1,35 @@
+#include "ShowPreviewScript.h"
+#include "MainMenuConfig.h"
+#include "iostream"
+
+using namespace crepe;
+using namespace std;
+
+
+void ShowPreviewScript::init(){
+ cout << "script init" << endl;
+ this->subscribe<ButtonPressEvent>([this](const ButtonPressEvent& e) { return this->on_button_press(e); });
+ this->subscribe<ButtonEnterEvent>([this](const ButtonEnterEvent& e) { return this->on_button_enter(e); });
+ this->subscribe<ButtonExitEvent>([this](const ButtonExitEvent& e) { return this->on_button_exit(e); });
+}
+
+bool ShowPreviewScript::on_button_press(const ButtonPressEvent& e){
+ if(!this->transition) this->transition = true;
+ cout << "Start triggered:" << e.metadata.game_object_id << std::endl;
+ return false;
+}
+bool ShowPreviewScript::on_button_enter(const ButtonEnterEvent& e){
+
+ cout << "Start Enter:" << e.metadata.game_object_id << std::endl;
+ return false;
+}
+bool ShowPreviewScript::on_button_exit(const ButtonExitEvent& e){
+
+ cout << "Start Exit:" << e.metadata.game_object_id << std::endl;
+ return false;
+}
+
+const char* ShowPreviewScript::get_scene_name() const {
+ // Provide the next scene defined in MainMenuConfig
+ return MainMenuConfig::PREVIEW_SCENE;
+}