2008-06-12 19:06:37 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
* $URL$
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef THEME_PARSER_H
|
|
|
|
#define THEME_PARSER_H
|
|
|
|
|
|
|
|
#include "common/scummsys.h"
|
|
|
|
#include "common/system.h"
|
2008-06-18 23:49:47 +00:00
|
|
|
#include "common/xmlparser.h"
|
2008-06-12 23:13:58 +00:00
|
|
|
|
2008-06-12 19:06:37 +00:00
|
|
|
namespace GUI {
|
|
|
|
|
2008-12-22 11:22:15 +00:00
|
|
|
class ThemeEngine;
|
2008-06-18 00:15:21 +00:00
|
|
|
|
2008-11-08 01:34:02 +00:00
|
|
|
class ThemeParser : public Common::XMLParser {
|
|
|
|
typedef void (Graphics::VectorRenderer::*DrawingFunctionCallback)(const Common::Rect &, const Graphics::DrawStep &);
|
2008-08-09 14:15:34 +00:00
|
|
|
|
2008-06-12 23:13:58 +00:00
|
|
|
public:
|
2008-11-09 15:59:14 +00:00
|
|
|
ThemeParser(ThemeEngine *parent);
|
2008-12-22 11:22:15 +00:00
|
|
|
|
2008-11-09 15:14:01 +00:00
|
|
|
virtual ~ThemeParser();
|
2008-12-22 11:22:15 +00:00
|
|
|
|
2008-07-15 10:50:31 +00:00
|
|
|
bool getPaletteColor(const Common::String &name, int &r, int &g, int &b) {
|
|
|
|
if (!_palette.contains(name))
|
|
|
|
return false;
|
2008-12-22 11:22:15 +00:00
|
|
|
|
2008-07-15 10:50:31 +00:00
|
|
|
r = _palette[name].r;
|
|
|
|
g = _palette[name].g;
|
|
|
|
b = _palette[name].b;
|
2008-12-22 11:22:15 +00:00
|
|
|
|
2008-07-15 10:50:31 +00:00
|
|
|
return true;
|
|
|
|
}
|
2008-06-13 22:05:21 +00:00
|
|
|
|
2008-06-12 19:06:37 +00:00
|
|
|
protected:
|
2008-09-02 17:51:08 +00:00
|
|
|
ThemeEngine *_theme;
|
2008-12-22 11:22:15 +00:00
|
|
|
|
2008-07-30 13:33:32 +00:00
|
|
|
CUSTOM_XML_PARSER(ThemeParser) {
|
|
|
|
XML_KEY(render_info)
|
2008-08-13 10:42:01 +00:00
|
|
|
XML_PROP(resolution, false)
|
2008-07-30 13:33:32 +00:00
|
|
|
XML_KEY(palette)
|
|
|
|
XML_KEY(color)
|
|
|
|
XML_PROP(name, true)
|
|
|
|
XML_PROP(rgb, true)
|
|
|
|
KEY_END()
|
|
|
|
KEY_END()
|
|
|
|
|
|
|
|
XML_KEY(fonts)
|
|
|
|
XML_KEY(font)
|
|
|
|
XML_PROP(id, true)
|
2008-08-07 18:42:47 +00:00
|
|
|
XML_PROP(file, true)
|
2008-07-30 13:33:32 +00:00
|
|
|
XML_PROP(color, true)
|
2008-08-08 18:30:16 +00:00
|
|
|
XML_PROP(resolution, false)
|
2008-07-30 13:33:32 +00:00
|
|
|
KEY_END()
|
|
|
|
KEY_END()
|
2008-12-22 11:22:15 +00:00
|
|
|
|
2008-08-09 18:34:16 +00:00
|
|
|
XML_KEY(bitmaps)
|
|
|
|
XML_KEY(bitmap)
|
|
|
|
XML_PROP(filename, true)
|
|
|
|
XML_PROP(resolution, false)
|
|
|
|
KEY_END()
|
|
|
|
KEY_END()
|
2008-12-22 11:22:15 +00:00
|
|
|
|
2008-08-10 17:22:12 +00:00
|
|
|
XML_KEY(cursor)
|
|
|
|
XML_PROP(file, true)
|
|
|
|
XML_PROP(hotspot, true)
|
|
|
|
XML_PROP(scale, true)
|
|
|
|
XML_PROP(resolution, false)
|
|
|
|
KEY_END()
|
2008-07-30 13:33:32 +00:00
|
|
|
|
|
|
|
XML_KEY(defaults)
|
|
|
|
XML_PROP(stroke, false)
|
|
|
|
XML_PROP(shadow, false)
|
2008-08-04 16:59:55 +00:00
|
|
|
XML_PROP(bevel, false)
|
2008-07-30 13:33:32 +00:00
|
|
|
XML_PROP(factor, false)
|
|
|
|
XML_PROP(fg_color, false)
|
|
|
|
XML_PROP(bg_color, false)
|
|
|
|
XML_PROP(gradient_start, false)
|
|
|
|
XML_PROP(gradient_end, false)
|
2008-08-04 16:59:55 +00:00
|
|
|
XML_PROP(bevel_color, false)
|
2008-07-30 13:33:32 +00:00
|
|
|
XML_PROP(gradient_factor, false)
|
|
|
|
XML_PROP(fill, false)
|
|
|
|
KEY_END()
|
|
|
|
|
|
|
|
XML_KEY(drawdata)
|
|
|
|
XML_PROP(id, true)
|
|
|
|
XML_PROP(cache, false)
|
2008-08-08 18:30:16 +00:00
|
|
|
XML_PROP(resolution, false)
|
2008-07-30 13:33:32 +00:00
|
|
|
|
|
|
|
XML_KEY(defaults)
|
|
|
|
XML_PROP(stroke, false)
|
|
|
|
XML_PROP(shadow, false)
|
2008-08-04 16:59:55 +00:00
|
|
|
XML_PROP(bevel, false)
|
2008-07-30 13:33:32 +00:00
|
|
|
XML_PROP(factor, false)
|
|
|
|
XML_PROP(fg_color, false)
|
|
|
|
XML_PROP(bg_color, false)
|
|
|
|
XML_PROP(gradient_start, false)
|
|
|
|
XML_PROP(gradient_end, false)
|
2008-08-04 16:59:55 +00:00
|
|
|
XML_PROP(bevel_color, false)
|
2008-07-30 13:33:32 +00:00
|
|
|
XML_PROP(gradient_factor, false)
|
|
|
|
XML_PROP(fill, false)
|
|
|
|
KEY_END()
|
|
|
|
|
|
|
|
XML_KEY(drawstep)
|
|
|
|
XML_PROP(func, true)
|
|
|
|
XML_PROP(stroke, false)
|
|
|
|
XML_PROP(shadow, false)
|
2008-08-04 16:59:55 +00:00
|
|
|
XML_PROP(bevel, false)
|
2008-07-30 13:33:32 +00:00
|
|
|
XML_PROP(factor, false)
|
|
|
|
XML_PROP(fg_color, false)
|
|
|
|
XML_PROP(bg_color, false)
|
|
|
|
XML_PROP(gradient_start, false)
|
|
|
|
XML_PROP(gradient_end, false)
|
|
|
|
XML_PROP(gradient_factor, false)
|
2008-08-04 16:59:55 +00:00
|
|
|
XML_PROP(bevel_color, false)
|
2008-07-30 13:33:32 +00:00
|
|
|
XML_PROP(fill, false)
|
|
|
|
XML_PROP(radius, false)
|
|
|
|
XML_PROP(width, false)
|
|
|
|
XML_PROP(height, false)
|
|
|
|
XML_PROP(xpos, false)
|
|
|
|
XML_PROP(ypos, false)
|
|
|
|
XML_PROP(orientation, false)
|
2008-08-10 22:03:00 +00:00
|
|
|
XML_PROP(file, false)
|
2008-07-30 13:33:32 +00:00
|
|
|
KEY_END()
|
|
|
|
|
|
|
|
XML_KEY(text)
|
|
|
|
XML_PROP(font, true)
|
|
|
|
XML_PROP(vertical_align, true)
|
|
|
|
XML_PROP(horizontal_align, true)
|
|
|
|
KEY_END()
|
|
|
|
KEY_END()
|
|
|
|
|
|
|
|
KEY_END() // render_info end
|
|
|
|
|
|
|
|
XML_KEY(layout_info)
|
2008-08-13 10:42:01 +00:00
|
|
|
XML_PROP(resolution, false)
|
2008-07-31 17:23:38 +00:00
|
|
|
XML_KEY(globals)
|
|
|
|
XML_PROP(resolution, false)
|
|
|
|
XML_KEY(def)
|
|
|
|
XML_PROP(var, true)
|
|
|
|
XML_PROP(value, true)
|
2008-08-08 18:30:16 +00:00
|
|
|
XML_PROP(resolution, false)
|
2008-07-31 17:23:38 +00:00
|
|
|
KEY_END()
|
2008-12-22 11:22:15 +00:00
|
|
|
|
2008-07-31 17:23:38 +00:00
|
|
|
XML_KEY(widget)
|
|
|
|
XML_PROP(name, true)
|
|
|
|
XML_PROP(size, false)
|
|
|
|
XML_PROP(pos, false)
|
|
|
|
XML_PROP(padding, false)
|
2008-08-08 18:30:16 +00:00
|
|
|
XML_PROP(resolution, false)
|
2008-07-31 17:23:38 +00:00
|
|
|
KEY_END()
|
|
|
|
KEY_END()
|
2008-12-22 11:22:15 +00:00
|
|
|
|
2008-07-31 17:23:38 +00:00
|
|
|
XML_KEY(dialog)
|
|
|
|
XML_PROP(name, true)
|
2008-08-05 23:58:45 +00:00
|
|
|
XML_PROP(overlays, true)
|
2008-08-06 15:06:22 +00:00
|
|
|
XML_PROP(shading, false)
|
2008-08-07 10:53:33 +00:00
|
|
|
XML_PROP(enabled, false)
|
2008-08-08 18:30:16 +00:00
|
|
|
XML_PROP(resolution, false)
|
2008-08-13 10:42:01 +00:00
|
|
|
XML_PROP(inset, false)
|
2008-08-04 16:59:55 +00:00
|
|
|
XML_KEY(layout)
|
|
|
|
XML_PROP(type, true)
|
2008-08-05 16:23:17 +00:00
|
|
|
XML_PROP(center, false)
|
2008-08-05 09:54:36 +00:00
|
|
|
XML_PROP(padding, false)
|
|
|
|
XML_PROP(spacing, false)
|
2008-12-22 11:22:15 +00:00
|
|
|
|
2008-08-07 10:53:33 +00:00
|
|
|
XML_KEY(import)
|
|
|
|
XML_PROP(layout, true)
|
|
|
|
KEY_END()
|
2008-12-22 11:22:15 +00:00
|
|
|
|
2008-08-04 16:59:55 +00:00
|
|
|
XML_KEY(widget)
|
|
|
|
XML_PROP(name, true)
|
|
|
|
XML_PROP(width, false)
|
|
|
|
XML_PROP(height, false)
|
2008-08-06 14:28:37 +00:00
|
|
|
XML_PROP(type, false)
|
2008-08-07 10:53:33 +00:00
|
|
|
XML_PROP(enabled, false)
|
2008-08-04 16:59:55 +00:00
|
|
|
KEY_END()
|
2008-12-22 11:22:15 +00:00
|
|
|
|
2008-08-04 16:59:55 +00:00
|
|
|
XML_KEY(space)
|
2008-08-05 09:54:36 +00:00
|
|
|
XML_PROP(size, false)
|
2008-08-04 16:59:55 +00:00
|
|
|
KEY_END()
|
2008-12-22 11:22:15 +00:00
|
|
|
|
2008-08-04 16:59:55 +00:00
|
|
|
XML_KEY_RECURSIVE(layout)
|
2008-07-31 17:23:38 +00:00
|
|
|
KEY_END()
|
|
|
|
KEY_END()
|
2008-12-22 11:22:15 +00:00
|
|
|
KEY_END()
|
|
|
|
|
2008-07-30 13:33:32 +00:00
|
|
|
} PARSER_END();
|
2008-12-22 11:22:15 +00:00
|
|
|
|
2008-07-31 17:23:38 +00:00
|
|
|
/** Render info callbacks */
|
|
|
|
bool parserCallback_render_info(ParserNode *node);
|
2008-07-30 13:33:32 +00:00
|
|
|
bool parserCallback_defaults(ParserNode *node);
|
|
|
|
bool parserCallback_font(ParserNode *node);
|
|
|
|
bool parserCallback_fonts(ParserNode *node);
|
|
|
|
bool parserCallback_text(ParserNode *node);
|
|
|
|
bool parserCallback_palette(ParserNode *node);
|
|
|
|
bool parserCallback_color(ParserNode *node);
|
|
|
|
bool parserCallback_drawstep(ParserNode *node);
|
|
|
|
bool parserCallback_drawdata(ParserNode *node);
|
2008-08-09 18:34:16 +00:00
|
|
|
bool parserCallback_bitmaps(ParserNode *node) { return true; }
|
|
|
|
bool parserCallback_bitmap(ParserNode *node);
|
2008-08-10 17:22:12 +00:00
|
|
|
bool parserCallback_cursor(ParserNode *node);
|
2008-12-22 11:22:15 +00:00
|
|
|
|
|
|
|
|
2008-07-31 17:23:38 +00:00
|
|
|
/** Layout info callbacks */
|
|
|
|
bool parserCallback_layout_info(ParserNode *node);
|
|
|
|
bool parserCallback_globals(ParserNode *node) { return true; }
|
|
|
|
bool parserCallback_def(ParserNode *node);
|
|
|
|
bool parserCallback_widget(ParserNode *node);
|
2008-08-01 15:45:02 +00:00
|
|
|
bool parserCallback_dialog(ParserNode *node);
|
2008-08-04 16:59:55 +00:00
|
|
|
bool parserCallback_layout(ParserNode *node);
|
2008-08-05 09:54:36 +00:00
|
|
|
bool parserCallback_space(ParserNode *node);
|
2008-08-07 10:53:33 +00:00
|
|
|
bool parserCallback_import(ParserNode *node);
|
2008-12-22 11:22:15 +00:00
|
|
|
|
2008-08-04 16:59:55 +00:00
|
|
|
bool closedKeyCallback(ParserNode *node);
|
2008-12-22 11:22:15 +00:00
|
|
|
|
2008-08-08 18:30:16 +00:00
|
|
|
bool resolutionCheck(const Common::String &resolution);
|
2008-12-22 11:22:15 +00:00
|
|
|
|
2008-07-03 10:26:55 +00:00
|
|
|
void cleanup();
|
|
|
|
|
2008-06-18 00:15:21 +00:00
|
|
|
Graphics::DrawStep *newDrawStep();
|
2008-06-26 19:54:55 +00:00
|
|
|
Graphics::DrawStep *defaultDrawStep();
|
|
|
|
bool parseDrawStep(ParserNode *stepNode, Graphics::DrawStep *drawstep, bool functionSpecific);
|
2008-08-01 10:18:47 +00:00
|
|
|
bool parseCommonLayoutProps(ParserNode *node, const Common::String &var);
|
2008-06-26 19:54:55 +00:00
|
|
|
|
|
|
|
Graphics::DrawStep *_defaultStepGlobal;
|
|
|
|
Graphics::DrawStep *_defaultStepLocal;
|
2008-06-18 00:15:21 +00:00
|
|
|
|
|
|
|
Common::HashMap<Common::String, DrawingFunctionCallback, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> _drawFunctions;
|
2008-06-25 17:56:00 +00:00
|
|
|
|
|
|
|
struct PaletteColor {
|
|
|
|
uint8 r, g, b;
|
|
|
|
};
|
|
|
|
|
|
|
|
Common::HashMap<Common::String, PaletteColor, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> _palette;
|
2008-06-12 19:06:37 +00:00
|
|
|
};
|
|
|
|
|
2008-10-12 22:25:35 +00:00
|
|
|
} // End of namespace GUI
|
2008-06-12 19:06:37 +00:00
|
|
|
|
2008-06-12 23:13:58 +00:00
|
|
|
#endif
|