Window creation and parent classes now implemented.

master
sigonasr2 1 year ago
parent c148202a4d
commit c5e40dae1b
  1. 1
      FiestaOnlineEditor/ActionIDs.h
  2. 39
      FiestaOnlineEditor/FiestaOnlineEditor.cpp
  3. 2
      FiestaOnlineEditor/FiestaOnlineEditor.h
  4. 16
      FiestaOnlineEditor/ItemEditor.cpp
  5. 6
      FiestaOnlineEditor/ItemEditor.h
  6. 29
      FiestaOnlineEditor/Window.cpp
  7. 12
      FiestaOnlineEditor/Window.h

@ -4,4 +4,5 @@ enum ActionID{
CHANGE_LOAD_PATH, CHANGE_LOAD_PATH,
GO_BACK, GO_BACK,
SELECTED_FOLDER, SELECTED_FOLDER,
LOAD_ITEM_EDITOR,
}; };

@ -20,14 +20,14 @@ bool FiestaOnlineEditor::OnUserCreate(){
EnableLayer(1,true); EnableLayer(1,true);
menu.SetTable(1,6); menu.SetTable(1,6);
menu["Save"].Enable(false); menu["Save"];
menu["Items"].SetTable(1,4).Enable(false); menu["Items"].SetTable(1,4);
menu["Items"]["Item Editor"]; menu["Items"]["Item Editor"].SetID(LOAD_ITEM_EDITOR);
menu["Items"]["Drop Groups"]; menu["Items"]["Drop Groups"];
menu["Items"]["Icons"]; menu["Items"]["Icons"];
menu["Mobs"].Enable(false); menu["Mobs"];
menu["Abilities"].Enable(false); menu["Abilities"];
menu["Buffs"].Enable(false); menu["Buffs"];
menu["Reload"].SetID(RELOAD_FILE_DIALOG); menu["Reload"].SetID(RELOAD_FILE_DIALOG);
menu.Build(); menu.Build();
sprMenu = new Sprite("assets/RetroMenu.png"); sprMenu = new Sprite("assets/RetroMenu.png");
@ -36,10 +36,7 @@ bool FiestaOnlineEditor::OnUserCreate(){
utils::datafile::Read(config,"assets/program.txt"); utils::datafile::Read(config,"assets/program.txt");
if(config.HasProperty("DefaultPath")){ if(config.HasProperty("DefaultPath")){
ItemEditor*itemEditor=new ItemEditor({32,32},GetScreenSize()-vi2d{64,64}); manager.Open(&menu);
//windows.push_back(new ItemEditor({0,0},GetScreenSize()-vi2d{64,64}));
windows.push_back(itemEditor);
itemEditor->Load(config["DefaultPath"].GetString());
} else { } else {
manager.Open(&dialog.GetMenu()); manager.Open(&dialog.GetMenu());
} }
@ -110,11 +107,19 @@ bool FiestaOnlineEditor::OnUserUpdate(float fElapsedTime){
std::cout<<selectedPath.back()<<std::endl; std::cout<<selectedPath.back()<<std::endl;
config["DefaultPath"].SetString(selectedPath.back()); config["DefaultPath"].SetString(selectedPath.back());
utils::datafile::Write(config,"assets/program.txt"); utils::datafile::Write(config,"assets/program.txt");
ItemEditor*itemEditor=new ItemEditor({32,32},GetScreenSize()-vi2d{64,64}); ItemEditor*itemEditor=new ItemEditor(this,{32,32},GetScreenSize()-vi2d{64,64});
windows.push_back(itemEditor); CreateWindow(itemEditor);
itemEditor->Load(selectedPath.back()); itemEditor->Load(selectedPath.back());
manager.Close(); manager.Close();
}break; }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 { } else {
SetDrawTarget(nullptr); SetDrawTarget(nullptr);
} }
w->InternalUpdate(this,fElapsedTime);
w->Draw(this); w->Draw(this);
w->Update(fElapsedTime);
} }
SetDrawTarget(nullptr); SetDrawTarget(nullptr);
@ -144,6 +149,14 @@ bool FiestaOnlineEditor::OnUserUpdate(float fElapsedTime){
return true; return true;
} }
void FiestaOnlineEditor::CreateWindow(Window*window){
for(Window*w:windows){
w->InternalRefresh(this);
}
window->InternalRefresh(this);
windows.push_back(window);
}
int main() int main()
{ {
FiestaOnlineEditor demo; FiestaOnlineEditor demo;

@ -26,4 +26,6 @@ public:
bool OnUserCreate() override; bool OnUserCreate() override;
bool OnUserUpdate(float fElapsedTime) override; bool OnUserUpdate(float fElapsedTime) override;
#undef CreateWindow //Stupid Windows
void CreateWindow(Window*window);
}; };

