From 8190b3f31280a9077a399ccc8f8524f7af9ccab2 Mon Sep 17 00:00:00 2001 From: Maplewheels Date: Sun, 8 Mar 2026 22:07:56 -0400 Subject: [PATCH] Fixed cs enabled prompt for hosts. --- .../ClientSource/LuaCs/LuaCsSetup.cs | 35 +++++++++++++------ 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/Barotrauma/BarotraumaClient/ClientSource/LuaCs/LuaCsSetup.cs b/Barotrauma/BarotraumaClient/ClientSource/LuaCs/LuaCsSetup.cs index 4dcd33bc7..83e158ff0 100644 --- a/Barotrauma/BarotraumaClient/ClientSource/LuaCs/LuaCsSetup.cs +++ b/Barotrauma/BarotraumaClient/ClientSource/LuaCs/LuaCsSetup.cs @@ -38,23 +38,37 @@ namespace Barotrauma sb.AppendLine($"- {cp.Name} (Not On Workshop)"); } - if (GameMain.Client == null || GameMain.Client.IsServerOwner) - { - DisplayCsModsPromptServer(sb); - } - else if (!_isClientPromptActive) + if (!_isClientPromptActive) { _isClientPromptActive = true; - DisplayCsModsPromptClient(sb); + if (GameMain.Client == null || GameMain.Client.IsServerOwner) + { + DisplayCsModsPromptServer(sb); + } + else + { + DisplayCsModsPromptClient(sb); + } } - + return false; void DisplayCsModsPromptServer(StringBuilder sb) { - new GUIMessageBox("", $"You have CSharp mods enabled but don't have the CSharp Scripting enabled, those mods might not work, go to the Main Menu, click on LuaCs Settings and check Enable CSharp Scripting.\n\n{sb}"); + var msg = new GUIMessageBox("", $"You have CSharp mods enabled but don't have the CSharp Scripting enabled, " + + $"those mods might not work, go to the Main Menu, click on LuaCs Settings and check Enable CSharp Scripting.\n\n{sb}"); + foreach (var button in msg.Buttons) + { + var old = button.OnClicked; + button.OnClicked = (btn, obj) => + { + var ret = old?.Invoke(btn, obj); + _isClientPromptActive = false; + return ret ?? true; + }; + } } void DisplayCsModsPromptClient(StringBuilder sb) @@ -67,13 +81,12 @@ namespace Barotrauma msg.Buttons[0].OnClicked = (GUIButton button, object obj) => { try - { - this.IsCsEnabled = true; + { this._isClientPromptActive = false; - CoroutineManager.Invoke(() => { SetRunState(RunState.LoadedNoExec); + this.IsCsEnabled = true; SetRunState(RunState.Running); }, 0f); return true;