From 7077fef33e648c266635bda2cf55fc6a6ed303db Mon Sep 17 00:00:00 2001 From: Loic Guegan Date: Mon, 2 Jan 2023 12:43:46 +0100 Subject: [PATCH] Debug and cleaning --- CMakeLists.txt | 4 +++- src/MainWindow.cpp | 2 +- src/MainWindow.hpp | 1 + src/config.h.in | 5 +++++ src/game_tab/left_panel/board/BoardCanvas.cpp | 2 +- src/game_tab/left_panel/board/BoardCanvas.hpp | 4 ++-- 6 files changed, 13 insertions(+), 5 deletions(-) create mode 100644 src/config.h.in diff --git a/CMakeLists.txt b/CMakeLists.txt index eee6a42..130849f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.10) -project(ochess VERSION "0.0.0") +project(ochess VERSION 0.0.0) # wxWidgets find_package(wxWidgets COMPONENTS net gl core base adv aui propgrid REQUIRED) @@ -8,6 +8,8 @@ include(${wxWidgets_USE_FILE}) # Ochess include_directories(src) file(GLOB_RECURSE CPP_FILES src/*.cpp) +configure_file(${CMAKE_SOURCE_DIR}/src/config.h.in ${CMAKE_BINARY_DIR}/config.h) +include_directories(${CMAKE_CURRENT_BINARY_DIR}) # Enable access to config.h add_executable(ochess ${CPP_FILES}) target_link_libraries(ochess ${wxWidgets_LIBRARIES}) diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index 5305a28..f468723 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -18,7 +18,7 @@ MainWindow::MainWindow() : MainFrame(NULL, wxID_ANY, "OChess: The Open Chess software", wxDefaultPosition, wxSize(1500, 1000)), prefsEditor(nullptr) { - SetStatusText("OChess"); + SetStatusText("OChess v"+std::string(OCHESS_VERSION)); /// File menu menu_file->Append(1, "Settings", "Configure OChess"); diff --git a/src/MainWindow.hpp b/src/MainWindow.hpp index 3596b66..b8025aa 100644 --- a/src/MainWindow.hpp +++ b/src/MainWindow.hpp @@ -6,6 +6,7 @@ #include #include #include +#include "config.h" wxDECLARE_EVENT(REFRESH_TAB_TITLE, wxCommandEvent); wxDECLARE_EVENT(NEW_GAME_EVENT, wxCommandEvent); diff --git a/src/config.h.in b/src/config.h.in new file mode 100644 index 0000000..b00a11d --- /dev/null +++ b/src/config.h.in @@ -0,0 +1,5 @@ +#define OCHESS_VERSION "@PROJECT_VERSION@" +#define OCHESS_MAJOR "@PROJECT_VERSION_MAJOR@" +#define OCHESS_MINOR "@PROJECT_VERSION_MINOR@" +#define OCHESS_PATCH "@PROJECT_VERSION_PATCH@" +#define OCHESS_TWEAK "@PROJECT_VERSION_TWEAK@" diff --git a/src/game_tab/left_panel/board/BoardCanvas.cpp b/src/game_tab/left_panel/board/BoardCanvas.cpp index f6846f1..4f95353 100644 --- a/src/game_tab/left_panel/board/BoardCanvas.cpp +++ b/src/game_tab/left_panel/board/BoardCanvas.cpp @@ -133,7 +133,7 @@ void BoardCanvas::SetupBoard(const GameState &new_gs) { Refresh(); } -void BoardCanvas::Animate(const GameState &new_gs, std::string src, std::string dst, bool faster){ +void BoardCanvas::Animate(const GameState &new_gs, const std::string &src, const std::string &dst, bool faster){ std::uint8_t pfile = src[0]-'a'; std::uint8_t prank = src[1]-'1'; adata.piece_moved = gs.board[pfile + 8 * (7-prank)]; // Piece to move diff --git a/src/game_tab/left_panel/board/BoardCanvas.hpp b/src/game_tab/left_panel/board/BoardCanvas.hpp index 7b6ccf7..2d2b01c 100644 --- a/src/game_tab/left_panel/board/BoardCanvas.hpp +++ b/src/game_tab/left_panel/board/BoardCanvas.hpp @@ -65,7 +65,7 @@ typedef struct GameState { bool is_black_turn; bool mat_black; bool mat_white; - ClockTime black_time, white_time; + ClockTime black_time={-1,-1,-1}, white_time={-1,-1,-1}; } GameState; class BoardCanvas : public wxPanel { @@ -101,6 +101,6 @@ public: void Swap(); void OnResize(wxSizeEvent &e); void SetupBoard(const GameState &new_gs); - void Animate(const GameState &new_gs, std::string src, std::string dst,bool faster); + void Animate(const GameState &new_gs, const std::string &src, const std::string &dst,bool faster); void SetClockTime(short hours, short min, short sec, bool IsBlack); };