diff --git a/OpenRA.Mods.Common/Widgets/Logic/Ingame/GameSaveLoadingLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Ingame/GameSaveLoadingLogic.cs index 312626a2c3..9983b67741 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Ingame/GameSaveLoadingLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Ingame/GameSaveLoadingLogic.cs @@ -20,13 +20,6 @@ namespace OpenRA.Mods.Common.Widgets.Logic { widget.Get("PROGRESS").GetPercentage = () => world.GameSaveLoadingPercentage; - var versionLabel = widget.GetOrNull("VERSION_LABEL"); - if (versionLabel != null) - { - var versionText = modData.Manifest.Metadata.Version; - versionLabel.GetText = () => versionText; - } - var keyhandler = widget.Get("CANCEL_HANDLER"); keyhandler.AddHandler(e => { diff --git a/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngameMenuLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngameMenuLogic.cs index 8b38d0d8eb..24e9b58ce9 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngameMenuLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngameMenuLogic.cs @@ -187,9 +187,6 @@ namespace OpenRA.Mods.Common.Widgets.Logic mpe = world.WorldActor.TraitOrDefault(); mpe?.Fade(mpe.Info.MenuEffect); - var versionText = modData.Manifest.Metadata.Version; - menu.Get("VERSION_LABEL").GetText = () => versionText; - buttonContainer = menu.Get("MENU_BUTTONS"); buttonTemplate = buttonContainer.Get("BUTTON_TEMPLATE"); buttonContainer.RemoveChild(buttonTemplate); diff --git a/OpenRA.Mods.Common/Widgets/Logic/MainMenuLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/MainMenuLogic.cs index ddc5fa7da5..e1a98448fd 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/MainMenuLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/MainMenuLogic.cs @@ -69,8 +69,6 @@ namespace OpenRA.Mods.Common.Widgets.Logic this.modData = modData; rootMenu = widget; - var versionText = modData.Manifest.Metadata.Version; - rootMenu.Get("VERSION_LABEL").GetText = () => versionText; // Menu buttons var mainMenu = widget.Get("MAIN_MENU"); diff --git a/OpenRA.Mods.Common/Widgets/Logic/VersionLabelLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/VersionLabelLogic.cs new file mode 100644 index 0000000000..0c76da5ed3 --- /dev/null +++ b/OpenRA.Mods.Common/Widgets/Logic/VersionLabelLogic.cs @@ -0,0 +1,25 @@ +#region Copyright & License Information +/* + * Copyright (c) The OpenRA Developers and Contributors + * This file is part of OpenRA, which is free software. It is made + * available to you under the terms of the GNU General Public License + * as published by the Free Software Foundation, either version 3 of + * the License, or (at your option) any later version. For more + * information, see COPYING. + */ +#endregion + +using OpenRA.Widgets; + +namespace OpenRA.Mods.Common.Widgets.Logic +{ + public class VersionLabelLogic : ChromeLogic + { + [ObjectCreator.UseCtor] + public VersionLabelLogic(LabelWidget widget, ModData modData) + { + var versionText = modData.Manifest.Metadata.Version; + widget.GetText = () => versionText; + } + } +} diff --git a/mods/cnc/chrome/gamesave-loading.yaml b/mods/cnc/chrome/gamesave-loading.yaml index 8bcfe90e4f..432558f1a5 100644 --- a/mods/cnc/chrome/gamesave-loading.yaml +++ b/mods/cnc/chrome/gamesave-loading.yaml @@ -22,6 +22,7 @@ Container@GAMESAVE_LOADING_SCREEN: ImageCollection: logos ImageName: eva Label@VERSION_LABEL: + Logic: VersionLabelLogic X: WINDOW_RIGHT - 128 - 43 Y: 116 Width: 128 diff --git a/mods/cnc/chrome/ingame-menu.yaml b/mods/cnc/chrome/ingame-menu.yaml index 4f6330dd36..06b1e8f131 100644 --- a/mods/cnc/chrome/ingame-menu.yaml +++ b/mods/cnc/chrome/ingame-menu.yaml @@ -13,6 +13,7 @@ Container@INGAME_MENU: ImageCollection: logos ImageName: eva Label@VERSION_LABEL: + Logic: VersionLabelLogic X: WINDOW_RIGHT - 128 - 43 Y: 116 Width: 128 diff --git a/mods/cnc/chrome/mainmenu.yaml b/mods/cnc/chrome/mainmenu.yaml index 3e54ceb388..23787d5256 100644 --- a/mods/cnc/chrome/mainmenu.yaml +++ b/mods/cnc/chrome/mainmenu.yaml @@ -31,6 +31,7 @@ Container@MENU_BACKGROUND: ImageCollection: logos ImageName: eva Label@VERSION_LABEL: + Logic: VersionLabelLogic X: WINDOW_RIGHT - 128 - 43 Y: 116 Width: 128 diff --git a/mods/common/chrome/ingame-menu.yaml b/mods/common/chrome/ingame-menu.yaml index 079763cfb9..d1529226a3 100644 --- a/mods/common/chrome/ingame-menu.yaml +++ b/mods/common/chrome/ingame-menu.yaml @@ -17,6 +17,7 @@ Container@INGAME_MENU: ImageCollection: logos ImageName: logo Label@VERSION_LABEL: + Logic: VersionLabelLogic X: WINDOW_RIGHT - 296 Y: 296 - 19 Width: 296 - 20 diff --git a/mods/common/chrome/mainmenu.yaml b/mods/common/chrome/mainmenu.yaml index 88971366db..e25a3148fa 100644 --- a/mods/common/chrome/mainmenu.yaml +++ b/mods/common/chrome/mainmenu.yaml @@ -21,6 +21,7 @@ Container@MAINMENU: ImageCollection: logos ImageName: logo Label@VERSION_LABEL: + Logic: VersionLabelLogic X: WINDOW_RIGHT - 296 Y: 296 - 20 Width: 296 - 20 diff --git a/mods/d2k/chrome/ingame-menu.yaml b/mods/d2k/chrome/ingame-menu.yaml index a71fd0e81a..c2a212ae73 100644 --- a/mods/d2k/chrome/ingame-menu.yaml +++ b/mods/d2k/chrome/ingame-menu.yaml @@ -6,6 +6,7 @@ Container@INGAME_MENU: ButtonStride: 0, 40 Children: Label@VERSION_LABEL: + Logic: VersionLabelLogic X: WINDOW_RIGHT - 10 Y: WINDOW_BOTTOM - 19 Align: Right diff --git a/mods/d2k/chrome/mainmenu.yaml b/mods/d2k/chrome/mainmenu.yaml index e6b060d123..6005f322e9 100644 --- a/mods/d2k/chrome/mainmenu.yaml +++ b/mods/d2k/chrome/mainmenu.yaml @@ -10,6 +10,7 @@ Container@MAINMENU: TakeScreenshotKey: TakeScreenshot MuteAudioKey: ToggleMute Label@VERSION_LABEL: + Logic: VersionLabelLogic X: WINDOW_RIGHT - 10 Y: WINDOW_BOTTOM - 19 Align: Right