2023-09-28 21:13:04 +00:00
|
|
|
#pragma once
|
2023-10-01 01:48:27 -05:00
|
|
|
#include "MenuComponent.h"
|
2023-09-28 21:13:04 +00:00
|
|
|
#include "olcPixelGameEngine.h"
|
|
|
|
|
#include <stack>
|
2023-10-03 02:34:26 -05:00
|
|
|
#include "safemap.h"
|
|
|
|
|
#include "Theme.h"
|
|
|
|
|
#include "Attributable.h"
|
2023-10-01 01:48:27 -05:00
|
|
|
|
2023-09-28 21:13:04 +00:00
|
|
|
class Crawler;
|
|
|
|
|
|
2023-10-03 02:34:26 -05:00
|
|
|
class Menu:IAttributable{
|
2023-09-29 00:03:20 -05:00
|
|
|
friend class Crawler;
|
|
|
|
|
friend class Player;
|
|
|
|
|
static bool MOUSE_NAVIGATION;
|
|
|
|
|
static std::map<MenuType,Menu>menus;
|
2023-10-01 01:11:53 -05:00
|
|
|
|
2023-10-06 17:19:02 -05:00
|
|
|
float buttonHoldTime=0;
|
2023-10-01 01:48:27 -05:00
|
|
|
std::map<int/*Y*/,std::vector<MenuComponent*>>buttons; //Buttons are stored in rows followed by their column order.
|
2023-10-06 17:19:02 -05:00
|
|
|
std::map<int/*Y*/,std::vector<MenuComponent*>>newButtonArrangement; //The new setup that the buttons will be at if a drag operation completes.
|
2023-10-03 02:34:26 -05:00
|
|
|
std::vector<MenuComponent*>displayComponents; //Components that are only for displaying purposes.
|
|
|
|
|
safemap<std::string,MenuComponent*>components; //A friendly way to interrogate any component we are interested in.
|
2023-10-01 01:11:53 -05:00
|
|
|
vi2d selection={-1,-1};
|
2023-10-06 15:00:27 -05:00
|
|
|
vf2d pos; //Specify the upper-left corner of the window. Using CENTERED will always put this where the upper-left corner would center the window.
|
2023-09-28 21:13:04 +00:00
|
|
|
vf2d size; //Size in tiles (24x24), every menu will be tile-based
|
2023-10-06 17:19:02 -05:00
|
|
|
|
|
|
|
|
MenuComponent*draggingComponent=nullptr;
|
2023-09-29 00:03:20 -05:00
|
|
|
public:
|
2023-09-28 21:13:04 +00:00
|
|
|
Menu();
|
2023-10-06 15:00:27 -05:00
|
|
|
Menu(vf2d pos,vf2d size);
|
2023-10-03 02:34:26 -05:00
|
|
|
void AddComponent(std::string key,MenuComponent*button);
|
2023-09-29 00:03:20 -05:00
|
|
|
void Update(Crawler*game);
|
2023-09-28 21:13:04 +00:00
|
|
|
void Draw(Crawler*game);
|
2023-09-29 00:03:20 -05:00
|
|
|
static void InitializeMenus();
|
|
|
|
|
static void OpenMenu(MenuType menu);
|
|
|
|
|
static std::vector<Menu*>stack;
|
2023-10-03 02:34:26 -05:00
|
|
|
static std::string themeSelection;
|
2023-10-03 04:09:42 -05:00
|
|
|
static safeunorderedmap<std::string,Theme>themes;
|
2023-10-06 15:00:27 -05:00
|
|
|
static const vf2d CENTERED;
|
2023-09-29 00:03:20 -05:00
|
|
|
private:
|
2023-10-06 17:19:02 -05:00
|
|
|
void HoverMenuSelect(Crawler*game);
|
2023-09-29 00:03:20 -05:00
|
|
|
void MenuSelect(Crawler*game);
|
2023-10-06 17:19:02 -05:00
|
|
|
void CheckClickAndPerformMenuSelect(Crawler*game);
|
2023-09-29 00:03:20 -05:00
|
|
|
static const Menu InitializeTestMenu();
|
|
|
|
|
static const Menu InitializeTestSubMenu();
|
2023-10-07 13:33:27 -05:00
|
|
|
static const Menu InitializeInventoryWindow();
|
2023-10-02 19:54:21 +00:00
|
|
|
//X (0-3), Y (0-2) for specific 9-patch tile (tiled version).
|
|
|
|
|
static Renderable&GetPatchPart(int x,int y);
|
2023-10-01 01:11:53 -05:00
|
|
|
|
2023-10-03 04:09:42 -05:00
|
|
|
static Theme&GetCurrentTheme();
|
|
|
|
|
|
2023-10-02 16:50:53 +00:00
|
|
|
void KeyboardButtonNavigation(Crawler*game,vf2d menuPos);
|
2023-10-02 19:54:21 +00:00
|
|
|
void DrawScaledWindow(Crawler*game,vf2d menuPos);
|
|
|
|
|
void DrawTiledWindow(Crawler*game,vf2d menuPos);
|
2023-10-05 00:42:28 -05:00
|
|
|
|
|
|
|
|
Pixel GetRenderColor();
|
2023-09-28 21:13:04 +00:00
|
|
|
};
|
|
|
|
|
|