Maps as packages. Disable broken map selector.
This commit is contained in:
@@ -326,8 +326,7 @@ namespace MapConverter
|
||||
|
||||
public void Save(string filepath)
|
||||
{
|
||||
Map.Tiledata = filepath+".bin";
|
||||
Map.Save(filepath+".yaml");
|
||||
Map.Save(filepath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
|
||||
@@ -38,6 +39,16 @@ namespace OpenRA.FileFormats
|
||||
if (!x.Key.StartsWith("-"))
|
||||
LoadField( self, x.Key, x.Value.Value );
|
||||
}
|
||||
|
||||
public static void LoadFields( object self, Dictionary<string,MiniYaml> my, IEnumerable<string> fields )
|
||||
{
|
||||
foreach (var field in fields)
|
||||
{
|
||||
if (!my.ContainsKey(field)) continue;
|
||||
FieldLoader.LoadField(self,field,my[field].Value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void LoadField( object self, string key, string value )
|
||||
{
|
||||
|
||||
@@ -29,13 +29,14 @@ namespace OpenRA.FileFormats
|
||||
{
|
||||
public class Map
|
||||
{
|
||||
public IFolder Package;
|
||||
|
||||
// Yaml map data
|
||||
public int MapFormat = 1;
|
||||
public string Title;
|
||||
public string Description;
|
||||
public string Author;
|
||||
public int PlayerCount;
|
||||
public string Preview;
|
||||
public string Tileset;
|
||||
|
||||
public Dictionary<string, ActorReference> Actors = new Dictionary<string, ActorReference>();
|
||||
@@ -43,7 +44,6 @@ namespace OpenRA.FileFormats
|
||||
public Dictionary<string, MiniYaml> Rules = new Dictionary<string, MiniYaml>();
|
||||
|
||||
// Binary map data
|
||||
public string Tiledata;
|
||||
public byte TileFormat = 1;
|
||||
public int2 MapSize;
|
||||
|
||||
@@ -62,22 +62,19 @@ namespace OpenRA.FileFormats
|
||||
public string Theater {get {return Tileset;}}
|
||||
public IEnumerable<int2> SpawnPoints {get {return Waypoints.Select(kv => kv.Value);}}
|
||||
|
||||
List<string> SimpleFields = new List<string>() {
|
||||
"MapFormat", "Title", "Description", "Author", "PlayerCount", "Tileset", "Tiledata", "Preview", "MapSize", "TopLeft", "BottomRight"
|
||||
static List<string> SimpleFields = new List<string>() {
|
||||
"MapFormat", "Title", "Description", "Author", "PlayerCount", "Tileset", "MapSize", "TopLeft", "BottomRight"
|
||||
};
|
||||
|
||||
public Map() {}
|
||||
|
||||
public Map(string filename)
|
||||
public Map(IFolder package)
|
||||
{
|
||||
var yaml = MiniYaml.FromFileInPackage(filename);
|
||||
Package = package;
|
||||
var yaml = MiniYaml.FromStream(Package.GetContent("map.yaml"));
|
||||
|
||||
// 'Simple' metadata
|
||||
foreach (var field in SimpleFields)
|
||||
{
|
||||
if (!yaml.ContainsKey(field)) continue;
|
||||
FieldLoader.LoadField(this,field,yaml[field].Value);
|
||||
}
|
||||
FieldLoader.LoadFields(this,yaml,SimpleFields);
|
||||
|
||||
// Waypoints
|
||||
foreach (var wp in yaml["Waypoints"].Nodes)
|
||||
@@ -100,7 +97,7 @@ namespace OpenRA.FileFormats
|
||||
// Rules
|
||||
Rules = yaml["Rules"].Nodes;
|
||||
|
||||
LoadBinaryData(Tiledata);
|
||||
LoadBinaryData();
|
||||
}
|
||||
|
||||
|
||||
@@ -120,8 +117,8 @@ namespace OpenRA.FileFormats
|
||||
// TODO: Players
|
||||
|
||||
root.Add("Rules",new MiniYaml(null,Rules));
|
||||
SaveBinaryData(Tiledata);
|
||||
root.WriteToFile(filepath);
|
||||
SaveBinaryData(filepath+"map.bin");
|
||||
root.WriteToFile(filepath+"map.yaml");
|
||||
}
|
||||
|
||||
static byte ReadByte( Stream s )
|
||||
@@ -140,16 +137,17 @@ namespace OpenRA.FileFormats
|
||||
return ret;
|
||||
}
|
||||
|
||||
public void LoadBinaryData(string filename)
|
||||
{
|
||||
Console.Write("path: {0}",filename);
|
||||
|
||||
Stream dataStream = FileSystem.Open(filename);
|
||||
public void LoadBinaryData()
|
||||
{
|
||||
Stream dataStream = Package.GetContent("map.bin");
|
||||
|
||||
// Load header info
|
||||
byte version = ReadByte(dataStream);
|
||||
MapSize.X = ReadWord(dataStream);
|
||||
MapSize.Y = ReadWord(dataStream);
|
||||
var width = ReadWord(dataStream);
|
||||
var height = ReadWord(dataStream);
|
||||
|
||||
if (width != MapSize.X || height != MapSize.Y)
|
||||
throw new InvalidDataException("Invalid tile data");
|
||||
|
||||
MapTiles = new TileReference<ushort, byte>[ MapSize.X, MapSize.Y ];
|
||||
MapResources = new TileReference<byte, byte>[ MapSize.X, MapSize.Y ];
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace OpenRA.FileFormats
|
||||
|
||||
public class Global
|
||||
{
|
||||
public string Map = "testmap.yaml";
|
||||
public string Map = "testmap";
|
||||
public string[] Packages = {}; // filename:sha1 pairs.
|
||||
public string[] Mods = { "ra" }; // mod names
|
||||
public int OrderLatency = 3;
|
||||
|
||||
@@ -258,7 +258,7 @@ namespace OpenRA
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
class MapInfo
|
||||
{
|
||||
public readonly string Filename;
|
||||
@@ -278,11 +278,12 @@ namespace OpenRA
|
||||
var mapsFolderMaps = Directory.GetFiles("maps/");
|
||||
return builtinMaps.Concat(mapsFolderMaps).Select(a => new MapInfo(a)).ToList();
|
||||
});
|
||||
|
||||
|
||||
|
||||
bool showMapChooser = false;
|
||||
MapInfo currentMap;
|
||||
bool mapPreviewDirty = true;
|
||||
|
||||
*/
|
||||
void AddUiButton(int2 pos, string text, Action<bool> a)
|
||||
{
|
||||
var rect = new Rectangle(pos.X - 160 / 2, pos.Y - 4, 160, 24);
|
||||
@@ -293,7 +294,7 @@ namespace OpenRA
|
||||
|
||||
public void DrawMapChooser()
|
||||
{
|
||||
var w = 800;
|
||||
/*var w = 800;
|
||||
var h = 600;
|
||||
var r = new Rectangle( (Game.viewport.Width - w) / 2, (Game.viewport.Height - h) / 2, w, h );
|
||||
DrawDialogBackground(r, "dialog");
|
||||
@@ -381,6 +382,7 @@ namespace OpenRA
|
||||
});
|
||||
|
||||
AddButton(r, _ => { });
|
||||
*/
|
||||
}
|
||||
bool PaletteAvailable(int index) { return Game.LobbyInfo.Clients.All(c => c.PaletteIndex != index); }
|
||||
bool SpawnPointAvailable(int index) { return (index == 0) || Game.LobbyInfo.Clients.All(c => c.SpawnPoint != index); }
|
||||
@@ -437,13 +439,14 @@ namespace OpenRA
|
||||
{
|
||||
buttons.Clear();
|
||||
DrawDownloadBar();
|
||||
|
||||
/*
|
||||
if (showMapChooser)
|
||||
{
|
||||
DrawMapChooser();
|
||||
return;
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
var w = 800;
|
||||
var h = 600;
|
||||
var r = new Rectangle( (Game.viewport.Width - w) / 2, (Game.viewport.Height - h) / 2, w, h );
|
||||
@@ -456,7 +459,7 @@ namespace OpenRA
|
||||
world.Minimap.Update();
|
||||
world.Minimap.Draw(minimapRect, true);
|
||||
world.Minimap.DrawSpawnPoints(minimapRect);
|
||||
|
||||
/*
|
||||
if (Game.IsHost)
|
||||
{
|
||||
AddUiButton(new int2(r.Right - 100, r.Top + 300), "Change Map",
|
||||
@@ -468,7 +471,8 @@ namespace OpenRA
|
||||
mapPreviewDirty = true;
|
||||
});
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
var f = renderer.BoldFont;
|
||||
f.DrawText(rgbaRenderer, "Name", new int2(r.Left + 40, r.Top + 50), Color.White);
|
||||
f.DrawText(rgbaRenderer, "Color", new int2(r.Left + 140, r.Top + 50), Color.White);
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace OpenRA.GameRules
|
||||
// External game settings
|
||||
public readonly string NetworkHost = "";
|
||||
public readonly int NetworkPort = 0;
|
||||
public readonly string Map = "testmap.yaml";
|
||||
public readonly string Map = "testmap";
|
||||
public readonly int Player = 1;
|
||||
public readonly string Replay = "";
|
||||
public readonly string PlayerName = "";
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
using OpenRA.Collections;
|
||||
using OpenRA.Effects;
|
||||
using OpenRA.FileFormats;
|
||||
@@ -78,7 +79,27 @@ namespace OpenRA
|
||||
{
|
||||
Timer.Time( "----World.ctor" );
|
||||
|
||||
Map = new Map( Game.LobbyInfo.GlobalSettings.Map );
|
||||
// TODO: Do this properly
|
||||
string mapPath = null;
|
||||
foreach (var mod in Game.LobbyInfo.GlobalSettings.Mods)
|
||||
{
|
||||
var path = "mods/"+mod+"/maps/"+Game.LobbyInfo.GlobalSettings.Map+"/";
|
||||
if (Directory.Exists(path))
|
||||
{
|
||||
mapPath = path;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (mapPath == null)
|
||||
{
|
||||
var path = "maps/"+Game.LobbyInfo.GlobalSettings.Map+"/";
|
||||
if (!Directory.Exists(path))
|
||||
throw new InvalidDataException("Unknown map `{0}`".F(Game.LobbyInfo.GlobalSettings.Map));
|
||||
mapPath = path;
|
||||
}
|
||||
Map = new Map( new Folder(mapPath) );
|
||||
|
||||
|
||||
customTerrain = new ICustomTerrain[Map.MapSize.X, Map.MapSize.Y];
|
||||
Timer.Time( "new Map: {0}" );
|
||||
|
||||
|
||||
@@ -1,19 +1,10 @@
|
||||
MapFormat: 1
|
||||
|
||||
Title: (null)
|
||||
|
||||
Title: GDI Mission 2
|
||||
Author: Westwood Studios
|
||||
|
||||
PlayerCount: 7
|
||||
|
||||
PlayerCount: 1
|
||||
Tileset: TEMPERAT
|
||||
|
||||
Tiledata: testmap.bin
|
||||
|
||||
MapSize: 64,64
|
||||
|
||||
TopLeft: 31,31
|
||||
|
||||
BottomRight: 62,62
|
||||
|
||||
Actors:
|
||||
@@ -95,21 +86,21 @@ Actors:
|
||||
Actor75: tc01 Neutral 54,42
|
||||
Actor76: t01 Neutral 32,31
|
||||
Actor77: tc02 Neutral 33,31
|
||||
Actor78: pyle GoodGuy 55,51
|
||||
# Actor78: pyle GoodGuy 55,51
|
||||
Actor79: silo BadGuy 57,32
|
||||
Actor80: silo BadGuy 59,32
|
||||
Actor81: nuke BadGuy 55,32
|
||||
Actor82: fact BadGuy 52,32
|
||||
Actor83: nuke GoodGuy 53,52
|
||||
# Actor83: nuke GoodGuy 53,52
|
||||
Actor84: proc BadGuy 57,34
|
||||
Actor85: bggy BadGuy 52,39
|
||||
Actor86: harv BadGuy 50,35
|
||||
Actor87: jeep GoodGuy 54,49
|
||||
Actor88: jeep GoodGuy 57,49
|
||||
# Actor87: jeep GoodGuy 54,49
|
||||
# Actor88: jeep GoodGuy 57,49
|
||||
Actor89: bggy BadGuy 33,37
|
||||
Actor90: bggy BadGuy 51,50
|
||||
Actor91: bggy BadGuy 59,39
|
||||
Actor92: jeep GoodGuy 56,54
|
||||
# Actor92: jeep GoodGuy 56,54
|
||||
Actor93: e1 BadGuy 48,32
|
||||
Actor94: e1 BadGuy 35,31
|
||||
Actor95: e1 BadGuy 39,31
|
||||
@@ -147,13 +138,13 @@ Actors:
|
||||
Actor127: e1 BadGuy 38,48
|
||||
Actor128: e1 BadGuy 53,40
|
||||
Actor129: e1 BadGuy 45,36
|
||||
Actor130: e1 GoodGuy 50,51
|
||||
Actor131: e1 GoodGuy 50,50
|
||||
Actor132: e1 GoodGuy 53,49
|
||||
Actor133: e1 GoodGuy 51,49
|
||||
# Actor130: e1 GoodGuy 50,51
|
||||
# Actor131: e1 GoodGuy 50,50
|
||||
# Actor132: e1 GoodGuy 53,49
|
||||
# Actor133: e1 GoodGuy 51,49
|
||||
Actor134: e1 BadGuy 52,40
|
||||
Actor135: e1 GoodGuy 52,50
|
||||
Actor136: e1 GoodGuy 56,49
|
||||
# Actor135: e1 GoodGuy 52,50
|
||||
# Actor136: e1 GoodGuy 56,49
|
||||
Actor137: e1 BadGuy 55,42
|
||||
Actor138: e1 BadGuy 56,42
|
||||
Actor139: e1 BadGuy 45,36
|
||||
@@ -168,13 +159,7 @@ Actors:
|
||||
Actor148: e1 BadGuy 48,36
|
||||
|
||||
Waypoints:
|
||||
spawn6: 54,39
|
||||
spawn5: 46,37
|
||||
spawn4: 46,41
|
||||
spawn3: 59,41
|
||||
spawn2: 54,55
|
||||
spawn1: 38,54
|
||||
spawn0: 35,33
|
||||
spawn0: 54,55
|
||||
|
||||
Rules:
|
||||
|
||||
Reference in New Issue
Block a user