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

Proposed by kaputtnik
Status: Merged
Merged at revision: 7667
Proposed branch: lp:~widelands-dev/widelands/forested_mountain_terrain
Merge into: lp:widelands
Diff against target: 454 lines (+235/-3)
4 files modified
src/editor/ui_menus/editor_tool_set_terrain_options_menu.cc (+3/-0)
src/logic/world/terrain_description.cc (+4/-0)
src/logic/world/terrain_description.h (+5/-0)
world/terrains/init.lua (+223/-3)
To merge this branch: bzr merge lp:~widelands-dev/widelands/forested_mountain_terrain
Reviewer Review Type Date Requested Status
GunChleoc Approve
kaputtnik (community) Needs Resubmitting
Review via email: mp+280198@code.launchpad.net

Description of the change

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.

To post a comment you must log in.
Revision history for this message
TiborB (tiborb95) wrote :

Is term "likes trees" proper from language point of view? I can not say if you resumed conflicts properly, but code looks good to me.

Revision history for this message
GunChleoc (gunchleoc) wrote :

We could go with "likes trees" or "tree friendly".

I will look at the code. If you are unsure about C++ merge conflicts in the future, you can submit the branch without a merge and let me have a look. Most often, I will have been the one fiddling with the code, so I'll have the reason for the changes in my head.

Revision history for this message
GunChleoc (gunchleoc) wrote :

Code LGTM - just 2 nits. I'll do some testing once the compiler has finished.

Revision history for this message
kaputtnik (franku) wrote :

Thanks :-)

I've just overlooked to adjust the comment.
"Forested Mountain" is better.

I will change this and resubmit.

7631. By kaputtnik

descname Forested mountain

7632. By kaputtnik

correct wrong spelling

Revision history for this message
kaputtnik (franku) wrote :

Changed "Mountain" into "Forested Mountain" for appropriate terrains and adjusted the comment.

review: Needs Resubmitting
Revision history for this message
GunChleoc (gunchleoc) wrote :

