Window creation and parent classes now implemented.

master
sigonasr2 1 year ago
parent c148202a4d
commit c5e40dae1b
  1. 1
      FiestaOnlineEditor/ActionIDs.h
  2. 77
      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,
GO_BACK,
SELECTED_FOLDER,
LOAD_ITEM_EDITOR,
};

@ -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<<sLastAction<<std::endl;
switch(selected->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<<selectedPath.back()<<std::endl;
config["DefaultPath"].SetString(selectedPath.back());
utils::datafile::Write(config,"assets/program.txt");
ItemEditor*itemEditor=new ItemEditor({32,32},GetScreenSize()-vi2d{64,64});
windows.push_back(itemEditor);
itemEditor->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<<selectedPath.back()<<std::endl;
config["DefaultPath"].SetString(selectedPath.back());
utils::datafile::Write(config,"assets/program.txt");
ItemEditor*itemEditor=new ItemEditor(this,{32,32},GetScreenSize()-vi2d{64,64});
CreateWindow(itemEditor);
itemEditor->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;

@ -26,4 +26,6 @@ public:
bool OnUserCreate() 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)
: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);
}

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

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

@ -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();
};
Loading…
Cancel
Save