Merge lp:~widelands-dev/widelands/bug-1625502-tips-in-help into lp:widelands
- bug-1625502-tips-in-help
- Merge into trunk
Status: | Merged | ||||||||
---|---|---|---|---|---|---|---|---|---|
Merged at revision: | 8259 | ||||||||
Proposed branch: | lp:~widelands-dev/widelands/bug-1625502-tips-in-help | ||||||||
Merge into: | lp:widelands | ||||||||
Diff against target: |
644 lines (+306/-162) 17 files modified
data/scripting/editor/editor_help.lua (+7/-0) data/scripting/editor/tips.lua (+18/-0) data/scripting/format_scenario.lua (+0/-12) data/scripting/formatting.lua (+11/-0) data/tribes/scripting/help/init.lua (+7/-1) data/tribes/scripting/help/tips.lua (+75/-0) data/txts/tips/atlanteans.lua (+12/-7) data/txts/tips/barbarians.lua (+12/-11) data/txts/tips/editor.lua (+32/-28) data/txts/tips/empire.lua (+12/-11) data/txts/tips/general_game.lua (+68/-59) data/txts/tips/multiplayer.lua (+16/-11) data/txts/tips/singleplayer.lua (+8/-3) src/scripting/lua_globals.cc (+3/-1) src/wui/game_tips.cc (+17/-17) src/wui/game_tips.h (+1/-1) src/wui/tribal_encyclopedia.cc (+7/-0) |
||||||||
To merge this branch: | bzr merge lp:~widelands-dev/widelands/bug-1625502-tips-in-help | ||||||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
kaputtnik (community) | testing | Approve | |
Review via email: mp+312969@code.launchpad.net |
Commit message
Convert editor/game tips to Lua and display them in the in-editor/in-game help.
Description of the change
bunnybot (widelandsofficial) wrote : | # |
bunnybot (widelandsofficial) wrote : | # |
Continuous integration builds have changed state:
Travis build 1761. State: passed. Details: https:/
Appveyor build 1601. State: success. Details: https:/
bunnybot (widelandsofficial) wrote : | # |
Bunnybot encountered an error while working on this merge proposal:
('The read operation timed out',)
bunnybot (widelandsofficial) wrote : | # |
Continuous integration builds have changed state:
Travis build 1761. State: passed. Details: https:/
Appveyor build 1601. State: success. Details: https:/
bunnybot (widelandsofficial) wrote : | # |
Bunnybot encountered an error while working on this merge proposal:
('The read operation timed out',)
bunnybot (widelandsofficial) wrote : | # |
Continuous integration builds have changed state:
Travis build 1761. State: passed. Details: https:/
Appveyor build 1601. State: success. Details: https:/
kaputtnik (franku) wrote : | # |
> How about we do a general overhaul if the tips?
Yes, that is a good idea. I think we could ask in the forums for such tips and get good answers then :-)
Klaus Halfmann (klaus-halfmann) wrote : | # |
Code LGTM, one nit about <br /> but as this HTML is not in the wild,
it may not be worth changing.
Will compile / test this now
kaputtnik (franku) wrote : | # |
Do you want to add/change the tips suggested in the forum in this branch? Since it could be a job for a person who don't know much about C++, the related changes could be made in another branch after this one is merged.
GunChleoc (gunchleoc) wrote : | # |
Let's get this branch in so we can add the content changes in another branch.
@bunnybot merge
Preview Diff
1 | === modified file 'data/scripting/editor/editor_help.lua' |
2 | --- data/scripting/editor/editor_help.lua 2016-04-02 08:09:19 +0000 |
3 | +++ data/scripting/editor/editor_help.lua 2017-01-23 08:39:34 +0000 |
4 | @@ -65,7 +65,14 @@ |
5 | title = _"Controls", |
6 | script = "scripting/editor/editor_controls.lua", |
7 | script_parameters = {} |
8 | + }, |
9 | + { |
10 | + name = "tips", |
11 | + title = _"Tips", |
12 | + script = "scripting/editor/tips.lua", |
13 | + script_parameters = {} |
14 | } |
15 | + |
16 | } |
17 | }, |
18 | { |
19 | |
20 | === added file 'data/scripting/editor/tips.lua' |
21 | --- data/scripting/editor/tips.lua 1970-01-01 00:00:00 +0000 |
22 | +++ data/scripting/editor/tips.lua 2017-01-23 08:39:34 +0000 |
23 | @@ -0,0 +1,18 @@ |
24 | +include "scripting/formatting.lua" |
25 | + |
26 | +function get_editor_tips() |
27 | + include "txts/tips/editor.lua" |
28 | + return tips |
29 | +end |
30 | + |
31 | +local text = paragraphdivider() |
32 | +for index, contents in pairs(get_editor_tips()) do |
33 | + text = text .. listitem_bullet(contents["text"]) |
34 | +end |
35 | +text = text .. "</p>" |
36 | + |
37 | +set_textdomain("widelands_editor") |
38 | +return { |
39 | + title = _"Tips", |
40 | + text = rt(text) |
41 | +} |
42 | |
43 | === modified file 'data/scripting/format_scenario.lua' |
44 | --- data/scripting/format_scenario.lua 2016-04-02 10:53:01 +0000 |
45 | +++ data/scripting/format_scenario.lua 2017-01-23 08:39:34 +0000 |
46 | @@ -48,18 +48,6 @@ |
47 | |
48 | |
49 | -- RST |
50 | --- .. function:: paragraphdivider() |
51 | --- |
52 | --- Closes a paragraph and opens a new paragraph. Use this when you format a string with the speech function |
53 | --- and need to divide the speech into multiple paragraphs. |
54 | --- |
55 | --- :returns: <br></p><p font-size=8><br></p><p line-spacing=3 font-size=12> |
56 | -function paragraphdivider() |
57 | - return ("<br></p><p font-size=8><br></p><p line-spacing=3 font-size=12>") |
58 | -end |
59 | - |
60 | - |
61 | --- RST |
62 | -- .. function:: objective_text(heading, body) |
63 | -- |
64 | -- Provides nice formatting for objective texts. |
65 | |
66 | === modified file 'data/scripting/formatting.lua' |
67 | --- data/scripting/formatting.lua 2016-09-21 08:41:51 +0000 |
68 | +++ data/scripting/formatting.lua 2017-01-23 08:39:34 +0000 |
69 | @@ -264,3 +264,14 @@ |
70 | t2 .. "<br></p><p font-size=8> <br></p></rt>" |
71 | end |
72 | end |
73 | + |
74 | +-- RST |
75 | +-- .. function:: paragraphdivider() |
76 | +-- |
77 | +-- Closes a paragraph and opens a new paragraph. Use this when you format a string with the speech function |
78 | +-- and need to divide the speech into multiple paragraphs. |
79 | +-- |
80 | +-- :returns: <br></p><p font-size=8><br></p><p line-spacing=3 font-size=12> |
81 | +function paragraphdivider() |
82 | + return ("<br></p><p font-size=8><br></p><p line-spacing=3 font-size=12>") |
83 | +end |
84 | |
85 | === modified file 'data/tribes/scripting/help/init.lua' |
86 | --- data/tribes/scripting/help/init.lua 2016-04-02 08:21:25 +0000 |
87 | +++ data/tribes/scripting/help/init.lua 2017-01-23 08:39:34 +0000 |
88 | @@ -42,7 +42,7 @@ |
89 | |
90 | -- Main function |
91 | return { |
92 | - func = function(tribename) |
93 | + func = function(tribename, game_type) |
94 | set_textdomain("tribes_encyclopedia") |
95 | return { |
96 | title = _"Tribal Encyclopedia", |
97 | @@ -64,6 +64,12 @@ |
98 | title = _"Controls", |
99 | script = "tribes/scripting/help/controls.lua", |
100 | script_parameters = {} |
101 | + }, |
102 | + { |
103 | + name = "tips", |
104 | + title = _"Tips", |
105 | + script = "tribes/scripting/help/tips.lua", |
106 | + script_parameters = {tribename, game_type} |
107 | } |
108 | } |
109 | }, |
110 | |
111 | === added file 'data/tribes/scripting/help/tips.lua' |
112 | --- data/tribes/scripting/help/tips.lua 1970-01-01 00:00:00 +0000 |
113 | +++ data/tribes/scripting/help/tips.lua 2017-01-23 08:39:34 +0000 |
114 | @@ -0,0 +1,75 @@ |
115 | +include "scripting/formatting.lua" |
116 | + |
117 | +function get_general_tips() |
118 | + include "txts/tips/general_game.lua" |
119 | + return tips |
120 | +end |
121 | + |
122 | +function get_atlantean_tips() |
123 | + include "txts/tips/atlanteans.lua" |
124 | + return tips |
125 | +end |
126 | + |
127 | +function get_barbarian_tips() |
128 | + include "txts/tips/barbarians.lua" |
129 | + return tips |
130 | +end |
131 | + |
132 | +function get_empire_tips() |
133 | + include "txts/tips/empire.lua" |
134 | + return tips |
135 | +end |
136 | + |
137 | +function get_singleplayer_tips() |
138 | + include "txts/tips/singleplayer.lua" |
139 | + return tips |
140 | +end |
141 | + |
142 | +function get_multiplayer_tips() |
143 | + include "txts/tips/multiplayer.lua" |
144 | + return tips |
145 | +end |
146 | + |
147 | +function format_tips(tips) |
148 | + local text = paragraphdivider() |
149 | + for index, contents in pairs(tips) do |
150 | + text = text .. listitem_bullet(contents["text"]) |
151 | + end |
152 | + text = text .. "</p>" |
153 | + return text |
154 | +end |
155 | + |
156 | +return { |
157 | + func = function(tribename, game_type) |
158 | + set_textdomain("tribes_encyclopedia") |
159 | + local text = h2(_"General") |
160 | + text = text .. format_tips(get_general_tips()) |
161 | + |
162 | + set_textdomain("tribes_encyclopedia") |
163 | + if (tribename == "atlanteans") then |
164 | + text = text .. h2(_"Atlanteans") |
165 | + text = text .. format_tips(get_atlantean_tips()) |
166 | + elseif (tribename == "barbarians") then |
167 | + text = text .. h2(_"Barbarians") |
168 | + text = text .. format_tips(get_barbarian_tips()) |
169 | + elseif (tribename == "empire") then |
170 | + text = text .. h2(_"Empire") |
171 | + text = text .. format_tips(get_empire_tips()) |
172 | + end |
173 | + |
174 | + set_textdomain("tribes_encyclopedia") |
175 | + if (game_type == "singleplayer") then |
176 | + text = text .. h2(_"Single Player") |
177 | + text = text .. format_tips(get_singleplayer_tips()) |
178 | + else |
179 | + text = text .. h2(_"Multiplayer") |
180 | + text = text .. format_tips(get_multiplayer_tips()) |
181 | + end |
182 | + |
183 | + set_textdomain("tribes_encyclopedia") |
184 | + return { |
185 | + title = _"Tips", |
186 | + text = rt(text) |
187 | + } |
188 | + end |
189 | +} |
190 | |
191 | === renamed file 'data/txts/tips/atlanteans.tip' => 'data/txts/tips/atlanteans.lua' |
192 | --- data/txts/tips/atlanteans.tip 2015-11-07 08:28:27 +0000 |
193 | +++ data/txts/tips/atlanteans.lua 2017-01-23 08:39:34 +0000 |
194 | @@ -1,7 +1,12 @@ |
195 | -[Tip 1] |
196 | -text=_Some buildings, such as the farm, have a very small work area. If the building is surrounded with trees or roads, production will stop. |
197 | -sec=7 |
198 | - |
199 | -[Tip 2] |
200 | -text=_"Always build a forester’s and a fish breeder’s house, so you will not run out of logs or food." |
201 | -sec=5 |
202 | +set_textdomain("texts") |
203 | +tips = { |
204 | + { |
205 | + text = _"Keep an eye on your fishers and build a fish breeder’s house. After fish resources are exhausted in their work area, the fish supply cannot be regenerated.", |
206 | + seconds = 4 |
207 | + }, |
208 | + { |
209 | + text = _"Always build a forester’s and a woodcutter’s house, so you will not run out of logs.", |
210 | + seconds = 5 |
211 | + }, |
212 | +} |
213 | +return tips |
214 | |
215 | === renamed file 'data/txts/tips/barbarians.tip' => 'data/txts/tips/barbarians.lua' |
216 | --- data/txts/tips/barbarians.tip 2015-11-07 08:28:27 +0000 |
217 | +++ data/txts/tips/barbarians.lua 2017-01-23 08:39:34 +0000 |
218 | @@ -1,11 +1,12 @@ |
219 | -[Tip 1] |
220 | -text=_Some buildings, such as the farm, have a very small work area. If the building is surrounded with trees or roads, production will stop. |
221 | -sec=7 |
222 | - |
223 | -[Tip 2] |
224 | -text=_Keep an eye on your fishers. After fish resources are exhausted in their work area, they will stop fishing. |
225 | -sec=4 |
226 | - |
227 | -[Tip 3] |
228 | -text=_"Always build a ranger’s and a gamekeeper’s hut, so you will not run out of logs or food." |
229 | -sec=5 |
230 | +set_textdomain("texts") |
231 | +tips = { |
232 | + { |
233 | + text = _"Keep an eye on your fishers. After fish resources are exhausted in their work area, they will stop fishing.", |
234 | + seconds = 4 |
235 | + }, |
236 | + { |
237 | + text = _"Always build a ranger’s and a gamekeeper’s hut, so you will not run out of logs.", |
238 | + seconds = 5 |
239 | + }, |
240 | +} |
241 | +return tips |
242 | |
243 | === renamed file 'data/txts/tips/editor.tip' => 'data/txts/tips/editor.lua' |
244 | --- data/txts/tips/editor.tip 2016-10-01 07:45:42 +0000 |
245 | +++ data/txts/tips/editor.lua 2017-01-23 08:39:34 +0000 |
246 | @@ -1,28 +1,32 @@ |
247 | -[Tip 1] |
248 | -text=_"You can find general help for the editor as well as a short tutorial on our wiki at www.widelands.org" |
249 | -sec=6 |
250 | - |
251 | -[Tip 2] |
252 | -text=_"You can select multiple animal types if you hold down Ctrl during selection. If you then click on the map, an instance of one of the selected animal types will be placed." |
253 | -sec=7 |
254 | - |
255 | -[Tip 3] |
256 | -text=_"Just like with animals, you can also select multiple immovables or ground textures with Ctrl + mouse click." |
257 | -sec=6 |
258 | - |
259 | -[Tip 4] |
260 | -text=_"Holding down Shift switches the first alternative tool on. This tool is in most cases the complete opposite of the normal tool (for example deletion of an object instead of placing one)." |
261 | -sec=7 |
262 | - |
263 | -[Tip 5] |
264 | -text=_"Holding down Alt switches the second alternative tool on (if it exists)." |
265 | -sec=6 |
266 | - |
267 | -[Tip 6] |
268 | -text=_"The number keys (0 - 9) allow you to directly set the size of the selected area around your mouse cursor." |
269 | -sec=6 |
270 | - |
271 | -[Tip 7] |
272 | -text=_"Space key behaves like in normal game. It switches if building spaces are shown on or off." |
273 | -sec=6 |
274 | - |
275 | +set_textdomain("texts") |
276 | +tips = { |
277 | + { |
278 | + text = _"You can find general help for the editor as well as a short tutorial on our wiki at www.widelands.org", |
279 | + seconds = 6 |
280 | + }, |
281 | + { |
282 | + text = _"You can select multiple animal types if you hold down Ctrl during selection. If you then click on the map, an instance of one of the selected animal types will be placed.", |
283 | + seconds = 7 |
284 | + }, |
285 | + { |
286 | + text = _"Just like with animals, you can also select multiple immovables or ground textures with Ctrl + mouse click.", |
287 | + seconds = 6 |
288 | + }, |
289 | + { |
290 | + text = _"Holding down Shift switches the first alternative tool on. This tool is in most cases the complete opposite of the normal tool (for example deletion of an object instead of placing one).", |
291 | + seconds = 7 |
292 | + }, |
293 | + { |
294 | + text = _"Holding down Alt switches the second alternative tool on (if it exists).", |
295 | + seconds = 6 |
296 | + }, |
297 | + { |
298 | + text = _"The number keys (0 - 9) allow you to directly set the size of the selected area around your mouse cursor.", |
299 | + seconds = 6 |
300 | + }, |
301 | + { |
302 | + text = _"Space key behaves like in normal game. It switches if building spaces are shown on or off.", |
303 | + seconds = 6 |
304 | + }, |
305 | +} |
306 | +return tips |
307 | |
308 | === renamed file 'data/txts/tips/empire.tip' => 'data/txts/tips/empire.lua' |
309 | --- data/txts/tips/empire.tip 2015-11-07 08:28:27 +0000 |
310 | +++ data/txts/tips/empire.lua 2017-01-23 08:39:34 +0000 |
311 | @@ -1,11 +1,12 @@ |
312 | -[Tip 1] |
313 | -text=_Some buildings, such as the farm, have a very small work area. If the building is surrounded with trees or roads, production will stop. |
314 | -sec=7 |
315 | - |
316 | -[Tip 2] |
317 | -text=_Keep an eye on your fishers. After fish resources are exhausted in their work area, they will stop fishing. |
318 | -sec=4 |
319 | - |
320 | -[Tip 3] |
321 | -text=_Always build a forester’s house so you will not run out of logs. |
322 | -sec=5 |
323 | +set_textdomain("texts") |
324 | +tips = { |
325 | + { |
326 | + text = _"Keep an eye on your fishers. After fish resources are exhausted in their work area, they will stop fishing.", |
327 | + seconds = 4 |
328 | + }, |
329 | + { |
330 | + text = _"Always build a forester’s house so you will not run out of logs.", |
331 | + seconds = 5 |
332 | + }, |
333 | +} |
334 | +return tips |
335 | |
336 | === renamed file 'data/txts/tips/general_game.tip' => 'data/txts/tips/general_game.lua' |
337 | --- data/txts/tips/general_game.tip 2017-01-02 18:32:52 +0000 |
338 | +++ data/txts/tips/general_game.lua 2017-01-23 08:39:34 +0000 |
339 | @@ -1,59 +1,68 @@ |
340 | -[Tip 1] |
341 | -text=_The building process will only start after a road is built to the construction site. |
342 | -sec=4 |
343 | - |
344 | -[Tip 2] |
345 | -text=_Be sure to send a geologist to survey sites before building a well or a mine. |
346 | -sec=4 |
347 | - |
348 | -[Tip 3] |
349 | -text=_Your territory can be expanded by building various military buildings – Sentry, Fortress, Blockhouse, etc. |
350 | -sec=5 |
351 | - |
352 | -[Tip 4] |
353 | -text=_Miners will work only if supplied with food. |
354 | -sec=3 |
355 | - |
356 | -[Tip 5] |
357 | -text=_Split your roads into shorter sections by planting some flags. This will speed up transportation of your wares. |
358 | -sec=6 |
359 | - |
360 | -[Tip 6] |
361 | -text=_Any further questions? Our FAQ, the wiki and of course our community forums can be found at www.widelands.org. |
362 | -sec=6 |
363 | - |
364 | -[Tip 7] |
365 | -text=_Use the priority buttons in building windows to adjust delivery of a specific ware. |
366 | -sec=5 |
367 | - |
368 | -[Tip 8] |
369 | -text=_Use the ‘configure economy’ menu to adjust the target quantity of wares. It can be accessed via the flag menu. |
370 | -sec=7 |
371 | - |
372 | -[Tip 9] |
373 | -text=_Manage your messages more efficiently: press ‘N’ for News to access the messages window, then use ‘G’ for Go To, and the Delete key to archive messages. |
374 | -sec=6 |
375 | - |
376 | -[Tip 10] |
377 | -text=_Press Ctrl+(0-9) to store important locations, then press 0-9 to recall them. |
378 | -sec=4 |
379 | - |
380 | -[Tip 11] |
381 | -text=_Removing a road while holding Ctrl lets you remove all flags up to the first junction. |
382 | -sec=4 |
383 | - |
384 | -[Tip 12] |
385 | -text=_New soldiers are recruited in the headquarters or a warehouse if all needed tools are available. Training sites are for improving their abilities. |
386 | -sec=6 |
387 | - |
388 | -[Tip 13] |
389 | -text=_If you like to live dangerously, pressing Ctrl while clicking the enhance, dismantle or destroy building buttons will skip the confirmation. |
390 | -sec=6 |
391 | - |
392 | -[Tip 14] |
393 | -text=_Press I to quickly toggle the display of your stock inventory. |
394 | -sec=4 |
395 | - |
396 | -[Tip 15] |
397 | -text=_An economy consists of all buildings and flags connected by roads. The supplies and demands of buildings are handled in its economy. |
398 | -sec=8 |
399 | +set_textdomain("texts") |
400 | +tips = { |
401 | + { |
402 | + text = _"The building process will only start after a road is built to the construction site.", |
403 | + seconds = 4 |
404 | + }, |
405 | + { |
406 | + text = _"Be sure to send a geologist to survey sites before building a well or a mine.", |
407 | + seconds = 4 |
408 | + }, |
409 | + { |
410 | + text = _"Your territory can be expanded by building various military buildings – Sentry, Fortress, Blockhouse, etc.", |
411 | + seconds = 5 |
412 | + }, |
413 | + { |
414 | + text = _"Miners will work only if supplied with food.", |
415 | + seconds = 3 |
416 | + }, |
417 | + { |
418 | + text = _"Split your roads into shorter sections by planting some flags. This will speed up transportation of your wares.", |
419 | + seconds = 6 |
420 | + }, |
421 | + { |
422 | + text = _"Any further questions? Our FAQ, the wiki and of course our community forums can be found at www.widelands.org.", |
423 | + seconds = 6 |
424 | + }, |
425 | + { |
426 | + text = _"Use the priority buttons in building windows to adjust delivery of a specific ware.", |
427 | + seconds = 5 |
428 | + }, |
429 | + { |
430 | + text = _"Use the ‘configure economy’ menu to adjust the target quantity of wares. It can be accessed via the flag menu.", |
431 | + seconds = 7 |
432 | + }, |
433 | + { |
434 | + text = _"Manage your messages more efficiently: press ‘N’ for News to access the messages window, then use ‘G’ for Go To, and the Delete key to archive messages.", |
435 | + seconds = 6 |
436 | + }, |
437 | + { |
438 | + text = _"Press Ctrl+(0-9) to store important locations, then press 0-9 to recall them.", |
439 | + seconds = 4 |
440 | + }, |
441 | + { |
442 | + text = _"Removing a road while holding Ctrl lets you remove all flags up to the first junction.", |
443 | + seconds = 4 |
444 | + }, |
445 | + { |
446 | + text = _"New soldiers are recruited in a barracks. Their abilities can then be improved in training sites.", |
447 | + seconds = 6 |
448 | + }, |
449 | + { |
450 | + text = _"If you like to live dangerously, pressing Ctrl while clicking the enhance, dismantle or destroy building buttons will skip the confirmation.", |
451 | + seconds = 6 |
452 | + }, |
453 | + { |
454 | + text = _"Press I to quickly toggle the display of your stock inventory.", |
455 | + seconds = 4 |
456 | + }, |
457 | + { |
458 | + text = _"An economy consists of all buildings and flags connected by roads. The supplies and demands of buildings are handled in its economy.", |
459 | + seconds = 8 |
460 | + }, |
461 | + { |
462 | + text = _"Some buildings, such as the farm, have a very small work area. If the building is surrounded with trees or roads, production will stop.", |
463 | + seconds = 7 |
464 | + }, |
465 | +} |
466 | +return tips |
467 | |
468 | === renamed file 'data/txts/tips/multiplayer.tip' => 'data/txts/tips/multiplayer.lua' |
469 | --- data/txts/tips/multiplayer.tip 2014-02-25 14:42:19 +0000 |
470 | +++ data/txts/tips/multiplayer.lua 2017-01-23 08:39:34 +0000 |
471 | @@ -1,11 +1,16 @@ |
472 | -[Tip 1] |
473 | -text=_"You can use the ’Page up’ and ‘Page down’ keys to adjust your desired speed – the real speed is then democratically set." |
474 | -sec=5 |
475 | - |
476 | -[Tip 2] |
477 | -text=_"You can use ‘/me’ at the beginning of a chatmessage: ‘/me is tired’ will be printed as ‘-> Nickname is tired’." |
478 | -sec=5 |
479 | - |
480 | -[Tip 3] |
481 | -text=_"Use ‘@name’ at the beginning of a chat message to send it to only one player." |
482 | -sec=5 |
483 | +set_textdomain("texts") |
484 | +tips = { |
485 | + { |
486 | + text = _"You can use the ’Page up’ and ‘Page down’ keys to adjust your desired speed – the real speed is then democratically set.", |
487 | + seconds = 5 |
488 | + }, |
489 | + { |
490 | + text = _"You can use ‘/me’ at the beginning of a chatmessage: ‘/me is tired’ will be printed as ‘-> Nickname is tired’.", |
491 | + seconds = 5 |
492 | + }, |
493 | + { |
494 | + text = _"Use ‘@name’ at the beginning of a chat message to send it to only one player.", |
495 | + seconds = 5 |
496 | + }, |
497 | +} |
498 | +return tips |
499 | |
500 | === renamed file 'data/txts/tips/singleplayer.tip' => 'data/txts/tips/singleplayer.lua' |
501 | --- data/txts/tips/singleplayer.tip 2009-04-15 12:49:22 +0000 |
502 | +++ data/txts/tips/singleplayer.lua 2017-01-23 08:39:34 +0000 |
503 | @@ -1,3 +1,8 @@ |
504 | -[Tip 1] |
505 | -text=_Our computer players are too boring? Visit our website at www.widelands.org and meet other players to play online. |
506 | -sec=6 |
507 | +set_textdomain("texts") |
508 | +tips = { |
509 | + { |
510 | + text = _"Our computer players are too boring? Visit our website at www.widelands.org and meet other players to play online.", |
511 | + seconds = 6 |
512 | + }, |
513 | +} |
514 | +return tips |
515 | |
516 | === modified file 'src/scripting/lua_globals.cc' |
517 | --- src/scripting/lua_globals.cc 2016-08-06 12:39:38 +0000 |
518 | +++ src/scripting/lua_globals.cc 2017-01-23 08:39:34 +0000 |
519 | @@ -20,6 +20,7 @@ |
520 | #include "scripting/lua_globals.h" |
521 | |
522 | #include <exception> |
523 | +#include <memory> |
524 | |
525 | #include <boost/format.hpp> |
526 | |
527 | @@ -239,7 +240,8 @@ |
528 | lua_getfield(L, LUA_REGISTRYINDEX, "lua_interface"); |
529 | LuaInterface* lua = static_cast<LuaInterface*>(lua_touserdata(L, -1)); |
530 | lua_pop(L, 1); // pop this userdata |
531 | - lua->run_script(script); |
532 | + std::unique_ptr<LuaTable> table(lua->run_script(script)); |
533 | + table->do_not_warn_about_unaccessed_keys(); |
534 | } catch (std::exception& e) { |
535 | report_error(L, "%s", e.what()); |
536 | } |
537 | |
538 | === modified file 'src/wui/game_tips.cc' |
539 | --- src/wui/game_tips.cc 2016-10-24 14:07:28 +0000 |
540 | +++ src/wui/game_tips.cc 2017-01-23 08:39:34 +0000 |
541 | @@ -19,15 +19,17 @@ |
542 | |
543 | #include "wui/game_tips.h" |
544 | |
545 | +#include <memory> |
546 | + |
547 | #include "base/i18n.h" |
548 | #include "graphic/font_handler1.h" |
549 | #include "graphic/graphic.h" |
550 | #include "graphic/rendertarget.h" |
551 | #include "graphic/text_layout.h" |
552 | #include "io/fileread.h" |
553 | -#include "profile/profile.h" |
554 | +#include "scripting/lua_interface.h" |
555 | +#include "scripting/lua_table.h" |
556 | |
557 | -#define DEFAULT_INTERVAL 5 // seconds |
558 | #define BG_IMAGE "images/loadscreens/tips_bg.png" |
559 | |
560 | GameTips::GameTips(UI::ProgressWindow& progressWindow, const std::vector<std::string>& names) |
561 | @@ -36,7 +38,7 @@ |
562 | progressWindow_(progressWindow), |
563 | registered_(false), |
564 | lastTip_(0) { |
565 | - // Loading texts-locals, for translating the tips |
566 | + // Loading the "texts" locale for translating the tips |
567 | i18n::Textdomain textdomain("texts"); |
568 | |
569 | for (uint8_t i = 0; i < names.size(); ++i) |
570 | @@ -54,24 +56,22 @@ |
571 | stop(); |
572 | } |
573 | |
574 | -/// Loads tips out of \var filename |
575 | -void GameTips::load_tips(std::string name) { |
576 | - std::string filename = "txts/tips/" + name + ".tip"; |
577 | +/// Loads tips out of \var name |
578 | +void GameTips::load_tips(const std::string& name) { |
579 | try { |
580 | - Profile prof(filename.c_str()); |
581 | - while (Section* const s = prof.get_next_section(nullptr)) { |
582 | - char const* const text = s->get_string("text"); |
583 | - if (nullptr == text) |
584 | - continue; |
585 | - |
586 | + LuaInterface lua; |
587 | + std::unique_ptr<LuaTable> table(lua.run_script("txts/tips/" + name + ".lua")); |
588 | + std::unique_ptr<LuaTable> tip_table; |
589 | + for (const int key : table->keys<int>()) { |
590 | + tip_table = table->get_table(key); |
591 | Tip tip; |
592 | - tip.text = text; |
593 | - tip.interval = s->get_int("sec", DEFAULT_INTERVAL); |
594 | + tip.text = tip_table->get_string("text"); |
595 | + tip.interval = tip_table->get_int("seconds"); |
596 | tips_.push_back(tip); |
597 | } |
598 | - } catch (std::exception&) { |
599 | - // just ignore - tips do not impact game |
600 | - return; |
601 | + } catch (LuaError& err) { |
602 | + log("Error loading tips script for %s:\n%s\n", name.c_str(), err.what()); |
603 | + // No further handling necessary - tips do not impact game |
604 | } |
605 | } |
606 | |
607 | |
608 | === modified file 'src/wui/game_tips.h' |
609 | --- src/wui/game_tips.h 2016-08-04 15:49:05 +0000 |
610 | +++ src/wui/game_tips.h 2017-01-23 08:39:34 +0000 |
611 | @@ -39,7 +39,7 @@ |
612 | std::string text; |
613 | int32_t interval; |
614 | }; |
615 | - void load_tips(std::string); |
616 | + void load_tips(const std::string& name); |
617 | void show_tip(int32_t index); |
618 | |
619 | uint32_t lastUpdated_; |
620 | |
621 | === modified file 'src/wui/tribal_encyclopedia.cc' |
622 | --- src/wui/tribal_encyclopedia.cc 2016-08-04 15:49:05 +0000 |
623 | +++ src/wui/tribal_encyclopedia.cc 2017-01-23 08:39:34 +0000 |
624 | @@ -24,6 +24,7 @@ |
625 | #include <boost/format.hpp> |
626 | |
627 | #include "base/i18n.h" |
628 | +#include "logic/game_controller.h" |
629 | #include "logic/map_objects/tribes/tribe_descr.h" |
630 | #include "logic/player.h" |
631 | #include "scripting/lua_coroutine.h" |
632 | @@ -41,6 +42,12 @@ |
633 | std::unique_ptr<LuaTable> table(lua_->run_script("tribes/scripting/help/init.lua")); |
634 | std::unique_ptr<LuaCoroutine> cr(table->get_coroutine("func")); |
635 | cr->push_arg(tribe.name()); |
636 | + upcast(Widelands::Game, game, &parent.egbase()); |
637 | + if (game->game_controller()->get_game_type() == GameController::GameType::SINGLEPLAYER) { |
638 | + cr->push_arg("singleplayer"); |
639 | + } else { |
640 | + cr->push_arg("multiplayer"); |
641 | + } |
642 | cr->resume(); |
643 | init(parent, cr->pop_table()); |
644 | } catch (LuaError& err) { |
Continuous integration builds have changed state:
Travis build 1754. State: failed. Details: https:/ /travis- ci.org/ widelands/ widelands/ builds/ 182871607. /ci.appveyor. com/project/ widelands- dev/widelands/ build/_ widelands_ dev_widelands_ bug_1625502_ tips_in_ help-1594.
Appveyor build 1594. State: success. Details: https:/