diff --git a/FiestaOnlineEditor/ActionIDs.h b/FiestaOnlineEditor/ActionIDs.h index fbdc316..414db21 100644 --- a/FiestaOnlineEditor/ActionIDs.h +++ b/FiestaOnlineEditor/ActionIDs.h @@ -4,4 +4,5 @@ enum ActionID{ CHANGE_LOAD_PATH, GO_BACK, SELECTED_FOLDER, + LOAD_ITEM_EDITOR, }; \ No newline at end of file diff --git a/FiestaOnlineEditor/FiestaOnlineEditor.cpp b/FiestaOnlineEditor/FiestaOnlineEditor.cpp index afae472..5e61ff1 100644 --- a/FiestaOnlineEditor/FiestaOnlineEditor.cpp +++ b/FiestaOnlineEditor/FiestaOnlineEditor.cpp @@ -20,14 +20,14 @@ bool FiestaOnlineEditor::OnUserCreate(){ EnableLayer(1,true); menu.SetTable(1,6); - menu["Save"].Enable(false); - menu["Items"].SetTable(1,4).Enable(false); - menu["Items"]["Item Editor"]; + menu["Save"]; + menu["Items"].SetTable(1,4); + menu["Items"]["Item Editor"].SetID(LOAD_ITEM_EDITOR); menu["Items"]["Drop Groups"]; menu["Items"]["Icons"]; - menu["Mobs"].Enable(false); - menu["Abilities"].Enable(false); - menu["Buffs"].Enable(false); + menu["Mobs"]; + menu["Abilities"]; + menu["Buffs"]; menu["Reload"].SetID(RELOAD_FILE_DIALOG); menu.Build(); sprMenu = new Sprite("assets/RetroMenu.png"); @@ -36,10 +36,7 @@ bool FiestaOnlineEditor::OnUserCreate(){ utils::datafile::Read(config,"assets/program.txt"); if(config.HasProperty("DefaultPath")){ - ItemEditor*itemEditor=new ItemEditor({32,32},GetScreenSize()-vi2d{64,64}); - //windows.push_back(new ItemEditor({0,0},GetScreenSize()-vi2d{64,64})); - windows.push_back(itemEditor); - itemEditor->Load(config["DefaultPath"].GetString()); + manager.Open(&menu); } else { manager.Open(&dialog.GetMenu()); } @@ -94,27 +91,35 @@ bool FiestaOnlineEditor::OnUserUpdate(float fElapsedTime){ " ID: " + std::to_string(selected->GetID()); std::cout<GetID()){ - case RELOAD_FILE_DIALOG:{ - }break; - case CHANGE_LOAD_PATH:{ - selectedPath.push_back(selectedPath.back()+"/"+selected->GetName()); - dialog.ChangePath(selectedPath.back()); - manager.Open(&dialog.GetMenu()); - }break; - case GO_BACK:{ - selectedPath.pop_back(); - dialog.ChangePath(selectedPath.back()); - manager.Open(&dialog.GetMenu()); - }break; - case SELECTED_FOLDER:{ - std::cout<Load(selectedPath.back()); - manager.Close(); - }break; + case RELOAD_FILE_DIALOG:{ + }break; + case CHANGE_LOAD_PATH:{ + selectedPath.push_back(selectedPath.back()+"/"+selected->GetName()); + dialog.ChangePath(selectedPath.back()); + manager.Open(&dialog.GetMenu()); + }break; + case GO_BACK:{ + selectedPath.pop_back(); + dialog.ChangePath(selectedPath.back()); + manager.Open(&dialog.GetMenu()); + }break; + case SELECTED_FOLDER:{ + std::cout<Load(selectedPath.back()); + manager.Close(); + }break; + case LOAD_ITEM_EDITOR:{ + ItemEditor*itemEditor=new ItemEditor(this,{32,32},GetScreenSize()-vi2d{64,64}); + CreateWindow(itemEditor); + itemEditor->Load(config["DefaultPath"].GetString()); + itemEditor=new ItemEditor(this,{0,0},GetScreenSize()-vi2d{64,64}); + CreateWindow(itemEditor); + itemEditor->Load(config["DefaultPath"].GetString()); + }break; } } } @@ -133,8 +138,8 @@ bool FiestaOnlineEditor::OnUserUpdate(float fElapsedTime){ } else { SetDrawTarget(nullptr); } + w->InternalUpdate(this,fElapsedTime); w->Draw(this); - w->Update(fElapsedTime); } SetDrawTarget(nullptr); @@ -144,6 +149,14 @@ bool FiestaOnlineEditor::OnUserUpdate(float fElapsedTime){ return true; } +void FiestaOnlineEditor::CreateWindow(Window*window){ + for(Window*w:windows){ + w->InternalRefresh(this); + } + window->InternalRefresh(this); + windows.push_back(window); +} + int main() { FiestaOnlineEditor demo; diff --git a/FiestaOnlineEditor/FiestaOnlineEditor.h b/FiestaOnlineEditor/FiestaOnlineEditor.h index 584bb39..cbf4423 100644 --- a/FiestaOnlineEditor/FiestaOnlineEditor.h +++ b/FiestaOnlineEditor/FiestaOnlineEditor.h @@ -26,4 +26,6 @@ public: bool OnUserCreate() override; bool OnUserUpdate(float fElapsedTime) override; + #undef CreateWindow //Stupid Windows + void CreateWindow(Window*window); }; \ No newline at end of file diff --git a/FiestaOnlineEditor/ItemEditor.cpp b/FiestaOnlineEditor/ItemEditor.cpp index 5da9fd9..228af81 100644 --- a/FiestaOnlineEditor/ItemEditor.cpp +++ b/FiestaOnlineEditor/ItemEditor.cpp @@ -1,16 +1,16 @@ -#include "ItemEditor.h" +#include "FiestaOnlineEditor.h" -ItemEditor::ItemEditor(vi2d pos,vi2d size) - :Window(pos,size){ - view.Initialise(size,{2,2}); -} +ItemEditor::ItemEditor(FiestaOnlineEditor*pge,vi2d pos,vi2d size) + :Window(pge,pos,size){} void ItemEditor::Load(std::string basePath){ ItemInfo.Load(basePath+"/ItemInfo.shn"); +} - view.SetWorldOffset(-1*pos); +void ItemEditor::Update(FiestaOnlineEditor*pge,float fElapsedTime){ + } -void ItemEditor::Update(float fElapsedTime){ - view.DrawRect(vi2d{32,120},{16,16},WHITE); +void ItemEditor::Refresh(FiestaOnlineEditor*pge){ + pge->DrawRect(vi2d{32,size.y-9},{16,16},WHITE); } \ No newline at end of file diff --git a/FiestaOnlineEditor/ItemEditor.h b/FiestaOnlineEditor/ItemEditor.h index 0bbee2e..7cc58f3 100644 --- a/FiestaOnlineEditor/ItemEditor.h +++ b/FiestaOnlineEditor/ItemEditor.h @@ -7,9 +7,9 @@ class FiestaOnlineEditor; class ItemEditor:public Window{ SHNFile ItemInfo,ItemInfoServer,ItemViewInfo; - TransformedView view; public: - ItemEditor(vi2d pos,vi2d size); + ItemEditor(FiestaOnlineEditor*pge,vi2d pos,vi2d size); void Load(std::string basePath); - void Update(float fElapsedTime)override; + void Refresh(FiestaOnlineEditor*pge)override; + void Update(FiestaOnlineEditor*pge,float fElapsedTime)override; }; \ No newline at end of file diff --git a/FiestaOnlineEditor/Window.cpp b/FiestaOnlineEditor/Window.cpp index 6d18e9c..df1998d 100644 --- a/FiestaOnlineEditor/Window.cpp +++ b/FiestaOnlineEditor/Window.cpp @@ -2,19 +2,40 @@ Window*Window::focusedWindow=nullptr; -Window::Window(vi2d pos,vi2d size) +Window::Window(FiestaOnlineEditor*pge,vi2d pos,vi2d size) :pos(pos),size(size){ focusedWindow=this; + sprWindow=new Sprite(size.x,size.y); + decWindow=new Decal(sprWindow); + //InternalRefresh(pge); } -void Window::Draw(FiestaOnlineEditor*pge){ +void Window::InternalUpdate(FiestaOnlineEditor*pge,float fElapsedTime){ + Update(pge,fElapsedTime); +} + +void Window::InternalRefresh(FiestaOnlineEditor*pge){ + Sprite*prevDrawTarget=pge->GetDrawTarget(); + pge->SetDrawTarget(sprWindow); if(focusedWindow==this){ - pge->FillRect(pos,size,VERY_DARK_BLUE); + pge->FillRect({0,0},size,VERY_DARK_BLUE); } else { - pge->FillRectDecal(pos,size,VERY_DARK_GREY); + pge->FillRect({0,0},size,VERY_DARK_GREY); } + Refresh(pge); + decWindow->Update(); + pge->SetDrawTarget(prevDrawTarget); } bool Window::IsFocusedWindow(){ return focusedWindow==this; +} + +void Window::Draw(FiestaOnlineEditor*pge){ + pge->DrawDecal(pos,decWindow); +} + +void Window::Cleanup(){ + delete sprWindow; + delete decWindow; } \ No newline at end of file diff --git a/FiestaOnlineEditor/Window.h b/FiestaOnlineEditor/Window.h index 1de28b3..557b2ff 100644 --- a/FiestaOnlineEditor/Window.h +++ b/FiestaOnlineEditor/Window.h @@ -4,14 +4,20 @@ class FiestaOnlineEditor; class Window{ -protected: +private: vi2d pos; + Decal*decWindow; +protected: vi2d size; Sprite*sprWindow; static Window*focusedWindow; public: - Window(vi2d pos,vi2d size); - virtual void Update(float fElapsedTime)=0; + Window(FiestaOnlineEditor*pge,vi2d pos,vi2d size); + void InternalUpdate(FiestaOnlineEditor*pge,float fElapsedTime); + virtual void Update(FiestaOnlineEditor*pge,float fElapsedTime)=0; + virtual void Refresh(FiestaOnlineEditor*pge)=0; + void InternalRefresh(FiestaOnlineEditor*pge); void Draw(FiestaOnlineEditor*pge); bool IsFocusedWindow(); + void Cleanup(); }; \ No newline at end of file