#region Copyright & License Information /* * Copyright 2007-2021 The OpenRA Developers (see AUTHORS) * This file is part of OpenRA, which is free software. It is made * available to you under the terms of the GNU General Public License * as published by the Free Software Foundation, either version 3 of * the License, or (at your option) any later version. For more * information, see COPYING. */ #endregion using System; using OpenRA.Widgets; namespace OpenRA.Mods.Common.Widgets.Logic { public class AdvancedSettingsLogic : ChromeLogic { static readonly bool OriginalServerDiscoverNatDevices; static AdvancedSettingsLogic() { var original = Game.Settings; OriginalServerDiscoverNatDevices = original.Server.DiscoverNatDevices; } [ObjectCreator.UseCtor] public AdvancedSettingsLogic(Action>, Func> registerPanel, string panelID, string label) { registerPanel(panelID, label, InitPanel, ResetPanel); } Func InitPanel(Widget panel) { var ds = Game.Settings.Debug; var ss = Game.Settings.Server; var gs = Game.Settings.Game; // Advanced SettingsUtils.BindCheckboxPref(panel, "NAT_DISCOVERY", ss, "DiscoverNatDevices"); SettingsUtils.BindCheckboxPref(panel, "PERFTEXT_CHECKBOX", ds, "PerfText"); SettingsUtils.BindCheckboxPref(panel, "PERFGRAPH_CHECKBOX", ds, "PerfGraph"); SettingsUtils.BindCheckboxPref(panel, "FETCH_NEWS_CHECKBOX", gs, "FetchNews"); SettingsUtils.BindCheckboxPref(panel, "SENDSYSINFO_CHECKBOX", ds, "SendSystemInformation"); SettingsUtils.BindCheckboxPref(panel, "CHECK_VERSION_CHECKBOX", ds, "CheckVersion"); var ssi = panel.Get("SENDSYSINFO_CHECKBOX"); ssi.IsDisabled = () => !gs.FetchNews; // Developer SettingsUtils.BindCheckboxPref(panel, "BOTDEBUG_CHECKBOX", ds, "BotDebug"); SettingsUtils.BindCheckboxPref(panel, "LUADEBUG_CHECKBOX", ds, "LuaDebug"); SettingsUtils.BindCheckboxPref(panel, "REPLAY_COMMANDS_CHECKBOX", ds, "EnableDebugCommandsInReplays"); SettingsUtils.BindCheckboxPref(panel, "CHECKUNSYNCED_CHECKBOX", ds, "SyncCheckUnsyncedCode"); SettingsUtils.BindCheckboxPref(panel, "CHECKBOTSYNC_CHECKBOX", ds, "SyncCheckBotModuleCode"); panel.Get("DEBUG_OPTIONS").IsVisible = () => ds.DisplayDeveloperSettings; panel.Get("DEBUG_HIDDEN_LABEL").IsVisible = () => !ds.DisplayDeveloperSettings; return () => ss.DiscoverNatDevices != OriginalServerDiscoverNatDevices; } Action ResetPanel(Widget panel) { var ds = Game.Settings.Debug; var ss = Game.Settings.Server; var dds = new DebugSettings(); var dss = new ServerSettings(); return () => { ss.DiscoverNatDevices = dss.DiscoverNatDevices; ds.PerfText = dds.PerfText; ds.PerfGraph = dds.PerfGraph; ds.SyncCheckUnsyncedCode = dds.SyncCheckUnsyncedCode; ds.SyncCheckBotModuleCode = dds.SyncCheckBotModuleCode; ds.BotDebug = dds.BotDebug; ds.LuaDebug = dds.LuaDebug; ds.SendSystemInformation = dds.SendSystemInformation; ds.CheckVersion = dds.CheckVersion; ds.EnableDebugCommandsInReplays = dds.EnableDebugCommandsInReplays; }; } } }