Enhanced the terrain symbol handling.

1) Dehardcoded the terrain symbol icon.
2) Use mix colors for mixed terrain in the minimap.
3) Show colored terrain symbol in the help browser.
4) Don't show magenta colored empty symbol for offmap locations.
This commit is contained in:
fendrin 2013-11-30 13:10:11 +01:00
parent a28cfc3fd9
commit 4e3338f90d
6 changed files with 74 additions and 48 deletions

View file

@ -821,19 +821,6 @@ Most units receive 20 to 40% defense in sand."
editor_group=cave
[/terrain_type]
[terrain_type]
symbol_image=symbols/terrain_group_mushrooms_30
id=fungus
name= _ "Fungus"
editor_name= _ "Fungus"
string=Uft
hidden=yes
help_topic_text= _ "<italic>text='Mushroom groves'</italic> are vast underground forests of giant mushrooms,
which thrive in the damp darkness. Most units have trouble negotiating the spongy floor of smaller fungi, but they have plenty of cover behind the larger stalks. Mounted units, however, become completely mired and lack proper freedom of movement in combat. Undead units have a natural affinity for decay and function quite well in mushroom forests.
Most units receive 50% to 60% defense in mushroom groves, whereas cavalry receive only 20%."
[/terrain_type]
[terrain_type]
symbol_image=forest/mushrooms-tile
id=fungus_grove
@ -2212,7 +2199,20 @@ For those who go by land or sea, a bridge is the best of both worlds — for gam
######### these are "virtual" terrain
[terrain_type]
symbol_image=symbols/terrain_group_caves_30
icon_image=symbols/terrain_type_fungus
id=fungus
name= _ "Fungus"
editor_name= _ "Fungus"
string=Uft
hidden=yes
help_topic_text= _ "<italic>text='Mushroom groves'</italic> are vast underground forests of giant mushrooms,
which thrive in the damp darkness. Most units have trouble negotiating the spongy floor of smaller fungi, but they have plenty of cover behind the larger stalks. Mounted units, however, become completely mired and lack proper freedom of movement in combat. Undead units have a natural affinity for decay and function quite well in mushroom forests.
Most units receive 50% to 60% defense in mushroom groves, whereas cavalry receive only 20%."
[/terrain_type]
[terrain_type]
icon_image=symbols/terrain_type_cave
id=cave
name= _ "Cave"
editor_name= _ "Cave"
@ -2227,7 +2227,7 @@ Most units receive 20 to 40% defense in caves, whereas dwarves have 50%."
[/terrain_type]
[terrain_type]
symbol_image=symbols/terrain_group_sand_30
icon_image=symbols/terrain_type_sand
id=sand
name= _ "Sand"
editor_name= _ "Sands"
@ -2240,7 +2240,7 @@ Most units receive 20 to 40% defense in sand."
[/terrain_type]
[terrain_type]
symbol_image=symbols/terrain_group_reef_30
icon_image=symbols/terrain_type_reef
id=reef
name= _ "Coastal Reef"
editor_name= _ "Coastal Reef"
@ -2255,7 +2255,7 @@ Mermen and Naga both receive 70% defense on coastal reefs."
[/terrain_type]
[terrain_type]
symbol_image=symbols/terrain_group_hills_30
icon_image=symbols/terrain_type_hills
id=hills
name= _ "Hills"
editor_name= _ "Hills"
@ -2269,7 +2269,7 @@ Most units have about 50% defense in hills, whereas cavalry are limited to 40%.
[/terrain_type]
[terrain_type]
symbol_image=symbols/terrain_group_swamp_30
icon_image=symbols/terrain_type_swamp_water
id=swamp_water
name= _ "Swamp"
editor_name= _ "Swamp"
@ -2284,7 +2284,7 @@ Most units make do with 30% defense in swamps. Mermen, naga, and saurians all ge
[/terrain_type]
[terrain_type]
symbol_image=symbols/terrain_group_water_shallow_30
icon_image=symbols/terrain_type_shallow_water
id=shallow_water
string=Wst
name= _ "Shallow Water"
@ -2296,7 +2296,7 @@ Most units make do with 20 to 30% defense in shallow water, whereas both naga an
[/terrain_type]
[terrain_type]
symbol_image=symbols/terrain_group_castle_30
icon_image=symbols/terrain_type_castle
id=castle
name= _ "Castle"
editor_name= _ "Castle"
@ -2312,7 +2312,7 @@ Most units have about 60% defense in a castle."
[/terrain_type]
[terrain_type]
symbol_image=symbols/terrain_group_mountains_30
icon_image=symbols/terrain_type_mountains
id=mountains
name= _ "Mountains"
editor_name= _ "Mountains"
@ -2325,7 +2325,7 @@ Most units receive about 60% defense in mountains, whereas Dwarves enjoy 70%."
[/terrain_type]
[terrain_type]
symbol_image=symbols/terrain_group_water_deep_30
icon_image=symbols/terrain_type_deep_water
id=deep_water
name= _ "Deep Water"
editor_name= _ "Deep Water"
@ -2338,7 +2338,7 @@ Mermen and naga both receive 50% defense in deep water, with full movement."
[/terrain_type]
[terrain_type]
symbol_image=symbols/terrain_group_flat_30
icon_image=symbols/terrain_type_flat
id=flat
name= _ "Flat"
editor_name= _ "Flat"
@ -2351,7 +2351,7 @@ Most units have defense of 30 to 40% on grassland."
[/terrain_type]
[terrain_type]
symbol_image=symbols/terrain_group_forest_30
icon_image=symbols/terrain_type_forest
id=forest
name= _ "Forest"
editor_name= _ "Forest"
@ -2363,7 +2363,7 @@ Most units have 50% defense in forests, but cavalry are limited to 30%. Elves, o
[/terrain_type]
[terrain_type]
symbol_image=symbols/terrain_group_frozen_30
icon_image=symbols/terrain_type_frozen
id=frozen
name= _ "Frozen"
editor_name= _ "Frozen"
@ -2376,7 +2376,7 @@ Most units have 20 to 40% defense in frozen terrain."
[/terrain_type]
[terrain_type]
symbol_image=symbols/terrain_group_village_30
icon_image=symbols/terrain_type_village
id=village
name= _ "Village"
editor_name= _ "Village"
@ -2389,7 +2389,7 @@ Most units have 50 to 60% defense in villages, whereas cavalry receive only 40%.
[/terrain_type]
[terrain_type]
symbol_image=symbols/terrain_group_impassable_30
icon_image=symbols/terrain_type_impassable
id=impassable
name= _ "Impassable"
editor_name= _ "Impassable"
@ -2399,7 +2399,7 @@ Most units have 50 to 60% defense in villages, whereas cavalry receive only 40%.
[/terrain_type]
[terrain_type]
symbol_image=symbols/terrain_group_unwalkable_30
icon_image=symbols/terrain_type_unwalkable
id=unwalkable
name= _ "Unwalkable"
editor_name= _ "Unwalkable"
@ -2409,7 +2409,7 @@ Most units have 50 to 60% defense in villages, whereas cavalry receive only 40%.
[/terrain_type]
[terrain_type]
symbol_image=symbols/terrain_group_rails_30
icon_image=symbols/terrain_type_rails
id=rails
name= _ "Rails"
editor_name= _ "Rails"

