Extract version label chrome logic to a dedicated class
This commit is contained in:
@@ -20,13 +20,6 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{
|
||||
widget.Get<ProgressBarWidget>("PROGRESS").GetPercentage = () => world.GameSaveLoadingPercentage;
|
||||
|
||||
var versionLabel = widget.GetOrNull<LabelWidget>("VERSION_LABEL");
|
||||
if (versionLabel != null)
|
||||
{
|
||||
var versionText = modData.Manifest.Metadata.Version;
|
||||
versionLabel.GetText = () => versionText;
|
||||
}
|
||||
|
||||
var keyhandler = widget.Get<LogicKeyListenerWidget>("CANCEL_HANDLER");
|
||||
keyhandler.AddHandler(e =>
|
||||
{
|
||||
|
||||
@@ -187,9 +187,6 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
mpe = world.WorldActor.TraitOrDefault<MenuPostProcessEffect>();
|
||||
mpe?.Fade(mpe.Info.MenuEffect);
|
||||
|
||||
var versionText = modData.Manifest.Metadata.Version;
|
||||
menu.Get<LabelWidget>("VERSION_LABEL").GetText = () => versionText;
|
||||
|
||||
buttonContainer = menu.Get("MENU_BUTTONS");
|
||||
buttonTemplate = buttonContainer.Get<ButtonWidget>("BUTTON_TEMPLATE");
|
||||
buttonContainer.RemoveChild(buttonTemplate);
|
||||
|
||||
@@ -69,8 +69,6 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
this.modData = modData;
|
||||
|
||||
rootMenu = widget;
|
||||
var versionText = modData.Manifest.Metadata.Version;
|
||||
rootMenu.Get<LabelWidget>("VERSION_LABEL").GetText = () => versionText;
|
||||
|
||||
// Menu buttons
|
||||
var mainMenu = widget.Get("MAIN_MENU");
|
||||
|
||||
25
OpenRA.Mods.Common/Widgets/Logic/VersionLabelLogic.cs
Normal file
25
OpenRA.Mods.Common/Widgets/Logic/VersionLabelLogic.cs
Normal file
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user