-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Display ordered NPC path on map, move TALK_GOTO_LOCATION to top-level menu #74093
Changes from 5 commits
9002770
bd83f68
06b458d
2e80177
65b284d
0d6eb29
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -538,7 +538,8 @@ | |
static void draw_ascii( | ||
const catacurses::window &w, const tripoint_abs_omt ¢er, | ||
const tripoint_abs_omt &orig, bool blink, bool show_explored, bool /* fast_scroll */, | ||
input_context * /* inp_ctxt */, const draw_data_t &data ) | ||
input_context * /* inp_ctxt */, const draw_data_t &data, | ||
std::vector<tripoint_abs_omt> display_path ) | ||
Check failure on line 542 in src/overmap_ui.cpp GitHub Actions / build (src)
|
||
{ | ||
|
||
const int om_map_width = OVERMAP_WINDOW_WIDTH; | ||
|
@@ -689,6 +690,11 @@ | |
npc *npc_to_add = npc_to_get.get(); | ||
followers.push_back( npc_to_add ); | ||
} | ||
if( !display_path.empty() ) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because this is technically passed different data than the tile overmaps, future changes could accidentally knock them out of sync. It would be ideal to NOT have these be different, but the kludge in game.h is not something I want to rely on. That is why they are still different. But having them be different at all is another problem... |
||
for( auto &elem : display_path ) { | ||
npc_path_route.insert( elem ); | ||
} | ||
} | ||
// get all traveling NPCs for the debug menu to show pathfinding routes. | ||
if( g->debug_pathfinding ) { | ||
for( auto &elem : overmap_buffer.get_npcs_near_player( 200 ) ) { | ||
|
@@ -1257,7 +1263,7 @@ | |
static void draw( | ||
ui_adaptor &ui, const tripoint_abs_omt ¢er, const tripoint_abs_omt &orig, | ||
bool blink, bool show_explored, bool fast_scroll, | ||
input_context *inp_ctxt, const draw_data_t &data ) | ||
input_context *inp_ctxt, const draw_data_t &data, std::vector<tripoint_abs_omt> display_path ) | ||
{ | ||
draw_om_sidebar( ui, g->w_omlegend, center, orig, blink, fast_scroll, inp_ctxt, data ); | ||
#if defined( TILES ) | ||
|
@@ -1269,7 +1275,8 @@ | |
return; | ||
} | ||
#endif // TILES | ||
draw_ascii( g->w_overmap, center, orig, blink, show_explored, fast_scroll, inp_ctxt, data ); | ||
draw_ascii( g->w_overmap, center, orig, blink, show_explored, fast_scroll, inp_ctxt, data, | ||
display_path ); | ||
} | ||
|
||
static void create_note( const tripoint_abs_omt &curs ) | ||
|
@@ -1773,7 +1780,7 @@ | |
} | ||
|
||
static tripoint_abs_omt display( const tripoint_abs_omt &orig, | ||
const draw_data_t &data = draw_data_t() ) | ||
const draw_data_t &data = draw_data_t(), std::vector<tripoint_abs_omt> display_path = {} ) | ||
{ | ||
const int previous_zoom = g->get_zoom(); | ||
g->set_zoom( overmap_zoom_level ); | ||
|
@@ -1861,10 +1868,13 @@ | |
int fast_scroll_offset = get_option<int>( "FAST_SCROLL_OFFSET" ); | ||
std::optional<tripoint> mouse_pos; | ||
std::chrono::time_point<std::chrono::steady_clock> last_blink = std::chrono::steady_clock::now(); | ||
std::chrono::time_point<std::chrono::steady_clock> last_advance = std::chrono::steady_clock::now(); | ||
auto display_path_iter = display_path.rbegin(); | ||
std::chrono::milliseconds cursor_advance_time = std::chrono::milliseconds( 0 ); | ||
|
||
ui.on_redraw( [&]( ui_adaptor & ui ) { | ||
draw( ui, curs, orig, uistate.overmap_show_overlays, | ||
show_explored, fast_scroll, &ictxt, data ); | ||
show_explored, fast_scroll, &ictxt, data, display_path ); | ||
} ); | ||
|
||
do { | ||
|
@@ -1880,6 +1890,22 @@ | |
#else | ||
action = ictxt.handle_input( get_option<int>( "BLINK_SPEED" ) ); | ||
#endif | ||
if( !display_path.empty() ) { | ||
std::chrono::time_point<std::chrono::steady_clock> now = std::chrono::steady_clock::now(); | ||
// We go faster per-tile the more we have to go | ||
cursor_advance_time = std::chrono::milliseconds( 1000 ) / display_path.size(); | ||
cursor_advance_time = std::max( cursor_advance_time, std::chrono::milliseconds( 1 ) ); | ||
if( now > last_advance + cursor_advance_time ) { | ||
if( display_path_iter != display_path.rend() ) { | ||
curs = *display_path_iter; | ||
last_advance = now; | ||
display_path_iter++; | ||
} else if( now > last_advance + cursor_advance_time * 10 ) { | ||
action = "QUIT"; | ||
break; | ||
} | ||
} | ||
} | ||
if( const std::optional<tripoint> vec = ictxt.get_direction( action ) ) { | ||
int scroll_d = fast_scroll ? fast_scroll_offset : 1; | ||
curs += vec->xy() * scroll_d; | ||
|
@@ -2053,6 +2079,12 @@ | |
overmap_ui::display( get_player_character().global_omt_location(), overmap_ui::draw_data_t() ); | ||
} | ||
|
||
void ui::omap::display_npc_path( tripoint_abs_omt starting_pos, | ||
std::vector<tripoint_abs_omt> display_path ) | ||
{ | ||
overmap_ui::display( starting_pos, overmap_ui::draw_data_t(), display_path ); | ||
} | ||
|
||
void ui::omap::display_hordes() | ||
{ | ||
overmap_ui::draw_data_t data; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really don't like this but the only alternative I see is passing display_path into a long chain of functions to get it to show up for tile overmaps.