View file

@ -1309,7 +1309,12 @@ public:
std::stringstream ss;
ss << "<img>src='" << type_.editor_image() << "'</img> ";
if (!type_.icon_image().empty())
ss << "<img>src='images/buttons/icon-base-32.png~RC(magenta>" << type_.id()
<< ")~BLIT("<< "terrain/" << type_.icon_image() << "_30.png)" << "'</img> ";
if (!type_.editor_image().empty())
ss << "<img>src='" << type_.editor_image() << "'</img> ";
ss << type_.help_topic_text().str() << "\n";

View file

@ -147,20 +147,27 @@ surface getMinimap(int w, int h, const gamemap &map, const team *vw)
} else {
SDL_Color col;
bool first = true;
const t_translation::t_list& underlying_terrains = map.underlying_union_terrain(terrain);
BOOST_FOREACH(const t_translation::t_terrain& underlying_terrain, underlying_terrains) {
const std::string& terrain_id = map.get_terrain_info(underlying_terrain).id();
SDL_Color col = fogged ? int_to_color(game_config::team_rgb_range.find(terrain_id)->second.min()) :
SDL_Color tmp = fogged ? int_to_color(game_config::team_rgb_range.find(terrain_id)->second.min()) :
int_to_color(game_config::team_rgb_range.find(terrain_id)->second.mid());
SDL_Rect fillrect = create_rect(maprect.x, maprect.y, scale, scale);
const Uint32 mapped_col = SDL_MapRGB(minimap->format,col.r,col.g,col.b);
sdl_fill_rect(minimap, &fillrect, mapped_col);
break;
if (first) {
first = false;
col = tmp;
} else {
col.r = col.r - (col.r - tmp.r)/2;
col.g = col.g - (col.g - tmp.g)/2;
col.b = col.b - (col.b - tmp.b)/2;
}
}
SDL_Rect fillrect = create_rect(maprect.x, maprect.y, scale, scale);
const Uint32 mapped_col = SDL_MapRGB(minimap->format,col.r,col.g,col.b);
sdl_fill_rect(minimap, &fillrect, mapped_col);
}
}

