aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gui/ThemeNew.cpp23
-rw-r--r--gui/eval.cpp4
-rw-r--r--gui/eval.h4
-rw-r--r--gui/theme-config.cpp14
4 files changed, 21 insertions, 24 deletions
diff --git a/gui/ThemeNew.cpp b/gui/ThemeNew.cpp
index 1a33eaec5c..300e15661e 100644
--- a/gui/ThemeNew.cpp
+++ b/gui/ThemeNew.cpp
@@ -51,11 +51,10 @@ extern int gBitFormat;
static void getColorFromConfig(const Common::ConfigFile &cfg, const Common::String &value, OverlayColor &color) {
Common::String temp;
- if (!cfg.hasKey(value, "colors")) {
+ if (!cfg.getKey(value, "colors", temp)) {
color = g_system->RGBToColor(0, 0, 0);
return;
}
- cfg.getKey(value, "colors", temp);
int rgb[3], pos = 0;
const char *colors = temp.c_str();
@@ -68,23 +67,21 @@ static void getColorFromConfig(const Common::ConfigFile &cfg, const Common::Stri
}
static void getValueFromConfig(const Common::ConfigFile &cfg, const Common::String &section, const Common::String &value, uint &val, uint defaultVal) {
- if (!cfg.hasKey(value, section)) {
+ Common::String temp;
+ if (!cfg.getKey(value, section, temp)) {
val = defaultVal;
- return;
+ } else {
+ val = atoi(temp.c_str());
}
- Common::String temp;
- cfg.getKey(value, section, temp);
- val = atoi(temp.c_str());
}
static void getValueFromConfig(const Common::ConfigFile &cfg, const Common::String &section, const Common::String &value, int &val, int defaultVal) {
- if (!cfg.hasKey(value, section)) {
+ Common::String temp;
+ if (!cfg.getKey(value, section, temp)) {
val = defaultVal;
- return;
+ } else {
+ val = atoi(temp.c_str());
}
- Common::String temp;
- cfg.getKey(value, section, temp);
- val = atoi(temp.c_str());
}
#define getFactorFromConfig(x, y, z) getValueFromConfig(x, "gradients", y, z, 1)
@@ -732,7 +729,7 @@ void ThemeNew::drawPopUpWidget(const Common::Rect &r, const Common::String &sel,
arrowRect.clip(r);
drawSurface(arrowRect, arrow, true, false, (state == kStateDisabled) ? -30 : 256);
- if (sel != "") {
+ if (!sel.empty()) {
Common::Rect text(r.left + 2, r.top + 3, r.right - 4, r.top + 3 + getFont()->getFontHeight());
getFont()->drawString(&_screen, sel, text.left, text.top, text.width(), getColor(state), convertAligment(align), deltax, false);
}
diff --git a/gui/eval.cpp b/gui/eval.cpp
index 70d057aa52..63f99f5676 100644
--- a/gui/eval.cpp
+++ b/gui/eval.cpp
@@ -317,8 +317,8 @@ int Eval::getVar_(const char *s, bool includeAliases) {
return EVAL_UNDEF_VAR;
}
-void Eval::setVar(const String &section, const char *name, const String &value) {
- _vars[name + 4] = eval(value, section, name, 0);
+void Eval::setVar(const String &section, const String &name, const String &value) {
+ _vars[name.c_str() + 4] = eval(value, section, name, 0);
}
void Eval::reset() {
diff --git a/gui/eval.h b/gui/eval.h
index 59511b76bb..012d8675e6 100644
--- a/gui/eval.h
+++ b/gui/eval.h
@@ -42,11 +42,11 @@ public:
~Eval();
int eval(const String &input, const String &section, const String &name, int startpos);
- void setVar(const String &section, const char *name, const String &value);
+ void setVar(const String &section, const String &name, const String &value);
void setParent(const String &name);
- void setVar(const char *name, int val) { _vars[name] = val; }
+ void setVar(const String &name, int val) { _vars[name.c_str()] = val; }
void setAlias(const char *name, const String &val) { _aliases[name] = val; }
int getVar(const String &s) { return getVar_(s.c_str()); }
diff --git a/gui/theme-config.cpp b/gui/theme-config.cpp
index dd4f54036e..a4fc16d4f6 100644
--- a/gui/theme-config.cpp
+++ b/gui/theme-config.cpp
@@ -424,13 +424,13 @@ void Theme::processSingleLine(const String &section, const String &prefix, const
to += postfixes[i];
_evaluator->setAlias(selfpostfixes[i], to);
- _evaluator->setVar(to.c_str(), EVAL_UNDEF_VAR);
+ _evaluator->setVar(to, EVAL_UNDEF_VAR);
}
for (i = 0; i < str.size(); i++) {
if (isspace(str[i]) && level == 0) {
value = _evaluator->eval(String(&(str.c_str()[start]), i - start), section, name + postfixes[npostfix], start);
- _evaluator->setVar((prefixedname + postfixes[npostfix++]).c_str(), value);
+ _evaluator->setVar(prefixedname + postfixes[npostfix++], value);
start = i + 1;
}
if (str[i] == '(')
@@ -453,15 +453,15 @@ void Theme::processSingleLine(const String &section, const String &prefix, const
// process VAR=VALUE construct
if (npostfix == 0)
- _evaluator->setVar(name.c_str(), value);
+ _evaluator->setVar(name, value);
else
- _evaluator->setVar((prefixedname + postfixes[npostfix]).c_str(), value);
+ _evaluator->setVar(prefixedname + postfixes[npostfix], value);
// If we have all 4 parameters, set .x2 and .y2
if (npostfix == 3) {
- _evaluator->setVar((prefixedname + ".x2").c_str(),
+ _evaluator->setVar(prefixedname + ".x2",
_evaluator->getVar(prefixedname + ".x") + _evaluator->getVar(prefixedname + ".w"));
- _evaluator->setVar((prefixedname + ".y2").c_str(),
+ _evaluator->setVar(prefixedname + ".y2",
_evaluator->getVar(prefixedname + ".y") + _evaluator->getVar(prefixedname + ".h"));
}
@@ -487,7 +487,7 @@ void Theme::processResSection(Common::ConfigFile &config, const String &name, bo
}
if (iterk->key.hasPrefix("def_")) {
if (!skipDefs)
- _evaluator->setVar(name, (prefix + iterk->key).c_str(), iterk->value);
+ _evaluator->setVar(name, prefix + iterk->key, iterk->value);
continue;
}
if (iterk->key == "use") {