aboutsummaryrefslogtreecommitdiff
path: root/src/game_tab/right_panel/editor/EditorCanvas.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/game_tab/right_panel/editor/EditorCanvas.cpp')
-rw-r--r--src/game_tab/right_panel/editor/EditorCanvas.cpp40
1 files changed, 9 insertions, 31 deletions
diff --git a/src/game_tab/right_panel/editor/EditorCanvas.cpp b/src/game_tab/right_panel/editor/EditorCanvas.cpp
index ae0c096..8a1c745 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)
- : wxPanel(parent), NeedRedraw(false) {
+EditorCanvas::EditorCanvas(wxFrame *parent, std::shared_ptr<Game> game)
+ : wxPanel(parent), game(game), NeedRedraw(false) {
hide_icon = LoadPNG("hide", wxSize(CGEditor::status.MoveIconWidth,
CGEditor::status.MoveIconWidth));
t.ResizePieces(CGEditor::status.MoveIconWidth);
@@ -173,28 +173,18 @@ void EditorCanvas::DrawElement(const cgeditor::Element &e) {
}
}
void EditorCanvas::HandleEvent(const cgeditor::Event &e) {
- wxLogDebug("Editor event!");
if (e.type == cgeditor::Event::Goto) {
- wxCommandEvent event(GOTO_MOVE_EVENT, GetId());
- event.SetEventObject(this);
- event.SetClientData(e.move);
- ProcessEvent(event);
+ game->SetCurrent((HalfMove *)e.move);
} else if (e.type == cgeditor::Event::Delete) {
- wxCommandEvent event(DELETE_MOVE_EVENT, GetId());
- event.SetEventObject(this);
- event.SetClientData(e.move);
- ProcessEvent(event);
+ game->DeleteMove((HalfMove *)e.move);
} else if (e.type == cgeditor::Event::Promote) {
- wxCommandEvent event(PROMOTE_MOVE_EVENT, GetId());
- event.SetEventObject(this);
- event.SetClientData(e.move);
- ProcessEvent(event);
+ game->PromoteMove((HalfMove *)e.move);
} else if (e.type == cgeditor::Event::SetAsMainline) {
- wxCommandEvent event(SET_AS_MAINLINE_EVENT, GetId());
- event.SetEventObject(this);
- event.SetClientData(e.move);
- ProcessEvent(event);
+ game->SetMoveAsMainline((HalfMove *)e.move);
}
+ wxCommandEvent event(GAME_CHANGE, GetId());
+ event.SetEventObject(this);
+ ProcessEvent(event);
}
void EditorCanvas::MouseEvent(wxMouseEvent &event) {
@@ -234,17 +224,5 @@ void EditorCanvas::SetMoves(HalfMove *moves, HalfMove *current) {
Refresh();
}
-void EditorCanvas::OnKeyEvent(wxKeyEvent &event) {
- /*if (event.GetKeyCode() == WXK_LEFT) {
- wxCommandEvent previousEvent(PREVIOUS_MOVE_EVENT, GetId());
- previousEvent.SetEventObject(this);
- ProcessEvent(previousEvent);
- } else if (event.GetKeyCode() == WXK_RIGHT) {
- wxCommandEvent nextEvent(NEXT_MOVE_EVENT, GetId());
- nextEvent.SetEventObject(this);
- ProcessEvent(nextEvent);
- }*/
-}
-
wxBEGIN_EVENT_TABLE(EditorCanvas, wxPanel) EVT_PAINT(EditorCanvas::OnPaint)
EVT_MOUSE_EVENTS(EditorCanvas::MouseEvent) wxEND_EVENT_TABLE()