1
0
forked from mirrors/0ad

Layout and code improvements on the welcome screen

Move the lines from the .txt to the .xml .
Add separate objects for each paragraph and icon.
Position the icons depending on the paragraph length in the current
language.

This eliminates potential for breakage during translation.

Fixes #7484
This commit is contained in:
Vantha
2025-01-08 20:51:28 +01:00
committed by Ralph Sennhauser
parent 9a43c43a33
commit aec5bf42da
5 changed files with 59 additions and 17 deletions
@@ -31,7 +31,7 @@ class SplashScreenHandler
this.showSplashScreen = false;
if (Engine.ConfigDB_GetValue("user", "gui.splashscreen.enable") === "true" ||
Engine.ConfigDB_GetValue("user", "gui.splashscreen.version") !== Engine.CalculateMD5(Engine.ReadFile("gui/splashscreen/splashscreen.txt")))
Engine.ConfigDB_GetValue("user", "gui.splashscreen.version") !== Engine.CalculateMD5(Engine.ReadFile("gui/splashscreen/splashscreen.xml")))
Engine.PushGuiPage("page_splashscreen.xml", {});
}
}
@@ -1,15 +1,36 @@
var g_SplashScreenFile = "gui/splashscreen/splashscreen.txt";
function init(data)
{
Engine.GetGUIObjectByName("mainText").caption = Engine.TranslateLines(Engine.ReadFile(g_SplashScreenFile));
const paragraphObjects = Engine.GetGUIObjectByName("paragraphs").children;
const iconSize = 32;
const iconMargin = 15;
const textIndent = iconMargin * 2 + iconSize - 5;
const paragraphSpacing = 20;
let verticalOffset = paragraphSpacing * 3;
for (let paragraphObject of paragraphObjects)
{
const text = paragraphObject.children.find(object => object.toString().startsWith("text"));
const icon = paragraphObject.children.find(object => object.toString().startsWith("icon"));
text.size = new GUISize(textIndent, verticalOffset, -10, 0, 0, 0, 100, 100);
let paragraphHeight = Math.max(text.getTextSize().height, iconSize);
const sizeTop = Math.min(verticalOffset + 5, verticalOffset + paragraphHeight / 2 - iconSize / 2);
icon.size = new GUISize(
iconMargin, sizeTop,
iconMargin + iconSize, sizeTop + iconSize,
0, 0, 0, 0
);
verticalOffset += paragraphHeight + paragraphSpacing;
}
Engine.GetGUIObjectByName("displaySplashScreen").checked = Engine.ConfigDB_GetValue("user", "gui.splashscreen.enable") === "true";
}
function closePage()
{
Engine.ConfigDB_CreateValue("user", "gui.splashscreen.enable", String(Engine.GetGUIObjectByName("displaySplashScreen").checked));
Engine.ConfigDB_CreateValue("user", "gui.splashscreen.version", Engine.CalculateMD5(Engine.ReadFile(g_SplashScreenFile)));
Engine.ConfigDB_CreateValue("user", "gui.splashscreen.version", Engine.CalculateMD5(Engine.ReadFile("gui/splashscreen/splashscreen.xml")));
Engine.ConfigDB_SaveChanges("user");
Engine.PopGuiPage();
}
@@ -1,9 +0,0 @@
[font="sans-bold-20"] Thank you for installing 0 A.D. Empires Ascendant!
[font="sans-16"]
[imgleft="constructionIcon"]This game is still in development. You may encounter bugs, and some features are not as fleshed out as we would like.
[imgleft="iconLag"]The game can have performance problems, especially with large maps and a great number of units.
[imgleft="iconMap"]0 A.D. is Free Software: you can participate in its development.
If you want to help with art, sound, gameplay or programming, make sure to join our official forum.
@@ -8,13 +8,44 @@
<!-- Add a translucent black background to fade out the menu page -->
<object type="image" sprite="ModernFade"/>
<object type="image" style="ModernDialog" size="50%-300 50%-225 50%+300 50%+225">
<object type="image" style="ModernDialog" size="50%-310 50%-225 50%+310 50%+225">
<object type="text" style="ModernLabelText" size="50%-128 -18 50%+128 14">
<translatableAttribute id="caption">Welcome!</translatableAttribute>
</object>
<object name="mainText" type="text" style="ModernTextPanel" size="20 20 100%-20 100%-52">
<object type="image" sprite="ModernDarkBox" size="20 20 100%-20 100%-52">
<object type="image" sprite="ModernDarkBoxGoldBorder"/>
<object type="text" style="ModernLabelText" size="10 8 100%-10 50" font="sans-bold-20" text_align="center">
<translatableAttribute id="caption">Thank you for installing 0 A.D. Empires Ascendant!</translatableAttribute>
</object>
<object name="paragraphs">
<object>
<object name="icon1" type="image" sprite="stretched:pregame/icons/experimental.png"/>
<object name="text1" type="text" textcolor="white" font="sans-16">
<translatableAttribute id="caption">
This game is still in development. You may encounter bugs, and some features are not as fleshed out as we would like.
</translatableAttribute>
</object>
</object>
<object>
<object name="icon2" type="image" sprite="stretched:pregame/icons/lag.png"/>
<object name="text2" type="text" textcolor="white" font="sans-16">
<translatableAttribute id="caption">
The game can have performance problems, especially with large maps and a great number of units.
</translatableAttribute>
</object>
</object>
<object>
<object name="icon3" type="image" sprite="stretched:pregame/icons/map.png"/>
<object name="text3" type="text" textcolor="white" font="sans-16">
<translatableAttribute id="caption">
0 A.D. is Free Software: you can participate in its development. If you want to help with art, sound, gameplay or programming, make sure to join our official forum.
</translatableAttribute>
</object>
</object>
</object>
<object name="displaySplashScreenText" size="30 100%-30 100% 100%-8" type="text" style="ModernLeftLabelText">
<translatableAttribute id="caption">Show this message in the future</translatableAttribute>
</object>
@@ -456,7 +456,6 @@
"extractor": "txt",
"filemasks": [
"gui/gamesetup/**.txt",
"gui/splashscreen/splashscreen.txt",
"gui/reference/tips/texts/**.txt"
],
"options": {