diff --git a/Makefile b/Makefile index ae19d88..327e3d2 100644 --- a/Makefile +++ b/Makefile @@ -34,7 +34,7 @@ TARGET := Wii_U_Account_Swap BUILD := build SOURCES := source DATA := data -INCLUDES := source +INCLUDES := include #------------------------------------------------------------------------------- # options for code generation diff --git a/include/global.h b/include/global.h new file mode 100644 index 0000000..3057ef3 --- /dev/null +++ b/include/global.h @@ -0,0 +1,13 @@ +#ifndef GLOBAL_H +#define GLOBAL_H + +extern const char* NNID_BACKUP; +extern const char* PNID_BACKUP; +extern const char* ACCOUNT_FILE; +extern const char* INKAY_CONFIG; +extern const int BUFFER_SIZE; + +void deinitialize(); +void initialize(); + +#endif // GLOBAL_H \ No newline at end of file diff --git a/source/screens.h b/include/screen.h similarity index 60% rename from source/screens.h rename to include/screen.h index 3b13dd0..7faa893 100644 --- a/source/screens.h +++ b/include/screen.h @@ -1,9 +1,8 @@ -// screens.h -#ifndef SCREENS_H -#define SCREENS_H +#ifndef SCREEN_H +#define SCREEN_H void printOnScreen(int line, const char* format, ...); void printMainMenu(); void printWarningScreen(); -#endif // SCREENS_H \ No newline at end of file +#endif // SCREEN_H \ No newline at end of file diff --git a/source/switch.h b/include/switch.h similarity index 91% rename from source/switch.h rename to include/switch.h index 09386fe..594fe2e 100644 --- a/source/switch.h +++ b/include/switch.h @@ -1,4 +1,3 @@ -// switch.h #ifndef SWITCH_H #define SWITCH_H diff --git a/source/unlink.h b/include/unlink.h similarity index 86% rename from source/unlink.h rename to include/unlink.h index 8341a51..5474683 100644 --- a/source/unlink.h +++ b/include/unlink.h @@ -1,4 +1,3 @@ -// unlink.h #ifndef UNLINK_H #define UNLINK_H diff --git a/source/globals.h b/source/globals.h deleted file mode 100644 index a785e4c..0000000 --- a/source/globals.h +++ /dev/null @@ -1,12 +0,0 @@ -// globals.h -#ifndef GLOBALS_H -#define GLOBALS_H - -extern const char* accountFile; -extern const char* inkayConfig; -extern const int BUFFER_SIZE; - -void deinitialize(); -void initialize(); - -#endif // GLOBALS_H \ No newline at end of file diff --git a/source/main.cpp b/source/main.cpp index 3d282c1..6535fad 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -8,14 +8,16 @@ #include #include -#include "globals.h" -#include "screens.h" -#include "switch.h" -#include "unlink.h" +#include "../include/global.h" +#include "../include/screen.h" +#include "../include/switch.h" +#include "../include/unlink.h" -const char* accountFile = "storage_mlc:/usr/save/system/act/8000000e/account.dat"; -const char* inkayConfig = "/vol/external01/wiiu/environments/aroma/plugins/config/inkay.json";\ +const char* NNID_BACKUP = "/vol/external01/accounts/nnid_account.dat"; +const char* PNID_BACKUP = "/vol/external01/accounts/pnid_account.dat"; +const char* ACCOUNT_FILE = "storage_mlc:/usr/save/system/act/8000000e/account.dat"; +const char* INKAY_CONFIG = "/vol/external01/wiiu/environments/aroma/plugins/config/inkay.json";\ const int BUFFER_SIZE = 0x2000; void deinitialize() @@ -46,7 +48,7 @@ void initialize() int main() { initialize(); - + VPADStatus input; VPADReadError error; @@ -59,12 +61,12 @@ int main() // If the A button is pressed, switch to the Nintendo Network ID account.dat. if (input.trigger & VPAD_BUTTON_A) { - switchAccount("/vol/external01/accounts/nnid_account.dat", "Nintendo Network ID"); + switchAccount(NNID_BACKUP, "Nintendo Network ID"); } // If the B button is pressed, switch to the Pretendo Network ID account.dat. else if (input.trigger & VPAD_BUTTON_B) { - switchAccount("/vol/external01/accounts/pnid_account.dat", "Pretendo Network ID"); + switchAccount(PNID_BACKUP, "Pretendo Network ID"); } // If the X button is pressed, unlink the account locally. else if (input.trigger & VPAD_BUTTON_X) diff --git a/source/screens.cpp b/source/screen.cpp similarity index 91% rename from source/screens.cpp rename to source/screen.cpp index 4040130..af974af 100644 --- a/source/screens.cpp +++ b/source/screen.cpp @@ -4,6 +4,7 @@ #include #include #include +#include void printOnScreen(int line, const char* format, ...) @@ -26,12 +27,14 @@ void printMainMenu() printOnScreen(0, "Wii U Account Swap (v1.0.0)"); printOnScreen(1, "Created by Nightkingale"); - printOnScreen(2, "-----------------------------------------------------------"); + printOnScreen(2, "----------------------------------------------------------"); printOnScreen(3, "Press A to switch to Nintendo Network ID."); printOnScreen(4, "Press B to switch to Pretendo Network ID."); printOnScreen(5, "Press X to unlink your account locally."); printOnScreen(6, "Press HOME to exit."); - printOnScreen(7, "-----------------------------------------------------------"); + printOnScreen(7, "----------------------------------------------------------"); + nn::act::Initialize(); // Initialize the Nintendo Account library + OSScreenFlipBuffersEx(SCREEN_TV); OSScreenFlipBuffersEx(SCREEN_DRC); @@ -44,11 +47,11 @@ void printWarningScreen() printOnScreen(0, "Warning: This will unlink your account locally!"); printOnScreen(1, "This will not unlink your account from the server!"); - printOnScreen(2, "-----------------------------------------------------------"); + printOnScreen(2, "----------------------------------------------------------"); printOnScreen(3, "Your user can have a new account reattached!"); printOnScreen(4, "You will be able to login again on this Wii U as normal."); printOnScreen(5, "However, you will NOT be able to login to another Wii U!"); - printOnScreen(6, "-----------------------------------------------------------"); + printOnScreen(6, "----------------------------------------------------------"); printOnScreen(7, "Press A to confirm the unlink or B to cancel."); OSScreenFlipBuffersEx(SCREEN_TV); diff --git a/source/switch.cpp b/source/switch.cpp index 351b284..c8cfb0b 100644 --- a/source/switch.cpp +++ b/source/switch.cpp @@ -12,14 +12,14 @@ #include #include -#include "globals.h" +#include "../include/global.h" void switchAccount(const char* backupFile, const char* accountType) { WHBLogPrintf("Switching to %s...", accountType); WHBLogPrintf("Source: %s", backupFile); - WHBLogPrintf("%s", accountFile); + WHBLogPrintf("%s", ACCOUNT_FILE); WHBLogPrint("----------------------------------------"); WHBLogConsoleDraw(); @@ -49,7 +49,7 @@ void switchAccount(const char* backupFile, const char* accountType) WHBLogPrint("Memory was allocated successfully!"); WHBLogConsoleDraw(); - FILE *account = fopen(accountFile, "wb"); + FILE *account = fopen(ACCOUNT_FILE, "wb"); if (account == NULL) { WHBLogConsoleSetColor(0x99000000); @@ -69,7 +69,7 @@ void switchAccount(const char* backupFile, const char* accountType) WHBLogConsoleSetColor(0x00990000); WHBLogPrint("System account.dat file was saved!"); // We'll attempt to automatically swap the network using Inkay's configuration. - FILE *inkay = fopen(inkayConfig, "wb"); + FILE *inkay = fopen(INKAY_CONFIG, "wb"); if (inkay == NULL) { // If we can't open the file, we will move on. diff --git a/source/unlink.cpp b/source/unlink.cpp index e2f9237..b35ad6c 100644 --- a/source/unlink.cpp +++ b/source/unlink.cpp @@ -17,7 +17,7 @@ #include #include -#include "globals.h" +#include "../include/global.h" void unlinkAccount() { @@ -60,12 +60,12 @@ void unlinkAccount() { }; WHBLogPrintf("Unlinking: Default settings will be applied."); - WHBLogPrintf("%s", accountFile); + WHBLogPrintf("%s", ACCOUNT_FILE); WHBLogPrint("----------------------------------------"); WHBLogConsoleDraw(); // Read the entire file into a string. - std::ifstream inFile(accountFile); + std::ifstream inFile(ACCOUNT_FILE); std::string fileContents((std::istreambuf_iterator(inFile)), std::istreambuf_iterator()); inFile.close(); WHBLogPrint("System account.dat file is in memory!"); @@ -88,7 +88,7 @@ void unlinkAccount() { WHBLogConsoleDraw(); // Write the string back to the file. - std::ofstream outFile(accountFile); + std::ofstream outFile(ACCOUNT_FILE); outFile << fileContents; outFile.close(); WHBLogPrint("System account.dat file was saved!");