mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-07-11 01:25:07 +02:00
Windows: Show instance counter only with peers.
This commit is contained in:
@@ -105,6 +105,14 @@ static bool UpdateInstanceCounter(void (*callback)(volatile InstanceInfo *)) {
|
||||
#endif
|
||||
}
|
||||
|
||||
int GetInstancePeerCount() {
|
||||
static int c = 0;
|
||||
UpdateInstanceCounter([](volatile InstanceInfo *buf) {
|
||||
c = buf->total;
|
||||
});
|
||||
return c;
|
||||
}
|
||||
|
||||
// Get current number of instance of PPSSPP running.
|
||||
// Must be called only once during init.
|
||||
void InitInstanceCounter() {
|
||||
|
||||
@@ -25,6 +25,7 @@ extern uint8_t PPSSPP_ID;
|
||||
|
||||
void InitInstanceCounter();
|
||||
void ShutdownInstanceCounter();
|
||||
int GetInstancePeerCount();
|
||||
|
||||
inline bool IsFirstInstance() {
|
||||
return PPSSPP_ID == 1;
|
||||
|
||||
+11
-1
@@ -46,6 +46,7 @@
|
||||
#include "Core/Config.h"
|
||||
#include "Core/ConfigValues.h"
|
||||
#include "Core/Debugger/SymbolMap.h"
|
||||
#include "Core/Instance.h"
|
||||
#include "Core/MIPS/JitCommon/JitCommon.h"
|
||||
#include "Core/MIPS/JitCommon/JitBlockCache.h"
|
||||
#include "Windows/InputBox.h"
|
||||
@@ -466,7 +467,11 @@ namespace MainWindow
|
||||
|
||||
void UpdateWindowTitle() {
|
||||
// Seems to be fine to call now since we use a UNICODE build...
|
||||
SetWindowText(hwndMain, windowTitle.c_str());
|
||||
std::wstring title = windowTitle;
|
||||
if (PPSSPP_ID >= 1 && GetInstancePeerCount() > 1) {
|
||||
title.append(ConvertUTF8ToWString(StringFromFormat(" (instance: %d)", (int)PPSSPP_ID)));
|
||||
}
|
||||
SetWindowText(hwndMain, title.c_str());
|
||||
}
|
||||
|
||||
void SetWindowTitle(const wchar_t *title) {
|
||||
@@ -708,6 +713,7 @@ namespace MainWindow
|
||||
|
||||
case WM_ACTIVATE:
|
||||
{
|
||||
UpdateWindowTitle();
|
||||
bool pause = true;
|
||||
if (wParam == WA_ACTIVE || wParam == WA_CLICKACTIVE) {
|
||||
WindowsRawInput::GainFocus();
|
||||
@@ -741,6 +747,10 @@ namespace MainWindow
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_SETFOCUS:
|
||||
UpdateWindowTitle();
|
||||
break;
|
||||
|
||||
case WM_ERASEBKGND:
|
||||
// This window is always covered by DisplayWindow. No reason to erase.
|
||||
return 1;
|
||||
|
||||
@@ -170,9 +170,7 @@ void WindowsHost::SetWindowTitle(const char *message) {
|
||||
#ifdef _DEBUG
|
||||
winTitle.append(L" (debug)");
|
||||
#endif
|
||||
if (PPSSPP_ID >= 1) {
|
||||
winTitle.append(ConvertUTF8ToWString(StringFromFormat(" (instance: %d)", (int)PPSSPP_ID)));
|
||||
}
|
||||
lastTitle_ = winTitle;
|
||||
|
||||
MainWindow::SetWindowTitle(winTitle.c_str());
|
||||
PostMessage(mainWindow_, MainWindow::WM_USER_WINDOW_TITLE_CHANGED, 0, 0);
|
||||
@@ -194,6 +192,12 @@ void WindowsHost::ShutdownSound() {
|
||||
|
||||
void WindowsHost::UpdateUI() {
|
||||
PostMessage(mainWindow_, MainWindow::WM_USER_UPDATE_UI, 0, 0);
|
||||
|
||||
int peers = GetInstancePeerCount();
|
||||
if (PPSSPP_ID >= 1 && peers != lastNumInstances_) {
|
||||
lastNumInstances_ = peers;
|
||||
PostMessage(mainWindow_, MainWindow::WM_USER_WINDOW_TITLE_CHANGED, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void WindowsHost::UpdateMemView() {
|
||||
|
||||
@@ -73,6 +73,8 @@ private:
|
||||
HWND mainWindow_;
|
||||
GraphicsContext *gfx_ = nullptr;
|
||||
size_t numDinputDevices_ = 0;
|
||||
std::wstring lastTitle_;
|
||||
int lastNumInstances_ = 0;
|
||||
|
||||
std::list<std::unique_ptr<InputDevice>> input;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user