File: editor_help.lua

package info (click to toggle)
widelands 1%3A19%2Brepack-3
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 370,608 kB
  • ctags: 20,609
  • sloc: cpp: 108,404; ansic: 18,695; python: 5,155; sh: 487; xml: 460; makefile: 233
file content (86 lines) | stat: -rw-r--r-- 2,497 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
-- Returns definitions for encyclopedia tabs and their contents for the
-- Editor Help


-- Comparison function used to sort map objects alphabetically
function compare_by_title(a, b)
  return a["title"] < b["title"]
end

-- Returns help entries for all the terrains in the world
function get_terrains()
   local result = {}
   for i, terrain in ipairs(wl.World().terrain_descriptions) do
      result[i] = {
         name = terrain.name,
         title = terrain.descname,
         icon = terrain.representative_image,
         script = "scripting/editor/terrain_help.lua",
         script_parameters = {[1] = terrain.name}
      }
   end
   table.sort(result, compare_by_title)
   return result
end

-- Returns help entries for all the trees in the world
function get_trees()
   local result = {}
   local counter = 1
   for i, immovable in ipairs(wl.World().immovable_descriptions) do
      if (immovable:has_attribute("tree")) then
         result[counter] = {
            name = immovable.name,
            title = immovable.species,
            icon = immovable.representative_image,
            script = "scripting/editor/tree_help.lua",
            script_parameters = {[1] = immovable.name}
         }
         counter = counter  + 1
      end
   end
   table.sort(result, compare_by_title)
   return result
end

-- Main function
set_textdomain("widelands_editor")
return {
   title = _"Editor Help",
   tabs = {
      {
         name = "general",
         -- TRANSLATORS Tab title: General help with the Widelands Editor
         title = _"General",
         icon = "images/logos/WL-Editor-32.png",
         entries = {
            {
               name = "intro",
               title = _"Introduction",
               script = "scripting/editor/editor_introduction.lua",
               script_parameters = {}
            },
            {
               name = "controls",
               title = _"Controls",
               script = "scripting/editor/editor_controls.lua",
               script_parameters = {}
            }
         }
      },
      {
         name = "terrains",
         -- TRANSLATORS Tab title: terrain help
         title = _"Terrains",
         icon = "images/wui/editor/editor_menu_tool_set_terrain.png",
         entries = get_terrains()
      },
      {
         name = "trees",
         -- TRANSLATORS Tab title: tree help
         title = _"Trees",
         icon = "world/immovables/trees/alder/old/idle_0.png",
         entries = get_trees()
      }
   }
}