Skip to content

Commit

Permalink
Fix #196
Browse files Browse the repository at this point in the history
  • Loading branch information
katahiromz committed Jul 21, 2024
1 parent bc98a33 commit 982d124
Show file tree
Hide file tree
Showing 31 changed files with 408 additions and 308 deletions.
1 change: 1 addition & 0 deletions HISTORY-ID.txt
Original file line number Diff line number Diff line change
Expand Up @@ -312,3 +312,4 @@
- Supported exporting RES file.
- v.5.8.3 (2024-XX-YY)
- Auto filling resource name from filename.
- Added resource language setting.
1 change: 1 addition & 0 deletions HISTORY-ITA.txt
Original file line number Diff line number Diff line change
Expand Up @@ -312,3 +312,4 @@
- Supporto esportazione file RES.
- v.5.8.3 (2024-XX-YY)
- Auto filling resource name from filename.
- Added resource language setting.
1 change: 1 addition & 0 deletions HISTORY-JPN.txt
Original file line number Diff line number Diff line change
Expand Up @@ -656,3 +656,4 @@
- RESファイルのエクスポートをサポート。
- v.5.8.3 (2024-XX-YY)
- ファイル名からリソース名を埋める。
- リソース言語設定を追加。
1 change: 1 addition & 0 deletions HISTORY-KOR.txt
Original file line number Diff line number Diff line change
Expand Up @@ -313,3 +313,4 @@
- RES 파일 내보내기가 지원됩니다.
- v.5.8.3 (2024-XX-YY)
- Auto filling resource name from filename.
- Added resource language setting.
1 change: 1 addition & 0 deletions HISTORY-PTB.txt
Original file line number Diff line number Diff line change
Expand Up @@ -312,3 +312,4 @@
- Supported exporting RES file.
- v.5.8.3 (2024-XX-YY)
- Auto filling resource name from filename.
- Added resource language setting.
1 change: 1 addition & 0 deletions HISTORY.txt
Original file line number Diff line number Diff line change
Expand Up @@ -312,3 +312,4 @@
- Supported exporting RES file.
- v.5.8.3 (2024-XX-YY)
- Auto filling resource name from filename.
- Added resource language setting.
14 changes: 11 additions & 3 deletions src/Common.hpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
#pragma once

enum LANG_TYPE
{
LANG_TYPE_0,
LANG_TYPE_1,
LANG_TYPE_2
};

BOOL CheckCommand(MString strCommand);
BOOL CheckCommand(MString& strCommand);
BOOL CheckLangComboBox(HWND hCmb3, WORD& lang);
BOOL CheckLangComboBox(HWND hCmb3, WORD& lang, BOOL bUILanguage);
BOOL CheckLangComboBox(HWND hCmb3, WORD& lang, LANG_TYPE type);
BOOL CheckNameComboBox(HWND hCmb2, MIdOrString& name);
BOOL CheckTypeComboBox(HWND hCmb1, MIdOrString& type);
BOOL Cmb1_CheckKey(HWND hwnd, HWND hCmb1, BOOL bVirtKey, std::wstring& str);
Expand All @@ -29,8 +36,8 @@ void InitComboBoxPlaceholder(HWND hCmb, UINT nStringID);
void InitConstantComboBox(HWND hCmb);
void InitCtrlIDComboBox(HWND hCmb);
void InitFontComboBox(HWND hCmb);
void InitLangComboBox(HWND hCmb3, LANGID langid);
void InitLangComboBox(HWND hCmb3, LANGID langid, BOOL bUILanguage);
void InitLangComboBox(HWND hCmb3, DWORD langid);
void InitLangComboBox(HWND hCmb3, DWORD langid, BOOL bUILanguage);
void InitLangListView(HWND hLst1, LPCTSTR pszText);
void InitMessageComboBox(HWND hCmb, const MString& strString);
void InitResNameComboBox(HWND hCmb, const MIdOrString& id, IDTYPE_ nIDTYPE_);
Expand All @@ -41,3 +48,4 @@ void InitStyleListBox(HWND hLst, ConstantsDB::TableType& table);
void InitWndClassComboBox(HWND hCmb, LPCTSTR pszWndClass);
void ReplaceFullWithHalf(LPWSTR pszText);
void ReplaceFullWithHalf(MStringW& strText);
DWORD GetDefaultResLanguage(VOID);
3 changes: 1 addition & 2 deletions src/MAddBitmapDlg.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ class MAddBitmapDlg : public MDialogBase
, m_pAutoComplete(new MLangAutoComplete())
{
m_cmb3.m_bAcceptSpace = TRUE;
m_pAutoComplete->AddRef();
}

