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
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (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, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  */
22 
23 #ifndef GLK_CONF_H
24 #define GLK_CONF_H
25 
26 #include "glk/glk_types.h"
27 #include "glk/fonts.h"
28 #include "glk/windows.h"
29 #include "graphics/pixelformat.h"
30 #include "common/config-manager.h"
31 
32 namespace Glk {
33 
34 /**
35  * Engine configuration
36  */
37 class Conf {
38 	typedef uint Color;
39 private:
40 	InterpreterType _interpType;
41 	bool _isLoading;
42 
exists(const Common::String & key)43 	bool exists(const Common::String &key) const {
44 		return ConfMan.hasKey(key);
45 	}
46 
47 	void syncAsString(const Common::String &name, Common::String &val);
48 	void syncAsInt(const Common::String &name, int &val);
49 	void syncAsInt(const Common::String &name, uint &val);
50 	void syncAsDouble(const Common::String &name, double &val);
51 	void syncAsBool(const Common::String &name, bool &val);
52 	void syncAsColor(const Common::String &name, uint &val);
53 	void syncAsFont(const Common::String &name, FACES &val);
54 
55 	/**
56 	 * Loads or saves the settings
57 	 */
58 	void synchronize();
59 public:
60 	/**
61 	 * Parse a color
62 	 */
63 	uint parseColor(const Common::String &str);
64 
65 	/**
66 	 * Convert an RGB tuplet to a color
67 	 */
68 	uint parseColor(const byte *rgb);
69 
70 	/**
71 	 * Convert an RGB uint32 to a color
72 	 */
73 	uint parseColor(const uint32 rgb);
74 
75 	/**
76 	 * Encode a color to an 6-character RGB hex string
77 	 */
78 	Common::String encodeColor(uint color);
79 public:
80 	uint _width, _height;
81 	Graphics::PixelFormat _screenFormat;
82 	MonoFontInfo _monoInfo;
83 	PropFontInfo _propInfo;
84 	int _cols, _rows;
85 	int _lockCols, _lockRows;
86 	int _wMarginX, _wMarginY;
87 	int _wMarginSaveX, _wMarginSaveY;
88 	int _wPaddingX, _wPaddingY;
89 	int _wBorderX, _wBorderY;
90 	int _tMarginX, _tMarginY;
91 	double _gamma;
92 	uint _borderColor, _borderSave;
93 	uint _windowColor, _windowSave;
94 	int _scrollWidth;
95 	uint _scrollBg, _scrollFg;
96 	bool _graphics;
97 	bool _sound;
98 	bool _speak;
99 	bool _speakInput;
100 	Common::String _speakLanguage;
101 	int _styleHint;
102 	bool _safeClicks;
103 	WindowStyle _tStyles[style_NUMSTYLES];
104 	WindowStyle _gStyles[style_NUMSTYLES];
105 	WindowStyle _tStylesDefault[style_NUMSTYLES];
106 	WindowStyle _gStylesDefault[style_NUMSTYLES];
107 
108 	int _imageW, _imageH;
109 public:
110 	/**
111 	 * Constructor
112 	 */
113 	Conf(InterpreterType interpType);
114 
115 	/**
116 	 * Loads the configuration from the ScummVM configuration
117 	 */
118 	void load();
119 
120 	/**
121 	 * The first time a game is played, flushes all the settings to game's
122 	 * entry in scummvm.ini. This will make it easier for users to manually
123 	 * modify scummvm.ini later on to see what options are available
124 	 */
125 	void flush();
126 };
127 
128 extern Conf *g_conf;
129 
130 } // End of namespace Glk
131 
132 #endif
133