unbanished_formats/ui/kinds.rs
1//! The element classes' own data: buttons, text, labels, documents, layouts and table cells.
2
3use super::*;
4
5/// A button's description.
6#[derive(Debug, Clone)]
7pub struct Button {
8 /// enabled, disabled, highlight, pressed state elements
9 pub states: [Ref; 4],
10 /// The content: a label or an image.
11 pub content: Ref,
12 /// Content colours per state (ARGB), same order as `states`.
13 pub colors: [u32; 4],
14}
15
16/// A text element's description.
17#[derive(Debug, Clone)]
18pub struct Text {
19 /// The font.
20 pub font: Ref,
21 /// The string table that `text` is a key of.
22 pub string_table: Ref,
23 /// String-table key, or literal text when no table is given.
24 pub text: String,
25 /// Draw a black shadow one pixel down and right (TextElement::Draw).
26 pub shadow: bool,
27 /// Whether long lines wrap.
28 pub wrap: bool,
29 /// Width limit passed to `Font::ComputeStringLayout` (wrapping / ellipsis).
30 pub max_width: i32,
31 /// `Font::Justify`: 0 left, 1 centre, 2 right.
32 pub justify: u32,
33 /// Non-wrapped line width at which the engine inserts "...". This is not a key code.
34 pub ellipsis_width: i32,
35}
36
37/// A label's description: text with an optional icon.
38#[derive(Debug, Clone)]
39pub struct Label {
40 /// The text.
41 pub text: Text,
42 /// The icon's sprite sheet.
43 pub sprite_sheet: Ref,
44 /// The icon's sprite name.
45 pub sprite: String,
46 /// The alignment of the text.
47 pub text_alignment: u32,
48 /// > 1 stacks icon above text, otherwise icon left of text (`LabelElement::ComputeSize`).
49 pub orientation: u32,
50 /// The smallest width of the text, in pixels.
51 pub min_text_width: i32,
52 /// The space between the icon and the text, in pixels.
53 pub gap: i32,
54 /// The icon's size, in pixels.
55 pub icon_size: [i32; 2],
56}
57
58/// What an element description is, with the fields of its class.
59#[derive(Debug, Clone)]
60pub enum ElementKind {
61 /// Children laid out on top of each other, each by its alignment.
62 Group {
63 /// The children.
64 children: Vec<Ref>,
65 },
66 /// Pages, of which one is shown.
67 Page {
68 /// The pages.
69 children: Vec<Ref>,
70 /// The page shown at first.
71 page: i32,
72 },
73 /// Radio buttons, of which one is selected.
74 Radio {
75 /// The buttons.
76 children: Vec<Ref>,
77 /// The button selected at first.
78 selected: i32,
79 },
80 /// Children in a row or a column.
81 Ribbon {
82 /// A column when true, a row when false.
83 vertical: bool,
84 /// Whether every cell has the size of the largest child.
85 uniform: bool,
86 /// The space between the cells, in pixels.
87 spacing: i32,
88 /// The children.
89 children: Vec<Ref>,
90 },
91 /// A frame drawn from nine sprites.
92 Border {
93 /// The sprite sheet.
94 sprite_sheet: Ref,
95 /// The nine sprites, row by row: corners, edges and centre.
96 sprites: [String; 9],
97 },
98 /// One sprite.
99 Image {
100 /// The sprite sheet.
101 sprite_sheet: Ref,
102 /// The sprite name.
103 sprite: String,
104 /// The size, in pixels.
105 size: [i32; 2],
106 },
107 /// The game's `FrustumOutlineDescription` (MapUI's camera outline): an image block whose
108 /// element draws lines instead of the sprite.
109 ///
110 /// Original: `FUN_14006c7f0`.
111 FrustumOutline {
112 /// The sprite sheet.
113 sprite_sheet: Ref,
114 /// The sprite the lines are drawn with.
115 sprite: String,
116 /// The size, in pixels.
117 size: [i32; 2],
118 },
119 /// A sequence of sprites played as an animation.
120 AnimatedImage {
121 /// The sprite sheet.
122 sprite_sheet: Ref,
123 /// The first frame's sprite.
124 sprite: String,
125 /// The size, in pixels.
126 size: [i32; 2],
127 /// The frames' sprite names.
128 frames: Vec<String>,
129 /// The frame rate.
130 rate: i32,
131 },
132 /// A button.
133 Button(Button),
134 /// A check box.
135 Check {
136 /// The box.
137 button: Button,
138 /// The tick, shown when checked.
139 check: Ref,
140 },
141 /// A combo box: a button that opens a list.
142 Combo {
143 /// The button that shows the choice.
144 button: Button,
145 /// The list's parts: the second is the text whose font the list uses, the third the
146 /// choices.
147 refs: [Ref; 3],
148 },
149 /// Text.
150 Text(Text),
151 /// Text with an optional icon.
152 Label(Label),
153 /// A window onto its content, cut at its edges.
154 ClipRegion {
155 /// The window's size, in pixels.
156 unknown: [i32; 2],
157 /// The content.
158 content: Ref,
159 },
160 /// A scrolling area.
161 Container {
162 /// The size (two values) and the space between the content and the bars.
163 unknown: [i32; 3],
164 /// The horizontal bar, the vertical bar and the content.
165 refs: [Ref; 3],
166 /// Not identified yet.
167 unknown_bools: [bool; 2],
168 },
169 /// An edit box.
170 Edit {
171 /// The font.
172 font: Ref,
173 /// The text at first.
174 text: String,
175 /// The most characters it takes (0: no limit).
176 max_length: i32,
177 /// Whether the text is drawn as `*`s (a password).
178 unknown_bool: bool,
179 /// The characters it takes, any when empty.
180 unknown_string: String,
181 },
182 /// A graph of values over time.
183 Graph {
184 /// The size (two values) and the length of the ticks.
185 unknown: [i32; 3],
186 /// Not identified yet.
187 unknown_u32: u32,
188 /// The sprite sheet of the lines.
189 sprite_sheet: Ref,
190 /// The sprite the lines are drawn with.
191 sprite: String,
192 },
193 /// Children placed by anchors relative to the element.
194 Layout {
195 /// The children and their anchors.
196 items: Vec<LayoutItem>,
197 },
198 /// A list of rows.
199 List {
200 /// The list's parts: the first is the text whose font the rows use.
201 refs: [Ref; 2],
202 /// The sprite sheet of the highlight.
203 sprite_sheet: Ref,
204 /// The highlight's sprite.
205 sprite: String,
206 /// Not identified yet.
207 unknown: [u32; 2],
208 },
209 /// An edit box for a number.
210 NumberEdit {
211 /// The font.
212 font: Ref,
213 /// The value at first, the smallest and largest value, and the most digits.
214 unknown: [i32; 4],
215 /// Whether the number may be below zero.
216 unknown_bool: bool,
217 },
218 /// A number shown as text.
219 Number {
220 /// The font.
221 font: Ref,
222 /// The colour, `0xAARRGGBB`.
223 color: u32,
224 /// Not identified yet.
225 unknown_int: i32,
226 /// The value at first.
227 unknown_float: f32,
228 /// Not identified yet.
229 unknown_bool: bool,
230 },
231 /// A slider.
232 Slider {
233 /// The number shown next to the slider.
234 track: Ref,
235 /// The sprite sheet.
236 sprite_sheet: Ref,
237 /// The sprites: the track's ends and middle, the knob, and the knob under the pointer.
238 sprites: [String; 5],
239 /// The track's vertical position and the inset of the knob's travel.
240 unknown: [i32; 2],
241 /// The smallest and the largest value.
242 range: [f32; 2],
243 /// The steps across the range: a click on the track moves the value one step.
244 unknown_b0: i32,
245 },
246 /// A number with up and down arrows.
247 Spinner {
248 /// The number and the two arrows.
249 refs: [Ref; 3],
250 /// How much an arrow changes the number.
251 unknown: i32,
252 },
253 /// Tabs: a header for each tab, and the page of the selected one.
254 Tab {
255 /// The elements drawn around the tabs.
256 refs: [Ref; 3],
257 /// The sprite sheet.
258 sprite_sheet: Ref,
259 /// The sprites of the tab headers.
260 sprites: [String; 3],
261 /// The space between the headers, in pixels.
262 unknown: i32,
263 /// Each tab: its header and its page.
264 tabs: Vec<(Ref, Ref)>,
265 },
266 /// A progress bar.
267 Progress {
268 /// The background's colour, `0xAARRGGBB`.
269 color: u32,
270 /// The sprite sheet.
271 sprite_sheet: Ref,
272 /// The sprites of the fill and the background.
273 sprites: [String; 6],
274 /// The element drawn on top (usually a label).
275 unknown_ref: Ref,
276 },
277 /// A scroll bar.
278 Scroll {
279 /// The sprite sheet.
280 sprite_sheet: Ref,
281 /// The sprites of the track, the thumb and the arrows.
282 sprites: [String; 9],
283 /// A vertical bar when true.
284 vertical: bool,
285 /// The thumb's inset at both ends of the track.
286 unknown: i32,
287 /// The thumb's colour, and a value not identified yet.
288 unknown_u32: [u32; 2],
289 },
290 /// A table of cells in rows and columns.
291 Table {
292 /// The number of columns, the number of rows, and the space between the cells.
293 unknown: [i32; 3],
294 /// The cells.
295 cells: Vec<TableCell>,
296 },
297 /// A document with markup (the help pages and the tutorials).
298 DocumentText(DocumentText),
299}
300
301/// Rich text configuration (`DocumentTextDescription::Serialize`).
302///
303/// Original: Runtime `0x1800d2110`.
304#[derive(Debug, Clone)]
305pub struct DocumentText {
306 /// The string table that `text` is a key of.
307 pub string_table: Ref,
308 /// The text with markup, or its key.
309 pub text: String,
310 /// The sprite sheet of the bullets and the underline.
311 pub sprite_sheet: Ref,
312 /// The bullets' sprite names.
313 pub bullets: Vec<String>,
314 /// The underline's sprite name.
315 pub underline_sprite: String,
316 /// The colours of links: normal, under the pointer, pressed.
317 pub link_colors: [u32; 3],
318 /// The indent of list items, in pixels.
319 pub indent: i32,
320 /// The width at which the text wraps, in pixels.
321 pub width: i32,
322 /// The fonts the markup can select.
323 pub fonts: Vec<Ref>,
324 /// The sprite sheets the markup can show images from.
325 pub sheets: Vec<Ref>,
326 /// The colours the markup can select.
327 pub colors: Vec<u32>,
328 /// The resource with the document's pictures.
329 pub images: Ref,
330}
331
332/// A child of a layout element, with its anchors.
333#[derive(Debug, Clone)]
334pub struct LayoutItem {
335 /// The child.
336 pub element: Ref,
337 /// The names of the anchors.
338 pub strings: [String; 3],
339 /// Not identified yet.
340 pub unknown_u32: [u32; 2],
341 /// The offsets from the anchors, in pixels.
342 pub unknown_i32: [i32; 2],
343 /// Not identified yet.
344 pub flag: bool,
345}
346
347/// A cell of a table element.
348#[derive(Debug, Clone)]
349pub struct TableCell {
350 /// The column.
351 pub column: i32,
352 /// The row.
353 pub row: i32,
354 /// The cell's element.
355 pub element: Ref,
356}