aboutsummaryrefslogtreecommitdiff
path: root/src/components
diff options
context:
space:
mode:
authorLoic Guegan <manzerbredes@mailbox.org>2022-02-17 08:33:32 +0100
committerLoic Guegan <manzerbredes@mailbox.org>2022-02-17 08:33:32 +0100
commit3e818c0f0ca741fe8404e841a93b1401aacc4301 (patch)
treeb607ac09a553f909e0eb5fc56582351bcd1d99d6 /src/components
parentfbb36fc82e7d069cdc91831aba8ccbdf063d5187 (diff)
Improve editor move icons management
Diffstat (limited to 'src/components')
-rw-r--r--src/components/MoveTable.cpp35
-rw-r--r--src/components/MoveTable.hpp1
2 files changed, 27 insertions, 9 deletions
diff --git a/src/components/MoveTable.cpp b/src/components/MoveTable.cpp
index e7f7af3..71142dd 100644
--- a/src/components/MoveTable.cpp
+++ b/src/components/MoveTable.cpp
@@ -2,9 +2,8 @@
namespace cgeditor {
-MoveTable::MoveTable(Status *s) : Component(s) {
- ImageWidth = status->MoveWidth * 0.25; // Image is 25% of the cell
-}
+MoveTable::MoveTable(Status *s) : Component(s) {}
+
void MoveTable::Refresh() {
status->MoveTableMaxX = 0;
status->MoveTableMaxY = 0;
@@ -16,7 +15,7 @@ void MoveTable::Refresh() {
// We only set the type after the call to UpdateMoves()
// This way only a single move will be the current move
if (CurrentMove >= 0) {
- if (status->UseMoveImages) {
+ if (status->UseMoveIcons) {
elements[CurrentMove].prop |= Property::Current;
elements[CurrentMove + 1].prop |= Property::Current;
} else {
@@ -90,13 +89,13 @@ std::uint32_t MoveTable::UpdateMoves(CGEHalfMove *m, std::uint32_t line,
}
//---------- Draw move ----------
- if (status->UseMoveImages) {
+ if (status->UseMoveIcons) {
// Image
Element img;
img.prop = Property::Image | Property::Move;
img.x = move_bound.x;
img.y = status->MoveHeight * line;
- img.width = ImageWidth;
+ img.width = status->MoveIconWidth;
img.height = status->MoveHeight;
img.ShouldApplyScroll = true;
elements.push_back(img);
@@ -104,9 +103,29 @@ std::uint32_t MoveTable::UpdateMoves(CGEHalfMove *m, std::uint32_t line,
Element e;
e.prop = move_bound.prop | Property::Text;
e.text = m->move;
- e.x = ImageWidth + move_bound.x;
+ if (m->move.size() > 0) {
+ char c = m->move[0];
+ if (!(c == 'a' || c == 'b' || c == 'c' || c == 'd' || c == 'e' ||
+ c == 'f' || c == 'O' || c == '0')) {
+ e.text = m->move.substr(1, m->move.size());
+ if (c == 'N') {
+ e.prop |= Property::Knight;
+ } else if (c == 'B') {
+ e.prop |= Property::Bishop;
+ } else if (c == 'R') {
+ e.prop |= Property::Rook;
+ } else if (c == 'Q') {
+ e.prop |= Property::Queen;
+ } else {
+ e.prop |= Property::King;
+ }
+ } else {
+ e.prop |= Property::Pawn;
+ }
+ }
+ e.x = status->MoveIconWidth + move_bound.x;
e.y = status->MoveHeight * line;
- e.width = status->MoveWidth - ImageWidth;
+ e.width = status->MoveWidth - status->MoveIconWidth;
e.height = status->MoveHeight;
e.ShouldApplyScroll = true;
elements.push_back(e);
diff --git a/src/components/MoveTable.hpp b/src/components/MoveTable.hpp
index d220f5e..28ebd12 100644
--- a/src/components/MoveTable.hpp
+++ b/src/components/MoveTable.hpp
@@ -48,7 +48,6 @@ namespace cgeditor {
class MoveTable : public Component {
std::uint32_t UpdateMoves(CGEHalfMove *, std::uint32_t, std::uint32_t,bool only_black);
std::int32_t CurrentMove;
- double ImageWidth;
std::vector<Element> VariationMargins;
bool IsMouseOver(const Element &e) const;
std::uint32_t DrawComment(CGEHalfMove *m, std::uint32_t line, std::uint32_t indent,