Don't use a static variable for player palette preview.

This commit is contained in:
Paul Chote
2011-05-13 16:36:33 +12:00
parent 1526b6ff37
commit 3e2a49934c
2 changed files with 8 additions and 7 deletions

View File

@@ -27,6 +27,7 @@ namespace OpenRA.Mods.Cnc
{ {
CncColorPickerPaletteModifierInfo Info; CncColorPickerPaletteModifierInfo Info;
PaletteFormat format; PaletteFormat format;
public ColorRamp Ramp;
public CncColorPickerPaletteModifier(CncColorPickerPaletteModifierInfo info) { Info = info; } public CncColorPickerPaletteModifier(CncColorPickerPaletteModifierInfo info) { Info = info; }
@@ -42,7 +43,7 @@ namespace OpenRA.Mods.Cnc
public void AdjustPalette(Dictionary<string, Palette> palettes) public void AdjustPalette(Dictionary<string, Palette> palettes)
{ {
palettes["colorpicker"] = new Palette(palettes["colorpicker"], palettes["colorpicker"] = new Palette(palettes["colorpicker"],
new PlayerColorRemap(CncLobbyLogic.CurrentColorPreview, format)); new PlayerColorRemap(Ramp, format));
} }
} }
} }

View File

@@ -31,11 +31,12 @@ namespace OpenRA.Mods.Cnc.Widgets
string MapUid; string MapUid;
Map Map; Map Map;
CncColorPickerPaletteModifier PlayerPalettePreview;
readonly Action OnGameStart; readonly Action OnGameStart;
readonly Action onExit; readonly Action onExit;
readonly OrderManager orderManager; readonly OrderManager orderManager;
public static ColorRamp CurrentColorPreview;
static bool staticSetup; static bool staticSetup;
public static CncLobbyLogic GetHandler() public static CncLobbyLogic GetHandler()
{ {
@@ -118,6 +119,7 @@ namespace OpenRA.Mods.Cnc.Widgets
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
internal CncLobbyLogic([ObjectCreator.Param( "widget" )] Widget lobby, internal CncLobbyLogic([ObjectCreator.Param( "widget" )] Widget lobby,
[ObjectCreator.Param] World world, // Shellmap world
[ObjectCreator.Param] OrderManager orderManager, [ObjectCreator.Param] OrderManager orderManager,
[ObjectCreator.Param] Action onExit, [ObjectCreator.Param] Action onExit,
[ObjectCreator.Param] Action onStart) [ObjectCreator.Param] Action onStart)
@@ -136,8 +138,8 @@ namespace OpenRA.Mods.Cnc.Widgets
} }
UpdateCurrentMap(); UpdateCurrentMap();
CurrentColorPreview = Game.Settings.Player.ColorRamp; PlayerPalettePreview = world.WorldActor.Trait<CncColorPickerPaletteModifier>();
PlayerPalettePreview.Ramp = Game.Settings.Player.ColorRamp;
Players = lobby.GetWidget<ScrollPanelWidget>("PLAYERS"); Players = lobby.GetWidget<ScrollPanelWidget>("PLAYERS");
LocalPlayerTemplate = Players.GetWidget("TEMPLATE_LOCAL"); LocalPlayerTemplate = Players.GetWidget("TEMPLATE_LOCAL");
RemotePlayerTemplate = Players.GetWidget("TEMPLATE_REMOTE"); RemotePlayerTemplate = Players.GetWidget("TEMPLATE_REMOTE");
@@ -399,7 +401,7 @@ namespace OpenRA.Mods.Cnc.Widgets
Action<ColorRamp> onChange = c => Action<ColorRamp> onChange = c =>
{ {
CurrentColorPreview = c; PlayerPalettePreview.Ramp = c;
}; };
var colorChooser = Game.LoadWidget(orderManager.world, "COLOR_CHOOSER", null, new WidgetArgs() var colorChooser = Game.LoadWidget(orderManager.world, "COLOR_CHOOSER", null, new WidgetArgs()
@@ -409,8 +411,6 @@ namespace OpenRA.Mods.Cnc.Widgets
{ "initialRamp", orderManager.LocalClient.ColorRamp } { "initialRamp", orderManager.LocalClient.ColorRamp }
}); });
Console.WriteLine(colorChooser.Id);
CncDropDownButtonWidget.ShowDropPanel(color, colorChooser, new List<Widget>() { colorChooser.GetWidget("SAVE_BUTTON") }, () => true); CncDropDownButtonWidget.ShowDropPanel(color, colorChooser, new List<Widget>() { colorChooser.GetWidget("SAVE_BUTTON") }, () => true);
return true; return true;
} }