Skip to content

Commit

Permalink
NoReadLooks and NoWriteLooks
Browse files Browse the repository at this point in the history
  • Loading branch information
katahiromz committed Apr 2, 2024
1 parent 714e37e commit 16327c6
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 12 deletions.
45 changes: 33 additions & 12 deletions GUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,10 @@ COLORREF xg_rgbMarkedCellColor = RGB(255, 255, 255);
// 二重マス文字。
XGStringW xg_strDoubleFrameLetters;

// LOOKS情報を読み込まない、書き込まない。
BOOL xg_bNoReadLooks = FALSE;
BOOL xg_bNoWriteLooks = FALSE;

//////////////////////////////////////////////////////////////////////////////
// static variables

Expand Down Expand Up @@ -926,6 +930,9 @@ void XgResetSettings(void)
xg_bShowAnswerOnOpen = FALSE;
xg_bShowAnswerOnGenerate = TRUE;
xg_bAutoSave = FALSE;

xg_bNoReadLooks = FALSE;
xg_bNoWriteLooks = FALSE;
}

// 設定を読み込む。
Expand Down Expand Up @@ -1040,6 +1047,12 @@ bool __fastcall XgLoadSettings(void)
if (!app_key.QueryDword(L"AutoSave", dwValue)) {
xg_bAutoSave = static_cast<BOOL>(dwValue);
}
if (!app_key.QueryDword(L"NoReadLooks", dwValue)) {
xg_bNoReadLooks = static_cast<BOOL>(dwValue);
}
if (!app_key.QueryDword(L"NoWriteLooks", dwValue)) {
xg_bNoWriteLooks = static_cast<BOOL>(dwValue);
}

