From 00e7a01ab1c5ca0aadd9222be0b5bc2bf2747334 Mon Sep 17 00:00:00 2001 From: Nic0Nic0Nii <89110903+Nic0Nic0Nii@users.noreply.github.com> Date: Tue, 30 Jan 2024 17:43:21 +0000 Subject: [PATCH] Add labels for items that can be crafted or enhanced at the blacksmith Co-authored-by: sigonasr2 --- Adventures in Lestoria/InventoryCreator.cpp | 14 +++++++++++--- Adventures in Lestoria/MenuComponent.cpp | 8 ++++---- Adventures in Lestoria/MenuComponent.h | 1 + Adventures in Lestoria/MenuLabel.h | 2 +- Adventures in Lestoria/RowItemDisplay.h | 16 +++++++++++++++- Adventures in Lestoria/TODO.txt | 1 + .../assets/config/items/items.txt | 12 ++++++++++++ 7 files changed, 45 insertions(+), 9 deletions(-) diff --git a/Adventures in Lestoria/InventoryCreator.cpp b/Adventures in Lestoria/InventoryCreator.cpp index 3a756eb0..6c65e452 100644 --- a/Adventures in Lestoria/InventoryCreator.cpp +++ b/Adventures in Lestoria/InventoryCreator.cpp @@ -30,7 +30,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -Portions of this software are copyright © 2023 The FreeType +Portions of this software are copyright � 2023 The FreeType Project (www.freetype.org). Please see LICENSE_FT.txt for more information. All rights reserved. */ @@ -161,7 +161,11 @@ std::function int itemIndex=y*invWidth+x; auto newItem=c->ADD("item_Weapon_"+std::to_string(itemIndex),RowItemDisplay)(geom2d::rect{totalSpacing*vf2d{float(x),float(y)},buttonSize},weapon,c->inventoryButtonClickAction,c->itemNameLabelName,c->itemDescriptionLabelName,c->inventoryButtonsActive?ButtonAttr::NONE:ButtonAttr::UNSELECTABLE)END; newItem->SetCompactDescriptions(c->compact); - newItem->SetPriceLabelType(c->priceLabel); + if(Inventory::GetItemCount(weapon.lock()->ActualName())==0){ //An item that is not in our inventory is considered craftable.. + newItem->SetPriceLabelType(PriceLabel::CRAFTABLE); + }else{ //Items that we do have are considered upgradeable. + newItem->SetPriceLabelType(PriceLabel::UPGRADEABLE); + } newItem->SetHoverFunc(c->inventoryButtonHoverAction); newItem->SetMouseOutFunc(c->inventoryButtonMouseOutAction); newItem->SetCheckCraftingRequirements(true); @@ -194,7 +198,11 @@ std::function int itemIndex=y*invWidth+x; auto newItem=c->ADD("item_Armor_"+std::to_string(itemIndex),RowItemDisplay)(geom2d::rect{totalSpacing*vf2d{float(x),float(y)},buttonSize},armor,c->inventoryButtonClickAction,c->itemNameLabelName,c->itemDescriptionLabelName,c->inventoryButtonsActive?ButtonAttr::NONE:ButtonAttr::UNSELECTABLE)END; newItem->SetCompactDescriptions(c->compact); - newItem->SetPriceLabelType(c->priceLabel); + if(Inventory::GetItemCount(armor.lock()->ActualName())==0){ //An item that is not in our inventory is considered craftable.. + newItem->SetPriceLabelType(PriceLabel::CRAFTABLE); + }else{ //Items that we do have are considered upgradeable. + newItem->SetPriceLabelType(PriceLabel::UPGRADEABLE); + } newItem->SetHoverFunc(c->inventoryButtonHoverAction); newItem->SetMouseOutFunc(c->inventoryButtonMouseOutAction); newItem->SetCheckCraftingRequirements(true); diff --git a/Adventures in Lestoria/MenuComponent.cpp b/Adventures in Lestoria/MenuComponent.cpp index 45fee3a7..751676aa 100644 --- a/Adventures in Lestoria/MenuComponent.cpp +++ b/Adventures in Lestoria/MenuComponent.cpp @@ -99,10 +99,10 @@ void MenuComponent::DrawDecal(ViewPort&window,bool focused){ window.FillRectDecal(rect.pos+V(A::DRAW_OFFSET),rect.size,PixelLerp(Menu::themes[Menu::themeSelection].GetButtonCol(),Menu::themes[Menu::themeSelection].GetHighlightCol(),util::lerp(0.75f,1.0f,hoverEffect/"ThemeGlobal.HighlightTime"_F))); } if(border){ - window.FillRectDecal(rect.pos+V(A::DRAW_OFFSET),{rect.size.x+1,1}); - window.FillRectDecal(rect.pos+V(A::DRAW_OFFSET),{1,rect.size.y+1}); - window.FillRectDecal(rect.pos+V(A::DRAW_OFFSET)+vf2d{rect.size.x-1+1,0},{1,rect.size.y+1}); - window.FillRectDecal(rect.pos+V(A::DRAW_OFFSET)+vf2d{0,rect.size.y-1+1},{rect.size.x+1,1}); + window.FillRectDecal(rect.pos+V(A::DRAW_OFFSET),{rect.size.x+1,1},borderCol); + window.FillRectDecal(rect.pos+V(A::DRAW_OFFSET),{1,rect.size.y+1},borderCol); + window.FillRectDecal(rect.pos+V(A::DRAW_OFFSET)+vf2d{rect.size.x-1+1,0},{1,rect.size.y+1},borderCol); + window.FillRectDecal(rect.pos+V(A::DRAW_OFFSET)+vf2d{0,rect.size.y-1+1},{rect.size.x+1,1},borderCol); } if(showDefaultLabel){ vf2d adjustedScale=labelScaling; diff --git a/Adventures in Lestoria/MenuComponent.h b/Adventures in Lestoria/MenuComponent.h index 3f41e1d0..d9aef0c5 100644 --- a/Adventures in Lestoria/MenuComponent.h +++ b/Adventures in Lestoria/MenuComponent.h @@ -114,6 +114,7 @@ protected: bool fitToLabel=false; //Will shrink text horizontally to fit the size of the label if the display text is too large. bool grayedOut=false; //If turned on, a button will appear grayed out and unresponsive. int inventoryIndex=0; + Pixel borderCol=WHITE; vf2d labelScaling={1,1}; virtual void Update(AiL*game); virtual void DrawDecal(ViewPort&window,bool focused); diff --git a/Adventures in Lestoria/MenuLabel.h b/Adventures in Lestoria/MenuLabel.h index c5c6361b..0aef4a4e 100644 --- a/Adventures in Lestoria/MenuLabel.h +++ b/Adventures in Lestoria/MenuLabel.h @@ -65,7 +65,7 @@ public: showDefaultLabel=false; fitToLabel=attributes&ComponentAttr::FIT_TO_LABEL; } - inline virtual void SetLabel(std::string text){ + inline virtual void SetLabel(std::string text)override{ label=text; if(runOnLabelChangeFunc)onLabelChangeFunc(text); } diff --git a/Adventures in Lestoria/RowItemDisplay.h b/Adventures in Lestoria/RowItemDisplay.h index 2733ae9b..0dc145de 100644 --- a/Adventures in Lestoria/RowItemDisplay.h +++ b/Adventures in Lestoria/RowItemDisplay.h @@ -116,9 +116,23 @@ public: } if(priceLabel!=PriceLabel::NONE){ + borderCol=WHITE; switch(priceLabel){ case PriceLabel::CRAFTABLE:{ - //An item can be crafted if we do not have it and we are on the correct chapter. + vf2d craftableTextSize=vf2d(game->GetTextSizeProp("Item.Craftable Item Text"_S))*vf2d{1.f,0.85f}; + window.DrawShadowStringPropDecal(rect.pos+vf2d{rect.size.x-craftableTextSize.x-1,3},"Item.Craftable Item Text"_S,"Item.Craftable Item Text Color"_Pixel,BLACK,{1.f,0.85f}); + borderCol=GREEN; + }break; + case PriceLabel::UPGRADEABLE:{ + if(!canEnhance&&fadeOutIfMissingRequirements){ + vf2d craftableTextSize=vf2d(game->GetTextSizeProp("Item.Missing Upgradeable Item Text"_S))*vf2d{1.f,0.85f}; + window.DrawShadowStringPropDecal(rect.pos+vf2d{rect.size.x-craftableTextSize.x-1,3},"Item.Missing Upgradeable Item Text"_S,"Item.Missing Upgradeable Item Text Color"_Pixel,BLACK,{1.f,0.85f}); + borderCol=GREY; + }else{ + vf2d craftableTextSize=vf2d(game->GetTextSizeProp("Item.Upgradeable Item Text"_S))*vf2d{1.f,0.85f}; + window.DrawShadowStringPropDecal(rect.pos+vf2d{rect.size.x-craftableTextSize.x-1,3},"Item.Upgradeable Item Text"_S,"Item.Upgradeable Item Text Color"_Pixel,BLACK,{1.f,0.85f}); + borderCol=YELLOW; + } }break; case PriceLabel::SELL_LABEL:{ std::string priceText=std::to_string(itemRef.lock()->SellValue()); diff --git a/Adventures in Lestoria/TODO.txt b/Adventures in Lestoria/TODO.txt index b969b03f..5e1a87a7 100644 --- a/Adventures in Lestoria/TODO.txt +++ b/Adventures in Lestoria/TODO.txt @@ -23,6 +23,7 @@ Settings Menu - Clamp bosses in boss arenas. - Track items used during a stage, on death, restore the loadout item quantities used. +- Stage Plate Navigation bugs January 31st ============ diff --git a/Adventures in Lestoria/assets/config/items/items.txt b/Adventures in Lestoria/assets/config/items/items.txt index ac3cb67c..9df79b19 100644 --- a/Adventures in Lestoria/assets/config/items/items.txt +++ b/Adventures in Lestoria/assets/config/items/items.txt @@ -15,6 +15,18 @@ Item Item Max Enhancement Level = 10 # The name of the currency in the game. Currency Name = Gold + # Text that displays when items are craftable in the Blacksmith. + Craftable Item Text = Can Craft + # Color of the text that displays when items are craftable in the Blacksmith. + Craftable Item Text Color = 0,255,0,255 + # Text that displays when items can be upgraded in the Blacksmith. + Upgradeable Item Text = Upgrade! + # Color of the text that displays when items can be upgraded in the Blacksmith. + Upgradeable Item Text Color = 255,255,0,255 + # Text that displays when items can be upgraded in the Blacksmith but the player doesn't have enough material. + Missing Upgradeable Item Text = Missing Materials + # Color of the text that displays when items can be upgraded in the Blacksmith but the player doesn't have enough material. + Missing Upgradeable Item Text Color = 192,0,0,255 } ItemDrop {