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

Proposed by GunChleoc
Status: Merged
Merged at revision: 9094
Proposed branch: lp:~widelands-dev/widelands/representative_image_in_font_renderer
Merge into: lp:widelands
Diff against target: 1348 lines (+229/-92)
53 files modified
data/campaigns/atl01.wmf/scripting/mission_thread.lua (+2/-3)
data/campaigns/atl01.wmf/scripting/texts.lua (+2/-2)
data/campaigns/bar01.wmf/scripting/texts.lua (+10/-10)
data/scripting/editor/editor_help.lua (+1/-1)
data/scripting/editor/terrain_help.lua (+1/-1)
data/scripting/editor/tree_help.lua (+1/-1)
data/scripting/richtext.lua (+41/-1)
data/tribes/immovables/resi/atlanteans/init.lua (+10/-0)
data/tribes/immovables/resi/barbarians/init.lua (+10/-0)
data/tribes/immovables/resi/empire/init.lua (+10/-0)
data/tribes/immovables/resi/frisians/init.lua (+10/-0)
data/tribes/immovables/shipconstruction_atlanteans/init.lua (+2/-1)
data/tribes/immovables/shipconstruction_barbarians/init.lua (+2/-1)
data/tribes/immovables/shipconstruction_empire/init.lua (+2/-1)
data/tribes/immovables/shipconstruction_frisians/init.lua (+2/-1)
data/tribes/scripting/help/building_help.lua (+3/-3)
data/tribes/scripting/help/immovable_help.lua (+1/-1)
data/world/immovables/trees/alder/init.lua (+1/-0)
data/world/immovables/trees/aspen/init.lua (+1/-0)
data/world/immovables/trees/beech/init.lua (+1/-0)
data/world/immovables/trees/birch/init.lua (+1/-0)
data/world/immovables/trees/cirrus/init.lua (+1/-0)
data/world/immovables/trees/larch/init.lua (+1/-0)
data/world/immovables/trees/liana/init.lua (+1/-0)
data/world/immovables/trees/maple/init.lua (+1/-0)
data/world/immovables/trees/mushroom_dark/init.lua (+1/-0)
data/world/immovables/trees/mushroom_green/init.lua (+1/-0)
data/world/immovables/trees/mushroom_red/init.lua (+1/-0)
data/world/immovables/trees/oak/init.lua (+1/-0)
data/world/immovables/trees/palm_borassus/init.lua (+1/-0)
data/world/immovables/trees/palm_coconut/init.lua (+1/-0)
data/world/immovables/trees/palm_date/init.lua (+1/-0)
data/world/immovables/trees/palm_oil/init.lua (+1/-0)
data/world/immovables/trees/palm_roystonea/init.lua (+1/-0)
data/world/immovables/trees/rowan/init.lua (+1/-0)
data/world/immovables/trees/spruce/init.lua (+1/-0)
data/world/immovables/trees/twine/init.lua (+1/-0)
data/world/immovables/trees/umbrella_green/init.lua (+1/-0)
data/world/immovables/trees/umbrella_red/init.lua (+1/-0)
doc/sphinx/source/animations.rst (+3/-0)
src/graphic/animation.cc (+22/-9)
src/graphic/animation.h (+8/-3)
src/graphic/text/rt_parse.cc (+5/-2)
src/graphic/text/rt_render.cc (+35/-17)
src/logic/map_objects/immovable.cc (+10/-0)
src/logic/map_objects/map_object.cc (+7/-6)
src/logic/map_objects/map_object.h (+0/-4)
src/logic/map_objects/tribes/building.cc (+2/-4)
src/logic/map_objects/tribes/tribe_descr.cc (+2/-2)
src/logic/map_objects/tribes/worker.cc (+2/-3)
src/scripting/lua_map.cc (+0/-13)
src/scripting/lua_map.h (+0/-1)
src/website/map_object_info.cc (+1/-1)
To merge this branch: bzr merge lp:~widelands-dev/widelands/representative_image_in_font_renderer
Reviewer Review Type Date Requested Status
Benedikt Straub Approve
GunChleoc Needs Resubmitting
Review via email: mp+363781@code.launchpad.net

Commit message

Add support for representative images to the font renderer

Description of the change

This is the second step in a series to improve graphics quality in Widelands, hopefully for Build 21.

1. Implement support for Mipmaps

2. Add support to the font renderer

3. Implement spritesheets, otherwise the number of files will explode

4. Implement compressed spritemaps, otherwise the filesize will explode.
   This is only feasible for immovables.

5. Re-export everything from Blender

To post a comment you must log in.
8832. By GunChleoc

Tweaked documentation

Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 4543. State: failed. Details: https://travis-ci.org/widelands/widelands/builds/499778127.
Appveyor build 4330. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_representative_image_in_font_renderer-4330.

8833. By GunChleoc

Merged trunk.

8834. By GunChleoc

Merged trunk.

Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 4719. State: errored. Details: https://travis-ci.org/widelands/widelands/builds/519930939.
Appveyor build 4505. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_representative_image_in_font_renderer-4505.

Revision history for this message
GunChleoc (gunchleoc) wrote :

Build animations are broken

review: Needs Fixing
8835. By GunChleoc

Merged trunk.

8836. By GunChleoc

Fix names for flag and frontier animations.

8837. By GunChleoc

Add missing default frame length back in.

Revision history for this message
GunChleoc (gunchleoc) wrote :

Found the bug

review: Needs Resubmitting
8838. By GunChleoc

Better representative frames for shipconstruction.

Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 4747. State: passed. Details: https://travis-ci.org/widelands/widelands/builds/522437719.
Appveyor build 4532. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_representative_image_in_font_renderer-4532.

8839. By GunChleoc

Merged trunk.

Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 4809. State: errored. Details: https://travis-ci.org/widelands/widelands/builds/524806605.
Appveyor build 4590. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_representative_image_in_font_renderer-4590.

Revision history for this message
Benedikt Straub (nordfriese) wrote :

Code LGTM. Tested briefly, no issues seen.

review: Approve
8840. By GunChleoc

Merged trunk.

Revision history for this message
GunChleoc (gunchleoc) wrote :

The inputqueues again

@bunnybot merge force

Revision history for this message
Toni Förster (stonerl) wrote :

I know this has been merged already, but I get a compile warning since this is in trunk.

src/graphic/text/rt_render.cc:978:14: warning: implicit conversion increases floating-point precision: 'float' to 'const double' [-Wdouble-promotion]
             scale_(1.0f),

Revision history for this message
GunChleoc (gunchleoc) wrote :

