Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debug menu fixes #21053

Merged
merged 9 commits into from
May 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4082,8 +4082,6 @@ void game::debug()
_( "Quit to Main Menu" ), // 33
_( "Cancel" ),
NULL );
int veh_num;
std::vector<std::string> opts;
refresh_all();
switch( action ) {
case 1:
Expand Down Expand Up @@ -4172,21 +4170,24 @@ void game::debug()
debugmsg( "There's already vehicle here" );
} else {
std::vector<vproto_id> veh_strings;
uimenu veh_menu;
veh_menu.text = _( "Choose vehicle to spawn" );
veh_menu.return_invalid = true;
int menu_ind = 0;
for( auto & elem : vehicle_prototype::get_all() ) {
if( elem != vproto_id( "custom" ) ) {
const vehicle_prototype &proto = elem.obj();
veh_strings.push_back( elem );
//~ Menu entry in vehicle wish menu: 1st string: displayed name, 2nd string: internal name of vehicle
opts.push_back( string_format( _( "%1$s (%2$s)" ), _( proto.name.c_str() ),
elem.c_str() ) );
veh_menu.addentry( menu_ind, true, MENU_AUTOASSIGN, _( "%1$s (%2$s)" ), _( proto.name.c_str() ), elem.c_str() );
++menu_ind;
}
}
opts.push_back( std::string( _( "Cancel" ) ) );
veh_num = menu_vec( false, _( "Choose vehicle to spawn" ), opts ) + 1;
veh_num -= 2;
if( veh_num < ( int )opts.size() - 1 ) {
veh_menu.addentry( menu_ind, true, MENU_AUTOASSIGN, _( "Cancel" ) );
veh_menu.query();
if( veh_menu.ret >= 0 && veh_menu.ret < ( int )veh_strings.size() ) {
//Didn't pick Cancel
const vproto_id &selected_opt = veh_strings[veh_num];
const vproto_id &selected_opt = veh_strings[veh_menu.ret];
tripoint dest = u.pos(); // TODO: Allow picking this when add_vehicle has 3d argument
vehicle *veh = m.add_vehicle( selected_opt, dest.x, dest.y, -90, 100, 0 );
if( veh != NULL ) {
Expand Down Expand Up @@ -4261,7 +4262,7 @@ void game::debug()

weather_menu.query();

if( weather_menu.ret >= 0 && weather_menu.ret <= NUM_WEATHER_TYPES ) {
if( weather_menu.ret >= 0 && weather_menu.ret < NUM_WEATHER_TYPES ) {
weather_type selected_weather = ( weather_type )weather_menu.selected;
weather_override = selected_weather;
nextweather = calendar::turn;
Expand Down
64 changes: 38 additions & 26 deletions src/wish.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,9 @@ class wish_mutate_callback: public uimenu_callback

mvwprintz( menu->window, menu->w_height - 3, startx, c_green, "%s", msg.c_str() );
msg = padding;
mvwprintw( menu->window, menu->w_height - 2, startx, _( "[/] find, [q]uit" ) );
input_context ctxt( "UIMENU" );
mvwprintw( menu->window, menu->w_height - 2, startx, _( "[%s] find, [%s] quit" ),
ctxt.get_desc( "FILTER" ).c_str(), ctxt.get_desc( "QUIT" ).c_str() );

};

Expand Down Expand Up @@ -255,7 +257,7 @@ void debug_menu::wishmutate( player *p )
}
}
}
} while( wmenu.keypress != 'q' && wmenu.keypress != KEY_ESCAPE && wmenu.keypress != ' ' );
} while( wmenu.ret >= 0 );
}

class wish_monster_callback: public uimenu_callback
Expand Down Expand Up @@ -334,8 +336,10 @@ class wish_monster_callback: public uimenu_callback

mvwprintz( w_info, getmaxy( w_info ) - 3, 0, c_green, "%s", msg.c_str() );
msg = padding;
input_context ctxt( "UIMENU" );
mvwprintw( w_info, getmaxy( w_info ) - 2, 0,
_( "[/] find, [f]riendly, [h]allucination, [i]ncrease group, [d]ecrease group, [q]uit" ) );
_( "[%s] find, [f]riendly, [h]allucination, [i]ncrease group, [d]ecrease group, [%s] quit" ),
ctxt.get_desc( "FILTER" ).c_str(), ctxt.get_desc( "QUIT" ).c_str() );
}

