Added locked item sound effect. Fixed label member being protected accessible, now private requiring all children to access through SetLabel. Fix reversed logic check for locked craftable items. Added controller compatibility for consumable item crafting selection window. Release Build 7291.

This commit is contained in:
sigonasr2 2024-02-17 00:32:38 -06:00
parent fd994c580d
commit e5ace36a60
19 changed files with 129 additions and 37 deletions

View File

@ -43,6 +43,7 @@ All rights reserved.
#include "RowInventoryScrollableWindowComponent.h"
#include "EnhancementStatsLabel.h"
#include "RequiredMaterialsList.h"
#include "SoundEffect.h"
INCLUDE_game
INCLUDE_ITEM_CATEGORIES
@ -83,6 +84,7 @@ void Menu::InitializeBlacksmithCraftingWindow(){
}else{
data.menu.SetSelection(std::weak_ptr<MenuComponent>(Component<MenuComponent>(data.menu.GetType(),"Leave Button")));
}
SoundEffect::PlaySFX("Button Click",SoundEffect::CENTERED);
return true;
})END;
weaponTab->selected=true;
@ -98,6 +100,7 @@ void Menu::InitializeBlacksmithCraftingWindow(){
}else{
data.menu.SetSelection(std::weak_ptr<MenuComponent>(Component<MenuComponent>(data.menu.GetType(),"Leave Button")));
}
SoundEffect::PlaySFX("Button Click",SoundEffect::CENTERED);
return true;
})END;
armorTab->selectionType=SelectionType::HIGHLIGHT;
@ -237,8 +240,8 @@ void Menu::InitializeBlacksmithCraftingWindow(){
{game->KEY_BACK,{"Leave",[](MenuType type){
Menu::CloseMenu();
}}},
{{game->KEY_SCROLL,Pressed},{"Navigate",[](MenuType type){}}},
{game->KEY_CONFIRM,{"Select",[](MenuType type){}}},
{{game->KEY_SHOULDER,Pressed},{"Scroll Up/Down",[](MenuType type){}}},
{{game->KEY_FASTSCROLLDOWN,PressedDAS},{"",[&](MenuType type){
if(!Menu::menus[type]->GetSelection().expired()&&
!Menu::menus[type]->GetSelection().lock()->parentComponent.expired()){
@ -264,7 +267,7 @@ void Menu::InitializeBlacksmithCraftingWindow(){
Component<MenuComponent>(type,"Weapon Tab")->Click();
}
}}},
{{game->KEY_SCROLL,Pressed},{"Navigate",[](MenuType type){}}},
{{game->KEY_SHOULDER,Pressed},{"Scroll Up/Down",[](MenuType type){}}},
}
,{ //Button Navigation Rules
{"Weapon Tab",{

View File

@ -134,6 +134,7 @@ void Menu::InitializeBuyItemWindow(){
Component<MenuComponent>(type,"Increase buy amount Button")->Click();
}
}}},
{{game->KEY_SCROLL,Pressed},{"Navigate",[](MenuType type){}}},
{game->KEY_BACK,{"Back",[](MenuType type){
Menu::CloseMenu();
}}},

View File

@ -44,6 +44,7 @@ All rights reserved.
#include "RowInventoryScrollableWindowComponent.h"
#include "EnhancementStatsLabel.h"
#include "RequiredMaterialsList.h"
#include "SoundEffect.h"
INCLUDE_game
INCLUDE_ITEM_CATEGORIES
@ -53,8 +54,12 @@ INCLUDE_GFX
void Menu::InitializeConsumableCraftingWindow(){
Menu*consumableCraftingWindow=CreateMenu(CRAFT_CONSUMABLE,CENTERED,game->GetScreenSize()-vi2d{52,52});
float windowWidth=consumableCraftingWindow->size.x;
consumableCraftingWindow->ADD("Craft Consumables Header",MenuLabel)(geom2d::rect<float>{{0,0},{windowWidth,24}},"Consumable Crafting",2.f,ComponentAttr::BACKGROUND|ComponentAttr::SHADOW|ComponentAttr::OUTLINE)END;
#pragma region Craftables Inventory Display
auto craftingItemsDisplay=consumableCraftingWindow->ADD("Crafting Inventory Display",RowInventoryScrollableWindowComponent)(geom2d::rect<float>{{2,28},{220,consumableCraftingWindow->size.y-44}},"Item Name Label","Item Description Label",
auto craftingItemsDisplay=consumableCraftingWindow->ADD("Crafting Inventory Display",RowInventoryScrollableWindowComponent)(geom2d::rect<float>{{0,28},{222,consumableCraftingWindow->size.y-44}},"Item Name Label","Item Description Label",
[](MenuFuncData data){
std::weak_ptr<RowItemDisplay>comp=DYNAMIC_POINTER_CAST<RowItemDisplay>(data.component.lock());
const std::weak_ptr<Item>item=comp.lock()->GetItem();
@ -65,6 +70,8 @@ void Menu::InitializeConsumableCraftingWindow(){
Component<MenuComponent>(CONSUMABLE_CRAFT_ITEM,"Craft Button")->SetGrayedOut(!item.lock()->CanEnhanceItem());
if(item.lock()->GetEnhancementInfo()[0].chapterAvailable<=game->GetCurrentChapter()){
Menu::OpenMenu(CONSUMABLE_CRAFT_ITEM);
}else{
SoundEffect::PlaySFX("Locked Item",SoundEffect::CENTERED);
}
return true;
},
@ -83,7 +90,7 @@ void Menu::InitializeConsumableCraftingWindow(){
return true;
},
InventoryCreator::RowPlayerWeapons_InventoryUpdate,
InventoryWindowOptions{.padding=1,.size={207,28}}
InventoryWindowOptions{.padding=1,.size={209,28}}
)END;
craftingItemsDisplay->SetCompactDescriptions(CRAFTING_INFO);
@ -134,4 +141,78 @@ void Menu::InitializeConsumableCraftingWindow(){
Menu::CloseMenu();
return true;
},vf2d{2.f,2.f})END;
consumableCraftingWindow->SetupKeyboardNavigation(
[](MenuType type,Data&returnData){ //On Open
auto&craftingList=Component<RowInventoryScrollableWindowComponent>(type,"Crafting Inventory Display")->GetComponents();
if(craftingList.size()>0){
returnData=craftingList[0];
}else{
returnData="Back Button";
}
},
{ //Button Key
{{game->KEY_SHOULDER,Pressed},{"Scroll Up/Down",[](MenuType type){}}},
{{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_BACK,{"Back",[](MenuType type){
Menu::CloseMenu();
}}},
{game->KEY_CONFIRM,{"Select",[](MenuType type){}}},
}
,{ //Button Navigation Rules
{"Back Button",{
.up=[](MenuType type,Data&returnData){
auto&itemList=Component<RowInventoryScrollableWindowComponent>(type,"Crafting Inventory Display")->GetComponents();
if(itemList.size()>0){
returnData=itemList[itemList.size()-1];
}else{
returnData="Back Button";
}
},
.down=[](MenuType type,Data&returnData){
auto&itemList=Component<RowInventoryScrollableWindowComponent>(type,"Crafting Inventory Display")->GetComponents();
if(itemList.size()>0){
returnData=itemList[0];
}else{
returnData="Back Button";
}
},}},
{"Crafting Inventory Display",{
.up=[](MenuType type,Data&returnData){
auto itemDisplay=Component<RowInventoryScrollableWindowComponent>(type,"Crafting Inventory Display");
size_t selectedIndex=itemDisplay->GetComponentIndex(Menu::menus[type]->GetSelection());
if(selectedIndex!=itemDisplay->GetComponents().size()){
selectedIndex--;
if(selectedIndex>=itemDisplay->GetComponents().size()){
returnData="Back Button";
}else{
returnData=itemDisplay->GetComponents()[selectedIndex];
}
}else ERR("WARNING! Could not get selected item within crafting inventory display! THIS SHOULD NOT BE HAPPENING!")
},
.down=[](MenuType type,Data&returnData){
auto itemDisplay=Component<RowInventoryScrollableWindowComponent>(type,"Crafting Inventory Display");
size_t selectedIndex=itemDisplay->GetComponentIndex(Menu::menus[type]->GetSelection());
if(selectedIndex!=itemDisplay->GetComponents().size()){
selectedIndex++;
if(selectedIndex>=itemDisplay->GetComponents().size()){
returnData="Back Button";
}else{
returnData=itemDisplay->GetComponents()[selectedIndex];
}
}else ERR("WARNING! Could not get selected item within crafting inventory display! THIS SHOULD NOT BE HAPPENING!")
},}},
});
}

View File

@ -55,14 +55,14 @@ protected:
inline virtual void DrawDecal(ViewPort&window,bool focused)override final{
MenuComponent::DrawDecal(window,focused);
vf2d adjustedScale={scale,scale};
vf2d labelTextSize=vf2d(game->GetWrappedTextSizeProp(label,rect.size.x,adjustedScale));
vf2d labelTextSize=vf2d(game->GetWrappedTextSizeProp(GetLabel(),rect.size.x,adjustedScale));
if(fitToLabel){
float sizeRatio=((labelTextSize*adjustedScale).x)/(rect.size.x-2);
if(sizeRatio>1){
adjustedScale.x/=sizeRatio;
}
labelTextSize=vf2d(game->GetTextSizeProp(label)*adjustedScale);
labelTextSize=vf2d(game->GetTextSizeProp(GetLabel())*adjustedScale);
}
vf2d drawPos=rect.middle()-vf2d{labelTextSize}/2; //Assume centered.

View File

@ -74,7 +74,6 @@ void Menu::InitializeMainMenuWindow(){
}
},
{ //Button Key
{game->KEY_BACK,{"Back",[](MenuType type){}}},
{game->KEY_CONFIRM,{"Select",[](MenuType type){}}},
}
,{ //Button Navigation Rules

View File

@ -96,13 +96,13 @@ private:
SelectionType selectionType=CROSSHAIR;
bool disableOutsideWindow=false; //If set to true, this component was automatically set to not be renderable outside the window.
bool disable=false; //If set to true, this component will not be rendered or updated.
std::string label="";
protected:
int depth=0;
float hoverEffect=0;
std::string name="";
geom2d::rect<float>rect;
vf2d originalPos;
std::string label;
bool border=true;
bool draggable=false;
bool background=true;

View File

@ -67,7 +67,7 @@ public:
fitToLabel=attributes&ComponentAttr::FIT_TO_LABEL;
}
inline virtual void SetLabel(std::string text)override{
label=text;
MenuComponent::SetLabel(text);
if(runOnLabelChangeFunc)onLabelChangeFunc(text);
}
protected:
@ -79,14 +79,14 @@ protected:
vf2d adjustedScale={scale,scale};
vf2d labelTextSize=
proportional?
vf2d(game->GetWrappedTextSizeProp(label,rect.size.x-2,adjustedScale)):
vf2d(game->GetWrappedTextSize(label,rect.size.x-2,adjustedScale));
vf2d(game->GetWrappedTextSizeProp(GetLabel(),rect.size.x-2,adjustedScale)):
vf2d(game->GetWrappedTextSize(GetLabel(),rect.size.x-2,adjustedScale));
if(fitToLabel){
labelTextSize=
proportional?
vf2d(game->GetTextSizeProp(label)*adjustedScale):
vf2d(game->GetTextSize(label)*adjustedScale);
vf2d(game->GetTextSizeProp(GetLabel())*adjustedScale):
vf2d(game->GetTextSize(GetLabel())*adjustedScale);
float sizeRatio=(labelTextSize.x)/(rect.size.x-2);
if(sizeRatio>1){
adjustedScale.x/=sizeRatio;
@ -105,15 +105,15 @@ protected:
if(shadow){
if(proportional){
window.DrawShadowStringPropDecal(drawPos,label,WHITE,BLACK,adjustedScale,fitToLabel?std::numeric_limits<float>::max():rect.size.x-2,1.0f);
window.DrawShadowStringPropDecal(drawPos,GetLabel(),WHITE,BLACK,adjustedScale,fitToLabel?std::numeric_limits<float>::max():rect.size.x-2,1.0f);
}else{
window.DrawShadowStringDecal(drawPos,label,WHITE,BLACK,adjustedScale,fitToLabel?std::numeric_limits<float>::max():rect.size.x-2,1.0f);
window.DrawShadowStringDecal(drawPos,GetLabel(),WHITE,BLACK,adjustedScale,fitToLabel?std::numeric_limits<float>::max():rect.size.x-2,1.0f);
}
}else{
if(proportional){
window.DrawStringPropDecal(drawPos,label,WHITE,adjustedScale,fitToLabel?std::numeric_limits<float>::max():rect.size.x-2,1.0f);
window.DrawStringPropDecal(drawPos,GetLabel(),WHITE,adjustedScale,fitToLabel?std::numeric_limits<float>::max():rect.size.x-2,1.0f);
}else{
window.DrawStringDecal(drawPos,label,WHITE,adjustedScale,fitToLabel?std::numeric_limits<float>::max():rect.size.x-2,1.0f);
window.DrawStringDecal(drawPos,GetLabel(),WHITE,adjustedScale,fitToLabel?std::numeric_limits<float>::max():rect.size.x-2,1.0f);
}
}
}

View File

@ -41,7 +41,7 @@ enum MenuType{
///////////////////////////////////////////////////////////
/*DO NOT REMOVE!!*/ENUM_START,///////////////////////////////
///////////////////////////////////////////////////////////
// 60% Controller Compatibility. (100 total items, 4 items per menu * 25 menus)
// 64% 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
@ -57,7 +57,7 @@ enum MenuType{
SELL_ITEM, //100% Controller Compatibility
BLACKSMITH, //100% Controller Compatibility
CRAFT_ITEM, //100% Controller Compatibility
CRAFT_CONSUMABLE, //0% Controller Compatibility
CRAFT_CONSUMABLE, //100% Controller Compatibility
CONSUMABLE_CRAFT_ITEM, //0% Controller Compatibility
SAVE_FILE_NAME, //100% Controller Compatibility
LOAD_GAME, //75% Controller Compatibility - Online Mode Tab switching

View File

@ -58,10 +58,10 @@ protected:
MenuLabel::Update(game);
}
virtual void inline DrawDecal(ViewPort&window,bool focused)override{
if(label.length()>0){
vf2d drawPos=rect.middle()-vf2d{game->GetWrappedTextSizeProp(label,int(rect.size.x-1),scale)}*scale/2; //Assume centered.
if(GetLabel().length()>0){
vf2d drawPos=rect.middle()-vf2d{game->GetWrappedTextSizeProp(GetLabel(),int(rect.size.x-1),scale)}*scale/2; //Assume centered.
if(!centered){
drawPos=vf2d{rect.pos.x+2,rect.middle().y-game->GetWrappedTextSizeProp(label,int(rect.size.x-1),scale).y/2}; //We should at least vertically align here.
drawPos=vf2d{rect.pos.x+2,rect.middle().y-game->GetWrappedTextSizeProp(GetLabel(),int(rect.size.x-1),scale).y/2}; //We should at least vertically align here.
}
if(background){
window.FillRectDecal(rect.pos,rect.size,PixelLerp(Menu::themes[Menu::themeSelection].GetButtonCol(),Menu::themes[Menu::themeSelection].GetHighlightCol(),hoverEffect/"ThemeGlobal.HighlightTime"_F));
@ -70,12 +70,12 @@ protected:
window.DrawRectDecal(rect.pos,rect.size);
}
if(showDefaultLabel){
window.DrawStringPropDecal(rect.pos+rect.size/2-game->GetWrappedTextSizeProp(label,int(rect.size.x-1),scale)/2,label,WHITE,{1,1},int(rect.size.x-1));
window.DrawStringPropDecal(rect.pos+rect.size/2-game->GetWrappedTextSizeProp(GetLabel(),int(rect.size.x-1),scale)/2,GetLabel(),WHITE,{1,1},int(rect.size.x-1));
}
if(shadow){
window.DrawShadowStringPropDecal(drawPos,label,WHITE,BLACK,scale,int(rect.size.x-1));
window.DrawShadowStringPropDecal(drawPos,GetLabel(),WHITE,BLACK,scale,int(rect.size.x-1));
}else{
window.DrawStringPropDecal(drawPos,label,WHITE,scale,int(rect.size.x-1));
window.DrawStringPropDecal(drawPos,GetLabel(),WHITE,scale,int(rect.size.x-1));
}
}
}

View File

@ -59,14 +59,14 @@ protected:
inline virtual void DrawDecal(ViewPort&window,bool focused)override final{
MenuComponent::DrawDecal(window,focused);
vf2d adjustedScale={scale,scale};
vf2d labelTextSize=vf2d(game->GetWrappedTextSizeProp(label,rect.size.x,adjustedScale));
vf2d labelTextSize=vf2d(game->GetWrappedTextSizeProp(GetLabel(),rect.size.x,adjustedScale));
if(fitToLabel){
float sizeRatio=((labelTextSize*adjustedScale).x)/(rect.size.x-2);
if(sizeRatio>1){
adjustedScale.x/=sizeRatio;
}
labelTextSize=vf2d(game->GetTextSizeProp(label)*adjustedScale);
labelTextSize=vf2d(game->GetTextSizeProp(GetLabel())*adjustedScale);
}
if(itemRef.lock()->EnhancementIsPossible()){

View File

@ -80,7 +80,8 @@ public:
}
if(locked){
window.FillRectDecal(rect.pos+vf2d{1,1},rect.size-vf2d{1,1},BLACK);
Pixel col=PixelLerp(BLACK,VERY_DARK_GREY,hoverEffect/"ThemeGlobal.HighlightTime"_F);
window.FillRectDecal(rect.pos+vf2d{1,1},rect.size-vf2d{1,1},col);
}
float scaleFactor=(rect.size.y-4)/24;
@ -214,16 +215,16 @@ public:
labelNameText="";
labelDescriptionText="";
}
if(hideLabelWhileLocked&&itemRef.lock()->EnhancementIsPossible()&&itemRef.lock()->CanEnhanceItem()){
if(hideLabelWhileLocked&&itemRef.lock()->GetEnhancementInfo()[0].chapterAvailable>game->GetCurrentChapter()){
std::for_each(labelNameText.begin(),labelNameText.end(),[](char&c){if(c>='0'&&c<='z'){c='?';}});
std::for_each(labelDescriptionText.begin(),labelDescriptionText.end(),[](char&c){if(c>='0'&&c<='z'){c='?';}});
}
if(itemNameLabelName!=""){
Component<MenuLabel>(parentMenu,itemNameLabelName)->label=labelNameText;
Component<MenuLabel>(parentMenu,itemNameLabelName)->SetLabel(labelNameText);
Component<MenuLabel>(parentMenu,itemNameLabelName)->Enable();
}
if(itemDescriptionLabelName!=""){
Component<MenuLabel>(parentMenu,itemDescriptionLabelName)->label=labelDescriptionText;
Component<MenuLabel>(parentMenu,itemDescriptionLabelName)->SetLabel(labelDescriptionText);
Component<MenuLabel>(parentMenu,itemDescriptionLabelName)->Enable();
}
}

View File

@ -48,6 +48,6 @@ public:
inline void Update(AiL*game)override{
MenuComponent::Update(game);
label=SaveFile::GetSaveFileName();
SetLabel(std::string(SaveFile::GetSaveFileName()));
}
};

View File

@ -112,8 +112,8 @@ public:
backCol=DARK_GREY;
}
vf2d labelSize=game->GetTextSizeProp(label);
window.DrawShadowStringPropDecal(vf2d{rect.pos.x-8-labelSize.x,rect.pos.y+rect.size.y/2-labelSize.y/2},label);
vf2d labelSize=game->GetTextSizeProp(GetLabel());
window.DrawShadowStringPropDecal(vf2d{rect.pos.x-8-labelSize.x,rect.pos.y+rect.size.y/2-labelSize.y/2},GetLabel());
window.FillRectDecal(vf2d{rect.pos.x+4,rect.pos.y+rect.size.y/2-1}+vf2d{0.f,1.f},{rect.size.x-8,2},BLACK);
window.FillRectDecal(vf2d{rect.pos.x+4,rect.pos.y+rect.size.y/2-1},{rect.size.x-8,2});

View File

@ -36,3 +36,5 @@ January 31st
- Fullscreen toggle
- Condense stage track (loading times)
- If you enter the keyboard config menu and press a controller button, it cancels the request. If you enter the controller config menu and press a keyboard/mouse button, it also cancels the request.

View File

@ -79,7 +79,7 @@ public:
inline virtual void SetInput(std::string text){
game->TextEntrySetString(text);
label=text;
SetLabel(text);
if(runOnLabelChangeFunc)onLabelChangeFunc(text);
}

View File

@ -39,7 +39,7 @@ All rights reserved.
#define VERSION_MAJOR 0
#define VERSION_MINOR 3
#define VERSION_PATCH 0
#define VERSION_BUILD 7259
#define VERSION_BUILD 7291
#define stringify(a) stringify_(a)
#define stringify_(a) #a

View File

@ -78,6 +78,11 @@ Events
# Specify file names, followed by volume %. Optional min and max pitch adjustment (Defaults are 90%,110%)
File[0] = item_sell.ogg, 80%
}
Locked Item
{
# Specify file names, followed by volume %. Optional min and max pitch adjustment (Defaults are 90%,110%)
File[0] = lock.ogg, 100%
}
Enhance Item
{
# Specify file names, followed by volume %. Optional min and max pitch adjustment (Defaults are 90%,110%)

Binary file not shown.