mirror of
https://gitlab.com/manzerbredes/ochess.git
synced 2025-04-07 02:26:29 +02:00
Improve UI
This commit is contained in:
parent
5aea044961
commit
34fd2d3736
2 changed files with 18 additions and 4 deletions
|
@ -22,6 +22,8 @@ BoardCanvas::BoardCanvas(wxFrame *parent)
|
||||||
|
|
||||||
Bind(wxEVT_KEY_DOWN, [p=this](wxKeyEvent &e){e.ResumePropagation(1);e.Skip();});
|
Bind(wxEVT_KEY_DOWN, [p=this](wxKeyEvent &e){e.ResumePropagation(1);e.Skip();});
|
||||||
Bind(wxEVT_KEY_UP, [p=this](wxKeyEvent &e){e.ResumePropagation(1);e.Skip();});
|
Bind(wxEVT_KEY_UP, [p=this](wxKeyEvent &e){e.ResumePropagation(1);e.Skip();});
|
||||||
|
SetClockTime(0,0,0, false);
|
||||||
|
SetClockTime(0,0,0, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
BoardCanvas::~BoardCanvas() {
|
BoardCanvas::~BoardCanvas() {
|
||||||
|
@ -172,6 +174,7 @@ void BoardCanvas::Animate(const std::string &board, bool is_black_turn, std::map
|
||||||
void BoardCanvas::DrawBoard(wxDC &dc) {
|
void BoardCanvas::DrawBoard(wxDC &dc) {
|
||||||
std::uint32_t piece_width = t->GetPiecesSizes();
|
std::uint32_t piece_width = t->GetPiecesSizes();
|
||||||
std::uint32_t centrer_offset = (square_width - piece_width) / 2;
|
std::uint32_t centrer_offset = (square_width - piece_width) / 2;
|
||||||
|
wxSize numbers_size=dc.GetTextExtent("0");
|
||||||
|
|
||||||
bool DrawDraggingPiece = false;
|
bool DrawDraggingPiece = false;
|
||||||
char dp = 'p';
|
char dp = 'p';
|
||||||
|
@ -198,6 +201,17 @@ void BoardCanvas::DrawBoard(wxDC &dc) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Draw numbers
|
||||||
|
dc.SetFont(wxFont(*wxNORMAL_FONT).MakeBold());
|
||||||
|
if(file==0){ // Right numbers
|
||||||
|
dc.DrawText(wxString((char)('1'+7-rank)),
|
||||||
|
x+square_width+numbers_size.x/2,y+square_width/2-numbers_size.y/2);
|
||||||
|
}
|
||||||
|
if(rank==7){ // Bottom numbers
|
||||||
|
dc.DrawText(wxString((char)('a'+7-file)),
|
||||||
|
x+square_width/2-numbers_size.x/2,y+square_width);
|
||||||
|
}
|
||||||
|
|
||||||
std::uint8_t prank = rank;
|
std::uint8_t prank = rank;
|
||||||
std::uint8_t pfile = file;
|
std::uint8_t pfile = file;
|
||||||
if (black_side) {
|
if (black_side) {
|
||||||
|
@ -236,7 +250,7 @@ void BoardCanvas::DrawBoard(wxDC &dc) {
|
||||||
badgeY = boardY + (8 * square_width) - badgeWidth;
|
badgeY = boardY + (8 * square_width) - badgeWidth;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
wxRect badge(boardX + (8 * square_width) + badgeWidth / 2, badgeY, badgeWidth,
|
wxRect badge(boardX + (8 * square_width) + badgeWidth, badgeY, badgeWidth,
|
||||||
badgeWidth);
|
badgeWidth);
|
||||||
dc.DrawRectangle(badge);
|
dc.DrawRectangle(badge);
|
||||||
|
|
||||||
|
@ -299,7 +313,7 @@ void BoardCanvas::DrawBoard(wxDC &dc) {
|
||||||
wxCoord width, height;
|
wxCoord width, height;
|
||||||
dc.GetTextExtent(time, &width, &height);
|
dc.GetTextExtent(time, &width, &height);
|
||||||
dc.DrawText(time,
|
dc.DrawText(time,
|
||||||
wxPoint(boardX + square_width * 8 - width, boardY - height));
|
wxPoint(boardX + square_width * 8 - width, boardY - height - numbers_size.y*2));
|
||||||
clock = black_side ? black_time : white_time;
|
clock = black_side ? black_time : white_time;
|
||||||
time = wxString::Format("%ds", std::get<1>(clock), std::get<2>(clock));
|
time = wxString::Format("%ds", std::get<1>(clock), std::get<2>(clock));
|
||||||
if (std::get<0>(clock) > 0) {
|
if (std::get<0>(clock) > 0) {
|
||||||
|
@ -309,7 +323,7 @@ void BoardCanvas::DrawBoard(wxDC &dc) {
|
||||||
}
|
}
|
||||||
dc.GetTextExtent(time, &width, &height);
|
dc.GetTextExtent(time, &width, &height);
|
||||||
dc.DrawText(time, wxPoint(boardX + square_width * 8 - width,
|
dc.DrawText(time, wxPoint(boardX + square_width * 8 - width,
|
||||||
boardY + square_width * 8));
|
boardY + square_width * 8 + numbers_size.y*2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ wxDECLARE_EVENT(NEXT_MOVE_EVENT, wxCommandEvent);
|
||||||
mouseY <= ((y) + (height)))
|
mouseY <= ((y) + (height)))
|
||||||
|
|
||||||
#define CAPTURE_FACTOR 0.5
|
#define CAPTURE_FACTOR 0.5
|
||||||
|
#define SQUARE_NUM_PADDING 5
|
||||||
typedef std::tuple<short, short, short> ClockTime;
|
typedef std::tuple<short, short, short> ClockTime;
|
||||||
|
|
||||||
// Drawing buffer (ANIMATIONS)
|
// Drawing buffer (ANIMATIONS)
|
||||||
|
|
Loading…
Add table
Reference in a new issue