Added dynamic labels for gamepad controls input helper. Fixed wrapping bug for pressing right on monster loot scrollable container. Added XP gain sound effect. Release Build 7112.

This commit is contained in:
2024-02-11 20:25:24 -06:00
parent 8afd66632a
commit bacd879e12
14 changed files with 192 additions and 35 deletions
+52 -17
View File
@@ -43,6 +43,7 @@ All rights reserved.
#include "Unlock.h"
#include "State_OverworldMap.h"
#include "ProgressBar.h"
#include "SoundEffect.h"
INCLUDE_game
@@ -97,22 +98,56 @@ void Menu::InitializeLevelCompleteWindow(){
}
},
{ //Button Key
{{game->KEY_SHOULDER,Pressed},{"Scroll",[](MenuType type){}}},
{{game->KEY_FASTSCROLLDOWN,PressedDAS,InputEngageGroup::NOT_VISIBLE},{"Scroll",[](MenuType type){
auto selection=Menu::menus[type]->GetSelection();
if(!selection.expired()){
auto parentComponent=DYNAMIC_POINTER_CAST<InventoryScrollableWindowComponent>(selection.lock()->parentComponent);
int invWidth=int((parentComponent->rect.size.x-12)/(float(parentComponent->options.size.x)+parentComponent->options.padding));
parentComponent->IncreaseSelectionIndex(invWidth*3.f);
{{game->KEY_SHOULDER,Pressed},{[](MenuFuncData data){
auto monsterLoot=Component<InventoryScrollableWindowComponent>(data.menu.GetType(),"Monster Loot Window");
auto stageLoot=Component<InventoryScrollableWindowComponent>(data.menu.GetType(),"Stage Loot Window");
if(!data.parentComponent.expired()){
if(data.parentComponent.lock()->GetName()=="Monster Loot Window"&&monsterLoot->GetComponents().size()>0){
return "Stage Loot";
}else
if(monsterLoot->GetComponents().size()>0){
return "Monster Loot";
}
}
return "";
},[](MenuType type){}}},
{{game->KEY_FASTSCROLLUP,Pressed},{"",[](MenuType type){
auto monsterLoot=Component<InventoryScrollableWindowComponent>(type,"Monster Loot Window");
auto stageLoot=Component<InventoryScrollableWindowComponent>(type,"Stage Loot Window");
auto selection=Menu::stack.back()->GetSelection();
if(!selection.expired()){
auto parent=selection.lock()->parentComponent;
if(!parent.expired()){
if(parent.lock()->GetName()=="Monster Loot Window"&&stageLoot->GetComponents().size()>0){
Menu::stack.back()->SetSelection(stageLoot->GetComponents()[0]);
SoundEffect::PlaySFX("Button Click",SoundEffect::CENTERED);
}else
if(monsterLoot->GetComponents().size()>0){
Menu::stack.back()->SetSelection(monsterLoot->GetComponents()[0]);
SoundEffect::PlaySFX("Button Click",SoundEffect::CENTERED);
}
}
}
return "";
}}},
{{game->KEY_FASTSCROLLUP,PressedDAS,InputEngageGroup::NOT_VISIBLE},{"Scroll",[](MenuType type){
auto selection=Menu::menus[type]->GetSelection();
{{game->KEY_FASTSCROLLDOWN,Pressed},{"",[](MenuType type){
auto monsterLoot=Component<InventoryScrollableWindowComponent>(type,"Monster Loot Window");
auto stageLoot=Component<InventoryScrollableWindowComponent>(type,"Stage Loot Window");
auto selection=Menu::stack.back()->GetSelection();
if(!selection.expired()){
auto parentComponent=DYNAMIC_POINTER_CAST<InventoryScrollableWindowComponent>(selection.lock()->parentComponent);
int invWidth=int((parentComponent->rect.size.x-12)/(float(parentComponent->options.size.x)+parentComponent->options.padding));
parentComponent->IncreaseSelectionIndex(invWidth*-3.f);
auto parent=selection.lock()->parentComponent;
if(!parent.expired()){
if(parent.lock()->GetName()=="Monster Loot Window"&&stageLoot->GetComponents().size()>0){
Menu::stack.back()->SetSelection(stageLoot->GetComponents()[0]);
SoundEffect::PlaySFX("Button Click",SoundEffect::CENTERED);
}else
if(monsterLoot->GetComponents().size()>0){
Menu::stack.back()->SetSelection(monsterLoot->GetComponents()[0]);
SoundEffect::PlaySFX("Button Click",SoundEffect::CENTERED);
}
}
}
return "";
}}},
{game->KEY_SCROLL,{"View Items",[](MenuType type){}}},
{game->KEY_START,{"Continue",[](MenuType type){
@@ -154,7 +189,7 @@ void Menu::InitializeLevelCompleteWindow(){
DetectInventory(InventoryScrollableWindowComponent,type,"Monster Loot Window")
{ //This means we have to wrap around. We have access to itemsList if we needed to point to a specific item in the inventory.
//By returning here, you are processing returnData yourself. Otherwise manipulate newRowIndex to point to an item in the itemsList when wrapping.
int colIndex=selectedButton.lock()->inventoryIndex; //Negative index, so we have to loop around.
int colIndex=selectedButton.lock()->inventoryIndex%invWidth; //Negative index, so we have to loop around.
//Get the base row index of the new inventory.
auto stageLootWindow=Component<InventoryScrollableWindowComponent>(type,"Stage Loot Window");
if(stageLootWindow->GetComponents().size()>0){
@@ -207,7 +242,7 @@ void Menu::InitializeLevelCompleteWindow(){
DetectInventory(InventoryScrollableWindowComponent,type,"Monster Loot Window")
{ //This means we have to wrap around. We have access to itemsList if we needed to point to a specific item in the inventory.
//By returning here, you are processing returnData yourself. Otherwise manipulate newRowIndex to point to an item in the itemsList when wrapping.
int colIndex=selectedButton.lock()->inventoryIndex;
int colIndex=selectedButton.lock()->inventoryIndex%invWidth;
//Get the base row index of the new inventory.
auto stageLootWindow=Component<InventoryScrollableWindowComponent>(type,"Stage Loot Window");
if(stageLootWindow->GetComponents().size()>0){
@@ -278,7 +313,7 @@ void Menu::InitializeLevelCompleteWindow(){
int rowBaseIndex=(selectedButton.lock()->inventoryIndex/invWidth)*invWidth; \
int newRowIndex=selectedButton.lock()->inventoryIndex+1; \
int newRowBaseIndex = (newRowIndex / invWidth) * invWidth; \
if(rowBaseIndex!=newRowBaseIndex)
if(rowBaseIndex!=newRowBaseIndex||newRowIndex>=itemsList.size())
#define DefaultBehavior \
newRowIndex=std::clamp(newRowIndex,0,int(itemsList.size()-1)); \
newRowIndex=std::min(int(itemsList.size())-1,newRowIndex); \
@@ -338,7 +373,7 @@ void Menu::InitializeLevelCompleteWindow(){
DetectInventory(InventoryScrollableWindowComponent,type,"Stage Loot Window")
{ //This means we have to wrap around. We have access to itemsList if we needed to point to a specific item in the inventory.
//By returning here, you are processing returnData yourself. Otherwise manipulate newRowIndex to point to an item in the itemsList when wrapping.
int colIndex=selectedButton.lock()->inventoryIndex;
int colIndex=selectedButton.lock()->inventoryIndex%invWidth;
//Get the base row index of the new inventory.
auto stageLootWindow=Component<InventoryScrollableWindowComponent>(type,"Monster Loot Window");
if(stageLootWindow->GetComponents().size()>0){
@@ -391,7 +426,7 @@ void Menu::InitializeLevelCompleteWindow(){
DetectInventory(InventoryScrollableWindowComponent,type,"Stage Loot Window")
{ //This means we have to wrap around. We have access to itemsList if we needed to point to a specific item in the inventory.
//By returning here, you are processing returnData yourself. Otherwise manipulate newRowIndex to point to an item in the itemsList when wrapping.
int colIndex=selectedButton.lock()->inventoryIndex;
int colIndex=selectedButton.lock()->inventoryIndex%invWidth;
//Get the base row index of the new inventory.
auto stageLootWindow=Component<InventoryScrollableWindowComponent>(type,"Monster Loot Window");
if(stageLootWindow->GetComponents().size()>0){