public void apply() { var flag = false; if (windowed != getIfWindowed()) { Game1.GetSingleton().graphics.ToggleFullScreen(); Settings.windowed = getIfWindowed(); flag = true; } if (resolutionChanged) { var strArray = resolutions[currentResIndex].Split(xArray); var num1 = Convert.ToInt32(strArray[0]); var num2 = Convert.ToInt32(strArray[1]); Game1.GetSingleton().graphics.PreferredBackBufferWidth = num1; Game1.GetSingleton().graphics.PreferredBackBufferHeight = num2; } GuiData.ActivateFontConfig(fontConfigs[currentFontIndex]); if (resolutionChanged || flag) { Game1.GetSingleton().graphics.ApplyChanges(); Game1.GetSingleton().SetNewGraphics(); } else { ExitScreen(); } SettingsLoader.writeStatusFile(); }
public override void HandleInput(InputState input) { base.HandleInput(input); GuiData.doInput(input); if (!Settings.debugCommandsEnabled || !Utils.keyPressed(input, Keys.F8, new PlayerIndex?())) { return; } ExitScreen(); Game1.GetSingleton().Exit(); }
public static void writeStatusFile() { var graphicsDevice = Game1.GetSingleton().GraphicsDevice; Utils.writeToFile( string.Concat( string.Concat( (graphicsDevice.PresentationParameters.BackBufferWidth.ToString() + "\r\n" + graphicsDevice.PresentationParameters.BackBufferHeight + "\r\n" + (Game1.GetSingleton().graphics.IsFullScreen ? "true" : "false") + "\r\n" + "bloom: " + (PostProcessor.bloomEnabled ? "true" : "false") + "\r\n" + "scanlines: " + (PostProcessor.scanlinesEnabled ? "true" : "false") + "\r\n" + "muted: " + (MusicManager.isMuted ? "true" : "false") + "\r\n"), "volume: ", MusicManager.getVolume(), "\r\n") + "fontConfig: " + GuiData.ActiveFontConfig.name + "\r\n", "hasSaved: ", hasEverSaved, "\r\n"), "Settings.txt"); }
private void drawDemoModeButtons(bool canRun) { if (Button.doButton(1, 180, 200, 450, 50, "New Session", buttonColor)) { if (canRun) { try { ExitScreen(); resetOS(); ScreenManager.playAlertSound(); ScreenManager.AddScreen(new OS(), ScreenManager.controllingPlayer); } catch (Exception ex) { Utils.writeToFile("OS Load Error: " + ex + "\n\n" + ex.StackTrace, "crashLog.txt"); } } } if (Button.doButton(11, 180, 265, 450, 50, "Load Session", canLoad ? buttonColor : Color.Black)) { if (canLoad) { try { if (canRun) { ExitScreen(); resetOS(); OS.WillLoadSave = true; ScreenManager.AddScreen(new OS(), ScreenManager.controllingPlayer); } } catch (Exception ex) { Utils.writeToFile("OS Load Error: " + ex + "\n\n" + ex.StackTrace, "crashLog.txt"); } } } if (!Button.doButton(15, 180, 330, 450, 28, "Exit", exitButtonColor)) { return; } MusicManager.stop(); Game1.threadsExiting = true; Game1.GetSingleton().Exit(); }
public static void SendErrorEmail(Exception ex, string postfix = "", string extraData = "") { var body = string.Concat( GenerateReportFromException(ex) + "\r\n White:" + white + "\r\n WhiteDisposed:" + white.IsDisposed + "\r\n SmallFont:" + GuiData.smallfont + "\r\n TinyFont:" + GuiData.tinyfont + "\r\n LineEffectTarget:" + FlickeringTextEffect.GetReportString() + "\r\n PostProcessort stuff:" + PostProcessor.GetStatusReportString(), "\r\nRESOLUTION:\r\n ", Game1.GetSingleton().GraphicsDevice.PresentationParameters.BackBufferWidth, "x") + Game1.GetSingleton().GraphicsDevice.PresentationParameters.BackBufferHeight + "\r\nFullscreen: " + (Game1.GetSingleton().graphics.IsFullScreen ? "true" : "false") + "\r\n Adapter: " + Game1.GetSingleton().GraphicsDevice.Adapter.Description + "\r\n Device Name: " + Game1.GetSingleton().GraphicsDevice.GraphicsDeviceStatus + "\r\n Extra:\r\n" + extraData + "\r\n"; SendRealWorldEmail( "Hackent " + postfix + MainMenu.OSVersion + " Crash " + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString(), "*****@*****.**", body); }
private void drawMainMenuButtons(bool canRun) { var num1 = 135; int num2; if (Button.doButton(1, 180, num2 = num1 + 65, 450, 50, "New Session", buttonColor) && canRun) { State = MainMenuState.NewUser; loginScreen.ResetForNewAccount(); } int num3; if ( Button.doButton(1102, 180, num3 = num2 + 65, 450, 28, canLoad ? "Continue with account [" + SaveFileManager.LastLoggedInUser.Username + "]" : "No Accounts", canLoad ? buttonColor : Color.Black) && canLoad) { loginScreen.LoadGameForUserFileAndUsername(SaveFileManager.LastLoggedInUser.FileUsername, SaveFileManager.LastLoggedInUser.Username); } int num4; if (Button.doButton(11, 180, num4 = num3 + 39, 450, 50, "Login", canLoad ? buttonColor : Color.Black)) { if (canLoad) { try { State = MainMenuState.Login; loginScreen.ResetForLogin(); } catch (Exception ex) { Utils.writeToFile("OS Load Error: " + ex + "\n\n" + ex.StackTrace, "crashLog.txt"); } } } int num5; if (Button.doButton(3, 180, num5 = num4 + 65, 450, 50, "Settings", buttonColor)) { ScreenManager.AddScreen(new OptionsMenu(), ScreenManager.controllingPlayer); } int num6; var y = num6 = num5 + 65; if (Settings.isServerMode) { if (Button.doButton(4, 180, y, 450, 50, "Start Relay Server", buttonColor)) { ScreenManager.AddScreen(new ServerScreen(), ScreenManager.controllingPlayer); } y += 65; } if (Settings.AllowAdventureMode) { if (Button.doButton(5, 180, y, 450, 50, "Adventure Session", buttonColor)) { ExitScreen(); resetOS(); Settings.IsInAdventureMode = true; if (!Settings.soundDisabled) { ScreenManager.playAlertSound(); } ScreenManager.AddScreen(new OS(), ScreenManager.controllingPlayer); } y += 65; } if (Button.doButton(15, 180, y, 450, 28, "Exit", exitButtonColor)) { MusicManager.stop(); Game1.threadsExiting = true; Game1.GetSingleton().Exit(); } var num7 = y + 30; if (!PlatformAPISettings.RemoteStorageRunning) { TextItem.doFontLabel(new Vector2(180f, num7), "WARNING: Error connecting to Steam Cloud", GuiData.smallfont, Color.DarkRed, float.MaxValue, float.MaxValue); num7 += 20; } if (string.IsNullOrWhiteSpace(AccumErrors)) { return; } TextItem.doFontLabel(new Vector2(180f, num7), AccumErrors, GuiData.smallfont, Color.DarkRed, float.MaxValue, float.MaxValue); var num8 = num7 + 20; }
private void drawTestingMainMenuButtons(bool canRun) { if (Button.doButton(8801, 634, 200, 225, 23, "New Test Session", buttonColor) && canRun) { ExitScreen(); resetOS(); if (!Settings.soundDisabled) { ScreenManager.playAlertSound(); } var os = new OS(); ScreenManager.AddScreen(os, ScreenManager.controllingPlayer); os.delayer.RunAllDelayedActions(); os.threadedSaveExecute(); ScreenManager.RemoveScreen(os); OS.WillLoadSave = true; resetOS(); ScreenManager.AddScreen(new OS(), ScreenManager.controllingPlayer); } if (Button.doButton(8803, 634, 225, 225, 23, "New Entropy Accelerated Session", buttonColor) && canRun) { ExitScreen(); resetOS(); if (!Settings.soundDisabled) { ScreenManager.playAlertSound(); } var os1 = new OS(); os1.SaveGameUserName = "******"; os1.SaveUserAccountName = "entropyTest"; ScreenManager.AddScreen(os1, ScreenManager.controllingPlayer); os1.Flags.AddFlag("TutorialComplete"); os1.delayer.RunAllDelayedActions(); os1.threadedSaveExecute(); ScreenManager.RemoveScreen(os1); OS.WillLoadSave = true; resetOS(); Settings.initShowsTutorial = false; var os2 = new OS(); ScreenManager.AddScreen(os2, ScreenManager.controllingPlayer); MissionFunctions.runCommand(0, "EntropyFastFowardSetup"); os2.delayer.Post(ActionDelayer.Wait(1.0), () => Game1.GetSingleton().IsMouseVisible = true); } if (Button.doButton(8806, 634, 250, 225, 23, "Run Test Suite", buttonColor)) { testSuiteResult = TestSuite.TestSaveLoadOnFile(ScreenManager); } if (Button.doButton(8809, 634, 275, 225, 23, "Export Animation", buttonColor)) { var TitleFill = new Rectangle(0, 0, 300, 100); AnimatedSpriteExporter.ExportAnimation("OutNowAnim", "OutNow", TitleFill.Width, TitleFill.Height, 24f, 40f, GuiData.spriteBatch.GraphicsDevice, t => new OS { highlightColor = new Color(166, byte.MaxValue, 215) }.timer += t, (sb, dest) => { sb.Draw(Utils.white, dest, new Color(13, 13, 13)); FlickeringTextEffect.DrawFlickeringText(TitleFill, "OUT NOW", 8f, 0.7f, titleFont, null, new Color(216, 216, 216)); }, 1); } if (Button.doButton(8812, 634, 300, 225, 23, "New CSEC Accel Session", buttonColor) && canRun) { ExitScreen(); resetOS(); if (!Settings.soundDisabled) { ScreenManager.playAlertSound(); } var os1 = new OS(); ScreenManager.AddScreen(os1, ScreenManager.controllingPlayer); os1.Flags.AddFlag("TutorialComplete"); os1.delayer.RunAllDelayedActions(); os1.threadedSaveExecute(); ScreenManager.RemoveScreen(os1); OS.WillLoadSave = true; resetOS(); Settings.initShowsTutorial = false; var os2 = new OS(); ScreenManager.AddScreen(os2, ScreenManager.controllingPlayer); MissionFunctions.runCommand(0, "CSECFastFowardSetup"); os2.delayer.Post(ActionDelayer.Wait(1.0), () => Game1.GetSingleton().IsMouseVisible = true); } if (testSuiteResult == null) { return; } TextItem.doFontLabel(new Vector2(635f, 325f), Utils.SuperSmartTwimForWidth(testSuiteResult, 600, GuiData.tinyfont), GuiData.tinyfont, testSuiteResult.Length > 250 ? Utils.AddativeRed : Utils.AddativeWhite, float.MaxValue, float.MaxValue); }
public override void Draw(GameTime gameTime) { base.Draw(gameTime); try { PostProcessor.begin(); ScreenManager.FadeBackBufferToBlack(byte.MaxValue); GuiData.startDraw(); var dest1 = new Rectangle(0, 0, ScreenManager.GraphicsDevice.Viewport.Width, ScreenManager.GraphicsDevice.Viewport.Height); var destinationRectangle = new Rectangle(-20, -20, ScreenManager.GraphicsDevice.Viewport.Width + 40, ScreenManager.GraphicsDevice.Viewport.Height + 40); var dest2 = new Rectangle(dest1.X + dest1.Width / 4, dest1.Height / 4, dest1.Width / 2, dest1.Height / 4); GuiData.spriteBatch.Draw(Utils.white, destinationRectangle, Color.Black); hexBackground.Draw(dest1, GuiData.spriteBatch, Color.Transparent, Settings.lighterColorHexBackground ? new Color(20, 20, 20) : new Color(10, 10, 10, 0), HexGridBackground.ColoringAlgorithm.NegaitiveSinWash, 0.0f); TextItem.DrawShadow = false; switch (State) { case MainMenuState.NewUser: DrawLoginScreen(dest2, true); break; case MainMenuState.Login: DrawLoginScreen(dest2, false); break; default: if (Settings.isLockedDemoMode) { attractModeScreen.Draw(dest1, GuiData.spriteBatch); break; } FlickeringTextEffect.DrawLinedFlickeringText(new Rectangle(180, 120, 340, 100), "HACKNET", 7f, 0.55f, titleFont, null, titleColor, 2); TextItem.doFontLabel(new Vector2(520f, 178f), "OS " + OSVersion, GuiData.smallfont, titleColor * 0.5f, 600f, 26f); var canRun = true; if (Settings.IsExpireLocked) { var timeSpan = Settings.ExpireTime - DateTime.Now; string text; if (timeSpan.TotalSeconds < 1.0) { text = "TEST BUILD EXPIRED - EXECUTION DISABLED"; canRun = false; } else { text = "Test Build : Expires in " + timeSpan; } TextItem.doFontLabel(new Vector2(180f, 105f), text, GuiData.smallfont, Color.Red * 0.8f, 600f, 26f); } if (Settings.isLockedDemoMode) { drawDemoModeButtons(canRun); break; } drawMainMenuButtons(canRun); if (Settings.testingMenuItemsEnabled) { drawTestingMainMenuButtons(canRun); } break; } GuiData.endDraw(); PostProcessor.end(); ScreenManager.FadeBackBufferToBlack(byte.MaxValue - TransitionAlpha); } catch (ObjectDisposedException ex) { if (hasSentErrorEmail) { throw ex; } var body = string.Concat( Utils.GenerateReportFromException(ex) + "\r\n Font:" + titleFont + "\r\n White:" + Utils.white + "\r\n WhiteDisposed:" + Utils.white.IsDisposed + "\r\n SmallFont:" + GuiData.smallfont + "\r\n TinyFont:" + GuiData.tinyfont + "\r\n LineEffectTarget:" + FlickeringTextEffect.GetReportString() + "\r\n PostProcessort stuff:" + PostProcessor.GetStatusReportString(), "\r\nRESOLUTION:\r\n ", Game1.GetSingleton().GraphicsDevice.PresentationParameters.BackBufferWidth, "x") + Game1.GetSingleton().GraphicsDevice.PresentationParameters.BackBufferHeight + "\r\nFullscreen: " + (Game1.GetSingleton().graphics.IsFullScreen ? "true" : "false") + "\r\n Adapter: " + Game1.GetSingleton().GraphicsDevice.Adapter.Description + "\r\n Device Name: " + Game1.GetSingleton().GraphicsDevice.GraphicsDeviceStatus; Utils.SendRealWorldEmail( "Hackent " + OSVersion + " Crash " + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString(), "*****@*****.**", body); hasSentErrorEmail = true; SettingsLoader.writeStatusFile(); } }
public bool getIfWindowed() { return(Game1.GetSingleton().graphics.IsFullScreen); }