diff --git a/.github/workflows/generate_pot.yml b/.github/workflows/generate_pot.yml index b057d441..bd42de46 100644 --- a/.github/workflows/generate_pot.yml +++ b/.github/workflows/generate_pot.yml @@ -31,6 +31,7 @@ jobs: find src -name *.cpp -o -name *.hpp -o -name *.h | xargs xgettext --from-code=utf-8 -w 100 --keyword="_" --keyword="wxTRANSLATE" --keyword="wxPLURAL:1,2" + --keyword="_tr" --keyword="TR_NOOP" --check=space-ellipsis --omit-header -o cemu.pot diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 04b6dfdd..a5ab2154 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -150,7 +150,3 @@ if(UNIX AND NOT APPLE) # most likely not helpful in debugging problems with cemu code target_link_options(CemuBin PRIVATE "$<$:-Xlinker;--strip-debug>") endif() - -if (ENABLE_WXWIDGETS) - target_link_libraries(CemuBin PRIVATE wx::base wx::core) -endif() diff --git a/src/Cafe/CMakeLists.txt b/src/Cafe/CMakeLists.txt index 2900059b..1b0def84 100644 --- a/src/Cafe/CMakeLists.txt +++ b/src/Cafe/CMakeLists.txt @@ -597,10 +597,6 @@ else () target_link_libraries(CemuCafe PRIVATE libusb::libusb) endif () -if (ENABLE_WXWIDGETS) - target_link_libraries(CemuCafe PRIVATE wx::base wx::core) -endif() - if(WIN32) target_link_libraries(CemuCafe PRIVATE iphlpapi) endif() diff --git a/src/Cafe/CafeSystem.cpp b/src/Cafe/CafeSystem.cpp index d20ccd9d..0a145a94 100644 --- a/src/Cafe/CafeSystem.cpp +++ b/src/Cafe/CafeSystem.cpp @@ -1,5 +1,5 @@ #include "Cafe/OS/common/OSCommon.h" -#include "gui/wxgui.h" +#include "WindowSystem.h" #include "Cafe/OS/libs/gx2/GX2.h" #include "Cafe/GameProfile/GameProfile.h" #include "Cafe/HW/Espresso/Interpreter/PPCInterpreterInternal.h" @@ -65,9 +65,6 @@ // HW interfaces #include "Cafe/HW/SI/si.h" -// dependency to be removed -#include "gui/guiWrapper.h" - #include #if BOOST_OS_LINUX @@ -172,7 +169,7 @@ void LoadMainExecutable() applicationRPX = RPLLoader_LoadFromMemory(rpxData, rpxSize, (char*)_pathToExecutable.c_str()); if (!applicationRPX) { - wxMessageBox(_("Failed to run this title because the executable is damaged")); + WindowSystem::ShowErrorDialog(_tr("Failed to run this title because the executable is damaged")); cemuLog_createLogFile(false); cemuLog_waitForFlush(); exit(0); @@ -357,7 +354,7 @@ uint32 LoadSharedData() void cemu_initForGame() { - gui_updateWindowTitles(false, true, 0.0); + WindowSystem::UpdateWindowTitles(false, true, 0.0); // input manager apply game profile InputManager::instance().apply_game_profile(); // log info for launched title @@ -855,7 +852,7 @@ namespace CafeSystem PPCTimer_waitForInit(); // start system sSystemRunning = true; - gui_notifyGameLoaded(); + WindowSystem::NotifyGameLoaded(); std::thread t(_LaunchTitleThread); t.detach(); } diff --git a/src/Cafe/Filesystem/FST/KeyCache.cpp b/src/Cafe/Filesystem/FST/KeyCache.cpp index 29903e84..f85d2b54 100644 --- a/src/Cafe/Filesystem/FST/KeyCache.cpp +++ b/src/Cafe/Filesystem/FST/KeyCache.cpp @@ -1,7 +1,7 @@ -#include #include -#include +#include "Cemu/Logging/CemuLogging.h" +#include "WindowSystem.h" #include "config/ActiveSettings.h" #include "util/crypto/aes128.h" #include "Common/FileStream.h" @@ -75,7 +75,7 @@ void KeyCache_Prepare() } else { - wxMessageBox(_("Unable to create file keys.txt\nThis can happen if Cemu does not have write permission to its own directory, the disk is full or if anti-virus software is blocking Cemu."), _("Error"), wxOK | wxCENTRE | wxICON_ERROR); + WindowSystem::ShowErrorDialog(_tr("Unable to create file keys.txt\nThis can happen if Cemu does not have write permission to its own directory, the disk is full or if anti-virus software is blocking Cemu."), _tr("Error"), WindowSystem::ErrorCategory::KEYS_TXT_CREATION); } mtxKeyCache.unlock(); return; @@ -108,8 +108,8 @@ void KeyCache_Prepare() continue; if( strishex(line) == false ) { - auto errorMsg = formatWxString(_("Error in keys.txt at line {}"), lineNumber); - wxMessageBox(errorMsg, _("Error"), wxOK | wxCENTRE | wxICON_ERROR); + auto errorMsg = _tr("Error in keys.txt at line {}", lineNumber); + WindowSystem::ShowErrorDialog(errorMsg, WindowSystem::ErrorCategory::KEYS_TXT_CREATION); continue; } if(line.size() == 32 ) diff --git a/src/Cafe/GraphicPack/GraphicPack2.cpp b/src/Cafe/GraphicPack/GraphicPack2.cpp index 6ae05c5b..ab4dbd3a 100644 --- a/src/Cafe/GraphicPack/GraphicPack2.cpp +++ b/src/Cafe/GraphicPack/GraphicPack2.cpp @@ -85,7 +85,7 @@ bool GraphicPack2::LoadGraphicPack(const fs::path& rulesPath, IniParser& rules) auto gp = std::make_shared(rulesPath, rules); // check if enabled and preset set - const auto& config_entries = g_config.data().graphic_pack_entries; + const auto& config_entries = GetConfigHandle().data().graphic_pack_entries; // legacy absolute path checking for not breaking compatibility auto file = gp->GetRulesPath(); diff --git a/src/Cafe/GraphicPack/GraphicPack2Patches.cpp b/src/Cafe/GraphicPack/GraphicPack2Patches.cpp index 2c067484..d0d00bf2 100644 --- a/src/Cafe/GraphicPack/GraphicPack2Patches.cpp +++ b/src/Cafe/GraphicPack/GraphicPack2Patches.cpp @@ -1,13 +1,12 @@ #include "Cafe/GraphicPack/GraphicPack2.h" +#include "Cemu/Logging/CemuLogging.h" #include "Common/FileStream.h" +#include "WindowSystem.h" #include "util/helpers/StringParser.h" #include "Cemu/PPCAssembler/ppcAssembler.h" #include "Cafe/OS/RPL/rpl_structs.h" #include "boost/algorithm/string.hpp" -#include "gui/wxgui.h" // for wxMessageBox -#include "gui/helpers/wxHelpers.h" - // error handler void PatchErrorHandler::printError(class PatchGroup* patchGroup, sint32 lineNumber, std::string_view errorMsg) { @@ -40,13 +39,13 @@ void PatchErrorHandler::printError(class PatchGroup* patchGroup, sint32 lineNumb void PatchErrorHandler::showStageErrorMessageBox() { - wxString errorMsg; + std::string errorMsg; if (m_gp) { if (m_stage == STAGE::PARSER) - errorMsg.assign(formatWxString(_("Failed to load patches for graphic pack \'{}\'"), m_gp->GetName())); + errorMsg.assign(_tr("Failed to load patches for graphic pack \'{}\'", m_gp->GetName())); else - errorMsg.assign(formatWxString(_("Failed to apply patches for graphic pack \'{}\'"), m_gp->GetName())); + errorMsg.assign(_tr("Failed to apply patches for graphic pack \'{}\'", m_gp->GetName())); } else { @@ -55,7 +54,7 @@ void PatchErrorHandler::showStageErrorMessageBox() if (cemuLog_isLoggingEnabled(LogType::Patches)) { errorMsg.append("\n \n") - .append(_("Details:")) + .append(_tr("Details:")) .append("\n"); for (auto& itr : errorMessages) { @@ -64,7 +63,7 @@ void PatchErrorHandler::showStageErrorMessageBox() } } - wxMessageBox(errorMsg, _("Graphic pack error")); + WindowSystem::ShowErrorDialog(errorMsg, _tr("Graphic pack error"), WindowSystem::ErrorCategory::GRAPHIC_PACKS); } // loads Cemu-style patches (patch_.asm) diff --git a/src/Cafe/HW/Espresso/Debugger/Debugger.cpp b/src/Cafe/HW/Espresso/Debugger/Debugger.cpp index e84c9fda..fbfc94fe 100644 --- a/src/Cafe/HW/Espresso/Debugger/Debugger.cpp +++ b/src/Cafe/HW/Espresso/Debugger/Debugger.cpp @@ -1,19 +1,20 @@ -#include "gui/guiWrapper.h" +#include "Common/precompiled.h" #include "Debugger.h" #include "Cafe/OS/RPL/rpl_structs.h" #include "Cemu/PPCAssembler/ppcAssembler.h" #include "Cafe/HW/Espresso/Recompiler/PPCRecompiler.h" #include "Cemu/ExpressionParser/ExpressionParser.h" -#include "gui/debugger/DebuggerWindow2.h" - #include "Cafe/OS/libs/coreinit/coreinit.h" +#include "OS/RPL/rpl.h" #include "util/helpers/helpers.h" #if BOOST_OS_WINDOWS #include #endif +DebuggerDispatcher g_debuggerDispatcher; + debuggerState_t debuggerState{ }; DebuggerBreakpoint* debugger_getFirstBP(uint32 address) @@ -337,7 +338,7 @@ void debugger_toggleBreakpoint(uint32 address, bool state, DebuggerBreakpoint* b { bp->enabled = state; debugger_updateExecutionBreakpoint(address); - debuggerWindow_updateViewThreadsafe2(); + g_debuggerDispatcher.UpdateViewThreadsafe(); } else if (bpItr->isMemBP()) { @@ -359,7 +360,7 @@ void debugger_toggleBreakpoint(uint32 address, bool state, DebuggerBreakpoint* b debugger_updateMemoryBreakpoint(bpItr); else debugger_updateMemoryBreakpoint(nullptr); - debuggerWindow_updateViewThreadsafe2(); + g_debuggerDispatcher.UpdateViewThreadsafe(); } return; } @@ -496,7 +497,7 @@ void debugger_stepInto(PPCInterpreter_t* hCPU, bool updateDebuggerWindow = true) debugger_updateExecutionBreakpoint(initialIP); debuggerState.debugSession.instructionPointer = hCPU->instructionPointer; if(updateDebuggerWindow) - debuggerWindow_moveIP(); + g_debuggerDispatcher.MoveIP(); ppcRecompilerEnabled = isRecEnabled; } @@ -515,7 +516,7 @@ bool debugger_stepOver(PPCInterpreter_t* hCPU) // nothing to skip, use step-into debugger_stepInto(hCPU); debugger_updateExecutionBreakpoint(initialIP); - debuggerWindow_moveIP(); + g_debuggerDispatcher.MoveIP(); ppcRecompilerEnabled = isRecEnabled; return false; } @@ -523,7 +524,7 @@ bool debugger_stepOver(PPCInterpreter_t* hCPU) debugger_createCodeBreakpoint(initialIP + 4, DEBUGGER_BP_T_ONE_SHOT); // step over current instruction (to avoid breakpoint) debugger_stepInto(hCPU); - debuggerWindow_moveIP(); + g_debuggerDispatcher.MoveIP(); // restore breakpoints debugger_updateExecutionBreakpoint(initialIP); // run @@ -621,8 +622,8 @@ void debugger_enterTW(PPCInterpreter_t* hCPU) DebuggerBreakpoint* singleshotBP = debugger_getFirstBP(debuggerState.debugSession.instructionPointer, DEBUGGER_BP_T_ONE_SHOT); if (singleshotBP) debugger_deleteBreakpoint(singleshotBP); - debuggerWindow_notifyDebugBreakpointHit2(); - debuggerWindow_updateViewThreadsafe2(); + g_debuggerDispatcher.NotifyDebugBreakpointHit(); + g_debuggerDispatcher.UpdateViewThreadsafe(); // reset step control debuggerState.debugSession.stepInto = false; debuggerState.debugSession.stepOver = false; @@ -639,14 +640,14 @@ void debugger_enterTW(PPCInterpreter_t* hCPU) break; // if true is returned, continue with execution } debugger_createPPCStateSnapshot(hCPU); - debuggerWindow_updateViewThreadsafe2(); + g_debuggerDispatcher.UpdateViewThreadsafe(); debuggerState.debugSession.stepOver = false; } if (debuggerState.debugSession.stepInto) { debugger_stepInto(hCPU); debugger_createPPCStateSnapshot(hCPU); - debuggerWindow_updateViewThreadsafe2(); + g_debuggerDispatcher.UpdateViewThreadsafe(); debuggerState.debugSession.stepInto = false; continue; } @@ -663,8 +664,8 @@ void debugger_enterTW(PPCInterpreter_t* hCPU) debuggerState.debugSession.isTrapped = false; debuggerState.debugSession.hCPU = nullptr; - debuggerWindow_updateViewThreadsafe2(); - debuggerWindow_notifyRun(); + g_debuggerDispatcher.UpdateViewThreadsafe(); + g_debuggerDispatcher.NotifyRun(); } void debugger_shouldBreak(PPCInterpreter_t* hCPU) diff --git a/src/Cafe/HW/Espresso/Debugger/Debugger.h b/src/Cafe/HW/Espresso/Debugger/Debugger.h index c220eb8a..d385cadd 100644 --- a/src/Cafe/HW/Espresso/Debugger/Debugger.h +++ b/src/Cafe/HW/Espresso/Debugger/Debugger.h @@ -15,6 +15,69 @@ #define DEBUGGER_BP_T_GDBSTUB_TW 0x7C010008 #define DEBUGGER_BP_T_DEBUGGER_TW 0x7C020008 +class DebuggerCallbacks +{ + public: + virtual void UpdateViewThreadsafe() {} + virtual void NotifyDebugBreakpointHit() {} + virtual void NotifyRun() {} + virtual void MoveIP() {} + virtual void NotifyModuleLoaded(void* module) {} + virtual void NotifyModuleUnloaded(void* module) {} + virtual ~DebuggerCallbacks() = default; +}; + +class DebuggerDispatcher +{ + private: + static inline class DefaultDebuggerCallbacks : public DebuggerCallbacks + { + } s_defaultDebuggerCallbacks; + DebuggerCallbacks* m_callbacks = &s_defaultDebuggerCallbacks; + + public: + void SetDebuggerCallbacks(DebuggerCallbacks* debuggerCallbacks) + { + cemu_assert_debug(m_callbacks == &s_defaultDebuggerCallbacks); + m_callbacks = debuggerCallbacks; + } + + void ClearDebuggerCallbacks() + { + cemu_assert_debug(m_callbacks != &s_defaultDebuggerCallbacks); + m_callbacks = &s_defaultDebuggerCallbacks; + } + + void UpdateViewThreadsafe() + { + m_callbacks->UpdateViewThreadsafe(); + } + + void NotifyDebugBreakpointHit() + { + m_callbacks->NotifyDebugBreakpointHit(); + } + + void NotifyRun() + { + m_callbacks->NotifyRun(); + } + + void MoveIP() + { + m_callbacks->MoveIP(); + } + + void NotifyModuleLoaded(void* module) + { + m_callbacks->NotifyModuleLoaded(module); + } + + void NotifyModuleUnloaded(void* module) + { + m_callbacks->NotifyModuleUnloaded(module); + } +} extern g_debuggerDispatcher; struct DebuggerBreakpoint { diff --git a/src/Cafe/HW/Latte/Core/LatteOverlay.cpp b/src/Cafe/HW/Latte/Core/LatteOverlay.cpp index e6edb904..7499d743 100644 --- a/src/Cafe/HW/Latte/Core/LatteOverlay.cpp +++ b/src/Cafe/HW/Latte/Core/LatteOverlay.cpp @@ -1,6 +1,6 @@ #include "Cafe/HW/Latte/Core/LatteOverlay.h" #include "Cafe/HW/Latte/Core/LattePerformanceMonitor.h" -#include "gui/guiWrapper.h" +#include "WindowSystem.h" #include "config/CemuConfig.h" @@ -519,17 +519,17 @@ void LatteOverlay_render(bool pad_view) return; sint32 w = 0, h = 0; - if (pad_view && gui_isPadWindowOpen()) - gui_getPadWindowPhysSize(w, h); + if (pad_view && WindowSystem::IsPadWindowOpen()) + WindowSystem::GetPadWindowPhysSize(w, h); else - gui_getWindowPhysSize(w, h); + WindowSystem::GetWindowPhysSize(w, h); if (w == 0 || h == 0) return; const Vector2f window_size{ (float)w,(float)h }; - float fontDPIScale = !pad_view ? gui_getWindowDPIScale() : gui_getPadDPIScale(); + float fontDPIScale = !pad_view ? WindowSystem::GetWindowDPIScale() : WindowSystem::GetPadDPIScale(); float overlayFontSize = 14.0f * (float)config.overlay.text_scale / 100.0f * fontDPIScale; diff --git a/src/Cafe/HW/Latte/Core/LattePerformanceMonitor.cpp b/src/Cafe/HW/Latte/Core/LattePerformanceMonitor.cpp index 14dfe9a9..a3bcb63e 100644 --- a/src/Cafe/HW/Latte/Core/LattePerformanceMonitor.cpp +++ b/src/Cafe/HW/Latte/Core/LattePerformanceMonitor.cpp @@ -1,6 +1,6 @@ #include "Cafe/HW/Latte/Core/LattePerformanceMonitor.h" #include "Cafe/HW/Latte/Core/LatteOverlay.h" -#include "gui/guiWrapper.h" +#include "WindowSystem.h" performanceMonitor_t performanceMonitor{}; @@ -106,12 +106,12 @@ void LattePerformanceMonitor_frameEnd() if (isFirstUpdate) { LatteOverlay_updateStats(0.0, 0, 0); - gui_updateWindowTitles(false, false, 0.0); + WindowSystem::UpdateWindowTitles(false, false, 0.0); } else { LatteOverlay_updateStats(fps, drawCallCounter / elapsedFrames, fastDrawCallCounter / elapsedFrames); - gui_updateWindowTitles(false, false, fps); + WindowSystem::UpdateWindowTitles(false, false, fps); } } } diff --git a/src/Cafe/HW/Latte/Core/LatteRenderTarget.cpp b/src/Cafe/HW/Latte/Core/LatteRenderTarget.cpp index 2efef5bf..be9917e1 100644 --- a/src/Cafe/HW/Latte/Core/LatteRenderTarget.cpp +++ b/src/Cafe/HW/Latte/Core/LatteRenderTarget.cpp @@ -11,7 +11,7 @@ #include "Cafe/HW/Latte/Core/LattePerformanceMonitor.h" #include "Cafe/GraphicPack/GraphicPack2.h" #include "config/ActiveSettings.h" -#include "gui/guiWrapper.h" +#include "WindowSystem.h" #include "Cafe/OS/libs/erreula/erreula.h" #include "input/InputManager.h" #include "Cafe/OS/libs/swkbd/swkbd.h" @@ -838,10 +838,10 @@ sint32 _currentOutputImageHeight = 0; void LatteRenderTarget_getScreenImageArea(sint32* x, sint32* y, sint32* width, sint32* height, sint32* fullWidth, sint32* fullHeight, bool padView) { int w, h; - if(padView && gui_isPadWindowOpen()) - gui_getPadWindowPhysSize(w, h); + if(padView && WindowSystem::IsPadWindowOpen()) + WindowSystem::GetPadWindowPhysSize(w, h); else - gui_getWindowPhysSize(w, h); + WindowSystem::GetWindowPhysSize(w, h); sint32 scaledOutputX; sint32 scaledOutputY; @@ -999,8 +999,8 @@ void LatteRenderTarget_itHLECopyColorBufferToScanBuffer(MPTR colorBufferPtr, uin return {pressed && !toggle, pressed && toggle}; }; - const bool tabPressed = gui_isKeyDown(PlatformKeyCodes::TAB); - const bool ctrlPressed = gui_isKeyDown(PlatformKeyCodes::LCONTROL); + const bool tabPressed = WindowSystem::IsKeyDown(WindowSystem::PlatformKeyCodes::TAB); + const bool ctrlPressed = WindowSystem::IsKeyDown(WindowSystem::PlatformKeyCodes::LCONTROL); const auto [vpad0Active, vpad0Toggle] = getVPADScreenActive(0); const auto [vpad1Active, vpad1Toggle] = getVPADScreenActive(1); diff --git a/src/Cafe/HW/Latte/Core/LatteShaderCache.cpp b/src/Cafe/HW/Latte/Core/LatteShaderCache.cpp index 86035973..737e9201 100644 --- a/src/Cafe/HW/Latte/Core/LatteShaderCache.cpp +++ b/src/Cafe/HW/Latte/Core/LatteShaderCache.cpp @@ -6,7 +6,7 @@ #include "Cafe/HW/Latte/Core/FetchShader.h" #include "Cemu/FileCache/FileCache.h" #include "Cafe/GameProfile/GameProfile.h" -#include "gui/guiWrapper.h" +#include "WindowSystem.h" #include "Cafe/HW/Latte/Renderer/Renderer.h" #include "Cafe/HW/Latte/Renderer/OpenGL/RendererShaderGL.h" @@ -24,7 +24,6 @@ #include "Cafe/HW/Latte/Common/ShaderSerializer.h" #include "util/helpers/Serializer.h" -#include #include