Setup internal menu components so they know what button was clicked on a menu function. Compacted the on click menu function for menu buttons.

Refactored some item convenience functions.
pull/28/head
sigonasr2 1 year ago
parent 819f5845b1
commit 99c24b9c37
  1. 12
      Crawler/Attributable.h
  2. 3
      Crawler/Crawler.vcxproj
  3. 9
      Crawler/Crawler.vcxproj.filters
  4. 4
      Crawler/DEFINES.h
  5. 21
      Crawler/InventoryWindow.cpp
  6. 56
      Crawler/Item.cpp
  7. 21
      Crawler/Item.h
  8. 2
      Crawler/Menu.cpp
  9. 22
      Crawler/Menu.h
  10. 2
      Crawler/MenuComponent.cpp
  11. 7
      Crawler/MenuComponent.h
  12. 2
      Crawler/MenuIconButton.h
  13. 13
      Crawler/MenuItemButton.h
  14. 16
      Crawler/MenuType.h
  15. 1
      Crawler/MonsterAttribute.h
  16. 12
      Crawler/Player.h
  17. 12
      Crawler/TestMenu.cpp
  18. 25
      Crawler/TestSubMenu.cpp
  19. 2
      Crawler/Version.h

@ -37,16 +37,4 @@ protected:
} }
return std::get<vf2d>(attributes[a]); return std::get<vf2d>(attributes[a]);
}; };
inline std::vector<int>&GetIntVec(Attribute a){
if(attributes.count(a)==0){
attributes[a]=std::vector<int>{};
}
return std::get<std::vector<int>>(attributes[a]);
};
inline std::vector<std::string>&GetStringVec(Attribute a){
if(attributes.count(a)==0){
attributes[a]=std::vector<std::string>{};
}
return std::get<std::vector<std::string>>(attributes[a]);
};
}; };

@ -273,14 +273,13 @@
<ClInclude Include="Emitter.h" /> <ClInclude Include="Emitter.h" />
<ClInclude Include="GameState.h" /> <ClInclude Include="GameState.h" />
<ClInclude Include="Item.h" /> <ClInclude Include="Item.h" />
<ClInclude Include="MenuComponent.h" />
<ClInclude Include="MenuIconButton.h" /> <ClInclude Include="MenuIconButton.h" />
<ClInclude Include="MenuItemButton.h" /> <ClInclude Include="MenuItemButton.h" />
<ClInclude Include="MenuLabel.h" /> <ClInclude Include="MenuLabel.h" />
<ClInclude Include="MenuType.h" />
<ClInclude Include="Key.h" /> <ClInclude Include="Key.h" />
<ClInclude Include="Map.h" /> <ClInclude Include="Map.h" />
<ClInclude Include="Menu.h" /> <ClInclude Include="Menu.h" />
<ClInclude Include="MenuComponent.h" />
<ClInclude Include="Monster.h" /> <ClInclude Include="Monster.h" />
<ClInclude Include="MonsterAttribute.h" /> <ClInclude Include="MonsterAttribute.h" />
<ClInclude Include="MonsterStrategyHelpers.h" /> <ClInclude Include="MonsterStrategyHelpers.h" />

@ -156,18 +156,12 @@
<ClInclude Include="Key.h"> <ClInclude Include="Key.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="MenuType.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Theme.h"> <ClInclude Include="Theme.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="Menu.h"> <ClInclude Include="Menu.h">
<Filter>Header Files\Interface</Filter> <Filter>Header Files\Interface</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="MenuComponent.h">
<Filter>Header Files\Interface</Filter>
</ClInclude>
<ClInclude Include="MenuIconButton.h"> <ClInclude Include="MenuIconButton.h">
<Filter>Header Files\Interface</Filter> <Filter>Header Files\Interface</Filter>
</ClInclude> </ClInclude>
@ -186,6 +180,9 @@
<ClInclude Include="MenuItemButton.h"> <ClInclude Include="MenuItemButton.h">
<Filter>Header Files\Interface</Filter> <Filter>Header Files\Interface</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="MenuComponent.h">
<Filter>Header Files\Interface</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="Player.cpp"> <ClCompile Include="Player.cpp">

