Skip to content

Commit 99001ae

Browse files
committed
Extract player profile loading chrome logic to a dedicated class
1 parent 7688e06 commit 99001ae

File tree

5 files changed

+33
-10
lines changed

5 files changed

+33
-10
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#region Copyright & License Information
2+
/*
3+
* Copyright (c) The OpenRA Developers and Contributors
4+
* This file is part of OpenRA, which is free software. It is made
5+
* available to you under the terms of the GNU General Public License
6+
* as published by the Free Software Foundation, either version 3 of
7+
* the License, or (at your option) any later version. For more
8+
* information, see COPYING.
9+
*/
10+
#endregion
11+
12+
using System;
13+
using OpenRA.Widgets;
14+
15+
namespace OpenRA.Mods.Common.Widgets.Logic
16+
{
17+
public class LoadLocalPlayerProfileLogic : ChromeLogic
18+
{
19+
[ObjectCreator.UseCtor]
20+
public LoadLocalPlayerProfileLogic(Widget widget, World world)
21+
{
22+
Func<bool> minimalProfile = () => Ui.CurrentWindow() != null;
23+
24+
Game.LoadWidget(world, "LOCAL_PROFILE_PANEL", widget, new WidgetArgs()
25+
{
26+
{ "minimalProfile", minimalProfile }
27+
});
28+
}
29+
}
30+
}

OpenRA.Mods.Common/Widgets/Logic/MainMenuLogic.cs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -243,16 +243,6 @@ public MainMenuLogic(Widget widget, World world, ModData modData)
243243
menuType != MenuType.StartupPrompts &&
244244
webServices.ModVersionStatus == ModVersionStatus.Outdated;
245245

246-
var playerProfile = widget.GetOrNull("PLAYER_PROFILE_CONTAINER");
247-
if (playerProfile != null)
248-
{
249-
Func<bool> minimalProfile = () => Ui.CurrentWindow() != null;
250-
Game.LoadWidget(world, "LOCAL_PROFILE_PANEL", playerProfile, new WidgetArgs()
251-
{
252-
{ "minimalProfile", minimalProfile }
253-
});
254-
}
255-
256246
menuType = MenuType.StartupPrompts;
257247

258248
void OnIntroductionComplete()

mods/cnc/chrome/mainmenu.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,5 +273,6 @@ Container@MENU_BACKGROUND:
273273
Width: 200
274274
Height: 200
275275
Container@PLAYER_PROFILE_CONTAINER:
276+
Logic: LoadLocalPlayerProfileLogic
276277
X: 31
277278
Y: 31

mods/common/chrome/mainmenu.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ Container@MAINMENU:
273273
Shadow: true
274274
Text: label-update-notice-b
275275
Container@PLAYER_PROFILE_CONTAINER:
276+
Logic: LoadLocalPlayerProfileLogic
276277
X: 25
277278
Y: 25
278279

mods/d2k/chrome/mainmenu.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,5 +266,6 @@ Container@MAINMENU:
266266
Width: 200
267267
Height: 200
268268
Container@PLAYER_PROFILE_CONTAINER:
269+
Logic: LoadLocalPlayerProfileLogic
269270
X: 5
270271
Y: 5

0 commit comments

Comments
 (0)