Skip to content

Commit 521eeb1

Browse files
committed
Isolate wxWidgets code from non-GUI code
1 parent e68c31e commit 521eeb1

File tree

192 files changed

+2157
-1656
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

192 files changed

+2157
-1656
lines changed

.github/workflows/build_check.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ on:
1111
paths-ignore:
1212
- "*.md"
1313
branches:
14-
- main
14+
- wx_widgets_decouple
1515

1616
jobs:
1717
build:

src/CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,3 @@ if(UNIX AND NOT APPLE)
150150
# most likely not helpful in debugging problems with cemu code
151151
target_link_options(CemuBin PRIVATE "$<$<CONFIG:Release>:-Xlinker;--strip-debug>")
152152
endif()
153-
154-
if (ENABLE_WXWIDGETS)
155-
target_link_libraries(CemuBin PRIVATE wx::base wx::core)
156-
endif()

src/Cafe/CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -597,10 +597,6 @@ else ()
597597
target_link_libraries(CemuCafe PRIVATE libusb::libusb)
598598
endif ()
599599

600-
if (ENABLE_WXWIDGETS)
601-
target_link_libraries(CemuCafe PRIVATE wx::base wx::core)
602-
endif()
603-
604600
if(WIN32)
605601
target_link_libraries(CemuCafe PRIVATE iphlpapi)
606602
endif()

src/Cafe/CafeSystem.cpp

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include "Cafe/OS/common/OSCommon.h"
2-
#include "gui/wxgui.h"
2+
#include "WindowSystem.h"
33
#include "Cafe/OS/libs/gx2/GX2.h"
44
#include "Cafe/GameProfile/GameProfile.h"
55
#include "Cafe/HW/Espresso/Interpreter/PPCInterpreterInternal.h"
@@ -65,9 +65,6 @@
6565
// HW interfaces
6666
#include "Cafe/HW/SI/si.h"
6767

68-
// dependency to be removed
69-
#include "gui/guiWrapper.h"
70-
7168
#include <time.h>
7269

7370
#if BOOST_OS_LINUX
@@ -131,7 +128,7 @@ void SetEntryPoint(MPTR entryPoint)
131128
}
132129

133130
// load executable into virtual memory and set entrypoint
134-
void LoadMainExecutable()
131+
bool LoadMainExecutable()
135132
{
136133
isLaunchTypeELF = false;
137134
// when launching from a disc image _pathToExecutable is initially empty
@@ -145,6 +142,7 @@ void LoadMainExecutable()
145142
cemuLog_log(LogType::Force, "Unable to find RPX executable");
146143
cemuLog_waitForFlush();
147144
cemu_assert(false);
145+
return false;
148146
}
149147
}
150148
// extract and load RPX
@@ -155,6 +153,7 @@ void LoadMainExecutable()
155153
cemuLog_log(LogType::Force, "Failed to load \"{}\"", _pathToExecutable);
156154
cemuLog_waitForFlush();
157155
cemu_assert(false);
156+
return false;
158157
}
159158
currentUpdatedApplicationHash = generateHashFromRawRPXData(rpxData, rpxSize);
160159
// determine if this file is an ELF
@@ -172,10 +171,10 @@ void LoadMainExecutable()
172171
applicationRPX = RPLLoader_LoadFromMemory(rpxData, rpxSize, (char*)_pathToExecutable.c_str());
173172
if (!applicationRPX)
174173
{
175-
wxMessageBox(_("Failed to run this title because the executable is damaged"));
176-
cemuLog_createLogFile(false);
174+
cemuLog_log(LogType::Force, "Failed to run this title because the executable is damaged");
177175
cemuLog_waitForFlush();
178-
exit(0);
176+
cemu_assert(false);
177+
return false;
179178
}
180179
RPLLoader_SetMainModule(applicationRPX);
181180
SetEntryPoint(RPLLoader_GetModuleEntrypoint(applicationRPX));
@@ -194,6 +193,7 @@ void LoadMainExecutable()
194193
}
195194
free(baseRpxData);
196195
debug_printf("RPXHash: 0x%08x\n", currentBaseApplicationHash);
196+
return true;
197197
}
198198

