← Back to team overview

widelands-dev team mailing list archive

[Merge] lp:~widelands-dev/widelands/forested_mountain_terrain into lp:widelands

 

kaputtnik has proposed merging lp:~widelands-dev/widelands/forested_mountain_terrain into lp:widelands.

Requested reviews:
  Widelands Developers (widelands-dev)
Related bugs:
  Bug #1515006 in widelands: "Create a new forested mountain terrain"
  https://bugs.launchpad.net/widelands/+bug/1515006

For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/forested_mountain_terrain/+merge/280198

Added new terrain type "forested mountain", a mineable terrain where trees will grow.

I had some trouble with merging trunk related to the last changes to "is value". There where conflicts (as assumed :-) ) and the additional "tooltip" entry in /world/terrains/init.lua does not appear on the terrains in editor. I've changed the code to work right, but i am not sure if my changes are nice from a coding point of view.
-- 
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/forested_mountain_terrain into lp:widelands.
=== modified file 'src/editor/ui_menus/editor_tool_set_terrain_options_menu.cc'
--- src/editor/ui_menus/editor_tool_set_terrain_options_menu.cc	2015-12-04 13:12:50 +0000
+++ src/editor/ui_menus/editor_tool_set_terrain_options_menu.cc	2015-12-10 21:13:03 +0000
@@ -62,6 +62,9 @@
 
 	// Collect tooltips and blit small icons representing "is" values
 	for (const TerrainDescription::Type& terrain_type : terrain_descr.get_types()) {
+                tooltips.insert(tooltips.end(),
+								terrain_descr.custom_tooltips().begin(),
+								terrain_descr.custom_tooltips().end());
 		tooltips.push_back(terrain_type.descname);
 
 		blit(Rect(pt.x, pt.y, terrain_type.icon->width(), terrain_type.icon->height()),

=== modified file 'src/logic/world/terrain_description.cc'
--- src/logic/world/terrain_description.cc	2015-12-05 10:59:02 +0000
+++ src/logic/world/terrain_description.cc	2015-12-10 21:13:03 +0000
@@ -112,6 +112,10 @@
      fertility_(table.get_double("fertility")),
      humidity_(table.get_double("humidity")) {
 
+	if (table.has_key("tooltips")) {
+		custom_tooltips_ = table.get_table("tooltips")->array_entries<std::string>();
+	}
+
 	if (!(0 < fertility_ && fertility_ < 1.)) {
 		throw GameDataError("%s: fertility is not in (0, 1).", name_.c_str());
 	}

=== modified file 'src/logic/world/terrain_description.h'
--- src/logic/world/terrain_description.h	2015-12-05 10:59:02 +0000
+++ src/logic/world/terrain_description.h	2015-12-10 21:13:03 +0000
@@ -121,11 +121,16 @@
 	/// Fertility in percent [0, 1].
 	double fertility() const;
 
+	/// Additional tooptip entries for the editor
+	const std::vector<std::string>& custom_tooltips() const {return custom_tooltips_;}
+
+
 private:
 	const std::string name_;
 	const std::string descname_;
 	const EditorCategory* editor_category_;  ///< not owned.
 	Is is_;
+	std::vector<std::string> custom_tooltips_;
 	std::vector<uint8_t> valid_resources_;
 	int default_resource_index_;
 	int default_resource_amount_;

=== modified file 'world/terrains/init.lua'
--- world/terrains/init.lua	2015-12-05 10:59:02 +0000
+++ world/terrains/init.lua	2015-12-10 21:13:03 +0000
@@ -42,12 +42,18 @@
    -- The following properties are available:
    -- "arable": Allows building of normal buildings and roads
    -- "mineable": Allows building of mines and roads
-   -- "walkable": Allows building of roads only
+   -- "walkable": Allows building of roads only. Trees don't like this terrain.
    -- "water": Nothing can be built here, but ships and aquatic animals can pass
-   -- "unreachable": Nothing can be built here (not even immovables), and nothing can walk on it
+   -- "unreachable": Nothing can be built here, and nothing can walk on it, and nothing will grow.
    -- "unwalkable": Nothing can be built here, and nothing can walk on it
    is = "arable",
 
+   -- You can add custom additional tooltip entries here.
+   tooltips = {
+		-- TRANSLATORS: This is an entry in a terrain tooltip. Try to use 1 word if possible.
+		_"likes trees",
+   },
+
    -- The list resources that can be found in this terrain.
    valid_resources = {"water"},
 
@@ -80,6 +86,10 @@
    descname = _ "Meadow",
    editor_category = "green",
    is = "arable",
+   tooltips = {
+		-- TRANSLATORS: This is an entry in a terrain tooltip. Try to use 1 word if possible.
+		_"likes trees",
+   },
    valid_resources = {"water"},
    default_resource = "water",
    default_resource_amount = 10,
@@ -97,6 +107,10 @@
    descname = _ "Meadow",
    editor_category = "green",
    is = "arable",
+   tooltips = {
+		-- TRANSLATORS: This is an entry in a terrain tooltip. Try to use 1 word if possible.
+		_"likes trees",
+   },
    valid_resources = {"water"},
    default_resource = "water",
    default_resource_amount = 10,
@@ -113,6 +127,10 @@
    descname = _ "Meadow",
    editor_category = "green",
    is = "arable",
+   tooltips = {
+		-- TRANSLATORS: This is an entry in a terrain tooltip. Try to use 1 word if possible.
+		_"likes trees",
+   },
    valid_resources = {"water"},
    default_resource = "water",
    default_resource_amount = 10,
@@ -237,6 +255,46 @@
 
 
 world:new_terrain_type{
+   name = "summer_forested_mountain1",
+   descname = _ "Mountain",
+   editor_category = "green",
+   is = "mineable",
+   -- You can add custom additional tooltip entries here.
+   tooltips = {
+		-- TRANSLATORS: This is an entry in a terrain tooltip. Try to use 1 word if possible.
+		_"likes trees",
+   },
+   valid_resources = {"coal", "iron", "gold", "stones"},
+   default_resource = "",
+   default_resource_amount = 0,
+   textures = { pics_dir .. "green/forested_mountain1_00.png" },
+   dither_layer = 71,
+   temperature = 50,
+   humidity = 0.75,
+   fertility = 0.5,
+}
+
+world:new_terrain_type{
+   name = "summer_forested_mountain2",
+   descname = _ "Mountain",
+   editor_category = "green",
+   is = "mineable",
+   -- You can add custom additional tooltip entries here.
+   tooltips = {
+		-- TRANSLATORS: This is an entry in a terrain tooltip. Try to use 1 word if possible.
+		_"likes trees",
+   },
+   valid_resources = {"coal", "iron", "gold", "stones"},
+   default_resource = "",
+   default_resource_amount = 0,
+   textures = { pics_dir .. "green/forested_mountain2_00.png" },
+   dither_layer = 71,
+   temperature = 50,
+   humidity = 0.75,
+   fertility = 0.5,
+}
+
+world:new_terrain_type{
    name = "sumpf",
    descname = _ "Swamp",
    editor_category = "green",
@@ -252,7 +310,6 @@
    fertility = 0.1,
 }
 
-
 world:new_terrain_type{
    name = "strand",
    descname = _ "Beach",
@@ -326,6 +383,10 @@
    descname = _ "Ashes",
    editor_category = "wasteland",
    is = "arable",
+   tooltips = {
+		-- TRANSLATORS: This is an entry in a terrain tooltip. Try to use 1 word if possible.
+		_"likes trees",
+   },
    valid_resources = { "water" },
    default_resource = "water",
    default_resource_amount = 5,
@@ -342,6 +403,10 @@
    descname = _ "Ashes",
    editor_category = "wasteland",
    is = "arable",
+   tooltips = {
+		-- TRANSLATORS: This is an entry in a terrain tooltip. Try to use 1 word if possible.
+		_"likes trees",
+   },
    valid_resources = { "water" },
    default_resource = "water",
    default_resource_amount = 4,
@@ -358,6 +423,10 @@
    descname = _ "Hard Ground",
    editor_category = "wasteland",
    is = "arable",
+   tooltips = {
+		-- TRANSLATORS: This is an entry in a terrain tooltip. Try to use 1 word if possible.
+		_"likes trees",
+   },
    valid_resources = { "water" },
    default_resource = "water",
    default_resource_amount = 10,
@@ -374,6 +443,10 @@
    descname = _ "Hard Ground",
    editor_category = "wasteland",
    is = "arable",
+   tooltips = {
+		-- TRANSLATORS: This is an entry in a terrain tooltip. Try to use 1 word if possible.
+		_"likes trees",
+   },
    valid_resources = { "water" },
    default_resource = "water",
    default_resource_amount = 10,
@@ -390,6 +463,10 @@
    descname = _ "Hard Ground",
    editor_category = "wasteland",
    is = "arable",
+   tooltips = {
+		-- TRANSLATORS: This is an entry in a terrain tooltip. Try to use 1 word if possible.
+		_"likes trees",
+   },
    valid_resources = { "water" },
    default_resource = "water",
    default_resource_amount = 10,
@@ -406,6 +483,10 @@
    descname = _ "Hard Ground",
    editor_category = "wasteland",
    is = "arable",
+   tooltips = {
+		-- TRANSLATORS: This is an entry in a terrain tooltip. Try to use 1 word if possible.
+		_"likes trees",
+   },
    valid_resources = { "water" },
    default_resource = "water",
    default_resource_amount = 10,
@@ -496,6 +577,43 @@
    fertility = 0.2,
 }
 
+world:new_terrain_type{
+   name = "wasteland_forested_mountain1",
+   descname = _ "Mountain",
+   editor_category = "wasteland",
+   is = "mineable",
+   tooltips = {
+		-- TRANSLATORS: This is an entry in a terrain tooltip. Try to use 1 word if possible.
+		_"likes trees",
+   },
+   valid_resources = {"coal", "iron", "gold", "stones"},
+   default_resource = "",
+   default_resource_amount = 0,
+   textures = { pics_dir .. "wasteland/forested_mountain1_00.png" },
+   dither_layer = 81,
+   temperature = 110,
+   humidity = 0.15,
+   fertility = 0.95,
+}
+
+world:new_terrain_type{
+   name = "wasteland_forested_mountain2",
+   descname = _ "Mountain",
+   editor_category = "wasteland",
+   is = "mineable",
+   tooltips = {
+		-- TRANSLATORS: This is an entry in a terrain tooltip. Try to use 1 word if possible.
+		_"likes trees",
+   },
+   valid_resources = {"coal", "iron", "gold", "stones"},
+   default_resource = "",
+   default_resource_amount = 0,
+   textures = { pics_dir .. "wasteland/forested_mountain2_00.png" },
+   dither_layer = 81,
+   temperature = 95,
+   humidity = 0.2,
+   fertility = 0.4,
+}
 
 world:new_terrain_type{
    name = "wasteland_beach",
@@ -574,6 +692,10 @@
    descname = _ "Tundra",
    editor_category = "winter",
    is = "arable",
+   tooltips = {
+		-- TRANSLATORS: This is an entry in a terrain tooltip. Try to use 1 word if possible.
+		_"likes trees",
+   },
    valid_resources = { "water" },
    default_resource = "water",
    default_resource_amount = 10,
@@ -590,6 +712,10 @@
    descname = _ "Tundra",
    editor_category = "winter",
    is = "arable",
+   tooltips = {
+		-- TRANSLATORS: This is an entry in a terrain tooltip. Try to use 1 word if possible.
+		_"likes trees",
+   },
    valid_resources = { "water" },
    default_resource = "water",
    default_resource_amount = 10,
@@ -606,6 +732,10 @@
    descname = _ "Tundra",
    editor_category = "winter",
    is = "arable",
+   tooltips = {
+		-- TRANSLATORS: This is an entry in a terrain tooltip. Try to use 1 word if possible.
+		_"likes trees",
+   },
    valid_resources = { "water" },
    default_resource = "water",
    default_resource_amount = 10,
@@ -728,6 +858,43 @@
    fertility = 0.05,
 }
 
+world:new_terrain_type{
+   name = "winter_forested_mountain1",
+   descname = _ "Mountain",
+   editor_category = "winter",
+   is = "mineable",
+   tooltips = {
+		-- TRANSLATORS: This is an entry in a terrain tooltip. Try to use 1 word if possible.
+		_"likes trees",
+   },
+   valid_resources = {"coal", "iron", "gold", "stones"},
+   default_resource = "",
+   default_resource_amount = 0,
+   textures = { pics_dir .. "winter/forested_mountain1_00.png" },
+   dither_layer = 101,
+   temperature = 35,
+   humidity = 0.7,
+   fertility = 0.4,
+}
+
+world:new_terrain_type{
+   name = "winter_forested_mountain2",
+   descname = _ "Mountain",
+   editor_category = "winter",
+   is = "mineable",
+   tooltips = {
+		-- TRANSLATORS: This is an entry in a terrain tooltip. Try to use 1 word if possible.
+		_"likes trees",
+   },
+   valid_resources = {"coal", "iron", "gold", "stones"},
+   default_resource = "",
+   default_resource_amount = 0,
+   textures = { pics_dir .. "winter/forested_mountain2_00.png" },
+   dither_layer = 101,
+   temperature = 35,
+   humidity = 0.7,
+   fertility = 0.4,
+}
 
 world:new_terrain_type{
    name = "ice",
@@ -852,6 +1019,10 @@
    descname = _ "Steppe",
    editor_category = "desert",
    is = "arable",
+   tooltips = {
+		-- TRANSLATORS: This is an entry in a terrain tooltip. Try to use 1 word if possible.
+		_"likes trees",
+   },
    valid_resources = {"water"},
    default_resource = "water",
    default_resource_amount = 5,
@@ -868,6 +1039,10 @@
    descname = _ "Meadow",
    editor_category = "desert",
    is = "arable",
+   tooltips = {
+		-- TRANSLATORS: This is an entry in a terrain tooltip. Try to use 1 word if possible.
+		_"likes trees",
+   },
    valid_resources = {"water"},
    default_resource = "water",
    default_resource_amount = 10,
@@ -884,6 +1059,10 @@
    descname = _ "Mountain Meadow",
    editor_category = "desert",
    is = "arable",
+   tooltips = {
+		-- TRANSLATORS: This is an entry in a terrain tooltip. Try to use 1 word if possible.
+		_"likes trees",
+   },
    valid_resources = {"water"},
    default_resource = "",
    default_resource_amount = 0,
@@ -900,6 +1079,10 @@
    descname = _ "High Mountain Meadow",
    editor_category = "desert",
    is = "arable",
+   tooltips = {
+		-- TRANSLATORS: This is an entry in a terrain tooltip. Try to use 1 word if possible.
+		_"likes trees",
+   },
    valid_resources = {"water"},
    default_resource = "",
    default_resource_amount = 0,
@@ -974,6 +1157,43 @@
    fertility = 0.05,
 }
 
+world:new_terrain_type{
+   name = "desert_forested_mountain1",
+   descname = _ "Mountain",
+   editor_category = "desert",
+   is = "mineable",
+   tooltips = {
+		-- TRANSLATORS: This is an entry in a terrain tooltip. Try to use 1 word if possible.
+		_"likes trees",
+   },
+   valid_resources = {"coal", "iron", "gold", "stones"},
+   default_resource = "",
+   default_resource_amount = 0,
+   textures = { pics_dir .. "desert/forested_mountain1_00.png" },
+   dither_layer = 71,
+   temperature = 141,
+   humidity = 0.5,
+   fertility = 0.5,
+}
+
+world:new_terrain_type{
+   name = "desert_forested_mountain2",
+   descname = _ "Mountain",
+   editor_category = "desert",
+   is = "mineable",
+   tooltips = {
+		-- TRANSLATORS: This is an entry in a terrain tooltip. Try to use 1 word if possible.
+		_"likes trees",
+   },
+   valid_resources = {"coal", "iron", "gold", "stones"},
+   default_resource = "",
+   default_resource_amount = 0,
+   textures = { pics_dir .. "desert/forested_mountain2_00.png" },
+   dither_layer = 141,
+   temperature = 120,
+   humidity = 0.5,
+   fertility = 0.5,
+}
 
 world:new_terrain_type{
    name = "desert1",

=== added file 'world/terrains/pics/desert/forested_mountain1_00.png'
Binary files world/terrains/pics/desert/forested_mountain1_00.png	1970-01-01 00:00:00 +0000 and world/terrains/pics/desert/forested_mountain1_00.png	2015-12-10 21:13:03 +0000 differ
=== added file 'world/terrains/pics/desert/forested_mountain2_00.png'
Binary files world/terrains/pics/desert/forested_mountain2_00.png	1970-01-01 00:00:00 +0000 and world/terrains/pics/desert/forested_mountain2_00.png	2015-12-10 21:13:03 +0000 differ
=== added file 'world/terrains/pics/green/forested_mountain1_00.png'
Binary files world/terrains/pics/green/forested_mountain1_00.png	1970-01-01 00:00:00 +0000 and world/terrains/pics/green/forested_mountain1_00.png	2015-12-10 21:13:03 +0000 differ
=== added file 'world/terrains/pics/green/forested_mountain2_00.png'
Binary files world/terrains/pics/green/forested_mountain2_00.png	1970-01-01 00:00:00 +0000 and world/terrains/pics/green/forested_mountain2_00.png	2015-12-10 21:13:03 +0000 differ
=== added file 'world/terrains/pics/wasteland/forested_mountain1_00.png'
Binary files world/terrains/pics/wasteland/forested_mountain1_00.png	1970-01-01 00:00:00 +0000 and world/terrains/pics/wasteland/forested_mountain1_00.png	2015-12-10 21:13:03 +0000 differ
=== added file 'world/terrains/pics/wasteland/forested_mountain2_00.png'
Binary files world/terrains/pics/wasteland/forested_mountain2_00.png	1970-01-01 00:00:00 +0000 and world/terrains/pics/wasteland/forested_mountain2_00.png	2015-12-10 21:13:03 +0000 differ
=== added file 'world/terrains/pics/winter/forested_mountain1_00.png'
Binary files world/terrains/pics/winter/forested_mountain1_00.png	1970-01-01 00:00:00 +0000 and world/terrains/pics/winter/forested_mountain1_00.png	2015-12-10 21:13:03 +0000 differ
=== added file 'world/terrains/pics/winter/forested_mountain2_00.png'
Binary files world/terrains/pics/winter/forested_mountain2_00.png	1970-01-01 00:00:00 +0000 and world/terrains/pics/winter/forested_mountain2_00.png	2015-12-10 21:13:03 +0000 differ

Follow ups