MapFormat = 1 and editor support
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
@@ -387,26 +387,12 @@ namespace OpenRA.Editor
|
||||
{
|
||||
var map = new Map();
|
||||
|
||||
map.MapSize = new int2(1, 1);
|
||||
map.MapResources = new TileReference<byte, byte>[1, 1];
|
||||
map.MapTiles = new TileReference<ushort, byte>[1, 1]
|
||||
{ { new TileReference<ushort, byte> {
|
||||
type = currentMod == "cnc" ? (ushort)0xffu : (ushort)0xffffu,
|
||||
image = (byte)0xffu,
|
||||
index = (byte)0xffu } } };
|
||||
|
||||
map.Resize((int)nmd.width.Value, (int)nmd.height.Value);
|
||||
|
||||
map.PlayerCount = 8;
|
||||
|
||||
map.TopLeft = new int2((int)nmd.cordonLeft.Value, (int)nmd.cordonTop.Value);
|
||||
map.BottomRight = new int2((int)nmd.cordonRight.Value, (int)nmd.cordonBottom.Value);
|
||||
|
||||
map.Tileset = nmd.theater.SelectedItem as string;
|
||||
|
||||
map.Title = "Name your map here";
|
||||
map.Description = "Describe your map here";
|
||||
map.Author = "Your name here";
|
||||
|
||||
NewMap(map);
|
||||
}
|
||||
|
||||
@@ -79,7 +79,27 @@ namespace OpenRA.FileFormats
|
||||
"Selectable", "MapFormat", "Title", "Description", "Author", "PlayerCount", "Tileset", "MapSize", "TopLeft", "BottomRight"
|
||||
};
|
||||
|
||||
public Map() { }
|
||||
public Map()
|
||||
{
|
||||
MapSize = new int2(1, 1);
|
||||
MapResources = new TileReference<byte, byte>[1, 1];
|
||||
MapTiles = new TileReference<ushort, byte>[1, 1]
|
||||
{ { new TileReference<ushort, byte> {
|
||||
type = (ushort)0xffffu,
|
||||
image = (byte)0xffu,
|
||||
index = (byte)0xffu } } };
|
||||
|
||||
PlayerCount = 0;
|
||||
TopLeft = new int2(0,0);
|
||||
BottomRight = new int2(0,0);
|
||||
|
||||
Tileset = "TEMPERAT";
|
||||
Players.Add("Neutral", new PlayerReference("Neutral", "neutral", "allies", true, true));
|
||||
|
||||
Title = "Name your map here";
|
||||
Description = "Describe your map here";
|
||||
Author = "Your name here";
|
||||
}
|
||||
|
||||
public Map(IFolder package)
|
||||
{
|
||||
@@ -97,19 +117,39 @@ namespace OpenRA.FileFormats
|
||||
}
|
||||
|
||||
// Players
|
||||
foreach (var kv in yaml["Players"].Nodes)
|
||||
if (MapFormat < 2)
|
||||
{
|
||||
var player = new PlayerReference(kv.Value);
|
||||
Players.Add(player.Name, player);
|
||||
Players.Add("Neutral", new PlayerReference("Neutral", "neutral", "allies", true, true));
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var kv in yaml["Players"].Nodes)
|
||||
{
|
||||
var player = new PlayerReference(kv.Value);
|
||||
Players.Add(player.Name, player);
|
||||
}
|
||||
}
|
||||
|
||||
// Actors
|
||||
foreach (var kv in yaml["Actors"].Nodes)
|
||||
if (MapFormat == 1 )
|
||||
{
|
||||
string[] vals = kv.Value.Value.Split(' ');
|
||||
string[] loc = vals[2].Split(',');
|
||||
var a = new ActorReference(vals[0], new int2(int.Parse(loc[0]), int.Parse(loc[1])), vals[1]);
|
||||
Actors.Add(kv.Key, a);
|
||||
foreach (var kv in yaml["Actors"].Nodes)
|
||||
{
|
||||
string[] vals = kv.Value.Value.Split(' ');
|
||||
string[] loc = vals[2].Split(',');
|
||||
var a = new ActorReference(vals[0], new int2(int.Parse(loc[0]), int.Parse(loc[1])), "Neutral");
|
||||
Actors.Add(kv.Key, a);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var kv in yaml["Actors"].Nodes)
|
||||
{
|
||||
string[] vals = kv.Value.Value.Split(' ');
|
||||
string[] loc = vals[2].Split(',');
|
||||
var a = new ActorReference(vals[0], new int2(int.Parse(loc[0]), int.Parse(loc[1])), vals[1]);
|
||||
Actors.Add(kv.Key, a);
|
||||
}
|
||||
}
|
||||
|
||||
// Smudges
|
||||
@@ -129,6 +169,8 @@ namespace OpenRA.FileFormats
|
||||
|
||||
public void Save(string filepath)
|
||||
{
|
||||
MapFormat = 2;
|
||||
|
||||
Dictionary<string, MiniYaml> root = new Dictionary<string, MiniYaml>();
|
||||
foreach (var field in SimpleFields)
|
||||
{
|
||||
|
||||
@@ -32,5 +32,14 @@ namespace OpenRA.FileFormats
|
||||
{
|
||||
FieldLoader.Load(this, my);
|
||||
}
|
||||
|
||||
public PlayerReference(string name, string palette, string race, bool ownsworld, bool noncombatant)
|
||||
{
|
||||
Name = name;
|
||||
Palette = palette;
|
||||
Race = race;
|
||||
OwnsWorld = ownsworld;
|
||||
NonCombatant = noncombatant;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
; clear ground
|
||||
DTW
|
||||
1
|
||||
ff
|
||||
00ff
|
||||
clear1
|
||||
|
||||
; clear ground
|
||||
DTW
|
||||
1
|
||||
ffff
|
||||
clear1
|
||||
|
||||
; clear ground
|
||||
|
||||
Reference in New Issue
Block a user