mirror of
https://gitlab.com/manzerbredes/ochess.git
synced 2025-04-19 04:09:41 +00:00
Improve game tab
This commit is contained in:
parent
8bf9e7e7b5
commit
679c735596
8 changed files with 31 additions and 114 deletions
|
@ -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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue