Item data loading completed.

master
sigonasr2 1 year ago
parent 1811120eed
commit 36756885e3
  1. 49
      FiestaOnlineEditor/FiestaOnlineEditor.cpp
  2. 1
      FiestaOnlineEditor/FiestaOnlineEditor.h
  3. 78
      FiestaOnlineEditor/ItemEditor.cpp
  4. 36
      FiestaOnlineEditor/ItemEditor.h
  5. 12
      FiestaOnlineEditor/OpenFileDialog.cpp
  6. 3
      FiestaOnlineEditor/OpenFileDialog.h
  7. 2
      FiestaOnlineEditor/State.h
  8. 4
      FiestaOnlineEditor/assets/program.txt

@ -76,7 +76,7 @@ bool FiestaOnlineEditor::OnUserUpdate(float fElapsedTime){
manager.OnRight(); manager.OnRight();
} }
if (GetKey(X).bPressed){ if (GetKey(X).bPressed){
if(appState!=LOADFOLDER){ if(appState!=LOADFOLDER&&appState!=LOADFILE){
manager.OnBack(); manager.OnBack();
} }
} }
@ -92,13 +92,23 @@ bool FiestaOnlineEditor::OnUserUpdate(float fElapsedTime){
}break; }break;
case CHANGE_LOAD_PATH:{ case CHANGE_LOAD_PATH:{
selectedPath.push_back(selectedPath.back()+"/"+selected->GetName()); selectedPath.push_back(selectedPath.back()+"/"+selected->GetName());
dialog.ChangePath(selectedPath.back()); if(appState==LOADFOLDER){
manager.Open(&dialog.GetMenu()); dialog.ChangePath(selectedPath.back());
manager.Open(&dialog.GetMenu());
} else {
filePickerDialog.ChangePath(selectedPath.back());
manager.Open(&filePickerDialog.GetMenu());
}
}break; }break;
case GO_BACK:{ case GO_BACK:{
selectedPath.pop_back(); selectedPath.pop_back();
dialog.ChangePath(selectedPath.back()); if(appState==LOADFOLDER){
manager.Open(&dialog.GetMenu()); dialog.ChangePath(selectedPath.back());
manager.Open(&dialog.GetMenu());
} else {
filePickerDialog.ChangePath(selectedPath.back());
manager.Open(&filePickerDialog.GetMenu());
}
}break; }break;
case SELECTED_FOLDER:{ case SELECTED_FOLDER:{
std::cout<<selectedPath.back()<<std::endl; std::cout<<selectedPath.back()<<std::endl;
@ -107,15 +117,22 @@ bool FiestaOnlineEditor::OnUserUpdate(float fElapsedTime){
} else } else
if(pickFileState==CLIENTDIR){ if(pickFileState==CLIENTDIR){
config["ClientPath"].SetString(selectedPath.back()); config["ClientPath"].SetString(selectedPath.back());
} else
if(pickFileState==IMAGEMAGICKEXE){
config["ImageMagickEXE"].SetString(selectedPath.back()+"/"+selected->GetName());
} }
utils::datafile::Write(config,"assets/program.txt"); utils::datafile::Write(config,"assets/program.txt");
manager.Close(); manager.Close();
InitializePathSelection(); InitializePathSelection();
}break; }break;
case LOAD_ITEM_EDITOR:{ 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); CreateWindow(itemEditor);
itemEditor->Load(config["DefaultPath"].GetString(),config["ClientPath"].GetString()); itemEditor->Load(config["DefaultPath"].GetString(),config["ClientPath"].GetString(),config["ImageMagickEXE"].GetString());
manager.Close(); manager.Close();
menuOpened=false; menuOpened=false;
}break; }break;
@ -140,7 +157,7 @@ bool FiestaOnlineEditor::OnUserUpdate(float fElapsedTime){
SetDrawTarget(1); SetDrawTarget(1);
//BACKGROUND DRAWING //BACKGROUND DRAWING
if(appState==LOADFOLDER){ if(appState==LOADFOLDER||appState==LOADFILE){
switch(pickFileState){ switch(pickFileState){
case SHINEDIR:{ case SHINEDIR:{
DrawString({2,2},"Choose the Shine file directory:"); DrawString({2,2},"Choose the Shine file directory:");
@ -148,6 +165,9 @@ bool FiestaOnlineEditor::OnUserUpdate(float fElapsedTime){
case CLIENTDIR:{ case CLIENTDIR:{
DrawString({2,2},"Choose the Client file directory:"); DrawString({2,2},"Choose the Client file directory:");
}break; }break;
case IMAGEMAGICKEXE:{
DrawString({2,2},"Choose the Image Magick Executable:");
}break;
} }
} }
@ -231,10 +251,6 @@ void FiestaOnlineEditor::CreateWindow(Window*window){
} }
void FiestaOnlineEditor::InitializePathSelection(){ void FiestaOnlineEditor::InitializePathSelection(){
if(config.HasProperty("DefaultPath")&&config.HasProperty("ClientPath")){
appState=MENUSELECT;
manager.Open(&menu);
} else
if(!config.HasProperty("DefaultPath")){ if(!config.HasProperty("DefaultPath")){
pickFileState=SHINEDIR; pickFileState=SHINEDIR;
manager.Open(&dialog.GetMenu()); manager.Open(&dialog.GetMenu());
@ -242,6 +258,15 @@ void FiestaOnlineEditor::InitializePathSelection(){
if(!config.HasProperty("ClientPath")){ if(!config.HasProperty("ClientPath")){
pickFileState=CLIENTDIR; pickFileState=CLIENTDIR;
manager.Open(&dialog.GetMenu()); 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);
} }
} }

@ -12,6 +12,7 @@ class FiestaOnlineEditor : public olc::PixelGameEngine
popup::Manager manager; popup::Manager manager;
Sprite*sprMenu; Sprite*sprMenu;
OpenFileDialog dialog; OpenFileDialog dialog;
OpenFileDialog filePickerDialog{false};
std::list<std::string>selectedPath; std::list<std::string>selectedPath;
float lastPressedTime=0; float lastPressedTime=0;
State appState=LOADFOLDER; State appState=LOADFOLDER;

@ -14,15 +14,16 @@ Money::Money(uint32_t money)
Item::Item(){} Item::Item(){}
ItemEditor::ItemEditor(FiestaOnlineEditor*pge,std::string windowTitle,vi2d pos,vi2d size) ItemEditor::ItemEditor(FiestaOnlineEditor*pge,std::string windowTitle,vi2d pos,vi2d size,bool reloadImages)
:Window(pge,windowTitle,pos,size){} :Window(pge,windowTitle,pos,size),reloadImages(reloadImages){}
ItemEditor::~ItemEditor(){}; 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"); ItemInfo.Load(basePath+"/ItemInfo.shn");
ItemInfoServer.Load(basePath+"/ItemInfoServer.shn"); ItemInfoServer.Load(basePath+"/ItemInfoServer.shn");
ItemViewInfo.Load(basePath+"/View/ItemViewInfo.shn"); ItemViewInfo.Load(basePath+"/View/ItemViewInfo.shn");
GradeItemOption.Load(basePath+"/GradeItemOption.shn");
for(int i=0;i<ItemInfo.Rows();i++){ for(int i=0;i<ItemInfo.Rows();i++){
Item it; Item it;
it.id=ItemInfo.Get<uint16_t>(i,0); it.id=ItemInfo.Get<uint16_t>(i,0);
@ -48,9 +49,76 @@ void ItemEditor::Load(std::string basePath,std::string clientPath){
it.useClass=Class(ItemInfo.Get<uint32_t>(i,31)); it.useClass=Class(ItemInfo.Get<uint32_t>(i,31));
it.buyPrice=Money(ItemInfo.Get<uint32_t>(i,32)); it.buyPrice=Money(ItemInfo.Get<uint32_t>(i,32));
it.sellPrice=Money(ItemInfo.Get<uint32_t>(i,33)); it.sellPrice=Money(ItemInfo.Get<uint32_t>(i,33));
it.enhanceLimit=ItemInfo.Get<uint32_t>(i,40); it.enhanceLimit=ItemInfo.Get<byte>(i,40);
it.blockRate=ItemInfo.Get<uint32_t>(i,46); it.blockRate=ItemInfo.Get<uint32_t>(i,46);
itemList[it.id]=it; itemList[it.inxName]=it;
}
for(int i=0;i<ItemInfoServer.Rows();i++){
std::string index=ItemInfoServer.Get<std::string>(i,1);
Item&it=itemList[index];
it.DropGroupA=ItemInfoServer.Get<std::string>(i,4);
it.DropGroupB=ItemInfoServer.Get<std::string>(i,5);
it.RandomOptionDrop=ItemInfoServer.Get<std::string>(i,6);
it.vanishTime=ItemInfoServer.Get<uint32_t>(i,7);
it.lootingTime=ItemInfoServer.Get<uint32_t>(i,8);
it.slot=EquipSlot(ItemInfoServer.Get<uint32_t>(i,11));
}
for(int i=0;i<ItemViewInfo.Rows();i++){
std::string index=ItemViewInfo.Get<std::string>(i,1);
Item&it=itemList[index];
it.iconIndex=ItemViewInfo.Get<uint32_t>(i,2);
std::string iconFilename=ItemViewInfo.Get<std::string>(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<Renderable>();
imgLookup[filename]->Load(basePath+filename+".png");
}
return imgLookup[filename].get();
};
it.icon=GetImage(iconFilename);
it.subIconIndex=ItemViewInfo.Get<uint32_t>(i,4);
std::string subIconFilename=ItemViewInfo.Get<std::string>(i,5);
if(subIconFilename!="-"){
it.subIcon=GetImage(subIconFilename);
}
uint32_t r=ItemViewInfo.Get<uint32_t>(i,8);
uint32_t g=ItemViewInfo.Get<uint32_t>(i,9);
uint32_t b=ItemViewInfo.Get<uint32_t>(i,10);
it.borderCol={uint8_t(r),uint8_t(g),uint8_t(b)};
uint32_t blend_r=ItemViewInfo.Get<uint32_t>(i,11);
uint32_t blend_g=ItemViewInfo.Get<uint32_t>(i,12);
uint32_t blend_b=ItemViewInfo.Get<uint32_t>(i,13);
it.blendCol={uint8_t(blend_r),uint8_t(blend_g),uint8_t(blend_b)};
it.itemSize=ItemViewInfo.Get<float>(i,19);
it.description=ItemViewInfo.Get<std::string>(i,26);
}
for(int i=0;i<GradeItemOption.Rows();i++){
std::string index=GradeItemOption.Get<std::string>(i,0);
Item&it=itemList[index];
it.stat_str=GradeItemOption.Get<uint16_t>(i,1);
it.stat_end=GradeItemOption.Get<uint16_t>(i,2);
it.stat_dex=GradeItemOption.Get<uint16_t>(i,3);
it.stat_int=GradeItemOption.Get<uint16_t>(i,4);
it.stat_spr=GradeItemOption.Get<uint16_t>(i,5);
it.resistPoison=GradeItemOption.Get<uint16_t>(i,6);
it.resistDisease=GradeItemOption.Get<uint16_t>(i,7);
it.resistCurse=GradeItemOption.Get<uint16_t>(i,8);
it.hitRatePctModifier=GradeItemOption.Get<uint16_t>(i,10);
it.blockRatePctModifier=GradeItemOption.Get<uint16_t>(i,11);
it.stat_hp=GradeItemOption.Get<uint16_t>(i,12);
it.stat_sp=GradeItemOption.Get<uint16_t>(i,13);
it.stat_dmg=GradeItemOption.Get<uint16_t>(i,14);
it.stat_magDmg=GradeItemOption.Get<uint16_t>(i,15);
} }
} }

@ -100,10 +100,14 @@ enum ItemGrade{
class Item{ class Item{
public: public:
uint16_t id; uint16_t id;
Renderable*icon; Renderable*icon=nullptr;
Renderable*subIcon=nullptr;
std::string inxName; std::string inxName;
std::string name; std::string name;
std::string description; std::string description;
std::string DropGroupA;
std::string DropGroupB;
std::string RandomOptionDrop;
EquipSlot slot; EquipSlot slot;
uint32_t lvReq; uint32_t lvReq;
uint32_t iconIndex; uint32_t iconIndex;
@ -113,6 +117,8 @@ public:
Money buyPrice; Money buyPrice;
Money sellPrice; Money sellPrice;
ItemGrade grade; ItemGrade grade;
uint32_t vanishTime;
uint32_t lootingTime;
Pixel borderCol; Pixel borderCol;
Pixel blendCol; Pixel blendCol;
uint32_t attackSpd; uint32_t attackSpd;
@ -129,21 +135,37 @@ public:
uint32_t magAtkPctBonus; uint32_t magAtkPctBonus;
uint32_t magDefPctBonus; uint32_t magDefPctBonus;
uint32_t critRate; uint32_t critRate;
uint32_t enhanceLimit; byte enhanceLimit;
uint32_t blockRate; 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: public:
Item(); Item();
}; };
class ItemEditor:public Window{ class ItemEditor:public Window{
SHNFile ItemInfo,ItemInfoServer,ItemViewInfo; SHNFile ItemInfo,ItemInfoServer,ItemViewInfo,GradeItemOption;
vf2d pos={64,64}; vf2d pos={64,64};
std::map<std::string,Renderable>imgLookup; std::map<std::string,std::unique_ptr<Renderable>>imgLookup;
std::map<int,Item>itemList; std::map<std::string,Item>itemList;
bool reloadImages;
public: 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(); ~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 Refresh(FiestaOnlineEditor*pge)override;
void Update(FiestaOnlineEditor*pge,float fElapsedTime)override; void Update(FiestaOnlineEditor*pge,float fElapsedTime)override;
void MouseFocus(FiestaOnlineEditor*pge)override; void MouseFocus(FiestaOnlineEditor*pge)override;

@ -1,7 +1,8 @@
#include "OpenFileDialog.h" #include "OpenFileDialog.h"
#include "ActionIDs.h" #include "ActionIDs.h"
OpenFileDialog::OpenFileDialog(){ OpenFileDialog::OpenFileDialog(bool foldersOnly)
:foldersOnly(foldersOnly){
BuildMenu(); BuildMenu();
} }
popup::Menu&OpenFileDialog::GetMenu(){ popup::Menu&OpenFileDialog::GetMenu(){
@ -18,7 +19,10 @@ void OpenFileDialog::ChangePath(std::string newPath){
void OpenFileDialog::BuildMenu(){ void OpenFileDialog::BuildMenu(){
menu.Clear(); menu.Clear();
menu["Select "+path].SetID(SELECTED_FOLDER); menu["Select "+path];
if(foldersOnly){
menu["Select "+path].SetID(SELECTED_FOLDER);
}
menu[""].Enable(false); menu[""].Enable(false);
if(path!="/"){ if(path!="/"){
menu[".."].SetID(GO_BACK); menu[".."].SetID(GO_BACK);
@ -27,6 +31,10 @@ void OpenFileDialog::BuildMenu(){
if(dir.is_directory()){ if(dir.is_directory()){
std::filesystem::path filename = dir.path().filename(); std::filesystem::path filename = dir.path().filename();
menu[filename.string()].SetID(CHANGE_LOAD_PATH); 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())); menu.SetTable(1,std::min(20,menu.GetChildrenCount()));

@ -5,8 +5,9 @@
class OpenFileDialog{ class OpenFileDialog{
popup::Menu menu; popup::Menu menu;
std::string path="/"; std::string path="/";
bool foldersOnly=true;
public: public:
OpenFileDialog(); OpenFileDialog(bool foldersOnly=true);
popup::Menu&GetMenu(); popup::Menu&GetMenu();
void ChangePath(std::string newPath); void ChangePath(std::string newPath);
void BuildMenu(); void BuildMenu();

@ -1,6 +1,7 @@
#pragma once #pragma once
enum State{ enum State{
LOADFOLDER, LOADFOLDER,
LOADFILE,
MENUSELECT, MENUSELECT,
ITEMEDIT, ITEMEDIT,
MOBEDIT, MOBEDIT,
@ -9,4 +10,5 @@ enum State{
enum PickState{ enum PickState{
SHINEDIR, SHINEDIR,
CLIENTDIR, CLIENTDIR,
IMAGEMAGICKEXE,
}; };

@ -1,2 +1,6 @@
DefaultPath = /Users/sigon/Documents/NA2016-main/Server/9Data/Shine DefaultPath = /Users/sigon/Documents/NA2016-main/Server/9Data/Shine
ClientPath = /Users/sigon/Documents/NA2016-main/Client 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
Loading…
Cancel
Save