From 958d9c26bbc4725a307f15e1a5de27fa9be0ea23 Mon Sep 17 00:00:00 2001 From: Samuel Yuan Date: Fri, 13 Nov 2015 20:16:01 -0500 Subject: [PATCH 1/4] Fixed "Save Slot (%s) selected" Text The text was not showing up correctly because it was not using wide strings. This worked in an earlier build, but was changed not too long ago. --- Lang/Chinese (Simplified).pj.Lang | 5 +++-- Lang/English.pj.Lang | 1 + Source/Project64/Multilanguage.h | 1 + .../Project64/Multilanguage/Language Class.cpp | 1 + .../User Interface/Main Menu Class.cpp | 6 +++--- .../User Interface/Notification Class.cpp | 17 +++++++++++++++++ .../User Interface/Notification Class.h | 2 ++ 7 files changed, 28 insertions(+), 5 deletions(-) diff --git a/Lang/Chinese (Simplified).pj.Lang b/Lang/Chinese (Simplified).pj.Lang index 3ac06bd97..024204739 100644 --- a/Lang/Chinese (Simplified).pj.Lang +++ b/Lang/Chinese (Simplified).pj.Lang @@ -88,6 +88,7 @@ #198# "插槽 8" #199# "插槽 9" #200# "插槽 10" +#201# "插槽 (%s) 被选" //Pop up Menu #210# "运行游戏" @@ -224,7 +225,7 @@ #452# " 选择材质包目录" //Options Dialog -#460# "当窗口处于非活动状态时暂停模拟器" +#460# "当模拟器窗口不是处于屏幕最上方,暂停模拟器" #461# "载入ROM后切换为全屏模式" #462# "隐藏高级设置" #463# "记住已选择的金手指" @@ -255,7 +256,7 @@ #503# "自我修改码方案:" #504# "默认存档容量:" #505# "高级模块连接" -#506# "当ROM加载后,开始模拟" +#506# "当读取完ROM后,开始模拟" #507# "总是从 RDB 中覆盖默认设置" #508# "自动压缩即时存档文件" #509# "开启调试器" diff --git a/Lang/English.pj.Lang b/Lang/English.pj.Lang index 07465641d..7a3a5aafd 100644 --- a/Lang/English.pj.Lang +++ b/Lang/English.pj.Lang @@ -88,6 +88,7 @@ #198# "Slot 8" #199# "Slot 9" #200# "Slot 10" +#201# "Save Slot (%s) selected" //Pop up Menu #210# "Play Game" diff --git a/Source/Project64/Multilanguage.h b/Source/Project64/Multilanguage.h index 910540d8a..c1e9ed0f3 100644 --- a/Source/Project64/Multilanguage.h +++ b/Source/Project64/Multilanguage.h @@ -117,6 +117,7 @@ enum LanguageStringID{ MENU_SLOT_8 = 198, MENU_SLOT_9 = 199, MENU_SLOT_10 = 200, + MENU_SLOT_SAVE = 201, //Pop up Menu POPUP_PLAY = 210, diff --git a/Source/Project64/Multilanguage/Language Class.cpp b/Source/Project64/Multilanguage/Language Class.cpp index e2f3d5855..1025cc380 100644 --- a/Source/Project64/Multilanguage/Language Class.cpp +++ b/Source/Project64/Multilanguage/Language Class.cpp @@ -124,6 +124,7 @@ void CLanguage::LoadDefaultStrings (void) DEF_STR(MENU_SLOT_8, L"Slot 8" ); DEF_STR(MENU_SLOT_9, L"Slot 9" ); DEF_STR(MENU_SLOT_10, L"Slot 10" ); + DEF_STR(MENU_SLOT_SAVE, L"Save Slot (%s) selected"); //Pop up Menu DEF_STR(POPUP_PLAY, L"Play Game" ); diff --git a/Source/Project64/User Interface/Main Menu Class.cpp b/Source/Project64/User Interface/Main Menu Class.cpp index 7b760a9f5..8505b6169 100644 --- a/Source/Project64/User Interface/Main Menu Class.cpp +++ b/Source/Project64/User Interface/Main Menu Class.cpp @@ -519,7 +519,7 @@ bool CMainMenu::ProcessMessage(HWND hWnd, DWORD /*FromAccelerator*/, DWORD MenuI case ID_DEBUGGER_INTERRUPT_PI: g_BaseSystem->ExternalEvent(SysEvent_Interrupt_PI); break; case ID_DEBUGGER_INTERRUPT_DP: g_BaseSystem->ExternalEvent(SysEvent_Interrupt_DP); break; case ID_CURRENT_SAVE_DEFAULT: - g_Notify->DisplayMessage(3, stdstr_f("Save Slot (%s) selected", GetSaveSlotString(MenuID - ID_CURRENT_SAVE_DEFAULT).c_str()).ToUTF16().c_str()); + g_Notify->DisplayMessageWide(3, GS(MENU_SLOT_SAVE), GetSaveSlotString(MenuID - ID_CURRENT_SAVE_DEFAULT).c_str()); g_Settings->SaveDword(Game_CurrentSaveState, (DWORD)(MenuID - ID_CURRENT_SAVE_DEFAULT)); break; case ID_CURRENT_SAVE_1: @@ -531,8 +531,8 @@ bool CMainMenu::ProcessMessage(HWND hWnd, DWORD /*FromAccelerator*/, DWORD MenuI case ID_CURRENT_SAVE_7: case ID_CURRENT_SAVE_8: case ID_CURRENT_SAVE_9: - case ID_CURRENT_SAVE_10: - g_Notify->DisplayMessage(3, stdstr_f("Save Slot (%s) selected", GetSaveSlotString((MenuID - ID_CURRENT_SAVE_1) + 1)).ToUTF16().c_str()); + case ID_CURRENT_SAVE_10: + g_Notify->DisplayMessageWide(3, GS(MENU_SLOT_SAVE), GetSaveSlotString((MenuID - ID_CURRENT_SAVE_1) + 1).c_str()); g_Settings->SaveDword(Game_CurrentSaveState, (DWORD)((MenuID - ID_CURRENT_SAVE_1) + 1)); break; case ID_HELP_SUPPORTFORUM: ShellExecute(NULL, "open", "http://forum.pj64-emu.com/", NULL, NULL, SW_SHOWMAXIMIZED); break; diff --git a/Source/Project64/User Interface/Notification Class.cpp b/Source/Project64/User Interface/Notification Class.cpp index 097adf98f..1e270d7eb 100644 --- a/Source/Project64/User Interface/Notification Class.cpp +++ b/Source/Project64/User Interface/Notification Class.cpp @@ -113,6 +113,23 @@ void CNotification::DisplayMessage(int DisplayTime, const wchar_t * Message) con } } +void CNotification::DisplayMessageWide(int DisplayTime, const wchar_t * Message, ...) const +{ + va_list ap; + va_start(ap, Message); + DisplayMessageWide(DisplayTime, Message, ap); +} + +void CNotification::DisplayMessageWide(int DisplayTime, const wchar_t * Message, va_list ap) const +{ + wchar_t Msg[1000]; + + _vsnwprintf(Msg, sizeof(Msg) - 1, Message, ap); + va_end(ap); + + DisplayMessage(DisplayTime, Msg); +} + void CNotification::DisplayMessage2(const wchar_t * Message) const { if (!m_hWnd) { return; } diff --git a/Source/Project64/User Interface/Notification Class.h b/Source/Project64/User Interface/Notification Class.h index c8b76833b..5f8aebcb3 100644 --- a/Source/Project64/User Interface/Notification Class.h +++ b/Source/Project64/User Interface/Notification Class.h @@ -35,6 +35,8 @@ public: //User Feedback virtual void DisplayMessage(int DisplayTime, const wchar_t * Message) const; virtual void DisplayMessage(int DisplayTime, LanguageStringID StringID) const; + virtual void DisplayMessageWide(int DisplayTime, const wchar_t * Message, ...) const; + virtual void DisplayMessageWide(int DisplayTime, const wchar_t * Message, va_list ap) const; virtual void DisplayMessage2(const wchar_t * Message) const; virtual void BreakPoint(const wchar_t * FileName, const int LineNumber); From 239490417e4a888bb0ef7cc1596db5e07b6a6dc6 Mon Sep 17 00:00:00 2001 From: Samuel Yuan Date: Fri, 13 Nov 2015 23:45:20 -0500 Subject: [PATCH 2/4] Minor changes to files --- Lang/Chinese (Simplified).pj.Lang | 2 +- Lang/English.pj.Lang | 2 +- Source/Project64/Multilanguage.h | 2 +- Source/Project64/Multilanguage/Language Class.cpp | 2 +- .../Project64/User Interface/Main Menu Class.cpp | 6 +++--- .../User Interface/Notification Class.cpp | 14 +++++++------- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Lang/Chinese (Simplified).pj.Lang b/Lang/Chinese (Simplified).pj.Lang index 024204739..41a77dbcb 100644 --- a/Lang/Chinese (Simplified).pj.Lang +++ b/Lang/Chinese (Simplified).pj.Lang @@ -88,7 +88,7 @@ #198# "插槽 8" #199# "插槽 9" #200# "插槽 10" -#201# "插槽 (%s) 被选" +#201# "插槽 (%ws) 被选" //Pop up Menu #210# "运行游戏" diff --git a/Lang/English.pj.Lang b/Lang/English.pj.Lang index 7a3a5aafd..ea3a5e8ac 100644 --- a/Lang/English.pj.Lang +++ b/Lang/English.pj.Lang @@ -88,7 +88,7 @@ #198# "Slot 8" #199# "Slot 9" #200# "Slot 10" -#201# "Save Slot (%s) selected" +#201# "Save Slot (%ws) selected" //Pop up Menu #210# "Play Game" diff --git a/Source/Project64/Multilanguage.h b/Source/Project64/Multilanguage.h index c1e9ed0f3..fd1042845 100644 --- a/Source/Project64/Multilanguage.h +++ b/Source/Project64/Multilanguage.h @@ -117,7 +117,7 @@ enum LanguageStringID{ MENU_SLOT_8 = 198, MENU_SLOT_9 = 199, MENU_SLOT_10 = 200, - MENU_SLOT_SAVE = 201, + MENU_SLOT_SAVE = 201, //Pop up Menu POPUP_PLAY = 210, diff --git a/Source/Project64/Multilanguage/Language Class.cpp b/Source/Project64/Multilanguage/Language Class.cpp index 1025cc380..e002f27fa 100644 --- a/Source/Project64/Multilanguage/Language Class.cpp +++ b/Source/Project64/Multilanguage/Language Class.cpp @@ -124,7 +124,7 @@ void CLanguage::LoadDefaultStrings (void) DEF_STR(MENU_SLOT_8, L"Slot 8" ); DEF_STR(MENU_SLOT_9, L"Slot 9" ); DEF_STR(MENU_SLOT_10, L"Slot 10" ); - DEF_STR(MENU_SLOT_SAVE, L"Save Slot (%s) selected"); + DEF_STR(MENU_SLOT_SAVE, L"Save Slot (%s) selected"); //Pop up Menu DEF_STR(POPUP_PLAY, L"Play Game" ); diff --git a/Source/Project64/User Interface/Main Menu Class.cpp b/Source/Project64/User Interface/Main Menu Class.cpp index 8505b6169..4cde81bac 100644 --- a/Source/Project64/User Interface/Main Menu Class.cpp +++ b/Source/Project64/User Interface/Main Menu Class.cpp @@ -519,7 +519,7 @@ bool CMainMenu::ProcessMessage(HWND hWnd, DWORD /*FromAccelerator*/, DWORD MenuI case ID_DEBUGGER_INTERRUPT_PI: g_BaseSystem->ExternalEvent(SysEvent_Interrupt_PI); break; case ID_DEBUGGER_INTERRUPT_DP: g_BaseSystem->ExternalEvent(SysEvent_Interrupt_DP); break; case ID_CURRENT_SAVE_DEFAULT: - g_Notify->DisplayMessageWide(3, GS(MENU_SLOT_SAVE), GetSaveSlotString(MenuID - ID_CURRENT_SAVE_DEFAULT).c_str()); + g_Notify->DisplayMessageWide(3, GS(MENU_SLOT_SAVE), GetSaveSlotString(MenuID - ID_CURRENT_SAVE_DEFAULT).c_str()); g_Settings->SaveDword(Game_CurrentSaveState, (DWORD)(MenuID - ID_CURRENT_SAVE_DEFAULT)); break; case ID_CURRENT_SAVE_1: @@ -531,8 +531,8 @@ bool CMainMenu::ProcessMessage(HWND hWnd, DWORD /*FromAccelerator*/, DWORD MenuI case ID_CURRENT_SAVE_7: case ID_CURRENT_SAVE_8: case ID_CURRENT_SAVE_9: - case ID_CURRENT_SAVE_10: - g_Notify->DisplayMessageWide(3, GS(MENU_SLOT_SAVE), GetSaveSlotString((MenuID - ID_CURRENT_SAVE_1) + 1).c_str()); + case ID_CURRENT_SAVE_10: + g_Notify->DisplayMessageWide(3, GS(MENU_SLOT_SAVE), GetSaveSlotString((MenuID - ID_CURRENT_SAVE_1) + 1).c_str()); g_Settings->SaveDword(Game_CurrentSaveState, (DWORD)((MenuID - ID_CURRENT_SAVE_1) + 1)); break; case ID_HELP_SUPPORTFORUM: ShellExecute(NULL, "open", "http://forum.pj64-emu.com/", NULL, NULL, SW_SHOWMAXIMIZED); break; diff --git a/Source/Project64/User Interface/Notification Class.cpp b/Source/Project64/User Interface/Notification Class.cpp index 1e270d7eb..126f1d99f 100644 --- a/Source/Project64/User Interface/Notification Class.cpp +++ b/Source/Project64/User Interface/Notification Class.cpp @@ -115,19 +115,19 @@ void CNotification::DisplayMessage(int DisplayTime, const wchar_t * Message) con void CNotification::DisplayMessageWide(int DisplayTime, const wchar_t * Message, ...) const { - va_list ap; - va_start(ap, Message); - DisplayMessageWide(DisplayTime, Message, ap); + va_list ap; + va_start(ap, Message); + DisplayMessageWide(DisplayTime, Message, ap); } void CNotification::DisplayMessageWide(int DisplayTime, const wchar_t * Message, va_list ap) const { - wchar_t Msg[1000]; + wchar_t Msg[1000]; - _vsnwprintf(Msg, sizeof(Msg) - 1, Message, ap); - va_end(ap); + _vsnwprintf(Msg, sizeof(Msg) - 1, Message, ap); + va_end(ap); - DisplayMessage(DisplayTime, Msg); + DisplayMessage(DisplayTime, Msg); } void CNotification::DisplayMessage2(const wchar_t * Message) const From 68ad452a07316771a87f1724af62454b618ce5c6 Mon Sep 17 00:00:00 2001 From: Samuel Yuan Date: Sat, 14 Nov 2015 20:04:42 -0500 Subject: [PATCH 3/4] Added string back in It was deleted earlier due to a merge conflict. --- Source/Project64/Multilanguage.h | 1 + Source/Project64/Multilanguage/Language Class.cpp | 1 + .../User Interface/Notification Class.cpp | 15 +++++---------- .../Project64/User Interface/Notification Class.h | 1 - 4 files changed, 7 insertions(+), 11 deletions(-) diff --git a/Source/Project64/Multilanguage.h b/Source/Project64/Multilanguage.h index 559e03930..9b37d1418 100644 --- a/Source/Project64/Multilanguage.h +++ b/Source/Project64/Multilanguage.h @@ -117,6 +117,7 @@ enum LanguageStringID{ MENU_SLOT_8 = 198, MENU_SLOT_9 = 199, MENU_SLOT_10 = 200, + MENU_SLOT_SAVE = 201, //Pop up Menu POPUP_PLAY = 210, diff --git a/Source/Project64/Multilanguage/Language Class.cpp b/Source/Project64/Multilanguage/Language Class.cpp index 5794c80c4..0321de0fc 100644 --- a/Source/Project64/Multilanguage/Language Class.cpp +++ b/Source/Project64/Multilanguage/Language Class.cpp @@ -124,6 +124,7 @@ void CLanguage::LoadDefaultStrings(void) DEF_STR(MENU_SLOT_8, L"Slot 8"); DEF_STR(MENU_SLOT_9, L"Slot 9"); DEF_STR(MENU_SLOT_10, L"Slot 10"); + DEF_STR(MENU_SLOT_SAVE, L"Save slot (%ws) selected"); //Pop up Menu DEF_STR(POPUP_PLAY, L"Play Game"); diff --git a/Source/Project64/User Interface/Notification Class.cpp b/Source/Project64/User Interface/Notification Class.cpp index 126f1d99f..bfc28b558 100644 --- a/Source/Project64/User Interface/Notification Class.cpp +++ b/Source/Project64/User Interface/Notification Class.cpp @@ -115,19 +115,14 @@ void CNotification::DisplayMessage(int DisplayTime, const wchar_t * Message) con void CNotification::DisplayMessageWide(int DisplayTime, const wchar_t * Message, ...) const { + wchar_t Msg[1000]; + va_list ap; va_start(ap, Message); - DisplayMessageWide(DisplayTime, Message, ap); -} + _vsnwprintf(Msg, sizeof(Msg) - 1, Message, ap); + va_end(ap); -void CNotification::DisplayMessageWide(int DisplayTime, const wchar_t * Message, va_list ap) const -{ - wchar_t Msg[1000]; - - _vsnwprintf(Msg, sizeof(Msg) - 1, Message, ap); - va_end(ap); - - DisplayMessage(DisplayTime, Msg); + DisplayMessage(DisplayTime, Msg); } void CNotification::DisplayMessage2(const wchar_t * Message) const diff --git a/Source/Project64/User Interface/Notification Class.h b/Source/Project64/User Interface/Notification Class.h index 5f8aebcb3..c853371bc 100644 --- a/Source/Project64/User Interface/Notification Class.h +++ b/Source/Project64/User Interface/Notification Class.h @@ -36,7 +36,6 @@ public: virtual void DisplayMessage(int DisplayTime, const wchar_t * Message) const; virtual void DisplayMessage(int DisplayTime, LanguageStringID StringID) const; virtual void DisplayMessageWide(int DisplayTime, const wchar_t * Message, ...) const; - virtual void DisplayMessageWide(int DisplayTime, const wchar_t * Message, va_list ap) const; virtual void DisplayMessage2(const wchar_t * Message) const; virtual void BreakPoint(const wchar_t * FileName, const int LineNumber); From 4b43afe27580c002467dbf166aa3351b64aeb935 Mon Sep 17 00:00:00 2001 From: Samuel Yuan Date: Sat, 14 Nov 2015 22:12:24 -0500 Subject: [PATCH 4/4] Added class to format wide strings --- Source/Common/std string.h | 17 +++++++++++++++++ .../User Interface/Main Menu Class.cpp | 4 ++-- .../User Interface/Notification Class.cpp | 12 ------------ .../User Interface/Notification Class.h | 1 - 4 files changed, 19 insertions(+), 15 deletions(-) diff --git a/Source/Common/std string.h b/Source/Common/std string.h index 8b61aa99b..c7ebd007e 100644 --- a/Source/Common/std string.h +++ b/Source/Common/std string.h @@ -51,5 +51,22 @@ public: } }; +class stdwstr_f : public std::wstring +{ +public: + stdwstr_f(const wchar_t * strFormat, ...) + { + va_list args; + va_start(args, strFormat); + + wchar_t Msg[1000]; + _vsnwprintf(Msg, sizeof(Msg) - 1, strFormat, args); + + va_end(args); + + this->assign(Msg); + } +}; + typedef std::list strlist; typedef strlist::iterator strlist_iter; diff --git a/Source/Project64/User Interface/Main Menu Class.cpp b/Source/Project64/User Interface/Main Menu Class.cpp index 4cde81bac..a2eef6a62 100644 --- a/Source/Project64/User Interface/Main Menu Class.cpp +++ b/Source/Project64/User Interface/Main Menu Class.cpp @@ -519,7 +519,7 @@ bool CMainMenu::ProcessMessage(HWND hWnd, DWORD /*FromAccelerator*/, DWORD MenuI case ID_DEBUGGER_INTERRUPT_PI: g_BaseSystem->ExternalEvent(SysEvent_Interrupt_PI); break; case ID_DEBUGGER_INTERRUPT_DP: g_BaseSystem->ExternalEvent(SysEvent_Interrupt_DP); break; case ID_CURRENT_SAVE_DEFAULT: - g_Notify->DisplayMessageWide(3, GS(MENU_SLOT_SAVE), GetSaveSlotString(MenuID - ID_CURRENT_SAVE_DEFAULT).c_str()); + g_Notify->DisplayMessage(3, stdwstr_f(GS(MENU_SLOT_SAVE), GetSaveSlotString(MenuID - ID_CURRENT_SAVE_DEFAULT).c_str()).c_str()); g_Settings->SaveDword(Game_CurrentSaveState, (DWORD)(MenuID - ID_CURRENT_SAVE_DEFAULT)); break; case ID_CURRENT_SAVE_1: @@ -532,7 +532,7 @@ bool CMainMenu::ProcessMessage(HWND hWnd, DWORD /*FromAccelerator*/, DWORD MenuI case ID_CURRENT_SAVE_8: case ID_CURRENT_SAVE_9: case ID_CURRENT_SAVE_10: - g_Notify->DisplayMessageWide(3, GS(MENU_SLOT_SAVE), GetSaveSlotString((MenuID - ID_CURRENT_SAVE_1) + 1).c_str()); + g_Notify->DisplayMessage(3, stdwstr_f(GS(MENU_SLOT_SAVE), GetSaveSlotString((MenuID - ID_CURRENT_SAVE_1) + 1).c_str()).c_str()); g_Settings->SaveDword(Game_CurrentSaveState, (DWORD)((MenuID - ID_CURRENT_SAVE_1) + 1)); break; case ID_HELP_SUPPORTFORUM: ShellExecute(NULL, "open", "http://forum.pj64-emu.com/", NULL, NULL, SW_SHOWMAXIMIZED); break; diff --git a/Source/Project64/User Interface/Notification Class.cpp b/Source/Project64/User Interface/Notification Class.cpp index bfc28b558..097adf98f 100644 --- a/Source/Project64/User Interface/Notification Class.cpp +++ b/Source/Project64/User Interface/Notification Class.cpp @@ -113,18 +113,6 @@ void CNotification::DisplayMessage(int DisplayTime, const wchar_t * Message) con } } -void CNotification::DisplayMessageWide(int DisplayTime, const wchar_t * Message, ...) const -{ - wchar_t Msg[1000]; - - va_list ap; - va_start(ap, Message); - _vsnwprintf(Msg, sizeof(Msg) - 1, Message, ap); - va_end(ap); - - DisplayMessage(DisplayTime, Msg); -} - void CNotification::DisplayMessage2(const wchar_t * Message) const { if (!m_hWnd) { return; } diff --git a/Source/Project64/User Interface/Notification Class.h b/Source/Project64/User Interface/Notification Class.h index c853371bc..c8b76833b 100644 --- a/Source/Project64/User Interface/Notification Class.h +++ b/Source/Project64/User Interface/Notification Class.h @@ -35,7 +35,6 @@ public: //User Feedback virtual void DisplayMessage(int DisplayTime, const wchar_t * Message) const; virtual void DisplayMessage(int DisplayTime, LanguageStringID StringID) const; - virtual void DisplayMessageWide(int DisplayTime, const wchar_t * Message, ...) const; virtual void DisplayMessage2(const wchar_t * Message) const; virtual void BreakPoint(const wchar_t * FileName, const int LineNumber);