MapFormat = 1 and editor support
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Drawing.Imaging;
|
using System.Drawing.Imaging;
|
||||||
@@ -387,26 +387,12 @@ namespace OpenRA.Editor
|
|||||||
{
|
{
|
||||||
var map = new Map();
|
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.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.TopLeft = new int2((int)nmd.cordonLeft.Value, (int)nmd.cordonTop.Value);
|
||||||
map.BottomRight = new int2((int)nmd.cordonRight.Value, (int)nmd.cordonBottom.Value);
|
map.BottomRight = new int2((int)nmd.cordonRight.Value, (int)nmd.cordonBottom.Value);
|
||||||
|
|
||||||
map.Tileset = nmd.theater.SelectedItem as string;
|
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);
|
NewMap(map);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,7 +79,27 @@ namespace OpenRA.FileFormats
|
|||||||
"Selectable", "MapFormat", "Title", "Description", "Author", "PlayerCount", "Tileset", "MapSize", "TopLeft", "BottomRight"
|
"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)
|
public Map(IFolder package)
|
||||||
{
|
{
|
||||||
@@ -97,13 +117,32 @@ namespace OpenRA.FileFormats
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Players
|
// Players
|
||||||
|
if (MapFormat < 2)
|
||||||
|
{
|
||||||
|
Players.Add("Neutral", new PlayerReference("Neutral", "neutral", "allies", true, true));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
foreach (var kv in yaml["Players"].Nodes)
|
foreach (var kv in yaml["Players"].Nodes)
|
||||||
{
|
{
|
||||||
var player = new PlayerReference(kv.Value);
|
var player = new PlayerReference(kv.Value);
|
||||||
Players.Add(player.Name, player);
|
Players.Add(player.Name, player);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Actors
|
// Actors
|
||||||
|
if (MapFormat == 1 )
|
||||||
|
{
|
||||||
|
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)
|
foreach (var kv in yaml["Actors"].Nodes)
|
||||||
{
|
{
|
||||||
string[] vals = kv.Value.Value.Split(' ');
|
string[] vals = kv.Value.Value.Split(' ');
|
||||||
@@ -111,6 +150,7 @@ namespace OpenRA.FileFormats
|
|||||||
var a = new ActorReference(vals[0], new int2(int.Parse(loc[0]), int.Parse(loc[1])), vals[1]);
|
var a = new ActorReference(vals[0], new int2(int.Parse(loc[0]), int.Parse(loc[1])), vals[1]);
|
||||||
Actors.Add(kv.Key, a);
|
Actors.Add(kv.Key, a);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Smudges
|
// Smudges
|
||||||
foreach (var kv in yaml["Smudges"].Nodes)
|
foreach (var kv in yaml["Smudges"].Nodes)
|
||||||
@@ -129,6 +169,8 @@ namespace OpenRA.FileFormats
|
|||||||
|
|
||||||
public void Save(string filepath)
|
public void Save(string filepath)
|
||||||
{
|
{
|
||||||
|
MapFormat = 2;
|
||||||
|
|
||||||
Dictionary<string, MiniYaml> root = new Dictionary<string, MiniYaml>();
|
Dictionary<string, MiniYaml> root = new Dictionary<string, MiniYaml>();
|
||||||
foreach (var field in SimpleFields)
|
foreach (var field in SimpleFields)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -32,5 +32,14 @@ namespace OpenRA.FileFormats
|
|||||||
{
|
{
|
||||||
FieldLoader.Load(this, my);
|
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
|
; clear ground
|
||||||
DTW
|
DTW
|
||||||
1
|
1
|
||||||
ff
|
00ff
|
||||||
|
clear1
|
||||||
|
|
||||||
|
; clear ground
|
||||||
|
DTW
|
||||||
|
1
|
||||||
|
ffff
|
||||||
clear1
|
clear1
|
||||||
|
|
||||||
; clear ground
|
; clear ground
|
||||||
|
|||||||
Reference in New Issue
Block a user