Пример #1
0
 private static void InitiateQuickstart()
 {
     if (!quickstartPending)
     {
         return;
     }
     quickstartPending = false;
     statusBox         = null;
     try {
         if (Settings.OperationMode == QuickstartSettings.QuickstartMode.Disabled)
         {
             return;
         }
         CheckForErrorsAndWarnings();
         if (Settings.OperationMode == QuickstartSettings.QuickstartMode.GenerateMap)
         {
             if (GenCommandLine.CommandLineArgPassed("quicktest"))
             {
                 // vanilla QuickStarter will change the scene, only set up scenario and map size injection
                 PrepareMapGeneration();
             }
             else
             {
                 InitateMapGeneration();
             }
         }
         else if (Settings.OperationMode == QuickstartSettings.QuickstartMode.LoadMap)
         {
             InitateSaveLoading();
         }
     } catch (WarningException e) {
         HugsLibController.Logger.Error("Quickstart aborted: " + e.Message);
     }
 }
        public static void OnGUI()
        {
            // if (Event.current.type == EventType.KeyDown)
            // {

            if (restartkey.KeyDownEvent)
            {
                GenCommandLine.Restart();
            }

            try
            {
                if (key != null && key.KeyDownEvent)
                {
                    if (Find.WindowStack.WindowOfType <Dialog_Analyzer>() != null)
                    {
                        Find.WindowStack.RemoveWindowsOfType(typeof(Dialog_Analyzer));
                    }
                    else
                    {
                        Find.WindowStack.Add(new Dialog_Analyzer());
                    }
                }
            }
            catch (Exception e)
            {
                Log.Error(e.ToString());
            }
            // }
        }
Пример #3
0
        public static void OnGUI()
        {
            if (restartkey.KeyDownEvent)
            {
                GenCommandLine.Restart();
            }

            try
            {
                if (key != null && key.KeyDownEvent)
                {
                    if (Find.WindowStack.WindowOfType <Window_Analyzer>() != null)
                    {
                        Find.WindowStack.RemoveWindowsOfType(typeof(Window_Analyzer));
                    }
                    else
                    {
                        Find.WindowStack.Add(new Window_Analyzer());
                    }
                }
            }
            catch (Exception e)
            {
                ThreadSafeLogger.Error(e.ToString());
            }

            if (alertKey.KeyDownEvent)
            {
                H_AlertsReadoutUpdate.DisableAlerts = !H_AlertsReadoutUpdate.DisableAlerts;
            }
        }
 private static void SetupForQuickstart()
 {
     try {
         if (Settings.OperationMode == QuickstartSettings.QuickstartMode.Disabled)
         {
             return;
         }
         if (HugsLibUtility.ShiftIsHeld)
         {
             HugsLibController.Logger.Warning("Quickstart aborted: Shift key was held.");
             return;
         }
         CheckForErrorsAndWarnings();
         if (Settings.OperationMode == QuickstartSettings.QuickstartMode.GenerateMap)
         {
             if (GenCommandLine.CommandLineArgPassed("quicktest"))
             {
                 // vanilla QuickStarter will change the scene, only set up scenario and map size injection
                 PrepareMapGeneration();
             }
             else
             {
                 InitateMapGeneration();
             }
         }
         else if (Settings.OperationMode == QuickstartSettings.QuickstartMode.LoadMap)
         {
             InitateSaveLoading();
         }
     } catch (WarningException e) {
         HugsLibController.Logger.Error("Quickstart aborted: " + e.Message);
     }
 }
        public override bool                Initialize()
        {
            // Don't auto-gen help if "quicktest" or "nohelp" command line switches are used
            if (
                (!GenCommandLine.CommandLineArgPassed("quicktest")) &&
                (!GenCommandLine.CommandLineArgPassed("nohelp"))
                )
            {
                LongEventHandler.SetCurrentEventText("LibraryHelpGen".Translate());

                var stringBuilder = new StringBuilder();
                CCL_Log.CaptureBegin(stringBuilder);

                var startTime = DateTime.Now;

                if (!HelpBuilder.ResolveImpliedDefs())
                {
                    strReturn = "Unexpected error in HelpBuilder.ResolveImpliedDefs()";
                    State     = SubControllerState.InitializationError;
                    return(false);
                }

                var finishTime = DateTime.Now;
                var finalTime  = finishTime - startTime;

                CCL_Log.CaptureEnd(stringBuilder, string.Format("Completed in {0}", finalTime.ToString()));
                CCL_Log.Message(stringBuilder.ToString(), "Help System");

                LongEventHandler.SetCurrentEventText("Initializing".Translate());
            }
            strReturn = "Initialized";
            State     = SubControllerState.Hybernating;
            return(true);
        }
