Skip to content

Commit f73043d

Browse files
committed
Extract player profile loading chrome logic to a dedicated class
1 parent 85277b5 commit f73043d

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
@@ -255,16 +255,6 @@ public MainMenuLogic(Widget widget, World world, ModData modData)
255255
menuType != MenuType.StartupPrompts &&
256256
webServices.ModVersionStatus == ModVersionStatus.Outdated;
257257

258-
var playerProfile = widget.GetOrNull("PLAYER_PROFILE_CONTAINER");
259-
if (playerProfile != null)
260-
{
261-
Func<bool> minimalProfile = () => Ui.CurrentWindow() != null;
262-
Game.LoadWidget(world, "LOCAL_PROFILE_PANEL", playerProfile, new WidgetArgs()
263-
{
264-
{ "minimalProfile", minimalProfile }
265-
});
266-
}
267-
268258
menuType = MenuType.StartupPrompts;
269259

270260
void OnIntroductionComplete()

mods/cnc/chrome/mainmenu.yaml

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

mods/common/chrome/mainmenu.yaml

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

mods/d2k/chrome/mainmenu.yaml

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

0 commit comments

Comments
 (0)