mirror of
https://github.com/PretendoNetwork/Inkay.git
synced 2026-04-24 07:27:16 -05:00
feat: Show notification is plugin is missing or module was never initialized
This commit is contained in:
parent
fa59526cd0
commit
1ffb9cf65a
|
|
@ -4,7 +4,7 @@ COPY --from=ghcr.io/wiiu-env/libnotifications:20240426 /artifacts $DEVKITPRO
|
|||
COPY --from=ghcr.io/wiiu-env/libfunctionpatcher:20230621 /artifacts $DEVKITPRO
|
||||
COPY --from=ghcr.io/wiiu-env/libkernel:20230621 /artifacts $DEVKITPRO
|
||||
COPY --from=ghcr.io/wiiu-env/libmocha:20231127 /artifacts $DEVKITPRO
|
||||
COPY --from=ghcr.io/wiiu-env/wiiumodulesystem:20240424 /artifacts $DEVKITPRO
|
||||
COPY --from=ghcr.io/wiiu-env/wiiumodulesystem:0.3.3-dev-20250130-474ef70 /artifacts $DEVKITPRO
|
||||
COPY --from=ghcr.io/wiiu-env/wiiupluginsystem:20240505 /artifacts $DEVKITPRO
|
||||
|
||||
WORKDIR /app
|
||||
|
|
|
|||
|
|
@ -62,7 +62,8 @@ DEINITIALIZE_PLUGIN() {
|
|||
}
|
||||
|
||||
ON_APPLICATION_START() {
|
||||
|
||||
// Tell the module the plugin is running!
|
||||
Inkay_SetPluginRunning();
|
||||
}
|
||||
|
||||
ON_APPLICATION_ENDS() {
|
||||
|
|
|
|||
|
|
@ -15,17 +15,18 @@
|
|||
*/
|
||||
|
||||
#include "module.h"
|
||||
#include <coreinit/dynload.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "Notification.h"
|
||||
#include "utils/logger.h"
|
||||
#include "sysconfig.h"
|
||||
#include "lang.h"
|
||||
|
||||
#include <coreinit/dynload.h>
|
||||
|
||||
static OSDynLoad_Module module;
|
||||
static void (*moduleInitialize)(bool) = nullptr;
|
||||
static InkayStatus (*moduleGetStatus)() = nullptr;
|
||||
static void (*moduleSetPluginRunning)() = nullptr;
|
||||
|
||||
static const char *get_module_not_found_message() {
|
||||
return get_config_strings(get_system_language()).module_not_found.data();
|
||||
|
|
@ -61,6 +62,7 @@ void Inkay_Finalize() {
|
|||
OSDynLoad_Release(module);
|
||||
moduleInitialize = nullptr;
|
||||
moduleGetStatus = nullptr;
|
||||
moduleSetPluginRunning = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -76,3 +78,16 @@ InkayStatus Inkay_GetStatus() {
|
|||
|
||||
return moduleGetStatus();
|
||||
}
|
||||
|
||||
void Inkay_SetPluginRunning() {
|
||||
if (!module) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!moduleSetPluginRunning && OSDynLoad_FindExport(module, OS_DYNLOAD_EXPORT_FUNC, "Inkay_SetPluginRunning", reinterpret_cast<void * *>(&moduleSetPluginRunning)) != OS_DYNLOAD_OK) {
|
||||
DEBUG_FUNCTION_LINE("Failed to find \"Inkay_SetPluginRunning\" function");
|
||||
return;
|
||||
}
|
||||
|
||||
moduleSetPluginRunning();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,3 +27,4 @@ enum class InkayStatus {
|
|||
void Inkay_Initialize(bool apply_patches);
|
||||
void Inkay_Finalize();
|
||||
InkayStatus Inkay_GetStatus();
|
||||
void Inkay_SetPluginRunning();
|
||||
|
|
|
|||
|
|
@ -20,3 +20,4 @@
|
|||
bool Config::connect_to_network = false;
|
||||
bool Config::initialized = false;
|
||||
bool Config::shown_uninitialized_warning = false;
|
||||
bool Config::plugin_is_loaded = false;
|
||||
|
|
|
|||
|
|
@ -15,6 +15,8 @@ public:
|
|||
static bool initialized;
|
||||
|
||||
static bool shown_uninitialized_warning;
|
||||
|
||||
static bool plugin_is_loaded;
|
||||
};
|
||||
|
||||
#endif //INKAY_CONFIG_H
|
||||
|
|
|
|||
34
src/main.cpp
34
src/main.cpp
|
|
@ -118,6 +118,10 @@ static const char *get_pretendo_message() {
|
|||
return get_config_strings(get_system_language()).using_pretendo_network.data();
|
||||
}
|
||||
|
||||
static void Inkay_SetPluginRunning() {
|
||||
Config::plugin_is_loaded = true;
|
||||
}
|
||||
|
||||
static InkayStatus Inkay_GetStatus() {
|
||||
if (!Config::initialized)
|
||||
return InkayStatus::Uninitialized;
|
||||
|
|
@ -131,7 +135,7 @@ static InkayStatus Inkay_GetStatus() {
|
|||
|
||||
static void Inkay_Initialize(bool apply_patches) {
|
||||
if (Config::initialized)
|
||||
return;
|
||||
return;
|
||||
|
||||
// if using pretendo then (try to) apply the ssl patches
|
||||
if (apply_patches) {
|
||||
|
|
@ -177,9 +181,7 @@ WUMS_INITIALIZE() {
|
|||
WHBLogCafeInit();
|
||||
WHBLogUdpInit();
|
||||
|
||||
auto res = Mocha_InitLibrary();
|
||||
|
||||
if (res != MOCHA_RESULT_SUCCESS) {
|
||||
if (const auto res = Mocha_InitLibrary(); res != MOCHA_RESULT_SUCCESS) {
|
||||
DEBUG_FUNCTION_LINE("Mocha init failed with code %d!", res);
|
||||
return;
|
||||
}
|
||||
|
|
@ -207,14 +209,8 @@ WUMS_DEINITIALIZE() {
|
|||
WUMS_APPLICATION_STARTS() {
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("Inkay " INKAY_VERSION " starting up...\n");
|
||||
|
||||
// TODO - Add a way to reliably check this. We can't do it here since this path gets triggered before
|
||||
// the plugin gets initialized.
|
||||
//
|
||||
// if (!Config::initialized && !Config::shown_uninitialized_warning) {
|
||||
// DEBUG_FUNCTION_LINE("Inkay module not initialized");
|
||||
// ShowNotification("Inkay module was not initialized. Ensure you have the Inkay plugin loaded");
|
||||
// Config::shown_uninitialized_warning = true;
|
||||
// }
|
||||
// Reset plugin loaded flag
|
||||
Config::plugin_is_loaded = false;
|
||||
|
||||
setup_olv_libs();
|
||||
peertopeer_patch();
|
||||
|
|
@ -222,9 +218,21 @@ WUMS_APPLICATION_STARTS() {
|
|||
hotpatchAccountSettings();
|
||||
}
|
||||
|
||||
WUMS_APPLICATION_ENDS() {
|
||||
WUMS_ALL_APPLICATION_STARTS_DONE() {
|
||||
if (Config::initialized && !Config::plugin_is_loaded) {
|
||||
DEBUG_FUNCTION_LINE("Inkay is running but the plugin got unloaded");
|
||||
ShowNotification("Inkay module is still running. Please restart the console to disable Pretendo.");
|
||||
Config::shown_uninitialized_warning = true;
|
||||
} else if (!Config::initialized && !Config::shown_uninitialized_warning) {
|
||||
DEBUG_FUNCTION_LINE("Inkay module not initialized");
|
||||
ShowNotification("Inkay module was not initialized. Ensure you have the Inkay plugin loaded");
|
||||
Config::shown_uninitialized_warning = true;
|
||||
}
|
||||
}
|
||||
|
||||
WUMS_APPLICATION_ENDS() {
|
||||
}
|
||||
|
||||
WUMS_EXPORT_FUNCTION(Inkay_Initialize);
|
||||
WUMS_EXPORT_FUNCTION(Inkay_GetStatus);
|
||||
WUMS_EXPORT_FUNCTION(Inkay_SetPluginRunning);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user