diff --git a/FiestaOnlineEditor/FiestaOnlineEditor.cpp b/FiestaOnlineEditor/FiestaOnlineEditor.cpp index b4b39e7..8bb5da7 100644 --- a/FiestaOnlineEditor/FiestaOnlineEditor.cpp +++ b/FiestaOnlineEditor/FiestaOnlineEditor.cpp @@ -179,6 +179,23 @@ bool FiestaOnlineEditor::OnUserUpdate(float fElapsedTime){ } } + bool focusErased=false; + std::erase_if(windows,[&](Window*w){ + if(w->IsClosed()){ + if(w->IsFocusedWindow()){ + focusErased=true; + } + w->Cleanup(); + return true; + } else { + return false; + } + }); + + if(focusErased&&windows.size()>0){ + Window::SetFocusedWindow(windows[0]); + } + SetDrawTarget(nullptr); //FOREGROUND DRAWING manager.Draw(sprMenu,{64,64}); diff --git a/FiestaOnlineEditor/FiestaOnlineEditor.vcxproj b/FiestaOnlineEditor/FiestaOnlineEditor.vcxproj index dd70770..9675825 100644 --- a/FiestaOnlineEditor/FiestaOnlineEditor.vcxproj +++ b/FiestaOnlineEditor/FiestaOnlineEditor.vcxproj @@ -76,7 +76,7 @@ true WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) true - stdcpp17 + stdcpp20 Console @@ -91,7 +91,7 @@ true WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) true - stdcpp17 + stdcpp20 Console @@ -106,7 +106,7 @@ true _DEBUG;_CONSOLE;%(PreprocessorDefinitions) true - stdcpp17 + stdcpp20 Console @@ -121,7 +121,7 @@ true NDEBUG;_CONSOLE;%(PreprocessorDefinitions) true - stdcpp17 + stdcpp20 Console diff --git a/FiestaOnlineEditor/Window.cpp b/FiestaOnlineEditor/Window.cpp index 3a52f92..37dad3f 100644 --- a/FiestaOnlineEditor/Window.cpp +++ b/FiestaOnlineEditor/Window.cpp @@ -17,6 +17,17 @@ void Window::InternalUpdate(FiestaOnlineEditor*pge,float fElapsedTime){ if(dragging){ pos=pge->GetMousePos()-dragPoint; } + if(pge->GetMouseX()>=pos.x+size.x-64&&pge->GetMouseY()GetMouseY()>=pos.y){ + if(!canClose){ + canClose=true; + InternalRefresh(pge); + } + } else { + if(canClose){ + canClose=false; + InternalRefresh(pge); + } + } } void Window::InternalRefresh(FiestaOnlineEditor*pge){ @@ -25,9 +36,17 @@ void Window::InternalRefresh(FiestaOnlineEditor*pge){ //Window background drawing if(focusedWindow==this){ - pge->FillRect({0,headerHeight},size,VERY_DARK_BLUE); + if(canClose){ + pge->FillRect({0,headerHeight},size,VERY_DARK_RED); + } else { + pge->FillRect({0,headerHeight},size,VERY_DARK_BLUE); + } } else { - pge->FillRect({0,headerHeight},size,VERY_DARK_GREY); + if(canClose){ + pge->FillRect({0,headerHeight},size,DARK_GREY); + } else { + pge->FillRect({0,headerHeight},size,VERY_DARK_GREY); + } } //All other drawing functions should go here. @@ -36,9 +55,17 @@ void Window::InternalRefresh(FiestaOnlineEditor*pge){ Refresh(pge); pos.y-=headerHeight; if(focusedWindow==this){ - pge->FillRect({0,0},{size.x,headerHeight},VERY_DARK_BLUE); + if(canClose){ + pge->FillRect({0,0},{size.x,headerHeight},VERY_DARK_RED); + } else { + pge->FillRect({0,0},{size.x,headerHeight},VERY_DARK_BLUE); + } } else { - pge->FillRect({0,0},{size.x,headerHeight},VERY_DARK_GREY); + if(canClose){ + pge->FillRect({0,0},{size.x,headerHeight},DARK_GREY); + } 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); @@ -79,5 +106,16 @@ void Window::InternalMouseFocus(FiestaOnlineEditor*pge){ if(pge->GetMouse(0).bReleased){ dragging=false; } + if(pge->GetMouse(1).bPressed){ + closed=true; + } } -void Window::MouseFocus(FiestaOnlineEditor*pge){} \ No newline at end of file +void Window::MouseFocus(FiestaOnlineEditor*pge){} + +bool Window::IsClosed(){ + return closed; +} + +void Window::SetFocusedWindow(Window*w){ + focusedWindow=w; +} \ No newline at end of file diff --git a/FiestaOnlineEditor/Window.h b/FiestaOnlineEditor/Window.h index 2afbdf8..c2b7ff6 100644 --- a/FiestaOnlineEditor/Window.h +++ b/FiestaOnlineEditor/Window.h @@ -10,6 +10,8 @@ private: const int headerHeight=12; bool dragging=false; vf2d dragPoint; + bool canClose=false; + bool closed=false; protected: vi2d size; Sprite*sprWindow; @@ -23,8 +25,10 @@ public: void InternalRefresh(FiestaOnlineEditor*pge); void Draw(FiestaOnlineEditor*pge); bool IsFocusedWindow(); + static void SetFocusedWindow(Window*w); void Cleanup(); bool IsInBounds(vf2d point); void InternalMouseFocus(FiestaOnlineEditor*pge); virtual void MouseFocus(FiestaOnlineEditor*pge); + bool IsClosed(); }; \ No newline at end of file