mirror of
https://github.com/Nightkingale/Wii-U-Account-Swap.git
synced 2026-04-26 00:10:36 -05:00
New Menu Handling (#6)
* Changed how the menus are handled so we only have one WHBProcIsRunning() loop. This fixes some™️ Crashes using wiiload for example
* Adapt code to follow project style
---------
Co-authored-by: Nightkingale <63483138+Nightkingale@users.noreply.github.com>
This commit is contained in:
parent
66dea21728
commit
c69e93c879
|
|
@ -2,8 +2,21 @@
|
|||
#define START_SCREEN_HPP
|
||||
|
||||
|
||||
enum screens
|
||||
{
|
||||
START_SCREEN,
|
||||
UNLINK_SCREEN,
|
||||
BACKUP_SCREEN,
|
||||
SWAP_SCREEN,
|
||||
OVERWRITE_SCREEN
|
||||
};
|
||||
|
||||
|
||||
extern screens current_screen;
|
||||
|
||||
|
||||
void draw_start_screen(int selected_menu_item);
|
||||
void process_start_screen();
|
||||
|
||||
void process_screens();
|
||||
|
||||
#endif
|
||||
|
|
@ -128,17 +128,23 @@ backup_account()
|
|||
|
||||
// Check if the backup file exists.
|
||||
std::ifstream ifile(backup_path);
|
||||
|
||||
current_screen = OVERWRITE_SCREEN;
|
||||
|
||||
if (ifile) {
|
||||
backup_confirm = false;
|
||||
bool selected = false;
|
||||
|
||||
while (WHBProcIsRunning()) {
|
||||
while (!selected) {
|
||||
draw_overwrite_menu(backup_path.c_str());
|
||||
int button = read_input();
|
||||
|
||||
if (button & VPAD_BUTTON_A) {
|
||||
backup_confirm = true;
|
||||
selected = true;
|
||||
break;
|
||||
} else if (button & VPAD_BUTTON_B) {
|
||||
selected = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -146,13 +152,21 @@ backup_account()
|
|||
backup_confirm = true;
|
||||
}
|
||||
|
||||
current_screen = BACKUP_SCREEN;
|
||||
|
||||
// Write the backup file.
|
||||
if (backup_confirm) {
|
||||
if (write_backup(account, backup_path, buffer))
|
||||
{
|
||||
handle_cleanup(account, NULL, buffer, false);
|
||||
current_screen = START_SCREEN;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
handle_cleanup(account, NULL, buffer, !backup_confirm);
|
||||
current_screen = START_SCREEN;
|
||||
return true;
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -172,7 +172,7 @@ main()
|
|||
|
||||
while (WHBProcIsRunning()) {
|
||||
if (!error_occurred)
|
||||
process_start_screen();
|
||||
process_screens();
|
||||
}
|
||||
|
||||
deinitialize();
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@
|
|||
|
||||
int selected_option = 0;
|
||||
const int NUM_OPTIONS = 4;
|
||||
|
||||
screens current_screen = START_SCREEN;
|
||||
|
||||
bool
|
||||
swap_account_action(const char* account_backup, const char* account_type)
|
||||
|
|
@ -40,6 +40,9 @@ swap_account_action(const char* account_backup, const char* account_type)
|
|||
SYSLaunchMenu();
|
||||
return true;
|
||||
}
|
||||
|
||||
current_screen = START_SCREEN;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -47,17 +50,19 @@ swap_account_action(const char* account_backup, const char* account_type)
|
|||
bool
|
||||
backup_account_action()
|
||||
{
|
||||
while (WHBProcIsRunning()) {
|
||||
OSEnableHomeButtonMenu(0);
|
||||
draw_backup_menu();
|
||||
int button = read_input();
|
||||
|
||||
if (button & VPAD_BUTTON_A) {
|
||||
backup_account();
|
||||
current_screen = START_SCREEN;
|
||||
return true;
|
||||
} else if (button & VPAD_BUTTON_B)
|
||||
{
|
||||
current_screen = START_SCREEN;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -66,18 +71,20 @@ bool
|
|||
unlink_account_action()
|
||||
{
|
||||
OSEnableHomeButtonMenu(0);
|
||||
while (WHBProcIsRunning()) {
|
||||
draw_unlink_menu();
|
||||
int button = read_input();
|
||||
draw_unlink_menu();
|
||||
int button = read_input();
|
||||
|
||||
if (button & VPAD_BUTTON_A) {
|
||||
if (unlink_account()) {
|
||||
OSForceFullRelaunch();
|
||||
SYSLaunchMenu();
|
||||
return true;
|
||||
}
|
||||
} else if (button & VPAD_BUTTON_B)
|
||||
if (button & VPAD_BUTTON_A) {
|
||||
if (unlink_account()) {
|
||||
OSForceFullRelaunch();
|
||||
SYSLaunchMenu();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (button & VPAD_BUTTON_B)
|
||||
{
|
||||
current_screen = START_SCREEN;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
@ -147,19 +154,47 @@ process_start_screen()
|
|||
} else if (button & VPAD_BUTTON_A) {
|
||||
switch (selected_option) {
|
||||
case 0:
|
||||
swap_account_action(NNID_BACKUP.c_str(), "Nintendo");
|
||||
current_screen = SWAP_SCREEN;
|
||||
//swap_account_action(NNID_BACKUP.c_str(), "Nintendo");
|
||||
break;
|
||||
case 1:
|
||||
swap_account_action(PNID_BACKUP.c_str(), "Pretendo");
|
||||
current_screen = SWAP_SCREEN;
|
||||
//swap_account_action(PNID_BACKUP.c_str(), "Pretendo");
|
||||
break;
|
||||
case 2:
|
||||
backup_account_action();
|
||||
current_screen = BACKUP_SCREEN;
|
||||
//backup_account_action();
|
||||
break;
|
||||
case 3:
|
||||
unlink_account_action();
|
||||
current_screen = UNLINK_SCREEN;
|
||||
//unlink_account_action();
|
||||
break;
|
||||
}
|
||||
} else if (button & VPAD_BUTTON_SYNC) {
|
||||
play_easter_egg();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void process_screens()
|
||||
{
|
||||
switch(current_screen)
|
||||
{
|
||||
case START_SCREEN:
|
||||
process_start_screen();
|
||||
break;
|
||||
case UNLINK_SCREEN:
|
||||
unlink_account_action();
|
||||
break;
|
||||
case SWAP_SCREEN:
|
||||
if(selected_option == 0)
|
||||
swap_account_action(NNID_BACKUP.c_str(), "Nintendo");
|
||||
else
|
||||
swap_account_action(PNID_BACKUP.c_str(), "Pretendo");
|
||||
break;
|
||||
case BACKUP_SCREEN:
|
||||
backup_account_action();
|
||||
break;
|
||||
case OVERWRITE_SCREEN:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user