SwicthUMD:Only update Switch UMD item of Windows menu instead of entire UI.

This commit is contained in:
shenweip 2020-10-22 17:14:35 +08:00
parent 0f647684a3
commit a0fe0e38c1
11 changed files with 37 additions and 4 deletions

View file

@ -515,17 +515,21 @@ bool getUMDReplacePermit() {
static u32 sceUmdReplaceProhibit() static u32 sceUmdReplaceProhibit()
{ {
UMDReplacePermit = false;
DEBUG_LOG(SCEIO,"sceUmdReplaceProhibit()"); DEBUG_LOG(SCEIO,"sceUmdReplaceProhibit()");
host->UpdateUI(); if (UMDReplacePermit) {
UMDReplacePermit = false;
host->NotifySwitchUMDUpdated();
}
return 0; return 0;
} }
static u32 sceUmdReplacePermit() static u32 sceUmdReplacePermit()
{ {
UMDReplacePermit = true;
DEBUG_LOG(SCEIO,"sceUmdReplacePermit()"); DEBUG_LOG(SCEIO,"sceUmdReplacePermit()");
host->UpdateUI(); if (!UMDReplacePermit) {
UMDReplacePermit = true;
host->NotifySwitchUMDUpdated();
}
return 0; return 0;
} }

View file

@ -57,6 +57,8 @@ public:
virtual void NotifyUserMessage(const std::string &message, float duration = 1.0f, u32 color = 0x00FFFFFF, const char *id = nullptr) {} virtual void NotifyUserMessage(const std::string &message, float duration = 1.0f, u32 color = 0x00FFFFFF, const char *id = nullptr) {}
virtual void SendUIMessage(const std::string &message, const std::string &value) {} virtual void SendUIMessage(const std::string &message, const std::string &value) {}
virtual void NotifySwitchUMDUpdated() {}
// Used for headless. // Used for headless.
virtual bool ShouldSkipUI() { return false; } virtual bool ShouldSkipUI() { return false; }
virtual void SendDebugOutput(const std::string &output) {} virtual void SendDebugOutput(const std::string &output) {}

View file

@ -92,6 +92,8 @@ public:
NativeMessageReceived(message.c_str(), value.c_str()); NativeMessageReceived(message.c_str(), value.c_str());
} }
void NotifySwitchUMDUpdated() override {}
private: private:
std::string SymbolMapFilename(std::string currentFilename); std::string SymbolMapFilename(std::string currentFilename);
MainWindow* mainWindow; MainWindow* mainWindow;

View file

@ -53,4 +53,6 @@ public:
void SendUIMessage(const std::string &message, const std::string &value) override { void SendUIMessage(const std::string &message, const std::string &value) override {
NativeMessageReceived(message.c_str(), value.c_str()); NativeMessageReceived(message.c_str(), value.c_str());
} }
void NotifySwitchUMDUpdated() override {}
}; };

View file

@ -40,6 +40,8 @@ public:
void NotifyUserMessage(const std::string &message, float duration = 1.0f, u32 color = 0x00FFFFFF, const char *id = nullptr) override; void NotifyUserMessage(const std::string &message, float duration = 1.0f, u32 color = 0x00FFFFFF, const char *id = nullptr) override;
void NotifySwitchUMDUpdated() override {}
GraphicsContext *GetGraphicsContext() { return nullptr; } GraphicsContext *GetGraphicsContext() { return nullptr; }
private: private:

View file

@ -970,6 +970,10 @@ namespace MainWindow
InputDevice::BeginPolling(); InputDevice::BeginPolling();
break; break;
case WM_USER_SWITCHUMD_UPDATED:
UpdateSwitchUMD();
break;
case WM_MENUSELECT: case WM_MENUSELECT:
// Called when a menu is opened. Also when an item is selected, but meh. // Called when a menu is opened. Also when an item is selected, but meh.
UpdateMenus(true); UpdateMenus(true);

View file

@ -21,6 +21,7 @@ namespace MainWindow
WM_USER_BROWSE_BOOT_DONE = WM_USER + 104, WM_USER_BROWSE_BOOT_DONE = WM_USER + 104,
WM_USER_TOGGLE_FULLSCREEN = WM_USER + 105, WM_USER_TOGGLE_FULLSCREEN = WM_USER + 105,
WM_USER_RESTART_EMUTHREAD = WM_USER + 106, WM_USER_RESTART_EMUTHREAD = WM_USER + 106,
WM_USER_SWITCHUMD_UPDATED = WM_USER + 107
}; };
enum { enum {
@ -66,6 +67,7 @@ namespace MainWindow
void Close(); void Close();
void UpdateMenus(bool isMenuSelect = false); void UpdateMenus(bool isMenuSelect = false);
void UpdateCommands(); void UpdateCommands();
void UpdateSwitchUMD();
void SetWindowTitle(const wchar_t *title); void SetWindowTitle(const wchar_t *title);
void Redraw(); void Redraw();
HWND GetHWND(); HWND GetHWND();

View file

@ -1379,6 +1379,13 @@ namespace MainWindow {
TranslateMenuItem(menu, ID_TOGGLE_BREAK, L"\tF8", isPaused ? "Run" : "Break"); TranslateMenuItem(menu, ID_TOGGLE_BREAK, L"\tF8", isPaused ? "Run" : "Break");
} }
void UpdateSwitchUMD() {
HMENU menu = GetMenu(GetHWND());
GlobalUIState state = GetUIState();
UINT umdSwitchEnable = state == UISTATE_INGAME && getUMDReplacePermit() ? MF_ENABLED : MF_GRAYED;
EnableMenuItem(menu, ID_EMULATION_SWITCH_UMD, umdSwitchEnable);
}
// Message handler for about box. // Message handler for about box.
LRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { LRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) {
switch (message) { switch (message) {

View file

@ -407,3 +407,7 @@ void WindowsHost::NotifyUserMessage(const std::string &message, float duration,
void WindowsHost::SendUIMessage(const std::string &message, const std::string &value) { void WindowsHost::SendUIMessage(const std::string &message, const std::string &value) {
NativeMessageReceived(message.c_str(), value.c_str()); NativeMessageReceived(message.c_str(), value.c_str());
} }
void WindowsHost::NotifySwitchUMDUpdated() {
PostMessage(mainWindow_, MainWindow::WM_USER_SWITCHUMD_UPDATED, 0, 0);
}

View file

@ -63,6 +63,8 @@ public:
void NotifyUserMessage(const std::string &message, float duration = 1.0f, u32 color = 0x00FFFFFF, const char *id = nullptr) override; void NotifyUserMessage(const std::string &message, float duration = 1.0f, u32 color = 0x00FFFFFF, const char *id = nullptr) override;
void SendUIMessage(const std::string &message, const std::string &value) override; void SendUIMessage(const std::string &message, const std::string &value) override;
void NotifySwitchUMDUpdated() override;
GraphicsContext *GetGraphicsContext() { return gfx_; } GraphicsContext *GetGraphicsContext() { return gfx_; }
private: private:

View file

@ -72,6 +72,8 @@ public:
void SendDebugScreenshot(const u8 *pixbuf, u32 w, u32 h) override; void SendDebugScreenshot(const u8 *pixbuf, u32 w, u32 h) override;
void NotifySwitchUMDUpdated() override {}
// Unique for HeadlessHost // Unique for HeadlessHost
virtual void SwapBuffers() {} virtual void SwapBuffers() {}