if (type == "")
type = "dialog";
- FGColor c(_gui->getColor("background"));
- c.merge(_gui->getColor(type));
- c.merge(props->getNode("color"));
- if (c.isValid())
- object->setColourScheme(c.red(), c.green(), c.blue(), c.alpha());
+ FGColor *c = new FGColor(_gui->getColor("background"));
+ c->merge(_gui->getColor(type));
+ c->merge(props->getNode("color"));
+ if (c->isValid())
+ object->setColourScheme(c->red(), c->green(), c->blue(), c->alpha());
const int numcol = 6;
const struct {
for (int i = 0; i < numcol; i++) {
bool dirty = false;
- c.clear();
- c.setAlpha(1.0);
+ c->clear();
+ c->setAlpha(1.0);
- dirty |= c.merge(_gui->getColor(type + '-' + pucol[i].name));
+ dirty |= c->merge(_gui->getColor(type + '-' + pucol[i].name));
if (which & pucol[i].mask)
- dirty |= c.merge(props->getNode("color"));
+ dirty |= c->merge(props->getNode("color"));
- if ((pucol[i].mask == LABEL) && !c.isValid())
- dirty |= c.merge(_gui->getColor("label"));
+ if ((pucol[i].mask == LABEL) && !c->isValid())
+ dirty |= c->merge(_gui->getColor("label"));
- if (c.isValid() && dirty)
- object->setColor(pucol[i].id, c.red(), c.green(), c.blue(), c.alpha());
+ if (c->isValid() && dirty)
+ object->setColor(pucol[i].id, c->red(), c->green(), c->blue(), c->alpha());
}
}
}
bool
-FGColor::merge(const FGColor& color)
+FGColor::merge(const FGColor *color)
{
bool dirty = false;
- if (color._red >= 0.0)
- _red = color._red, dirty = true;
- if (color._green >= 0.0)
- _green = color._green, dirty = true;
- if (color._blue >= 0.0)
- _blue = color._blue, dirty = true;
- if (color._alpha >= 0.0)
- _alpha = color._alpha, dirty = true;
+ if (color && color->_red >= 0.0)
+ _red = color->_red, dirty = true;
+ if (color && color->_green >= 0.0)
+ _green = color->_green, dirty = true;
+ if (color && color->_blue >= 0.0)
+ _blue = color->_blue, dirty = true;
+ if (color && color->_alpha >= 0.0)
+ _alpha = color->_alpha, dirty = true;
return dirty;
}
virtual FGColor *getColor (const char * name) const {
_itt_t it = _colors.find(name);
- return it->second;
+ 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;
+ return (it != _colors.end()) ? it->second : NULL;
}
virtual puFont *getDefaultFont() { return &_font; }
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;