Merge ColorPreviewManagerWidget into ColorPickerManager.
This commit is contained in:
@@ -14,6 +14,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Mods.Common.Traits;
|
||||
using OpenRA.Network;
|
||||
using OpenRA.Primitives;
|
||||
using OpenRA.Traits;
|
||||
@@ -32,7 +33,6 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
readonly WorldRenderer worldRenderer;
|
||||
readonly bool skirmishMode;
|
||||
readonly Ruleset modRules;
|
||||
readonly World shellmapWorld;
|
||||
readonly WebServices services;
|
||||
|
||||
enum PanelType { Players, Options, Music, Servers, Kick, ForceStart }
|
||||
@@ -53,7 +53,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
|
||||
readonly Dictionary<string, LobbyFaction> factions = new Dictionary<string, LobbyFaction>();
|
||||
|
||||
readonly ColorPreviewManagerWidget colorPreview;
|
||||
readonly ColorPickerManagerInfo colorManager;
|
||||
|
||||
readonly TabCompletionLogic tabCompletion = new TabCompletionLogic();
|
||||
|
||||
@@ -116,7 +116,6 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
|
||||
// TODO: This needs to be reworked to support per-map tech levels, bots, etc.
|
||||
modRules = modData.DefaultRules;
|
||||
shellmapWorld = worldRenderer.World;
|
||||
|
||||
services = modData.Manifest.Get<WebServices>();
|
||||
|
||||
@@ -159,8 +158,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
editableSpectatorTemplate = players.Get("TEMPLATE_EDITABLE_SPECTATOR");
|
||||
nonEditableSpectatorTemplate = players.Get("TEMPLATE_NONEDITABLE_SPECTATOR");
|
||||
newSpectatorTemplate = players.Get("TEMPLATE_NEW_SPECTATOR");
|
||||
colorPreview = lobby.Get<ColorPreviewManagerWidget>("COLOR_MANAGER");
|
||||
colorPreview.Color = Game.Settings.Player.Color;
|
||||
colorManager = modRules.Actors[SystemActors.World].TraitInfo<ColorPickerManagerInfo>();
|
||||
colorManager.Update(worldRenderer, Game.Settings.Player.Color);
|
||||
|
||||
foreach (var f in modRules.Actors[SystemActors.World].TraitInfos<FactionInfo>())
|
||||
factions.Add(f.InternalName, new LobbyFaction { Selectable = f.Selectable, Name = f.Name, Side = f.Side, Description = f.Description });
|
||||
@@ -601,7 +600,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
else
|
||||
LobbyUtils.SetupEditableNameWidget(template, slot, client, orderManager, worldRenderer);
|
||||
|
||||
LobbyUtils.SetupEditableColorWidget(template, slot, client, orderManager, shellmapWorld, colorPreview);
|
||||
LobbyUtils.SetupEditableColorWidget(template, slot, client, orderManager, worldRenderer, colorManager);
|
||||
LobbyUtils.SetupEditableFactionWidget(template, slot, client, orderManager, factions);
|
||||
LobbyUtils.SetupEditableTeamWidget(template, slot, client, orderManager, map);
|
||||
LobbyUtils.SetupEditableHandicapWidget(template, slot, client, orderManager, map);
|
||||
|
||||
@@ -13,6 +13,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Mods.Common.Traits;
|
||||
using OpenRA.Network;
|
||||
using OpenRA.Primitives;
|
||||
using OpenRA.Traits;
|
||||
@@ -220,23 +221,23 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
}
|
||||
|
||||
public static void ShowColorDropDown(DropDownButtonWidget color, Session.Client client,
|
||||
OrderManager orderManager, World world, ColorPreviewManagerWidget preview)
|
||||
OrderManager orderManager, WorldRenderer worldRenderer, ColorPickerManagerInfo colorManager)
|
||||
{
|
||||
Action onExit = () =>
|
||||
{
|
||||
if (client.Bot == null)
|
||||
if (client == orderManager.LocalClient)
|
||||
{
|
||||
Game.Settings.Player.Color = preview.Color;
|
||||
Game.Settings.Player.Color = colorManager.Color;
|
||||
Game.Settings.Save();
|
||||
}
|
||||
|
||||
color.RemovePanel();
|
||||
orderManager.IssueOrder(Order.Command($"color {client.Index} {preview.Color}"));
|
||||
orderManager.IssueOrder(Order.Command($"color {client.Index} {colorManager.Color}"));
|
||||
};
|
||||
|
||||
Action<Color> onChange = c => preview.Color = c;
|
||||
Action<Color> onChange = c => colorManager.Update(worldRenderer, c);
|
||||
|
||||
var colorChooser = Game.LoadWidget(world, "COLOR_CHOOSER", null, new WidgetArgs()
|
||||
var colorChooser = Game.LoadWidget(worldRenderer.World, "COLOR_CHOOSER", null, new WidgetArgs()
|
||||
{
|
||||
{ "onChange", onChange },
|
||||
{ "initialColor", client.Color },
|
||||
@@ -523,11 +524,11 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
};
|
||||
}
|
||||
|
||||
public static void SetupEditableColorWidget(Widget parent, Session.Slot s, Session.Client c, OrderManager orderManager, World world, ColorPreviewManagerWidget colorPreview)
|
||||
public static void SetupEditableColorWidget(Widget parent, Session.Slot s, Session.Client c, OrderManager orderManager, WorldRenderer worldRenderer, ColorPickerManagerInfo colorManager)
|
||||
{
|
||||
var color = parent.Get<DropDownButtonWidget>("COLOR");
|
||||
color.IsDisabled = () => (s != null && s.LockColor) || orderManager.LocalClient.IsReady;
|
||||
color.OnMouseDown = _ => ShowColorDropDown(color, c, orderManager, world, colorPreview);
|
||||
color.OnMouseDown = _ => ShowColorDropDown(color, c, orderManager, worldRenderer, colorManager);
|
||||
|
||||
SetupColorWidget(color, s, c);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user