Implemented equipment menu navigation (partially).
This commit is contained in:
parent
fd9fdc0924
commit
48ba282fa5
@ -267,6 +267,7 @@ void Menu::InitializeCharacterMenuWindow(){
|
||||
return true;
|
||||
},[](MenuFuncData data){//On Mouse Hover
|
||||
EquipSlot slot=DYNAMIC_POINTER_CAST<EquipSlotButton>(data.component.lock())->GetSlot();
|
||||
data.menu.I(A::ITEM_SLOT)=int(slot);
|
||||
const std::weak_ptr<Item>equip=Inventory::GetEquip(slot);
|
||||
if(!ISBLANK(equip)){
|
||||
Component<CharacterRotatingDisplay>(data.component.lock()->parentMenu,"Character Rotating Display")->Disable();
|
||||
@ -324,37 +325,98 @@ void Menu::InitializeCharacterMenuWindow(){
|
||||
{game->KEY_CONFIRM,{"Select",[](MenuType type){}}},
|
||||
}
|
||||
,{ //Button Navigation Rules
|
||||
{"Equip List",{}},
|
||||
{"Equip List",{
|
||||
.up=[](MenuType type,Data&returnData){
|
||||
if(!Menu::menus[type]->GetSelection().expired()){
|
||||
auto selection=Menu::menus[type]->GetSelection().lock();
|
||||
size_t index=Component<ScrollableWindowComponent>(type,"Equip List")->GetComponentIndex(selection);
|
||||
index=std::clamp(index-1,size_t(0),Component<ScrollableWindowComponent>(type,"Equip List")->GetComponents().size()-1);
|
||||
returnData=Component<ScrollableWindowComponent>(type,"Equip List")->GetComponents()[index];
|
||||
}
|
||||
},
|
||||
.down=[](MenuType type,Data&returnData){
|
||||
if(!Menu::menus[type]->GetSelection().expired()){
|
||||
auto selection=Menu::menus[type]->GetSelection().lock();
|
||||
size_t index=Component<ScrollableWindowComponent>(type,"Equip List")->GetComponentIndex(selection);
|
||||
index=std::clamp(index+1,size_t(0),Component<ScrollableWindowComponent>(type,"Equip List")->GetComponents().size()-1);
|
||||
returnData=Component<ScrollableWindowComponent>(type,"Equip List")->GetComponents()[index];
|
||||
}
|
||||
},
|
||||
.left=[](MenuType type,Data&returnData){
|
||||
auto equipList=Component<ScrollableWindowComponent>(type,"Equip List")->GetComponents();
|
||||
returnData=std::format("Equip Slot {}",slotNames[std::bit_width(unsigned(Menu::menus[type]->I(A::EQUIP_TYPE)))-1]);
|
||||
},
|
||||
.right=[](MenuType type,Data&returnData){
|
||||
auto equipList=Component<ScrollableWindowComponent>(type,"Equip List")->GetComponents();
|
||||
returnData=std::format("Equip Slot {}",slotNames[std::bit_width(unsigned(Menu::menus[type]->I(A::EQUIP_TYPE)))-1]);
|
||||
}
|
||||
}},
|
||||
{"Equip Selection Select Button",{
|
||||
.up=[](MenuType type,Data&returnData){
|
||||
auto equipList=Component<ScrollableWindowComponent>(type,"Equip List")->GetComponents();
|
||||
returnData="Equip Selection Select Button";
|
||||
if(equipList.size()>0){
|
||||
returnData=equipList.back();
|
||||
}
|
||||
},
|
||||
.down=[](MenuType type,Data&returnData){
|
||||
auto equipList=Component<ScrollableWindowComponent>(type,"Equip List")->GetComponents();
|
||||
returnData="Equip Selection Select Button";
|
||||
if(equipList.size()>0){
|
||||
returnData=equipList.front();
|
||||
}
|
||||
},
|
||||
.left=[](MenuType type,Data&returnData){
|
||||
auto equipList=Component<ScrollableWindowComponent>(type,"Equip List")->GetComponents();
|
||||
returnData=std::format("Equip Slot {}",slotNames[std::bit_width(unsigned(Menu::menus[type]->I(A::EQUIP_TYPE)))-1]);
|
||||
},
|
||||
.right=[](MenuType type,Data&returnData){
|
||||
auto equipList=Component<ScrollableWindowComponent>(type,"Equip List")->GetComponents();
|
||||
returnData=std::format("Equip Slot {}",slotNames[std::bit_width(unsigned(Menu::menus[type]->I(A::EQUIP_TYPE)))-1]);
|
||||
}
|
||||
}},
|
||||
{std::format("Equip Slot {}", slotNames[0]),{
|
||||
.up="Back button",
|
||||
.down=std::format("Equip Slot {}", slotNames[2]),
|
||||
.left=std::format("Equip Slot {}", slotNames[1]),
|
||||
.left=[](MenuType type,Data&returnData){
|
||||
Menu::menus[type]->SetSelection(Component<ScrollableWindowComponent>(type,"Equip List")->GetComponents()[std::bit_width(unsigned(Menu::menus[type]->I(A::ITEM_SLOT)))-1]);
|
||||
},
|
||||
.right=std::format("Equip Slot {}", slotNames[1]),}},
|
||||
{std::format("Equip Slot {}", slotNames[1]),{
|
||||
.up="Back button",
|
||||
.down=std::format("Equip Slot {}", slotNames[3]),
|
||||
.left=std::format("Equip Slot {}", slotNames[0]),
|
||||
.right=std::format("Equip Slot {}", slotNames[0]),}},
|
||||
.right=[](MenuType type,Data&returnData){
|
||||
Menu::menus[type]->SetSelection(Component<ScrollableWindowComponent>(type,"Equip List")->GetComponents()[std::bit_width(unsigned(Menu::menus[type]->I(A::ITEM_SLOT)))-1]);
|
||||
},}},
|
||||
{std::format("Equip Slot {}", slotNames[2]),{
|
||||
.up=std::format("Equip Slot {}", slotNames[0]),
|
||||
.down=std::format("Equip Slot {}", slotNames[4]),
|
||||
.left=std::format("Equip Slot {}", slotNames[3]),
|
||||
.left=[](MenuType type,Data&returnData){
|
||||
Menu::menus[type]->SetSelection(Component<ScrollableWindowComponent>(type,"Equip List")->GetComponents()[std::bit_width(unsigned(Menu::menus[type]->I(A::ITEM_SLOT)))-1]);
|
||||
},
|
||||
.right=std::format("Equip Slot {}", slotNames[3]),}},
|
||||
{std::format("Equip Slot {}", slotNames[3]),{
|
||||
.up=std::format("Equip Slot {}", slotNames[1]),
|
||||
.down=std::format("Equip Slot {}", slotNames[5]),
|
||||
.left=std::format("Equip Slot {}", slotNames[2]),
|
||||
.right=std::format("Equip Slot {}", slotNames[2]),}},
|
||||
.right=[](MenuType type,Data&returnData){
|
||||
Menu::menus[type]->SetSelection(Component<ScrollableWindowComponent>(type,"Equip List")->GetComponents()[std::bit_width(unsigned(Menu::menus[type]->I(A::ITEM_SLOT)))-1]);
|
||||
},}},
|
||||
{std::format("Equip Slot {}", slotNames[4]),{
|
||||
.up=std::format("Equip Slot {}", slotNames[2]),
|
||||
.down=std::format("Equip Slot {}", slotNames[6]),
|
||||
.left=std::format("Equip Slot {}", slotNames[5]),
|
||||
.left=[](MenuType type,Data&returnData){
|
||||
Menu::menus[type]->SetSelection(Component<ScrollableWindowComponent>(type,"Equip List")->GetComponents()[std::bit_width(unsigned(Menu::menus[type]->I(A::ITEM_SLOT)))-1]);
|
||||
},
|
||||
.right=std::format("Equip Slot {}", slotNames[5]),}},
|
||||
{std::format("Equip Slot {}", slotNames[5]),{
|
||||
.up=std::format("Equip Slot {}", slotNames[3]),
|
||||
.down=std::format("Equip Slot {}", slotNames[7]),
|
||||
.left=std::format("Equip Slot {}", slotNames[4]),
|
||||
.right=std::format("Equip Slot {}", slotNames[4]),}},
|
||||
.right=[](MenuType type,Data&returnData){
|
||||
std::format("Equip Slot {}", slotNames[4]);
|
||||
},}},
|
||||
{std::format("Equip Slot {}", slotNames[6]),{
|
||||
.up=std::format("Equip Slot {}", slotNames[4]),
|
||||
.down="Back button",
|
||||
@ -363,12 +425,16 @@ void Menu::InitializeCharacterMenuWindow(){
|
||||
{std::format("Equip Slot {}", slotNames[7]),{
|
||||
.up=std::format("Equip Slot {}", slotNames[5]),
|
||||
.down="Back button",
|
||||
.left=std::format("Equip Slot {}", slotNames[6]),
|
||||
.left=[](MenuType type,Data&returnData){
|
||||
Menu::menus[type]->SetSelection(Component<ScrollableWindowComponent>(type,"Equip List")->GetComponents()[std::bit_width(unsigned(Menu::menus[type]->I(A::ITEM_SLOT)))-1]);
|
||||
},
|
||||
.right=std::format("Equip Slot {}", slotNames[6]),}},
|
||||
{"Back button",{
|
||||
.up=std::format("Equip Slot {}", slotNames[7]),
|
||||
.down=std::format("Equip Slot {}", slotNames[0]),
|
||||
.left=std::format("Equip Slot {}", slotNames[7]),
|
||||
.right=std::format("Equip Slot {}", slotNames[6]),}},
|
||||
.right=[](MenuType type,Data&returnData){
|
||||
Menu::menus[type]->SetSelection(Component<ScrollableWindowComponent>(type,"Equip List")->GetComponents()[std::bit_width(unsigned(Menu::menus[type]->I(A::ITEM_SLOT)))-1]);
|
||||
},}},
|
||||
});
|
||||
}
|
@ -45,6 +45,7 @@ All rights reserved.
|
||||
#include "RowInventoryScrollableWindowComponent.h"
|
||||
#include "MenuItemItemButton.h"
|
||||
#include <variant>
|
||||
#include "SoundEffect.h"
|
||||
|
||||
INCLUDE_ITEM_CATEGORIES
|
||||
INCLUDE_DATA
|
||||
@ -64,6 +65,7 @@ MenuType Menu::lastMenuTypeCreated;
|
||||
std::string Menu::lastRegisteredComponent;
|
||||
bool Menu::alreadyClicked=false;
|
||||
bool Menu::scrolling=false;
|
||||
std::weak_ptr<MenuComponent>Menu::lastHover;
|
||||
|
||||
INCLUDE_game
|
||||
INCLUDE_GFX
|
||||
@ -152,6 +154,7 @@ void Menu::MenuSelect(AiL*game){
|
||||
if(buttonStillValid){
|
||||
if(selection.lock()->menuDest!=MenuType::ENUM_END){
|
||||
if(stack.size()<MAX_MENUS){
|
||||
SoundEffect::PlaySFX("Menu Select",SoundEffect::CENTERED);
|
||||
Menu::OpenMenu(selection.lock()->menuDest); //Navigate to the next menu.
|
||||
}else{
|
||||
ERR("WARNING! Exceeded menu stack size limit!")
|
||||
@ -188,6 +191,8 @@ void Menu::Update(AiL*game){
|
||||
if(component->selectable){
|
||||
if(!component->disable&&!component->disableOutsideWindow&&!component->grayedOut){
|
||||
if(component->GetHoverState(game)){
|
||||
if(!Menu::lastHover.expired()&&&*component!=&*Menu::lastHover.lock())SoundEffect::PlaySFX("Menu Navigate",SoundEffect::CENTERED);
|
||||
Menu::lastHover=component;
|
||||
component->hovered=true;
|
||||
itemHovered=true;
|
||||
SetSelection(std::weak_ptr<MenuComponent>(component));
|
||||
@ -356,6 +361,7 @@ void Menu::KeyboardButtonNavigation(AiL*game,vf2d menuPos){
|
||||
if(navigationGroups.count(selectionButtonName)){
|
||||
Navigation nav=navigationGroups[selectionButtonName];
|
||||
if(game->KEY_UP.PressedDAS()||game->KEY_SCROLLUP.AnalogDAS(0.5f)<-0.5f){
|
||||
SoundEffect::PlaySFX("Menu Navigate",SoundEffect::CENTERED);
|
||||
SetMouseNavigation(false);
|
||||
if(std::holds_alternative<std::string>(nav.up)&&std::get<std::string>(nav.up).length()>0)SetSelection(std::string_view(std::get<std::string>(nav.up)));
|
||||
else
|
||||
@ -366,6 +372,7 @@ void Menu::KeyboardButtonNavigation(AiL*game,vf2d menuPos){
|
||||
}
|
||||
}
|
||||
if(game->KEY_DOWN.PressedDAS()||game->KEY_SCROLLDOWN.AnalogDAS(0.5f)>0.5f){
|
||||
SoundEffect::PlaySFX("Menu Navigate",SoundEffect::CENTERED);
|
||||
SetMouseNavigation(false);
|
||||
if(std::holds_alternative<std::string>(nav.down)&&std::get<std::string>(nav.down).length()>0)SetSelection(std::string_view(std::get<std::string>(nav.down)));
|
||||
else
|
||||
@ -376,6 +383,7 @@ void Menu::KeyboardButtonNavigation(AiL*game,vf2d menuPos){
|
||||
}
|
||||
}
|
||||
if(game->KEY_LEFT.PressedDAS()||game->KEY_SCROLLLEFT.AnalogDAS(0.5f)<-0.5f){
|
||||
SoundEffect::PlaySFX("Menu Navigate",SoundEffect::CENTERED);
|
||||
SetMouseNavigation(false);
|
||||
if(std::holds_alternative<std::string>(nav.left)&&std::get<std::string>(nav.left).length()>0)SetSelection(std::string_view(std::get<std::string>(nav.left)));
|
||||
else
|
||||
@ -386,6 +394,7 @@ void Menu::KeyboardButtonNavigation(AiL*game,vf2d menuPos){
|
||||
}
|
||||
}
|
||||
if(game->KEY_RIGHT.PressedDAS()||game->KEY_SCROLLRIGHT.AnalogDAS(0.5f)>0.5f){
|
||||
SoundEffect::PlaySFX("Menu Navigate",SoundEffect::CENTERED);
|
||||
SetMouseNavigation(false);
|
||||
if(std::holds_alternative<std::string>(nav.right)&&std::get<std::string>(nav.right).length()>0)SetSelection(std::string_view(std::get<std::string>(nav.right)));
|
||||
else
|
||||
|
@ -228,6 +228,7 @@ private:
|
||||
InputHelper helpDisplay;
|
||||
|
||||
static bool MOUSE_NAVIGATION;
|
||||
static std::weak_ptr<MenuComponent>lastHover;
|
||||
bool cover; //A black cover for when a menu pops up to fade out the stuff behind it.
|
||||
};
|
||||
|
||||
|
@ -41,7 +41,7 @@ enum MenuType{
|
||||
///////////////////////////////////////////////////////////
|
||||
/*DO NOT REMOVE!!*/ENUM_START,///////////////////////////////
|
||||
///////////////////////////////////////////////////////////
|
||||
// 32% Controller Compatibility. (100 total items, 4 items per menu * 25 menus)
|
||||
// 34% 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
|
||||
@ -50,7 +50,7 @@ enum MenuType{
|
||||
ITEM_LOADOUT, //100% Controller Compatibility
|
||||
LEVEL_COMPLETE, //100% Controller Compatibility
|
||||
OVERWORLD_MENU, //100% Controller Compatibility
|
||||
CHARACTER_MENU, //0% Controller Compatibility
|
||||
CHARACTER_MENU, //50% Controller Compatibility
|
||||
INVENTORY, //0% Controller Compatibility
|
||||
MERCHANT, //0% Controller Compatibility
|
||||
BUY_ITEM, //0% Controller Compatibility
|
||||
|
@ -97,4 +97,5 @@ enum class Attribute{
|
||||
LAST_SFX_VOLUME,
|
||||
IS_KEYBOARD,
|
||||
KEYBIND,
|
||||
ITEM_SLOT,
|
||||
};
|
@ -39,7 +39,7 @@ All rights reserved.
|
||||
#define VERSION_MAJOR 0
|
||||
#define VERSION_MINOR 3
|
||||
#define VERSION_PATCH 0
|
||||
#define VERSION_BUILD 7162
|
||||
#define VERSION_BUILD 7167
|
||||
|
||||
#define stringify(a) stringify_(a)
|
||||
#define stringify_(a) #a
|
||||
|
@ -93,6 +93,18 @@ Events
|
||||
# Specify file names, followed by volume %. Optional min and max pitch adjustment (Defaults are 90%,110%)
|
||||
File[0] = levelup.ogg, 100%
|
||||
}
|
||||
Menu Navigate
|
||||
{
|
||||
# Muted for now.
|
||||
# Specify file names, followed by volume %. Optional min and max pitch adjustment (Defaults are 90%,110%)
|
||||
File[0] = menu_navigate.ogg, 0%, 60%, 100%
|
||||
}
|
||||
Menu Select
|
||||
{
|
||||
# Muted for now.
|
||||
# Specify file names, followed by volume %. Optional min and max pitch adjustment (Defaults are 90%,110%)
|
||||
File[0] = menu_navigate.ogg, 0%
|
||||
}
|
||||
Monster Hurt
|
||||
{
|
||||
# Specify file names, followed by volume %. Optional min and max pitch adjustment (Defaults are 90%,110%)
|
||||
|
BIN
Adventures in Lestoria/assets/sounds/menu_navigate.ogg
Normal file
BIN
Adventures in Lestoria/assets/sounds/menu_navigate.ogg
Normal file
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user