199199
fs::path getTitleSavePath()
@@ -357,7 +357,7 @@ uint32 LoadSharedData()
357357

358358
void cemu_initForGame()
359359
{
360-
gui_updateWindowTitles(false, true, 0.0);
360+
WindowSystem::updateWindowTitles(false, true, 0.0);
361361
// input manager apply game profile
362362
InputManager::instance().apply_game_profile();
363363
// log info for launched title
@@ -755,7 +755,12 @@ namespace CafeSystem
755755
}
756756
}
757757
}
758-
LoadMainExecutable();
758+
759+
if (!LoadMainExecutable())
760+
{
761+
return PREPARE_STATUS_CODE::INVALID_RPX;
762+
}
763+
759764
return PREPARE_STATUS_CODE::SUCCESS;
760765
}
761766

@@ -855,7 +860,7 @@ namespace CafeSystem
855860
PPCTimer_waitForInit();
856861
// start system
857862
sSystemRunning = true;
858-
gui_notifyGameLoaded();
863+
WindowSystem::notifyGameLoaded();
859864
std::thread t(_LaunchTitleThread);
860865
t.detach();
861866
}

src/Cafe/Filesystem/FST/KeyCache.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
#include <wx/msgdlg.h>
21
#include <mutex>
3-
#include <gui/helpers/wxHelpers.h>
42

3+
#include "Cemu/Logging/CemuLogging.h"
54
#include "config/ActiveSettings.h"
65
#include "util/crypto/aes128.h"
76
#include "Common/FileStream.h"
@@ -75,7 +74,7 @@ void KeyCache_Prepare()
7574
}
7675
else
7776
{
78-
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);
77+
cemuLog_log(LogType::Force, "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.");
7978
}
8079
mtxKeyCache.unlock();
8180
return;
@@ -108,8 +107,7 @@ void KeyCache_Prepare()
108107
continue;
109108
if( strishex(line) == false )
110109
{
111-
auto errorMsg = formatWxString(_("Error in keys.txt at line {}"), lineNumber);
112-
wxMessageBox(errorMsg, _("Error"), wxOK | wxCENTRE | wxICON_ERROR);
110+
cemuLog_log(LogType::Force, "Error in keys.txt at line {}", lineNumber);
113111
continue;
114112
}
115113
if(line.size() == 32 )

src/Cafe/GraphicPack/GraphicPack2Patches.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
#include "Cafe/GraphicPack/GraphicPack2.h"
2+
#include "Cemu/Logging/CemuLogging.h"
23
#include "Common/FileStream.h"
34
#include "util/helpers/StringParser.h"
45
#include "Cemu/PPCAssembler/ppcAssembler.h"
56
#include "Cafe/OS/RPL/rpl_structs.h"
67
#include "boost/algorithm/string.hpp"
78

