From ec849c19ab0e13db89b4f46c468db8ac2284b404 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sat, 30 Jan 2010 12:13:25 +1300 Subject: [PATCH] Load default packages from the default mod --- OpenRa.FileFormats/Session.cs | 4 +++- OpenRa.Game/Game.cs | 25 +++++++++++++++++-------- OpenRa.Game/MainWindow.cs | 7 ++++--- mods/ra/mod.yaml | 16 ++++++++++++++++ 4 files changed, 40 insertions(+), 12 deletions(-) diff --git a/OpenRa.FileFormats/Session.cs b/OpenRa.FileFormats/Session.cs index 4bbf324ea1..b0dbca125e 100644 --- a/OpenRa.FileFormats/Session.cs +++ b/OpenRa.FileFormats/Session.cs @@ -38,6 +38,7 @@ namespace OpenRa.FileFormats public class Manifest { + public readonly string[] Folders = { }; public readonly string[] Packages = { }; public readonly string[] LegacyRules = { }; public readonly string[] Rules = { }; @@ -49,7 +50,8 @@ namespace OpenRa.FileFormats var yaml = mods .Select(m => MiniYaml.FromFile("mods/" + m + "/mod.yaml")) .Aggregate(MiniYaml.Merge); - + + Folders = YamlList(yaml, "Folders"); Packages = YamlList(yaml, "Packages"); LegacyRules = YamlList(yaml, "LegacyRules"); Rules = YamlList(yaml, "Rules"); diff --git a/OpenRa.Game/Game.cs b/OpenRa.Game/Game.cs index 5c132be711..b01e5e3b0e 100644 --- a/OpenRa.Game/Game.cs +++ b/OpenRa.Game/Game.cs @@ -35,6 +35,19 @@ namespace OpenRa internal static Session LobbyInfo = new Session(); static bool changePending; + public static void LoadModPackages(Manifest manifest) + { + FileSystem.UnmountTemporaryPackages(); + Timer.Time("reset: {0}"); + + foreach (var dir in manifest.Folders) + FileSystem.MountTemporary(new Folder(dir)); + + foreach (var pkg in manifest.Packages) + FileSystem.MountTemporary(new Package(pkg)); + Timer.Time("mount tempory packages: {0}"); + } + public static void ChangeMap(string mapName) { Timer.Time( "----ChangeMap" ); @@ -42,17 +55,12 @@ namespace OpenRa var manifest = new Manifest(LobbyInfo.GlobalSettings.Mods); Timer.Time( "manifest: {0}" ); - chat.AddLine(Color.White, "Debug", "Map change {0} -> {1}".F(Game.mapName, mapName)); Game.changePending = false; Game.mapName = mapName; SheetBuilder.Initialize(renderer); - FileSystem.UnmountTemporaryPackages(); - Timer.Time( "reset: {0}" ); - - foreach (var pkg in manifest.Packages) - FileSystem.MountTemporary(new Package(pkg)); - Timer.Time( "mount tempory packages: {0}" ); - + + LoadModPackages(manifest); + Rules.LoadRules(mapName, manifest); Timer.Time( "load rules: {0}" ); @@ -82,6 +90,7 @@ namespace OpenRa Timer.Time( "chrome: {0}" ); Timer.Time( "----end ChangeMap" ); + chat.AddLine(Color.White, "Debug", "Map change {0} -> {1}".F(Game.mapName, mapName)); } internal static void Initialize(string mapName, Renderer renderer, int2 clientSize, int localPlayer, Controller controller) diff --git a/OpenRa.Game/MainWindow.cs b/OpenRa.Game/MainWindow.cs index e3f9d69e30..d86b80700c 100755 --- a/OpenRa.Game/MainWindow.cs +++ b/OpenRa.Game/MainWindow.cs @@ -49,12 +49,13 @@ namespace OpenRa } LoadUserSettings(settings); - + + // Load the default mod to access required files + Game.LoadModPackages(new Manifest(Game.LobbyInfo.GlobalSettings.Mods)); + UiOverlay.ShowUnitDebug = Game.Settings.UnitDebug; WorldRenderer.ShowUnitPaths = Game.Settings.PathDebug; Renderer.SheetSize = Game.Settings.SheetSize; - - FileSystem.MountDefaultPackages(); bool windowed = !Game.Settings.Fullscreen; renderer = new Renderer(this, GetResolution(settings), windowed); diff --git a/mods/ra/mod.yaml b/mods/ra/mod.yaml index 9befc9c417..96eead4ce1 100644 --- a/mods/ra/mod.yaml +++ b/mods/ra/mod.yaml @@ -1,6 +1,22 @@ # Classic Red Alert Mod -- Package Manifest +Folders: + ./ + Packages: + main.mix + redalert.mix + conquer.mix + hires.mix + general.mix + local.mix + sounds.mix + speech.mix + allies.mix + russian.mix + temperat.mix + snow.mix + interior.mix LegacyRules: mods/ra/rules.ini: More or less original Red Alert rules file.