From aec5bf42da8b979a87b686a48bc2840a51a41b01 Mon Sep 17 00:00:00 2001 From: Vantha Date: Wed, 8 Jan 2025 20:51:28 +0100 Subject: [PATCH] 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 --- .../public/gui/pregame/SplashscreenHandler.js | 2 +- .../public/gui/splashscreen/splashscreen.js | 29 ++++++++++++--- .../public/gui/splashscreen/splashscreen.txt | 9 ----- .../public/gui/splashscreen/splashscreen.xml | 35 +++++++++++++++++-- binaries/data/mods/public/l10n/messages.json | 1 - 5 files changed, 59 insertions(+), 17 deletions(-) delete mode 100644 binaries/data/mods/public/gui/splashscreen/splashscreen.txt diff --git a/binaries/data/mods/public/gui/pregame/SplashscreenHandler.js b/binaries/data/mods/public/gui/pregame/SplashscreenHandler.js index 746d5efadd..59bd66dc67 100644 --- a/binaries/data/mods/public/gui/pregame/SplashscreenHandler.js +++ b/binaries/data/mods/public/gui/pregame/SplashscreenHandler.js @@ -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", {}); } } diff --git a/binaries/data/mods/public/gui/splashscreen/splashscreen.js b/binaries/data/mods/public/gui/splashscreen/splashscreen.js index b653e36af7..ae56034756 100644 --- a/binaries/data/mods/public/gui/splashscreen/splashscreen.js +++ b/binaries/data/mods/public/gui/splashscreen/splashscreen.js @@ -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(); } diff --git a/binaries/data/mods/public/gui/splashscreen/splashscreen.txt b/binaries/data/mods/public/gui/splashscreen/splashscreen.txt deleted file mode 100644 index 20c572c6cb..0000000000 --- a/binaries/data/mods/public/gui/splashscreen/splashscreen.txt +++ /dev/null @@ -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. diff --git a/binaries/data/mods/public/gui/splashscreen/splashscreen.xml b/binaries/data/mods/public/gui/splashscreen/splashscreen.xml index 3fd9144f71..213280d88b 100644 --- a/binaries/data/mods/public/gui/splashscreen/splashscreen.xml +++ b/binaries/data/mods/public/gui/splashscreen/splashscreen.xml @@ -8,13 +8,44 @@ - + Welcome! - + + + + Thank you for installing 0 A.D. Empires Ascendant! + + + + + + + This game is still in development. You may encounter bugs, and some features are not as fleshed out as we would like. + + + + + + + + The game can have performance problems, especially with large maps and a great number of units. + + + + + + + + 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. + + + + + Show this message in the future diff --git a/binaries/data/mods/public/l10n/messages.json b/binaries/data/mods/public/l10n/messages.json index 3590bc5e82..02797101b5 100644 --- a/binaries/data/mods/public/l10n/messages.json +++ b/binaries/data/mods/public/l10n/messages.json @@ -456,7 +456,6 @@ "extractor": "txt", "filemasks": [ "gui/gamesetup/**.txt", - "gui/splashscreen/splashscreen.txt", "gui/reference/tips/texts/**.txt" ], "options": {