8-
#include "gui/wxgui.h" // for wxMessageBox
9-
#include "gui/helpers/wxHelpers.h"
10-
119
// error handler
1210
void PatchErrorHandler::printError(class PatchGroup* patchGroup, sint32 lineNumber, std::string_view errorMsg)
1311
{
@@ -38,15 +36,15 @@ void PatchErrorHandler::printError(class PatchGroup* patchGroup, sint32 lineNumb
3836
errorMessages.emplace_back(msg);
3937
}
4038

41-
void PatchErrorHandler::showStageErrorMessageBox()
39+
void PatchErrorHandler::logStageError()
4240
{
43-
wxString errorMsg;
41+
std::string errorMsg;
4442
if (m_gp)
4543
{
4644
if (m_stage == STAGE::PARSER)
47-
errorMsg.assign(formatWxString(_("Failed to load patches for graphic pack \'{}\'"), m_gp->GetName()));
45+
errorMsg = fmt::format("Failed to load patches for graphic pack \'{}\'", m_gp->GetName());
4846
else
49-
errorMsg.assign(formatWxString(_("Failed to apply patches for graphic pack \'{}\'"), m_gp->GetName()));
47+
errorMsg = fmt::format("Failed to apply patches for graphic pack \'{}\'", m_gp->GetName());
5048
}
5149
else
5250
{
@@ -55,7 +53,7 @@ void PatchErrorHandler::showStageErrorMessageBox()
5553
if (cemuLog_isLoggingEnabled(LogType::Patches))
5654
{
5755
errorMsg.append("\n \n")
58-
.append(_("Details:"))
56+
.append("Details:")
5957
.append("\n");
6058
for (auto& itr : errorMessages)
6159
{
@@ -64,7 +62,7 @@ void PatchErrorHandler::showStageErrorMessageBox()
6462
}
6563
}
6664

67-
wxMessageBox(errorMsg, _("Graphic pack error"));
65+
cemuLog_log(LogType::Force, errorMsg);
6866
}
6967

7068
// loads Cemu-style patches (patch_<anything>.asm)

src/Cafe/GraphicPack/GraphicPack2PatchesApply.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -691,13 +691,13 @@ void GraphicPack2::ApplyPatchGroups(std::vector<PatchGroup*>& groups, const RPLM
691691
patchContext.errorHandler.printError(nullptr, -1, "Some symbols could not be resolved because the dependency chain is too deep");
692692
for (auto& itr : patchContext.unresolvedSymbols)
693693
patchContext.errorHandler.printError(itr.patchGroup, itr.lineNumber, fmt::format("Unresolved symbol: {}", itr.symbolName));
694-
patchContext.errorHandler.showStageErrorMessageBox();
694+
patchContext.errorHandler.logStageError();
695695
return;
696696
}
697697
}
698698
if (!isUnresolvedPatchesEmpty() || patchContext.errorHandler.hasError())
699699
{
700-
patchContext.errorHandler.showStageErrorMessageBox();
700+
patchContext.errorHandler.logStageError();
701701
return;
702702
}
703703
// apply relocated patches

src/Cafe/GraphicPack/GraphicPackError.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class PatchErrorHandler
2121
}
2222

2323
void printError(class PatchGroup* patchGroup, sint32 lineNumber, std::string_view errorMsg);
24-
void showStageErrorMessageBox();
24+
void logStageError();
2525

2626
bool hasError() const { return m_anyErrorTriggered; };
2727

src/Cafe/HW/Espresso/Debugger/Debugger.cpp

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
1-
#include "gui/guiWrapper.h"
1+
#include "Common/precompiled.h"
22
#include "Debugger.h"
33
#include "Cafe/OS/RPL/rpl_structs.h"
44
#include "Cemu/PPCAssembler/ppcAssembler.h"
55
#include "Cafe/HW/Espresso/Recompiler/PPCRecompiler.h"
66
#include "Cemu/ExpressionParser/ExpressionParser.h"
77

8-
#include "gui/debugger/DebuggerWindow2.h"
9-
108
#include "Cafe/OS/libs/coreinit/coreinit.h"
9+
#include "OS/RPL/rpl.h"
1110
#include "util/helpers/helpers.h"
1211

1312
#if BOOST_OS_WINDOWS
1413
#include <Windows.h>
1514
#endif
1615

16+
DebuggerDispatcher g_debuggerDispatcher;
17+
1718
debuggerState_t debuggerState{ };
1819

1920
DebuggerBreakpoint* debugger_getFirstBP(uint32 address)
@@ -337,7 +338,7 @@ void debugger_toggleBreakpoint(uint32 address, bool state, DebuggerBreakpoint* b
337338
{
338339
bp->enabled = state;
339340
debugger_updateExecutionBreakpoint(address);
340-
debuggerWindow_updateViewThreadsafe2();
341+
g_debuggerDispatcher.updateViewThreadsafe();
341342
}
342343
else if (bpItr->isMemBP())
343344
{
@@ -359,7 +360,7 @@ void debugger_toggleBreakpoint(uint32 address, bool state, DebuggerBreakpoint* b
359360
debugger_updateMemoryBreakpoint(bpItr);
360361
else
361362
debugger_updateMemoryBreakpoint(nullptr);
362-
debuggerWindow_updateViewThreadsafe2();
363+
g_debuggerDispatcher.updateViewThreadsafe();
363364
}
364365
return;
365366
}
@@ -496,7 +497,7 @@ void debugger_stepInto(PPCInterpreter_t* hCPU, bool updateDebuggerWindow = true)
496497
debugger_updateExecutionBreakpoint(initialIP);
497498
debuggerState.debugSession.instructionPointer = hCPU->instructionPointer;
498499
if(updateDebuggerWindow)
499-
debuggerWindow_moveIP();
500+
g_debuggerDispatcher.moveIP();
500501
ppcRecompilerEnabled = isRecEnabled;
501502
}
502503

@@ -515,15 +516,15 @@ bool debugger_stepOver(PPCInterpreter_t* hCPU)
515516
// nothing to skip, use step-into
516517
debugger_stepInto(hCPU);
517518
debugger_updateExecutionBreakpoint(initialIP);
518-
debuggerWindow_moveIP();
519+
g_debuggerDispatcher.moveIP();
519520
ppcRecompilerEnabled = isRecEnabled;
520521
return false;
521522
}
522523
// create one-shot breakpoint at next instruction
523524
debugger_createCodeBreakpoint(initialIP + 4, DEBUGGER_BP_T_ONE_SHOT);
524525
// step over current instruction (to avoid breakpoint)
525526
debugger_stepInto(hCPU);
526-
debuggerWindow_moveIP();
527+
g_debuggerDispatcher.moveIP();
527528
// restore breakpoints
528529
debugger_updateExecutionBreakpoint(initialIP);
529530
// run
@@ -621,8 +622,8 @@ void debugger_enterTW(PPCInterpreter_t* hCPU)
621622
DebuggerBreakpoint* singleshotBP = debugger_getFirstBP(debuggerState.debugSession.instructionPointer, DEBUGGER_BP_T_ONE_SHOT);
622623
if (singleshotBP)
623624
debugger_deleteBreakpoint(singleshotBP);
624-
debuggerWindow_notifyDebugBreakpointHit2();
625-
debuggerWindow_updateViewThreadsafe2();
625+
g_debuggerDispatcher.notifyDebugBreakpointHit();
626+
g_debuggerDispatcher.updateViewThreadsafe();
626627
// reset step control
627628
debuggerState.debugSession.stepInto = false;
628629
debuggerState.debugSession.stepOver = false;
@@ -639,14 +640,14 @@ void debugger_enterTW(PPCInterpreter_t* hCPU)
639640
break; // if true is returned, continue with execution
640641
}
641642
debugger_createPPCStateSnapshot(hCPU);
642-
debuggerWindow_updateViewThreadsafe2();
643+
g_debuggerDispatcher.updateViewThreadsafe();
643644
debuggerState.debugSession.stepOver = false;
644645
}
645646
if (debuggerState.debugSession.stepInto)
646647
{
647648
debugger_stepInto(hCPU);
648649
debugger_createPPCStateSnapshot(hCPU);
649-
debuggerWindow_updateViewThreadsafe2();
650+
g_debuggerDispatcher.updateViewThreadsafe();
650651
debuggerState.debugSession.stepInto = false;
651652
continue;
652653
}
@@ -663,8 +664,8 @@ void debugger_enterTW(PPCInterpreter_t* hCPU)
663664

664665
debuggerState.debugSession.isTrapped = false;
665666
debuggerState.debugSession.hCPU = nullptr;
666-
debuggerWindow_updateViewThreadsafe2();
667-
debuggerWindow_notifyRun();
667+
g_debuggerDispatcher.updateViewThreadsafe();
668+
g_debuggerDispatcher.notifyRun();
668669
}
669670

670671
void debugger_shouldBreak(PPCInterpreter_t* hCPU)

0 commit comments

Comments
 (0)