Skip to content

Commit

Permalink
WiiU: Address review comments
Browse files Browse the repository at this point in the history
- ProdUi renamed
- Fixed save path for bundled games
- Moved ProcessProcUi call to the Ui
  • Loading branch information
Ghabry committed Aug 27, 2024
1 parent 8260bd5 commit f95f358
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 18 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,7 @@ if(${PLAYER_TARGET_PLATFORM} MATCHES "^(3ds|psvita|switch|wii)$" OR NINTENDO_WII
endif()
# Make content available (romfs/wuhb bundle)
if(${PLAYER_TARGET_PLATFORM} MATCHES "^(3ds|switch)$" OR NINTENDO_WIIU)
option(PLAYER_BUNDLE "Embedd a directory in the executable" OFF)
option(PLAYER_BUNDLE "Embed a directory in the executable" OFF)
set(PLAYER_BUNDLE_PATH "content" CACHE PATH "Directory to include in executable")
set(BUNDLE_ARG "_IGNORE_ME")
if(PLAYER_BUNDLE)
Expand Down
9 changes: 9 additions & 0 deletions src/platform/sdl/sdl2_ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
# include <SDL_system.h>
#elif defined(EMSCRIPTEN)
# include <emscripten.h>
#elif defined(__WIIU__)
# include "platform/wiiu/main.h"
#endif
#include "icon.h"

Expand Down Expand Up @@ -531,6 +533,13 @@ void Sdl2Ui::ToggleZoom() {
}

void Sdl2Ui::ProcessEvents() {
#if defined(__WIIU__)
if (!WiiU_ProcessProcUI()) {
Player::Exit();
return;
}
#endif

SDL_Event evnt;

#if defined(USE_MOUSE) && defined(SUPPORT_MOUSE)
Expand Down
21 changes: 12 additions & 9 deletions src/platform/wiiu/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@

using namespace std::chrono_literals;

static bool procUiExited = false;

#ifdef NDEBUG
// stubbed
static void initLogging() {}
Expand All @@ -48,7 +50,6 @@ static void deinitLogging() {}
static bool moduleLogInit = false;
static bool cafeLogInit = false;
static bool udpLogInit = false;
static bool prodUiExited = false;

static void initLogging() {
if (!(moduleLogInit = WHBLogModuleInit())) {
Expand Down Expand Up @@ -92,7 +93,7 @@ static uint32_t SaveCallback(void*) {
bool WiiU_ProcessProcUI() {
ProcUIStatus status = ProcUIProcessMessages(TRUE);
if (status == PROCUI_STATUS_EXITING) {
prodUiExited = true;
procUiExited = true;
return false;
} else if (status == PROCUI_STATUS_RELEASE_FOREGROUND) {
ProcUIDrawDoneRelease();
Expand All @@ -101,13 +102,13 @@ bool WiiU_ProcessProcUI() {
}

void WiiU_Exit() {
Output::Debug("Shutdown Reason: {}", prodUiExited ? "HOME Menu" : "Player Exit");
Output::Debug("Shutdown Reason: {}", procUiExited ? "HOME Menu" : "Player Exit");

if (!prodUiExited) {
if (!procUiExited) {
// Exit was not through the Home Menu
// Manually launch the system menu
SYSLaunchMenu();
Game_Clock::SleepFor(std::chrono::milliseconds(10));
Game_Clock::SleepFor(10ms);
while (WiiU_ProcessProcUI()) {}
}

Expand All @@ -130,6 +131,9 @@ extern "C" int main(int argc, char* argv[]) {

const char *default_dir = "fs:/vol/external01/wiiu/apps/easyrpg-player";

char working_dir[256];
getcwd(working_dir, 255);

// Check if wuhb has some files inside or not
if(::access("fs:/vol/content/RPG_RT.lmt", F_OK) == 0) {
Output::Debug("Running packaged game from wuhb.");
Expand All @@ -138,14 +142,13 @@ extern "C" int main(int argc, char* argv[]) {
args.push_back("--project-path");
args.push_back(cafe_dir);

//args.push_back("--save-path");
//args.push_back(cafe_dir);
// Save directory is where the wuhb is located
args.push_back("--save-path");
args.push_back(working_dir);
} else if(::access(default_dir, F_OK) == 0) {
chdir(default_dir);
} else {
// fall back to current working directory
char working_dir[256];
getcwd(working_dir, 255);
args.push_back("--project-path");
args.push_back(working_dir);
}
Expand Down
8 changes: 0 additions & 8 deletions src/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@
# include <windows.h>
#elif defined(EMSCRIPTEN)
# include <emscripten.h>
#elif defined(__WIIU__)
# include "platform/wiiu/main.h"
#endif

#include "async_handler.h"
Expand Down Expand Up @@ -218,12 +216,6 @@ void Player::Run() {
// libretro invokes the MainLoop through a retro_run-callback
#else
while (Transition::instance().IsActive() || (Scene::instance && Scene::instance->type != Scene::Null)) {
#if defined(__WIIU__)
if (!WiiU_ProcessProcUI()) {
Player::Exit();
return;
}
#endif
MainLoop();
}
#endif
Expand Down

0 comments on commit f95f358

Please sign in to comment.