Пример #6
0
 private static void SetupForQuickstart()
 {
     try {
         if (Settings.OperationMode == QuickstartSettings.QuickstartMode.Disabled)
         {
             return;
         }
         if (HugsLibUtility.ShiftIsHeld)
         {
             HugsLibController.Logger.Warning("Quickstart aborted: Shift key was held.");
             return;
         }
         CheckForErrorsAndWarnings();
         if (Settings.OperationMode == QuickstartSettings.QuickstartMode.GenerateMap)
         {
             if (GenCommandLine.CommandLineArgPassed("quicktest"))
             {
                 // vanilla QuickStarter will change the scene, only set up scenario and map size injection
                 PrepareMapGeneration();
             }
             else
             {
                 InitateMapGeneration();
             }
         }
         else if (Settings.OperationMode == QuickstartSettings.QuickstartMode.LoadMap)
         {
             var saveName = Settings.SaveFileToLoad;
             if (saveName == null)
             {
                 throw new WarningException("save filename not set");
             }
             var filePath = GenFilePaths.FilePathForSavedGame(saveName);
             if (!File.Exists(filePath))
             {
                 throw new WarningException("save file not found: " + Settings.SaveFileToLoad);
             }
             HugsLibController.Logger.Message("Quickstarter is loading saved game: " + saveName);
             Action loadAction = () => {
                 LongEventHandler.QueueLongEvent(delegate {
                     Current.Game = new Game {
                         InitData = new GameInitData {
                             gameToLoad = saveName
                         }
                     };
                 }, "Play", "LoadingLongEvent", true, null);
             };
             if (Settings.BypassSafetyDialog)
             {
                 loadAction();
             }
             else
             {
                 PreLoadUtility.CheckVersionAndLoad(filePath, ScribeMetaHeaderUtility.ScribeHeaderMode.Map, loadAction);
             }
         }
     } catch (WarningException e) {
         HugsLibController.Logger.Error("Quickstart aborted: " + e.Message);
     }
 }
Пример #7
0
 public SaveLoader(ModContentPack mod) : base(mod)
 {
     if (GenCommandLine.TryGetCommandLineArg("save", out var saveName))
     {
         InitiateSaveLoading(saveName);
     }
 }
Пример #8
0
        /// <summary>
        /// Attempts to return the patch of the log file Unity is writing to.
        /// </summary>
        /// <returns></returns>
        public static string TryGetLogFilePath()
        {
            string logfile;

            if (GenCommandLine.TryGetCommandLineArg("logfile", out logfile) && logfile.NullOrEmpty())
            {
                return(logfile);
            }
            var platform = PlatformUtility.GetCurrentPlatform();

            switch (platform)
            {
            case PlatformType.Linux:
                return(@"/tmp/rimworld_log");

            case PlatformType.MacOSX:
                return(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "Library/Logs/Unity/Player.log"));

            case PlatformType.Windows:
                logfile = Path.Combine(UnityData.dataPath, "output_log.txt");
                if (File.Exists(logfile))
                {
                    return(logfile);
                }
                return(Environment.ExpandEnvironmentVariables("%LOCALAPPDATA%") + String.Format(@"Low\{0}\{1}\output_log.txt", Application.companyName, Application.productName));

            default:
                return(null);
            }
        }
Пример #9
0
        /// <summary>
        /// Attempts to return the patch of the log file Unity is writing to.
        /// </summary>
        /// <returns></returns>
        public static string TryGetLogFilePath()
        {
            string logfile;

            if (GenCommandLine.TryGetCommandLineArg("logfile", out logfile) && logfile.NullOrEmpty())
            {
                return(logfile);
            }
            var platform = PlatformUtility.GetCurrentPlatform();

            switch (platform)
            {
            case PlatformType.Linux:
                return(@"/tmp/rimworld_log");

            case PlatformType.MacOSX:
                return(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "Library/Logs/Unity/Player.log"));

            case PlatformType.Windows:
                return(Path.Combine(Application.persistentDataPath, "Player.log"));

            default:
                return(null);
            }
        }
