mirror of
https://gitlab.com/manzerbredes/ochess.git
synced 2025-05-02 01:37:46 +00:00
Remove all warnings from source code
This commit is contained in:
parent
ff671f2171
commit
a9b9ed95f3
31 changed files with 72 additions and 48 deletions
|
@ -11,12 +11,12 @@
|
|||
*/
|
||||
class Game {
|
||||
/// @brief 64 char string that contains all the pieces on the board (used in BoardCanvas)
|
||||
HalfMove *current;
|
||||
HalfMove *moves;
|
||||
std::string board;
|
||||
std::string initial_fen;
|
||||
std::string result;
|
||||
std::unordered_map<std::string, std::string> tags;
|
||||
HalfMove *moves;
|
||||
HalfMove *current;
|
||||
/// @brief Used by various methods of the class
|
||||
chessarbiter::ChessArbiter arbiter;
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ wxDEFINE_EVENT(GAME_CHANGE, wxCommandEvent);
|
|||
wxDEFINE_EVENT(SHOW_ENGINE_EVALUATION, wxCommandEvent);
|
||||
|
||||
GameTab::GameTab(wxFrame *parent, std::shared_ptr<Game> game)
|
||||
: wxPanel(parent), game(game), TabInfos(TabInfos::GAME) {
|
||||
: wxPanel(parent), TabInfos(TabInfos::GAME), game(game) {
|
||||
// Splitter
|
||||
wxSplitterWindow *splitter = new wxSplitterWindow(this, wxID_ANY);
|
||||
splitter->SetSashGravity(0.8);
|
||||
|
@ -41,7 +41,7 @@ GameTab::GameTab(wxFrame *parent, std::shared_ptr<Game> game)
|
|||
void GameTab::OnToolClick(wxCommandEvent &event){
|
||||
short id=event.GetId();
|
||||
if(id==0){
|
||||
if(!related_file.size()>0){
|
||||
if(!(related_file.size()>0)){
|
||||
wxFileDialog
|
||||
newFileDialog(this, _("Save Game"), "", "",
|
||||
"PGN files (*.pgn)|*.pgn", wxFD_SAVE|wxFD_OVERWRITE_PROMPT);
|
||||
|
|
|
@ -50,7 +50,7 @@ std::string HalfMove::GetLineAsSAN(){
|
|||
auto line=GetLine(); // Vector of HalfMove
|
||||
std::string pgn;
|
||||
int count=1;
|
||||
for(int i=0;i<line.size();i++){
|
||||
for(std::size_t i=0;i<line.size();i++){
|
||||
if(i%2==0){
|
||||
pgn+=std::to_string(count)+".";
|
||||
count+=1;
|
||||
|
|
|
@ -25,10 +25,10 @@ GameTabLeftPanel::GameTabLeftPanel(wxFrame *parent, std::shared_ptr<Game> game)
|
|||
|
||||
// Bind events:
|
||||
Bind(PLAY_MOVE_EVENT, &GameTabLeftPanel::OnPlay, this, wxID_ANY);
|
||||
Bind(wxEVT_BUTTON, [bc=board_canvas](wxCommandEvent &event){bc->Zoom(10);}, ZOOM_IN_BTN);
|
||||
Bind(wxEVT_BUTTON, [bc=board_canvas](wxCommandEvent &event){bc->Zoom(-10);}, ZOOM_OUT_BTN);
|
||||
Bind(wxEVT_BUTTON, [bc=board_canvas](wxCommandEvent &event){bc->Swap();}, SWAP_BTN);
|
||||
Bind(wxEVT_KEY_UP, [p=this](wxKeyEvent &e){p->repeat=false;});
|
||||
Bind(wxEVT_BUTTON, [bc=board_canvas](wxCommandEvent &event){UNUSED(event);bc->Zoom(10);}, ZOOM_IN_BTN);
|
||||
Bind(wxEVT_BUTTON, [bc=board_canvas](wxCommandEvent &event){UNUSED(event);bc->Zoom(-10);}, ZOOM_OUT_BTN);
|
||||
Bind(wxEVT_BUTTON, [bc=board_canvas](wxCommandEvent &event){UNUSED(event);bc->Swap();}, SWAP_BTN);
|
||||
Bind(wxEVT_KEY_UP, [p=this](wxKeyEvent &e){UNUSED(e);p->repeat=false;});
|
||||
Bind(wxEVT_KEY_DOWN, [p=this](wxKeyEvent &e){
|
||||
if(e.GetKeyCode() == WXK_RIGHT){
|
||||
p->game->Next();
|
||||
|
|
|
@ -11,8 +11,8 @@ tmp=rot_m.TransformPoint(tmp); \
|
|||
wxDEFINE_EVENT(PLAY_MOVE_EVENT, wxCommandEvent);
|
||||
|
||||
BoardCanvas::BoardCanvas(wxFrame *parent)
|
||||
: wxPanel(parent), black_side(false), frozen(false),
|
||||
lock_square_size(false), t(new Theme()), t_captures(new Theme()) {
|
||||
: wxPanel(parent), t(new Theme()), t_captures(new Theme()), black_side(false), frozen(false),
|
||||
lock_square_size(false) {
|
||||
color_arrows=wxColour(145, 233, 255);
|
||||
is_dragging = false;
|
||||
valid_drag = false;
|
||||
|
@ -64,11 +64,12 @@ BoardCanvas::BoardCanvas(wxFrame *parent, std::uint32_t square_width,
|
|||
: BoardCanvas(parent) {
|
||||
t->ResizeSquaresAndPieces(square_width);
|
||||
t_captures->ResizePieces(t->GetPiecesSizes() * CAPTURE_FACTOR);
|
||||
this->frozen = true;
|
||||
this->frozen = frozen;
|
||||
lock_square_size = true;
|
||||
}
|
||||
|
||||
void BoardCanvas::OnPaint(wxPaintEvent &event) {
|
||||
UNUSED(event);
|
||||
wxBufferedPaintDC dc(this);
|
||||
dc.SetBackground(*wxWHITE_BRUSH);
|
||||
dc.Clear();
|
||||
|
@ -90,7 +91,6 @@ void BoardCanvas::OnPaint(wxPaintEvent &event) {
|
|||
else {
|
||||
// Reuse buffer and animate
|
||||
dc.DrawBitmap(*adata.buffer, 0, 0, true);
|
||||
double percent=adata.frame/adata.frames;
|
||||
// Draw moving piece
|
||||
dc.DrawBitmap(*t->Get(adata.piece_moved),
|
||||
adata.src.x + adata.frame*(adata.transVect.x/adata.frames),
|
||||
|
@ -174,7 +174,6 @@ void BoardCanvas::Animate(const GameState &new_gs, const std::string &src, const
|
|||
int frame_duration=(1000/adata.fps);
|
||||
adata.frame=0;
|
||||
adata.frames=adata.duration/frame_duration; // total number of frames
|
||||
int time_per_frame=adata.duration/adata.frames;
|
||||
wxStopWatch sw;
|
||||
for(int i=adata.frames;i>0;i--){
|
||||
Refresh();
|
||||
|
@ -220,7 +219,7 @@ void BoardCanvas::DrawBoard(wxDC &dc) {
|
|||
}
|
||||
|
||||
// Draw highlighted squares
|
||||
for(int i=0;i<(gs.squares_hl.size()+squares_hl.size());i++){
|
||||
for(std::size_t i=0;i<(gs.squares_hl.size()+squares_hl.size());i++){
|
||||
const GameState::Square &s=i<gs.squares_hl.size() ? gs.squares_hl[i] : squares_hl[i-gs.squares_hl.size()];
|
||||
std::uint8_t sfile = s.square[0]-'a';
|
||||
std::uint8_t srank = s.square[1]-'1';
|
||||
|
@ -357,7 +356,7 @@ void BoardCanvas::DrawBoard(wxDC &dc) {
|
|||
boardY + square_width * 8 + numbers_size.y*2));
|
||||
}
|
||||
// Draw arrows
|
||||
for(int i=0;i<(gs.arrows.size()+arrows.size());i++){
|
||||
for(std::size_t i=0;i<(gs.arrows.size()+arrows.size());i++){
|
||||
const GameState::Arrow &arrow= i<gs.arrows.size() ? gs.arrows[i] : arrows[i-gs.arrows.size()];
|
||||
std::uint8_t sfile = arrow.src[0]-'a';
|
||||
std::uint8_t srank = arrow.src[1]-'1';
|
||||
|
@ -404,7 +403,6 @@ void BoardCanvas::DrawBoard(wxDC &dc) {
|
|||
std::uint32_t PY = boardY + srank * square_width;
|
||||
|
||||
short offset=0,border=5;
|
||||
char s=is_black_promotion ? 's' : 'S';
|
||||
|
||||
for (char p : {'q', 'r', 'b', 'n'}) {
|
||||
p=is_black_promotion ? p : std::toupper(p);
|
||||
|
@ -612,7 +610,7 @@ void BoardCanvas::DrawArrow(wxDC &dc, int xsrc, int ysrc, int xdst, int ydst, st
|
|||
wxPoint vect(xdst-xsrc,ydst-ysrc);
|
||||
double length=ceil(sqrt(pow(vect.x,2)+pow(vect.y,2)));
|
||||
double angle=acos(vect.x/length);
|
||||
angle= (vect.y>0) ? angle=angle : -angle;
|
||||
angle= (vect.y>0) ? angle : -angle;
|
||||
|
||||
// Translate starting point (xsrc,ysrc) about arrows_offset px to not start on the center of the square (less confusing visually)
|
||||
double k=arrows_offset/length;
|
||||
|
|
|
@ -27,7 +27,7 @@ wxDECLARE_EVENT(PLAY_MOVE_EVENT, wxCommandEvent);
|
|||
file = 7 - file; \
|
||||
rank = 7 - rank; \
|
||||
} \
|
||||
bool IsCurrentSquareValid = file >= 0 && file <= 7 && rank >= 0 && rank <= 7;
|
||||
bool IsCurrentSquareValid = file <= 7 && rank <= 7; // Do not need to check rank>=0 and file>=0 since unsigned int
|
||||
|
||||
#define MOUSE_ON(x, y, width, height) \
|
||||
(mouseX >= (x) && mouseX <= ((x) + (width)) && mouseY >= (y) && \
|
||||
|
@ -100,7 +100,7 @@ class BoardCanvas : public wxPanel {
|
|||
|
||||
// Various canvas state variables
|
||||
bool black_side, is_dragging, valid_drag, arrow_drag, is_black_turn;
|
||||
std::uint32_t boardX, boardY, square_width, piece_width, mouseX, mouseY, lastClickX,
|
||||
std::int32_t boardX, boardY, square_width, piece_width, mouseX, mouseY, lastClickX,
|
||||
lastClickY;
|
||||
wxSize canvas_size;
|
||||
wxPoint active_square;
|
||||
|
|
|
@ -46,6 +46,7 @@ GameTabRightPanel::GameTabRightPanel(wxFrame *parent, std::shared_ptr<Game> game
|
|||
}
|
||||
|
||||
void GameTabRightPanel::OnLiveAnalysis(wxCommandEvent &event) {
|
||||
UNUSED(event);
|
||||
if (live_engine == nullptr) {
|
||||
int selection = engine_list->GetSelection();
|
||||
if (selection != wxNOT_FOUND) {
|
||||
|
@ -84,6 +85,7 @@ void GameTabRightPanel::OnTagSelected(wxListEvent &event) {
|
|||
}
|
||||
|
||||
void GameTabRightPanel::OnTagDeselected(wxListEvent &event) {
|
||||
UNUSED(event);
|
||||
selected_item = -1;
|
||||
delete_button->Enable(false);
|
||||
}
|
||||
|
@ -114,6 +116,7 @@ void GameTabRightPanel::OnCommentChange(wxCommandEvent &event) {
|
|||
}
|
||||
|
||||
void GameTabRightPanel::OnApply(wxCommandEvent &event) {
|
||||
UNUSED(event);
|
||||
std::string key = tagTextCtrl->GetValue().ToStdString();
|
||||
if (key == "FEN") {
|
||||
SHOW_DIALOG_ERROR("Editing the FEN tag is forbidden");
|
||||
|
@ -130,6 +133,7 @@ void GameTabRightPanel::OnApply(wxCommandEvent &event) {
|
|||
}
|
||||
|
||||
void GameTabRightPanel::OnDelete(wxCommandEvent &event) {
|
||||
UNUSED(event);
|
||||
if (selected_item >= 0) {
|
||||
wxListItem item;
|
||||
item.SetColumn(0);
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
#include "LiveEngineDialog.hpp"
|
||||
|
||||
LiveEngineDialog::LiveEngineDialog(wxWindow *parent, std::uint32_t engine_id)
|
||||
: DialogLiveEngine(parent), interval(1000),
|
||||
engine(nullptr) {
|
||||
: DialogLiveEngine(parent), engine(nullptr), interval(1000) {
|
||||
lines_list->InsertColumn(0, "#", wxLIST_FORMAT_LEFT, 50);
|
||||
lines_list->InsertColumn(1, "CP", wxLIST_FORMAT_LEFT, 70);
|
||||
lines_list->InsertColumn(2, "Line", wxLIST_FORMAT_LEFT, 300);
|
||||
|
@ -63,6 +62,7 @@ void LiveEngineDialog::InitEngine() {
|
|||
}
|
||||
|
||||
void LiveEngineDialog::OnClose(wxCloseEvent &e) {
|
||||
UNUSED(e);
|
||||
if (engine != nullptr) {
|
||||
wxLogDebug("Close live engine!!");
|
||||
timer.Stop();
|
||||
|
@ -83,6 +83,7 @@ void LiveEngineDialog::SetFEN(std::string fen) {
|
|||
}
|
||||
|
||||
void LiveEngineDialog::TogglePauseEngine(wxCommandEvent &event) {
|
||||
UNUSED(event);
|
||||
if (timer.IsRunning()) {
|
||||
StopEngine();
|
||||
engine_stop_button->SetLabel("Restart");
|
||||
|
@ -115,6 +116,7 @@ void LiveEngineDialog::StartEngine() {
|
|||
}
|
||||
|
||||
void LiveEngineDialog::OnTimerTick(wxTimerEvent &event) {
|
||||
UNUSED(event);
|
||||
lines_list->DeleteAllItems(); // Clear lines_list
|
||||
engine->SyncAfter(0);
|
||||
EngineEvaluation *eval=new EngineEvaluation();
|
||||
|
|
|
@ -22,6 +22,7 @@ EditorCanvas::EditorCanvas(wxFrame *parent, std::shared_ptr<Game> game)
|
|||
}
|
||||
|
||||
void EditorCanvas::OnPaint(wxPaintEvent &event) {
|
||||
UNUSED(event);
|
||||
wxPaintDC current_dc(this);
|
||||
current_dc.SetBackground(*wxWHITE_BRUSH);
|
||||
current_dc.Clear();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue