private static void Main(string[] args) { // Override working directory Environment.CurrentDirectory = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); DualityApp.Init(DualityApp.ExecutionContext.Game, new DefaultAssemblyLoader(), args); ScreenMode newScreenMode; switch (Preferences.Get <int>("Screen", 0)) { default: case 0: newScreenMode = ScreenMode.Window; break; case 1: newScreenMode = ScreenMode.FullWindow; break; } using (INativeWindow window = DualityApp.OpenWindow(new WindowOptions { Title = AssemblyTitle, RefreshMode = (args.Contains("/nv") ? RefreshMode.NoSync : (args.Contains("/mv") ? RefreshMode.ManualSync : RefreshMode.VSync)), Size = LevelRenderSetup.TargetSize, ScreenMode = newScreenMode })) { current = new App(window); current.ShowMainMenu(); window.Run(); } DualityApp.Terminate(); // ToDo: Linux-specific workaround Environment.Exit(0); }
public static async void Main() { DualityApp.Init(DualityApp.ExecutionContext.Game, null, null); // Download all needed files bool assetsLoaded = await DownloadFilesToCache(new[] { "Content/Main.dz", "Content/i18n/en.res", "Content/Tilesets/labrat1n.set", "Content/Tilesets/psych2.set", "Content/Tilesets/diam2.set", "Content/Episodes/share/01_share1.level", "Content/Episodes/share/02_share2.level", "Content/Episodes/share/03_share3.level", "Content/Episodes/share/Episode.res", "Content/Episodes/share/Logo.png" }); if (!assetsLoaded) { using (var app = (JSObject)Runtime.GetGlobalObject("App")) { app.Invoke("loadingFailed"); } return; } i18n.Language = Preferences.Get <string>("Language", "en"); ContentResolver.Current.Init(); INativeWindow window = DualityApp.OpenWindow(new WindowOptions { Title = AssemblyTitle, RefreshMode = RefreshMode.VSync, Size = LevelRenderSetup.TargetSize, ScreenMode = ScreenMode.Window }); ContentResolver.Current.InitPostWindow(); current = new App(window); current.ShowMainMenu(false); using (var app = (JSObject)Runtime.GetGlobalObject("App")) { app.Invoke("ready"); } window.Run(); }
private static void Main(string[] args) { // Override working directory Environment.CurrentDirectory = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); DualityApp.Init(DualityApp.ExecutionContext.Game, new DefaultAssemblyLoader(), args); using (INativeWindow window = DualityApp.OpenWindow(new WindowOptions { Title = AssemblyTitle, RefreshMode = (args.Contains("/nv") ? RefreshMode.NoSync : (args.Contains("/mv") ? RefreshMode.ManualSync : RefreshMode.VSync)), Size = LevelRenderSetup.TargetSize })) { controller = new Controller(window); controller.ShowMainMenu(); window.Run(); } DualityApp.Terminate(); // ToDo: Linux-specific workaround Environment.Exit(0); }
public static void Main(string[] args) { System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture; System.Threading.Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.InvariantCulture; bool isDebugging = System.Diagnostics.Debugger.IsAttached || args.Contains(DualityApp.CmdArgDebug); bool isRunFromEditor = args.Contains(DualityApp.CmdArgEditor); bool isProfiling = args.Contains(DualityApp.CmdArgProfiling); if (isDebugging || isRunFromEditor) { ShowConsole(); } // Set up console logging Log.AddGlobalOutput(new ConsoleLogOutput()); // Set up file logging StreamWriter logfileWriter = null; TextWriterLogOutput logfileOutput = null; try { logfileWriter = new StreamWriter("logfile.txt"); logfileWriter.AutoFlush = true; logfileOutput = new TextWriterLogOutput(logfileWriter); Log.AddGlobalOutput(logfileOutput); } catch (Exception e) { Log.Core.WriteWarning("Text Logfile unavailable: {0}", Log.Exception(e)); } // Set up a global exception handler to log errors AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; // Write initial log message before actually booting Duality Log.Core.Write("Running DualityLauncher with flags: {1}{0}", Environment.NewLine, new[] { isDebugging ? "Debugging" : null, isProfiling ? "Profiling" : null, isRunFromEditor ? "RunFromEditor" : null }.NotNull().ToString(", ")); // Initialize the Duality core DualityApp.Init( DualityApp.ExecutionEnvironment.Launcher, DualityApp.ExecutionContext.Game, new DefaultPluginLoader(), args); // Open up a new window WindowOptions options = new WindowOptions { Width = DualityApp.UserData.GfxWidth, Height = DualityApp.UserData.GfxHeight, ScreenMode = isDebugging ? ScreenMode.Window : DualityApp.UserData.GfxMode, RefreshMode = (isDebugging || isProfiling) ? RefreshMode.NoSync : DualityApp.UserData.RefreshMode, Title = DualityApp.AppData.AppName, SystemCursorVisible = isDebugging || DualityApp.UserData.SystemCursorVisible }; using (INativeWindow window = DualityApp.OpenWindow(options)) { // Load the starting Scene Scene.SwitchTo(DualityApp.AppData.StartScene); // Enter the applications update / render loop window.Run(); } // Shut down the Duality core DualityApp.Terminate(); // Clean up the log file if (logfileWriter != null) { Log.RemoveGlobalOutput(logfileOutput); logfileWriter.Flush(); logfileWriter.Close(); logfileWriter = null; logfileOutput = null; } }
private static void Main(string[] args) { // Override working directory try { Environment.CurrentDirectory = AssemblyPath; } catch (Exception ex) { Console.WriteLine("Cannot override current directory: " + ex); } DualityApp.Init(DualityApp.ExecutionContext.Game, new DefaultAssemblyLoader(), args); ScreenMode screenMode; switch (Preferences.Get <int>("Screen", 0)) { default: case 0: screenMode = ScreenMode.Window; break; case 1: screenMode = ScreenMode.FullWindow; break; } RefreshMode refreshMode = (RefreshMode)Preferences.Get <int>("RefreshMode", (int)RefreshMode.VSync); i18n.Language = Preferences.Get <string>("Language", "en"); ContentResolver.Current.Init(); using (INativeWindow window = DualityApp.OpenWindow(new WindowOptions { Title = AssemblyTitle, RefreshMode = refreshMode, Size = LevelRenderSetup.TargetSize, ScreenMode = screenMode })) { ContentResolver.Current.InitPostWindow(); current = new App(window); bool suppressMainMenu = false; #if MULTIPLAYER for (int i = 0; i < args.Length; i++) { if (args[i].StartsWith("/connect:", StringComparison.InvariantCulture)) { int idx = args[i].LastIndexOf(':', 10); if (idx == -1) { continue; } int port; if (!int.TryParse(args[i].Substring(idx + 1), NumberStyles.Any, CultureInfo.InvariantCulture, out port)) { continue; } try { System.Net.IPAddress ip = Lidgren.Network.NetUtility.Resolve(args[i].Substring(9, idx - 9)); current.ConnectToServer(new System.Net.IPEndPoint(ip, port)); suppressMainMenu = true; } catch { // Nothing to do... } } } #endif if (!suppressMainMenu) { current.PlayCinematics("intro", endOfStream => { current.ShowMainMenu(endOfStream); }); } window.Run(); } DualityApp.Terminate(); // ToDo: Linux-specific workaround Environment.Exit(0); }