@ -1,16 +1,16 @@
#include "ItemEditor.h" #include "FiestaOnlineEditor.h"
ItemEditor::ItemEditor(vi2d pos,vi2d size) ItemEditor::ItemEditor(FiestaOnlineEditor*pge,vi2d pos,vi2d size)
:Window(pos,size){ :Window(pge,pos,size){}
view.Initialise(size,{2,2});
}
void ItemEditor::Load(std::string basePath){ void ItemEditor::Load(std::string basePath){
ItemInfo.Load(basePath+"/ItemInfo.shn"); ItemInfo.Load(basePath+"/ItemInfo.shn");
}
void ItemEditor::Update(FiestaOnlineEditor*pge,float fElapsedTime){
view.SetWorldOffset(-1*pos);
} }
void ItemEditor::Update(float fElapsedTime){ void ItemEditor::Refresh(FiestaOnlineEditor*pge){
view.DrawRect(vi2d{32,120},{16,16},WHITE); pge->DrawRect(vi2d{32,size.y-9},{16,16},WHITE);
} }

@ -7,9 +7,9 @@ class FiestaOnlineEditor;
class ItemEditor:public Window{ class ItemEditor:public Window{
SHNFile ItemInfo,ItemInfoServer,ItemViewInfo; SHNFile ItemInfo,ItemInfoServer,ItemViewInfo;
TransformedView view;
public: public:
ItemEditor(vi2d pos,vi2d size); ItemEditor(FiestaOnlineEditor*pge,vi2d pos,vi2d size);
void Load(std::string basePath); void Load(std::string basePath);
void Update(float fElapsedTime)override; void Refresh(FiestaOnlineEditor*pge)override;
void Update(FiestaOnlineEditor*pge,float fElapsedTime)override;
}; };

@ -2,19 +2,40 @@
Window*Window::focusedWindow=nullptr; Window*Window::focusedWindow=nullptr;
Window::Window(vi2d pos,vi2d size) Window::Window(FiestaOnlineEditor*pge,vi2d pos,vi2d size)
:pos(pos),size(size){ :pos(pos),size(size){
focusedWindow=this; 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){ if(focusedWindow==this){
pge->FillRect(pos,size,VERY_DARK_BLUE); pge->FillRect({0,0},size,VERY_DARK_BLUE);
} else { } 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(){ bool Window::IsFocusedWindow(){
return focusedWindow==this; return focusedWindow==this;
} }
void Window::Draw(FiestaOnlineEditor*pge){
pge->DrawDecal(pos,decWindow);
}
void Window::Cleanup(){
delete sprWindow;
delete decWindow;
}

@ -4,14 +4,20 @@
class FiestaOnlineEditor; class FiestaOnlineEditor;
class Window{ class Window{
protected: private:
vi2d pos; vi2d pos;
Decal*decWindow;
protected:
vi2d size; vi2d size;
Sprite*sprWindow; Sprite*sprWindow;
static Window*focusedWindow; static Window*focusedWindow;
public: public:
Window(vi2d pos,vi2d size); Window(FiestaOnlineEditor*pge,vi2d pos,vi2d size);
virtual void Update(float fElapsedTime)=0; 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); void Draw(FiestaOnlineEditor*pge);
bool IsFocusedWindow(); bool IsFocusedWindow();
void Cleanup();
}; };
Loading…
Cancel
Save