~MAddBitmapDlg()
Expand All @@ -70,7 +69,7 @@ class MAddBitmapDlg : public MDialogBase

// for Langs
HWND hCmb3 = GetDlgItem(hwnd, cmb3);
InitLangComboBox(hCmb3, GetThreadUILanguage());
InitLangComboBox(hCmb3, GetDefaultResLanguage());
SubclassChildDx(m_cmb3, cmb3);

CenterWindowDx();
Expand Down
3 changes: 1 addition & 2 deletions src/MAddCursorDlg.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ class MAddCursorDlg : public MDialogBase
, m_file(NULL)
, m_pAutoComplete(new MLangAutoComplete())
{
m_pAutoComplete->AddRef();
m_hCursor = NULL;
m_cmb3.m_bAcceptSpace = TRUE;
}
Expand Down Expand Up @@ -77,7 +76,7 @@ class MAddCursorDlg : public MDialogBase

// for Langs
HWND hCmb3 = GetDlgItem(hwnd, cmb3);
InitLangComboBox(hCmb3, GetThreadUILanguage());
InitLangComboBox(hCmb3, GetDefaultResLanguage());
SubclassChildDx(m_cmb3, cmb3);

// auto complete
Expand Down
3 changes: 1 addition & 2 deletions src/MAddIconDlg.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ class MAddIconDlg : public MDialogBase
, m_hIcon(NULL)
, m_pAutoComplete(new MLangAutoComplete())
{
m_pAutoComplete->AddRef();
m_cmb3.m_bAcceptSpace = TRUE;
}

Expand Down Expand Up @@ -77,7 +76,7 @@ class MAddIconDlg : public MDialogBase

// for Langs
HWND hCmb3 = GetDlgItem(hwnd, cmb3);
InitLangComboBox(hCmb3, GetThreadUILanguage());
InitLangComboBox(hCmb3, GetDefaultResLanguage());
SubclassChildDx(m_cmb3, cmb3);

CenterWindowDx();
Expand Down
3 changes: 1 addition & 2 deletions src/MAddResDlg.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ class MAddResDlg : public MDialogBase
, m_file(NULL)
, m_pAutoComplete(new MLangAutoComplete())
{
m_pAutoComplete->AddRef();
m_cmb3.m_bAcceptSpace = TRUE;
}

Expand Down Expand Up @@ -84,7 +83,7 @@ class MAddResDlg : public MDialogBase

// for Langs
HWND hCmb3 = GetDlgItem(hwnd, cmb3);
InitLangComboBox(hCmb3, GetThreadUILanguage());
InitLangComboBox(hCmb3, GetDefaultResLanguage());
SubclassChildDx(m_cmb3, cmb3);

// for file
Expand Down
12 changes: 7 additions & 5 deletions src/MChooseLangDlg.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,16 @@ class MChooseLangDlg : public MDialogBase
, m_pAutoComplete(new MLangAutoComplete(TRUE))
{
m_cmb3.m_bAcceptSpace = TRUE;
m_pAutoComplete->AddRef();
}

~MChooseLangDlg()
{
m_pAutoComplete->unbind();
m_pAutoComplete->Release();
m_pAutoComplete = NULL;
if (m_pAutoComplete)
{
m_pAutoComplete->unbind();
m_pAutoComplete->Release();
m_pAutoComplete = NULL;
}
}

