diff --git a/Adventures in Lestoria/MenuType.h b/Adventures in Lestoria/MenuType.h index cf702a47..5f51af6b 100644 --- a/Adventures in Lestoria/MenuType.h +++ b/Adventures in Lestoria/MenuType.h @@ -41,7 +41,7 @@ enum MenuType{ /////////////////////////////////////////////////////////// /*DO NOT REMOVE!!*/ENUM_START,/////////////////////////////// /////////////////////////////////////////////////////////// - // 40% Controller Compatibility. (100 total items, 4 items per menu * 25 menus) + // 44% Controller Compatibility. (100 total items, 4 items per menu * 25 menus) INVENTORY_CONSUMABLES, //100% Controller Compatibility CLASS_INFO, //100% Controller Compatibility CLASS_SELECTION, //100% Controller Compatibility @@ -52,7 +52,7 @@ enum MenuType{ OVERWORLD_MENU, //100% Controller Compatibility CHARACTER_MENU, //100% Controller Compatibility INVENTORY, //100% Controller Compatibility - MERCHANT, //0% Controller Compatibility + MERCHANT, //100% Controller Compatibility BUY_ITEM, //0% Controller Compatibility SELL_ITEM, //0% Controller Compatibility BLACKSMITH, //0% Controller Compatibility diff --git a/Adventures in Lestoria/MerchantWindow.cpp b/Adventures in Lestoria/MerchantWindow.cpp index d4aded90..63ea0c69 100644 --- a/Adventures in Lestoria/MerchantWindow.cpp +++ b/Adventures in Lestoria/MerchantWindow.cpp @@ -43,6 +43,7 @@ All rights reserved. #include "MenuComponent.h" #include "PlayerMoneyLabel.h" #include "ItemMenuLabel.h" +#include "SoundEffect.h" INCLUDE_game INCLUDE_ITEM_CATEGORIES @@ -54,13 +55,18 @@ void Menu::InitializeMerchantWindow(){ static std::string lastInventoryTypeOpened=""; - std::vector>categories; - for(auto&[category,items]:ITEM_CATEGORIES){ - if(DATA["ItemCategory"][category].GetString(0)=="!HIDE")continue; //This category is meant to be hidden! - categories.push_back({category,DATA["ItemCategory"][category].GetInt(0)}); //We assume the first value becomes the sort order we wish to use. - } - std::sort(categories.begin(),categories.end(),[](std::pair&cat1,std::pair&cat2){return cat1.second>categories; + for(auto&[category,items]:ITEM_CATEGORIES){ + if(DATA["ItemCategory"][category].GetString(0)=="!HIDE")continue; //This category is meant to be hidden! + categories.push_back({category,DATA["ItemCategory"][category].GetInt(0)}); //We assume the first value becomes the sort order we wish to use. + } + std::sort(categories.begin(),categories.end(),[](std::pair&cat1,std::pair&cat2){return cat1.second>categories=GetSortedCategories(); + auto buyTab=merchantWindow->ADD("Buy Tab",MenuComponent)(geom2d::rect{{2,0},{merchantWindow->size.x/2-4,24}},"Buy",[](MenuFuncData data){ Component(MERCHANT,"Merchant Inventory Display")->Enable(); Component(MERCHANT,"Sell Tab")->selected=false; @@ -72,6 +78,7 @@ void Menu::InitializeMerchantWindow(){ Component(data.menu.GetType(),"Inventory Display - "+data.menu.S(A::LAST_INVENTORY_TYPE_OPENED))->Disable(); Component(data.menu.GetType(),data.menu.S(A::LAST_INVENTORY_TYPE_OPENED)+" Inventory Tab")->Disable(); data.component.lock()->selected=true; + SoundEffect::PlaySFX("Button Click",SoundEffect::CENTERED); return true; })END; buyTab->selected=true; @@ -88,9 +95,12 @@ void Menu::InitializeMerchantWindow(){ Component(data.menu.GetType(),"Inventory Display - "+data.menu.S(A::LAST_INVENTORY_TYPE_OPENED))->Enable(); Component(data.menu.GetType(),data.menu.S(A::LAST_INVENTORY_TYPE_OPENED)+" Inventory Tab")->Enable(); data.component.lock()->selected=true; + SoundEffect::PlaySFX("Button Click",SoundEffect::CENTERED); return true; })END; sellTab->selectionType=SelectionType::HIGHLIGHT; + + merchantWindow->I(A::ITEM_SLOT)=0; auto inventoryDisplay=merchantWindow->ADD("Merchant Inventory Display",RowInventoryScrollableWindowComponent)(geom2d::rect{{2,28},{220,merchantWindow->size.y-44}},"Item Name Label","Item Description Label", [](MenuFuncData data){ @@ -112,6 +122,7 @@ void Menu::InitializeMerchantWindow(){ }, [](MenuFuncData data){ Component(data.menu.GetType(),"Item Icon")->SetItem(DYNAMIC_POINTER_CAST(data.component.lock())->GetItem()); + data.menu.I(A::MERCHANT_ITEM_SLOT)=data.parentComponent.lock()->GetComponentIndex(data.component); return true; }, [](MenuFuncData data){ @@ -128,8 +139,6 @@ void Menu::InitializeMerchantWindow(){ merchantWindow->ADD("Inventory Tabs Outline",MenuComponent)(geom2d::rect{{0,28},{72,merchantWindow->size.y-44}},"",DO_NOTHING,ButtonAttr::UNSELECTABLE)END; - std::sort(categories.begin(),categories.end(),[](std::pair&cat1,std::pair&cat2){return cat1.second(data.menu.GetType(),"Inventory Display - "+data.component.lock()->S(A::CATEGORY_NAME))->Enable(); Component(data.menu.GetType(),data.component.lock()->S(A::CATEGORY_NAME)+" Inventory Tab")->SetSelected(true); data.menu.S(A::LAST_INVENTORY_TYPE_OPENED)=data.component.lock()->S(A::CATEGORY_NAME); + if(Component(data.menu.GetType(),"Inventory Display - "+data.component.lock()->S(A::CATEGORY_NAME))->GetComponents().size()>0){ + data.menu.I(A::ITEM_SLOT)=0; + }else{ + data.menu.I(A::ITEM_SLOT)=-1; + } + if(data.menu.I(A::ITEM_SLOT)>=0){ + data.menu.SetSelection(Component(data.menu.GetType(),"Inventory Display - "+data.component.lock()->S(A::CATEGORY_NAME))->GetComponents()[0],true); + } + SoundEffect::PlaySFX("Button Click",SoundEffect::CENTERED); return true; },vf2d{textScaling,1.f})END; button->SetSelectionType(HIGHLIGHT); @@ -172,6 +190,7 @@ void Menu::InitializeMerchantWindow(){ }, [](MenuFuncData data){ Component(data.menu.GetType(),"Item Icon")->SetItem(DYNAMIC_POINTER_CAST(data.component.lock())->GetItem()); + data.menu.I(A::ITEM_SLOT)=data.parentComponent.lock()->GetComponentIndex(data.component); return true; }, [](MenuFuncData data){ @@ -224,27 +243,570 @@ void Menu::InitializeMerchantWindow(){ buyTab->onClick(MenuFuncData{*merchantWindow,game,buyTab}); - /*merchantWindow->SetupKeyboardNavigation( + merchantWindow->SetupKeyboardNavigation( [](MenuType type,Data&returnData){ //On Open - if(SaveFile::GetSaveFileCount()>0){ - returnData="Load Game Button"; - }else{ - returnData="New Game Button"; - } + returnData=Component(type,"Merchant Inventory Display")->GetComponents()[0]; }, { //Button Key - {game->KEY_BACK,{"Back",[](MenuType type){}}}, + {game->KEY_BACK,{"Leave",[](MenuType type){ + Menu::CloseMenu(); + }}}, + {game->KEY_FACELEFT,{[](MenuFuncData data){ + if(Component(MERCHANT,"Buy Tab")->selected){ + return "Sell Page"; + }else{ + return "Buy Page"; + } + },[](MenuType type){ + if(Component(MERCHANT,"Buy Tab")->selected){ + Component(MERCHANT,"Sell Tab")->Click(); + + }else{ + Component(MERCHANT,"Buy Tab")->Click(); + } + if(Component(MERCHANT,"Buy Tab")->selected){ + auto merchantList=Component(type,"Merchant Inventory Display"); + Menu::menus[type]->SetSelection(merchantList->GetComponents()[merchantList->GetComponents().size()-1]); + }else{ + auto inventory=Component(type,std::format("Inventory Display - {}",Menu::menus[type]->S(A::LAST_INVENTORY_TYPE_OPENED))); + if(inventory->GetComponents().size()>0){ + Menu::menus[type]->SetSelection(inventory->GetComponents()[0]); + }else{ + Menu::menus[type]->SetSelection(std::weak_ptr{Component(type,std::format("{} Inventory Tab",Menu::menus[type]->S(A::LAST_INVENTORY_TYPE_OPENED)))}); + } + } + }}}, + {{game->KEY_SHOULDER,Pressed},{"Scroll Up/Down",[](MenuType type){}}}, + {{game->KEY_FACEUP,Pressed},{[](MenuFuncData data){ + if(Component(MERCHANT,"Buy Tab")->selected){ + return ""; + }else{ + return "Change Category"; + } + },[&](MenuType type){ + auto categories=GetSortedCategories(); + size_t index=0; + for(auto&[category,item]:categories){ + if(category==Menu::menus[type]->S(A::LAST_INVENTORY_TYPE_OPENED))break; + index++; + } + if(index=categories.size()){ + index-=categories.size(); + } + Component(type,std::format("{} Inventory Tab",categories[index].first))->Click(); + }else ERR("WARNING! Could not find current category! THIS SHOULD NOT BE HAPPENING!"); + }}}, + {{game->KEY_FASTSCROLLDOWN,PressedDAS},{"",[&](MenuType type){ + if(!Menu::menus[type]->GetSelection().expired()&& + !Menu::menus[type]->GetSelection().lock()->parentComponent.expired()){ + Menu::menus[type]->GetSelection().lock()->parentComponent.lock()->IncreaseSelectionIndex(3.f); + } + }}}, + {{game->KEY_FASTSCROLLUP,PressedDAS},{"",[&](MenuType type){ + if(!Menu::menus[type]->GetSelection().expired()&& + !Menu::menus[type]->GetSelection().lock()->parentComponent.expired()){ + Menu::menus[type]->GetSelection().lock()->parentComponent.lock()->IncreaseSelectionIndex(-3.f); + } + }}}, + {{game->KEY_SCROLL,Pressed},{"Navigate",[](MenuType type){}}}, {game->KEY_CONFIRM,{"Select",[](MenuType type){}}}, } ,{ //Button Navigation Rules - {"New Game Button",{ - .up="Quit Game Button", - .down="Load Game Button",}}, - {"Load Game Button",{ - .up="New Game Button", - .down="Quit Game Button",}}, - {"Quit Game Button",{ - .up="Load Game Button", - .down="New Game Button",}}, - });*/ + {"Leave Button",{ + .up=[](MenuType type,Data&returnData){ + if(Component(MERCHANT,"Buy Tab")->selected){ + auto merchantList=Component(type,"Merchant Inventory Display"); + returnData=merchantList->GetComponents()[merchantList->GetComponents().size()-1]; + }else{ + auto inventory=Component(type,std::format("Inventory Display - {}",Menu::menus[type]->S(A::LAST_INVENTORY_TYPE_OPENED))); + if(inventory->GetComponents().size()>0){ + returnData=inventory->GetComponents()[inventory->GetComponents().size()-1]; + }else{ + returnData=Component(type,std::format("{} Inventory Tab",Menu::menus[type]->S(A::LAST_INVENTORY_TYPE_OPENED))); + } + } + }, + .down=[](MenuType type,Data&returnData){ + if(Component(MERCHANT,"Buy Tab")->selected){ + auto merchantList=Component(type,"Merchant Inventory Display"); + returnData=merchantList->GetComponents()[0]; + }else{ + auto inventory=Component(type,std::format("Inventory Display - {}",Menu::menus[type]->S(A::LAST_INVENTORY_TYPE_OPENED))); + if(inventory->GetComponents().size()>0){ + returnData=inventory->GetComponents()[0]; + }else{ + returnData=Component(type,std::format("{} Inventory Tab",Menu::menus[type]->S(A::LAST_INVENTORY_TYPE_OPENED))); + } + } + }, + .left=[](MenuType type,Data&returnData){ + if(Component(MERCHANT,"Buy Tab")->selected){ + Component(MERCHANT,"Sell Tab")->Click(); + }else{ + Component(MERCHANT,"Buy Tab")->Click(); + } + if(Component(MERCHANT,"Buy Tab")->selected){ + auto merchantList=Component(type,"Merchant Inventory Display"); + returnData=merchantList->GetComponents()[0]; + }else{ + auto inventory=Component(type,std::format("Inventory Display - {}",Menu::menus[type]->S(A::LAST_INVENTORY_TYPE_OPENED))); + if(inventory->GetComponents().size()>0){ + returnData=inventory->GetComponents()[0]; + }else{ + returnData=Component(type,std::format("{} Inventory Tab",Menu::menus[type]->S(A::LAST_INVENTORY_TYPE_OPENED))); + } + } + }, + .right=[](MenuType type,Data&returnData){ + if(Component(MERCHANT,"Buy Tab")->selected){ + Component(MERCHANT,"Sell Tab")->Click(); + }else{ + Component(MERCHANT,"Buy Tab")->Click(); + } + if(Component(MERCHANT,"Buy Tab")->selected){ + auto merchantList=Component(type,"Merchant Inventory Display"); + returnData=merchantList->GetComponents()[0]; + }else{ + auto inventory=Component(type,std::format("Inventory Display - {}",Menu::menus[type]->S(A::LAST_INVENTORY_TYPE_OPENED))); + if(inventory->GetComponents().size()>0){ + returnData=inventory->GetComponents()[0]; + }else{ + returnData=Component(type,std::format("{} Inventory Tab",Menu::menus[type]->S(A::LAST_INVENTORY_TYPE_OPENED))); + } + } + }, + }}, + {"Inventory Display - Consumables",{ + .up=[](MenuType type,Data&returnData){ + Menu::menus[type]->I(A::ITEM_SLOT)--; + if(Menu::menus[type]->I(A::ITEM_SLOT)<0){ + returnData="Leave Button"; + }else returnData=Component(type,"Inventory Display - Consumables")->GetComponents()[Menu::menus[type]->I(A::ITEM_SLOT)]; + }, + .down=[](MenuType type,Data&returnData){ + Menu::menus[type]->I(A::ITEM_SLOT)++; + if(Menu::menus[type]->I(A::ITEM_SLOT)>=Component(type,"Inventory Display - Consumables")->GetComponents().size()){ + returnData="Leave Button"; + }else returnData=Component(type,"Inventory Display - Consumables")->GetComponents()[Menu::menus[type]->I(A::ITEM_SLOT)]; + }, + .left=[](MenuType type,Data&returnData){ + returnData=std::format("{} Inventory Tab",Menu::menus[type]->S(A::LAST_INVENTORY_TYPE_OPENED)); + }, + .right=[](MenuType type,Data&returnData){ + if(Component(MERCHANT,"Buy Tab")->selected){ + Component(MERCHANT,"Sell Tab")->Click(); + }else{ + Component(MERCHANT,"Buy Tab")->Click(); + } + if(Component(MERCHANT,"Buy Tab")->selected){ + auto merchantList=Component(type,"Merchant Inventory Display"); + returnData=merchantList->GetComponents()[0]; + }else{ + auto inventory=Component(type,std::format("Inventory Display - {}",Menu::menus[type]->S(A::LAST_INVENTORY_TYPE_OPENED))); + if(inventory->GetComponents().size()>0){ + returnData=inventory->GetComponents()[0]; + }else{ + returnData=Component(type,std::format("{} Inventory Tab",Menu::menus[type]->S(A::LAST_INVENTORY_TYPE_OPENED))); + } + } + } + }}, + {"Inventory Display - Equipment",{ + .up=[](MenuType type,Data&returnData){ + Menu::menus[type]->I(A::ITEM_SLOT)--; + if(Menu::menus[type]->I(A::ITEM_SLOT)<0){ + returnData="Leave Button"; + }else returnData=Component(type,"Inventory Display - Equipment")->GetComponents()[Menu::menus[type]->I(A::ITEM_SLOT)]; + }, + .down=[](MenuType type,Data&returnData){ + Menu::menus[type]->I(A::ITEM_SLOT)++; + if(Menu::menus[type]->I(A::ITEM_SLOT)>=Component(type,"Inventory Display - Equipment")->GetComponents().size()){ + returnData="Leave Button"; + }else returnData=Component(type,"Inventory Display - Equipment")->GetComponents()[Menu::menus[type]->I(A::ITEM_SLOT)]; + }, + .left=[](MenuType type,Data&returnData){ + returnData=std::format("{} Inventory Tab",Menu::menus[type]->S(A::LAST_INVENTORY_TYPE_OPENED)); + }, + .right=[](MenuType type,Data&returnData){ + if(Component(MERCHANT,"Buy Tab")->selected){ + Component(MERCHANT,"Sell Tab")->Click(); + }else{ + Component(MERCHANT,"Buy Tab")->Click(); + } + if(Component(MERCHANT,"Buy Tab")->selected){ + auto merchantList=Component(type,"Merchant Inventory Display"); + returnData=merchantList->GetComponents()[0]; + }else{ + auto inventory=Component(type,std::format("Inventory Display - {}",Menu::menus[type]->S(A::LAST_INVENTORY_TYPE_OPENED))); + if(inventory->GetComponents().size()>0){ + returnData=inventory->GetComponents()[0]; + }else{ + returnData=Component(type,std::format("{} Inventory Tab",Menu::menus[type]->S(A::LAST_INVENTORY_TYPE_OPENED))); + } + } + } + }}, + {"Inventory Display - Accessories",{ + .up=[](MenuType type,Data&returnData){ + Menu::menus[type]->I(A::ITEM_SLOT)--; + if(Menu::menus[type]->I(A::ITEM_SLOT)<0){ + returnData="Leave Button"; + }else returnData=Component(type,"Inventory Display - Accessories")->GetComponents()[Menu::menus[type]->I(A::ITEM_SLOT)]; + }, + .down=[](MenuType type,Data&returnData){ + Menu::menus[type]->I(A::ITEM_SLOT)++; + if(Menu::menus[type]->I(A::ITEM_SLOT)>=Component(type,"Inventory Display - Accessories")->GetComponents().size()){ + returnData="Leave Button"; + }else returnData=Component(type,"Inventory Display - Accessories")->GetComponents()[Menu::menus[type]->I(A::ITEM_SLOT)]; + }, + .left=[](MenuType type,Data&returnData){ + returnData=std::format("{} Inventory Tab",Menu::menus[type]->S(A::LAST_INVENTORY_TYPE_OPENED)); + }, + .right=[](MenuType type,Data&returnData){ + if(Component(MERCHANT,"Buy Tab")->selected){ + Component(MERCHANT,"Sell Tab")->Click(); + }else{ + Component(MERCHANT,"Buy Tab")->Click(); + } + if(Component(MERCHANT,"Buy Tab")->selected){ + auto merchantList=Component(type,"Merchant Inventory Display"); + returnData=merchantList->GetComponents()[0]; + }else{ + auto inventory=Component(type,std::format("Inventory Display - {}",Menu::menus[type]->S(A::LAST_INVENTORY_TYPE_OPENED))); + if(inventory->GetComponents().size()>0){ + returnData=inventory->GetComponents()[0]; + }else{ + returnData=Component(type,std::format("{} Inventory Tab",Menu::menus[type]->S(A::LAST_INVENTORY_TYPE_OPENED))); + } + } + } + }}, + {"Inventory Display - Materials",{ + .up=[](MenuType type,Data&returnData){ + Menu::menus[type]->I(A::ITEM_SLOT)--; + if(Menu::menus[type]->I(A::ITEM_SLOT)<0){ + returnData="Leave Button"; + }else returnData=Component(type,"Inventory Display - Materials")->GetComponents()[Menu::menus[type]->I(A::ITEM_SLOT)]; + }, + .down=[](MenuType type,Data&returnData){ + Menu::menus[type]->I(A::ITEM_SLOT)++; + if(Menu::menus[type]->I(A::ITEM_SLOT)>=Component(type,"Inventory Display - Materials")->GetComponents().size()){ + returnData="Leave Button"; + }else returnData=Component(type,"Inventory Display - Materials")->GetComponents()[Menu::menus[type]->I(A::ITEM_SLOT)]; + }, + .left=[](MenuType type,Data&returnData){ + returnData=std::format("{} Inventory Tab",Menu::menus[type]->S(A::LAST_INVENTORY_TYPE_OPENED)); + }, + .right=[](MenuType type,Data&returnData){ + if(Component(MERCHANT,"Buy Tab")->selected){ + Component(MERCHANT,"Sell Tab")->Click(); + }else{ + Component(MERCHANT,"Buy Tab")->Click(); + } + if(Component(MERCHANT,"Buy Tab")->selected){ + auto merchantList=Component(type,"Merchant Inventory Display"); + returnData=merchantList->GetComponents()[0]; + }else{ + auto inventory=Component(type,std::format("Inventory Display - {}",Menu::menus[type]->S(A::LAST_INVENTORY_TYPE_OPENED))); + if(inventory->GetComponents().size()>0){ + returnData=inventory->GetComponents()[0]; + }else{ + returnData=Component(type,std::format("{} Inventory Tab",Menu::menus[type]->S(A::LAST_INVENTORY_TYPE_OPENED))); + } + } + } + }}, + {"Merchant Inventory Display",{ + .up=[](MenuType type,Data&returnData){ + Menu::menus[type]->I(A::MERCHANT_ITEM_SLOT)--; + if(Menu::menus[type]->I(A::MERCHANT_ITEM_SLOT)<0){ + returnData="Leave Button"; + }else{ + returnData=Component(type,"Merchant Inventory Display")->GetComponents()[Menu::menus[type]->I(A::MERCHANT_ITEM_SLOT)]; + } + }, + .down=[](MenuType type,Data&returnData){ + Menu::menus[type]->I(A::MERCHANT_ITEM_SLOT)++; + if(Menu::menus[type]->I(A::MERCHANT_ITEM_SLOT)>=Component(type,"Merchant Inventory Display")->GetComponents().size()){ + returnData="Leave Button"; + }else{ + returnData=Component(type,"Merchant Inventory Display")->GetComponents()[Menu::menus[type]->I(A::MERCHANT_ITEM_SLOT)]; + } + }, + .left=[](MenuType type,Data&returnData){ + if(Component(MERCHANT,"Buy Tab")->selected){ + Component(MERCHANT,"Sell Tab")->Click(); + }else{ + Component(MERCHANT,"Buy Tab")->Click(); + } + if(Component(MERCHANT,"Buy Tab")->selected){ + auto merchantList=Component(type,"Merchant Inventory Display"); + returnData=merchantList->GetComponents()[0]; + }else{ + auto inventory=Component(type,std::format("Inventory Display - {}",Menu::menus[type]->S(A::LAST_INVENTORY_TYPE_OPENED))); + if(inventory->GetComponents().size()>0){ + returnData=inventory->GetComponents()[0]; + }else{ + returnData=Component(type,std::format("{} Inventory Tab",Menu::menus[type]->S(A::LAST_INVENTORY_TYPE_OPENED))); + } + } + }, + .right=[](MenuType type,Data&returnData){ + if(Component(MERCHANT,"Buy Tab")->selected){ + Component(MERCHANT,"Sell Tab")->Click(); + }else{ + Component(MERCHANT,"Buy Tab")->Click(); + } + if(Component(MERCHANT,"Buy Tab")->selected){ + auto merchantList=Component(type,"Merchant Inventory Display"); + returnData=merchantList->GetComponents()[0]; + }else{ + auto inventory=Component(type,std::format("Inventory Display - {}",Menu::menus[type]->S(A::LAST_INVENTORY_TYPE_OPENED))); + if(inventory->GetComponents().size()>0){ + returnData=inventory->GetComponents()[0]; + }else{ + returnData=Component(type,std::format("{} Inventory Tab",Menu::menus[type]->S(A::LAST_INVENTORY_TYPE_OPENED))); + } + } + }, + }}, + {"Consumables Inventory Tab",{ + .up=[&](MenuType type,Data&returnData){ + auto categories=GetSortedCategories(); + size_t index=0; + for(auto&[category,item]:categories){ + if(category=="Consumables")break; + index++; + } + if(index=categories.size()){ + index=categories.size()-1; + } + Component(type,std::format("{} Inventory Tab",categories[index].first))->Click(); + returnData=std::format("{} Inventory Tab",categories[index].first); + }else ERR("WARNING! Could not find current category! THIS SHOULD NOT BE HAPPENING!"); + }, + .down=[&](MenuType type,Data&returnData){ + auto categories=GetSortedCategories(); + size_t index=0; + for(auto&[category,item]:categories){ + if(category=="Consumables")break; + index++; + } + if(index=categories.size()){ + index-=categories.size(); + } + Component(type,std::format("{} Inventory Tab",categories[index].first))->Click(); + returnData=std::format("{} Inventory Tab",categories[index].first); + }else ERR("WARNING! Could not find current category! THIS SHOULD NOT BE HAPPENING!"); + }, + .left=[&](MenuType type,Data&returnData){ + if(Component(MERCHANT,"Buy Tab")->selected){ + Component(MERCHANT,"Sell Tab")->Click(); + }else{ + Component(MERCHANT,"Buy Tab")->Click(); + } + if(Component(MERCHANT,"Buy Tab")->selected){ + auto merchantList=Component(type,"Merchant Inventory Display"); + returnData=merchantList->GetComponents()[0]; + }else{ + auto inventory=Component(type,std::format("Inventory Display - {}",Menu::menus[type]->S(A::LAST_INVENTORY_TYPE_OPENED))); + if(inventory->GetComponents().size()>0){ + returnData=inventory->GetComponents()[0]; + }else{ + returnData=Component(type,std::format("{} Inventory Tab",Menu::menus[type]->S(A::LAST_INVENTORY_TYPE_OPENED))); + } + } + }, + .right=[&](MenuType type,Data&returnData){ + if(Menu::menus[type]->I(A::ITEM_SLOT)>=0){ + returnData=Component(type,"Inventory Display - Consumables")->GetComponents()[Menu::menus[type]->I(A::ITEM_SLOT)]; + }else{ + returnData="Consumables Inventory Tab"; + } + }, + }}, + {"Equipment Inventory Tab",{ + .up=[&](MenuType type,Data&returnData){ + auto categories=GetSortedCategories(); + size_t index=0; + for(auto&[category,item]:categories){ + if(category=="Equipment")break; + index++; + } + if(index=categories.size()){ + index=categories.size()-1; + } + Component(type,std::format("{} Inventory Tab",categories[index].first))->Click(); + returnData=std::format("{} Inventory Tab",categories[index].first); + }else ERR("WARNING! Could not find current category! THIS SHOULD NOT BE HAPPENING!"); + }, + .down=[&](MenuType type,Data&returnData){ + auto categories=GetSortedCategories(); + size_t index=0; + for(auto&[category,item]:categories){ + if(category=="Equipment")break; + index++; + } + if(index=categories.size()){ + index-=categories.size(); + } + Component(type,std::format("{} Inventory Tab",categories[index].first))->Click(); + returnData=std::format("{} Inventory Tab",categories[index].first); + }else ERR("WARNING! Could not find current category! THIS SHOULD NOT BE HAPPENING!"); + }, + .left=[&](MenuType type,Data&returnData){ + if(Component(MERCHANT,"Buy Tab")->selected){ + Component(MERCHANT,"Sell Tab")->Click(); + }else{ + Component(MERCHANT,"Buy Tab")->Click(); + } + if(Component(MERCHANT,"Buy Tab")->selected){ + auto merchantList=Component(type,"Merchant Inventory Display"); + returnData=merchantList->GetComponents()[0]; + }else{ + auto inventory=Component(type,std::format("Inventory Display - {}",Menu::menus[type]->S(A::LAST_INVENTORY_TYPE_OPENED))); + if(inventory->GetComponents().size()>0){ + returnData=inventory->GetComponents()[0]; + }else{ + returnData=Component(type,std::format("{} Inventory Tab",Menu::menus[type]->S(A::LAST_INVENTORY_TYPE_OPENED))); + } + } + }, + .right=[&](MenuType type,Data&returnData){ + if(Menu::menus[type]->I(A::ITEM_SLOT)>=0){ + returnData=Component(type,"Inventory Display - Equipment")->GetComponents()[Menu::menus[type]->I(A::ITEM_SLOT)]; + }else{ + returnData="Equipment Inventory Tab"; + } + }, + }}, + {"Accessories Inventory Tab",{ + .up=[&](MenuType type,Data&returnData){ + auto categories=GetSortedCategories(); + size_t index=0; + for(auto&[category,item]:categories){ + if(category=="Accessories")break; + index++; + } + if(index=categories.size()){ + index=categories.size()-1; + } + Component(type,std::format("{} Inventory Tab",categories[index].first))->Click(); + returnData=std::format("{} Inventory Tab",categories[index].first); + }else ERR("WARNING! Could not find current category! THIS SHOULD NOT BE HAPPENING!"); + }, + .down=[&](MenuType type,Data&returnData){ + auto categories=GetSortedCategories(); + size_t index=0; + for(auto&[category,item]:categories){ + if(category=="Accessories")break; + index++; + } + if(index=categories.size()){ + index-=categories.size(); + } + Component(type,std::format("{} Inventory Tab",categories[index].first))->Click(); + returnData=std::format("{} Inventory Tab",categories[index].first); + }else ERR("WARNING! Could not find current category! THIS SHOULD NOT BE HAPPENING!"); + }, + .left=[&](MenuType type,Data&returnData){ + if(Component(MERCHANT,"Buy Tab")->selected){ + Component(MERCHANT,"Sell Tab")->Click(); + }else{ + Component(MERCHANT,"Buy Tab")->Click(); + } + if(Component(MERCHANT,"Buy Tab")->selected){ + auto merchantList=Component(type,"Merchant Inventory Display"); + returnData=merchantList->GetComponents()[0]; + }else{ + auto inventory=Component(type,std::format("Inventory Display - {}",Menu::menus[type]->S(A::LAST_INVENTORY_TYPE_OPENED))); + if(inventory->GetComponents().size()>0){ + returnData=inventory->GetComponents()[0]; + }else{ + returnData=Component(type,std::format("{} Inventory Tab",Menu::menus[type]->S(A::LAST_INVENTORY_TYPE_OPENED))); + } + } + }, + .right=[&](MenuType type,Data&returnData){ + if(Menu::menus[type]->I(A::ITEM_SLOT)>=0){ + returnData=Component(type,"Inventory Display - Accessories")->GetComponents()[Menu::menus[type]->I(A::ITEM_SLOT)]; + }else{ + returnData="Accessories Inventory Tab"; + } + }, + }}, + {"Materials Inventory Tab",{ + .up=[&](MenuType type,Data&returnData){ + auto categories=GetSortedCategories(); + size_t index=0; + for(auto&[category,item]:categories){ + if(category=="Materials")break; + index++; + } + if(index=categories.size()){ + index=categories.size()-1; + } + Component(type,std::format("{} Inventory Tab",categories[index].first))->Click(); + returnData=std::format("{} Inventory Tab",categories[index].first); + }else ERR("WARNING! Could not find current category! THIS SHOULD NOT BE HAPPENING!"); + }, + .down=[&](MenuType type,Data&returnData){ + auto categories=GetSortedCategories(); + size_t index=0; + for(auto&[category,item]:categories){ + if(category=="Materials")break; + index++; + } + if(index=categories.size()){ + index-=categories.size(); + } + Component(type,std::format("{} Inventory Tab",categories[index].first))->Click(); + returnData=std::format("{} Inventory Tab",categories[index].first); + }else ERR("WARNING! Could not find current category! THIS SHOULD NOT BE HAPPENING!"); + }, + .left=[&](MenuType type,Data&returnData){ + if(Component(MERCHANT,"Buy Tab")->selected){ + Component(MERCHANT,"Sell Tab")->Click(); + }else{ + Component(MERCHANT,"Buy Tab")->Click(); + } + if(Component(MERCHANT,"Buy Tab")->selected){ + auto merchantList=Component(type,"Merchant Inventory Display"); + returnData=merchantList->GetComponents()[0]; + }else{ + auto inventory=Component(type,std::format("Inventory Display - {}",Menu::menus[type]->S(A::LAST_INVENTORY_TYPE_OPENED))); + if(inventory->GetComponents().size()>0){ + returnData=inventory->GetComponents()[0]; + }else{ + returnData=Component(type,std::format("{} Inventory Tab",Menu::menus[type]->S(A::LAST_INVENTORY_TYPE_OPENED))); + } + } + }, + .right=[&](MenuType type,Data&returnData){ + if(Menu::menus[type]->I(A::ITEM_SLOT)>=0){ + returnData=Component(type,"Inventory Display - Materials")->GetComponents()[Menu::menus[type]->I(A::ITEM_SLOT)]; + }else{ + returnData="Materials Inventory Tab"; + } + }, + }}, + }); } \ No newline at end of file diff --git a/Adventures in Lestoria/MonsterAttribute.h b/Adventures in Lestoria/MonsterAttribute.h index 484bb649..c0d39f68 100644 --- a/Adventures in Lestoria/MonsterAttribute.h +++ b/Adventures in Lestoria/MonsterAttribute.h @@ -98,4 +98,5 @@ enum class Attribute{ IS_KEYBOARD, KEYBIND, ITEM_SLOT, + MERCHANT_ITEM_SLOT, }; \ No newline at end of file diff --git a/Adventures in Lestoria/OverworldMapLevelWindow.cpp b/Adventures in Lestoria/OverworldMapLevelWindow.cpp index 911af849..7b80d829 100644 --- a/Adventures in Lestoria/OverworldMapLevelWindow.cpp +++ b/Adventures in Lestoria/OverworldMapLevelWindow.cpp @@ -85,7 +85,7 @@ void Menu::InitializeOverworldMapLevelWindow(){ {{game->KEY_FASTSCROLLDOWN,Held,InputEngageGroup::NOT_VISIBLE},{"Scroll Encounters",[](MenuType type){ Component(type,"Spawns List")->Scroll(1.0f); }}}, - {{game->KEY_SCROLLVERT_R,Analog},{"Scroll Encounters",[](MenuType type){ + {{game->KEY_SCROLLVERT_R,Analog,InputEngageGroup::NOT_VISIBLE},{"Scroll Encounters",[](MenuType type){ Component(type,"Spawns List")->Scroll(game->KEY_SCROLLVERT.Analog()); }}}, {{game->KEY_SCROLLUP,Held},{"",[](MenuType type){ diff --git a/Adventures in Lestoria/Version.h b/Adventures in Lestoria/Version.h index 308d8ccb..9bfe683a 100644 --- a/Adventures in Lestoria/Version.h +++ b/Adventures in Lestoria/Version.h @@ -39,7 +39,7 @@ All rights reserved. #define VERSION_MAJOR 0 #define VERSION_MINOR 3 #define VERSION_PATCH 0 -#define VERSION_BUILD 7204 +#define VERSION_BUILD 7211 #define stringify(a) stringify_(a) #define stringify_(a) #a diff --git a/x64/Release/Adventures in Lestoria.exe b/x64/Release/Adventures in Lestoria.exe index cf9d3da5..5408299c 100644 Binary files a/x64/Release/Adventures in Lestoria.exe and b/x64/Release/Adventures in Lestoria.exe differ