diff --git a/OpenRA.Mods.Cnc/CncColorPickerPaletteModifier.cs b/OpenRA.Mods.Cnc/CncColorPickerPaletteModifier.cs deleted file mode 100644 index c575a36a74..0000000000 --- a/OpenRA.Mods.Cnc/CncColorPickerPaletteModifier.cs +++ /dev/null @@ -1,47 +0,0 @@ -#region Copyright & License Information -/* - * Copyright 2007-2011 The OpenRA Developers (see AUTHORS) - * 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. For more information, - * see COPYING. - */ -#endregion - -using System.Collections.Generic; -using System.Linq; -using OpenRA.FileFormats; -using OpenRA.Graphics; -using OpenRA.Traits; - -namespace OpenRA.Mods.Cnc -{ - class CncColorPickerPaletteModifierInfo : ITraitInfo - { - public string PlayerPalette = "player"; - public object Create( ActorInitializer init ) { return new CncColorPickerPaletteModifier( this ); } - } - - class CncColorPickerPaletteModifier : IPalette, IPaletteModifier - { - CncColorPickerPaletteModifierInfo Info; - PaletteFormat format; - public ColorRamp Ramp; - - public CncColorPickerPaletteModifier(CncColorPickerPaletteModifierInfo info) { Info = info; } - - public void InitPalette( WorldRenderer wr ) - { - var info = Rules.Info["player"].Traits.WithInterface() - .First(p => p.BaseName == Info.PlayerPalette); - format = info.PaletteFormat; - wr.AddPalette("colorpicker", wr.GetPalette(info.BasePalette)); - } - - public void AdjustPalette(Dictionary palettes) - { - palettes["colorpicker"] = new Palette(palettes["colorpicker"], - new PlayerColorRemap(Ramp, format)); - } - } -} diff --git a/OpenRA.Mods.Cnc/OpenRA.Mods.Cnc.csproj b/OpenRA.Mods.Cnc/OpenRA.Mods.Cnc.csproj index 982507eeb7..8640d51349 100644 --- a/OpenRA.Mods.Cnc/OpenRA.Mods.Cnc.csproj +++ b/OpenRA.Mods.Cnc/OpenRA.Mods.Cnc.csproj @@ -1,4 +1,4 @@ - + Debug @@ -53,7 +53,6 @@ - diff --git a/OpenRA.Mods.Cnc/Widgets/Logic/CncLobbyLogic.cs b/OpenRA.Mods.Cnc/Widgets/Logic/CncLobbyLogic.cs index 9b9bce2dfa..0287a970ba 100644 --- a/OpenRA.Mods.Cnc/Widgets/Logic/CncLobbyLogic.cs +++ b/OpenRA.Mods.Cnc/Widgets/Logic/CncLobbyLogic.cs @@ -16,6 +16,7 @@ using OpenRA.FileFormats; using OpenRA.Network; using OpenRA.Traits; using OpenRA.Widgets; +using OpenRA.Mods.RA; using OpenRA.Mods.RA.Widgets.Logic; namespace OpenRA.Mods.Cnc.Widgets.Logic @@ -32,7 +33,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic string MapUid; Map Map; - CncColorPickerPaletteModifier PlayerPalettePreview; + ColorPickerPaletteModifier PlayerPalettePreview; readonly Action OnGameStart; readonly Action onExit; @@ -102,7 +103,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic Game.ConnectionStateChanged += ConnectionStateChanged; UpdateCurrentMap(); - PlayerPalettePreview = world.WorldActor.Trait(); + PlayerPalettePreview = world.WorldActor.Trait(); PlayerPalettePreview.Ramp = Game.Settings.Player.ColorRamp; Players = lobby.GetWidget("PLAYERS"); EditablePlayerTemplate = Players.GetWidget("TEMPLATE_EDITABLE_PLAYER"); diff --git a/OpenRA.Mods.Cnc/Widgets/Logic/CncSettingsLogic.cs b/OpenRA.Mods.Cnc/Widgets/Logic/CncSettingsLogic.cs index 8e8009b3c6..dc6cf375c8 100644 --- a/OpenRA.Mods.Cnc/Widgets/Logic/CncSettingsLogic.cs +++ b/OpenRA.Mods.Cnc/Widgets/Logic/CncSettingsLogic.cs @@ -14,6 +14,7 @@ using System.Linq; using OpenRA.FileFormats; using OpenRA.FileFormats.Graphics; using OpenRA.GameRules; +using OpenRA.Mods.RA; using OpenRA.Mods.RA.Widgets.Logic; using OpenRA.Widgets; @@ -24,7 +25,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic enum PanelType { General, Input } PanelType Settings = PanelType.General; - CncColorPickerPaletteModifier playerPalettePreview; + ColorPickerPaletteModifier playerPalettePreview; World world; [ObjectCreator.UseCtor] @@ -53,7 +54,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic var nameTextfield = generalPane.GetWidget("NAME_TEXTFIELD"); nameTextfield.Text = playerSettings.Name; - playerPalettePreview = world.WorldActor.Trait(); + playerPalettePreview = world.WorldActor.Trait(); playerPalettePreview.Ramp = playerSettings.ColorRamp; var colorDropdown = generalPane.GetWidget("COLOR_DROPDOWN"); diff --git a/OpenRA.Mods.RA/ColorPickerPaletteModifier.cs b/OpenRA.Mods.RA/ColorPickerPaletteModifier.cs index a5c5d34e0c..b8db9393b2 100644 --- a/OpenRA.Mods.RA/ColorPickerPaletteModifier.cs +++ b/OpenRA.Mods.RA/ColorPickerPaletteModifier.cs @@ -12,29 +12,28 @@ using System.Collections.Generic; using System.Linq; using OpenRA.FileFormats; using OpenRA.Graphics; -using OpenRA.Mods.RA.Widgets.Logic; using OpenRA.Traits; namespace OpenRA.Mods.RA { - class ColorPickerPaletteModifierInfo : ITraitInfo + public class ColorPickerPaletteModifierInfo : ITraitInfo { public string PlayerPalette = "player"; public object Create( ActorInitializer init ) { return new ColorPickerPaletteModifier( this ); } } - class ColorPickerPaletteModifier : IPalette, IPaletteModifier + public class ColorPickerPaletteModifier : IPalette, IPaletteModifier { ColorPickerPaletteModifierInfo Info; PaletteFormat format; + public ColorRamp Ramp; public ColorPickerPaletteModifier(ColorPickerPaletteModifierInfo info) { Info = info; } public void InitPalette( WorldRenderer wr ) { var info = Rules.Info["player"].Traits.WithInterface() - .Where(p => p.BaseName == Info.PlayerPalette) - .First(); + .First(p => p.BaseName == Info.PlayerPalette); format = info.PaletteFormat; wr.AddPalette("colorpicker", wr.GetPalette(info.BasePalette)); } @@ -42,7 +41,7 @@ namespace OpenRA.Mods.RA public void AdjustPalette(Dictionary palettes) { palettes["colorpicker"] = new Palette(palettes["colorpicker"], - new PlayerColorRemap(LobbyLogic.CurrentColorPreview, format)); + new PlayerColorRemap(Ramp, format)); } } } diff --git a/OpenRA.Mods.RA/RALoadScreen.cs b/OpenRA.Mods.RA/RALoadScreen.cs index d4924db465..fb6ce1f9dd 100644 --- a/OpenRA.Mods.RA/RALoadScreen.cs +++ b/OpenRA.Mods.RA/RALoadScreen.cs @@ -88,7 +88,7 @@ namespace OpenRA.Mods.RA new WidgetArgs() { { "orderManager", orderManager } }); break; case ConnectionState.Connected: - var lobby = Game.OpenWindow(orderManager.world, "SERVER_LOBBY"); + var lobby = Game.OpenWindow("SERVER_LOBBY", new WidgetArgs {}); lobby.GetWidget("CHAT_DISPLAY").ClearChat(); lobby.GetWidget("CHANGEMAP_BUTTON").Visible = true; lobby.GetWidget("ALLOWCHEATS_CHECKBOX").Visible = true; diff --git a/OpenRA.Mods.RA/Widgets/Logic/LobbyLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/LobbyLogic.cs index 36ffc7dd41..5ba4a0253f 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/LobbyLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/LobbyLogic.cs @@ -30,12 +30,14 @@ namespace OpenRA.Mods.RA.Widgets.Logic string MapUid; Map Map; - public static ColorRamp CurrentColorPreview; + ColorPickerPaletteModifier PlayerPalettePreview; readonly OrderManager orderManager; readonly WorldRenderer worldRenderer; + [ObjectCreator.UseCtor] internal LobbyLogic([ObjectCreator.Param( "widget" )] Widget lobby, + [ObjectCreator.Param] World world, // Shellmap world [ObjectCreator.Param] OrderManager orderManager, [ObjectCreator.Param] WorldRenderer worldRenderer) { @@ -47,7 +49,8 @@ namespace OpenRA.Mods.RA.Widgets.Logic Game.LobbyInfoChanged += UpdatePlayerList; UpdateCurrentMap(); - CurrentColorPreview = Game.Settings.Player.ColorRamp; + PlayerPalettePreview = world.WorldActor.Trait(); + PlayerPalettePreview.Ramp = Game.Settings.Player.ColorRamp; Players = lobby.GetWidget("PLAYERS"); LocalPlayerTemplate = Players.GetWidget("TEMPLATE_LOCAL"); @@ -208,7 +211,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic void UpdateColorPreview(float hf, float sf, float lf, float r) { - CurrentColorPreview = new ColorRamp((byte)(hf * 255), (byte)(sf * 255), (byte)(lf * 255), (byte)(r * 255)); + PlayerPalettePreview.Ramp = new ColorRamp((byte)(hf * 255), (byte)(sf * 255), (byte)(lf * 255), (byte)(r * 255)); } void UpdateCurrentMap() diff --git a/mods/cnc/rules/system.yaml b/mods/cnc/rules/system.yaml index cc4f5da29e..6685e48ae3 100644 --- a/mods/cnc/rules/system.yaml +++ b/mods/cnc/rules/system.yaml @@ -84,7 +84,7 @@ World: G: 0 B: 0 A: 180 - CncColorPickerPaletteModifier: + ColorPickerPaletteModifier: ShroudPalette@shroud: ShroudPalette@fog: IsFog: yes