|
|
|
@ -43,11 +43,25 @@ All rights reserved. |
|
|
|
|
#include "Attributable.h" |
|
|
|
|
#include "olcUTIL_Geometry2D.h" |
|
|
|
|
#include "olcPGEX_ViewPort.h" |
|
|
|
|
#include "Key.h" |
|
|
|
|
|
|
|
|
|
class AiL; |
|
|
|
|
class MenuComponent; |
|
|
|
|
class ScrollableWindowComponent; |
|
|
|
|
|
|
|
|
|
struct Navigation; |
|
|
|
|
|
|
|
|
|
class Menu; |
|
|
|
|
|
|
|
|
|
struct MenuFuncData{ |
|
|
|
|
Menu&menu; |
|
|
|
|
AiL*const game; |
|
|
|
|
const std::weak_ptr<MenuComponent> component; |
|
|
|
|
const std::weak_ptr<ScrollableWindowComponent> parentComponent={}; |
|
|
|
|
MenuFuncData(Menu&menu,AiL*const game,std::weak_ptr<MenuComponent> component,std::weak_ptr<ScrollableWindowComponent>parentComponent={}); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
using MenuFunc=std::function<bool(MenuFuncData)>; |
|
|
|
|
//Add a component to a menu using this macro. Follow-up with END at the end of it.
|
|
|
|
|
#define ADD(key,componentType) _AddComponent<componentType>(key,std::make_shared<componentType> |
|
|
|
|
#define END ) |
|
|
|
@ -85,6 +99,21 @@ enum MenuType{ |
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
using MenuDataFunc=std::function<void(MenuType)>; |
|
|
|
|
|
|
|
|
|
using InputGroupActionDisplayName=std::string; |
|
|
|
|
using ButtonName=std::string; |
|
|
|
|
using MenuInputGroups=std::map<InputGroup,std::pair<InputGroupActionDisplayName,std::variant<ButtonName,MenuDataFunc>>>; |
|
|
|
|
using ButtonNavigationGroups=std::map<ButtonName,Navigation>; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct Navigation{ |
|
|
|
|
std::variant<std::string,MenuDataFunc>up; |
|
|
|
|
std::variant<std::string,MenuDataFunc>down; |
|
|
|
|
std::variant<std::string,MenuDataFunc>left; |
|
|
|
|
std::variant<std::string,MenuDataFunc>right; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
class Menu:public IAttributable{ |
|
|
|
|
static void InitializeConsumableInventoryWindow(); |
|
|
|
|
static void InitializeClassInfoWindow(); |
|
|
|
@ -188,6 +217,8 @@ public: |
|
|
|
|
void RecalculateComponentCount(); |
|
|
|
|
|
|
|
|
|
void SetDefaultButton(std::weak_ptr<MenuComponent>button); |
|
|
|
|
void SetSelection(std::weak_ptr<MenuComponent>button); |
|
|
|
|
const std::weak_ptr<MenuComponent>GetSelection()const; |
|
|
|
|
private: |
|
|
|
|
Menu(vf2d pos,vf2d size); |
|
|
|
|
std::weak_ptr<MenuComponent>defaultButton; |
|
|
|
@ -198,7 +229,8 @@ private: |
|
|
|
|
void CheckClickAndPerformMenuSelect(AiL*game); |
|
|
|
|
//Mandatory before any menu operations! This creates and sets up the menu in memory.
|
|
|
|
|
static Menu*CreateMenu(MenuType type,vf2d pos,vf2d size); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void SetupKeyboardNavigation(MenuInputGroups inputGroups,ButtonNavigationGroups navigationGroups); |
|
|
|
|
void KeyboardButtonNavigation(AiL*game,vf2d menuPos); |
|
|
|
|
static void DrawScaledWindowBackground(AiL*game,vf2d menuPos,vf2d size,Pixel renderColor); |
|
|
|
|
static void DrawTiledWindowBackground(AiL*game,vf2d menuPos,vf2d size,Pixel renderColor); |
|
|
|
@ -210,6 +242,8 @@ private: |
|
|
|
|
|
|
|
|
|
Pixel GetRenderColor(); |
|
|
|
|
MenuType type; |
|
|
|
|
MenuInputGroups inputGroups; |
|
|
|
|
ButtonNavigationGroups navigationGroups; |
|
|
|
|
|
|
|
|
|
static bool MOUSE_NAVIGATION; |
|
|
|
|
bool cover; //A black cover for when a menu pops up to fade out the stuff behind it.
|
|
|
|
@ -218,14 +252,4 @@ private: |
|
|
|
|
template<typename T> |
|
|
|
|
std::shared_ptr<T>Component(MenuType menu,std::string componentName){ |
|
|
|
|
return DYNAMIC_POINTER_CAST<T>(Menu::menus[menu]->components[componentName]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
struct MenuFuncData{ |
|
|
|
|
Menu&menu; |
|
|
|
|
AiL*const game; |
|
|
|
|
const std::weak_ptr<MenuComponent> component; |
|
|
|
|
const std::weak_ptr<ScrollableWindowComponent> parentComponent={}; |
|
|
|
|
MenuFuncData(Menu&menu,AiL*const game,std::weak_ptr<MenuComponent> component,std::weak_ptr<ScrollableWindowComponent>parentComponent={}); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
using MenuFunc=std::function<bool(MenuFuncData)>; |
|
|
|
|
} |