From 07615060da6c211e08a3d7f2e1bb9e99ffc05364 Mon Sep 17 00:00:00 2001 From: JAROWMR Date: Mon, 6 Jan 2025 17:49:39 +0100 Subject: moved and updated files --- game/menus/BannerSubScene.cpp | 42 +++++++ game/menus/BannerSubScene.h | 19 +++ game/menus/ButtonSetMainMenuScript.cpp | 19 +++ game/menus/ButtonSetMainMenuScript.h | 14 +++ game/menus/ButtonSetShopScript.cpp | 19 +++ game/menus/ButtonSetShopScript.h | 14 +++ game/menus/ButtonSubScene.cpp | 128 +++++++++++++++++++++ game/menus/ButtonSubScene.h | 57 +++++++++ game/menus/IButtonScript.cpp | 33 ++++++ game/menus/IButtonScript.h | 12 ++ game/menus/MenusConfig.h | 18 +++ .../mainmenu/ButtonTransitionPreviewScript.cpp | 24 ++++ .../menus/mainmenu/ButtonTransitionPreviewScript.h | 11 ++ game/menus/mainmenu/ITransitionScript.cpp | 30 +++++ game/menus/mainmenu/ITransitionScript.h | 13 +++ game/menus/mainmenu/MainMenuConfig.h | 22 ++++ game/menus/mainmenu/MainMenuScene.cpp | 99 ++++++++++++++++ game/menus/mainmenu/MainMenuScene.h | 11 ++ game/menus/mainmenu/TransitionStartScript.cpp | 20 ++++ game/menus/mainmenu/TransitionStartScript.h | 10 ++ game/menus/shop/ShopMenuScene.cpp | 44 +++++++ game/menus/shop/ShopMenuScene.h | 11 ++ 22 files changed, 670 insertions(+) create mode 100644 game/menus/BannerSubScene.cpp create mode 100644 game/menus/BannerSubScene.h create mode 100644 game/menus/ButtonSetMainMenuScript.cpp create mode 100644 game/menus/ButtonSetMainMenuScript.h create mode 100644 game/menus/ButtonSetShopScript.cpp create mode 100644 game/menus/ButtonSetShopScript.h create mode 100644 game/menus/ButtonSubScene.cpp create mode 100644 game/menus/ButtonSubScene.h create mode 100644 game/menus/IButtonScript.cpp create mode 100644 game/menus/IButtonScript.h create mode 100644 game/menus/MenusConfig.h create mode 100644 game/menus/mainmenu/ButtonTransitionPreviewScript.cpp create mode 100644 game/menus/mainmenu/ButtonTransitionPreviewScript.h create mode 100644 game/menus/mainmenu/ITransitionScript.cpp create mode 100644 game/menus/mainmenu/ITransitionScript.h create mode 100644 game/menus/mainmenu/MainMenuConfig.h create mode 100644 game/menus/mainmenu/MainMenuScene.cpp create mode 100644 game/menus/mainmenu/MainMenuScene.h create mode 100644 game/menus/mainmenu/TransitionStartScript.cpp create mode 100644 game/menus/mainmenu/TransitionStartScript.h create mode 100644 game/menus/shop/ShopMenuScene.cpp create mode 100644 game/menus/shop/ShopMenuScene.h (limited to 'game/menus') diff --git a/game/menus/BannerSubScene.cpp b/game/menus/BannerSubScene.cpp new file mode 100644 index 0000000..638b330 --- /dev/null +++ b/game/menus/BannerSubScene.cpp @@ -0,0 +1,42 @@ +#include "BannerSubScene.h" +#include "MenusConfig.h" +#include "../Config.h" + + +#include +#include +#include + +using namespace crepe; +using namespace std; + +void BannerSubScene::create(Scene & scn,const Data & data){ + GameObject menu_banner = scn.new_object("menu_banner","", {0,-414}); + menu_banner.add_component( + Asset("asset/ui/settings_container/top_middle_setting.png"), + Sprite::Data{ + .sorting_in_layer = STARTING_SORTING_IN_LAYER+1, + .size = {1100,88}, + }); + menu_banner.add_component( + Asset("asset/ui/settings_container/top_2_middle_setting.png"), + Sprite::Data{ + .sorting_in_layer = STARTING_SORTING_IN_LAYER+1, + .size = {1100,66}, + .position_offset {0,77}, + }); + menu_banner.add_component( + Asset("asset/ui/settings_container/banner_bottom.png"), + Sprite::Data{ + .sorting_in_layer = STARTING_SORTING_IN_LAYER+1, + .size = {1100,7}, + .position_offset {0,113}, + }); + crepe::vec2 size = {data.banner_title_width,(data.banner_title_width/data.banner_title.size())*2}; + + menu_banner.add_component( size, FONT, Text::Data{ + .world_space = true, + .text_color = Color::WHITE, + }, data.banner_title_offset + FONTOFFSET, data.banner_title); + +} diff --git a/game/menus/BannerSubScene.h b/game/menus/BannerSubScene.h new file mode 100644 index 0000000..341943d --- /dev/null +++ b/game/menus/BannerSubScene.h @@ -0,0 +1,19 @@ +#pragma once + +#include "types.h" +#include + +namespace crepe { +class Scene; +} + +class BannerSubScene { +public: +struct Data{ + const std::string & banner_title = "NODATA"; + const float banner_title_width = 100; + const crepe::vec2 & banner_title_offset = {0,0}; + }; +public: + void create(crepe::Scene & scn,const Data & data); +}; diff --git a/game/menus/ButtonSetMainMenuScript.cpp b/game/menus/ButtonSetMainMenuScript.cpp new file mode 100644 index 0000000..74773a0 --- /dev/null +++ b/game/menus/ButtonSetMainMenuScript.cpp @@ -0,0 +1,19 @@ +#include "ButtonSetMainMenuScript.h" +#include "MenusConfig.h" +#include "iostream" + +using namespace crepe; +using namespace std; + +void ButtonSetMainMenuScript::init(){ + cout << "script init" << endl; + IButtonScript::init(); + this->subscribe([this](const ButtonPressEvent& e) { return this->on_button_press(e); }); +} + +bool ButtonSetMainMenuScript::on_button_press(const ButtonPressEvent& e){ + this->set_next_scene(MAINMENU_SCENE); + cout << "Start triggered:" << e.metadata.game_object_id << std::endl; + return false; +} + diff --git a/game/menus/ButtonSetMainMenuScript.h b/game/menus/ButtonSetMainMenuScript.h new file mode 100644 index 0000000..44c21aa --- /dev/null +++ b/game/menus/ButtonSetMainMenuScript.h @@ -0,0 +1,14 @@ +#pragma once + +#include "IButtonScript.h" +#include + +class ButtonSetMainMenuScript : public IButtonScript { +public: + void init() override; + bool on_button_press(const crepe::ButtonPressEvent& e); +private: + float velocity = 20; +protected: + bool transition = false; +}; diff --git a/game/menus/ButtonSetShopScript.cpp b/game/menus/ButtonSetShopScript.cpp new file mode 100644 index 0000000..035419f --- /dev/null +++ b/game/menus/ButtonSetShopScript.cpp @@ -0,0 +1,19 @@ +#include "ButtonSetShopScript.h" +#include "iostream" +#include "MenusConfig.h" + +using namespace crepe; +using namespace std; + +void ButtonSetShopScript::init(){ + cout << "script init" << endl; + IButtonScript::init(); + this->subscribe([this](const ButtonPressEvent& e) { return this->on_button_press(e); }); +} + +bool ButtonSetShopScript::on_button_press(const ButtonPressEvent& e){ + this->set_next_scene(SHOP_SCENE); + cout << "Start triggered:" << e.metadata.game_object_id << std::endl; + return false; +} + diff --git a/game/menus/ButtonSetShopScript.h b/game/menus/ButtonSetShopScript.h new file mode 100644 index 0000000..51db928 --- /dev/null +++ b/game/menus/ButtonSetShopScript.h @@ -0,0 +1,14 @@ +#pragma once + +#include "IButtonScript.h" +#include + +class ButtonSetShopScript : public IButtonScript { +public: + void init() override; + bool on_button_press(const crepe::ButtonPressEvent& e); +private: + float velocity = 20; +protected: + bool transition = false; +}; diff --git a/game/menus/ButtonSubScene.cpp b/game/menus/ButtonSubScene.cpp new file mode 100644 index 0000000..3d68657 --- /dev/null +++ b/game/menus/ButtonSubScene.cpp @@ -0,0 +1,128 @@ +#include "ButtonSubScene.h" +#include "ButtonSetMainMenuScript.h" +#include "ButtonSetShopScript.h" +#include "mainmenu/ButtonTransitionPreviewScript.h" +#include "IButtonScript.h" +#include "../Config.h" +#include "api/Color.h" +#include "MenusConfig.h" + +#include +#include +#include +#include +#include + +using namespace crepe; +using namespace std; + +void ButtonSubScene::create(Scene & scn,const Data & data){ + GameObject button_object = scn.new_object("button",data.tag,data.position,0,data.scale); + this->set_button_overlay(button_object,data); + this->btn_text(button_object,data); + this->set_script(button_object,data); + this->set_icon(button_object,data); +} + +void ButtonSubScene::btn_text(crepe::GameObject & button_object,const Data & data){ + + crepe::vec2 size = {data.text_width,(data.text_width/data.text.size())*2}; + button_object.add_component(size, FONT,Text::Data{ + .world_space = data.worldspace, + .text_color = Color::WHITE, + }, data.text_offset+FONTOFFSET, data.text); +} + +void ButtonSubScene::set_script(crepe::GameObject & button_object,const Data & data){ + switch (data.script_type) { + case ScriptSelect::PREVIEW: + button_object.add_component().set_script(); + break; + case ScriptSelect::SHOP: + button_object.add_component().set_script(); + break; + case ScriptSelect::MAINMENU: + button_object.add_component().set_script(); + break; + case ScriptSelect::NONE: + button_object.add_component().set_script(); + break; + } +} + +void ButtonSubScene::set_icon(crepe::GameObject & button_object,const Data & data){ + switch (data.icon_type) { + case IconSelect::SHOP: + button_object.add_component(Asset("asset/ui/buttonCoinsSmall.png"),Sprite::Data{ + .sorting_in_layer = STARTING_SORTING_IN_LAYER+3, + .size = ICON_SIZE, + .position_offset = data.icon_offset, + .world_space = data.worldspace, + }); + break; + case IconSelect::COINS: + button_object.add_component(Asset("asset/ui/buttonCoinsSmall.png"),Sprite::Data{ + .sorting_in_layer = STARTING_SORTING_IN_LAYER+3, + .size = ICON_SIZE, + .position_offset = data.icon_offset, + .world_space = data.worldspace, + }); + break; + case IconSelect::NONE: + break; + } +} + +void ButtonSubScene::set_button_overlay(crepe::GameObject & button_object,const Data & data){ + switch (data.button_type) { + case ButtonSelect::LARGE: + this->large_btn_overlay(button_object,data); + break; + case ButtonSelect::SMALL: + this->small_btn_overlay(button_object,data); + break; + } +} + +void ButtonSubScene::large_btn_overlay(crepe::GameObject & button_object,const Data & data){ + button_object.add_component(Asset("asset/ui/buttonBacking.png"),Sprite::Data{ + .sorting_in_layer = STARTING_SORTING_IN_LAYER+1, + .size = LARGE_OVERLAY_SIZE, + .world_space = data.worldspace, + }); + button_object.add_component