diff --git a/OpenRa.Game/MainWindow.cs b/OpenRa.Game/MainWindow.cs index 7f79967910..3c9b0ec143 100644 --- a/OpenRa.Game/MainWindow.cs +++ b/OpenRa.Game/MainWindow.cs @@ -11,7 +11,13 @@ namespace OpenRa.Game { class MainWindow : Form { - GraphicsDevice device; + readonly GraphicsDevice device; + readonly Map map; + readonly TileSet tileSet; + + Palette pal; + Package TileMix; + string TileSuffix; const string mapName = "scm12ea.ini"; @@ -24,9 +30,11 @@ namespace OpenRa.Game device = GraphicsDevice.Create(this, ClientSize.Width, ClientSize.Height, true, false); IniFile mapFile = new IniFile(File.OpenRead("../../../" + mapName)); - Map map = new Map(mapFile); + map = new Map(mapFile); Text = string.Format("OpenRA - {0} - {1}", map.Title, mapName); + + tileSet = LoadTileSet(map); } internal void Run() @@ -43,8 +51,35 @@ namespace OpenRa.Game device.Begin(); device.Clear(0); + // render something :) + device.End(); device.Present(); } + + TileSet LoadTileSet(Map currentMap) + { + switch (currentMap.Theater.ToLowerInvariant()) + { + case "temperate": + pal = new Palette(File.OpenRead("../../../temperat.pal")); + TileMix = new Package("../../../temperat.mix"); + TileSuffix = ".tem"; + break; + case "snow": + pal = new Palette(File.OpenRead("../../../snow.pal")); + TileMix = new Package("../../../snow.mix"); + TileSuffix = ".sno"; + break; + case "interior": + pal = new Palette(File.OpenRead("../../../interior.pal")); + TileMix = new Package("../../../interior.mix"); + TileSuffix = ".int"; + break; + default: + throw new NotImplementedException(); + } + return new TileSet(TileMix, TileSuffix, pal); + } } }