Unhardcode minimap terrain colours; use dummy values for cnc temporarily
This commit is contained in:
@@ -226,8 +226,6 @@ namespace OpenRA.FileFormats
|
||||
{
|
||||
var loc = int.Parse( kv.Key );
|
||||
int2 cell = new int2(loc % MapSize, loc / MapSize);
|
||||
|
||||
Log.Write("Overlay {0} at ({1},{2})",kv.Value,cell.X,cell.Y);
|
||||
MapTiles[ cell.X, cell.Y ].overlay = kv.Value.ToLower();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,6 +94,7 @@
|
||||
<Compile Include="TypeDictionary.cs" />
|
||||
<Compile Include="Walkability.cs" />
|
||||
<Compile Include="ActorReference.cs" />
|
||||
<Compile Include="TerrainColorSet.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
|
||||
69
OpenRA.FileFormats/TerrainColorSet.cs
Normal file
69
OpenRA.FileFormats/TerrainColorSet.cs
Normal file
@@ -0,0 +1,69 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
|
||||
* This file is part of OpenRA.
|
||||
*
|
||||
* OpenRA is free software: you can redistribute it and/or modify
|
||||
* it 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.
|
||||
*
|
||||
* OpenRA is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with OpenRA. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Drawing;
|
||||
|
||||
namespace OpenRA.FileFormats
|
||||
{
|
||||
public class TerrainColorSet
|
||||
{
|
||||
public readonly Dictionary<int, Color> colors = new Dictionary<int, Color>();
|
||||
|
||||
string NextLine( StreamReader reader )
|
||||
{
|
||||
string ret;
|
||||
do
|
||||
{
|
||||
ret = reader.ReadLine();
|
||||
if( ret == null )
|
||||
return null;
|
||||
ret = ret.Trim();
|
||||
}
|
||||
while( ret.Length == 0 || ret[ 0 ] == ';' );
|
||||
return ret;
|
||||
}
|
||||
|
||||
public TerrainColorSet( string colorFile )
|
||||
{
|
||||
StreamReader file = new StreamReader( FileSystem.Open(colorFile) );
|
||||
|
||||
while( true )
|
||||
{
|
||||
string line = NextLine( file );
|
||||
if( line == null )
|
||||
break;
|
||||
|
||||
string[] entries = line.Split(',');
|
||||
int key = int.Parse(entries[0]);
|
||||
Color val = Color.FromArgb(int.Parse(entries[1]),int.Parse(entries[2]),int.Parse(entries[3]));
|
||||
colors.Add(key,val);
|
||||
}
|
||||
|
||||
file.Close();
|
||||
}
|
||||
|
||||
public Color ColorForTerrainType(int type)
|
||||
{
|
||||
return colors[type];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -76,14 +76,10 @@ namespace OpenRA.Graphics
|
||||
return new Rectangle(m.Offset.X - dw, m.Offset.Y - dh, size, size);
|
||||
}
|
||||
|
||||
static Cache<string, Color[]> terrainTypeColors = new Cache<string, Color[]>(
|
||||
static Cache<string, TerrainColorSet> terrainTypeColors = new Cache<string, TerrainColorSet>(
|
||||
theater =>
|
||||
{
|
||||
var pal = Game.world.WorldRenderer.GetPalette("terrain");
|
||||
return new[] {
|
||||
theater == "snow" ? 0xe3 :0x1a,
|
||||
0x63, 0x2f, 0x1f, 0x14, 0x64, 0x1f, 0x68, 0x6b, 0x6d, 0x88 }
|
||||
.Select(a => Color.FromArgb(alpha, pal.GetColor(a))).ToArray();
|
||||
return new TerrainColorSet(Game.world.WorldActor.Info.Traits.WithInterface<TheaterInfo>().FirstOrDefault(t => t.Theater == theater).MapColors);
|
||||
});
|
||||
|
||||
static Color shroudColor;
|
||||
@@ -92,12 +88,11 @@ namespace OpenRA.Graphics
|
||||
|
||||
public static Bitmap RenderTerrainBitmap(Map map, TileSet tileset)
|
||||
{
|
||||
var colors = terrainTypeColors[map.Theater.ToLowerInvariant()];
|
||||
var terrain = new Bitmap(map.MapSize, map.MapSize);
|
||||
for (var y = 0; y < map.MapSize; y++)
|
||||
for (var x = 0; x < map.MapSize; x++)
|
||||
terrain.SetPixel(x, y, map.IsInMap(x, y)
|
||||
? colors[tileset.GetWalkability(map.MapTiles[x, y])]
|
||||
? Color.FromArgb(alpha, terrainTypeColors[map.Theater].ColorForTerrainType(tileset.GetWalkability(map.MapTiles[x, y])))
|
||||
: shroudColor);
|
||||
return terrain;
|
||||
}
|
||||
@@ -120,13 +115,12 @@ namespace OpenRA.Graphics
|
||||
if (oreLayer == null)
|
||||
{
|
||||
var res = world.WorldActor.traits.Get<ResourceLayer>();
|
||||
var colors = terrainTypeColors[world.Map.Theater.ToLowerInvariant()];
|
||||
|
||||
oreLayer = new Bitmap(terrain);
|
||||
for (var y = world.Map.YOffset; y < world.Map.YOffset + world.Map.Height; y++)
|
||||
for (var x = world.Map.XOffset; x < world.Map.XOffset + world.Map.Width; x++)
|
||||
if (res.GetResource(new int2(x,y)) != null)
|
||||
oreLayer.SetPixel(x, y, colors[(int)TerrainMovementType.Ore]);
|
||||
oreLayer.SetPixel(x, y, Color.FromArgb(alpha, terrainTypeColors[world.Map.Theater].ColorForTerrainType((int)TerrainMovementType.Ore)));
|
||||
}
|
||||
|
||||
mapOnlySheet.Texture.SetData(oreLayer);
|
||||
@@ -140,7 +134,6 @@ namespace OpenRA.Graphics
|
||||
|
||||
unsafe
|
||||
{
|
||||
var colors = terrainTypeColors[world.Map.Theater.ToLowerInvariant()];
|
||||
int* c = (int*)bitmapData.Scan0;
|
||||
|
||||
foreach (var a in world.Queries.WithTrait<Unit>().Where( a => a.Actor.Owner != null ))
|
||||
@@ -158,7 +151,7 @@ namespace OpenRA.Graphics
|
||||
var b = world.WorldActor.traits.Get<BuildingInfluence>().GetBuildingAt(new int2(x, y));
|
||||
if (b != null)
|
||||
*(c + (y * bitmapData.Stride >> 2) + x) =
|
||||
(b.Owner != null ? Color.FromArgb(alpha, b.Owner.Color) : colors[4]).ToArgb();
|
||||
(b.Owner != null ? Color.FromArgb(alpha, b.Owner.Color) : Color.FromArgb(alpha, terrainTypeColors[world.Map.Theater].ColorForTerrainType(4))).ToArgb();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ namespace OpenRA.Traits
|
||||
public readonly string Suffix = null;
|
||||
public readonly string Tileset = null;
|
||||
public readonly string Templates = null;
|
||||
public readonly string MapColors = null;
|
||||
}
|
||||
class Theater {}
|
||||
}
|
||||
|
||||
13
mods/cnc/desert.col
Normal file
13
mods/cnc/desert.col
Normal file
@@ -0,0 +1,13 @@
|
||||
; Minimap colors for cnc WINTER theater
|
||||
; Format: terraintype,R,G,B
|
||||
0,40,68,40
|
||||
1,92,116,164
|
||||
2,88,116,116
|
||||
3,68,68,60
|
||||
4,28,32,36
|
||||
5,92,140,180
|
||||
6,68,68,60
|
||||
7,208,192,160
|
||||
8,176,156,120
|
||||
9,148,128,96
|
||||
10,124,124,124
|
||||
@@ -211,15 +211,18 @@ World:
|
||||
Suffix:des
|
||||
Templates:templates.ini
|
||||
Tileset:tileSet.til
|
||||
MapColors:desert.col
|
||||
Theater@WINTER:
|
||||
Name:Winter
|
||||
Theater:WINTER
|
||||
Suffix:win
|
||||
Templates:templates.ini
|
||||
Tileset:tileSet.til
|
||||
MapColors:winter.col
|
||||
Theater@TEMPERAT:
|
||||
Name:Temperate
|
||||
Theater:TEMPERAT
|
||||
Suffix:tem
|
||||
Templates:templates.ini
|
||||
Tileset:tileSet.til
|
||||
MapColors:temperat.col
|
||||
13
mods/cnc/temperat.col
Normal file
13
mods/cnc/temperat.col
Normal file
@@ -0,0 +1,13 @@
|
||||
; Minimap colors for cnc TEMPERAT theater
|
||||
; Format: terraintype,R,G,B
|
||||
0,40,68,40
|
||||
1,92,116,164
|
||||
2,88,116,116
|
||||
3,68,68,60
|
||||
4,28,32,36
|
||||
5,92,140,180
|
||||
6,68,68,60
|
||||
7,208,192,160
|
||||
8,176,156,120
|
||||
9,148,128,96
|
||||
10,124,124,124
|
||||
Binary file not shown.
13
mods/cnc/winter.col
Normal file
13
mods/cnc/winter.col
Normal file
@@ -0,0 +1,13 @@
|
||||
; Minimap colors for cnc WINTER theater
|
||||
; Format: terraintype,R,G,B
|
||||
0,40,68,40
|
||||
1,92,116,164
|
||||
2,88,116,116
|
||||
3,68,68,60
|
||||
4,28,32,36
|
||||
5,92,140,180
|
||||
6,68,68,60
|
||||
7,208,192,160
|
||||
8,176,156,120
|
||||
9,148,128,96
|
||||
10,124,124,124
|
||||
@@ -250,18 +250,21 @@ World:
|
||||
Suffix:sno
|
||||
Templates:templates.ini
|
||||
Tileset:tileSet.til
|
||||
MapColors:snow.col
|
||||
Theater@TEMPERAT:
|
||||
Name:Temperate
|
||||
Theater:TEMPERAT
|
||||
Suffix:tem
|
||||
Templates:templates.ini
|
||||
Tileset:tileSet.til
|
||||
MapColors:temperat.col
|
||||
Theater@INTERIOR:
|
||||
Name:Interior
|
||||
Theater:INTERIOR
|
||||
Suffix:int
|
||||
Templates:templates.ini
|
||||
Tileset:tileSet.til
|
||||
MapColors:temperat.col
|
||||
|
||||
MGG:
|
||||
GeneratesGap:
|
||||
|
||||
13
mods/ra/snow.col
Normal file
13
mods/ra/snow.col
Normal file
@@ -0,0 +1,13 @@
|
||||
; Minimap colors for ra SNOW theater
|
||||
; Format: terraintype,R,G,B
|
||||
0,196,196,196
|
||||
1,92,116,164
|
||||
2,88,116,116
|
||||
3,68,68,60
|
||||
4,28,32,36
|
||||
5,92,140,180
|
||||
6,68,68,60
|
||||
7,208,192,160
|
||||
8,176,156,120
|
||||
9,148,128,96
|
||||
10,124,124,124
|
||||
13
mods/ra/temperat.col
Normal file
13
mods/ra/temperat.col
Normal file
@@ -0,0 +1,13 @@
|
||||
; Minimap colors for ra TEMPERAT theater
|
||||
; Format: terraintype,R,G,B
|
||||
0,40,68,40
|
||||
1,92,116,164
|
||||
2,88,116,116
|
||||
3,68,68,60
|
||||
4,28,32,36
|
||||
5,92,140,180
|
||||
6,68,68,60
|
||||
7,208,192,160
|
||||
8,176,156,120
|
||||
9,148,128,96
|
||||
10,124,124,124
|
||||
Reference in New Issue
Block a user