void refresh( uimenu *menu ) override {
Expand Down Expand Up @@ -395,13 +399,14 @@ void debug_menu::wishmonster( const tripoint &p )
g->add_zombie( mon, true );
}
}
cb.msg = string_format( _( "Spawned %d/%d monsters, choose another or 'q' to quit." ),
num_spawned, int( spawn_points.size() ) );
input_context ctxt( "UIMENU" );
cb.msg = string_format( _( "Spawned %d/%d monsters, choose another or [%s] to quit." ),
num_spawned, int( spawn_points.size() ), ctxt.get_desc( "QUIT" ).c_str() );
uistate.wishmonster_selected = wmenu.ret;
wmenu.redraw();
}
}
} while( wmenu.keypress != 'q' && wmenu.keypress != KEY_ESCAPE && wmenu.keypress != ' ' );
} while( wmenu.ret >= 0 );
}

class wish_item_callback: public uimenu_callback
Expand Down Expand Up @@ -441,7 +446,9 @@ class wish_item_callback: public uimenu_callback
mvwprintz( menu->window, menu->w_height - 3, startx, c_green, "%s", msg.c_str() );
msg.erase();

mvwprintw( menu->window, menu->w_height - 2, startx, _( "[/] find, [f] container, [q]uit" ) );
input_context ctxt( "UIMENU" );
mvwprintw( menu->window, menu->w_height - 2, startx, _( "[%s] find, [f] container, [%s] quit" ),
ctxt.get_desc( "FILTER" ).c_str(), ctxt.get_desc( "QUIT" ).c_str() );
}
};

Expand Down Expand Up @@ -476,36 +483,42 @@ void debug_menu::wishitem( player *p, int x, int y, int z )
wmenu.query();
if( wmenu.ret >= 0 ) {
item granted( opts[wmenu.ret] );
if( cb.incontainer ) {
granted = granted.in_its_container();
}
prev_amount = amount;
bool canceled = false;
if( p != NULL ) {
string_input_popup()
string_input_popup popup;
popup
.title( _( "How many?" ) )
.width( 20 )
.description( granted.tname() )
.edit( amount );
canceled = popup.canceled();
}
if( dynamic_cast<wish_item_callback *>( wmenu.callback )->incontainer ) {
granted = granted.in_its_container();
}
if( p != NULL ) {
for( int i = 0; i < amount; i++ ) {
p->i_add( granted );
if( !canceled ) {
if( p != NULL ) {
for( int i = 0; i < amount; i++ ) {
p->i_add( granted );
}
p->invalidate_crafting_inventory();
} else if( x >= 0 && y >= 0 ) {
g->m.add_item_or_charges( tripoint( x, y, z ), granted );
wmenu.ret = -1;
}
if( amount > 0 ) {
input_context ctxt( "UIMENU" );
cb.msg = string_format( _( "Wish granted. Wish for more or hit [%s] to quit." ),
ctxt.get_desc( "QUIT" ).c_str() );
}
p->invalidate_crafting_inventory();
} else if( x >= 0 && y >= 0 ) {
g->m.add_item_or_charges( tripoint( x, y, z ), granted );
wmenu.keypress = 'q';
}
if( amount > 0 ) {
dynamic_cast<wish_item_callback *>( wmenu.callback )->msg =
_( "Wish granted. Wish for more or hit 'q' to quit." );
}
uistate.wishitem_selected = wmenu.ret;
if( !amount ) {
if( canceled || amount <= 0 ) {
amount = prev_amount;
}
}
} while( wmenu.keypress != 'q' && wmenu.keypress != KEY_ESCAPE && wmenu.keypress != ' ' );
} while( wmenu.ret >= 0 );
}

/*
Expand Down Expand Up @@ -595,6 +608,5 @@ void debug_menu::wishskill( player *p )
}
}
}
} while( skmenu.ret != -1 && ( skmenu.keypress != 'q' && skmenu.keypress != ' ' &&
skmenu.keypress != KEY_ESCAPE ) );
} while( skmenu.ret >= 0 );
}