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

Debug menu fixes #21053

merged 9 commits into from
May 27, 2017

Conversation

Qrox
Copy link
Contributor

@Qrox Qrox commented May 19, 2017

Fixes several issues with regard to the debug menu:

  1. When wishing for items, items are granted even if the player cancels inputing item count;
  2. Container name is not shown when inputing item count, which may cause the player to assume the game is asking for content count, but end up with many full containers;
  3. Selecting "cancel" when changing the weather will cause the weather to change to an invalid value;
  4. Vehicle spawning menu is not cancelable by pressing ESC;
  5. Some debug UIs does not use input context to generate keybinding text.
  6. Some debug UIs uses hardcoded keypress value as exit conditions.

src/wish.cpp Outdated
@@ -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, string_format( _( "[%s] find, [%s] quit" ),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mvwprintw does formatting, no need to invoke string_format. Actually, this can cause trouble if the formatted string contains a '%', which is interpreted by mvwprintw and expects another (missing) argument.

src/wish.cpp Outdated
mvwprintw( w_info, getmaxy( w_info ) - 2, 0,
_( "[/] find, [f]riendly, [h]allucination, [i]ncrease group, [d]ecrease group, [q]uit" ) );
string_format(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same problem here: mvwprintw does formatting on its own.

src/wish.cpp Outdated
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,
string_format( _( "[%s] find, [f] container, [%s] quit" ),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here.

src/wish.cpp Outdated
@@ -476,36 +485,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( dynamic_cast<wish_item_callback *>( wmenu.callback )->incontainer ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't you use the callback object cb directly? That way you won't need the dynamic_cast.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, I actually moved these code here from a latter place. I'll see if I can improve it.

@Leland
Copy link
Contributor

Leland commented May 23, 2017

This will fix 2 of 3 remaining items in #17889.

@kevingranade kevingranade merged commit e3a561d into CleverRaven:master May 27, 2017
@Qrox Qrox deleted the debug-menu-fix branch May 27, 2017 05:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants