ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

ThemeEval.h

Go to the documentation of this file.
00001 /* ScummVM - Graphic Adventure Engine
00002  *
00003  * ScummVM is the legal property of its developers, whose names
00004  * are too numerous to list here. Please refer to the COPYRIGHT
00005  * file distributed with this source distribution.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 #ifndef GUI_THEME_EVAL_H
00024 #define GUI_THEME_EVAL_H
00025 
00026 #include "common/scummsys.h"
00027 #include "common/hashmap.h"
00028 #include "common/hash-str.h"
00029 #include "common/stack.h"
00030 #include "common/str.h"
00031 #include "common/textconsole.h"
00032 #include "graphics/font.h"
00033 
00034 #include "gui/ThemeLayout.h"
00035 
00036 namespace GUI {
00037 
00038 class ThemeEval {
00039 
00040     typedef Common::HashMap<Common::String, int> VariablesMap;
00041     typedef Common::HashMap<Common::String, ThemeLayout *> LayoutsMap;
00042 
00043 public:
00044     ThemeEval() {
00045         buildBuiltinVars();
00046     }
00047 
00048     ~ThemeEval();
00049 
00050     void buildBuiltinVars();
00051 
00052     int getVar(const Common::String &s) {
00053         if (_vars.contains(s))
00054             return _vars[s];
00055 
00056         if (_builtin.contains(s))
00057             return _builtin[s];
00058 
00059         error("CRITICAL: Missing variable: '%s'", s.c_str());
00060         return -13375; //EVAL_UNDEF_VAR
00061     }
00062 
00063     int getVar(const Common::String &s, int def) {
00064         if (_vars.contains(s))
00065             return _vars[s];
00066 
00067         if (_builtin.contains(s))
00068             return _builtin[s];
00069 
00070         return def;
00071     }
00072 
00073     void setVar(const Common::String &name, int val) { _vars[name] = val; }
00074 
00075     bool hasVar(const Common::String &name) { return _vars.contains(name) || _builtin.contains(name); }
00076 
00077     void addDialog(const Common::String &name, const Common::String &overlays, bool enabled = true, int inset = 0);
00078     void addLayout(ThemeLayout::LayoutType type, int spacing, bool center = false);
00079     void addWidget(const Common::String &name, int w, int h, const Common::String &type, bool enabled = true, Graphics::TextAlign align = Graphics::kTextAlignLeft);
00080     bool addImportedLayout(const Common::String &name);
00081     void addSpace(int size);
00082 
00083     void addPadding(int16 l, int16 r, int16 t, int16 b) { _curLayout.top()->setPadding(l, r, t, b); }
00084 
00085     void closeLayout() { _curLayout.pop(); }
00086     void closeDialog() { _curLayout.pop()->reflowLayout(); _curDialog.clear(); }
00087 
00088     bool getWidgetData(const Common::String &widget, int16 &x, int16 &y, uint16 &w, uint16 &h);
00089 
00090     Graphics::TextAlign getWidgetTextHAlign(const Common::String &widget);
00091 
00092 #ifdef LAYOUT_DEBUG_DIALOG
00093     void debugDraw(Graphics::Surface *screen, const Graphics::Font *font) {
00094         _layouts[LAYOUT_DEBUG_DIALOG]->debugDraw(screen, font);
00095     }
00096 #endif
00097 
00098     void reset();
00099 
00100 private:
00101     VariablesMap _vars;
00102     VariablesMap _builtin;
00103 
00104     LayoutsMap _layouts;
00105     Common::Stack<ThemeLayout *> _curLayout;
00106     Common::String _curDialog;
00107 };
00108 
00109 } // End of namespace GUI
00110 
00111 #endif


Generated on Sat Feb 16 2019 05:01:09 for ResidualVM by doxygen 1.7.1
curved edge   curved edge