Options menu layout parsing, featuring the brand new FATPOPUPS.

svn-id: r33651
This commit is contained in:
Vicent Marti 2008-08-05 23:58:45 +00:00
parent eb3d163439
commit 4256c35791
11 changed files with 117 additions and 37 deletions

View file

@ -157,15 +157,26 @@ void ThemeEval::addWidget(const Common::String &name, int w, int h) {
_curLayout.top()->addChild(widget); _curLayout.top()->addChild(widget);
} }
void ThemeEval::addDialog(const Common::String &name) { void ThemeEval::addDialog(const Common::String &name, const Common::String &overlays) {
ThemeLayout *layout = new ThemeLayoutMain(); ThemeLayout *layout = new ThemeLayoutMain();
_layouts[name] = layout; _layouts[name] = layout;
int16 x, y;
uint16 w, h;
layout->setX(0); if (overlays == "screen" || overlays.empty()) {
layout->setY(0); x = y = 0;
layout->setWidth(g_system->getOverlayWidth()); w = g_system->getOverlayWidth();
layout->setHeight(g_system->getOverlayHeight()); h = g_system->getOverlayHeight();
} else if (!getWidgetData(overlays, x, y, w, h)) {
error("Error when loading dialog position for '%s'", overlays.c_str());
}
layout->setX(x);
layout->setY(y);
layout->setWidth(w);
layout->setHeight(h);
layout->setPadding( layout->setPadding(
getVar("Globals.Padding.Left", 0), getVar("Globals.Padding.Left", 0),
getVar("Globals.Padding.Right", 0), getVar("Globals.Padding.Right", 0),

View file

@ -146,6 +146,13 @@ public:
virtual const char *getName() { return _name.c_str(); } virtual const char *getName() { return _name.c_str(); }
virtual bool getWidgetData(const Common::String &name, int16 &x, int16 &y, uint16 &w, uint16 &h); virtual bool getWidgetData(const Common::String &name, int16 &x, int16 &y, uint16 &w, uint16 &h);
virtual bool getDialogData(int16 &x, int16 &y, uint16 &w, uint16 &h) {
assert(getLayoutType() == kLayoutMain);
x = _x; y = _y;
w = _w; h = _h;
return true;
}
protected: protected:
int16 _x, _y, _w, _h; int16 _x, _y, _w, _h;
@ -246,7 +253,7 @@ public:
bool hasVar(const Common::String &name) { return _vars.contains(name); } bool hasVar(const Common::String &name) { return _vars.contains(name); }
void addDialog(const Common::String &name); void addDialog(const Common::String &name, const Common::String &overlays);
void addLayout(ThemeLayout::LayoutType type, bool reverse, bool center = false); void addLayout(ThemeLayout::LayoutType type, bool reverse, bool center = false);
void addWidget(const Common::String &name, int w, int h); void addWidget(const Common::String &name, int w, int h);
void addSpacing(int size); void addSpacing(int size);
@ -261,10 +268,17 @@ public:
bool getWidgetData(const Common::String &widget, int16 &x, int16 &y, uint16 &w, uint16 &h) { bool getWidgetData(const Common::String &widget, int16 &x, int16 &y, uint16 &w, uint16 &h) {
Common::StringTokenizer tokenizer(widget, "."); Common::StringTokenizer tokenizer(widget, ".");
Common::String dialogName = "Dialog." + tokenizer.nextToken(); Common::String dialogName = "Dialog." + tokenizer.nextToken();
if (dialogName == "Dialog.Dialog")
dialogName = "Dialog." + tokenizer.nextToken();
Common::String widgetName = tokenizer.nextToken(); Common::String widgetName = tokenizer.nextToken();
if (!_layouts.contains(dialogName)) if (!_layouts.contains(dialogName))
return false; return false;
if (widgetName.empty())
return _layouts[dialogName]->getDialogData(x, y, w, h);
return _layouts[dialogName]->getWidgetData(widgetName, x, y, w, h); return _layouts[dialogName]->getWidgetData(widgetName, x, y, w, h);
} }
@ -279,7 +293,8 @@ public:
} }
void debugDraw(Graphics::Surface *screen, const Graphics::Font *font) { void debugDraw(Graphics::Surface *screen, const Graphics::Font *font) {
_layouts["Dialog.Launcher"]->debugDraw(screen, font); _layouts["Dialog.GlobalOptions"]->debugDraw(screen, font);
_layouts["Dialog.GlobalOptions_Graphics"]->debugDraw(screen, font);
} }
private: private:

View file

@ -493,7 +493,7 @@ bool ThemeParser::parserCallback_child(ParserNode *node) {
bool ThemeParser::parserCallback_dialog(ParserNode *node) { bool ThemeParser::parserCallback_dialog(ParserNode *node) {
Common::String var = "Dialog." + node->values["name"]; Common::String var = "Dialog." + node->values["name"];
_theme->themeEval()->addDialog(var); _theme->themeEval()->addDialog(var, node->values["overlays"]);
return true; return true;
} }

View file

@ -435,6 +435,7 @@ protected:
XML_KEY(dialog) XML_KEY(dialog)
XML_PROP(name, true) XML_PROP(name, true)
XML_PROP(overlays, true)
XML_KEY(layout) XML_KEY(layout)
XML_PROP(type, true) XML_PROP(type, true)
XML_PROP(center, false) XML_PROP(center, false)

View file

@ -695,9 +695,9 @@ void ThemeRenderer::updateScreen() {
renderDirtyScreen(); renderDirtyScreen();
// _vectorRenderer->fillSurface(); // _vectorRenderer->fillSurface();
// themeEval()->debugDraw(_screen, _font); // themeEval()->debugDraw(_screen, _font);
// _vectorRenderer->copyWholeFrame(_system); // _vectorRenderer->copyWholeFrame(_system);
} }
void ThemeRenderer::renderDirtyScreen() { void ThemeRenderer::renderDirtyScreen() {

View file

@ -150,7 +150,7 @@ void Dialog::drawDialog() {
// Draw all children // Draw all children
Widget *w = _firstWidget; Widget *w = _firstWidget;
while (w) { while (w) {
w->draw(); if (w->_debugVisible) w->draw();
w = w->_next; w = w->_next;
} }
} }

View file

@ -58,8 +58,20 @@ enum {
void GuiObject::reflowLayout() { void GuiObject::reflowLayout() {
if (!_name.empty()) { if (!_name.empty()) {
if (!g_gui.xmlEval()->getWidgetData(_name, _x, _y, _w, _h)) if (!g_gui.xmlEval()->getWidgetData(_name, _x, _y, _w, _h)) {
error("Could not load widget position for '%s'", _name.c_str()); warning("Could not load widget position for '%s'", _name.c_str());
// if ((_x = g_gui.evaluator()->getVar(_name + ".x")) == EVAL_UNDEF_VAR)
// error("Undefined variable %s.x", _name.c_str());
// if ((_y = g_gui.evaluator()->getVar(_name + ".y")) == EVAL_UNDEF_VAR)
// error("Undefined variable %s.y", _name.c_str());
// _w = g_gui.evaluator()->getVar(_name + ".w");
// _h = g_gui.evaluator()->getVar(_name + ".h");
_w = _x = _y = _h = 32;
_debugVisible = false;
}
_debugVisible = true;
if (_x < 0) if (_x < 0)
error("Widget <%s> has x < 0: %d", _name.c_str(), _x); error("Widget <%s> has x < 0: %d", _name.c_str(), _x);

View file

@ -78,7 +78,10 @@ public:
virtual uint16 getWidth() const { return _w; } virtual uint16 getWidth() const { return _w; }
virtual uint16 getHeight() const { return _h; } virtual uint16 getHeight() const { return _h; }
// Tanoku-TODO: fix this back
virtual bool isVisible() const = 0; virtual bool isVisible() const = 0;
bool _debugVisible;
virtual void draw() = 0; virtual void draw() = 0;

View file

@ -659,27 +659,27 @@ void OptionsDialog::reflowLayout() {
GlobalOptionsDialog::GlobalOptionsDialog() GlobalOptionsDialog::GlobalOptionsDialog()
: OptionsDialog(Common::ConfigManager::kApplicationDomain, "globaloptions") { : OptionsDialog(Common::ConfigManager::kApplicationDomain, "GlobalOptions") {
// The tab widget // The tab widget
TabWidget *tab = new TabWidget(this, "globaloptions_tabwidget"); TabWidget *tab = new TabWidget(this, "GlobalOptions.TabWidget");
tab->setHints(THEME_HINT_FIRST_DRAW | THEME_HINT_SAVE_BACKGROUND); tab->setHints(THEME_HINT_FIRST_DRAW | THEME_HINT_SAVE_BACKGROUND);
// //
// 1) The graphics tab // 1) The graphics tab
// //
tab->addTab("Graphics"); tab->addTab("Graphics");
addGraphicControls(tab, "globaloptions_"); addGraphicControls(tab, "GlobalOptions_Graphics.");
// //
// 2) The audio tab // 2) The audio tab
// //
tab->addTab("Audio"); tab->addTab("Audio");
addAudioControls(tab, "globaloptions_"); addAudioControls(tab, "GlobalOptions.");
addSubtitleControls(tab, "globaloptions_"); addSubtitleControls(tab, "GlobalOptions_Audio.");
tab->addTab("Volume"); tab->addTab("Volume");
addVolumeControls(tab, "globaloptions_"); addVolumeControls(tab, "GlobalOptions_Volume.");
// TODO: cd drive setting // TODO: cd drive setting
@ -687,7 +687,7 @@ GlobalOptionsDialog::GlobalOptionsDialog()
// 3) The MIDI tab // 3) The MIDI tab
// //
tab->addTab("MIDI"); tab->addTab("MIDI");
addMIDIControls(tab, "globaloptions_"); addMIDIControls(tab, "GlobalOptions_MIDI.");
// //
// 4) The miscellaneous tab // 4) The miscellaneous tab
@ -699,33 +699,33 @@ GlobalOptionsDialog::GlobalOptionsDialog()
// truncated in the small version of the GUI. // truncated in the small version of the GUI.
// Save game path // Save game path
new ButtonWidget(tab, "globaloptions_savebutton", "Save Path: ", kChooseSaveDirCmd, 0); new ButtonWidget(tab, "GlobalOptions_Paths.SaveButton", "Save Path: ", kChooseSaveDirCmd, 0);
_savePath = new StaticTextWidget(tab, "globaloptions_savepath", "/foo/bar"); _savePath = new StaticTextWidget(tab, "GlobalOptions_Paths.SavePath", "/foo/bar");
new ButtonWidget(tab, "globaloptions_themebutton", "Theme Path:", kChooseThemeDirCmd, 0); new ButtonWidget(tab, "GlobalOptions_Paths.ThemeButton", "Theme Path:", kChooseThemeDirCmd, 0);
_themePath = new StaticTextWidget(tab, "globaloptions_themepath", "None"); _themePath = new StaticTextWidget(tab, "GlobalOptions_Paths.ThemePath", "None");
new ButtonWidget(tab, "globaloptions_extrabutton", "Extra Path:", kChooseExtraDirCmd, 0); new ButtonWidget(tab, "GlobalOptions_Paths.ExtraButton", "Extra Path:", kChooseExtraDirCmd, 0);
_extraPath = new StaticTextWidget(tab, "globaloptions_extrapath", "None"); _extraPath = new StaticTextWidget(tab, "GlobalOptions_Paths.ExtraPath", "None");
#ifdef DYNAMIC_MODULES #ifdef DYNAMIC_MODULES
new ButtonWidget(tab, "globaloptions_pluginsbutton", "Plugins Path:", kChoosePluginsDirCmd, 0); new ButtonWidget(tab, "GlobalOptions_Paths.PluginsButton", "Plugins Path:", kChoosePluginsDirCmd, 0);
_pluginsPath = new StaticTextWidget(tab, "globaloptions_pluginspath", "None"); _pluginsPath = new StaticTextWidget(tab, "GlobalOptions_Paths.PluginsPath", "None");
#endif #endif
#endif #endif
#ifdef SMALL_SCREEN_DEVICE #ifdef SMALL_SCREEN_DEVICE
new ButtonWidget(tab, "globaloptions_keysbutton", "Keys", kChooseKeyMappingCmd, 0); new ButtonWidget(tab, "GlobalOptions.KeysButton", "Keys", kChooseKeyMappingCmd, 0);
#endif #endif
tab->addTab("Misc"); tab->addTab("Misc");
new ButtonWidget(tab, "globaloptions_themebutton2", "Theme:", kChooseThemeCmd, 0); new ButtonWidget(tab, "GlobalOptions_Misc.ThemeButton", "Theme:", kChooseThemeCmd, 0);
_curTheme = new StaticTextWidget(tab, "globaloptions_curtheme", g_gui.theme()->getThemeName()); _curTheme = new StaticTextWidget(tab, "GlobalOptions_Misc.CurTheme", g_gui.theme()->getThemeName());
int labelWidth = g_gui.evaluator()->getVar("tabPopupsLabelW"); int labelWidth = g_gui.evaluator()->getVar("tabPopupsLabelW");
_autosavePeriodPopUp = new PopUpWidget(tab, "globaloptions_autosaveperiod", "Autosave:", labelWidth); _autosavePeriodPopUp = new PopUpWidget(tab, "GlobalOptions_Misc.AutosavePeriod", "Autosave:", labelWidth);
for (int i = 0; savePeriodLabels[i]; i++) { for (int i = 0; savePeriodLabels[i]; i++) {
_autosavePeriodPopUp->appendEntry(savePeriodLabels[i], savePeriodValues[i]); _autosavePeriodPopUp->appendEntry(savePeriodLabels[i], savePeriodValues[i]);
@ -738,8 +738,8 @@ GlobalOptionsDialog::GlobalOptionsDialog()
tab->setActiveTab(0); tab->setActiveTab(0);
// Add OK & Cancel buttons // Add OK & Cancel buttons
new ButtonWidget(this, "globaloptions_cancel", "Cancel", kCloseCmd, 0); new ButtonWidget(this, "GlobalOptions.Cancel", "Cancel", kCloseCmd, 0);
new ButtonWidget(this, "globaloptions_ok", "OK", kOKCmd, 0); new ButtonWidget(this, "GlobalOptions.Ok", "OK", kOKCmd, 0);
#ifdef SMALL_SCREEN_DEVICE #ifdef SMALL_SCREEN_DEVICE
_keysDialog = new KeysDialog(); _keysDialog = new KeysDialog();

File diff suppressed because one or more lines are too long

View file

@ -464,7 +464,7 @@
</widget> </widget>
</globals> </globals>
<dialog name = 'Launcher'> <dialog name = 'Launcher' overlays = 'screen'>
<layout type = 'vertical' center = 'true' padding = '23, 23, 8, 23'> <layout type = 'vertical' center = 'true' padding = '23, 23, 8, 23'>
<widget name = 'Version' <widget name = 'Version'
width = '247' width = '247'
@ -513,4 +513,42 @@
</layout> </layout>
</layout> </layout>
</dialog> </dialog>
<dialog name = 'GlobalOptions' overlays = 'Dialog.Launcher.GameList'>
<layout type = 'vertical' padding = '0, 0, 0, 0' direction = 'bottom2top'>
<layout type = 'horizontal' direction = 'right2left' padding = '16, 16, 16, 16'>
<widget name = 'Ok'
width = 'Globals.Button.Width'
height = 'Globals.Button.Height'
/>
<widget name = 'Cancel'
width = 'Globals.Button.Width'
height = 'Globals.Button.Height'
/>
<space/>
</layout>
<widget name = 'TabWidget'/>
</layout>
</dialog>
<dialog name = 'GlobalOptions_Graphics' overlays = 'Dialog.GlobalOptions.TabWidget'>
<layout type = 'vertical' padding = '16, 16, 16, 16'>
<widget name = 'grModePopup'
width = '512'
height = '64'
/>
<widget name = 'grRenderPopup'
width = '512'
height = '64'
/>
<widget name = 'grAspectCheckbox'
width = '256'
height = '32'
/>
<widget name = 'grFullscreenCheckbox'
width = '256'
height = '32'
/>
</layout>
</dialog>
</layout_info> </layout_info>