Move three notifications out of Host

This commit is contained in:
Henrik Rydgård 2023-03-21 11:21:19 +01:00
parent 06fcc9ccd7
commit dda8635c89
21 changed files with 51 additions and 95 deletions

View file

@ -308,8 +308,8 @@ void Core_ProcessStepping() {
static int lastSteppingCounter = -1;
if (lastSteppingCounter != steppingCounter) {
CBreakPoints::ClearTemporaryBreakPoints();
host->UpdateDisassembly();
host->UpdateMemView();
System_Notify(SystemNotification::DISASSEMBLY);
System_Notify(SystemNotification::MEM_VIEW);
lastSteppingCounter = steppingCounter;
}
@ -320,15 +320,15 @@ void Core_ProcessStepping() {
if (doStep && coreState == CORE_STEPPING) {
Core_SingleStep();
// Update disasm dialog.
host->UpdateDisassembly();
host->UpdateMemView();
System_Notify(SystemNotification::DISASSEMBLY);
System_Notify(SystemNotification::MEM_VIEW);
}
}
// Many platforms, like Android, do not call this function but handle things on their own.
// Instead they simply call NativeRender and NativeUpdate directly.
bool Core_Run(GraphicsContext *ctx) {
host->UpdateDisassembly();
System_Notify(SystemNotification::DISASSEMBLY);
while (true) {
if (GetUIState() != UISTATE_INGAME) {
Core_StateProcessed();

View file

@ -19,6 +19,7 @@
#include <atomic>
#include <mutex>
#include "Common/System/System.h"
#include "Common/Log.h"
#include "Core/Core.h"
#include "Core/Debugger/Breakpoints.h"
@ -674,7 +675,7 @@ void CBreakPoints::Update(u32 addr) {
}
// Redraw in order to show the breakpoint.
host->UpdateDisassembly();
System_Notify(SystemNotification::DISASSEMBLY);
}
bool CBreakPoints::ValidateLogFormat(DebugInterface *cpu, const std::string &fmt) {

View file

@ -55,8 +55,9 @@ void WebSocketGameReset(DebuggerRequest &req) {
ERROR_LOG(BOOT, "Error resetting: %s", resetError.c_str());
return req.Fail("Could not reset");
}
System_Notify(SystemNotification::BOOT_DONE);
host->UpdateDisassembly();
System_Notify(SystemNotification::DISASSEMBLY);
req.Respond();
}

View file

@ -17,6 +17,7 @@
#include <vector>
#include "Common/System/System.h"
#include "Common/Serialize/Serializer.h"
#include "Common/Serialize/SerializeFuncs.h"
#include "Common/Serialize/SerializeMap.h"
@ -104,8 +105,9 @@ void __UmdDoState(PointerWrap &p)
if (s > 1) {
Do(p, UMDReplacePermit);
if (UMDReplacePermit)
host->UpdateUI();
if (UMDReplacePermit) {
System_Notify(SystemNotification::UI);
}
}
if (s > 2) {
Do(p, umdInsertChangeEvent);

View file

@ -27,9 +27,6 @@ class Host {
public:
virtual ~Host() {}
virtual void UpdateUI() {}
virtual void UpdateMemView() {}
virtual void UpdateDisassembly() {}
virtual void NotifySymbolMapUpdated() {}
virtual void SetDebugMode(bool mode) { }
virtual void NotifySwitchUMDUpdated() {}

View file

@ -1080,7 +1080,7 @@ namespace SaveState
return;
}
System_Notify(SystemNotification::BOOT_DONE);
host->UpdateDisassembly();
System_Notify(SystemNotification::DISASSEMBLY);
needsRestart = false;
}
}

View file

@ -124,8 +124,7 @@ void UpdateUIState(GlobalUIState newState) {
// Never leave the EXIT state.
if (globalUIState != newState && globalUIState != UISTATE_EXIT) {
globalUIState = newState;
if (host)
host->UpdateDisassembly();
System_Notify(SystemNotification::DISASSEMBLY);
const char *state = nullptr;
switch (globalUIState) {
case UISTATE_EXIT: state = "exit"; break;

View file

@ -30,16 +30,6 @@ public:
mainWindow = mainWindow_;
}
void UpdateUI() override {
mainWindow->updateMenus();
}
void UpdateMemView() override {
}
void UpdateDisassembly() override {
mainWindow->updateMenus();
}
void SetDebugMode(bool mode) override {}
bool InitGraphics(std::string *error_message, GraphicsContext **ctx) override { return true; }

View file

@ -355,8 +355,7 @@ void EmuScreen::bootGame(const Path &filename) {
void EmuScreen::bootComplete() {
UpdateUIState(UISTATE_INGAME);
System_Notify(SystemNotification::BOOT_DONE);
host->UpdateDisassembly();
System_Notify(SystemNotification::DISASSEMBLY);
NOTICE_LOG(BOOT, "Loading %s...", PSP_CoreParameter().fileToStart.c_str());
autoLoad();
@ -448,7 +447,7 @@ static void AfterSaveStateAction(SaveState::Status status, const std::string &me
static void AfterStateBoot(SaveState::Status status, const std::string &message, void *ignored) {
AfterSaveStateAction(status, message, ignored);
Core_EnableStepping(false);
host->UpdateDisassembly();
System_Notify(SystemNotification::DISASSEMBLY);
}
void EmuScreen::sendMessage(const char *message, const char *value) {
@ -461,12 +460,12 @@ void EmuScreen::sendMessage(const char *message, const char *value) {
bootPending_ = false;
stopRender_ = true;
invalid_ = true;
host->UpdateDisassembly();
System_Notify(SystemNotification::DISASSEMBLY);
} else if (!strcmp(message, "reset")) {
PSP_Shutdown();
bootPending_ = true;
invalid_ = true;
host->UpdateDisassembly();
System_Notify(SystemNotification::DISASSEMBLY);
std::string resetError;
if (!PSP_InitStart(PSP_CoreParameter(), &resetError)) {

View file

@ -913,8 +913,7 @@ void GameSettingsScreen::CreateSystemSettings(UI::ViewGroup *systemSettings) {
auto langScreen = new NewLanguageScreen(sy->T("Language"));
langScreen->OnChoice.Add([&](UI::EventParams &e) {
screenManager()->RecreateAllViews();
if (host)
host->UpdateUI();
System_Notify(SystemNotification::UI);
return UI::EVENT_DONE;
});
if (e.v)
@ -1362,7 +1361,7 @@ void GameSettingsScreen::onFinish(DialogResult result) {
g_Config.unloadGameConfig();
}
host->UpdateUI();
System_Notify(SystemNotification::UI);
KeyMap::UpdateNativeMenuKeys();
@ -1895,7 +1894,7 @@ void GameSettingsScreen::CallbackRestoreDefaults(bool yes) {
if (yes) {
g_Config.RestoreDefaults(RestoreSettingsBits::SETTINGS);
}
host->UpdateUI();
System_Notify(SystemNotification::UI);
}
UI::EventReturn GameSettingsScreen::OnRestoreDefaultSettings(UI::EventParams &e) {

View file

@ -24,11 +24,6 @@ class NativeHost : public Host {
public:
NativeHost() {}
void UpdateUI() override {}
void UpdateMemView() override {}
void UpdateDisassembly() override {}
void SetDebugMode(bool mode) override { }
bool InitGraphics(std::string *error_message, GraphicsContext **ctx) override { return true; }

View file

@ -964,9 +964,7 @@ UI::EventReturn GameBrowser::GridSettingsClick(UI::EventParams &e) {
UI::EventReturn GameBrowser::OnRecentClear(UI::EventParams &e) {
screenManager_->RecreateAllViews();
if (host) {
host->UpdateUI();
}
System_Notify(SystemNotification::UI);
return UI::EVENT_DONE;
}

View file

@ -431,9 +431,7 @@ void HandleCommonMessages(const char *message, const char *value, ScreenManager
auto langScreen = new NewLanguageScreen(sy->T("Language"));
langScreen->OnChoice.Add([](UI::EventParams &) {
NativeMessageReceived("recreateviews", "");
if (host) {
host->UpdateUI();
}
System_Notify(SystemNotification::UI);
return UI::EVENT_DONE;
});
manager->push(langScreen);

View file

@ -438,13 +438,6 @@ bool System_GetPropertyBool(SystemProperty prop) {
void System_Notify(SystemNotification notification) {
switch (notification) {
case SystemNotification::BOOT_DONE:
g_symbolMap->SortSymbols();
SetDebugMode(false);
Core_EnableStepping(false);
break;
default:
break;
}

View file

@ -64,7 +64,6 @@ void UWPHost::ShutdownGraphics() {
}
void UWPHost::SetWindowTitle(const char *message) {
// Should really be done differently
}
void UWPHost::InitSound() {
@ -76,15 +75,6 @@ void UWPHost::UpdateSound() {
void UWPHost::ShutdownSound() {
}
void UWPHost::UpdateUI() {
}
void UWPHost::UpdateMemView() {
}
void UWPHost::UpdateDisassembly() {
}
void UWPHost::SetDebugMode(bool mode) {}
void UWPHost::PollControllers() {

View file

@ -12,9 +12,6 @@ public:
UWPHost();
~UWPHost();
void UpdateMemView() override;
void UpdateDisassembly() override;
void UpdateUI() override;
void SetDebugMode(bool mode) override;
// If returns false, will return a null context

View file

@ -161,7 +161,7 @@ void MainThreadFunc() {
// Let's continue (and probably crash) just so they have a way to keep trying.
}
host->UpdateUI();
System_Notify(SystemNotification::UI);
std::string error_string;
bool success = host->InitGraphics(&error_string, &g_graphicsContext);

View file

@ -189,26 +189,6 @@ void WindowsHost::UpdateSound() {
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() {
if (memoryWindow)
PostDialogMessage(memoryWindow, WM_DEB_UPDATE);
}
void WindowsHost::UpdateDisassembly() {
if (disasmWindow)
PostDialogMessage(disasmWindow, WM_DEB_UPDATE);
}
void WindowsHost::SetDebugMode(bool mode) {
if (disasmWindow)
PostDialogMessage(disasmWindow, WM_DEB_SETDEBUGLPARAM, 0, (LPARAM)mode);

View file

@ -34,9 +34,6 @@ public:
UpdateConsolePosition();
}
void UpdateMemView() override;
void UpdateDisassembly() override;
void UpdateUI() override;
void SetDebugMode(bool mode) override;
// If returns false, will return a null context
@ -74,7 +71,6 @@ private:
GraphicsContext *gfx_ = nullptr;
size_t numDinputDevices_ = 0;
std::wstring lastTitle_;
int lastNumInstances_ = 0;
std::list<std::unique_ptr<InputDevice>> input;
};

View file

@ -47,6 +47,7 @@
#include "Core/Config.h"
#include "Core/ConfigValues.h"
#include "Core/SaveState.h"
#include "Core/Instance.h"
#include "Windows/EmuThread.h"
#include "Windows/WindowsAudio.h"
#include "ext/disarm.h"
@ -110,6 +111,7 @@ int g_activeWindow = 0;
static std::thread inputBoxThread;
static bool inputBoxRunning = false;
int g_lastNumInstances = 0;
void System_ShowFileInFolder(const char *path) {
// SHParseDisplayName can't handle relative paths, so normalize first.
@ -377,6 +379,7 @@ static BOOL PostDialogMessage(Dialog *dialog, UINT message, WPARAM wParam = 0, L
void System_Notify(SystemNotification notification) {
switch (notification) {
case SystemNotification::BOOT_DONE:
{
if (g_symbolMap)
g_symbolMap->SortSymbols();
PostMessage(MainWindow::GetHWND(), WM_USER + 1, 0, 0);
@ -386,6 +389,29 @@ void System_Notify(SystemNotification notification) {
PostDialogMessage(disasmWindow, WM_DEB_SETDEBUGLPARAM, 0, (LPARAM)mode);
break;
}
case SystemNotification::UI:
{
PostMessage(MainWindow::GetHWND(), MainWindow::WM_USER_UPDATE_UI, 0, 0);
int peers = GetInstancePeerCount();
if (PPSSPP_ID >= 1 && peers != g_lastNumInstances) {
g_lastNumInstances = peers;
PostMessage(MainWindow::GetHWND(), MainWindow::WM_USER_WINDOW_TITLE_CHANGED, 0, 0);
}
break;
}
case SystemNotification::MEM_VIEW:
if (memoryWindow)
PostDialogMessage(memoryWindow, WM_DEB_UPDATE);
break;
case SystemNotification::DISASSEMBLY:
if (disasmWindow)
PostDialogMessage(disasmWindow, WM_DEB_UPDATE);
break;
}
}
void System_SendMessage(const char *command, const char *parameter) {

View file

@ -26,11 +26,6 @@
// TODO: Get rid of this junk
class HeadlessHost : public Host {
public:
void UpdateUI() override {}
void UpdateMemView() override {}
void UpdateDisassembly() override {}
void SetDebugMode(bool mode) override { }
void SetGraphicsCore(GPUCore core) { gpuCore_ = core; }