GUI: RTL: Overload and simplify getWidgetData for getting rtl flag

This commit is contained in:
aryanrawlani28 2020-06-06 16:05:37 +05:30 committed by Eugene Sandulenko
parent 12a4af77bd
commit dde4200d35
6 changed files with 18 additions and 11 deletions

View file

@ -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

View file

@ -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, ".");

View file

@ -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);

View file

@ -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());
}

View file

@ -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);

View file

@ -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;