virtual void init ();
/**
- * Reinitialize the GUI subsystem.
+ * Reinitialize the GUI subsystem. Reloads all XML dialogs.
*/
virtual void reinit ();
*/
virtual void update (double delta_time_sec);
+ /**
+ * Redraw the GUI picking up new GUI colors.
+ */
+ virtual void redraw ();
+
/**
* Creates a new dialog box, using the same property format as the
* gui/dialogs configuration files. Does not display the
*/
virtual bool closeDialog (const string &name);
+ /**
+ * Get dialog property tree's root node.
+ * @param name The name of the dialog box.
+ * @return node pointer if the dialog was found, zero otherwise.
+ */
+ virtual SGPropertyNode_ptr getDialog (const string &name);
+
/**
* Return a pointer to the current menubar.
*/
virtual FGMenuBar * getMenuBar ();
-
/**
* Ignore this method.
*
virtual FGDialog * getActiveDialog ();
virtual FGColor *getColor (const char * name) const {
- _itt_t it = _colors.find(name);
- return it->second;
+ _citt_t it = _colors.find(name);
+ return (it != _colors.end()) ? it->second : NULL;
}
virtual FGColor *getColor (const string &name) const {
- _itt_t it = _colors.find(name.c_str());
- return it->second;
+ _citt_t it = _colors.find(name.c_str());
+ return (it != _colors.end()) ? it->second : NULL;
}
- virtual puFont *getDefaultFont() { return &_font; }
+ virtual puFont *getDefaultFont() { return _font; }
/**
virtual void setStyle ();
virtual void setupFont (SGPropertyNode *);
+ /**
+ * Used by reinit() and redraw() to close all dialogs and to apply
+ * current GUI colors. If "reload" is false, reopens all dialogs.
+ * Otherwise reloads all XML dialog files from disk and reopens all
+ * but Nasal * generated dialogs, omitting dynamic widgets. (This
+ * is only useful for GUI development.)
+ */
+ virtual void reset (bool reload);
+
private:
- fntTexFont _tex_font;
- puFont _font;
- map<const char*,FGColor*> _colors;
- typedef map<const char*,FGColor*>::const_iterator _itt_t;
+ struct ltstr
+ {
+ bool operator()(const char* s1, const char* s2) const {
+ return strcmp(s1, s2) < 0;
+ }
+ };
+
+ puFont *_font;
+ map<const char*,FGColor*, ltstr> _colors;
+ typedef map<const char*,FGColor*, ltstr>::iterator _itt_t;
+ typedef map<const char*,FGColor*, ltstr>::const_iterator _citt_t;
- // Free all allocated memory.
- void clear ();
+ void clear_colors();
// Read all the configuration files in a directory.
void readDir (const char * path);
FGColor() { clear(); }
FGColor(float r, float g, float b, float a = 1.0f) { set(r, g, b, a); }
FGColor(const SGPropertyNode *prop) { set(prop); }
- FGColor(FGColor *c) { set(c->_red, c->_green, c->_blue, c->_alpha); }
+ FGColor(FGColor *c) {
+ if (c) set(c->_red, c->_green, c->_blue, c->_alpha);
+ }
inline void clear() { _red = _green = _blue = _alpha = -1.0f; }
// merges in non-negative components from property with children <red> etc.
bool merge(const SGPropertyNode *prop);
- bool merge(const FGColor& color);
+ bool merge(const FGColor *color);
bool set(const SGPropertyNode *prop) { clear(); return merge(prop); };
- bool set(const FGColor& color) { clear(); return merge(color); }
+ bool set(const FGColor *color) { clear(); return merge(color); }
bool set(float r, float g, float b, float a = 1.0f) {
_red = r, _green = g, _blue = b, _alpha = a;
return true;
*/
class FGFontCache {
private:
+ struct fnt {
+ fnt(puFont *pu = 0) : pufont(pu), texfont(0) {}
+ ~fnt() { delete pufont; delete texfont; }
+ puFont *pufont;
+ fntTexFont *texfont;
+ };
SGPath _path;
- map<const char*,puFont*> _fonts;
- typedef map<const char*,puFont*>::iterator _itt_t;
+ map<const string,fnt *> _fonts;
+ typedef map<const string,fnt *>::const_iterator _itt_t;
public:
FGFontCache();