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.
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.

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
Revision history for this message
GunChleoc (gunchleoc) wrote :

Found the bug

review: Needs Resubmitting
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.

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
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
=== modified file 'data/campaigns/atl01.wmf/scripting/mission_thread.lua'
--- data/campaigns/atl01.wmf/scripting/mission_thread.lua 2018-12-13 17:36:58 +0000
+++ data/campaigns/atl01.wmf/scripting/mission_thread.lua 2019-05-03 18:29:53 +0000
@@ -3,8 +3,7 @@
3-- =======================================================================3-- =======================================================================
44
5function send_building_lost_message(f)5function send_building_lost_message(f)
6 local icon = f.immovable.descr.representative_image6 local message = building_lost(f.immovable.descr.name)
7 local message = building_lost(icon)
8 send_message(7 send_message(
9 p1,8 p1,
10 message.title,9 message.title,
@@ -12,7 +11,7 @@
12 {11 {
13 field = f,12 field = f,
14 popup = false,13 popup = false,
15 icon = icon,14 icon = f.immovable.descr.icon_name,
16 message.title15 message.title
17 }16 }
18 )17 )
1918
=== modified file 'data/campaigns/atl01.wmf/scripting/texts.lua'
--- data/campaigns/atl01.wmf/scripting/texts.lua 2017-12-09 19:06:07 +0000
+++ data/campaigns/atl01.wmf/scripting/texts.lua 2019-05-03 18:29:53 +0000
@@ -480,11 +480,11 @@
480 }480 }
481}481}
482482
483function building_lost(icon)483function building_lost(buildingname)
484 set_textdomain("scenario_atl01.wmf")484 set_textdomain("scenario_atl01.wmf")
485 return {485 return {
486 -- TRANSLATORS: Short message title. Translate as "Lost!" if you don't have enough space.486 -- TRANSLATORS: Short message title. Translate as "Lost!" if you don't have enough space.
487 title = pgettext("message_short_title", "Building lost!"),487 title = pgettext("message_short_title", "Building lost!"),
488 text = li_image(icon, _"We lost a building to the ocean!")488 text = li_object(buildingname, _"We lost a building to the ocean!")
489 }489 }
490end490end
491491
=== modified file 'data/campaigns/bar01.wmf/scripting/texts.lua'
--- data/campaigns/bar01.wmf/scripting/texts.lua 2018-09-02 11:44:52 +0000
+++ data/campaigns/bar01.wmf/scripting/texts.lua 2019-05-03 18:29:53 +0000
@@ -43,16 +43,16 @@
43 body = objective_text(_"Build coal and iron mines",43 body = objective_text(_"Build coal and iron mines",
44 li(_"Build a coal mine and an iron mine.") ..44 li(_"Build a coal mine and an iron mine.") ..
45 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:") ..45 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:") ..
46 li_image(wl.Game():get_immovable_description("barbarians_resi_coal_1").representative_image, _"a bit of coal") ..46 li_object("barbarians_resi_coal_1", _"a bit of coal") ..
47 li_image(wl.Game():get_immovable_description("barbarians_resi_coal_2").representative_image, _"a lot of coal") ..47 li_object("barbarians_resi_coal_2", _"a lot of coal") ..
48 li_image(wl.Game():get_immovable_description("barbarians_resi_iron_1").representative_image, _"a bit of iron") ..48 li_object("barbarians_resi_iron_1", _"a bit of iron") ..
49 li_image(wl.Game():get_immovable_description("barbarians_resi_iron_2").representative_image, _"a lot of iron") ..49 li_object("barbarians_resi_iron_2", _"a lot of iron") ..
50 li_image(wl.Game():get_immovable_description("barbarians_resi_gold_1").representative_image, _"a bit of gold") ..50 li_object("barbarians_resi_gold_1", _"a bit of gold") ..
51 li_image(wl.Game():get_immovable_description("barbarians_resi_gold_2").representative_image, _"a lot of gold") ..51 li_object("barbarians_resi_gold_2", _"a lot of gold") ..
52 li_image(wl.Game():get_immovable_description("barbarians_resi_stones_1").representative_image, _"a bit of granite") ..52 li_object("barbarians_resi_stones_1", _"a bit of granite") ..
53 li_image(wl.Game():get_immovable_description("barbarians_resi_stones_2").representative_image, _"a lot of granite") ..53 li_object("barbarians_resi_stones_2", _"a lot of granite") ..
54 li_image(wl.Game():get_immovable_description("barbarians_resi_water").representative_image, _"water") ..54 li_object("barbarians_resi_water", _"water") ..
55 li_image(wl.Game():get_immovable_description("barbarians_resi_none").representative_image, _"nothing was found here") ..55 li_object("barbarians_resi_none", _"nothing was found here") ..
56 p(_[[Mines can only be built on mountain terrain. Suitable places for mines are displayed as orange mine symbols.]]))56 p(_[[Mines can only be built on mountain terrain. Suitable places for mines are displayed as orange mine symbols.]]))
57}57}
5858
5959
=== modified file 'data/scripting/editor/editor_help.lua'
--- data/scripting/editor/editor_help.lua 2016-10-19 09:00:29 +0000
+++ data/scripting/editor/editor_help.lua 2019-05-03 18:29:53 +0000
@@ -32,7 +32,7 @@
32 result[counter] = {32 result[counter] = {
33 name = immovable.name,33 name = immovable.name,
34 title = immovable.species,34 title = immovable.species,
35 icon = immovable.representative_image,35 icon = immovable.icon_name,
36 script = "scripting/editor/tree_help.lua",36 script = "scripting/editor/tree_help.lua",
37 script_parameters = {[1] = immovable.name}37 script_parameters = {[1] = immovable.name}
38 }38 }
3939
=== modified file 'data/scripting/editor/terrain_help.lua'
--- data/scripting/editor/terrain_help.lua 2018-01-10 16:21:50 +0000
+++ data/scripting/editor/terrain_help.lua 2019-05-03 18:29:53 +0000
@@ -59,7 +59,7 @@
5959
60 local tree_string = ""60 local tree_string = ""
61 for k,v in ipairs(tree_list) do61 for k,v in ipairs(tree_list) do
62 tree_string = tree_string .. li_image(v.tree.representative_image,62 tree_string = tree_string .. li_object(v.tree.name,
63 v.tree.species .. ("<br>%2.1f%%"):bformat(100 * v.probability)) .. vspace(3)63 v.tree.species .. ("<br>%2.1f%%"):bformat(100 * v.probability)) .. vspace(3)
64 end64 end
6565
6666
=== modified file 'data/scripting/editor/tree_help.lua'
--- data/scripting/editor/tree_help.lua 2018-01-10 16:21:50 +0000
+++ data/scripting/editor/tree_help.lua 2019-05-03 18:29:53 +0000
@@ -13,7 +13,7 @@
13 set_textdomain("widelands_editor")13 set_textdomain("widelands_editor")
14 local world = wl.World();14 local world = wl.World();
15 local tree = wl.Editor():get_immovable_description(tree_name)15 local tree = wl.Editor():get_immovable_description(tree_name)
16 local result = li_image(tree.representative_image, "")16 local result = li_object(tree.name, "")
1717
18 -- TRANSLATORS: A header in the editor help. Terrains preferred by a type of tree.18 -- TRANSLATORS: A header in the editor help. Terrains preferred by a type of tree.
19 result = result .. vspace(3) .. h2(vspace(12) .. _"Preferred terrains") .. vspace(3)19 result = result .. vspace(3) .. h2(vspace(12) .. _"Preferred terrains") .. vspace(3)
2020
=== modified file 'data/scripting/richtext.lua'
--- data/scripting/richtext.lua 2018-03-24 13:51:48 +0000
+++ data/scripting/richtext.lua 2019-05-03 18:29:53 +0000
@@ -402,7 +402,6 @@
402 return li("→", text)402 return li("→", text)
403end403end
404404
405
406-- RST405-- RST
407-- .. function:: li_image(imagepath, text)406-- .. function:: li_image(imagepath, text)
408--407--
@@ -424,6 +423,26 @@
424 )423 )
425end424end
426425
426-- RST
427-- .. function:: li_object(name, text)
428--
429-- Places a paragraph of text to the right of an image representing the given map object
430--
431-- :arg name: the name of the map object to be represented by an image
432-- :type name: :class:`string`
433--
434-- :arg text: the text to be placed next to the image
435-- :type text: :class:`string`
436--
437-- :returns: the text wrapped in a paragraph and placed next to the image, the outer tag is a div.
438
439function li_object(name, text)
440 return
441 div("width=100%",
442 div("float=left padding_r=6", p(img_object(name))) ..
443 p(text)
444 )
445end
427446
428-- RST447-- RST
429-- :ref:`Return to index<richtext.lua>`448-- :ref:`Return to index<richtext.lua>`
@@ -455,6 +474,27 @@
455 end474 end
456end475end
457476
477-- RST
478-- .. function:: img_object(object[, attributes = nil])
479--
480-- Creates a richtest image tag for the given map object type. See also :any:`li_object`.
481--
482-- :arg name: the name of the map object.
483-- :type name: :class:`string`
484-- :arg attributes: see the :ref:`img tag's documentation <rt_tags_img>`
485-- for a list of attributes and their descriptions.
486-- :type attributes: :class:`string`
487--
488-- :returns: the img tag.
489
490function img_object(name, attributes)
491 if attributes then
492 return "<img object=" .. name .. " " .. attributes .. ">"
493 else
494 return "<img object=" .. name .. ">"
495 end
496end
497
458498
459-- RST499-- RST
460-- :ref:`Return to index<richtext.lua>`500-- :ref:`Return to index<richtext.lua>`
461501
=== modified file 'data/tribes/immovables/resi/atlanteans/init.lua'
--- data/tribes/immovables/resi/atlanteans/init.lua 2018-09-10 06:25:11 +0000
+++ data/tribes/immovables/resi/atlanteans/init.lua 2019-05-03 18:29:53 +0000
@@ -6,6 +6,7 @@
6 -- TRANSLATORS: This is a resource name used in lists of resources6 -- TRANSLATORS: This is a resource name used in lists of resources
7 descname = pgettext("immovable", "Resources: None"),7 descname = pgettext("immovable", "Resources: None"),
8 helptext_script = dirname .. "../helptexts/none.lua",8 helptext_script = dirname .. "../helptexts/none.lua",
9 icon = dirname .. "pics/none_0.png",
9 attributes = { "resi" },10 attributes = { "resi" },
10 programs = {11 programs = {
11 program = {12 program = {
@@ -28,6 +29,7 @@
28 -- TRANSLATORS: This is a resource name used in lists of resources29 -- TRANSLATORS: This is a resource name used in lists of resources
29 descname = pgettext("immovable", "Resources: Water Vein"),30 descname = pgettext("immovable", "Resources: Water Vein"),
30 helptext_script = dirname .. "../helptexts/water.lua",31 helptext_script = dirname .. "../helptexts/water.lua",
32 icon = dirname .. "pics/water_0.png",
31 attributes = { "resi" },33 attributes = { "resi" },
32 programs = {34 programs = {
33 program = {35 program = {
@@ -51,6 +53,7 @@
51 -- TRANSLATORS: This is a resource name used in lists of resources53 -- TRANSLATORS: This is a resource name used in lists of resources
52 descname = pgettext("immovable", "Resources: Coal Vein"),54 descname = pgettext("immovable", "Resources: Coal Vein"),
53 helptext_script = dirname .. "../helptexts/coal_1.lua",55 helptext_script = dirname .. "../helptexts/coal_1.lua",
56 icon = dirname .. "pics/coal_1_0.png",
54 attributes = { "resi" },57 attributes = { "resi" },
55 programs = {58 programs = {
56 program = {59 program = {
@@ -74,6 +77,7 @@
74 -- TRANSLATORS: This is a resource name used in lists of resources77 -- TRANSLATORS: This is a resource name used in lists of resources
75 descname = pgettext("immovable", "Resources: Gold Vein"),78 descname = pgettext("immovable", "Resources: Gold Vein"),
76 helptext_script = dirname .. "../helptexts/gold_1.lua",79 helptext_script = dirname .. "../helptexts/gold_1.lua",
80 icon = dirname .. "pics/gold_1_0.png",
77 attributes = { "resi" },81 attributes = { "resi" },
78 programs = {82 programs = {
79 program = {83 program = {
@@ -97,6 +101,7 @@
97 -- TRANSLATORS: This is a resource name used in lists of resources101 -- TRANSLATORS: This is a resource name used in lists of resources
98 descname = pgettext("immovable", "Resources: Iron Vein"),102 descname = pgettext("immovable", "Resources: Iron Vein"),
99 helptext_script = dirname .. "../helptexts/iron_1.lua",103 helptext_script = dirname .. "../helptexts/iron_1.lua",
104 icon = dirname .. "pics/iron_1_0.png",
100 attributes = { "resi" },105 attributes = { "resi" },
101 programs = {106 programs = {
102 program = {107 program = {
@@ -120,6 +125,7 @@
120 -- TRANSLATORS: This is a resource name used in lists of resources125 -- TRANSLATORS: This is a resource name used in lists of resources
121 descname = pgettext("immovable", "Resources: Some Stones"),126 descname = pgettext("immovable", "Resources: Some Stones"),
122 helptext_script = dirname .. "../helptexts/stones_1.lua",127 helptext_script = dirname .. "../helptexts/stones_1.lua",
128 icon = dirname .. "pics/stones_1_0.png",
123 attributes = { "resi" },129 attributes = { "resi" },
124 programs = {130 programs = {
125 program = {131 program = {
@@ -143,6 +149,7 @@
143 -- TRANSLATORS: This is a resource name used in lists of resources149 -- TRANSLATORS: This is a resource name used in lists of resources
144 descname = pgettext("immovable", "Resources: Main Coal Vein"),150 descname = pgettext("immovable", "Resources: Main Coal Vein"),
145 helptext_script = dirname .. "../helptexts/coal_2.lua",151 helptext_script = dirname .. "../helptexts/coal_2.lua",
152 icon = dirname .. "pics/coal_2_0.png",
146 attributes = { "resi" },153 attributes = { "resi" },
147 programs = {154 programs = {
148 program = {155 program = {
@@ -166,6 +173,7 @@
166 -- TRANSLATORS: This is a resource name used in lists of resources173 -- TRANSLATORS: This is a resource name used in lists of resources
167 descname = pgettext("immovable", "Resources: Main Gold Vein"),174 descname = pgettext("immovable", "Resources: Main Gold Vein"),
168 helptext_script = dirname .. "../helptexts/gold_2.lua",175 helptext_script = dirname .. "../helptexts/gold_2.lua",
176 icon = dirname .. "pics/gold_2_0.png",
169 attributes = { "resi" },177 attributes = { "resi" },
170 programs = {178 programs = {
171 program = {179 program = {
@@ -189,6 +197,7 @@
189 -- TRANSLATORS: This is a resource name used in lists of resources197 -- TRANSLATORS: This is a resource name used in lists of resources
190 descname = pgettext("immovable", "Resources: Main Iron Vein"),198 descname = pgettext("immovable", "Resources: Main Iron Vein"),
191 helptext_script = dirname .. "../helptexts/iron_2.lua",199 helptext_script = dirname .. "../helptexts/iron_2.lua",
200 icon = dirname .. "pics/iron_2_0.png",
192 attributes = { "resi" },201 attributes = { "resi" },
193 programs = {202 programs = {
194 program = {203 program = {
@@ -212,6 +221,7 @@
212 -- TRANSLATORS: This is a resource name used in lists of resources221 -- TRANSLATORS: This is a resource name used in lists of resources
213 descname = pgettext("immovable", "Resources: A Lot of Stones"),222 descname = pgettext("immovable", "Resources: A Lot of Stones"),
214 helptext_script = dirname .. "../helptexts/stones_2.lua",223 helptext_script = dirname .. "../helptexts/stones_2.lua",
224 icon = dirname .. "pics/stones_2_0.png",
215 attributes = { "resi" },225 attributes = { "resi" },
216 programs = {226 programs = {
217 program = {227 program = {
218228
=== modified file 'data/tribes/immovables/resi/barbarians/init.lua'
--- data/tribes/immovables/resi/barbarians/init.lua 2018-09-01 10:50:00 +0000
+++ data/tribes/immovables/resi/barbarians/init.lua 2019-05-03 18:29:53 +0000
@@ -6,6 +6,7 @@
6 -- TRANSLATORS: This is a resource name used in lists of resources6 -- TRANSLATORS: This is a resource name used in lists of resources
7 descname = pgettext("immovable", "Resources: None"),7 descname = pgettext("immovable", "Resources: None"),
8 helptext_script = dirname .. "../helptexts/none.lua",8 helptext_script = dirname .. "../helptexts/none.lua",
9 icon = dirname .. "pics/none.png",
9 attributes = { "resi" },10 attributes = { "resi" },
10 programs = {11 programs = {
11 program = {12 program = {
@@ -28,6 +29,7 @@
28 -- TRANSLATORS: This is a resource name used in lists of resources29 -- TRANSLATORS: This is a resource name used in lists of resources
29 descname = pgettext("immovable", "Resources: Water Vein"),30 descname = pgettext("immovable", "Resources: Water Vein"),
30 helptext_script = dirname .. "../helptexts/water.lua",31 helptext_script = dirname .. "../helptexts/water.lua",
32 icon = dirname .. "pics/water.png",
31 attributes = { "resi" },33 attributes = { "resi" },
32 programs = {34 programs = {
33 program = {35 program = {
@@ -50,6 +52,7 @@
50 -- TRANSLATORS: This is a resource name used in lists of resources52 -- TRANSLATORS: This is a resource name used in lists of resources
51 descname = pgettext("immovable", "Resources: Coal Vein"),53 descname = pgettext("immovable", "Resources: Coal Vein"),
52 helptext_script = dirname .. "../helptexts/coal_1.lua",54 helptext_script = dirname .. "../helptexts/coal_1.lua",
55 icon = dirname .. "pics/coal_1.png",
53 attributes = { "resi" },56 attributes = { "resi" },
54 programs = {57 programs = {
55 program = {58 program = {
@@ -72,6 +75,7 @@
72 -- TRANSLATORS: This is a resource name used in lists of resources75 -- TRANSLATORS: This is a resource name used in lists of resources
73 descname = pgettext("immovable", "Resources: Gold Vein"),76 descname = pgettext("immovable", "Resources: Gold Vein"),
74 helptext_script = dirname .. "../helptexts/gold_1.lua",77 helptext_script = dirname .. "../helptexts/gold_1.lua",
78 icon = dirname .. "pics/gold_1.png",
75 attributes = { "resi" },79 attributes = { "resi" },
76 programs = {80 programs = {
77 program = {81 program = {
@@ -94,6 +98,7 @@
94 -- TRANSLATORS: This is a resource name used in lists of resources98 -- TRANSLATORS: This is a resource name used in lists of resources
95 descname = pgettext("immovable", "Resources: Iron Vein"),99 descname = pgettext("immovable", "Resources: Iron Vein"),
96 helptext_script = dirname .. "../helptexts/iron_1.lua",100 helptext_script = dirname .. "../helptexts/iron_1.lua",
101 icon = dirname .. "pics/iron_1.png",
97 attributes = { "resi" },102 attributes = { "resi" },
98 programs = {103 programs = {
99 program = {104 program = {
@@ -116,6 +121,7 @@
116 -- TRANSLATORS: This is a resource name used in lists of resources121 -- TRANSLATORS: This is a resource name used in lists of resources
117 descname = pgettext("immovable", "Resources: Some Stones"),122 descname = pgettext("immovable", "Resources: Some Stones"),
118 helptext_script = dirname .. "../helptexts/stones_1.lua",123 helptext_script = dirname .. "../helptexts/stones_1.lua",
124 icon = dirname .. "pics/stones_1.png",
119 attributes = { "resi" },125 attributes = { "resi" },
120 programs = {126 programs = {
121 program = {127 program = {
@@ -138,6 +144,7 @@
138 -- TRANSLATORS: This is a resource name used in lists of resources144 -- TRANSLATORS: This is a resource name used in lists of resources
139 descname = pgettext("immovable", "Resources: Main Coal Vein"),145 descname = pgettext("immovable", "Resources: Main Coal Vein"),
140 helptext_script = dirname .. "../helptexts/coal_2.lua",146 helptext_script = dirname .. "../helptexts/coal_2.lua",
147 icon = dirname .. "pics/coal_2.png",
141 attributes = { "resi" },148 attributes = { "resi" },
142 programs = {149 programs = {
143 program = {150 program = {
@@ -160,6 +167,7 @@
160 -- TRANSLATORS: This is a resource name used in lists of resources167 -- TRANSLATORS: This is a resource name used in lists of resources
161 descname = pgettext("immovable", "Resources: Main Gold Vein"),168 descname = pgettext("immovable", "Resources: Main Gold Vein"),
162 helptext_script = dirname .. "../helptexts/gold_2.lua",169 helptext_script = dirname .. "../helptexts/gold_2.lua",
170 icon = dirname .. "pics/gold_2.png",
163 attributes = { "resi" },171 attributes = { "resi" },
164 programs = {172 programs = {
165 program = {173 program = {
@@ -182,6 +190,7 @@
182 -- TRANSLATORS: This is a resource name used in lists of resources190 -- TRANSLATORS: This is a resource name used in lists of resources
183 descname = pgettext("immovable", "Resources: Main Iron Vein"),191 descname = pgettext("immovable", "Resources: Main Iron Vein"),
184 helptext_script = dirname .. "../helptexts/iron_2.lua",192 helptext_script = dirname .. "../helptexts/iron_2.lua",
193 icon = dirname .. "pics/iron_2.png",
185 attributes = { "resi" },194 attributes = { "resi" },
186 programs = {195 programs = {
187 program = {196 program = {
@@ -204,6 +213,7 @@
204 -- TRANSLATORS: This is a resource name used in lists of resources213 -- TRANSLATORS: This is a resource name used in lists of resources
205 descname = pgettext("immovable", "Resources: A Lot of Stones"),214 descname = pgettext("immovable", "Resources: A Lot of Stones"),
206 helptext_script = dirname .. "../helptexts/stones_2.lua",215 helptext_script = dirname .. "../helptexts/stones_2.lua",
216 icon = dirname .. "pics/stones_2.png",
207 attributes = { "resi" },217 attributes = { "resi" },
208 programs = {218 programs = {
209 program = {219 program = {
210220
=== modified file 'data/tribes/immovables/resi/empire/init.lua'
--- data/tribes/immovables/resi/empire/init.lua 2018-09-01 10:50:00 +0000
+++ data/tribes/immovables/resi/empire/init.lua 2019-05-03 18:29:53 +0000
@@ -6,6 +6,7 @@
6 -- TRANSLATORS: This is a resource name used in lists of resources6 -- TRANSLATORS: This is a resource name used in lists of resources
7 descname = pgettext("immovable", "Resources: None"),7 descname = pgettext("immovable", "Resources: None"),
8 helptext_script = dirname .. "../helptexts/none.lua",8 helptext_script = dirname .. "../helptexts/none.lua",
9 icon = dirname .. "pics/none.png",
9 attributes = { "resi" },10 attributes = { "resi" },
10 programs = {11 programs = {
11 program = {12 program = {
@@ -28,6 +29,7 @@
28 -- TRANSLATORS: This is a resource name used in lists of resources29 -- TRANSLATORS: This is a resource name used in lists of resources
29 descname = pgettext("immovable", "Resources: Water Vein"),30 descname = pgettext("immovable", "Resources: Water Vein"),
30 helptext_script = dirname .. "../helptexts/water.lua",31 helptext_script = dirname .. "../helptexts/water.lua",
32 icon = dirname .. "pics/water.png",
31 attributes = { "resi" },33 attributes = { "resi" },
32 programs = {34 programs = {
33 program = {35 program = {
@@ -50,6 +52,7 @@
50 -- TRANSLATORS: This is a resource name used in lists of resources52 -- TRANSLATORS: This is a resource name used in lists of resources
51 descname = pgettext("immovable", "Resources: Coal Vein"),53 descname = pgettext("immovable", "Resources: Coal Vein"),
52 helptext_script = dirname .. "../helptexts/coal_1.lua",54 helptext_script = dirname .. "../helptexts/coal_1.lua",
55 icon = dirname .. "pics/coal_1.png",
53 attributes = { "resi" },56 attributes = { "resi" },
54 programs = {57 programs = {
55 program = {58 program = {
@@ -72,6 +75,7 @@
72 -- TRANSLATORS: This is a resource name used in lists of resources75 -- TRANSLATORS: This is a resource name used in lists of resources
73 descname = pgettext("immovable", "Resources: Gold Vein"),76 descname = pgettext("immovable", "Resources: Gold Vein"),
74 helptext_script = dirname .. "../helptexts/gold_1.lua",77 helptext_script = dirname .. "../helptexts/gold_1.lua",
78 icon = dirname .. "pics/gold_1.png",
75 attributes = { "resi" },79 attributes = { "resi" },
76 programs = {80 programs = {
77 program = {81 program = {
@@ -94,6 +98,7 @@
94 -- TRANSLATORS: This is a resource name used in lists of resources98 -- TRANSLATORS: This is a resource name used in lists of resources
95 descname = pgettext("immovable", "Resources: Iron Vein"),99 descname = pgettext("immovable", "Resources: Iron Vein"),
96 helptext_script = dirname .. "../helptexts/iron_1.lua",100 helptext_script = dirname .. "../helptexts/iron_1.lua",
101 icon = dirname .. "pics/iron_1.png",
97 attributes = { "resi" },102 attributes = { "resi" },
98 programs = {103 programs = {
99 program = {104 program = {
@@ -116,6 +121,7 @@
116 -- TRANSLATORS: This is a resource name used in lists of resources121 -- TRANSLATORS: This is a resource name used in lists of resources
117 descname = pgettext("immovable", "Resources: Some Stones"),122 descname = pgettext("immovable", "Resources: Some Stones"),
118 helptext_script = dirname .. "../helptexts/stones_1.lua",123 helptext_script = dirname .. "../helptexts/stones_1.lua",
124 icon = dirname .. "pics/stones_1.png",
119 attributes = { "resi" },125 attributes = { "resi" },
120 programs = {126 programs = {
121 program = {127 program = {
@@ -138,6 +144,7 @@
138 -- TRANSLATORS: This is a resource name used in lists of resources144 -- TRANSLATORS: This is a resource name used in lists of resources
139 descname = pgettext("immovable", "Resources: Main Coal Vein"),145 descname = pgettext("immovable", "Resources: Main Coal Vein"),
140 helptext_script = dirname .. "../helptexts/coal_2.lua",146 helptext_script = dirname .. "../helptexts/coal_2.lua",
147 icon = dirname .. "pics/coal_2.png",
141 attributes = { "resi" },148 attributes = { "resi" },
142 programs = {149 programs = {
143 program = {150 program = {
@@ -160,6 +167,7 @@
160 -- TRANSLATORS: This is a resource name used in lists of resources167 -- TRANSLATORS: This is a resource name used in lists of resources
161 descname = pgettext("immovable", "Resources: Main Gold Vein"),168 descname = pgettext("immovable", "Resources: Main Gold Vein"),
162 helptext_script = dirname .. "../helptexts/gold_2.lua",169 helptext_script = dirname .. "../helptexts/gold_2.lua",
170 icon = dirname .. "pics/gold_2.png",
163 attributes = { "resi" },171 attributes = { "resi" },
164 programs = {172 programs = {
165 program = {173 program = {
@@ -182,6 +190,7 @@
182 -- TRANSLATORS: This is a resource name used in lists of resources190 -- TRANSLATORS: This is a resource name used in lists of resources
183 descname = pgettext("immovable", "Resources: Main Iron Vein"),191 descname = pgettext("immovable", "Resources: Main Iron Vein"),
184 helptext_script = dirname .. "../helptexts/iron_2.lua",192 helptext_script = dirname .. "../helptexts/iron_2.lua",
193 icon = dirname .. "pics/iron_2.png",
185 attributes = { "resi" },194 attributes = { "resi" },
186 programs = {195 programs = {
187 program = {196 program = {
@@ -204,6 +213,7 @@
204 -- TRANSLATORS: This is a resource name used in lists of resources213 -- TRANSLATORS: This is a resource name used in lists of resources
205 descname = pgettext("immovable", "Resources: A Lot of Stones"),214 descname = pgettext("immovable", "Resources: A Lot of Stones"),
206 helptext_script = dirname .. "../helptexts/stones_2.lua",215 helptext_script = dirname .. "../helptexts/stones_2.lua",
216 icon = dirname .. "pics/stones_2.png",
207 attributes = { "resi" },217 attributes = { "resi" },
208 programs = {218 programs = {
209 program = {219 program = {
210220
=== modified file 'data/tribes/immovables/resi/frisians/init.lua'
--- data/tribes/immovables/resi/frisians/init.lua 2018-09-21 20:12:46 +0000
+++ data/tribes/immovables/resi/frisians/init.lua 2019-05-03 18:29:53 +0000
@@ -6,6 +6,7 @@
6 -- TRANSLATORS: This is a resource name used in lists of resources6 -- TRANSLATORS: This is a resource name used in lists of resources
7 descname = pgettext("immovable", "Resources: None"),7 descname = pgettext("immovable", "Resources: None"),
8 helptext_script = dirname .. "../helptexts/none.lua",8 helptext_script = dirname .. "../helptexts/none.lua",
9 icon = dirname .. "pics/none_0.png",
9 attributes = { "resi" },10 attributes = { "resi" },
10 programs = {11 programs = {
11 program = {12 program = {
@@ -28,6 +29,7 @@
28 -- TRANSLATORS: This is a resource name used in lists of resources29 -- TRANSLATORS: This is a resource name used in lists of resources
29 descname = pgettext("immovable", "Resources: Water Vein"),30 descname = pgettext("immovable", "Resources: Water Vein"),
30 helptext_script = dirname .. "../helptexts/water.lua",31 helptext_script = dirname .. "../helptexts/water.lua",
32 icon = dirname .. "pics/water_0.png",
31 attributes = { "resi" },33 attributes = { "resi" },
32 programs = {34 programs = {
33 program = {35 program = {
@@ -51,6 +53,7 @@
51 -- TRANSLATORS: This is a resource name used in lists of resources53 -- TRANSLATORS: This is a resource name used in lists of resources
52 descname = pgettext("immovable", "Resources: Coal Vein"),54 descname = pgettext("immovable", "Resources: Coal Vein"),
53 helptext_script = dirname .. "../helptexts/coal_1.lua",55 helptext_script = dirname .. "../helptexts/coal_1.lua",
56 icon = dirname .. "pics/coal_1_0.png",
54 attributes = { "resi" },57 attributes = { "resi" },
55 programs = {58 programs = {
56 program = {59 program = {
@@ -74,6 +77,7 @@
74 -- TRANSLATORS: This is a resource name used in lists of resources77 -- TRANSLATORS: This is a resource name used in lists of resources
75 descname = pgettext("immovable", "Resources: Gold Vein"),78 descname = pgettext("immovable", "Resources: Gold Vein"),
76 helptext_script = dirname .. "../helptexts/gold_1.lua",79 helptext_script = dirname .. "../helptexts/gold_1.lua",
80 icon = dirname .. "pics/gold_1_0.png",
77 attributes = { "resi" },81 attributes = { "resi" },
78 programs = {82 programs = {
79 program = {83 program = {
@@ -97,6 +101,7 @@
97 -- TRANSLATORS: This is a resource name used in lists of resources101 -- TRANSLATORS: This is a resource name used in lists of resources
98 descname = pgettext("immovable", "Resources: Iron Vein"),102 descname = pgettext("immovable", "Resources: Iron Vein"),
99 helptext_script = dirname .. "../helptexts/iron_1.lua",103 helptext_script = dirname .. "../helptexts/iron_1.lua",
104 icon = dirname .. "pics/iron_1_0.png",
100 attributes = { "resi" },105 attributes = { "resi" },
101 programs = {106 programs = {
102 program = {107 program = {
@@ -120,6 +125,7 @@
120 -- TRANSLATORS: This is a resource name used in lists of resources125 -- TRANSLATORS: This is a resource name used in lists of resources
121 descname = pgettext("immovable", "Resources: Some Stones"),126 descname = pgettext("immovable", "Resources: Some Stones"),
122 helptext_script = dirname .. "../helptexts/stones_1.lua",127 helptext_script = dirname .. "../helptexts/stones_1.lua",
128 icon = dirname .. "pics/stones_1_0.png",
123 attributes = { "resi" },129 attributes = { "resi" },
124 programs = {130 programs = {
125 program = {131 program = {
@@ -143,6 +149,7 @@
143 -- TRANSLATORS: This is a resource name used in lists of resources149 -- TRANSLATORS: This is a resource name used in lists of resources
144 descname = pgettext("immovable", "Resources: Main Coal Vein"),150 descname = pgettext("immovable", "Resources: Main Coal Vein"),
145 helptext_script = dirname .. "../helptexts/coal_2.lua",151 helptext_script = dirname .. "../helptexts/coal_2.lua",
152 icon = dirname .. "pics/coal_2_0.png",
146 attributes = { "resi" },153 attributes = { "resi" },
147 programs = {154 programs = {
148 program = {155 program = {
@@ -166,6 +173,7 @@
166 -- TRANSLATORS: This is a resource name used in lists of resources173 -- TRANSLATORS: This is a resource name used in lists of resources
167 descname = pgettext("immovable", "Resources: Main Gold Vein"),174 descname = pgettext("immovable", "Resources: Main Gold Vein"),
168 helptext_script = dirname .. "../helptexts/gold_2.lua",175 helptext_script = dirname .. "../helptexts/gold_2.lua",
176 icon = dirname .. "pics/gold_2_0.png",
169 attributes = { "resi" },177 attributes = { "resi" },
170 programs = {178 programs = {
171 program = {179 program = {
@@ -189,6 +197,7 @@
189 -- TRANSLATORS: This is a resource name used in lists of resources197 -- TRANSLATORS: This is a resource name used in lists of resources
190 descname = pgettext("immovable", "Resources: Main Iron Vein"),198 descname = pgettext("immovable", "Resources: Main Iron Vein"),
191 helptext_script = dirname .. "../helptexts/iron_2.lua",199 helptext_script = dirname .. "../helptexts/iron_2.lua",
200 icon = dirname .. "pics/iron_2_0.png",
192 attributes = { "resi" },201 attributes = { "resi" },
193 programs = {202 programs = {
194 program = {203 program = {
@@ -212,6 +221,7 @@
212 -- TRANSLATORS: This is a resource name used in lists of resources221 -- TRANSLATORS: This is a resource name used in lists of resources
213 descname = pgettext("immovable", "Resources: A Lot of Stones"),222 descname = pgettext("immovable", "Resources: A Lot of Stones"),
214 helptext_script = dirname .. "../helptexts/stones_2.lua",223 helptext_script = dirname .. "../helptexts/stones_2.lua",
224 icon = dirname .. "pics/stones_2_0.png",
215 attributes = { "resi" },225 attributes = { "resi" },
216 programs = {226 programs = {
217 program = {227 program = {
218228
=== modified file 'data/tribes/immovables/shipconstruction_atlanteans/init.lua'
--- data/tribes/immovables/shipconstruction_atlanteans/init.lua 2018-02-28 09:38:13 +0000
+++ data/tribes/immovables/shipconstruction_atlanteans/init.lua 2019-05-03 18:29:53 +0000
@@ -24,7 +24,8 @@
24 idle = {24 idle = {
25 pictures = path.list_files(dirname .. "build_??.png"),25 pictures = path.list_files(dirname .. "build_??.png"),
26 hotspot = { 118, 94 },26 hotspot = { 118, 94 },
27 fps = 127 fps = 1,
28 representative_frame = 5
28 },29 },
29 }30 }
30}31}
3132
=== modified file 'data/tribes/immovables/shipconstruction_barbarians/init.lua'
--- data/tribes/immovables/shipconstruction_barbarians/init.lua 2018-02-28 09:38:13 +0000
+++ data/tribes/immovables/shipconstruction_barbarians/init.lua 2019-05-03 18:29:53 +0000
@@ -24,7 +24,8 @@
24 idle = {24 idle = {
25 pictures = path.list_files(dirname .. "build_??.png"),25 pictures = path.list_files(dirname .. "build_??.png"),
26 hotspot = { 115, 82 },26 hotspot = { 115, 82 },
27 fps = 127 fps = 1,
28 representative_frame = 5
28 },29 },
29 }30 }
30}31}
3132
=== modified file 'data/tribes/immovables/shipconstruction_empire/init.lua'
--- data/tribes/immovables/shipconstruction_empire/init.lua 2018-02-28 09:38:13 +0000
+++ data/tribes/immovables/shipconstruction_empire/init.lua 2019-05-03 18:29:53 +0000
@@ -24,7 +24,8 @@
24 idle = {24 idle = {
25 pictures = path.list_files(dirname .. "build_??.png"),25 pictures = path.list_files(dirname .. "build_??.png"),
26 hotspot = { 115, 78 },26 hotspot = { 115, 78 },
27 fps = 127 fps = 1,
28 representative_frame = 5
28 },29 },
29 }30 }
30}31}
3132
=== modified file 'data/tribes/immovables/shipconstruction_frisians/init.lua'
--- data/tribes/immovables/shipconstruction_frisians/init.lua 2018-09-09 04:18:24 +0000
+++ data/tribes/immovables/shipconstruction_frisians/init.lua 2019-05-03 18:29:53 +0000
@@ -24,7 +24,8 @@
24 idle = {24 idle = {
25 pictures = path.list_files (dirname .. "build_??.png"),25 pictures = path.list_files (dirname .. "build_??.png"),
26 hotspot = { 75, 141 },26 hotspot = { 75, 141 },
27 fps = 127 fps = 1,
28 representative_frame = 3
28 },29 },
29 }30 }
30}31}
3132
=== modified file 'data/tribes/scripting/help/building_help.lua'
--- data/tribes/scripting/help/building_help.lua 2019-04-07 05:46:13 +0000
+++ data/tribes/scripting/help/building_help.lua 2019-05-03 18:29:53 +0000
@@ -57,7 +57,7 @@
57 am = amount57 am = amount
58 end58 end
59 end59 end
60 local items_with_resource = { wl.Game():get_immovable_description(resi).representative_image }60 local items_with_resource = { wl.Game():get_immovable_description(resi).icon_name }
61 for count, item in pairs(items) do61 for count, item in pairs(items) do
62 table.insert(items_with_resource, item.icon_name)62 table.insert(items_with_resource, item.icon_name)
63 end63 end
@@ -181,13 +181,13 @@
181 local result = h2(_"Lore")181 local result = h2(_"Lore")
182 local lore_text = building_helptext_lore()182 local lore_text = building_helptext_lore()
183 if type(lore_text) == "table" then183 if type(lore_text) == "table" then
184 result = result .. li_image(building_description.representative_image, lore_text[1])184 result = result .. li_object(building_description.name, lore_text[1])
185 for k,v in ipairs({table.unpack(lore_text, 2)}) do185 for k,v in ipairs({table.unpack(lore_text, 2)}) do
186 result = result .. p(v)186 result = result .. p(v)
187 end187 end
188 else188 else
189 result = result ..189 result = result ..
190 li_image(building_description.representative_image, lore_text)190 li_object(building_description.name, lore_text)
191 end191 end
192192
193 local lore_author = building_helptext_lore_author()193 local lore_author = building_helptext_lore_author()
194194
=== modified file 'data/tribes/scripting/help/immovable_help.lua'
--- data/tribes/scripting/help/immovable_help.lua 2018-03-24 14:31:37 +0000
+++ data/tribes/scripting/help/immovable_help.lua 2019-05-03 18:29:53 +0000
@@ -32,7 +32,7 @@
3232
33 -- TRANSLATORS: Put 2 sentences one after the other. Languages using Chinese script probably want to lose the blank space here.33 -- TRANSLATORS: Put 2 sentences one after the other. Languages using Chinese script probably want to lose the blank space here.
34 local purpose_text = pgettext("sentence_separator", "%s %s"):bformat(immovable_helptext(), immovable_helptext(tribe.name))34 local purpose_text = pgettext("sentence_separator", "%s %s"):bformat(immovable_helptext(), immovable_helptext(tribe.name))
35 local result = li_image(immovable_description.representative_image, purpose_text)35 local result = li_object(immovable_description.name, purpose_text)
3636
37 -- Build cost37 -- Build cost
38 local buildcost = ""38 local buildcost = ""
3939
=== modified file 'data/world/immovables/trees/alder/init.lua'
--- data/world/immovables/trees/alder/init.lua 2019-03-17 08:30:43 +0000
+++ data/world/immovables/trees/alder/init.lua 2019-05-03 18:29:53 +0000
@@ -88,6 +88,7 @@
88 name = "alder_summer_old",88 name = "alder_summer_old",
89 descname = _ "Alder (Old)",89 descname = _ "Alder (Old)",
90 species = _ "Alder",90 species = _ "Alder",
91 icon = dirname .. "old/idle_0.png",
91 editor_category = "trees_deciduous",92 editor_category = "trees_deciduous",
92 size = "small",93 size = "small",
93 attributes = { "tree" },94 attributes = { "tree" },
9495
=== modified file 'data/world/immovables/trees/aspen/init.lua'
--- data/world/immovables/trees/aspen/init.lua 2019-03-17 08:30:43 +0000
+++ data/world/immovables/trees/aspen/init.lua 2019-05-03 18:29:53 +0000
@@ -83,6 +83,7 @@
83 name = "aspen_summer_old",83 name = "aspen_summer_old",
84 descname = _ "Aspen (Old)",84 descname = _ "Aspen (Old)",
85 species = _ "Aspen",85 species = _ "Aspen",
86 icon = dirname .. "old/idle_0.png",
86 editor_category = "trees_deciduous",87 editor_category = "trees_deciduous",
87 size = "small",88 size = "small",
88 attributes = { "tree" },89 attributes = { "tree" },
8990
=== modified file 'data/world/immovables/trees/beech/init.lua'
--- data/world/immovables/trees/beech/init.lua 2019-03-17 08:30:43 +0000
+++ data/world/immovables/trees/beech/init.lua 2019-05-03 18:29:53 +0000
@@ -80,6 +80,7 @@
80 name = "beech_summer_old",80 name = "beech_summer_old",
81 descname = _ "Beech (Old)",81 descname = _ "Beech (Old)",
82 species = _ "Beech",82 species = _ "Beech",
83 icon = dirname .. "old/idle_0.png",
83 editor_category = "trees_deciduous",84 editor_category = "trees_deciduous",
84 size = "small",85 size = "small",
85 attributes = { "tree" },86 attributes = { "tree" },
8687
=== modified file 'data/world/immovables/trees/birch/init.lua'
--- data/world/immovables/trees/birch/init.lua 2019-03-17 08:30:43 +0000
+++ data/world/immovables/trees/birch/init.lua 2019-05-03 18:29:53 +0000
@@ -83,6 +83,7 @@
83 name = "birch_summer_old",83 name = "birch_summer_old",
84 descname = _ "Birch (Old)",84 descname = _ "Birch (Old)",
85 species = _ "Birch",85 species = _ "Birch",
86 icon = dirname .. "old/idle_0.png",
86 editor_category = "trees_deciduous",87 editor_category = "trees_deciduous",
87 size = "small",88 size = "small",
88 attributes = { "tree" },89 attributes = { "tree" },
8990
=== modified file 'data/world/immovables/trees/cirrus/init.lua'
--- data/world/immovables/trees/cirrus/init.lua 2018-11-03 11:27:18 +0000
+++ data/world/immovables/trees/cirrus/init.lua 2019-05-03 18:29:53 +0000
@@ -85,6 +85,7 @@
85 descname = _ "Cirrus Tree (Old)",85 descname = _ "Cirrus Tree (Old)",
86 -- TRANSLATORS: This is a fictitious tree. Be creative if you want.86 -- TRANSLATORS: This is a fictitious tree. Be creative if you want.
87 species = _ "Cirrus Tree",87 species = _ "Cirrus Tree",
88 icon = dirname .. "old/idle_0.png",
88 editor_category = "trees_wasteland",89 editor_category = "trees_wasteland",
89 size = "small",90 size = "small",
90 attributes = { "tree" },91 attributes = { "tree" },
9192
=== modified file 'data/world/immovables/trees/larch/init.lua'
--- data/world/immovables/trees/larch/init.lua 2019-03-17 08:30:43 +0000
+++ data/world/immovables/trees/larch/init.lua 2019-05-03 18:29:53 +0000
@@ -80,6 +80,7 @@
80 name = "larch_summer_old",80 name = "larch_summer_old",
81 descname = _ "Larch (Old)",81 descname = _ "Larch (Old)",
82 species = _ "Larch",82 species = _ "Larch",
83 icon = dirname .. "old/idle_0.png",
83 editor_category = "trees_coniferous",84 editor_category = "trees_coniferous",
84 size = "small",85 size = "small",
85 attributes = { "tree" },86 attributes = { "tree" },
8687
=== modified file 'data/world/immovables/trees/liana/init.lua'
--- data/world/immovables/trees/liana/init.lua 2018-11-03 11:27:18 +0000
+++ data/world/immovables/trees/liana/init.lua 2019-05-03 18:29:53 +0000
@@ -88,6 +88,7 @@
88 descname = _ "Liana Tree (Old)",88 descname = _ "Liana Tree (Old)",
89 -- TRANSLATORS: This is a fictitious tree. Be creative if you want.89 -- TRANSLATORS: This is a fictitious tree. Be creative if you want.
90 species = _ "Liana Tree",90 species = _ "Liana Tree",
91 icon = dirname .. "old/idle_0.png",
91 editor_category = "trees_wasteland",92 editor_category = "trees_wasteland",
92 size = "small",93 size = "small",
93 attributes = { "tree" },94 attributes = { "tree" },
9495
=== modified file 'data/world/immovables/trees/maple/init.lua'
--- data/world/immovables/trees/maple/init.lua 2019-03-17 08:30:43 +0000
+++ data/world/immovables/trees/maple/init.lua 2019-05-03 18:29:53 +0000
@@ -80,6 +80,7 @@
80 name = "maple_winter_old",80 name = "maple_winter_old",
81 descname = _ "Maple (Old)",81 descname = _ "Maple (Old)",
82 species = _ "Maple",82 species = _ "Maple",
83 icon = dirname .. "old/idle_0.png",
83 editor_category = "trees_deciduous",84 editor_category = "trees_deciduous",
84 size = "small",85 size = "small",
85 attributes = { "tree" },86 attributes = { "tree" },
8687
=== modified file 'data/world/immovables/trees/mushroom_dark/init.lua'
--- data/world/immovables/trees/mushroom_dark/init.lua 2018-11-03 11:27:18 +0000
+++ data/world/immovables/trees/mushroom_dark/init.lua 2019-05-03 18:29:53 +0000
@@ -85,6 +85,7 @@
85 descname = _ "Dark Mushroom Tree (Old)",85 descname = _ "Dark Mushroom Tree (Old)",
86 -- TRANSLATORS: This is a fictitious tree. Be creative if you want.86 -- TRANSLATORS: This is a fictitious tree. Be creative if you want.
87 species = _ "Dark Mushroom Tree",87 species = _ "Dark Mushroom Tree",
88 icon = dirname .. "old/idle_0.png",
88 editor_category = "trees_wasteland",89 editor_category = "trees_wasteland",
89 size = "small",90 size = "small",
90 attributes = { "tree" },91 attributes = { "tree" },
9192
=== modified file 'data/world/immovables/trees/mushroom_green/init.lua'
--- data/world/immovables/trees/mushroom_green/init.lua 2018-11-03 11:27:18 +0000
+++ data/world/immovables/trees/mushroom_green/init.lua 2019-05-03 18:29:53 +0000
@@ -85,6 +85,7 @@
85 descname = _ "Green Mushroom Tree (Old)",85 descname = _ "Green Mushroom Tree (Old)",
86 -- TRANSLATORS: This is a fictitious tree. Be creative if you want.86 -- TRANSLATORS: This is a fictitious tree. Be creative if you want.
87 species = _ "Green Mushroom Tree",87 species = _ "Green Mushroom Tree",
88 icon = dirname .. "old/idle_0.png",
88 editor_category = "trees_wasteland",89 editor_category = "trees_wasteland",
89 size = "small",90 size = "small",
90 attributes = { "tree" },91 attributes = { "tree" },
9192
=== modified file 'data/world/immovables/trees/mushroom_red/init.lua'
--- data/world/immovables/trees/mushroom_red/init.lua 2018-11-03 11:27:18 +0000
+++ data/world/immovables/trees/mushroom_red/init.lua 2019-05-03 18:29:53 +0000
@@ -88,6 +88,7 @@
88 descname = _ "Red Mushroom Tree (Old)",88 descname = _ "Red Mushroom Tree (Old)",
89 -- TRANSLATORS: This is a fictitious tree. Be creative if you want.89 -- TRANSLATORS: This is a fictitious tree. Be creative if you want.
90 species = _ "Red Mushroom Tree",90 species = _ "Red Mushroom Tree",
91 icon = dirname .. "old/idle_0.png",
91 editor_category = "trees_wasteland",92 editor_category = "trees_wasteland",
92 size = "small",93 size = "small",
93 attributes = { "tree" },94 attributes = { "tree" },
9495
=== modified file 'data/world/immovables/trees/oak/init.lua'
--- data/world/immovables/trees/oak/init.lua 2019-03-17 08:30:43 +0000
+++ data/world/immovables/trees/oak/init.lua 2019-05-03 18:29:53 +0000
@@ -80,6 +80,7 @@
80 name = "oak_summer_old",80 name = "oak_summer_old",
81 descname = _ "Oak (Old)",81 descname = _ "Oak (Old)",
82 species = _ "Oak",82 species = _ "Oak",
83 icon = dirname .. "old/idle_0.png",
83 editor_category = "trees_deciduous",84 editor_category = "trees_deciduous",
84 size = "small",85 size = "small",
85 attributes = { "tree" },86 attributes = { "tree" },
8687
=== modified file 'data/world/immovables/trees/palm_borassus/init.lua'
--- data/world/immovables/trees/palm_borassus/init.lua 2019-03-17 08:30:43 +0000
+++ data/world/immovables/trees/palm_borassus/init.lua 2019-05-03 18:29:53 +0000
@@ -80,6 +80,7 @@
80 name = "palm_borassus_desert_old",80 name = "palm_borassus_desert_old",
81 descname = _ "Borassus Palm (Old)",81 descname = _ "Borassus Palm (Old)",
82 species = _ "Borassus Palm",82 species = _ "Borassus Palm",
83 icon = dirname .. "old/idle_0.png",
83 editor_category = "trees_palm",84 editor_category = "trees_palm",
84 size = "small",85 size = "small",
85 attributes = { "tree" },86 attributes = { "tree" },
8687
=== modified file 'data/world/immovables/trees/palm_coconut/init.lua'
--- data/world/immovables/trees/palm_coconut/init.lua 2019-03-17 08:30:43 +0000
+++ data/world/immovables/trees/palm_coconut/init.lua 2019-05-03 18:29:53 +0000
@@ -80,6 +80,7 @@
80 name = "palm_coconut_desert_old",80 name = "palm_coconut_desert_old",
81 descname = _ "Coconut Palm (Old)",81 descname = _ "Coconut Palm (Old)",
82 species = _ "Coconut Palm",82 species = _ "Coconut Palm",
83 icon = dirname .. "old/idle_0.png",
83 editor_category = "trees_palm",84 editor_category = "trees_palm",
84 size = "small",85 size = "small",
85 attributes = { "tree" },86 attributes = { "tree" },
8687
=== modified file 'data/world/immovables/trees/palm_date/init.lua'
--- data/world/immovables/trees/palm_date/init.lua 2019-03-17 08:30:43 +0000
+++ data/world/immovables/trees/palm_date/init.lua 2019-05-03 18:29:53 +0000
@@ -83,6 +83,7 @@
83 name = "palm_date_desert_old",83 name = "palm_date_desert_old",
84 descname = _ "Date Palm (Old)",84 descname = _ "Date Palm (Old)",
85 species = _ "Date Palm",85 species = _ "Date Palm",
86 icon = dirname .. "old/idle_0.png",
86 editor_category = "trees_palm",87 editor_category = "trees_palm",
87 size = "small",88 size = "small",
88 attributes = { "tree" },89 attributes = { "tree" },
8990
=== modified file 'data/world/immovables/trees/palm_oil/init.lua'
--- data/world/immovables/trees/palm_oil/init.lua 2019-03-17 08:30:43 +0000
+++ data/world/immovables/trees/palm_oil/init.lua 2019-05-03 18:29:53 +0000
@@ -84,6 +84,7 @@
84 name = "palm_oil_desert_old",84 name = "palm_oil_desert_old",
85 descname = _ "Oil Palm (Old)",85 descname = _ "Oil Palm (Old)",
86 species = _ "Oil Palm",86 species = _ "Oil Palm",
87 icon = dirname .. "old/idle_0.png",
87 editor_category = "trees_palm",88 editor_category = "trees_palm",
88 size = "small",89 size = "small",
89 attributes = { "tree" },90 attributes = { "tree" },
9091
=== modified file 'data/world/immovables/trees/palm_roystonea/init.lua'
--- data/world/immovables/trees/palm_roystonea/init.lua 2019-03-17 08:30:43 +0000
+++ data/world/immovables/trees/palm_roystonea/init.lua 2019-05-03 18:29:53 +0000
@@ -80,6 +80,7 @@
80 name = "palm_roystonea_desert_old",80 name = "palm_roystonea_desert_old",
81 descname = _ "Roystonea regia Palm (Old)",81 descname = _ "Roystonea regia Palm (Old)",
82 species = _ "Roystonea regia Palm",82 species = _ "Roystonea regia Palm",
83 icon = dirname .. "old/idle_0.png",
83 editor_category = "trees_palm",84 editor_category = "trees_palm",
84 size = "small",85 size = "small",
85 attributes = { "tree" },86 attributes = { "tree" },
8687
=== modified file 'data/world/immovables/trees/rowan/init.lua'
--- data/world/immovables/trees/rowan/init.lua 2019-03-17 08:30:43 +0000
+++ data/world/immovables/trees/rowan/init.lua 2019-05-03 18:29:53 +0000
@@ -83,6 +83,7 @@
83 name = "rowan_summer_old",83 name = "rowan_summer_old",
84 descname = _ "Rowan (Old)",84 descname = _ "Rowan (Old)",
85 species = _ "Rowan",85 species = _ "Rowan",
86 icon = dirname .. "old/idle_0.png",
86 editor_category = "trees_deciduous",87 editor_category = "trees_deciduous",
87 size = "small",88 size = "small",
88 attributes = { "tree" },89 attributes = { "tree" },
8990
=== modified file 'data/world/immovables/trees/spruce/init.lua'
--- data/world/immovables/trees/spruce/init.lua 2019-03-17 08:30:43 +0000
+++ data/world/immovables/trees/spruce/init.lua 2019-05-03 18:29:53 +0000
@@ -80,6 +80,7 @@
80 name = "spruce_summer_old",80 name = "spruce_summer_old",
81 descname = _ "Spruce (Old)",81 descname = _ "Spruce (Old)",
82 species = _ "Spruce",82 species = _ "Spruce",
83 icon = dirname .. "old/idle_0.png",
83 editor_category = "trees_coniferous",84 editor_category = "trees_coniferous",
84 size = "small",85 size = "small",
85 attributes = { "tree" },86 attributes = { "tree" },
8687
=== modified file 'data/world/immovables/trees/twine/init.lua'
--- data/world/immovables/trees/twine/init.lua 2018-11-03 11:27:18 +0000
+++ data/world/immovables/trees/twine/init.lua 2019-05-03 18:29:53 +0000
@@ -85,6 +85,7 @@
85 descname = _ "Twine Tree (Old)",85 descname = _ "Twine Tree (Old)",
86 -- TRANSLATORS: This is a fictitious tree. Be creative if you want.86 -- TRANSLATORS: This is a fictitious tree. Be creative if you want.
87 species = _ "Twine Tree",87 species = _ "Twine Tree",
88 icon = dirname .. "old/idle_0.png",
88 editor_category = "trees_wasteland",89 editor_category = "trees_wasteland",
89 size = "small",90 size = "small",
90 attributes = { "tree" },91 attributes = { "tree" },
9192
=== modified file 'data/world/immovables/trees/umbrella_green/init.lua'
--- data/world/immovables/trees/umbrella_green/init.lua 2018-11-03 11:27:18 +0000
+++ data/world/immovables/trees/umbrella_green/init.lua 2019-05-03 18:29:53 +0000
@@ -85,6 +85,7 @@
85 descname = _ "Green Umbrella Tree (Old)",85 descname = _ "Green Umbrella Tree (Old)",
86 -- TRANSLATORS: This is a fictitious tree. Be creative if you want.86 -- TRANSLATORS: This is a fictitious tree. Be creative if you want.
87 species = _ "Green Umbrella Tree",87 species = _ "Green Umbrella Tree",
88 icon = dirname .. "old/idle_0.png",
88 editor_category = "trees_wasteland",89 editor_category = "trees_wasteland",
89 size = "small",90 size = "small",
90 attributes = { "tree" },91 attributes = { "tree" },
9192
=== modified file 'data/world/immovables/trees/umbrella_red/init.lua'
--- data/world/immovables/trees/umbrella_red/init.lua 2018-11-03 11:27:18 +0000
+++ data/world/immovables/trees/umbrella_red/init.lua 2019-05-03 18:29:53 +0000
@@ -88,6 +88,7 @@
88 descname = _ "Red Umbrella Tree (Old)",88 descname = _ "Red Umbrella Tree (Old)",
89 -- TRANSLATORS: This is a fictitious tree. Be creative if you want.89 -- TRANSLATORS: This is a fictitious tree. Be creative if you want.
90 species = _ "Red Umbrella Tree",90 species = _ "Red Umbrella Tree",
91 icon = dirname .. "old/idle_0.png",
91 editor_category = "trees_wasteland",92 editor_category = "trees_wasteland",
92 size = "small",93 size = "small",
93 attributes = { "tree" },94 attributes = { "tree" },
9495
=== modified file 'doc/sphinx/source/animations.rst'
--- doc/sphinx/source/animations.rst 2019-04-24 06:32:02 +0000
+++ doc/sphinx/source/animations.rst 2019-05-03 18:29:53 +0000
@@ -26,6 +26,7 @@
26 path = "sound/foo/bar",26 path = "sound/foo/bar",
27 priority = 12827 priority = 128
28 },28 },
29 representative_frame = 3,
29 },30 },
30 working = ...31 working = ...
31 }32 }
@@ -103,6 +104,8 @@
103Each mimap entry must define the ``files`` and the ``scale``.104Each mimap entry must define the ``files`` and the ``scale``.
104See also :ref:`animations_converting_formats`.105See also :ref:`animations_converting_formats`.
105106
107**representative_frame**
108 *Optional*. Choose the animation frame that will be displayed in messages and in the encyclopedia as a representative image. Default is 0.
106109
107Directional Animations110Directional Animations
108----------------------111----------------------
109112
=== modified file 'src/graphic/animation.cc'
--- src/graphic/animation.cc 2019-04-24 20:48:37 +0000
+++ src/graphic/animation.cc 2019-05-03 18:29:53 +0000
@@ -85,7 +85,6 @@
85 uint16_t nr_frames() const override;85 uint16_t nr_frames() const override;
86 uint32_t frametime() const override;86 uint32_t frametime() const override;
87 const Image* representative_image(const RGBColor* clr) const override;87 const Image* representative_image(const RGBColor* clr) const override;
88 const std::string& representative_image_filename() const override;
89 virtual void blit(uint32_t time,88 virtual void blit(uint32_t time,
90 const Widelands::Coords& coords,89 const Widelands::Coords& coords,
91 const Rectf& source_rect,90 const Rectf& source_rect,
@@ -162,7 +161,8 @@
162}161}
163162
164NonPackedAnimation::NonPackedAnimation(const LuaTable& table)163NonPackedAnimation::NonPackedAnimation(const LuaTable& table)
165 : frametime_(FRAME_LENGTH),164 : Animation(table.has_key("representative_frame") ? table.get_int("representative_frame") : 0),
165 frametime_(FRAME_LENGTH),
166 hotspot_(table.get_vector<std::string, int>("hotspot")),166 hotspot_(table.get_vector<std::string, int>("hotspot")),
167 sound_effect_(kNoSoundEffect),167 sound_effect_(kNoSoundEffect),
168 sound_priority_(kFxPriorityLowest),168 sound_priority_(kFxPriorityLowest),
@@ -224,6 +224,10 @@
224 frametime_ = 1000 / get_positive_int(table, "fps");224 frametime_ = 1000 / get_positive_int(table, "fps");
225 }225 }
226226
227 if (representative_frame_ < 0 || representative_frame_ > nr_frames_ - 1) {
228 throw wexception("Animation has %d as its representative frame, but the frame indices available are 0 - %d", representative_frame_, nr_frames_ - 1);
229 }
230
227 // Perform some checks to make sure that the data is complete and consistent231 // Perform some checks to make sure that the data is complete and consistent
228 const bool should_have_playercolor = mipmaps_.begin()->second->has_playercolor_masks;232 const bool should_have_playercolor = mipmaps_.begin()->second->has_playercolor_masks;
229 for (const auto& mipmap : mipmaps_) {233 for (const auto& mipmap : mipmaps_) {
@@ -327,8 +331,8 @@
327 const MipMapEntry& mipmap = *mipmaps_.at(1.0f);331 const MipMapEntry& mipmap = *mipmaps_.at(1.0f);
328 std::vector<std::string> images = mipmap.image_files;332 std::vector<std::string> images = mipmap.image_files;
329 assert(!images.empty());333 assert(!images.empty());
330 const Image* image = (mipmap.has_playercolor_masks && clr) ? playercolor_image(*clr, images[0]) :334 const Image* image = (mipmap.has_playercolor_masks && clr) ? playercolor_image(*clr, images[representative_frame_]) :
331 g_gr->images().get(images[0]);335 g_gr->images().get(images[representative_frame_]);
332336
333 const int w = image->width();337 const int w = image->width();
334 const int h = image->height();338 const int h = image->height();
@@ -338,11 +342,6 @@
338 return rv;342 return rv;
339}343}
340344
341// TODO(GunChleoc): This is only here for the font renderers.
342const std::string& NonPackedAnimation::representative_image_filename() const {
343 return mipmaps_.at(1.0f)->image_files[0];
344}
345
346uint32_t NonPackedAnimation::current_frame(uint32_t time) const {345uint32_t NonPackedAnimation::current_frame(uint32_t time) const {
347 if (nr_frames() > 1) {346 if (nr_frames() > 1) {
348 return (play_once_ && time / frametime_ > static_cast<uint32_t>(nr_frames() - 1)) ?347 return (play_once_ && time / frametime_ > static_cast<uint32_t>(nr_frames() - 1)) ?
@@ -437,6 +436,12 @@
437 animations_.push_back(std::unique_ptr<Animation>(new NonPackedAnimation(table)));436 animations_.push_back(std::unique_ptr<Animation>(new NonPackedAnimation(table)));
438 return animations_.size();437 return animations_.size();
439}438}
439uint32_t AnimationManager::load(const std::string& map_object_name, const LuaTable& table) {
440 animations_.push_back(std::unique_ptr<Animation>(new NonPackedAnimation(table)));
441 const size_t result = animations_.size();
442 representative_animations_by_map_object_name_.insert(std::make_pair(map_object_name, result));
443 return result;
444}
440445
441const Animation& AnimationManager::get_animation(uint32_t id) const {446const Animation& AnimationManager::get_animation(uint32_t id) const {
442 if (!id || id > animations_.size())447 if (!id || id > animations_.size())
@@ -454,3 +459,11 @@
454 }459 }
455 return representative_images_.at(hash).get();460 return representative_images_.at(hash).get();
456}461}
462
463const Image* AnimationManager::get_representative_image(const std::string& map_object_name, const RGBColor* clr) {
464 if (representative_animations_by_map_object_name_.count(map_object_name) != 1) {
465 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());
466 return new Texture(0, 0);
467 }
468 return get_representative_image(representative_animations_by_map_object_name_.at(map_object_name), clr);
469}
457470
=== modified file 'src/graphic/animation.h'
--- src/graphic/animation.h 2019-04-24 20:48:37 +0000
+++ src/graphic/animation.h 2019-05-03 18:29:53 +0000
@@ -53,7 +53,7 @@
53 */53 */
54class Animation {54class Animation {
55public:55public:
56 Animation() {56 Animation(int representative_frame) : representative_frame_(representative_frame) {
57 }57 }
58 virtual ~Animation() {58 virtual ~Animation() {
59 }59 }
@@ -82,8 +82,6 @@
82 /// The 'clr' is the player color used for blending - the parameter can be82 /// The 'clr' is the player color used for blending - the parameter can be
83 /// 'nullptr', in which case the neutral image will be returned.83 /// 'nullptr', in which case the neutral image will be returned.
84 virtual const Image* representative_image(const RGBColor* clr) const = 0;84 virtual const Image* representative_image(const RGBColor* clr) const = 0;
85 /// The filename of the image used for the first frame, without player color.
86 virtual const std::string& representative_image_filename() const = 0;
8785
88 /// Blit the animation frame that should be displayed at the given time index86 /// Blit the animation frame that should be displayed at the given time index
89 /// into the given 'destination_rect'.87 /// into the given 'destination_rect'.
@@ -105,6 +103,9 @@
105 /// If 'coords' == Widelands::Coords::null(), skip playing any sound effects.103 /// If 'coords' == Widelands::Coords::null(), skip playing any sound effects.
106 virtual void trigger_sound(uint32_t time, const Widelands::Coords& coords) const = 0;104 virtual void trigger_sound(uint32_t time, const Widelands::Coords& coords) const = 0;
107105
106protected:
107 int representative_frame_;
108
108private:109private:
109 DISALLOW_COPY_AND_ASSIGN(Animation);110 DISALLOW_COPY_AND_ASSIGN(Animation);
110};111};
@@ -122,6 +123,8 @@
122 * Optional parameters in the Lua table are 'fps' and 'sound_effect'.123 * Optional parameters in the Lua table are 'fps' and 'sound_effect'.
123 */124 */
124 uint32_t load(const LuaTable& table);125 uint32_t load(const LuaTable& table);
126 /// Same as above, but this animation will be used for getting a representative image by map object name
127 uint32_t load(const std::string& map_object_name, const LuaTable& table);
125128
126 /// Returns the animation with the given ID or throws an exception if it is129 /// Returns the animation with the given ID or throws an exception if it is
127 /// unknown.130 /// unknown.
@@ -131,11 +134,13 @@
131 /// If this image has been generated before, it is pulled from the cache using134 /// If this image has been generated before, it is pulled from the cache using
132 /// the clr argument that was used previously.135 /// the clr argument that was used previously.
133 const Image* get_representative_image(uint32_t id, const RGBColor* clr = nullptr);136 const Image* get_representative_image(uint32_t id, const RGBColor* clr = nullptr);
137 const Image* get_representative_image(const std::string& map_object_name, const RGBColor* clr = nullptr);
134138
135private:139private:
136 std::vector<std::unique_ptr<Animation>> animations_;140 std::vector<std::unique_ptr<Animation>> animations_;
137 std::map<std::pair<uint32_t, const RGBColor*>, std::unique_ptr<const Image>>141 std::map<std::pair<uint32_t, const RGBColor*>, std::unique_ptr<const Image>>
138 representative_images_;142 representative_images_;
143 std::map<std::string, uint32_t> representative_animations_by_map_object_name_;
139};144};
140145
141#endif // end of include guard: WL_GRAPHIC_ANIMATION_H146#endif // end of include guard: WL_GRAPHIC_ANIMATION_H
142147
=== modified file 'src/graphic/text/rt_parse.cc'
--- src/graphic/text/rt_parse.cc 2019-02-23 11:00:49 +0000
+++ src/graphic/text/rt_parse.cc 2019-05-03 18:29:53 +0000
@@ -481,15 +481,18 @@
481^^^^^^^^^^481^^^^^^^^^^
482482
483* **src**: The path to the image, relative to the ``data`` directory.483* **src**: The path to the image, relative to the ``data`` directory.
484* **object**: Show the representative image of a map object instead of using ``src``.
484* **ref**: To be implemented485* **ref**: To be implemented
485* **color**: Player color for the image as a hex value486* **color**: Player color for the image as a hex value
486* **width**: Width of the image as a pixel amount. The corresponding height will be matched487* **width**: Width of the image as a pixel amount.
487 automatically.488 The corresponding height will be matched automatically.
489 Not supported in conjunction with the ``object`` parameter.
488490
489:ref:`Return to tag index<rt_tags>`491:ref:`Return to tag index<rt_tags>`
490 */492 */
491 TagConstraint tc;493 TagConstraint tc;
492 tc.allowed_attrs.insert("src");494 tc.allowed_attrs.insert("src");
495 tc.allowed_attrs.insert("object");
493 tc.allowed_attrs.insert("ref");496 tc.allowed_attrs.insert("ref");
494 tc.allowed_attrs.insert("color");497 tc.allowed_attrs.insert("color");
495 tc.allowed_attrs.insert("width");498 tc.allowed_attrs.insert("width");
496499
=== modified file 'src/graphic/text/rt_render.cc'
--- src/graphic/text/rt_render.cc 2019-02-23 11:00:49 +0000
+++ src/graphic/text/rt_render.cc 2019-05-03 18:29:53 +0000
@@ -36,6 +36,7 @@
36#include "base/vector.h"36#include "base/vector.h"
37#include "base/wexception.h"37#include "base/wexception.h"
38#include "graphic/align.h"38#include "graphic/align.h"
39#include "graphic/animation.h"
39#include "graphic/graphic.h"40#include "graphic/graphic.h"
40#include "graphic/image_cache.h"41#include "graphic/image_cache.h"
41#include "graphic/image_io.h"42#include "graphic/image_io.h"
@@ -970,6 +971,17 @@
970 check_size();971 check_size();
971 }972 }
972973
974 ImgRenderNode(NodeStyle& ns,
975 const Image* image)
976 : RenderNode(ns),
977 image_(image),
978 filename_(""),
979 scale_(1.0f),
980 color_(RGBColor(0, 0, 0)),
981 use_playercolor_(false) {
982 check_size();
983 }
984
973 std::string debug_info() const override {985 std::string debug_info() const override {
974 return "img";986 return "img";
975 }987 }
@@ -989,14 +1001,14 @@
989 const Image* image_;1001 const Image* image_;
990 const std::string filename_;1002 const std::string filename_;
991 const double scale_;1003 const double scale_;
992 const RGBColor& color_;1004 const RGBColor color_;
993 bool use_playercolor_;1005 bool use_playercolor_;
994};1006};
9951007
996std::shared_ptr<UI::RenderedText> ImgRenderNode::render(TextureCache* texture_cache) {1008std::shared_ptr<UI::RenderedText> ImgRenderNode::render(TextureCache* texture_cache) {
997 std::shared_ptr<UI::RenderedText> rendered_text(new UI::RenderedText());1009 std::shared_ptr<UI::RenderedText> rendered_text(new UI::RenderedText());
9981010
999 if (scale_ == 1.0) {1011 if (scale_ == 1.0 || filename_.empty()) {
1000 // Image can be used as is, and has already been cached in g_gr->images()1012 // Image can be used as is, and has already been cached in g_gr->images()
1001 assert(image_ != nullptr);1013 assert(image_ != nullptr);
1002 rendered_text->rects.push_back(1014 rendered_text->rects.push_back(
@@ -1267,28 +1279,34 @@
1267 const AttrMap& a = tag_.attrs();1279 const AttrMap& a = tag_.attrs();
1268 RGBColor color;1280 RGBColor color;
1269 bool use_playercolor = false;1281 bool use_playercolor = false;
1270 const std::string image_filename = a["src"].get_string();
1271 double scale = 1.0;1282 double scale = 1.0;
12721283
1273 if (a.has("color")) {1284 if (a.has("color")) {
1274 color = a["color"].get_color();1285 color = a["color"].get_color();
1275 use_playercolor = true;1286 use_playercolor = true;
1276 }1287 }
1277 if (a.has("width")) {1288 if (a.has("object")) {
1278 int width = a["width"].get_int();1289 const Image* representative_image = g_gr->animations().get_representative_image(a["object"].get_string(), use_playercolor ? &color : nullptr);
1279 if (width > renderer_style_.overall_width) {1290 render_node_.reset(new ImgRenderNode(nodestyle_, representative_image));
1280 log("WARNING: Font renderer: Specified image width of %d exceeds the overall available "1291 } else {
1281 "width of %d. Setting width to %d.\n",1292 const std::string image_filename = a["src"].get_string();
1282 width, renderer_style_.overall_width, renderer_style_.overall_width);1293
1283 width = renderer_style_.overall_width;1294 if (a.has("width")) {
1284 }1295 int width = a["width"].get_int();
1285 const int image_width = image_cache_->get(image_filename)->width();1296 if (width > renderer_style_.overall_width) {
1286 if (width < image_width) {1297 log("WARNING: Font renderer: Specified image width of %d exceeds the overall available "
1287 scale = static_cast<double>(width) / image_width;1298 "width of %d. Setting width to %d.\n",
1288 }1299 width, renderer_style_.overall_width, renderer_style_.overall_width);
1300 width = renderer_style_.overall_width;
1301 }
1302 const int image_width = image_cache_->get(image_filename)->width();
1303 if (width < image_width) {
1304 scale = static_cast<double>(width) / image_width;
1305 }
1306 }
1307 render_node_.reset(
1308 new ImgRenderNode(nodestyle_, image_filename, scale, color, use_playercolor));
1289 }1309 }
1290 render_node_.reset(
1291 new ImgRenderNode(nodestyle_, image_filename, scale, color, use_playercolor));
1292 }1310 }
1293 void emit_nodes(std::vector<std::shared_ptr<RenderNode>>& nodes) override {1311 void emit_nodes(std::vector<std::shared_ptr<RenderNode>>& nodes) override {
1294 nodes.push_back(render_node_);1312 nodes.push_back(render_node_);
12951313
=== modified file 'src/logic/map_objects/immovable.cc'
--- src/logic/map_objects/immovable.cc 2019-04-24 06:01:37 +0000
+++ src/logic/map_objects/immovable.cc 2019-05-03 18:29:53 +0000
@@ -222,6 +222,16 @@
222 table.get_table("attributes")->array_entries<std::string>();222 table.get_table("attributes")->array_entries<std::string>();
223 add_attributes(attributes, {MapObject::Attribute::RESI});223 add_attributes(attributes, {MapObject::Attribute::RESI});
224224
225 // All resource indicators must have a menu icon
226 for (const std::string& attribute : attributes) {
227 if (attribute == "resi") {
228 if (icon_filename().empty()) {
229 throw GameDataError("Resource indicator %s has no menu icon", name().c_str());
230 }
231 break;
232 }
233 }
234
225 // Old trees get an extra species name so we can use it in help lists.235 // Old trees get an extra species name so we can use it in help lists.
226 bool is_tree = false;236 bool is_tree = false;
227 for (const std::string& attribute : attributes) {237 for (const std::string& attribute : attributes) {
228238
=== modified file 'src/logic/map_objects/map_object.cc'
--- src/logic/map_objects/map_object.cc 2019-03-03 08:31:25 +0000
+++ src/logic/map_objects/map_object.cc 2019-05-03 18:29:53 +0000
@@ -240,14 +240,18 @@
240 if (table.has_key("animations")) {240 if (table.has_key("animations")) {
241 std::unique_ptr<LuaTable> anims(table.get_table("animations"));241 std::unique_ptr<LuaTable> anims(table.get_table("animations"));
242 for (const std::string& animation : anims->keys<std::string>()) {242 for (const std::string& animation : anims->keys<std::string>()) {
243 add_animation(animation, g_gr->animations().load(*anims->get_table(animation)));243 if (animation == "idle") {
244 add_animation(animation, g_gr->animations().load(init_name, *anims->get_table(animation)));
245 } else {
246 add_animation(animation, g_gr->animations().load(*anims->get_table(animation)));
247 }
244 }248 }
245 if (!is_animation_known("idle")) {249 if (!is_animation_known("idle")) {
246 throw GameDataError(250 throw GameDataError(
247 "Map object %s has animations but no idle animation", init_name.c_str());251 "Map object %s has animations but no idle animation", init_name.c_str());
248 }252 }
249 representative_image_filename_ =253
250 g_gr->animations().get_animation(get_animation("idle")).representative_image_filename();254 assert(g_gr->animations().get_representative_image(name())->width() > 0);
251 }255 }
252 if (table.has_key("icon")) {256 if (table.has_key("icon")) {
253 icon_filename_ = table.get_string("icon");257 icon_filename_ = table.get_string("icon");
@@ -322,9 +326,6 @@
322 }326 }
323 return nullptr;327 return nullptr;
324}328}
325const std::string& MapObjectDescr::representative_image_filename() const {
326 return representative_image_filename_;
327}
328329
329void MapObjectDescr::check_representative_image() {330void MapObjectDescr::check_representative_image() {
330 if (representative_image() == nullptr) {331 if (representative_image() == nullptr) {
331332
=== modified file 'src/logic/map_objects/map_object.h'
--- src/logic/map_objects/map_object.h 2019-02-27 17:19:00 +0000
+++ src/logic/map_objects/map_object.h 2019-05-03 18:29:53 +0000
@@ -138,9 +138,6 @@
138 /// Returns the image for the first frame of the idle animation if the MapObject has animations,138 /// Returns the image for the first frame of the idle animation if the MapObject has animations,
139 /// nullptr otherwise139 /// nullptr otherwise
140 const Image* representative_image(const RGBColor* player_color = nullptr) const;140 const Image* representative_image(const RGBColor* player_color = nullptr) const;
141 /// Returns the image fileneme for first frame of the idle animation if the MapObject has
142 /// animations, is empty otherwise
143 const std::string& representative_image_filename() const;
144141
145 /// Returns the menu image if the MapObject has one, nullptr otherwise142 /// Returns the menu image if the MapObject has one, nullptr otherwise
146 const Image* icon() const;143 const Image* icon() const;
@@ -175,7 +172,6 @@
175 Anims anims_;172 Anims anims_;
176 static uint32_t dyn_attribhigh_; ///< highest attribute ID used173 static uint32_t dyn_attribhigh_; ///< highest attribute ID used
177 static AttribMap dyn_attribs_;174 static AttribMap dyn_attribs_;
178 std::string representative_image_filename_; // Image for big represenations, e.g. on buttons
179 std::string icon_filename_; // Filename for the menu icon175 std::string icon_filename_; // Filename for the menu icon
180176
181 DISALLOW_COPY_AND_ASSIGN(MapObjectDescr);177 DISALLOW_COPY_AND_ASSIGN(MapObjectDescr);
182178
=== modified file 'src/logic/map_objects/tribes/building.cc'
--- src/logic/map_objects/tribes/building.cc 2019-04-24 06:01:37 +0000
+++ src/logic/map_objects/tribes/building.cc 2019-05-03 18:29:53 +0000
@@ -774,12 +774,10 @@
774 bool link_to_building_lifetime,774 bool link_to_building_lifetime,
775 uint32_t throttle_time,775 uint32_t throttle_time,
776 uint32_t throttle_radius) {776 uint32_t throttle_radius) {
777 const std::string& img = descr().representative_image_filename();
778 const int width = descr().representative_image()->width();
779 const std::string rt_description =777 const std::string rt_description =
780 (boost::format("<div padding_r=10><p><img width=%d src=%s color=%s></p></div>"778 (boost::format("<div padding_r=10><p><img object=%s color=%s></p></div>"
781 "<div width=*><p><font size=%d>%s</font></p></div>") %779 "<div width=*><p><font size=%d>%s</font></p></div>") %
782 width % img % owner().get_playercolor().hex_value() % UI_FONT_SIZE_MESSAGE % description)780 descr().name() % owner().get_playercolor().hex_value() % UI_FONT_SIZE_MESSAGE % description)
783 .str();781 .str();
784782
785 std::unique_ptr<Message> msg(new Message(msgtype, game.get_gametime(), title, icon_filename,783 std::unique_ptr<Message> msg(new Message(msgtype, game.get_gametime(), title, icon_filename,
786784
=== modified file 'src/logic/map_objects/tribes/tribe_descr.cc'
--- src/logic/map_objects/tribes/tribe_descr.cc 2019-04-09 16:43:49 +0000
+++ src/logic/map_objects/tribes/tribe_descr.cc 2019-05-03 18:29:53 +0000
@@ -64,8 +64,8 @@
64 initializations_ = info.initializations;64 initializations_ = info.initializations;
6565
66 std::unique_ptr<LuaTable> items_table = table.get_table("animations");66 std::unique_ptr<LuaTable> items_table = table.get_table("animations");
67 frontier_animation_id_ = g_gr->animations().load(*items_table->get_table("frontier"));67 frontier_animation_id_ = g_gr->animations().load(name_ + std::string("_frontier"), *items_table->get_table("frontier"));
68 flag_animation_id_ = g_gr->animations().load(*items_table->get_table("flag"));68 flag_animation_id_ = g_gr->animations().load(name_ + std::string("_flag"), *items_table->get_table("flag"));
6969
70 items_table = table.get_table("roads");70 items_table = table.get_table("roads");
71 const auto load_roads = [&items_table](71 const auto load_roads = [&items_table](
7272
=== modified file 'src/logic/map_objects/tribes/worker.cc'
--- src/logic/map_objects/tribes/worker.cc 2019-04-27 13:24:29 +0000
+++ src/logic/map_objects/tribes/worker.cc 2019-05-03 18:29:53 +0000
@@ -973,11 +973,10 @@
973973
974 // Geologist also sends a message notifying the player974 // Geologist also sends a message notifying the player
975 if (rdescr && rdescr->detectable() && position.field->get_resources_amount()) {975 if (rdescr && rdescr->detectable() && position.field->get_resources_amount()) {
976 const int width = g_gr->images().get(rdescr->representative_image())->width();
977 const std::string message =976 const std::string message =
978 (boost::format("<div padding_r=10><p><img width=%d src=%s></p></div>"977 (boost::format("<div padding_r=10><p><img object=%s></p></div>"
979 "<div width=*><p><font size=%d>%s</font></p></div>") %978 "<div width=*><p><font size=%d>%s</font></p></div>") %
980 width % ri.descr().representative_image_filename() % UI_FONT_SIZE_MESSAGE %979 ri.descr().name() % UI_FONT_SIZE_MESSAGE %
981 _("A geologist found resources."))980 _("A geologist found resources."))
982 .str();981 .str();
983982
984983
=== modified file 'src/scripting/lua_map.cc'
--- src/scripting/lua_map.cc 2019-04-09 16:43:49 +0000
+++ src/scripting/lua_map.cc 2019-05-03 18:29:53 +0000
@@ -1804,7 +1804,6 @@
1804 PROP_RO(LuaMapObjectDescription, icon_name),1804 PROP_RO(LuaMapObjectDescription, icon_name),
1805 PROP_RO(LuaMapObjectDescription, name),1805 PROP_RO(LuaMapObjectDescription, name),
1806 PROP_RO(LuaMapObjectDescription, type_name),1806 PROP_RO(LuaMapObjectDescription, type_name),
1807 PROP_RO(LuaMapObjectDescription, representative_image),
1808 {nullptr, nullptr, nullptr},1807 {nullptr, nullptr, nullptr},
1809};1808};
18101809
@@ -1866,17 +1865,6 @@
1866}1865}
18671866
1868/* RST1867/* RST
1869 .. attribute:: representative_image
1870
1871 (RO) a :class:`string` with the file path to the representative image
1872 of the map object's idle animation
1873*/
1874int LuaMapObjectDescription::get_representative_image(lua_State* L) {
1875 lua_pushstring(L, get()->representative_image_filename());
1876 return 1;
1877}
1878
1879/* RST
1880 .. attribute:: type_name1868 .. attribute:: type_name
18811869
1882 (RO) the map object's type as a string. Map object types are1870 (RO) the map object's type as a string. Map object types are
@@ -3701,7 +3689,6 @@
37013689
3702 (RO) the :class:`string` file path to a representative image3690 (RO) the :class:`string` file path to a representative image
3703*/3691*/
3704
3705int LuaTerrainDescription::get_representative_image(lua_State* L) {3692int LuaTerrainDescription::get_representative_image(lua_State* L) {
3706 lua_pushstring(L, get()->texture_paths().front());3693 lua_pushstring(L, get()->texture_paths().front());
3707 return 1;3694 return 1;
37083695
=== modified file 'src/scripting/lua_map.h'
--- src/scripting/lua_map.h 2019-04-07 05:46:13 +0000
+++ src/scripting/lua_map.h 2019-05-03 18:29:53 +0000
@@ -198,7 +198,6 @@
198 int get_helptext_script(lua_State*);198 int get_helptext_script(lua_State*);
199 int get_name(lua_State*);199 int get_name(lua_State*);
200 int get_type_name(lua_State*);200 int get_type_name(lua_State*);
201 int get_representative_image(lua_State*);
202201
203 /*202 /*
204 * Lua methods203 * Lua methods
205204
=== modified file 'src/website/map_object_info.cc'
--- src/website/map_object_info.cc 2019-03-08 17:26:28 +0000
+++ src/website/map_object_info.cc 2019-05-03 18:29:53 +0000
@@ -70,7 +70,7 @@
70 JSON::Object* json_building = json_buildings_array->add_object();70 JSON::Object* json_building = json_buildings_array->add_object();
71 json_building->add_string("name", building.name());71 json_building->add_string("name", building.name());
72 json_building->add_string("descname", building.descname());72 json_building->add_string("descname", building.descname());
73 json_building->add_string("icon", building.representative_image_filename());73 json_building->add_string("icon", building.icon_filename());
7474
75 // Buildcost75 // Buildcost
76 if (building.is_buildable()) {76 if (building.is_buildable()) {

Subscribers

People subscribed via source and target branches

to status/vote changes: