Skip to content

Commit

Permalink
Allow using magic hotkeys when in other category
Browse files Browse the repository at this point in the history
  • Loading branch information
b3brodie committed Jun 3, 2024
1 parent e90dc11 commit f1787ab
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/magic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2848,7 +2848,7 @@ int known_magic::select_spell( Character &guy )
}
reflesh_favorite( &spell_menu, known_spells );

spell_menu.query();
spell_menu.query(true, -1, true);

casting_ignore = static_cast<spellcasting_callback *>( spell_menu.callback )->casting_ignore;

Expand Down
33 changes: 20 additions & 13 deletions src/ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1029,7 +1029,7 @@ uilist::handle_mouse_result_t uilist::handle_mouse( const input_context &ctxt,
* Handle input and update display
*
*/
void uilist::query( bool loop, int timeout )
void uilist::query( bool loop, int timeout, bool allow_unfiltered_hotkeys )
{
#if defined(__ANDROID__)
bool auto_pos = w_x_setup.fun == nullptr && w_y_setup.fun == nullptr &&
Expand Down Expand Up @@ -1140,19 +1140,26 @@ void uilist::query( bool loop, int timeout )
}
filterlist();
} else if( iter != keymap.end() ) {
const auto it = std::find( fentries.begin(), fentries.end(), iter->second );
if( it != fentries.end() ) {
const bool enabled = entries[*it].enabled;
if( enabled || allow_disabled || hilight_disabled ) {
// Change the selection to display correctly when this function
// is called again.
fselected = std::distance( fentries.begin(), it );
selected = *it;
if( enabled || allow_disabled ) {
ret = entries[selected].retval;
if ( allow_unfiltered_hotkeys ) {
const bool enabled = entries[iter->second].enabled;
if (enabled || allow_disabled) {
ret = entries[iter->second].retval;
}
if( callback != nullptr ) {
callback->select( this );
} else {
const auto it = std::find( fentries.begin(), fentries.end(), iter->second );
if( it != fentries.end() ) {
const bool enabled = entries[*it].enabled;
if( enabled || allow_disabled || hilight_disabled ) {
// Change the selection to display correctly when this function
// is called again.
fselected = std::distance( fentries.begin(), it );
selected = *it;
if( enabled || allow_disabled ) {
ret = entries[selected].retval;
}
if( callback != nullptr ) {
callback->select( this );
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/ui.h
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ class uilist // NOLINT(cata-xy)
void reposition( ui_adaptor &ui );
void show( ui_adaptor &ui );
bool scrollby( int scrollby );
void query( bool loop = true, int timeout = -1 );
void query( bool loop = true, int timeout = -1, bool allow_unfiltered_hotkeys = false );
void filterlist();
// In add_entry/add_entry_desc/add_entry_col, int k only support letters
// (a-z, A-Z) and digits (0-9), MENU_AUTOASSIGN, and 0 or ' ' (disable
Expand Down

0 comments on commit f1787ab

Please sign in to comment.