BOOL OnInitDialog(HWND hwnd, HWND hwndFocus, LPARAM lParam)
Expand All @@ -74,7 +76,7 @@ class MChooseLangDlg : public MDialogBase
{
HWND hCmb3 = GetDlgItem(hwnd, cmb3);
WORD lang;
if (!CheckLangComboBox(hCmb3, lang, TRUE))
if (!CheckLangComboBox(hCmb3, lang, LANG_TYPE_1))
return;

m_langid = lang;
Expand Down
45 changes: 44 additions & 1 deletion src/MConfigDlg.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,31 @@
#include "MMacrosDlg.hpp"
#include "MPathsDlg.hpp"
#include "MFontsDlg.hpp"
#include "MLangAutoComplete.hpp"

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

class MConfigDlg : public MDialogBase
{
public:
MConfigDlg() : MDialogBase(IDD_CONFIG)
MComboBoxAutoComplete m_cmb3;
MLangAutoComplete *m_pAutoComplete;

MConfigDlg()
: MDialogBase(IDD_CONFIG)
, m_pAutoComplete(new MLangAutoComplete())
{
m_cmb3.m_bAcceptSpace = TRUE;
}

~MConfigDlg()
{
if (m_pAutoComplete)
{
m_pAutoComplete->unbind();
m_pAutoComplete->Release();
m_pAutoComplete = NULL;
}
}

void Reload(HWND hwnd)
Expand Down Expand Up @@ -78,13 +95,33 @@ class MConfigDlg : public MDialogBase
Cmb1_AddString(hwnd, TEXT(ATLAXWIN_CLASS));
#endif

HWND hCmb3 = GetDlgItem(hwnd, cmb3);
InitLangComboBox(hCmb3, g_settings.nDefResLangID);
SubclassChildDx(m_cmb3, cmb3);

// auto complete
if (m_pAutoComplete)
{
COMBOBOXINFO info = { sizeof(info) };
GetComboBoxInfo(m_cmb3, &info);
HWND hwndEdit = info.hwndItem;
m_pAutoComplete->bind(hwndEdit);
}

Reload(hwnd);
CenterWindowDx();
return TRUE;
}

void OnOK(HWND hwnd)
{
HWND hCmb3 = GetDlgItem(hwnd, cmb3);
WORD lang;
if (CheckLangComboBox(hCmb3, lang, LANG_TYPE_2))
g_settings.nDefResLangID = lang;
else
g_settings.nDefResLangID = BAD_LANG;

BOOL bTranslated = FALSE;
INT nHeight = GetDlgItemInt(hwnd, edt1, &bTranslated, FALSE);
if (!bTranslated)
Expand Down Expand Up @@ -171,6 +208,12 @@ class MConfigDlg : public MDialogBase
case psh4:
OnPsh4(hwnd);
break;
case cmb3:
if (codeNotify == CBN_EDITCHANGE)
{
m_cmb3.OnEditChange(); // input completion
}
break;
}
}

Expand Down
10 changes: 6 additions & 4 deletions src/MCopyToMultiLangDlg.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,16 @@ class MCopyToMultiLangDlg : public MDialogBase
m_pAutoComplete(new MLangAutoComplete())
{
m_cmb3.m_bAcceptSpace = TRUE;
m_pAutoComplete->AddRef();
}

~MCopyToMultiLangDlg()
{
m_pAutoComplete->unbind();
m_pAutoComplete->Release();
m_pAutoComplete = NULL;
if (m_pAutoComplete)
{
m_pAutoComplete->unbind();
m_pAutoComplete->Release();
m_pAutoComplete = NULL;
}
}

virtual INT_PTR CALLBACK
Expand Down
40 changes: 28 additions & 12 deletions src/RisohEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,13 @@ void ReplaceFullWithHalf(MStringW& strText)
ReplaceFullWithHalf(&strText[0]);
}

DWORD GetDefaultResLanguage(VOID)
{
if (g_settings.nDefResLangID == BAD_LANG)
return ::GetThreadUILanguage();
return g_settings.nDefResLangID;
}

// get the path of a shortcut file
BOOL GetPathOfShortcutDx(HWND hwnd, LPCWSTR pszLnkFile, LPWSTR pszPath)
{
Expand Down Expand Up @@ -1218,7 +1225,7 @@ BOOL IsValidUILang(LANGID langid)
MLangAutoComplete::MLangAutoComplete(BOOL bUILanguage)
{
m_nCurrentElement = 0;
m_nRefCount = 0;
m_nRefCount = 1;
m_fBound = FALSE;
m_pAC = NULL;

Expand All @@ -1232,7 +1239,7 @@ MLangAutoComplete::MLangAutoComplete(BOOL bUILanguage)
}

// initialize the language combobox
void InitLangComboBox(HWND hCmb3, LANGID langid, BOOL bUILanguage)
void InitLangComboBox(HWND hCmb3, DWORD langid, BOOL bUILanguage)
{
InitComboBoxPlaceholder(hCmb3, IDS_INTEGERORIDENTIFIER);

Expand Down Expand Up @@ -1275,10 +1282,13 @@ void InitLangComboBox(HWND hCmb3, LANGID langid, BOOL bUILanguage)
// add the text as a new item to combobox
ComboBox_AddString(hCmb3, sz);
}

if (langid == (DWORD)-1)
ComboBox_SetText(hCmb3, L"");
}

// initialize the language combobox
void InitLangComboBox(HWND hCmb3, LANGID langid)
void InitLangComboBox(HWND hCmb3, DWORD langid)
{
InitLangComboBox(hCmb3, langid, FALSE);
}
Expand Down Expand Up @@ -1595,29 +1605,33 @@ WORD LangFromText(LPWSTR pszLang)
}

// verify the language combobox
BOOL CheckLangComboBox(HWND hCmb3, WORD& lang, BOOL bUILanguage)
BOOL CheckLangComboBox(HWND hCmb3, WORD& lang, LANG_TYPE type)
{
// get the text from combobox
WCHAR szLang[MAX_PATH];
GetWindowTextW(hCmb3, szLang, _countof(szLang));

// get the language ID from texts
lang = LangFromText(szLang);
if ((!bUILanguage || IsValidUILang(lang)) && lang != BAD_LANG)
if ((type != LANG_TYPE_1 || IsValidUILang(lang)) && lang != BAD_LANG)
return TRUE; // success

// error
ComboBox_SetEditSel(hCmb3, 0, -1);
SetFocus(hCmb3);
LogMessageBoxW(GetParent(hCmb3), LoadStringDx(IDS_ENTERLANG),
NULL, MB_ICONERROR);
if (type != LANG_TYPE_2)
{
// error
ComboBox_SetEditSel(hCmb3, 0, -1);
SetFocus(hCmb3);
LogMessageBoxW(GetParent(hCmb3), LoadStringDx(IDS_ENTERLANG),
NULL, MB_ICONERROR);
}

return FALSE; // failure
}

// verify the language combobox
BOOL CheckLangComboBox(HWND hCmb3, WORD& lang)
{
return CheckLangComboBox(hCmb3, lang, FALSE);
return CheckLangComboBox(hCmb3, lang, LANG_TYPE_0);
}

// callback function for MMainWnd::DoLoadLangInfo
Expand Down Expand Up @@ -12091,7 +12105,6 @@ void MMainWnd::DoLangEditAutoComplete(HWND hwnd, HWND hwndEdit)
if (!m_pAutoComplete)
return;

m_pAutoComplete->AddRef();
m_pAutoComplete->bind(hwndEdit);
m_auto_comp_edit.hook(hwndEdit, m_hwndTV);
m_auto_comp_edit.m_bAdjustSize = TRUE;
Expand Down Expand Up @@ -13693,6 +13706,7 @@ void MMainWnd::SetDefaultSettings(HWND hwnd)
g_settings.nEgaY = CW_USEDEFAULT;
g_settings.nEgaWidth = CW_USEDEFAULT;
g_settings.nEgaHeight = CW_USEDEFAULT;
g_settings.nDefResLangID = BAD_LANG;

HFONT hFont;
LOGFONTW lf, lfBin, lfSrc;
Expand Down Expand Up @@ -13908,6 +13922,7 @@ BOOL MMainWnd::LoadSettings(HWND hwnd)
keyRisoh.QueryDword(TEXT("nEgaY"), (DWORD&)g_settings.nEgaY);
keyRisoh.QueryDword(TEXT("nEgaWidth"), (DWORD&)g_settings.nEgaWidth);
keyRisoh.QueryDword(TEXT("nEgaHeight"), (DWORD&)g_settings.nEgaHeight);
keyRisoh.QueryDword(TEXT("nDefResLangID"), (DWORD&)g_settings.nDefResLangID);

TCHAR szText[128];
TCHAR szValueName[128];
Expand Down Expand Up @@ -14230,6 +14245,7 @@ BOOL MMainWnd::SaveSettings(HWND hwnd)
keyRisoh.SetDword(TEXT("nEgaY"), g_settings.nEgaY);
keyRisoh.SetDword(TEXT("nEgaWidth"), g_settings.nEgaWidth);
keyRisoh.SetDword(TEXT("nEgaHeight"), g_settings.nEgaHeight);
keyRisoh.SetDword(TEXT("nDefResLangID"), g_settings.nDefResLangID);
keyRisoh.SetSz(TEXT("strSrcFont"), g_settings.strSrcFont.c_str());
keyRisoh.SetDword(TEXT("nSrcFontSize"), g_settings.nSrcFontSize);
keyRisoh.SetSz(TEXT("strBinFont"), g_settings.strBinFont.c_str());
Expand Down
2 changes: 1 addition & 1 deletion src/RisohEditor_res.rc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// RisohEditor_res.rc
// This file is automatically generated by RisohEditor 5.8.3.
// This file is automatically generated by RisohEditor 5.8.2.
// † <-- This dagger helps UTF-8 detection.

#include "resource.h"
Expand Down
1 change: 1 addition & 0 deletions src/RisohSettings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ struct RisohSettings
MString strFontReplaceTo1;
MString strFontReplaceTo2;
MString strFontReplaceTo3;
DWORD nDefResLangID;

RisohSettings()
{
Expand Down
Loading

0 comments on commit 982d124

Please sign in to comment.