if (!app_key.QuerySz(L"CellFont", sz, _countof(sz))) {
StringCchCopy(xg_szCellFont, _countof(xg_szCellFont), sz);
Expand Down Expand Up @@ -1252,6 +1265,8 @@ bool __fastcall XgSaveSettings(void)
app_key.SetDword(L"ShowAnswerOnOpen", xg_bShowAnswerOnOpen);
app_key.SetDword(L"ShowAnswerOnGenerate", xg_bShowAnswerOnGenerate);
app_key.SetDword(L"AutoSave", xg_bAutoSave);
app_key.SetDword(L"NoReadLooks", xg_bNoReadLooks);
app_key.SetDword(L"NoWriteLooks", xg_bNoWriteLooks);

app_key.SetSz(L"CellFont", xg_szCellFont, _countof(xg_szCellFont));
app_key.SetSz(L"SmallFont", xg_szSmallFont, _countof(xg_szSmallFont));
Expand Down Expand Up @@ -2262,16 +2277,18 @@ bool __fastcall XgDoSaveFiles(HWND hwnd, LPCWSTR pszFile)
XgGetFileManager()->set_looks(L"");

// 関連画像ファイルをパス名を変換して保存する。
XGStringW files_dir;
XgGetFileManager()->get_files_dir(files_dir);
CreateDirectoryW(files_dir.c_str(), nullptr);
for (auto& box : xg_boxes) {
if (box->m_type == L"pic") {
auto pic = dynamic_cast<XG_PictureBoxWindow*>(&*box);
XgGetFileManager()->save_image2(pic->m_strText);
if (!xg_bNoWriteLooks) {
XGStringW files_dir;
XgGetFileManager()->get_files_dir(files_dir);
CreateDirectoryW(files_dir.c_str(), nullptr);
for (auto& box : xg_boxes) {
if (box->m_type == L"pic") {
auto pic = dynamic_cast<XG_PictureBoxWindow*>(&*box);
XgGetFileManager()->save_image2(pic->m_strText);
}
}
XgGetFileManager()->save_image2(xg_strBlackCellImage);
}
XgGetFileManager()->save_image2(xg_strBlackCellImage);

// 保存する。
if (!XgDoSaveFile(hwnd, pszFile)) {
Expand All @@ -2282,8 +2299,10 @@ bool __fastcall XgDoSaveFiles(HWND hwnd, LPCWSTR pszFile)
}

// 関連ファイルをエクスポートする。
auto looks_file = XgGetFileManager()->get_looks_file();
XgExportLooks(hwnd, looks_file.c_str());
if (!xg_bNoWriteLooks) {
auto looks_file = XgGetFileManager()->get_looks_file();
XgExportLooks(hwnd, looks_file.c_str());
}

// ファイルの種類を保存する。
LPCWSTR pchDotExt = PathFindExtensionW(pszFile);
Expand Down Expand Up @@ -2516,8 +2535,10 @@ bool __fastcall XgDoLoadFiles(HWND hwnd, LPCWSTR pszFile)
XgLoadImageFiles();

// LOOKSファイルも自動でインポートする。
auto looks_file = XgGetFileManager()->get_looks_file();
XgImportLooks(hwnd, looks_file.c_str());
if (!xg_bNoReadLooks) {
auto looks_file = XgGetFileManager()->get_looks_file();
XgImportLooks(hwnd, looks_file.c_str());
}

// 答えを表示するかどうか?
xg_bShowAnswer = xg_bShowAnswerOnOpen;
Expand Down
4 changes: 4 additions & 0 deletions GUI.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,8 @@ void XgUpdateRules(HWND hwnd);
// 問題を生成したときに答えを表示するか?
extern BOOL xg_bShowAnswerOnGenerate;

// LOOKS情報を読み込まない、書き込まない。
extern BOOL xg_bNoReadLooks;
extern BOOL xg_bNoWriteLooks;

//////////////////////////////////////////////////////////////////////////////
8 changes: 8 additions & 0 deletions XgFileSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ XgFileSettingsDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
CheckDlgButton(hwnd, chx2, BST_CHECKED);
if (xg_bShowAnswerOnGenerate)
CheckDlgButton(hwnd, chx3, BST_CHECKED);
if (xg_bNoReadLooks)
CheckDlgButton(hwnd, chx4, BST_CHECKED);
if (xg_bNoWriteLooks)
CheckDlgButton(hwnd, chx5, BST_CHECKED);
// 保存先を初期化。
for (const auto& dir : xg_dirs_save_to) {
SendDlgItemMessage(hwnd, cmb1, CB_ADDSTRING, 0, (LPARAM)dir.c_str());
Expand All @@ -28,6 +32,8 @@ XgFileSettingsDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
case chx1:
case chx2:
case chx3:
case chx4:
case chx5:
if (HIWORD(wParam) == BN_CLICKED)
PropSheet_Changed(GetParent(hwnd), hwnd);
break;
Expand Down Expand Up @@ -87,6 +93,8 @@ XgFileSettingsDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
xg_bShowAnswerOnOpen = (IsDlgButtonChecked(hwnd, chx1) == BST_CHECKED);
xg_bAutoSave = (IsDlgButtonChecked(hwnd, chx2) == BST_CHECKED);
xg_bShowAnswerOnGenerate = (IsDlgButtonChecked(hwnd, chx3) == BST_CHECKED);
xg_bNoReadLooks = (IsDlgButtonChecked(hwnd, chx4) == BST_CHECKED);
xg_bNoWriteLooks = (IsDlgButtonChecked(hwnd, chx5) == BST_CHECKED);

// テキストを取得する。
WCHAR szFile[MAX_PATH];
Expand Down
2 changes: 2 additions & 0 deletions lang/en_US.rc
Original file line number Diff line number Diff line change
Expand Up @@ -1516,6 +1516,8 @@ FONT 9, "Tahoma"
COMBOBOX cmb1, 10, 100, 195, 300, CBS_HASSTRINGS | CBS_AUTOHSCROLL | CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP
PUSHBUTTON "&Browse...", psh1, 10, 115, 60, 15
PUSHBUTTON "Open &Folder", psh2, 110, 115, 95, 15
AUTOCHECKBOX "Do not &read LOOKS information from file", chx4, 10, 145, 195, 15
AUTOCHECKBOX "Do not &write LOOKS information to file", chx5, 10, 170, 195, 15
}

IDD_VIEWSETTINGS DIALOG 0, 0, 220, 190
Expand Down
2 changes: 2 additions & 0 deletions lang/ja_JP.rc
Original file line number Diff line number Diff line change
Expand Up @@ -1519,6 +1519,8 @@ FONT 9, "MS UI Gothic"
COMBOBOX cmb1, 10, 100, 195, 300, CBS_HASSTRINGS | CBS_AUTOHSCROLL | CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP
PUSHBUTTON "参照(&B)...", psh1, 10, 115, 60, 15
PUSHBUTTON "フォルダを開く(&F)", psh2, 110, 115, 95, 15
AUTOCHECKBOX "ファイルからLOOKS情報を読み込まない(&R)", chx4, 10, 145, 195, 15
AUTOCHECKBOX "ファイルへLOOKS情報を書き込まない(&W)", chx5, 10, 170, 195, 15
}

IDD_VIEWSETTINGS DIALOG 0, 0, 220, 190
Expand Down

0 comments on commit 16327c6

Please sign in to comment.