Allow maps/mods to properly disable fog or shroud (or both).

This commit is contained in:
Paul Chote
2013-04-11 22:29:51 +12:00
parent 2c680a1831
commit 400ad49de0
12 changed files with 77 additions and 93 deletions

View File

@@ -1,46 +0,0 @@
#region Copyright & License Information
/*
* Copyright 2007-2013 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.Drawing;
using OpenRA.FileFormats;
using OpenRA.Graphics;
using OpenRA.Traits;
namespace OpenRA.Mods.RA
{
[Desc("Adds the hard-coded fog palette to the game")]
class FogPaletteInfo : ITraitInfo
{
[Desc("internal palette name")]
public readonly string Name = "fog";
public object Create(ActorInitializer init) { return new FogPalette(this); }
}
class FogPalette : IPalette
{
readonly FogPaletteInfo info;
public FogPalette(FogPaletteInfo info) { this.info = info; }
public void InitPalette(WorldRenderer wr)
{
var c = new[] {
Color.Transparent, Color.Green,
Color.Blue, Color.Yellow,
Color.FromArgb(128,0,0,0),
Color.FromArgb(128,0,0,0),
Color.FromArgb(128,0,0,0),
Color.FromArgb(64,0,0,0)
};
wr.AddPalette(info.Name, new Palette(Exts.MakeArray(256, i => (uint)c[i % 8].ToArgb())), false);
}
}
}

View File

@@ -416,7 +416,6 @@
<Compile Include="Widgets\Logic\CheatsLogic.cs" />
<Compile Include="CloakPaletteEffect.cs" />
<Compile Include="Widgets\ColorPreviewManagerWidget.cs" />
<Compile Include="FogPalette.cs" />
<Compile Include="Infiltrates.cs" />
<Compile Include="Armament.cs" />
<Compile Include="DebugMuzzlePositions.cs" />

View File

@@ -15,11 +15,17 @@ using OpenRA.Traits;
namespace OpenRA.Mods.RA
{
public enum ShroudPaletteType { Shroud, Fog, Combined };
[Desc("Adds the hard-coded shroud palette to the game")]
class ShroudPaletteInfo : ITraitInfo
{
[Desc("internal palette name")]
[Desc("Internal palette name")]
public readonly string Name = "shroud";
[Desc("Palette type")]
public readonly ShroudPaletteType Type = ShroudPaletteType.Combined;
public object Create(ActorInitializer init) { return new ShroudPalette(this); }
}
@@ -31,16 +37,37 @@ namespace OpenRA.Mods.RA
public void InitPalette(WorldRenderer wr)
{
var c = new[] {
Color.Transparent, Color.Green,
Color.Blue, Color.Yellow,
Color.Black,
Color.FromArgb(128,0,0,0),
Color.Transparent,
Color.Transparent
};
var c = info.Type == ShroudPaletteType.Shroud ? Shroud :
info.Type == ShroudPaletteType.Fog ? Fog : Combined;
wr.AddPalette(info.Name, new Palette(Exts.MakeArray(256, i => (uint)c[i % 8].ToArgb())), false);
}
static Color[] Shroud = new[] {
Color.Transparent, Color.Green,
Color.Blue, Color.Yellow,
Color.Black,
Color.FromArgb(128,0,0,0),
Color.Transparent,
Color.Transparent
};
static Color[] Fog = new[] {
Color.Transparent, Color.Green,
Color.Blue, Color.Yellow,
Color.FromArgb(128,0,0,0),
Color.FromArgb(128,0,0,0),
Color.FromArgb(128,0,0,0),
Color.FromArgb(64,0,0,0)
};
static Color[] Combined = new[] {
Color.Transparent, Color.Green,
Color.Blue, Color.Yellow,
Color.Black,
Color.FromArgb(192,0,0,0),
Color.FromArgb(128,0,0,0),
Color.FromArgb(64,0,0,0)
};
}
}