Use static ctors for static setup.
This commit is contained in:
@@ -16,11 +16,15 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
{
|
{
|
||||||
public class CncConnectingLogic
|
public class CncConnectingLogic
|
||||||
{
|
{
|
||||||
static bool staticSetup;
|
|
||||||
Action onConnect, onRetry, onAbort;
|
Action onConnect, onRetry, onAbort;
|
||||||
string host;
|
string host;
|
||||||
int port;
|
int port;
|
||||||
|
|
||||||
|
static CncConnectingLogic()
|
||||||
|
{
|
||||||
|
Game.ConnectionStateChanged += ConnectionStateChangedStub;
|
||||||
|
}
|
||||||
|
|
||||||
static void ConnectionStateChangedStub(OrderManager om)
|
static void ConnectionStateChangedStub(OrderManager om)
|
||||||
{
|
{
|
||||||
var panel = Widget.RootWidget.GetWidget("CONNECTING_PANEL");
|
var panel = Widget.RootWidget.GetWidget("CONNECTING_PANEL");
|
||||||
@@ -68,11 +72,6 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
this.onConnect = onConnect;
|
this.onConnect = onConnect;
|
||||||
this.onRetry = onRetry;
|
this.onRetry = onRetry;
|
||||||
this.onAbort = onAbort;
|
this.onAbort = onAbort;
|
||||||
if (!staticSetup)
|
|
||||||
{
|
|
||||||
staticSetup = true;
|
|
||||||
Game.ConnectionStateChanged += ConnectionStateChangedStub;
|
|
||||||
}
|
|
||||||
|
|
||||||
var panel = widget.GetWidget("CONNECTING_PANEL");
|
var panel = widget.GetWidget("CONNECTING_PANEL");
|
||||||
panel.GetWidget<ButtonWidget>("ABORT_BUTTON").OnClick = () => { Widget.CloseWindow(); onAbort(); };
|
panel.GetWidget<ButtonWidget>("ABORT_BUTTON").OnClick = () => { Widget.CloseWindow(); onAbort(); };
|
||||||
|
|||||||
@@ -19,9 +19,13 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
enum MenuType { None, Diplomacy, Cheats }
|
enum MenuType { None, Diplomacy, Cheats }
|
||||||
MenuType menu = MenuType.None;
|
MenuType menu = MenuType.None;
|
||||||
|
|
||||||
static bool staticSetup;
|
|
||||||
Widget ingameRoot;
|
Widget ingameRoot;
|
||||||
|
|
||||||
|
static CncIngameChromeLogic()
|
||||||
|
{
|
||||||
|
Game.AddChatLine += AddChatLineStub;
|
||||||
|
}
|
||||||
|
|
||||||
static void AddChatLineStub(Color c, string from, string text)
|
static void AddChatLineStub(Color c, string from, string text)
|
||||||
{
|
{
|
||||||
var panel = Widget.RootWidget.GetWidget("INGAME_ROOT");
|
var panel = Widget.RootWidget.GetWidget("INGAME_ROOT");
|
||||||
@@ -49,11 +53,6 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
.Fade(CncMenuPaletteEffect.EffectType.None);
|
.Fade(CncMenuPaletteEffect.EffectType.None);
|
||||||
|
|
||||||
ingameRoot = widget.GetWidget("INGAME_ROOT");
|
ingameRoot = widget.GetWidget("INGAME_ROOT");
|
||||||
if (!staticSetup)
|
|
||||||
{
|
|
||||||
staticSetup = true;
|
|
||||||
Game.AddChatLine += AddChatLineStub;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (world.LocalPlayer != null)
|
if (world.LocalPlayer != null)
|
||||||
widget.GetWidget("PLAYER_WIDGETS").IsVisible = () => true;
|
widget.GetWidget("PLAYER_WIDGETS").IsVisible = () => true;
|
||||||
|
|||||||
@@ -37,7 +37,14 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
readonly Action onExit;
|
readonly Action onExit;
|
||||||
readonly OrderManager orderManager;
|
readonly OrderManager orderManager;
|
||||||
|
|
||||||
static bool staticSetup;
|
static CncLobbyLogic()
|
||||||
|
{
|
||||||
|
Game.LobbyInfoChanged += LobbyInfoChangedStub;
|
||||||
|
Game.BeforeGameStart += BeforeGameStartStub;
|
||||||
|
Game.AddChatLine += AddChatLineStub;
|
||||||
|
Game.ConnectionStateChanged += ConnectionStateChangedStub;
|
||||||
|
}
|
||||||
|
|
||||||
public static CncLobbyLogic GetHandler()
|
public static CncLobbyLogic GetHandler()
|
||||||
{
|
{
|
||||||
var panel = Widget.RootWidget.GetWidget("SERVER_LOBBY");
|
var panel = Widget.RootWidget.GetWidget("SERVER_LOBBY");
|
||||||
@@ -128,15 +135,6 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
this.OnGameStart = () => { Widget.CloseWindow(); onStart(); };
|
this.OnGameStart = () => { Widget.CloseWindow(); onStart(); };
|
||||||
this.onExit = onExit;
|
this.onExit = onExit;
|
||||||
|
|
||||||
if (!staticSetup)
|
|
||||||
{
|
|
||||||
staticSetup = true;
|
|
||||||
Game.LobbyInfoChanged += LobbyInfoChangedStub;
|
|
||||||
Game.BeforeGameStart += BeforeGameStartStub;
|
|
||||||
Game.AddChatLine += AddChatLineStub;
|
|
||||||
Game.ConnectionStateChanged += ConnectionStateChangedStub;
|
|
||||||
}
|
|
||||||
|
|
||||||
UpdateCurrentMap();
|
UpdateCurrentMap();
|
||||||
PlayerPalettePreview = world.WorldActor.Trait<CncColorPickerPaletteModifier>();
|
PlayerPalettePreview = world.WorldActor.Trait<CncColorPickerPaletteModifier>();
|
||||||
PlayerPalettePreview.Ramp = Game.Settings.Player.ColorRamp;
|
PlayerPalettePreview.Ramp = Game.Settings.Player.ColorRamp;
|
||||||
|
|||||||
Reference in New Issue
Block a user