mirror of
https://gitlab.com/manzerbredes/ochess.git
synced 2025-07-03 10:47:39 +00:00
Migrate to std::shared_ptr<Game>
This commit is contained in:
parent
4c959fe12e
commit
44ea0a50a3
16 changed files with 44 additions and 49 deletions
|
@ -3,7 +3,7 @@
|
|||
|
||||
wxDEFINE_EVENT(GAME_CHANGE, wxCommandEvent);
|
||||
|
||||
GameTab::GameTab(wxFrame *parent, Game *game)
|
||||
GameTab::GameTab(wxFrame *parent, std::shared_ptr<Game> game)
|
||||
: wxPanel(parent), game(game), TabInfos(TabInfos::GAME) {
|
||||
// Splitter
|
||||
wxSplitterWindow *splitter = new wxSplitterWindow(this, wxID_ANY);
|
||||
|
@ -30,10 +30,6 @@ GameTab::GameTab(wxFrame *parent, Game *game)
|
|||
Bind(GAME_CHANGE, &GameTab::OnGameChange, this, wxID_ANY);
|
||||
}
|
||||
|
||||
GameTab::~GameTab() {
|
||||
delete game;
|
||||
}
|
||||
|
||||
void GameTab::OnGameChange(wxCommandEvent &event) {
|
||||
board_panel->Notify();
|
||||
editor_panel->Notify();
|
||||
|
|
|
@ -16,16 +16,15 @@ wxDECLARE_EVENT(GAME_CHANGE, wxCommandEvent);
|
|||
class GameTab : public wxPanel, public TabInfos {
|
||||
GameTabRightPanel *editor_panel;
|
||||
GameTabLeftPanel *board_panel;
|
||||
Game *game;
|
||||
std::shared_ptr<Game> game;
|
||||
|
||||
void RefreshLabel();
|
||||
void OnRefreshTabTitle(wxCommandEvent &event);
|
||||
void OnGameChange(wxCommandEvent &event);
|
||||
|
||||
public:
|
||||
GameTab(wxFrame *parent, Game *game);
|
||||
~GameTab();
|
||||
GameTab(wxFrame *parent, std::shared_ptr<Game> game);
|
||||
void ApplyPreferences();
|
||||
void *GetGame() { return (game); }
|
||||
std::shared_ptr<Game> GetGame() { return (std::shared_ptr<Game>(game)); }
|
||||
void *GetBase() { return (NULL); };
|
||||
};
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "GameTabLeftPanel.hpp"
|
||||
#include <wx/clipbrd.h>
|
||||
|
||||
GameTabLeftPanel::GameTabLeftPanel(wxFrame *parent, Game *game)
|
||||
GameTabLeftPanel::GameTabLeftPanel(wxFrame *parent, std::shared_ptr<Game> game)
|
||||
: TabGameLeftPanel(parent), game(game) {
|
||||
|
||||
// Add board
|
||||
|
|
|
@ -9,12 +9,12 @@ wxDECLARE_EVENT(GAME_CHANGE, wxCommandEvent);
|
|||
|
||||
|
||||
class GameTabLeftPanel : public TabGameLeftPanel {
|
||||
Game *game;
|
||||
std::shared_ptr<Game> game;
|
||||
BoardCanvas *board_canvas;
|
||||
void NotifyEditor();
|
||||
|
||||
public:
|
||||
GameTabLeftPanel(wxFrame *parent, Game *game);
|
||||
GameTabLeftPanel(wxFrame *parent, std::shared_ptr<Game> game);
|
||||
void Notify();
|
||||
void OnPlay(wxCommandEvent &event);
|
||||
void OnGotoMove(wxCommandEvent &event);
|
||||
|
|
|
@ -7,7 +7,7 @@ wxDEFINE_EVENT(SET_AS_MAINLINE_EVENT, wxCommandEvent);
|
|||
wxDEFINE_EVENT(PREVIOUS_MOVE_EVENT, wxCommandEvent);
|
||||
wxDEFINE_EVENT(NEXT_MOVE_EVENT, wxCommandEvent);
|
||||
|
||||
GameTabRightPanel::GameTabRightPanel(wxFrame *parent, Game *game)
|
||||
GameTabRightPanel::GameTabRightPanel(wxFrame *parent, std::shared_ptr<Game> game)
|
||||
: TabGameRightPanel(parent), game(game), selected_item(-1),
|
||||
live_engine(NULL) {
|
||||
editor_canvas = new EditorCanvas((wxFrame *)editor_page);
|
||||
|
|
|
@ -16,13 +16,13 @@ wxDECLARE_EVENT(REFRESH_TAB_TITLE, wxCommandEvent);
|
|||
wxDECLARE_EVENT(GAME_CHANGE, wxCommandEvent);
|
||||
|
||||
class GameTabRightPanel : public TabGameRightPanel {
|
||||
Game *game;
|
||||
std::shared_ptr<Game> game;
|
||||
EditorCanvas *editor_canvas;
|
||||
long selected_item;
|
||||
LiveEngineDialog *live_engine;
|
||||
|
||||
public:
|
||||
GameTabRightPanel(wxFrame *parent, Game *game);
|
||||
GameTabRightPanel(wxFrame *parent, std::shared_ptr<Game> game);
|
||||
void NotifyBoard();
|
||||
void Notify();
|
||||
void OnCommentChange(wxCommandEvent &event);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue