From 833e6bd6524e93c43fade15878776f37a8ad91d1 Mon Sep 17 00:00:00 2001 From: RoosterDragon Date: Thu, 19 Sep 2024 21:15:16 +0100 Subject: [PATCH] Fix CreditsLogic to word-wrap the text. This allows the text to be word-wrapped automatically, rather than the current approach of manually wrapping the source text. --- AUTHORS | 58 ++++++------------- .../Widgets/Logic/CreditsLogic.cs | 7 ++- mods/cnc/chrome/credits.yaml | 3 +- mods/common/chrome/credits.yaml | 3 +- 4 files changed, 29 insertions(+), 42 deletions(-) diff --git a/AUTHORS b/AUTHORS index c74d276cfa..ba1de28b2a 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1,5 +1,4 @@ -OpenRA wouldn't be where it is today without the -hard work of many contributors. +OpenRA wouldn't be where it is today without the hard work of many contributors. The OpenRA developers are: * Gustas Kažukauskas (PunkPun) @@ -163,61 +162,42 @@ Also thanks to: * Wojciech Walaszek (Voidwalker) * Wuschel -Using GNU FreeFont distributed under the GNU GPL -terms. +Using GNU FreeFont distributed under the GNU GPL terms. -Using Simple DirectMedia Layer distributed under -the terms of the zlib license. +Using Simple DirectMedia Layer distributed under the terms of the zlib license. -Using FreeType distributed under the terms of the -FreeType License. +Using FreeType distributed under the terms of the FreeType License. Using OpenAL Soft distributed under the GNU LGPL. -Using SDL2-CS and OpenAL-CS created by Ethan -Lee and released under the zlib license. +Using SDL2-CS and OpenAL-CS created by Ethan Lee and released under the zlib license. -Using Eluant created by Chris Howie and released -under the MIT license. +Using Eluant created by Chris Howie and released under the MIT license. -Using FuzzyLogicLibrary (fuzzynet) by Dmitry -Kaluzhny and released under the GNU GPL terms. +Using FuzzyLogicLibrary (fuzzynet) by Dmitry Kaluzhny and released under the GNU GPL terms. -Using Mono.Nat by Alan McGovern, Ben Motmans, -Nicholas Terry distributed under the MIT license. +Using Mono.Nat by Alan McGovern, Ben Motmans, Nicholas Terry distributed under the MIT license. -Using MP3Sharp by Robert Bruke and Zane Wagner -licensed under the GNU LGPL Version 3. +Using MP3Sharp by Robert Bruke and Zane Wagner licensed under the GNU LGPL Version 3. -Using TagLib# by Stephen Shaw licensed under the -GNU LGPL Version 2.1. +Using TagLib# by Stephen Shaw licensed under the GNU LGPL Version 2.1. -Using NVorbis by Andrew Ward distributed under -the MIT license. +Using NVorbis by Andrew Ward distributed under the MIT license. -Using ICSharpCode.SharpZipLib initially by Mike -Krueger and distributed under the GNU GPL terms. +Using ICSharpCode.SharpZipLib initially by Mike Krueger and distributed under the GNU GPL terms. -Using rix0rrr.BeaconLib developed by Rico Huijbers -distributed under MIT License. +Using rix0rrr.BeaconLib developed by Rico Huijbers distributed under MIT License. -Using DiscordRichPresence developed by Lachee -distributed under MIT License. +Using DiscordRichPresence developed by Lachee distributed under MIT License. -Using Json.NET developed by James Newton-King -distributed under MIT License. +Using Json.NET developed by James Newton-King distributed under MIT License. Using ANGLE distributed under the BS3 3-Clause license. -Using Pfim developed by Nick Babcock -distributed under the MIT license. +Using Pfim developed by Nick Babcock distributed under the MIT license. -Using Linguini by the Space Station 14 team -licensed under Apache and MIT terms. +Using Linguini by the Space Station 14 team licensed under Apache and MIT terms. -This site or product includes IP2Location LITE data -available from https://www.ip2location.com. +This site or product includes IP2Location LITE data available from https://www.ip2location.com. -Finally, special thanks goes to the original teams -at Westwood Studios and EA for creating the classic -games which OpenRA aims to reimagine. +Finally, special thanks goes to the original teams at Westwood Studios and EA for creating the classic games which OpenRA aims to reimagine. diff --git a/OpenRA.Mods.Common/Widgets/Logic/CreditsLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/CreditsLogic.cs index f76d6507db..d1467891a4 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/CreditsLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/CreditsLogic.cs @@ -82,10 +82,15 @@ namespace OpenRA.Mods.Common.Widgets.Logic isShowingModTab = modCredits; scrollPanel.RemoveChildren(); + var font = Game.Renderer.Fonts[template.Font]; foreach (var line in modCredits ? modLines : engineLines) { - var label = template.Clone() as LabelWidget; + var label = (LabelWidget)template.Clone(); label.GetText = () => line; + var wrappedLine = line; + if (label.WordWrap) + wrappedLine = WidgetUtils.WrapText(line, label.Bounds.Width, font); + label.Bounds.Height = Math.Max(label.Bounds.Height, font.Measure(wrappedLine).Y); scrollPanel.AddChild(label); } } diff --git a/mods/cnc/chrome/credits.yaml b/mods/cnc/chrome/credits.yaml index 31d7e6dbf3..e0b466efc5 100644 --- a/mods/cnc/chrome/credits.yaml +++ b/mods/cnc/chrome/credits.yaml @@ -42,9 +42,10 @@ Container@CREDITS_PANEL: Children: Label@CREDITS_TEMPLATE: X: 8 - Width: PARENT_RIGHT - 25 + Width: PARENT_RIGHT - 24 - 2 * 8 Height: 16 VAlign: Top + WordWrap: true Button@BACK_BUTTON: Y: PARENT_BOTTOM - 1 Width: 140 diff --git a/mods/common/chrome/credits.yaml b/mods/common/chrome/credits.yaml index caea8ef20d..f23e4af448 100644 --- a/mods/common/chrome/credits.yaml +++ b/mods/common/chrome/credits.yaml @@ -38,9 +38,10 @@ Background@CREDITS_PANEL: Children: Label@CREDITS_TEMPLATE: X: 8 - Width: PARENT_RIGHT - 25 + Width: PARENT_RIGHT - 24 - 2 * 8 Height: 16 VAlign: Top + WordWrap: true Button@BACK_BUTTON: X: PARENT_RIGHT - 180 Y: PARENT_BOTTOM - 45