Save and restore viewport position / selection / control groups.
This commit is contained in:
@@ -200,5 +200,42 @@ namespace OpenRA
|
||||
.Select(g => (int?)g.Key)
|
||||
.FirstOrDefault();
|
||||
}
|
||||
|
||||
public List<MiniYamlNode> Serialize()
|
||||
{
|
||||
var groups = controlGroups
|
||||
.Where(cg => cg.Value.Any())
|
||||
.Select(cg => new MiniYamlNode(cg.Key.ToString(),
|
||||
FieldSaver.FormatValue(cg.Value.Select(a => a.ActorID).ToArray())))
|
||||
.ToList();
|
||||
|
||||
return new List<MiniYamlNode>()
|
||||
{
|
||||
new MiniYamlNode("Selection", FieldSaver.FormatValue(Actors.Select(a => a.ActorID).ToArray())),
|
||||
new MiniYamlNode("Groups", new MiniYaml("", groups))
|
||||
};
|
||||
}
|
||||
|
||||
public void Deserialize(World world, List<MiniYamlNode> data)
|
||||
{
|
||||
var selectionNode = data.FirstOrDefault(n => n.Key == "Selection");
|
||||
if (selectionNode != null)
|
||||
{
|
||||
var selected = FieldLoader.GetValue<uint[]>("Selection", selectionNode.Value.Value)
|
||||
.Select(a => world.GetActorById(a));
|
||||
Combine(world, selected, false, false);
|
||||
}
|
||||
|
||||
var groupsNode = data.FirstOrDefault(n => n.Key == "Groups");
|
||||
if (groupsNode != null)
|
||||
{
|
||||
foreach (var n in groupsNode.Value.Nodes)
|
||||
{
|
||||
var group = FieldLoader.GetValue<uint[]>(n.Key, n.Value.Value)
|
||||
.Select(a => world.GetActorById(a));
|
||||
controlGroups[int.Parse(n.Key)].AddRange(group);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user