diff options
| author | Loic Guegan <manzerbredes@mailbox.org> | 2023-01-01 17:30:55 +0100 |
|---|---|---|
| committer | Loic Guegan <manzerbredes@mailbox.org> | 2023-01-01 17:30:55 +0100 |
| commit | 88430eec2951290633875b0f036a33bbc6ee60a2 (patch) | |
| tree | 09098d3151ffe2ea0f9307c545ec3a301fc0eef1 /src | |
| parent | f0e6f0b665527e027938d421bf5567d669b285c7 (diff) | |
Improve editor drawing loop
Diffstat (limited to 'src')
| -rw-r--r-- | src/game_tab/right_panel/editor/EditorCanvas.cpp | 15 | ||||
| -rw-r--r-- | src/game_tab/right_panel/editor/EditorCanvas.hpp | 1 |
2 files changed, 11 insertions, 5 deletions
diff --git a/src/game_tab/right_panel/editor/EditorCanvas.cpp b/src/game_tab/right_panel/editor/EditorCanvas.cpp index 8a1c745..3856102 100644 --- a/src/game_tab/right_panel/editor/EditorCanvas.cpp +++ b/src/game_tab/right_panel/editor/EditorCanvas.cpp @@ -1,7 +1,7 @@ #include "EditorCanvas.hpp" EditorCanvas::EditorCanvas(wxFrame *parent, std::shared_ptr<Game> game) - : wxPanel(parent), game(game), NeedRedraw(false) { + : wxPanel(parent), game(game) { hide_icon = LoadPNG("hide", wxSize(CGEditor::status.MoveIconWidth, CGEditor::status.MoveIconWidth)); t.ResizePieces(CGEditor::status.MoveIconWidth); @@ -210,10 +210,17 @@ void EditorCanvas::MouseEvent(wxMouseEvent &event) { Refresh(); } - // Should another draw of CGEditor be made? - if (NeedRedraw) { + // Handle editor events + Update(); + bool need_redraw=false; + for(auto event: status.Events){ + HandleEvent(event); + need_redraw=true; + } + if(need_redraw){ + status.Events.clear(); Refresh(); - NeedRedraw = false; + Update(); } } diff --git a/src/game_tab/right_panel/editor/EditorCanvas.hpp b/src/game_tab/right_panel/editor/EditorCanvas.hpp index 7ee56d3..740a6a1 100644 --- a/src/game_tab/right_panel/editor/EditorCanvas.hpp +++ b/src/game_tab/right_panel/editor/EditorCanvas.hpp @@ -11,7 +11,6 @@ wxDECLARE_EVENT(GAME_CHANGE, wxCommandEvent); class EditorCanvas : public wxPanel, public cgeditor::CGEditor { wxPaintDC *dc; - bool NeedRedraw; wxPoint Middle(cgeditor::Element e); wxBitmap hide_icon; Theme t; |
