|
1 #summary List of functions in the Lua API that affect the GUI |
|
2 |
|
3 = Lua API: GUI functions = |
|
4 This page is a list of all functios in the [LuaAPI Lua API] that affect the GUI (graphical user interface). |
|
5 |
|
6 == Captions == |
|
7 === <tt>!AddCaption(text)</tt> === |
|
8 Display an event text in the upper part of the screen. The text will be white and the caption group will be `capgrpMessage`. |
|
9 |
|
10 Example: |
|
11 <code language="lua"> |
|
12 AddCaption("Hello, world!") |
|
13 </code> |
|
14 |
|
15 === <tt>!AddCaption(text, color, captiongroup)</tt> === |
|
16 Display an event text in the upper part of the screen with the specified RGBA text [LuaOverview#Color color] and caption group. Although an RBGA color is used, Hedgewars does not actually support transparent or semi-transparent captions, so the fourth byte is ignored. We recommend you to always specify a full opacity (`FF` in hexadecimal) for the caption. |
|
17 |
|
18 || *`captiongroup`* || *Meaning* || |
|
19 || `capgrpGameState` || Used for important global game events, like Sudden Death || |
|
20 || `capgrpAmmoinfo` || Used for new weapon crates and some other events || |
|
21 || `capgrpVolume` || Used for “local” changes of client settings that don't affect gameplay, like volume change, auto camera on/off, etc. || |
|
22 || `capgrpMessage` || Generic message || |
|
23 || `capgrpMessage2` || Generic message || |
|
24 || `capgrpAmmostate` || Used to show information about weapon state, i.e. bounce level, timer, remaining shots, etc. || |
|
25 |
|
26 The color can be specified in RGBA format, but you can (but don't have to) use one of the following built-in text color. |
|
27 |
|
28 || *Built-in color* || *Meaning* || |
|
29 || `capcolDefault` || Default caption color || |
|
30 || `capcolSetting` || Notification related to a local client setting (audio volume, auto camera on/off) || |
|
31 |
|
32 Example: |
|
33 <code language="lua"> |
|
34 AddCaption("Melon bomb rain in 2 rounds!", 0xFF0000FF, capgrpGameState) |
|
35 -- Green example message. |
|
36 </code> |
|
37 |
|
38 == Mission panel == |
|
39 === <tt>!ShowMission(caption, subcaption, text, icon, time [, forceDisplay])</tt> === |
|
40 This function will open the mission panel and set the texts in it. |
|
41 |
|
42 Use to tell the player what he/she is supposed to do. If you use this function, a mission panel is shown for the amount of time specified in `time` (in milliseconds). If `time` is set to 0, it will be displayed for a default amount of time. |
|
43 This function replaces the *entire* text of the mission panel. Compare this to the global `Goals` variable, which *adds* to the default text without replacing it. |
|
44 |
|
45 `caption` is the text displayed in the first line, `subcaption` is displayed in the second line and `text` is the text displayed in the third and following lines. |
|
46 |
|
47 By convention, `caption` should *normally* contain the name of the game style or mission and `subcaption` should *normally* contain the type of game style or mission, or a witty tagline. But this is only a loose convention which you don't have to follow all the time. |
|
48 |
|
49 `text` uses some special characters for formatting: |
|
50 |
|
51 || *Special character* || *Meaning* || |
|
52 || `|` || Line break || |
|
53 || `:` || Highlight itself and all text before that character in this line. The colon itself will be written. || |
|
54 || `::` || Like above, except the two colons will not be written. || |
|
55 || `\|` || Will be replaced with “|” without triggering a line break (escape sequence) || |
|
56 || `\:` || Will be replaced with “:” without triggering highlighting (escape sequence) || |
|
57 |
|
58 `icon` accepts the following values: |
|
59 |
|
60 || *`icon`* || *What is shown* || |
|
61 || _negative number_ || Icon of an ammo type. It is specified as the negative of an ammo type constant (see [AmmoTypes]), i.e. `-amBazooka` for the bazooka icon. || |
|
62 || `0` || Golden crown || |
|
63 || `1` || Target || |
|
64 || `2` || Exclamation mark || |
|
65 || `3` || Question mark || |
|
66 || `4` || Golden star || |
|
67 || `5` || Utility crate || |
|
68 || `6` || Health crate || |
|
69 || `7` || Ammo crate || |
|
70 || `8` || Barrel || |
|
71 || `9` || Dud mine || |
|
72 |
|
73 If the optional parameter `forceDisplay` is `true`, this mission panel cannot be removed manually by the player. It's `false` by default. |
|
74 |
|
75 Example: |
|
76 <code language="lua"> |
|
77 ShowMission(loc("Nobody Laugh"), loc("User Challenge"), loc("Eliminate the enemy before the time runs out"), 0, 0) |
|
78 </code> |
|
79 |
|
80 (Note: `loc` comes from the [LuaLibraryLocale Locale Lua library.) |
|
81 |
|
82 === <tt>!HideMission()</tt> === |
|
83 Hides the mission panel if it is currently displayed, otherwise, this function does nothing. |
|
84 |
|
85 == Zoom == |
|
86 === <tt>!SetZoom(zoomLevel)</tt> === |
|
87 Sets the zoom level. The value for maximum zoom is currently 1.0 and for minimum 3.0 The default zoom level is 2.0 |
|
88 |
|
89 === <tt>!GetZoom()</tt> === |
|
90 Returns the current zoom level. |
|
91 |
|
92 == Cinematic mode == |
|
93 === <tt>!SetCinematicMode(enable)</tt> (0.9.23) === |
|
94 Turns on or off cinematic mode. Cinematic mode can be used for cutscenes etc. |
|
95 If `enable` is set to `true`, cinematic mode is enabled, |
|
96 if it is `false`, cinematic mode is disabled. |
|
97 |
|
98 |