View file

@ -1317,9 +1317,9 @@ REPORT_GENERATOR(income)
}
namespace {
void blit_tced_icon(config &cfg, const std::string &terrain_id, bool high_res) {
void blit_tced_icon(config &cfg, const std::string &terrain_id, const std::string &icon_image, bool high_res) {
const std::string tc_base = high_res ? "images/buttons/icon-base-32.png" : "images/buttons/icon-base-16.png";
const std::string terrain_image = "icons/terrain/terrain_type_" + terrain_id + (high_res ? "_30.png" : ".png");
const std::string terrain_image = "terrain/" + icon_image + (high_res ? "_30.png" : ".png");
add_image(cfg, tc_base + "~RC(magenta>" + terrain_id + ")~BLIT(" + terrain_image + ")", terrain_id);
}
}
@ -1329,6 +1329,12 @@ REPORT_GENERATOR(terrain_info)
const gamemap &map = *resources::game_map;
map_location mouseover_hex = display::get_singleton()->mouseover_hex();
if (!map.on_board(mouseover_hex))
mouseover_hex = display::get_singleton()->selected_hex();
if (!map.on_board(mouseover_hex))
return report();
t_translation::t_terrain terrain = map.get_terrain(mouseover_hex);
if (terrain == t_translation::OFF_MAP_USER)
return report();
@ -1339,22 +1345,23 @@ REPORT_GENERATOR(terrain_info)
bool high_res = false;
if (display::get_singleton()->shrouded(mouseover_hex)) {
blit_tced_icon(cfg, "shroud", high_res);
return cfg;
}
if (display::get_singleton()->fogged(mouseover_hex)) {
blit_tced_icon(cfg, "fog", high_res);
}
if (map.is_keep(mouseover_hex)) {
blit_tced_icon(cfg, "keep", high_res);
}
//TODO
// if (display::get_singleton()->fogged(mouseover_hex)) {
// blit_tced_icon(cfg, "fog", high_res);
// }
//
// if (map.is_keep(mouseover_hex)) {
// blit_tced_icon(cfg, "keep", high_res);
// }
const t_translation::t_list& underlying_terrains = map.underlying_union_terrain(terrain);
BOOST_FOREACH(const t_translation::t_terrain& underlying_terrain, underlying_terrains) {
const std::string& terrain_id = map.get_terrain_info(underlying_terrain).id();
blit_tced_icon(cfg, terrain_id, high_res);
const std::string& terrain_icon = map.get_terrain_info(underlying_terrain).icon_image();
blit_tced_icon(cfg, terrain_id, terrain_icon, high_res);
}
return cfg;
}

View file

@ -68,6 +68,7 @@ terrain_type::terrain_type() :
{}
terrain_type::terrain_type(const config& cfg) :
icon_image_(cfg["icon_image"]),
minimap_image_(cfg["symbol_image"]),
minimap_image_overlay_(),
editor_image_(cfg["editor_image"].empty() ? "terrain/" + minimap_image_ + ".png" : "terrain/" + cfg["editor_image"].str() + ".png"),
@ -192,6 +193,7 @@ terrain_type::terrain_type(const config& cfg) :
}
terrain_type::terrain_type(const terrain_type& base, const terrain_type& overlay) :
icon_image_(),
minimap_image_(base.minimap_image_),
minimap_image_overlay_(overlay.minimap_image_),
editor_image_(base.editor_image_ + "~BLIT(" + overlay.editor_image_ +")"),

View file

@ -26,6 +26,7 @@ public:
terrain_type(const config& cfg);
terrain_type(const terrain_type& base, const terrain_type& overlay);
const std::string& icon_image() const { return icon_image_; }
const std::string& minimap_image() const { return minimap_image_; }
const std::string& minimap_image_overlay() const { return minimap_image_overlay_; }
const std::string& editor_image() const { return editor_image_; }
@ -80,6 +81,10 @@ public:
bool operator==(const terrain_type& other) const;
private:
/** The image used as symbol icon */
std::string icon_image_;
/** The image used in the minimap */
std::string minimap_image_;
std::string minimap_image_overlay_;