[Scummvm-cvs-logs] SF.net SVN: scummvm: [21420] scummvm/trunk/gui
sev at users.sourceforge.net
sev at users.sourceforge.net
Thu Mar 23 17:26:11 CET 2006
Revision: 21420
Author: sev
Date: 2006-03-23 17:24:26 -0800 (Thu, 23 Mar 2006)
ViewCVS: http://svn.sourceforge.net/scummvm/?rev=21420&view=rev
Log Message:
-----------
o Move built-in evaluator constants to AssocArray to speed it up
o Introduced .align text widget property
o Moved all text widgets to use it and populated theme config file
Modified Paths:
--------------
scummvm/trunk/engines/scumm/dialogs.cpp
scummvm/trunk/gui/KeysDialog.cpp
scummvm/trunk/gui/browser.cpp
scummvm/trunk/gui/chooser.cpp
scummvm/trunk/gui/eval.cpp
scummvm/trunk/gui/eval.h
scummvm/trunk/gui/launcher.cpp
scummvm/trunk/gui/options.cpp
scummvm/trunk/gui/theme-config.cpp
scummvm/trunk/gui/themes/default-theme.ini
scummvm/trunk/gui/widget.cpp
scummvm/trunk/gui/widget.h
Modified: scummvm/trunk/engines/scumm/dialogs.cpp
===================================================================
--- scummvm/trunk/engines/scumm/dialogs.cpp 2006-03-23 22:59:38 UTC (rev 21419)
+++ scummvm/trunk/engines/scumm/dialogs.cpp 2006-03-24 01:24:26 UTC (rev 21420)
@@ -357,7 +357,7 @@
_drawingHints |= GUI::THEME_HINT_MAIN_DIALOG;
- new StaticTextWidget(this, "scummsaveload_title", title, kTextAlignCenter);
+ new StaticTextWidget(this, "scummsaveload_title", title);
// Add choice list
_list = new GUI::ListWidget(this, "scummsaveload_list");
@@ -737,7 +737,7 @@
int lineHeight = g_gui.getFontHeight();
- _title = new StaticTextWidget(this, "scummhelp_title", "", kTextAlignCenter);
+ _title = new StaticTextWidget(this, "scummhelp_title", "");
int keyX = g_gui.evaluator()->getVar("scummhelp_key.x");
int keyYoff = g_gui.evaluator()->getVar("scummhelp_key.yoffset");
int keyW = g_gui.evaluator()->getVar("scummhelp_key.w");
Modified: scummvm/trunk/gui/KeysDialog.cpp
===================================================================
--- scummvm/trunk/gui/KeysDialog.cpp 2006-03-23 22:59:38 UTC (rev 21419)
+++ scummvm/trunk/gui/KeysDialog.cpp 2006-03-24 01:24:26 UTC (rev 21420)
@@ -38,7 +38,6 @@
using GUI::kListSelectionChangedCmd;
using GUI::kCloseCmd;
using GUI::StaticTextWidget;
-using GUI::kTextAlignCenter;
using GUI::CommandSender;
*/
@@ -60,8 +59,8 @@
_actionsList = new ListWidget(this, "keysdialog_list");
_actionsList->setNumberingMode(kListNumberingZero);
- _actionTitle = new StaticTextWidget(this, "keysdialog_action", title, kTextAlignCenter);
- _keyMapping = new StaticTextWidget(this, "keysdialog_mapping", "", kTextAlignCenter);
+ _actionTitle = new StaticTextWidget(this, "keysdialog_action", title);
+ _keyMapping = new StaticTextWidget(this, "keysdialog_mapping", "");
_actionTitle->setFlags(WIDGET_CLEARBG);
_keyMapping->setFlags(WIDGET_CLEARBG);
Modified: scummvm/trunk/gui/browser.cpp
===================================================================
--- scummvm/trunk/gui/browser.cpp 2006-03-23 22:59:38 UTC (rev 21419)
+++ scummvm/trunk/gui/browser.cpp 2006-03-24 01:24:26 UTC (rev 21420)
@@ -138,10 +138,10 @@
_currentPath = NULL;
// Headline - TODO: should be customizable during creation time
- new StaticTextWidget(this, "browser_headline", title, kTextAlignCenter);
+ new StaticTextWidget(this, "browser_headline", title);
// Current path - TODO: handle long paths ?
- _currentPath = new StaticTextWidget(this, "browser_path", "DUMMY", kTextAlignLeft);
+ _currentPath = new StaticTextWidget(this, "browser_path", "DUMMY");
// Add file list
_fileList = new ListWidget(this, "browser_list");
Modified: scummvm/trunk/gui/chooser.cpp
===================================================================
--- scummvm/trunk/gui/chooser.cpp 2006-03-23 22:59:38 UTC (rev 21419)
+++ scummvm/trunk/gui/chooser.cpp 2006-03-24 01:24:26 UTC (rev 21420)
@@ -35,7 +35,7 @@
: Dialog(prefix + "chooser") {
// Headline
- new StaticTextWidget(this, prefix + "chooser_headline", title, kTextAlignCenter);
+ new StaticTextWidget(this, prefix + "chooser_headline", title);
// Add choice list
// HACK: Subtracting -12 from the height makes the list look good when
Modified: scummvm/trunk/gui/eval.cpp
===================================================================
--- scummvm/trunk/gui/eval.cpp 2006-03-23 22:59:38 UTC (rev 21419)
+++ scummvm/trunk/gui/eval.cpp 2006-03-24 01:24:26 UTC (rev 21420)
@@ -38,10 +38,12 @@
}
Eval::Eval() {
+ loadConstants();
}
Eval::~Eval() {
- reset();
+ _vars.clear();
+ _aliases.clear();
}
int Eval::eval(const String &input, const String §ion, const String &name, int startpos) {
@@ -244,11 +246,22 @@
{"kThumbnailWidth", kThumbnailWidth},
+ {"kTextAlignLeft", kTextAlignLeft},
+ {"kTextAlignRight", kTextAlignRight},
+ {"kTextAlignCenter", kTextAlignCenter},
+
{"false", 0},
{"true", 1},
{NULL, 0}
};
+void Eval::loadConstants() {
+ int i;
+
+ for (i = 0; builtinConsts[i].name; i++)
+ _vars[builtinConsts[i].name] = builtinConsts[i].value;
+}
+
int Eval::getBuiltinVar(const char *s) {
if (!strcmp(s, "w"))
return g_system->getOverlayWidth();
@@ -260,13 +273,8 @@
}
int Eval::getVar_(const char *s, bool includeAliases) {
- int i;
int val;
- for (i = 0; builtinConsts[i].name; i++)
- if (!scumm_stricmp(s, builtinConsts[i].name))
- return builtinConsts[i].value;
-
val = getBuiltinVar(s);
if (val != EVAL_UNDEF_VAR)
@@ -288,7 +296,7 @@
_aliases[var] = value;
}
-void Eval::setVariable(const String §ion, const String name, const String value) {
+void Eval::setVar(const String §ion, const String name, const String value) {
String var = String(&(name.c_str()[4]));
_vars[var] = eval(value, section, name, 0);
@@ -297,6 +305,7 @@
void Eval::reset() {
_vars.clear();
_aliases.clear();
+ loadConstants();
}
} // end of namespace GUI
Modified: scummvm/trunk/gui/eval.h
===================================================================
--- scummvm/trunk/gui/eval.h 2006-03-23 22:59:38 UTC (rev 21419)
+++ scummvm/trunk/gui/eval.h 2006-03-24 01:24:26 UTC (rev 21420)
@@ -56,11 +56,11 @@
int eval(const String &input, const String §ion, const String &name, int startpos);
void setAlias(const String §ion, const String name, const String value);
- void setVariable(const String §ion, const String name, const String value);
+ void setVar(const String §ion, const String name, const String value);
void setParent(const String name);
- void setVariable(const String name, int val) { _vars[name] = val; }
+ void setVar(const String name, int val) { _vars[name] = val; }
void setAlias(const String name, const String val) { _aliases[name] = val; }
int getVar(String s) { return getVar_(s.c_str()); };
@@ -82,6 +82,7 @@
void exprError(int error);
int getVar_(const char *s, bool includeAliases = true);
int getBuiltinVar(const char *s);
+ void loadConstants();
char _input[256];
String _section;
Modified: scummvm/trunk/gui/launcher.cpp
===================================================================
--- scummvm/trunk/gui/launcher.cpp 2006-03-23 22:59:38 UTC (rev 21419)
+++ scummvm/trunk/gui/launcher.cpp 2006-03-24 01:24:26 UTC (rev 21420)
@@ -163,11 +163,11 @@
tab->addTab("Game");
// GUI: Label & edit widget for the game ID
- new StaticTextWidget(tab, "gameoptions_id", "ID: ", kTextAlignRight);
+ new StaticTextWidget(tab, "gameoptions_id", "ID: ");
_domainWidget = new DomainEditTextWidget(tab, "gameoptions_domain", _domain);
// GUI: Label & edit widget for the description
- new StaticTextWidget(tab, "gameoptions_name", "Name: ", kTextAlignRight);
+ new StaticTextWidget(tab, "gameoptions_name", "Name: ");
_descriptionWidget = new EditTextWidget(tab, "gameoptions_desc", description);
// Language popup
@@ -196,18 +196,18 @@
// GUI: Button + Label for the game path
new ButtonWidget(tab, "gameoptions_gamepath", "Game Path: ", kCmdGameBrowser, 0);
- _gamePathWidget = new StaticTextWidget(tab, "gameoptions_gamepathText", gamePath, kTextAlignLeft);
+ _gamePathWidget = new StaticTextWidget(tab, "gameoptions_gamepathText", gamePath);
// GUI: Button + Label for the additional path
new ButtonWidget(tab, "gameoptions_extrapath", "Extra Path:", kCmdExtraBrowser, 0);
- _extraPathWidget = new StaticTextWidget(tab, "gameoptions_extrapathText", extraPath, kTextAlignLeft);
+ _extraPathWidget = new StaticTextWidget(tab, "gameoptions_extrapathText", extraPath);
if (extraPath.isEmpty() || !ConfMan.hasKey("extrapath", _domain)) {
_extraPathWidget->setLabel("None");
}
// GUI: Button + Label for the save path
new ButtonWidget(tab, "gameoptions_savepath", "Save Path: ", kCmdSaveBrowser, 0);
- _savePathWidget = new StaticTextWidget(tab, "gameoptions_savepathText", savePath, kTextAlignLeft);
+ _savePathWidget = new StaticTextWidget(tab, "gameoptions_savepathText", savePath);
if (savePath.isEmpty() || !ConfMan.hasKey("savepath", _domain)) {
_savePathWidget->setLabel("Default");
}
@@ -451,12 +451,12 @@
logo->setGfx(th->getImageSurface(th->kThemeLogo));
- new StaticTextWidget(this, "launcher_version", gScummVMVersionDate, kTextAlignRight);
+ new StaticTextWidget(this, "launcher_version", gScummVMVersionDate);
} else
- new StaticTextWidget(this, "launcher_version", gScummVMFullVersion, kTextAlignCenter);
+ new StaticTextWidget(this, "launcher_version", gScummVMFullVersion);
#else
// Show ScummVM version
- new StaticTextWidget(this, "launcher_version", gScummVMFullVersion, kTextAlignCenter);
+ new StaticTextWidget(this, "launcher_version", gScummVMFullVersion);
#endif
new ButtonWidget(this, "launcher_quit_button", "Quit", kQuitCmd, 'Q');
Modified: scummvm/trunk/gui/options.cpp
===================================================================
--- scummvm/trunk/gui/options.cpp 2006-03-23 22:59:38 UTC (rev 21419)
+++ scummvm/trunk/gui/options.cpp 2006-03-24 01:24:26 UTC (rev 21420)
@@ -386,7 +386,7 @@
void OptionsDialog::addMIDIControls(GuiObject *boss, String prefix) {
// SoundFont
_soundFontButton = new ButtonWidget(boss, prefix + "mcFontButton", "SoundFont:", kChooseSoundFontCmd, 0);
- _soundFont = new StaticTextWidget(boss, prefix + "mcFontPath", "None", kTextAlignLeft);
+ _soundFont = new StaticTextWidget(boss, prefix + "mcFontPath", "None");
// Multi midi setting
_multiMidiCheckbox = new CheckboxWidget(boss, prefix + "mcMixedCheckbox", "Mixed Adlib/MIDI mode", 0, 0);
@@ -408,23 +408,23 @@
};
// Volume controllers
- new StaticTextWidget(boss, prefix + "vcMusicText", slider_labels[0], kTextAlignRight);
+ new StaticTextWidget(boss, prefix + "vcMusicText", slider_labels[0]);
_musicVolumeSlider = new SliderWidget(boss, prefix + "vcMusicSlider", kMusicVolumeChanged);
- _musicVolumeLabel = new StaticTextWidget(boss, prefix + "vcMusicLabel", "100%", kTextAlignLeft);
+ _musicVolumeLabel = new StaticTextWidget(boss, prefix + "vcMusicLabel", "100%");
_musicVolumeSlider->setMinValue(0);
_musicVolumeSlider->setMaxValue(Audio::Mixer::kMaxMixerVolume);
_musicVolumeLabel->setFlags(WIDGET_CLEARBG);
- new StaticTextWidget(boss, prefix + "vcSfxText", slider_labels[1], kTextAlignRight);
+ new StaticTextWidget(boss, prefix + "vcSfxText", slider_labels[1]);
_sfxVolumeSlider = new SliderWidget(boss, prefix + "vcSfxSlider", kSfxVolumeChanged);
- _sfxVolumeLabel = new StaticTextWidget(boss, prefix + "vcSfxLabel", "100%", kTextAlignLeft);
+ _sfxVolumeLabel = new StaticTextWidget(boss, prefix + "vcSfxLabel", "100%");
_sfxVolumeSlider->setMinValue(0);
_sfxVolumeSlider->setMaxValue(Audio::Mixer::kMaxMixerVolume);
_sfxVolumeLabel->setFlags(WIDGET_CLEARBG);
- new StaticTextWidget(boss, prefix + "vcSpeechText" , slider_labels[2], kTextAlignRight);
+ new StaticTextWidget(boss, prefix + "vcSpeechText" , slider_labels[2]);
_speechVolumeSlider = new SliderWidget(boss, prefix + "vcSpeechSlider", kSpeechVolumeChanged);
- _speechVolumeLabel = new StaticTextWidget(boss, prefix + "vcSpeechLabel", "100%", kTextAlignLeft);
+ _speechVolumeLabel = new StaticTextWidget(boss, prefix + "vcSpeechLabel", "100%");
_speechVolumeSlider->setMinValue(0);
_speechVolumeSlider->setMaxValue(Audio::Mixer::kMaxMixerVolume);
_speechVolumeLabel->setFlags(WIDGET_CLEARBG);
@@ -473,10 +473,10 @@
// Save game path
new ButtonWidget(tab, "globaloptions_savebutton", "Save Path: ", kChooseSaveDirCmd, 0);
- _savePath = new StaticTextWidget(tab, "globaloptions_savepath", "/foo/bar", kTextAlignLeft);
+ _savePath = new StaticTextWidget(tab, "globaloptions_savepath", "/foo/bar");
new ButtonWidget(tab, "globaloptions_extrabutton", "Extra Path:", kChooseExtraDirCmd, 0);
- _extraPath = new StaticTextWidget(tab, "globaloptions_extrapath", "None", kTextAlignLeft);
+ _extraPath = new StaticTextWidget(tab, "globaloptions_extrapath", "None");
#endif
#ifdef SMALL_SCREEN_DEVICE
Modified: scummvm/trunk/gui/theme-config.cpp
===================================================================
--- scummvm/trunk/gui/theme-config.cpp 2006-03-23 22:59:38 UTC (rev 21419)
+++ scummvm/trunk/gui/theme-config.cpp 2006-03-24 01:24:26 UTC (rev 21420)
@@ -87,6 +87,7 @@
"browser=((w - brW) / 2) ((h - brH) / 2) brW brH\n"
"set_parent=browser\n"
"browser_headline=10 kLineHeight (parent.w - 2 * 10) kLineHeight\n"
+"browser_headline.align=kTextAlignCenter\n"
"browser_path=10 prev.y2 prev.w prev.h\n"
"browser_list=10 prev.y2 prev.w (parent.h - 3 * kLineHeight - buttonHeight - 14)\n"
"browser_up=10 (parent.h - buttonHeight - 8) buttonWidth buttonHeight\n"
@@ -96,6 +97,7 @@
"##### launcher\n"
"hBorder=10\n"
"launcher_version=hBorder 8 (w - 2 * hBorder) kLineHeight\n"
+"launcher_version.align=kTextAlignCenter\n"
"top=(h - 8 - buttonHeight)\n"
"numButtons=4\n"
"space=8\n"
@@ -158,9 +160,11 @@
"# game tab\n"
"opYoffset=vBorder\n"
"gameoptions_id=gox (opYoffset + 2) gameOptionsLabelWidth kLineHeight\n"
+"gameoptions_id.align=kTextAlignRight\n"
"gameoptions_domain=prev.x2 (prev.y - 1) (parent.w - gameOptionsLabelWidth - 10 - gox) (prev.h + 2)\n"
"opYoffset=(opYoffset + prev.h + 3)\n"
"gameoptions_name=gox (opYoffset + 2) gameOptionsLabelWidth kLineHeight\n"
+"gameoptions_name.align=kTextAlignRight\n"
"gameoptions_desc=prev.x2 (prev.y - 1) (parent.w - gameOptionsLabelWidth - 10 - gox) (prev.h + 2)\n"
"opYoffset=(opYoffset + prev.h + 3)\n"
"gameoptions_lang=gox (opYoffset - 1) gow (kLineHeight + 2)\n"
@@ -273,6 +277,7 @@
"chooserW=(w - 2 * 8)\n"
"chooser=((w - chooserW) / 2) ((h - opHeight) / 2) chooserW opHeight\n"
"chooser_headline=10 6 (chooserW - 2 * 10) (kLineHeight)\n"
+"chooser_headline.align=kTextAlignCenter\n"
"chooser_list=10 (6 + kLineHeight + 2) prev.w (opHeight - self.y - buttonHeight - 12)\n"
"chooser_cancel=(chooserW - 2 * (buttonWidth + 10)) (opHeight - buttonHeight - 8) buttonWidth buttonHeight\n"
"chooser_ok=(prev.x2 + 10) prev.y prev.w prev.h\n"
@@ -302,14 +307,17 @@
"vctextw=95\n"
"vcxoff=(vctextw + 15)\n"
"vcMusicText=10 (opYoffset + 2) vctextw kLineHeight\n"
+"vcMusicText.align=kTextAlignRight\n"
"vcMusicSlider=vcxoff opYoffset sliderWidth sliderHeight\n"
"vcMusicLabel=(vcxoff + prev.w + 10) (opYoffset + 2) 24 kLineHeight\n"
"opYoffset=(opYoffset + sliderHeight + 4)\n"
"vcSfxText=10 (opYoffset + 2) vctextw kLineHeight\n"
+"vcSfxText.align=kTextAlignRight\n"
"vcSfxSlider=vcxoff opYoffset sliderWidth sliderHeight\n"
"vcSfxLabel=(vcxoff + prev.w + 10) (opYoffset + 2) 24 kLineHeight\n"
"opYoffset=(opYoffset + sliderHeight + 4)\n"
"vcSpeechText=10 (opYoffset + 2) vctextw kLineHeight\n"
+"vcSpeechText.align=kTextAlignRight\n"
"vcSpeechSlider=vcxoff opYoffset sliderWidth sliderHeight\n"
"vcSpeechLabel=(vcxoff + prev.w + 10) (opYoffset + 2) 24 kLineHeight\n"
"opYoffset=(opYoffset + sliderHeight + 4)\n"
@@ -370,13 +378,13 @@
to = prefix + name + "." + postfixes[i];
_evaluator->setAlias(from, to);
- _evaluator->setVariable(to, 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->setVariable(prefix + name + "." + postfixes[npostfix++], value);
+ _evaluator->setVar(prefix + name + "." + postfixes[npostfix++], value);
start = i + 1;
}
if (str[i] == '(')
@@ -399,15 +407,15 @@
// process VAR=VALUE construct
if (npostfix == 0)
- _evaluator->setVariable(name, value);
+ _evaluator->setVar(name, value);
else
- _evaluator->setVariable(prefix + name + "." + postfixes[npostfix], value);
+ _evaluator->setVar(prefix + name + "." + postfixes[npostfix], value);
// If we have all 4 parameters, set .x2 and .y2
if (npostfix == 3) {
- _evaluator->setVariable(prefix + name + ".x2",
+ _evaluator->setVar(prefix + name + ".x2",
_evaluator->getVar(prefix + name + ".x") + _evaluator->getVar(prefix + name + ".w"));
- _evaluator->setVariable(prefix + name + ".y2",
+ _evaluator->setVar(prefix + name + ".y2",
_evaluator->getVar(prefix +name + ".y") + _evaluator->getVar(prefix + name + ".h"));
}
@@ -433,7 +441,7 @@
}
if (iterk->key.hasPrefix("def_")) {
if (!skipDefs)
- _evaluator->setVariable(name, prefix + iterk->key, iterk->value);
+ _evaluator->setVar(name, prefix + iterk->key, iterk->value);
continue;
}
if (iterk->key == "use") {
Modified: scummvm/trunk/gui/themes/default-theme.ini
===================================================================
--- scummvm/trunk/gui/themes/default-theme.ini 2006-03-23 22:59:38 UTC (rev 21419)
+++ scummvm/trunk/gui/themes/default-theme.ini 2006-03-24 01:24:26 UTC (rev 21420)
@@ -1,7 +1,7 @@
# $URL$
# $Id$
[theme]
-version=4
+version=5
[pixmaps]
dialog_corner=dialog_bkgd_corner.bmp
@@ -141,6 +141,7 @@
##### launcher
launcher_version=85 21 247 kLineHeight
+launcher_version.align=kTextAlignRight
launcher_logo=180 5 283 80
launcher_logo.visible=true
space1=20
Modified: scummvm/trunk/gui/widget.cpp
===================================================================
--- scummvm/trunk/gui/widget.cpp 2006-03-23 22:59:38 UTC (rev 21419)
+++ scummvm/trunk/gui/widget.cpp 2006-03-24 01:24:26 UTC (rev 21420)
@@ -131,12 +131,17 @@
_label = text;
}
-StaticTextWidget::StaticTextWidget(GuiObject *boss, String name, const String &text, TextAlignment align)
- : Widget(boss, name), _align(align) {
+StaticTextWidget::StaticTextWidget(GuiObject *boss, String name, const String &text)
+ : Widget(boss, name) {
_ws = g_gui.getWidgetSize();
_flags = WIDGET_ENABLED;
_type = kStaticTextWidget;
_label = text;
+
+ _align = (Graphics::TextAlignment)g_gui.evaluator()->getVar(name + ".align");
+
+ if (_align == EVAL_UNDEF_VAR)
+ _align = kTextAlignLeft;
}
void StaticTextWidget::setValue(int value) {
@@ -177,8 +182,9 @@
}
ButtonWidget::ButtonWidget(GuiObject *boss, String name, const String &label, uint32 cmd, uint8 hotkey)
- : StaticTextWidget(boss, name, label, kTextAlignCenter), CommandSender(boss),
+ : StaticTextWidget(boss, name, label), CommandSender(boss),
_cmd(cmd), _hotkey(hotkey) {
+ g_gui.evaluator()->setVar(name + ".align", kTextAlignCenter);
_flags = WIDGET_ENABLED/* | WIDGET_BORDER*/ | WIDGET_CLEARBG;
_type = kButtonWidget;
}
Modified: scummvm/trunk/gui/widget.h
===================================================================
--- scummvm/trunk/gui/widget.h 2006-03-23 22:59:38 UTC (rev 21419)
+++ scummvm/trunk/gui/widget.h 2006-03-24 01:24:26 UTC (rev 21420)
@@ -164,7 +164,7 @@
WidgetSize _ws;
public:
StaticTextWidget(GuiObject *boss, int x, int y, int w, int h, const String &text, TextAlignment align);
- StaticTextWidget(GuiObject *boss, String name, const String &text, TextAlignment align);
+ StaticTextWidget(GuiObject *boss, String name, const String &text);
void setValue(int value);
void setLabel(const String &label);
const String &getLabel() const { return _label; }
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