Skip to content

Commit

Permalink
rewrite V menu
Browse files Browse the repository at this point in the history
  • Loading branch information
mqrause committed Oct 9, 2024
1 parent b65f3e6 commit b90179f
Show file tree
Hide file tree
Showing 13 changed files with 1,734 additions and 36 deletions.
26 changes: 13 additions & 13 deletions data/raw/keybindings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2456,7 +2456,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 @@ -3248,21 +3248,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 @@ -3275,7 +3275,7 @@
{
"type": "keybinding",
"id": "EXAMINE",
"category": "LIST_ITEMS",
"category": "LIST_SURROUNDINGS",
"name": "Examine",
"bindings": [
{ "input_method": "keyboard_any", "key": "e" },
Expand All @@ -3286,7 +3286,7 @@
{
"type": "keybinding",
"id": "PRIORITY_INCREASE",
"category": "LIST_ITEMS",
"category": "LIST_SURROUNDINGS",
"name": "Increase priority",
"bindings": [
{ "input_method": "keyboard_any", "key": "=" },
Expand All @@ -3297,14 +3297,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 @@ -3315,36 +3315,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 @@ -7617,7 +7618,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 @@ -8101,7 +8102,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 @@ -8136,19 +8137,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> path_start = u.pos();
std::optional<tripoint> 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 @@ -889,7 +889,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 @@ -2451,7 +2451,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
Loading

0 comments on commit b90179f

Please sign in to comment.