Skip to content

Commit

Permalink
minor bug fixes and simplification
Browse files Browse the repository at this point in the history
  • Loading branch information
katahiromz committed Apr 1, 2024
1 parent fcacd1d commit 10d2818
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 24 deletions.
12 changes: 5 additions & 7 deletions GUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -856,7 +856,6 @@ void XgResetSettings(void)
XG_PatternDialog::xg_nPatWndY = CW_USEDEFAULT;
XG_PatternDialog::xg_nPatWndCX = CW_USEDEFAULT;
XG_PatternDialog::xg_nPatWndCY = CW_USEDEFAULT;
XG_PatternDialog::xg_bShowAnswerOnPattern = TRUE;

xg_nRules = XG_DEFAULT_RULES;
xg_nViewMode = XG_VIEW_NORMAL;
Expand Down Expand Up @@ -1086,9 +1085,6 @@ bool __fastcall XgLoadSettings(void)
if (!app_key.QueryDword(L"PatWndCY", dwValue)) {
XG_PatternDialog::xg_nPatWndCY = dwValue;
}
if (!app_key.QueryDword(L"ShowAnsOnPat", dwValue)) {
XG_PatternDialog::xg_bShowAnswerOnPattern = dwValue;
}
if (!app_key.QueryDword(L"Rules", dwValue)) {
xg_nRules = dwValue | RULE_DONTDIVIDE;
}
Expand Down Expand Up @@ -1242,7 +1238,6 @@ bool __fastcall XgSaveSettings(void)
app_key.SetDword(L"PatWndY", XG_PatternDialog::xg_nPatWndY);
app_key.SetDword(L"PatWndCX", XG_PatternDialog::xg_nPatWndCX);
app_key.SetDword(L"PatWndCY", XG_PatternDialog::xg_nPatWndCY);
app_key.SetDword(L"ShowAnsOnPat", XG_PatternDialog::xg_bShowAnswerOnPattern);

