Added window header

master
sigonasr2 1 year ago
parent c5e40dae1b
commit bc55854b83
  1. 6
      FiestaOnlineEditor/FiestaOnlineEditor.cpp
  2. 27
      FiestaOnlineEditor/ItemEditor.cpp
  3. 3
      FiestaOnlineEditor/ItemEditor.h
  4. 28
      FiestaOnlineEditor/Window.cpp
  5. 4
      FiestaOnlineEditor/Window.h

@ -107,16 +107,16 @@ bool FiestaOnlineEditor::OnUserUpdate(float fElapsedTime){
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});
ItemEditor*itemEditor=new ItemEditor(this,"Item Editor: "+selectedPath.back(),{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});
ItemEditor*itemEditor=new ItemEditor(this,"Item Editor: "+config["DefaultPath"].GetString(),{32,32},GetScreenSize()-vi2d{64,64});
CreateWindow(itemEditor);
itemEditor->Load(config["DefaultPath"].GetString());
itemEditor=new ItemEditor(this,{0,0},GetScreenSize()-vi2d{64,64});
itemEditor=new ItemEditor(this,"Item Editor: "+config["DefaultPath"].GetString(),{0,0},GetScreenSize()-vi2d{64,64});
CreateWindow(itemEditor);
itemEditor->Load(config["DefaultPath"].GetString());
}break;

@ -1,16 +1,35 @@
#include "FiestaOnlineEditor.h"
ItemEditor::ItemEditor(FiestaOnlineEditor*pge,vi2d pos,vi2d size)
:Window(pge,pos,size){}
ItemEditor::ItemEditor(FiestaOnlineEditor*pge,std::string windowTitle,vi2d pos,vi2d size)
:Window(pge,windowTitle,pos,size){}
void ItemEditor::Load(std::string basePath){
ItemInfo.Load(basePath+"/ItemInfo.shn");
}
void ItemEditor::Update(FiestaOnlineEditor*pge,float fElapsedTime){
bool updateRequired=false;
if(pge->GetKey(UP).bHeld){
pos.y-=32*fElapsedTime;
updateRequired=true;
}
if(pge->GetKey(DOWN).bHeld){
pos.y+=32*fElapsedTime;
updateRequired=true;
}
if(pge->GetKey(RIGHT).bHeld){
pos.x+=32*fElapsedTime;
updateRequired=true;
}
if(pge->GetKey(LEFT).bHeld){
pos.x-=32*fElapsedTime;
updateRequired=true;
}
if(updateRequired){
InternalRefresh(pge);
}
}
void ItemEditor::Refresh(FiestaOnlineEditor*pge){
pge->DrawRect(vi2d{32,size.y-9},{16,16},WHITE);
pge->DrawRect(pos,{16,16},WHITE);
}

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

@ -2,27 +2,43 @@
Window*Window::focusedWindow=nullptr;
Window::Window(FiestaOnlineEditor*pge,vi2d pos,vi2d size)
:pos(pos),size(size){
Window::Window(FiestaOnlineEditor*pge,std::string windowTitle,vi2d pos,vi2d size)
:pos(pos),size(size),windowTitle(windowTitle){
focusedWindow=this;
sprWindow=new Sprite(size.x,size.y);
sprWindow=new Sprite(size.x,size.y+headerHeight);
decWindow=new Decal(sprWindow);
//InternalRefresh(pge);
}
void Window::InternalUpdate(FiestaOnlineEditor*pge,float fElapsedTime){
Update(pge,fElapsedTime);
if(this==focusedWindow){
Update(pge,fElapsedTime);
}
}
void Window::InternalRefresh(FiestaOnlineEditor*pge){
Sprite*prevDrawTarget=pge->GetDrawTarget();
pge->SetDrawTarget(sprWindow);
//Window background drawing
if(focusedWindow==this){
pge->FillRect({0,0},size,VERY_DARK_BLUE);
pge->FillRect({0,headerHeight},size,VERY_DARK_BLUE);
} else {
pge->FillRect({0,0},size,VERY_DARK_GREY);
pge->FillRect({0,headerHeight},size,VERY_DARK_GREY);
}
//All other drawing functions should go here.
pos.y+=headerHeight;
Refresh(pge);
pos.y-=headerHeight;
if(focusedWindow==this){
pge->FillRect({0,0},{size.x,headerHeight},VERY_DARK_BLUE);
} else {
pge->FillRect({0,0},{size.x,headerHeight},VERY_DARK_GREY);
}
pge->DrawString({2,2},windowTitle,CYAN);
pge->DrawLine({1,10},{size.x-2,10},DARK_CYAN,0xFFFFFF00);
decWindow->Update();
pge->SetDrawTarget(prevDrawTarget);
}

@ -7,12 +7,14 @@ class Window{
private:
vi2d pos;
Decal*decWindow;
const int headerHeight=12;
protected:
vi2d size;
Sprite*sprWindow;
static Window*focusedWindow;
std::string windowTitle="";
public:
Window(FiestaOnlineEditor*pge,vi2d pos,vi2d size);
Window(FiestaOnlineEditor*pge,std::string windowTitle,vi2d pos,vi2d size);
void InternalUpdate(FiestaOnlineEditor*pge,float fElapsedTime);
virtual void Update(FiestaOnlineEditor*pge,float fElapsedTime)=0;
virtual void Refresh(FiestaOnlineEditor*pge)=0;

Loading…
Cancel
Save