Added Merchant/Buy/Sell Menu windows. Added sorted item callbacks for traveling merchant inventory modifications.

This commit is contained in:
2023-12-19 17:10:04 -06:00
parent d9e1a1ebaf
commit 71fe49162d
23 changed files with 434 additions and 31 deletions
+12 -1
View File
@@ -72,6 +72,9 @@ enum MenuType{
OVERWORLD_MENU,
CHARACTER_MENU,
INVENTORY,
MERCHANT,
BUY_ITEM,
SELL_ITEM,
#pragma region Enum End //DO NOT REMOVE
///////////////////////////////////////////////////////////
/*DO NOT REMOVE!!*/ENUM_END////////////////////////////////
@@ -90,6 +93,9 @@ class Menu:public IAttributable{
static void InitializeOverworldMenuWindow();
static void InitializeCharacterMenuWindow();
static void InitializeInventoryWindow();
static void InitializeMerchantWindow();
static void InitializeBuyItemWindow();
static void InitializeSellItemWindow();
friend class Crawler;
friend struct Player;
@@ -104,6 +110,7 @@ class Menu:public IAttributable{
MenuComponent*draggingComponent=nullptr;
ViewPort window;
static safemap<ITCategory,std::vector<MenuComponent*>>inventoryListeners; //All menu components that care about inventory updates subscribe to this list indirectly (See Menu::AddInventoryListener()).
static safemap<ITCategory,std::vector<MenuComponent*>>merchantInventoryListeners; //All menu components that care about merchant inventory updates subscribe to this list indirectly (See Menu::AddMerchantInventoryListener()).
static std::vector<MenuComponent*>equipStatListeners; //All menu components that care about stat/equip updates subscribe to this list indirectly (See Menu::AddStatListener()).
public:
//The constructor is private. Use CreateMenu() instead!
@@ -167,7 +174,9 @@ public:
}
void Update(Crawler*game);
void Draw(Crawler*game);
static void InitializeMenuListenerCategory(const std::string&category);
static void InitializeMenus();
static void LockInListeners();
static void OpenMenu(MenuType menu,bool cover=true);
static void CloseMenu();
static void CloseAllMenus();
@@ -190,8 +199,10 @@ public:
static Theme&GetCurrentTheme();
bool UsingMouseNavigation();
void SetMouseNavigation(bool mouseNavigation);
static void InventorySlotsUpdated(ITCategory cat); //Called whenever an inventory item gets added to the player's inventory, thus increasing the total number of slots in our bag.
static void InventorySlotsUpdated(ITCategory cat); //Called whenever the player's inventory gets modified.
static void MerchantInventorySlotsUpdated(ITCategory cat); //Called whenever a traveling merchant's inventory item gets updated.
static void AddInventoryListener(MenuComponent*component,ITCategory category); //Adds a component to be in a given listener category.
static void AddMerchantInventoryListener(MenuComponent*component,ITCategory category); //Adds a component to be in a given listener category.
static void AddEquipStatListener(MenuComponent*component); //Adds a component to be in an equip stat listener. Will receive updates whenever stats are updated via equips.
vf2d center();
//Returns the last menu type created and last registered component, in case a component is detected as memory leaking, provides this information to each component for safety.