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/ButtonSubScene.cpp | 128 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100644 game/menus/ButtonSubScene.cpp (limited to 'game/menus/ButtonSubScene.cpp') 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