diff options
author | Eugene Sandulenko | 2006-03-08 01:42:02 +0000 |
---|---|---|
committer | Eugene Sandulenko | 2006-03-08 01:42:02 +0000 |
commit | a8a8624511f280ea1fdc9bb4bde4f79477b76ae1 (patch) | |
tree | 544b36ae8748d427bb0eb3ded7795f270c27d1c1 | |
parent | cca7da5ba1fec174a692dfdb6dbc4805a9da44e2 (diff) | |
download | scummvm-rg350-a8a8624511f280ea1fdc9bb4bde4f79477b76ae1.tar.gz scummvm-rg350-a8a8624511f280ea1fdc9bb4bde4f79477b76ae1.tar.bz2 scummvm-rg350-a8a8624511f280ea1fdc9bb4bde4f79477b76ae1.zip |
o Converted most (all?) widgets to new scheme.
o Converted global options dialog to new scheme.
svn-id: r21137
-rw-r--r-- | engines/scumm/dialogs.cpp | 6 | ||||
-rw-r--r-- | gui/ListWidget.cpp | 6 | ||||
-rw-r--r-- | gui/ListWidget.h | 2 | ||||
-rw-r--r-- | gui/PopUpWidget.cpp | 10 | ||||
-rw-r--r-- | gui/PopUpWidget.h | 5 | ||||
-rw-r--r-- | gui/TabWidget.cpp | 9 | ||||
-rw-r--r-- | gui/TabWidget.h | 5 | ||||
-rw-r--r-- | gui/chooser.cpp | 4 | ||||
-rw-r--r-- | gui/dialog.cpp | 2 | ||||
-rw-r--r-- | gui/editable.cpp | 2 | ||||
-rw-r--r-- | gui/editable.h | 2 | ||||
-rw-r--r-- | gui/eval.cpp | 7 | ||||
-rw-r--r-- | gui/eval.h | 4 | ||||
-rw-r--r-- | gui/launcher.cpp | 35 | ||||
-rw-r--r-- | gui/newgui.h | 5 | ||||
-rw-r--r-- | gui/options.cpp | 178 | ||||
-rw-r--r-- | gui/options.h | 10 | ||||
-rw-r--r-- | gui/theme-config.cpp | 159 | ||||
-rw-r--r-- | gui/theme.h | 3 | ||||
-rw-r--r-- | gui/themes/default-theme.ini | 139 | ||||
-rw-r--r-- | gui/widget.cpp | 22 | ||||
-rw-r--r-- | gui/widget.h | 8 |
22 files changed, 426 insertions, 197 deletions
diff --git a/engines/scumm/dialogs.cpp b/engines/scumm/dialogs.cpp index 2331231285..4e1e4c303e 100644 --- a/engines/scumm/dialogs.cpp +++ b/engines/scumm/dialogs.cpp @@ -693,15 +693,18 @@ ConfigDialog::ConfigDialog(ScummEngine *scumm) GUI::WidgetSize ws; int buttonWidth; int buttonHeight; + int sliderHeight; if (screenW >= 400 && screenH >= 300) { ws = GUI::kBigWidgetSize; buttonWidth = kBigButtonWidth; buttonHeight = kBigButtonHeight; + sliderHeight = GUI::kBigSliderHeight; } else { ws = GUI::kNormalWidgetSize; buttonWidth = kButtonWidth; buttonHeight = kButtonHeight; + sliderHeight = GUI::kSliderHeight; } int yoffset = 8; @@ -710,7 +713,8 @@ ConfigDialog::ConfigDialog(ScummEngine *scumm) // Sound controllers // - yoffset = addVolumeControls(this, yoffset, ws) + 4; + addVolumeControls(this, "scummoptions_"); + yoffset += (sliderHeight + 4) * 8; // // Some misc options diff --git a/gui/ListWidget.cpp b/gui/ListWidget.cpp index 963b37b944..1eb0c45864 100644 --- a/gui/ListWidget.cpp +++ b/gui/ListWidget.cpp @@ -33,11 +33,11 @@ ListWidget::ListWidget(GuiObject *boss, int x, int y, int w, int h, WidgetSize w init(boss, w, ws); } -ListWidget::ListWidget(GuiObject *boss, String name, WidgetSize ws) - : EditableWidget(boss, name, ws), CommandSender(boss) { +ListWidget::ListWidget(GuiObject *boss, String name) + : EditableWidget(boss, name), CommandSender(boss) { int w = g_gui.evaluator()->getVar(name + ".w"); - init(boss, w, ws); + init(boss, w, g_gui.getWidgetSize()); } void ListWidget::init(GuiObject *boss, int w, WidgetSize ws) { diff --git a/gui/ListWidget.h b/gui/ListWidget.h index 2ee8ed8c37..4cb89f020b 100644 --- a/gui/ListWidget.h +++ b/gui/ListWidget.h @@ -63,7 +63,7 @@ protected: public: ListWidget(GuiObject *boss, int x, int y, int w, int h, WidgetSize ws = kDefaultWidgetSize); - ListWidget(GuiObject *boss, String name, WidgetSize ws = kDefaultWidgetSize); + ListWidget(GuiObject *boss, String name); virtual ~ListWidget(); void init(GuiObject *boss, int w, WidgetSize ws); diff --git a/gui/PopUpWidget.cpp b/gui/PopUpWidget.cpp index 8a79166b97..f12a4d5637 100644 --- a/gui/PopUpWidget.cpp +++ b/gui/PopUpWidget.cpp @@ -336,6 +336,16 @@ void PopUpDialog::drawMenuEntry(int entry, bool hilite) { PopUpWidget::PopUpWidget(GuiObject *boss, int x, int y, int w, int h, const String &label, uint labelWidth, WidgetSize ws) : Widget(boss, x, y - 1, w, h + 2), CommandSender(boss), _ws(ws), _label(label), _labelWidth(labelWidth) { + init(); +} + +PopUpWidget::PopUpWidget(GuiObject *boss, String name, const String &label, uint labelWidth) + : Widget(boss, name), CommandSender(boss), _label(label), _labelWidth(labelWidth) { + _ws = g_gui.getWidgetSize(); + init(); +} + +void PopUpWidget::init() { _flags = WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS; setHints(THEME_HINT_SAVE_BACKGROUND); _type = kPopUpWidget; diff --git a/gui/PopUpWidget.h b/gui/PopUpWidget.h index affde47459..bfa549c05a 100644 --- a/gui/PopUpWidget.h +++ b/gui/PopUpWidget.h @@ -49,7 +49,7 @@ class PopUpWidget : public Widget, public CommandSender { }; typedef Common::Array<Entry> EntryList; protected: - const WidgetSize _ws; + WidgetSize _ws; EntryList _entries; int _selectedItem; @@ -58,6 +58,9 @@ protected: public: PopUpWidget(GuiObject *boss, int x, int y, int w, int h, const String &label, uint labelWidth = 0, WidgetSize ws = kDefaultWidgetSize); + PopUpWidget(GuiObject *boss, String name, const String &label, uint labelWidth = 0); + + void init(); void handleMouseDown(int x, int y, int button, int clickCount); diff --git a/gui/TabWidget.cpp b/gui/TabWidget.cpp index 679aa31ad0..3d236b2f20 100644 --- a/gui/TabWidget.cpp +++ b/gui/TabWidget.cpp @@ -38,7 +38,16 @@ enum { TabWidget::TabWidget(GuiObject *boss, int x, int y, int w, int h, WidgetSize ws) : Widget(boss, x, y, w, h), _ws(ws) { + init(); +} + +TabWidget::TabWidget(GuiObject *boss, String name) + : Widget(boss, name) { + _ws = g_gui.getWidgetSize(); + init(); +} +void TabWidget::init() { _flags = WIDGET_ENABLED; _type = kTabWidget; _activeTab = -1; diff --git a/gui/TabWidget.h b/gui/TabWidget.h index b40650296b..6b4c80904d 100644 --- a/gui/TabWidget.h +++ b/gui/TabWidget.h @@ -40,12 +40,15 @@ protected: TabList _tabs; int _tabWidth; int _tabHeight; - const WidgetSize _ws; + WidgetSize _ws; public: TabWidget(GuiObject *boss, int x, int y, int w, int h, WidgetSize ws = kDefaultWidgetSize); + TabWidget(GuiObject *boss, String name); ~TabWidget(); + void init(); + virtual int16 getChildY() const; // Problem: how to add items to a tab? diff --git a/gui/chooser.cpp b/gui/chooser.cpp index b373078a11..6687164238 100644 --- a/gui/chooser.cpp +++ b/gui/chooser.cpp @@ -62,14 +62,14 @@ ChooserDialog::ChooserDialog(const String &title, const String &buttonLabel, int int yoffset = 6; // Headline - new StaticTextWidget(this, "chooser_headline", title, kTextAlignCenter, ws); + new StaticTextWidget(this, "chooser_headline", title, kTextAlignCenter); yoffset += kLineHeight + 2; // Add choice list // HACK: Subtracting -12 from the height makes the list look good when // it's used to list savegames in the 320x200 version of the GUI. - _list = new ListWidget(this, "chooser_list", ws); + _list = new ListWidget(this, "chooser_list"); _list->setNumberingMode(kListNumberingOff); // Buttons diff --git a/gui/dialog.cpp b/gui/dialog.cpp index 2e9099de1b..375963b889 100644 --- a/gui/dialog.cpp +++ b/gui/dialog.cpp @@ -323,6 +323,8 @@ CheckboxWidget *Dialog::addCheckbox(GuiObject *boss, int x, int y, const Common: w = g_gui.getFontHeight() + 10 + g_gui.getStringWidth(label); + debug(0, "%s: %d", label.c_str(), g_gui.getStringWidth(label)); + return new CheckboxWidget(boss, x, y, w, h, label, cmd, hotkey, ws); } diff --git a/gui/editable.cpp b/gui/editable.cpp index d44b43131d..0f30005cf1 100644 --- a/gui/editable.cpp +++ b/gui/editable.cpp @@ -30,7 +30,7 @@ EditableWidget::EditableWidget(GuiObject *boss, int x, int y, int w, int h, Widg init(); } -EditableWidget::EditableWidget(GuiObject *boss, String name, WidgetSize ws) +EditableWidget::EditableWidget(GuiObject *boss, String name) : Widget(boss, name) { init(); } diff --git a/gui/editable.h b/gui/editable.h index 8d13a691d4..0c6869b9f4 100644 --- a/gui/editable.h +++ b/gui/editable.h @@ -48,7 +48,7 @@ protected: public: EditableWidget(GuiObject *boss, int x, int y, int w, int h, WidgetSize ws = kNormalWidgetSize); - EditableWidget(GuiObject *boss, String name, WidgetSize ws = kNormalWidgetSize); + EditableWidget(GuiObject *boss, String name); virtual ~EditableWidget(); void init(); diff --git a/gui/eval.cpp b/gui/eval.cpp index ad9b0607d3..ba2ed1e694 100644 --- a/gui/eval.cpp +++ b/gui/eval.cpp @@ -127,7 +127,7 @@ void Eval::primitive(int *result) { switch (_tokenType) { case tVariable: - *result = getVar(_token); + *result = getVar_(_token); if (*result == EVAL_UNDEF_VAR) exprError(eUndefVar); getToken(); @@ -237,6 +237,9 @@ static const BuiltinConsts builtinConsts[] = { {"kBigSliderWidth", GUI::kBigSliderWidth}, {"kBigSliderHeight", GUI::kBigSliderHeight}, + {"kNormalWidgetSize", GUI::kNormalWidgetSize}, + {"kBigWidgetSize", GUI::kBigWidgetSize}, + {"false", 0}, {"true", 1}, {NULL, 0} @@ -252,7 +255,7 @@ int Eval::getBuiltinVar(const char *s) { return EVAL_UNDEF_VAR; } -int Eval::getVar(const char *s, bool includeAliases) { +int Eval::getVar_(const char *s, bool includeAliases) { int i; int val; diff --git a/gui/eval.h b/gui/eval.h index 297f455b54..0608f83603 100644 --- a/gui/eval.h +++ b/gui/eval.h @@ -67,7 +67,7 @@ public: void setVariable(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()); }; + int getVar(String s) { return getVar_(s.c_str()); }; void reset(); @@ -84,7 +84,7 @@ private: void arith(char op, int *r, int *h); void unary(char op, int *r); void exprError(int error); - int getVar(const char *s, bool includeAliases = true); + int getVar_(const char *s, bool includeAliases = true); int getBuiltinVar(const char *s); char _input[256]; diff --git a/gui/launcher.cpp b/gui/launcher.cpp index dd81e6afc3..e539460ee5 100644 --- a/gui/launcher.cpp +++ b/gui/launcher.cpp @@ -257,7 +257,7 @@ EditGameDialog::EditGameDialog(const String &domain, const char *desc) _globalGraphicsOverride = addCheckbox(tab, x, yoffset, "Override global graphic settings", kCmdGlobalGraphicsOverride, 0, ws); yoffset += _globalGraphicsOverride->getHeight(); - yoffset = addGraphicControls(tab, yoffset, ws); + addGraphicControls(tab, "gameoptions_"); // // 4) The audio tab @@ -268,7 +268,7 @@ EditGameDialog::EditGameDialog(const String &domain, const char *desc) _globalAudioOverride = addCheckbox(tab, x, yoffset, "Override global audio settings", kCmdGlobalAudioOverride, 0, ws); yoffset += _globalAudioOverride->getHeight(); - yoffset = addAudioControls(tab, yoffset, ws); + addAudioControls(tab, "gameoptions_"); // // 5) The MIDI tab @@ -279,7 +279,7 @@ EditGameDialog::EditGameDialog(const String &domain, const char *desc) _globalMIDIOverride = addCheckbox(tab, x, yoffset, "Override global MIDI settings", kCmdGlobalMIDIOverride, 0, ws); yoffset += _globalMIDIOverride->getHeight(); - yoffset = addMIDIControls(tab, yoffset, ws); + addMIDIControls(tab, "gameoptions_"); // // 6) The volume tab @@ -290,7 +290,7 @@ EditGameDialog::EditGameDialog(const String &domain, const char *desc) _globalVolumeOverride = addCheckbox(tab, x, yoffset, "Override global volume settings", kCmdGlobalVolumeOverride, 0, ws); yoffset += _globalVolumeOverride->getHeight(); - yoffset = addVolumeControls(tab, yoffset, ws); + addVolumeControls(tab, "gameoptions_"); // Activate the first tab @@ -487,35 +487,28 @@ LauncherDialog::LauncherDialog(GameDetector &detector) _w = screenW; _h = screenH; - GUI::WidgetSize ws; - - if (screenW >= 400 && screenH >= 300) - ws = GUI::kBigWidgetSize; - else - ws = GUI::kNormalWidgetSize; - // Show ScummVM version - new StaticTextWidget(this, "launcher_version", gScummVMFullVersion, kTextAlignCenter, ws); + new StaticTextWidget(this, "launcher_version", gScummVMFullVersion, kTextAlignCenter); // Add some buttons at the bottom // TODO: Rearrange them a bit? In particular, we could put a slightly smaller space // between About and Options, and in exchange remove those a bit from Quit and Start. - new ButtonWidget(this, "launcher_quit_button", "Quit", kQuitCmd, 'Q', ws); - new ButtonWidget(this, "launcher_about_button", "About", kAboutCmd, 'B', ws); - new ButtonWidget(this, "launcher_options_button", "Options", kOptionsCmd, 'O', ws); + new ButtonWidget(this, "launcher_quit_button", "Quit", kQuitCmd, 'Q'); + new ButtonWidget(this, "launcher_about_button", "About", kAboutCmd, 'B'); + new ButtonWidget(this, "launcher_options_button", "Options", kOptionsCmd, 'O'); _startButton = - new ButtonWidget(this, "launcher_start_button", "Start", kStartCmd, 'S', ws); + new ButtonWidget(this, "launcher_start_button", "Start", kStartCmd, 'S'); // Above the lowest button rows: two more buttons (directly below the list box) - new ButtonWidget(this, "launcher_addGame_button", "Add Game...", kAddGameCmd, 'A', ws); + new ButtonWidget(this, "launcher_addGame_button", "Add Game...", kAddGameCmd, 'A'); _editButton = - new ButtonWidget(this, "launcher_editGame_button", "Edit Game...", kEditGameCmd, 'E', ws); + new ButtonWidget(this, "launcher_editGame_button", "Edit Game...", kEditGameCmd, 'E'); _removeButton = - new ButtonWidget(this, "launcher_removeGame_button", "Remove Game", kRemoveGameCmd, 'R', ws); + new ButtonWidget(this, "launcher_removeGame_button", "Remove Game", kRemoveGameCmd, 'R'); // Add list with game titles - _list = new ListWidget(this, "launcher_list", ws); + _list = new ListWidget(this, "launcher_list"); _list->setEditable(false); _list->setNumberingMode(kListNumberingOff); @@ -762,7 +755,7 @@ void LauncherDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat editGame(item); break; case kOptionsCmd: { - GlobalOptionsDialog options; + GlobalOptionsDialog options("globaloptions"); options.runModal(); } break; diff --git a/gui/newgui.h b/gui/newgui.h index 4eb3e9d10c..21719041ce 100644 --- a/gui/newgui.h +++ b/gui/newgui.h @@ -78,6 +78,11 @@ public: int getStringWidth(const Common::String &str) const { return _theme->getStringWidth(str); } int getCharWidth(byte c) const { return _theme->getCharWidth(c); } + WidgetSize getWidgetSize() { + return (WidgetSize)(_theme->_evaluator->getVar("widgetSize")); + } + + protected: OSystem *_system; diff --git a/gui/options.cpp b/gui/options.cpp index 0eb596bb0e..4c987a9362 100644 --- a/gui/options.cpp +++ b/gui/options.cpp @@ -325,22 +325,13 @@ void OptionsDialog::setVolumeSettingsState(bool enabled) { _speechVolumeLabel->setEnabled(enabled); } -int OptionsDialog::addGraphicControls(GuiObject *boss, int yoffset, WidgetSize ws) { - const int x = 10; - const int w = _w - 2 * 10; +void OptionsDialog::addGraphicControls(GuiObject *boss, String prefix) { const OSystem::GraphicsMode *gm = g_system->getSupportedGraphicsModes(); - int labelWidth; - - if (ws == kBigWidgetSize) { - labelWidth = 150; - } else { - labelWidth = 100; - } + int labelWidth = g_gui.evaluator()->getVar("tabPopupsLabelW"); // The GFX mode popup - _gfxPopUp = addPopUp(boss, x-5, yoffset, w+5, "Graphics mode: ", labelWidth, ws); - yoffset += _gfxPopUp->getHeight() + 4; + _gfxPopUp = new PopUpWidget(boss, prefix + "grModePopup", "Graphics mode: ", labelWidth); _gfxPopUp->appendEntry("<default>"); _gfxPopUp->appendEntry(""); @@ -350,8 +341,7 @@ int OptionsDialog::addGraphicControls(GuiObject *boss, int yoffset, WidgetSize w } // RenderMode popup - _renderModePopUp = addPopUp(boss, x-5, yoffset, w+5, "Render mode: ", labelWidth, ws); - yoffset += _renderModePopUp->getHeight() + 4; + _renderModePopUp = new PopUpWidget(boss, prefix + "grRenderPopup", "Render mode: ", labelWidth); _renderModePopUp->appendEntry("<default>", Common::kRenderDefault); _renderModePopUp->appendEntry(""); const Common::RenderModeDescription *rm = Common::g_renderModes; @@ -360,12 +350,10 @@ int OptionsDialog::addGraphicControls(GuiObject *boss, int yoffset, WidgetSize w } // Fullscreen checkbox - _fullscreenCheckbox = addCheckbox(boss, x, yoffset, "Fullscreen mode", 0, 0, ws); - yoffset += _fullscreenCheckbox->getHeight(); + _fullscreenCheckbox = new CheckboxWidget(boss, prefix + "grFullscreenCheckbox", "Fullscreen mode", 0, 0); // Aspect ratio checkbox - _aspectCheckbox = addCheckbox(boss, x, yoffset, "Aspect ratio correction", 0, 0, ws); - yoffset += _aspectCheckbox->getHeight(); + _aspectCheckbox = new CheckboxWidget(boss, prefix + "grAspectCheckbox", "Aspect ratio correction", 0, 0); #ifdef SMALL_SCREEN_DEVICE _fullscreenCheckbox->setState(TRUE); @@ -374,25 +362,13 @@ int OptionsDialog::addGraphicControls(GuiObject *boss, int yoffset, WidgetSize w #endif _enableGraphicSettings = true; - - return yoffset; } -int OptionsDialog::addAudioControls(GuiObject *boss, int yoffset, WidgetSize ws) { - const int x = 10; - const int w = _w - 20; - - int labelWidth; - - if (ws == kBigWidgetSize) { - labelWidth = 150; - } else { - labelWidth = 100; - } +void OptionsDialog::addAudioControls(GuiObject *boss, String prefix) { + int labelWidth = g_gui.evaluator()->getVar("tabPopupsLabelW"); // The MIDI mode popup & a label - _midiPopUp = addPopUp(boss, x-5, yoffset, w+5, "Music driver: ", labelWidth, ws); - yoffset += _midiPopUp->getHeight() + 4; + _midiPopUp = new PopUpWidget(boss, prefix + "auMidiPopup", "Music driver: ", labelWidth); // Populate it const MidiDriverDescription *md = MidiDriver::getAvailableMidiDrivers(); @@ -402,99 +378,58 @@ int OptionsDialog::addAudioControls(GuiObject *boss, int yoffset, WidgetSize ws) } // Subtitles on/off - _subCheckbox = addCheckbox(boss, x, yoffset, "Display subtitles", 0, 0, ws); - yoffset += _subCheckbox->getHeight(); - - yoffset += 18; + _subCheckbox = new CheckboxWidget(boss, prefix + "auSubtitlesCheckbox", "Display subtitles", 0, 0); _enableAudioSettings = true; - - return yoffset; } -int OptionsDialog::addMIDIControls(GuiObject *boss, int yoffset, WidgetSize ws) { - const int x = 10; - int spacing; - int buttonWidth, buttonHeight; - - if (ws == kBigWidgetSize) { - buttonWidth = kBigButtonWidth; - buttonHeight = kBigButtonHeight; - spacing = 2; - } else { - buttonWidth = kButtonWidth; - buttonHeight = kButtonHeight; - spacing = 1; - } - +void OptionsDialog::addMIDIControls(GuiObject *boss, String prefix) { // SoundFont - _soundFontButton = addButton(boss, x, yoffset, "SoundFont:", kChooseSoundFontCmd, 0, ws); - _soundFont = new StaticTextWidget(boss, x + buttonWidth + 20, yoffset + 3, _w - (x + buttonWidth + 20) - 10, kLineHeight, "None", kTextAlignLeft, ws); - yoffset += buttonHeight + 2 * spacing; + _soundFontButton = new ButtonWidget(boss, prefix + "mcFontButton", "SoundFont:", kChooseSoundFontCmd, 0); + _soundFont = new StaticTextWidget(boss, prefix + "mcFontPath", "None", kTextAlignLeft); // Multi midi setting - _multiMidiCheckbox = addCheckbox(boss, x, yoffset, "Mixed Adlib/MIDI mode", 0, 0, ws); - yoffset += _multiMidiCheckbox->getHeight() + spacing; + _multiMidiCheckbox = new CheckboxWidget(boss, prefix + "mcMixedCheckbox", "Mixed Adlib/MIDI mode", 0, 0); // Native mt32 setting - _mt32Checkbox = addCheckbox(boss, x, yoffset, "True Roland MT-32 (disable GM emulation)", 0, 0, ws); - yoffset += _mt32Checkbox->getHeight() + spacing; + _mt32Checkbox = new CheckboxWidget(boss, prefix + "mcMt32Checkbox", "True Roland MT-32 (disable GM emulation)", 0, 0); // GS Extensions setting - _enableGSCheckbox = addCheckbox(boss, x, yoffset, "Enable Roland GS Mode", 0, 0, ws); - yoffset += _enableGSCheckbox->getHeight() + spacing; + _enableGSCheckbox = new CheckboxWidget(boss, prefix + "mcGSCheckbox", "Enable Roland GS Mode", 0, 0); _enableMIDISettings = true; - - return yoffset; } -int OptionsDialog::addVolumeControls(GuiObject *boss, int yoffset, WidgetSize ws) { +void OptionsDialog::addVolumeControls(GuiObject *boss, String prefix) { const char *slider_labels[] = { "Music volume:", "SFX volume:", "Speech volume:" }; - int textwidth = 0; - - for (int i = 0; i < ARRAYSIZE(slider_labels); i++) { - int width = g_gui.getStringWidth(slider_labels[i]); - - if (width > textwidth) - textwidth = width; - } - - int xoffset = textwidth + 15; - // Volume controllers - new StaticTextWidget(boss, 10, yoffset + 2, textwidth, kLineHeight, slider_labels[0], kTextAlignRight, ws); - _musicVolumeSlider = addSlider(boss, xoffset, yoffset, kMusicVolumeChanged, ws); - _musicVolumeLabel = new StaticTextWidget(boss, xoffset + _musicVolumeSlider->getWidth() + 10, yoffset + 2, 24, kLineHeight, "100%", kTextAlignLeft, ws); + new StaticTextWidget(boss, prefix + "vcMusicText", slider_labels[0], kTextAlignRight); + _musicVolumeSlider = new SliderWidget(boss, prefix + "vcMusicSlider", kMusicVolumeChanged); + _musicVolumeLabel = new StaticTextWidget(boss, prefix + "vcMusicLabel", "100%", kTextAlignLeft); _musicVolumeSlider->setMinValue(0); _musicVolumeSlider->setMaxValue(Audio::Mixer::kMaxMixerVolume); _musicVolumeLabel->setFlags(WIDGET_CLEARBG); - yoffset += _musicVolumeSlider->getHeight() + 4; - new StaticTextWidget(boss, 10, yoffset + 2, textwidth, kLineHeight, slider_labels[1], kTextAlignRight, ws); - _sfxVolumeSlider = addSlider(boss, xoffset, yoffset, kSfxVolumeChanged, ws); - _sfxVolumeLabel = new StaticTextWidget(boss, xoffset + _musicVolumeSlider->getWidth() + 10, yoffset + 2, 24, kLineHeight, "100%", kTextAlignLeft, ws); + new StaticTextWidget(boss, prefix + "vcSfxText", slider_labels[1], kTextAlignRight); + _sfxVolumeSlider = new SliderWidget(boss, prefix + "vcSfxSlider", kSfxVolumeChanged); + _sfxVolumeLabel = new StaticTextWidget(boss, prefix + "vcSfxLabel", "100%", kTextAlignLeft); _sfxVolumeSlider->setMinValue(0); _sfxVolumeSlider->setMaxValue(Audio::Mixer::kMaxMixerVolume); _sfxVolumeLabel->setFlags(WIDGET_CLEARBG); - yoffset += _sfxVolumeSlider->getHeight() + 4; - new StaticTextWidget(boss, 10, yoffset + 2, textwidth, kLineHeight, slider_labels[2], kTextAlignRight, ws); - _speechVolumeSlider = addSlider(boss, xoffset, yoffset, kSpeechVolumeChanged, ws); - _speechVolumeLabel = new StaticTextWidget(boss, xoffset + _musicVolumeSlider->getWidth() + 10, yoffset + 2, 24, kLineHeight, "100%", kTextAlignLeft, ws); + new StaticTextWidget(boss, prefix + "vcSpeechText" , slider_labels[2], kTextAlignRight); + _speechVolumeSlider = new SliderWidget(boss, prefix + "vcSpeechSlider", kSpeechVolumeChanged); + _speechVolumeLabel = new StaticTextWidget(boss, prefix + "vcSpeechLabel", "100%", kTextAlignLeft); _speechVolumeSlider->setMinValue(0); _speechVolumeSlider->setMaxValue(Audio::Mixer::kMaxMixerVolume); _speechVolumeLabel->setFlags(WIDGET_CLEARBG); - yoffset += _speechVolumeSlider->getHeight() + 4; _enableVolumeSettings = true; - - return yoffset; } #pragma mark - @@ -506,80 +441,81 @@ GlobalOptionsDialog::GlobalOptionsDialog() const int screenW = g_system->getOverlayWidth(); const int screenH = g_system->getOverlayHeight(); - GUI::WidgetSize ws; - int buttonWidth, buttonHeight; - if (screenW >= 400 && screenH >= 300) { - ws = GUI::kBigWidgetSize; - buttonWidth = kBigButtonWidth; - buttonHeight = kBigButtonHeight; _w = screenW - 2 * 10; _h = screenH - 2 * 40; _x = 10; _y = 40; } else { - ws = GUI::kNormalWidgetSize; - buttonWidth = kButtonWidth; - buttonHeight = kButtonHeight; _w = screenW - 2 * 10; _h = screenH - 1 * 20; _x = 10; _y = 20; } - const int vBorder = 5; // Tab border - int yoffset; + init(); +} + +GlobalOptionsDialog::GlobalOptionsDialog(String name) + : OptionsDialog(Common::ConfigManager::kApplicationDomain, name) { + init(); +} + +void GlobalOptionsDialog::init() { + const int screenW = g_system->getOverlayWidth(); + const int screenH = g_system->getOverlayHeight(); + + GUI::WidgetSize ws; + + if (screenW >= 400 && screenH >= 300) { + ws = GUI::kBigWidgetSize; + } else { + ws = GUI::kNormalWidgetSize; + } // The tab widget - TabWidget *tab = new TabWidget(this, 0, vBorder, _w, _h - buttonHeight - 8 - 2 * vBorder, ws); + TabWidget *tab = new TabWidget(this, "globaloptions_tabwidget"); tab->setHints(THEME_HINT_FIRST_DRAW | THEME_HINT_SAVE_BACKGROUND); // // 1) The graphics tab // tab->addTab("Graphics"); - yoffset = vBorder; - yoffset = addGraphicControls(tab, yoffset, ws); + addGraphicControls(tab, "globaloptions_"); // // 2) The audio tab // tab->addTab("Audio"); - yoffset = vBorder; - yoffset = addAudioControls(tab, yoffset, ws); - yoffset = addVolumeControls(tab, yoffset, ws); + addAudioControls(tab, "globaloptions_"); + addVolumeControls(tab, "globaloptions_"); // TODO: cd drive setting // // 3) The MIDI tab // tab->addTab("MIDI"); - yoffset = vBorder; - yoffset = addMIDIControls(tab, yoffset, ws); + addMIDIControls(tab, "globaloptions_"); // // 4) The miscellaneous tab // tab->addTab("Paths"); - yoffset = vBorder; #if !( defined(__DC__) || defined(__GP32__) ) // These two buttons have to be extra wide, or the text will be // truncated in the small version of the GUI. // Save game path - new ButtonWidget(tab, 5, yoffset, buttonWidth + 5, buttonHeight, "Save Path: ", kChooseSaveDirCmd, 0, ws); - _savePath = new StaticTextWidget(tab, 5 + buttonWidth + 20, yoffset + 3, _w - (5 + buttonWidth + 20) - 10, kLineHeight, "/foo/bar", kTextAlignLeft, ws); - yoffset += buttonHeight + 4; + new ButtonWidget(tab, "globaloptions_savebutton", "Save Path: ", kChooseSaveDirCmd, 0); + _savePath = new StaticTextWidget(tab, "globaloptions_savepath", "/foo/bar", kTextAlignLeft); - new ButtonWidget(tab, 5, yoffset, buttonWidth + 5, buttonHeight, "Extra Path:", kChooseExtraDirCmd, 0, ws); - _extraPath = new StaticTextWidget(tab, 5 + buttonWidth + 20, yoffset + 3, _w - (5 + buttonWidth + 20) - 10, kLineHeight, "None", kTextAlignLeft, ws); - yoffset += buttonHeight + 4; + new ButtonWidget(tab, "globaloptions_extrabutton", "Extra Path:", kChooseExtraDirCmd, 0); + _extraPath = new StaticTextWidget(tab, "globaloptions_extrapath", "None", kTextAlignLeft); #endif #ifdef SMALL_SCREEN_DEVICE - addButton(tab, 5, yoffset, "Keys", kChooseKeyMappingCmd, 0, ws); - yoffset += buttonHeight + 4; + new ButtonWidget(tab, "globaloptions_keysbutton", "Keys", kChooseKeyMappingCmd, 0); #endif // TODO: joystick setting @@ -589,8 +525,8 @@ GlobalOptionsDialog::GlobalOptionsDialog() tab->setActiveTab(0); // Add OK & Cancel buttons - addButton(this, _w - 2 * (buttonWidth + 10), _h - buttonHeight - 8, "Cancel", kCloseCmd, 0, ws); - addButton(this, _w - (buttonWidth + 10), _h - buttonHeight - 8, "OK", kOKCmd, 0, ws); + new ButtonWidget(this, "globaloptions_cancel", "Cancel", kCloseCmd, 0); + new ButtonWidget(this, "globaloptions_ok", "OK", kOKCmd, 0); #ifdef SMALL_SCREEN_DEVICE _keysDialog = new KeysDialog(); diff --git a/gui/options.h b/gui/options.h index 7ea4f09170..d3cc5b5a84 100644 --- a/gui/options.h +++ b/gui/options.h @@ -60,10 +60,10 @@ protected: ButtonWidget *_soundFontButton; StaticTextWidget *_soundFont; - int addGraphicControls(GuiObject *boss, int yoffset, WidgetSize ws); - int addAudioControls(GuiObject *boss, int yoffset, WidgetSize ws); - int addMIDIControls(GuiObject *boss, int yoffset, WidgetSize ws); - int addVolumeControls(GuiObject *boss, int yoffset, WidgetSize ws); + void addGraphicControls(GuiObject *boss, String prefix); + void addAudioControls(GuiObject *boss, String prefix); + void addMIDIControls(GuiObject *boss, String prefix); + void addVolumeControls(GuiObject *boss, String prefix); void setGraphicSettingsState(bool enabled); void setAudioSettingsState(bool enabled); @@ -115,8 +115,10 @@ class GlobalOptionsDialog : public OptionsDialog { typedef Common::String String; public: GlobalOptionsDialog(); + GlobalOptionsDialog(String name); ~GlobalOptionsDialog(); + void init(); void open(); void close(); void handleCommand(CommandSender *sender, uint32 cmd, uint32 data); diff --git a/gui/theme-config.cpp b/gui/theme-config.cpp index 65230d0bf5..4249fd882c 100644 --- a/gui/theme-config.cpp +++ b/gui/theme-config.cpp @@ -27,38 +27,159 @@ namespace GUI { const char *Theme::_defaultConfigINI = "\n\ # Define our classic greenish theme here\n\ [320xY]\n\ +def_widgetSize=kNormalWidgetSize\n\ +def_buttonWidth=kButtonWidth\n\ def_buttonHeight=kButtonHeight\n\ +def_sliderWidth=kSliderWidth\n\ +def_sliderHeight=kSliderHeight\n\ def_kLineHeight=12\n\ +def_kFontHeight=10\n\ +def_globOptionsW=(w - 2 * 10)\n\ +def_globOptionsH=(h - 1 * 40)\n\ +def_tabPopupsLabelW=100\n\ +def_midiControlsSpacing=1\n\ use=XxY\n\ \n\ [XxY]\n\ +def_widgetSize=kBigWidgetSize\n\ +def_buttonWidth=kBigButtonWidth\n\ def_buttonHeight=kBigButtonHeight\n\ +def_sliderWidth=kBigSliderWidth\n\ +def_sliderHeight=kBigSliderHeight\n\ def_kLineHeight=16\n\ +def_kFontHeight=14\n\ +def_globOptionsW=(w - 2 * 10)\n\ +def_globOptionsH=(h - 2 * 40)\n\ +def_tabPopupsLabelW=150\n\ +def_midiControlsSpacing=2\n\ chooser_headline=10 6 (w - 2 * 16) (kLineHeight)\n\ chooser_list=10 (6 + kLineHeight + 2) (w - 2 * 16) (h - self.y - buttonHeight - 12)\n\ +\n\ +## launcher\n\ hBorder=10\n\ launcher_version=hBorder 8 (w - 2 * hBorder) kLineHeight\n\ top=(h - 8 - buttonHeight)\n\ numButtons=4\n\ space=8\n\ -buttonWidth=((w - 2 * hBorder - space * (numButtons - 1)) / numButtons)\n\ -launcher_quit_button=hBorder top buttonWidth buttonHeight\n\ -launcher_about_button=(prev.x2 + space) top buttonWidth buttonHeight\n\ -launcher_options_button=(prev.x2 + space) top buttonWidth buttonHeight\n\ -launcher_start_button=(prev.x2 + space) top buttonWidth buttonHeight\n\ +butWidth=((w - 2 * hBorder - space * (numButtons - 1)) / numButtons)\n\ +launcher_quit_button=hBorder top butWidth buttonHeight\n\ +launcher_about_button=(prev.x2 + space) top butWidth buttonHeight\n\ +launcher_options_button=(prev.x2 + space) top butWidth buttonHeight\n\ +launcher_start_button=(prev.x2 + space) top butWidth buttonHeight\n\ top=(top - buttonHeight * 2)\n\ numButtons=3\n\ space=10\n\ -buttonWidth=((w - 2 * hBorder - space * (numButtons - 1)) / numButtons)\n\ -launcher_addGame_button=hBorder top buttonWidth buttonHeight\n\ -launcher_editGame_button=(prev.x2 + space) top buttonWidth buttonHeight\n\ -launcher_removeGame_button=(prev.x2 + space) top buttonWidth buttonHeight\n\ +butWidth=((w - 2 * hBorder - space * (numButtons - 1)) / numButtons)\n\ +launcher_addGame_button=hBorder top butWidth buttonHeight\n\ +launcher_editGame_button=(prev.x2 + space) top butWidth buttonHeight\n\ +launcher_removeGame_button=(prev.x2 + space) top butWidth buttonHeight\n\ launcher_list=hBorder (kLineHeight + 16) (w - 2 * hBorder) (top - kLineHeight - 20)\n\ +\n\ +# global options\n\ +globaloptions=10 40 globOptionsW globOptionsH\n\ +set_parent=globaloptions\n\ +vBorder=5\n\ +globaloptions_tabwidget=0, vBorder parent.w (parent.h - buttonHeight -8 - 2 * vBorder)\n\ +\n\ +# graphics tab\n\ +opYoffset=vBorder\n\ +opWidth=globOptionsW\n\ +useWithPrefix=graphicsControls globaloptions_\n\ +\n\ +# audio tab\n\ +opYoffset=vBorder\n\ +opWidth=globOptionsW\n\ +useWithPrefix=audioControls globaloptions_\n\ +useWithPrefix=volumeControls globaloptions_\n\ +\n\ +# MIDI tab\n\ +opYoffset=vBorder\n\ +opWidth=globOptionsW\n\ +useWithPrefix=midiControls globaloptions_\n\ +\n\ +# paths tab\n\ +yoffset=vBorder\n\ +globaloptions_savebutton=5 yoffset (buttonWidth + 5) buttonHeight\n\ +globaloptions_savepath=(prev.x2 + 20) (vBorder + 3) (parent.w - (5 + buttonWidth + 20) - 10) kLineHeight\n\ +yoffset=(yoffset + buttonHeight + 4)\n\ +globaloptions_extrabutton=5 yoffset (buttonWidth + 5) buttonHeight\n\ +globaloptions_extrapath=(prev.x2 + 20) (vBorder + 3) (parent.w - (5 + buttonWidth + 20) - 10) kLineHeight\n\ +yoffset=(yoffset + buttonHeight + 4)\n\ +globaloptions_keysbutton=5 yoffset buttonWidth buttonHeight\n\ +\n\ +globaloptions_ok=(parent.w - (buttonWidth + 10)) (parent.h - buttonHeight - 8) buttonWidth buttonHeight\n\ +globaloptions_cancel=(parent.w - 2 * (buttonWidth + 10)) (parent.h - buttonHeight - 8) buttonWidth buttonHeight\n\ +\n\ +# game options\n\ +opYoffset=(vBorder + buttonHeight)\n\ +opWidth=globOptionsW\n\ +useWithPrefix=graphicsControls gameoptions_\n\ +\n\ +opYoffset=(vBorder + buttonHeight)\n\ +useWithPrefix=audioControls gameoptions_\n\ +\n\ +opYoffset=(vBorder + buttonHeight)\n\ +useWithPrefix=volumeControls gameoptions_\n\ +\n\ +opYoffset=(vBorder + buttonHeight)\n\ +useWithPrefix=midiControls gameoptions_\n\ +\n\ +### SCUMM game options\n\ +opYoffset=8\n\ +useWithPrefix=volumeControls scummoptions_\n\ +\n\ +[graphicsControls]\n\ +gcx=10\n\ +gcw=(opWidth - 2 * 10)\n\ +grModePopup=(gcx - 5) opYoffset (gcw + 5) kLineHeight\n\ +opYoffset=(opYoffset + kLineHeight + 4)\n\ +grRenderPopup=(gcx - 5) opYoffset (gcw + 5) kLineHeight\n\ +opYoffset=(opYoffset + kLineHeight + 4)\n\ +grFullscreenCheckbox=gcx opYoffset (kFontHeight + 10 + 96) buttonHeight\n\ +opYoffset=(opYoffset + buttonHeight)\n\ +grAspectCheckbox=gcx opYoffset (kFontHeight + 10 + 136) buttonHeight\n\ +opYoffset=(opYoffset + buttonHeight)\n\ +\n\ +[audioControls]\n\ +aux=10\n\ +auw=(opWidth - 2 * 10)\n\ +auMidiPopup=(aux - 5) opYoffset (auw + 5) kLineHeight\n\ +opYoffset=(opYoffset + kLineHeight + 4)\n\ +auSubtitlesCheckbox=aux opYoffset (kFontHeight + 10 + 102) buttonHeight\n\ +opYoffset=(opYoffset + buttonHeight + 18)\n\ +\n\ +[volumeControls]\n\ +vctextw=95\n\ +vcxoff=(vctextw + 15)\n\ +vcMusicText=10 (opYoffset + 2) vctextw kLineHeight\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\ +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\ +vcSpeechSlider=vcxoff opYoffset sliderWidth sliderHeight\n\ +vcSpeechLabel=(vcxoff + prev.w + 10) (opYoffset + 2) 24 kLineHeight\n\ +opYoffset=(opYoffset + sliderHeight + 4)\n\ +\n\ +[midiControls]\n\ +mcx=10\n\ +mcFontButton=mcx opYoffset buttonWidth buttonHeight\n\ +mcFontPath=(prev.x2 + 20) (opYoffset + 3) (opWidth - (buttonWidth + 20) - 10) kLineHeight\n\ +opYoffset=(opYoffset + buttonHeight + 2 * midiControlsSpacing)\n\ +mcMixedCheckbox=mcx opYoffset (kFontHeight + 10 + 135) buttonHeight\n\ +opYoffset=(opYoffset + buttonHeight + midiControlsSpacing)\n\ +mcMt32Checkbox=mcx opYoffset (kFontHeight + 10 + 256) buttonHeight\n\ +opYoffset=(opYoffset + buttonHeight + midiControlsSpacing)\n\ +mcGSCheckbox=mcx opYoffset (kFontHeight + 10 + 142) buttonHeight\n\ +opYoffset=(opYoffset + buttonHeight + midiControlsSpacing)\n\ "; using Common::String; -void Theme::processSingleLine(const String §ion, const String name, const String str) { +void Theme::processSingleLine(const String §ion, const String prefix, const String name, const String str) { int level = 0; int start = 0; uint i; @@ -71,7 +192,7 @@ void Theme::processSingleLine(const String §ion, const String name, const St String from, to; from = String("self.") + postfixes[i]; - to = name + "." + postfixes[i]; + to = prefix + name + "." + postfixes[i]; _evaluator->setAlias(from, to); _evaluator->setVariable(to, EVAL_UNDEF_VAR); @@ -80,7 +201,7 @@ void Theme::processSingleLine(const String §ion, const String name, const St 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, start); - _evaluator->setVariable(name + "." + postfixes[npostfix++], value); + _evaluator->setVariable(prefix + name + "." + postfixes[npostfix++], value); start = i + 1; } if (str[i] == '(') @@ -105,18 +226,18 @@ void Theme::processSingleLine(const String §ion, const String name, const St if (npostfix == 0) _evaluator->setVariable(name, value); else - _evaluator->setVariable(name + "." + postfixes[npostfix], value); + _evaluator->setVariable(prefix + name + "." + postfixes[npostfix], value); // If we have all 4 parameters, set .x2 and .y2 if (npostfix == 3) { - _evaluator->setVariable(name + ".x2", _evaluator->getVar(name + ".x") + - _evaluator->getVar(name + ".w")); - _evaluator->setVariable(name + ".y2", _evaluator->getVar(name + ".y") + - _evaluator->getVar(name + ".h")); + _evaluator->setVariable(prefix + name + ".x2", + _evaluator->getVar(prefix + name + ".x") + _evaluator->getVar(prefix + name + ".w")); + _evaluator->setVariable(prefix + name + ".y2", + _evaluator->getVar(prefix +name + ".y") + _evaluator->getVar(prefix + name + ".h")); } if (npostfix != 0) - setSpecialAlias("prev", name); + setSpecialAlias("prev", prefix + name); } @@ -166,7 +287,7 @@ void Theme::processResSection(Common::ConfigFile &config, String name, bool skip processResSection(config, n, true, pref); continue; } - processSingleLine(name, prefix + iterk->key, iterk->value); + processSingleLine(name, prefix, iterk->key, iterk->value); } } diff --git a/gui/theme.h b/gui/theme.h index 26190df436..f6a5d8c40d 100644 --- a/gui/theme.h +++ b/gui/theme.h @@ -31,6 +31,7 @@ #include "graphics/surface.h" #include "graphics/fontman.h" +#include "gui/widget.h" #include "gui/eval.h" namespace GUI { @@ -170,7 +171,7 @@ public: } void processResSection(Common::ConfigFile &config, String name, bool skipDefs = false, const String prefix = ""); - void processSingleLine(const String §ion, const String name, const String str); + void processSingleLine(const String §ion, const String prefix, const String name, const String str); void setSpecialAlias(const String alias, const String &name); bool isThemeLoadingRequired(); diff --git a/gui/themes/default-theme.ini b/gui/themes/default-theme.ini index 72c66d866f..3b6e0a034b 100644 --- a/gui/themes/default-theme.ini +++ b/gui/themes/default-theme.ini @@ -131,30 +131,151 @@ shadow_top_height=2 pshadow_bottom_height=4 [320xY] +def_widgetSize=kNormalWidgetSize +def_buttonWidth=kButtonWidth def_buttonHeight=kButtonHeight +def_sliderWidth=kSliderWidth +def_sliderHeight=kSliderHeight def_kLineHeight=12 +def_kFontHeight=10 +def_globOptionsW=(w - 2 * 10) +def_globOptionsH=(h - 1 * 40) +def_tabPopupsLabelW=100 +def_midiControlsSpacing=1 use=XxY [XxY] +def_widgetSize=kBigWidgetSize +def_buttonWidth=kBigButtonWidth def_buttonHeight=kBigButtonHeight +def_sliderWidth=kBigSliderWidth +def_sliderHeight=kBigSliderHeight def_kLineHeight=16 +def_kFontHeight=14 +def_globOptionsW=(w - 2 * 10) +def_globOptionsH=(h - 2 * 40) +def_tabPopupsLabelW=150 +def_midiControlsSpacing=2 chooser_headline=10 6 (w - 2 * 16) (kLineHeight) chooser_list=10 (6 + kLineHeight + 2) (w - 2 * 16) (h - self.y - buttonHeight - 12) + +## launcher hBorder=10 launcher_version=hBorder 8 (w - 2 * hBorder) kLineHeight top=(h - 8 - buttonHeight) numButtons=4 space=8 -buttonWidth=((w - 2 * hBorder - space * (numButtons - 1)) / numButtons) -launcher_quit_button=hBorder top buttonWidth buttonHeight -launcher_about_button=(prev.x2 + space) top buttonWidth buttonHeight -launcher_options_button=(prev.x2 + space) top buttonWidth buttonHeight -launcher_start_button=(prev.x2 + space) top buttonWidth buttonHeight +butWidth=((w - 2 * hBorder - space * (numButtons - 1)) / numButtons) +launcher_quit_button=hBorder top butWidth buttonHeight +launcher_about_button=(prev.x2 + space) top butWidth buttonHeight +launcher_options_button=(prev.x2 + space) top butWidth buttonHeight +launcher_start_button=(prev.x2 + space) top butWidth buttonHeight top=(top - buttonHeight * 2) numButtons=3 space=10 -buttonWidth=((w - 2 * hBorder - space * (numButtons - 1)) / numButtons) -launcher_addGame_button=hBorder top buttonWidth buttonHeight -launcher_editGame_button=(prev.x2 + space) top buttonWidth buttonHeight -launcher_removeGame_button=(prev.x2 + space) top buttonWidth buttonHeight +butWidth=((w - 2 * hBorder - space * (numButtons - 1)) / numButtons) +launcher_addGame_button=hBorder top butWidth buttonHeight +launcher_editGame_button=(prev.x2 + space) top butWidth buttonHeight +launcher_removeGame_button=(prev.x2 + space) top butWidth buttonHeight launcher_list=hBorder (kLineHeight + 16) (w - 2 * hBorder) (top - kLineHeight - 20) + +# global options +globaloptions=10 40 globOptionsW globOptionsH +set_parent=globaloptions +vBorder=5 +globaloptions_tabwidget=0, vBorder parent.w (parent.h - buttonHeight -8 - 2 * vBorder) + +# graphics tab +opYoffset=vBorder +opWidth=globOptionsW +useWithPrefix=graphicsControls globaloptions_ + +# audio tab +opYoffset=vBorder +opWidth=globOptionsW +useWithPrefix=audioControls globaloptions_ +useWithPrefix=volumeControls globaloptions_ + +# MIDI tab +opYoffset=vBorder +opWidth=globOptionsW +useWithPrefix=midiControls globaloptions_ + +# paths tab +yoffset=vBorder +globaloptions_savebutton=5 yoffset (buttonWidth + 5) buttonHeight +globaloptions_savepath=(prev.x2 + 20) (vBorder + 3) (parent.w - (5 + buttonWidth + 20) - 10) kLineHeight +yoffset=(yoffset + buttonHeight + 4) +globaloptions_extrabutton=5 yoffset (buttonWidth + 5) buttonHeight +globaloptions_extrapath=(prev.x2 + 20) (vBorder + 3) (parent.w - (5 + buttonWidth + 20) - 10) kLineHeight +yoffset=(yoffset + buttonHeight + 4) +globaloptions_keysbutton=5 yoffset buttonWidth buttonHeight + +globaloptions_ok=(parent.w - (buttonWidth + 10)) (parent.h - buttonHeight - 8) buttonWidth buttonHeight +globaloptions_cancel=(parent.w - 2 * (buttonWidth + 10)) (parent.h - buttonHeight - 8) buttonWidth buttonHeight + +# game options +opYoffset=(vBorder + buttonHeight) +opWidth=globOptionsW +useWithPrefix=graphicsControls gameoptions_ + +opYoffset=(vBorder + buttonHeight) +useWithPrefix=audioControls gameoptions_ + +opYoffset=(vBorder + buttonHeight) +useWithPrefix=volumeControls gameoptions_ + +opYoffset=(vBorder + buttonHeight) +useWithPrefix=midiControls gameoptions_ + +### SCUMM game options +opYoffset=8 +useWithPrefix=volumeControls scummoptions_ + +[graphicsControls] +gcx=10 +gcw=(opWidth - 2 * 10) +grModePopup=(gcx - 5) opYoffset (gcw + 5) kLineHeight +opYoffset=(opYoffset + kLineHeight + 4) +grRenderPopup=(gcx - 5) opYoffset (gcw + 5) kLineHeight +opYoffset=(opYoffset + kLineHeight + 4) +grFullscreenCheckbox=gcx opYoffset (kFontHeight + 10 + 96) buttonHeight +opYoffset=(opYoffset + buttonHeight) +grAspectCheckbox=gcx opYoffset (kFontHeight + 10 + 136) buttonHeight +opYoffset=(opYoffset + buttonHeight) + +[audioControls] +aux=10 +auw=(opWidth - 2 * 10) +auMidiPopup=(aux - 5) opYoffset (auw + 5) kLineHeight +opYoffset=(opYoffset + kLineHeight + 4) +auSubtitlesCheckbox=aux opYoffset (kFontHeight + 10 + 102) buttonHeight +opYoffset=(opYoffset + buttonHeight + 18) + +[volumeControls] +vctextw=95 +vcxoff=(vctextw + 15) +vcMusicText=10 (opYoffset + 2) vctextw kLineHeight +vcMusicSlider=vcxoff opYoffset sliderWidth sliderHeight +vcMusicLabel=(vcxoff + prev.w + 10) (opYoffset + 2) 24 kLineHeight +opYoffset=(opYoffset + sliderHeight + 4) +vcSfxText=10 (opYoffset + 2) vctextw kLineHeight +vcSfxSlider=vcxoff opYoffset sliderWidth sliderHeight +vcSfxLabel=(vcxoff + prev.w + 10) (opYoffset + 2) 24 kLineHeight +opYoffset=(opYoffset + sliderHeight + 4) +vcSpeechText=10 (opYoffset + 2) vctextw kLineHeight +vcSpeechSlider=vcxoff opYoffset sliderWidth sliderHeight +vcSpeechLabel=(vcxoff + prev.w + 10) (opYoffset + 2) 24 kLineHeight +opYoffset=(opYoffset + sliderHeight + 4) + +[midiControls] +mcx=10 +mcFontButton=mcx opYoffset buttonWidth buttonHeight +mcFontPath=(prev.x2 + 20) (opYoffset + 3) (opWidth - (buttonWidth + 20) - 10) kLineHeight +opYoffset=(opYoffset + buttonHeight + 2 * midiControlsSpacing) +mcMixedCheckbox=mcx opYoffset (kFontHeight + 10 + 135) buttonHeight +opYoffset=(opYoffset + buttonHeight + midiControlsSpacing) +mcMt32Checkbox=mcx opYoffset (kFontHeight + 10 + 256) buttonHeight +opYoffset=(opYoffset + buttonHeight + midiControlsSpacing) +mcGSCheckbox=mcx opYoffset (kFontHeight + 10 + 142) buttonHeight +opYoffset=(opYoffset + buttonHeight + midiControlsSpacing) diff --git a/gui/widget.cpp b/gui/widget.cpp index 87aeb4db56..21b18a1f1b 100644 --- a/gui/widget.cpp +++ b/gui/widget.cpp @@ -130,8 +130,9 @@ 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, WidgetSize ws) - : Widget(boss, name), _align(align), _ws(ws) { +StaticTextWidget::StaticTextWidget(GuiObject *boss, String name, const String &text, TextAlignment align) + : Widget(boss, name), _align(align) { + _ws = g_gui.getWidgetSize(); _flags = WIDGET_ENABLED; _type = kStaticTextWidget; _label = text; @@ -174,8 +175,8 @@ ButtonWidget::ButtonWidget(GuiObject *boss, int x, int y, int w, int h, const St _type = kButtonWidget; } -ButtonWidget::ButtonWidget(GuiObject *boss, String name, const String &label, uint32 cmd, uint8 hotkey, WidgetSize ws) - : StaticTextWidget(boss, name, label, kTextAlignCenter, ws), CommandSender(boss), +ButtonWidget::ButtonWidget(GuiObject *boss, String name, const String &label, uint32 cmd, uint8 hotkey) + : StaticTextWidget(boss, name, label, kTextAlignCenter), CommandSender(boss), _cmd(cmd), _hotkey(hotkey) { _flags = WIDGET_ENABLED/* | WIDGET_BORDER*/ | WIDGET_CLEARBG; _type = kButtonWidget; @@ -198,6 +199,12 @@ CheckboxWidget::CheckboxWidget(GuiObject *boss, int x, int y, int w, int h, cons _type = kCheckboxWidget; } +CheckboxWidget::CheckboxWidget(GuiObject *boss, String name, const String &label, uint32 cmd, uint8 hotkey) + : ButtonWidget(boss, name, label, cmd, hotkey), _state(false) { + _flags = WIDGET_ENABLED; + _type = kCheckboxWidget; +} + void CheckboxWidget::handleMouseUp(int x, int y, int button, int clickCount) { if (isEnabled() && x >= 0 && x < _w && y >= 0 && y < _h) { toggleState(); @@ -227,6 +234,13 @@ SliderWidget::SliderWidget(GuiObject *boss, int x, int y, int w, int h, uint32 c _type = kSliderWidget; } +SliderWidget::SliderWidget(GuiObject *boss, String name, uint32 cmd) + : Widget(boss, name), CommandSender(boss), + _cmd(cmd), _value(0), _oldValue(0), _valueMin(0), _valueMax(100), _isDragging(false) { + _flags = WIDGET_ENABLED | WIDGET_TRACK_MOUSE | WIDGET_CLEARBG; + _type = kSliderWidget; +} + void SliderWidget::handleMouseMoved(int x, int y, int button) { if (isEnabled() && _isDragging && x >= 0) { int newValue = posToValue(x); diff --git a/gui/widget.h b/gui/widget.h index 4f54b5708c..17ad52221a 100644 --- a/gui/widget.h +++ b/gui/widget.h @@ -161,10 +161,10 @@ protected: String _label; TextAlignment _align; - const WidgetSize _ws; + WidgetSize _ws; public: StaticTextWidget(GuiObject *boss, int x, int y, int w, int h, const String &text, TextAlignment align, WidgetSize ws = kDefaultWidgetSize); - StaticTextWidget(GuiObject *boss, String name, const String &text, TextAlignment align, WidgetSize ws = kDefaultWidgetSize); + StaticTextWidget(GuiObject *boss, String name, const String &text, TextAlignment align); void setValue(int value); void setLabel(const String &label); const String &getLabel() const { return _label; } @@ -183,7 +183,7 @@ protected: uint8 _hotkey; public: ButtonWidget(GuiObject *boss, int x, int y, int w, int h, const String &label, uint32 cmd = 0, uint8 hotkey = 0, WidgetSize ws = kDefaultWidgetSize); - ButtonWidget(GuiObject *boss, String name, const String &label, uint32 cmd = 0, uint8 hotkey = 0, WidgetSize ws = kDefaultWidgetSize); + ButtonWidget(GuiObject *boss, String name, const String &label, uint32 cmd = 0, uint8 hotkey = 0); void setCmd(uint32 cmd) { _cmd = cmd; } uint32 getCmd() const { return _cmd; } @@ -202,6 +202,7 @@ protected: bool _state; public: CheckboxWidget(GuiObject *boss, int x, int y, int w, int h, const String &label, uint32 cmd = 0, uint8 hotkey = 0, WidgetSize ws = kDefaultWidgetSize); + CheckboxWidget(GuiObject *boss, String name, const String &label, uint32 cmd = 0, uint8 hotkey = 0); void handleMouseUp(int x, int y, int button, int clickCount); virtual void handleMouseEntered(int button) { setFlags(WIDGET_HILITED); draw(); } @@ -225,6 +226,7 @@ protected: uint _labelWidth; public: SliderWidget(GuiObject *boss, int x, int y, int w, int h, uint32 cmd = 0); + SliderWidget(GuiObject *boss, Common::String name, uint32 cmd = 0); void setCmd(uint32 cmd) { _cmd = cmd; } uint32 getCmd() const { return _cmd; } |