Skip to content

Commit

Permalink
Merge pull request #39477 from ZhilkinSerg/translations-2020-04-11
Browse files Browse the repository at this point in the history
Utilize translation class instead of using raw strings
  • Loading branch information
kevingranade authored Apr 13, 2020
2 parents d925026 + 959c033 commit 1204f64
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/auto_note.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ void auto_note_manager_gui::show()
wprintz( w, c_yellow, " " );
}

wprintz( w, lineColor, "%s", _( cacheEntry.first.name ) );
wprintz( w, lineColor, "%s", cacheEntry.first.name() );

// Print the character this map extra is indicated by on the map
mvwprintz( w, point( 55, i - startPosition ), charColor, "%s", displayChar );
Expand Down
2 changes: 1 addition & 1 deletion src/construction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ construction_id construction_menu( const bool blueprint )
werase( w_list );
// Print new tab listing
// NOLINTNEXTLINE(cata-use-named-point-constants)
mvwprintz( w_con, point( 1, 1 ), c_yellow, "<< %s >>", _( construct_cat[tabindex].name ) );
mvwprintz( w_con, point( 1, 1 ), c_yellow, "<< %s >>", construct_cat[tabindex].name() );
// Determine where in the master list to start printing
calcStartPos( offset, select, w_list_height, constructs.size() );
// Print the constructions between offset and max (or how many will fit)
Expand Down
2 changes: 1 addition & 1 deletion src/construction_category.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const string_id<construction_category> &int_id<construction_category>::id() cons

void construction_category::load( const JsonObject &jo, const std::string & )
{
mandatory( jo, was_loaded, "name", name );
mandatory( jo, was_loaded, "name", _name );
}

size_t construction_category::count()
Expand Down
9 changes: 7 additions & 2 deletions src/construction_category.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <vector>

#include "type_id.h"
#include "translations.h"

class JsonObject;

Expand All @@ -16,9 +17,13 @@ struct construction_category {
construction_category_id id;
bool was_loaded = false;

std::string name;

std::string name() const {
return _name.translated();
}
static size_t count();

private:
translation _name;
};

namespace construction_categories
Expand Down
8 changes: 4 additions & 4 deletions src/map_extras.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3006,8 +3006,8 @@ void apply_function( const string_id<map_extra> &id, map &m, const tripoint &abs
string_format( "%s:%s;<color_yellow>%s</color>: <color_white>%s</color>",
extra.get_symbol(),
get_note_string_from_color( extra.color ),
_( extra.name ),
_( extra.description ) );
extra.name(),
extra.description() );
overmap_buffer.add_note( sm_to_omt_copy( abs_sub ), mx_note );
}
}
Expand Down Expand Up @@ -3084,8 +3084,8 @@ void debug_spawn_test()

void map_extra::load( const JsonObject &jo, const std::string & )
{
mandatory( jo, was_loaded, "name", name );
mandatory( jo, was_loaded, "description", description );
mandatory( jo, was_loaded, "name", _name );
mandatory( jo, was_loaded, "description", _description );
if( jo.has_object( "generator" ) ) {
JsonObject jg = jo.get_object( "generator" );
generator_method = jg.get_enum_value<map_extra_method>( "generator_method",
Expand Down
12 changes: 10 additions & 2 deletions src/map_extras.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "catacharset.h"
#include "color.h"
#include "string_id.h"
#include "translations.h"

class JsonObject;
class map;
Expand All @@ -35,8 +36,6 @@ class map_extra
{
public:
string_id<map_extra> id = string_id<map_extra>::NULL_ID();
std::string name;
std::string description;
std::string generator_id;
map_extra_method generator_method = map_extra_method::null;
bool autonote = false;
Expand All @@ -46,11 +45,20 @@ class map_extra
std::string get_symbol() const {
return utf32_to_utf8( symbol );
}
std::string name() const {
return _name.translated();
}
std::string description() const {
return _description.translated();
}

// Used by generic_factory
bool was_loaded = false;
void load( const JsonObject &jo, const std::string &src );
void check() const;
private:
translation _name;
translation _description;
};

namespace MapExtras
Expand Down

0 comments on commit 1204f64

Please sign in to comment.