public static void DoWindowContents(Rect rect, Listing_Standard optionsListing) { if (optionsListing.ButtonTextLabeled("Chat Connection Setup", "Setup")) { ToolkitSettings.FirstTimeInstallation = true; Window_Install window = new Window_Install(); Find.WindowStack.TryRemove(window.GetType()); Find.WindowStack.Add(window); } optionsListing.Gap(); optionsListing.CheckboxLabeled("Auto Reconnection Tool", ref Reconnecter.autoReconnect, "Always on by Default"); optionsListing.Gap(24); optionsListing.Label("<b>Warning</b>: Setting interval to less than 45 seconds may be unnecessarily reconnecting. Too low of a value can crash your game."); optionsListing.Gap(); optionsListing.SliderLabeled("Check Connection Every X Seconds", ref Reconnecter.reconnectInterval, Reconnecter.reconnectInterval.ToString(), 45, 300); optionsListing.GapLine(); optionsListing.Gap(); optionsListing.CheckboxLabeled("Should whispers be responded to in separate chat room?", ref ToolkitSettings.WhispersGoToChatRoom); optionsListing.CheckboxLabeled(Helper.ReplacePlaceholder("TwitchToolkitWhisperAllowed".Translate(), first: ToolkitSettings.Username), ref ToolkitSettings.WhisperCmdsAllowed); optionsListing.CheckboxLabeled(Helper.ReplacePlaceholder("TwitchToolkitWhisperOnly".Translate(), first: ToolkitSettings.Username), ref ToolkitSettings.WhisperCmdsOnly); }
public Reconnecter(Game game) { if (ToolkitSettings.FirstTimeInstallation) { Window_Install window = new Window_Install(); Find.WindowStack.TryRemove(window.GetType()); Find.WindowStack.Add(window); } }
public override void GameComponentTick() { if (!Helper.ModActive) { return; } if (!openedInstall && ToolkitSettings.FirstTimeInstallation) { openedInstall = true; Window_Install window = new Window_Install(); Find.WindowStack.TryRemove(window.GetType()); Find.WindowStack.Add(window); } if (!autoReconnect || Find.TickManager.TicksGame % reconnectTime != 0) { return; } reconnectTime = 2500; if (ToolkitSettings.AutoConnect && Toolkit.client == null) { ToolkitIRC.Reset(); } else if (Toolkit.client != null && !Toolkit.client.Connected) { Helper.Log("Disconnect detected, attempting reconnect"); ToolkitIRC.Reset(); } else if (Ticker.LastIRCPong != 0 && TimeHelper.SecondsElapsed(DateTime.FromFileTime(Ticker.LastIRCPong)) > reconnectInterval) { Helper.Log($"Has been over {reconnectInterval} seconds since last message from server, reconnecting"); ToolkitIRC.Reset(); } }