I just noticed this in the font_size-lua branch too and have fixed it there.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'data/campaigns/atl01.wmf/scripting/mission_thread.lua'
2--- data/campaigns/atl01.wmf/scripting/mission_thread.lua 2018-12-13 17:36:58 +0000
3+++ data/campaigns/atl01.wmf/scripting/mission_thread.lua 2019-05-03 18:29:53 +0000
4@@ -3,8 +3,7 @@
5 -- =======================================================================
6
7 function send_building_lost_message(f)
8- local icon = f.immovable.descr.representative_image
9- local message = building_lost(icon)
10+ local message = building_lost(f.immovable.descr.name)
11 send_message(
12 p1,
13 message.title,
14@@ -12,7 +11,7 @@
15 {
16 field = f,
17 popup = false,
18- icon = icon,
19+ icon = f.immovable.descr.icon_name,
20 message.title
21 }
22 )
23
24=== modified file 'data/campaigns/atl01.wmf/scripting/texts.lua'
25--- data/campaigns/atl01.wmf/scripting/texts.lua 2017-12-09 19:06:07 +0000
26+++ data/campaigns/atl01.wmf/scripting/texts.lua 2019-05-03 18:29:53 +0000
27@@ -480,11 +480,11 @@
28 }
29 }
30
31-function building_lost(icon)
32+function building_lost(buildingname)
33 set_textdomain("scenario_atl01.wmf")
34 return {
35 -- TRANSLATORS: Short message title. Translate as "Lost!" if you don't have enough space.
36 title = pgettext("message_short_title", "Building lost!"),
37- text = li_image(icon, _"We lost a building to the ocean!")
38+ text = li_object(buildingname, _"We lost a building to the ocean!")
39 }
40 end
41
42=== modified file 'data/campaigns/bar01.wmf/scripting/texts.lua'
43--- data/campaigns/bar01.wmf/scripting/texts.lua 2018-09-02 11:44:52 +0000
44+++ data/campaigns/bar01.wmf/scripting/texts.lua 2019-05-03 18:29:53 +0000
45@@ -43,16 +43,16 @@
46 body = objective_text(_"Build coal and iron mines",
47 li(_"Build a coal mine and an iron mine.") ..
48 li_arrow(_"To do so, place a flag up on the mountain’s flank to the east (on mountain terrain though, not mountain meadow). When you click on the new flag, you can send geologists there. Because the flag is on a mountain, the geologists will search for ores; otherwise, they would search for water. Then build a mine for both kinds of resources that they will find, choosing the appropriate mine to be built:") ..
49- li_image(wl.Game():get_immovable_description("barbarians_resi_coal_1").representative_image, _"a bit of coal") ..
50- li_image(wl.Game():get_immovable_description("barbarians_resi_coal_2").representative_image, _"a lot of coal") ..
51- li_image(wl.Game():get_immovable_description("barbarians_resi_iron_1").representative_image, _"a bit of iron") ..
52- li_image(wl.Game():get_immovable_description("barbarians_resi_iron_2").representative_image, _"a lot of iron") ..
53- li_image(wl.Game():get_immovable_description("barbarians_resi_gold_1").representative_image, _"a bit of gold") ..
54- li_image(wl.Game():get_immovable_description("barbarians_resi_gold_2").representative_image, _"a lot of gold") ..
55- li_image(wl.Game():get_immovable_description("barbarians_resi_stones_1").representative_image, _"a bit of granite") ..
56- li_image(wl.Game():get_immovable_description("barbarians_resi_stones_2").representative_image, _"a lot of granite") ..
57- li_image(wl.Game():get_immovable_description("barbarians_resi_water").representative_image, _"water") ..
58- li_image(wl.Game():get_immovable_description("barbarians_resi_none").representative_image, _"nothing was found here") ..
59+ li_object("barbarians_resi_coal_1", _"a bit of coal") ..
60+ li_object("barbarians_resi_coal_2", _"a lot of coal") ..
61+ li_object("barbarians_resi_iron_1", _"a bit of iron") ..
62+ li_object("barbarians_resi_iron_2", _"a lot of iron") ..
63+ li_object("barbarians_resi_gold_1", _"a bit of gold") ..
64+ li_object("barbarians_resi_gold_2", _"a lot of gold") ..
65+ li_object("barbarians_resi_stones_1", _"a bit of granite") ..
66+ li_object("barbarians_resi_stones_2", _"a lot of granite") ..
67+ li_object("barbarians_resi_water", _"water") ..
68+ li_object("barbarians_resi_none", _"nothing was found here") ..
69 p(_[[Mines can only be built on mountain terrain. Suitable places for mines are displayed as orange mine symbols.]]))
70 }
71
72
73=== modified file 'data/scripting/editor/editor_help.lua'
74--- data/scripting/editor/editor_help.lua 2016-10-19 09:00:29 +0000
75+++ data/scripting/editor/editor_help.lua 2019-05-03 18:29:53 +0000
76@@ -32,7 +32,7 @@
77 result[counter] = {
78 name = immovable.name,
79 title = immovable.species,
80- icon = immovable.representative_image,
81+ icon = immovable.icon_name,
82 script = "scripting/editor/tree_help.lua",
83 script_parameters = {[1] = immovable.name}
84 }
85
86=== modified file 'data/scripting/editor/terrain_help.lua'
87--- data/scripting/editor/terrain_help.lua 2018-01-10 16:21:50 +0000
88+++ data/scripting/editor/terrain_help.lua 2019-05-03 18:29:53 +0000
89@@ -59,7 +59,7 @@
90
91 local tree_string = ""
92 for k,v in ipairs(tree_list) do
93- tree_string = tree_string .. li_image(v.tree.representative_image,
94+ tree_string = tree_string .. li_object(v.tree.name,
95 v.tree.species .. ("<br>%2.1f%%"):bformat(100 * v.probability)) .. vspace(3)
96 end
97
98
99=== modified file 'data/scripting/editor/tree_help.lua'
100--- data/scripting/editor/tree_help.lua 2018-01-10 16:21:50 +0000
101+++ data/scripting/editor/tree_help.lua 2019-05-03 18:29:53 +0000
102@@ -13,7 +13,7 @@
103 set_textdomain("widelands_editor")
104 local world = wl.World();
105 local tree = wl.Editor():get_immovable_description(tree_name)
106- local result = li_image(tree.representative_image, "")
107+ local result = li_object(tree.name, "")
108
109 -- TRANSLATORS: A header in the editor help. Terrains preferred by a type of tree.
110 result = result .. vspace(3) .. h2(vspace(12) .. _"Preferred terrains") .. vspace(3)
111
112=== modified file 'data/scripting/richtext.lua'
113--- data/scripting/richtext.lua 2018-03-24 13:51:48 +0000
114+++ data/scripting/richtext.lua 2019-05-03 18:29:53 +0000
115@@ -402,7 +402,6 @@
116 return li("→", text)
117 end
118
119-
120 -- RST
121 -- .. function:: li_image(imagepath, text)
122 --
123@@ -424,6 +423,26 @@
124 )
125 end
126
127+-- RST
128+-- .. function:: li_object(name, text)
129+--
130+-- Places a paragraph of text to the right of an image representing the given map object
131+--
132+-- :arg name: the name of the map object to be represented by an image
133+-- :type name: :class:`string`
134+--
135+-- :arg text: the text to be placed next to the image
136+-- :type text: :class:`string`
137+--
138+-- :returns: the text wrapped in a paragraph and placed next to the image, the outer tag is a div.
139+
140+function li_object(name, text)
141+ return
142+ div("width=100%",
143+ div("float=left padding_r=6", p(img_object(name))) ..
144+ p(text)
145+ )
146+end
147
148 -- RST
149 -- :ref:`Return to index<richtext.lua>`
150@@ -455,6 +474,27 @@
151 end
152 end
153
154+-- RST
155+-- .. function:: img_object(object[, attributes = nil])
156+--
157+-- Creates a richtest image tag for the given map object type. See also :any:`li_object`.
158+--
159+-- :arg name: the name of the map object.
160+-- :type name: :class:`string`
161+-- :arg attributes: see the :ref:`img tag's documentation <rt_tags_img>`
162+-- for a list of attributes and their descriptions.
163+-- :type attributes: :class:`string`
164+--
165+-- :returns: the img tag.
166+
167+function img_object(name, attributes)
168+ if attributes then
169+ return "<img object=" .. name .. " " .. attributes .. ">"
170+ else
171+ return "<img object=" .. name .. ">"
172+ end
173+end
174+
175
176 -- RST
177 -- :ref:`Return to index<richtext.lua>`
178
179=== modified file 'data/tribes/immovables/resi/atlanteans/init.lua'
180--- data/tribes/immovables/resi/atlanteans/init.lua 2018-09-10 06:25:11 +0000
181+++ data/tribes/immovables/resi/atlanteans/init.lua 2019-05-03 18:29:53 +0000
182@@ -6,6 +6,7 @@
183 -- TRANSLATORS: This is a resource name used in lists of resources
184 descname = pgettext("immovable", "Resources: None"),
185 helptext_script = dirname .. "../helptexts/none.lua",
186+ icon = dirname .. "pics/none_0.png",
187 attributes = { "resi" },
188 programs = {
189 program = {
190@@ -28,6 +29,7 @@
191 -- TRANSLATORS: This is a resource name used in lists of resources
192 descname = pgettext("immovable", "Resources: Water Vein"),
193 helptext_script = dirname .. "../helptexts/water.lua",
194+ icon = dirname .. "pics/water_0.png",
195 attributes = { "resi" },
196 programs = {
197 program = {
198@@ -51,6 +53,7 @@
199 -- TRANSLATORS: This is a resource name used in lists of resources
200 descname = pgettext("immovable", "Resources: Coal Vein"),
201 helptext_script = dirname .. "../helptexts/coal_1.lua",
202+ icon = dirname .. "pics/coal_1_0.png",
203 attributes = { "resi" },
204 programs = {
205 program = {
206@@ -74,6 +77,7 @@
207 -- TRANSLATORS: This is a resource name used in lists of resources
208 descname = pgettext("immovable", "Resources: Gold Vein"),
209 helptext_script = dirname .. "../helptexts/gold_1.lua",
210+ icon = dirname .. "pics/gold_1_0.png",
211 attributes = { "resi" },
212 programs = {
213 program = {
214@@ -97,6 +101,7 @@
215 -- TRANSLATORS: This is a resource name used in lists of resources
216 descname = pgettext("immovable", "Resources: Iron Vein"),
217 helptext_script = dirname .. "../helptexts/iron_1.lua",
218+ icon = dirname .. "pics/iron_1_0.png",
219 attributes = { "resi" },
220 programs = {
221 program = {
222@@ -120,6 +125,7 @@
223 -- TRANSLATORS: This is a resource name used in lists of resources
224 descname = pgettext("immovable", "Resources: Some Stones"),
225 helptext_script = dirname .. "../helptexts/stones_1.lua",
226+ icon = dirname .. "pics/stones_1_0.png",
227 attributes = { "resi" },
228 programs = {
229 program = {
230@@ -143,6 +149,7 @@
231 -- TRANSLATORS: This is a resource name used in lists of resources
232 descname = pgettext("immovable", "Resources: Main Coal Vein"),
233 helptext_script = dirname .. "../helptexts/coal_2.lua",
234+ icon = dirname .. "pics/coal_2_0.png",
235 attributes = { "resi" },
236 programs = {
237 program = {
238@@ -166,6 +173,7 @@
239 -- TRANSLATORS: This is a resource name used in lists of resources
240 descname = pgettext("immovable", "Resources: Main Gold Vein"),
241 helptext_script = dirname .. "../helptexts/gold_2.lua",
242+ icon = dirname .. "pics/gold_2_0.png",
243 attributes = { "resi" },
244 programs = {
245 program = {
246@@ -189,6 +197,7 @@
247 -- TRANSLATORS: This is a resource name used in lists of resources
248 descname = pgettext("immovable", "Resources: Main Iron Vein"),
249 helptext_script = dirname .. "../helptexts/iron_2.lua",
250+ icon = dirname .. "pics/iron_2_0.png",
251 attributes = { "resi" },
252 programs = {
253 program = {
254@@ -212,6 +221,7 @@
255 -- TRANSLATORS: This is a resource name used in lists of resources
256 descname = pgettext("immovable", "Resources: A Lot of Stones"),
257 helptext_script = dirname .. "../helptexts/stones_2.lua",
258+ icon = dirname .. "pics/stones_2_0.png",
259 attributes = { "resi" },
260 programs = {
261 program = {
262
263=== modified file 'data/tribes/immovables/resi/barbarians/init.lua'
264--- data/tribes/immovables/resi/barbarians/init.lua 2018-09-01 10:50:00 +0000
265+++ data/tribes/immovables/resi/barbarians/init.lua 2019-05-03 18:29:53 +0000
266@@ -6,6 +6,7 @@
267 -- TRANSLATORS: This is a resource name used in lists of resources
268 descname = pgettext("immovable", "Resources: None"),
269 helptext_script = dirname .. "../helptexts/none.lua",
270+ icon = dirname .. "pics/none.png",
271 attributes = { "resi" },
272 programs = {
273 program = {
274@@ -28,6 +29,7 @@
275 -- TRANSLATORS: This is a resource name used in lists of resources
276 descname = pgettext("immovable", "Resources: Water Vein"),
277 helptext_script = dirname .. "../helptexts/water.lua",
278+ icon = dirname .. "pics/water.png",
279 attributes = { "resi" },
280 programs = {
281 program = {
282@@ -50,6 +52,7 @@
283 -- TRANSLATORS: This is a resource name used in lists of resources
284 descname = pgettext("immovable", "Resources: Coal Vein"),
285 helptext_script = dirname .. "../helptexts/coal_1.lua",
286+ icon = dirname .. "pics/coal_1.png",
287 attributes = { "resi" },
288 programs = {
289 program = {
290@@ -72,6 +75,7 @@
291 -- TRANSLATORS: This is a resource name used in lists of resources
292 descname = pgettext("immovable", "Resources: Gold Vein"),
293 helptext_script = dirname .. "../helptexts/gold_1.lua",
294+ icon = dirname .. "pics/gold_1.png",
295 attributes = { "resi" },
296 programs = {
297 program = {
298@@ -94,6 +98,7 @@
299 -- TRANSLATORS: This is a resource name used in lists of resources
300 descname = pgettext("immovable", "Resources: Iron Vein"),
301 helptext_script = dirname .. "../helptexts/iron_1.lua",
302+ icon = dirname .. "pics/iron_1.png",
303 attributes = { "resi" },
304 programs = {
305 program = {
306@@ -116,6 +121,7 @@
307 -- TRANSLATORS: This is a resource name used in lists of resources
308 descname = pgettext("immovable", "Resources: Some Stones"),
309 helptext_script = dirname .. "../helptexts/stones_1.lua",
310+ icon = dirname .. "pics/stones_1.png",
311 attributes = { "resi" },
312 programs = {
313 program = {
314@@ -138,6 +144,7 @@
315 -- TRANSLATORS: This is a resource name used in lists of resources
316 descname = pgettext("immovable", "Resources: Main Coal Vein"),
317 helptext_script = dirname .. "../helptexts/coal_2.lua",
318+ icon = dirname .. "pics/coal_2.png",
319 attributes = { "resi" },
320 programs = {
321 program = {
322@@ -160,6 +167,7 @@
323 -- TRANSLATORS: This is a resource name used in lists of resources
324 descname = pgettext("immovable", "Resources: Main Gold Vein"),
325 helptext_script = dirname .. "../helptexts/gold_2.lua",
326+ icon = dirname .. "pics/gold_2.png",
327 attributes = { "resi" },
328 programs = {
329 program = {
330@@ -182,6 +190,7 @@
331 -- TRANSLATORS: This is a resource name used in lists of resources
332 descname = pgettext("immovable", "Resources: Main Iron Vein"),
333 helptext_script = dirname .. "../helptexts/iron_2.lua",
334+ icon = dirname .. "pics/iron_2.png",
335 attributes = { "resi" },
336 programs = {
337 program = {
338@@ -204,6 +213,7 @@
339 -- TRANSLATORS: This is a resource name used in lists of resources
340 descname = pgettext("immovable", "Resources: A Lot of Stones"),
341 helptext_script = dirname .. "../helptexts/stones_2.lua",
342+ icon = dirname .. "pics/stones_2.png",
343 attributes = { "resi" },
344 programs = {
345 program = {
346
347=== modified file 'data/tribes/immovables/resi/empire/init.lua'
348--- data/tribes/immovables/resi/empire/init.lua 2018-09-01 10:50:00 +0000
349+++ data/tribes/immovables/resi/empire/init.lua 2019-05-03 18:29:53 +0000
350@@ -6,6 +6,7 @@
351 -- TRANSLATORS: This is a resource name used in lists of resources
352 descname = pgettext("immovable", "Resources: None"),
353 helptext_script = dirname .. "../helptexts/none.lua",
354+ icon = dirname .. "pics/none.png",
355 attributes = { "resi" },
356 programs = {
357 program = {
358@@ -28,6 +29,7 @@
359 -- TRANSLATORS: This is a resource name used in lists of resources
360 descname = pgettext("immovable", "Resources: Water Vein"),
361 helptext_script = dirname .. "../helptexts/water.lua",
362+ icon = dirname .. "pics/water.png",
363 attributes = { "resi" },
364 programs = {
365 program = {
366@@ -50,6 +52,7 @@
367 -- TRANSLATORS: This is a resource name used in lists of resources
368 descname = pgettext("immovable", "Resources: Coal Vein"),
369 helptext_script = dirname .. "../helptexts/coal_1.lua",
370+ icon = dirname .. "pics/coal_1.png",
371 attributes = { "resi" },
372 programs = {
373 program = {
374@@ -72,6 +75,7 @@
375 -- TRANSLATORS: This is a resource name used in lists of resources
376 descname = pgettext("immovable", "Resources: Gold Vein"),
377 helptext_script = dirname .. "../helptexts/gold_1.lua",
378+ icon = dirname .. "pics/gold_1.png",
379 attributes = { "resi" },
380 programs = {
381 program = {
382@@ -94,6 +98,7 @@
383 -- TRANSLATORS: This is a resource name used in lists of resources
384 descname = pgettext("immovable", "Resources: Iron Vein"),
385 helptext_script = dirname .. "../helptexts/iron_1.lua",
386+ icon = dirname .. "pics/iron_1.png",
387 attributes = { "resi" },
388 programs = {
389 program = {
390@@ -116,6 +121,7 @@
391 -- TRANSLATORS: This is a resource name used in lists of resources
392 descname = pgettext("immovable", "Resources: Some Stones"),
393 helptext_script = dirname .. "../helptexts/stones_1.lua",
394+ icon = dirname .. "pics/stones_1.png",
395 attributes = { "resi" },
396 programs = {
397 program = {
398@@ -138,6 +144,7 @@
399 -- TRANSLATORS: This is a resource name used in lists of resources
400 descname = pgettext("immovable", "Resources: Main Coal Vein"),
401 helptext_script = dirname .. "../helptexts/coal_2.lua",
402+ icon = dirname .. "pics/coal_2.png",
403 attributes = { "resi" },
404 programs = {
405 program = {
406@@ -160,6 +167,7 @@
407 -- TRANSLATORS: This is a resource name used in lists of resources
408 descname = pgettext("immovable", "Resources: Main Gold Vein"),
409 helptext_script = dirname .. "../helptexts/gold_2.lua",
410+ icon = dirname .. "pics/gold_2.png",
411 attributes = { "resi" },
412 programs = {
413 program = {
414@@ -182,6 +190,7 @@
415 -- TRANSLATORS: This is a resource name used in lists of resources
416 descname = pgettext("immovable", "Resources: Main Iron Vein"),
417 helptext_script = dirname .. "../helptexts/iron_2.lua",
418+ icon = dirname .. "pics/iron_2.png",
419 attributes = { "resi" },
420 programs = {
421 program = {
422@@ -204,6 +213,7 @@
423 -- TRANSLATORS: This is a resource name used in lists of resources
424 descname = pgettext("immovable", "Resources: A Lot of Stones"),
425 helptext_script = dirname .. "../helptexts/stones_2.lua",
426+ icon = dirname .. "pics/stones_2.png",
427 attributes = { "resi" },
428 programs = {
429 program = {
430
431=== modified file 'data/tribes/immovables/resi/frisians/init.lua'
432--- data/tribes/immovables/resi/frisians/init.lua 2018-09-21 20:12:46 +0000
433+++ data/tribes/immovables/resi/frisians/init.lua 2019-05-03 18:29:53 +0000
434@@ -6,6 +6,7 @@
435 -- TRANSLATORS: This is a resource name used in lists of resources
436 descname = pgettext("immovable", "Resources: None"),
437 helptext_script = dirname .. "../helptexts/none.lua",
438+ icon = dirname .. "pics/none_0.png",
439 attributes = { "resi" },
440 programs = {
441 program = {
442@@ -28,6 +29,7 @@
443 -- TRANSLATORS: This is a resource name used in lists of resources
444 descname = pgettext("immovable", "Resources: Water Vein"),
445 helptext_script = dirname .. "../helptexts/water.lua",
446+ icon = dirname .. "pics/water_0.png",
447 attributes = { "resi" },
448 programs = {
449 program = {
450@@ -51,6 +53,7 @@
451 -- TRANSLATORS: This is a resource name used in lists of resources
452 descname = pgettext("immovable", "Resources: Coal Vein"),
453 helptext_script = dirname .. "../helptexts/coal_1.lua",
454+ icon = dirname .. "pics/coal_1_0.png",
455 attributes = { "resi" },
456 programs = {
457 program = {
458@@ -74,6 +77,7 @@
459 -- TRANSLATORS: This is a resource name used in lists of resources
460 descname = pgettext("immovable", "Resources: Gold Vein"),
461 helptext_script = dirname .. "../helptexts/gold_1.lua",
462+ icon = dirname .. "pics/gold_1_0.png",
463 attributes = { "resi" },
464 programs = {
465 program = {
466@@ -97,6 +101,7 @@
467 -- TRANSLATORS: This is a resource name used in lists of resources
468 descname = pgettext("immovable", "Resources: Iron Vein"),
469 helptext_script = dirname .. "../helptexts/iron_1.lua",
470+ icon = dirname .. "pics/iron_1_0.png",
471 attributes = { "resi" },
472 programs = {
473 program = {
474@@ -120,6 +125,7 @@
475 -- TRANSLATORS: This is a resource name used in lists of resources
476 descname = pgettext("immovable", "Resources: Some Stones"),
477 helptext_script = dirname .. "../helptexts/stones_1.lua",
478+ icon = dirname .. "pics/stones_1_0.png",
479 attributes = { "resi" },
480 programs = {
481 program = {
482@@ -143,6 +149,7 @@
483 -- TRANSLATORS: This is a resource name used in lists of resources
484 descname = pgettext("immovable", "Resources: Main Coal Vein"),
485 helptext_script = dirname .. "../helptexts/coal_2.lua",
486+ icon = dirname .. "pics/coal_2_0.png",
487 attributes = { "resi" },
488 programs = {
489 program = {
490@@ -166,6 +173,7 @@
491 -- TRANSLATORS: This is a resource name used in lists of resources
492 descname = pgettext("immovable", "Resources: Main Gold Vein"),
493 helptext_script = dirname .. "../helptexts/gold_2.lua",
494+ icon = dirname .. "pics/gold_2_0.png",
495 attributes = { "resi" },
496 programs = {
497 program = {
498@@ -189,6 +197,7 @@
499 -- TRANSLATORS: This is a resource name used in lists of resources
500 descname = pgettext("immovable", "Resources: Main Iron Vein"),
501 helptext_script = dirname .. "../helptexts/iron_2.lua",
502+ icon = dirname .. "pics/iron_2_0.png",
503 attributes = { "resi" },
504 programs = {
505 program = {
506@@ -212,6 +221,7 @@
507 -- TRANSLATORS: This is a resource name used in lists of resources
508 descname = pgettext("immovable", "Resources: A Lot of Stones"),
509 helptext_script = dirname .. "../helptexts/stones_2.lua",
510+ icon = dirname .. "pics/stones_2_0.png",
511 attributes = { "resi" },
512 programs = {
513 program = {
514
515=== modified file 'data/tribes/immovables/shipconstruction_atlanteans/init.lua'
516--- data/tribes/immovables/shipconstruction_atlanteans/init.lua 2018-02-28 09:38:13 +0000
517+++ data/tribes/immovables/shipconstruction_atlanteans/init.lua 2019-05-03 18:29:53 +0000
518@@ -24,7 +24,8 @@
519 idle = {
520 pictures = path.list_files(dirname .. "build_??.png"),
521 hotspot = { 118, 94 },
522- fps = 1
523+ fps = 1,
524+ representative_frame = 5
525 },
526 }
527 }
528
529=== modified file 'data/tribes/immovables/shipconstruction_barbarians/init.lua'
530--- data/tribes/immovables/shipconstruction_barbarians/init.lua 2018-02-28 09:38:13 +0000
531+++ data/tribes/immovables/shipconstruction_barbarians/init.lua 2019-05-03 18:29:53 +0000
532@@ -24,7 +24,8 @@
533 idle = {
534 pictures = path.list_files(dirname .. "build_??.png"),
535 hotspot = { 115, 82 },
536- fps = 1
537+ fps = 1,
538+ representative_frame = 5
539 },
540 }
541 }
542
543=== modified file 'data/tribes/immovables/shipconstruction_empire/init.lua'
544--- data/tribes/immovables/shipconstruction_empire/init.lua 2018-02-28 09:38:13 +0000
545+++ data/tribes/immovables/shipconstruction_empire/init.lua 2019-05-03 18:29:53 +0000
546@@ -24,7 +24,8 @@
547 idle = {
548 pictures = path.list_files(dirname .. "build_??.png"),
549 hotspot = { 115, 78 },
550- fps = 1
551+ fps = 1,
552+ representative_frame = 5
553 },
554 }
555 }
556
557=== modified file 'data/tribes/immovables/shipconstruction_frisians/init.lua'
558--- data/tribes/immovables/shipconstruction_frisians/init.lua 2018-09-09 04:18:24 +0000
559+++ data/tribes/immovables/shipconstruction_frisians/init.lua 2019-05-03 18:29:53 +0000
560@@ -24,7 +24,8 @@
561 idle = {
562 pictures = path.list_files (dirname .. "build_??.png"),
563 hotspot = { 75, 141 },
564- fps = 1
565+ fps = 1,
566+ representative_frame = 3
567 },
568 }
569 }
570
571=== modified file 'data/tribes/scripting/help/building_help.lua'
572--- data/tribes/scripting/help/building_help.lua 2019-04-07 05:46:13 +0000
573+++ data/tribes/scripting/help/building_help.lua 2019-05-03 18:29:53 +0000
574@@ -57,7 +57,7 @@
575 am = amount
576 end
577 end
578- local items_with_resource = { wl.Game():get_immovable_description(resi).representative_image }
579+ local items_with_resource = { wl.Game():get_immovable_description(resi).icon_name }
580 for count, item in pairs(items) do
581 table.insert(items_with_resource, item.icon_name)
582 end
583@@ -181,13 +181,13 @@
584 local result = h2(_"Lore")
585 local lore_text = building_helptext_lore()
586 if type(lore_text) == "table" then
587- result = result .. li_image(building_description.representative_image, lore_text[1])
588+ result = result .. li_object(building_description.name, lore_text[1])
589 for k,v in ipairs({table.unpack(lore_text, 2)}) do
590 result = result .. p(v)
591 end
592 else
593 result = result ..
594- li_image(building_description.representative_image, lore_text)
595+ li_object(building_description.name, lore_text)
596 end
597
598 local lore_author = building_helptext_lore_author()
599
600=== modified file 'data/tribes/scripting/help/immovable_help.lua'
601--- data/tribes/scripting/help/immovable_help.lua 2018-03-24 14:31:37 +0000
602+++ data/tribes/scripting/help/immovable_help.lua 2019-05-03 18:29:53 +0000
603@@ -32,7 +32,7 @@
604
605 -- TRANSLATORS: Put 2 sentences one after the other. Languages using Chinese script probably want to lose the blank space here.
606 local purpose_text = pgettext("sentence_separator", "%s %s"):bformat(immovable_helptext(), immovable_helptext(tribe.name))
607- local result = li_image(immovable_description.representative_image, purpose_text)
608+ local result = li_object(immovable_description.name, purpose_text)
609
610 -- Build cost
611 local buildcost = ""
612
613=== modified file 'data/world/immovables/trees/alder/init.lua'
614--- data/world/immovables/trees/alder/init.lua 2019-03-17 08:30:43 +0000
615+++ data/world/immovables/trees/alder/init.lua 2019-05-03 18:29:53 +0000
616@@ -88,6 +88,7 @@
617 name = "alder_summer_old",
618 descname = _ "Alder (Old)",
619 species = _ "Alder",
620+ icon = dirname .. "old/idle_0.png",
621 editor_category = "trees_deciduous",
622 size = "small",
623 attributes = { "tree" },
624
625=== modified file 'data/world/immovables/trees/aspen/init.lua'
626--- data/world/immovables/trees/aspen/init.lua 2019-03-17 08:30:43 +0000
627+++ data/world/immovables/trees/aspen/init.lua 2019-05-03 18:29:53 +0000
628@@ -83,6 +83,7 @@
629 name = "aspen_summer_old",
630 descname = _ "Aspen (Old)",
631 species = _ "Aspen",
632+ icon = dirname .. "old/idle_0.png",
633 editor_category = "trees_deciduous",
634 size = "small",
635 attributes = { "tree" },
636
637=== modified file 'data/world/immovables/trees/beech/init.lua'
638--- data/world/immovables/trees/beech/init.lua 2019-03-17 08:30:43 +0000
639+++ data/world/immovables/trees/beech/init.lua 2019-05-03 18:29:53 +0000
640@@ -80,6 +80,7 @@
641 name = "beech_summer_old",
642 descname = _ "Beech (Old)",
643 species = _ "Beech",
644+ icon = dirname .. "old/idle_0.png",
645 editor_category = "trees_deciduous",
646 size = "small",
647 attributes = { "tree" },
648
649=== modified file 'data/world/immovables/trees/birch/init.lua'
650--- data/world/immovables/trees/birch/init.lua 2019-03-17 08:30:43 +0000
651+++ data/world/immovables/trees/birch/init.lua 2019-05-03 18:29:53 +0000
652@@ -83,6 +83,7 @@
653 name = "birch_summer_old",
654 descname = _ "Birch (Old)",
655 species = _ "Birch",
656+ icon = dirname .. "old/idle_0.png",
657 editor_category = "trees_deciduous",
658 size = "small",
659 attributes = { "tree" },
660
661=== modified file 'data/world/immovables/trees/cirrus/init.lua'
662--- data/world/immovables/trees/cirrus/init.lua 2018-11-03 11:27:18 +0000
663+++ data/world/immovables/trees/cirrus/init.lua 2019-05-03 18:29:53 +0000
664@@ -85,6 +85,7 @@
665 descname = _ "Cirrus Tree (Old)",
666 -- TRANSLATORS: This is a fictitious tree. Be creative if you want.
667 species = _ "Cirrus Tree",
668+ icon = dirname .. "old/idle_0.png",
669 editor_category = "trees_wasteland",
670 size = "small",
671 attributes = { "tree" },
672
673=== modified file 'data/world/immovables/trees/larch/init.lua'
674--- data/world/immovables/trees/larch/init.lua 2019-03-17 08:30:43 +0000
675+++ data/world/immovables/trees/larch/init.lua 2019-05-03 18:29:53 +0000
676@@ -80,6 +80,7 @@
677 name = "larch_summer_old",
678 descname = _ "Larch (Old)",
679 species = _ "Larch",
680+ icon = dirname .. "old/idle_0.png",
681 editor_category = "trees_coniferous",
682 size = "small",
683 attributes = { "tree" },
684
685=== modified file 'data/world/immovables/trees/liana/init.lua'
686--- data/world/immovables/trees/liana/init.lua 2018-11-03 11:27:18 +0000
687+++ data/world/immovables/trees/liana/init.lua 2019-05-03 18:29:53 +0000
688@@ -88,6 +88,7 @@
689 descname = _ "Liana Tree (Old)",
690 -- TRANSLATORS: This is a fictitious tree. Be creative if you want.
691 species = _ "Liana Tree",
692+ icon = dirname .. "old/idle_0.png",
693 editor_category = "trees_wasteland",
694 size = "small",
695 attributes = { "tree" },
696
697=== modified file 'data/world/immovables/trees/maple/init.lua'
698--- data/world/immovables/trees/maple/init.lua 2019-03-17 08:30:43 +0000
699+++ data/world/immovables/trees/maple/init.lua 2019-05-03 18:29:53 +0000
700@@ -80,6 +80,7 @@
701 name = "maple_winter_old",
702 descname = _ "Maple (Old)",
703 species = _ "Maple",
704+ icon = dirname .. "old/idle_0.png",
705 editor_category = "trees_deciduous",
706 size = "small",
707 attributes = { "tree" },
708
709=== modified file 'data/world/immovables/trees/mushroom_dark/init.lua'
710--- data/world/immovables/trees/mushroom_dark/init.lua 2018-11-03 11:27:18 +0000
711+++ data/world/immovables/trees/mushroom_dark/init.lua 2019-05-03 18:29:53 +0000
712@@ -85,6 +85,7 @@
713 descname = _ "Dark Mushroom Tree (Old)",
714 -- TRANSLATORS: This is a fictitious tree. Be creative if you want.
715 species = _ "Dark Mushroom Tree",
716+ icon = dirname .. "old/idle_0.png",
717 editor_category = "trees_wasteland",
718 size = "small",
719 attributes = { "tree" },
720
721=== modified file 'data/world/immovables/trees/mushroom_green/init.lua'
722--- data/world/immovables/trees/mushroom_green/init.lua 2018-11-03 11:27:18 +0000
723+++ data/world/immovables/trees/mushroom_green/init.lua 2019-05-03 18:29:53 +0000
724@@ -85,6 +85,7 @@
725 descname = _ "Green Mushroom Tree (Old)",
726 -- TRANSLATORS: This is a fictitious tree. Be creative if you want.
727 species = _ "Green Mushroom Tree",
728+ icon = dirname .. "old/idle_0.png",
729 editor_category = "trees_wasteland",
730 size = "small",
731 attributes = { "tree" },
732
733=== modified file 'data/world/immovables/trees/mushroom_red/init.lua'
734--- data/world/immovables/trees/mushroom_red/init.lua 2018-11-03 11:27:18 +0000
735+++ data/world/immovables/trees/mushroom_red/init.lua 2019-05-03 18:29:53 +0000
736@@ -88,6 +88,7 @@
737 descname = _ "Red Mushroom Tree (Old)",
738 -- TRANSLATORS: This is a fictitious tree. Be creative if you want.
739 species = _ "Red Mushroom Tree",
740+ icon = dirname .. "old/idle_0.png",
741 editor_category = "trees_wasteland",
742 size = "small",
743 attributes = { "tree" },
744
745=== modified file 'data/world/immovables/trees/oak/init.lua'
746--- data/world/immovables/trees/oak/init.lua 2019-03-17 08:30:43 +0000
747+++ data/world/immovables/trees/oak/init.lua 2019-05-03 18:29:53 +0000
748@@ -80,6 +80,7 @@
749 name = "oak_summer_old",
750 descname = _ "Oak (Old)",
751 species = _ "Oak",
752+ icon = dirname .. "old/idle_0.png",
753 editor_category = "trees_deciduous",
754 size = "small",
755 attributes = { "tree" },
756
757=== modified file 'data/world/immovables/trees/palm_borassus/init.lua'
758--- data/world/immovables/trees/palm_borassus/init.lua 2019-03-17 08:30:43 +0000
759+++ data/world/immovables/trees/palm_borassus/init.lua 2019-05-03 18:29:53 +0000
760@@ -80,6 +80,7 @@
761 name = "palm_borassus_desert_old",
762 descname = _ "Borassus Palm (Old)",
763 species = _ "Borassus Palm",
764+ icon = dirname .. "old/idle_0.png",
765 editor_category = "trees_palm",
766 size = "small",
767 attributes = { "tree" },
768
769=== modified file 'data/world/immovables/trees/palm_coconut/init.lua'
770--- data/world/immovables/trees/palm_coconut/init.lua 2019-03-17 08:30:43 +0000
771+++ data/world/immovables/trees/palm_coconut/init.lua 2019-05-03 18:29:53 +0000
772@@ -80,6 +80,7 @@
773 name = "palm_coconut_desert_old",
774 descname = _ "Coconut Palm (Old)",
775 species = _ "Coconut Palm",
776+ icon = dirname .. "old/idle_0.png",
777 editor_category = "trees_palm",
778 size = "small",
779 attributes = { "tree" },
780
781=== modified file 'data/world/immovables/trees/palm_date/init.lua'
782--- data/world/immovables/trees/palm_date/init.lua 2019-03-17 08:30:43 +0000
783+++ data/world/immovables/trees/palm_date/init.lua 2019-05-03 18:29:53 +0000
784@@ -83,6 +83,7 @@
785 name = "palm_date_desert_old",
786 descname = _ "Date Palm (Old)",
787 species = _ "Date Palm",
788+ icon = dirname .. "old/idle_0.png",
789 editor_category = "trees_palm",
790 size = "small",
791 attributes = { "tree" },
792
793=== modified file 'data/world/immovables/trees/palm_oil/init.lua'
794--- data/world/immovables/trees/palm_oil/init.lua 2019-03-17 08:30:43 +0000
795+++ data/world/immovables/trees/palm_oil/init.lua 2019-05-03 18:29:53 +0000
796@@ -84,6 +84,7 @@
797 name = "palm_oil_desert_old",
798 descname = _ "Oil Palm (Old)",
799 species = _ "Oil Palm",
800+ icon = dirname .. "old/idle_0.png",
801 editor_category = "trees_palm",
802 size = "small",
803 attributes = { "tree" },
804
805=== modified file 'data/world/immovables/trees/palm_roystonea/init.lua'
806--- data/world/immovables/trees/palm_roystonea/init.lua 2019-03-17 08:30:43 +0000
807+++ data/world/immovables/trees/palm_roystonea/init.lua 2019-05-03 18:29:53 +0000
808@@ -80,6 +80,7 @@
809 name = "palm_roystonea_desert_old",
810 descname = _ "Roystonea regia Palm (Old)",
811 species = _ "Roystonea regia Palm",
812+ icon = dirname .. "old/idle_0.png",
813 editor_category = "trees_palm",
814 size = "small",
815 attributes = { "tree" },
816
817=== modified file 'data/world/immovables/trees/rowan/init.lua'
818--- data/world/immovables/trees/rowan/init.lua 2019-03-17 08:30:43 +0000
819+++ data/world/immovables/trees/rowan/init.lua 2019-05-03 18:29:53 +0000
820@@ -83,6 +83,7 @@
821 name = "rowan_summer_old",
822 descname = _ "Rowan (Old)",
823 species = _ "Rowan",
824+ icon = dirname .. "old/idle_0.png",
825 editor_category = "trees_deciduous",
826 size = "small",
827 attributes = { "tree" },
828
829=== modified file 'data/world/immovables/trees/spruce/init.lua'
830--- data/world/immovables/trees/spruce/init.lua 2019-03-17 08:30:43 +0000
831+++ data/world/immovables/trees/spruce/init.lua 2019-05-03 18:29:53 +0000
832@@ -80,6 +80,7 @@
833 name = "spruce_summer_old",
834 descname = _ "Spruce (Old)",
835 species = _ "Spruce",
836+ icon = dirname .. "old/idle_0.png",
837 editor_category = "trees_coniferous",
838 size = "small",
839 attributes = { "tree" },
840
841=== modified file 'data/world/immovables/trees/twine/init.lua'
842--- data/world/immovables/trees/twine/init.lua 2018-11-03 11:27:18 +0000
843+++ data/world/immovables/trees/twine/init.lua 2019-05-03 18:29:53 +0000
844@@ -85,6 +85,7 @@
845 descname = _ "Twine Tree (Old)",
846 -- TRANSLATORS: This is a fictitious tree. Be creative if you want.
847 species = _ "Twine Tree",
848+ icon = dirname .. "old/idle_0.png",
849 editor_category = "trees_wasteland",
850 size = "small",
851 attributes = { "tree" },
852
853=== modified file 'data/world/immovables/trees/umbrella_green/init.lua'
854--- data/world/immovables/trees/umbrella_green/init.lua 2018-11-03 11:27:18 +0000
855+++ data/world/immovables/trees/umbrella_green/init.lua 2019-05-03 18:29:53 +0000
856@@ -85,6 +85,7 @@
857 descname = _ "Green Umbrella Tree (Old)",
858 -- TRANSLATORS: This is a fictitious tree. Be creative if you want.
859 species = _ "Green Umbrella Tree",
860+ icon = dirname .. "old/idle_0.png",
861 editor_category = "trees_wasteland",
862 size = "small",
863 attributes = { "tree" },
864
865=== modified file 'data/world/immovables/trees/umbrella_red/init.lua'
866--- data/world/immovables/trees/umbrella_red/init.lua 2018-11-03 11:27:18 +0000
867+++ data/world/immovables/trees/umbrella_red/init.lua 2019-05-03 18:29:53 +0000
868@@ -88,6 +88,7 @@
869 descname = _ "Red Umbrella Tree (Old)",
870 -- TRANSLATORS: This is a fictitious tree. Be creative if you want.
871 species = _ "Red Umbrella Tree",
872+ icon = dirname .. "old/idle_0.png",
873 editor_category = "trees_wasteland",
874 size = "small",
875 attributes = { "tree" },
876
877=== modified file 'doc/sphinx/source/animations.rst'
878--- doc/sphinx/source/animations.rst 2019-04-24 06:32:02 +0000
879+++ doc/sphinx/source/animations.rst 2019-05-03 18:29:53 +0000
880@@ -26,6 +26,7 @@
881 path = "sound/foo/bar",
882 priority = 128
883 },
884+ representative_frame = 3,
885 },
886 working = ...
887 }
888@@ -103,6 +104,8 @@
889 Each mimap entry must define the ``files`` and the ``scale``.
890 See also :ref:`animations_converting_formats`.
891
892+**representative_frame**
893+ *Optional*. Choose the animation frame that will be displayed in messages and in the encyclopedia as a representative image. Default is 0.
894
895 Directional Animations
896 ----------------------
897
898=== modified file 'src/graphic/animation.cc'
899--- src/graphic/animation.cc 2019-04-24 20:48:37 +0000
900+++ src/graphic/animation.cc 2019-05-03 18:29:53 +0000
901@@ -85,7 +85,6 @@
902 uint16_t nr_frames() const override;
903 uint32_t frametime() const override;
904 const Image* representative_image(const RGBColor* clr) const override;
905- const std::string& representative_image_filename() const override;
906 virtual void blit(uint32_t time,
907 const Widelands::Coords& coords,
908 const Rectf& source_rect,
909@@ -162,7 +161,8 @@
910 }
911
912 NonPackedAnimation::NonPackedAnimation(const LuaTable& table)
913- : frametime_(FRAME_LENGTH),
914+ : Animation(table.has_key("representative_frame") ? table.get_int("representative_frame") : 0),
915+ frametime_(FRAME_LENGTH),
916 hotspot_(table.get_vector<std::string, int>("hotspot")),
917 sound_effect_(kNoSoundEffect),
918 sound_priority_(kFxPriorityLowest),
919@@ -224,6 +224,10 @@
920 frametime_ = 1000 / get_positive_int(table, "fps");
921 }
922
923+ if (representative_frame_ < 0 || representative_frame_ > nr_frames_ - 1) {
924+ throw wexception("Animation has %d as its representative frame, but the frame indices available are 0 - %d", representative_frame_, nr_frames_ - 1);
925+ }
926+
927 // Perform some checks to make sure that the data is complete and consistent
928 const bool should_have_playercolor = mipmaps_.begin()->second->has_playercolor_masks;
929 for (const auto& mipmap : mipmaps_) {
930@@ -327,8 +331,8 @@
931 const MipMapEntry& mipmap = *mipmaps_.at(1.0f);
932 std::vector<std::string> images = mipmap.image_files;
933 assert(!images.empty());
934- const Image* image = (mipmap.has_playercolor_masks && clr) ? playercolor_image(*clr, images[0]) :
935- g_gr->images().get(images[0]);
936+ const Image* image = (mipmap.has_playercolor_masks && clr) ? playercolor_image(*clr, images[representative_frame_]) :
937+ g_gr->images().get(images[representative_frame_]);
938
939 const int w = image->width();
940 const int h = image->height();
941@@ -338,11 +342,6 @@
942 return rv;
943 }
944
945-// TODO(GunChleoc): This is only here for the font renderers.
946-const std::string& NonPackedAnimation::representative_image_filename() const {
947- return mipmaps_.at(1.0f)->image_files[0];
948-}
949-
950 uint32_t NonPackedAnimation::current_frame(uint32_t time) const {
951 if (nr_frames() > 1) {
952 return (play_once_ && time / frametime_ > static_cast<uint32_t>(nr_frames() - 1)) ?
953@@ -437,6 +436,12 @@
954 animations_.push_back(std::unique_ptr<Animation>(new NonPackedAnimation(table)));
955 return animations_.size();
956 }
957+uint32_t AnimationManager::load(const std::string& map_object_name, const LuaTable& table) {
958+ animations_.push_back(std::unique_ptr<Animation>(new NonPackedAnimation(table)));
959+ const size_t result = animations_.size();
960+ representative_animations_by_map_object_name_.insert(std::make_pair(map_object_name, result));
961+ return result;
962+}
963
964 const Animation& AnimationManager::get_animation(uint32_t id) const {
965 if (!id || id > animations_.size())
966@@ -454,3 +459,11 @@
967 }
968 return representative_images_.at(hash).get();
969 }
970+
971+const Image* AnimationManager::get_representative_image(const std::string& map_object_name, const RGBColor* clr) {
972+ if (representative_animations_by_map_object_name_.count(map_object_name) != 1) {
973+ log("Warning: %s has no animation assigned for its representative image, or it's not a known map object\n", map_object_name.c_str());
974+ return new Texture(0, 0);
975+ }
976+ return get_representative_image(representative_animations_by_map_object_name_.at(map_object_name), clr);
977+}
978
979=== modified file 'src/graphic/animation.h'
980--- src/graphic/animation.h 2019-04-24 20:48:37 +0000
981+++ src/graphic/animation.h 2019-05-03 18:29:53 +0000
982@@ -53,7 +53,7 @@
983 */
984 class Animation {
985 public:
986- Animation() {
987+ Animation(int representative_frame) : representative_frame_(representative_frame) {
988 }
989 virtual ~Animation() {
990 }
991@@ -82,8 +82,6 @@
992 /// The 'clr' is the player color used for blending - the parameter can be
993 /// 'nullptr', in which case the neutral image will be returned.
994 virtual const Image* representative_image(const RGBColor* clr) const = 0;
995- /// The filename of the image used for the first frame, without player color.
996- virtual const std::string& representative_image_filename() const = 0;
997
998 /// Blit the animation frame that should be displayed at the given time index
999 /// into the given 'destination_rect'.
1000@@ -105,6 +103,9 @@
1001 /// If 'coords' == Widelands::Coords::null(), skip playing any sound effects.
1002 virtual void trigger_sound(uint32_t time, const Widelands::Coords& coords) const = 0;
1003
1004+protected:
1005+ int representative_frame_;
1006+
1007 private:
1008 DISALLOW_COPY_AND_ASSIGN(Animation);
1009 };
1010@@ -122,6 +123,8 @@
1011 * Optional parameters in the Lua table are 'fps' and 'sound_effect'.
1012 */
1013 uint32_t load(const LuaTable& table);
1014+ /// Same as above, but this animation will be used for getting a representative image by map object name
1015+ uint32_t load(const std::string& map_object_name, const LuaTable& table);
1016
1017 /// Returns the animation with the given ID or throws an exception if it is
1018 /// unknown.
1019@@ -131,11 +134,13 @@
1020 /// If this image has been generated before, it is pulled from the cache using
1021 /// the clr argument that was used previously.
1022 const Image* get_representative_image(uint32_t id, const RGBColor* clr = nullptr);
1023+ const Image* get_representative_image(const std::string& map_object_name, const RGBColor* clr = nullptr);
1024
1025 private:
1026 std::vector<std::unique_ptr<Animation>> animations_;
1027 std::map<std::pair<uint32_t, const RGBColor*>, std::unique_ptr<const Image>>
1028 representative_images_;
1029+ std::map<std::string, uint32_t> representative_animations_by_map_object_name_;
1030 };
1031
1032 #endif // end of include guard: WL_GRAPHIC_ANIMATION_H
1033
1034=== modified file 'src/graphic/text/rt_parse.cc'
1035--- src/graphic/text/rt_parse.cc 2019-02-23 11:00:49 +0000
1036+++ src/graphic/text/rt_parse.cc 2019-05-03 18:29:53 +0000
1037@@ -481,15 +481,18 @@
1038 ^^^^^^^^^^
1039
1040 * **src**: The path to the image, relative to the ``data`` directory.
1041+* **object**: Show the representative image of a map object instead of using ``src``.
1042 * **ref**: To be implemented
1043 * **color**: Player color for the image as a hex value
1044-* **width**: Width of the image as a pixel amount. The corresponding height will be matched
1045- automatically.
1046+* **width**: Width of the image as a pixel amount.
1047+ The corresponding height will be matched automatically.
1048+ Not supported in conjunction with the ``object`` parameter.
1049
1050 :ref:`Return to tag index<rt_tags>`
1051 */
1052 TagConstraint tc;
1053 tc.allowed_attrs.insert("src");
1054+ tc.allowed_attrs.insert("object");
1055 tc.allowed_attrs.insert("ref");
1056 tc.allowed_attrs.insert("color");
1057 tc.allowed_attrs.insert("width");
1058
1059=== modified file 'src/graphic/text/rt_render.cc'
1060--- src/graphic/text/rt_render.cc 2019-02-23 11:00:49 +0000
1061+++ src/graphic/text/rt_render.cc 2019-05-03 18:29:53 +0000
1062@@ -36,6 +36,7 @@
1063 #include "base/vector.h"
1064 #include "base/wexception.h"
1065 #include "graphic/align.h"
1066+#include "graphic/animation.h"
1067 #include "graphic/graphic.h"
1068 #include "graphic/image_cache.h"
1069 #include "graphic/image_io.h"
1070@@ -970,6 +971,17 @@
1071 check_size();
1072 }
1073
1074+ ImgRenderNode(NodeStyle& ns,
1075+ const Image* image)
1076+ : RenderNode(ns),
1077+ image_(image),
1078+ filename_(""),
1079+ scale_(1.0f),
1080+ color_(RGBColor(0, 0, 0)),
1081+ use_playercolor_(false) {
1082+ check_size();
1083+ }
1084+
1085 std::string debug_info() const override {
1086 return "img";
1087 }
1088@@ -989,14 +1001,14 @@
1089 const Image* image_;
1090 const std::string filename_;
1091 const double scale_;
1092- const RGBColor& color_;
1093+ const RGBColor color_;
1094 bool use_playercolor_;
1095 };
1096
1097 std::shared_ptr<UI::RenderedText> ImgRenderNode::render(TextureCache* texture_cache) {
1098 std::shared_ptr<UI::RenderedText> rendered_text(new UI::RenderedText());
1099
1100- if (scale_ == 1.0) {
1101+ if (scale_ == 1.0 || filename_.empty()) {
1102 // Image can be used as is, and has already been cached in g_gr->images()
1103 assert(image_ != nullptr);
1104 rendered_text->rects.push_back(
1105@@ -1267,28 +1279,34 @@
1106 const AttrMap& a = tag_.attrs();
1107 RGBColor color;
1108 bool use_playercolor = false;
1109- const std::string image_filename = a["src"].get_string();
1110 double scale = 1.0;
1111
1112 if (a.has("color")) {
1113 color = a["color"].get_color();
1114 use_playercolor = true;
1115 }
1116- if (a.has("width")) {
1117- int width = a["width"].get_int();
1118- if (width > renderer_style_.overall_width) {
1119- log("WARNING: Font renderer: Specified image width of %d exceeds the overall available "
1120- "width of %d. Setting width to %d.\n",
1121- width, renderer_style_.overall_width, renderer_style_.overall_width);
1122- width = renderer_style_.overall_width;
1123- }
1124- const int image_width = image_cache_->get(image_filename)->width();
1125- if (width < image_width) {
1126- scale = static_cast<double>(width) / image_width;
1127- }
1128+ if (a.has("object")) {
1129+ const Image* representative_image = g_gr->animations().get_representative_image(a["object"].get_string(), use_playercolor ? &color : nullptr);
1130+ render_node_.reset(new ImgRenderNode(nodestyle_, representative_image));
1131+ } else {
1132+ const std::string image_filename = a["src"].get_string();
1133+
1134+ if (a.has("width")) {
1135+ int width = a["width"].get_int();
1136+ if (width > renderer_style_.overall_width) {
1137+ log("WARNING: Font renderer: Specified image width of %d exceeds the overall available "
1138+ "width of %d. Setting width to %d.\n",
1139+ width, renderer_style_.overall_width, renderer_style_.overall_width);
1140+ width = renderer_style_.overall_width;
1141+ }
1142+ const int image_width = image_cache_->get(image_filename)->width();
1143+ if (width < image_width) {
1144+ scale = static_cast<double>(width) / image_width;
1145+ }
1146+ }
1147+ render_node_.reset(
1148+ new ImgRenderNode(nodestyle_, image_filename, scale, color, use_playercolor));
1149 }
1150- render_node_.reset(
1151- new ImgRenderNode(nodestyle_, image_filename, scale, color, use_playercolor));
1152 }
1153 void emit_nodes(std::vector<std::shared_ptr<RenderNode>>& nodes) override {
1154 nodes.push_back(render_node_);
1155
1156=== modified file 'src/logic/map_objects/immovable.cc'
1157--- src/logic/map_objects/immovable.cc 2019-04-24 06:01:37 +0000
1158+++ src/logic/map_objects/immovable.cc 2019-05-03 18:29:53 +0000
1159@@ -222,6 +222,16 @@
1160 table.get_table("attributes")->array_entries<std::string>();
1161 add_attributes(attributes, {MapObject::Attribute::RESI});
1162
1163+ // All resource indicators must have a menu icon
1164+ for (const std::string& attribute : attributes) {
1165+ if (attribute == "resi") {
1166+ if (icon_filename().empty()) {
1167+ throw GameDataError("Resource indicator %s has no menu icon", name().c_str());
1168+ }
1169+ break;
1170+ }
1171+ }
1172+
1173 // Old trees get an extra species name so we can use it in help lists.
1174 bool is_tree = false;
1175 for (const std::string& attribute : attributes) {
1176
1177=== modified file 'src/logic/map_objects/map_object.cc'
1178--- src/logic/map_objects/map_object.cc 2019-03-03 08:31:25 +0000
1179+++ src/logic/map_objects/map_object.cc 2019-05-03 18:29:53 +0000
1180@@ -240,14 +240,18 @@
1181 if (table.has_key("animations")) {
1182 std::unique_ptr<LuaTable> anims(table.get_table("animations"));
1183 for (const std::string& animation : anims->keys<std::string>()) {
1184- add_animation(animation, g_gr->animations().load(*anims->get_table(animation)));
1185+ if (animation == "idle") {
1186+ add_animation(animation, g_gr->animations().load(init_name, *anims->get_table(animation)));
1187+ } else {
1188+ add_animation(animation, g_gr->animations().load(*anims->get_table(animation)));
1189+ }
1190 }
1191 if (!is_animation_known("idle")) {
1192 throw GameDataError(
1193 "Map object %s has animations but no idle animation", init_name.c_str());
1194 }
1195- representative_image_filename_ =
1196- g_gr->animations().get_animation(get_animation("idle")).representative_image_filename();
1197+
1198+ assert(g_gr->animations().get_representative_image(name())->width() > 0);
1199 }
1200 if (table.has_key("icon")) {
1201 icon_filename_ = table.get_string("icon");
1202@@ -322,9 +326,6 @@
1203 }
1204 return nullptr;
1205 }
1206-const std::string& MapObjectDescr::representative_image_filename() const {
1207- return representative_image_filename_;
1208-}
1209
1210 void MapObjectDescr::check_representative_image() {
1211 if (representative_image() == nullptr) {
1212
1213=== modified file 'src/logic/map_objects/map_object.h'
1214--- src/logic/map_objects/map_object.h 2019-02-27 17:19:00 +0000
1215+++ src/logic/map_objects/map_object.h 2019-05-03 18:29:53 +0000
1216@@ -138,9 +138,6 @@
1217 /// Returns the image for the first frame of the idle animation if the MapObject has animations,
1218 /// nullptr otherwise
1219 const Image* representative_image(const RGBColor* player_color = nullptr) const;
1220- /// Returns the image fileneme for first frame of the idle animation if the MapObject has
1221- /// animations, is empty otherwise
1222- const std::string& representative_image_filename() const;
1223
1224 /// Returns the menu image if the MapObject has one, nullptr otherwise
1225 const Image* icon() const;
1226@@ -175,7 +172,6 @@
1227 Anims anims_;
1228 static uint32_t dyn_attribhigh_; ///< highest attribute ID used
1229 static AttribMap dyn_attribs_;
1230- std::string representative_image_filename_; // Image for big represenations, e.g. on buttons
1231 std::string icon_filename_; // Filename for the menu icon
1232
1233 DISALLOW_COPY_AND_ASSIGN(MapObjectDescr);
1234
1235=== modified file 'src/logic/map_objects/tribes/building.cc'
1236--- src/logic/map_objects/tribes/building.cc 2019-04-24 06:01:37 +0000
1237+++ src/logic/map_objects/tribes/building.cc 2019-05-03 18:29:53 +0000
1238@@ -774,12 +774,10 @@
1239 bool link_to_building_lifetime,
1240 uint32_t throttle_time,
1241 uint32_t throttle_radius) {
1242- const std::string& img = descr().representative_image_filename();
1243- const int width = descr().representative_image()->width();
1244 const std::string rt_description =
1245- (boost::format("<div padding_r=10><p><img width=%d src=%s color=%s></p></div>"
1246+ (boost::format("<div padding_r=10><p><img object=%s color=%s></p></div>"
1247 "<div width=*><p><font size=%d>%s</font></p></div>") %
1248- width % img % owner().get_playercolor().hex_value() % UI_FONT_SIZE_MESSAGE % description)
1249+ descr().name() % owner().get_playercolor().hex_value() % UI_FONT_SIZE_MESSAGE % description)
1250 .str();
1251
1252 std::unique_ptr<Message> msg(new Message(msgtype, game.get_gametime(), title, icon_filename,
1253
1254=== modified file 'src/logic/map_objects/tribes/tribe_descr.cc'
1255--- src/logic/map_objects/tribes/tribe_descr.cc 2019-04-09 16:43:49 +0000
1256+++ src/logic/map_objects/tribes/tribe_descr.cc 2019-05-03 18:29:53 +0000
1257@@ -64,8 +64,8 @@
1258 initializations_ = info.initializations;
1259
1260 std::unique_ptr<LuaTable> items_table = table.get_table("animations");
1261- frontier_animation_id_ = g_gr->animations().load(*items_table->get_table("frontier"));
1262- flag_animation_id_ = g_gr->animations().load(*items_table->get_table("flag"));
1263+ frontier_animation_id_ = g_gr->animations().load(name_ + std::string("_frontier"), *items_table->get_table("frontier"));
1264+ flag_animation_id_ = g_gr->animations().load(name_ + std::string("_flag"), *items_table->get_table("flag"));
1265
1266 items_table = table.get_table("roads");
1267 const auto load_roads = [&items_table](
1268
1269=== modified file 'src/logic/map_objects/tribes/worker.cc'
1270--- src/logic/map_objects/tribes/worker.cc 2019-04-27 13:24:29 +0000
1271+++ src/logic/map_objects/tribes/worker.cc 2019-05-03 18:29:53 +0000
1272@@ -973,11 +973,10 @@
1273
1274 // Geologist also sends a message notifying the player
1275 if (rdescr && rdescr->detectable() && position.field->get_resources_amount()) {
1276- const int width = g_gr->images().get(rdescr->representative_image())->width();
1277 const std::string message =
1278- (boost::format("<div padding_r=10><p><img width=%d src=%s></p></div>"
1279+ (boost::format("<div padding_r=10><p><img object=%s></p></div>"
1280 "<div width=*><p><font size=%d>%s</font></p></div>") %
1281- width % ri.descr().representative_image_filename() % UI_FONT_SIZE_MESSAGE %
1282+ ri.descr().name() % UI_FONT_SIZE_MESSAGE %
1283 _("A geologist found resources."))
1284 .str();
1285
1286
1287=== modified file 'src/scripting/lua_map.cc'
1288--- src/scripting/lua_map.cc 2019-04-09 16:43:49 +0000
1289+++ src/scripting/lua_map.cc 2019-05-03 18:29:53 +0000
1290@@ -1804,7 +1804,6 @@
1291 PROP_RO(LuaMapObjectDescription, icon_name),
1292 PROP_RO(LuaMapObjectDescription, name),
1293 PROP_RO(LuaMapObjectDescription, type_name),
1294- PROP_RO(LuaMapObjectDescription, representative_image),
1295 {nullptr, nullptr, nullptr},
1296 };
1297
1298@@ -1866,17 +1865,6 @@
1299 }
1300
1301 /* RST
1302- .. attribute:: representative_image
1303-
1304- (RO) a :class:`string` with the file path to the representative image
1305- of the map object's idle animation
1306-*/
1307-int LuaMapObjectDescription::get_representative_image(lua_State* L) {
1308- lua_pushstring(L, get()->representative_image_filename());
1309- return 1;
1310-}
1311-
1312-/* RST
1313 .. attribute:: type_name
1314
1315 (RO) the map object's type as a string. Map object types are
1316@@ -3701,7 +3689,6 @@
1317
1318 (RO) the :class:`string` file path to a representative image
1319 */
1320-
1321 int LuaTerrainDescription::get_representative_image(lua_State* L) {
1322 lua_pushstring(L, get()->texture_paths().front());
1323 return 1;
1324
1325=== modified file 'src/scripting/lua_map.h'
1326--- src/scripting/lua_map.h 2019-04-07 05:46:13 +0000
1327+++ src/scripting/lua_map.h 2019-05-03 18:29:53 +0000
1328@@ -198,7 +198,6 @@
1329 int get_helptext_script(lua_State*);
1330 int get_name(lua_State*);
1331 int get_type_name(lua_State*);
1332- int get_representative_image(lua_State*);
1333
1334 /*
1335 * Lua methods
1336
1337=== modified file 'src/website/map_object_info.cc'
1338--- src/website/map_object_info.cc 2019-03-08 17:26:28 +0000
1339+++ src/website/map_object_info.cc 2019-05-03 18:29:53 +0000
1340@@ -70,7 +70,7 @@
1341 JSON::Object* json_building = json_buildings_array->add_object();
1342 json_building->add_string("name", building.name());
1343 json_building->add_string("descname", building.descname());
1344- json_building->add_string("icon", building.representative_image_filename());
1345+ json_building->add_string("icon", building.icon_filename());
1346
1347 // Buildcost
1348 if (building.is_buildable()) {

Subscribers

People subscribed via source and target branches

to status/vote changes: