diff --git a/data/json/mapgen/hazardous_waste_sarcophagus.json b/data/json/mapgen/hazardous_waste_sarcophagus.json index b94baa72cb922..21b9f73f80cc7 100644 --- a/data/json/mapgen/hazardous_waste_sarcophagus.json +++ b/data/json/mapgen/hazardous_waste_sarcophagus.json @@ -155,7 +155,6 @@ { "monster": "mon_hazmatbot", "x": 26, "y": 37 }, { "monster": "mon_hazmatbot", "x": 22, "y": 29 } ], - "//": "There is 4th security reminder with name 'Security Reminder [1058]' and action 'sr4_mess'. Add it when our computer UI will support more than 9 options.", "computers": { "5": { "name": "SRCF Security Terminal", @@ -164,6 +163,7 @@ { "name": "Security Reminder [1055]", "action": "sr1_mess" }, { "name": "Security Reminder [1056]", "action": "sr2_mess" }, { "name": "Security Reminder [1057]", "action": "sr3_mess" }, + { "name": "Security Reminder [1058]", "action": "sr4_mess" }, { "name": "EPA: Report All Potential Containment Breaches [3873643]", "action": "srcf_1_mess" }, { "name": "SRCF: Internal Memo, EPA [2918024]", "action": "srcf_2_mess" }, { "name": "CDC: Internal Memo, Standby [2918115]", "action": "srcf_3_mess" }, diff --git a/src/computer.cpp b/src/computer.cpp index ec996580a8aee..8cf29e1ef0b65 100644 --- a/src/computer.cpp +++ b/src/computer.cpp @@ -206,54 +206,46 @@ void computer::use() } // Main computer loop + int sel = 0; while( true ) { - //reset_terminal(); size_t options_size = options.size(); - print_newline(); - print_line( "%s - %s", _( name ), _( "Root Menu" ) ); -#if defined(__ANDROID__) - input_context ctxt( "COMPUTER_MAINLOOP" ); -#endif + + uilist computer_menu; + computer_menu.text = string_format( _( "%s - Root Menu" ), name ); + computer_menu.selected = sel; + computer_menu.fselected = sel; + for( size_t i = 0; i < options_size; i++ ) { - print_line( "%d - %s", i + 1, _( options[i].name ) ); -#if defined(__ANDROID__) - ctxt.register_manual_key( '1' + i, options[i].name ); -#endif + computer_menu.addentry( i, true, MENU_AUTOASSIGN, options[i].name ); } - print_line( "Q - %s", _( "Quit and Shut Down" ) ); - print_newline(); -#if defined(__ANDROID__) - ctxt.register_manual_key( 'Q', _( "Quit and Shut Down" ) ); -#endif - char ch; - do { - // TODO: use input context - ch = inp_mngr.get_input_event().get_first_input(); - } while( ch != 'q' && ch != 'Q' && ( ch < '1' || ch - '1' >= static_cast( options_size ) ) ); - if( ch == 'q' || ch == 'Q' ) { - break; // Exit from main computer loop - } else { // We selected an option other than quit. - ch -= '1'; // So '1' -> 0; index in options.size() - computer_option current = options[ch]; - // Once you trip the security, you have to roll every time you want to do something - if( ( current.security + ( alerts ) ) > 0 ) { - print_error( _( "Password required." ) ); - if( query_bool( _( "Hack into system?" ) ) ) { - if( !hack_attempt( g->u, current.security ) ) { - activate_random_failure(); - shutdown_terminal(); - return; - } else { - // Successfully hacked function - options[ch].security = 0; - activate_function( current.action ); - } + + computer_menu.query(); + if( computer_menu.ret < 0 || static_cast( computer_menu.ret ) >= options.size() ) { + break; + } + + sel = computer_menu.ret; + computer_option current = options[sel]; + reset_terminal(); + // Once you trip the security, you have to roll every time you want to do something + if( current.security + alerts > 0 ) { + print_error( _( "Password required." ) ); + if( query_bool( _( "Hack into system?" ) ) ) { + if( !hack_attempt( g->u, current.security ) ) { + activate_random_failure(); + shutdown_terminal(); + return; + } else { + // Successfully hacked function + options[sel].security = 0; + activate_function( current.action ); } - } else { // No need to hack, just activate - activate_function( current.action ); } - reset_terminal(); - } // Done processing a selected option. + } else { // No need to hack, just activate + activate_function( current.action ); + } + reset_terminal(); + // Done processing a selected option. } shutdown_terminal(); // This should have been done by now, but just in case.