mirror of
https://gitlab.com/manzerbredes/ochess.git
synced 2025-04-07 02:26:29 +02:00
Refactoring game tab
This commit is contained in:
parent
7178f18ab8
commit
bf485fa577
16 changed files with 68 additions and 69 deletions
|
@ -11,8 +11,8 @@ GameTab::GameTab(wxFrame *parent, Game *game)
|
||||||
|
|
||||||
// Panels
|
// Panels
|
||||||
game->BuildAndVerify();
|
game->BuildAndVerify();
|
||||||
board_panel = new BoardPanel((wxFrame *)splitter, game);
|
board_panel = new GameTabLeftPanel((wxFrame *)splitter, game);
|
||||||
editor_panel = new EditorPanel((wxFrame *)splitter, game);
|
editor_panel = new GameTabRightPanel((wxFrame *)splitter, game);
|
||||||
splitter->SplitVertically(board_panel, editor_panel);
|
splitter->SplitVertically(board_panel, editor_panel);
|
||||||
|
|
||||||
// Setup splitter
|
// Setup splitter
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
#include "ChessArbiter.hpp"
|
#include "ChessArbiter.hpp"
|
||||||
#include "Game.hpp"
|
#include "Game.hpp"
|
||||||
#include "HalfMove.hpp"
|
#include "HalfMove.hpp"
|
||||||
#include "board/BoardPanel.hpp"
|
#include "left_panel/GameTabLeftPanel.hpp"
|
||||||
#include "editor/EditorPanel.hpp"
|
#include "right_panel/GameTabRightPanel.hpp"
|
||||||
#include "ochess.hpp"
|
#include "ochess.hpp"
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <wx/collpane.h>
|
#include <wx/collpane.h>
|
||||||
|
@ -14,8 +14,8 @@ wxDECLARE_EVENT(REFRESH_TAB_TITLE, wxCommandEvent);
|
||||||
wxDECLARE_EVENT(GAME_CHANGE, wxCommandEvent);
|
wxDECLARE_EVENT(GAME_CHANGE, wxCommandEvent);
|
||||||
|
|
||||||
class GameTab : public wxPanel, public TabInfos {
|
class GameTab : public wxPanel, public TabInfos {
|
||||||
EditorPanel *editor_panel;
|
GameTabRightPanel *editor_panel;
|
||||||
BoardPanel *board_panel;
|
GameTabLeftPanel *board_panel;
|
||||||
Game *game;
|
Game *game;
|
||||||
void RefreshLabel();
|
void RefreshLabel();
|
||||||
void OnRefreshTabTitle(wxCommandEvent &event);
|
void OnRefreshTabTitle(wxCommandEvent &event);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include "BoardPanel.hpp"
|
#include "GameTabLeftPanel.hpp"
|
||||||
#include <wx/clipbrd.h>
|
#include <wx/clipbrd.h>
|
||||||
|
|
||||||
BoardPanel::BoardPanel(wxFrame *parent, Game *game)
|
GameTabLeftPanel::GameTabLeftPanel(wxFrame *parent, Game *game)
|
||||||
: wxPanel(parent), game(game) {
|
: wxPanel(parent), game(game) {
|
||||||
|
|
||||||
wxBoxSizer *board_panel_sizer = new wxBoxSizer(wxVERTICAL);
|
wxBoxSizer *board_panel_sizer = new wxBoxSizer(wxVERTICAL);
|
||||||
|
@ -21,44 +21,44 @@ BoardPanel::BoardPanel(wxFrame *parent, Game *game)
|
||||||
board_panel_sizer->Add(board_panel_button_sizer, 0);
|
board_panel_sizer->Add(board_panel_button_sizer, 0);
|
||||||
this->SetSizer(board_panel_sizer);
|
this->SetSizer(board_panel_sizer);
|
||||||
|
|
||||||
Bind(PLAY_MOVE_EVENT, &BoardPanel::OnPlay, this, wxID_ANY);
|
Bind(PLAY_MOVE_EVENT, &GameTabLeftPanel::OnPlay, this, wxID_ANY);
|
||||||
Bind(PREVIOUS_MOVE_EVENT, &BoardPanel::OnPreviousMove, this, wxID_ANY);
|
Bind(PREVIOUS_MOVE_EVENT, &GameTabLeftPanel::OnPreviousMove, this, wxID_ANY);
|
||||||
Bind(NEXT_MOVE_EVENT, &BoardPanel::OnNextMove, this, wxID_ANY);
|
Bind(NEXT_MOVE_EVENT, &GameTabLeftPanel::OnNextMove, this, wxID_ANY);
|
||||||
Bind(wxEVT_BUTTON, &BoardPanel::OnSwap, this, SWAP_BTN);
|
Bind(wxEVT_BUTTON, &GameTabLeftPanel::OnSwap, this, SWAP_BTN);
|
||||||
Bind(wxEVT_BUTTON, &BoardPanel::OnZoomIn, this, ZOOM_IN_BTN);
|
Bind(wxEVT_BUTTON, &GameTabLeftPanel::OnZoomIn, this, ZOOM_IN_BTN);
|
||||||
Bind(wxEVT_BUTTON, &BoardPanel::OnZoomOut, this, ZOOM_OUT_BTN);
|
Bind(wxEVT_BUTTON, &GameTabLeftPanel::OnZoomOut, this, ZOOM_OUT_BTN);
|
||||||
Bind(wxEVT_BUTTON, &BoardPanel::OnCopyFEN, this, COPY_FEN_BTN);
|
Bind(wxEVT_BUTTON, &GameTabLeftPanel::OnCopyFEN, this, COPY_FEN_BTN);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BoardPanel::OnPreviousMove(wxCommandEvent &event) {
|
void GameTabLeftPanel::OnPreviousMove(wxCommandEvent &event) {
|
||||||
game->Previous();
|
game->Previous();
|
||||||
Notify();
|
Notify();
|
||||||
NotifyEditor();
|
NotifyEditor();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BoardPanel::OnZoomIn(wxCommandEvent &event) {
|
void GameTabLeftPanel::OnZoomIn(wxCommandEvent &event) {
|
||||||
wxLogDebug("Clicked on zoom in");
|
wxLogDebug("Clicked on zoom in");
|
||||||
board_canvas->Zoom(10);
|
board_canvas->Zoom(10);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BoardPanel::OnZoomOut(wxCommandEvent &event) {
|
void GameTabLeftPanel::OnZoomOut(wxCommandEvent &event) {
|
||||||
wxLogDebug("Clicked on zoom out");
|
wxLogDebug("Clicked on zoom out");
|
||||||
board_canvas->Zoom(-10);
|
board_canvas->Zoom(-10);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BoardPanel::OnSwap(wxCommandEvent &event) {
|
void GameTabLeftPanel::OnSwap(wxCommandEvent &event) {
|
||||||
wxLogDebug("Clicked on swap");
|
wxLogDebug("Clicked on swap");
|
||||||
board_canvas->Swap();
|
board_canvas->Swap();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BoardPanel::OnNextMove(wxCommandEvent &event) {
|
void GameTabLeftPanel::OnNextMove(wxCommandEvent &event) {
|
||||||
wxLogDebug("Game tab received NEXT_MOVE_EVENT");
|
wxLogDebug("Game tab received NEXT_MOVE_EVENT");
|
||||||
game->Next();
|
game->Next();
|
||||||
Notify();
|
Notify();
|
||||||
NotifyEditor();
|
NotifyEditor();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BoardPanel::OnPlay(wxCommandEvent &event) {
|
void GameTabLeftPanel::OnPlay(wxCommandEvent &event) {
|
||||||
wxLogDebug("Game tab received PLAY_MOVE_EVENT");
|
wxLogDebug("Game tab received PLAY_MOVE_EVENT");
|
||||||
if (game->Play(event.GetString().ToStdString())) {
|
if (game->Play(event.GetString().ToStdString())) {
|
||||||
NotifyEditor();
|
NotifyEditor();
|
||||||
|
@ -66,7 +66,7 @@ void BoardPanel::OnPlay(wxCommandEvent &event) {
|
||||||
Notify();
|
Notify();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BoardPanel::OnCopyFEN(wxCommandEvent &event) {
|
void GameTabLeftPanel::OnCopyFEN(wxCommandEvent &event) {
|
||||||
wxLogDebug("Clicked on copy fen");
|
wxLogDebug("Clicked on copy fen");
|
||||||
if (wxTheClipboard->Open()) {
|
if (wxTheClipboard->Open()) {
|
||||||
wxTheClipboard->SetData(new wxTextDataObject(game->GetFen()));
|
wxTheClipboard->SetData(new wxTextDataObject(game->GetFen()));
|
||||||
|
@ -74,7 +74,7 @@ void BoardPanel::OnCopyFEN(wxCommandEvent &event) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BoardPanel::Notify() {
|
void GameTabLeftPanel::Notify() {
|
||||||
std::string fen = game->GetFen();
|
std::string fen = game->GetFen();
|
||||||
std::map<char, std::uint8_t> captures;
|
std::map<char, std::uint8_t> captures;
|
||||||
HalfMove *m = game->GetCurrentMove();
|
HalfMove *m = game->GetCurrentMove();
|
||||||
|
@ -85,12 +85,12 @@ void BoardPanel::Notify() {
|
||||||
game->IsBlackToPlay(), captures);
|
game->IsBlackToPlay(), captures);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BoardPanel::NotifyEditor() {
|
void GameTabLeftPanel::NotifyEditor() {
|
||||||
wxCommandEvent previousEvent(GAME_CHANGE, GetId());
|
wxCommandEvent previousEvent(GAME_CHANGE, GetId());
|
||||||
previousEvent.SetEventObject(this);
|
previousEvent.SetEventObject(this);
|
||||||
ProcessEvent(previousEvent);
|
ProcessEvent(previousEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BoardPanel::ApplyPreferences() {
|
void GameTabLeftPanel::ApplyPreferences() {
|
||||||
board_canvas->ApplyPreferences();
|
board_canvas->ApplyPreferences();
|
||||||
}
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "../Game.hpp"
|
#include "../Game.hpp"
|
||||||
#include "BoardCanvas.hpp"
|
#include "board/BoardCanvas.hpp"
|
||||||
#include "ochess.hpp"
|
#include "ochess.hpp"
|
||||||
|
|
||||||
// Foreign events
|
// Foreign events
|
||||||
|
@ -9,13 +9,13 @@ wxDECLARE_EVENT(GAME_CHANGE, wxCommandEvent);
|
||||||
|
|
||||||
enum { COPY_FEN_BTN = wxID_HIGHEST + 1, ZOOM_IN_BTN, ZOOM_OUT_BTN, SWAP_BTN };
|
enum { COPY_FEN_BTN = wxID_HIGHEST + 1, ZOOM_IN_BTN, ZOOM_OUT_BTN, SWAP_BTN };
|
||||||
|
|
||||||
class BoardPanel : public wxPanel {
|
class GameTabLeftPanel : public wxPanel {
|
||||||
Game *game;
|
Game *game;
|
||||||
BoardCanvas *board_canvas;
|
BoardCanvas *board_canvas;
|
||||||
void NotifyEditor();
|
void NotifyEditor();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
BoardPanel(wxFrame *parent, Game *game);
|
GameTabLeftPanel(wxFrame *parent, Game *game);
|
||||||
void Notify();
|
void Notify();
|
||||||
void OnPlay(wxCommandEvent &event);
|
void OnPlay(wxCommandEvent &event);
|
||||||
void OnGotoMove(wxCommandEvent &event);
|
void OnGotoMove(wxCommandEvent &event);
|
|
@ -1,4 +1,4 @@
|
||||||
#include "EditorPanel.hpp"
|
#include "GameTabRightPanel.hpp"
|
||||||
#include "LiveEngineDialog.hpp"
|
#include "LiveEngineDialog.hpp"
|
||||||
|
|
||||||
wxDEFINE_EVENT(GOTO_MOVE_EVENT, wxCommandEvent);
|
wxDEFINE_EVENT(GOTO_MOVE_EVENT, wxCommandEvent);
|
||||||
|
@ -8,7 +8,7 @@ wxDEFINE_EVENT(SET_AS_MAINLINE_EVENT, wxCommandEvent);
|
||||||
wxDEFINE_EVENT(PREVIOUS_MOVE_EVENT, wxCommandEvent);
|
wxDEFINE_EVENT(PREVIOUS_MOVE_EVENT, wxCommandEvent);
|
||||||
wxDEFINE_EVENT(NEXT_MOVE_EVENT, wxCommandEvent);
|
wxDEFINE_EVENT(NEXT_MOVE_EVENT, wxCommandEvent);
|
||||||
|
|
||||||
EditorPanel::EditorPanel(wxFrame *parent, Game *game)
|
GameTabRightPanel::GameTabRightPanel(wxFrame *parent, Game *game)
|
||||||
: TabGameRightPanel(parent), game(game), selected_item(-1) {
|
: TabGameRightPanel(parent), game(game), selected_item(-1) {
|
||||||
editor_canvas = new EditorCanvas((wxFrame *)editor_page);
|
editor_canvas = new EditorCanvas((wxFrame *)editor_page);
|
||||||
editor_canvas_sizer->Add(editor_canvas, 1, wxEXPAND);
|
editor_canvas_sizer->Add(editor_canvas, 1, wxEXPAND);
|
||||||
|
@ -24,28 +24,28 @@ EditorPanel::EditorPanel(wxFrame *parent, Game *game)
|
||||||
RefreshTagsList();
|
RefreshTagsList();
|
||||||
|
|
||||||
// Bind events
|
// Bind events
|
||||||
this->Bind(wxEVT_TEXT, &EditorPanel::OnCommentChange, this,
|
this->Bind(wxEVT_TEXT, &GameTabRightPanel::OnCommentChange, this,
|
||||||
COMMENT_INPUT_BOX);
|
COMMENT_INPUT_BOX);
|
||||||
this->Bind(GOTO_MOVE_EVENT, &EditorPanel::OnGotoMove, this, wxID_ANY);
|
this->Bind(GOTO_MOVE_EVENT, &GameTabRightPanel::OnGotoMove, this, wxID_ANY);
|
||||||
this->Bind(DELETE_MOVE_EVENT, &EditorPanel::OnMoveDelete, this, wxID_ANY);
|
this->Bind(DELETE_MOVE_EVENT, &GameTabRightPanel::OnMoveDelete, this, wxID_ANY);
|
||||||
this->Bind(PROMOTE_MOVE_EVENT, &EditorPanel::OnMovePromote, this, wxID_ANY);
|
this->Bind(PROMOTE_MOVE_EVENT, &GameTabRightPanel::OnMovePromote, this, wxID_ANY);
|
||||||
this->Bind(SET_AS_MAINLINE_EVENT, &EditorPanel::OnMoveSetAsMainline, this,
|
this->Bind(SET_AS_MAINLINE_EVENT, &GameTabRightPanel::OnMoveSetAsMainline, this,
|
||||||
wxID_ANY);
|
wxID_ANY);
|
||||||
this->Bind(NEXT_MOVE_EVENT, &EditorPanel::OnNextMove, this, wxID_ANY);
|
this->Bind(NEXT_MOVE_EVENT, &GameTabRightPanel::OnNextMove, this, wxID_ANY);
|
||||||
this->Bind(PREVIOUS_MOVE_EVENT, &EditorPanel::OnPreviousMove, this, wxID_ANY);
|
this->Bind(PREVIOUS_MOVE_EVENT, &GameTabRightPanel::OnPreviousMove, this, wxID_ANY);
|
||||||
this->Bind(wxEVT_LIST_ITEM_SELECTED, &EditorPanel::OnTagSelected, this,
|
this->Bind(wxEVT_LIST_ITEM_SELECTED, &GameTabRightPanel::OnTagSelected, this,
|
||||||
wxID_ANY);
|
wxID_ANY);
|
||||||
this->Bind(wxEVT_LIST_ITEM_DESELECTED, &EditorPanel::OnTagDeselected, this,
|
this->Bind(wxEVT_LIST_ITEM_DESELECTED, &GameTabRightPanel::OnTagDeselected, this,
|
||||||
wxID_ANY);
|
wxID_ANY);
|
||||||
this->Bind(wxEVT_BUTTON, &EditorPanel::OnApply, this, UPDATE_BTN);
|
this->Bind(wxEVT_BUTTON, &GameTabRightPanel::OnApply, this, UPDATE_BTN);
|
||||||
this->Bind(wxEVT_BUTTON, &EditorPanel::OnDelete, this, DELETE_BTN);
|
this->Bind(wxEVT_BUTTON, &GameTabRightPanel::OnDelete, this, DELETE_BTN);
|
||||||
this->Bind(wxEVT_BUTTON, &EditorPanel::OnLiveAnalysis, this,
|
this->Bind(wxEVT_BUTTON, &GameTabRightPanel::OnLiveAnalysis, this,
|
||||||
LIVE_ANALYSIS_GAME_BUTTON);
|
LIVE_ANALYSIS_GAME_BUTTON);
|
||||||
|
|
||||||
ApplyPreferences();
|
ApplyPreferences();
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorPanel::OnLiveAnalysis(wxCommandEvent &event) {
|
void GameTabRightPanel::OnLiveAnalysis(wxCommandEvent &event) {
|
||||||
int selection = engine_list->GetSelection();
|
int selection = engine_list->GetSelection();
|
||||||
if (selection != wxNOT_FOUND) {
|
if (selection != wxNOT_FOUND) {
|
||||||
LiveEngineDialog *diag = new LiveEngineDialog(this, engine_list->GetString(selection).ToStdString());
|
LiveEngineDialog *diag = new LiveEngineDialog(this, engine_list->GetString(selection).ToStdString());
|
||||||
|
@ -54,7 +54,7 @@ void EditorPanel::OnLiveAnalysis(wxCommandEvent &event) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorPanel::OnTagSelected(wxListEvent &event) {
|
void GameTabRightPanel::OnTagSelected(wxListEvent &event) {
|
||||||
wxListItem item = event.GetItem();
|
wxListItem item = event.GetItem();
|
||||||
std::string key = item.GetText().ToStdString();
|
std::string key = item.GetText().ToStdString();
|
||||||
tagTextCtrl->ChangeValue(key);
|
tagTextCtrl->ChangeValue(key);
|
||||||
|
@ -65,19 +65,19 @@ void EditorPanel::OnTagSelected(wxListEvent &event) {
|
||||||
delete_button->Enable(true);
|
delete_button->Enable(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorPanel::OnTagDeselected(wxListEvent &event) {
|
void GameTabRightPanel::OnTagDeselected(wxListEvent &event) {
|
||||||
selected_item = -1;
|
selected_item = -1;
|
||||||
delete_button->Enable(false);
|
delete_button->Enable(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorPanel::NotifyBoard() {
|
void GameTabRightPanel::NotifyBoard() {
|
||||||
wxCommandEvent previousEvent(GAME_CHANGE, GetId());
|
wxCommandEvent previousEvent(GAME_CHANGE, GetId());
|
||||||
previousEvent.SetEventObject(this);
|
previousEvent.SetEventObject(this);
|
||||||
ProcessEvent(previousEvent);
|
ProcessEvent(previousEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorPanel::OnCommentChange(wxCommandEvent &event) {
|
void GameTabRightPanel::OnCommentChange(wxCommandEvent &event) {
|
||||||
wxLogDebug("EditorPanel: comment input change");
|
wxLogDebug("GameTabRightPanel: comment input change");
|
||||||
HalfMove *m = game->GetCurrentMove();
|
HalfMove *m = game->GetCurrentMove();
|
||||||
if (m != NULL) {
|
if (m != NULL) {
|
||||||
m->SetComment(event.GetString().ToStdString());
|
m->SetComment(event.GetString().ToStdString());
|
||||||
|
@ -85,7 +85,7 @@ void EditorPanel::OnCommentChange(wxCommandEvent &event) {
|
||||||
editor_canvas->Refresh();
|
editor_canvas->Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorPanel::OnApply(wxCommandEvent &event) {
|
void GameTabRightPanel::OnApply(wxCommandEvent &event) {
|
||||||
std::string key = tagTextCtrl->GetValue().ToStdString();
|
std::string key = tagTextCtrl->GetValue().ToStdString();
|
||||||
if (key == "FEN") {
|
if (key == "FEN") {
|
||||||
SHOW_DIALOG_ERROR("Editing the FEN tag is forbidden");
|
SHOW_DIALOG_ERROR("Editing the FEN tag is forbidden");
|
||||||
|
@ -101,7 +101,7 @@ void EditorPanel::OnApply(wxCommandEvent &event) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorPanel::OnDelete(wxCommandEvent &event) {
|
void GameTabRightPanel::OnDelete(wxCommandEvent &event) {
|
||||||
if (selected_item >= 0) {
|
if (selected_item >= 0) {
|
||||||
wxListItem item;
|
wxListItem item;
|
||||||
item.SetColumn(0);
|
item.SetColumn(0);
|
||||||
|
@ -118,34 +118,34 @@ void EditorPanel::OnDelete(wxCommandEvent &event) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorPanel::OnGotoMove(wxCommandEvent &event) {
|
void GameTabRightPanel::OnGotoMove(wxCommandEvent &event) {
|
||||||
wxLogDebug("EditorPanel: received GOTO_MOVE_EVENT");
|
wxLogDebug("GameTabRightPanel: received GOTO_MOVE_EVENT");
|
||||||
game->SetCurrent((HalfMove *)event.GetClientData());
|
game->SetCurrent((HalfMove *)event.GetClientData());
|
||||||
NotifyBoard();
|
NotifyBoard();
|
||||||
editor_canvas->Refresh();
|
editor_canvas->Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorPanel::OnMoveDelete(wxCommandEvent &event) {
|
void GameTabRightPanel::OnMoveDelete(wxCommandEvent &event) {
|
||||||
game->DeleteMove((HalfMove *)event.GetClientData());
|
game->DeleteMove((HalfMove *)event.GetClientData());
|
||||||
NotifyBoard();
|
NotifyBoard();
|
||||||
editor_canvas->Refresh();
|
editor_canvas->Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorPanel::OnMovePromote(wxCommandEvent &event) {
|
void GameTabRightPanel::OnMovePromote(wxCommandEvent &event) {
|
||||||
wxLogDebug("EditorPanel: promote move called");
|
wxLogDebug("GameTabRightPanel: promote move called");
|
||||||
game->PromoteMove((HalfMove *)event.GetClientData());
|
game->PromoteMove((HalfMove *)event.GetClientData());
|
||||||
NotifyBoard();
|
NotifyBoard();
|
||||||
editor_canvas->Refresh();
|
editor_canvas->Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorPanel::OnMoveSetAsMainline(wxCommandEvent &event) {
|
void GameTabRightPanel::OnMoveSetAsMainline(wxCommandEvent &event) {
|
||||||
wxLogDebug("EditorPanel: set move as mainline called");
|
wxLogDebug("GameTabRightPanel: set move as mainline called");
|
||||||
game->SetMoveAsMainline((HalfMove *)event.GetClientData());
|
game->SetMoveAsMainline((HalfMove *)event.GetClientData());
|
||||||
NotifyBoard();
|
NotifyBoard();
|
||||||
editor_canvas->Refresh();
|
editor_canvas->Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorPanel::Notify() {
|
void GameTabRightPanel::Notify() {
|
||||||
HalfMove *m = game->GetCurrentMove();
|
HalfMove *m = game->GetCurrentMove();
|
||||||
if (m != NULL) {
|
if (m != NULL) {
|
||||||
comment_input->ChangeValue(
|
comment_input->ChangeValue(
|
||||||
|
@ -154,7 +154,7 @@ void EditorPanel::Notify() {
|
||||||
editor_canvas->SetMoves(game->GetMoves(), m);
|
editor_canvas->SetMoves(game->GetMoves(), m);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorPanel::ApplyPreferences() {
|
void GameTabRightPanel::ApplyPreferences() {
|
||||||
engine_list->Clear();
|
engine_list->Clear();
|
||||||
CONFIG_OPEN(conf);
|
CONFIG_OPEN(conf);
|
||||||
conf->SetPath("engines/");
|
conf->SetPath("engines/");
|
||||||
|
@ -169,7 +169,7 @@ void EditorPanel::ApplyPreferences() {
|
||||||
CONFIG_CLOSE(conf);
|
CONFIG_CLOSE(conf);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorPanel::RefreshTagsList() {
|
void GameTabRightPanel::RefreshTagsList() {
|
||||||
tags_list->DeleteAllItems();
|
tags_list->DeleteAllItems();
|
||||||
for (std::string s : game->ListTags()) {
|
for (std::string s : game->ListTags()) {
|
||||||
long index = tags_list->InsertItem(0, s);
|
long index = tags_list->InsertItem(0, s);
|
||||||
|
@ -180,13 +180,13 @@ void EditorPanel::RefreshTagsList() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorPanel::OnPreviousMove(wxCommandEvent &event) {
|
void GameTabRightPanel::OnPreviousMove(wxCommandEvent &event) {
|
||||||
game->Previous();
|
game->Previous();
|
||||||
Notify();
|
Notify();
|
||||||
NotifyBoard();
|
NotifyBoard();
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorPanel::OnNextMove(wxCommandEvent &event) {
|
void GameTabRightPanel::OnNextMove(wxCommandEvent &event) {
|
||||||
game->Next();
|
game->Next();
|
||||||
Notify();
|
Notify();
|
||||||
NotifyBoard();
|
NotifyBoard();
|
|
@ -1,5 +1,5 @@
|
||||||
#include "../Game.hpp"
|
#include "../Game.hpp"
|
||||||
#include "EditorCanvas.hpp"
|
#include "editor/EditorCanvas.hpp"
|
||||||
#include "ochess.hpp"
|
#include "ochess.hpp"
|
||||||
#include <wx/listctrl.h>
|
#include <wx/listctrl.h>
|
||||||
#include <wx/notebook.h>
|
#include <wx/notebook.h>
|
||||||
|
@ -14,13 +14,13 @@ wxDECLARE_EVENT(REFRESH_TAB_TITLE, wxCommandEvent);
|
||||||
// Foreign events
|
// Foreign events
|
||||||
wxDECLARE_EVENT(GAME_CHANGE, wxCommandEvent);
|
wxDECLARE_EVENT(GAME_CHANGE, wxCommandEvent);
|
||||||
|
|
||||||
class EditorPanel : public TabGameRightPanel {
|
class GameTabRightPanel : public TabGameRightPanel {
|
||||||
Game *game;
|
Game *game;
|
||||||
EditorCanvas *editor_canvas;
|
EditorCanvas *editor_canvas;
|
||||||
long selected_item;
|
long selected_item;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
EditorPanel(wxFrame *parent, Game *game);
|
GameTabRightPanel(wxFrame *parent, Game *game);
|
||||||
void NotifyBoard();
|
void NotifyBoard();
|
||||||
void Notify();
|
void Notify();
|
||||||
void OnCommentChange(wxCommandEvent &event);
|
void OnCommentChange(wxCommandEvent &event);
|
|
@ -1,9 +1,9 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "../HalfMove.hpp"
|
#include "../../HalfMove.hpp"
|
||||||
#include "CGEditor.hpp"
|
#include "CGEditor.hpp"
|
||||||
#include "ochess.hpp"
|
#include "ochess.hpp"
|
||||||
#include "../board/Theme.hpp"
|
#include "../../left_panel/board/Theme.hpp"
|
||||||
|
|
||||||
// Foreign events
|
// Foreign events
|
||||||
wxDECLARE_EVENT(GOTO_MOVE_EVENT, wxCommandEvent);
|
wxDECLARE_EVENT(GOTO_MOVE_EVENT, wxCommandEvent);
|
|
@ -1,4 +1,4 @@
|
||||||
#include "game_tab/board/BoardCanvas.hpp"
|
#include "game_tab/left_panel/board/BoardCanvas.hpp"
|
||||||
#include "ochess.hpp"
|
#include "ochess.hpp"
|
||||||
#include <wx/combobox.h>
|
#include <wx/combobox.h>
|
||||||
#include <wx/dir.h>
|
#include <wx/dir.h>
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
#include "game_tab/board/BoardCanvas.hpp"
|
|
||||||
#include "ochess.hpp"
|
#include "ochess.hpp"
|
||||||
#include <wx/combobox.h>
|
#include <wx/combobox.h>
|
||||||
#include <wx/dir.h>
|
#include <wx/dir.h>
|
||||||
|
|
Loading…
Add table
Reference in a new issue