app_key.SetDword(L"Rules", xg_nRules);
app_key.SetDword(L"MarkingX", xg_nMarkingX);
Expand Down Expand Up @@ -2857,9 +2852,7 @@ bool __fastcall XgOnGenerate(HWND hwnd)
{
// [問題の作成]ダイアログ。
XG_GenDialog dialog;
dialog.m_bShowAnswer = xg_bShowAnswerOnGenerate;
nID = static_cast<int>(dialog.DoModal(hwnd));
xg_bShowAnswerOnGenerate = dialog.m_bShowAnswer;
}
::EnableWindow(xg_hwndInputPalette, TRUE);
if (nID != IDOK) {
Expand Down Expand Up @@ -5289,6 +5282,11 @@ void XgGenerateFromWordList(HWND hwnd)
// ズームを実際のウィンドウに合わせる。
XgFitZoom(hwnd);

// 自動保存なら保存する。
if (xg_bAutoSave) {
XgNumberingSave(hwnd);
}

// 成功メッセージ。
XgShowResults(hwnd);

Expand Down
5 changes: 5 additions & 0 deletions GUI.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,8 @@ void XgUpdateTheme(HWND hwnd);
void XgUpdateRules(HWND hwnd);

//////////////////////////////////////////////////////////////////////////////

// 問題を生成したときに答えを表示するか?
extern BOOL xg_bShowAnswerOnGenerate;

//////////////////////////////////////////////////////////////////////////////
6 changes: 2 additions & 4 deletions XG_GenDialog.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
class XG_GenDialog : public XG_Dialog
{
public:
BOOL m_bShowAnswer = FALSE;

XG_GenDialog() noexcept
{
}
Expand All @@ -31,7 +29,7 @@ class XG_GenDialog : public XG_Dialog
if (xg_bSmartResolution)
::CheckDlgButton(hwnd, chx2, BST_CHECKED);
// 答えを表示するか?
if (m_bShowAnswer)
if (xg_bShowAnswerOnGenerate)
::CheckDlgButton(hwnd, chx3, BST_CHECKED);
// 自動的にPAT.txtから選択するか?
if (xg_bChoosePAT)
Expand Down Expand Up @@ -95,7 +93,7 @@ class XG_GenDialog : public XG_Dialog
// スマート解決か?
xg_bSmartResolution = (::IsDlgButtonChecked(hwnd, chx2) == BST_CHECKED);
// 答えを表示するか?
m_bShowAnswer = (::IsDlgButtonChecked(hwnd, chx3) == BST_CHECKED);
xg_bShowAnswerOnGenerate = (::IsDlgButtonChecked(hwnd, chx3) == BST_CHECKED);
// 自動的にPAT.txtから選択するか?
xg_bChoosePAT = (::IsDlgButtonChecked(hwnd, chx4) == BST_CHECKED);
// 初期化する。
Expand Down
11 changes: 2 additions & 9 deletions XG_PatternDialog.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
#include "layout.h"
#include "XWordGiver.hpp"

// 黒マスパターンで答えを表示する。
extern BOOL xg_bShowAnswerOnPattern;
// 解を求める(黒マス追加なし)。
bool __fastcall XgOnSolve_NoAddBlack(HWND hwnd);
// 解を求める(黒マス追加なし)。結果を表示しない。
Expand All @@ -32,9 +30,6 @@ class XG_PatternDialog : public XG_Dialog
inline static int xg_nPatWndCX = CW_USEDEFAULT;
inline static int xg_nPatWndCY = CW_USEDEFAULT;

// 黒マスパターンで答えを表示する。
inline static BOOL xg_bShowAnswerOnPattern = TRUE;

XG_PatternDialog() noexcept
{
}
Expand Down Expand Up @@ -139,10 +134,8 @@ class XG_PatternDialog : public XG_Dialog
s_pLayout = nullptr;
}

if (xg_bShowAnswerOnPattern)
if (xg_bShowAnswerOnGenerate)
CheckDlgButton(hwnd, chx1, BST_CHECKED);
else
CheckDlgButton(hwnd, chx1, BST_UNCHECKED);

CheckRadioButton(hwnd, rad1, rad3, rad2);
CheckRadioButton(hwnd, rad4, rad6, rad6);
Expand Down Expand Up @@ -244,7 +237,7 @@ class XG_PatternDialog : public XG_Dialog
EndDialog(hwnd, IDOK);

// 答えを表示するか?
xg_bShowAnswerOnPattern = (IsDlgButtonChecked(hwnd, chx1) == BST_CHECKED);
xg_bShowAnswerOnGenerate = (IsDlgButtonChecked(hwnd, chx1) == BST_CHECKED);

// ズームを実際のウィンドウに合わせる。
XgFitZoom(GetParent(hwnd));
Expand Down
4 changes: 2 additions & 2 deletions lang/en_US.rc
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ IDB_DELETEPAT BITMAP "res/1033_Bitmap_102.bmp"
MENUITEM SEPARATOR
MENUITEM "&Retry regularly", ID_RETRYIFTIMEOUT
MENUITEM SEPARATOR
MENUITEM "Show &solution\tCtrl+M", ID_SHOWSOLUTION
MENUITEM "Hi&de solution\tCtrl+M", ID_NOSOLUTION
MENUITEM "Show Ans&wer\tCtrl+M", ID_SHOWSOLUTION
MENUITEM "Hi&de Answer\tCtrl+M", ID_NOSOLUTION
MENUITEM SEPARATOR
MENUITEM "&Checking Answer", ID_CHECKANSWER
MENUITEM SEPARATOR
Expand Down
4 changes: 2 additions & 2 deletions lang/ja_JP.rc
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ IDB_DELETEPAT BITMAP "res/1041_Bitmap_102.bmp"
MENUITEM SEPARATOR
MENUITEM "一定時間が過ぎたら再試行(&T)", ID_RETRYIFTIMEOUT
MENUITEM SEPARATOR
MENUITEM "解を表示する(&S)\tCtrl+M", ID_SHOWSOLUTION
MENUITEM "解を表示しない(&D)\tCtrl+M", ID_NOSOLUTION
MENUITEM "答えを表示する(&W)\tCtrl+M", ID_SHOWSOLUTION
MENUITEM "答えを表示しない(&D)\tCtrl+M", ID_NOSOLUTION
MENUITEM SEPARATOR
MENUITEM "答え合わせ(&C)", ID_CHECKANSWER
MENUITEM SEPARATOR
Expand Down

0 comments on commit 10d2818

Please sign in to comment.