unify C&C and RA colorpicker palette manipulation code
This commit is contained in:
@@ -1,47 +0,0 @@
|
|||||||
#region Copyright & License Information
|
|
||||||
/*
|
|
||||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
|
||||||
* This file is part of OpenRA, which is free software. It is made
|
|
||||||
* available to you under the terms of the GNU General Public License
|
|
||||||
* as published by the Free Software Foundation. For more information,
|
|
||||||
* see COPYING.
|
|
||||||
*/
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using OpenRA.FileFormats;
|
|
||||||
using OpenRA.Graphics;
|
|
||||||
using OpenRA.Traits;
|
|
||||||
|
|
||||||
namespace OpenRA.Mods.Cnc
|
|
||||||
{
|
|
||||||
class CncColorPickerPaletteModifierInfo : ITraitInfo
|
|
||||||
{
|
|
||||||
public string PlayerPalette = "player";
|
|
||||||
public object Create( ActorInitializer init ) { return new CncColorPickerPaletteModifier( this ); }
|
|
||||||
}
|
|
||||||
|
|
||||||
class CncColorPickerPaletteModifier : IPalette, IPaletteModifier
|
|
||||||
{
|
|
||||||
CncColorPickerPaletteModifierInfo Info;
|
|
||||||
PaletteFormat format;
|
|
||||||
public ColorRamp Ramp;
|
|
||||||
|
|
||||||
public CncColorPickerPaletteModifier(CncColorPickerPaletteModifierInfo info) { Info = info; }
|
|
||||||
|
|
||||||
public void InitPalette( WorldRenderer wr )
|
|
||||||
{
|
|
||||||
var info = Rules.Info["player"].Traits.WithInterface<PlayerColorPaletteInfo>()
|
|
||||||
.First(p => p.BaseName == Info.PlayerPalette);
|
|
||||||
format = info.PaletteFormat;
|
|
||||||
wr.AddPalette("colorpicker", wr.GetPalette(info.BasePalette));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void AdjustPalette(Dictionary<string, Palette> palettes)
|
|
||||||
{
|
|
||||||
palettes["colorpicker"] = new Palette(palettes["colorpicker"],
|
|
||||||
new PlayerColorRemap(Ramp, format));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
@@ -53,7 +53,6 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Activities\HarvesterDockSequence.cs" />
|
<Compile Include="Activities\HarvesterDockSequence.cs" />
|
||||||
<Compile Include="CncColorPickerPaletteModifier.cs" />
|
|
||||||
<Compile Include="CncLoadScreen.cs" />
|
<Compile Include="CncLoadScreen.cs" />
|
||||||
<Compile Include="CncMenuPaletteEffect.cs" />
|
<Compile Include="CncMenuPaletteEffect.cs" />
|
||||||
<Compile Include="CncWaterPaletteRotation.cs" />
|
<Compile Include="CncWaterPaletteRotation.cs" />
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ using OpenRA.FileFormats;
|
|||||||
using OpenRA.Network;
|
using OpenRA.Network;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
using OpenRA.Widgets;
|
using OpenRA.Widgets;
|
||||||
|
using OpenRA.Mods.RA;
|
||||||
using OpenRA.Mods.RA.Widgets.Logic;
|
using OpenRA.Mods.RA.Widgets.Logic;
|
||||||
|
|
||||||
namespace OpenRA.Mods.Cnc.Widgets.Logic
|
namespace OpenRA.Mods.Cnc.Widgets.Logic
|
||||||
@@ -32,7 +33,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
string MapUid;
|
string MapUid;
|
||||||
Map Map;
|
Map Map;
|
||||||
|
|
||||||
CncColorPickerPaletteModifier PlayerPalettePreview;
|
ColorPickerPaletteModifier PlayerPalettePreview;
|
||||||
|
|
||||||
readonly Action OnGameStart;
|
readonly Action OnGameStart;
|
||||||
readonly Action onExit;
|
readonly Action onExit;
|
||||||
@@ -102,7 +103,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
Game.ConnectionStateChanged += ConnectionStateChanged;
|
Game.ConnectionStateChanged += ConnectionStateChanged;
|
||||||
|
|
||||||
UpdateCurrentMap();
|
UpdateCurrentMap();
|
||||||
PlayerPalettePreview = world.WorldActor.Trait<CncColorPickerPaletteModifier>();
|
PlayerPalettePreview = world.WorldActor.Trait<ColorPickerPaletteModifier>();
|
||||||
PlayerPalettePreview.Ramp = Game.Settings.Player.ColorRamp;
|
PlayerPalettePreview.Ramp = Game.Settings.Player.ColorRamp;
|
||||||
Players = lobby.GetWidget<ScrollPanelWidget>("PLAYERS");
|
Players = lobby.GetWidget<ScrollPanelWidget>("PLAYERS");
|
||||||
EditablePlayerTemplate = Players.GetWidget("TEMPLATE_EDITABLE_PLAYER");
|
EditablePlayerTemplate = Players.GetWidget("TEMPLATE_EDITABLE_PLAYER");
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ using System.Linq;
|
|||||||
using OpenRA.FileFormats;
|
using OpenRA.FileFormats;
|
||||||
using OpenRA.FileFormats.Graphics;
|
using OpenRA.FileFormats.Graphics;
|
||||||
using OpenRA.GameRules;
|
using OpenRA.GameRules;
|
||||||
|
using OpenRA.Mods.RA;
|
||||||
using OpenRA.Mods.RA.Widgets.Logic;
|
using OpenRA.Mods.RA.Widgets.Logic;
|
||||||
using OpenRA.Widgets;
|
using OpenRA.Widgets;
|
||||||
|
|
||||||
@@ -24,7 +25,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
enum PanelType { General, Input }
|
enum PanelType { General, Input }
|
||||||
|
|
||||||
PanelType Settings = PanelType.General;
|
PanelType Settings = PanelType.General;
|
||||||
CncColorPickerPaletteModifier playerPalettePreview;
|
ColorPickerPaletteModifier playerPalettePreview;
|
||||||
World world;
|
World world;
|
||||||
|
|
||||||
[ObjectCreator.UseCtor]
|
[ObjectCreator.UseCtor]
|
||||||
@@ -53,7 +54,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
var nameTextfield = generalPane.GetWidget<TextFieldWidget>("NAME_TEXTFIELD");
|
var nameTextfield = generalPane.GetWidget<TextFieldWidget>("NAME_TEXTFIELD");
|
||||||
nameTextfield.Text = playerSettings.Name;
|
nameTextfield.Text = playerSettings.Name;
|
||||||
|
|
||||||
playerPalettePreview = world.WorldActor.Trait<CncColorPickerPaletteModifier>();
|
playerPalettePreview = world.WorldActor.Trait<ColorPickerPaletteModifier>();
|
||||||
playerPalettePreview.Ramp = playerSettings.ColorRamp;
|
playerPalettePreview.Ramp = playerSettings.ColorRamp;
|
||||||
|
|
||||||
var colorDropdown = generalPane.GetWidget<DropDownButtonWidget>("COLOR_DROPDOWN");
|
var colorDropdown = generalPane.GetWidget<DropDownButtonWidget>("COLOR_DROPDOWN");
|
||||||
|
|||||||
@@ -12,29 +12,28 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenRA.FileFormats;
|
using OpenRA.FileFormats;
|
||||||
using OpenRA.Graphics;
|
using OpenRA.Graphics;
|
||||||
using OpenRA.Mods.RA.Widgets.Logic;
|
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
|
|
||||||
namespace OpenRA.Mods.RA
|
namespace OpenRA.Mods.RA
|
||||||
{
|
{
|
||||||
class ColorPickerPaletteModifierInfo : ITraitInfo
|
public class ColorPickerPaletteModifierInfo : ITraitInfo
|
||||||
{
|
{
|
||||||
public string PlayerPalette = "player";
|
public string PlayerPalette = "player";
|
||||||
public object Create( ActorInitializer init ) { return new ColorPickerPaletteModifier( this ); }
|
public object Create( ActorInitializer init ) { return new ColorPickerPaletteModifier( this ); }
|
||||||
}
|
}
|
||||||
|
|
||||||
class ColorPickerPaletteModifier : IPalette, IPaletteModifier
|
public class ColorPickerPaletteModifier : IPalette, IPaletteModifier
|
||||||
{
|
{
|
||||||
ColorPickerPaletteModifierInfo Info;
|
ColorPickerPaletteModifierInfo Info;
|
||||||
PaletteFormat format;
|
PaletteFormat format;
|
||||||
|
public ColorRamp Ramp;
|
||||||
|
|
||||||
public ColorPickerPaletteModifier(ColorPickerPaletteModifierInfo info) { Info = info; }
|
public ColorPickerPaletteModifier(ColorPickerPaletteModifierInfo info) { Info = info; }
|
||||||
|
|
||||||
public void InitPalette( WorldRenderer wr )
|
public void InitPalette( WorldRenderer wr )
|
||||||
{
|
{
|
||||||
var info = Rules.Info["player"].Traits.WithInterface<PlayerColorPaletteInfo>()
|
var info = Rules.Info["player"].Traits.WithInterface<PlayerColorPaletteInfo>()
|
||||||
.Where(p => p.BaseName == Info.PlayerPalette)
|
.First(p => p.BaseName == Info.PlayerPalette);
|
||||||
.First();
|
|
||||||
format = info.PaletteFormat;
|
format = info.PaletteFormat;
|
||||||
wr.AddPalette("colorpicker", wr.GetPalette(info.BasePalette));
|
wr.AddPalette("colorpicker", wr.GetPalette(info.BasePalette));
|
||||||
}
|
}
|
||||||
@@ -42,7 +41,7 @@ namespace OpenRA.Mods.RA
|
|||||||
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(LobbyLogic.CurrentColorPreview, format));
|
new PlayerColorRemap(Ramp, format));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ namespace OpenRA.Mods.RA
|
|||||||
new WidgetArgs() { { "orderManager", orderManager } });
|
new WidgetArgs() { { "orderManager", orderManager } });
|
||||||
break;
|
break;
|
||||||
case ConnectionState.Connected:
|
case ConnectionState.Connected:
|
||||||
var lobby = Game.OpenWindow(orderManager.world, "SERVER_LOBBY");
|
var lobby = Game.OpenWindow("SERVER_LOBBY", new WidgetArgs {});
|
||||||
lobby.GetWidget<ChatDisplayWidget>("CHAT_DISPLAY").ClearChat();
|
lobby.GetWidget<ChatDisplayWidget>("CHAT_DISPLAY").ClearChat();
|
||||||
lobby.GetWidget("CHANGEMAP_BUTTON").Visible = true;
|
lobby.GetWidget("CHANGEMAP_BUTTON").Visible = true;
|
||||||
lobby.GetWidget("ALLOWCHEATS_CHECKBOX").Visible = true;
|
lobby.GetWidget("ALLOWCHEATS_CHECKBOX").Visible = true;
|
||||||
|
|||||||
@@ -30,12 +30,14 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
string MapUid;
|
string MapUid;
|
||||||
Map Map;
|
Map Map;
|
||||||
|
|
||||||
public static ColorRamp CurrentColorPreview;
|
ColorPickerPaletteModifier PlayerPalettePreview;
|
||||||
|
|
||||||
readonly OrderManager orderManager;
|
readonly OrderManager orderManager;
|
||||||
readonly WorldRenderer worldRenderer;
|
readonly WorldRenderer worldRenderer;
|
||||||
|
|
||||||
[ObjectCreator.UseCtor]
|
[ObjectCreator.UseCtor]
|
||||||
internal LobbyLogic([ObjectCreator.Param( "widget" )] Widget lobby,
|
internal LobbyLogic([ObjectCreator.Param( "widget" )] Widget lobby,
|
||||||
|
[ObjectCreator.Param] World world, // Shellmap world
|
||||||
[ObjectCreator.Param] OrderManager orderManager,
|
[ObjectCreator.Param] OrderManager orderManager,
|
||||||
[ObjectCreator.Param] WorldRenderer worldRenderer)
|
[ObjectCreator.Param] WorldRenderer worldRenderer)
|
||||||
{
|
{
|
||||||
@@ -47,7 +49,8 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
Game.LobbyInfoChanged += UpdatePlayerList;
|
Game.LobbyInfoChanged += UpdatePlayerList;
|
||||||
UpdateCurrentMap();
|
UpdateCurrentMap();
|
||||||
|
|
||||||
CurrentColorPreview = Game.Settings.Player.ColorRamp;
|
PlayerPalettePreview = world.WorldActor.Trait<ColorPickerPaletteModifier>();
|
||||||
|
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");
|
||||||
@@ -208,7 +211,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
|
|
||||||
void UpdateColorPreview(float hf, float sf, float lf, float r)
|
void UpdateColorPreview(float hf, float sf, float lf, float r)
|
||||||
{
|
{
|
||||||
CurrentColorPreview = new ColorRamp((byte)(hf * 255), (byte)(sf * 255), (byte)(lf * 255), (byte)(r * 255));
|
PlayerPalettePreview.Ramp = new ColorRamp((byte)(hf * 255), (byte)(sf * 255), (byte)(lf * 255), (byte)(r * 255));
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateCurrentMap()
|
void UpdateCurrentMap()
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ World:
|
|||||||
G: 0
|
G: 0
|
||||||
B: 0
|
B: 0
|
||||||
A: 180
|
A: 180
|
||||||
CncColorPickerPaletteModifier:
|
ColorPickerPaletteModifier:
|
||||||
ShroudPalette@shroud:
|
ShroudPalette@shroud:
|
||||||
ShroudPalette@fog:
|
ShroudPalette@fog:
|
||||||
IsFog: yes
|
IsFog: yes
|
||||||
|
|||||||
Reference in New Issue
Block a user