/* * Determines whether the node is currently visible * * node The node * return Whether the node is visible */ BOOL wii_menu_handle_is_node_visible( TREENODE *node ) { switch( node->node_type ) { case NODETYPE_LOAD_STATE: return wii_snapshot_current_exists(); case NODETYPE_REWIND_BUTTON: return wii_rewind; case NODETYPE_GX_VI_SCALER_SPACER: case NODETYPE_GX_VI_SCALER: return !wii_filter; case NODETYPE_RESET: case NODETYPE_RESUME: case NODETYPE_EMULATOR_SETTINGS_SPACER: return wii_last_rom != NULL; case NODETYPE_CARTRIDGE_SAVE_STATES: return wii_last_rom != NULL && MDFNGameInfo->StateAction != NULL; case NODETYPE_CARTRIDGE_SETTINGS_CURRENT_SPACER: { Emulator* emu = emuRegistry.getCurrentEmulator(); return emu != NULL && ( ( emu->getMenuManager().getCartridgeSettingsMenu() != NULL && wii_last_rom != NULL ) || ( emu->getMenuManager().getEmulatorMenu() != NULL ) ); } case NODETYPE_CARTRIDGE_SETTINGS_CURRENT: { Emulator* emu = emuRegistry.getCurrentEmulator(); return emu != NULL && emu->getMenuManager().getCartridgeSettingsMenu() != NULL && wii_last_rom != NULL; } case NODETYPE_EMULATOR_SETTINGS: { Emulator* emu = emuRegistry.getCurrentEmulator(); return emu != NULL && emu->getMenuManager().getEmulatorMenu() != NULL; } default: { Emulator* emu = emuRegistry.getCurrentEmulator(); if( emu != NULL ) { return emu->getMenuManager().isNodeVisible( node ); } } } return TRUE; }
/* * React to the "select" event for the specified node * * node The node */ void wii_menu_handle_select_node( TREENODE *node ) { char buff[WII_MAX_PATH]; Emulator* emu = emuRegistry.getCurrentEmulator(); if( emu != NULL ) { emu->getMenuManager().selectNode( node ); } if( node->node_type == NODETYPE_ROM || node->node_type == NODETYPE_RESUME || node->node_type == NODETYPE_LOAD_STATE || node->node_type == NODETYPE_RESET ) { // Essentially blanks the screen //wii_gx_push_callback( NULL, FALSE, NULL ); switch( node->node_type ) { case NODETYPE_LOAD_STATE: wii_start_snapshot(); break; case NODETYPE_ROM: snprintf( buff, sizeof(buff), "%s%s", wii_get_roms_dir(), node->name ); last_rom_index = wii_menu_get_current_index(); loading_game = TRUE; wii_start_emulation( buff, "", false, false ); loading_game = FALSE; break; case NODETYPE_RESUME: wii_resume_emulation(); break; case NODETYPE_RESET: wii_reset_emulation(); break; default: /* do nothing */ break; } //wii_gx_pop_callback(); } else { LOCK_RENDER_MUTEX(); switch( node->node_type ) { case NODETYPE_VOLUME: wii_volume += 10; if( wii_volume > 150 ) { wii_volume = 0; } break; case NODETYPE_SAVE_STATE: wii_save_snapshot( NULL, TRUE ); break; case NODETYPE_CARTRIDGE_SAVE_STATES_SLOT: wii_snapshot_next(); break; case NODETYPE_SELECT_LANG: language_index++; if( language_index >= language_menu->child_count ) { language_index = 0; } select_language(); break; case NODETYPE_DOUBLE_STRIKE: wii_double_strike_mode ^= 1; break; case NODETYPE_FULL_WIDESCREEN: wii_full_widescreen++; if( wii_full_widescreen > WS_AUTO ) { wii_full_widescreen = 0; } break; case NODETYPE_16_9_CORRECTION: wii_16_9_correction ^= 1; break; case NODETYPE_GX_VI_SCALER: wii_gx_vi_scaler ^= 1; break; case NODETYPE_AUTO_LOAD_SAVE: wii_auto_load_save_state ^= 1; break; case NODETYPE_TOP_MENU_EXIT: wii_top_menu_exit ^= 1; break; case NODETYPE_CHEATS: wii_cheats ^= 1; break; case NODETYPE_REWIND: wii_rewind ^= 1; if( wii_rewind ) { wii_set_status_message( "Note: Enabling rewind may affect performance." ); } break; case NODETYPE_REWIND_BUTTON: wii_rewind_add_buttons ^= 1; break; case NODETYPE_WIIMOTE_MENU_ORIENT: wii_mote_menu_vertical ^= 1; break; case NODETYPE_DEBUG_MODE: wii_debug ^= 1; break; case NODETYPE_TRAP_FILTER: wii_trap_filter ^= 1; break; case NODETYPE_FILTER: wii_filter ^= 1; break; case NODETYPE_ROOT_DRIVE: case NODETYPE_UPDIR: case NODETYPE_DIR: if( node->node_type == NODETYPE_ROOT_DRIVE ) { char path[WII_MAX_PATH]; snprintf( path, sizeof(path), "%s/", node->name ); wii_set_roms_dir( path ); mount_pending = TRUE; } else if( node->node_type == NODETYPE_UPDIR ) { const char* romsDir = wii_get_roms_dir(); int len = strlen( romsDir ); if( len > 1 && romsDir[len-1] == '/' ) { char dirpart[WII_MAX_PATH] = ""; char filepart[WII_MAX_PATH] = ""; Util_splitpath( romsDir, dirpart, filepart ); len = strlen(dirpart); if( len > 0 ) { dirpart[len] = '/'; dirpart[len+1] = '\0'; } wii_set_roms_dir( dirpart ); } } else { char newDir[WII_MAX_PATH]; snprintf( newDir, sizeof(newDir), "%s%s/", wii_get_roms_dir(), node->name ); wii_set_roms_dir( newDir ); } games_read = FALSE; last_rom_index = 1; break; case NODETYPE_ADVANCED: case NODETYPE_VIDEO_SETTINGS: case NODETYPE_CARTRIDGE_SAVE_STATES: case NODETYPE_LOAD_ROM: wii_menu_push( node ); if( node->node_type == NODETYPE_LOAD_ROM ) { if( games_read ) { wii_menu_move( node, last_rom_index ); } } else if( node->node_type == NODETYPE_CARTRIDGE_SAVE_STATES ) { // Initialize the "current" value prior to displaying // the menu... BOOL foo; wii_snapshot_current( &foo ); } break; case NODETYPE_CARTRIDGE_SETTINGS_CURRENT: { Emulator* emu = emuRegistry.getCurrentEmulator(); if( emu != NULL ) { TREENODE* menu = emu->getMenuManager().getCartridgeSettingsMenu(); if( menu != NULL ) { wii_menu_push( menu ); } } } break; case NODETYPE_EMULATOR_SETTINGS: { Emulator* emu = emuRegistry.getCurrentEmulator(); if( emu != NULL ) { TREENODE* menu = emu->getMenuManager().getEmulatorMenu(); if( menu != NULL ) { wii_menu_push( menu ); } } } break; default: /* do nothing */ break; } UNLOCK_RENDER_MUTEX(); } }
/* * Updates the buffer with the name of the specified node * * node The node * name The name of the specified node * value The value of the specified node */ void wii_menu_handle_get_node_name( TREENODE* node, char *buffer, char* value ) { const char* strmode = NULL; int index; snprintf( buffer, WII_MENU_BUFF_SIZE, "%s", node->name ); switch( node->node_type ) { case NODETYPE_ROOT_DRIVE: { int device; FindDevice( node->name, &device ); switch( device ) { case DEVICE_SD: snprintf( buffer, WII_MENU_BUFF_SIZE, "[%s]", gettextmsg( "SD Card" ) ); break; case DEVICE_USB: snprintf( buffer, WII_MENU_BUFF_SIZE, "[%s]", gettextmsg( "USB Device" ) ); break; case DEVICE_SMB: snprintf( buffer, WII_MENU_BUFF_SIZE, "[%s]", gettextmsg( "Network Share" ) ); break; } } break; case NODETYPE_DIR: snprintf( buffer, WII_MENU_BUFF_SIZE, "[%s]", node->name ); break; case NODETYPE_CARTRIDGE_SAVE_STATES_SLOT: { BOOL isLatest; int current = wii_snapshot_current( &isLatest ); current++; if( !isLatest ) { snprintf( value, WII_MENU_BUFF_SIZE, "%d", current ); } else { snprintf( value, WII_MENU_BUFF_SIZE, "%d (%s)", current, gettextmsg( "Latest" ) ); } } break; case NODETYPE_EMULATOR_SETTINGS: snprintf( buffer, WII_MENU_BUFF_SIZE, "%s (%s)", gettextmsg(node->name), gettextmsg(emuRegistry.getCurrentEmulator()->getName()) ); break; case NODETYPE_SELECT_LANG: snprintf( value, WII_MENU_BUFF_SIZE, "%s", language_menu->children[language_index]->name ); break; case NODETYPE_FULL_WIDESCREEN: snprintf( value, WII_MENU_BUFF_SIZE, "%s", ( wii_full_widescreen == WS_AUTO ? "(auto)" : ( wii_full_widescreen ? "Enabled" : "Disabled" ) ) ); break; case NODETYPE_GX_VI_SCALER: snprintf( value, WII_MENU_BUFF_SIZE, "%s", ( wii_gx_vi_scaler ? "GX + VI" : "GX" ) ); break; case NODETYPE_VOLUME: snprintf( value, WII_MENU_BUFF_SIZE, "%d %s", ( wii_volume / 10 ), ( wii_volume == 100 ? gettextmsg("(normal)") : "" ) ); break; case NODETYPE_REWIND_BUTTON: snprintf( value, WII_MENU_BUFF_SIZE, "%s", wii_rewind_add_buttons ? "Auto" : "Manual" ); break; case NODETYPE_DEBUG_MODE: case NODETYPE_TOP_MENU_EXIT: case NODETYPE_FILTER: case NODETYPE_VSYNC: case NODETYPE_AUTO_LOAD_SAVE: case NODETYPE_DOUBLE_STRIKE: case NODETYPE_CHEATS: case NODETYPE_TRAP_FILTER: case NODETYPE_16_9_CORRECTION: case NODETYPE_REWIND: { BOOL enabled = FALSE; switch( node->node_type ) { case NODETYPE_REWIND: enabled = wii_rewind; break; case NODETYPE_16_9_CORRECTION: enabled = wii_16_9_correction; break; case NODETYPE_TRAP_FILTER: enabled = wii_trap_filter; break; case NODETYPE_DOUBLE_STRIKE: enabled = wii_double_strike_mode; break; case NODETYPE_CHEATS: enabled = wii_cheats; break; case NODETYPE_AUTO_LOAD_SAVE: enabled = wii_auto_load_save_state; break; case NODETYPE_VSYNC: enabled = ( wii_vsync == VSYNC_ENABLED ); break; case NODETYPE_DEBUG_MODE: enabled = wii_debug; break; case NODETYPE_FILTER: enabled = wii_filter; break; case NODETYPE_TOP_MENU_EXIT: enabled = wii_top_menu_exit; break; default: /* do nothing */ break; } snprintf( value, WII_MENU_BUFF_SIZE, "%s", enabled ? "Enabled" : "Disabled" ); break; } case NODETYPE_WIIMOTE_MENU_ORIENT: if( wii_mote_menu_vertical ) { strmode="Upright"; } else { strmode="Sideways"; } snprintf( value, WII_MENU_BUFF_SIZE, "%s", strmode ); break; default: { Emulator* emu = emuRegistry.getCurrentEmulator(); if( emu != NULL ) { emu->getMenuManager().getNodeName( node, buffer, value ); } } break; } }