Changed IFolder implementations' priorities to be based on listing order in mod.yaml
This commit is contained in:
@@ -62,7 +62,7 @@ namespace OpenRA.Editor
|
||||
Game.modData = new ModData(currentMod);
|
||||
|
||||
// load the map
|
||||
var map = new Map(new Folder(mapname));
|
||||
var map = new Map(new Folder(mapname, 0));
|
||||
|
||||
// upgrade maps that have no player definitions. editor doesnt care,
|
||||
// but this breaks the game pretty badly.
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace OpenRA.Editor
|
||||
if (MapList.SelectedItems.Count == 1)
|
||||
{
|
||||
txtNew.Text = MapList.SelectedItems[0].Text;
|
||||
var map = new Map(new Folder(Path.Combine(MapFolderPath, MapList.SelectedItems[0].Text)));
|
||||
var map = new Map(new Folder(Path.Combine(MapFolderPath, MapList.SelectedItems[0].Text), 0));
|
||||
txtTitle.Text = map.Title;
|
||||
txtAuthor.Text = map.Author;
|
||||
txtTheater.Text = map.Theater;
|
||||
|
||||
@@ -21,9 +21,11 @@ namespace OpenRA.FileFormats
|
||||
readonly uint[] hashes;
|
||||
readonly Stream s;
|
||||
readonly ZipPackage pkg;
|
||||
int priority;
|
||||
|
||||
public CompressedPackage(string filename)
|
||||
public CompressedPackage(string filename, int priority)
|
||||
{
|
||||
this.priority = priority;
|
||||
s = FileSystem.Open(filename);
|
||||
pkg = (ZipPackage)ZipPackage.Open(s, FileMode.Open);
|
||||
hashes = pkg.GetParts()
|
||||
@@ -45,7 +47,7 @@ namespace OpenRA.FileFormats
|
||||
|
||||
public int Priority
|
||||
{
|
||||
get { return 1; }
|
||||
get { return 500 + priority; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,14 +34,16 @@ namespace OpenRA.FileFormats
|
||||
}
|
||||
}
|
||||
|
||||
static int order = 0;
|
||||
|
||||
static IFolder OpenPackage(string filename)
|
||||
{
|
||||
if (filename.EndsWith(".mix"))
|
||||
return new Package(filename);
|
||||
return new Package(filename, order++);
|
||||
else if (filename.EndsWith(".zip"))
|
||||
return new CompressedPackage(filename);
|
||||
return new CompressedPackage(filename, order++);
|
||||
else
|
||||
return new Folder(filename);
|
||||
return new Folder(filename, order++);
|
||||
}
|
||||
|
||||
public static void Mount(string name)
|
||||
@@ -76,7 +78,7 @@ namespace OpenRA.FileFormats
|
||||
{
|
||||
var folder = index[PackageEntry.HashFilename(filename)]
|
||||
.Where(x => x.Exists(filename))
|
||||
.OrderByDescending(x => x.Priority)
|
||||
.OrderBy(x => x.Priority)
|
||||
.FirstOrDefault();
|
||||
|
||||
if (folder != null)
|
||||
|
||||
@@ -17,7 +17,9 @@ namespace OpenRA.FileFormats
|
||||
{
|
||||
readonly string path;
|
||||
|
||||
public Folder(string path) { this.path = path; }
|
||||
int priority;
|
||||
|
||||
public Folder(string path, int priority) { this.path = path; this.priority = priority; }
|
||||
|
||||
public Stream GetContent(string filename)
|
||||
{
|
||||
@@ -39,7 +41,7 @@ namespace OpenRA.FileFormats
|
||||
|
||||
public int Priority
|
||||
{
|
||||
get { return 100; }
|
||||
get { return priority; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,9 +29,11 @@ namespace OpenRA.FileFormats
|
||||
readonly bool isRmix, isEncrypted;
|
||||
readonly long dataStart;
|
||||
readonly Stream s;
|
||||
int priority;
|
||||
|
||||
public Package(string filename)
|
||||
public Package(string filename, int priority)
|
||||
{
|
||||
this.priority = priority;
|
||||
s = FileSystem.Open(filename);
|
||||
|
||||
BinaryReader reader = new BinaryReader(s);
|
||||
@@ -154,7 +156,7 @@ namespace OpenRA.FileFormats
|
||||
|
||||
public int Priority
|
||||
{
|
||||
get { return 0; }
|
||||
get { return 1000 + priority; }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -184,7 +184,7 @@ namespace OpenRA
|
||||
public void Save(string filepath)
|
||||
{
|
||||
// Todo: save to a zip file in the support dir by default
|
||||
Package = new Folder(filepath);
|
||||
Package = new Folder(filepath, 0);
|
||||
MapFormat = 3;
|
||||
|
||||
var root = new List<MiniYamlNode>();
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace OpenRA
|
||||
.Where(p => Directory.Exists(p))
|
||||
.SelectMany(p => Directory.GetDirectories(p)).ToList();
|
||||
|
||||
return paths.Select(p => new MapStub(new Folder(p))).ToDictionary(m => m.Uid);
|
||||
return paths.Select(p => new MapStub(new Folder(p, 0))).ToDictionary(m => m.Uid);
|
||||
}
|
||||
|
||||
string cachedTheatre = null;
|
||||
|
||||
Reference in New Issue
Block a user