Client LuaCsForBarotrauma
LuaCsSettingsMenu.cs
1 using Microsoft.Xna.Framework;
2 
3 namespace Barotrauma
4 {
5  static class LuaCsSettingsMenu
6  {
7  private static GUIFrame frame;
8 
9  public static void Open(RectTransform rectTransform)
10  {
11  Close();
12 
13  frame = new GUIFrame(new RectTransform(new Vector2(0.4f, 0.6f), rectTransform, Anchor.Center));
14 
15  GUIListBox list = new GUIListBox(new RectTransform(new Vector2(0.95f, 0.95f), frame.RectTransform, Anchor.Center), false);
16 
17  new GUITextBlock(new RectTransform(new Vector2(1f, 0.1f), list.Content.RectTransform), "LuaCs Settings", textAlignment: Alignment.Center);
18 
19 
20  new GUITickBox(new RectTransform(new Vector2(0.8f, 0.1f), list.Content.RectTransform), "Enable CSharp Scripting")
21  {
22  Selected = GameMain.LuaCs.Config.EnableCsScripting,
23  ToolTip = "This enables CSharp Scripting for mods to use, WARNING: CSharp is NOT sandboxed, be careful with what mods you download.",
24  OnSelected = (GUITickBox tick) =>
25  {
26  GameMain.LuaCs.Config.EnableCsScripting = tick.Selected;
27  GameMain.LuaCs.WriteSettings();
28 
29  return true;
30  }
31  };
32 
33  new GUITickBox(new RectTransform(new Vector2(0.8f, 0.1f), list.Content.RectTransform), "Treat Forced Mods As Normal")
34  {
35  Selected = GameMain.LuaCs.Config.TreatForcedModsAsNormal,
36  ToolTip = "This makes mods that were setup to run even when disabled to only run when enabled.",
37  OnSelected = (GUITickBox tick) =>
38  {
39  GameMain.LuaCs.Config.TreatForcedModsAsNormal = tick.Selected;
40  GameMain.LuaCs.WriteSettings();
41 
42  return true;
43  }
44  };
45 
46  new GUITickBox(new RectTransform(new Vector2(0.8f, 0.1f), list.Content.RectTransform), "Prefer To Use Workshop Lua Setup")
47  {
48  Selected = GameMain.LuaCs.Config.PreferToUseWorkshopLuaSetup,
49  ToolTip = "This makes Lua look first for the Lua/LuaSetup.lua located in the Workshop package instead of the one located locally.",
50  OnSelected = (GUITickBox tick) =>
51  {
52  GameMain.LuaCs.Config.PreferToUseWorkshopLuaSetup = tick.Selected;
53  GameMain.LuaCs.WriteSettings();
54 
55  return true;
56  }
57  };
58 
59  new GUITickBox(new RectTransform(new Vector2(0.8f, 0.1f), list.Content.RectTransform), "Disable Error GUI Overlay")
60  {
61  Selected = GameMain.LuaCs.Config.DisableErrorGUIOverlay,
62  ToolTip = "",
63  OnSelected = (GUITickBox tick) =>
64  {
65  GameMain.LuaCs.Config.DisableErrorGUIOverlay = tick.Selected;
66  GameMain.LuaCs.WriteSettings();
67 
68  return true;
69  }
70  };
71 
72  new GUITickBox(new RectTransform(new Vector2(0.8f, 0.1f), list.Content.RectTransform), "Hide usernames In Error Logs")
73  {
74  Selected = GameMain.LuaCs.Config.HideUserNames,
75  ToolTip = "Hides the operating system username when displaying error logs (eg your username on windows).",
76  OnSelected = (GUITickBox tick) =>
77  {
78  GameMain.LuaCs.Config.HideUserNames = tick.Selected;
79  GameMain.LuaCs.WriteSettings();
80 
81  return true;
82  }
83  };
84 
85  new GUIButton(new RectTransform(new Vector2(1f, 0.1f), list.Content.RectTransform), $"Remove Client-Side LuaCs", style: "GUIButtonSmall")
86  {
87  ToolTip = "Remove Client-Side LuaCs.",
88  OnClicked = (tb, userdata) =>
89  {
90  LuaCsInstaller.Uninstall();
91  return true;
92  }
93  };
94 
95  new GUIButton(new RectTransform(new Vector2(0.8f, 0.01f), frame.RectTransform, Anchor.BottomCenter)
96  {
97  RelativeOffset = new Vector2(0f, 0.05f)
98  }, "Close")
99  {
100  OnClicked = (GUIButton button, object obj) =>
101  {
102  Close();
103 
104  return true;
105  }
106  };
107  }
108 
109  public static void Close()
110  {
111  frame?.Parent.RemoveChild(frame);
112  frame = null;
113  }
114  }
115 }