Rewrite TS minimap rendering:
* Rename LeftColor and RightColor to MinColor and MaxColor These are mapped from LowRadarColor and HighRadarColor in the original inis, and appear to be used to set the bounding values for selecting a random colour, NOT for left/right pixels (which caused noticeably wrong banding). * Adjust brightness based on terrain height. MinHeightColorBrightness and MaxHeightColorBrightness were chosen by trial/error to match the original map preview rendering.
@@ -702,6 +702,11 @@ namespace OpenRA
|
||||
var pxStride = 4;
|
||||
var minimapData = new byte[stride * height];
|
||||
Color leftColor, rightColor;
|
||||
|
||||
var useHeightModifiers = tileset.MinHeightColorBrightness != 1.0f || tileset.MaxHeightColorBrightness != 1.0f;
|
||||
var minHeightBrightness = tileset.MinHeightColorBrightness;
|
||||
var maxHeightBrightness = tileset.MaxHeightColorBrightness;
|
||||
var heightModifier = 1f / Grid.MaximumTerrainHeight;
|
||||
for (var y = 0; y < height; y++)
|
||||
{
|
||||
for (var x = 0; x < width; x++)
|
||||
@@ -716,8 +721,21 @@ namespace OpenRA
|
||||
{
|
||||
// Cell contains terrain
|
||||
var type = tileset.GetTileInfo(Tiles[uv]);
|
||||
leftColor = type != null ? type.LeftColor : Color.Black;
|
||||
rightColor = type != null ? type.RightColor : Color.Black;
|
||||
if (type != null)
|
||||
{
|
||||
if (useHeightModifiers)
|
||||
{
|
||||
var left = Exts.ColorLerp(Game.CosmeticRandom.NextFloat(), type.MinColor, type.MaxColor);
|
||||
var right = Exts.ColorLerp(Game.CosmeticRandom.NextFloat(), type.MinColor, type.MaxColor);
|
||||
var scale = float2.Lerp(minHeightBrightness, maxHeightBrightness, heightModifier * Height[uv]);
|
||||
leftColor = Color.FromArgb((int)(scale * left.R).Clamp(0, 255), (int)(scale * left.G).Clamp(0, 255), (int)(scale * left.B).Clamp(0, 255));
|
||||
rightColor = Color.FromArgb((int)(scale * right.R).Clamp(0, 255), (int)(scale * right.G).Clamp(0, 255), (int)(scale * right.B).Clamp(0, 255));
|
||||
}
|
||||
else
|
||||
leftColor = rightColor = type.MinColor;
|
||||
}
|
||||
else
|
||||
leftColor = rightColor = Color.Black;
|
||||
}
|
||||
|
||||
if (isRectangularIsometric)
|
||||
|
||||
@@ -24,9 +24,8 @@ namespace OpenRA
|
||||
public readonly byte TerrainType = byte.MaxValue;
|
||||
public readonly byte Height;
|
||||
public readonly byte RampType;
|
||||
public readonly Color LeftColor;
|
||||
public readonly Color RightColor;
|
||||
|
||||
public readonly Color MinColor;
|
||||
public readonly Color MaxColor;
|
||||
public readonly float ZOffset = 0.0f;
|
||||
public readonly float ZRamp = 1.0f;
|
||||
}
|
||||
@@ -106,11 +105,11 @@ namespace OpenRA
|
||||
|
||||
// Fall back to the terrain-type color if necessary
|
||||
var overrideColor = tileSet.TerrainInfo[tile.TerrainType].Color;
|
||||
if (tile.LeftColor == default(Color))
|
||||
tile.GetType().GetField("LeftColor").SetValue(tile, overrideColor);
|
||||
if (tile.MinColor == default(Color))
|
||||
tile.GetType().GetField("MinColor").SetValue(tile, overrideColor);
|
||||
|
||||
if (tile.RightColor == default(Color))
|
||||
tile.GetType().GetField("RightColor").SetValue(tile, overrideColor);
|
||||
if (tile.MaxColor == default(Color))
|
||||
tile.GetType().GetField("MaxColor").SetValue(tile, overrideColor);
|
||||
|
||||
return tile;
|
||||
}
|
||||
@@ -139,6 +138,8 @@ namespace OpenRA
|
||||
public readonly string[] EditorTemplateOrder;
|
||||
public readonly bool IgnoreTileSpriteOffsets;
|
||||
public readonly bool EnableDepth = false;
|
||||
public readonly float MinHeightColorBrightness = 1.0f;
|
||||
public readonly float MaxHeightColorBrightness = 1.0f;
|
||||
|
||||
[FieldLoader.Ignore]
|
||||
public readonly IReadOnlyDictionary<ushort, TerrainTemplateInfo> Templates;
|
||||
|
||||
@@ -143,8 +143,8 @@ namespace OpenRA.Mods.Cnc.UtilityCommands
|
||||
if (rampType != 0)
|
||||
data.AppendLine("\t\t\t\tRampType: {0}".F(rampType));
|
||||
|
||||
data.AppendLine("\t\t\t\tLeftColor: {0:X2}{1:X2}{2:X2}".F(s.ReadUInt8(), s.ReadUInt8(), s.ReadUInt8()));
|
||||
data.AppendLine("\t\t\t\tRightColor: {0:X2}{1:X2}{2:X2}".F(s.ReadUInt8(), s.ReadUInt8(), s.ReadUInt8()));
|
||||
data.AppendLine("\t\t\t\tMinColor: {0:X2}{1:X2}{2:X2}".F(s.ReadUInt8(), s.ReadUInt8(), s.ReadUInt8()));
|
||||
data.AppendLine("\t\t\t\tMaxColor: {0:X2}{1:X2}{2:X2}".F(s.ReadUInt8(), s.ReadUInt8(), s.ReadUInt8()));
|
||||
data.AppendLine("\t\t\t\tZOffset: {0}".F(-tileSize.Height / 2.0f));
|
||||
data.AppendLine("\t\t\t\tZRamp: 0");
|
||||
}
|
||||
|
||||
@@ -91,17 +91,31 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public static Pair<int, int> GetColor(Map map, MPos uv)
|
||||
{
|
||||
var custom = map.CustomTerrain[uv];
|
||||
int leftColor, rightColor;
|
||||
Color leftColor, rightColor;
|
||||
if (custom == byte.MaxValue)
|
||||
{
|
||||
var type = map.Rules.TileSet.GetTileInfo(map.Tiles[uv]);
|
||||
leftColor = type != null ? type.LeftColor.ToArgb() : Color.Black.ToArgb();
|
||||
rightColor = type != null ? type.RightColor.ToArgb() : Color.Black.ToArgb();
|
||||
var tileset = map.Rules.TileSet;
|
||||
var type = tileset.GetTileInfo(map.Tiles[uv]);
|
||||
if (type != null)
|
||||
{
|
||||
if (tileset.MinHeightColorBrightness != 1.0f || tileset.MaxHeightColorBrightness != 1.0f)
|
||||
{
|
||||
var left = Exts.ColorLerp(Game.CosmeticRandom.NextFloat(), type.MinColor, type.MaxColor);
|
||||
var right = Exts.ColorLerp(Game.CosmeticRandom.NextFloat(), type.MinColor, type.MaxColor);
|
||||
var scale = float2.Lerp(tileset.MinHeightColorBrightness, tileset.MaxHeightColorBrightness, map.Height[uv] * 1f / map.Grid.MaximumTerrainHeight);
|
||||
leftColor = Color.FromArgb((int)(scale * left.R).Clamp(0, 255), (int)(scale * left.G).Clamp(0, 255), (int)(scale * left.B).Clamp(0, 255));
|
||||
rightColor = Color.FromArgb((int)(scale * right.R).Clamp(0, 255), (int)(scale * right.G).Clamp(0, 255), (int)(scale * right.B).Clamp(0, 255));
|
||||
}
|
||||
else
|
||||
leftColor = rightColor = map.Rules.TileSet[custom].Color.ToArgb();
|
||||
leftColor = rightColor = type.MinColor;
|
||||
}
|
||||
else
|
||||
leftColor = rightColor = Color.Black;
|
||||
}
|
||||
else
|
||||
leftColor = rightColor = map.Rules.TileSet[custom].Color;
|
||||
|
||||
return Pair.New(leftColor, rightColor);
|
||||
return Pair.New(leftColor.ToArgb(), rightColor.ToArgb());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2020 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, either version 3 of
|
||||
* the License, or (at your option) any later version. For more
|
||||
* information, see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace OpenRA.Mods.Common.UpdateRules.Rules
|
||||
{
|
||||
class UpdateTilesetColors : UpdateRule
|
||||
{
|
||||
public override string Name { get { return "Rename Tileset LeftColor and RightColor"; } }
|
||||
public override string Description
|
||||
{
|
||||
get
|
||||
{
|
||||
return "The LeftColor and RightColor keys in tilesets have been renamed to MinColor and MaxColor to reflect their proper usage.";
|
||||
}
|
||||
}
|
||||
|
||||
public override IEnumerable<string> UpdateTilesetNode(ModData modData, MiniYamlNode tilesetNode)
|
||||
{
|
||||
if (tilesetNode.Key == "Templates")
|
||||
{
|
||||
foreach (var templateNode in tilesetNode.Value.Nodes)
|
||||
{
|
||||
foreach (var tilesNode in templateNode.ChildrenMatching("Tiles"))
|
||||
{
|
||||
foreach (var node in tilesNode.Value.Nodes)
|
||||
{
|
||||
foreach (var leftNode in node.ChildrenMatching("LeftColor"))
|
||||
leftNode.RenameKey("MinColor");
|
||||
foreach (var leftNode in node.ChildrenMatching("RightColor"))
|
||||
leftNode.RenameKey("MaxColor");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -65,6 +65,7 @@ namespace OpenRA.Mods.Common.UpdateRules
|
||||
new SpawnActorPowerDefaultEffect(),
|
||||
new RemoveConditionManager(),
|
||||
new ConvertSupportPowerRangesToFootprint(),
|
||||
new UpdateTilesetColors(),
|
||||
})
|
||||
};
|
||||
|
||||
|
||||
|
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 43 KiB |
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 47 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 32 KiB |
|
Before Width: | Height: | Size: 47 KiB After Width: | Height: | Size: 104 KiB |
|
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 73 KiB |
|
Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 76 KiB |
|
Before Width: | Height: | Size: 8.3 KiB After Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 22 KiB |
|
Before Width: | Height: | Size: 40 KiB After Width: | Height: | Size: 95 KiB |
|
Before Width: | Height: | Size: 42 KiB After Width: | Height: | Size: 93 KiB |
|
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 49 KiB |
|
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 79 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 26 KiB |
|
Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 75 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 34 KiB |
|
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 92 KiB |
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 44 KiB |
|
Before Width: | Height: | Size: 8.3 KiB After Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 51 KiB After Width: | Height: | Size: 113 KiB |
|
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 42 KiB |
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 41 KiB |