Verbose terrain names can be specified using terrain.editor_name...

...to be displayed in the editor as "<verbose name>/<common name>
(<underlying>)" (bug #16450)
This commit is contained in:
Ignacio R. Morelle 2010-10-18 00:44:43 +00:00
parent 44c0c283d7
commit e30195e1a6
7 changed files with 66 additions and 12 deletions

View file

@ -9,6 +9,10 @@ Version 1.9.1+svn:
* Fixed scenario 04 not being playable.
* Liberty:
* New (unanimated) sprites for the Rogue Mage unit line.
* Editor:
* Verbose terrain names can be specified using terrain.editor_name to
be displayed in the editor as "<verbose name>/<common name> (<underlying>)"
(bug #16450)
* Graphics:
* Terrain:
* Any Castle or Keep except Dwarvish can now be combined without large gaps

View file

@ -99,7 +99,7 @@ void editor_display::draw_sidebar()
{
// Fill in the terrain report
if(get_map().on_board_with_border(mouseoverHex_)) {
refresh_report(reports::TERRAIN, reports::report(get_map().get_terrain_string(mouseoverHex_)));
refresh_report(reports::TERRAIN, reports::report(get_map().get_terrain_editor_string(mouseoverHex_)));
refresh_report(reports::POSITION, reports::report(lexical_cast<std::string>(mouseoverHex_)));
}
refresh_report(reports::VILLAGES, reports::report(lexical_cast<std::string>(get_map().villages().size())));

View file

@ -37,6 +37,14 @@ static bool is_valid_terrain(t_translation::t_terrain c) {
return !(c == t_translation::VOID_TERRAIN || c == t_translation::FOGGED);
}
static const std::string& terrain_display_name(const terrain_type& t_info)
{
if(t_info.editor_name().empty()) {
return t_info.name();
}
return t_info.editor_name();
}
terrain_group::terrain_group(const config& cfg, display& gui):
id(cfg["id"]), name(cfg["name"].t_str()),
button(gui.video(), "", gui::button::TYPE_CHECK, cfg["icon"]),
@ -98,6 +106,7 @@ terrain_palette::terrain_palette(display &gui, const size_specs &sizes,
foreach (const t_translation::t_terrain& t, terrains_) {
const terrain_type& t_info = map().get_terrain_info(t);
DBG_ED << "Palette: processing terrain " << t_info.name()
<< "(editor name: '" << t_info.editor_name() << "') "
<< "(" << t_info.number() << ")"
<< ": " << t_info.editor_group() << "\n";
@ -302,7 +311,8 @@ void terrain_palette::update_selected_terrains()
std::string terrain_palette::get_terrain_string(const t_translation::t_terrain t)
{
std::stringstream str;
const std::string& name = map().get_terrain_info(t).name();
const std::string& name = terrain_display_name(map().get_terrain_info(t));
const t_translation::t_list& underlying = map().underlying_union_terrain(t);
str << name;
if(underlying.size() != 1 || underlying[0] != t) {
@ -310,7 +320,7 @@ std::string terrain_palette::get_terrain_string(const t_translation::t_terrain t
for(t_translation::t_list::const_iterator i = underlying.begin();
i != underlying.end(); ++i) {
str << map().get_terrain_info(*i).name();
str << terrain_display_name(map().get_terrain_info(*i));
if(i+1 != underlying.end()) {
str << ",";
}
@ -501,7 +511,7 @@ void terrain_palette::draw(bool force) {
draw_rectangle(dstrect.x, dstrect.y, image->w, image->h, color, screen);
bool is_core = non_core_terrains_.find(terrain) == non_core_terrains_.end();
tooltip_text << map().get_terrain_string(terrain);
tooltip_text << map().get_terrain_editor_string(terrain);
if (gui_.get_draw_terrain_codes()) {
tooltip_text << " - " << terrain;
}

View file

@ -82,23 +82,53 @@ const t_translation::t_list& gamemap::underlying_union_terrain(t_translation::t_
}
}
std::string gamemap::get_terrain_string(const t_translation::t_terrain& terrain) const
{
std::stringstream ss;
const std::string& name = get_terrain_info(terrain).description();
std::string str =
get_terrain_info(terrain).description();
str += " ";
str += get_underlying_terrain_string(terrain);
return str;
}
std::string gamemap::get_terrain_editor_string(const t_translation::t_terrain& terrain) const
{
std::string str =
get_terrain_info(terrain).editor_name();
if(str != get_terrain_info(terrain).description()) {
str += "/";
str += get_terrain_info(terrain).description();
}
str += " ";
str += get_underlying_terrain_string(terrain);
return str;
}
std::string gamemap::get_underlying_terrain_string(const t_translation::t_terrain& terrain) const
{
std::string str;
const t_translation::t_list& underlying = underlying_union_terrain(terrain);
assert(!underlying.empty());
ss << name;
if(underlying.size() > 1 || underlying[0] != terrain) {
ss << " (";
str += "(";
t_translation::t_list::const_iterator i = underlying.begin();
ss << get_terrain_info(*i).name();
str += get_terrain_info(*i).name();
while (++i != underlying.end()) {
ss << "," << get_terrain_info(*i).name();
str += "," + get_terrain_info(*i).name();
}
ss << ")";
str += ")";
}
return ss.str();
return str;
}
void gamemap::write_terrain(const map_location &loc, config& cfg) const

View file

@ -51,6 +51,8 @@ public:
* Get a formatted terrain name -- terrain (underlying, terrains)
*/
std::string get_terrain_string(const t_translation::t_terrain& terrain) const;
std::string get_terrain_editor_string(const t_translation::t_terrain& terrain) const;
std::string get_underlying_terrain_string(const t_translation::t_terrain& terrain) const;
const t_translation::t_list& underlying_mvt_terrain(const map_location& loc) const
{ return underlying_mvt_terrain(get_terrain(loc)); }
@ -60,6 +62,8 @@ public:
{ return underlying_union_terrain(get_terrain(loc)); }
std::string get_terrain_string(const map_location& loc) const
{ return get_terrain_string(get_terrain(loc)); }
std::string get_terrain_editor_string(const map_location& loc) const
{ return get_terrain_editor_string(get_terrain(loc)); }
bool is_village(t_translation::t_terrain terrain) const
{ return get_terrain_info(terrain).is_village(); }
int gives_healing(t_translation::t_terrain terrain) const

View file

@ -36,6 +36,7 @@ terrain_type::terrain_type() :
editor_image_(),
id_(),
name_(),
editor_name_(),
description_(),
number_(t_translation::VOID_TERRAIN),
mvt_type_(1, t_translation::VOID_TERRAIN),
@ -67,6 +68,7 @@ terrain_type::terrain_type(const config& cfg) :
editor_image_(cfg["editor_image"]),
id_(cfg["id"]),
name_(cfg["name"].t_str()),
editor_name_(cfg["editor_name"].t_str()),
description_(cfg["description"].t_str()),
number_(t_translation::read_terrain_code(cfg["string"])),
mvt_type_(),
@ -178,6 +180,7 @@ terrain_type::terrain_type(const terrain_type& base, const terrain_type& overlay
editor_image_(overlay.editor_image_),
id_(base.id_+"^"+overlay.id_),
name_(overlay.name_),
editor_name_(overlay.editor_name_),
description_(overlay.description_),
number_(t_translation::t_terrain(base.number_.base, overlay.number_.overlay)),
mvt_type_(overlay.mvt_type_),
@ -261,6 +264,7 @@ bool terrain_type::operator==(const terrain_type& other) const {
&& editor_image_ == other.editor_image_
&& id_ == other.id_
&& name_.base_str() == other.name_.base_str()
&& editor_name_.base_str() == other.editor_name_.base_str()
&& number_ == other.number_
&& height_adjust_ == other.height_adjust_
&& height_adjust_set_ == other.height_adjust_set_

View file

@ -34,6 +34,7 @@ public:
const std::string& minimap_image_overlay() const { return minimap_image_overlay_; }
const std::string& editor_image() const { return editor_image_; }
const t_string& name() const { return name_; }
const t_string& editor_name() const { return editor_name_.empty() ? description() : editor_name_; }
const t_string& description() const { return description_.empty() ? name_ : description_; }
const std::string& id() const { return id_; }
@ -88,6 +89,7 @@ private:
std::string editor_image_;
std::string id_;
t_string name_;
t_string editor_name_;
t_string description_;
//the 'number' is the number that represents this