diff --git a/Adventures in Lestoria Tests/ItemTests.cpp b/Adventures in Lestoria Tests/ItemTests.cpp index 11ee3a96..8e225bf2 100644 --- a/Adventures in Lestoria Tests/ItemTests.cpp +++ b/Adventures in Lestoria Tests/ItemTests.cpp @@ -291,5 +291,10 @@ namespace ItemTests Test::InRange(enchantCounts[ItemEnchantInfo::ItemEnchantCategory::CLASS],{350U,450U},util::wformat("Class enchants % is approx 40%.")); Test::InRange(enchantCounts[ItemEnchantInfo::ItemEnchantCategory::UNIQUE],{50U,150U},util::wformat("Unique enchants % is approx 40%.")); } + TEST_METHOD(EnchantColorTest){ + Assert::AreEqual("Item Enchants.General Enchants.Enchant Display Color"_Pixel.n,ItemEnchantInfo::GetEnchant("Health Boost").DisplayCol().n,L"Expecting a general enchant to have the general enchant pixel display color."); + Assert::AreEqual("Item Enchants.Class Enchants.Enchant Display Color"_Pixel.n,ItemEnchantInfo::GetEnchant("Quickdraw").DisplayCol().n,L"Expecting a class enchant to have the class enchant pixel display color."); + Assert::AreEqual("Item Enchants.Unique Enchants.Enchant Display Color"_Pixel.n,ItemEnchantInfo::GetEnchant("Magical Protection").DisplayCol().n,L"Expecting a unique enchant to have the unique enchant pixel display color."); + } }; } diff --git a/Adventures in Lestoria/ArtificerEnchantWindow.cpp b/Adventures in Lestoria/ArtificerEnchantWindow.cpp index eeab6d3d..26a4d7e4 100644 --- a/Adventures in Lestoria/ArtificerEnchantWindow.cpp +++ b/Adventures in Lestoria/ArtificerEnchantWindow.cpp @@ -66,6 +66,11 @@ void Menu::InitializeArtificerEnchantWindow(){ const auto EnableRefineDisplay{[artificerEnchantWindow](){ MenuType menuType{artificerEnchantWindow->GetType()}; const std::weak_ptr&selectedItem{Component(menuType,"Item Icon")->GetItem()}; + std::vectoravailableEnchants{ItemEnchant::GetAvailableEnchants()}; + std::string enchantList{std::accumulate(availableEnchants.begin(),availableEnchants.end(),""s,[](const std::string&acc,const ItemEnchantInfo&enchant){ + return std::format("{}{}{}#FFFFFF\n",acc,enchant.DisplayCol().toHTMLColorCode(),enchant.Name()); + })}; + Component(menuType,"Enchant List")->SetLabel(enchantList); }}; auto inventoryDisplay{artificerEnchantWindow->ADD("Accessory List",RowInventoryScrollableWindowComponent)(geom2d::rect{{0.f,28.f},{artificerEnchantWindow->size.x/2-4.f,artificerEnchantWindow->size.y-44}},"","",[](MenuFuncData data){ @@ -94,6 +99,7 @@ void Menu::InitializeArtificerEnchantWindow(){ auto enchantListHeaderLabel{artificerEnchantWindow->ADD("Enchant List Header",MenuLabel)(geom2d::rect{{artificerEnchantWindow->size.x/2+4.f,92.f},{artificerEnchantWindow->size.x/2+12.f,12.f}},"Possible Enchantments:",1.f,ComponentAttr::FIT_TO_LABEL|ComponentAttr::BACKGROUND|ComponentAttr::OUTLINE|ComponentAttr::SHADOW)END}; auto enchantContainer{artificerEnchantWindow->ADD("Enchant Container",ScrollableWindowComponent)(geom2d::rect{{artificerEnchantWindow->size.x/2+4.f,104.f},{artificerEnchantWindow->size.x/2+12.f,44.f}})END}; + auto enchantList{enchantContainer->ADD("Enchant List",MenuLabel)(geom2d::rect{{0.f,2.f},{enchantContainer->GetSize().x-12.f,0.f}},"",1.f,ComponentAttr::CENTER|ComponentAttr::SHADOW)END}; auto enchantCostLabel{artificerEnchantWindow->ADD("Enchant Cost Label",MenuLabel)(geom2d::rect{{artificerEnchantWindow->size.x/2+4.f,152.f},{64.f,20.f}},"Enchant Cost:",1.f,ComponentAttr::SHADOW|ComponentAttr::BACKGROUND|ComponentAttr::OUTLINE)END}; diff --git a/Adventures in Lestoria/ItemEnchant.cpp b/Adventures in Lestoria/ItemEnchant.cpp index a6a03428..a26ee179 100644 --- a/Adventures in Lestoria/ItemEnchant.cpp +++ b/Adventures in Lestoria/ItemEnchant.cpp @@ -52,6 +52,7 @@ INCLUDE_DATA const Pixel ItemEnchantInfo::enchantAttributeCol{0x00DFE2}; std::unordered_mapItemEnchantInfo::ENCHANT_LIST; std::unordered_mapItemEnchantInfo::ENCHANT_CATEGORIES; +std::unordered_mapItemEnchantInfo::enchantTextDisplayCol; const ItemEnchantInfo&operator ""_ENC(const char*key,std::size_t len){ return ItemEnchantInfo::GetEnchant(std::string(key)); @@ -79,6 +80,8 @@ void ItemEnchantInfo::Initialize(){ enchantCategory=ItemEnchantCategory::UNIQUE; }else ERR(std::format("WARNING! Enchant type {} is not supported! THIS SHOULD NOT BE HAPPENING! Please check ItemEnchants.txt",key)); + enchantTextDisplayCol[enchantCategory]=DATA["Item Enchants"][key]["Enchant Display Color"].GetPixel(); + datafile&enchantData=DATA["Item Enchants"][key]; ItemEnchantCategoryData categoryData; @@ -290,7 +293,7 @@ std::map::const_iterator ItemEnchant::end()const{ } const Pixel&ItemEnchant::DisplayCol()const{ - return ItemEnchantInfo::GetEnchant(Name()).enchantAttributeCol; + return ItemEnchantInfo::enchantTextDisplayCol.at(Category()); } const std::optional&ItemEnchantInfo::GetAbilitySlot()const{ @@ -321,4 +324,8 @@ const std::optionalItemEnchantInfo::GetAbility()const{ const std::optional>ItemEnchant::Ability()const{ if(GetEnchantInfo().GetAbility())return **GetEnchantInfo().GetAbility(); return {}; +} + +const Pixel&ItemEnchantInfo::DisplayCol()const{ + return ItemEnchantInfo::enchantTextDisplayCol.at(Category()); } \ No newline at end of file diff --git a/Adventures in Lestoria/ItemEnchant.h b/Adventures in Lestoria/ItemEnchant.h index 3f072673..25fe0320 100644 --- a/Adventures in Lestoria/ItemEnchant.h +++ b/Adventures in Lestoria/ItemEnchant.h @@ -69,6 +69,7 @@ public: static void Initialize(); const static ItemEnchantInfo&GetEnchant(const std::string_view enchantName); const static std::unordered_map&GetEnchants(); + static std::unordered_mapenchantTextDisplayCol; const std::string Name(TextStyle style=TextStyle::NORMAL)const; const std::string_view Description()const; @@ -76,6 +77,7 @@ public: const std::optional&GetClass()const; const std::optional&GetAbilitySlot()const; const std::optionalGetAbility()const; //Get the ability this enchant is tied to. + const Pixel&DisplayCol()const; const float GetConfigValue(const std::string_view keyName)const; const float operator[](const std::string&name)const; private: diff --git a/Adventures in Lestoria/ScrollableWindowComponent.h b/Adventures in Lestoria/ScrollableWindowComponent.h index 1c74a0aa..41bfadd9 100644 --- a/Adventures in Lestoria/ScrollableWindowComponent.h +++ b/Adventures in Lestoria/ScrollableWindowComponent.h @@ -223,7 +223,7 @@ protected: } } - if(game->GetMouseWheel()!=0){ + if(game->GetMouseWheel()!=0&&geom2d::overlaps(game->GetMousePos(),geom2d::rect{windowAbsPos,rect.size})){ if(game->GetMouseWheel()>0){ SetScrollAmount(GetTargetScrollAmount()+vf2d{0,"ThemeGlobal.MenuScrollWheelSpeed"_F}); }else{ diff --git a/Adventures in Lestoria/Version.h b/Adventures in Lestoria/Version.h index 26fdb3d9..0d1f8c99 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 11497 +#define VERSION_BUILD 11508 #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 0a5990af..9c205c98 100644 Binary files a/x64/Release/Adventures in Lestoria.exe and b/x64/Release/Adventures in Lestoria.exe differ