loads tileset.

needs a lot of rework, cant push existing implementation into hardware.

git-svn-id: svn://svn.ijw.co.nz/svn/OpenRa@1107 993157c7-ee19-0410-b2c4-bb4e9862e678
This commit is contained in:
chrisf
2007-07-05 23:05:25 +00:00
parent 32e8e8a475
commit c77b8378f5

View File

@@ -11,7 +11,13 @@ namespace OpenRa.Game
{ {
class MainWindow : Form 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"; const string mapName = "scm12ea.ini";
@@ -24,9 +30,11 @@ namespace OpenRa.Game
device = GraphicsDevice.Create(this, ClientSize.Width, ClientSize.Height, true, false); device = GraphicsDevice.Create(this, ClientSize.Width, ClientSize.Height, true, false);
IniFile mapFile = new IniFile(File.OpenRead("../../../" + mapName)); 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); Text = string.Format("OpenRA - {0} - {1}", map.Title, mapName);
tileSet = LoadTileSet(map);
} }
internal void Run() internal void Run()
@@ -43,8 +51,35 @@ namespace OpenRa.Game
device.Begin(); device.Begin();
device.Clear(0); device.Clear(0);
// render something :)
device.End(); device.End();
device.Present(); 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);
}
} }
} }