@ -13,12 +13,12 @@
#define INCLUDE_STRATEGY_ID_DATA extern safemap<std::string,int>STRATEGY_ID_DATA; #define INCLUDE_STRATEGY_ID_DATA extern safemap<std::string,int>STRATEGY_ID_DATA;
#define INCLUDE_TILE_ANIMATION_DATA extern std::map<int,std::vector<std::pair<int,float>>>TILE_ANIMATION_DATA; #define INCLUDE_TILE_ANIMATION_DATA extern std::map<int,std::vector<std::pair<int,float>>>TILE_ANIMATION_DATA;
#define INCLUDE_GFX extern safemap<std::string,Renderable>GFX; #define INCLUDE_GFX extern safemap<std::string,Renderable>GFX;
#define INCLUDE_ITEM_DATA extern safemap<Item::ItemName,ItemInfo>ITEM_DATA; #define INCLUDE_ITEM_DATA extern safemap<std::string,ItemInfo>ITEM_DATA;
#define INCLUDE_ITEM_CATEGORIES extern safemap<std::string,std::set<std::string>>ITEM_CATEGORIES; #define INCLUDE_ITEM_CATEGORIES extern safemap<std::string,std::set<std::string>>ITEM_CATEGORIES;
#define ACCESS_PLAYER Player*p=game->GetPlayer(); #define ACCESS_PLAYER Player*p=game->GetPlayer();
#define VARIANTS float,int,std::string,bool,vf2d,std::vector<int>,std::vector<std::string> #define VARIANTS float,int,std::string,bool,vf2d
#define INFINITE 999999 #define INFINITE 999999

@ -1,10 +1,10 @@
#pragma once #pragma once
#include "Crawler.h" #include "Crawler.h"
#include "Menu.h"
#include "DEFINES.h" #include "DEFINES.h"
#include "olcPixelGameEngine.h" #include "olcPixelGameEngine.h"
#include "safemap.h" #include "safemap.h"
#include "Item.h" #include "Item.h"
#include "MenuItemButton.h"
INCLUDE_GFX INCLUDE_GFX
typedef Attribute A; typedef Attribute A;
@ -14,11 +14,22 @@ const Menu Menu::InitializeInventoryWindow(){
constexpr int invHeight=3; constexpr int invHeight=3;
constexpr int totalItemSlots=invWidth*invHeight; constexpr int totalItemSlots=invWidth*invHeight;
Menu inventoryWindow(CENTERED,{24*invWidth,24*(invHeight+1)}); constexpr int itemSpacing=8;
constexpr int buttonSize=24;
constexpr int totalSpacing=buttonSize+itemSpacing;
for(int i=0;i<totalItemSlots;i++){ Menu inventoryWindow(CENTERED,{totalSpacing*invWidth,totalSpacing*(invHeight+1)});
inventoryWindow.GetStringVec(A::INDEXED_ITEMS).push_back();
MenuFunc useItemFunc=[](MenuFuncData data){
};
for(int y=0;y<invHeight;y++){
for(int x=0;x<invWidth;x++){
int itemIndex=y*invWidth+x;
MenuItemButton button1{{{float(totalSpacing*x),float(totalSpacing*y)},{float(buttonSize),float(buttonSize)}},Inventory::get("Consumables"),itemIndex,useItemFunc};
}
} }
return testSubMenu; return inventoryWindow;
} }