Пример #10
0
 public static void OnGUI()
 {
     if (Event.current.type != EventType.KeyDown)
     {
         return;
     }
     if (HugsLibKeyBindings.PublishLogs.JustPressed && HugsLibUtility.ControlIsHeld)
     {
         if (HugsLibUtility.AltIsHeld)
         {
             HugsLibController.Instance.LogUploader.CopyToClipboard();
         }
         else
         {
             HugsLibController.Instance.LogUploader.ShowPublishPrompt();
         }
     }
     if (HugsLibKeyBindings.OpenLogFile.JustPressed)
     {
         ShellOpenLog.Execute();
     }
     if (HugsLibKeyBindings.RestartRimworld.JustPressed)
     {
         GenCommandLine.Restart();
     }
 }
Пример #11
0
        private static void HandleCommandLine()
        {
            if (GenCommandLine.TryGetCommandLineArg("connect", out string addressPort) && Multiplayer.restartConnect == null)
            {
                int port = MultiplayerServer.DefaultPort;

                var split = addressPort.Split(':');
                if (split.Length == 0)
                {
                    addressPort = "127.0.0.1";
                }
                else if (split.Length >= 1)
                {
                    addressPort = split[0];
                }

                if (split.Length == 2)
                {
                    int.TryParse(split[1], out port);
                }

                DoubleLongEvent(() => ClientUtil.TryConnectWithWindow(addressPort, port, false), "Connecting");
            }

            if (GenCommandLine.CommandLineArgPassed("arbiter"))
            {
                Multiplayer.username = "******";
                Prefs.VolumeGame     = 0;
            }

            if (GenCommandLine.TryGetCommandLineArg("replay", out string replay))
            {
                DoubleLongEvent(() =>
                {
                    Replay.LoadReplay(Replay.ReplayFile(replay), true, () =>
                    {
                        var rand = Find.Maps.Select(m => m.AsyncTime().randState).Select(s => $"{s} {(uint)s} {s >> 32}");

                        Log.Message($"timer {TickPatch.Timer}");
                        Log.Message($"world rand {Multiplayer.WorldComp.randState} {(uint)Multiplayer.WorldComp.randState} {Multiplayer.WorldComp.randState >> 32}");
                        Log.Message($"map rand {rand.ToStringSafeEnumerable()} | {Find.Maps.Select(m => m.AsyncTime().mapTicks).ToStringSafeEnumerable()}");

                        Application.Quit();
                    });
                }, "Replay");
            }

            if (GenCommandLine.CommandLineArgPassed("printsync"))
            {
                ExtendDirectXmlSaver.extend = true;
                DirectXmlSaver.SaveDataObject(new SyncContainer(), "SyncHandlers.xml");
                ExtendDirectXmlSaver.extend = false;
            }
        }
        public static void OnGUI()
        {
            // if (Event.current.type == EventType.KeyDown)
            // {

            if (restartkey.KeyDownEvent)
            {
                GenCommandLine.Restart();
            }
            // }
        }
Пример #13
0
 public override void WriteSettings()
 {
     Settings.UpdateCache();
     LoadedModManager.WriteModSettings(Content.PackageId, "RuntimeGC", Settings);
     if (Settings.RequiresRestart())
     {
         Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation("DlgTextRestartRequest".Translate(), delegate
         {
             GenCommandLine.Restart();
         }, false, "DlgTitleRestart".Translate()));
     }
 }
Пример #14
0
        public MultiplayerMod(ModContentPack pack) : base(pack)
        {
            if (GenCommandLine.CommandLineArgPassed("arbiter"))
            {
                arbiterInstance = true;
            }

            EarlyMarkNoInline(typeof(Multiplayer).Assembly);
            EarlyPatches();

            settings = GetSettings <MpSettings>();
        }
Пример #15
0
 public static bool ShowRestartDialogOutsideDevMode()
 {
     if (Prefs.DevMode)
     {
         if (!HugsLibUtility.ShiftIsHeld)
         {
             GenCommandLine.Restart();
         }
         return(false);
     }
     return(true);
 }
Пример #16
0
 private void ApplyHarmonyPatches()
 {
     try {
         if (ShouldHarmonyAutoPatch(typeof(HugsLibController).Assembly, ModIdentifier))
         {
             HarmonyInstance.DEBUG = GenCommandLine.CommandLineArgPassed(HarmonyDebugCommandLineArg);
             HarmonyInst           = HarmonyInstance.Create(HarmonyInstanceIdentifier);
             HarmonyInst.PatchAll(typeof(HugsLibController).Assembly);
         }
     } catch (Exception e) {
         Logger.ReportException(e);
     }
 }
Пример #17
0
        private void DrawAdvanced(Rect rect)
        {
            GUI.BeginGroup(rect);

            float curY = 0f;

            CheckBox("(Recommended) Activate Mip-Mapping", ref curY, ref mainSettings.useMipMap);
            Text.Anchor = TextAnchor.UpperCenter;
            if (mainSettings.useMipMap)
            {
                mainSettings.mipMapBias = LabeledSlider("MipMap Bias", ref curY, MipMapBiasRange, mainSettings.mipMapBias, "Sharpest", "Blurriest", "This value changes how blurry textures can get depending on zoom, it is recommended to be equal or below 0.", 0.05f);
            }
            curY += 10f;
            mainSettings.anisoLevel = (int)LabeledSlider("Anisotropic Filter Level", ref curY, anisoRange, (float)mainSettings.anisoLevel, "", "", "Set the level of anisotropic filtering, higher levels may reduce performance on older graphics cards.", 1);
            Text.Anchor             = 0;
            curY += 10f;
            SetFilter(ref curY);
            curY += 10;

            Rect resetButton = new Rect(0, curY, 120, 25);

            if (!mainSettings.IsDefault())
            {
                if (Widgets.ButtonText(resetButton, "Reset"))
                {
                    mainSettings.Reset();
                }
            }

            if (AnySettingsChanged())
            {
                GUI.color = Color.red;
                Text.Font = GameFont.Medium;
                string  text = "You will have to restart the game to apply changes!";
                Vector2 size = Text.CalcSize(text);
                float   x2   = (rect.width - size.x) / 2f;
                float   x3   = (rect.width - 150) / 2f;
                float   y2   = rect.yMax - 150;
                Widgets.Label(new Rect(x2, y2, size.x, size.y), text);
                if (Widgets.ButtonText(new Rect(x3, y2 + size.y, 150, 45), "Restart Game", true, true))
                {
                    this.Write();
                    GenCommandLine.Restart();
                }
                //...
                Text.Font = GameFont.Small;
                GUI.color = Color.white;
            }

            GUI.EndGroup();
        }
Пример #18
0
 public static void BypassOrShowDialog(Window originalDialog)
 {
     if (Prefs.DevMode)
     {
         if (!HugsLibUtility.ShiftIsHeld)
         {
             GenCommandLine.Restart();
         }
     }
     else
     {
         Find.WindowStack.Add(originalDialog);
     }
 }
        private static void StartArbiter()
        {
            Multiplayer.session.AddMsg("The Arbiter instance is starting...", false);

            Multiplayer.LocalServer.SetupArbiterConnection();

            string args = $"-batchmode -nographics -arbiter -logfile arbiter_log.txt -connect=127.0.0.1:{Multiplayer.LocalServer.ArbiterPort}";

            if (GenCommandLine.TryGetCommandLineArg("savedatafolder", out string saveDataFolder))
            {
                args += $" -savedatafolder=\"{saveDataFolder}\"";
            }

            string ArbiterInstancePath;

            switch (Application.platform)
            {
            case RuntimePlatform.OSXPlayer:
                ArbiterInstancePath = Application.dataPath + "/MacOS/" + Process.GetCurrentProcess().MainModule.ModuleName;
                break;

            /*                case RuntimePlatform.LinuxPlayer:
             *                  ArbiterInstancePath = "";
             *                  break;*/
            //case RuntimePlatform.WindowsPlayer:
            default:
                ArbiterInstancePath = Process.GetCurrentProcess().MainModule.FileName;
                break;
            }

            try
            {
                Multiplayer.session.arbiter = Process.Start(
                    ArbiterInstancePath,
                    args
                    );
            }
            catch (Exception ex)
            {
                Multiplayer.session.AddMsg("Arbiter failed to start.", false);
                Log.Error("Arbiter failed to start.", false);
                Log.Error(ex.ToString());
                if (ex.InnerException is Win32Exception)
                {
                    Log.Error("Win32 Error Code: " + ((Win32Exception)ex).NativeErrorCode.ToString());
                }
            }
        }
Пример #20
0
        public override void SettingsChanged()
        {
            kinsey        = toggleKinsey.Value;
            mode          = kinseyMode.Value;
            notBabyMode   = toggleIndividuality.Value;
            elections     = toggleElections.Value;
            convoDuration = conversationDuration.Value;
            dateLetters   = toggleDateLetters.Value;
            bool oldBenchmarkVal = benchmark;

            benchmark = toggleBenchmarking.Value;
            // The game has to be restarted for benchmarking to be applied/removed.
            if (oldBenchmarkVal != benchmark)
            {
                GenCommandLine.Restart();
            }
        }
