Closed Captions / Subtitles for Vintage Story.
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Give it a SHOT, palboy.

+1955 -21
.DS_Store

This is a binary file and will not be displayed.

+41 -9
ClosedCaptions/CaptionsSystem.cs
··· 26 26 27 27 Caption.Initialize(_api); 28 28 29 - if (!Config.Enabled) return; 30 - 29 + // Initial load of overlay 30 + if (Config.Enabled) 31 + { 32 + _dialog = new CaptionsDialog(_api); 33 + _dialog.TryOpen(); 34 + } 35 + 36 + // Register Hotkey for Settings 37 + _api.Input.RegisterHotKey("captionssettings", "Open Captions Settings", GlKeys.C, HotkeyType.GUIOrOtherControls, ctrlPressed: true, shiftPressed: false, altPressed: false); 38 + _api.Input.SetHotKeyHandler("captionssettings", OnToggleSettings); 39 + 31 40 _api.Event.IsPlayerReady += (ref EnumHandling _) => 32 41 { 33 - Reload(); 42 + // Maybe ensure dialog is open if enabled 43 + if (Config.Enabled && (_dialog == null || !_dialog.IsOpened())) 44 + { 45 + Reload(); 46 + } 34 47 return true; 35 48 }; 36 49 } 50 + 51 + private static bool OnToggleSettings(KeyCombination comb) 52 + { 53 + if (_settings != null && _settings.IsOpened()) 54 + { 55 + _settings.TryClose(); 56 + _settings = null; // Dispose reference 57 + } 58 + else 59 + { 60 + _settings = new SettingsDialog(_api); 61 + _settings.TryOpen(); 62 + } 63 + return true; 64 + } 37 65 38 66 private static void LoadConfig() 39 67 { ··· 54 82 55 83 public static void Reload() 56 84 { 85 + // Reloads the Captions Overlay (and Config) 86 + // Does NOT auto-open SettingsDialog 87 + 57 88 _dialog?.TryClose(); 58 - _settings?.TryClose(); 89 + 59 90 LoadConfig(); 60 - if (!Config.Enabled) return; 61 - _dialog = new CaptionsDialog(_api); 62 - _dialog.TryOpen(); 63 - _settings = new SettingsDialog(_api); 64 - _settings.TryOpen(); 91 + 92 + if (Config.Enabled) 93 + { 94 + _dialog = new CaptionsDialog(_api); 95 + _dialog.TryOpen(); 96 + } 65 97 } 66 98 }
+327 -12
ClosedCaptions/SettingsDialog.cs
··· 1 + using System; 2 + using System.Collections.Generic; 1 3 using Vintagestory.API.Client; 4 + using Vintagestory.API.Common; 5 + using Vintagestory.API.Config; 2 6 3 7 namespace ClosedCaptions; 4 8 5 - public class SettingsDialog : HudElement 9 + public class SettingsDialog : GuiDialog 6 10 { 7 - private CaptionsConfig Cfg => CaptionsSystem.Config; 11 + private CaptionsConfig Cfg => CaptionsSystem.Config; 12 + 13 + public override string ToggleKeyCombinationCode => "captionssettings"; 8 14 9 15 public SettingsDialog(ICoreClientAPI capi) : base(capi) 10 16 { 11 - ComposeGui(); 17 + SetupDialog(); 12 18 } 13 19 14 - public void ComposeGui() 20 + private ElementBounds containerBounds; 21 + 22 + private void InitializeDialog() 23 + { 24 + double insetWidth = 950.0; 25 + double insetHeight = 740.0; 26 + 27 + ElementBounds dialogBounds = ElementStdBounds.AutosizedMainDialog.WithAlignment(EnumDialogArea.CenterMiddle); 28 + ElementBounds insetBounds = ElementBounds.Fixed(0, GuiStyle.TitleBarHeight, insetWidth, insetHeight); 29 + ElementBounds scrollbarBounds = insetBounds.RightCopy().WithFixedWidth(20); 30 + 31 + ElementBounds clipBounds = insetBounds.ForkContainingChild(GuiStyle.HalfPadding, GuiStyle.HalfPadding, GuiStyle.HalfPadding, GuiStyle.HalfPadding); 32 + ElementBounds containerBounds = insetBounds.ForkContainingChild(GuiStyle.HalfPadding, GuiStyle.HalfPadding, GuiStyle.HalfPadding); 33 + 34 + ElementBounds bgBounds = ElementBounds.Fill 35 + .WithFixedPadding(GuiStyle.ElementToDialogPadding) 36 + .WithSizing(ElementSizing.FitToChildren) 37 + .WithChildren(insetBounds, scrollbarBounds); 38 + 39 + SingleComposer = capi.Gui.CreateCompo("captionsSettings", dialogBounds) 40 + .AddShadedDialogBG(bgBounds) 41 + .AddDialogTitleBar("Captions", OnTitleBarClose) 42 + .BeginChildElements() 43 + .AddInset(clipBounds, 3) 44 + .BeginClip(clipBounds) 45 + .AddContainer(containerBounds, "scroll-content") 46 + .EndClip() 47 + .AddVerticalScrollbar(OnNewScrollbarValue, scrollbarBounds, "scrollbar") 48 + .EndChildElements(); 49 + 50 + GuiElementContainer container = SingleComposer.GetContainer("scroll-content"); 51 + 52 + } 53 + 54 + private void SetupDialog() 15 55 { 56 + // 1. Layout Calculations 57 + double col1Width = 150; // Labels 58 + double col2Width = 200; // Controls 59 + double padding = GuiStyle.ElementToDialogPadding; 60 + double contentWidth = col1Width + col2Width; 61 + double visibleHeight = 500; // Fixed visible height for scrolling area 62 + 63 + // 2. Define Bounds 16 64 ElementBounds dialogBounds = ElementStdBounds.AutosizedMainDialog.WithAlignment(EnumDialogArea.CenterMiddle); 17 - ElementBounds textBounds = ElementBounds.Fixed(0, 0, 300, 600); 18 - ElementBounds bgBounds = ElementBounds.Fill.WithFixedPadding(GuiStyle.ElementToDialogPadding); 65 + 66 + ElementBounds bgBounds = ElementBounds.Fill.WithFixedPadding(padding); 19 67 bgBounds.BothSizing = ElementSizing.FitToChildren; 20 - bgBounds.WithChildren(textBounds); 21 68 69 + // Clip and Container Bounds 70 + // InsetBounds is the area "reserved" for the list in the dialog 71 + ElementBounds insetBounds = ElementBounds.Fixed(0, GuiStyle.TitleBarHeight, contentWidth + 20, visibleHeight); 72 + 73 + // Explicit ClipBounds 74 + ElementBounds clipBounds = insetBounds.ForkContainingChild(GuiStyle.HalfPadding, GuiStyle.HalfPadding, GuiStyle.HalfPadding, GuiStyle.HalfPadding); 75 + 76 + // ContainerBounds 77 + containerBounds = ElementBounds.Fixed(0, 0, contentWidth, 0); 78 + containerBounds.ParentBounds = clipBounds; 79 + 80 + // Scrollbar 81 + ElementBounds scrollbarBounds = insetBounds.RightCopy().WithFixedWidth(20).WithFixedPadding(0, 0); 82 + 83 + // Buttons Row (Fixed at bottom) 84 + ElementBounds buttonRow = insetBounds.BelowCopy(fixedDeltaY: 10).WithFixedHeight(30); 85 + 86 + // 3. Compose 22 87 SingleComposer = capi.Gui.CreateCompo("captionssettings", dialogBounds) 23 88 .AddShadedDialogBG(bgBounds) 24 - .AddDialogTitleBar("Captions Settings") 25 - .AddDynamicText("Hello, World!", CairoFont.WhiteDetailText(), textBounds, "Captions Settings") 26 - .Compose(); 89 + .AddDialogTitleBar("Captions Settings", OnTitleBarClose) 90 + .BeginChildElements(bgBounds) 91 + .AddInset(insetBounds, 3) 92 + .BeginClip(clipBounds) 93 + .AddContainer(containerBounds, "scroll-content") 94 + .EndClip() 95 + .AddVerticalScrollbar(OnNewScrollbarValue, scrollbarBounds, "scrollbar") 96 + .AddSmallButton("Cancel", OnCancel, buttonRow.FlatCopy().WithFixedWidth(80).WithAlignment(EnumDialogArea.LeftFixed)) 97 + .AddSmallButton("Save", OnSave, buttonRow.FlatCopy().WithFixedWidth(80).WithAlignment(EnumDialogArea.RightFixed)) 98 + .EndChildElements(); 99 + 100 + // 4. Populate Container 101 + GuiElementContainer container = SingleComposer.GetContainer("scroll-content"); 102 + double currentY = 0; 103 + 104 + // --- Options Section --- 105 + AddSectionHeader(container, "Options", ref currentY); 106 + AddSwitch(container, "Enabled", "enabled", Cfg.Enabled, ref currentY); 107 + AddSwitch(container, "Show Symbols", "showSymbols", Cfg.ShowSymbols, ref currentY); 108 + AddSwitch(container, "Invert Warnings", "invertedWarnings", Cfg.InvertedWarnings, ref currentY); 109 + AddSlider(container, "Duration", "duration", Cfg.Duration, 0, 10, ref currentY, true); 110 + AddNumberInput(container, "Max Captions", "maxCaptions", Cfg.MaxCaptions, ref currentY); 111 + 112 + // --- Colors Section --- 113 + AddSectionHeader(container, "Colors", ref currentY); 114 + AddSlider(container, "BG Opacity", "backgroundOpacity", (float)Cfg.BackgroundOpacity, 0, 1, ref currentY); 115 + AddSlider(container, "Text Opacity", "textOpacity", (float)Cfg.TextOpacity, 0, 1, ref currentY); 116 + // RGB For Warning 117 + AddRGBInput(container, "Warning Color", "warnR", "warnG", "warnB", Cfg.WarningRed, Cfg.WarningGreen, Cfg.WarningBlue, ref currentY); 118 + // RGB For Notice 119 + AddRGBInput(container, "Notice Color", "noticeR", "noticeG", "noticeB", Cfg.NoticeRed, Cfg.NoticeGreen, Cfg.NoticeBlue, ref currentY); 120 + 121 + // --- Typography Section --- 122 + AddSectionHeader(container, "Typography", ref currentY); 123 + AddTextInput(container, "Font", "font", Cfg.Font, ref currentY); 124 + AddNumberInput(container, "Size", "fontSize", (int)Cfg.FontSize, ref currentY); 125 + AddSwitch(container, "Bold", "fontBold", Cfg.FontBold, ref currentY); 126 + 127 + // --- Appearance Section --- 128 + AddSectionHeader(container, "Appearance", ref currentY); 129 + AddNumberInput(container, "Width", "width", Cfg.Width, ref currentY); 130 + AddNumberInput(container, "Height", "height", Cfg.Height, ref currentY); 131 + 132 + // Position Dropdown 133 + string[] names = Enum.GetNames(typeof(EnumDialogArea)); 134 + int index = Array.IndexOf(names, Cfg.Position.ToString()); 135 + 136 + AddLabel(container, "Position", ref currentY); // Label on left 137 + // Dropdown on right 138 + ElementBounds dropdownBounds = ElementBounds.Fixed(col1Width, currentY - 30, col2Width, 30).WithParent(containerBounds); 139 + var dd = new GuiElementDropDown(capi, names, names, index, (code, selected) => { }, dropdownBounds, CairoFont.WhiteDetailText(), false); 140 + _elements["position"] = dd; 141 + container.Add(dd); 142 + 143 + currentY += 35; 144 + 145 + AddNumberInput(container, "Padding", "padding", (int)Cfg.Padding, ref currentY); 146 + 147 + // Finish Composition 148 + SingleComposer.Compose(); 149 + 150 + // 5. Setup Scrollbar Heights 151 + // Calculate total height based on currentY 152 + SingleComposer.GetScrollbar("scrollbar").SetHeights((float)clipBounds.fixedHeight, (float)currentY); 153 + 154 + // Update container bounds to full height just in case 155 + containerBounds.fixedHeight = currentY; 156 + } 157 + 158 + private void OnNewScrollbarValue(float value) 159 + { 160 + containerBounds.fixedY = -value; 161 + containerBounds.CalcWorldBounds(); 162 + // Manually update children bounds to ensure they track the scroll 163 + GuiElementContainer container = SingleComposer.GetContainer("scroll-content"); 164 + foreach(var elem in container.Elements) { 165 + elem.Bounds.CalcWorldBounds(); 166 + } 167 + } 168 + 169 + // Helpers 170 + private void AddSectionHeader(GuiElementContainer container, string text, ref double y) 171 + { 172 + y += 15; 173 + ElementBounds headerBounds = ElementBounds.Fixed(0, y, 350, 25).WithParent(containerBounds); 174 + container.Add(new GuiElementStaticText(capi, text, EnumTextOrientation.Left, headerBounds, CairoFont.WhiteSmallText().WithWeight(Cairo.FontWeight.Bold))); 175 + y += 30; 176 + } 177 + 178 + private void AddSwitch(GuiElementContainer container, string label, string key, bool value, ref double y) 179 + { 180 + ElementBounds left = ElementBounds.Fixed(0, y, 150, 30).WithParent(containerBounds); 181 + ElementBounds right = ElementBounds.Fixed(150, y, 50, 30).WithParent(containerBounds); 182 + 183 + container.Add(new GuiElementStaticText(capi, label, EnumTextOrientation.Left, left, CairoFont.WhiteDetailText())); 184 + 185 + var sw = new GuiElementSwitch(capi, OnSwitchToggle, right); 186 + sw.On = value; 187 + _elements[key] = sw; 188 + container.Add(sw); 189 + 190 + y += 35; 191 + } 192 + 193 + private void OnSwitchToggle(bool on) { } 194 + 195 + private void AddSlider(GuiElementContainer container, string label, string key, float value, float min, float max, ref double y, bool displayValue = false) 196 + { 197 + ElementBounds left = ElementBounds.Fixed(0, y, 120, 30).WithParent(containerBounds); 198 + ElementBounds right = ElementBounds.Fixed(120, y, 180, 30).WithParent(containerBounds); 199 + 200 + container.Add(new GuiElementStaticText(capi, label, EnumTextOrientation.Left, left, CairoFont.WhiteDetailText())); 201 + 202 + var slider = new GuiElementSlider(capi, (val) => true, right); 203 + _elements[key] = slider; 204 + container.Add(slider); 205 + 206 + y += 35; 207 + } 208 + 209 + private void AddNumberInput(GuiElementContainer container, string label, string key, float value, ref double y) 210 + { 211 + ElementBounds left = ElementBounds.Fixed(0, y, 150, 30).WithParent(containerBounds); 212 + ElementBounds right = ElementBounds.Fixed(150, y, 100, 30).WithParent(containerBounds); 213 + 214 + container.Add(new GuiElementStaticText(capi, label, EnumTextOrientation.Left, left, CairoFont.WhiteDetailText())); 215 + 216 + var input = new GuiElementNumberInput(capi, right, null, CairoFont.WhiteDetailText()); 217 + input.SetValue(value); 218 + _elements[key] = input; 219 + container.Add(input); 220 + 221 + y += 35; 222 + } 223 + 224 + private void AddTextInput(GuiElementContainer container, string label, string key, string value, ref double y) 225 + { 226 + ElementBounds left = ElementBounds.Fixed(0, y, 100, 30).WithParent(containerBounds); 227 + ElementBounds right = ElementBounds.Fixed(100, y, 200, 30).WithParent(containerBounds); 228 + 229 + container.Add(new GuiElementStaticText(capi, label, EnumTextOrientation.Left, left, CairoFont.WhiteDetailText())); 230 + 231 + var input = new GuiElementTextInput(capi, right, null, CairoFont.WhiteDetailText()); 232 + input.SetValue(value); 233 + _elements[key] = input; 234 + container.Add(input); 235 + 236 + y += 35; 237 + } 238 + 239 + private void AddLabel(GuiElementContainer container, string label, ref double y) { 240 + ElementBounds left = ElementBounds.Fixed(0, y, 150, 30).WithParent(containerBounds); 241 + container.Add(new GuiElementStaticText(capi, label, EnumTextOrientation.Left, left, CairoFont.WhiteDetailText())); 242 + // Do NOT increment Y here, let caller handle it for multi-element rows 243 + } 244 + 245 + private void AddRGBInput(GuiElementContainer container, string label, string rKey, string gKey, string bKey, double r, double g, double b, ref double y) 246 + { 247 + AddLabel(container, label, ref y); 248 + 249 + ElementBounds rBounds = ElementBounds.Fixed(150, y, 50, 30).WithParent(containerBounds); 250 + ElementBounds gBounds = ElementBounds.Fixed(210, y, 50, 30).WithParent(containerBounds); 251 + ElementBounds bBounds = ElementBounds.Fixed(270, y, 50, 30).WithParent(containerBounds); 252 + 253 + var rIn = new GuiElementNumberInput(capi, rBounds, null, CairoFont.WhiteDetailText()); 254 + rIn.SetValue((float)r); 255 + _elements[rKey] = rIn; 256 + container.Add(rIn); 257 + 258 + var gIn = new GuiElementNumberInput(capi, gBounds, null, CairoFont.WhiteDetailText()); 259 + gIn.SetValue((float)g); 260 + _elements[gKey] = gIn; 261 + container.Add(gIn); 262 + 263 + var bIn = new GuiElementNumberInput(capi, bBounds, null, CairoFont.WhiteDetailText()); 264 + bIn.SetValue((float)b); 265 + _elements[bKey] = bIn; 266 + container.Add(bIn); 267 + 268 + y += 35; 27 269 } 28 270 29 - public override double DrawOrder => 0.1999; 30 - public override string ToggleKeyCombinationCode => "Captions Settings"; 271 + // Helper to get typed element 272 + private T Get<T>(string key) where T : GuiElement 273 + { 274 + if (_elements.TryGetValue(key, out var e) && e is T typed) return typed; 275 + return null; 276 + } 277 + 278 + private bool OnSave() 279 + { 280 + // Harvest values 281 + Cfg.Enabled = Get<GuiElementSwitch>("enabled").On; 282 + Cfg.ShowSymbols = Get<GuiElementSwitch>("showSymbols").On; 283 + Cfg.InvertedWarnings = Get<GuiElementSwitch>("invertedWarnings").On; 284 + 285 + // Sliders need normalization 286 + int durationVal = Get<GuiElementSlider>("duration").GetValue(); 287 + Cfg.Duration = (durationVal / 100f) * 10f; 288 + 289 + Cfg.MaxCaptions = (int)Get<GuiElementNumberInput>("maxCaptions").GetValue(); 290 + 291 + // Opacity 292 + Cfg.BackgroundOpacity = Get<GuiElementSlider>("backgroundOpacity").GetValue() / 100.0; 293 + Cfg.TextOpacity = Get<GuiElementSlider>("textOpacity").GetValue() / 100.0; 294 + 295 + // RGB 296 + Cfg.WarningRed = Get<GuiElementNumberInput>("warnR").GetValue(); 297 + Cfg.WarningGreen = Get<GuiElementNumberInput>("warnG").GetValue(); 298 + Cfg.WarningBlue = Get<GuiElementNumberInput>("warnB").GetValue(); 299 + 300 + Cfg.NoticeRed = Get<GuiElementNumberInput>("noticeR").GetValue(); 301 + Cfg.NoticeGreen = Get<GuiElementNumberInput>("noticeG").GetValue(); 302 + Cfg.NoticeBlue = Get<GuiElementNumberInput>("noticeB").GetValue(); 303 + 304 + // Font 305 + Cfg.Font = Get<GuiElementTextInput>("font").GetText(); 306 + Cfg.FontSize = Get<GuiElementNumberInput>("fontSize").GetValue(); 307 + Cfg.FontBold = Get<GuiElementSwitch>("fontBold").On; 308 + 309 + // Appearance 310 + Cfg.Width = (int)Get<GuiElementNumberInput>("width").GetValue(); 311 + Cfg.Height = (int)Get<GuiElementNumberInput>("height").GetValue(); 312 + Cfg.Padding = Get<GuiElementNumberInput>("padding").GetValue(); 313 + 314 + // Position Dropdown 315 + string pos = Get<GuiElementDropDown>("position").SelectedValue; 316 + if (Enum.TryParse(pos, out EnumDialogArea area)) 317 + { 318 + Cfg.Position = area; 319 + } 320 + 321 + // Save 322 + try { 323 + capi.StoreModConfig(Cfg, "captions.json"); 324 + CaptionsSystem.Reload(); 325 + } catch(Exception e) { 326 + capi.Logger.Error("Failed to save captions config: " + e); 327 + } 328 + 329 + TryClose(); 330 + return true; 331 + } 332 + 333 + private bool OnCancel() 334 + { 335 + TryClose(); 336 + return true; 337 + } 338 + 339 + public override void OnGuiOpened() { 340 + base.OnGuiOpened(); 341 + // Set slider values 342 + Get<GuiElementSlider>("duration")?.SetValues((int)((Cfg.Duration / 10.0) * 100), 0, 100, 1); 343 + Get<GuiElementSlider>("backgroundOpacity")?.SetValues((int)(Cfg.BackgroundOpacity * 100), 0, 100, 1); 344 + Get<GuiElementSlider>("textOpacity")?.SetValues((int)(Cfg.TextOpacity * 100), 0, 100, 1); 345 + } 31 346 32 347 private void OnTitleBarClose() 33 348 {
+1587
GuiCompositeSettings.cs
··· 1 + // Decompiled with JetBrains decompiler 2 + // Type: Vintagestory.Client.NoObf.GuiCompositeSettings 3 + // Assembly: VintagestoryLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null 4 + // MVID: 3C34B313-80E7-4F34-A3B7-98604168E042 5 + // Assembly location: /Applications/Vintage Story.app/VintagestoryLib.dll 6 + 7 + using Cairo; 8 + using OpenTK.Windowing.Common; 9 + using OpenTK.Windowing.GraphicsLibraryFramework; 10 + using System; 11 + using System.Collections.Generic; 12 + using System.Linq; 13 + using Vintagestory.API.Client; 14 + using Vintagestory.API.Common; 15 + using Vintagestory.API.Config; 16 + using Vintagestory.API.MathTools; 17 + using Vintagestory.API.Util; 18 + using Vintagestory.Client.Gui; 19 + 20 + #nullable disable 21 + namespace Vintagestory.Client.NoObf; 22 + 23 + public class GuiCompositeSettings : GuiComposite 24 + { 25 + private IGameSettingsHandler handler; 26 + private bool onMainscreen; 27 + private GuiComposer composer; 28 + private string startupLanguage = ClientSettings.Language; 29 + public bool IsInCreativeMode; 30 + private ElementBounds gButtonBounds = ElementBounds.Fixed(0.0, 0.0, 0.0, 40.0).WithFixedPadding(0.0, 3.0); 31 + private ElementBounds mButtonBounds = ElementBounds.Fixed(0.0, 0.0, 0.0, 40.0).WithFixedPadding(0.0, 3.0); 32 + private ElementBounds aButtonBounds = ElementBounds.Fixed(0.0, 0.0, 0.0, 40.0).WithFixedPadding(0.0, 3.0); 33 + private ElementBounds cButtonBounds = ElementBounds.Fixed(0.0, 0.0, 0.0, 40.0).WithFixedPadding(0.0, 3.0); 34 + private ElementBounds sButtonBounds = ElementBounds.Fixed(0.0, 0.0, 0.0, 40.0).WithFixedPadding(0.0, 3.0); 35 + private ElementBounds iButtonBounds = ElementBounds.Fixed(0.0, 0.0, 0.0, 40.0).WithFixedPadding(0.0, 3.0); 36 + private ElementBounds dButtonBounds = ElementBounds.Fixed(0.0, 0.0, 0.0, 40.0).WithFixedPadding(0.0, 3.0); 37 + private ElementBounds backButtonBounds = ElementBounds.Fixed(0.0, 0.0, 0.0, 40.0).WithFixedPadding(0.0, 3.0); 38 + private List<ConfigItem> mousecontrolItems = new List<ConfigItem>(); 39 + private bool mousecontrolsTabActive; 40 + private List<ConfigItem> keycontrolItems = new List<ConfigItem>(); 41 + private HotKey keyCombClone; 42 + private int? clickedItemIndex; 43 + private HotkeyCapturer hotkeyCapturer = new HotkeyCapturer(); 44 + public string currentSearchText; 45 + private Dictionary<HotkeyType, int> sortOrder = new Dictionary<HotkeyType, int>() 46 + { 47 + { 48 + HotkeyType.MovementControls, 49 + 0 50 + }, 51 + { 52 + HotkeyType.MouseModifiers, 53 + 1 54 + }, 55 + { 56 + HotkeyType.CharacterControls, 57 + 2 58 + }, 59 + { 60 + HotkeyType.HelpAndOverlays, 61 + 3 62 + }, 63 + { 64 + HotkeyType.GUIOrOtherControls, 65 + 4 66 + }, 67 + { 68 + HotkeyType.InventoryHotkeys, 69 + 5 70 + }, 71 + { 72 + HotkeyType.CreativeOrSpectatorTool, 73 + 6 74 + }, 75 + { 76 + HotkeyType.CreativeTool, 77 + 7 78 + }, 79 + { 80 + HotkeyType.DevTool, 81 + 8 82 + }, 83 + { 84 + HotkeyType.MouseControls, 85 + 9 86 + } 87 + }; 88 + private string[] titles = new string[9] 89 + { 90 + Lang.Get("Movement controls"), 91 + Lang.Get("Mouse click modifiers"), 92 + Lang.Get("Actions"), 93 + Lang.Get("In-game Help and Overlays"), 94 + Lang.Get("User interface & More"), 95 + Lang.Get("Inventory hotkeys"), 96 + Lang.Get("Creative mode"), 97 + Lang.Get("Creative mode"), 98 + Lang.Get("Debug and Macros") 99 + }; 100 + 101 + public bool IsCapturingHotKey => this.hotkeyCapturer.IsCapturing(); 102 + 103 + public GuiCompositeSettings(IGameSettingsHandler handler, bool onMainScreen) 104 + { 105 + this.handler = handler; 106 + this.onMainscreen = onMainScreen; 107 + } 108 + 109 + private GuiComposer ComposerHeader(string dialogName, string currentTab) 110 + { 111 + CairoFont font = CairoFont.ButtonText(); 112 + this.updateButtonBounds(); 113 + GuiComposer composer; 114 + if (this.onMainscreen) 115 + { 116 + int width = ScreenManager.Platform.WindowSize.Width; 117 + int height = ScreenManager.Platform.WindowSize.Height; 118 + ElementBounds bounds = ElementBounds.Fixed(0.0, 0.0, 950.0, 740.0); 119 + this.aButtonBounds.ParentBounds = bounds; 120 + this.gButtonBounds.ParentBounds = bounds; 121 + this.mButtonBounds.ParentBounds = bounds; 122 + this.cButtonBounds.ParentBounds = bounds; 123 + this.sButtonBounds.ParentBounds = bounds; 124 + this.iButtonBounds.ParentBounds = bounds; 125 + this.dButtonBounds.ParentBounds = bounds; 126 + composer = this.handler.dialogBase(dialogName + "main", bounds.fixedWidth, bounds.fixedHeight).BeginChildElements(bounds).AddToggleButton(Lang.Get("setting-graphics-header"), font, new Action<bool>(this.OnGraphicsOptions), this.gButtonBounds, "graphics").AddToggleButton(Lang.Get("setting-mouse-header"), font, new Action<bool>(this.OnMouseOptions), this.mButtonBounds, "mouse").AddToggleButton(Lang.Get("setting-controls-header"), font, new Action<bool>(this.OnControlOptions), this.cButtonBounds, "controls").AddToggleButton(Lang.Get("setting-accessibility-header"), font, new Action<bool>(this.OnAccessibilityOptions), this.aButtonBounds, "accessibility").AddToggleButton(Lang.Get("setting-sound-header"), font, new Action<bool>(this.OnSoundOptions), this.sButtonBounds, "sounds").AddToggleButton(Lang.Get("setting-interface-header"), font, new Action<bool>(this.OnInterfaceOptions), this.iButtonBounds, "interface").AddIf(ClientSettings.DeveloperMode).AddToggleButton(Lang.Get("setting-dev-header"), font, new Action<bool>(this.OnDeveloperOptions), this.dButtonBounds, "developer").EndIf(); 127 + } 128 + else 129 + { 130 + ElementBounds bounds1 = ElementStdBounds.AutosizedMainDialog.WithAlignment(EnumDialogArea.CenterFixed).WithFixedPosition(0.0, 75.0); 131 + double num = this.backButtonBounds.fixedX + this.backButtonBounds.fixedWidth + 35.0; 132 + bounds1.horizontalSizing = ElementSizing.Fixed; 133 + bounds1.fixedWidth = num; 134 + ElementBounds bounds2 = new ElementBounds().WithSizing(ElementSizing.FitToChildren).WithFixedPadding(GuiStyle.ElementToDialogPadding); 135 + bounds2.horizontalSizing = ElementSizing.Fixed; 136 + bounds2.fixedWidth = num - 2.0 * GuiStyle.ElementToDialogPadding; 137 + this.gButtonBounds.ParentBounds = bounds2; 138 + this.aButtonBounds.ParentBounds = bounds2; 139 + this.mButtonBounds.ParentBounds = bounds2; 140 + this.cButtonBounds.ParentBounds = bounds2; 141 + this.sButtonBounds.ParentBounds = bounds2; 142 + this.iButtonBounds.ParentBounds = bounds2; 143 + this.dButtonBounds.ParentBounds = bounds2; 144 + this.backButtonBounds.ParentBounds = bounds2; 145 + composer = this.handler.GuiComposers.Create(dialogName + "ingame", bounds1).AddShadedDialogBG(bounds2, false).AddStaticCustomDraw(bounds2, (DrawDelegateWithBounds) ((ctx, surface, bounds) => 146 + { 147 + ctx.SetSourceRGBA(1.0, 1.0, 1.0, 0.1); 148 + GuiElement.RoundRectangle(ctx, GuiElement.scaled(5.0) + bounds.bgDrawX, GuiElement.scaled(5.0) + bounds.bgDrawY, bounds.OuterWidth - GuiElement.scaled(10.0), GuiElement.scaled(75.0), 1.0); 149 + ctx.Fill(); 150 + })).BeginChildElements().AddToggleButton(Lang.Get("setting-graphics-header"), font, new Action<bool>(this.OnGraphicsOptions), this.gButtonBounds, "graphics").AddToggleButton(Lang.Get("setting-mouse-header"), font, new Action<bool>(this.OnMouseOptions), this.mButtonBounds, "mouse").AddToggleButton(Lang.Get("setting-controls-header"), font, new Action<bool>(this.OnControlOptions), this.cButtonBounds, "controls").AddToggleButton(Lang.Get("setting-accessibility-header"), font, new Action<bool>(this.OnAccessibilityOptions), this.aButtonBounds, "accessibility").AddToggleButton(Lang.Get("setting-sound-header"), font, new Action<bool>(this.OnSoundOptions), this.sButtonBounds, "sounds").AddToggleButton(Lang.Get("setting-interface-header"), font, new Action<bool>(this.OnInterfaceOptions), this.iButtonBounds, "interface").AddIf(ClientSettings.DeveloperMode).AddToggleButton(Lang.Get("setting-dev-header"), font, new Action<bool>(this.OnDeveloperOptions), this.dButtonBounds, "developer").EndIf().AddButton(Lang.Get("general-back"), (ActionConsumable) (() => 151 + { 152 + this.clickedItemIndex = new int?(); 153 + this.hotkeyCapturer?.EndCapture(true); 154 + return this.handler.OnBackPressed(); 155 + }), this.backButtonBounds); 156 + } 157 + composer.GetToggleButton("graphics").SetValue(currentTab == "graphics"); 158 + composer.GetToggleButton("mouse").SetValue(currentTab == "mouse"); 159 + composer.GetToggleButton("controls").SetValue(currentTab == "controls"); 160 + composer.GetToggleButton("accessibility").SetValue(currentTab == "accessibility"); 161 + composer.GetToggleButton("sounds").SetValue(currentTab == "sounds"); 162 + composer.GetToggleButton("interface").SetValue(currentTab == "interface"); 163 + composer.GetToggleButton("developer")?.SetValue(currentTab == "developer"); 164 + return composer; 165 + } 166 + 167 + private void updateButtonBounds() 168 + { 169 + CairoFont cairoFont = CairoFont.ButtonText(); 170 + double width1 = cairoFont.GetTextExtents(Lang.Get("setting-graphics-header")).Width / (double) ClientSettings.GUIScale + 15.0; 171 + double width2 = cairoFont.GetTextExtents(Lang.Get("setting-mouse-header")).Width / (double) ClientSettings.GUIScale + 15.0; 172 + double width3 = cairoFont.GetTextExtents(Lang.Get("setting-controls-header")).Width / (double) ClientSettings.GUIScale + 15.0; 173 + double width4 = cairoFont.GetTextExtents(Lang.Get("setting-accessibility-header")).Width / (double) ClientSettings.GUIScale + 15.0; 174 + double width5 = cairoFont.GetTextExtents(Lang.Get("setting-sound-header")).Width / (double) ClientSettings.GUIScale + 15.0; 175 + double width6 = cairoFont.GetTextExtents(Lang.Get("setting-interface-header")).Width / (double) ClientSettings.GUIScale + 15.0; 176 + double width7 = cairoFont.GetTextExtents(Lang.Get("setting-dev-header")).Width / (double) ClientSettings.GUIScale + 15.0; 177 + double width8 = cairoFont.GetTextExtents(Lang.Get("general-back")).Width / (double) ClientSettings.GUIScale + 15.0; 178 + this.gButtonBounds.WithFixedWidth(width1); 179 + this.mButtonBounds.WithFixedWidth(width2).FixedRightOf(this.gButtonBounds, 15.0); 180 + this.cButtonBounds.WithFixedWidth(width3).FixedRightOf(this.mButtonBounds, 15.0); 181 + this.aButtonBounds.WithFixedWidth(width4).FixedRightOf(this.cButtonBounds, 15.0); 182 + this.sButtonBounds.WithFixedWidth(width5).FixedRightOf(this.aButtonBounds, 15.0); 183 + this.iButtonBounds.WithFixedWidth(width6).FixedRightOf(this.sButtonBounds, 15.0); 184 + this.dButtonBounds.WithFixedWidth(width7).FixedRightOf(this.iButtonBounds, 15.0); 185 + this.backButtonBounds.WithFixedWidth(width8).FixedRightOf(ClientSettings.DeveloperMode ? this.dButtonBounds : this.iButtonBounds, 25.0); 186 + } 187 + 188 + internal bool OpenSettingsMenu() 189 + { 190 + this.OnGraphicsOptions(true); 191 + return true; 192 + } 193 + 194 + internal void Refresh() 195 + { 196 + if (!ClientSettings.DynamicColorGrading || this.composer == null) 197 + return; 198 + DefaultShaderUniforms shaderUniforms = ScreenManager.Platform.ShaderUniforms; 199 + if (shaderUniforms == null) 200 + return; 201 + this.composer.GetSlider("sepiaSlider")?.SetValue((int) ((double) shaderUniforms.SepiaLevel * 100.0)); 202 + this.composer.GetSlider("contrastSlider")?.SetValue((int) ((double) shaderUniforms.ExtraContrastLevel * 100.0) + 100); 203 + } 204 + 205 + internal void OnGraphicsOptions(bool on) 206 + { 207 + int num = 160 /*0xA0*/; 208 + ElementBounds elementBounds1 = ElementBounds.Fixed(0.0, 82.0, 225.0, 42.0); 209 + ElementBounds elementBounds2 = ElementBounds.Fixed(235.0, 85.0, (double) num, 20.0); 210 + ElementBounds elementBounds3 = ElementBounds.Fixed(470.0, 90.0, 225.0, 42.0); 211 + ElementBounds elementBounds4 = ElementBounds.Fixed(705.0, 119.0, (double) num, 20.0); 212 + ElementBounds.Fixed(0.0, 0.0, 30.0, 30.0).WithFixedPadding(10.0, 2.0); 213 + string[] strArray = new string[26] 214 + { 215 + !this.handler.MaxViewDistanceAlarmValue.HasValue ? Lang.Get("setting-hover-viewdist-singleplayer") : Lang.Get("setting-hover-viewdist"), 216 + Lang.Get("setting-hover-gamma"), 217 + Lang.Get("setting-hover-sepia"), 218 + Lang.Get("setting-hover-fov"), 219 + Lang.Get("setting-hover-guiscale"), 220 + Lang.Get("setting-hover-maxfps"), 221 + Lang.Get("setting-hover-resolution"), 222 + Lang.Get("setting-hover-smoothshadows"), 223 + Lang.Get("setting-hover-vsync"), 224 + Lang.Get("setting-hover-fxaa"), 225 + Lang.Get("setting-hover-bloom"), 226 + Lang.Get("setting-hover-abloom"), 227 + Lang.Get("setting-hover-godrays"), 228 + Lang.Get("setting-hover-particles"), 229 + Lang.Get("setting-hover-grasswaves"), 230 + Lang.Get("setting-hover-dynalight"), 231 + Lang.Get("setting-hover-dynashade"), 232 + Lang.Get("setting-hover-contrast"), 233 + Lang.Get("setting-hover-hqanimation"), 234 + Lang.Get("setting-hover-optimizeram"), 235 + Lang.Get("setting-hover-occlusionculling"), 236 + Lang.Get("setting-hover-foamandshinyeffect"), 237 + Lang.Get("setting-hover-ssao"), 238 + "setting-hover-radeonhdfix", 239 + Lang.Get("setting-hover-instancedgrass"), 240 + Lang.Get("setting-hover-chunkuploadratelimiter") 241 + }; 242 + string[] array1 = GraphicsPreset.Presets.Select<GraphicsPreset, string>((System.Func<GraphicsPreset, string>) (p => p.PresetId.ToString() ?? "")).ToArray<string>(); 243 + string[] array2 = GraphicsPreset.Presets.Select<GraphicsPreset, string>((System.Func<GraphicsPreset, string>) (p => Lang.Get(p.Langcode) ?? "")).ToArray<string>(); 244 + string displayText = ClientSettings.ShowMoreGfxOptions ? Lang.Get("general-lessoptions") : Lang.Get("general-moreoptions"); 245 + CairoFont font = CairoFont.WhiteSmallishText().Clone().WithWeight(FontWeight.Bold); 246 + font.Color[3] = 0.6; 247 + ElementBounds elementBounds5; 248 + ElementBounds elementBounds6; 249 + ElementBounds elementBounds7; 250 + ElementBounds elementBounds8; 251 + ElementBounds elementBounds9; 252 + ElementBounds elementBounds10; 253 + ElementBounds elementBounds11; 254 + ElementBounds elementBounds12; 255 + ElementBounds elementBounds13; 256 + ElementBounds elementBounds14; 257 + ElementBounds elementBounds15; 258 + ElementBounds elementBounds16; 259 + ElementBounds elementBounds17; 260 + ElementBounds elementBounds18; 261 + ElementBounds elementBounds19; 262 + ElementBounds elementBounds20; 263 + this.composer = this.ComposerHeader("gamesettings-graphics", "graphics").AddRichtext(new RichTextComponentBase[1] 264 + { 265 + (RichTextComponentBase) new LinkTextComponent(this.handler.Api, displayText, CairoFont.WhiteDetailText(), new Action<LinkTextComponent>(this.OnMoreOptions)) 266 + }, elementBounds5 = elementBounds3.FlatCopy()).AddStaticText(Lang.Get("setting-column-appear"), font, elementBounds6 = elementBounds5.BelowCopy(fixedDeltaY: 10.0).WithFixedWidth(250.0)).AddStaticText(Lang.Get("setting-name-gamma"), CairoFont.WhiteSmallishText(), elementBounds7 = elementBounds6.BelowCopy(fixedDeltaY: -4.0).WithFixedWidth(200.0)).AddSlider(new ActionConsumable<int>(this.onGammaChanged), elementBounds8 = elementBounds4.BelowCopy(fixedDeltaY: 45.0), "gammaSlider").AddHoverText(strArray[1], CairoFont.WhiteSmallText(), 250, elementBounds7.FlatCopy().WithFixedHeight(25.0)).AddStaticText(Lang.Get("setting-name-dynamiccolorgrading"), CairoFont.WhiteSmallishText(), elementBounds9 = elementBounds7.BelowCopy(fixedDeltaY: -8.0)).AddHoverText(Lang.Get("setting-hover-dynamiccolorgrading"), CairoFont.WhiteSmallText(), 250, elementBounds9.FlatCopy().WithFixedHeight(25.0)).AddSwitch(new Action<bool>(this.onDynamicGradingToggled), elementBounds10 = elementBounds8.BelowCopy(fixedDeltaY: 15.0), "dynamicColorGradingSwitch").AddStaticText(Lang.Get("setting-name-contrast"), CairoFont.WhiteSmallishText(), elementBounds11 = elementBounds9.BelowCopy(fixedDeltaY: 10.0)).AddSlider(new ActionConsumable<int>(this.onContrastChanged), elementBounds12 = elementBounds10.BelowCopy(fixedDeltaY: 21.0).WithFixedSize((double) num, 20.0), "contrastSlider").AddHoverText(strArray[17], CairoFont.WhiteSmallText(), 250, elementBounds11.FlatCopy().WithFixedHeight(25.0)).AddStaticText(Lang.Get("setting-name-sepia"), CairoFont.WhiteSmallishText(), elementBounds13 = elementBounds11.BelowCopy()).AddSlider(new ActionConsumable<int>(this.onSepiaLevelChanged), elementBounds14 = elementBounds12.BelowCopy(fixedDeltaY: 21.0), "sepiaSlider").AddHoverText(strArray[2], CairoFont.WhiteSmallText(), 250, elementBounds13.FlatCopy().WithFixedHeight(25.0)).AddStaticText(Lang.Get("setting-name-abloom"), CairoFont.WhiteSmallishText(), elementBounds15 = elementBounds13.BelowCopy()).AddSlider(new ActionConsumable<int>(this.onAmbientBloomChanged), elementBounds16 = elementBounds14.BelowCopy(fixedDeltaY: 21.0).WithFixedSize((double) num, 20.0), "ambientBloomSlider").AddHoverText(strArray[11], CairoFont.WhiteSmallText(), 250, elementBounds15.FlatCopy().WithFixedHeight(25.0)).AddStaticText(Lang.Get("setting-name-fov"), CairoFont.WhiteSmallishText(), elementBounds17 = elementBounds15.BelowCopy()).AddSlider(new ActionConsumable<int>(this.onVowChanged), elementBounds18 = elementBounds16.BelowCopy(fixedDeltaY: 21.0), "fovSlider").AddHoverText(strArray[3], CairoFont.WhiteSmallText(), 250, elementBounds17.FlatCopy().WithFixedHeight(25.0)).AddStaticText(Lang.Get("setting-name-windowmode"), CairoFont.WhiteSmallishText(), elementBounds19 = elementBounds17.BelowCopy(fixedDeltaY: -2.0)).AddDropDown(new string[4] 267 + { 268 + "0", 269 + "1", 270 + "2", 271 + "3" 272 + }, new string[4] 273 + { 274 + Lang.Get("windowmode-normal"), 275 + Lang.Get("windowmode-fullscreen"), 276 + Lang.Get("windowmode-maxborderless"), 277 + Lang.Get("windowmode-fullscreen-ontop") 278 + }, GuiCompositeSettings.GetWindowModeIndex(), new SelectionChangedDelegate(this.OnWindowModeChanged), elementBounds20 = elementBounds18.BelowCopy(fixedDeltaY: 18.0).WithFixedSize((double) num, 26.0), "windowModeSwitch"); 279 + if (ClientSettings.ShowMoreGfxOptions) 280 + { 281 + ElementBounds elementBounds21; 282 + ElementBounds elementBounds22; 283 + ElementBounds elementBounds23; 284 + ElementBounds elementBounds24; 285 + ElementBounds elementBounds25; 286 + ElementBounds elementBounds26; 287 + ElementBounds elementBounds27; 288 + ElementBounds elementBounds28; 289 + ElementBounds elementBounds29; 290 + ElementBounds elementBounds30; 291 + this.composer.AddStaticText(Lang.Get("setting-name-maxfps"), CairoFont.WhiteSmallishText(), elementBounds21 = elementBounds19.BelowCopy(fixedDeltaY: -3.0).WithFixedHeight(40.0)).AddSlider(new ActionConsumable<int>(this.onMaxFpsChanged), elementBounds22 = elementBounds20.BelowCopy(fixedDeltaY: 15.0).WithFixedSize((double) num, 20.0), "maxFpsSlider").AddHoverText(strArray[5], CairoFont.WhiteSmallText(), 250, elementBounds21.FlatCopy().WithFixedHeight(25.0)).AddStaticText(Lang.Get("setting-name-vsync"), CairoFont.WhiteSmallishText(), elementBounds23 = elementBounds21.BelowCopy(fixedDeltaY: 4.0)).AddHoverText(strArray[8], CairoFont.WhiteSmallText(), 250, elementBounds23.FlatCopy().WithFixedHeight(25.0)).AddDropDown(new string[3] 292 + { 293 + "0", 294 + "1", 295 + "2" 296 + }, new string[3] 297 + { 298 + Lang.Get("Off"), 299 + Lang.Get("On"), 300 + Lang.Get("On + Sleep") 301 + }, ClientSettings.VsyncMode, new SelectionChangedDelegate(this.onVsyncChanged), elementBounds24 = elementBounds22.BelowCopy(fixedDeltaY: 18.0).WithFixedSize((double) num, 26.0), "vsyncMode").AddStaticText(Lang.Get("setting-name-optimizeram"), CairoFont.WhiteSmallishText(), elementBounds25 = elementBounds23.BelowCopy(fixedDeltaY: 4.0)).AddHoverText(strArray[19], CairoFont.WhiteSmallText(), 250, elementBounds25.FlatCopy().WithFixedHeight(25.0)).AddDropDown(new string[2] 302 + { 303 + "1", 304 + "2" 305 + }, new string[2] 306 + { 307 + Lang.Get("Optimize somewhat"), 308 + Lang.Get("Aggressively optimize ram") 309 + }, ClientSettings.OptimizeRamMode - 1, new SelectionChangedDelegate(this.onOptimizeRamChanged), elementBounds26 = elementBounds24.BelowCopy(fixedDeltaY: 18.0).WithFixedSize((double) num, 26.0), "optimizeRamMode").AddStaticText(Lang.Get("setting-name-occlusionculling"), CairoFont.WhiteSmallishText(), elementBounds27 = elementBounds25.BelowCopy(fixedDeltaY: 3.0)).AddHoverText(strArray[20], CairoFont.WhiteSmallText(), 250, elementBounds27.FlatCopy().WithFixedHeight(25.0)).AddSwitch(new Action<bool>(this.onOcclusionCullingChanged), elementBounds28 = elementBounds26.BelowCopy(fixedDeltaY: 17.0), "occlusionCullingSwitch").AddStaticText(Lang.Get("setting-name-lodbiasfar"), CairoFont.WhiteSmallishText(), elementBounds29 = elementBounds27.BelowCopy(fixedDeltaY: 4.0)).AddHoverText(Lang.Get("setting-hover-lodbiasfar"), CairoFont.WhiteSmallText(), 250, elementBounds29.FlatCopy().WithFixedHeight(25.0)).AddSlider(new ActionConsumable<int>(this.onLodbiasFarChanged), elementBounds30 = elementBounds28.BelowCopy(fixedDeltaY: 21.0).WithFixedSize((double) num, 20.0), "lodbiasfarSlider").AddStaticText(Lang.Get("setting-name-windowborder"), CairoFont.WhiteSmallishText(), elementBounds29.BelowCopy(fixedDeltaY: 4.0)).AddDropDown(new string[3] 310 + { 311 + "0", 312 + "1", 313 + "2" 314 + }, new string[3] 315 + { 316 + Lang.Get("windowborder-resizable"), 317 + Lang.Get("windowborder-fixed"), 318 + Lang.Get("windowborder-hidden") 319 + }, (int) ScreenManager.Platform.WindowBorder, new SelectionChangedDelegate(this.OnWindowBorderChanged), elementBounds30.BelowCopy(fixedDeltaY: 18.0).WithFixedSize((double) num, 26.0), "windowBorder"); 320 + } 321 + ElementBounds elementBounds31; 322 + ElementBounds elementBounds32; 323 + ElementBounds elementBounds33; 324 + ElementBounds elementBounds34; 325 + ElementBounds elementBounds35; 326 + this.composer.AddStaticText(Lang.Get("setting-name-preset"), CairoFont.WhiteSmallishText(), elementBounds31 = elementBounds1.FlatCopy().WithFixedOffset(0.0, 5.0)).AddDropDown(array1, array2, ClientSettings.GraphicsPresetId, new SelectionChangedDelegate(this.onPresetChanged), elementBounds32 = elementBounds2.FlatCopy().WithFixedSize((double) num, 30.0), "graphicsPreset").AddStaticText(Lang.Get("setting-column-graphics"), font, elementBounds33 = elementBounds31.BelowCopy(fixedDeltaY: 15.0)).AddStaticText(Lang.Get("setting-name-viewdist"), CairoFont.WhiteSmallishText(), elementBounds34 = elementBounds33.BelowCopy(fixedDeltaY: -6.0)).AddSlider(new ActionConsumable<int>(this.onViewdistanceChanged), elementBounds35 = elementBounds32.BelowCopy(fixedDeltaY: 68.0).WithFixedSize((double) num, 20.0), "viewDistanceSlider").AddHoverText(strArray[0], CairoFont.WhiteSmallText(), 250, elementBounds34.FlatCopy().WithFixedHeight(25.0)); 327 + ElementBounds elementBounds36; 328 + if (ClientSettings.ShowMoreGfxOptions) 329 + { 330 + ElementBounds elementBounds37; 331 + ElementBounds elementBounds38; 332 + ElementBounds elementBounds39; 333 + ElementBounds elementBounds40; 334 + ElementBounds elementBounds41; 335 + ElementBounds elementBounds42; 336 + ElementBounds elementBounds43; 337 + ElementBounds elementBounds44; 338 + ElementBounds elementBounds45; 339 + ElementBounds elementBounds46; 340 + ElementBounds elementBounds47; 341 + ElementBounds elementBounds48; 342 + ElementBounds elementBounds49; 343 + ElementBounds elementBounds50; 344 + ElementBounds elementBounds51; 345 + ElementBounds elementBounds52; 346 + ElementBounds elementBounds53; 347 + ElementBounds elementBounds54; 348 + ElementBounds elementBounds55; 349 + ElementBounds elementBounds56; 350 + ElementBounds elementBounds57; 351 + ElementBounds elementBounds58; 352 + ElementBounds elementBounds59; 353 + this.composer.AddStaticText(Lang.Get("setting-name-smoothshadows"), CairoFont.WhiteSmallishText(), elementBounds37 = elementBounds34.BelowCopy()).AddHoverText(strArray[7], CairoFont.WhiteSmallText(), 250, elementBounds37.FlatCopy().WithFixedHeight(25.0)).AddSwitch(new Action<bool>(this.onSmoothShadowsToggled), elementBounds38 = elementBounds35.BelowCopy(fixedDeltaY: 15.0), "smoothShadowsLever").AddStaticText(Lang.Get("setting-name-fxaa"), CairoFont.WhiteSmallishText(), elementBounds39 = elementBounds37.BelowCopy()).AddHoverText(strArray[9], CairoFont.WhiteSmallText(), 250, elementBounds39.FlatCopy().WithFixedHeight(25.0)).AddSwitch(new Action<bool>(this.onFxaaChanged), elementBounds40 = elementBounds38.BelowCopy(fixedDeltaY: 12.0), "FxaaSwitch").AddStaticText(Lang.Get("setting-name-grasswaves"), CairoFont.WhiteSmallishText(), elementBounds41 = elementBounds39.BelowCopy()).AddHoverText(strArray[14], CairoFont.WhiteSmallText(), 250, elementBounds41.FlatCopy().WithFixedHeight(25.0)).AddSwitch(new Action<bool>(this.onWavingFoliageChanged), elementBounds42 = elementBounds40.BelowCopy(fixedDeltaY: 12.0), "wavingFoliageSwitch").AddStaticText(Lang.Get("setting-name-foamandshinyeffect"), CairoFont.WhiteSmallishText(), elementBounds43 = elementBounds41.BelowCopy()).AddHoverText(strArray[21], CairoFont.WhiteSmallText(), 250, elementBounds43.FlatCopy().WithFixedHeight(25.0)).AddSwitch(new Action<bool>(this.onFoamAndShinyEffectChanged), elementBounds44 = elementBounds42.BelowCopy(fixedDeltaY: 12.0), "liquidFoamEffectSwitch").AddStaticText(Lang.Get("setting-name-bloom"), CairoFont.WhiteSmallishText(), elementBounds45 = elementBounds43.BelowCopy()).AddHoverText(strArray[10], CairoFont.WhiteSmallText(), 250, elementBounds45.FlatCopy().WithFixedHeight(25.0)).AddSwitch(new Action<bool>(this.onBloomChanged), elementBounds46 = elementBounds44.BelowCopy(fixedDeltaY: 12.0), "BloomSwitch").AddStaticText(Lang.Get("setting-name-clouds"), CairoFont.WhiteSmallishText(), elementBounds47 = elementBounds45.BelowCopy().WithFixedHeight(39.0)).AddHoverText(Lang.Get("settings-hover-clouds"), CairoFont.WhiteSmallText(), 250, elementBounds47.FlatCopy().WithFixedHeight(25.0)).AddDropDown(new string[3] 354 + { 355 + "0", 356 + "1", 357 + "2" 358 + }, new string[3] 359 + { 360 + Lang.Get("settings-clouds-off"), 361 + Lang.Get("settings-clouds-volumetric"), 362 + Lang.Get("settings-clouds-classic") 363 + }, ClientSettings.CloudRenderMode, new SelectionChangedDelegate(this.onCloudsChanged), elementBounds48 = elementBounds46.BelowCopy(fixedDeltaY: 18.0).WithFixedSize((double) num, 26.0), "clouds").AddStaticText(Lang.Get("setting-name-godrays"), CairoFont.WhiteSmallishText(), elementBounds49 = elementBounds47.BelowCopy(fixedDeltaY: 3.0).WithFixedHeight(39.0)).AddSwitch(new Action<bool>(this.onGodRaysToggled), elementBounds50 = elementBounds48.BelowCopy(fixedDeltaY: 15.0).WithFixedSize((double) num, 20.0), "godraySwitch").AddHoverText(strArray[12], CairoFont.WhiteSmallText(), 250, elementBounds49.FlatCopy().WithFixedHeight(25.0)).AddStaticText(Lang.Get("setting-name-ssao"), CairoFont.WhiteSmallishText(), elementBounds51 = elementBounds49.BelowCopy(fixedDeltaY: 4.0).WithFixedHeight(36.0)).AddHoverText(strArray[22], CairoFont.WhiteSmallText(), 250, elementBounds51.FlatCopy().WithFixedHeight(25.0)).AddSlider(new ActionConsumable<int>(this.onSsaoChanged), elementBounds52 = elementBounds50.BelowCopy(fixedDeltaY: 17.0).WithFixedSize((double) num, 20.0), "ssaoSlider").AddStaticText(Lang.Get("setting-name-shadows"), CairoFont.WhiteSmallishText(), elementBounds53 = elementBounds51.BelowCopy(fixedDeltaY: 4.0)).AddSlider(new ActionConsumable<int>(this.onShadowsChanged), elementBounds54 = elementBounds52.BelowCopy(fixedDeltaY: 21.0).WithFixedSize((double) num, 20.0), "shadowsSlider").AddHoverText(strArray[16 /*0x10*/], CairoFont.WhiteSmallText(), 250, elementBounds53.FlatCopy().WithFixedHeight(25.0)).AddStaticText(Lang.Get("setting-name-particles"), CairoFont.WhiteSmallishText(), elementBounds55 = elementBounds53.BelowCopy(fixedDeltaY: 4.0)).AddSlider(new ActionConsumable<int>(this.onParticleLevelChanged), elementBounds56 = elementBounds54.BelowCopy(fixedDeltaY: 21.0).WithFixedSize((double) num, 20.0), "particleSlider").AddHoverText(strArray[13], CairoFont.WhiteSmallText(), 250, elementBounds55.FlatCopy().WithFixedHeight(25.0)).AddStaticText(Lang.Get("setting-name-dynalight"), CairoFont.WhiteSmallishText(), elementBounds57 = elementBounds55.BelowCopy(fixedDeltaY: 4.0)).AddSlider(new ActionConsumable<int>(this.onDynamicLightsChanged), elementBounds58 = elementBounds56.BelowCopy(fixedDeltaY: 21.0).WithFixedSize((double) num, 20.0), "dynamicLightsSlider").AddHoverText(strArray[15], CairoFont.WhiteSmallText(), 250, elementBounds57.FlatCopy().WithFixedHeight(25.0)).AddStaticText(Lang.Get("setting-name-resolution"), CairoFont.WhiteSmallishText(), elementBounds59 = elementBounds57.BelowCopy(fixedDeltaY: 4.0)).AddHoverText(strArray[6], CairoFont.WhiteSmallText(), 250, elementBounds59.FlatCopy().WithFixedHeight(25.0)).AddSlider(new ActionConsumable<int>(this.onResolutionChanged), elementBounds58.BelowCopy(fixedDeltaY: 21.0), "resolutionSlider").AddRichtext(Lang.Get("help-framerateissues"), CairoFont.WhiteDetailText(), elementBounds36 = elementBounds59.BelowCopy(fixedDeltaY: 5.0)).EndChildElements(); 364 + } 365 + else 366 + { 367 + ElementBounds elementBounds60; 368 + this.composer.AddRichtext(Lang.Get("help-moresettingsavailable", (object) displayText), CairoFont.WhiteDetailText(), elementBounds60 = elementBounds34.BelowCopy(fixedDeltaY: 225.0, fixedDeltaWidth: 440.0)).AddRichtext(Lang.Get("help-framerateissues"), CairoFont.WhiteDetailText(), elementBounds36 = elementBounds60.BelowCopy(fixedDeltaY: 125.0)); 369 + } 370 + this.composer.GetDropDown("graphicsPreset").listMenu.MaxHeight = 330; 371 + this.composer.Compose(); 372 + this.handler.LoadComposer(this.composer); 373 + this.SetGfxValues(); 374 + } 375 + 376 + private void onCloudsChanged(string newvalue, bool selected) 377 + { 378 + ClientSettings.CloudRenderMode = newvalue.ToInt(); 379 + } 380 + 381 + private void onDynamicGradingToggled(bool on) 382 + { 383 + ClientSettings.DynamicColorGrading = on; 384 + if (!on) 385 + { 386 + ScreenManager.Platform.ShaderUniforms.SepiaLevel = ClientSettings.SepiaLevel; 387 + ScreenManager.Platform.ShaderUniforms.ExtraContrastLevel = ClientSettings.ExtraContrastLevel; 388 + } 389 + this.composer.GetSlider("sepiaSlider").SetValue((int) ((double) ScreenManager.Platform.ShaderUniforms.SepiaLevel * 100.0)); 390 + this.composer.GetSlider("sepiaSlider").Enabled = !ClientSettings.DynamicColorGrading; 391 + this.composer.GetSlider("contrastSlider").SetValue((int) ((double) ScreenManager.Platform.ShaderUniforms.ExtraContrastLevel * 100.0) + 100); 392 + this.composer.GetSlider("contrastSlider").Enabled = !ClientSettings.DynamicColorGrading; 393 + } 394 + 395 + private void onVsyncChanged(string newvalue, bool selected) 396 + { 397 + ClientSettings.VsyncMode = newvalue.ToInt(); 398 + } 399 + 400 + private void OnMoreOptions(LinkTextComponent comp) 401 + { 402 + ClientSettings.ShowMoreGfxOptions = !ClientSettings.ShowMoreGfxOptions; 403 + this.OnGraphicsOptions(true); 404 + } 405 + 406 + private void SetGfxValues() 407 + { 408 + this.composer.GetSlider("viewDistanceSlider").SetValues(ClientSettings.ViewDistance, 32 /*0x20*/, 1536 /*0x0600*/, 32 /*0x20*/, " blocks"); 409 + this.composer.GetSlider("viewDistanceSlider").OnSliderTooltip = (SliderTooltipDelegate) (value => 410 + { 411 + string str = Lang.Get("createworld-worldheight", (object) value); 412 + return value <= 512 /*0x0200*/ ? str : $"{str}\n{Lang.Get("vram-warning")}"; 413 + }); 414 + this.composer.GetSlider("viewDistanceSlider").TriggerOnlyOnMouseUp(); 415 + int? distanceAlarmValue = this.handler.MaxViewDistanceAlarmValue; 416 + if (distanceAlarmValue.HasValue) 417 + { 418 + GuiElementSlider slider = this.composer.GetSlider("viewDistanceSlider"); 419 + distanceAlarmValue = this.handler.MaxViewDistanceAlarmValue; 420 + int num = distanceAlarmValue.Value; 421 + slider.SetAlarmValue(num); 422 + } 423 + if (ClientSettings.ShowMoreGfxOptions) 424 + { 425 + this.composer.GetSwitch("smoothShadowsLever").On = ClientSettings.SmoothShadows; 426 + this.composer.GetSwitch("FxaaSwitch").On = ClientSettings.FXAA; 427 + this.composer.GetDropDown("optimizeRamMode").SetSelectedIndex(ClientSettings.OptimizeRamMode - 1); 428 + this.composer.GetSwitch("occlusionCullingSwitch").On = ClientSettings.Occlusionculling; 429 + this.composer.GetSwitch("wavingFoliageSwitch").On = ClientSettings.WavingFoliage; 430 + this.composer.GetSwitch("liquidFoamEffectSwitch").On = ClientSettings.LiquidFoamAndShinyEffect; 431 + this.composer.GetSwitch("BloomSwitch").On = ClientSettings.Bloom; 432 + this.composer.GetSwitch("godraySwitch").On = ClientSettings.GodRayQuality > 0; 433 + this.composer.GetDropDown("windowModeSwitch").SetSelectedIndex(ClientSettings.CloudRenderMode); 434 + this.composer.GetSlider("ambientBloomSlider").SetValues((int) ClientSettings.AmbientBloomLevel, 0, 100, 10, "%"); 435 + this.composer.GetSlider("ambientBloomSlider").TriggerOnlyOnMouseUp(); 436 + this.composer.GetSlider("ssaoSlider").SetValues(ClientSettings.SSAOQuality, 0, 2, 1); 437 + string[] qualityssao = new string[3] 438 + { 439 + Lang.Get("Off"), 440 + Lang.Get("Medium quality"), 441 + Lang.Get("High quality") 442 + }; 443 + this.composer.GetSlider("ssaoSlider").OnSliderTooltip = (SliderTooltipDelegate) (value => qualityssao[value]); 444 + this.composer.GetSlider("ssaoSlider").ComposeHoverTextElement(); 445 + this.composer.GetSlider("ssaoSlider").TriggerOnlyOnMouseUp(); 446 + this.composer.GetSlider("shadowsSlider").SetValues(ClientSettings.ShadowMapQuality, 0, 4, 1); 447 + string[] quality2 = new string[5] 448 + { 449 + Lang.Get("Off"), 450 + Lang.Get("Low quality"), 451 + Lang.Get("Medium quality"), 452 + Lang.Get("High quality"), 453 + Lang.Get("Very high quality") 454 + }; 455 + this.composer.GetSlider("shadowsSlider").OnSliderTooltip = (SliderTooltipDelegate) (value => quality2[value]); 456 + this.composer.GetSlider("shadowsSlider").ComposeHoverTextElement(); 457 + this.composer.GetSlider("shadowsSlider").TriggerOnlyOnMouseUp(); 458 + this.composer.GetSlider("particleSlider").SetValues(ClientSettings.ParticleLevel, 0, 100, 2, " %"); 459 + this.composer.GetSlider("dynamicLightsSlider").SetValues(ClientSettings.MaxDynamicLights, 0, 100, 1, " " + Lang.Get("units-lightsources")); 460 + this.composer.GetSlider("dynamicLightsSlider").OnSliderTooltip = (SliderTooltipDelegate) (value => value != 0 ? $"{value.ToString()} {Lang.Get("units-lightsources")}" : Lang.Get("disabled")); 461 + this.composer.GetSlider("dynamicLightsSlider").TriggerOnlyOnMouseUp(); 462 + this.composer.GetSlider("resolutionSlider").SetValues((int) ((double) ClientSettings.SSAA * 100.0), 25, 100, 25, " %"); 463 + this.composer.GetSlider("resolutionSlider").OnSliderTooltip = (SliderTooltipDelegate) (value => 464 + { 465 + float num = (float) value / 100f; 466 + return $"{num.ToString()}x ({((int) ((double) num * (double) num * 100.0)).ToString()}%)"; 467 + }); 468 + this.composer.GetSlider("resolutionSlider").TriggerOnlyOnMouseUp(); 469 + this.composer.GetSlider("lodbiasfarSlider").SetValues((int) ((double) ClientSettings.LodBiasFar * 100.0), 35, 100, 1, " %"); 470 + this.composer.GetSlider("lodbiasfarSlider").OnSliderTooltip = (SliderTooltipDelegate) (value => 471 + { 472 + float num = (float) value / 100f; 473 + return $"{num.ToString()}x ({((int) ((double) num * (double) num * 100.0)).ToString()}%)"; 474 + }); 475 + this.composer.GetSlider("lodbiasfarSlider").TriggerOnlyOnMouseUp(); 476 + } 477 + this.composer.GetSlider("gammaSlider").Enabled = true; 478 + this.composer.GetSlider("gammaSlider").OnSliderTooltip = (SliderTooltipDelegate) null; 479 + this.composer.GetSlider("gammaSlider").ComposeHoverTextElement(); 480 + this.composer.GetSlider("gammaSlider").SetValues((int) Math.Round((double) ClientSettings.GammaLevel * 100.0), 30, 300, 5); 481 + this.composer.GetSwitch("dynamicColorGradingSwitch").On = ClientSettings.DynamicColorGrading; 482 + this.composer.GetSlider("sepiaSlider").SetValues((int) ((double) ScreenManager.Platform.ShaderUniforms.SepiaLevel * 100.0), 0, 100, 5); 483 + this.composer.GetSlider("sepiaSlider").Enabled = !ClientSettings.DynamicColorGrading; 484 + this.composer.GetSlider("contrastSlider").SetValues((int) ((double) ScreenManager.Platform.ShaderUniforms.ExtraContrastLevel * 100.0) + 100, 100, 200, 10, "%"); 485 + this.composer.GetSlider("contrastSlider").Enabled = !ClientSettings.DynamicColorGrading; 486 + this.composer.GetSlider("fovSlider").SetValues(ClientSettings.FieldOfView, 20, 150, 1, "°"); 487 + this.composer.GetDropDown("windowModeSwitch").SetSelectedIndex(GuiCompositeSettings.GetWindowModeIndex()); 488 + if (!ClientSettings.ShowMoreGfxOptions) 489 + return; 490 + this.composer.GetSlider("maxFpsSlider").SetValues(GameMath.Clamp(ClientSettings.MaxFPS, 15, 241), 15, 241, 1); 491 + this.composer.GetSlider("maxFpsSlider").OnSliderTooltip = (SliderTooltipDelegate) (value => value != 241 ? value.ToString() : Lang.Get("unlimited")); 492 + this.composer.GetSlider("maxFpsSlider").ComposeHoverTextElement(); 493 + this.composer.GetDropDown("vsyncMode").SetSelectedIndex(ClientSettings.VsyncMode); 494 + } 495 + 496 + internal static int GetWindowModeIndex() 497 + { 498 + int windowModeIndex = ClientSettings.GameWindowMode; 499 + if (ClientSettings.GameWindowMode == 2 && ScreenManager.Platform.WindowBorder != EnumWindowBorder.Hidden) 500 + windowModeIndex = 0; 501 + return windowModeIndex; 502 + } 503 + 504 + private void onPresetChanged(string id, bool on) 505 + { 506 + GraphicsPreset preset = GraphicsPreset.Presets[int.Parse(id)]; 507 + if (preset.Langcode == "preset-custom") 508 + return; 509 + ClientSettings.GraphicsPresetId = preset.PresetId; 510 + ClientSettings.ViewDistance = preset.ViewDistance; 511 + ClientSettings.SmoothShadows = preset.SmoothLight; 512 + ClientSettings.FXAA = preset.FXAA; 513 + ClientSettings.SSAOQuality = preset.SSAO; 514 + ClientSettings.WavingFoliage = preset.WavingFoliage; 515 + ClientSettings.LiquidFoamAndShinyEffect = preset.LiquidFoamEffect; 516 + ClientSettings.Bloom = preset.Bloom; 517 + ClientSettings.GodRayQuality = preset.GodRays ? 1 : 0; 518 + ClientSettings.ShadowMapQuality = preset.ShadowMapQuality; 519 + ClientSettings.ParticleLevel = preset.ParticleLevel; 520 + ClientSettings.MaxDynamicLights = preset.DynamicLights; 521 + ClientSettings.SSAA = preset.Resolution; 522 + ClientSettings.LodBiasFar = preset.LodBiasFar; 523 + this.SetGfxValues(); 524 + ScreenManager.Platform.RebuildFrameBuffers(); 525 + this.handler.ReloadShaders(); 526 + } 527 + 528 + private void SetCustomPreset() 529 + { 530 + GraphicsPreset graphicsPreset = GraphicsPreset.Presets.Where<GraphicsPreset>((System.Func<GraphicsPreset, bool>) (p => p.Langcode == "preset-custom")).FirstOrDefault<GraphicsPreset>(); 531 + ClientSettings.GraphicsPresetId = graphicsPreset.PresetId; 532 + this.composer.GetDropDown("graphicsPreset").SetSelectedIndex(graphicsPreset.PresetId); 533 + } 534 + 535 + private void OnWindowModeChanged(string code, bool selected) 536 + { 537 + GuiCompositeSettings.SetWindowMode(code.ToInt()); 538 + } 539 + 540 + internal static void SetWindowMode(int mode) 541 + { 542 + switch (mode) 543 + { 544 + case 1: 545 + ScreenManager.Platform.SetWindowAttribute((WindowAttribute) 131078 /*0x020006*/, true); 546 + ScreenManager.Platform.SetWindowState((WindowState) 3); 547 + ClientSettings.GameWindowMode = 1; 548 + break; 549 + case 2: 550 + ClientSettings.WindowBorder = 2; 551 + ScreenManager.Platform.WindowBorder = EnumWindowBorder.Hidden; 552 + if (ScreenManager.Platform.GetWindowState() == 2) 553 + ScreenManager.Platform.SetWindowState((WindowState) 0); 554 + ScreenManager.Platform.SetWindowState((WindowState) 2); 555 + ClientSettings.GameWindowMode = 2; 556 + break; 557 + case 3: 558 + ScreenManager.Platform.SetWindowAttribute((WindowAttribute) 131078 /*0x020006*/, false); 559 + ScreenManager.Platform.SetWindowState((WindowState) 3); 560 + ClientSettings.GameWindowMode = 3; 561 + break; 562 + default: 563 + ScreenManager.Platform.SetWindowAttribute((WindowAttribute) 131078 /*0x020006*/, false); 564 + ScreenManager.Platform.SetWindowState((WindowState) 0); 565 + if (ScreenManager.Platform.WindowBorder != EnumWindowBorder.Resizable) 566 + { 567 + ScreenManager.Platform.WindowBorder = EnumWindowBorder.Resizable; 568 + ClientSettings.WindowBorder = 0; 569 + } 570 + ClientSettings.GameWindowMode = 0; 571 + break; 572 + } 573 + } 574 + 575 + private void OnWindowBorderChanged(string newval, bool on) 576 + { 577 + int result; 578 + int.TryParse(newval, out result); 579 + ClientSettings.WindowBorder = result; 580 + if (ClientSettings.GameWindowMode != 2 || result == 2) 581 + return; 582 + ClientSettings.GameWindowMode = 0; 583 + } 584 + 585 + private void onOptimizeRamChanged(string code, bool selected) 586 + { 587 + ClientSettings.OptimizeRamMode = code.ToInt(); 588 + } 589 + 590 + private void onOcclusionCullingChanged(bool on) => ClientSettings.Occlusionculling = on; 591 + 592 + private bool onResolutionChanged(int newval) 593 + { 594 + ClientSettings.SSAA = (float) newval / 100f; 595 + ScreenManager.Platform.RebuildFrameBuffers(); 596 + this.SetCustomPreset(); 597 + return true; 598 + } 599 + 600 + private bool onLodbiasFarChanged(int newval) 601 + { 602 + ClientSettings.LodBiasFar = (float) newval / 100f; 603 + this.SetCustomPreset(); 604 + return true; 605 + } 606 + 607 + private bool onDynamicLightsChanged(int value) 608 + { 609 + ClientSettings.MaxDynamicLights = value; 610 + this.handler.ReloadShaders(); 611 + this.SetCustomPreset(); 612 + return true; 613 + } 614 + 615 + private void onWavingFoliageChanged(bool on) 616 + { 617 + ClientSettings.WavingFoliage = on; 618 + this.handler.ReloadShaders(); 619 + this.SetCustomPreset(); 620 + } 621 + 622 + private void onFoamAndShinyEffectChanged(bool on) 623 + { 624 + ClientSettings.LiquidFoamAndShinyEffect = on; 625 + this.handler.ReloadShaders(); 626 + this.SetCustomPreset(); 627 + } 628 + 629 + private bool onParticleLevelChanged(int level) 630 + { 631 + ClientSettings.ParticleLevel = level; 632 + this.SetCustomPreset(); 633 + return true; 634 + } 635 + 636 + private bool onMaxFpsChanged(int fps) 637 + { 638 + ClientSettings.MaxFPS = fps; 639 + return true; 640 + } 641 + 642 + private bool onSepiaLevelChanged(int value) 643 + { 644 + ClientSettings.SepiaLevel = (float) value / 100f; 645 + return true; 646 + } 647 + 648 + private bool onGammaChanged(int value) 649 + { 650 + ClientSettings.GammaLevel = (float) value / 100f; 651 + return true; 652 + } 653 + 654 + private void onGodRaysToggled(bool on) 655 + { 656 + ClientSettings.GodRayQuality = on ? 1 : 0; 657 + this.handler.ReloadShaders(); 658 + this.SetCustomPreset(); 659 + } 660 + 661 + private bool onShadowsChanged(int newvalue) 662 + { 663 + ClientSettings.ShadowMapQuality = newvalue; 664 + ScreenManager.Platform.RebuildFrameBuffers(); 665 + this.handler.ReloadShaders(); 666 + this.SetCustomPreset(); 667 + return true; 668 + } 669 + 670 + private bool onLagspikeReductionChanged(int newvalue) 671 + { 672 + ClientSettings.ChunkVerticesUploadRateLimiter = newvalue; 673 + return true; 674 + } 675 + 676 + private bool onAmbientBloomChanged(int newvalue) 677 + { 678 + ClientSettings.AmbientBloomLevel = (float) newvalue; 679 + this.handler.ReloadShaders(); 680 + this.SetCustomPreset(); 681 + return true; 682 + } 683 + 684 + private bool onContrastChanged(int newvalue) 685 + { 686 + ClientSettings.ExtraContrastLevel = (float) (newvalue - 100) / 100f; 687 + this.SetCustomPreset(); 688 + return true; 689 + } 690 + 691 + private void onBloomChanged(bool on) 692 + { 693 + ClientSettings.Bloom = on; 694 + this.handler.ReloadShaders(); 695 + this.SetCustomPreset(); 696 + } 697 + 698 + private bool onVowChanged(int newvalue) 699 + { 700 + ClientSettings.FieldOfView = newvalue; 701 + return true; 702 + } 703 + 704 + private bool onGuiScaleChanged(int newsize) 705 + { 706 + ClientSettings.GUIScale = (float) newsize / 8f; 707 + this.updateButtonBounds(); 708 + return true; 709 + } 710 + 711 + private void onFxaaChanged(bool fxaa) 712 + { 713 + ClientSettings.FXAA = fxaa; 714 + this.handler.ReloadShaders(); 715 + this.SetCustomPreset(); 716 + } 717 + 718 + private bool onSsaoChanged(int ssao) 719 + { 720 + ClientSettings.SSAOQuality = ssao; 721 + if (!this.handler.IsIngame) 722 + { 723 + ScreenManager.Platform.RebuildFrameBuffers(); 724 + this.handler.ReloadShaders(); 725 + } 726 + this.SetCustomPreset(); 727 + return true; 728 + } 729 + 730 + internal void onSmoothShadowsToggled(bool newstate) 731 + { 732 + ClientSettings.SmoothShadows = newstate; 733 + this.SetCustomPreset(); 734 + } 735 + 736 + internal bool onViewdistanceChanged(int newvalue) 737 + { 738 + ClientSettings.ViewDistance = newvalue; 739 + this.SetCustomPreset(); 740 + return true; 741 + } 742 + 743 + private void OnMouseOptions(bool on) 744 + { 745 + this.mousecontrolsTabActive = true; 746 + this.LoadMouseCombinations(); 747 + ElementBounds elementBounds1 = ElementBounds.Fixed(0.0, 85.0, 320.0, 42.0); 748 + ElementBounds elementBounds2 = ElementBounds.Fixed(340.0, 89.0, 200.0, 20.0); 749 + ElementBounds bounds1 = ElementBounds.Fixed(0.0, 0.0, 900.0 - 2.0 * GuiStyle.ElementToDialogPadding - 35.0, this.onMainscreen ? 140.0 : 114.0); 750 + ElementBounds bounds2 = bounds1.ForkBoundingParent(5.0, 5.0, 5.0, 5.0); 751 + ElementBounds bounds3 = bounds1.FlatCopy().WithParent(bounds2); 752 + ElementBounds elementBounds3; 753 + ElementBounds elementBounds4; 754 + ElementBounds elementBounds5; 755 + ElementBounds elementBounds6; 756 + ElementBounds elementBounds7; 757 + ElementBounds elementBounds8; 758 + ElementBounds elementBounds9; 759 + ElementBounds elementBounds10; 760 + ElementBounds elementBounds11; 761 + ElementBounds elementBounds12; 762 + ElementBounds refBounds; 763 + this.composer = this.ComposerHeader("gamesettings-mouse", "mouse").AddStaticText(Lang.Get("setting-name-mousesensivity"), CairoFont.WhiteSmallishText(), elementBounds1.FlatCopy()).AddSlider(new ActionConsumable<int>(this.onMouseSensivityChanged), elementBounds3 = elementBounds2.FlatCopy(), "mouseSensivitySlider").AddStaticText(Lang.Get("setting-name-mousesmoothing"), CairoFont.WhiteSmallishText(), elementBounds4 = elementBounds1.BelowCopy()).AddSlider(new ActionConsumable<int>(this.onMouseSmoothingChanged), elementBounds5 = elementBounds3.BelowCopy(fixedDeltaY: 21.0), "mouseSmoothingSlider").AddStaticText(Lang.Get("setting-name-mousewheelsensivity"), CairoFont.WhiteSmallishText(), elementBounds6 = elementBounds4.BelowCopy()).AddSlider(new ActionConsumable<int>(this.onMouseWheelSensivityChanged), elementBounds7 = elementBounds5.BelowCopy(fixedDeltaY: 21.0), "mouseWheelSensivitySlider").AddStaticText(Lang.Get("setting-name-directmousemode"), CairoFont.WhiteSmallishText(), elementBounds8 = elementBounds6.BelowCopy(fixedDeltaY: 3.0)).AddSwitch(new Action<bool>(this.onMouseModeChanged), elementBounds9 = elementBounds7.BelowCopy(fixedDeltaY: 21.0), "directMouseModeSwitch").AddHoverText(Lang.Get("setting-hover-directmousemode"), CairoFont.WhiteSmallText(), 250, elementBounds8.FlatCopy().WithFixedHeight(25.0)).AddStaticText(Lang.Get("setting-name-invertyaxis"), CairoFont.WhiteSmallishText(), elementBounds10 = elementBounds8.BelowCopy(fixedDeltaY: 3.0)).AddSwitch(new Action<bool>(this.onInvertYAxisChanged), elementBounds11 = elementBounds9.BelowCopy(fixedDeltaY: 21.0), "invertYAxisSwitch").AddStaticText(Lang.Get("setting-name-itemCollectMode"), CairoFont.WhiteSmallishText(), elementBounds12 = elementBounds10.BelowCopy(fixedDeltaY: 2.0)).AddDropDown(new string[2] 764 + { 765 + "0", 766 + "1" 767 + }, new string[2] 768 + { 769 + Lang.Get("Always collect items"), 770 + Lang.Get("Only collect items when sneaking") 771 + }, ClientSettings.ItemCollectMode, new SelectionChangedDelegate(this.onCollectionModeChange), elementBounds11.BelowCopy(fixedDeltaY: 12.0).WithFixedWidth(200.0), "itemCollectionMode").AddStaticText(Lang.Get("mousecontrols"), CairoFont.WhiteSmallishText(), refBounds = elementBounds12.BelowCopy(fixedDeltaY: 20.0)).AddHoverText(Lang.Get("hover-mousecontrols"), CairoFont.WhiteSmallText(), 250, refBounds.FlatCopy().WithFixedHeight(60.0)).AddInset(bounds2.FixedUnder(refBounds, -8.0), 3, 0.8f).BeginClip(bounds3).AddConfigList(this.mousecontrolItems, new ConfigItemClickDelegate(this.OnMouseControlItemClick), CairoFont.WhiteSmallText().WithFontSize(18f), bounds1, "configlist").EndClip().AddIf(this.onMainscreen).AddStaticText(Lang.Get("mousecontrols-mainmenuwarning"), CairoFont.WhiteSmallText(), refBounds.BelowCopy(fixedDeltaY: 112.0, fixedDeltaWidth: 500.0)).EndIf().EndChildElements().Compose(); 772 + this.handler.LoadComposer(this.composer); 773 + this.composer.GetSlider("mouseWheelSensivitySlider").SetValues((int) ((double) ClientSettings.MouseWheelSensivity * 10.0), 1, 100, 1); 774 + this.composer.GetSlider("mouseWheelSensivitySlider").OnSliderTooltip = (SliderTooltipDelegate) (value => ((float) value / 10f).ToString() + "x"); 775 + this.composer.GetSlider("mouseWheelSensivitySlider").ComposeHoverTextElement(); 776 + this.composer.GetSlider("mouseSensivitySlider").SetValues(ClientSettings.MouseSensivity, 1, 200, 5); 777 + this.composer.GetSlider("mouseSmoothingSlider").SetValues(100 - ClientSettings.MouseSmoothing, 0, 95, 5); 778 + this.composer.GetSwitch("directMouseModeSwitch").SetValue(ClientSettings.DirectMouseMode); 779 + this.composer.GetSwitch("invertYAxisSwitch").SetValue(ClientSettings.InvertMouseYAxis); 780 + } 781 + 782 + private void OnMouseControlItemClick(int index, int indexNoTitle) 783 + { 784 + if (this.clickedItemIndex.HasValue) 785 + return; 786 + this.mousecontrolItems[index].Value = "?"; 787 + this.clickedItemIndex = new int?(index); 788 + int data = (int) this.mousecontrolItems[this.clickedItemIndex.Value].Data; 789 + this.composer.GetConfigList("configlist").Refresh(); 790 + string keyAtIndex = ScreenManager.hotkeyManager.HotKeys.GetKeyAtIndex(data); 791 + this.keyCombClone = ScreenManager.hotkeyManager.HotKeys[keyAtIndex].Clone(); 792 + this.hotkeyCapturer.BeginCapture(); 793 + this.keyCombClone.CurrentMapping = this.hotkeyCapturer.CapturingKeyComb; 794 + } 795 + 796 + private void LoadMouseCombinations() 797 + { 798 + int num1 = -1; 799 + int count = this.mousecontrolItems.Count; 800 + int? clickedItemIndex = this.clickedItemIndex; 801 + int valueOrDefault = clickedItemIndex.GetValueOrDefault(); 802 + if (count >= valueOrDefault & clickedItemIndex.HasValue) 803 + num1 = (int) this.mousecontrolItems[this.clickedItemIndex.Value].Data; 804 + this.mousecontrolItems.Clear(); 805 + int num2 = 0; 806 + List<ConfigItem>[] configItemListArray = new List<ConfigItem>[this.sortOrder.Count]; 807 + for (int index = 0; index < configItemListArray.Length; ++index) 808 + configItemListArray[index] = new List<ConfigItem>(); 809 + this.mousecontrolItems.Add(new ConfigItem() 810 + { 811 + Type = EnumItemType.Title, 812 + Key = Lang.Get("mouseactions") 813 + }); 814 + foreach (KeyValuePair<string, HotKey> hotKey in ScreenManager.hotkeyManager.HotKeys) 815 + { 816 + HotKey keyCombClone = hotKey.Value; 817 + if (this.clickedItemIndex.HasValue && num2 == num1) 818 + keyCombClone = this.keyCombClone; 819 + string text = "?"; 820 + if (keyCombClone.CurrentMapping != null) 821 + text = keyCombClone.CurrentMapping.ToString(); 822 + ConfigItem configItem = new ConfigItem() 823 + { 824 + Code = hotKey.Key, 825 + Key = keyCombClone.Name, 826 + Value = text, 827 + Data = (object) num2 828 + }; 829 + int index = this.mousecontrolItems.FindIndex((Predicate<ConfigItem>) (configitem => configitem.Value == text)); 830 + if (index != -1) 831 + { 832 + configItem.error = true; 833 + this.mousecontrolItems[index].error = true; 834 + } 835 + configItemListArray[this.sortOrder[keyCombClone.KeyCombinationType]].Add(configItem); 836 + ++num2; 837 + } 838 + for (int index = 9; index < configItemListArray.Length; ++index) 839 + this.mousecontrolItems.AddRange((IEnumerable<ConfigItem>) configItemListArray[index]); 840 + } 841 + 842 + private void OnControlOptions(bool on) 843 + { 844 + this.mousecontrolsTabActive = false; 845 + this.LoadKeyCombinations(); 846 + ElementBounds bounds1 = ElementBounds.Fixed(0.0, 0.0, 900.0 - 2.0 * GuiStyle.ElementToDialogPadding - 35.0, 400.0); 847 + ElementBounds elementBounds1 = bounds1.ForkBoundingParent(5.0, 5.0, 5.0, 5.0); 848 + ElementBounds bounds2 = bounds1.FlatCopy().WithParent(elementBounds1); 849 + ElementBounds elementBounds2 = ElementStdBounds.VerticalScrollbar(elementBounds1); 850 + ElementBounds elementBounds3 = ElementBounds.Fixed(0.0, 41.0, 360.0, 42.0); 851 + ElementBounds elementBounds4 = ElementBounds.Fixed(490.0, 38.0, 200.0, 20.0); 852 + ElementBounds elementBounds5; 853 + ElementBounds elementBounds6; 854 + ElementBounds refBounds; 855 + this.composer = this.ComposerHeader("gamesettings-controls", "controls").AddStaticText(Lang.Get("setting-name-noseparatectrlkeys"), CairoFont.WhiteSmallishText(), elementBounds5 = elementBounds3.BelowCopy(fixedDeltaY: 10.0, fixedDeltaWidth: 120.0)).AddSwitch(new Action<bool>(this.onSeparateCtrl), elementBounds4.BelowCopy(fixedDeltaY: 32.0), "separateCtrl").AddHoverText(Lang.Get("setting-hover-noseparatectrlkeys"), CairoFont.WhiteSmallText(), 250, elementBounds5.FlatCopy().WithFixedHeight(25.0)).AddStaticText(Lang.Get("keycontrols"), CairoFont.WhiteSmallishText(), elementBounds6 = elementBounds5.BelowCopy(fixedDeltaY: 5.0, fixedDeltaWidth: -120.0)).AddTextInput(refBounds = elementBounds6.BelowCopy(fixedDeltaY: 5.0), (Action<string>) (text => 856 + { 857 + if (this.currentSearchText == text) 858 + return; 859 + this.currentSearchText = text; 860 + this.ReLoadKeyCombinations(); 861 + }), key: "searchField").AddVerticalScrollbar(new Action<float>(this.OnNewScrollbarValue), elementBounds2.FixedUnder(refBounds, 10.0), "scrollbar").AddInset(elementBounds1.FixedUnder(refBounds, 10.0), 3, 0.8f).BeginClip(bounds2).AddConfigList(this.keycontrolItems, new ConfigItemClickDelegate(this.OnKeyControlItemClick), CairoFont.WhiteSmallText().WithFontSize(18f), bounds1, "configlist").EndClip().AddButton(Lang.Get("setting-name-setdefault"), new ActionConsumable(this.OnResetControls), ElementStdBounds.MenuButton(0.0f, EnumDialogArea.LeftFixed).FixedUnder(elementBounds1, 10.0).WithFixedPadding(10.0, 2.0)).AddIf(this.handler.IsIngame).AddButton(Lang.Get("setting-name-macroeditor"), new ActionConsumable(this.OnMacroEditor), ElementStdBounds.MenuButton(0.0f, EnumDialogArea.RightFixed).FixedUnder(elementBounds1, 10.0).WithFixedPadding(10.0, 2.0)).EndIf().EndChildElements().Compose(); 862 + this.handler.LoadComposer(this.composer); 863 + this.composer.GetSwitch("separateCtrl").SetValue(!ClientSettings.SeparateCtrl); 864 + this.composer.GetTextInput("searchField").SetPlaceHolderText(Lang.Get("Search...")); 865 + this.composer.GetTextInput("searchField").SetValue(""); 866 + GuiElementConfigList configList = this.composer.GetConfigList("configlist"); 867 + configList.errorFont = configList.stdFont.Clone(); 868 + configList.errorFont.Color = GuiStyle.ErrorTextColor; 869 + configList.Bounds.CalcWorldBounds(); 870 + bounds2.CalcWorldBounds(); 871 + this.ReLoadKeyCombinations(); 872 + this.composer.GetScrollbar("scrollbar").SetHeights((float) bounds2.fixedHeight, (float) configList.innerBounds.fixedHeight); 873 + } 874 + 875 + private bool OnMacroEditor() 876 + { 877 + this.handler.OnMacroEditor(); 878 + return true; 879 + } 880 + 881 + private void onCollectionModeChange(string code, bool selected) 882 + { 883 + ClientSettings.ItemCollectMode = code.ToInt(); 884 + } 885 + 886 + private void onMouseModeChanged(bool on) 887 + { 888 + ClientSettings.DirectMouseMode = on; 889 + ScreenManager.Platform.SetDirectMouseMode(on); 890 + } 891 + 892 + private void onInvertYAxisChanged(bool on) => ClientSettings.InvertMouseYAxis = on; 893 + 894 + private void onSeparateCtrl(bool on) 895 + { 896 + ClientSettings.SeparateCtrl = !on; 897 + if (on) 898 + { 899 + HotKey hotKey1 = ScreenManager.hotkeyManager.HotKeys["shift"]; 900 + hotKey1.CurrentMapping = ScreenManager.hotkeyManager.HotKeys["sneak"].CurrentMapping; 901 + ClientSettings.Inst.SetKeyMapping("shift", hotKey1.CurrentMapping); 902 + HotKey hotKey2 = ScreenManager.hotkeyManager.HotKeys["ctrl"]; 903 + hotKey2.CurrentMapping = ScreenManager.hotkeyManager.HotKeys["sprint"].CurrentMapping; 904 + ClientSettings.Inst.SetKeyMapping("ctrl", hotKey2.CurrentMapping); 905 + } 906 + else 907 + { 908 + HotKey hotKey3 = ScreenManager.hotkeyManager.HotKeys["shift"]; 909 + hotKey3.CurrentMapping = new KeyCombination() 910 + { 911 + KeyCode = 1 912 + }; 913 + ClientSettings.Inst.SetKeyMapping("shift", hotKey3.CurrentMapping); 914 + HotKey hotKey4 = ScreenManager.hotkeyManager.HotKeys["ctrl"]; 915 + hotKey4.CurrentMapping = new KeyCombination() 916 + { 917 + KeyCode = 3 918 + }; 919 + ClientSettings.Inst.SetKeyMapping("ctrl", hotKey4.CurrentMapping); 920 + } 921 + this.OnControlOptions(true); 922 + } 923 + 924 + private bool onMouseWheelSensivityChanged(int val) 925 + { 926 + ClientSettings.MouseWheelSensivity = (float) val / 10f; 927 + return true; 928 + } 929 + 930 + private void ReLoadKeyCombinations() 931 + { 932 + if (this.mousecontrolsTabActive) 933 + this.LoadMouseCombinations(); 934 + else 935 + this.LoadKeyCombinations(); 936 + GuiElementConfigList configList = this.composer.GetConfigList("configlist"); 937 + if (configList == null) 938 + return; 939 + configList.Refresh(); 940 + this.composer.GetScrollbar("scrollbar")?.SetNewTotalHeight((float) configList.innerBounds.OuterHeight); 941 + this.composer.GetScrollbar("scrollbar")?.TriggerChanged(); 942 + } 943 + 944 + private void LoadKeyCombinations() 945 + { 946 + int num1 = -1; 947 + int count = this.keycontrolItems.Count; 948 + int? clickedItemIndex = this.clickedItemIndex; 949 + int valueOrDefault = clickedItemIndex.GetValueOrDefault(); 950 + if (count >= valueOrDefault & clickedItemIndex.HasValue) 951 + num1 = (int) this.keycontrolItems[this.clickedItemIndex.Value].Data; 952 + this.keycontrolItems.Clear(); 953 + int num2 = 0; 954 + List<ConfigItem>[] configItemListArray = new List<ConfigItem>[this.sortOrder.Count]; 955 + for (int index = 0; index < configItemListArray.Length; ++index) 956 + configItemListArray[index] = new List<ConfigItem>(); 957 + foreach (KeyValuePair<string, HotKey> hotKey in ScreenManager.hotkeyManager.HotKeys) 958 + { 959 + HotKey keyCombClone = hotKey.Value; 960 + if (this.clickedItemIndex.HasValue && num2 == num1) 961 + keyCombClone = this.keyCombClone; 962 + string text = "?"; 963 + if (keyCombClone.CurrentMapping != null) 964 + text = keyCombClone.CurrentMapping.ToString(); 965 + ConfigItem configItem = new ConfigItem() 966 + { 967 + Code = hotKey.Key, 968 + Key = keyCombClone.Name, 969 + Value = text, 970 + Data = (object) num2 971 + }; 972 + int index = this.keycontrolItems.FindIndex((Predicate<ConfigItem>) (configitem => configitem.Value == text)); 973 + if (index != -1) 974 + { 975 + configItem.error = true; 976 + this.keycontrolItems[index].error = true; 977 + } 978 + configItemListArray[this.sortOrder[keyCombClone.KeyCombinationType]].Add(configItem); 979 + ++num2; 980 + } 981 + for (int index = 0; index < configItemListArray.Length; ++index) 982 + { 983 + List<ConfigItem> source = new List<ConfigItem>(); 984 + string currentSearchText = this.currentSearchText; 985 + string lowerInvariant = currentSearchText != null ? currentSearchText.ToSearchFriendly().ToLowerInvariant() : (string) null; 986 + bool flag = !string.IsNullOrEmpty(lowerInvariant); 987 + if ((index != 1 || ClientSettings.SeparateCtrl) && index != 9) 988 + { 989 + if (flag) 990 + { 991 + foreach (ConfigItem configItem in configItemListArray[index]) 992 + { 993 + if (configItem.Key.ToSearchFriendly().ToLowerInvariant().Contains(lowerInvariant)) 994 + source.Add(configItem); 995 + } 996 + if (source != null && !source.Any<ConfigItem>()) 997 + continue; 998 + } 999 + if (index != 7) 1000 + this.keycontrolItems.Add(new ConfigItem() 1001 + { 1002 + Type = EnumItemType.Title, 1003 + Key = this.titles[index] 1004 + }); 1005 + this.keycontrolItems.AddRange(flag ? (IEnumerable<ConfigItem>) source : (IEnumerable<ConfigItem>) configItemListArray[index]); 1006 + } 1007 + } 1008 + } 1009 + 1010 + private void OnKeyControlItemClick(int index, int indexNoTitle) 1011 + { 1012 + if (this.clickedItemIndex.HasValue) 1013 + return; 1014 + this.keycontrolItems[index].Value = "?"; 1015 + this.clickedItemIndex = new int?(index); 1016 + int data = (int) this.keycontrolItems[this.clickedItemIndex.Value].Data; 1017 + this.composer.GetConfigList("configlist").Refresh(); 1018 + this.composer.GetScrollbar("scrollbar")?.TriggerChanged(); 1019 + string keyAtIndex = ScreenManager.hotkeyManager.HotKeys.GetKeyAtIndex(data); 1020 + this.keyCombClone = ScreenManager.hotkeyManager.HotKeys[keyAtIndex].Clone(); 1021 + this.hotkeyCapturer.BeginCapture(); 1022 + this.keyCombClone.CurrentMapping = this.hotkeyCapturer.CapturingKeyComb; 1023 + } 1024 + 1025 + public bool ShouldCaptureAllInputs() => this.hotkeyCapturer.IsCapturing(); 1026 + 1027 + public void OnKeyDown(KeyEvent eventArgs) 1028 + { 1029 + if (!this.hotkeyCapturer.OnKeyDown(eventArgs)) 1030 + return; 1031 + if (!this.hotkeyCapturer.IsCapturing()) 1032 + { 1033 + this.clickedItemIndex = new int?(); 1034 + this.keyCombClone = (HotKey) null; 1035 + } 1036 + this.ReLoadKeyCombinations(); 1037 + } 1038 + 1039 + public void OnKeyUp(KeyEvent eventArgs) 1040 + { 1041 + this.hotkeyCapturer.OnKeyUp(eventArgs, new Action(this.CompletedCapture)); 1042 + } 1043 + 1044 + public void OnMouseDown(MouseEvent eventArgs) 1045 + { 1046 + if (!this.hotkeyCapturer.OnMouseDown(eventArgs)) 1047 + return; 1048 + if (!this.hotkeyCapturer.IsCapturing()) 1049 + { 1050 + this.clickedItemIndex = new int?(); 1051 + this.keyCombClone = (HotKey) null; 1052 + } 1053 + this.ReLoadKeyCombinations(); 1054 + } 1055 + 1056 + public void OnMouseUp(MouseEvent eventArgs) 1057 + { 1058 + this.hotkeyCapturer.OnMouseUp(eventArgs, new Action(this.CompletedCapture)); 1059 + } 1060 + 1061 + private void CompletedCapture() 1062 + { 1063 + int index = this.mousecontrolsTabActive ? (int) this.mousecontrolItems[this.clickedItemIndex.Value].Data : (int) this.keycontrolItems[this.clickedItemIndex.Value].Data; 1064 + string keyAtIndex = ScreenManager.hotkeyManager.HotKeys.GetKeyAtIndex(index); 1065 + if (!this.hotkeyCapturer.WasCancelled) 1066 + { 1067 + this.keyCombClone.CurrentMapping = this.hotkeyCapturer.CapturedKeyComb; 1068 + ScreenManager.hotkeyManager.HotKeys[keyAtIndex] = this.keyCombClone; 1069 + ClientSettings.Inst.SetKeyMapping(keyAtIndex, this.keyCombClone.CurrentMapping); 1070 + if (keyAtIndex == "sneak" && !ClientSettings.SeparateCtrl) 1071 + { 1072 + ScreenManager.hotkeyManager.HotKeys["shift"].CurrentMapping = this.keyCombClone.CurrentMapping; 1073 + this.ShiftOrCtrlChanged(); 1074 + } 1075 + if (keyAtIndex == "sprint" && !ClientSettings.SeparateCtrl) 1076 + { 1077 + ScreenManager.hotkeyManager.HotKeys["ctrl"].CurrentMapping = this.keyCombClone.CurrentMapping; 1078 + this.ShiftOrCtrlChanged(); 1079 + } 1080 + if (keyAtIndex == "shift" || keyAtIndex == "ctrl" || keyAtIndex == "primarymouse" || keyAtIndex == "secondarymouse" || keyAtIndex == "toolmodeselect") 1081 + this.ShiftOrCtrlChanged(); 1082 + } 1083 + this.clickedItemIndex = new int?(); 1084 + this.keyCombClone = (HotKey) null; 1085 + this.ReLoadKeyCombinations(); 1086 + } 1087 + 1088 + private void ShiftOrCtrlChanged() 1089 + { 1090 + if (!(this.handler.Api is ClientCoreAPI api)) 1091 + return; 1092 + api.eventapi.TriggerHotkeysChanged(); 1093 + } 1094 + 1095 + private void OnNewScrollbarValue(float value) 1096 + { 1097 + ElementBounds innerBounds = this.composer.GetConfigList("configlist").innerBounds; 1098 + innerBounds.fixedY = 5.0 - (double) value; 1099 + innerBounds.CalcWorldBounds(); 1100 + } 1101 + 1102 + private bool onMouseSmoothingChanged(int value) 1103 + { 1104 + ClientSettings.MouseSmoothing = 100 - value; 1105 + return true; 1106 + } 1107 + 1108 + private bool onMouseSensivityChanged(int value) 1109 + { 1110 + ClientSettings.MouseSensivity = value; 1111 + return true; 1112 + } 1113 + 1114 + private bool OnResetControls() 1115 + { 1116 + this.composer = this.ComposerHeader("gamesettings-confirmreset", "controls").AddStaticText(Lang.Get("Please Confirm"), CairoFont.WhiteSmallishText(), ElementStdBounds.Rowed(1.5f, 0.0, EnumDialogArea.LeftFixed).WithFixedWidth(600.0)).AddStaticText(Lang.Get("Really reset key controls to default settings?"), CairoFont.WhiteSmallishText(), ElementStdBounds.Rowed(2f, 0.0, EnumDialogArea.LeftFixed).WithFixedSize(600.0, 100.0)).AddButton(Lang.Get("Cancel"), new ActionConsumable(this.OnCancelReset), ElementStdBounds.Rowed(3.7f, 0.0, EnumDialogArea.LeftFixed).WithFixedPadding(10.0, 2.0)).AddButton(Lang.Get("Confirm"), new ActionConsumable(this.OnConfirmReset), ElementStdBounds.Rowed(3.7f, 0.0, EnumDialogArea.RightFixed).WithFixedPadding(10.0, 2.0)).EndChildElements().Compose(); 1117 + this.handler.LoadComposer(this.composer); 1118 + return true; 1119 + } 1120 + 1121 + private bool OnConfirmReset() 1122 + { 1123 + ClientSettings.KeyMapping.Clear(); 1124 + ScreenManager.hotkeyManager.ResetKeyMapping(); 1125 + this.OnControlOptions(true); 1126 + return true; 1127 + } 1128 + 1129 + private bool OnCancelReset() 1130 + { 1131 + this.OnControlOptions(true); 1132 + return true; 1133 + } 1134 + 1135 + private void OnAccessibilityOptions(bool on) 1136 + { 1137 + ElementBounds elementBounds1 = ElementBounds.Fixed(0.0, 85.0, 450.0, 42.0); 1138 + ElementBounds elementBounds2 = ElementBounds.Fixed(470.0, 138.0, 200.0, 20.0); 1139 + ElementBounds elementBounds3; 1140 + ElementBounds elementBounds4; 1141 + ElementBounds elementBounds5; 1142 + ElementBounds elementBounds6; 1143 + ElementBounds elementBounds7; 1144 + ElementBounds elementBounds8; 1145 + ElementBounds elementBounds9; 1146 + ElementBounds elementBounds10; 1147 + ElementBounds elementBounds11; 1148 + ElementBounds elementBounds12; 1149 + this.composer = this.ComposerHeader("gamesettings-accessibility", "accessibility").AddStaticText(Lang.Get("setting-accessibility-notes"), CairoFont.WhiteSmallText(), elementBounds1.FlatCopy().WithFixedWidth(800.0)).AddStaticText(Lang.Get("setting-name-togglesprint"), CairoFont.WhiteSmallishText(), elementBounds3 = elementBounds1.BelowCopy(fixedDeltaY: 12.0).WithFixedWidth(360.0)).AddHoverText(Lang.Get("setting-hover-togglesprint"), CairoFont.WhiteSmallText(), 250, elementBounds3.FlatCopy().WithFixedHeight(25.0)).AddSwitch(new Action<bool>(this.onToggleSprint), elementBounds2.FlatCopy(), "toggleSprint").AddStaticText(Lang.Get("setting-name-bobblehead"), CairoFont.WhiteSmallishText(), elementBounds4 = elementBounds3.BelowCopy(fixedDeltaY: 2.0)).AddHoverText(Lang.Get("setting-hover-bobblehead"), CairoFont.WhiteSmallText(), 250, elementBounds4.FlatCopy().WithFixedHeight(25.0)).AddSwitch(new Action<bool>(this.onViewBobbingChanged), elementBounds5 = elementBounds2.BelowCopy(fixedDeltaY: 20.0), "viewBobbingSwitch").AddStaticText(Lang.Get("setting-name-camerashake"), CairoFont.WhiteSmallishText(), elementBounds6 = elementBounds4.BelowCopy(fixedDeltaY: 2.0)).AddSlider(new ActionConsumable<int>(this.onCameraShakeChanged), elementBounds7 = elementBounds5.BelowCopy(fixedDeltaY: 18.0).WithFixedSize(200.0, 25.0), "cameraShakeSlider").AddHoverText(Lang.Get("setting-hover-camerashake"), CairoFont.WhiteSmallText(), 250, elementBounds6.FlatCopy().WithFixedHeight(25.0)).AddStaticText(Lang.Get("setting-name-wireframethickness"), CairoFont.WhiteSmallishText(), elementBounds8 = elementBounds6.BelowCopy(fixedDeltaY: 2.0)).AddSlider(new ActionConsumable<int>(this.onWireframeThicknessChanged), elementBounds9 = elementBounds7.BelowCopy(fixedDeltaY: 19.0).WithFixedSize(200.0, 25.0), "wireframethicknessSlider").AddHoverText(Lang.Get("setting-hover-wireframethickness"), CairoFont.WhiteSmallText(), 250, elementBounds8.FlatCopy().WithFixedHeight(25.0)).AddStaticText(Lang.Get("setting-name-wireframecolors"), CairoFont.WhiteSmallishText(), elementBounds10 = elementBounds8.BelowCopy(fixedDeltaY: 2.0)).AddDropDown(new string[3] 1150 + { 1151 + "Preset1", 1152 + "Preset2", 1153 + "Preset3" 1154 + }, new string[3] 1155 + { 1156 + Lang.Get("Preset 1"), 1157 + Lang.Get("Preset 2"), 1158 + Lang.Get("Preset 3") 1159 + }, ClientSettings.guiColorsPreset - 1, new SelectionChangedDelegate(this.onWireframeColorsChanged), elementBounds11 = elementBounds9.BelowCopy(fixedDeltaY: 19.0).WithFixedSize(100.0, 25.0), "wireframecolorsDropdown").AddHoverText(Lang.Get("setting-hover-wireframecolors"), CairoFont.WhiteSmallText(), 250, elementBounds10.FlatCopy().WithFixedHeight(25.0)).AddStaticText(Lang.Get("setting-name-instabilityWavingStrength"), CairoFont.WhiteSmallishText(), elementBounds12 = elementBounds10.BelowCopy(fixedDeltaY: 2.0)).AddSlider(new ActionConsumable<int>(this.onInstabilityStrengthChanged), elementBounds11.BelowCopy(fixedDeltaY: 19.0).WithFixedSize(200.0, 25.0), "instabilityWavingStrengthSlider").AddHoverText(Lang.Get("setting-hover-instabilityWavingStrength"), CairoFont.WhiteSmallText(), 250, elementBounds12.FlatCopy().WithFixedHeight(25.0)).AddRichtext(Lang.Get("help-accessibility"), CairoFont.WhiteDetailText(), elementBounds12.BelowCopy(fixedDeltaY: 23.0)).EndChildElements().Compose(); 1160 + this.composer.GetSwitch("viewBobbingSwitch").On = ClientSettings.ViewBobbing; 1161 + this.composer.GetSwitch("toggleSprint").SetValue(ClientSettings.ToggleSprint); 1162 + this.composer.GetSlider("cameraShakeSlider").SetValues((int) ((double) ClientSettings.CameraShakeStrength * 100.0), 0, 100, 1, " %"); 1163 + this.composer.GetSlider("wireframethicknessSlider").SetValues((int) ((double) ClientSettings.Wireframethickness * 2.0), 1, 16 /*0x10*/, 1, "x"); 1164 + this.composer.GetSlider("wireframethicknessSlider").OnSliderTooltip = (SliderTooltipDelegate) (value => ((float) value / 2f).ToString() + "x"); 1165 + this.composer.GetSlider("wireframethicknessSlider").ComposeHoverTextElement(); 1166 + this.composer.GetSlider("instabilityWavingStrengthSlider").SetValues((int) ((double) ClientSettings.InstabilityWavingStrength * 100.0), 0, 150, 1, " %"); 1167 + this.handler.LoadComposer(this.composer); 1168 + } 1169 + 1170 + private bool onInstabilityStrengthChanged(int value) 1171 + { 1172 + ClientSettings.InstabilityWavingStrength = (float) value / 100f; 1173 + return true; 1174 + } 1175 + 1176 + private bool onWireframeThicknessChanged(int value) 1177 + { 1178 + ClientSettings.Wireframethickness = (float) value / 2f; 1179 + return true; 1180 + } 1181 + 1182 + private void onWireframeColorsChanged(string code, bool selected) 1183 + { 1184 + ClientSettings.guiColorsPreset = (int) code[code.Length - 1] - 48 /*0x30*/; 1185 + this.handler.Api.ColorPreset?.OnUpdateSetting(); 1186 + } 1187 + 1188 + private bool onCameraShakeChanged(int value) 1189 + { 1190 + ClientSettings.CameraShakeStrength = (float) value / 100f; 1191 + return true; 1192 + } 1193 + 1194 + private void onViewBobbingChanged(bool val) => ClientSettings.ViewBobbing = val; 1195 + 1196 + private void onToggleSprint(bool on) => ClientSettings.ToggleSprint = on; 1197 + 1198 + internal void OnSoundOptions(bool on) 1199 + { 1200 + ElementBounds elementBounds1 = ElementBounds.Fixed(0.0, 87.0, 320.0, 40.0); 1201 + ElementBounds elementBounds2 = ElementBounds.Fixed(340.0, 89.0, 330.0, 20.0); 1202 + string[] strArray = new string[1].Append<string>(ScreenManager.Platform.AvailableAudioDevices.ToArray<string>()); 1203 + string[] names = new string[1]{ "Default" }.Append<string>(ScreenManager.Platform.AvailableAudioDevices.ToArray<string>()); 1204 + ElementBounds elementBounds3; 1205 + ElementBounds elementBounds4; 1206 + ElementBounds elementBounds5; 1207 + ElementBounds elementBounds6; 1208 + ElementBounds elementBounds7; 1209 + ElementBounds elementBounds8; 1210 + ElementBounds elementBounds9; 1211 + ElementBounds elementBounds10; 1212 + ElementBounds elementBounds11; 1213 + ElementBounds elementBounds12; 1214 + ElementBounds elementBounds13; 1215 + ElementBounds elementBounds14; 1216 + ElementBounds elementBounds15; 1217 + ElementBounds elementBounds16; 1218 + ElementBounds elementBounds17; 1219 + ElementBounds elementBounds18; 1220 + this.composer = this.ComposerHeader("gamesettings-soundoptions", "sounds").AddStaticText(Lang.Get("setting-name-mastersoundlevel"), CairoFont.WhiteSmallishText(), elementBounds3 = elementBounds1.FlatCopy()).AddSlider(new ActionConsumable<int>(this.onMasterSoundLevelChanged), elementBounds4 = elementBounds2.FlatCopy(), "mastersoundLevel").AddStaticText(Lang.Get("setting-name-soundlevel"), CairoFont.WhiteSmallishText(), elementBounds5 = elementBounds3.BelowCopy(fixedDeltaY: 25.0)).AddSlider(new ActionConsumable<int>(this.onSoundLevelChanged), elementBounds6 = elementBounds4.BelowCopy(fixedDeltaY: 46.0), "soundLevel").AddStaticText(Lang.Get("setting-name-entitysoundlevel"), CairoFont.WhiteSmallishText(), elementBounds7 = elementBounds5.BelowCopy()).AddSlider(new ActionConsumable<int>(this.onEntitySoundLevelChanged), elementBounds8 = elementBounds6.BelowCopy(fixedDeltaY: 21.0), "entitySoundLevel").AddStaticText(Lang.Get("setting-name-ambientsoundlevel"), CairoFont.WhiteSmallishText(), elementBounds9 = elementBounds7.BelowCopy()).AddSlider(new ActionConsumable<int>(this.onAmbientSoundLevelChanged), elementBounds10 = elementBounds8.BelowCopy(fixedDeltaY: 21.0), "ambientSoundLevel").AddStaticText(Lang.Get("setting-name-weathersoundlevel"), CairoFont.WhiteSmallishText(), elementBounds11 = elementBounds9.BelowCopy()).AddSlider(new ActionConsumable<int>(this.onWeatherSoundLevelChanged), elementBounds12 = elementBounds10.BelowCopy(fixedDeltaY: 21.0), "weatherSoundLevel").AddStaticText(Lang.Get("setting-name-musiclevel"), CairoFont.WhiteSmallishText(), elementBounds13 = elementBounds11.BelowCopy(fixedDeltaY: 22.0)).AddSlider(new ActionConsumable<int>(this.onMusicLevelChanged), elementBounds14 = elementBounds12.BelowCopy(fixedDeltaY: 41.0), "musicLevel").AddStaticText(Lang.Get("setting-name-musicfrequency"), CairoFont.WhiteSmallishText(), elementBounds15 = elementBounds13.BelowCopy()).AddSlider(new ActionConsumable<int>(this.onMusicFrequencyChanged), elementBounds16 = elementBounds14.BelowCopy(fixedDeltaY: 21.0), "musicFrequency").AddStaticText(Lang.Get("setting-name-hrtfmode"), CairoFont.WhiteSmallishText(), elementBounds17 = elementBounds15.BelowCopy(fixedDeltaY: 26.0)).AddHoverText(Lang.Get("setting-hover-hrtfmode"), CairoFont.WhiteSmallText(), 250, elementBounds17.FlatCopy().WithFixedHeight(30.0)).AddSwitch(new Action<bool>(this.onHRTFMode), elementBounds18 = elementBounds16.BelowCopy(fixedDeltaY: 34.0), "hrtfmode").AddStaticText(Lang.Get("setting-name-audiooutputdevice"), CairoFont.WhiteSmallishText(), elementBounds17.BelowCopy(fixedDeltaY: 5.0)).AddDropDown(strArray, names, 0, new SelectionChangedDelegate(this.onAudioDeviceChanged), elementBounds18.BelowCopy(fixedDeltaY: 16.0).WithFixedSize(300.0, 30.0), "audiooutputdevice").EndChildElements().Compose(); 1221 + this.handler.LoadComposer(this.composer); 1222 + this.composer.GetSlider("mastersoundLevel").SetValues(ClientSettings.MasterSoundLevel, 0, 100, 1, "%"); 1223 + this.composer.GetSlider("soundLevel").SetValues(ClientSettings.SoundLevel, 0, 100, 1, "%"); 1224 + this.composer.GetSlider("entitySoundLevel").SetValues(ClientSettings.EntitySoundLevel, 0, 100, 1, "%"); 1225 + this.composer.GetSlider("ambientSoundLevel").SetValues(ClientSettings.AmbientSoundLevel, 0, 100, 1, "%"); 1226 + this.composer.GetSlider("weatherSoundLevel").SetValues(ClientSettings.WeatherSoundLevel, 0, 100, 1, "%"); 1227 + this.composer.GetSlider("musicLevel").SetValues(ClientSettings.MusicLevel, 0, 100, 1, "%"); 1228 + string[] frequencies = new string[4] 1229 + { 1230 + Lang.Get("setting-musicfrequency-low"), 1231 + Lang.Get("setting-musicfrequency-medium"), 1232 + Lang.Get("setting-musicfrequency-often"), 1233 + Lang.Get("setting-musicfrequency-veryoften") 1234 + }; 1235 + this.composer.GetSlider("musicFrequency").OnSliderTooltip = (SliderTooltipDelegate) (value => frequencies[value] ?? ""); 1236 + this.composer.GetSlider("musicFrequency").SetValues(ClientSettings.MusicFrequency, 0, 3, 1); 1237 + this.composer.GetSwitch("hrtfmode").SetValue(ClientSettings.UseHRTFAudio); 1238 + this.composer.GetDropDown("audiooutputdevice").SetSelectedIndex(Math.Max(0, strArray.IndexOf<string>(ClientSettings.AudioDevice))); 1239 + } 1240 + 1241 + private void onAudioDeviceChanged(string code, bool selected) 1242 + { 1243 + ClientSettings.AudioDevice = code; 1244 + } 1245 + 1246 + private bool onMusicFrequencyChanged(int val) 1247 + { 1248 + ClientSettings.MusicFrequency = val; 1249 + return true; 1250 + } 1251 + 1252 + private bool onMasterSoundLevelChanged(int soundLevel) 1253 + { 1254 + ClientSettings.MasterSoundLevel = soundLevel; 1255 + return true; 1256 + } 1257 + 1258 + private bool onSoundLevelChanged(int soundLevel) 1259 + { 1260 + ClientSettings.SoundLevel = soundLevel; 1261 + return true; 1262 + } 1263 + 1264 + private bool onEntitySoundLevelChanged(int soundLevel) 1265 + { 1266 + ClientSettings.EntitySoundLevel = soundLevel; 1267 + return true; 1268 + } 1269 + 1270 + private bool onAmbientSoundLevelChanged(int soundLevel) 1271 + { 1272 + ClientSettings.AmbientSoundLevel = soundLevel; 1273 + return true; 1274 + } 1275 + 1276 + private bool onWeatherSoundLevelChanged(int soundLevel) 1277 + { 1278 + ClientSettings.WeatherSoundLevel = soundLevel; 1279 + return true; 1280 + } 1281 + 1282 + private bool onMusicLevelChanged(int musicLevel) 1283 + { 1284 + ClientSettings.MusicLevel = musicLevel; 1285 + return true; 1286 + } 1287 + 1288 + private void onHRTFMode(bool val) => ClientSettings.UseHRTFAudio = val; 1289 + 1290 + public static void getLanguages(out string[] languageCodes, out string[] languageNames) 1291 + { 1292 + GuiCompositeSettings.LanguageConfig[] languageConfigArray = ScreenManager.Platform.AssetManager.Get<GuiCompositeSettings.LanguageConfig[]>(new AssetLocation("lang/languages.json")); 1293 + languageCodes = new string[languageConfigArray.Length]; 1294 + languageNames = new string[languageConfigArray.Length]; 1295 + for (int index = 0; index < languageConfigArray.Length; ++index) 1296 + { 1297 + languageCodes[index] = languageConfigArray[index].Code; 1298 + languageNames[index] = $"{languageConfigArray[index].Name} / {languageConfigArray[index].Englishname}"; 1299 + } 1300 + } 1301 + 1302 + internal void OnInterfaceOptions(bool on) 1303 + { 1304 + ElementBounds bounds1 = ElementBounds.Fixed(0.0, 85.0, 475.0, 42.0); 1305 + ElementBounds bounds2 = ElementBounds.Fixed(495.0, 89.0, 200.0, 20.0); 1306 + int windowBorder = (int) ScreenManager.Platform.WindowBorder; 1307 + string language = ClientSettings.Language; 1308 + string[] languageCodes; 1309 + string[] languageNames; 1310 + GuiCompositeSettings.getLanguages(out languageCodes, out languageNames); 1311 + int selectedIndex = languageCodes.IndexOf<string>(language); 1312 + ElementBounds elementBounds1; 1313 + ElementBounds elementBounds2; 1314 + ElementBounds elementBounds3; 1315 + ElementBounds elementBounds4; 1316 + ElementBounds elementBounds5; 1317 + ElementBounds elementBounds6; 1318 + ElementBounds elementBounds7; 1319 + ElementBounds elementBounds8; 1320 + ElementBounds elementBounds9; 1321 + ElementBounds elementBounds10; 1322 + ElementBounds elementBounds11; 1323 + ElementBounds elementBounds12; 1324 + this.composer = this.ComposerHeader("gamesettings-interfaceoptions", "interface").AddStaticText(Lang.Get("setting-name-guiscale"), CairoFont.WhiteSmallishText(), bounds1).AddHoverText(Lang.Get("setting-hover-guiscale"), CairoFont.WhiteSmallText(), 250, bounds1.FlatCopy().WithFixedHeight(25.0)).AddSlider(new ActionConsumable<int>(this.onGuiScaleChanged), bounds2, "guiScaleSlider").AddStaticText(Lang.Get("setting-name-language"), CairoFont.WhiteSmallishText(), elementBounds1 = bounds1.BelowCopy(fixedDeltaY: 2.0)).AddHoverText(Lang.Get("setting-hover-language"), CairoFont.WhiteSmallText(), 250, elementBounds1.FlatCopy().WithFixedHeight(25.0)).AddDropDown(languageCodes, languageNames, selectedIndex, new SelectionChangedDelegate(this.onLanguageChanged), elementBounds2 = bounds2.BelowCopy(fixedDeltaY: 17.0).WithFixedSize(330.0, 30.0)).AddStaticText(Lang.Get("setting-name-autochat"), CairoFont.WhiteSmallishText(), elementBounds3 = elementBounds1.BelowCopy(fixedDeltaY: 1.0)).AddHoverText(Lang.Get("setting-hover-autochat"), CairoFont.WhiteSmallText(), 250, elementBounds3.FlatCopy().WithFixedHeight(25.0)).AddSwitch(new Action<bool>(this.onAutoChatChanged), elementBounds4 = elementBounds2.BelowCopy(fixedDeltaY: 15.0), "autoChatSwitch").AddStaticText(Lang.Get("setting-name-autochat-selected"), CairoFont.WhiteSmallishText(), elementBounds5 = elementBounds3.BelowCopy(fixedDeltaY: 1.0)).AddHoverText(Lang.Get("setting-hover-autochat-selected"), CairoFont.WhiteSmallText(), 250, elementBounds5.FlatCopy().WithFixedHeight(25.0)).AddSwitch(new Action<bool>(this.onAutoChatOpenSelectedChanged), elementBounds6 = elementBounds4.BelowCopy(fixedDeltaY: 15.0), "autoChatOpenSelectedSwitch").AddStaticText(Lang.Get("setting-name-blockinfohud") + this.HotkeyReminder("blockinfohud"), CairoFont.WhiteSmallishText(), elementBounds7 = elementBounds5.BelowCopy(fixedDeltaY: 2.0)).AddHoverText(Lang.Get("setting-hover-blockinfohud"), CairoFont.WhiteSmallText(), 250, elementBounds7.FlatCopy().WithFixedHeight(25.0)).AddSwitch(new Action<bool>(this.onBlockInfoHudChanged), elementBounds8 = elementBounds6.BelowCopy(fixedDeltaY: 14.0), "blockinfohudSwitch").AddStaticText(Lang.Get("setting-name-blockinteractioninfohud") + this.HotkeyReminder("blockinteractionhelp"), CairoFont.WhiteSmallishText(), elementBounds9 = elementBounds7.BelowCopy(fixedDeltaY: 2.0)).AddHoverText(Lang.Get("setting-hover-blockinteractioninfohud"), CairoFont.WhiteSmallText(), 250, elementBounds9.FlatCopy().WithFixedHeight(25.0)).AddSwitch(new Action<bool>(this.onBlockInteractionInfoHudChanged), elementBounds10 = elementBounds8.BelowCopy(fixedDeltaY: 14.0), "blockinteractioninfohudSwitch").AddStaticText(Lang.Get("setting-name-coordinatehud") + this.HotkeyReminder("coordinateshud"), CairoFont.WhiteSmallishText(), elementBounds11 = elementBounds9.BelowCopy(fixedDeltaY: 2.0)).AddHoverText(Lang.Get("setting-hover-coordinatehud"), CairoFont.WhiteSmallText(), 250, elementBounds11.FlatCopy().WithFixedHeight(25.0)).AddSwitch(new Action<bool>(this.onCoordinateHudChanged), elementBounds12 = elementBounds10.BelowCopy(fixedDeltaY: 14.0), "coordinatehudSwitch"); 1325 + if (this.composer.Api is MainMenuAPI || this.composer.Api.World.Config.GetBool("allowMap", true)) 1326 + this.composer = this.composer.AddStaticText(Lang.Get("setting-name-minimaphud") + this.HotkeyReminder("worldmaphud"), CairoFont.WhiteSmallishText(), elementBounds11 = elementBounds11.BelowCopy(fixedDeltaY: 2.0)).AddHoverText(Lang.Get("setting-hover-minimaphud"), CairoFont.WhiteSmallText(), 250, elementBounds11.FlatCopy().WithFixedHeight(25.0)).AddSwitch(new Action<bool>(this.onMinimapHudChanged), elementBounds12 = elementBounds12.BelowCopy(fixedDeltaY: 14.0), "minimaphudSwitch"); 1327 + ElementBounds elementBounds13; 1328 + ElementBounds elementBounds14; 1329 + ElementBounds elementBounds15; 1330 + ElementBounds elementBounds16; 1331 + ElementBounds elementBounds17; 1332 + ElementBounds elementBounds18; 1333 + ElementBounds elementBounds19; 1334 + ElementBounds elementBounds20; 1335 + ElementBounds elementBounds21; 1336 + ElementBounds bounds3; 1337 + this.composer = this.composer.AddStaticText(Lang.Get("setting-name-immersivemousemode"), CairoFont.WhiteSmallishText(), elementBounds13 = elementBounds11.BelowCopy(fixedDeltaY: 4.0)).AddHoverText(Lang.Get("setting-hover-immersivemousemode"), CairoFont.WhiteSmallText(), 250, elementBounds13.FlatCopy().WithFixedHeight(25.0)).AddSwitch(new Action<bool>(this.onImmersiveMouseModeChanged), elementBounds14 = elementBounds12.BelowCopy(fixedDeltaY: 17.0), "immersiveMouseModeSwitch").AddStaticText(Lang.Get("setting-name-immersivefpmode"), CairoFont.WhiteSmallishText(), elementBounds15 = elementBounds13.BelowCopy(fixedDeltaY: 5.0)).AddHoverText(Lang.Get("setting-hover-immersivefpmode"), CairoFont.WhiteSmallText(), 250, elementBounds15.FlatCopy().WithFixedHeight(25.0)).AddSwitch(new Action<bool>(this.onImmersiveFpModeChanged), elementBounds16 = elementBounds14.BelowCopy(fixedDeltaY: 17.0), "immersiveFpModeSwitch").AddStaticText(Lang.Get("setting-name-fpmodeyoffset"), CairoFont.WhiteSmallishText(), elementBounds17 = elementBounds15.BelowCopy(fixedDeltaY: 5.0)).AddHoverText(Lang.Get("setting-hover-fpmodeyoffset"), CairoFont.WhiteSmallText(), 250, elementBounds17.FlatCopy().WithFixedHeight(25.0)).AddSlider(new ActionConsumable<int>(this.onFpModeYOffsetChanged), elementBounds18 = elementBounds16.BelowCopy(fixedDeltaY: 19.0).WithFixedSize(150.0, 20.0), "fpmodeYOffsetSlider").AddStaticText(Lang.Get("setting-name-fpmodefov"), CairoFont.WhiteSmallishText(), elementBounds19 = elementBounds17.BelowCopy(fixedDeltaY: 5.0)).AddHoverText(Lang.Get("setting-hover-fpmodefov"), CairoFont.WhiteSmallText(), 250, elementBounds19.FlatCopy().WithFixedHeight(25.0)).AddSlider(new ActionConsumable<int>(this.onFpModeFoVChanged), elementBounds20 = elementBounds18.BelowCopy(fixedDeltaY: 28.0).WithFixedSize(150.0, 20.0), "fpmodefovSlider").AddStaticText(Lang.Get("setting-name-developermode"), CairoFont.WhiteSmallishText(), elementBounds21 = elementBounds19.BelowCopy(fixedDeltaY: 4.0)).AddHoverText(Lang.Get("setting-hover-developermode"), CairoFont.WhiteSmallText(), 250, bounds3 = elementBounds20.BelowCopy(fixedDeltaY: 20.0).WithFixedHeight(25.0)).AddSwitch(new Action<bool>(this.onDeveloperModeChanged), bounds3, "developerSwitch").AddRichtext(this.startupLanguage != "en" ? Lang.Get("setting-notice-lang-communitycreated") : "", CairoFont.WhiteSmallishText(), elementBounds21.BelowCopy().WithFixedMargin(0.0, 25.0).WithFixedSize(880.0, 110.0), "restartText").EndChildElements().Compose(); 1338 + this.handler.LoadComposer(this.composer); 1339 + if (ScreenManager.Platform.ScreenSize.Width > 3000) 1340 + this.composer.GetSlider("guiScaleSlider").SetValues((int) (8.0 * (double) ClientSettings.GUIScale), 4, 24, 1); 1341 + else 1342 + this.composer.GetSlider("guiScaleSlider").SetValues((int) (8.0 * (double) ClientSettings.GUIScale), 4, 16 /*0x10*/, 1); 1343 + this.composer.GetSlider("guiScaleSlider").TriggerOnlyOnMouseUp(); 1344 + this.composer.GetSlider("fpmodeYOffsetSlider").SetValues((int) ((double) ClientSettings.FpHandsYOffset * 100.0), -100, 10, 1); 1345 + this.composer.GetSlider("fpmodefovSlider").SetValues(ClientSettings.FpHandsFoV, 70, 90, 1, "°"); 1346 + this.composer.GetSwitch("immersiveMouseModeSwitch").SetValue(ClientSettings.ImmersiveMouseMode); 1347 + this.composer.GetSwitch("immersiveFpModeSwitch").SetValue(ClientSettings.ImmersiveFpMode); 1348 + this.composer.GetSwitch("autoChatSwitch").SetValue(ClientSettings.AutoChat); 1349 + this.composer.GetSwitch("autoChatOpenSelectedSwitch").SetValue(ClientSettings.AutoChatOpenSelected); 1350 + this.composer.GetSwitch("blockinfohudSwitch").SetValue(ClientSettings.ShowBlockInfoHud); 1351 + this.composer.GetSwitch("blockinteractioninfohudSwitch").SetValue(ClientSettings.ShowBlockInteractionHelp); 1352 + this.composer.GetSwitch("coordinatehudSwitch").SetValue(ClientSettings.ShowCoordinateHud); 1353 + this.composer.GetSwitch("minimaphudSwitch")?.SetValue(this.composer.Api.Settings.Bool["showMinimapHud"]); 1354 + this.composer.GetSwitch("developerSwitch").SetValue(ClientSettings.DeveloperMode); 1355 + } 1356 + 1357 + private bool onFpModeYOffsetChanged(int pos) 1358 + { 1359 + ClientSettings.FpHandsYOffset = (float) pos / 100f; 1360 + return true; 1361 + } 1362 + 1363 + private bool onFpModeFoVChanged(int pos) 1364 + { 1365 + ClientSettings.FpHandsFoV = pos; 1366 + return true; 1367 + } 1368 + 1369 + private string HotkeyReminder(string key) 1370 + { 1371 + HotKey hotKey; 1372 + return !ScreenManager.hotkeyManager.HotKeys.TryGetValue(key, out hotKey) || hotKey.CurrentMapping == null ? "" : $" ({hotKey.CurrentMapping?.ToString()})"; 1373 + } 1374 + 1375 + private void onMinimapHudChanged(bool on) 1376 + { 1377 + this.composer.Api.Settings.Bool["showMinimapHud"] = on; 1378 + } 1379 + 1380 + private void onCoordinateHudChanged(bool on) => ClientSettings.ShowCoordinateHud = on; 1381 + 1382 + private void onBlockInteractionInfoHudChanged(bool on) 1383 + { 1384 + ClientSettings.ShowBlockInteractionHelp = on; 1385 + } 1386 + 1387 + private void onBlockInfoHudChanged(bool on) => ClientSettings.ShowBlockInfoHud = on; 1388 + 1389 + private void onImmersiveMouseModeChanged(bool on) => ClientSettings.ImmersiveMouseMode = on; 1390 + 1391 + private void onImmersiveFpModeChanged(bool on) => ClientSettings.ImmersiveFpMode = on; 1392 + 1393 + private void onAutoChatChanged(bool on) => ClientSettings.AutoChat = on; 1394 + 1395 + private void onAutoChatOpenSelectedChanged(bool on) => ClientSettings.AutoChatOpenSelected = on; 1396 + 1397 + private void onLanguageChanged(string lang, bool on) 1398 + { 1399 + bool flag = false; 1400 + if (lang != ClientSettings.Language) 1401 + { 1402 + if (lang != "en") 1403 + this.composer.GetRichtext("restartText").SetNewText($"{Lang.GetL(lang, "setting-notice-restart")} {Lang.GetL(lang, "setting-notice-lang-communitycreated")}", CairoFont.WhiteSmallishText()); 1404 + else 1405 + this.composer.GetRichtext("restartText").SetNewText(Lang.GetL(lang, "setting-notice-restart"), CairoFont.WhiteSmallishText()); 1406 + flag = true; 1407 + } 1408 + if (lang == this.startupLanguage) 1409 + this.composer.GetRichtext("restartText").SetNewText(lang != "en" ? Lang.Get("setting-notice-lang-communitycreated") : "", CairoFont.WhiteSmallishText()); 1410 + ClientSettings.Language = lang; 1411 + if (lang.StartsWithOrdinal("zh-") || lang == "ar" || lang == "ja" || lang == "ko" || lang == "th") 1412 + { 1413 + if (RuntimeEnv.OS != OS.Windows) 1414 + { 1415 + if (lang != this.startupLanguage && ClientSettings.DefaultFontName == "sans-serif") 1416 + { 1417 + ClientSettings.DecorativeFontName = "sans-serif"; 1418 + this.composer.GetRichtext("restartText").SetNewText($"{Lang.GetL(this.startupLanguage, "setting-notice-restart")} {Lang.GetL(this.startupLanguage, "setting-notice-lang-communitycreated")}\n{Lang.GetL(this.startupLanguage, "setting-notice-lang-nonwindowsfonts")}", CairoFont.WhiteSmallishText()); 1419 + } 1420 + } 1421 + else 1422 + { 1423 + switch (lang) 1424 + { 1425 + case "ko": 1426 + this.SetupLocalizedFonts(lang, "Malgun Gothic", "Malgun Gothic"); 1427 + flag = true; 1428 + break; 1429 + case "th": 1430 + this.SetupLocalizedFonts(lang, "Leelawadee UI Semilight", "Leelawadee UI"); 1431 + flag = true; 1432 + break; 1433 + case "ja": 1434 + this.SetupLocalizedFonts(lang, "meiryo", "meiryo"); 1435 + flag = true; 1436 + break; 1437 + case "zh-cn": 1438 + this.SetupLocalizedFonts(lang, "Microsoft YaHei Light", "Microsoft YaHei"); 1439 + flag = true; 1440 + break; 1441 + case "zh-tw": 1442 + this.SetupLocalizedFonts(lang, "Microsoft JhengHei UI Light", "Microsoft JhengHei UI"); 1443 + flag = true; 1444 + break; 1445 + default: 1446 + ClientSettings.DecorativeFontName = "sans-serif"; 1447 + flag = true; 1448 + break; 1449 + } 1450 + } 1451 + } 1452 + else 1453 + { 1454 + if (ClientSettings.DefaultFontName == "meiryo" || ClientSettings.DefaultFontName == "Malgun Gothic" || ClientSettings.DefaultFontName == "Leelawadee UI Semilight" || ClientSettings.DefaultFontName == "Microsoft YaHei Light" || ClientSettings.DefaultFontName == "Microsoft JhengHei UI Light") 1455 + { 1456 + ClientSettings.DefaultFontName = "sans-serif"; 1457 + flag = true; 1458 + } 1459 + if (ClientSettings.DefaultFontName == "sans-serif") 1460 + { 1461 + ClientSettings.DecorativeFontName = "Lora"; 1462 + flag = true; 1463 + } 1464 + } 1465 + if (!flag) 1466 + return; 1467 + ClientSettings.Inst.Save(true); 1468 + } 1469 + 1470 + private void SetupLocalizedFonts(string lang, string baseFont, string decorativeFont) 1471 + { 1472 + ClientSettings.DefaultFontName = baseFont; 1473 + ClientSettings.DecorativeFontName = decorativeFont; 1474 + string vtmlCode = lang != this.startupLanguage ? $"{Lang.GetL(lang, "setting-notice-restart")} {Lang.GetL(lang, "setting-notice-lang-communitycreated")}" : Lang.GetL(lang, "setting-notice-lang-communitycreated"); 1475 + if (lang != this.startupLanguage) 1476 + this.composer.GetRichtext("restartText").SetNewText(vtmlCode, CairoFont.WhiteSmallishText(baseFont)); 1477 + else 1478 + this.composer.GetRichtext("restartText").SetNewText(vtmlCode, CairoFont.WhiteSmallishText(baseFont)); 1479 + } 1480 + 1481 + private void OnDeveloperOptions(bool on) 1482 + { 1483 + ElementBounds elementBounds1 = ElementBounds.Fixed(0.0, 42.0, 425.0, 42.0); 1484 + ElementBounds elementBounds2 = ElementBounds.Fixed(450.0, 45.0, 200.0, 20.0); 1485 + string[] strArray = new string[8] 1486 + { 1487 + Lang.Get("setting-hover-errorreporter"), 1488 + Lang.Get("setting-hover-extdebuginfo"), 1489 + Lang.Get("setting-hover-opengldebug"), 1490 + Lang.Get("setting-hover-openglerrorchecking"), 1491 + Lang.Get("setting-hover-debugtexturedispose"), 1492 + Lang.Get("setting-hover-debugvaodispose"), 1493 + Lang.Get("setting-hover-debugsounddispose"), 1494 + Lang.Get("setting-hover-fasterstartup") 1495 + }; 1496 + ElementBounds elementBounds3; 1497 + ElementBounds elementBounds4; 1498 + ElementBounds elementBounds5; 1499 + ElementBounds elementBounds6; 1500 + ElementBounds elementBounds7; 1501 + ElementBounds elementBounds8; 1502 + ElementBounds elementBounds9; 1503 + ElementBounds elementBounds10; 1504 + ElementBounds elementBounds11; 1505 + ElementBounds elementBounds12; 1506 + ElementBounds elementBounds13; 1507 + ElementBounds elementBounds14; 1508 + ElementBounds elementBounds15; 1509 + ElementBounds elementBounds16; 1510 + ElementBounds elementBounds17; 1511 + this.composer = this.ComposerHeader("gamesettings-developeroptions", "developer").AddStaticText(Lang.Get("setting-name-errorreporter"), CairoFont.WhiteSmallishText(), elementBounds3 = elementBounds1.BelowCopy()).AddHoverText(strArray[0], CairoFont.WhiteSmallText(), 250, elementBounds3.FlatCopy().WithFixedHeight(25.0)).AddSwitch(new Action<bool>(this.onErrorReporterChanged), elementBounds4 = elementBounds2.BelowCopy(fixedDeltaY: 16.0), "errorReporterSwitch").AddStaticText(Lang.Get("setting-name-extdebuginfo"), CairoFont.WhiteSmallishText(), elementBounds5 = elementBounds3.BelowCopy(fixedDeltaY: 4.0)).AddHoverText(strArray[1], CairoFont.WhiteSmallText(), 250, elementBounds5.FlatCopy().WithFixedHeight(25.0)).AddSwitch(new Action<bool>(this.onExtDebugInfoChanged), elementBounds6 = elementBounds4.BelowCopy(fixedDeltaY: 16.0), "extDbgInfoSwitch").AddStaticText(Lang.Get("setting-name-opengldebug"), CairoFont.WhiteSmallishText(), elementBounds7 = elementBounds5.BelowCopy(fixedDeltaY: 4.0)).AddHoverText(strArray[2], CairoFont.WhiteSmallText(), 250, elementBounds7.FlatCopy().WithFixedHeight(25.0)).AddSwitch(new Action<bool>(this.onOpenGLDebugChanged), elementBounds8 = elementBounds6.BelowCopy(fixedDeltaY: 16.0), "openglDebugSwitch").AddStaticText(Lang.Get("setting-name-openglerrorchecking"), CairoFont.WhiteSmallishText(), elementBounds9 = elementBounds7.BelowCopy(fixedDeltaY: 4.0)).AddHoverText(strArray[3], CairoFont.WhiteSmallText(), 250, elementBounds9.FlatCopy().WithFixedHeight(25.0)).AddSwitch(new Action<bool>(this.onOpenGLErrorCheckingChanged), elementBounds10 = elementBounds8.BelowCopy(fixedDeltaY: 16.0), "openglErrorCheckingSwitch").AddStaticText(Lang.Get("setting-name-debugtexturedispose"), CairoFont.WhiteSmallishText(), elementBounds11 = elementBounds9.BelowCopy(fixedDeltaY: 4.0)).AddHoverText(strArray[4], CairoFont.WhiteSmallText(), 250, elementBounds11.FlatCopy().WithFixedHeight(25.0)).AddSwitch(new Action<bool>(this.onDebugTextureDisposeChanged), elementBounds12 = elementBounds10.BelowCopy(fixedDeltaY: 16.0), "debugTextureDisposeSwitch").AddStaticText(Lang.Get("setting-name-debugvaodispose"), CairoFont.WhiteSmallishText(), elementBounds13 = elementBounds11.BelowCopy(fixedDeltaY: 4.0)).AddHoverText(strArray[5], CairoFont.WhiteSmallText(), 250, elementBounds13.FlatCopy().WithFixedHeight(25.0)).AddSwitch(new Action<bool>(this.onDebugVaoDisposeChanged), elementBounds14 = elementBounds12.BelowCopy(fixedDeltaY: 16.0), "debugVaoDisposeSwitch").AddStaticText(Lang.Get("setting-name-debugsounddispose"), CairoFont.WhiteSmallishText(), elementBounds15 = elementBounds13.BelowCopy(fixedDeltaY: 4.0)).AddHoverText(strArray[6], CairoFont.WhiteSmallText(), 250, elementBounds15.FlatCopy().WithFixedHeight(25.0)).AddSwitch(new Action<bool>(this.onDebugSoundDisposeChanged), elementBounds16 = elementBounds14.BelowCopy(fixedDeltaY: 16.0), "debugSoundDisposeSwitch").AddStaticText(Lang.Get("setting-name-fasterstartup"), CairoFont.WhiteSmallishText(), elementBounds17 = elementBounds15.BelowCopy(fixedDeltaY: 4.0)).AddHoverText(strArray[7], CairoFont.WhiteSmallText(), 250, elementBounds17.FlatCopy().WithFixedHeight(25.0)).AddSwitch(new Action<bool>(this.onFasterStartupChanged), elementBounds16.BelowCopy(fixedDeltaY: 16.0), "fasterStartupSwitch").EndChildElements().Compose(); 1512 + this.handler.LoadComposer(this.composer); 1513 + this.composer.GetSwitch("errorReporterSwitch").SetValue(ClientSettings.StartupErrorDialog); 1514 + this.composer.GetSwitch("extDbgInfoSwitch").SetValue(ClientSettings.ExtendedDebugInfo); 1515 + this.composer.GetSwitch("openglDebugSwitch").SetValue(ClientSettings.GlDebugMode); 1516 + this.composer.GetSwitch("openglErrorCheckingSwitch").SetValue(ClientSettings.GlErrorChecking); 1517 + this.composer.GetSwitch("debugTextureDisposeSwitch").SetValue(RuntimeEnv.DebugTextureDispose); 1518 + this.composer.GetSwitch("debugVaoDisposeSwitch").SetValue(RuntimeEnv.DebugVAODispose); 1519 + this.composer.GetSwitch("debugSoundDisposeSwitch").SetValue(RuntimeEnv.DebugSoundDispose); 1520 + this.composer.GetSwitch("fasterStartupSwitch").SetValue(ClientSettings.OffThreadMipMapCreation); 1521 + } 1522 + 1523 + private void onErrorReporterChanged(bool on) => ClientSettings.StartupErrorDialog = on; 1524 + 1525 + private void onDebugSoundDisposeChanged(bool on) => RuntimeEnv.DebugSoundDispose = on; 1526 + 1527 + private void onDebugVaoDisposeChanged(bool on) => RuntimeEnv.DebugVAODispose = on; 1528 + 1529 + private void onDebugTextureDisposeChanged(bool on) => RuntimeEnv.DebugTextureDispose = on; 1530 + 1531 + private void onOpenGLDebugChanged(bool on) 1532 + { 1533 + ClientSettings.GlDebugMode = on; 1534 + ScreenManager.Platform.GlDebugMode = on; 1535 + } 1536 + 1537 + private void onOpenGLErrorCheckingChanged(bool on) 1538 + { 1539 + ClientSettings.GlErrorChecking = on; 1540 + ScreenManager.Platform.GlErrorChecking = on; 1541 + } 1542 + 1543 + private void onExtDebugInfoChanged(bool on) => ClientSettings.ExtendedDebugInfo = on; 1544 + 1545 + private void onFasterStartupChanged(bool on) => ClientSettings.OffThreadMipMapCreation = on; 1546 + 1547 + private void onDeveloperModeChanged(bool on) 1548 + { 1549 + if (!on) 1550 + { 1551 + ClientSettings.DeveloperMode = on; 1552 + ClientSettings.StartupErrorDialog = false; 1553 + ClientSettings.ExtendedDebugInfo = false; 1554 + ClientSettings.GlDebugMode = false; 1555 + ClientSettings.GlErrorChecking = false; 1556 + RuntimeEnv.DebugTextureDispose = false; 1557 + RuntimeEnv.DebugVAODispose = false; 1558 + RuntimeEnv.DebugSoundDispose = false; 1559 + this.OnInterfaceOptions(true); 1560 + } 1561 + else 1562 + { 1563 + this.composer = this.ComposerHeader("gamesettings-confirmdevelopermode", "developer").AddStaticText(Lang.Get("Please Confirm"), CairoFont.WhiteSmallishText(), ElementStdBounds.Rowed(1.5f, 0.0, EnumDialogArea.LeftFixed).WithFixedWidth(600.0)).AddStaticText(Lang.Get("confirmEnableDevMode"), CairoFont.WhiteSmallishText(), ElementStdBounds.Rowed(2f, 0.0, EnumDialogArea.LeftFixed).WithFixedSize(600.0, 100.0)).AddButton(Lang.Get("Cancel"), new ActionConsumable(this.OnCancelDevMode), ElementStdBounds.Rowed(3.7f, 0.0, EnumDialogArea.LeftFixed).WithFixedPadding(10.0, 2.0)).AddButton(Lang.Get("Confirm"), new ActionConsumable(this.OnConfirmDevMode), ElementStdBounds.Rowed(3.7f, 0.0, EnumDialogArea.RightFixed).WithFixedPadding(10.0, 2.0)).EndChildElements().Compose(); 1564 + this.handler.LoadComposer(this.composer); 1565 + } 1566 + } 1567 + 1568 + private bool OnCancelDevMode() 1569 + { 1570 + this.OnInterfaceOptions(true); 1571 + return true; 1572 + } 1573 + 1574 + private bool OnConfirmDevMode() 1575 + { 1576 + ClientSettings.DeveloperMode = true; 1577 + this.OnDeveloperOptions(true); 1578 + return true; 1579 + } 1580 + 1581 + public class LanguageConfig 1582 + { 1583 + public string Code; 1584 + public string Englishname; 1585 + public string Name; 1586 + } 1587 + }