aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLoic Guegan <manzerbredes@mailbox.org>2022-12-29 19:58:37 +0100
committerLoic Guegan <manzerbredes@mailbox.org>2022-12-29 19:58:37 +0100
commitf1f638100f4bcd88b31c3412e961dbbb5e12ad0a (patch)
tree1a66d6b192985d272d3fbb97f06edaaea92c4acf
parenta90469e71a821d152ae31d16bd8b78793ada98d6 (diff)
Now showing move NAGs is possible
-rw-r--r--README.md2
-rw-r--r--examples/wxWidgets/MyHalfMove.cpp5
-rw-r--r--src/CGEHalfMove.hpp2
-rw-r--r--src/Types.hpp5
-rw-r--r--src/components/MoveTable.cpp14
5 files changed, 24 insertions, 4 deletions
diff --git a/README.md b/README.md
index b092ac2..fdbac72 100644
--- a/README.md
+++ b/README.md
@@ -4,7 +4,7 @@
cgeditor is a dependency-free chess game editor library written in C++. It can be used with any library that provides 2D canvas drawing and mouse inputs features.
# Features
-- Show move,move number, variations, comments etc.
+- Show move,move number, variations, NAGs, comments etc.
- *Delete*, *Promote* and *Set as main line* features
- Handle pieces icons
- Its graphical appareance is entirely customizable
diff --git a/examples/wxWidgets/MyHalfMove.cpp b/examples/wxWidgets/MyHalfMove.cpp
index 6560006..c1d1ab3 100644
--- a/examples/wxWidgets/MyHalfMove.cpp
+++ b/examples/wxWidgets/MyHalfMove.cpp
@@ -144,7 +144,7 @@ MyHalfMove *BuildExampleGame() {
m->SetMainline(m2);
m = m2;
- m2 = new MyHalfMove("o-o");
+ m2 = new MyHalfMove("O-O");
m->SetMainline(m2);
m = m2;
@@ -196,10 +196,11 @@ MyHalfMove *BuildExampleGame() {
m = m2;
m2 = new MyHalfMove("Re1");
+ m2->nag="!!";
m->SetMainline(m2);
m = m2;
- m2 = new MyHalfMove("o-o");
+ m2 = new MyHalfMove("O-O");
m->SetMainline(m2);
m = m2;
diff --git a/src/CGEHalfMove.hpp b/src/CGEHalfMove.hpp
index 2ed7516..abef708 100644
--- a/src/CGEHalfMove.hpp
+++ b/src/CGEHalfMove.hpp
@@ -24,6 +24,8 @@ public:
std::uint16_t Number;
/// @brief Current move value
std::string move;
+ /// @brief Current NAG
+ std::string nag;
CGEHalfMove *MainLine;
CGEHalfMove *Parent;
diff --git a/src/Types.hpp b/src/Types.hpp
index e2ad0e2..7f54d0a 100644
--- a/src/Types.hpp
+++ b/src/Types.hpp
@@ -29,7 +29,8 @@ enum class Property : std::uint32_t {
Bishop = 1 << 19,
Rook = 1 << 20,
Queen = 1 << 21,
- King = 1 << 22
+ King = 1 << 22,
+ Nag = 1 << 23
};
Property operator|(Property lhs, Property rhs);
Property &operator|=(Property &lhs, Property rhs);
@@ -68,6 +69,8 @@ typedef struct Status {
double CanvasWidth, CanvasHeight;
double MenuItemWidth = 150, MenuItemHeight = 50;
double MoveWidth = 100, MoveHeight = 50;
+ double NagWidth = 25, NagHeight = MoveHeight;
+ double NagRightMargin = 0;
double MarginBarWidth = 50;
double ScrollbarWidth = 30;
double MoveIconWidth = 25;
diff --git a/src/components/MoveTable.cpp b/src/components/MoveTable.cpp
index 42280eb..9e8ee38 100644
--- a/src/components/MoveTable.cpp
+++ b/src/components/MoveTable.cpp
@@ -127,6 +127,7 @@ std::uint32_t MoveTable::UpdateMoves(CGEHalfMove *m, std::uint32_t line,
e.width = status->MoveWidth - status->MoveIconWidth;
e.height = status->MoveHeight;
e.ShouldApplyScroll = true;
+ // Add elements:
elements.push_back(img);
elements.push_back(e);
} else {
@@ -134,6 +135,19 @@ std::uint32_t MoveTable::UpdateMoves(CGEHalfMove *m, std::uint32_t line,
elements.push_back(move_bound);
}
+ //---------- NAG ----------
+ if(m->nag.size()>0){
+ Element nag;
+ nag.text = m->nag;
+ nag.x = move_bound.x + status->MoveWidth - status->NagWidth - status->NagRightMargin;
+ nag.y = status->MoveHeight * line;
+ nag.width = status->NagWidth;
+ nag.height = status->NagHeight;
+ nag.prop = move_bound.prop | Property::Text | Property::Nag;
+ nag.ShouldApplyScroll = true;
+ elements.push_back(nag);
+ }
+
//---------- Move number in marge or for variation ----------
if (indent == 0 && (!m->IsBlack || only_black)) {
DRAW_NB(0, status->MoveHeight * line, m->Number);