From dde4200d3524dfa2f102f920d82a2d3d01b3ad80 Mon Sep 17 00:00:00 2001 From: aryanrawlani28 Date: Sat, 6 Jun 2020 16:05:37 +0530 Subject: [PATCH] GUI: RTL: Overload and simplify getWidgetData for getting rtl flag --- engines/scumm/dialogs.cpp | 2 +- gui/ThemeEval.cpp | 6 ++++++ gui/ThemeEval.h | 1 + gui/ThemeLayout.cpp | 2 +- gui/options.cpp | 14 +++++++------- gui/saveload-dialog.cpp | 4 ++-- 6 files changed, 18 insertions(+), 11 deletions(-) diff --git a/engines/scumm/dialogs.cpp b/engines/scumm/dialogs.cpp index 20f63ce7b9a..14bf29e1f28 100644 --- a/engines/scumm/dialogs.cpp +++ b/engines/scumm/dialogs.cpp @@ -309,7 +309,7 @@ void HelpDialog::reflowLayout() { assert(lineHeight); - g_gui.xmlEval()->getWidgetData("ScummHelp.HelpText", x, y, w, h, _useRTL); + g_gui.xmlEval()->getWidgetData("ScummHelp.HelpText", x, y, w, h); // Make sure than we don't have more lines than what we can fit // on the space that the layout reserves for text diff --git a/gui/ThemeEval.cpp b/gui/ThemeEval.cpp index ceecb14303f..f7d0fde9135 100644 --- a/gui/ThemeEval.cpp +++ b/gui/ThemeEval.cpp @@ -50,6 +50,12 @@ void ThemeEval::reset() { _layouts.clear(); } +bool ThemeEval::getWidgetData(const Common::String &widget, int16 &x, int16 &y, int16 &w, int16 &h) { + bool useRTL; + + return getWidgetData(widget, x, y, w, h, useRTL); +} + bool ThemeEval::getWidgetData(const Common::String &widget, int16 &x, int16 &y, int16 &w, int16 &h, bool &useRTL) { Common::StringTokenizer tokenizer(widget, "."); diff --git a/gui/ThemeEval.h b/gui/ThemeEval.h index 757b6c32d83..ff7fe82a946 100644 --- a/gui/ThemeEval.h +++ b/gui/ThemeEval.h @@ -88,6 +88,7 @@ public: bool hasDialog(const Common::String &name); void reflowDialogLayout(const Common::String &name, Widget *widgetChain); + bool getWidgetData(const Common::String &widget, int16 &x, int16 &y, int16 &w, int16 &h); bool getWidgetData(const Common::String &widget, int16 &x, int16 &y, int16 &w, int16 &h, bool &useRTL); Graphics::TextAlign getWidgetTextHAlign(const Common::String &widget); diff --git a/gui/ThemeLayout.cpp b/gui/ThemeLayout.cpp index f89014ea552..bc02efbd4cc 100644 --- a/gui/ThemeLayout.cpp +++ b/gui/ThemeLayout.cpp @@ -233,7 +233,7 @@ void ThemeLayoutMain::reflowLayout(Widget *widgetChain) { _w = _defaultW > 0 ? MIN(_defaultW, g_system->getOverlayWidth()) : -1; _h = _defaultH > 0 ? MIN(_defaultH, g_system->getOverlayHeight()) : -1; } else { - if (!g_gui.xmlEval()->getWidgetData(_overlays, _x, _y, _w, _h, _useRTL)) { + if (!g_gui.xmlEval()->getWidgetData(_overlays, _x, _y, _w, _h)) { warning("Unable to retrieve overlayed dialog position %s", _overlays.c_str()); } diff --git a/gui/options.cpp b/gui/options.cpp index 5f59b65844d..a9a8a568db3 100644 --- a/gui/options.cpp +++ b/gui/options.cpp @@ -2786,10 +2786,10 @@ void GlobalOptionsDialog::setupCloudTab() { int16 shiftUp = 0; if (!showingCurrentStorage || enabled) { // "storage is disabled" hint is not shown, shift everything up - if (!g_gui.xmlEval()->getWidgetData("GlobalOptions_Cloud_Container.StorageDisabledHint", x, y, w, h, _useRTL)) + if (!g_gui.xmlEval()->getWidgetData("GlobalOptions_Cloud_Container.StorageDisabledHint", x, y, w, h)) warning("GlobalOptions_Cloud_Container.StorageUsernameDesc's position is undefined"); shiftUp = y; - if (!g_gui.xmlEval()->getWidgetData("GlobalOptions_Cloud_Container.StorageUsernameDesc", x, y, w, h, _useRTL)) + if (!g_gui.xmlEval()->getWidgetData("GlobalOptions_Cloud_Container.StorageUsernameDesc", x, y, w, h)) warning("GlobalOptions_Cloud_Container.StorageWizardNotConnectedHint's position is undefined"); shiftUp = y - shiftUp; } @@ -2839,10 +2839,10 @@ void GlobalOptionsDialog::setupCloudTab() { int16 disconnectWidgetsAdditionalShift = 0; if (!showDownloadButton) { - if (!g_gui.xmlEval()->getWidgetData("GlobalOptions_Cloud_Container.StorageDownloadHint", x, y, w, h, _useRTL)) + if (!g_gui.xmlEval()->getWidgetData("GlobalOptions_Cloud_Container.StorageDownloadHint", x, y, w, h)) warning("GlobalOptions_Cloud_Container.StorageDownloadHint's position is undefined"); disconnectWidgetsAdditionalShift = y; - if (!g_gui.xmlEval()->getWidgetData("GlobalOptions_Cloud_Container.StorageDisconnectHint", x, y, w, h, _useRTL)) + if (!g_gui.xmlEval()->getWidgetData("GlobalOptions_Cloud_Container.StorageDisconnectHint", x, y, w, h)) warning("GlobalOptions_Cloud_Container.DownloadButton's position is undefined"); disconnectWidgetsAdditionalShift = y - disconnectWidgetsAdditionalShift; } @@ -2889,10 +2889,10 @@ void GlobalOptionsDialog::setupCloudTab() { } if (!shownConnectedInfo) { - if (!g_gui.xmlEval()->getWidgetData("GlobalOptions_Cloud_Container.StorageDisabledHint", x, y, w, h, _useRTL)) + if (!g_gui.xmlEval()->getWidgetData("GlobalOptions_Cloud_Container.StorageDisabledHint", x, y, w, h)) warning("GlobalOptions_Cloud_Container.StorageUsernameDesc's position is undefined"); shiftUp = y; - if (!g_gui.xmlEval()->getWidgetData("GlobalOptions_Cloud_Container.StorageWizardNotConnectedHint", x, y, w, h, _useRTL)) + if (!g_gui.xmlEval()->getWidgetData("GlobalOptions_Cloud_Container.StorageWizardNotConnectedHint", x, y, w, h)) warning("GlobalOptions_Cloud_Container.StorageWizardNotConnectedHint's position is undefined"); shiftUp = y - shiftUp; @@ -2912,7 +2912,7 @@ void GlobalOptionsDialog::shiftWidget(Widget *widget, const char *widgetName, in int16 x, y; int16 w, h; - if (!g_gui.xmlEval()->getWidgetData(widgetName, x, y, w, h, _useRTL)) + if (!g_gui.xmlEval()->getWidgetData(widgetName, x, y, w, h)) warning("%s's position is undefined", widgetName); widget->setPos(x + xOffset, y + yOffset); diff --git a/gui/saveload-dialog.cpp b/gui/saveload-dialog.cpp index 2e84f40dd01..bc059fcb2b8 100644 --- a/gui/saveload-dialog.cpp +++ b/gui/saveload-dialog.cpp @@ -493,7 +493,7 @@ void SaveLoadChooserSimple::reflowLayout() { int16 x, y; int16 w, h; - if (!g_gui.xmlEval()->getWidgetData("SaveLoadChooser.Thumbnail", x, y, w, h, _useRTL)) + if (!g_gui.xmlEval()->getWidgetData("SaveLoadChooser.Thumbnail", x, y, w, h)) error("Error when loading position data for Save/Load Thumbnails"); // Even if there is no thumbnail support, getWidgetData() will provide default thumbnail values @@ -934,7 +934,7 @@ void SaveLoadChooserGrid::reflowLayout() { int16 x, y; int16 w; - if (!g_gui.xmlEval()->getWidgetData("SaveLoadChooser.List", x, y, w, availableHeight, _useRTL)) + if (!g_gui.xmlEval()->getWidgetData("SaveLoadChooser.List", x, y, w, availableHeight)) error("Could not load widget position for 'SaveLoadChooser.List'"); const int16 buttonWidth = kThumbnailWidth + 6;