aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLoic Guegan <manzerbredes@mailbox.org>2023-01-09 14:43:54 +0100
committerLoic Guegan <manzerbredes@mailbox.org>2023-01-09 14:43:54 +0100
commit518edf6f3050022fa4d1a15d147efe6665459863 (patch)
tree99bb53b970af942a0bef3f1801c9c2afaf1f73d1
parent445cc09d01f8e3beeb406e175b5a98d6be58ea9a (diff)
Bind settings of the Editor (still ongoing)
-rw-r--r--src/game_tab/left_panel/board/BoardCanvas.cpp14
-rw-r--r--src/game_tab/right_panel/GameTabRightPanel.cpp2
-rw-r--r--src/game_tab/right_panel/editor/EditorCanvas.cpp12
-rw-r--r--src/game_tab/right_panel/editor/EditorCanvas.hpp2
-rw-r--r--src/gui.cpp1
-rw-r--r--src/gui.h2
-rw-r--r--src/preferences/EditorPrefs.hpp14
-rw-r--r--tools/wxFrameBuilder.fbp6
8 files changed, 36 insertions, 17 deletions
diff --git a/src/game_tab/left_panel/board/BoardCanvas.cpp b/src/game_tab/left_panel/board/BoardCanvas.cpp
index 7cca378..0593cde 100644
--- a/src/game_tab/left_panel/board/BoardCanvas.cpp
+++ b/src/game_tab/left_panel/board/BoardCanvas.cpp
@@ -243,17 +243,17 @@ void BoardCanvas::DrawBoard(wxDC &dc) {
type=s[2];
// Default highlight (type='a' or something else not supported)
dc.SetPen(wxNullPen);
- dc.SetBrush(wxColour(255,0,0,110));
+ dc.SetBrush(wxColour(255, 102, 122));
if(type=='b')
- dc.SetBrush(wxColour(0,255,0,110));
+ dc.SetBrush(wxColour(120, 255, 102));
else if(type=='c')
- dc.SetBrush(wxColour(0,0,255,110));
+ dc.SetBrush(wxColour(102, 196, 255));
else if(type=='d')
- dc.SetBrush(wxColour(255,0,0,50));
+ dc.SetBrush(wxColour(255, 204, 213));
else if(type=='e')
- dc.SetBrush(wxColour(0,255,0,50));
+ dc.SetBrush(wxColour(220, 255, 204));
else if(type=='f')
- dc.SetBrush(wxColour(0,0,255,50));
+ dc.SetBrush(wxColour(204, 231, 255));
dc.DrawRectangle(wxRect(x,y,square_width,square_width));
}
}
@@ -505,7 +505,7 @@ void BoardCanvas::MouseEvent(wxMouseEvent &event) {
if(std::count(squares_hl.begin(), squares_hl.end(), src)){
squares_hl.erase(std::remove(squares_hl.begin(), squares_hl.end(), src), squares_hl.end());
}else{
- squares_hl.push_back(src);
+ squares_hl.push_back(src+"f");
wxLogDebug("Highlight square %s",src);
}
}
diff --git a/src/game_tab/right_panel/GameTabRightPanel.cpp b/src/game_tab/right_panel/GameTabRightPanel.cpp
index dd0ebca..7aa8bbd 100644
--- a/src/game_tab/right_panel/GameTabRightPanel.cpp
+++ b/src/game_tab/right_panel/GameTabRightPanel.cpp
@@ -156,8 +156,8 @@ void GameTabRightPanel::ApplyPreferences() {
engine_list->Append(engine_name);
} while (conf->GetNextGroup(engine_name, index));
}
-
CONFIG_CLOSE(conf);
+ editor_canvas->ApplyPreferences();
}
void GameTabRightPanel::RefreshTagsList() {
diff --git a/src/game_tab/right_panel/editor/EditorCanvas.cpp b/src/game_tab/right_panel/editor/EditorCanvas.cpp
index 19d81ec..b728d91 100644
--- a/src/game_tab/right_panel/editor/EditorCanvas.cpp
+++ b/src/game_tab/right_panel/editor/EditorCanvas.cpp
@@ -31,8 +31,6 @@ void EditorCanvas::OnPaint(wxPaintEvent &event) {
wxSize sz = GetClientSize();
CGEditor::status.CanvasWidth = sz.GetWidth();
CGEditor::status.CanvasHeight = sz.GetHeight();
- CGEditor::status.UseMoveIcons =
- true; // Piece image should be drawn before the move ?
const wxPoint pt = wxGetMousePosition();
CGEditor::status.MouseX = pt.x - this->GetScreenPosition().x;
@@ -229,5 +227,15 @@ void EditorCanvas::SetMoves(HalfMove *moves, HalfMove *current) {
Refresh();
}
+void EditorCanvas::ApplyPreferences(){
+ CONFIG_OPEN(conf);
+ conf->SetPath("editor/");
+ CGEditor::status.MoveHeight=conf->Read("row_size", 50);
+ CGEditor::status.MoveWidth=conf->Read("col_size", 100);
+ CGEditor::status.UseMoveIcons=conf->Read("show_move_icons", true);
+ CONFIG_CLOSE(conf);
+ Refresh();
+}
+
wxBEGIN_EVENT_TABLE(EditorCanvas, wxPanel) EVT_PAINT(EditorCanvas::OnPaint)
EVT_MOUSE_EVENTS(EditorCanvas::MouseEvent) wxEND_EVENT_TABLE()
diff --git a/src/game_tab/right_panel/editor/EditorCanvas.hpp b/src/game_tab/right_panel/editor/EditorCanvas.hpp
index 740a6a1..7fea474 100644
--- a/src/game_tab/right_panel/editor/EditorCanvas.hpp
+++ b/src/game_tab/right_panel/editor/EditorCanvas.hpp
@@ -31,6 +31,6 @@ public:
void DrawElement(const cgeditor::Element &e);
void HandleEvent(const cgeditor::Event &e);
void SetMoves(HalfMove *moves, HalfMove *current);
-
+ void ApplyPreferences();
DECLARE_EVENT_TABLE()
};
diff --git a/src/gui.cpp b/src/gui.cpp
index 4702692..5afa289 100644
--- a/src/gui.cpp
+++ b/src/gui.cpp
@@ -268,6 +268,7 @@ PrefsEditor::PrefsEditor( wxWindow* parent, wxWindowID id, const wxPoint& pos, c
this->SetSizer( main_sizer );
this->Layout();
+ main_sizer->Fit( this );
}
PrefsEditor::~PrefsEditor()
diff --git a/src/gui.h b/src/gui.h
index 3380e02..7b178c2 100644
--- a/src/gui.h
+++ b/src/gui.h
@@ -189,7 +189,7 @@ class PrefsEditor : public wxPanel
public:
- PrefsEditor( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 622,420 ), long style = wxTAB_TRAVERSAL, const wxString& name = wxEmptyString );
+ PrefsEditor( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxTAB_TRAVERSAL, const wxString& name = wxEmptyString );
~PrefsEditor();
diff --git a/src/preferences/EditorPrefs.hpp b/src/preferences/EditorPrefs.hpp
index 9a8ca0d..4287410 100644
--- a/src/preferences/EditorPrefs.hpp
+++ b/src/preferences/EditorPrefs.hpp
@@ -17,15 +17,25 @@ public:
}
virtual bool TransferDataToWindow() {
+ CONFIG_OPEN(config);
+ row_size->SetValue(config->Read("editor/row_size", 50));
+ col_size->SetValue(config->Read("editor/col_size", 100));
+ show_move_icons->SetValue(config->Read("editor/show_move_icons", true));
+ CONFIG_CLOSE(config);
return true;
}
void ApplyPreferences() {
-
+ CONFIG_OPEN(config);
+ config->Write("editor/row_size", row_size->GetValue());
+ config->Write("editor/col_size", col_size->GetValue());
+ config->Write("editor/show_move_icons", show_move_icons->GetValue());
+ CONFIG_CLOSE(config);
}
virtual bool TransferDataFromWindow() {
-
+ ApplyPreferences();
+ MAINWIN->ApplyPreferences();
return (true);
}
};
diff --git a/tools/wxFrameBuilder.fbp b/tools/wxFrameBuilder.fbp
index ab8d3d3..5120414 100644
--- a/tools/wxFrameBuilder.fbp
+++ b/tools/wxFrameBuilder.fbp
@@ -1835,7 +1835,7 @@
</object>
</object>
</object>
- <object class="Panel" expanded="0">
+ <object class="Panel" expanded="1">
<property name="aui_managed">0</property>
<property name="aui_manager_style">wxAUI_MGR_DEFAULT</property>
<property name="bg"></property>
@@ -1851,14 +1851,14 @@
<property name="minimum_size"></property>
<property name="name">PrefsEditor</property>
<property name="pos"></property>
- <property name="size">622,420</property>
+ <property name="size">-1,-1</property>
<property name="subclass">; ; forward_declare</property>
<property name="tooltip"></property>
<property name="two_step_creation">0</property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style">wxTAB_TRAVERSAL</property>
- <object class="wxGridSizer" expanded="0">
+ <object class="wxGridSizer" expanded="1">
<property name="cols">2</property>
<property name="hgap">0</property>
<property name="minimum_size"></property>