Пример #21
0
        public static void OnGUI()
        {
            if (Event.current.type != EventType.KeyDown)
            {
                return;
            }
            var useEvent = false;

            if (HugsLibKeyBindings.PublishLogs.JustPressed && HugsLibUtility.ControlIsHeld)
            {
                if (HugsLibUtility.AltIsHeld)
                {
                    HugsLibController.Instance.LogUploader.CopyToClipboard();
                }
                else
                {
                    HugsLibController.Instance.LogUploader.ShowPublishPrompt();
                }
                useEvent = true;
            }
            if (HugsLibKeyBindings.OpenLogFile.JustPressed)
            {
                ShellOpenLog.Execute();
                useEvent = true;
            }
            if (HugsLibKeyBindings.RestartRimworld.JustPressed)
            {
                GenCommandLine.Restart();
                useEvent = true;
            }
            if (HugsLibKeyBindings.HLOpenModSettings.JustPressed)
            {
                HugsLibUtility.OpenModSettingsDialog();
                useEvent = true;
            }
            if (HugsLibKeyBindings.HLOpenUpdateNews.JustPressed)
            {
                HugsLibController.Instance.UpdateFeatures.TryShowDialog(true);
                useEvent = true;
            }
            if (useEvent)
            {
                Event.current.Use();
            }
        }
Пример #22
0
 public void RestoreToDefaultSettings()
 {
     FileInfo[] files = new DirectoryInfo(GenFilePaths.ConfigFolderPath).GetFiles("*.xml");
     foreach (FileInfo fileInfo in files)
     {
         try
         {
             fileInfo.Delete();
         }
         catch (SystemException)
         {
         }
     }
     Find.WindowStack.Add(new Dialog_MessageBox("ResetAndRestart".Translate(), null, delegate
     {
         GenCommandLine.Restart();
     }));
 }
Пример #23
0
 public static bool CheckQuickStart()
 {
     Log.Message("Checking Quick Start!!!");
     if (GenCommandLine.CommandLineArgPassed("quicktest") && !quickStarted && GenScene.InEntryScene)
     {
         string savefile;
         if (GenCommandLine.TryGetCommandLineArg("quicktest", out savefile))
         {
             Current.Game                    = new Game();
             Current.Game.InitData           = new GameInitData();
             Current.Game.InitData.mapToLoad = savefile;
         }
         quickStarted = true;
         SceneManager.LoadScene("Map");
         return(true);
     }
     return(false);
 }
Пример #24
0
        private static void StartArbiter()
        {
            Multiplayer.session.AddMsg("The Arbiter instance is starting...", false);

            Multiplayer.LocalServer.SetupArbiterConnection();

            string args = $"-batchmode -nographics -arbiter -logfile arbiter_log.txt -connect=127.0.0.1:{Multiplayer.LocalServer.ArbiterPort}";

            if (GenCommandLine.TryGetCommandLineArg("savedatafolder", out string saveDataFolder))
            {
                args += $" -savedatafolder=\"{saveDataFolder}\"";
            }

            Multiplayer.session.arbiter = Process.Start(
                Process.GetCurrentProcess().MainModule.FileName,
                args
                );
        }
Пример #25
0
        public MultiplayerMod(ModContentPack pack) : base(pack)
        {
            if (GenCommandLine.CommandLineArgPassed("arbiter"))
            {
                arbiterInstance = true;
            }

            //EarlyMarkNoInline(typeof(Multiplayer).Assembly);
            EarlyPatches();

            CheckInterfaceVersions();

            settings = GetSettings <MpSettings>();

            LongEventHandler.ExecuteWhenFinished(() => {
                // Double Execute ensures it'll run last.
                LongEventHandler.ExecuteWhenFinished(LatePatches);
            });
        }
Пример #26
0
        public MultiplayerMod(ModContentPack pack) : base(pack)
        {
            if (GenCommandLine.CommandLineArgPassed("arbiter"))
            {
                arbiterInstance = true;
            }

            EarlyMarkNoInline(typeof(Multiplayer).Assembly);
            EarlyPatches();

            CheckInterfaceVersions();

            settings = GetSettings <MpSettings>();

#if DEBUG
            LongEventHandler.ExecuteWhenFinished(() => {
                Log.Message("== Structure == \n" + Sync.syncWorkers.PrintStructure());
            });
#endif
        }
