Add a mechanism to add palettes via traits

This commit is contained in:
Paul Chote
2010-02-03 21:49:37 +13:00
parent e44c46200d
commit 1e01911b46
6 changed files with 50 additions and 9 deletions

View File

@@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using OpenRa.FileFormats;
namespace OpenRa.Traits
{
class PaletteFromFileInfo : ITraitInfo
{
public readonly string Name = "Undefined";
public readonly string Theatre = "Undefined";
public readonly string Filename = "";
public readonly string Remap = "";
public object Create(Actor self) { return new PaletteFromFile(self, this); }
}
class PaletteFromFile
{
public PaletteFromFile(Actor self, PaletteFromFileInfo info)
{
Log.Write("Created palette");
if (info.Theatre == "Undefined" ||
info.Theatre.ToLowerInvariant() == self.World.Map.Theater.ToLowerInvariant())
{
self.World.WorldRenderer.AddPalette(info.Name, new Palette(FileSystem.Open("temperat_ra.pal")));
}
}
}
}