Skip to content

Commit

Permalink
Display distance to mission objective as a real distance
Browse files Browse the repository at this point in the history
  • Loading branch information
RenechCDDA committed Jun 13, 2024
1 parent 62b7550 commit b41f32f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/mission_ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "translations.h"
#include "ui.h"
#include "ui_manager.h"
#include "units_utility.h"
#include "cata_imgui.h"
#include "imgui/imgui.h"

Expand Down Expand Up @@ -306,6 +307,13 @@ void mission_ui_impl::draw_selected_description( std::vector<mission *> missions
// Below is done instead of a table for the benefit of right-to-left languages
//~Extra padding spaces in the English text are so that the replaced string vertically aligns with the one above
draw_colored_text( string_format( _( "You: %s" ), pos.to_string() ), c_white );
int omt_distance = rl_dist( pos, miss->get_target() );
if( omt_distance > 0 ) {
// One OMT is 24 tiles across, at 1x1 meters each, so we can simply do number of OMTs * 24
units::length actual_distance = omt_distance * 24_meter;
draw_colored_text( string_format( _( "Distance: %d %s" ), convert_length( actual_distance ),
length_units( actual_distance ) ), c_white );
}
}
}

Expand Down
3 changes: 3 additions & 0 deletions src/overmap_ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
#include "ui_manager.h"
#include "uistate.h"
#include "units.h"
#include "units_utility.h"
#include "vehicle.h"
#include "vpart_position.h"
#include "weather_gen.h"
Expand Down Expand Up @@ -1170,6 +1171,8 @@ static void draw_om_sidebar(
const int distance = rl_dist( center, target );
mvwprintz( wbar, point( 1, ++lines ), c_white, _( "Distance to current objective:" ) );
mvwprintz( wbar, point( 1, ++lines ), c_white, _( "%d tiles" ), distance );
// One OMT is 24 tiles across, at 1x1 meters each, so we can simply do number of OMTs * 24
mvwprintz( wbar, point( 1, ++lines ), c_white, _( "%s" ), length_to_string( distance * 24_meter ) );

const int above_below = target.z() - orig.z();
std::string msg;
Expand Down

0 comments on commit b41f32f

Please sign in to comment.