ScummVM API documentation
ThemeParser.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef THEME_PARSER_H
23 #define THEME_PARSER_H
24 
25 #include "common/scummsys.h"
26 #include "common/formats/xmlparser.h"
27 
28 namespace GUI {
29 
30 class ThemeEngine;
31 
33 public:
34  ThemeParser(ThemeEngine *parent);
35 
36  ~ThemeParser() override;
37 
38  void setBaseResolution(int w, int h, float s) {
39  _baseWidth = w;
40  _baseHeight = h;
41  _scaleFactor = s;
42  }
43 
44  bool getPaletteColor(const Common::String &name, int &r, int &g, int &b) {
45  if (!_palette.contains(name))
46  return false;
47 
48  r = _palette[name].r;
49  g = _palette[name].g;
50  b = _palette[name].b;
51 
52  return true;
53  }
54 
55 protected:
56  ThemeEngine *_theme;
57 
58  CUSTOM_XML_PARSER(ThemeParser) {
59  XML_KEY(render_info)
60  XML_PROP(resolution, false)
61  XML_KEY(palette)
62  XML_KEY(color)
63  XML_PROP(name, true)
64  XML_PROP(rgb, true)
65  KEY_END()
66  KEY_END()
67 
68  XML_KEY(fonts)
69  XML_KEY(font)
70  XML_PROP(id, true)
71  XML_PROP(file, false)
72  XML_PROP(resolution, false)
73  XML_PROP(scalable_file, false)
74  XML_PROP(point_size, false)
75  XML_KEY(language)
76  XML_PROP(id, true)
77  XML_PROP(file, false)
78  XML_PROP(scalable_file, false)
79  XML_PROP(point_size, false)
80  KEY_END()
81  KEY_END()
82 
83  XML_KEY(text_color)
84  XML_PROP(id, true);
85  XML_PROP(color, true);
86  KEY_END()
87  KEY_END()
88 
89  XML_KEY(bitmaps)
90  XML_KEY(bitmap)
91  XML_PROP(filename, true)
92  XML_PROP(resolution, false)
93  XML_PROP(scalable_file, false)
94  XML_PROP(width, false)
95  XML_PROP(height, false)
96  KEY_END()
97  KEY_END()
98 
99  XML_KEY(cursor)
100  XML_PROP(file, true)
101  XML_PROP(hotspot, true)
102  XML_PROP(resolution, false)
103  KEY_END()
104 
105  XML_KEY(defaults)
106  XML_PROP(stroke, false)
107  XML_PROP(shadow, false)
108  XML_PROP(bevel, false)
109  XML_PROP(factor, false)
110  XML_PROP(fg_color, false)
111  XML_PROP(bg_color, false)
112  XML_PROP(gradient_start, false)
113  XML_PROP(gradient_end, false)
114  XML_PROP(bevel_color, false)
115  XML_PROP(gradient_factor, false)
116  XML_PROP(fill, false)
117  KEY_END()
118 
119  XML_KEY(drawdata)
120  XML_PROP(id, true)
121  XML_PROP(cache, false)
122  XML_PROP(resolution, false)
123 
124  XML_KEY(defaults)
125  XML_PROP(stroke, false)
126  XML_PROP(shadow, false)
127  XML_PROP(bevel, false)
128  XML_PROP(factor, false)
129  XML_PROP(fg_color, false)
130  XML_PROP(bg_color, false)
131  XML_PROP(gradient_start, false)
132  XML_PROP(gradient_end, false)
133  XML_PROP(bevel_color, false)
134  XML_PROP(gradient_factor, false)
135  XML_PROP(fill, false)
136  KEY_END()
137 
138  XML_KEY(drawstep)
139  XML_PROP(func, true)
140  XML_PROP(stroke, false)
141  XML_PROP(shadow, false)
142  XML_PROP(bevel, false)
143  XML_PROP(factor, false)
144  XML_PROP(fg_color, false)
145  XML_PROP(bg_color, false)
146  XML_PROP(gradient_start, false)
147  XML_PROP(gradient_end, false)
148  XML_PROP(gradient_factor, false)
149  XML_PROP(bevel_color, false)
150  XML_PROP(fill, false)
151  XML_PROP(radius, false)
152  XML_PROP(width, false)
153  XML_PROP(height, false)
154  XML_PROP(xpos, false)
155  XML_PROP(ypos, false)
156  XML_PROP(padding, false)
157  XML_PROP(orientation, false)
158  XML_PROP(file, false)
159  XML_PROP(autoscale, false)
160  XML_PROP(clip, false)
161  KEY_END()
162 
163  XML_KEY(text)
164  XML_PROP(font, true)
165  XML_PROP(text_color, true)
166  XML_PROP(vertical_align, true)
167  XML_PROP(horizontal_align, true)
168  KEY_END()
169  KEY_END()
170 
171  KEY_END() // render_info end
172 
173  XML_KEY(layout_info)
174  XML_PROP(resolution, false)
175  XML_KEY(globals)
176  XML_PROP(resolution, false)
177  XML_KEY(def)
178  XML_PROP(var, true)
179  XML_PROP(value, true)
180  XML_PROP(resolution, false)
181  XML_PROP(scalable, false)
182  KEY_END()
183 
184  XML_KEY(widget)
185  XML_PROP(name, true)
186  XML_PROP(size, false)
187  XML_PROP(pos, false)
188  XML_PROP(padding, false)
189  XML_PROP(resolution, false)
190  XML_PROP(textalign, false)
191  XML_PROP(rtl, false)
192  KEY_END()
193  KEY_END()
194 
195  XML_KEY(dialog)
196  XML_PROP(name, true)
197  XML_PROP(overlays, true)
198  XML_PROP(size, false)
199  XML_PROP(shading, false)
200  XML_PROP(resolution, false)
201  XML_PROP(inset, false)
202  XML_KEY(layout)
203  XML_PROP(type, true)
204  XML_PROP(align, false)
205  XML_PROP(padding, false)
206  XML_PROP(spacing, false)
207  XML_PROP(resolution, false)
208 
209  XML_KEY(import)
210  XML_PROP(layout, true)
211  KEY_END()
212 
213  XML_KEY(widget)
214  XML_PROP(name, true)
215  XML_PROP(width, false)
216  XML_PROP(height, false)
217  XML_PROP(type, false)
218  XML_PROP(textalign, false)
219  XML_PROP(rtl, false)
220  XML_PROP(resolution, false)
221  KEY_END()
222 
223  XML_KEY(space)
224  XML_PROP(size, false)
225  XML_PROP(resolution, false)
226  KEY_END()
227 
228  XML_KEY_RECURSIVE(layout)
229  KEY_END()
230  KEY_END()
231  KEY_END()
232 
233  } PARSER_END()
234 
235 
236  bool parserCallback_render_info(ParserNode *node);
237  bool parserCallback_defaults(ParserNode *node);
238  bool parserCallback_font(ParserNode *node);
239  bool parserCallback_text_color(ParserNode *node);
240  bool parserCallback_fonts(ParserNode *node);
241  bool parserCallback_language(ParserNode *node);
242  bool parserCallback_text(ParserNode *node);
243  bool parserCallback_palette(ParserNode *node);
244  bool parserCallback_color(ParserNode *node);
245  bool parserCallback_drawstep(ParserNode *node);
246  bool parserCallback_drawdata(ParserNode *node);
247  bool parserCallback_bitmaps(ParserNode *node) { return true; }
248  bool parserCallback_bitmap(ParserNode *node);
249  bool parserCallback_cursor(ParserNode *node);
250 
251 
254  bool parserCallback_globals(ParserNode *node) { return true; }
255  bool parserCallback_def(ParserNode *node);
256  bool parserCallback_widget(ParserNode *node);
257  bool parserCallback_dialog(ParserNode *node);
258  bool parserCallback_layout(ParserNode *node);
259  bool parserCallback_space(ParserNode *node);
260  bool parserCallback_import(ParserNode *node);
261 
262  bool closedKeyCallback(ParserNode *node) override;
263 
264  bool resolutionCheck(const Common::String &resolution);
265 
266  void cleanup() override;
267 
268  Graphics::DrawStep *newDrawStep();
269  Graphics::DrawStep *defaultDrawStep();
270  bool parseDrawStep(ParserNode *stepNode, Graphics::DrawStep *drawstep, bool functionSpecific);
271  bool parseCommonLayoutProps(ParserNode *node, const Common::String &var);
272 
273  Graphics::DrawStep *_defaultStepGlobal;
274  Graphics::DrawStep *_defaultStepLocal;
275 
276  int16 _baseWidth, _baseHeight;
277  float _scaleFactor;
278 
279  struct PaletteColor {
280  uint8 r, g, b;
281  };
282 
284 };
285 
286 } // End of namespace GUI
287 
288 #endif
void cleanup() override
bool closedKeyCallback(ParserNode *node) override
Definition: str.h:59
Definition: VectorRenderer.h:51
Definition: ThemeParser.h:279
Definition: xmlparser.h:145
Definition: system.h:46
PARSER_END() bool parserCallback_render_info(ParserNode *node)
Definition: xmlparser.h:98
Definition: hashmap.h:85
Definition: ThemeEngine.h:209
Definition: ThemeParser.h:32
signed char * fill(signed char *first, signed char *last, Value val)
Definition: algorithm.h:168
bool parserCallback_layout_info(ParserNode *node)