Skip to content

Commit

Permalink
Add setting to show/hide completion status while solving.
Browse files Browse the repository at this point in the history
Allows solvers to hide the percent complete and correct/incorrect
notifications, as well as prevent the timer from automatically
stopping when the grid is completed correctly. This offers a more
paper-like solving experience.

Fixes mrichards42#28
  • Loading branch information
jpd236 committed Aug 19, 2019
1 parent a112765 commit 856b3ca
Show file tree
Hide file tree
Showing 11 changed files with 246 additions and 20 deletions.
24 changes: 21 additions & 3 deletions src/MyFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,8 @@ MyFrame::MyFrame()
m_isTimerRunning(false),
m_autoStartTimer(false),
m_autoSaveTimer(this, ID_AUTOSAVE_TIMER),
m_autoSaveInterval(0),
m_autoSaveInterval(0),
m_showCompletionStatus(true),
m_mgr(),
m_fileHistory(10, ID_FILE_HISTORY_1)
{
Expand Down Expand Up @@ -1056,7 +1057,11 @@ MyFrame::ShowNotes()

void
MyFrame::CheckPuzzle()
{
{
if (!m_showCompletionStatus) {
m_status->SetAlert("");
return;
}
GridStats stats;
m_XGridCtrl->GetStats(&stats);
switch (stats.correct)
Expand Down Expand Up @@ -1579,7 +1584,8 @@ MyFrame::LoadConfig()

// Misc
config.Timer.autoStart.AddCallback(this, &MyFrame::SetAutoStartTimer);
config.autoSaveInterval.AddCallback(this, &MyFrame::SetAutoSaveInterval);
config.autoSaveInterval.AddCallback(this, &MyFrame::SetAutoSaveInterval);
config.Status.showCompletionStatus.AddCallback(this, &MyFrame::SetShowCompletionStatus);

// File History
config.FileHistory.saveFileHistory.AddCallback(
Expand Down Expand Up @@ -2425,6 +2431,18 @@ MyFrame::OnTimerNotify(wxTimerEvent & WXUNUSED(evt))
{
m_XGridCtrl->SetPaused(true);
}
}

// Status bar
//-----------
void
MyFrame::SetShowCompletionStatus(bool show)
{
m_showCompletionStatus = show;
if (m_puz.IsOk())
{
CheckPuzzle();
}
}

// AutoSave
Expand Down
9 changes: 6 additions & 3 deletions src/MyFrame.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ class MyFrame : public wxFrame

// Status bar
//-----------
void SetStatus(const wxString & text) { m_status->SetStatus(text); }

void SetStatus(const wxString & text) { m_status->SetStatus(text); }
void SetShowCompletionStatus(bool show);

// Timer
//-----------
Expand Down Expand Up @@ -235,7 +235,10 @@ class MyFrame : public wxFrame

// AutoSave
int m_autoSaveInterval;
wxTimer m_autoSaveTimer;
wxTimer m_autoSaveTimer;

// Status
bool m_showCompletionStatus;

// The XWord puzzle
//-----------------
Expand Down
3 changes: 2 additions & 1 deletion src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ ConfigManager::Status_t::Status_t(ConfigManager * cfg)
completeColor(this, _T("completeColor"), *wxGREEN),
incorrectColor(this, _T("incorrectColor"), *wxRED),
uncheckableColor(this, _T("uncheckableColor"), *wxCYAN),
brightnessCutoff(this, _T("brightnessCutoff"), 200)
brightnessCutoff(this, _T("brightnessCutoff"), 200),
showCompletionStatus(this, _T("showCompletionStatus"), true)
{}

// Printing
Expand Down
3 changes: 2 additions & 1 deletion src/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ class ConfigManager : public ConfigManagerBase
ConfigColor completeColor;
ConfigColor incorrectColor;
ConfigColor uncheckableColor;
ConfigLong brightnessCutoff;
ConfigLong brightnessCutoff;
ConfigBool showCompletionStatus;
} Status;

// Printing
Expand Down
12 changes: 9 additions & 3 deletions src/dialogs/PreferencesPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,10 @@ void SolvePanel::DoLoadConfig()
m_strictRebus->SetValue((gridStyle & STRICT_REBUS) != 0);

// Timer
m_startTimer->SetValue(m_config.Timer.autoStart());
m_startTimer->SetValue(m_config.Timer.autoStart());

// Status
m_showCompletionStatus->SetValue(m_config.Status.showCompletionStatus());

// Autosave
m_useAutoSave->SetValue(m_config.autoSaveInterval() > 0);
Expand Down Expand Up @@ -260,7 +263,9 @@ void SolvePanel::DoSaveConfig()

m_config.Grid.style = gridStyle;

m_config.Timer.autoStart = m_startTimer->GetValue();
m_config.Timer.autoStart = m_startTimer->GetValue();

m_config.Status.showCompletionStatus = m_showCompletionStatus->GetValue();

m_config.autoSaveInterval =
m_useAutoSave->IsChecked() ? m_autoSave->GetValue() : 0;
Expand All @@ -280,7 +285,8 @@ void SolvePanel::ConnectChangedEvents()
BindChangedEvent(m_moveOnRightClick);
BindChangedEvent(m_checkWhileTyping);
BindChangedEvent(m_strictRebus);
BindChangedEvent(m_startTimer);
BindChangedEvent(m_startTimer);
BindChangedEvent(m_showCompletionStatus);
BindChangedEvent(m_useAutoSave);
BindChangedEvent(m_autoSave);
BindChangedEvent(m_saveFileHistory);
Expand Down
14 changes: 12 additions & 2 deletions src/dialogs/wxFB_PreferencesPanels.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Oct 10 2016)
// C++ code generated with wxFormBuilder (version May 29 2018)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
// PLEASE DO *NOT* EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////

#include "wxFB_PreferencesPanels.h"
Expand Down Expand Up @@ -90,6 +90,16 @@ wxFB_SolvePanel::wxFB_SolvePanel( wxWindow* parent, wxWindowID id, const wxPoint

sbSizer41->Add( m_strictRebus, 0, wxALL, 5 );

m_showCompletionStatus
= new wxCheckBox( sbSizer41->GetStaticBox(), wxID_ANY, wxT("Show completion status"), wxDefaultPosition, wxDefaultSize, 0 );
m_showCompletionStatus
->SetValue(true);
m_showCompletionStatus
->SetToolTip( wxT("Show percentage completion while solving and whether a completed puzzle is correct or incorrect, and stop the timer when the puzzle is completed correctly.") );

sbSizer41->Add( m_showCompletionStatus
, 0, wxALL, 5 );


bSizer5->Add( sbSizer41, 0, wxALL|wxEXPAND, 5 );

Expand Down
89 changes: 89 additions & 0 deletions src/dialogs/wxFB_PreferencesPanels.fbp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<property name="file">wxFB_PreferencesPanels</property>
<property name="first_id">1000</property>
<property name="help_provider">none</property>
<property name="indent_with_spaces"></property>
<property name="internationalize">0</property>
<property name="name">Preferences Dialog Panels</property>
<property name="namespace"></property>
Expand Down Expand Up @@ -1131,6 +1132,94 @@
<event name="OnUpdateUI"></event>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL</property>
<property name="proportion">0</property>
<object class="wxCheckBox" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="checked">1</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Show completion status</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_showCompletionStatus&#x0A;</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip">Show percentage completion while solving and whether a completed puzzle is correct or incorrect, and stop the timer when the puzzle is completed correctly.</property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnChar"></event>
<event name="OnCheckBox"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
</object>
</object>
</object>
</object>
<object class="sizeritem" expanded="0">
Expand Down
6 changes: 4 additions & 2 deletions src/dialogs/wxFB_PreferencesPanels.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Oct 10 2016)
// C++ code generated with wxFormBuilder (version May 29 2018)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
// PLEASE DO *NOT* EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////

#ifndef __WXFB_PREFERENCESPANELS_H__
Expand Down Expand Up @@ -48,6 +48,8 @@ class wxFB_SolvePanel : public wxPanel
wxCheckBox* m_moveOnRightClick;
wxCheckBox* m_checkWhileTyping;
wxCheckBox* m_strictRebus;
wxCheckBox* m_showCompletionStatus
;
wxCheckBox* m_saveFileHistory;
wxCheckBox* m_reopenLastPuzzle;
wxCheckBox* m_useAutoSave;
Expand Down
10 changes: 8 additions & 2 deletions src/dialogs/wxFB_PreferencesPanelsOSX.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Oct 10 2016)
// C++ code generated with wxFormBuilder (version May 29 2018)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
// PLEASE DO *NOT* EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////

#include "wxFB_PreferencesPanelsOSX.h"
Expand Down Expand Up @@ -60,6 +60,12 @@ wxFB_SolvePanel::wxFB_SolvePanel( wxWindow* parent, wxWindowID id, const wxPoint

bSizer121->Add( m_strictRebus, 0, wxTOP|wxRIGHT|wxLEFT, 5 );

m_showCompletionStatus = new wxCheckBox( this, wxID_ANY, wxT("Show completion status"), wxDefaultPosition, wxDefaultSize, 0 );
m_showCompletionStatus->SetValue(true);
m_showCompletionStatus->SetToolTip( wxT("Show percentage completion while solving and whether a completed puzzle is correct or incorrect, and stop the timer when the puzzle is completed correctly.") );

bSizer121->Add( m_showCompletionStatus, 0, wxALL, 5 );


bSizer41->Add( bSizer121, 0, wxLEFT, 25 );

Expand Down
Loading

0 comments on commit 856b3ca

Please sign in to comment.