diff options
-rw-r--r-- | engines/scumm/dialogs.cpp | 4 | ||||
-rw-r--r-- | gui/KeysDialog.cpp | 5 | ||||
-rw-r--r-- | gui/browser.cpp | 4 | ||||
-rw-r--r-- | gui/chooser.cpp | 2 | ||||
-rw-r--r-- | gui/eval.cpp | 23 | ||||
-rw-r--r-- | gui/eval.h | 5 | ||||
-rw-r--r-- | gui/launcher.cpp | 16 | ||||
-rw-r--r-- | gui/options.cpp | 18 | ||||
-rw-r--r-- | gui/theme-config.cpp | 22 | ||||
-rw-r--r-- | gui/themes/default-theme.ini | 3 | ||||
-rw-r--r-- | gui/widget.cpp | 12 | ||||
-rw-r--r-- | gui/widget.h | 2 |
12 files changed, 70 insertions, 46 deletions
diff --git a/engines/scumm/dialogs.cpp b/engines/scumm/dialogs.cpp index 9a831720a8..09f383cec3 100644 --- a/engines/scumm/dialogs.cpp +++ b/engines/scumm/dialogs.cpp @@ -357,7 +357,7 @@ SaveLoadChooserEx::SaveLoadChooserEx(const String &title, const String &buttonLa _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 @@ HelpDialog::HelpDialog(ScummEngine *scumm) 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"); diff --git a/gui/KeysDialog.cpp b/gui/KeysDialog.cpp index 5dacb5deda..80d9602d82 100644 --- a/gui/KeysDialog.cpp +++ b/gui/KeysDialog.cpp @@ -38,7 +38,6 @@ using GUI::WIDGET_CLEARBG; using GUI::kListSelectionChangedCmd; using GUI::kCloseCmd; using GUI::StaticTextWidget; -using GUI::kTextAlignCenter; using GUI::CommandSender; */ @@ -60,8 +59,8 @@ KeysDialog::KeysDialog(const Common::String &title) _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); diff --git a/gui/browser.cpp b/gui/browser.cpp index 61a45079d2..fc605e4080 100644 --- a/gui/browser.cpp +++ b/gui/browser.cpp @@ -138,10 +138,10 @@ BrowserDialog::BrowserDialog(const char *title, bool dirBrowser) _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"); diff --git a/gui/chooser.cpp b/gui/chooser.cpp index 3b18bf912e..aa3dc8f5ca 100644 --- a/gui/chooser.cpp +++ b/gui/chooser.cpp @@ -35,7 +35,7 @@ ChooserDialog::ChooserDialog(const String &title, String prefix, const String &b : 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 diff --git a/gui/eval.cpp b/gui/eval.cpp index f3d4f496c7..5dcfdfe124 100644 --- a/gui/eval.cpp +++ b/gui/eval.cpp @@ -38,10 +38,12 @@ static bool isdelim(char c) { } 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 @@ static const BuiltinConsts builtinConsts[] = { {"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::getBuiltinVar(const char *s) { } 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 @@ void Eval::setAlias(const String §ion, const String name, const String value _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::setVariable(const String §ion, const String name, const String va void Eval::reset() { _vars.clear(); _aliases.clear(); + loadConstants(); } } // end of namespace GUI diff --git a/gui/eval.h b/gui/eval.h index fc4f12c11d..799a6f74e8 100644 --- a/gui/eval.h +++ b/gui/eval.h @@ -56,11 +56,11 @@ public: 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 @@ private: void exprError(int error); int getVar_(const char *s, bool includeAliases = true); int getBuiltinVar(const char *s); + void loadConstants(); char _input[256]; String _section; diff --git a/gui/launcher.cpp b/gui/launcher.cpp index 26be849690..201c1d9bce 100644 --- a/gui/launcher.cpp +++ b/gui/launcher.cpp @@ -163,11 +163,11 @@ EditGameDialog::EditGameDialog(const String &domain, const String &desc) 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 @@ EditGameDialog::EditGameDialog(const String &domain, const String &desc) // 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 @@ LauncherDialog::LauncherDialog(GameDetector &detector) 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'); diff --git a/gui/options.cpp b/gui/options.cpp index 26fc017992..67add1a27f 100644 --- a/gui/options.cpp +++ b/gui/options.cpp @@ -386,7 +386,7 @@ void OptionsDialog::addAudioControls(GuiObject *boss, String prefix) { 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 @@ void OptionsDialog::addVolumeControls(GuiObject *boss, String prefix) { }; // 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 @@ GlobalOptionsDialog::GlobalOptionsDialog() // 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 diff --git a/gui/theme-config.cpp b/gui/theme-config.cpp index d55e2efecd..893aa6369c 100644 --- a/gui/theme-config.cpp +++ b/gui/theme-config.cpp @@ -87,6 +87,7 @@ const char *Theme::_defaultConfigINI = "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 @@ const char *Theme::_defaultConfigINI = "##### 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 @@ const char *Theme::_defaultConfigINI = "# 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 @@ const char *Theme::_defaultConfigINI = "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 @@ const char *Theme::_defaultConfigINI = "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 @@ void Theme::processSingleLine(const String §ion, const String prefix, const 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 @@ void Theme::processSingleLine(const String §ion, const String prefix, const // 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 @@ void Theme::processResSection(Common::ConfigFile &config, String name, bool skip } 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") { diff --git a/gui/themes/default-theme.ini b/gui/themes/default-theme.ini index 429516c107..85ef24b927 100644 --- a/gui/themes/default-theme.ini +++ b/gui/themes/default-theme.ini @@ -1,7 +1,7 @@ # $URL$ # $Id$ [theme] -version=4 +version=5 [pixmaps] dialog_corner=dialog_bkgd_corner.bmp @@ -141,6 +141,7 @@ def_scummmainVAddOff=5 ##### launcher launcher_version=85 21 247 kLineHeight +launcher_version.align=kTextAlignRight launcher_logo=180 5 283 80 launcher_logo.visible=true space1=20 diff --git a/gui/widget.cpp b/gui/widget.cpp index 26c3df4731..51fbec3456 100644 --- a/gui/widget.cpp +++ b/gui/widget.cpp @@ -131,12 +131,17 @@ StaticTextWidget::StaticTextWidget(GuiObject *boss, int x, int y, int w, int h, _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, int x, int y, int w, int h, const St } 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; } diff --git a/gui/widget.h b/gui/widget.h index 777a3404f4..9869331909 100644 --- a/gui/widget.h +++ b/gui/widget.h @@ -164,7 +164,7 @@ protected: 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; } |