[Scummvm-cvs-logs] SF.net SVN: scummvm: [23000] scummvm/trunk/gui
eriktorbjorn at users.sourceforge.net
eriktorbjorn at users.sourceforge.net
Sat Jun 10 12:09:46 CEST 2006
Revision: 23000
Author: eriktorbjorn
Date: 2006-06-10 03:09:40 -0700 (Sat, 10 Jun 2006)
ViewCVS: http://svn.sourceforge.net/scummvm/?rev=23000&view=rev
Log Message:
-----------
This may cut down a little on unnecessary strings / mallocs:
* Only create the self.[xywh] aliases and its variables if prefixedname has no
periods in it, e.g. MusicText.x, but not MusicText.align.x
* Set the .r, .g and .b variables directly, rather than aliasing them through
.x, .y and .w
Modified Paths:
--------------
scummvm/trunk/gui/theme-config.cpp
scummvm/trunk/gui/theme.h
Modified: scummvm/trunk/gui/theme-config.cpp
===================================================================
--- scummvm/trunk/gui/theme-config.cpp 2006-06-10 08:24:00 UTC (rev 22999)
+++ scummvm/trunk/gui/theme-config.cpp 2006-06-10 10:09:40 UTC (rev 23000)
@@ -413,30 +413,36 @@
uint i;
int value;
const char *selfpostfixes[] = {"self.x", "self.y", "self.w", "self.h"};
- const char *postfixes[] = {".x", ".y", ".w", ".h"};
+ const char *postfixesXYWH[] = {".x", ".y", ".w", ".h"};
+ const char *postfixesRGB[] = {".r", ".g", ".b"};
int npostfix = 0;
const String prefixedname(prefix + name);
- // Make self.BLAH work
- for (i = 0; i < ARRAYSIZE(postfixes); i++) {
- String to(prefixedname);
+ // Make self.BLAH work, but not self.ANYTHING.BLAH
+ if (!strchr(prefixedname.c_str(), '.')) {
+ for (i = 0; i < ARRAYSIZE(postfixesXYWH); i++) {
+ String to(prefixedname);
- to += postfixes[i];
+ to += postfixesXYWH[i];
- _evaluator->setAlias(selfpostfixes[i], to);
- _evaluator->setVar(to, EVAL_UNDEF_VAR);
+ _evaluator->setAlias(selfpostfixes[i], to);
+ _evaluator->setVar(to, EVAL_UNDEF_VAR);
+ }
}
+ // Count the number of parameters, so that we know if they're meant to
+ // be XY[WH] or RGB.
+
+ int ntmppostfix = 0;
+
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++], value);
- start = i + 1;
+ ntmppostfix++;
}
+
if (str[i] == '(')
level++;
-
- if (str[i] == ')') {
+ else if (str[i] == ')') {
if (level == 0) {
error("Extra ')' in section: [%s] expression: \"%s\" start is at: %d",
section.c_str(), name.c_str(), start);
@@ -449,6 +455,23 @@
error("Missing ')' in section: [%s] expression: \"%s\" start is at: %d",
section.c_str(), name.c_str(), start);
+ const char **postfixes = (ntmppostfix == 2) ? postfixesRGB : postfixesXYWH;
+
+ // Now do it for real, only this time we already know the parantheses
+ // are balanced.
+
+ 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++], value);
+ start = i + 1;
+ }
+ if (str[i] == '(')
+ level++;
+ else if (str[i] == ')')
+ level--;
+ }
+
value = _evaluator->eval(String(&(str.c_str()[start]), i - start), section, name + postfixes[npostfix], start);
if (value == EVAL_STRING_VAR)
@@ -466,8 +489,6 @@
_evaluator->getVar(prefixedname + ".x") + _evaluator->getVar(prefixedname + ".w"));
_evaluator->setVar(prefixedname + ".y2",
_evaluator->getVar(prefixedname + ".y") + _evaluator->getVar(prefixedname + ".h"));
- } else if (npostfix == 2) { // Specify shortcuts for R G B
- setRGBAlias(prefixedname);
}
if (npostfix != 0)
@@ -544,19 +565,6 @@
}
}
-void Theme::setRGBAlias(const String &name) {
- const char *frompostfixes[] = {".x", ".y", ".w"};
- const char *topostfixes[] = {".r", ".g", ".b"};
- int i;
-
- for (i = 0; i < ARRAYSIZE(frompostfixes); i++) {
- String from(name + frompostfixes[i]);
- String to(name + topostfixes[i]);
-
- _evaluator->setAlias(to.c_str(), from);
- }
-}
-
bool Theme::isThemeLoadingRequired() {
int x = g_system->getOverlayWidth(), y = g_system->getOverlayHeight();
Modified: scummvm/trunk/gui/theme.h
===================================================================
--- scummvm/trunk/gui/theme.h 2006-06-10 08:24:00 UTC (rev 22999)
+++ scummvm/trunk/gui/theme.h 2006-06-10 10:09:40 UTC (rev 23000)
@@ -195,7 +195,6 @@
void processResSection(Common::ConfigFile &config, const String &name, bool skipDefs = false, const String &prefix = "");
void processSingleLine(const String §ion, const String &prefix, const String &name, const String &str);
void setSpecialAlias(const String &alias, const String &name);
- void setRGBAlias(const String &name);
bool isThemeLoadingRequired();
bool sectionIsSkipped(Common::ConfigFile &config, const char *name, int w, int h);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list