Add in basic setup for Artificer Disassembly menu. Release Build 11382.

pull/65/head
sigonasr2 3 months ago
parent ef5239657d
commit ac934eead5
  1. 35
      Adventures in Lestoria/ArtificerDisassembleWindow.cpp
  2. 35
      Adventures in Lestoria/Item.cpp
  3. 2
      Adventures in Lestoria/Item.h
  4. 3
      Adventures in Lestoria/MenuItemItemButton.h
  5. 13
      Adventures in Lestoria/MenuLabel.h
  6. 4
      Adventures in Lestoria/RowItemDisplay.h
  7. 2
      Adventures in Lestoria/Version.h
  8. BIN
      x64/Release/Adventures in Lestoria.exe

@ -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<float>{{},{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<float>{{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<float>{{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<RowItemDisplay>(data.component)};
Component<MenuItemItemButton>(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<float>({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<float>({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<float>{{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="";

@ -153,6 +153,7 @@ void ItemInfo::InitializeItems(){
std::unordered_set<std::string>equippableClass;
EventName useSound;
std::optional<std::string>fragmentName;
std::optional<std::string>fragmentIcon;
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::set<Pixel>colors;
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::set<Pixel>colors;
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_ptr<Item>equipAttempti
return &*equipAttemptingToEquip.lock()!=&*currentItem.lock();
}
}
}
const std::optional<std::string>&ItemInfo::FragmentIcon()const{
return fragmentIcon;
}

@ -361,6 +361,7 @@ class ItemInfo{
Stats minStats;
Stats maxStats;
std::optional<std::string>fragmentName;
std::optional<std::string>fragmentIcon;
private:
static void InitializeScripts();
static void InitializeSets();
@ -403,6 +404,7 @@ public:
const std::unordered_set<std::string>&GetClass()const;
Stats RandomizeStats();
const std::string&FragmentName()const;
const std::optional<std::string>&FragmentIcon()const;
};
class ItemOverlay{

@ -75,6 +75,7 @@ public:
}
inline const std::weak_ptr<Item>SetItem(const std::weak_ptr<Item>newItem,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<MenuLabel>(parentMenu,itemNameLabelName)->SetLabel(labelNameText);
Component<MenuLabel>(parentMenu,itemNameLabelName)->SetBorderCol(borderCol);
Component<MenuLabel>(parentMenu,itemNameLabelName)->Enable();
}
if(itemDescriptionLabelName!=""){
Component<MenuLabel>(parentMenu,itemDescriptionLabelName)->SetLabel(labelDescriptionText);
Component<MenuLabel>(parentMenu,itemDescriptionLabelName)->SetBorderCol(borderCol);
Component<MenuLabel>(parentMenu,itemDescriptionLabelName)->Enable();
}
}

@ -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();
}

@ -94,7 +94,7 @@ public:
}
window.DrawDecal(rect.pos+vf2d{2,2},const_cast<Decal*>(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){

@ -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

Loading…
Cancel
Save