From 36756885e39b764567300bd039972612aa2491d4 Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Sat, 12 Aug 2023 18:53:02 -0500 Subject: [PATCH] Item data loading completed. --- FiestaOnlineEditor/FiestaOnlineEditor.cpp | 49 ++++++++++---- FiestaOnlineEditor/FiestaOnlineEditor.h | 1 + FiestaOnlineEditor/ItemEditor.cpp | 78 +++++++++++++++++++++-- FiestaOnlineEditor/ItemEditor.h | 36 +++++++++-- FiestaOnlineEditor/OpenFileDialog.cpp | 12 +++- FiestaOnlineEditor/OpenFileDialog.h | 3 +- FiestaOnlineEditor/State.h | 2 + FiestaOnlineEditor/assets/program.txt | 4 ++ 8 files changed, 158 insertions(+), 27 deletions(-) diff --git a/FiestaOnlineEditor/FiestaOnlineEditor.cpp b/FiestaOnlineEditor/FiestaOnlineEditor.cpp index 37294ba..39e4ee9 100644 --- a/FiestaOnlineEditor/FiestaOnlineEditor.cpp +++ b/FiestaOnlineEditor/FiestaOnlineEditor.cpp @@ -76,7 +76,7 @@ bool FiestaOnlineEditor::OnUserUpdate(float fElapsedTime){ manager.OnRight(); } if (GetKey(X).bPressed){ - if(appState!=LOADFOLDER){ + if(appState!=LOADFOLDER&&appState!=LOADFILE){ manager.OnBack(); } } @@ -92,13 +92,23 @@ bool FiestaOnlineEditor::OnUserUpdate(float fElapsedTime){ }break; case CHANGE_LOAD_PATH:{ selectedPath.push_back(selectedPath.back()+"/"+selected->GetName()); - dialog.ChangePath(selectedPath.back()); - manager.Open(&dialog.GetMenu()); + if(appState==LOADFOLDER){ + dialog.ChangePath(selectedPath.back()); + manager.Open(&dialog.GetMenu()); + } else { + filePickerDialog.ChangePath(selectedPath.back()); + manager.Open(&filePickerDialog.GetMenu()); + } }break; case GO_BACK:{ selectedPath.pop_back(); - dialog.ChangePath(selectedPath.back()); - manager.Open(&dialog.GetMenu()); + if(appState==LOADFOLDER){ + dialog.ChangePath(selectedPath.back()); + manager.Open(&dialog.GetMenu()); + } else { + filePickerDialog.ChangePath(selectedPath.back()); + manager.Open(&filePickerDialog.GetMenu()); + } }break; case SELECTED_FOLDER:{ std::cout<GetName()); } utils::datafile::Write(config,"assets/program.txt"); manager.Close(); InitializePathSelection(); }break; case LOAD_ITEM_EDITOR:{ - ItemEditor*itemEditor=new ItemEditor(this,"Item Editor: "+config["DefaultPath"].GetString(),{32,32},GetScreenSize()-vi2d{64,64}); + bool reloadImages=true; + if(config["ItemEditorImagesCached"].GetInt()==1){ + reloadImages=false; + } + ItemEditor*itemEditor=new ItemEditor(this,"Item Editor: "+config["DefaultPath"].GetString(),{32,32},GetScreenSize()-vi2d{64,64},reloadImages); CreateWindow(itemEditor); - itemEditor->Load(config["DefaultPath"].GetString(),config["ClientPath"].GetString()); + itemEditor->Load(config["DefaultPath"].GetString(),config["ClientPath"].GetString(),config["ImageMagickEXE"].GetString()); manager.Close(); menuOpened=false; }break; @@ -140,7 +157,7 @@ bool FiestaOnlineEditor::OnUserUpdate(float fElapsedTime){ SetDrawTarget(1); //BACKGROUND DRAWING - if(appState==LOADFOLDER){ + if(appState==LOADFOLDER||appState==LOADFILE){ switch(pickFileState){ case SHINEDIR:{ DrawString({2,2},"Choose the Shine file directory:"); @@ -148,6 +165,9 @@ bool FiestaOnlineEditor::OnUserUpdate(float fElapsedTime){ case CLIENTDIR:{ DrawString({2,2},"Choose the Client file directory:"); }break; + case IMAGEMAGICKEXE:{ + DrawString({2,2},"Choose the Image Magick Executable:"); + }break; } } @@ -231,10 +251,6 @@ void FiestaOnlineEditor::CreateWindow(Window*window){ } void FiestaOnlineEditor::InitializePathSelection(){ - if(config.HasProperty("DefaultPath")&&config.HasProperty("ClientPath")){ - appState=MENUSELECT; - manager.Open(&menu); - } else if(!config.HasProperty("DefaultPath")){ pickFileState=SHINEDIR; manager.Open(&dialog.GetMenu()); @@ -242,6 +258,15 @@ void FiestaOnlineEditor::InitializePathSelection(){ if(!config.HasProperty("ClientPath")){ pickFileState=CLIENTDIR; manager.Open(&dialog.GetMenu()); + } else + if(!config.HasProperty("ImageMagickEXE")){ + pickFileState=IMAGEMAGICKEXE; + appState=LOADFILE; + manager.Open(&filePickerDialog.GetMenu()); + } else { + //We have all properties we need. Start using program. + appState=MENUSELECT; + manager.Open(&menu); } } diff --git a/FiestaOnlineEditor/FiestaOnlineEditor.h b/FiestaOnlineEditor/FiestaOnlineEditor.h index 4650ca4..03ca8c3 100644 --- a/FiestaOnlineEditor/FiestaOnlineEditor.h +++ b/FiestaOnlineEditor/FiestaOnlineEditor.h @@ -12,6 +12,7 @@ class FiestaOnlineEditor : public olc::PixelGameEngine popup::Manager manager; Sprite*sprMenu; OpenFileDialog dialog; + OpenFileDialog filePickerDialog{false}; std::listselectedPath; float lastPressedTime=0; State appState=LOADFOLDER; diff --git a/FiestaOnlineEditor/ItemEditor.cpp b/FiestaOnlineEditor/ItemEditor.cpp index ea65260..ecf704e 100644 --- a/FiestaOnlineEditor/ItemEditor.cpp +++ b/FiestaOnlineEditor/ItemEditor.cpp @@ -14,15 +14,16 @@ Money::Money(uint32_t money) Item::Item(){} -ItemEditor::ItemEditor(FiestaOnlineEditor*pge,std::string windowTitle,vi2d pos,vi2d size) - :Window(pge,windowTitle,pos,size){} +ItemEditor::ItemEditor(FiestaOnlineEditor*pge,std::string windowTitle,vi2d pos,vi2d size,bool reloadImages) + :Window(pge,windowTitle,pos,size),reloadImages(reloadImages){} ItemEditor::~ItemEditor(){}; -void ItemEditor::Load(std::string basePath,std::string clientPath){ +void ItemEditor::Load(std::string basePath,std::string clientPath,std::string imageMagickPath){ ItemInfo.Load(basePath+"/ItemInfo.shn"); ItemInfoServer.Load(basePath+"/ItemInfoServer.shn"); ItemViewInfo.Load(basePath+"/View/ItemViewInfo.shn"); + GradeItemOption.Load(basePath+"/GradeItemOption.shn"); for(int i=0;i(i,0); @@ -48,9 +49,76 @@ void ItemEditor::Load(std::string basePath,std::string clientPath){ it.useClass=Class(ItemInfo.Get(i,31)); it.buyPrice=Money(ItemInfo.Get(i,32)); it.sellPrice=Money(ItemInfo.Get(i,33)); - it.enhanceLimit=ItemInfo.Get(i,40); + it.enhanceLimit=ItemInfo.Get(i,40); it.blockRate=ItemInfo.Get(i,46); - itemList[it.id]=it; + itemList[it.inxName]=it; + } + for(int i=0;i(i,1); + Item&it=itemList[index]; + it.DropGroupA=ItemInfoServer.Get(i,4); + it.DropGroupB=ItemInfoServer.Get(i,5); + it.RandomOptionDrop=ItemInfoServer.Get(i,6); + it.vanishTime=ItemInfoServer.Get(i,7); + it.lootingTime=ItemInfoServer.Get(i,8); + it.slot=EquipSlot(ItemInfoServer.Get(i,11)); + } + for(int i=0;i(i,1); + Item&it=itemList[index]; + it.iconIndex=ItemViewInfo.Get(i,2); + std::string iconFilename=ItemViewInfo.Get(i,3); + + auto GetImage=[&](std::string filename){ + if (imgLookup.count(filename)==0){ + std::string basePath = clientPath+"/resmenu/Icon/"; + if(reloadImages){ + std::string baseCmd = "\""+imageMagickPath+"\" "+basePath+filename+".dds "+basePath+filename+".png"; + std::system(baseCmd.c_str()); + } + imgLookup[filename]=std::make_unique(); + imgLookup[filename]->Load(basePath+filename+".png"); + } + return imgLookup[filename].get(); + }; + + it.icon=GetImage(iconFilename); + it.subIconIndex=ItemViewInfo.Get(i,4); + std::string subIconFilename=ItemViewInfo.Get(i,5); + if(subIconFilename!="-"){ + it.subIcon=GetImage(subIconFilename); + } + + uint32_t r=ItemViewInfo.Get(i,8); + uint32_t g=ItemViewInfo.Get(i,9); + uint32_t b=ItemViewInfo.Get(i,10); + it.borderCol={uint8_t(r),uint8_t(g),uint8_t(b)}; + uint32_t blend_r=ItemViewInfo.Get(i,11); + uint32_t blend_g=ItemViewInfo.Get(i,12); + uint32_t blend_b=ItemViewInfo.Get(i,13); + it.blendCol={uint8_t(blend_r),uint8_t(blend_g),uint8_t(blend_b)}; + + it.itemSize=ItemViewInfo.Get(i,19); + + it.description=ItemViewInfo.Get(i,26); + } + for(int i=0;i(i,0); + Item&it=itemList[index]; + it.stat_str=GradeItemOption.Get(i,1); + it.stat_end=GradeItemOption.Get(i,2); + it.stat_dex=GradeItemOption.Get(i,3); + it.stat_int=GradeItemOption.Get(i,4); + it.stat_spr=GradeItemOption.Get(i,5); + it.resistPoison=GradeItemOption.Get(i,6); + it.resistDisease=GradeItemOption.Get(i,7); + it.resistCurse=GradeItemOption.Get(i,8); + it.hitRatePctModifier=GradeItemOption.Get(i,10); + it.blockRatePctModifier=GradeItemOption.Get(i,11); + it.stat_hp=GradeItemOption.Get(i,12); + it.stat_sp=GradeItemOption.Get(i,13); + it.stat_dmg=GradeItemOption.Get(i,14); + it.stat_magDmg=GradeItemOption.Get(i,15); } } diff --git a/FiestaOnlineEditor/ItemEditor.h b/FiestaOnlineEditor/ItemEditor.h index 4dd4ff2..1a65aef 100644 --- a/FiestaOnlineEditor/ItemEditor.h +++ b/FiestaOnlineEditor/ItemEditor.h @@ -100,10 +100,14 @@ enum ItemGrade{ class Item{ public: uint16_t id; - Renderable*icon; + Renderable*icon=nullptr; + Renderable*subIcon=nullptr; std::string inxName; std::string name; std::string description; + std::string DropGroupA; + std::string DropGroupB; + std::string RandomOptionDrop; EquipSlot slot; uint32_t lvReq; uint32_t iconIndex; @@ -113,6 +117,8 @@ public: Money buyPrice; Money sellPrice; ItemGrade grade; + uint32_t vanishTime; + uint32_t lootingTime; Pixel borderCol; Pixel blendCol; uint32_t attackSpd; @@ -129,21 +135,37 @@ public: uint32_t magAtkPctBonus; uint32_t magDefPctBonus; uint32_t critRate; - uint32_t enhanceLimit; + byte enhanceLimit; uint32_t blockRate; + float itemSize; + uint16_t stat_str=0; + uint16_t stat_end=0; + uint16_t stat_dex=0; + uint16_t stat_int=0; + uint16_t stat_spr=0; + uint16_t resistPoison=0; + uint16_t resistDisease=0; + uint16_t resistCurse=0; + uint16_t hitRatePctModifier=1000; + uint16_t blockRatePctModifier=1000; + uint16_t stat_hp=0; + uint16_t stat_sp=0; + uint16_t stat_dmg=0; + uint16_t stat_magDmg=0; public: Item(); }; class ItemEditor:public Window{ - SHNFile ItemInfo,ItemInfoServer,ItemViewInfo; + SHNFile ItemInfo,ItemInfoServer,ItemViewInfo,GradeItemOption; vf2d pos={64,64}; - std::mapimgLookup; - std::mapitemList; + std::map>imgLookup; + std::mapitemList; + bool reloadImages; public: - ItemEditor(FiestaOnlineEditor*pge,std::string windowTitle,vi2d pos,vi2d size); + ItemEditor(FiestaOnlineEditor*pge,std::string windowTitle,vi2d pos,vi2d size,bool reloadImages=true); ~ItemEditor(); - void Load(std::string basePath,std::string clientPath); + void Load(std::string basePath,std::string clientPath,std::string imageMagickPath); void Refresh(FiestaOnlineEditor*pge)override; void Update(FiestaOnlineEditor*pge,float fElapsedTime)override; void MouseFocus(FiestaOnlineEditor*pge)override; diff --git a/FiestaOnlineEditor/OpenFileDialog.cpp b/FiestaOnlineEditor/OpenFileDialog.cpp index 050491e..036fa48 100644 --- a/FiestaOnlineEditor/OpenFileDialog.cpp +++ b/FiestaOnlineEditor/OpenFileDialog.cpp @@ -1,7 +1,8 @@ #include "OpenFileDialog.h" #include "ActionIDs.h" -OpenFileDialog::OpenFileDialog(){ +OpenFileDialog::OpenFileDialog(bool foldersOnly) +:foldersOnly(foldersOnly){ BuildMenu(); } popup::Menu&OpenFileDialog::GetMenu(){ @@ -18,7 +19,10 @@ void OpenFileDialog::ChangePath(std::string newPath){ void OpenFileDialog::BuildMenu(){ menu.Clear(); - menu["Select "+path].SetID(SELECTED_FOLDER); + menu["Select "+path]; + if(foldersOnly){ + menu["Select "+path].SetID(SELECTED_FOLDER); + } menu[""].Enable(false); if(path!="/"){ menu[".."].SetID(GO_BACK); @@ -27,6 +31,10 @@ void OpenFileDialog::BuildMenu(){ if(dir.is_directory()){ std::filesystem::path filename = dir.path().filename(); menu[filename.string()].SetID(CHANGE_LOAD_PATH); + } else + if(!foldersOnly&&dir.is_regular_file()){ + std::filesystem::path filename = dir.path().filename(); + menu[filename.string()].SetID(SELECTED_FOLDER); } } menu.SetTable(1,std::min(20,menu.GetChildrenCount())); diff --git a/FiestaOnlineEditor/OpenFileDialog.h b/FiestaOnlineEditor/OpenFileDialog.h index f4fcad5..5874956 100644 --- a/FiestaOnlineEditor/OpenFileDialog.h +++ b/FiestaOnlineEditor/OpenFileDialog.h @@ -5,8 +5,9 @@ class OpenFileDialog{ popup::Menu menu; std::string path="/"; + bool foldersOnly=true; public: - OpenFileDialog(); + OpenFileDialog(bool foldersOnly=true); popup::Menu&GetMenu(); void ChangePath(std::string newPath); void BuildMenu(); diff --git a/FiestaOnlineEditor/State.h b/FiestaOnlineEditor/State.h index 806297f..ed2debe 100644 --- a/FiestaOnlineEditor/State.h +++ b/FiestaOnlineEditor/State.h @@ -1,6 +1,7 @@ #pragma once enum State{ LOADFOLDER, + LOADFILE, MENUSELECT, ITEMEDIT, MOBEDIT, @@ -9,4 +10,5 @@ enum State{ enum PickState{ SHINEDIR, CLIENTDIR, + IMAGEMAGICKEXE, }; \ No newline at end of file diff --git a/FiestaOnlineEditor/assets/program.txt b/FiestaOnlineEditor/assets/program.txt index 56f5af2..e2d4b76 100644 --- a/FiestaOnlineEditor/assets/program.txt +++ b/FiestaOnlineEditor/assets/program.txt @@ -1,2 +1,6 @@ DefaultPath = /Users/sigon/Documents/NA2016-main/Server/9Data/Shine ClientPath = /Users/sigon/Documents/NA2016-main/Client +ImageMagickEXE = /Program Files/ImageMagick-7.1.1-Q16-HDRI/magick.exe + +# You can set this to 0 to reload the images for the item editor. Once they are converted to png files, it doesn't have to be done again unless something changes. +ItemEditorImagesCached = 1 \ No newline at end of file