Switch to templates for grabbing a component from a menu.
This commit is contained in:
parent
347f4cc576
commit
795d59f1a4
@ -9,8 +9,6 @@
|
||||
class Crawler;
|
||||
class MenuComponent;
|
||||
|
||||
#define COMPONENT(type,menu,componentName) ((type*)Menu::menus[menu]->components.at(componentName))
|
||||
|
||||
enum MenuType{
|
||||
TEST,
|
||||
TEST_2,
|
||||
@ -24,6 +22,11 @@ enum MenuType{
|
||||
///////////////////////////////////////////////////////////
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
T*Component(MenuType menu,std::string componentName){
|
||||
return (T*)Menu::menus[menu]->components[componentName];
|
||||
}
|
||||
|
||||
class Menu:IAttributable{
|
||||
friend class Crawler;
|
||||
friend class Player;
|
||||
|
||||
@ -27,10 +27,10 @@ void State_OverworldMap::OnStateChange(GameState*prevState){
|
||||
game->GetPlayer()->SetState(State::FORCE_WALK);
|
||||
game->GetPlayer()->SetSizeMult(1);
|
||||
game->camera.MoveCamera(currentConnectionPoint->rect.middle()+vf2d{game->GetScreenSize().x/6.0f,0});
|
||||
COMPONENT(MenuLabel,OVERWORLD_LEVEL_SELECT,"Chapter Label")->SetLabel("Chapter "+std::to_string(game->GetCurrentChapter()));
|
||||
COMPONENT(MenuLabel,OVERWORLD_LEVEL_SELECT,"Stage Label")->SetLabel(currentConnectionPoint->name);
|
||||
COMPONENT(EncountersSpawnListScrollableWindowComponent,OVERWORLD_LEVEL_SELECT,"Spawns List")->UpdateSpawns(currentConnectionPoint->spawns);
|
||||
COMPONENT(MenuComponent,OVERWORLD_LEVEL_SELECT,"Enter Button")->Enable(currentConnectionPoint->levelDataExists);
|
||||
Component<MenuLabel>(OVERWORLD_LEVEL_SELECT,"Chapter Label")->SetLabel("Chapter "+std::to_string(game->GetCurrentChapter()));
|
||||
Component<MenuLabel>(OVERWORLD_LEVEL_SELECT,"Stage Label")->SetLabel(currentConnectionPoint->name);
|
||||
Component<EncountersSpawnListScrollableWindowComponent>(OVERWORLD_LEVEL_SELECT,"Spawns List")->UpdateSpawns(currentConnectionPoint->spawns);
|
||||
Component<MenuComponent>(OVERWORLD_LEVEL_SELECT,"Enter Button")->Enable(currentConnectionPoint->levelDataExists);
|
||||
Menu::OpenMenu(OVERWORLD_LEVEL_SELECT,false);
|
||||
};
|
||||
void State_OverworldMap::OnUserUpdate(Crawler*game){
|
||||
@ -66,9 +66,9 @@ void State_OverworldMap::OnUserUpdate(Crawler*game){
|
||||
}else{
|
||||
game->GetPlayer()->UpdateWalkingAnimation(LEFT);
|
||||
}
|
||||
COMPONENT(MenuLabel,OVERWORLD_LEVEL_SELECT,"Stage Label")->SetLabel(currentConnectionPoint->name);
|
||||
COMPONENT(EncountersSpawnListScrollableWindowComponent,OVERWORLD_LEVEL_SELECT,"Spawns List")->UpdateSpawns(currentConnectionPoint->spawns);
|
||||
COMPONENT(MenuComponent,OVERWORLD_LEVEL_SELECT,"Enter Button")->Enable(currentConnectionPoint->levelDataExists);
|
||||
Component<MenuLabel>(OVERWORLD_LEVEL_SELECT,"Stage Label")->SetLabel(currentConnectionPoint->name);
|
||||
Component<EncountersSpawnListScrollableWindowComponent>(OVERWORLD_LEVEL_SELECT,"Spawns List")->UpdateSpawns(currentConnectionPoint->spawns);
|
||||
Component<MenuComponent>(OVERWORLD_LEVEL_SELECT,"Enter Button")->Enable(currentConnectionPoint->levelDataExists);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
#define VERSION_MAJOR 0
|
||||
#define VERSION_MINOR 2
|
||||
#define VERSION_PATCH 1
|
||||
#define VERSION_BUILD 2790
|
||||
#define VERSION_BUILD 2794
|
||||
|
||||
#define stringify(a) stringify_(a)
|
||||
#define stringify_(a) #a
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<map version="1.10" tiledversion="1.10.1" orientation="orthogonal" renderorder="right-down" width="174" height="144" tilewidth="24" tileheight="24" infinite="0" nextlayerid="6" nextobjectid="5">
|
||||
<map version="1.10" tiledversion="1.10.1" orientation="orthogonal" renderorder="right-down" width="174" height="144" tilewidth="24" tileheight="24" infinite="0" nextlayerid="6" nextobjectid="7">
|
||||
<tileset firstgid="1" source="../maps/grass_tiles_24x24.tsx"/>
|
||||
<tileset firstgid="784" source="../maps/grass_tiles_modded.tsx"/>
|
||||
<tileset firstgid="1567" source="../maps/Tilesheet_No_Shadow24x24.tsx"/>
|
||||
|
||||
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user