Пример #27
0
        public override void DoWindowContents(Rect rect)
        {
            spinner.OnDoWindowContents();
            Rect outRect = new Rect(0.0f, 0.0f, rect.width + 30f, rect.height);

            float pushY = 70f;

            // sync mods title
            DoTopBar(outRect, pushY);
            // place labels ontop of table
            PlaceTableLabels(outRect, pushY);

            Rect rect4           = new Rect(0f, 40f + pushY, outRect.width - 30f, outRect.height - 110f - 60f - pushY);
            Rect safeUpdatesRect = new Rect(15f + 28f, rect4.height + rect4.y + 15f, rect4.width - 100f, 80f);

            GUI.DrawTexture(new Rect(15f, rect4.height + rect4.y + 15f, 24f, 24f), Widgets.CheckboxOnTex);
            Widgets.Label(safeUpdatesRect, " - " + "ModSync.ModNotBreakingSave".Translate());
            Widgets.DrawMenuSection(rect4);

            // long scroller
            //float height = (float)(ModLister.AllInstalledMods.Count<ModMetaData>() * 34 *60+ 300);
            // real scroller

            float height = (float)(ModLister.AllInstalledMods.Count <ModMetaData>() * 34 + 300);

            DrawModsToSync(rect4, height, this.modsToSync);

            if (Widgets.ButtonText(new Rect((rect.xMax / 2) - 100, rect.yMax - 65f, 80f, 50f), "CloseButton".Translate(), true, false, true))
            {
                Find.WindowStack.TryRemove(this.GetType(), true);
            }
            if (Widgets.ButtonText(new Rect((rect.xMax / 2) + 100, rect.yMax - 65f, 80f, 50f), "Reset".Translate(), true, false, true))
            {
                GenCommandLine.Restart();
            }
            //AddBrandLogo(rect);

            // reset UI settings
            Text.Anchor = TextAnchor.UpperLeft;
            GUI.color   = Color.white;
        }
Пример #28
0
        public void RestoreToDefaultSettings()
        {
            DirectoryInfo directoryInfo = new DirectoryInfo(GenFilePaths.ConfigFolderPath);

            FileInfo[] files = directoryInfo.GetFiles("*.xml");
            for (int i = 0; i < files.Length; i++)
            {
                FileInfo fileInfo = files[i];
                try
                {
                    fileInfo.Delete();
                }
                catch (SystemException)
                {
                }
            }
            Find.WindowStack.Add(new Dialog_MessageBox("ResetAndRestart".Translate(), null, delegate
            {
                GenCommandLine.Restart();
            }, null, null, null, false, null, null));
        }
Пример #29
0
 public static void Draw()
 {
     if (Prefs.DevMode && AwesomeInventoryMod.Settings.ShowRestartButton)
     {
         Vector2 vector = new Vector2((float)UI.screenWidth * 0.5f - WidgetRow.IconSize, 3f);
         Find.WindowStack.ImmediateWindow(
             typeof(UnitTestButton).GetHashCode(),
             new Rect(vector.x, vector.y, WidgetRow.IconSize, WidgetRow.IconSize).Rounded(),
             WindowLayer.GameUI,
             () =>
         {
             WidgetRow row = new WidgetRow(WidgetRow.IconSize, 0, UIDirection.LeftThenDown);
             if (row.ButtonIcon(UnitTextIcon, "Restart Rimworld"))
             {
                 GenCommandLine.Restart();
             }
         },
             doBackground: false,
             absorbInputAroundWindow: false, 0f);
     }
 }
        public static void OnGUI()
        {
            try
            {
                if (restartkey.KeyDownEvent)
                {
                    GenCommandLine.Restart();
                }

                if (key != null && key.KeyDownEvent)
                {
                    if (Find.WindowStack.WindowOfType <Window_Analyzer>() != null)
                    {
                        Find.WindowStack.RemoveWindowsOfType(typeof(Window_Analyzer));
                    }
                    else
                    {
                        Find.WindowStack.Add(new Window_Analyzer());
                    }
                }

                if (alertKey.KeyDownEvent)
                {
                    H_AlertsReadoutUpdate.DisableAlerts = !H_AlertsReadoutUpdate.DisableAlerts;
                }
            }
            catch (Exception e)
            {
                if ((attemptedInitialise is false) && AttemptToInitialiseKeys())
                {
                    return;
                }

                if (Settings.verboseLogging)
                {
                    ThreadSafeLogger.ReportException(e, "Error while handling analyzer keybindings");
                }
            }
        }