diff options
author | Tametomo <irarice@gmail.com> | 2009-04-20 07:44:26 -0600 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2009-04-29 19:56:01 +0200 |
commit | 377880eca6d9d0cace2c43a12a131b67661192d3 (patch) | |
tree | 842689993d011295f6efbfa36be7cfe28a8317b4 /src/gui | |
parent | 461cf5d1ce4cecfaaa6cef45cb5ba0955c16ca41 (diff) | |
download | mana-377880eca6d9d0cace2c43a12a131b67661192d3.tar.gz mana-377880eca6d9d0cace2c43a12a131b67661192d3.tar.bz2 mana-377880eca6d9d0cace2c43a12a131b67661192d3.tar.xz mana-377880eca6d9d0cace2c43a12a131b67661192d3.zip |
Changed palette colors to be once again stored in a human readable
format once again. This was originally reverted because it caused a
regression on Windows, but not Linux, which was later found out to be
because there's a Linux kernel function which will convert hex strings
into an integer format, while Windows doesn't share the same luxury. So,
to avoid any issues, this commit adds an atox (ascii to hex) string
utility, and uses it when parsing hex strings for colors from the
configuration file. Also ensured that people who have colors saved in
the old, raw integer format can get their colors converted to hex
values.
Signed-off-by: Tametomo <irarice@gmail.com>
Signed-off-by: Bjørn Lindeijer <bjorn@lindeijer.nl>
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/palette.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/gui/palette.cpp b/src/gui/palette.cpp index 897c7efd..855487d3 100644 --- a/src/gui/palette.cpp +++ b/src/gui/palette.cpp @@ -152,7 +152,11 @@ Palette::~Palette() config.setValue(*configName + "Delay", col->delay); if (col->grad == STATIC || col->grad == PULSE) - config.setValue(*configName, toString(col->getRGB())); + { + char buffer[20]; + sprintf(buffer, "0x%06x", col->getRGB()); + config.setValue(*configName, buffer); + } } } @@ -265,7 +269,15 @@ void Palette::addColor(Palette::ColorType type, int rgb, char c, int delay) { const std::string *configName = &ColorTypeNames[type]; - gcn::Color trueCol = (int) config.getValue(*configName, rgb); + char buffer[20]; + sprintf(buffer, "0x%06x", rgb); + const std::string rgbString = config.getValue(*configName, buffer); + unsigned int rgbValue = 0; + if (rgbString.length() == 8 && rgbString[0] == '0' && rgbString[1] == 'x') + rgbValue = atox(rgbString); + else + rgbValue = atoi(rgbString.c_str()); + gcn::Color trueCol = rgbValue; grad = (GradientType) config.getValue(*configName + "Gradient", grad); delay = (int) config.getValue(*configName + "Delay", delay); mColVector[type].set(type, trueCol, grad, text, c, delay); |