diff options
Diffstat (limited to 'game/mainmenu/ButtonSubScene.cpp')
-rw-r--r-- | game/mainmenu/ButtonSubScene.cpp | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/game/mainmenu/ButtonSubScene.cpp b/game/mainmenu/ButtonSubScene.cpp index 8890ccc..53ac8d0 100644 --- a/game/mainmenu/ButtonSubScene.cpp +++ b/game/mainmenu/ButtonSubScene.cpp @@ -16,7 +16,7 @@ using namespace crepe; using namespace std; void ButtonSubScene::create(Scene & scn,const Data & data){ - GameObject button_object = scn.new_object("button","",data.position,0,data.scale); + 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); @@ -27,6 +27,7 @@ void ButtonSubScene::btn_text(crepe::GameObject & button_object,const Data & dat crepe::vec2 size = {data.text_width,(data.text_width/data.text.size())*2}; button_object.add_component<Text>(size, MainMenuConfig::FONT,Text::Data{ + .world_space = data.worldspace, .text_color = Color::WHITE, }, data.text_offset+MainMenuConfig::FONTOFFSET, data.text); } @@ -55,6 +56,15 @@ void ButtonSubScene::set_icon(crepe::GameObject & button_object,const Data & dat .sorting_in_layer = MainMenuConfig::STARTING_SORTING_IN_LAYER+3, .size = MainMenuConfig::ICON_SIZE, .position_offset = data.icon_offset, + .world_space = data.worldspace, + }); + break; + case IconSelect::COINS: + button_object.add_component<Sprite>(Asset("asset/ui/buttonCoinsSmall.png"),Sprite::Data{ + .sorting_in_layer = MainMenuConfig::STARTING_SORTING_IN_LAYER+3, + .size = MainMenuConfig::ICON_SIZE, + .position_offset = data.icon_offset, + .world_space = data.worldspace, }); break; case IconSelect::NONE: @@ -65,47 +75,53 @@ void ButtonSubScene::set_icon(crepe::GameObject & button_object,const Data & dat 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); + this->large_btn_overlay(button_object,data); break; case ButtonSelect::SMALL: - this->small_btn_overlay(button_object); + this->small_btn_overlay(button_object,data); break; } } -void ButtonSubScene::large_btn_overlay(crepe::GameObject & button_object){ +void ButtonSubScene::large_btn_overlay(crepe::GameObject & button_object,const Data & data){ button_object.add_component<Sprite>(Asset("asset/ui/buttonBacking.png"),Sprite::Data{ .sorting_in_layer = MainMenuConfig::STARTING_SORTING_IN_LAYER+1, .size = MainMenuConfig::LARGE_OVERLAY_SIZE, + .world_space = data.worldspace, }); button_object.add_component<Button>(MainMenuConfig::LARGE_OVERLAY_SIZE,Button::Data{}); - this->btn_color_side(button_object,SIDE_PANEL_OFFSET); + if(!data.color_side) return; + this->btn_color_side(button_object,SIDE_PANEL_OFFSET,data); } -void ButtonSubScene::small_btn_overlay(crepe::GameObject & button_object){ +void ButtonSubScene::small_btn_overlay(crepe::GameObject & button_object,const Data & data){ button_object.add_component<Sprite>(Asset("asset/ui/backbuttonright.png"),Sprite::Data{ .sorting_in_layer = MainMenuConfig::STARTING_SORTING_IN_LAYER+1, .size = MainMenuConfig::SMALL_OVERLAY_SIZE_RIGHT, .position_offset = {20,0}, + .world_space = data.worldspace, }); button_object.add_component<Sprite>(Asset("asset/ui/backbuttonleft.png"),Sprite::Data{ .sorting_in_layer = MainMenuConfig::STARTING_SORTING_IN_LAYER+1, .size = MainMenuConfig::SMALL_OVERLAY_SIZE_LEFT, .position_offset = {-80,0}, + .world_space = data.worldspace, }); button_object.add_component<Button>(vec2{MainMenuConfig::SMALL_OVERLAY_SIZE_LEFT.x+MainMenuConfig::SMALL_OVERLAY_SIZE_RIGHT.x,MainMenuConfig::SMALL_OVERLAY_SIZE_LEFT.y},Button::Data{}); } -void ButtonSubScene::btn_color_side(crepe::GameObject & button_object,const vec2 & offset){ +void ButtonSubScene::btn_color_side(crepe::GameObject & button_object,const vec2 & offset,const Data & data){ button_object.add_component<Sprite>(Asset("asset/ui/buttonSmallBlue.png"),Sprite::Data{ .sorting_in_layer = MainMenuConfig::STARTING_SORTING_IN_LAYER+2, .size = MainMenuConfig::SIDE_PANEL_SIZE, .position_offset = offset, + .world_space = data.worldspace, }); button_object.add_component<Sprite>(Asset("asset/ui/buttonSmallBlue.png"),Sprite::Data{ .flip = {true,false}, .sorting_in_layer = MainMenuConfig::STARTING_SORTING_IN_LAYER+2, .size = MainMenuConfig::SIDE_PANEL_SIZE, .position_offset = {-offset.x,offset.y}, + .world_space = data.worldspace, }); } |