Skip to content

Commit

Permalink
Merge pull request #76017 from ShnitzelX2/hold-overmap-ui
Browse files Browse the repository at this point in the history
Toggle to Only Draw Overmap During Autotravel
  • Loading branch information
Maleclypse authored Aug 31, 2024
2 parents 738f60f + 958a7d6 commit 88ecaf6
Show file tree
Hide file tree
Showing 13 changed files with 308 additions and 201 deletions.
7 changes: 7 additions & 0 deletions data/raw/keybindings.json
Original file line number Diff line number Diff line change
Expand Up @@ -1192,6 +1192,13 @@
"name": "Toggle forest trails",
"bindings": [ { "input_method": "keyboard_char", "key": "T" }, { "input_method": "keyboard_code", "key": "t", "mod": [ "shift" ] } ]
},
{
"type": "keybinding",
"id": "TOGGLE_FAST_TRAVEL",
"category": "OVERMAP",
"name": "Toggle fast travel",
"bindings": [ { "input_method": "keyboard_char", "key": "x" }, { "input_method": "keyboard_code", "key": "x", "mod": [ "shift" ] } ]
},
{
"type": "keybinding",
"id": "TOGGLE_EXPLORED",
Expand Down
2 changes: 2 additions & 0 deletions src/activity_actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -653,13 +653,15 @@ void autodrive_activity_actor::canceled( player_activity &act, Character &who )
if( player_vehicle ) {
player_vehicle->stop_autodriving( false );
}
ui::omap::force_quit();
act.set_to_null();
}

void autodrive_activity_actor::finish( player_activity &act, Character &who )
{
who.add_msg_if_player( m_info, _( "You have reached your destination." ) );
player_vehicle->stop_autodriving( false );
ui::omap::force_quit();
act.set_to_null();
}

Expand Down
2 changes: 2 additions & 0 deletions src/activity_handlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2903,6 +2903,7 @@ void activity_handlers::travel_do_turn( player_activity *act, Character *you )
if( you->omt_path.empty() ) {
you->add_msg_if_player( m_info, _( "You have reached your destination." ) );
act->set_to_null();
ui::omap::force_quit();
return;
}
const tripoint_abs_omt next_omt = you->omt_path.back();
Expand Down Expand Up @@ -2938,6 +2939,7 @@ void activity_handlers::travel_do_turn( player_activity *act, Character *you )
}
} else {
you->add_msg_if_player( m_info, _( "You have reached your destination." ) );
ui::omap::force_quit();
}
act->set_to_null();
}
Expand Down
6 changes: 3 additions & 3 deletions src/avatar_action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ bool avatar_action::move( avatar &you, map &m, const tripoint &d )
if( you.is_auto_moving() ) {
add_msg( m_warning, _( "Monster in the way. Auto move canceled." ) );
add_msg( m_info, _( "Move into the monster to attack." ) );
you.clear_destination();
you.abort_automove();
return false;
}
if( !you.try_break_relax_gas( _( "Your willpower asserts itself, and so do you!" ),
Expand Down Expand Up @@ -406,7 +406,7 @@ bool avatar_action::move( avatar &you, map &m, const tripoint &d )
if( you.is_auto_moving() ) {
add_msg( _( "NPC in the way, Auto move canceled." ) );
add_msg( m_info, _( "Move into the NPC to interact or attack." ) );
you.clear_destination();
you.abort_automove();
return false;
}

Expand Down Expand Up @@ -460,7 +460,7 @@ bool avatar_action::move( avatar &you, map &m, const tripoint &d )
if( is_riding ) {
if( !you.check_mount_will_move( dest_loc.raw() ) ) {
if( you.is_auto_moving() ) {
you.clear_destination();
you.abort_automove();
}
you.mod_moves( -you.get_speed() * 0.2 );
return false;
Expand Down
10 changes: 9 additions & 1 deletion src/character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1836,7 +1836,7 @@ void Character::forced_dismount()
set_movement_mode( move_mode_walk );
if( player_character.is_auto_moving() || player_character.has_destination() ||
player_character.has_destination_activity() ) {
player_character.clear_destination();
player_character.abort_automove();
}
g->update_map( player_character );
}
Expand Down Expand Up @@ -11292,6 +11292,14 @@ void Character::clear_destination()
next_expected_position = std::nullopt;
}

void Character::abort_automove()
{
clear_destination();
if( g->overmap_data.fast_traveling && is_avatar() ) {
ui::omap::force_quit();
}
}

bool Character::has_distant_destination() const
{
return has_destination() && !get_destination_activity().is_null() &&
Expand Down
2 changes: 2 additions & 0 deletions src/character.h
Original file line number Diff line number Diff line change
Expand Up @@ -3766,6 +3766,8 @@ class Character : public Creature, public visitable
void set_destination( const std::vector<tripoint_bub_ms> &route,
const player_activity &new_destination_activity = player_activity() );
void clear_destination();
//clear_destination(), also closes overmap UI if still open
void abort_automove();
bool has_distant_destination() const;

// true if the player is auto moving, or if the player is going to finish
Expand Down
4 changes: 2 additions & 2 deletions src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1466,7 +1466,7 @@ static bool cancel_auto_move( Character &you, const std::string &text )
g->invalidate_main_ui_adaptor();
if( query_yn( _( "%s Cancel auto move?" ), text ) ) {
add_msg( m_warning, _( "%s Auto move canceled." ), text );
you.clear_destination();
you.abort_automove();
return true;
}
return false;
Expand Down Expand Up @@ -1602,7 +1602,7 @@ bool game::cancel_activity_query( const std::string &text )
}
}
u.cancel_activity();
u.clear_destination();
u.abort_automove();
u.resume_backlog_activity();
return true;
}
Expand Down
4 changes: 4 additions & 0 deletions src/game.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "global_vars.h"
#include "item_location.h"
#include "memory_fast.h"
#include "overmap_ui.h"
#include "pimpl.h"
#include "point.h"
#include "type_id.h"
Expand Down Expand Up @@ -1138,6 +1139,9 @@ class game
catacurses::window w_pixel_minimap; // NOLINT(cata-serialize)
//only a pointer, can refer to w_messages_short or w_messages_long

//overmap UI singleton
overmap_ui::overmap_draw_data_t overmap_data; // NOLINT(cata-serialize)

// View offset based on the driving speed (if any)
// that has been added to u.view_offset,
// Don't write to this directly, always use set_driving_view_offset
Expand Down
6 changes: 3 additions & 3 deletions src/handle_action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2257,13 +2257,13 @@ bool game::do_regular_action( action_id &act, avatar &player_character,
act = player_character.get_next_auto_move_direction();
const point dest_next = get_delta_from_movement_action( act, iso_rotate::yes );
if( dest_next == point_zero ) {
player_character.clear_destination();
player_character.abort_automove();
}
dest_delta = dest_next;
}
if( !avatar_action::move( player_character, m, dest_delta ) ) {
// auto-move should be canceled due to a failed move or obstacle
player_character.clear_destination();
player_character.abort_automove();
}

if( get_option<bool>( "AUTO_FEATURES" ) && get_option<bool>( "AUTO_MOPPING" ) &&
Expand Down Expand Up @@ -3002,7 +3002,7 @@ bool game::handle_action()
act = player_character.get_next_auto_move_direction();
if( act == ACTION_NULL ) {
add_msg( m_info, _( "Auto-move canceled" ) );
player_character.clear_destination();
player_character.abort_automove();
return false;
}
handle_key_blocking_activity();
Expand Down
Loading

0 comments on commit 88ecaf6

Please sign in to comment.