Skip to content

Commit

Permalink
rewrite V menu
Browse files Browse the repository at this point in the history
  • Loading branch information
mqrause committed Jan 8, 2025
1 parent 92f70f2 commit 032f2ce
Show file tree
Hide file tree
Showing 15 changed files with 1,915 additions and 37 deletions.
26 changes: 13 additions & 13 deletions data/raw/keybindings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2487,7 +2487,7 @@
},
{
"type": "keybinding",
"name": "List all items around the player",
"name": "List nearby items, monsters, terrain and furniture",
"category": "DEFAULTMODE",
"id": "listitems",
"bindings": [ { "input_method": "keyboard_char", "key": "V" }, { "input_method": "keyboard_code", "key": "v", "mod": [ "shift" ] } ]
Expand Down Expand Up @@ -3297,21 +3297,21 @@
{
"type": "keybinding",
"id": "SCROLL_ITEM_INFO_UP",
"category": "LIST_ITEMS",
"category": "LIST_SURROUNDINGS",
"name": "Scroll item info up",
"bindings": [ { "input_method": "keyboard_char", "key": "<" }, { "input_method": "keyboard_code", "key": ",", "mod": [ "shift" ] } ]
},
{
"type": "keybinding",
"id": "SCROLL_ITEM_INFO_DOWN",
"category": "LIST_ITEMS",
"category": "LIST_SURROUNDINGS",
"name": "Scroll item info down",
"bindings": [ { "input_method": "keyboard_char", "key": ">" }, { "input_method": "keyboard_code", "key": ".", "mod": [ "shift" ] } ]
},
{
"type": "keybinding",
"id": "COMPARE",
"category": "LIST_ITEMS",
"category": "LIST_SURROUNDINGS",
"name": "Compare",
"bindings": [
{ "input_method": "keyboard_char", "key": "I" },
Expand All @@ -3324,7 +3324,7 @@
{
"type": "keybinding",
"id": "EXAMINE",
"category": "LIST_ITEMS",
"category": "LIST_SURROUNDINGS",
"name": "Examine",
"bindings": [
{ "input_method": "keyboard_any", "key": "e" },
Expand All @@ -3335,7 +3335,7 @@
{
"type": "keybinding",
"id": "PRIORITY_INCREASE",
"category": "LIST_ITEMS",
"category": "LIST_SURROUNDINGS",
"name": "Increase priority",
"bindings": [
{ "input_method": "keyboard_any", "key": "=" },
Expand All @@ -3346,14 +3346,14 @@
{
"type": "keybinding",
"id": "PRIORITY_DECREASE",
"category": "LIST_ITEMS",
"category": "LIST_SURROUNDINGS",
"name": "Decrease priority",
"bindings": [ { "input_method": "keyboard_any", "key": "-" }, { "input_method": "keyboard_code", "key": "KEYPAD_MINUS" } ]
},
{
"type": "keybinding",
"id": "SORT",
"category": "LIST_ITEMS",
"category": "LIST_SURROUNDINGS",
"name": "Change sort order",
"bindings": [
{ "input_method": "keyboard_any", "key": "s" },
Expand All @@ -3364,36 +3364,36 @@
{
"type": "keybinding",
"id": "SAFEMODE_BLACKLIST_ADD",
"category": "LIST_MONSTERS",
"category": "LIST_SURROUNDINGS",
"name": "Add to safe mode blacklist",
"bindings": [ { "input_method": "keyboard_any", "key": "a" } ]
},
{
"type": "keybinding",
"id": "SAFEMODE_BLACKLIST_REMOVE",
"category": "LIST_MONSTERS",
"category": "LIST_SURROUNDINGS",
"name": "Remove from safe mode blacklist",
"bindings": [ { "input_method": "keyboard_any", "key": "r" } ]
},
{
"type": "keybinding",
"id": "look",
"category": "LIST_MONSTERS",
"category": "LIST_SURROUNDINGS",
"name": "Look around",
"bindings": [ { "input_method": "keyboard_any", "key": "x" } ]
},
{
"type": "keybinding",
"id": "fire",
"category": "LIST_MONSTERS",
"category": "LIST_SURROUNDINGS",
"name": { "ctxt": "verb", "str": "Fire" },
"bindings": [ { "input_method": "keyboard_any", "key": "f" } ]
},
{
"type": "keybinding",
"id": "LIST_ITEMS",
"category": "LOOK",
"name": "List items and monsters",
"name": "List nearby items, monsters, terrain and furniture",
"bindings": [ { "input_method": "keyboard_char", "key": "V" }, { "input_method": "keyboard_code", "key": "v", "mod": [ "shift" ] } ]
},
{
Expand Down
39 changes: 24 additions & 15 deletions src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@
#include "stats_tracker.h"
#include "string_formatter.h"
#include "string_input_popup.h"
#include "surroundings_menu.h"
#include "talker.h"
#include "text_snippets.h"
#include "tileray.h"
Expand Down Expand Up @@ -7871,7 +7872,7 @@ look_around_result game::look_around(
blink = !blink;
}
if( action == "LIST_ITEMS" ) {
list_items_monsters();
list_surroundings();
} else if( action == "TOGGLE_FAST_SCROLL" ) {
fast_scroll = !fast_scroll;
} else if( action == "map" ) {
Expand Down Expand Up @@ -8352,7 +8353,7 @@ void game::reset_item_list_state( const catacurses::window &window, int height,
}
}

void game::list_items_monsters()
void game::list_surroundings()
{
// Search whole reality bubble because each function internally verifies
// the visibility of the items / monsters in question.
Expand Down Expand Up @@ -8387,19 +8388,27 @@ void game::list_items_monsters()
}

temp_exit_fullscreen();
game::vmenu_ret ret;
while( true ) {
ret = uistate.vmenu_show_items ? list_items( items ) : list_monsters( mons );
if( ret == game::vmenu_ret::CHANGE_TAB ) {
uistate.vmenu_show_items = !uistate.vmenu_show_items;
} else {
break;
}
}

if( ret == game::vmenu_ret::FIRE ) {
avatar_action::fire_wielded_weapon( u );
}
std::optional<tripoint_bub_ms> path_start = u.pos_bub();
std::optional<tripoint_bub_ms> path_end = std::nullopt;
surroundings_menu vmenu( u, m, path_end, 55 );
shared_ptr_fast<draw_callback_t> trail_cb = create_trail_callback( path_start, path_end, true );
add_draw_callback( trail_cb );
vmenu.execute();
//} else {
// game::vmenu_ret ret;
// while( true ) {
// ret = uistate.vmenu_show_items ? list_items( items ) : list_monsters( mons );
// if( ret == game::vmenu_ret::CHANGE_TAB ) {
// uistate.vmenu_show_items = !uistate.vmenu_show_items;
// } else {
// break;
// }
// }

// if( ret == game::vmenu_ret::FIRE ) {
// avatar_action::fire_wielded_weapon( u );
// }
//}
reenter_fullscreen();
}

Expand Down
2 changes: 1 addition & 1 deletion src/game.h
Original file line number Diff line number Diff line change
Expand Up @@ -872,7 +872,7 @@ class game
const vproto_id &id, const point_abs_omt &origin, int min_distance,
int max_distance, const std::vector<std::string> &omt_search_types = {} );
// V Menu Functions and helpers:
void list_items_monsters(); // Called when you invoke the `V`-menu
void list_surroundings(); // Called when you invoke the `V`-menu

enum class vmenu_ret : int {
CHANGE_TAB,
Expand Down
2 changes: 1 addition & 1 deletion src/handle_action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2541,7 +2541,7 @@ bool game::do_regular_action( action_id &act, avatar &player_character,
break;

case ACTION_LIST_ITEMS:
list_items_monsters();
list_surroundings();
break;

case ACTION_ZONES:
Expand Down
8 changes: 7 additions & 1 deletion src/inventory_ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ void uistatedata::deserialize( const JsonObject &jo )
v.push_back( line );
}
}
// fetch list_item settings from input_history
// fetch surroundings menu settings from input_history
if( !gethistory( "item_filter" ).empty() ) {
list_item_filter = gethistory( "item_filter" ).back();
}
Expand All @@ -512,6 +512,12 @@ void uistatedata::deserialize( const JsonObject &jo )
if( !gethistory( "list_item_priority" ).empty() ) {
list_item_priority = gethistory( "list_item_priority" ).back();
}
if( !gethistory( "monster_filter" ).empty() ) {
monster_filter = gethistory( "monster_filter" ).back();
}
if( !gethistory( "terfurn_filter" ).empty() ) {
terfurn_filter = gethistory( "terfurn_filter" ).back();
}

jo.read( "lastreload", lastreload );
}
Expand Down
Loading

0 comments on commit 032f2ce

Please sign in to comment.