Tested and LGTM. Will merge :)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/editor/ui_menus/editor_tool_set_terrain_options_menu.cc'
2--- src/editor/ui_menus/editor_tool_set_terrain_options_menu.cc 2015-12-04 13:12:50 +0000
3+++ src/editor/ui_menus/editor_tool_set_terrain_options_menu.cc 2015-12-11 07:30:44 +0000
4@@ -62,6 +62,9 @@
5
6 // Collect tooltips and blit small icons representing "is" values
7 for (const TerrainDescription::Type& terrain_type : terrain_descr.get_types()) {
8+ tooltips.insert(tooltips.end(),
9+ terrain_descr.custom_tooltips().begin(),
10+ terrain_descr.custom_tooltips().end());
11 tooltips.push_back(terrain_type.descname);
12
13 blit(Rect(pt.x, pt.y, terrain_type.icon->width(), terrain_type.icon->height()),
14
15=== modified file 'src/logic/world/terrain_description.cc'
16--- src/logic/world/terrain_description.cc 2015-12-05 10:59:02 +0000
17+++ src/logic/world/terrain_description.cc 2015-12-11 07:30:44 +0000
18@@ -112,6 +112,10 @@
19 fertility_(table.get_double("fertility")),
20 humidity_(table.get_double("humidity")) {
21
22+ if (table.has_key("tooltips")) {
23+ custom_tooltips_ = table.get_table("tooltips")->array_entries<std::string>();
24+ }
25+
26 if (!(0 < fertility_ && fertility_ < 1.)) {
27 throw GameDataError("%s: fertility is not in (0, 1).", name_.c_str());
28 }
29
30=== modified file 'src/logic/world/terrain_description.h'
31--- src/logic/world/terrain_description.h 2015-12-05 10:59:02 +0000
32+++ src/logic/world/terrain_description.h 2015-12-11 07:30:44 +0000
33@@ -121,11 +121,16 @@
34 /// Fertility in percent [0, 1].
35 double fertility() const;
36
37+ /// Additional tooptip entries for the editor
38+ const std::vector<std::string>& custom_tooltips() const {return custom_tooltips_;}
39+
40+
41 private:
42 const std::string name_;
43 const std::string descname_;
44 const EditorCategory* editor_category_; ///< not owned.
45 Is is_;
46+ std::vector<std::string> custom_tooltips_;
47 std::vector<uint8_t> valid_resources_;
48 int default_resource_index_;
49 int default_resource_amount_;
50
51=== modified file 'world/terrains/init.lua'
52--- world/terrains/init.lua 2015-12-05 10:59:02 +0000
53+++ world/terrains/init.lua 2015-12-11 07:30:44 +0000
54@@ -42,12 +42,18 @@
55 -- The following properties are available:
56 -- "arable": Allows building of normal buildings and roads
57 -- "mineable": Allows building of mines and roads
58- -- "walkable": Allows building of roads only
59+ -- "walkable": Allows building of roads only.
60 -- "water": Nothing can be built here, but ships and aquatic animals can pass
61- -- "unreachable": Nothing can be built here (not even immovables), and nothing can walk on it
62+ -- "unreachable": Nothing can be built here, and nothing can walk on it, and nothing will grow.
63 -- "unwalkable": Nothing can be built here, and nothing can walk on it
64 is = "arable",
65
66+ -- You can add custom additional tooltip entries here.
67+ tooltips = {
68+ -- TRANSLATORS: This is an entry in a terrain tooltip. Try to use 1 word if possible.
69+ _"likes trees",
70+ },
71+
72 -- The list resources that can be found in this terrain.
73 valid_resources = {"water"},
74
75@@ -80,6 +86,10 @@
76 descname = _ "Meadow",
77 editor_category = "green",
78 is = "arable",
79+ tooltips = {
80+ -- TRANSLATORS: This is an entry in a terrain tooltip. Try to use 1 word if possible.
81+ _"likes trees",
82+ },
83 valid_resources = {"water"},
84 default_resource = "water",
85 default_resource_amount = 10,
86@@ -97,6 +107,10 @@
87 descname = _ "Meadow",
88 editor_category = "green",
89 is = "arable",
90+ tooltips = {
91+ -- TRANSLATORS: This is an entry in a terrain tooltip. Try to use 1 word if possible.
92+ _"likes trees",
93+ },
94 valid_resources = {"water"},
95 default_resource = "water",
96 default_resource_amount = 10,
97@@ -113,6 +127,10 @@
98 descname = _ "Meadow",
99 editor_category = "green",
100 is = "arable",
101+ tooltips = {
102+ -- TRANSLATORS: This is an entry in a terrain tooltip. Try to use 1 word if possible.
103+ _"likes trees",
104+ },
105 valid_resources = {"water"},
106 default_resource = "water",
107 default_resource_amount = 10,
108@@ -237,6 +255,46 @@
109
110
111 world:new_terrain_type{
112+ name = "summer_forested_mountain1",
113+ descname = _ "Forested Mountain",
114+ editor_category = "green",
115+ is = "mineable",
116+ -- You can add custom additional tooltip entries here.
117+ tooltips = {
118+ -- TRANSLATORS: This is an entry in a terrain tooltip. Try to use 1 word if possible.
119+ _"likes trees",
120+ },
121+ valid_resources = {"coal", "iron", "gold", "stones"},
122+ default_resource = "",
123+ default_resource_amount = 0,
124+ textures = { pics_dir .. "green/forested_mountain1_00.png" },
125+ dither_layer = 71,
126+ temperature = 50,
127+ humidity = 0.75,
128+ fertility = 0.5,
129+}
130+
131+world:new_terrain_type{
132+ name = "summer_forested_mountain2",
133+ descname = _ "Forested Mountain",
134+ editor_category = "green",
135+ is = "mineable",
136+ -- You can add custom additional tooltip entries here.
137+ tooltips = {
138+ -- TRANSLATORS: This is an entry in a terrain tooltip. Try to use 1 word if possible.
139+ _"likes trees",
140+ },
141+ valid_resources = {"coal", "iron", "gold", "stones"},
142+ default_resource = "",
143+ default_resource_amount = 0,
144+ textures = { pics_dir .. "green/forested_mountain2_00.png" },
145+ dither_layer = 71,
146+ temperature = 50,
147+ humidity = 0.75,
148+ fertility = 0.5,
149+}
150+
151+world:new_terrain_type{
152 name = "sumpf",
153 descname = _ "Swamp",
154 editor_category = "green",
155@@ -252,7 +310,6 @@
156 fertility = 0.1,
157 }
158
159-
160 world:new_terrain_type{
161 name = "strand",
162 descname = _ "Beach",
163@@ -326,6 +383,10 @@
164 descname = _ "Ashes",
165 editor_category = "wasteland",
166 is = "arable",
167+ tooltips = {
168+ -- TRANSLATORS: This is an entry in a terrain tooltip. Try to use 1 word if possible.
169+ _"likes trees",
170+ },
171 valid_resources = { "water" },
172 default_resource = "water",
173 default_resource_amount = 5,
174@@ -342,6 +403,10 @@
175 descname = _ "Ashes",
176 editor_category = "wasteland",
177 is = "arable",
178+ tooltips = {
179+ -- TRANSLATORS: This is an entry in a terrain tooltip. Try to use 1 word if possible.
180+ _"likes trees",
181+ },
182 valid_resources = { "water" },
183 default_resource = "water",
184 default_resource_amount = 4,
185@@ -358,6 +423,10 @@
186 descname = _ "Hard Ground",
187 editor_category = "wasteland",
188 is = "arable",
189+ tooltips = {
190+ -- TRANSLATORS: This is an entry in a terrain tooltip. Try to use 1 word if possible.
191+ _"likes trees",
192+ },
193 valid_resources = { "water" },
194 default_resource = "water",
195 default_resource_amount = 10,
196@@ -374,6 +443,10 @@
197 descname = _ "Hard Ground",
198 editor_category = "wasteland",
199 is = "arable",
200+ tooltips = {
201+ -- TRANSLATORS: This is an entry in a terrain tooltip. Try to use 1 word if possible.
202+ _"likes trees",
203+ },
204 valid_resources = { "water" },
205 default_resource = "water",
206 default_resource_amount = 10,
207@@ -390,6 +463,10 @@
208 descname = _ "Hard Ground",
209 editor_category = "wasteland",
210 is = "arable",
211+ tooltips = {
212+ -- TRANSLATORS: This is an entry in a terrain tooltip. Try to use 1 word if possible.
213+ _"likes trees",
214+ },
215 valid_resources = { "water" },
216 default_resource = "water",
217 default_resource_amount = 10,
218@@ -406,6 +483,10 @@
219 descname = _ "Hard Ground",
220 editor_category = "wasteland",
221 is = "arable",
222+ tooltips = {
223+ -- TRANSLATORS: This is an entry in a terrain tooltip. Try to use 1 word if possible.
224+ _"likes trees",
225+ },
226 valid_resources = { "water" },
227 default_resource = "water",
228 default_resource_amount = 10,
229@@ -496,6 +577,43 @@
230 fertility = 0.2,
231 }
232
233+world:new_terrain_type{
234+ name = "wasteland_forested_mountain1",
235+ descname = _ "Forested Mountain",
236+ editor_category = "wasteland",
237+ is = "mineable",
238+ tooltips = {
239+ -- TRANSLATORS: This is an entry in a terrain tooltip. Try to use 1 word if possible.
240+ _"likes trees",
241+ },
242+ valid_resources = {"coal", "iron", "gold", "stones"},
243+ default_resource = "",
244+ default_resource_amount = 0,
245+ textures = { pics_dir .. "wasteland/forested_mountain1_00.png" },
246+ dither_layer = 81,
247+ temperature = 110,
248+ humidity = 0.15,
249+ fertility = 0.95,
250+}
251+
252+world:new_terrain_type{
253+ name = "wasteland_forested_mountain2",
254+ descname = _ "Forested Mountain",
255+ editor_category = "wasteland",
256+ is = "mineable",
257+ tooltips = {
258+ -- TRANSLATORS: This is an entry in a terrain tooltip. Try to use 1 word if possible.
259+ _"likes trees",
260+ },
261+ valid_resources = {"coal", "iron", "gold", "stones"},
262+ default_resource = "",
263+ default_resource_amount = 0,
264+ textures = { pics_dir .. "wasteland/forested_mountain2_00.png" },
265+ dither_layer = 81,
266+ temperature = 95,
267+ humidity = 0.2,
268+ fertility = 0.4,
269+}
270
271 world:new_terrain_type{
272 name = "wasteland_beach",
273@@ -574,6 +692,10 @@
274 descname = _ "Tundra",
275 editor_category = "winter",
276 is = "arable",
277+ tooltips = {
278+ -- TRANSLATORS: This is an entry in a terrain tooltip. Try to use 1 word if possible.
279+ _"likes trees",
280+ },
281 valid_resources = { "water" },
282 default_resource = "water",
283 default_resource_amount = 10,
284@@ -590,6 +712,10 @@
285 descname = _ "Tundra",
286 editor_category = "winter",
287 is = "arable",
288+ tooltips = {
289+ -- TRANSLATORS: This is an entry in a terrain tooltip. Try to use 1 word if possible.
290+ _"likes trees",
291+ },
292 valid_resources = { "water" },
293 default_resource = "water",
294 default_resource_amount = 10,
295@@ -606,6 +732,10 @@
296 descname = _ "Tundra",
297 editor_category = "winter",
298 is = "arable",
299+ tooltips = {
300+ -- TRANSLATORS: This is an entry in a terrain tooltip. Try to use 1 word if possible.
301+ _"likes trees",
302+ },
303 valid_resources = { "water" },
304 default_resource = "water",
305 default_resource_amount = 10,
306@@ -728,6 +858,43 @@
307 fertility = 0.05,
308 }
309
310+world:new_terrain_type{
311+ name = "winter_forested_mountain1",
312+ descname = _ "Forested Mountain",
313+ editor_category = "winter",
314+ is = "mineable",
315+ tooltips = {
316+ -- TRANSLATORS: This is an entry in a terrain tooltip. Try to use 1 word if possible.
317+ _"likes trees",
318+ },
319+ valid_resources = {"coal", "iron", "gold", "stones"},
320+ default_resource = "",
321+ default_resource_amount = 0,
322+ textures = { pics_dir .. "winter/forested_mountain1_00.png" },
323+ dither_layer = 101,
324+ temperature = 35,
325+ humidity = 0.7,
326+ fertility = 0.4,
327+}
328+
329+world:new_terrain_type{
330+ name = "winter_forested_mountain2",
331+ descname = _ "Forested Mountain",
332+ editor_category = "winter",
333+ is = "mineable",
334+ tooltips = {
335+ -- TRANSLATORS: This is an entry in a terrain tooltip. Try to use 1 word if possible.
336+ _"likes trees",
337+ },
338+ valid_resources = {"coal", "iron", "gold", "stones"},
339+ default_resource = "",
340+ default_resource_amount = 0,
341+ textures = { pics_dir .. "winter/forested_mountain2_00.png" },
342+ dither_layer = 101,
343+ temperature = 35,
344+ humidity = 0.7,
345+ fertility = 0.4,
346+}
347
348 world:new_terrain_type{
349 name = "ice",
350@@ -852,6 +1019,10 @@
351 descname = _ "Steppe",
352 editor_category = "desert",
353 is = "arable",
354+ tooltips = {
355+ -- TRANSLATORS: This is an entry in a terrain tooltip. Try to use 1 word if possible.
356+ _"likes trees",
357+ },
358 valid_resources = {"water"},
359 default_resource = "water",
360 default_resource_amount = 5,
361@@ -868,6 +1039,10 @@
362 descname = _ "Meadow",
363 editor_category = "desert",
364 is = "arable",
365+ tooltips = {
366+ -- TRANSLATORS: This is an entry in a terrain tooltip. Try to use 1 word if possible.
367+ _"likes trees",
368+ },
369 valid_resources = {"water"},
370 default_resource = "water",
371 default_resource_amount = 10,
372@@ -884,6 +1059,10 @@
373 descname = _ "Mountain Meadow",
374 editor_category = "desert",
375 is = "arable",
376+ tooltips = {
377+ -- TRANSLATORS: This is an entry in a terrain tooltip. Try to use 1 word if possible.
378+ _"likes trees",
379+ },
380 valid_resources = {"water"},
381 default_resource = "",
382 default_resource_amount = 0,
383@@ -900,6 +1079,10 @@
384 descname = _ "High Mountain Meadow",
385 editor_category = "desert",
386 is = "arable",
387+ tooltips = {
388+ -- TRANSLATORS: This is an entry in a terrain tooltip. Try to use 1 word if possible.
389+ _"likes trees",
390+ },
391 valid_resources = {"water"},
392 default_resource = "",
393 default_resource_amount = 0,
394@@ -974,6 +1157,43 @@
395 fertility = 0.05,
396 }
397
398+world:new_terrain_type{
399+ name = "desert_forested_mountain1",
400+ descname = _ "Forested Mountain",
401+ editor_category = "desert",
402+ is = "mineable",
403+ tooltips = {
404+ -- TRANSLATORS: This is an entry in a terrain tooltip. Try to use 1 word if possible.
405+ _"likes trees",
406+ },
407+ valid_resources = {"coal", "iron", "gold", "stones"},
408+ default_resource = "",
409+ default_resource_amount = 0,
410+ textures = { pics_dir .. "desert/forested_mountain1_00.png" },
411+ dither_layer = 71,
412+ temperature = 141,
413+ humidity = 0.5,
414+ fertility = 0.5,
415+}
416+
417+world:new_terrain_type{
418+ name = "desert_forested_mountain2",
419+ descname = _ "Forested Mountain",
420+ editor_category = "desert",
421+ is = "mineable",
422+ tooltips = {
423+ -- TRANSLATORS: This is an entry in a terrain tooltip. Try to use 1 word if possible.
424+ _"likes trees",
425+ },
426+ valid_resources = {"coal", "iron", "gold", "stones"},
427+ default_resource = "",
428+ default_resource_amount = 0,
429+ textures = { pics_dir .. "desert/forested_mountain2_00.png" },
430+ dither_layer = 141,
431+ temperature = 120,
432+ humidity = 0.5,
433+ fertility = 0.5,
434+}
435
436 world:new_terrain_type{
437 name = "desert1",
438
439=== added file 'world/terrains/pics/desert/forested_mountain1_00.png'
440Binary 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-11 07:30:44 +0000 differ
441=== added file 'world/terrains/pics/desert/forested_mountain2_00.png'
442Binary 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-11 07:30:44 +0000 differ
443=== added file 'world/terrains/pics/green/forested_mountain1_00.png'
444Binary 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-11 07:30:44 +0000 differ
445=== added file 'world/terrains/pics/green/forested_mountain2_00.png'
446Binary 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-11 07:30:44 +0000 differ
447=== added file 'world/terrains/pics/wasteland/forested_mountain1_00.png'
448Binary 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-11 07:30:44 +0000 differ
449=== added file 'world/terrains/pics/wasteland/forested_mountain2_00.png'
450Binary 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-11 07:30:44 +0000 differ
451=== added file 'world/terrains/pics/winter/forested_mountain1_00.png'
452Binary 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-11 07:30:44 +0000 differ
453=== added file 'world/terrains/pics/winter/forested_mountain2_00.png'
454Binary 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-11 07:30:44 +0000 differ

Subscribers

People subscribed via source and target branches

to status/vote changes: