unify colorpickers across ra and cnc

This commit is contained in:
Chris Forbes
2011-10-30 09:27:50 +13:00
parent a060d99780
commit c9fd874b07
8 changed files with 62 additions and 118 deletions

View File

@@ -120,6 +120,33 @@ namespace OpenRA.Mods.RA.Widgets.Logic
dropdown.ShowDropDown("RACE_DROPDOWN_TEMPLATE", 150, countryNames.Keys, setupItem);
}
public static void ShowColorDropDown(DropDownButtonWidget color, Session.Client client,
OrderManager orderManager, ColorPickerPaletteModifier preview)
{
Action<ColorRamp> onSelect = c =>
{
if (client.Bot == null)
{
Game.Settings.Player.ColorRamp = c;
Game.Settings.Save();
}
color.RemovePanel();
orderManager.IssueOrder(Order.Command("color {0} {1}".F(client.Index, c)));
};
Action<ColorRamp> onChange = c => preview.Ramp = c;
var colorChooser = Game.LoadWidget(orderManager.world, "COLOR_CHOOSER", null, new WidgetArgs()
{
{ "onSelect", onSelect },
{ "onChange", onChange },
{ "initialRamp", client.ColorRamp }
});
color.AttachPanel(colorChooser);
}
public static Dictionary<int2, Color> GetSpawnColors(OrderManager orderManager, Map map)
{
var spawns = map.GetSpawnPoints();