aboutsummaryrefslogtreecommitdiff
path: root/game/menus/mainmenu
diff options
context:
space:
mode:
Diffstat (limited to 'game/menus/mainmenu')
-rw-r--r--game/menus/mainmenu/CreditsSubScene.cpp132
-rw-r--r--game/menus/mainmenu/CreditsSubScene.h9
-rw-r--r--game/menus/mainmenu/CreditsSubScript.cpp58
-rw-r--r--game/menus/mainmenu/CreditsSubScript.h18
-rw-r--r--game/menus/mainmenu/MainMenuScene.cpp19
5 files changed, 235 insertions, 1 deletions
diff --git a/game/menus/mainmenu/CreditsSubScene.cpp b/game/menus/mainmenu/CreditsSubScene.cpp
new file mode 100644
index 0000000..65576ee
--- /dev/null
+++ b/game/menus/mainmenu/CreditsSubScene.cpp
@@ -0,0 +1,132 @@
+
+#include "CreditsSubScene.h"
+#include "CreditsSubScript.h"
+
+#include "../../Config.h"
+#include "../ButtonSubScene.h"
+#include "../FloatingWindowSubScene.h"
+
+#include <string>
+
+#include <crepe/api/BehaviorScript.h>
+#include <crepe/api/GameObject.h>
+#include <crepe/api/Text.h>
+#include <crepe/types.h>
+
+using namespace crepe;
+using namespace std;
+
+void CreditsSubScene::create(Scene & scn) {
+
+ const std::string TAG = "credits_tag";
+ GameObject script = scn.new_object("script");
+ script.add_component<BehaviorScript>().set_script<CreditsSubScript>(TAG);
+
+ // Window
+ FloatingWindowSubScene window;
+ window.create(
+ scn,
+ FloatingWindowSubScene::Data {
+ .group_tag = TAG,
+ .width = 500,
+ .offset = {150, -50},
+ .width_middle_offset = -2,
+ }
+ );
+
+ // Titel
+ const string TITEL_STRING = "Credits";
+ GameObject titel = scn.new_object("titel", TAG);
+ crepe::vec2 size = {200, (200.0f / TITEL_STRING.size()) * 2};
+ titel.add_component<Text>(
+ size, FONT,
+ Text::Data {
+ .world_space = false,
+ .text_color = Color::WHITE,
+ },
+ vec2 {150, -207} + FONTOFFSET, TITEL_STRING
+ );
+
+ // Buttons
+ vec2 button_position = {190, 190};
+ ButtonSubScene button;
+ button.create(
+ scn,
+ ButtonSubScene::Data {
+ .text = "Back",
+ .text_width = 150,
+ .position = {-button_position.x + 150, button_position.y},
+ .script_type = ButtonSubScene::ScriptSelect::CREDITS_BACK,
+ .button_type = ButtonSubScene::ButtonSelect::BACK,
+ .scale = 0.6,
+ .worldspace = false,
+ .tag = TAG,
+ .sorting_layer_offset = 20,
+ }
+ );
+
+ const float SIZE_CHAR_NAMES = 10;
+ const float Y_OFFSET_NAMES_BEGIN = 100;
+ const float Y_OFFSET_NAMES = 30;
+ const string LOEK = "Loek Le Blansch";
+ crepe::vec2 size_loek
+ = {LOEK.size() * SIZE_CHAR_NAMES, (LOEK.size() * SIZE_CHAR_NAMES / LOEK.size()) * 2};
+ titel.add_component<Text>(
+ size_loek, FONT,
+ Text::Data {
+ .world_space = false,
+ .text_color = Color::WHITE,
+ },
+ vec2 {150, -207 + Y_OFFSET_NAMES + Y_OFFSET_NAMES_BEGIN} + FONTOFFSET, LOEK
+ );
+
+ const string WOUTER = "Wouter Boerenkamps";
+ crepe::vec2 size_wouter
+ = {WOUTER.size() * SIZE_CHAR_NAMES,
+ (WOUTER.size() * SIZE_CHAR_NAMES / WOUTER.size()) * 2};
+ titel.add_component<Text>(
+ size_wouter, FONT,
+ Text::Data {
+ .world_space = false,
+ .text_color = Color::WHITE,
+ },
+ vec2 {150, -207 + Y_OFFSET_NAMES * 2 + Y_OFFSET_NAMES_BEGIN} + FONTOFFSET, WOUTER
+ );
+
+ const string JARO = "Jaro Rutjes";
+ crepe::vec2 size_jaro
+ = {JARO.size() * SIZE_CHAR_NAMES, (JARO.size() * SIZE_CHAR_NAMES / JARO.size()) * 2};
+ titel.add_component<Text>(
+ size_jaro, FONT,
+ Text::Data {
+ .world_space = false,
+ .text_color = Color::WHITE,
+ },
+ vec2 {150, -207 + Y_OFFSET_NAMES * 3 + Y_OFFSET_NAMES_BEGIN} + FONTOFFSET, JARO
+ );
+
+ const string MAX = "Max Smits";
+ crepe::vec2 size_max
+ = {MAX.size() * SIZE_CHAR_NAMES, (MAX.size() * SIZE_CHAR_NAMES / MAX.size()) * 2};
+ titel.add_component<Text>(
+ size_max, FONT,
+ Text::Data {
+ .world_space = false,
+ .text_color = Color::WHITE,
+ },
+ vec2 {150, -207 + Y_OFFSET_NAMES * 4 + Y_OFFSET_NAMES_BEGIN} + FONTOFFSET, MAX
+ );
+
+ const string NIELS = "Niels Stunnebrink";
+ crepe::vec2 size_niels
+ = {NIELS.size() * SIZE_CHAR_NAMES, (NIELS.size() * SIZE_CHAR_NAMES / NIELS.size()) * 2
+ };
+ titel.add_component<Text>(
+ size_niels, FONT,
+ Text::Data {
+ .world_space = false,
+ .text_color = Color::WHITE,
+ },
+ vec2 {150, -207 + Y_OFFSET_NAMES * 5 + Y_OFFSET_NAMES_BEGIN} + FONTOFFSET, NIELS
+ );
+}
diff --git a/game/menus/mainmenu/CreditsSubScene.h b/game/menus/mainmenu/CreditsSubScene.h
new file mode 100644
index 0000000..e7ff735
--- /dev/null
+++ b/game/menus/mainmenu/CreditsSubScene.h
@@ -0,0 +1,9 @@
+#pragma once
+
+#include <crepe/api/Scene.h>
+
+class CreditsSubScene {
+
+public:
+ void create(crepe::Scene & scn);
+};
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();
+}
diff --git a/game/menus/mainmenu/CreditsSubScript.h b/game/menus/mainmenu/CreditsSubScript.h
new file mode 100644
index 0000000..81f941a
--- /dev/null
+++ b/game/menus/mainmenu/CreditsSubScript.h
@@ -0,0 +1,18 @@
+#pragma once
+
+#include "../IButtonScript.h"
+#include "../IFloatingWindowScript.h"
+
+#include <crepe/api/Event.h>
+#include <crepe/api/Script.h>
+
+struct ShowCreditsEvent : public crepe::Event {};
+
+class CreditsSubScript : public IFloatingWindowScript, public IButtonScript {
+public:
+ CreditsSubScript(const std::string & tag);
+ void init() override;
+ bool disable_all();
+ bool enable_all();
+ bool on_button_press(const crepe::ButtonPressEvent & e);
+};
diff --git a/game/menus/mainmenu/MainMenuScene.cpp b/game/menus/mainmenu/MainMenuScene.cpp
index 43418e3..fba90ac 100644
--- a/game/menus/mainmenu/MainMenuScene.cpp
+++ b/game/menus/mainmenu/MainMenuScene.cpp
@@ -1,5 +1,6 @@
#include "MainMenuScene.h"
+#include "CreditsSubScene.h"
#include "MainMenuConfig.h"
#include "TransitionStartSubScript.h"
@@ -64,7 +65,7 @@ void MainMenuScene::load_scene() {
ButtonSubScene::Data {
.text = "SHOP",
.text_offset = {-20, 0},
- .text_width = 115,
+ .text_width = 110,
.icon_offset = {60, 0},
.icon_type = ButtonSubScene::IconSelect::SHOP,
.position = pos_btn,
@@ -72,6 +73,19 @@ void MainMenuScene::load_scene() {
}
);
+ //Credits btn
+ pos_btn.y += MENU_BUTTON_SPACING + LARGE_OVERLAY_SIZE.y;
+ button.create(
+ *this,
+ ButtonSubScene::Data {
+ .text = "CREDITS",
+ .text_offset = {0, 0},
+ .text_width = 200,
+ .position = pos_btn,
+ .script_type = ButtonSubScene::ScriptSelect::CREDITS_SHOW,
+ }
+ );
+
//Start of map
StartSubScene start;
HallwaySubScene hallway;
@@ -110,6 +124,9 @@ void MainMenuScene::load_scene() {
.tag = MENU_INFO_TAG,
}
);
+
+ CreditsSubScene creditscene;
+ creditscene.create(*this);
}
string MainMenuScene::get_name() const { return MAINMENU_SCENE; }