Extract player profile loading chrome logic to a dedicated class

This commit is contained in:
Ivaylo Draganov
2024-10-03 12:17:08 +03:00
committed by Gustas
parent ca3ab78cf8
commit 791595e3ae
5 changed files with 33 additions and 10 deletions

View File

@@ -0,0 +1,30 @@
#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 System;
using OpenRA.Widgets;
namespace OpenRA.Mods.Common.Widgets.Logic
{
public class LoadLocalPlayerProfileLogic : ChromeLogic
{
[ObjectCreator.UseCtor]
public LoadLocalPlayerProfileLogic(Widget widget, World world)
{
Func<bool> minimalProfile = () => Ui.CurrentWindow() != null;
Game.LoadWidget(world, "LOCAL_PROFILE_PANEL", widget, new WidgetArgs()
{
{ "minimalProfile", minimalProfile }
});
}
}
}

View File

@@ -255,16 +255,6 @@ namespace OpenRA.Mods.Common.Widgets.Logic
menuType != MenuType.StartupPrompts &&
webServices.ModVersionStatus == ModVersionStatus.Outdated;
var playerProfile = widget.GetOrNull("PLAYER_PROFILE_CONTAINER");
if (playerProfile != null)
{
Func<bool> minimalProfile = () => Ui.CurrentWindow() != null;
Game.LoadWidget(world, "LOCAL_PROFILE_PANEL", playerProfile, new WidgetArgs()
{
{ "minimalProfile", minimalProfile }
});
}
menuType = MenuType.StartupPrompts;
void OnIntroductionComplete()

View File

@@ -274,5 +274,6 @@ Container@MENU_BACKGROUND:
Width: 200
Height: 200
Container@PLAYER_PROFILE_CONTAINER:
Logic: LoadLocalPlayerProfileLogic
X: 31
Y: 31

View File

@@ -274,5 +274,6 @@ Container@MAINMENU:
Shadow: true
Text: label-update-notice-b
Container@PLAYER_PROFILE_CONTAINER:
Logic: LoadLocalPlayerProfileLogic
X: 25
Y: 25

View File

@@ -267,5 +267,6 @@ Container@MAINMENU:
Width: 200
Height: 200
Container@PLAYER_PROFILE_CONTAINER:
Logic: LoadLocalPlayerProfileLogic
X: 5
Y: 5