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()
{
UMDReplacePermit = false;
DEBUG_LOG(SCEIO,"sceUmdReplaceProhibit()");
host->UpdateUI();
if (UMDReplacePermit) {
UMDReplacePermit = false;
host->NotifySwitchUMDUpdated();
}
return 0;
}
static u32 sceUmdReplacePermit()
{
UMDReplacePermit = true;
DEBUG_LOG(SCEIO,"sceUmdReplacePermit()");
host->UpdateUI();
if (!UMDReplacePermit) {
UMDReplacePermit = true;
host->NotifySwitchUMDUpdated();
}
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 SendUIMessage(const std::string &message, const std::string &value) {}
virtual void NotifySwitchUMDUpdated() {}
// Used for headless.
virtual bool ShouldSkipUI() { return false; }
virtual void SendDebugOutput(const std::string &output) {}

View File

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

View File

@ -53,4 +53,6 @@ public:
void SendUIMessage(const std::string &message, const std::string &value) override {
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 NotifySwitchUMDUpdated() override {}
GraphicsContext *GetGraphicsContext() { return nullptr; }
private:

View File

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

View File

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

View File

@ -1379,6 +1379,13 @@ namespace MainWindow {
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.
LRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) {
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) {
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 SendUIMessage(const std::string &message, const std::string &value) override;
void NotifySwitchUMDUpdated() override;
GraphicsContext *GetGraphicsContext() { return gfx_; }
private:

View File

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