@ -11,6 +11,9 @@ INCLUDE_GFX
safemap<std::string,ItemInfo>ITEM_DATA; safemap<std::string,ItemInfo>ITEM_DATA;
safemap<std::string,ItemScript>ITEM_SCRIPTS; safemap<std::string,ItemScript>ITEM_SCRIPTS;
safemap<std::string,std::set<std::string>>ITEM_CATEGORIES; safemap<std::string,std::set<std::string>>ITEM_CATEGORIES;
Item Item::BLANK;
std::map<IT,Item>Inventory::_inventory;
std::map<ITCategory,std::vector<IT>>Inventory::sortedInv;
ItemInfo::ItemInfo() ItemInfo::ItemInfo()
:customProps({nullptr,nullptr}),img(nullptr){} :customProps({nullptr,nullptr}),img(nullptr){}
@ -104,10 +107,13 @@ void ItemInfo::InitializeScripts(){
std::cout<<ITEM_SCRIPTS.size()<<" item scripts have been loaded."<<std::endl; std::cout<<ITEM_SCRIPTS.size()<<" item scripts have been loaded."<<std::endl;
} }
Item::Item()
:amt(0),it(nullptr){}
Item::Item(uint32_t amt,IT item) Item::Item(uint32_t amt,IT item)
:amt(amt),it(&ITEM_DATA.at(item)){} :amt(amt),it(&ITEM_DATA.at(item)){}
void Inventory::AddItem(IT it,int amt){ void Inventory::AddItem(IT it,uint32_t amt){
//There are two places to manipulate items in (Both the sorted inventory and the actual inventory) //There are two places to manipulate items in (Both the sorted inventory and the actual inventory)
if(!_inventory.count(it)){ if(!_inventory.count(it)){
_inventory[it]=Item{amt,it}; _inventory[it]=Item{amt,it};
@ -117,6 +123,11 @@ void Inventory::AddItem(IT it,int amt){
} }
} }
Item Inventory::GetItem(IT it){
if(!_inventory.count(it))return Item::BLANK;
return _inventory.at(it);
}
uint32_t Inventory::GetItemCount(IT it){ uint32_t Inventory::GetItemCount(IT it){
if(!_inventory.count(it)){ if(!_inventory.count(it)){
return 0; return 0;
@ -125,7 +136,7 @@ uint32_t Inventory::GetItemCount(IT it){
} }
} }
void Inventory::UseItem(IT it,int amt){ void Inventory::UseItem(IT it,uint32_t amt){
//There are two places to manipulate items in (Both the sorted inventory and the actual inventory) //There are two places to manipulate items in (Both the sorted inventory and the actual inventory)
for(int i=0;i<amt;i++){ for(int i=0;i<amt;i++){
if(ExecuteAction(it)){ if(ExecuteAction(it)){
@ -134,7 +145,7 @@ void Inventory::UseItem(IT it,int amt){
} }
} }
void Inventory::RemoveItem(IT it,int amt){ void Inventory::RemoveItem(IT it,uint32_t amt){
//There are two places to manipulate items in (Both the sorted inventory and the actual inventory) //There are two places to manipulate items in (Both the sorted inventory and the actual inventory)
if(!_inventory.count(it))return; if(!_inventory.count(it))return;
if(amt>=_inventory.at(it).Amt()){ if(amt>=_inventory.at(it).Amt()){
@ -176,4 +187,43 @@ bool Inventory::SwapItems(IT it,IT it2){
auto index2=std::find(inv.begin(),inv.end(),it2); auto index2=std::find(inv.begin(),inv.end(),it2);
std::swap(*index1,*index2); std::swap(*index1,*index2);
return true; return true;
}
uint32_t Item::Amt(){
return amt;
};
std::string Item::Name(){
return it->Name();
};
std::string Item::Description(){
return it->Description();
};
ITCategory Item::Category(){
return it->Category();
};
Decal*Item::Decal(){
return it->Decal();
};
ItemScript&Item::OnUseAction(){
return it->OnUseAction();
};
std::string ItemInfo::Name(){
return name;
};
std::string ItemInfo::Description(){
return description;
};
ITCategory ItemInfo::Category(){
return category;
};
Decal*ItemInfo::Decal(){
return img;
};
ItemScript&ItemInfo::OnUseAction(){
return ITEM_SCRIPTS.at(useFunc);
};
bool Item::IsBlank(){
return amt==0||it==nullptr;
} }

@ -8,16 +8,20 @@
class Crawler; class Crawler;
class ItemInfo; class ItemInfo;
class ItemProps;
typedef std::string IT; typedef std::string IT;
typedef std::string ITCategory; typedef std::string ITCategory;
typedef std::function<bool(Crawler*,ItemProps)> ItemScript;
class Item{ class Item{
friend class Inventory; friend class Inventory;
private: private:
uint32_t amt; uint32_t amt;
ItemInfo*it; ItemInfo*it;
public: public:
Item();
Item(uint32_t amt,IT item); Item(uint32_t amt,IT item);
uint32_t Amt(); uint32_t Amt();
std::string Name(); std::string Name();
@ -25,16 +29,18 @@ public:
ITCategory Category(); ITCategory Category();
Decal*Decal(); Decal*Decal();
ItemScript&OnUseAction(); ItemScript&OnUseAction();
bool IsBlank();
static Item BLANK;
}; };
class Inventory{ class Inventory{
public: public:
static void AddItem(IT it,int amt=1); static void AddItem(IT it,uint32_t amt=1);
static uint32_t GetItemCount(IT it); static uint32_t GetItemCount(IT it);
static Item GetItem(IT it)const; static Item GetItem(IT it);
//Auto-executes its use function and removes the amt specified from the inventory. Multiple amounts will cause the item to execute its useFunc multiple times. //Auto-executes its use function and removes the amt specified from the inventory. Multiple amounts will cause the item to execute its useFunc multiple times.
static void UseItem(IT it,int amt=1); static void UseItem(IT it,uint32_t amt=1);
static void RemoveItem(IT it,int amt=1); static void RemoveItem(IT it,uint32_t amt=1);
static std::vector<IT>&get(ITCategory itemCategory); static std::vector<IT>&get(ITCategory itemCategory);
static bool SwapItems(IT it,IT it2); static bool SwapItems(IT it,IT it2);
@ -56,8 +62,6 @@ public:
std::string GetStringProp(std::string prop); std::string GetStringProp(std::string prop);
}; };
typedef std::function<bool(Crawler*,ItemProps)> ItemScript;
class ItemInfo{ class ItemInfo{
friend class Inventory; friend class Inventory;
std::string name; std::string name;
@ -75,6 +79,11 @@ private:
public: public:
static void InitializeItems(); static void InitializeItems();
ItemInfo(); ItemInfo();
std::string Name();
std::string Description();
ITCategory Category();
Decal*Decal();
ItemScript&OnUseAction();
/* /*
For the useFunc, return true if the item can be used, false otherwise. For the useFunc, return true if the item can be used, false otherwise.
*/ */

@ -65,7 +65,7 @@ void Menu::HoverMenuSelect(Crawler*game){
void Menu::MenuSelect(Crawler*game){ void Menu::MenuSelect(Crawler*game){
if(selection==vi2d{-1,-1})return; if(selection==vi2d{-1,-1})return;
buttons[selection.y][selection.x]->onClick(*this,game); 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.

@ -1,12 +1,24 @@
#pragma once #pragma once
#include "MenuComponent.h"
#include "olcPixelGameEngine.h" #include "olcPixelGameEngine.h"
#include <stack> #include <stack>
#include "safemap.h" #include "safemap.h"
#include "Theme.h" #include "Theme.h"
#include "Attributable.h" #include "Attributable.h"
#include "olcUTIL_Geometry2D.h"
#include <functional>
class Crawler; class Crawler;
class MenuComponent;
enum MenuType{
TEST,
TEST_2,
INVENTORY,
///////////////////////////////////////////////////////////
/*DO NOT REMOVE!!*/ENUM_END////////////////////////////////
///////////////////////////////////////////////////////////
};
class Menu:IAttributable{ class Menu:IAttributable{
friend class Crawler; friend class Crawler;
@ -36,6 +48,7 @@ public:
static std::string themeSelection; static std::string themeSelection;
static safeunorderedmap<std::string,Theme>themes; static safeunorderedmap<std::string,Theme>themes;
static const vf2d CENTERED; static const vf2d CENTERED;
private: private:
void HoverMenuSelect(Crawler*game); void HoverMenuSelect(Crawler*game);
void MenuSelect(Crawler*game); void MenuSelect(Crawler*game);
@ -55,3 +68,10 @@ private:
Pixel GetRenderColor(); Pixel GetRenderColor();
}; };
struct MenuFuncData{
Menu&menu;
Crawler*game;
MenuComponent*component;
};
typedef std::function<void(MenuFuncData)> MenuFunc;

@ -1,5 +1,5 @@
#include "Crawler.h" #include "Crawler.h"
#include "Menu.h" #include "MenuComponent.h"
MenuComponent::MenuComponent(geom2d::rect<float>rect,std::string label,MenuFunc onClick,bool selectable) MenuComponent::MenuComponent(geom2d::rect<float>rect,std::string label,MenuFunc onClick,bool selectable)
:rect(rect),label(label),menuDest(MenuType::ENUM_END),onClick(onClick),hoverEffect(0),selectable(selectable){} :rect(rect),label(label),menuDest(MenuType::ENUM_END),onClick(onClick),hoverEffect(0),selectable(selectable){}

@ -1,10 +1,5 @@
#pragma once #pragma once
#include "olcUTIL_Geometry2D.h" #include "Menu.h"
#include "MenuType.h"
#include <functional>
class Menu;
class Crawler;
class MenuComponent{ class MenuComponent{
friend class Menu; friend class Menu;

@ -6,7 +6,7 @@
INCLUDE_game INCLUDE_game
class MenuIconButton:public MenuComponent{ class MenuIconButton:public MenuComponent{
private: protected:
Decal*icon; Decal*icon;
public: public:
inline MenuIconButton(geom2d::rect<float>rect,Decal*icon,MenuFunc onClick) inline MenuIconButton(geom2d::rect<float>rect,Decal*icon,MenuFunc onClick)

@ -3,21 +3,24 @@
#include "DEFINES.h" #include "DEFINES.h"
#include "Crawler.h" #include "Crawler.h"
#include "Item.h" #include "Item.h"
#include "safemap.h"
INCLUDE_game INCLUDE_game
INCLUDE_ITEM_DATA
class MenuItemButton:public MenuIconButton{ class MenuItemButton:public MenuIconButton{
private: private:
Decal*icon; std::vector<IT>&invRef;
int inventoryIndex=0;
public: public:
inline MenuItemButton(geom2d::rect<float>rect,Decal*icon,MenuFunc onClick) inline MenuItemButton(geom2d::rect<float>rect,std::vector<IT>&invRef,int invIndex,MenuFunc onClick)
:MenuIconButton(rect,icon,onClick){} :MenuIconButton(rect,ITEM_DATA.at(invRef[invIndex]).Decal(),onClick),invRef(invRef),inventoryIndex(invIndex){}
protected: protected:
virtual void inline Update(Crawler*game)override{ virtual void inline Update(Crawler*game)override{
MenuComponent::Update(game); MenuIconButton::Update(game);
} }
virtual void inline Draw(Crawler*game,vf2d parentPos,bool focused)override{ virtual void inline Draw(Crawler*game,vf2d parentPos,bool focused)override{
MenuComponent::Draw(game,parentPos,focused); MenuIconButton::Draw(game,parentPos,focused);
game->DrawRotatedDecal(parentPos+rect.middle(),icon,0,icon->sprite->Size()/2,{1,1},focused?WHITE:WHITE*"ThemeGlobal.MenuUnfocusedColorMult"_F); game->DrawRotatedDecal(parentPos+rect.middle(),icon,0,icon->sprite->Size()/2,{1,1},focused?WHITE:WHITE*"ThemeGlobal.MenuUnfocusedColorMult"_F);
} }
}; };

@ -1,16 +0,0 @@
#pragma once
class Menu;
class Crawler;
typedef std::function<void(Menu&,Crawler*)> MenuFunc;
enum MenuType{
TEST,
TEST_2,
INVENTORY,
///////////////////////////////////////////////////////////
/*DO NOT REMOVE!!*/ENUM_END////////////////////////////////
///////////////////////////////////////////////////////////
};

@ -28,5 +28,4 @@ enum class Attribute{
JUMP_TOWARDS_PLAYER, JUMP_TOWARDS_PLAYER,
HITS_UNTIL_DEATH, //When this is set, it is reduced by 1 each time the monster is hit. HITS_UNTIL_DEATH, //When this is set, it is reduced by 1 each time the monster is hit.
INDEXED_THEME, INDEXED_THEME,
INDEXED_ITEMS,
}; };

@ -21,12 +21,12 @@ struct CastInfo{
struct Player{ struct Player{
friend class Crawler; friend class Crawler;
friend class sig::Animation; friend class sig::Animation;
friend class Warrior; friend struct Warrior;
friend class Thief; friend struct Thief;
friend class Ranger; friend struct Ranger;
friend class Trapper; friend struct Trapper;
friend class Wizard; friend struct Wizard;
friend class Witch; friend struct Witch;
friend class State_GameRun; friend class State_GameRun;
private: private:
int hp="Player.BaseHealth"_I,maxhp=hp; int hp="Player.BaseHealth"_I,maxhp=hp;

@ -1,21 +1,21 @@
#include "Crawler.h" #include "Crawler.h"
#include "Menu.h" #include "MenuComponent.h"
const Menu Menu::InitializeTestMenu(){ const Menu Menu::InitializeTestMenu(){
Menu testMenu(CENTERED,{24*8,24*6}); Menu testMenu(CENTERED,{24*8,24*6});
MenuFunc quitWindow=[](Menu&menu,Crawler*game){ MenuFunc quitWindow=[](MenuFuncData data){
menu.stack.clear(); data.menu.stack.clear();
}; };
testMenu.AddComponent("Close",new MenuComponent({{24*1,24*1},{24*2,24*1}},"Close",quitWindow)); testMenu.AddComponent("Close",new MenuComponent({{24*1,24*1},{24*2,24*1}},"Close",quitWindow));
MenuFunc doNothing=[](Menu&menu,Crawler*game){}; MenuFunc doNothing=[](MenuFuncData data){};
testMenu.AddComponent("Test",new MenuComponent({{24*4,24*1},{24*3,24*1}},"Test",doNothing)); testMenu.AddComponent("Test",new MenuComponent({{24*4,24*1},{24*3,24*1}},"Test",doNothing));
MenuFunc HurtPlayer=[](Menu&menu,Crawler*game){ MenuFunc HurtPlayer=[](MenuFuncData data){
game->GetPlayer()->Hurt(20,game->GetPlayer()->OnUpperLevel(),game->GetPlayer()->GetZ()); data.game->GetPlayer()->Hurt(20,data.game->GetPlayer()->OnUpperLevel(),data.game->GetPlayer()->GetZ());
}; };
testMenu.AddComponent("Hurt Player",new MenuComponent({{24*4,24*3},{24*3,24*1}},"Hurt Player",HurtPlayer)); testMenu.AddComponent("Hurt Player",new MenuComponent({{24*4,24*3},{24*3,24*1}},"Hurt Player",HurtPlayer));

@ -1,5 +1,4 @@
#include "Crawler.h" #include "Crawler.h"
#include "Menu.h"
#include "DEFINES.h" #include "DEFINES.h"
#include "olcPixelGameEngine.h" #include "olcPixelGameEngine.h"
#include "safemap.h" #include "safemap.h"
@ -12,8 +11,8 @@ typedef Attribute A;
const Menu Menu::InitializeTestSubMenu(){ const Menu Menu::InitializeTestSubMenu(){
Menu testSubMenu({30,30},{24*4,24*5}); Menu testSubMenu({30,30},{24*4,24*5});
MenuFunc goBack=[](Menu&menu,Crawler*game){ MenuFunc goBack=[](MenuFuncData data){
menu.stack.pop_back(); data.menu.stack.pop_back();
}; };
testSubMenu.AddComponent("BACK",new MenuComponent({{24*1,24*1},{24*2,24*1}},"Go Back",goBack)); testSubMenu.AddComponent("BACK",new MenuComponent({{24*1,24*1},{24*2,24*1}},"Go Back",goBack));
@ -27,17 +26,17 @@ const Menu Menu::InitializeTestSubMenu(){
index++; index++;
} }
MenuFunc themePrev=[](Menu&menu,Crawler*game){ MenuFunc themePrev=[](MenuFuncData data){
bool found=false; bool found=false;
menu.I(A::INDEXED_THEME)--; data.menu.I(A::INDEXED_THEME)--;
if(menu.I(A::INDEXED_THEME)<0){ if(data.menu.I(A::INDEXED_THEME)<0){
menu.I(A::INDEXED_THEME)=themes.size()-1; data.menu.I(A::INDEXED_THEME)=themes.size()-1;
} }
int index=0; int index=0;
for(auto&theme:Menu::themes){ for(auto&theme:Menu::themes){
if(index==menu.I(A::INDEXED_THEME)){ if(index==data.menu.I(A::INDEXED_THEME)){
Menu::themeSelection=theme.displayName; Menu::themeSelection=theme.displayName;
((MenuLabel*)(menu.components["THEME_DISPLAY"]))->SetLabel("Theme\n"+Menu::themes[themeSelection].GetThemeName()); ((MenuLabel*)(data.menu.components["THEME_DISPLAY"]))->SetLabel("Theme\n"+Menu::themes[themeSelection].GetThemeName());
break; break;
} }
index++; index++;
@ -48,13 +47,13 @@ const Menu Menu::InitializeTestSubMenu(){
testSubMenu.AddComponent("THEME_DISPLAY",new MenuLabel({{24*0.5,24*3},{24*3,24*1}},"Theme\n"+Menu::themes[themeSelection].GetThemeName())); testSubMenu.AddComponent("THEME_DISPLAY",new MenuLabel({{24*0.5,24*3},{24*3,24*1}},"Theme\n"+Menu::themes[themeSelection].GetThemeName()));
MenuFunc themeNext=[](Menu&menu,Crawler*game){ MenuFunc themeNext=[](MenuFuncData data){
menu.I(A::INDEXED_THEME)=(size_t(menu.I(A::INDEXED_THEME))+1)%themes.size(); data.menu.I(A::INDEXED_THEME)=(size_t(data.menu.I(A::INDEXED_THEME))+1)%themes.size();
int index=0; int index=0;
for(auto&theme:Menu::themes){ for(auto&theme:Menu::themes){
if(index==menu.I(A::INDEXED_THEME)){ if(index==data.menu.I(A::INDEXED_THEME)){
Menu::themeSelection=theme.displayName; Menu::themeSelection=theme.displayName;
((MenuLabel*)(menu.components["THEME_DISPLAY"]))->SetLabel("Theme\n"+Menu::themes[themeSelection].GetThemeName()); ((MenuLabel*)(data.menu.components["THEME_DISPLAY"]))->SetLabel("Theme\n"+Menu::themes[themeSelection].GetThemeName());
break; break;
} }
index++; index++;

@ -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 1814 #define VERSION_BUILD 1839
#define stringify(a) stringify_(a) #define stringify(a) stringify_(a)
#define stringify_(a) #a #define stringify_(a) #a

Loading…
Cancel
Save