mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Post a message when the window title's text needs to change. This resolves #3282.
This commit is contained in:
parent
670d0c35fe
commit
975b8cf7e7
3 changed files with 21 additions and 24 deletions
|
@ -107,32 +107,14 @@ void WindowsHost::ShutdownGL()
|
|||
|
||||
void WindowsHost::SetWindowTitle(const char *message)
|
||||
{
|
||||
std::string title = std::string("PPSSPP ") + PPSSPP_GIT_VERSION;
|
||||
if (message)
|
||||
title = title + " - " + message;
|
||||
|
||||
int size = MultiByteToWideChar(CP_UTF8, 0, title.c_str(), (int) title.size(), NULL, 0);
|
||||
if (size > 0)
|
||||
{
|
||||
// VC++6.0 any more?
|
||||
wchar_t *utf16_title = new(std::nothrow) wchar_t[size + 1];
|
||||
if (utf16_title)
|
||||
size = MultiByteToWideChar(CP_UTF8, 0, title.c_str(), (int) title.size(), utf16_title, size);
|
||||
else
|
||||
size = 0;
|
||||
|
||||
if (size > 0)
|
||||
{
|
||||
utf16_title[size] = 0;
|
||||
// Don't use SetWindowTextW because it will internally use DefWindowProcA.
|
||||
DefWindowProcW(mainWindow_, WM_SETTEXT, 0, (LPARAM) utf16_title);
|
||||
delete[] utf16_title;
|
||||
}
|
||||
std::wstring winTitle = ConvertUTF8ToWString(std::string("PPSSPP ") + PPSSPP_GIT_VERSION);
|
||||
if(message != nullptr) {
|
||||
winTitle.append(ConvertUTF8ToWString(" - "));
|
||||
winTitle.append(ConvertUTF8ToWString(message));
|
||||
}
|
||||
|
||||
// Something went wrong, fall back to using the local codepage.
|
||||
if (size <= 0)
|
||||
SetWindowTextA(mainWindow_, title.c_str());
|
||||
MainWindow::SetWindowTitle(winTitle.c_str());
|
||||
PostMessage(MainWindow::GetHWND(), MainWindow::WM_USER_WINDOW_TITLE_CHANGED, 0, 0);
|
||||
}
|
||||
|
||||
void WindowsHost::InitSound(PMixer *mixer)
|
||||
|
|
|
@ -74,6 +74,7 @@
|
|||
extern std::map<int, int> windowsTransTable;
|
||||
BOOL g_bFullScreen = FALSE;
|
||||
static RECT g_normalRC = {0};
|
||||
static std::wstring windowTitle;
|
||||
extern bool g_TakeScreenshot;
|
||||
extern InputState input_state;
|
||||
|
||||
|
@ -642,6 +643,14 @@ namespace MainWindow
|
|||
g_Config.bEnableCheats = cheats;
|
||||
}
|
||||
|
||||
void UpdateWindowTitle() {
|
||||
DefWindowProcW(hwndMain, WM_SETTEXT, 0, (LPARAM)windowTitle.c_str());
|
||||
}
|
||||
|
||||
void SetWindowTitle(const wchar_t *title) {
|
||||
windowTitle = title;
|
||||
}
|
||||
|
||||
BOOL Show(HINSTANCE hInstance, int nCmdShow) {
|
||||
hInst = hInstance; // Store instance handle in our global variable.
|
||||
|
||||
|
@ -1514,6 +1523,10 @@ namespace MainWindow
|
|||
ResizeDisplay(true);
|
||||
break;
|
||||
|
||||
case WM_USER_WINDOW_TITLE_CHANGED:
|
||||
UpdateWindowTitle();
|
||||
break;
|
||||
|
||||
case WM_MENUSELECT:
|
||||
// Unfortunately, accelerate keys (hotkeys) shares the same enabled/disabled states
|
||||
// with corresponding menu items.
|
||||
|
|
|
@ -12,6 +12,7 @@ namespace MainWindow
|
|||
WM_USER_LOG_STATUS_CHANGED = WM_USER + 101,
|
||||
WM_USER_UPDATE_UI = WM_USER + 102,
|
||||
WM_USER_UPDATE_SCREEN = WM_USER + 103,
|
||||
WM_USER_WINDOW_TITLE_CHANGED = WM_USER + 104,
|
||||
};
|
||||
|
||||
enum {
|
||||
|
@ -41,6 +42,7 @@ namespace MainWindow
|
|||
void Close();
|
||||
void UpdateMenus();
|
||||
void UpdateCommands();
|
||||
void SetWindowTitle(const wchar_t *title);
|
||||
void Update();
|
||||
void Redraw();
|
||||
HWND GetHWND();
|
||||
|
|
Loading…
Add table
Reference in a new issue