Don't use a static variable for player palette preview.
This commit is contained in:
@@ -27,6 +27,7 @@ namespace OpenRA.Mods.Cnc
|
||||
{
|
||||
CncColorPickerPaletteModifierInfo Info;
|
||||
PaletteFormat format;
|
||||
public ColorRamp Ramp;
|
||||
|
||||
public CncColorPickerPaletteModifier(CncColorPickerPaletteModifierInfo info) { Info = info; }
|
||||
|
||||
@@ -42,7 +43,7 @@ namespace OpenRA.Mods.Cnc
|
||||
public void AdjustPalette(Dictionary<string, Palette> palettes)
|
||||
{
|
||||
palettes["colorpicker"] = new Palette(palettes["colorpicker"],
|
||||
new PlayerColorRemap(CncLobbyLogic.CurrentColorPreview, format));
|
||||
new PlayerColorRemap(Ramp, format));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,11 +31,12 @@ namespace OpenRA.Mods.Cnc.Widgets
|
||||
string MapUid;
|
||||
Map Map;
|
||||
|
||||
CncColorPickerPaletteModifier PlayerPalettePreview;
|
||||
|
||||
readonly Action OnGameStart;
|
||||
readonly Action onExit;
|
||||
readonly OrderManager orderManager;
|
||||
|
||||
public static ColorRamp CurrentColorPreview;
|
||||
static bool staticSetup;
|
||||
public static CncLobbyLogic GetHandler()
|
||||
{
|
||||
@@ -118,6 +119,7 @@ namespace OpenRA.Mods.Cnc.Widgets
|
||||
|
||||
[ObjectCreator.UseCtor]
|
||||
internal CncLobbyLogic([ObjectCreator.Param( "widget" )] Widget lobby,
|
||||
[ObjectCreator.Param] World world, // Shellmap world
|
||||
[ObjectCreator.Param] OrderManager orderManager,
|
||||
[ObjectCreator.Param] Action onExit,
|
||||
[ObjectCreator.Param] Action onStart)
|
||||
@@ -136,8 +138,8 @@ namespace OpenRA.Mods.Cnc.Widgets
|
||||
}
|
||||
|
||||
UpdateCurrentMap();
|
||||
CurrentColorPreview = Game.Settings.Player.ColorRamp;
|
||||
|
||||
PlayerPalettePreview = world.WorldActor.Trait<CncColorPickerPaletteModifier>();
|
||||
PlayerPalettePreview.Ramp = Game.Settings.Player.ColorRamp;
|
||||
Players = lobby.GetWidget<ScrollPanelWidget>("PLAYERS");
|
||||
LocalPlayerTemplate = Players.GetWidget("TEMPLATE_LOCAL");
|
||||
RemotePlayerTemplate = Players.GetWidget("TEMPLATE_REMOTE");
|
||||
@@ -399,7 +401,7 @@ namespace OpenRA.Mods.Cnc.Widgets
|
||||
|
||||
Action<ColorRamp> onChange = c =>
|
||||
{
|
||||
CurrentColorPreview = c;
|
||||
PlayerPalettePreview.Ramp = c;
|
||||
};
|
||||
|
||||
var colorChooser = Game.LoadWidget(orderManager.world, "COLOR_CHOOSER", null, new WidgetArgs()
|
||||
@@ -409,8 +411,6 @@ namespace OpenRA.Mods.Cnc.Widgets
|
||||
{ "initialRamp", orderManager.LocalClient.ColorRamp }
|
||||
});
|
||||
|
||||
Console.WriteLine(colorChooser.Id);
|
||||
|
||||
CncDropDownButtonWidget.ShowDropPanel(color, colorChooser, new List<Widget>() { colorChooser.GetWidget("SAVE_BUTTON") }, () => true);
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user