Clean up custom color palette
This commit is contained in:
@@ -93,14 +93,12 @@ namespace OpenRA.FileFormats
|
||||
frameData = new uint[frameSize,frameSize];
|
||||
|
||||
var type = new String(reader.ReadChars(4));
|
||||
Console.WriteLine(type);
|
||||
if (type != "FINF")
|
||||
{
|
||||
reader.ReadBytes(27);
|
||||
type = new String(reader.ReadChars(4));
|
||||
}
|
||||
|
||||
Console.WriteLine(type);
|
||||
/*var length = */reader.ReadUInt16();
|
||||
/*var unknown4 = */reader.ReadUInt16();
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace OpenRA
|
||||
|
||||
public static World world;
|
||||
public static Viewport viewport;
|
||||
internal static UserSettings Settings;
|
||||
public static UserSettings Settings;
|
||||
|
||||
internal static OrderManager orderManager;
|
||||
|
||||
|
||||
@@ -52,16 +52,10 @@ namespace OpenRA.Graphics
|
||||
|
||||
public void AddPalette(string name, Palette p)
|
||||
{
|
||||
Console.WriteLine("Adding palette "+name);
|
||||
palettes.Add(name, p);
|
||||
indices.Add(name, allocated++);
|
||||
}
|
||||
|
||||
public void UpdatePalette(string name, Palette p)
|
||||
{
|
||||
palettes[name] = p;
|
||||
}
|
||||
|
||||
public void Update(IEnumerable<IPaletteModifier> paletteMods)
|
||||
{
|
||||
var copy = palettes.ToDictionary(p => p.Key, p => new Palette(p.Value));
|
||||
|
||||
@@ -36,7 +36,6 @@ namespace OpenRA.Graphics
|
||||
public int GetPaletteIndex(string name) { return palette.GetPaletteIndex(name); }
|
||||
public Palette GetPalette(string name) { return palette.GetPalette(name); }
|
||||
public void AddPalette(string name, Palette pal) { palette.AddPalette(name, pal); }
|
||||
public void UpdatePalette(string name, Palette pal) { palette.UpdatePalette(name, pal); }
|
||||
|
||||
class SpriteComparer : IComparer<Renderable>
|
||||
{
|
||||
|
||||
@@ -22,17 +22,20 @@ namespace OpenRA.Widgets.Delegates
|
||||
Widget Players, LocalPlayerTemplate, RemotePlayerTemplate;
|
||||
|
||||
Dictionary<string, string> CountryNames;
|
||||
|
||||
string MapUid;
|
||||
MapStub Map;
|
||||
|
||||
bool SplitPlayerPalette = false;
|
||||
Palette BasePlayerPalette = null;
|
||||
public static Color CurrentColorPreview1;
|
||||
public static Color CurrentColorPreview2;
|
||||
|
||||
public LobbyDelegate()
|
||||
{
|
||||
Game.LobbyInfoChanged += UpdateCurrentMap;
|
||||
UpdateCurrentMap();
|
||||
|
||||
CurrentColorPreview1 = Game.Settings.PlayerColor1;
|
||||
CurrentColorPreview2 = Game.Settings.PlayerColor2;
|
||||
|
||||
var r = Widget.RootWidget;
|
||||
var lobby = r.GetWidget("SERVER_LOBBY");
|
||||
Players = Widget.RootWidget.GetWidget("SERVER_LOBBY").GetWidget("PLAYERS");
|
||||
@@ -152,12 +155,6 @@ namespace OpenRA.Widgets.Delegates
|
||||
UpdatePlayerColor(hueSlider.GetOffset(), satSlider.GetOffset(), lumSlider.GetOffset(), rangeSlider.GetOffset());
|
||||
return true;
|
||||
};
|
||||
|
||||
// Copy the base palette for the colorpicker
|
||||
var info = Rules.Info["world"].Traits.Get<PlayerColorPaletteInfo>();
|
||||
BasePlayerPalette = Game.world.WorldRenderer.GetPalette(info.BasePalette);
|
||||
SplitPlayerPalette = info.SplitRamp;
|
||||
Game.world.WorldRenderer.AddPalette("colorpicker",BasePlayerPalette);
|
||||
}
|
||||
|
||||
void UpdatePlayerColor(float hf, float sf, float lf, float r)
|
||||
@@ -173,9 +170,8 @@ namespace OpenRA.Widgets.Delegates
|
||||
|
||||
void UpdateColorPreview(float hf, float sf, float lf, float r)
|
||||
{
|
||||
var c1 = ColorFromHSL(hf, sf, lf);
|
||||
var c2 = ColorFromHSL(hf, sf, r*lf);
|
||||
Game.world.WorldRenderer.UpdatePalette("colorpicker", new Palette(BasePlayerPalette, new PlayerColorRemap(c1, c2, SplitPlayerPalette)));
|
||||
CurrentColorPreview1 = ColorFromHSL(hf, sf, lf);
|
||||
CurrentColorPreview2 = ColorFromHSL(hf, sf, r*lf);
|
||||
Game.viewport.RefreshPalette();
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,6 @@ namespace OpenRA.Mods.RA
|
||||
return;
|
||||
|
||||
var frac = (float)remainingFrames / chronoEffectLength;
|
||||
System.Console.WriteLine("{0}",frac);
|
||||
var excludePalettes = new List<string>(){"cursor", "chrome", "colorpicker"};
|
||||
foreach (var pal in palettes)
|
||||
{
|
||||
|
||||
38
OpenRA.Mods.RA/ColorPickerPaletteModifier.cs
Normal file
38
OpenRA.Mods.RA/ColorPickerPaletteModifier.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2010 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 LICENSE.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Drawing;
|
||||
using OpenRA.Traits;
|
||||
using System.Collections.Generic;
|
||||
using OpenRA.FileFormats;
|
||||
using OpenRA.Widgets.Delegates;
|
||||
|
||||
namespace OpenRA.Mods.RA
|
||||
{
|
||||
class ColorPickerPaletteModifierInfo : TraitInfo<ColorPickerPaletteModifier> {}
|
||||
|
||||
class ColorPickerPaletteModifier : IPaletteModifier, ILoadWorldHook
|
||||
{
|
||||
bool SplitPlayerPalette;
|
||||
public void WorldLoaded(World w)
|
||||
{
|
||||
// Copy the base palette for the colorpicker
|
||||
var info = Rules.Info["world"].Traits.Get<PlayerColorPaletteInfo>();
|
||||
SplitPlayerPalette = info.SplitRamp;
|
||||
w.WorldRenderer.AddPalette("colorpicker", w.WorldRenderer.GetPalette(info.BasePalette));
|
||||
}
|
||||
|
||||
public void AdjustPalette(Dictionary<string,Palette> palettes)
|
||||
{
|
||||
palettes["colorpicker"] = new Palette(palettes["colorpicker"],
|
||||
new PlayerColorRemap(LobbyDelegate.CurrentColorPreview1, LobbyDelegate.CurrentColorPreview2, SplitPlayerPalette));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -232,6 +232,7 @@
|
||||
<Compile Include="Activities\Transform.cs" />
|
||||
<Compile Include="ActorLostNotification.cs" />
|
||||
<Compile Include="AppearsOnRadar.cs" />
|
||||
<Compile Include="ColorPickerPaletteModifier.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">
|
||||
|
||||
@@ -44,6 +44,7 @@ Player:
|
||||
|
||||
World:
|
||||
ScreenShaker:
|
||||
ColorPickerPaletteModifier:
|
||||
WaterPaletteRotation:
|
||||
CncMode: true
|
||||
BuildingInfluence:
|
||||
|
||||
@@ -87,6 +87,7 @@ Player:
|
||||
|
||||
World:
|
||||
ScreenShaker:
|
||||
ColorPickerPaletteModifier:
|
||||
WaterPaletteRotation:
|
||||
ChronoshiftPaletteEffect:
|
||||
NukePaletteEffect:
|
||||
|
||||
Reference in New Issue
Block a user