Confirm and Back Buttons added.
This commit is contained in:
parent
02c7165b37
commit
598ce523e9
@ -4,6 +4,7 @@
|
|||||||
#include "Menu.h"
|
#include "Menu.h"
|
||||||
#include "MenuLabel.h"
|
#include "MenuLabel.h"
|
||||||
#include "MenuAnimatedIconButton.h"
|
#include "MenuAnimatedIconButton.h"
|
||||||
|
#include "GameState.h"
|
||||||
|
|
||||||
INCLUDE_game
|
INCLUDE_game
|
||||||
typedef Attribute A;
|
typedef Attribute A;
|
||||||
@ -22,6 +23,13 @@ void Menu::InitializeClassSelectionWindow(){
|
|||||||
|
|
||||||
classSelectionWindow->AddComponent("Outline Border",outline);
|
classSelectionWindow->AddComponent("Outline Border",outline);
|
||||||
|
|
||||||
|
vf2d navigationButtonSize={24*2.5f,16};
|
||||||
|
|
||||||
|
MenuComponent*backButton=new MenuComponent(CLASS_SELECTION,{{4+2,outlineSize.y+4-navigationButtonSize.y-2},navigationButtonSize},"Back",[](MenuFuncData data){Menu::CloseMenu();});
|
||||||
|
classSelectionWindow->AddComponent("Back Button",backButton);
|
||||||
|
MenuComponent*confirmButton=new MenuComponent(CLASS_SELECTION,{{outlineSize.x+4-navigationButtonSize.x-2,outlineSize.y+4-navigationButtonSize.y-2},navigationButtonSize},"Confirm",[](MenuFuncData data){GameState::ChangeState(States::GAME_RUN);});
|
||||||
|
classSelectionWindow->AddComponent("Confirm",confirmButton);
|
||||||
|
|
||||||
vf2d buttonPadding={2,2};
|
vf2d buttonPadding={2,2};
|
||||||
vf2d buttonSize={floor(outlineSize.y/3-buttonPadding.y*3),outlineSize.y/9-buttonPadding.y*3}; //The floor is for fixing a small pixel rounding bug.
|
vf2d buttonSize={floor(outlineSize.y/3-buttonPadding.y*3),outlineSize.y/9-buttonPadding.y*3}; //The floor is for fixing a small pixel rounding bug.
|
||||||
|
|
||||||
|
|||||||
@ -156,7 +156,7 @@ void Menu::HoverMenuSelect(Crawler*game){
|
|||||||
|
|
||||||
void Menu::MenuSelect(Crawler*game){
|
void Menu::MenuSelect(Crawler*game){
|
||||||
if(selection==vi2d{-1,-1}||buttons[selection.y][selection.x]->disabled)return;
|
if(selection==vi2d{-1,-1}||buttons[selection.y][selection.x]->disabled)return;
|
||||||
buttons[selection.y][selection.x]->onClick(MenuFuncData{*this,game,buttons[selection.y][selection.x]});
|
buttons[selection.y][selection.x]->onClick(MenuFuncData{*this,game,buttons[selection.y][selection.x]});
|
||||||
if(buttons[selection.y][selection.x]->menuDest!=MenuType::ENUM_END){
|
if(buttons[selection.y][selection.x]->menuDest!=MenuType::ENUM_END){
|
||||||
if(stack.size()<32){
|
if(stack.size()<32){
|
||||||
stack.push_back(menus[buttons[selection.y][selection.x]->menuDest]);//Navigate to the next menu.
|
stack.push_back(menus[buttons[selection.y][selection.x]->menuDest]);//Navigate to the next menu.
|
||||||
@ -639,4 +639,12 @@ void Menu::CloseMenu(){
|
|||||||
|
|
||||||
std::pair<MenuType,std::string>Menu::GetMemoryLeakReportInfo(){
|
std::pair<MenuType,std::string>Menu::GetMemoryLeakReportInfo(){
|
||||||
return {lastMenuTypeCreated,lastRegisteredComponent};
|
return {lastMenuTypeCreated,lastRegisteredComponent};
|
||||||
|
}
|
||||||
|
|
||||||
|
void Menu::CloseAllMenus(){
|
||||||
|
if(stack.size()<=0){
|
||||||
|
std::cout<<"WARNING! Trying to close out no menu?? Why are we doing this?"<<std::endl;
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
stack.clear();
|
||||||
}
|
}
|
||||||
@ -43,6 +43,7 @@ public:
|
|||||||
static void InitializeMenus();
|
static void InitializeMenus();
|
||||||
static void OpenMenu(MenuType menu);
|
static void OpenMenu(MenuType menu);
|
||||||
static void CloseMenu();
|
static void CloseMenu();
|
||||||
|
static void CloseAllMenus();
|
||||||
static std::vector<Menu*>stack;
|
static std::vector<Menu*>stack;
|
||||||
static std::string themeSelection;
|
static std::string themeSelection;
|
||||||
static safeunorderedmap<std::string,Theme>themes;
|
static safeunorderedmap<std::string,Theme>themes;
|
||||||
|
|||||||
@ -7,7 +7,7 @@
|
|||||||
INCLUDE_MONSTER_LIST
|
INCLUDE_MONSTER_LIST
|
||||||
|
|
||||||
void State_GameRun::OnStateChange(GameState*prevState){
|
void State_GameRun::OnStateChange(GameState*prevState){
|
||||||
Menu::stack.clear();
|
Menu::CloseAllMenus();
|
||||||
};
|
};
|
||||||
void State_GameRun::OnUserUpdate(Crawler*game){
|
void State_GameRun::OnUserUpdate(Crawler*game){
|
||||||
game->bossDisplayTimer=std::max(0.f,game->bossDisplayTimer-game->GetElapsedTime());
|
game->bossDisplayTimer=std::max(0.f,game->bossDisplayTimer-game->GetElapsedTime());
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
#define VERSION_MAJOR 0
|
#define VERSION_MAJOR 0
|
||||||
#define VERSION_MINOR 2
|
#define VERSION_MINOR 2
|
||||||
#define VERSION_PATCH 0
|
#define VERSION_PATCH 0
|
||||||
#define VERSION_BUILD 2391
|
#define VERSION_BUILD 2393
|
||||||
|
|
||||||
#define stringify(a) stringify_(a)
|
#define stringify(a) stringify_(a)
|
||||||
#define stringify_(a) #a
|
#define stringify_(a) #a
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user