File: toolhistory_tooltip.lua

package info (click to toggle)
widelands 2%3A1.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 684,084 kB
  • sloc: cpp: 196,737; ansic: 19,395; python: 8,515; sh: 1,734; xml: 700; makefile: 46; lisp: 25
file content (46 lines) | stat: -rw-r--r-- 1,304 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
-- RST
-- toolhistory_tooltip.lua
-- -----------------------
--
-- This script returns a compact formatted entry for toolhistory list tooltips in the editor.
-- Pass map object type ("terrain", "critter", or "immovable") followed by the internal names of
-- the map objects to the coroutine.
-- If the map object type is "image", the arguments are interpreted as image filepaths.

include "scripting/richtext.lua"
include "scripting/help.lua"

local gap = styles.get_size("editor_tooltip_icon_gap")

return {
   func = function(mo_type, ...)
      push_textdomain("widelands_editor")
      local result = ""
      for i,name in ipairs{...} do
         if mo_type == "terrain" then
            local descr = wl.Editor():get_terrain_description(name)
            result = result .. img(descr.representative_image) .. space(gap)

         elseif mo_type == "critter" then
            result = result .. img_object(name) .. space(gap)

         elseif mo_type == "immovable" then
            result = result .. img_object(name) .. space(gap)

         elseif mo_type == "image" then
            result = result .. img(name) .. space(gap)

         end
      end

      if result ~= "" then
         result = p(result)
      end

      pop_textdomain()

      return {
         text = result
      }
   end
}