mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-23 12:44:02 +00:00
Look, the launcher is rendered with the new layout parser.
svn-id: r33641
This commit is contained in:
parent
fdf485ea9b
commit
eb3d163439
@ -36,7 +36,7 @@
|
||||
|
||||
namespace GUI {
|
||||
|
||||
bool ThemeLayoutWidget::getWidgetData(const Common::String &name, int16 &x, int16 &y, int16 &w, int16 &h) {
|
||||
bool ThemeLayoutWidget::getWidgetData(const Common::String &name, int16 &x, int16 &y, uint16 &w, uint16 &h) {
|
||||
if (name == _name) {
|
||||
x = _x; y = _y;
|
||||
w = _w; h = _h;
|
||||
@ -46,7 +46,7 @@ bool ThemeLayoutWidget::getWidgetData(const Common::String &name, int16 &x, int1
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ThemeLayout::getWidgetData(const Common::String &name, int16 &x, int16 &y, int16 &w, int16 &h) {
|
||||
bool ThemeLayout::getWidgetData(const Common::String &name, int16 &x, int16 &y, uint16 &w, uint16 &h) {
|
||||
for (uint i = 0; i < _children.size(); ++i) {
|
||||
if (_children[i]->getWidgetData(name, x, y, w, h))
|
||||
return true;
|
||||
@ -82,15 +82,19 @@ void ThemeLayoutVertical::reflowLayout() {
|
||||
|
||||
if (i == 0)
|
||||
assert(_children[i]->getWidth() != -1);
|
||||
|
||||
_children[i]->setX(curX);
|
||||
_children[i]->setY(curY);
|
||||
|
||||
if (_children[i]->getWidth() == -1)
|
||||
_children[i]->setWidth(_w - _paddingLeft - _paddingRight);
|
||||
|
||||
if (_children[i]->getHeight() == -1)
|
||||
_children[i]->setHeight(getParentH() - _h - _spacing);
|
||||
|
||||
_children[i]->setY(curY);
|
||||
|
||||
if (_centered)
|
||||
_children[i]->setX((_w >> 1) - (_children[i]->getWidth() >> 1));
|
||||
else
|
||||
_children[i]->setX(curX);
|
||||
|
||||
if (_reverse) {
|
||||
for (int j = i - 1; j >= 0; --j)
|
||||
@ -121,9 +125,6 @@ void ThemeLayoutHorizontal::reflowLayout() {
|
||||
|
||||
if (i == 0)
|
||||
assert(_children[i]->getHeight() != -1);
|
||||
|
||||
_children[i]->setX(curX);
|
||||
_children[i]->setY(curY);
|
||||
|
||||
if (_children[i]->getHeight() == -1)
|
||||
_children[i]->setHeight(_h - _paddingTop - _paddingBottom);
|
||||
@ -131,6 +132,9 @@ void ThemeLayoutHorizontal::reflowLayout() {
|
||||
if (_children[i]->getWidth() == -1)
|
||||
_children[i]->setWidth(getParentW() - _w - _spacing);
|
||||
|
||||
_children[i]->setX(curX);
|
||||
_children[i]->setY(curY);
|
||||
|
||||
if (_reverse) {
|
||||
for (int j = i - 1; j >= 0; --j)
|
||||
_children[j]->setX(_children[i]->getWidth() + _spacing);
|
||||
@ -172,13 +176,13 @@ void ThemeEval::addDialog(const Common::String &name) {
|
||||
_curLayout.push(layout);
|
||||
}
|
||||
|
||||
void ThemeEval::addLayout(ThemeLayout::LayoutType type, bool reverse) {
|
||||
void ThemeEval::addLayout(ThemeLayout::LayoutType type, bool reverse, bool center) {
|
||||
ThemeLayout *layout = 0;
|
||||
|
||||
if (type == ThemeLayout::kLayoutVertical)
|
||||
layout = new ThemeLayoutVertical(_curLayout.top(), getVar("Globals.Layout.Spacing", 4), reverse);
|
||||
layout = new ThemeLayoutVertical(_curLayout.top(), getVar("Globals.Layout.Spacing", 4), reverse, center);
|
||||
else if (type == ThemeLayout::kLayoutHorizontal)
|
||||
layout = new ThemeLayoutHorizontal(_curLayout.top(), getVar("Globals.Layout.Spacing", 4), reverse);
|
||||
layout = new ThemeLayoutHorizontal(_curLayout.top(), getVar("Globals.Layout.Spacing", 4), reverse, center);
|
||||
|
||||
layout->setPadding(
|
||||
getVar("Globals.Padding.Left", 0),
|
||||
@ -187,8 +191,6 @@ void ThemeEval::addLayout(ThemeLayout::LayoutType type, bool reverse) {
|
||||
getVar("Globals.Padding.Bottom", 0)
|
||||
);
|
||||
|
||||
layout->setSpacing(4);
|
||||
|
||||
_curLayout.top()->addChild(layout);
|
||||
_curLayout.push(layout);
|
||||
}
|
||||
|
@ -51,7 +51,8 @@ public:
|
||||
|
||||
ThemeLayout(ThemeLayout *p, const Common::String &name) :
|
||||
_parent(p), _name(name), _x(0), _y(0), _w(-1), _h(-1), _reverse(false),
|
||||
_paddingLeft(0), _paddingRight(0), _paddingTop(0), _paddingBottom(0) { }
|
||||
_paddingLeft(0), _paddingRight(0), _paddingTop(0), _paddingBottom(0),
|
||||
_centered(false) { }
|
||||
|
||||
virtual ~ThemeLayout() {
|
||||
_children.clear();
|
||||
@ -144,7 +145,7 @@ public:
|
||||
virtual LayoutType getLayoutType() = 0;
|
||||
virtual const char *getName() { return _name.c_str(); }
|
||||
|
||||
virtual bool getWidgetData(const Common::String &name, int16 &x, int16 &y, int16 &w, int16 &h);
|
||||
virtual bool getWidgetData(const Common::String &name, int16 &x, int16 &y, uint16 &w, uint16 &h);
|
||||
|
||||
protected:
|
||||
int16 _x, _y, _w, _h;
|
||||
@ -153,6 +154,7 @@ protected:
|
||||
Common::Array<ThemeLayout*> _children;
|
||||
ThemeLayout *_parent;
|
||||
bool _reverse;
|
||||
bool _centered;
|
||||
Common::String _name;
|
||||
};
|
||||
|
||||
@ -166,9 +168,11 @@ public:
|
||||
|
||||
class ThemeLayoutVertical : public ThemeLayout {
|
||||
public:
|
||||
ThemeLayoutVertical(ThemeLayout *p, int spacing, bool reverse) : ThemeLayout(p, "") {
|
||||
ThemeLayoutVertical(ThemeLayout *p, int spacing, bool reverse, bool center) :
|
||||
ThemeLayout(p, "") {
|
||||
_spacing = spacing;
|
||||
_reverse = reverse;
|
||||
_centered = center;
|
||||
}
|
||||
|
||||
void reflowLayout();
|
||||
@ -178,10 +182,11 @@ public:
|
||||
|
||||
class ThemeLayoutHorizontal : public ThemeLayout {
|
||||
public:
|
||||
ThemeLayoutHorizontal(ThemeLayout *p, int spacing, bool reverse) :
|
||||
ThemeLayoutHorizontal(ThemeLayout *p, int spacing, bool reverse, bool center) :
|
||||
ThemeLayout(p, "") {
|
||||
_spacing = spacing;
|
||||
_reverse = reverse;
|
||||
_centered = center;
|
||||
}
|
||||
|
||||
void reflowLayout();
|
||||
@ -192,7 +197,7 @@ public:
|
||||
class ThemeLayoutWidget : public ThemeLayout {
|
||||
public:
|
||||
ThemeLayoutWidget(ThemeLayout *p, const Common::String &name) : ThemeLayout(p, name) {}
|
||||
bool getWidgetData(const Common::String &name, int16 &x, int16 &y, int16 &w, int16 &h);
|
||||
bool getWidgetData(const Common::String &name, int16 &x, int16 &y, uint16 &w, uint16 &h);
|
||||
void reflowLayout() {}
|
||||
LayoutType getLayoutType() { return kLayoutWidget; }
|
||||
};
|
||||
@ -209,7 +214,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
bool getWidgetData(const Common::String &name, int16 &x, int16 &y, int16 &w, int16 &h) { return false; }
|
||||
bool getWidgetData(const Common::String &name, int16 &x, int16 &y, uint16 &w, uint16 &h) { return false; }
|
||||
void reflowLayout() {}
|
||||
LayoutType getLayoutType() { return kLayoutWidget; }
|
||||
const char *getName() { return "SPACE"; }
|
||||
@ -242,14 +247,27 @@ public:
|
||||
bool hasVar(const Common::String &name) { return _vars.contains(name); }
|
||||
|
||||
void addDialog(const Common::String &name);
|
||||
void addLayout(ThemeLayout::LayoutType type, bool reverse);
|
||||
void addLayout(ThemeLayout::LayoutType type, bool reverse, bool center = false);
|
||||
void addWidget(const Common::String &name, int w, int h);
|
||||
void addSpacing(int size);
|
||||
|
||||
void addPadding(int16 l, int16 r, int16 t, int16 b) {
|
||||
_curLayout.top()->setPadding(l, r, t, b);
|
||||
}
|
||||
|
||||
void closeLayout() { _curLayout.pop(); }
|
||||
void closeDialog() { _curLayout.pop()->reflowLayout(); }
|
||||
|
||||
|
||||
bool getWidgetData(const Common::String &widget, int16 &x, int16 &y, uint16 &w, uint16 &h) {
|
||||
Common::StringTokenizer tokenizer(widget, ".");
|
||||
Common::String dialogName = "Dialog." + tokenizer.nextToken();
|
||||
Common::String widgetName = tokenizer.nextToken();
|
||||
|
||||
if (!_layouts.contains(dialogName))
|
||||
return false;
|
||||
|
||||
return _layouts[dialogName]->getWidgetData(widgetName, x, y, w, h);
|
||||
}
|
||||
|
||||
void debugPrint() {
|
||||
printf("Debug variable list:\n");
|
||||
|
@ -501,9 +501,23 @@ bool ThemeParser::parserCallback_dialog(ParserNode *node) {
|
||||
bool ThemeParser::parserCallback_layout(ParserNode *node) {
|
||||
|
||||
if (node->values["type"] == "vertical")
|
||||
_theme->themeEval()->addLayout(GUI::ThemeLayout::kLayoutVertical, node->values["direction"] == "bottom2top");
|
||||
_theme->themeEval()->addLayout(GUI::ThemeLayout::kLayoutVertical,
|
||||
node->values["direction"] == "bottom2top",
|
||||
node->values["center"] == "true");
|
||||
|
||||
else if (node->values["type"] == "horizontal")
|
||||
_theme->themeEval()->addLayout(GUI::ThemeLayout::kLayoutHorizontal, node->values["direction"] == "right2left");
|
||||
_theme->themeEval()->addLayout(GUI::ThemeLayout::kLayoutHorizontal,
|
||||
node->values["direction"] == "right2left",
|
||||
node->values["center"] == "true");
|
||||
|
||||
if (node->values.contains("padding")) {
|
||||
int paddingL, paddingR, paddingT, paddingB;
|
||||
|
||||
if (!parseIntegerKey(node->values["padding"].c_str(), 4, &paddingL, &paddingR, &paddingT, &paddingB))
|
||||
return false;
|
||||
|
||||
_theme->themeEval()->addPadding(paddingL, paddingR, paddingT, paddingB);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -437,7 +437,7 @@ protected:
|
||||
XML_PROP(name, true)
|
||||
XML_KEY(layout)
|
||||
XML_PROP(type, true)
|
||||
XML_PROP(align, false)
|
||||
XML_PROP(center, false)
|
||||
XML_PROP(direction, false)
|
||||
XML_PROP(padding, false)
|
||||
XML_PROP(spacing, false)
|
||||
|
@ -693,11 +693,11 @@ void ThemeRenderer::updateScreen() {
|
||||
_textQueue.clear();
|
||||
}
|
||||
|
||||
// renderDirtyScreen();
|
||||
renderDirtyScreen();
|
||||
|
||||
_vectorRenderer->fillSurface();
|
||||
themeEval()->debugDraw(_screen, _font);
|
||||
_vectorRenderer->copyWholeFrame(_system);
|
||||
// _vectorRenderer->fillSurface();
|
||||
// themeEval()->debugDraw(_screen, _font);
|
||||
// _vectorRenderer->copyWholeFrame(_system);
|
||||
}
|
||||
|
||||
void ThemeRenderer::renderDirtyScreen() {
|
||||
|
@ -481,35 +481,35 @@ LauncherDialog::LauncherDialog()
|
||||
#ifndef DISABLE_FANCY_THEMES
|
||||
_logo = 0;
|
||||
if (g_gui.evaluator()->getVar("launcher_logo.visible") == 1 && g_gui.theme()->supportsImages()) {
|
||||
_logo = new GraphicsWidget(this, "launcher_logo");
|
||||
_logo = new GraphicsWidget(this, "Launcher.Logo");
|
||||
_logo->useThemeTransparency(true);
|
||||
_logo->setGfx(g_gui.theme()->getImageSurface(Theme::kImageLogo));
|
||||
|
||||
new StaticTextWidget(this, "launcher_version", gScummVMVersionDate);
|
||||
new StaticTextWidget(this, "Launcher.Version", gScummVMVersionDate);
|
||||
} else
|
||||
new StaticTextWidget(this, "launcher_version", gScummVMFullVersion);
|
||||
new StaticTextWidget(this, "Launcher.Version", gScummVMFullVersion);
|
||||
#else
|
||||
// Show ScummVM version
|
||||
new StaticTextWidget(this, "launcher_version", gScummVMFullVersion);
|
||||
new StaticTextWidget(this, "Launcher.Version", gScummVMFullVersion);
|
||||
#endif
|
||||
|
||||
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');
|
||||
new ButtonWidget(this, "Launcher.QuitButton", "Quit", kQuitCmd, 'Q');
|
||||
new ButtonWidget(this, "Launcher.AboutButton", "About", kAboutCmd, 'B');
|
||||
new ButtonWidget(this, "Launcher.OptionsButton", "Options", kOptionsCmd, 'O');
|
||||
_startButton =
|
||||
new ButtonWidget(this, "launcher_start_button", "Start", kStartCmd, 'S');
|
||||
new ButtonWidget(this, "Launcher.StartButton", "Start", kStartCmd, 'S');
|
||||
|
||||
// Above the lowest button rows: two more buttons (directly below the list box)
|
||||
_addButton =
|
||||
new ButtonWidget(this, "launcher_addGame_button", "Add Game...", kAddGameCmd, 'A');
|
||||
new ButtonWidget(this, "Launcher.AddGameButton", "Add Game...", kAddGameCmd, 'A');
|
||||
_editButton =
|
||||
new ButtonWidget(this, "launcher_editGame_button", "Edit Game...", kEditGameCmd, 'E');
|
||||
new ButtonWidget(this, "Launcher.EditGameButton", "Edit Game...", kEditGameCmd, 'E');
|
||||
_removeButton =
|
||||
new ButtonWidget(this, "launcher_removeGame_button", "Remove Game", kRemoveGameCmd, 'R');
|
||||
new ButtonWidget(this, "Launcher.RemoveGameButton", "Remove Game", kRemoveGameCmd, 'R');
|
||||
|
||||
|
||||
// Add list with game titles
|
||||
_list = new ListWidget(this, "launcher_list");
|
||||
_list = new ListWidget(this, "Launcher.GameList");
|
||||
_list->setEditable(false);
|
||||
_list->setNumberingMode(kListNumberingOff);
|
||||
|
||||
|
@ -58,15 +58,11 @@ enum {
|
||||
|
||||
void GuiObject::reflowLayout() {
|
||||
if (!_name.empty()) {
|
||||
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");
|
||||
if (!g_gui.xmlEval()->getWidgetData(_name, _x, _y, _w, _h))
|
||||
error("Could not load widget position for '%s'", _name.c_str());
|
||||
|
||||
if (_x < 0)
|
||||
error("Widget <%s> has x < 0", _name.c_str());
|
||||
error("Widget <%s> has x < 0: %d", _name.c_str(), _x);
|
||||
if (_x >= g_system->getOverlayWidth())
|
||||
error("Widget <%s> has x > %d", _name.c_str(), g_system->getOverlayWidth());
|
||||
if (_x + _w > g_system->getOverlayWidth())
|
||||
|
File diff suppressed because one or more lines are too long
@ -465,7 +465,7 @@
|
||||
</globals>
|
||||
|
||||
<dialog name = 'Launcher'>
|
||||
<layout type = 'vertical' align = 'center'>
|
||||
<layout type = 'vertical' center = 'true' padding = '23, 23, 8, 23'>
|
||||
<widget name = 'Version'
|
||||
width = '247'
|
||||
height = 'Globals.Line.Height'
|
||||
@ -474,12 +474,13 @@
|
||||
width = '283'
|
||||
height = '80'
|
||||
/>
|
||||
<layout type = 'horizontal' direction = 'right2left'>
|
||||
<layout type = 'vertical'>
|
||||
<layout type = 'horizontal' direction = 'right2left' padding = '0, 0, 0, 0'>
|
||||
<layout type = 'vertical' padding = '16, 0, 0, 0'>
|
||||
<widget name = 'StartButton'
|
||||
width = 'Globals.Button.Width'
|
||||
height = 'Globals.Button.Height'
|
||||
/>
|
||||
<space size = '16' />
|
||||
<widget name = 'AddGameButton'
|
||||
width = 'Globals.Button.Width'
|
||||
height = 'Globals.Button.Height'
|
||||
@ -492,6 +493,7 @@
|
||||
width = 'Globals.Button.Width'
|
||||
height = 'Globals.Button.Height'
|
||||
/>
|
||||
<space size = '16' />
|
||||
<widget name = 'OptionsButton'
|
||||
width = 'Globals.Button.Width'
|
||||
height = 'Globals.Button.Height'
|
||||
@ -500,7 +502,8 @@
|
||||
width = 'Globals.Button.Width'
|
||||
height = 'Globals.Button.Height'
|
||||
/>
|
||||
<widget name = 'QuittButton'
|
||||
<space size = '16' />
|
||||
<widget name = 'QuitButton'
|
||||
width = 'Globals.Button.Width'
|
||||
height = 'Globals.Button.Height'
|
||||
/>
|
||||
|
Loading…
x
Reference in New Issue
Block a user