Rework color picker palette modification.
The old method had the lobby code dig around inside the palette modification machinery, which was a giant hack preventing necessary streamlining.
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Traits;
|
||||
using OpenRA.Widgets;
|
||||
|
||||
@@ -20,7 +21,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
||||
Widget menu;
|
||||
|
||||
[ObjectCreator.UseCtor]
|
||||
public CncIngameMenuLogic(Widget widget, World world, Action onExit)
|
||||
public CncIngameMenuLogic(Widget widget, World world, Action onExit, WorldRenderer worldRenderer)
|
||||
{
|
||||
var resumeDisabled = false;
|
||||
menu = widget.Get("INGAME_MENU");
|
||||
@@ -72,6 +73,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
||||
Ui.OpenWindow("SETTINGS_PANEL", new WidgetArgs()
|
||||
{
|
||||
{ "world", world },
|
||||
{ "worldRenderer", worldRenderer },
|
||||
{ "onExit", () => hideButtons = false },
|
||||
});
|
||||
};
|
||||
|
||||
@@ -85,9 +85,8 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
||||
settingsMenu.Get<ButtonWidget>("SETTINGS_BUTTON").OnClick = () =>
|
||||
{
|
||||
Menu = MenuType.None;
|
||||
Ui.OpenWindow("SETTINGS_PANEL", new WidgetArgs()
|
||||
Game.OpenWindow("SETTINGS_PANEL", new WidgetArgs()
|
||||
{
|
||||
{ "world", world },
|
||||
{ "onExit", () => Menu = MenuType.Settings },
|
||||
});
|
||||
};
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
*/
|
||||
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
@@ -17,6 +18,7 @@ using OpenRA.GameRules;
|
||||
using OpenRA.Mods.RA;
|
||||
using OpenRA.Mods.RA.Widgets.Logic;
|
||||
using OpenRA.Widgets;
|
||||
using OpenRA.Mods.RA.Widgets;
|
||||
|
||||
namespace OpenRA.Mods.Cnc.Widgets.Logic
|
||||
{
|
||||
@@ -25,7 +27,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
||||
enum PanelType { General, Input }
|
||||
|
||||
PanelType Settings = PanelType.General;
|
||||
ColorPickerPaletteModifier playerPalettePreview;
|
||||
ColorPreviewManagerWidget colorPreview;
|
||||
World world;
|
||||
|
||||
[ObjectCreator.UseCtor]
|
||||
@@ -52,8 +54,8 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
||||
var nameTextfield = generalPane.Get<TextFieldWidget>("NAME_TEXTFIELD");
|
||||
nameTextfield.Text = playerSettings.Name;
|
||||
|
||||
playerPalettePreview = world.WorldActor.Trait<ColorPickerPaletteModifier>();
|
||||
playerPalettePreview.Ramp = playerSettings.ColorRamp;
|
||||
colorPreview = panel.Get<ColorPreviewManagerWidget>("COLOR_MANAGER");
|
||||
colorPreview.Ramp = playerSettings.ColorRamp;
|
||||
|
||||
var colorDropdown = generalPane.Get<DropDownButtonWidget>("COLOR");
|
||||
colorDropdown.OnMouseDown = _ => ShowColorPicker(colorDropdown, playerSettings);
|
||||
@@ -153,8 +155,8 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
||||
|
||||
bool ShowColorPicker(DropDownButtonWidget color, PlayerSettings s)
|
||||
{
|
||||
Action<ColorRamp> onSelect = c => { s.ColorRamp = c; color.RemovePanel(); };
|
||||
Action<ColorRamp> onChange = c => { playerPalettePreview.Ramp = c; };
|
||||
Action<ColorRamp> onSelect = c => {s.ColorRamp = c; color.RemovePanel();};
|
||||
Action<ColorRamp> onChange = c => {colorPreview.Ramp = c;};
|
||||
|
||||
var colorChooser = Game.LoadWidget(world, "COLOR_CHOOSER", null, new WidgetArgs()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user