[Scummvm-git-logs] scummvm master -> ff69b5a06f1403f0eefcda00b1906fb96af4ee35
sev-
noreply at scummvm.org
Mon Jan 26 19:05:51 UTC 2026
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .
Summary:
ff69b5a06f GUI: Restrict max width of scaled pictures in Help
Commit: ff69b5a06f1403f0eefcda00b1906fb96af4ee35
https://github.com/scummvm/scummvm/commit/ff69b5a06f1403f0eefcda00b1906fb96af4ee35
Author: Gulraiz (gulraiznoorbari at gmail.com)
Date: 2026-01-26T22:05:46+03:00
Commit Message:
GUI: Restrict max width of scaled pictures in Help
Changed paths:
backends/platform/android/android.cpp
graphics/macgui/mactext-canvas.cpp
gui/helpdialog.cpp
diff --git a/backends/platform/android/android.cpp b/backends/platform/android/android.cpp
index 9d033bfba8e..a3e2d8a0def 100644
--- a/backends/platform/android/android.cpp
+++ b/backends/platform/android/android.cpp
@@ -1095,19 +1095,19 @@ _s(
"\n"
"The touch controls are direct. The pointer jumps to where the finger touches the screen (default for menus).\n"
"\n"
-" {w=10em}\n"
+" {w=10em,maxw=50em}\n"
"\n"
"### Touchpad emulation \n"
"\n"
"The touch controls are indirect, like on a laptop touchpad.\n"
"\n"
-" {w=10em}\n"
+" {w=10em,maxw=50em}\n"
"\n"
"### Gamepad emulation \n"
"\n"
"Fingers must be placed on lower left and right of the screen to emulate a directional pad and action buttons.\n"
"\n"
-" {w=10em}\n"
+" {w=10em,maxw=50em}\n"
"\n"
"To select the preferred touch mode for menus, 2D games, and 3D games, go to **Global Options > Backend > Choose the preferred touch mode**.\n"
"\n"
@@ -1133,14 +1133,14 @@ _s(
"\n"
"To open the Global Main Menu, tap on the menu icon at the top right of the screen.\n"
"\n"
-" {w=10em}\n"
+" {w=10em,maxw=50em}\n"
"\n"
"## Virtual keyboard\n"
"\n"
"To open the virtual keyboard, long press on the controller icon at the top right of the screen, or tap on any editable text field. To hide the virtual keyboard, tap the controller icon again, or tap outside the text field.\n"
"\n"
"\n"
-" {w=10em}\n"
+" {w=10em,maxw=50em}\n"
"\n"
),
@@ -1153,21 +1153,21 @@ _s(
"\n"
"2. Inside the ScummVM file browser, select **Go Up** until you reach the root folder which has the **<Add a new folder>** option. \n"
"\n"
-" {w=70%}\n"
+" {w=70%,maxw=50em}\n"
"\n"
"3. Double-tap **<Add a new folder>**. In your device's file browser, navigate to the folder containing all your game folders. For example, **SD Card > ScummVMgames**. \n"
"\n"
"4. Select **Use this folder**. \n"
"\n"
-" {w=70%}\n"
+" {w=70%,maxw=50em}\n"
"\n"
"5. Select **ALLOW** to give ScummVM permission to access the folder. \n"
"\n"
-" {w=70%}\n"
+" {w=70%,maxw=50em}\n"
"\n"
"6. In the ScummVM file browser, double-tap to browse through your added folder. Add a game by selecting the sub-folder containing the game files, then tap **Choose**. \n"
"\n"
-" {w=70%}\n"
+" {w=70%,maxw=50em}\n"
"\n"
"Step 2 and 3 are done only once. To add more games, repeat Steps 1 and 6. \n"
"\n"
diff --git a/graphics/macgui/mactext-canvas.cpp b/graphics/macgui/mactext-canvas.cpp
index c429864e1d5..b090cee6c1b 100644
--- a/graphics/macgui/mactext-canvas.cpp
+++ b/graphics/macgui/mactext-canvas.cpp
@@ -152,6 +152,7 @@ void MacTextCanvas::splitString(const Common::U32String &str, int curLine, MacFo
Common::String preprocessImageExt(const char *ptr) {
// w[idth]=WWWw -- width in units 'w'
// h[eight]=HHHh -- height in units 'h'
+ // maxw[idth]=MMMm -- max-width in units 'maxw'
//
// units:
// % for percents of the text width -> %
@@ -159,27 +160,45 @@ Common::String preprocessImageExt(const char *ptr) {
// px for actual pixels -> p
//
// Translated into fixed format:
- // WWWWwHHHHh -- 4 fixed hex numbers followed by units
+ // WWWWwHHHHhMMMMm -- 4 fixed hex numbers followed by units
- int w = 0, h = 0;
- char wu = ' ', hu = ' ';
+ int w = 0, h = 0, maxw = 0;
+ char wu = ' ', hu = ' ', maxwu = ' ';
enum {
kStateNone,
kStateW,
kStateH,
+ kStateMaxW,
};
int state = kStateNone;
while (*ptr) {
- if (*ptr == ' ' || *ptr == '\t') {
+ if (*ptr == ' ' || *ptr == '\t' || *ptr == ',') {
ptr++;
continue;
}
- if (*ptr == 'w' || *ptr == 'h') {
- state = *ptr == 'w' ? kStateW : kStateH;
+ if (*ptr == '=') {
+ ptr++;
+ continue;
+ }
+
+ if (Common::isAlpha(*ptr)) {
+ if (*ptr == 'w') {
+ state = kStateW;
+ } else if (*ptr == 'h') {
+ state = kStateH;
+ } else if (scumm_strnicmp(ptr, "maxw", 4) == 0) {
+ state = kStateMaxW;
+ } else if (*ptr == '=') {
+ ptr++;
+ continue;
+ } else {
+ warning("MacTextCanvas: Malformatted image extension: unknown key at '%s'", ptr);
+ return "";
+ }
while (*ptr && *ptr != '=')
ptr++;
@@ -208,26 +227,29 @@ Common::String preprocessImageExt(const char *ptr) {
if (state == kStateW) {
w = num;
wu = unit;
- } else {
+ } else if (state == kStateH) {
h = num;
hu = unit;
+ } else {
+ maxw = num;
+ maxwu = unit;
}
- while (*ptr && *ptr != ' ' && *ptr != '\t')
+ state = kStateNone;
+
+ while (*ptr && *ptr != ' ' && *ptr != '\t' && *ptr != ',')
ptr++;
} else {
warning("MacTextCanvas: Malformatted image extension: %% or e[m] or p[x] expected at '%s'", ptr);
return "";
}
} else {
- warning("MacTextCanvas: Malformatted image extension: w[idth] or h[eight] expected at '%s'", ptr);
+ warning("MacTextCanvas: Malformatted image extension: w[idth], h[eight] or maxw[idth] expected at '%s'", ptr);
return "";
}
-
- ptr++;
}
- return Common::String::format("%04x%c%04x%c", w, wu, h, hu);
+ return Common::String::format("%04x%c%04x%c%04x%c", w, wu, h, hu, maxw, maxwu);
}
const Common::U32String::value_type *MacTextCanvas::splitString(const Common::U32String::value_type *s, int curLine, MacFontRun &defaultFormatting) {
@@ -784,19 +806,19 @@ void MacTextCanvas::parsePicExt(const Common::U32String &ext, uint16 &wOut, uint
D(9, "P: %s", ext.encode().c_str());
- // wwwwWhhhhH
+ // wwwwWhhhhHmmmmM
// 0123456789
bool useDefault = false;
- if (ext.size() == 10 && s[4] != ' ' && s[9] != ' ' && s[4] != s[9]) {
+ if (ext.size() == 15 && s[4] != ' ' && s[9] != ' ' && s[4] != s[9]) {
warning("MacTextCanvas: Non-matching dimension unitss in image extension: '%s'", ext.encode().c_str());
useDefault = true;
}
// if it is empty or without dimensions, use default width percrent
- if (useDefault || ext.size() < 10 || (s[4] == ' ' && s[9] == ' ')) {
+ if (useDefault || ext.size() < 15 || (s[4] == ' ' && s[9] == ' ' && s[14] == ' ')) {
float ratio = _maxWidth * defpercent / 100.0 / (float)wOut;
wOut = wOut * ratio;
@@ -805,23 +827,30 @@ void MacTextCanvas::parsePicExt(const Common::U32String &ext, uint16 &wOut, uint
return;
}
- uint16 w, h;
+ uint16 w;
+ uint16 h;
+ uint16 maxw;
+ char maxwu;
(void)readHex(&w, s, 4);
(void)readHex(&h, &s[5], 4);
+ (void)readHex(&maxw, &s[10], 4);
+ maxwu = s[14];
- D(9, "w: %d%c h: %d%c", w, s[4], h, s[9]);
+ D(9, "w: %d%c h: %d%c maxw: %d%c", w, s[4], h, s[9], maxw, s[14]);
if (s[9] == '%') {
warning("MacTextCanvas: image height in %% is not supported");
h = 0;
}
- float ratio;
+ float ratio = 1.0;
// Percent of the total width
- if (s[4] == '%') {
+ if (s[4] == '%' || s[5] == '%') {
ratio = _maxWidth * w / 100.0 / (float)wOut;
+ wOut = wOut * ratio;
+ hOut = hOut * ratio;
// Size in em (font height) units
} else if (s[4] == 'm' || s[5] == 'm') {
@@ -831,14 +860,16 @@ void MacTextCanvas::parsePicExt(const Common::U32String &ext, uint16 &wOut, uint
wOut = em * w;
hOut = em * h;
- return;
- }
-
- // now we need to compute ratio
- if (w != 0)
+ } else if (w != 0) {
ratio = em * w / (float)wOut;
- else
+ wOut = wOut * ratio;
+ hOut = hOut * ratio;
+
+ } else {
ratio = em * h / (float)hOut;
+ wOut = wOut * ratio;
+ hOut = hOut * ratio;
+ }
// Size in pixels
} else if (s[4] == 'p' || s[5] == 'p') {
@@ -846,22 +877,51 @@ void MacTextCanvas::parsePicExt(const Common::U32String &ext, uint16 &wOut, uint
wOut = w;
hOut = h;
- return;
- }
-
- // now we need to compute ratio
- if (w != 0)
+ } else if (w != 0) {
ratio = w / (float)wOut;
- else
+ wOut = wOut * ratio;
+ hOut = hOut * ratio;
+
+ } else {
ratio = h / (float)hOut;
+ wOut = wOut * ratio;
+ hOut = hOut * ratio;
+ }
+
} else {
error("MacTextCanvas: malformed image extension '%s", ext.encode().c_str());
}
D(9, "ratio is %f", ratio);
- wOut = wOut * ratio;
- hOut = hOut * ratio;
+ if (maxw > 0 && maxwu != ' ') {
+ int maxWidthPixels = 0;
+
+ if (maxwu == '%') {
+ maxWidthPixels = _maxWidth * maxw / 100;
+
+ } else if (maxwu == 'm') {
+ int em = _defaultFormatting.fontSize;
+ maxWidthPixels = em * maxw;
+
+ } else if (maxwu == 'p') {
+ maxWidthPixels = maxw;
+
+ } else {
+ warning("MacTextCanvas: unknown max width unit '%c' in image extension '%s'", maxwu, ext.encode().c_str());
+ }
+
+ if (maxWidthPixels > 0 && wOut > maxWidthPixels) {
+ float clampRatio = maxWidthPixels / (float)wOut;
+
+ D(9, "Clamping image width from %d to %d (ratio %f)", wOut, maxWidthPixels, clampRatio);
+
+ wOut = maxWidthPixels;
+ hOut = hOut * clampRatio;
+ }
+ }
+
+ D(9, "Final dimensions: %d x %d", wOut, hOut);
}
int MacTextCanvas::getLineWidth(int lineNum, bool enforce, int col) {
diff --git a/gui/helpdialog.cpp b/gui/helpdialog.cpp
index 555e364317b..294ec20565f 100644
--- a/gui/helpdialog.cpp
+++ b/gui/helpdialog.cpp
@@ -74,38 +74,38 @@ _s(
"\n"
"2. Select your preferred cloud storage service from the **Active storage** dropdown, then select **Connect**.\n"
"\n "
-" {w=70%}\n"
+" {w=70%,maxw=50em}\n"
"\n"
"3. Select **Quick mode**.\n"
"\n "
-" {w=70%}\n"
+" {w=70%,maxw=50em}\n"
"\n"
"4. Select **Run server** and then select **Next** \n"
"\n "
-" {w=70%}\n"
+" {w=70%,maxw=50em}\n"
"\n"
-" {w=70%}\n"
+" {w=70%,maxw=50em}\n"
"\n"
"5. Open the link.\n"
"\n "
-" {w=70%}\n"
+" {w=70%,maxw=50em}\n"
"\n"
"6. In the browser window that opens, select the cloud service to connect. \n"
"\n "
-" {w=70%}\n"
+" {w=70%,maxw=50em}\n"
"\n"
"7. Sign in to the chosen cloud service. Once completed, return to ScummVM.\n"
"\n"
"8. On the success screen, select **Finish** to exit. \n"
"\n "
-" {w=70%}\n"
+" {w=70%,maxw=50em}\n"
"9. Back on the main Cloud tab, select **Enable storage**.\n"
"\n "
-" {w=70%}\n"
+" {w=70%,maxw=50em}\n"
"\n"
"10. You're ready to go! Use the cloud functionality to sync saved games or game files between your devices.\n"
"\n "
-" {w=70%}\n"
+" {w=70%,maxw=50em}\n"
"\n"
" For more information, including how to use the manual connection wizard, see our [Cloud documentation](https://docs.scummvm.org/en/latest/use_scummvm/connect_cloud.html) "
),
More information about the Scummvm-git-logs
mailing list