diff --git a/Adventures in Lestoria/ArtificerDisassembleWindow.cpp b/Adventures in Lestoria/ArtificerDisassembleWindow.cpp index 86e2ff6f..3482aa61 100644 --- a/Adventures in Lestoria/ArtificerDisassembleWindow.cpp +++ b/Adventures in Lestoria/ArtificerDisassembleWindow.cpp @@ -38,12 +38,43 @@ All rights reserved. #include "Menu.h" #include "AdventuresInLestoria.h" +#include "RowInventoryScrollableWindowComponent.h" +#include "InventoryCreator.h" +#include "MenuItemItemButton.h" +#include "RowItemDisplay.h" INCLUDE_game void Menu::InitializeArtificerDisassembleWindow(){ - Menu*artificerDisassembleWindow=CreateMenu(ARTIFICER_DISASSEMBLE,CENTERED,vi2d{144,144}); - + Menu*artificerDisassembleWindow=CreateMenu(ARTIFICER_DISASSEMBLE,CENTERED,game->GetScreenSize()-vi2d{52,52}); + + auto disassemblyTitleLabel{artificerDisassembleWindow->ADD("Disassembly Title Label",MenuLabel)(geom2d::rect{{},{artificerDisassembleWindow->size.x,24.f}},"Accessory Disassembly",2.f,ComponentAttr::SHADOW|ComponentAttr::OUTLINE|ComponentAttr::BACKGROUND)END}; + + auto inventoryLabel=artificerDisassembleWindow->ADD("Accessory List Label",MenuLabel)(geom2d::rect{{0.f,28.f},{180.f,12.f}},"Choose Accessory:",1.f,ComponentAttr::SHADOW|ComponentAttr::LEFT_ALIGN)END; + + auto inventoryDisplay=artificerDisassembleWindow->ADD("Accessory List",RowInventoryScrollableWindowComponent)(geom2d::rect{{0.f,44.f},{artificerDisassembleWindow->size.x/2-4.f,artificerDisassembleWindow->size.y-60}},"","",[](MenuFuncData data){ + return true; + },[](MenuFuncData data){ + RowItemDisplay&item{*DYNAMIC_POINTER_CAST(data.component)}; + Component(data.menu.type,"Item Icon")->SetItem(item.GetItem().lock()); + return true; + },DO_NOTHING, + InventoryCreator::RowPlayer_InventoryUpdate, + InventoryWindowOptions{.padding=1,.size={artificerDisassembleWindow->size.x/2-5.f-12.f,28}})END; + + auto itemIcon{artificerDisassembleWindow->ADD("Item Icon",MenuItemItemButton)(geom2d::rect({artificerDisassembleWindow->size.x/2+4.f,44.f},{48,48}),Item::BLANK,DO_NOTHING,"","Item Description",IconButtonAttr::NOT_SELECTABLE)END}; + itemIcon->SetIconScale({2.f,2.f}); + itemIcon->SetCompactDescriptions(true); + + auto accessoryDescription{artificerDisassembleWindow->ADD("Item Description",MenuLabel)(geom2d::rect({artificerDisassembleWindow->size.x/2+56.f,44.f},{artificerDisassembleWindow->size.x/2-56.f,72.f}),"",0.5f,ComponentAttr::BACKGROUND|ComponentAttr::OUTLINE|ComponentAttr::SHADOW|ComponentAttr::LEFT_ALIGN)END}; + + auto backButton=artificerDisassembleWindow->ADD("Back",MenuComponent)(geom2d::rect{{0.f,artificerDisassembleWindow->size.y-12.f},{96.f,16.f}},"Back",[](MenuFuncData data){ + Menu::CloseMenu(); + return true; + })END; + + Menu::AddInventoryListener(inventoryDisplay,"Accessories"); + artificerDisassembleWindow->SetupKeyboardNavigation( [](MenuType type,Data&returnData){ //On Open returnData=""; diff --git a/Adventures in Lestoria/Item.cpp b/Adventures in Lestoria/Item.cpp index 254c7513..3c5e9942 100644 --- a/Adventures in Lestoria/Item.cpp +++ b/Adventures in Lestoria/Item.cpp @@ -153,6 +153,7 @@ void ItemInfo::InitializeItems(){ std::unordered_setequippableClass; EventName useSound; std::optionalfragmentName; + std::optionalfragmentIcon; for(auto&[itemKey,itemValue]:data[key].GetKeys()){ std::string keyName=itemKey; if(keyName=="Description"){ @@ -204,6 +205,9 @@ void ItemInfo::InitializeItems(){ }else if(keyName.starts_with("Fragment Name")){ fragmentName=data[key][keyName].GetString(); + }else + if(keyName.starts_with("Fragment Icon")){ + fragmentIcon=data[key][keyName].GetString(); }else{ //THis is a custom override modifier for a script. NO-OP } } @@ -326,6 +330,7 @@ void ItemInfo::InitializeItems(){ it.minStats=minStats; it.maxStats=maxStats; it.fragmentName=fragmentName; + it.fragmentIcon=fragmentIcon; #pragma region Equipment Category Verification Tests int equipmentCategories=0; @@ -368,16 +373,24 @@ void ItemInfo::InitializeItems(){ ItemInfo&it{ITEM_DATA[fragmentName]}; GFX[fragmentName].Create(24,24); if(!game->TestingModeEnabled()){ - #pragma region Collect colors from source ring image - std::setcolors; - for(int y=0;y<24;y++){ - for(int x=0;x<24;x++){ - colors.insert(ITEM_DATA.at(itemName).img->sprite->GetPixel(x,y)); + if(it.FragmentIcon()){ + game->SetDrawTarget(GFX.at(fragmentName).Sprite()); + game->Clear(BLANK); + game->SetPixelMode(Pixel::ALPHA); + game->DrawSprite({},GFX.at(it.FragmentIcon().value()).Sprite()); + game->SetDrawTarget(nullptr); + GFX.at(fragmentName).Decal()->Update(); + }else{ + #pragma region Collect colors from source ring image + std::setcolors; + for(int y=0;y<24;y++){ + for(int x=0;x<24;x++){ + colors.insert(ITEM_DATA.at(itemName).img->sprite->GetPixel(x,y)); + } } - } - colors.erase(BLANK); - #pragma endregion - #pragma region Generate fragment with randomly sampled pixels from the source ring image + colors.erase(BLANK); + #pragma endregion + #pragma region Generate fragment with randomly sampled pixels from the source ring image game->SetDrawTarget(GFX.at(fragmentName).Sprite()); game->DrawSprite({},GFX.at("items/Fragment.png").Sprite(),1U,0U,[colors](const Pixel&in){ if(in==BLANK)return in; @@ -389,6 +402,7 @@ void ItemInfo::InitializeItems(){ game->SetDrawTarget(nullptr); GFX.at(fragmentName).Decal()->Update(); #pragma endregion + } } it.img=GFX.at(fragmentName).Decal(); it.name=fragmentName; @@ -1494,4 +1508,7 @@ const bool Item::SelectedEquipIsDifferent(const std::weak_ptrequipAttempti return &*equipAttemptingToEquip.lock()!=&*currentItem.lock(); } } +} +const std::optional&ItemInfo::FragmentIcon()const{ + return fragmentIcon; } \ No newline at end of file diff --git a/Adventures in Lestoria/Item.h b/Adventures in Lestoria/Item.h index ae936605..a4cfac6c 100644 --- a/Adventures in Lestoria/Item.h +++ b/Adventures in Lestoria/Item.h @@ -361,6 +361,7 @@ class ItemInfo{ Stats minStats; Stats maxStats; std::optionalfragmentName; + std::optionalfragmentIcon; private: static void InitializeScripts(); static void InitializeSets(); @@ -403,6 +404,7 @@ public: const std::unordered_set&GetClass()const; Stats RandomizeStats(); const std::string&FragmentName()const; + const std::optional&FragmentIcon()const; }; class ItemOverlay{ diff --git a/Adventures in Lestoria/MenuItemItemButton.h b/Adventures in Lestoria/MenuItemItemButton.h index e21d141a..ba96a122 100644 --- a/Adventures in Lestoria/MenuItemItemButton.h +++ b/Adventures in Lestoria/MenuItemItemButton.h @@ -75,6 +75,7 @@ public: } inline const std::weak_ptrSetItem(const std::weak_ptrnewItem,bool labelUpdate=true){ itemRef=newItem; + borderCol=newItem.lock()->HasEnchant()?newItem.lock()->GetEnchant().value().DisplayCol():WHITE; if(labelUpdate){ UpdateLabel(); } @@ -135,10 +136,12 @@ protected: } if(itemNameLabelName!=""){ Component(parentMenu,itemNameLabelName)->SetLabel(labelNameText); + Component(parentMenu,itemNameLabelName)->SetBorderCol(borderCol); Component(parentMenu,itemNameLabelName)->Enable(); } if(itemDescriptionLabelName!=""){ Component(parentMenu,itemDescriptionLabelName)->SetLabel(labelDescriptionText); + Component(parentMenu,itemDescriptionLabelName)->SetBorderCol(borderCol); Component(parentMenu,itemDescriptionLabelName)->Enable(); } } diff --git a/Adventures in Lestoria/MenuLabel.h b/Adventures in Lestoria/MenuLabel.h index f2e7bbf8..bf97afe0 100644 --- a/Adventures in Lestoria/MenuLabel.h +++ b/Adventures in Lestoria/MenuLabel.h @@ -81,6 +81,9 @@ public: CalculateWrappedLabel(); if(runOnLabelChangeFunc)onLabelChangeFunc(text); } + inline void SetBorderCol(const Pixel col){ + borderCol=col; + } protected: inline virtual void Update(AiL*game)override{ MenuComponent::Update(game); @@ -122,7 +125,7 @@ protected: if(shadow){ if(proportional){ for(int counter=0;const std::string_view&text:lines){ - window.DrawShadowStringPropDecal(rect.pos+vf2d{offsets[counter],counter*10.f},text,WHITE,BLACK); + window.DrawShadowStringPropDecal(rect.pos+vf2d{offsets[counter],counter*10.f},text,WHITE,BLACK,{scale,scale}); counter++; } }else{ @@ -131,7 +134,7 @@ protected: }else{ if(proportional){ for(int counter=0;const std::string_view&text:lines){ - window.DrawStringPropDecal(rect.pos+vf2d{offsets[counter],counter*10.f},text,WHITE); + window.DrawStringPropDecal(rect.pos+vf2d{offsets[counter],counter*10.f},text,WHITE,{scale,scale}); counter++; } }else{ @@ -159,7 +162,7 @@ private: if(multiLineCentered){ lines.clear(); offsets.clear(); - wrappedLabel=util::WrapText(game,GetLabel(),rect.size.x,true,{1.f,1.f}); + wrappedLabel=util::WrapText(game,GetLabel(),rect.size.x,true,{scale,scale}); int labelInd=0; float largestWidth=0; while(labelInd!=wrappedLabel.length()){ @@ -176,11 +179,11 @@ private: } } for(const std::string_view&text:lines){ - float width=game->GetTextSizeProp(text).x; + float width=game->GetTextSizeProp(text).x*scale; offsets.push_back(rect.size.x/2.f-width/2); } //Recalculate label height based on line count. - rect.size.y=lines.size()*10.f; + rect.size.y=lines.size()*10.f*scale; if(!parentComponent.expired()){ parentComponent.lock()->CalculateBounds(); } diff --git a/Adventures in Lestoria/RowItemDisplay.h b/Adventures in Lestoria/RowItemDisplay.h index c2171a69..a2ef3096 100644 --- a/Adventures in Lestoria/RowItemDisplay.h +++ b/Adventures in Lestoria/RowItemDisplay.h @@ -94,7 +94,7 @@ public: } window.DrawDecal(rect.pos+vf2d{2,2},const_cast(itemRef.lock()->Decal()),{scaleFactor,scaleFactor},tint); - window.DrawRectDecal(rect.pos+vf2d{2,2},iconSize); + window.DrawRectDecal(rect.pos+vf2d{2,2},iconSize,borderCol); #pragma region Item Name Display std::string itemName=itemRef.lock()->DisplayName(); @@ -119,8 +119,8 @@ public: window.DrawShadowStringPropDecal(rect.pos+rect.size-vf2d{1,1}+vf2d{-qtyTextSize.x,-qtyTextSize.y},quantityText,WHITE,BLACK,{qtyTextScale,qtyTextScale}); } + borderCol=itemRef.lock()->HasEnchant()?itemRef.lock()->GetEnchant().value().DisplayCol():WHITE; if(priceLabel!=PriceLabel::NONE){ - borderCol=WHITE; switch(priceLabel){ case PriceLabel::CRAFTABLE:{ if(!canEnhance&&fadeOutIfMissingRequirements){ diff --git a/Adventures in Lestoria/Version.h b/Adventures in Lestoria/Version.h index 41d9fd32..7e557bd4 100644 --- a/Adventures in Lestoria/Version.h +++ b/Adventures in Lestoria/Version.h @@ -39,7 +39,7 @@ All rights reserved. #define VERSION_MAJOR 1 #define VERSION_MINOR 2 #define VERSION_PATCH 5 -#define VERSION_BUILD 11362 +#define VERSION_BUILD 11382 #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 7315093c..9477709a 100644 Binary files a/x64/Release/Adventures in Lestoria.exe and b/x64/Release/Adventures in Lestoria.exe differ