Skip to content

Commit

Permalink
Merge pull request CleverRaven#77876 from db48x/popup-input-timeout
Browse files Browse the repository at this point in the history
fix popup messages that show up the wrong size until the next input
  • Loading branch information
Night-Pryanik authored Nov 15, 2024
2 parents a8deffc + f130715 commit d7df3a1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/action.h
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ std::optional<tripoint_bub_ms> choose_adjacent_bub( const std::string &message,
std::optional<tripoint> choose_adjacent( const tripoint &pos, const std::string &message,
bool allow_vertical = false );
std::optional<tripoint_bub_ms> choose_adjacent( const tripoint_bub_ms &pos,
const std::string &message, bool allow_vertical = false, int timeout = -1,
const std::string &message, bool allow_vertical = false, int timeout = 50,
const std::function<std::pair<bool, std::optional<tripoint_bub_ms>>(
const input_context &ctxt, const std::string &action )> &action_cb = nullptr );

Expand Down Expand Up @@ -509,7 +509,7 @@ std::optional<tripoint_bub_ms> choose_adjacent( const tripoint_bub_ms &pos,
std::optional<tripoint> choose_direction( const std::string &message,
bool allow_vertical = false );
std::optional<tripoint_rel_ms> choose_direction_rel_ms( const std::string &message,
bool allow_vertical = false, bool allow_mouse = false, int timeout = -1,
bool allow_vertical = false, bool allow_mouse = false, int timeout = 50,
const std::function<std::pair<bool, std::optional<tripoint_rel_ms>>(
const input_context &ctxt, const std::string &action )> &action_cb = nullptr );

Expand Down
4 changes: 3 additions & 1 deletion src/do_turn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,9 @@ bool do_turn()

// Avoid redrawing the main UI every time due to invalidation
ui_adaptor dummy( ui_adaptor::disable_uis_below {} );
g->wait_popup = std::make_unique<static_popup>();
if( !g->wait_popup ) {
g->wait_popup = std::make_unique<static_popup>();
}
g->wait_popup->on_top( true ).wait_message( "%s", wait_message );
ui_manager::redraw();
refresh_display();
Expand Down
5 changes: 1 addition & 4 deletions src/popup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,16 +317,13 @@ query_popup::result query_popup::query_once()
if( cancel ) {
ctxt.register_action( "QUIT" );
}
#if defined(WIN32) || defined(TILES)
ctxt.set_timeout( 50 );
#endif

result res;
// Assign outside construction of `res` to ensure execution order
res.wait_input = !anykey;
do {
ui_manager::redraw();
res.action = ctxt.handle_input();
res.action = ctxt.handle_input( 50 );
res.evt = ctxt.get_raw_input();

// If we're tracking mouse movement
Expand Down

0 comments on commit d7df3a1

Please sign in to comment.