static void Main(string[] args) { PerfTracker.StartupEvent("Entered main"); Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); // Required for code page 850 support in .NET Core PerfTracker.StartupEvent("Registered encodings"); var commandLine = new CommandLineOptions(args); if (commandLine.Mode == ExecutionMode.Exit) { return; } var baseDir = FormatUtil.FindBasePath(); if (baseDir == null) { throw new InvalidOperationException("No base directory could be found."); } PerfTracker.StartupEvent($"Found base directory {baseDir}"); PerfTracker.StartupEvent("Registering asset manager"); var factory = new VeldridCoreFactory(); using var locatorRegistry = new AssetLocatorRegistry() .AddAssetLocator(new StandardAssetLocator()) .AddAssetLocator(new AssetConfigLocator()) .AddAssetLocator(new CoreSpriteLocator()) .AddAssetLocator(new MetaFontLocator(factory)) .AddAssetLocator(new NewStringLocator()) .AddAssetLocator(new SoundBankLocator()) .AddAssetLocator(new SavedGameLocator()) .AddAssetPostProcessor(new AlbionSpritePostProcessor()) .AddAssetPostProcessor(new ImageSharpPostProcessor()) .AddAssetPostProcessor(new InterlacedBitmapPostProcessor()) .AddAssetPostProcessor(new InventoryPostProcessor()) ; var assets = new AssetManager(); var services = new Container("Services", new StdioConsoleLogger(), new ClipboardManager(), new ImGuiConsoleLogger(), Settings.Load(baseDir), // Need to register settings first, as the AssetConfigLocator relies on it. locatorRegistry, assets); using var exchange = new EventExchange(new LogExchange()) .Register <ICoreFactory>(factory) .Attach(services); Engine.GlobalExchange = exchange; PerfTracker.StartupEvent("Registered asset manager"); PerfTracker.StartupEvent($"Running as {commandLine.Mode}"); switch (commandLine.Mode) { case ExecutionMode.Game: case ExecutionMode.GameWithSlavedAudio: Albion.RunGame(exchange, services, baseDir, commandLine); break; case ExecutionMode.AudioSlave: exchange.Attach(new AudioManager(true)); break; case ExecutionMode.Editor: break; // TODO case ExecutionMode.SavedGameTests: SavedGameTests.RoundTripTest(baseDir); break; case ExecutionMode.DumpData: PerfTracker.BeginFrame(); // Don't need to show verbose startup logging while dumping var tf = new TextFormatter(); exchange.Attach(tf); DumpType dumpTypes = DumpType.All; if (commandLine.GameModeArgument != null) { dumpTypes = 0; foreach (var t in commandLine.GameModeArgument.Split(' ', StringSplitOptions.RemoveEmptyEntries)) { dumpTypes |= Enum.Parse <DumpType>(t); } } if ((dumpTypes & DumpType.Characters) != 0) { Dump.CharacterSheets(assets, tf, baseDir); } if ((dumpTypes & DumpType.Chests) != 0) { Dump.Chests(assets, baseDir); } if ((dumpTypes & DumpType.CoreSprites) != 0) { Dump.CoreSprites(assets, baseDir); } if ((dumpTypes & DumpType.EventSets) != 0) { Dump.EventSets(assets, baseDir); } if ((dumpTypes & DumpType.Items) != 0) { Dump.ItemData(assets, baseDir); } if ((dumpTypes & DumpType.MapEvents) != 0) { Dump.MapEvents(assets, baseDir); } if ((dumpTypes & DumpType.Maps) != 0) { Dump.MapData(assets, tf, baseDir); } if ((dumpTypes & DumpType.Spells) != 0) { Dump.Spells(assets, tf, baseDir); } if ((dumpTypes & DumpType.ThreeDMaps) != 0) { Dump.ThreeDMapAndLabInfo(assets, baseDir); } break; case ExecutionMode.Exit: break; } }
static void Main(string[] args) { PerfTracker.StartupEvent("Entered main"); Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); // Required for code page 850 support in .NET Core PerfTracker.StartupEvent("Registered encodings"); Task.Run(() => new LogEvent(LogEvent.Level.Verbose, "Preheat Event Metadata").ToString()); var commandLine = new CommandLineOptions(args); if (commandLine.Mode == ExecutionMode.Exit) { return; } var baseDir = ConfigUtil.FindBasePath(); if (baseDir == null) { throw new InvalidOperationException("No base directory could be found."); } PerfTracker.StartupEvent($"Found base directory {baseDir}"); var setupAssetSystem = Task.Run(() => SetupAssetSystem(baseDir)); PerfTracker.StartupEvent("Creating engine"); using var engine = commandLine.NeedsEngine ? new VeldridEngine(commandLine.Backend, commandLine.UseRenderDoc) .AddRenderer(new SkyboxRenderer()) .AddRenderer(new SpriteRenderer()) .AddRenderer(new ExtrudedTileMapRenderer()) .AddRenderer(new InfoOverlayRenderer()) .AddRenderer(new DebugGuiRenderer()) : null; engine?.ChangeBackend(); // PerfTracker.StartupEvent("Running asset tests..."); // AssetTest(assets); // PerfTracker.StartupEvent("Asset tests done"); PerfTracker.StartupEvent($"Running as {commandLine.Mode}"); var(exchange, services) = setupAssetSystem.Result; // Auto-detect language var assets = exchange.Resolve <IAssetManager>(); if (!assets.IsStringDefined((TextId)Base.SystemText.MainMenu_MainMenu)) { foreach (var language in Enum.GetValues(typeof(GameLanguage)).Cast <GameLanguage>()) { exchange.Raise(new SetLanguageEvent(language), null); if (assets.IsStringDefined((TextId)Base.SystemText.MainMenu_MainMenu)) { break; } } } switch (commandLine.Mode) { case ExecutionMode.Game: case ExecutionMode.GameWithSlavedAudio: Albion.RunGame(engine, exchange, services, baseDir, commandLine); break; case ExecutionMode.AudioSlave: exchange.Attach(new AudioManager(true)); break; case ExecutionMode.Editor: break; // TODO case ExecutionMode.SavedGameTests: SavedGameTests.RoundTripTest(baseDir); break; case ExecutionMode.DumpData: PerfTracker.BeginFrame(); // Don't need to show verbose startup logging while dumping var tf = new TextFormatter(); exchange.Attach(tf); AssetId[] dumpIds = null; if (commandLine.DumpIds != null) { dumpIds = commandLine.DumpIds.Select(AssetId.Parse).ToArray(); } if ((commandLine.DumpFormats & DumpFormats.Json) != 0) { DumpJson.Dump(baseDir, assets, commandLine.DumpAssetTypes, dumpIds); } if ((commandLine.DumpFormats & DumpFormats.Text) != 0) { DumpText.Dump(assets, baseDir, tf, commandLine.DumpAssetTypes, dumpIds); } if ((commandLine.DumpFormats & DumpFormats.GraphicsMask) != 0) { DumpGraphics.Dump(assets, baseDir, commandLine.DumpAssetTypes, commandLine.DumpFormats & DumpFormats.GraphicsMask, dumpIds); } if ((commandLine.DumpFormats & DumpFormats.Tiled) != 0) { DumpTiled.Dump(baseDir, assets, commandLine.DumpAssetTypes, dumpIds); } break; case ExecutionMode.Exit: break; } Console.WriteLine("Exiting"); }