public void OnSettingsUI(UIHelperBase helper)
        {
            var uIHelperBase = helper.AddGroup("Network Extensions Options");
            var optionsChanged = false;

            foreach (var part in ActivableParts)
            {
                var partLocal = part;
                var partName = part.GetSerializableName();

                if (!Options.Instance.PartsEnabled.ContainsKey(partName))
                {
                    Options.Instance.PartsEnabled[partName] = true;
                    optionsChanged = true;
                }

                uIHelperBase.AddCheckbox(
                    part.DisplayName, 
                    Options.Instance.PartsEnabled[partName], 
                    isChecked =>
                    {
                        Options.Instance.PartsEnabled[partName] = partLocal.IsEnabled = isChecked;
                        Options.Instance.Save();
                    });
            }

            if (optionsChanged)
            {
                Options.Instance.Save();
            }
        }
Exemple #2
0
        public void OnSettingsUI(UIHelperBase helper)
        {
            if (sm_optionsManager == null)
                sm_optionsManager = new GameObject("OptionsManager").AddComponent<OptionsManager>();

            sm_optionsManager.CreateSettings(helper);
        }
		public static void makeSettings(UIHelperBase helper) {
			UIHelperBase group = helper.AddGroup("Traffic Manager: President Edition (Settings are defined for each savegame separately)");
			simAccuracyDropdown = group.AddDropdown("Simulation accuracy (higher accuracy reduces performance):", new string[] { "Very high", "High", "Medium", "Low", "Very Low" }, simAccuracy, onSimAccuracyChanged) as UIDropDown;
			recklessDriversDropdown = group.AddDropdown("Reckless driving (BETA feature):", new string[] { "Path Of Evil (10 %)", "Rush Hour (5 %)", "Minor Complaints (2 %)", "Holy City (0 %)" }, recklessDrivers, onRecklessDriversChanged) as UIDropDown;
			relaxedBussesToggle = group.AddCheckbox("Busses may ignore lane arrows", relaxedBusses, onRelaxedBussesChanged) as UICheckBox;
#if DEBUG
			allRelaxedToggle = group.AddCheckbox("All vehicles may ignore lane arrows", allRelaxed, onAllRelaxedChanged) as UICheckBox;
#endif
			mayEnterBlockedJunctionsToggle = group.AddCheckbox("Vehicles may enter blocked junctions", mayEnterBlockedJunctions, onMayEnterBlockedJunctionsChanged) as UICheckBox;
			UIHelperBase groupAI = helper.AddGroup("Advanced Vehicle AI");
			advancedAIToggle = groupAI.AddCheckbox("Enable Advanced Vehicle AI", advancedAI, onAdvancedAIChanged) as UICheckBox;
			highwayRulesToggle = groupAI.AddCheckbox("Enable highway specific lane merging/splitting rules", highwayRules, onHighwayRulesChanged) as UICheckBox;
			laneChangingRandomizationDropdown = groupAI.AddDropdown("Drivers want to change lanes (only applied if Advanced AI is enabled):", new string[] { "Very often (50 %)", "Often (25 %)", "Sometimes (10 %)", "Rarely (5 %)", "Very rarely (2.5 %)", "Only if necessary" }, laneChangingRandomization, onLaneChangingRandomizationChanged) as UIDropDown;
//#if DEBUG
			UIHelperBase senseAI = helper.AddGroup("Avoidance of lanes with high traffic density (low - high)");
			carCityTrafficSensitivitySlider = senseAI.AddSlider("Cars, city:", 0f, 1f, 0.05f, carCityTrafficSensitivity, onCarCityTrafficSensitivityChange) as UISlider;
			carHighwayTrafficSensitivitySlider = senseAI.AddSlider("Cars, highway:", 0f, 1f, 0.05f, carHighwayTrafficSensitivity, onCarHighwayTrafficSensitivityChange) as UISlider;
			truckCityTrafficSensitivitySlider = senseAI.AddSlider("Trucks, city:", 0f, 1f, 0.05f, truckCityTrafficSensitivity, onTruckCityTrafficSensitivityChange) as UISlider;
			truckHighwayTrafficSensitivitySlider = senseAI.AddSlider("Trucks, highway:", 0f, 1f, 0.05f, truckHighwayTrafficSensitivity, onTruckHighwayTrafficSensitivityChange) as UISlider;
//#endif
			UIHelperBase group2 = helper.AddGroup("Maintenance");
			group2.AddButton("Forget toggled traffic lights", onClickForgetToggledLights);
			nodesOverlayToggle = group2.AddCheckbox("Show nodes and segments", nodesOverlay, onNodesOverlayChanged) as UICheckBox;
			showLanesToggle = group2.AddCheckbox("Show lanes", showLanes, onShowLanesChanged) as UICheckBox;
#if DEBUG
			pathCostMultiplicatorField = group2.AddTextfield("Pathcost multiplicator", String.Format("{0:0.##}", pathCostMultiplicator), onPathCostMultiplicatorChanged) as UITextField;
#endif
		}
Exemple #4
0
        public void OnSettingsUI(UIHelperBase helper)
        {
            var group = helper.AddGroup("MoreFlags");
            var defaultIndex = 0;
            if (OptionsHolder.Options.replacement != string.Empty)
            {
                for (var i = 0; i < LoadingExtension.Flags.Count; i++)
                {
                    var flag = LoadingExtension.Flags[i];
                    if (!flag.id.Equals(OptionsHolder.Options.replacement))
                    {
                        continue;
                    }
                    defaultIndex = i + 1;
                    break;
                }
                if (defaultIndex == 0)
                {
                    OptionsHolder.Options.replacement = string.Empty;
                    OptionsLoader.SaveOptions();
                }
            }

            group.AddDropdown("Replace stock Flags with",
                new[] { "-----" }.Concat(LoadingExtension.Flags.Select(flag => flag.description)).ToArray(), defaultIndex, sel =>
                 {
                     OptionsHolder.Options.replacement = sel == 0 ? string.Empty : LoadingExtension.Flags[sel - 1].id;
                     OptionsLoader.SaveOptions();
                 });
        }
        public void OnSettingsUI(UIHelperBase helper)
        {
            var uIHelperBase = helper.AddGroup("Network Extensions Options");
            var optionsChanged = false;

            foreach (var part in Parts.OrderBy(p => p.OptionsPriority))
            {
                var partLocal = part;
                var partName = part.GetSerializableName();

                if (!Options.Instance.PartsEnabled.ContainsKey(partName))
                {
                    Options.Instance.PartsEnabled[partName] = true;
                    optionsChanged = true;
                }

                uIHelperBase.AddCheckbox(
                    part.DisplayName, 
                    Options.Instance.PartsEnabled[partName], 
                    isChecked =>
                    {
                        Options.Instance.PartsEnabled[partName] = partLocal.IsEnabled = isChecked;
                        Options.Instance.Save();

                        s_netInfoBuilders = null;
                        s_netInfoModifiers = null;
                    });
            }

            if (optionsChanged)
            {
                Options.Instance.Save();
            }
        }
        public void OnSettingsUI(UIHelperBase helper)
        {
            var tabTemplate = Resources
                .FindObjectsOfTypeAll<UITabstrip>()[0]
                .GetComponentInChildren<UIButton>();

            _optionsPanel = ((UIHelper)helper).self as UIScrollablePanel;
            _optionsPanel.autoLayout = false;

            UITabstrip strip = _optionsPanel.AddUIComponent<UITabstrip>();
            strip.relativePosition = new Vector3(0, 0);
            strip.size = new Vector2(744, 40);

            UITabContainer container = _optionsPanel.AddUIComponent<UITabContainer>();
            container.relativePosition = new Vector3(0, 40);
            container.size = new Vector3(744, 713);
            strip.tabPages = container;

            int tabIndex = 0;
            foreach (IModule module in Modules)
            {
                strip.AddTab(module.Name, tabTemplate, true);
                strip.selectedIndex = tabIndex;

                // Get the current container and use the UIHelper to have something in there
                UIPanel stripRoot = strip.tabContainer.components[tabIndex++] as UIPanel;
                stripRoot.autoLayout = true;
                stripRoot.autoLayoutDirection = LayoutDirection.Vertical;
                stripRoot.autoLayoutPadding.top = 5;
                stripRoot.autoLayoutPadding.left = 10;
                UIHelper stripHelper = new UIHelper(stripRoot);
                
                module.OnSettingsUI(stripHelper);
            }
        }
        public void OnSettingsUI(UIHelperBase helper)
        {
            if (m_optionsManager == null)
            {
                m_optionsManager = new GameObject("RoadNamerOptions").AddComponent<OptionsManager>();
            }

            OptionsManager.LoadOptions();
            m_optionsManager.CreateOptions(helper);
        }
Exemple #8
0
        public void OnSettingsUI(UIHelperBase helper)
        {
            var group = helper.AddGroup("Prop Remover Options");
            var properties = typeof (Options).GetProperties();
            foreach (var name in from property in properties select property.Name)
            {
                var description = OptionsHolder.Options.GetPropertyDescription(name);
                group.AddCheckbox(description, name);

            }
        }
        public void OnSettingsUI(UIHelperBase helper)
        {
            UIHelperBase group = helper.AddGroup("Building Themes");
            group.AddCheckbox("Unlock Policies Panel From Start", PolicyPanelEnabler.Unlock, delegate(bool c) { PolicyPanelEnabler.Unlock = c; });
            group.AddCheckbox("Enable Prefab Cloning (experimental, not stable!)", BuildingVariationManager.Enabled, delegate(bool c) { BuildingVariationManager.Enabled = c; });
            group.AddGroup("Warning: When you disable this option, spawned clones will disappear!");

            group.AddCheckbox("Warning message when selecting an invalid theme", UIThemePolicyItem.showWarning, delegate(bool c) { UIThemePolicyItem.showWarning = c; });
            group.AddCheckbox("Generate Debug Output", Debugger.Enabled, delegate(bool c) { Debugger.Enabled = c; });

        }
        public void OnSettingsUI(UIHelperBase helper)
        {
            // Quick fix for REx
            foreach (IModule module in Modules)
                module.OnSettingsUI(helper);
            // End of quick fix for REx

            //System.IO.File.AppendAllText("version.txt", "OnSettingsUI\n");
            //OnSaveSettings();
            //OnLoadSettings();
        }
Exemple #11
0
 public void OnSettingsUI(UIHelperBase helper)
 {
     UIHelper uiHelper = helper as UIHelper;
     if (uiHelper != null)
     {
         var optionsPanel = new UIModOptionsPanelBuilder(uiHelper, _configuration);
         optionsPanel.CreateUI();
         ModLogger.Debug("Options panel created");
     }
     else
         ModLogger.Warning("Could not populate the settings panel, helper is null or not a UIHelper");
 }
 public void initialize(UIHelperBase helper)
 {
     Logger.logInfo(Logger.LOG_OPTIONS, "OptionsManager.initialize -- Initializing Menu Options");
     UIHelperBase group = helper.AddGroup("Nursing Home Settings");
     this.capacityDropDown = (UIDropDown) group.AddDropdown("Capacity Modifier", CAPACITY_LABELS, 1, handleCapacityChange);
     this.incomeDropDown = (UIDropDown) group.AddDropdown("Income Modifier", INCOME_LABELS, 2, handleIncomeChange);
     group.AddSpace(5);
     this.hideTabCheckBox = (UICheckBox) group.AddCheckbox("Hide Strange Healthcare Tab (Requires reload from Main Menu)", hideTab, handleHideTabChange);
     group.AddSpace(5);
     group.AddButton("Save", saveOptions);
     //group.AddSlider("Capacity Modifier", 0.5f, 5.0f, 0.5f, 1.0f, handleCapacityChange);
 }
 /// <summary>
 /// Logs the UI helper group.
 /// </summary>
 /// <param name="source">The source.</param>
 /// <param name="block">The block.</param>
 /// <param name="group">The group.</param>
 /// <param name="componentName">Name of the component.</param>
 /// <param name="connectedName">Name of the connected component.</param>
 public static void LogGroup(object source, string block, UIHelperBase group, string componentName = null, string connectedName = null)
 {
     try
     {
         if (group != null && group is UIHelper)
         {
             LogComponent(source, block, group.Component(), componentName, connectedName, 0);
         }
     }
     catch (Exception ex)
     {
         Log.Debug(source, block, connectedName, componentName, ex.GetType(), ex.Message);
     }
 }
        public void OnSettingsUI(UIHelperBase helper)
        {
            UIHelperBase group = helper.AddGroup("ARUT Settings");

            group.AddGroup("ARUT Options");

            cbDelete = (UICheckBox)group.AddCheckbox("Delete panel", us.ShowDelete, ShowDelete_Checked);
            cbDelete.tooltip = "Toggle to show or hide Delete panel";

            cbUpdate = (UICheckBox)group.AddCheckbox("Update panel", us.ShowUpdate, ShowUpdate_Checked);
            cbUpdate.tooltip = "Toggle to show or hide Update panel";

            cbTerrain = (UICheckBox)group.AddCheckbox("Terrain panel", us.ShowTerrain, ShowTerrain_Checked);
            cbTerrain.tooltip = "Toggle to show or hide Terrain panel";

            cbServices = (UICheckBox)group.AddCheckbox("Services panel", us.ShowServices, ShowServices_Checked);
            cbServices.tooltip = "Toggle to show or hide Services panel";

            cbDistricts = (UICheckBox)group.AddCheckbox("Districts panel", us.ShowDistricts, ShowDistricts_Checked);
            cbDistricts.tooltip = "Toggle to show or hide Districts panel";

            cbChirper = (UICheckBox)group.AddCheckbox("Chirper panel ", us.Chirper, ShowChirper_Checked);
            cbChirper.tooltip = "Toggle to show or hide Chirper panel";

            cbAllRoads = (UICheckBox)group.AddCheckbox("All Roads Enabled", us.AllRoads, AllRoadsEnabled_Checked);
            cbAllRoads.tooltip = "Check to enable all road types.";

            cbAutoDistroy = (UICheckBox)group.AddCheckbox("Enable Auto Distroy", us.AutoDistroy, AutoDistroy_Checked);
            cbAutoDistroy.tooltip = "Check to enable Auto Distroy.";

            //set up the Max Area
            cbMaxAreas = (UICheckBox)group.AddCheckbox("Adjust Max Areas", us.AdjustAreas, AdjustAreas_Checked);
            cbMaxAreas.tooltip = " Check to adjust Games Max Areas.";
            slMaxArea = (UISlider)group.AddSlider("Max Areas (1 - 25)", 1, 25, 1f, us.MaxAreas, MaxArea_Changed);
            tfMaxArea = (UITextField)group.AddTextfield("Max Areas", us.MaxAreas.ToString(), MaxAreas_Changed);
            tfMaxArea.readOnly = true;
            tfMaxArea.width = 100;
            slMaxArea.enabled = cbMaxAreas.isChecked;
            tfMaxArea.enabled = cbMaxAreas.isChecked;

            //Set up Start Money
            cbStartMoney = (UICheckBox)group.AddCheckbox("Adjust Start up Money", us.AdjustMoney, AdjustMoney_Checked);
            cbStartMoney.tooltip = " Check to adjust new Games Start up money.";
            slStartMoney = (UISlider)group.AddSlider("Start up Amount", 100000, 750000, 50000, (int)us.StartMoney, StartMoney_Changed);
            tfStartMoney = (UITextField)group.AddTextfield("Start amount", us.StartMoney.ToString(), StartMoneys_Changed);
            tfStartMoney.readOnly = true;
            slStartMoney.enabled = cbStartMoney.isChecked;
            tfStartMoney.enabled = cbStartMoney.isChecked;
        }
 public void OnSettingsUI(UIHelperBase helper)
 {
     var group = helper.AddGroup("Maintenance fees\n\r0 - 100%, 10% steps");
     group.AddSlider("Educations:", 0, 1, 0.1f, vars.datam.education, EduSlide);
     group.AddSlider("Electricity:", 0, 1, 0.1f, vars.datam.electricity, EleSlide);
     group.AddSlider("Fire Department:", 0, 1, 0.1f, vars.datam.fire, FireSlide);
     group.AddSlider("Garbage:", 0, 1, 0.1f, vars.datam.garbage, GarbSlide);
     group.AddSlider("Healthcare:", 0, 1, 0.1f, vars.datam.health, HealthSlide);
     group.AddSlider("Public Transport:", 0, 1, 0.1f, vars.datam.transport, TransportSlide);
     group.AddSlider("Police Department:", 0, 1, 0.1f, vars.datam.police, PoliceSlide);
     group.AddSlider("Roads:", 0, 1, 0.1f, vars.datam.road, RoadSlide);
     group.AddSlider("Water:", 0, 1, 0.1f, vars.datam.water, WaterSlide);
     group.AddSlider("Beautification:", 0, 1, 0.1f, vars.datam.beauty, BeautySlide);
     group.AddSlider("Monuments:", 0, 1, 0.1f, vars.datam.monument, MonumentSlide);
     group.AddButton("Save", Save);
 }
        public void CreateSettings(UIHelperBase helper)
        {
            UIHelperBase group = helper.AddGroup("Traffic++ Options");
            m_allowTrucksCheckBox = group.AddCheckbox("Allow Trucks in Pedestrian Roads", false, IgnoreMe) as UICheckBox;
            m_allowResidentsCheckBox = group.AddCheckbox("Allow Residents in Pedestrian Roads", false, IgnoreMe) as UICheckBox;
            m_disableCentralLaneCheckBox = group.AddCheckbox("Disable Central Lane on Pedestrian Roads", false, IgnoreMe) as UICheckBox;
            m_noDespawnCheckBox = group.AddCheckbox("No Despawn by CBeTHaX", false, IgnoreMe) as UICheckBox;
            m_realisticSpeedsCheckBox = group.AddCheckbox("Beta Test: Realistic Speeds", false, IgnoreMe) as UICheckBox;
            m_betaTestRoadCustomizerCheckBox = group.AddCheckbox("Beta Test: Road Customizer Tool", false, IgnoreMe) as UICheckBox;
            m_improvedAICheckBox = group.AddCheckbox("Beta Test: Improved AI", false, IgnoreMe) as UICheckBox;
            m_ghostModeCheckBox = group.AddCheckbox("Ghost Mode (disables all mod functionality leaving only enough logic to load the map)", false, IgnoreMe) as UICheckBox;

            group.AddButton("Save", OnSave);

            LoadOptions();
        }
        public void OnSettingsUI(UIHelperBase helper)
        {
            helper.AddDropdown(
                "Tourism income",
                PTM_Options.TourismIncomeMultipliersStr,
                PTM_Options.Instance.GetTourismIncomeMultiplierIndex(),
                TourismIncomeMultiplierOnSelected
                );

            helper.AddDropdown(
                "Taxi income",
                PTM_Options.TaxiIncomeMultipliersStr,
                PTM_Options.Instance.GetTaxiIncomeMultiplierIndex(),
                TaxiIncomeMultiplierOnSelected
                );
        }
        public void OnSettingsUI(UIHelperBase helper)
        {
            Config = Configuration.Instance;
            Config.FlushStagedChanges(); //make sure no prior changes are still around
            //Generate arrays of colors and naming strategies
            String[] ColorStrategies = Enum.GetNames(typeof(ColorStrategy));
            String[] NamingStrategies = Enum.GetNames(typeof(NamingStrategy));
            UIHelperBase group = helper.AddGroup(Constants.ModName);
            group.AddDropdown("Color Strategy", ColorStrategies, (int)Config.ColorStrategy, Config.ColorStrategyChange);
            group.AddDropdown("Naming Strategy", NamingStrategies, (int)Config.NamingStrategy, Config.NamingStrategyChange);
            group.AddSpace(5);

            group.AddGroup("Advanced Settings");
            group.AddSlider("Max Different Color Picks", 1f, 20f, 1f, (float)Config.MaxDiffColorPickAttempt, Config.MaxDiffColorPickChange);
            group.AddSlider("MinColorDifference", 1f, 100f, 5f, (float)Config.MinColorDiffPercentage, Config.MinColorDiffChange);
            group.AddCheckbox("Debug", logger.debug, logger.SetDebug);
            group.AddButton("Save", Config.Save);
        }
        public virtual void OnSettingsUI(UIHelperBase helper)
        {
            foreach (var part in Parts.OfType<IActivablePart>())
            {
                var partLocal = part;

                helper.AddCheckbox(
                    part.DisplayName,
                    part is IShortDescriptor ? ((IShortDescriptor)part).ShortDescription :
                    part is IDescriptor ? ((IDescriptor)part).Description :
                    null,
                    part.IsEnabled,
                    isChecked =>
                    {
                        partLocal.IsEnabled = isChecked;
                        FireSaveSettingsNeeded();
                    },
                    true);
            }
        }
 public override void OnSettingsUI(UIHelperBase helper)
 {
     helper.AddCheckbox(
         "Road Zone Modifier",
         "Press SHIFT (or SHIFT+CTRL) on the Upgrade Road tool to use",
         s_activeOptions.IsFlagSet(ModOptions.RoadZoneModifier), 
         isChecked =>
         {
             if (isChecked)
             {
                 s_activeOptions = s_activeOptions | ModOptions.RoadZoneModifier;
             }
             else
             {
                 s_activeOptions = s_activeOptions & ~ModOptions.RoadZoneModifier;
             }
             FireSaveSettingsNeeded();
         },
         true);
 }
 public override void OnSettingsUI(UIHelperBase helper)
 {
     base.OnSettingsUI(helper);
     
     helper.AddCheckbox(
         "Congestion Avoidance", 
         "Vehicles will actively avoid congestions",
         s_activeOptions.IsFlagSet(Options.CongestionAvoidance),
         isChecked =>
         {
             if (isChecked)
             {
                 s_activeOptions = s_activeOptions | Options.CongestionAvoidance;
             }
             else
             {
                 s_activeOptions = s_activeOptions & ~Options.CongestionAvoidance;
             }
             FireSaveSettingsNeeded();
         },
         true);
 } 
 public void OnSettingsUI(UIHelperBase helper)
 {
     this.optionsManager.initialize(helper);
     this.optionsManager.loadOptions();
 }
 public void OnSettingsUI(UIHelperBase helper)
 {
     helper.AddOptionsGroup<Options>(s => translation.GetTranslation(s));
 }
        /// <summary>
        /// Creates the service group.
        /// </summary>
        /// <param name="helper">The helper.</param>
        /// <param name="settings">The settings.</param>
        /// <param name="dispatcher">The dispatcher.</param>
        /// <param name="canService">If set to <c>true</c> this service can be enabled.</param>
        /// <returns>
        /// The group.
        /// </returns>
        private UIHelperBase CreateServiceGroup(UIHelperBase helper, Settings.StandardServiceSettings settings, Dispatcher dispatcher, bool canService)
        {
            try
            {
                UIHelperBase group = helper.AddGroup(settings.VehicleNamePlural);

                if (canService)
                {
                    group.AddCheckbox(
                        "Dispatch " + settings.VehicleNamePlural.ToLower(),
                        settings.DispatchVehicles,
                        value =>
                        {
                            try
                            {
                                if (settings.DispatchVehicles != value)
                                {
                                    settings.DispatchVehicles = value;
                                    Global.Settings.Save();
                                    Global.ReInitializeHandlers();
                                }
                            }
                            catch (Exception ex)
                            {
                                Log.Error(this, "CreateServiceGroup", ex, settings.VehicleNamePlural, "DispatchVehicles", value);
                            }
                        });
                }
                else
                {
                    UIComponent checkBox = group.AddCheckbox(
                        "Dispatch " + settings.VehicleNamePlural.ToLower(),
                        false,
                        value =>
                        {
                        }) as UIComponent;
                }

                group.AddCheckbox(
                    "Dispatch by district",
                    settings.DispatchByDistrict,
                    value =>
                    {
                        try
                        {
                            if (settings.DispatchByDistrict != value)
                            {
                                settings.DispatchByDistrict = value;
                                Global.BuildingUpdateNeeded = true;
                                Global.Settings.Save();
                            }
                        }
                        catch (Exception ex)
                        {
                            Log.Error(this, "CreateServiceGroup", ex, settings.VehicleNamePlural, "DispatchByDistrict", value);
                        }
                    });

                group.AddCheckbox(
                    "Dispatch by building range",
                    settings.DispatchByRange,
                    value =>
                    {
                        try
                        {
                            if (settings.DispatchByRange != value)
                            {
                                settings.DispatchByRange = value;
                                Global.BuildingUpdateNeeded = true;
                                Global.Settings.Save();
                            }
                        }
                        catch (Exception ex)
                        {
                            Log.Error(this, "CreateServiceGroup", ex, settings.VehicleNamePlural, "DispatchByRange", value);
                        }
                    });

                if (settings.CanRemoveFromGrid)
                {
                    group.AddCheckbox(
                        "Pass through " + settings.VehicleNamePlural.ToLower(),
                        settings.RemoveFromGrid,
                        value =>
                        {
                            try
                            {
                                if (settings.RemoveFromGrid != value)
                                {
                                    settings.RemoveFromGrid = value;
                                    Global.Settings.Save();
                                    Global.ReInitializeHandlers();
                                }
                            }
                            catch (Exception ex)
                            {
                                Log.Error(this, "CreateServiceGroup", ex, settings.VehicleNamePlural, "RemoveFromGrid", value);
                            }
                        });
                }

                if (settings.CanLimitOpportunisticCollection)
                {
                    if (settings.OpportunisticCollectionLimitDetour == Detours.Methods.None || Detours.CanDetour(settings.OpportunisticCollectionLimitDetour))
                    {
                        group.AddCheckbox(
                            "Prioritize assigned buildings",
                            settings.LimitOpportunisticCollection,
                            value =>
                            {
                                try
                                {
                                    if (settings.LimitOpportunisticCollection != value)
                                    {
                                        settings.LimitOpportunisticCollection = value;
                                        Detours.InitNeeded = true;
                                        Global.Settings.Save();
                                    }
                                }
                                catch (Exception ex)
                                {
                                    Log.Error(this, "OnSettingsUI", ex, "GarbageGroup", "LimitOpportunisticGarbageCollection", value);
                                    Log.Error(this, "CreateServiceGroup", ex, settings.VehicleNamePlural, "LimitOpportunisticCollection");
                                }
                            });
                    }
                    else
                    {
                        UIComponent limitOpportunisticGarbageCollectionCheckBox = group.AddCheckbox(
                            "Prioritize assigned buildings",
                            false,
                            value =>
                            {
                            }) as UIComponent;
                        limitOpportunisticGarbageCollectionCheckBox.Disable();
                    }
                }

                group.AddDropdown(
                    "Send out spare " + settings.VehicleNamePlural.ToLower() + " when",
                    this.vehicleCreationOptions.OrderBy(vco => vco.Key).Select(vco => vco.Value).ToArray(),
                    (int)settings.CreateSpares,
                    value =>
                    {
                        try
                        {
                            if (Log.LogALot || Library.IsDebugBuild)
                            {
                                Log.Debug(this, "CreateServiceGroup", "Set", settings.VehicleNamePlural, "CreateSpares", value);
                            }

                            foreach (ServiceDispatcherSettings.SpareVehiclesCreation option in Enum.GetValues(typeof(ServiceDispatcherSettings.SpareVehiclesCreation)))
                            {
                                if ((byte)option == value)
                                {
                                    if (settings.CreateSpares != option)
                                    {
                                        if (Log.LogALot || Library.IsDebugBuild)
                                        {
                                            Log.Debug(this, "CreateServiceGroup", "Set", settings.VehicleNamePlural, "CreateSpares", value, option);
                                        }

                                        settings.CreateSpares = option;

                                        if (dispatcher != null)
                                        {
                                            try
                                            {
                                                dispatcher.ReInitialize();
                                            }
                                            catch (Exception ex)
                                            {
                                                Log.Error(this, "CreateServiceGroup", ex, settings.VehicleNamePlural, "CreateSpares", "ReInitializeDispatcher");
                                            }
                                        }

                                        Global.Settings.Save();
                                    }

                                    break;
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            Log.Error(this, "CreateServiceGroup", ex, settings.VehicleNamePlural, "CreateSpares", value);
                        }
                    });

                group.AddDropdown(
                    settings.VehicleNameSingular + " dispatch strategy",
                    this.targetBuildingChecks.OrderBy(bco => bco.Key).Select(bco => bco.Value).ToArray(),
                    (int)settings.ChecksPreset,
                    value =>
                    {
                        try
                        {
                            if (Log.LogALot || Library.IsDebugBuild)
                            {
                                Log.Debug(this, "CreateServiceGroup", "Set", settings.VehicleNamePlural, "ChecksPreset", value);
                            }

                            foreach (ServiceDispatcherSettings.BuildingCheckOrder checks in Enum.GetValues(typeof(ServiceDispatcherSettings.BuildingCheckOrder)))
                            {
                                if ((byte)checks == value)
                                {
                                    if (settings.ChecksPreset != checks)
                                    {
                                        if (Log.LogALot || Library.IsDebugBuild)
                                        {
                                            Log.Debug(this, "CreateServiceGroup", "Set", settings.VehicleNamePlural, "ChecksPreset", value, checks);
                                        }

                                        try
                                        {
                                            settings.ChecksPreset = checks;
                                        }
                                        catch (Exception ex)
                                        {
                                            Log.Error(this, "OnSettingsUI", ex, "Set", "DeathChecksPreset", checks);
                                        }

                                        if (dispatcher != null)
                                        {
                                            try
                                            {
                                                dispatcher.ReInitialize();
                                            }
                                            catch (Exception ex)
                                            {
                                                Log.Error(this, "CreateServiceGroup", ex, settings.VehicleNamePlural, "ChecksPreset", "ReInitializeDispatcher");
                                            }
                                        }

                                        Global.Settings.Save();
                                    }

                                    break;
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            Log.Error(this, "CreateServiceGroup", ex, settings.VehicleNamePlural, "ChecksPreset", value);
                        }
                    });

                if (settings.UseMinimumAmountForPatrol)
                {
                    group.AddExtendedSlider(
                        settings.MaterialName + " patrol limit",
                        1.0f,
                        5000.0f,
                        1.0f,
                        settings.MinimumAmountForPatrol,
                        false,
                        value =>
                        {
                            try
                            {
                                if (settings.MinimumAmountForPatrol != (ushort)value)
                                {
                                    settings.MinimumAmountForPatrol = (ushort)value;
                                    Global.BuildingUpdateNeeded = true;
                                    Global.Settings.Save();
                                }
                            }
                            catch (Exception ex)
                            {
                                Log.Error(this, "CreateServiceGroup", ex, settings.VehicleNamePlural, "MinimumAmountForPatrol", value);
                            }
                        });
                }

                if (settings.UseMinimumAmountForDispatch)
                {
                    group.AddExtendedSlider(
                        settings.MaterialName + " dispatch limit",
                        1.0f,
                        5000.0f,
                        1.0f,
                        settings.MinimumAmountForDispatch,
                        false,
                        value =>
                        {
                            try
                            {
                                if (settings.MinimumAmountForDispatch != (ushort)value)
                                {
                                    settings.MinimumAmountForDispatch = (ushort)value;
                                    Global.BuildingUpdateNeeded = true;
                                    Global.Settings.Save();
                                }
                            }
                            catch (Exception ex)
                            {
                                Log.Error(this, "CreateServiceGroup", ex, settings.VehicleNamePlural, "MinimumAmountForDispatch", value);
                            }
                        });
                }

                return group;
            }
            catch (Exception ex)
            {
                Log.Error(this, "CreateServiceGroup", ex, settings.EmptiableServiceBuildingNamePlural);
                return null;
            }
        }
Exemple #25
0
        public static void MakeSettings(UIHelperBase helper)
        {
            // tabbing code is borrowed from RushHour mod
            // https://github.com/PropaneDragon/RushHour/blob/release/RushHour/Options/OptionHandler.cs
            LoadSetting();
            UIHelper    actualHelper = helper as UIHelper;
            UIComponent container    = actualHelper.self as UIComponent;

            UITabstrip tabStrip = container.AddUIComponent <UITabstrip>();

            tabStrip.relativePosition = new Vector3(0, 0);
            tabStrip.size             = new Vector2(container.width - 20, 40);

            UITabContainer tabContainer = container.AddUIComponent <UITabContainer>();

            tabContainer.relativePosition = new Vector3(0, 40);
            tabContainer.size             = new Vector2(container.width - 20, container.height - tabStrip.height - 20);
            tabStrip.tabPages             = tabContainer;

            int tabIndex = 0;

            // Lane_ShortCut

            AddOptionTab(tabStrip, Localization.Get("Lane_ShortCut"));
            tabStrip.selectedIndex = tabIndex;

            UIPanel currentPanel = tabStrip.tabContainer.components[tabIndex] as UIPanel;

            currentPanel.autoLayout              = true;
            currentPanel.autoLayoutDirection     = LayoutDirection.Vertical;
            currentPanel.autoLayoutPadding.top   = 5;
            currentPanel.autoLayoutPadding.left  = 10;
            currentPanel.autoLayoutPadding.right = 10;

            UIHelper panelHelper = new UIHelper(currentPanel);

            var generalGroup = panelHelper.AddGroup(Localization.Get("Lane_Button_ShortCut")) as UIHelper;
            var panel        = generalGroup.self as UIPanel;

            panel.gameObject.AddComponent <OptionsKeymappingLane>();

            var generalGroup1 = panelHelper.AddGroup(Localization.Get("ShortCuts_Control")) as UIHelper;

            generalGroup1.AddCheckbox(Localization.Get("ShortCuts_Control_TIPS"), isShortCutsToPanel, (index) => isShortCutsToPanelEnable(index));

            // Function_ShortCut
            ++tabIndex;

            AddOptionTab(tabStrip, Localization.Get("Function_ShortCut"));
            tabStrip.selectedIndex = tabIndex;

            currentPanel                         = tabStrip.tabContainer.components[tabIndex] as UIPanel;
            currentPanel.autoLayout              = true;
            currentPanel.autoLayoutDirection     = LayoutDirection.Vertical;
            currentPanel.autoLayoutPadding.top   = 5;
            currentPanel.autoLayoutPadding.left  = 10;
            currentPanel.autoLayoutPadding.right = 10;

            panelHelper = new UIHelper(currentPanel);

            generalGroup = panelHelper.AddGroup(Localization.Get("Function_Button_ShortCut")) as UIHelper;
            panel        = generalGroup.self as UIPanel;

            panel.gameObject.AddComponent <OptionsKeymappingFunction>();

            ++tabIndex;

            AddOptionTab(tabStrip, Localization.Get("Experimental_Function"));
            tabStrip.selectedIndex = tabIndex;

            currentPanel                         = tabStrip.tabContainer.components[tabIndex] as UIPanel;
            currentPanel.autoLayout              = true;
            currentPanel.autoLayoutDirection     = LayoutDirection.Vertical;
            currentPanel.autoLayoutPadding.top   = 5;
            currentPanel.autoLayoutPadding.left  = 10;
            currentPanel.autoLayoutPadding.right = 10;

            panelHelper = new UIHelper(currentPanel);
            var generalGroup2 = panelHelper.AddGroup(Localization.Get("Experimental_Function")) as UIHelper;

            generalGroup2.AddCheckbox(Localization.Get("Debug_Mode"), isDebug, (index) => isDebugEnable(index));
            generalGroup2.AddCheckbox(Localization.Get("DisableZone"), disableZone, (index) => isDisableZoneEnable(index));
            generalGroup2.AddCheckbox(Localization.Get("UpdateZone"), disableZoneUpdateAll, (index) => isDisableZoneUpdateAllEnable(index));
            generalGroup2.AddCheckbox(Localization.Get("EnablePillar"), enablePillar, (index) => isEnablePillarEnable(index));
            generalGroup2.AddCheckbox(Localization.Get("AlignZone"), alignZone, (index) => isAlignZoneEnable(index));
            generalGroup2.AddCheckbox(Localization.Get("FixLargeJunction"), fixLargeJunction, (index) => isFixLargeJunctionEnable(index));
            generalGroup2.AddCheckbox(Localization.Get("NOJunction"), noJunction, (index) => isNoJunctionEnable(index));
            generalGroup2.AddCheckbox(Localization.Get("TEMPPATCH"), tempPatchForSpeedAndPrice, (index) => isTempPatchEnable(index));
            SaveSetting();
        }
Exemple #26
0
        public static void MakeSettings(UIHelperBase helper)
        {
            LoadSetting();
            UIHelper    actualHelper = helper as UIHelper;
            UIComponent container    = actualHelper.self as UIComponent;

            UITabstrip tabStrip = container.AddUIComponent <UITabstrip>();

            tabStrip.relativePosition = new Vector3(0, 0);
            tabStrip.size             = new Vector2(container.width - 20, 40);

            UITabContainer tabContainer = container.AddUIComponent <UITabContainer>();

            tabContainer.relativePosition = new Vector3(0, 40);
            tabContainer.size             = new Vector2(container.width - 20, container.height - tabStrip.height - 20);
            tabStrip.tabPages             = tabContainer;

            int tabIndex = 0;

            // Lane_ShortCut

            AddOptionTab(tabStrip, Localization.Get("BASIC_SETTING"));
            tabStrip.selectedIndex = tabIndex;

            UIPanel currentPanel = tabStrip.tabContainer.components[tabIndex] as UIPanel;

            currentPanel.autoLayout              = true;
            currentPanel.autoLayoutDirection     = LayoutDirection.Vertical;
            currentPanel.autoLayoutPadding.top   = 5;
            currentPanel.autoLayoutPadding.left  = 10;
            currentPanel.autoLayoutPadding.right = 10;

            UIHelper panelHelper = new UIHelper(currentPanel);

            UIHelperBase group = panelHelper.AddGroup(Localization.Get("BASIC_SETTING"));

            group.AddCheckbox(Localization.Get("SHOW_LACK_OF_RESOURCE"), RealCity.debugMode, (index) => debugModeEnable(index));
            group.AddCheckbox(Localization.Get("REDUCE_CARGO_ENABLE"), RealCity.reduceVehicle, (index) => reduceVehicleEnable(index));
            group.AddCheckbox(Localization.Get("NO_PASSENGERCAR"), RealCity.noPassengerCar, (index) => noPassengerCarEnable(index));
            group.AddButton(Localization.Get("RESET_VALUE"), Loader.InitData);

            if (Loader.isTransportLinesManagerRunning)
            {
                UIHelperBase group1 = panelHelper.AddGroup(Localization.Get("TLMRUNNING"));
            }
            else
            {
                UIHelperBase group1 = panelHelper.AddGroup(Localization.Get("TLMNOTRUNNING"));
            }

            ++tabIndex;

            AddOptionTab(tabStrip, Localization.Get("SPTB"));
            tabStrip.selectedIndex = tabIndex;

            currentPanel                         = tabStrip.tabContainer.components[tabIndex] as UIPanel;
            currentPanel.autoLayout              = true;
            currentPanel.autoLayoutDirection     = LayoutDirection.Vertical;
            currentPanel.autoLayoutPadding.top   = 5;
            currentPanel.autoLayoutPadding.left  = 10;
            currentPanel.autoLayoutPadding.right = 10;

            panelHelper = new UIHelper(currentPanel);
            var generalGroup2 = panelHelper.AddGroup(Localization.Get("SMART_PUBLIC_TRANSPORT_BUDGET_WEEKDAY")) as UIHelper;

            morningBudgetWeekDaySlider = generalGroup2.AddSlider(Localization.Get("WEEKDAY_MORNING_BUDGET") + "(" + morningBudgetWeekDay.ToString() + "%)", 10, 300, 5, morningBudgetWeekDay, onMorningBudgetWeekDayChanged) as UISlider;
            morningBudgetWeekDaySlider.parent.Find <UILabel>("Label").width = 500f;
            eveningBudgetWeekDaySlider = generalGroup2.AddSlider(Localization.Get("WEEKDAY_EVENING_BUDGET") + "(" + eveningBudgetWeekDay.ToString() + "%)", 10, 300, 5, eveningBudgetWeekDay, onEveningBudgetWeekDayChanged) as UISlider;
            eveningBudgetWeekDaySlider.parent.Find <UILabel>("Label").width = 500f;
            deepNightBudgetWeekDaySlider = generalGroup2.AddSlider(Localization.Get("WEEKDAY_DEEPNIGHT_BUDGET") + "(" + deepNightBudgetWeekDay.ToString() + "%)", 10, 300, 5, deepNightBudgetWeekDay, onDeepNightBudgetWeekDayChanged) as UISlider;
            deepNightBudgetWeekDaySlider.parent.Find <UILabel>("Label").width = 500f;
            otherBudgetWeekDaySlider = generalGroup2.AddSlider(Localization.Get("WEEKDAY_OTHER_BUDGET") + "(" + otherBudgetWeekDay.ToString() + "%)", 10, 300, 5, otherBudgetWeekDay, onOtherBudgetWeekDayChanged) as UISlider;
            otherBudgetWeekDaySlider.parent.Find <UILabel>("Label").width = 500f;

            var generalGroup3 = panelHelper.AddGroup(Localization.Get("SMART_PUBLIC_TRANSPORT_BUDGET_WEEKEND")) as UIHelper;

            morningBudgetWeekEndSlider = generalGroup3.AddSlider(Localization.Get("WEEKEND_MORNING_BUDGET") + "(" + morningBudgetWeekEnd.ToString() + "%)", 10, 300, 5, morningBudgetWeekEnd, onMorningBudgetWeekEndChanged) as UISlider;
            morningBudgetWeekEndSlider.parent.Find <UILabel>("Label").width = 500f;
            eveningBudgetWeekEndSlider = generalGroup3.AddSlider(Localization.Get("WEEKEND_EVENING_BUDGET") + "(" + eveningBudgetWeekEnd.ToString() + "%)", 10, 300, 5, eveningBudgetWeekEnd, onEveningBudgetWeekEndChanged) as UISlider;
            eveningBudgetWeekEndSlider.parent.Find <UILabel>("Label").width = 500f;
            deepNightBudgetWeekEndSlider = generalGroup3.AddSlider(Localization.Get("WEEKEND_DEEPNIGHT_BUDGET") + "(" + deepNightBudgetWeekEnd.ToString() + "%)", 10, 300, 5, deepNightBudgetWeekEnd, onDeepNightBudgetWeekEndChanged) as UISlider;
            deepNightBudgetWeekEndSlider.parent.Find <UILabel>("Label").width = 500f;
            otherBudgetWeekEndSlider = generalGroup3.AddSlider(Localization.Get("WEEKEND_OTHER_BUDGET") + "(" + otherBudgetWeekEnd.ToString() + "%)", 10, 300, 5, otherBudgetWeekEnd, onOtherBudgetWeekEndChanged) as UISlider;
            otherBudgetWeekEndSlider.parent.Find <UILabel>("Label").width = 500f;

            ++tabIndex;

            AddOptionTab(tabStrip, Localization.Get("SPTB2"));
            tabStrip.selectedIndex = tabIndex;

            currentPanel                         = tabStrip.tabContainer.components[tabIndex] as UIPanel;
            currentPanel.autoLayout              = true;
            currentPanel.autoLayoutDirection     = LayoutDirection.Vertical;
            currentPanel.autoLayoutPadding.top   = 5;
            currentPanel.autoLayoutPadding.left  = 10;
            currentPanel.autoLayoutPadding.right = 10;

            panelHelper = new UIHelper(currentPanel);
            var generalGroup4 = panelHelper.AddGroup(Localization.Get("SMART_PUBLIC_TRANSPORT_BUDGET_MAX")) as UIHelper;

            morningBudgetMaxSlider = generalGroup4.AddSlider(Localization.Get("MAX_MORNING_BUDGET") + "(" + morningBudgetMax.ToString() + "%)", 10, 300, 5, morningBudgetMax, onMorningBudgetMaxChanged) as UISlider;
            morningBudgetMaxSlider.parent.Find <UILabel>("Label").width = 500f;
            eveningBudgetMaxSlider = generalGroup4.AddSlider(Localization.Get("MAX_EVENING_BUDGET") + "(" + eveningBudgetMax.ToString() + "%)", 10, 300, 5, eveningBudgetMax, onEveningBudgetMaxChanged) as UISlider;
            eveningBudgetMaxSlider.parent.Find <UILabel>("Label").width = 500f;
            deepNightBudgetMaxSlider = generalGroup4.AddSlider(Localization.Get("MAX_DEEPNIGHT_BUDGET") + "(" + deepNightBudgetMax.ToString() + "%)", 10, 300, 5, deepNightBudgetMax, onDeepNightBudgetMaxChanged) as UISlider;
            deepNightBudgetMaxSlider.parent.Find <UILabel>("Label").width = 500f;
            otherBudgetMaxSlider = generalGroup4.AddSlider(Localization.Get("MAX_OTHER_BUDGET") + "(" + otherBudgetMax.ToString() + "%)", 10, 300, 5, otherBudgetMax, onOtherBudgetMaxChanged) as UISlider;
            otherBudgetMaxSlider.parent.Find <UILabel>("Label").width = 500f;

            var generalGroup5 = panelHelper.AddGroup(Localization.Get("SMART_PUBLIC_TRANSPORT_BUDGET_MIN")) as UIHelper;

            morningBudgetMinSlider = generalGroup5.AddSlider(Localization.Get("MIN_MORNING_BUDGET") + "(" + morningBudgetMin.ToString() + "%)", 10, 300, 5, morningBudgetMin, onMorningBudgetMinChanged) as UISlider;
            morningBudgetMinSlider.parent.Find <UILabel>("Label").width = 500f;
            eveningBudgetMinSlider = generalGroup5.AddSlider(Localization.Get("MIN_EVENING_BUDGET") + "(" + eveningBudgetMin.ToString() + "%)", 10, 300, 5, eveningBudgetMin, onEveningBudgetMinChanged) as UISlider;
            eveningBudgetMinSlider.parent.Find <UILabel>("Label").width = 500f;
            deepNightBudgetMinSlider = generalGroup5.AddSlider(Localization.Get("MIN_DEEPNIGHT_BUDGET") + "(" + deepNightBudgetMin.ToString() + "%)", 10, 300, 5, deepNightBudgetMin, onDeepNightBudgetMinChanged) as UISlider;
            deepNightBudgetMinSlider.parent.Find <UILabel>("Label").width = 500f;
            otherBudgetMinSlider = generalGroup5.AddSlider(Localization.Get("MIN_OTHER_BUDGET") + "(" + otherBudgetMin.ToString() + "%)", 10, 300, 5, otherBudgetMin, onOtherBudgetMinChanged) as UISlider;
            otherBudgetMinSlider.parent.Find <UILabel>("Label").width = 500f;

            SaveSetting();
        }
Exemple #27
0
        public void OnSettingsUI(UIHelperBase helper)
        {
            UIHelperBase group = helper.AddGroup("Railway Mod");

            group.AddCheckbox("Enable Thin Wires", enableWires.value, (t) => { enableWires.value = t; });
        }
Exemple #28
0
 public void OnSettingsUI(UIHelperBase helper) => Settings.settings.OnSettingsUI(helper);
 public void OnSettingsUI(UIHelperBase helper)
 {
     Options.makeSettings(helper);
 }
Exemple #30
0
 public void OnSettingsUI(UIHelperBase helper)
 {
     OptionHandler.SetUpOptions(helper);
 }
Exemple #31
0
        public static void OnSettingsUI(UIHelperBase helper)
        {
            var config = Configuration <TrueLodTogglerConfiguration> .Load();

            if (RenderManager.LevelOfDetailFactor < 1.4)
            {
                helper.AddGroup("Warning: Set your 'Level Of Detail' graphics option to 'Very High' for good results!");
            }

            var group = helper.AddGroup("Ultimate Level Of Detail");

            var treeLodDistanceOptions = new LodDropdownOption[]
            {
                new LodDropdownOption("1m :P", 1f),
                new LodDropdownOption("50m", 50f),
                new LodDropdownOption("100m", 100f),
                new LodDropdownOption("200m", 200f),
                new LodDropdownOption("300m", 300f),
                new LodDropdownOption("425m (Game Default)", 425f),
                new LodDropdownOption("500m", 500f),
                new LodDropdownOption("625m", 625f),
                new LodDropdownOption("750m", 750f),
                new LodDropdownOption("875m", 875f),
                new LodDropdownOption("1000m", 1000f),
                new LodDropdownOption("1250m", 1250f),
                new LodDropdownOption("1500m", 1500f),
                new LodDropdownOption("2000m", 2000f),
                new LodDropdownOption("3000m", 3000f),
                new LodDropdownOption("4000m", 4000f),
                new LodDropdownOption("5000m", 5000f),
                new LodDropdownOption("10000m (Good luck!)", 10000f),
                new LodDropdownOption("100000m (Goodbye!)", 100000f),
            };

            group.AddDropdown(
                "Tree LOD Distance",
                LodDropdownOption.BuildLabels(treeLodDistanceOptions),
                LodDropdownOption.FindIndex(treeLodDistanceOptions, config.TreeLodDistance),
                sel =>
            {
                // Change config value and save config
                config.TreeLodDistance = treeLodDistanceOptions[sel].Value;
                Configuration <TrueLodTogglerConfiguration> .Save();
                LodUpdater.UpdateTrees();
            });

            var lodDistanceOptions = new LodDropdownOption[]
            {
                new LodDropdownOption("1m :P", 1f),
                new LodDropdownOption("50m", 50f),
                new LodDropdownOption("100m", 100f),
                new LodDropdownOption("200m", 200f),
                new LodDropdownOption("300m", 300f),
                new LodDropdownOption("400m", 400f),
                new LodDropdownOption("500m", 500f),
                new LodDropdownOption("750m", 750f),
                new LodDropdownOption("1000m (Game Default)", 1000f),
                new LodDropdownOption("1125m", 1125f),
                new LodDropdownOption("1250m", 1250f),
                new LodDropdownOption("1500m", 1500f),
                new LodDropdownOption("1750m", 1750f),
                new LodDropdownOption("2000m", 2000f),
                new LodDropdownOption("3000m", 3000f),
                new LodDropdownOption("4000m", 4000f),
                new LodDropdownOption("5000m", 5000f),
                new LodDropdownOption("10000m (Good luck!)", 10000f),
                new LodDropdownOption("100000m (Goodbye!)", 100000f),
            };

            group.AddDropdown(
                "Prop LOD Distance",
                LodDropdownOption.BuildLabels(lodDistanceOptions),
                LodDropdownOption.FindIndex(lodDistanceOptions, config.PropLodDistance),
                sel =>
            {
                // Change config value and save config
                config.PropLodDistance = lodDistanceOptions[sel].Value;
                Configuration <TrueLodTogglerConfiguration> .Save();
                LodUpdater.UpdateProps();
            });

            var decalFadeDistanceOptions = new LodDropdownOption[]
            {
                new LodDropdownOption("1m :P", 1f),
                new LodDropdownOption("50m", 50f),
                new LodDropdownOption("100m", 100f),
                new LodDropdownOption("200m", 200f),
                new LodDropdownOption("300m", 300f),
                new LodDropdownOption("400m", 400f),
                new LodDropdownOption("500m", 500f),
                new LodDropdownOption("750m", 750f),
                new LodDropdownOption("1000m (Game Default)", 1000f),
                new LodDropdownOption("1250m", 1250f),
                new LodDropdownOption("1500m", 1500f),
                new LodDropdownOption("1750m", 1750f),
                new LodDropdownOption("2000m", 2000f),
                new LodDropdownOption("3000m", 3000f),
                new LodDropdownOption("4000m", 4000f),
                new LodDropdownOption("5000m", 5000f),
                new LodDropdownOption("10000m", 10000f),
                new LodDropdownOption("15000m", 15000f),
                new LodDropdownOption("20000m", 20000f),
                new LodDropdownOption("25000m", 25000f),
                new LodDropdownOption("100000m (Goodbye!)", 100000f),
            };

            group.AddDropdown(
                "Decal Prop Fade Distance",
                LodDropdownOption.BuildLabels(decalFadeDistanceOptions),
                LodDropdownOption.FindIndex(decalFadeDistanceOptions, config.DecalPropFadeDistance),
                sel =>
            {
                // Change config value and save config
                config.DecalPropFadeDistance = decalFadeDistanceOptions[sel].Value;
                Configuration <TrueLodTogglerConfiguration> .Save();
                LodUpdater.UpdateProps();
            });

            group.AddDropdown(
                "Building LOD Distance",
                LodDropdownOption.BuildLabels(lodDistanceOptions),
                LodDropdownOption.FindIndex(lodDistanceOptions, config.BuildingLodDistance),
                sel =>
            {
                // Change config value and save config
                config.BuildingLodDistance = lodDistanceOptions[sel].Value;
                Configuration <TrueLodTogglerConfiguration> .Save();
                LodUpdater.UpdateBuildings();
            });

            group.AddDropdown(
                "Network LOD Distance",
                LodDropdownOption.BuildLabels(lodDistanceOptions),
                LodDropdownOption.FindIndex(lodDistanceOptions, config.NetworkLodDistance),
                sel =>
            {
                // Change config value and save config
                config.NetworkLodDistance = lodDistanceOptions[sel].Value;
                Configuration <TrueLodTogglerConfiguration> .Save();
                LodUpdater.UpdateNetworks();
            });

            var vehicleLodDistanceOptions = new LodDropdownOption[]
            {
                new LodDropdownOption("1m :P", 1f),
                new LodDropdownOption("50m", 50f),
                new LodDropdownOption("100m", 100f),
                new LodDropdownOption("200m", 200f),
                new LodDropdownOption("300m", 300f),
                new LodDropdownOption("400m (Game Default)", 400f),
                new LodDropdownOption("500m", 500f),
                new LodDropdownOption("625m", 625f),
                new LodDropdownOption("750m", 750f),
                new LodDropdownOption("875m", 875f),
                new LodDropdownOption("1000m", 1000f),
                new LodDropdownOption("1250m", 1250f),
                new LodDropdownOption("1500m", 1500f),
                new LodDropdownOption("2000m", 2000f),
                new LodDropdownOption("3000m", 3000f),
                new LodDropdownOption("4000m", 4000f),
                new LodDropdownOption("5000m", 5000f),
                new LodDropdownOption("10000m (Good luck!)", 10000f),
                new LodDropdownOption("100000m (Goodbye!)", 100000f),
            };

            group.AddDropdown(
                "Vehicle LOD Distance",
                LodDropdownOption.BuildLabels(vehicleLodDistanceOptions),
                LodDropdownOption.FindIndex(vehicleLodDistanceOptions, config.VehicleLodDistance),
                sel => {
                // Change config value and save config
                config.VehicleLodDistance = vehicleLodDistanceOptions[sel].Value;
                Configuration <TrueLodTogglerConfiguration> .Save();
                LodUpdater.UpdateVehicles();
            });

            var vehicleRenderDistanceOptions = new LodDropdownOption[]
            {
                new LodDropdownOption("1m :P", 1f),
                new LodDropdownOption("50m", 50f),
                new LodDropdownOption("100m", 100f),
                new LodDropdownOption("250m", 250f),
                new LodDropdownOption("500m", 500f),
                new LodDropdownOption("750m", 750f),
                new LodDropdownOption("1000m", 1000f),
                new LodDropdownOption("1250m", 1250f),
                new LodDropdownOption("1500m", 1500f),
                new LodDropdownOption("2000m (Game Default)", 2000f),
                new LodDropdownOption("2500m", 2500f),
                new LodDropdownOption("3000m", 3000f),
                new LodDropdownOption("4000m", 4000f),
                new LodDropdownOption("5000m", 5000f),
                new LodDropdownOption("6000m", 6000f),
                new LodDropdownOption("10000m", 10000f),
                new LodDropdownOption("15000m", 15000f),
                new LodDropdownOption("20000m", 20000f),
                new LodDropdownOption("25000m (Good luck!)", 25000f),
                new LodDropdownOption("100000m (Goodbye!)", 100000f),
            };

            group.AddDropdown(
                "Vehicle Render Distance",
                LodDropdownOption.BuildLabels(vehicleRenderDistanceOptions),
                LodDropdownOption.FindIndex(vehicleRenderDistanceOptions, config.VehicleRenderDistance),
                sel => {
                // Change config value and save config
                config.VehicleRenderDistance = vehicleRenderDistanceOptions[sel].Value;
                Configuration <TrueLodTogglerConfiguration> .Save();
                LodUpdater.UpdateVehicles();
            });

            var shadowDistanceOptions = new LodDropdownOption[]
            {
                new LodDropdownOption("1m :P", 1f),
                new LodDropdownOption("50m", 50f),
                new LodDropdownOption("100m", 100f),
                new LodDropdownOption("250m", 250f),
                new LodDropdownOption("500m", 500f),
                new LodDropdownOption("750m", 750f),
                new LodDropdownOption("1000m", 1000f),
                new LodDropdownOption("1250m", 1250f),
                new LodDropdownOption("1500m", 1500f),
                new LodDropdownOption("2000m", 2000f),
                new LodDropdownOption("2500m", 2500f),
                new LodDropdownOption("3000m", 3000f),
                new LodDropdownOption("4000m (Game Default)", 4000f),
                new LodDropdownOption("5000m", 5000f),
                new LodDropdownOption("6000m", 6000f),
                new LodDropdownOption("10000m", 10000f),
                new LodDropdownOption("15000m", 15000f),
                new LodDropdownOption("20000m", 20000f),
                new LodDropdownOption("25000m (Good luck!)", 25000f),
                new LodDropdownOption("100000m (Goodbye!)", 100000f),
            };

            group.AddDropdown(
                "Shadow Distance",
                LodDropdownOption.BuildLabels(shadowDistanceOptions),
                LodDropdownOption.FindIndex(shadowDistanceOptions, config.ShadowDistance),
                sel => {
                // Change config value and save config
                config.ShadowDistance = shadowDistanceOptions[sel].Value;
                Configuration <TrueLodTogglerConfiguration> .Save();
                LodUpdater.UpdateShadowDistance();
            });

            group.AddCheckbox("Disable on startup (press CTRL + SHIFT + [.] to enable)", config.VanillaModeOnStartup, sel =>
            {
                config.VanillaModeOnStartup = sel;
                Configuration <TrueLodTogglerConfiguration> .Save();
            });

            group.AddCheckbox("Display current ULOD mode in Free Camera Button", config.FreeCameraButtonDisplay, sel =>
            {
                config.FreeCameraButtonDisplay = sel;
                Configuration <TrueLodTogglerConfiguration> .Save();
                TrueLodTogglerMod.UpdateFreeCameraButton();
            });
        }
Exemple #32
0
        public void OnSettingsUI(UIHelperBase helper)
        {
            SettingsPanel sp = new SettingsPanel();

            sp.CreatePanel(helper);
        }
Exemple #33
0
        public void OnSettingsUI(UIHelperBase helper)
        {
            ensureComponents();

            if (_settingsui == null)
                _settingsui = _gameObject.AddComponent<SettingsUI>();

            _settingsui.Mod = this;
            _settingsui.InitializeSettingsUI(helper);
        }
Exemple #34
0
        public void OnSettingsUI(UIHelperBase helper)
        {
            try
            {
                UICheckBox  checkBox;
                UITextField TextField;
                UIButton    Button;

// Section for General Settings

                UIHelperBase group_general = helper.AddGroup("General Settings                                                   " + Name);

                checkBox = (UICheckBox)group_general.AddCheckbox("Disable debug messages logging", DebugUtils.hideDebugMessages.value, (b) =>
                {
                    DebugUtils.hideDebugMessages.value = b;
                });
                checkBox.tooltip = "If checked, debug messages will not be logged.";

                group_general.AddSpace(10);

                checkBox = (UICheckBox)group_general.AddCheckbox("Hide the user interface", AdvancedVehicleOptionsUID.hideGUI.value, (b) =>
                {
                    AdvancedVehicleOptionsUID.hideGUI.value = b;
                    AdvancedVehicleOptionsUID.UpdateGUI();
                });
                checkBox.tooltip = "Hide the UI completely if you feel like you are done with it and want to save\n" +
                                   "the little bit of memory it takes. Everything else will still be functional.";

                checkBox = (UICheckBox)group_general.AddCheckbox("Disable warning for no available services at map loading", !AdvancedVehicleOptionsUID.onLoadCheck.value, (b) =>
                {
                    AdvancedVehicleOptionsUID.onLoadCheck.value = !b;
                });
                checkBox.tooltip = "Disable the check for missing service vehicles assigned in any category when loading a map.";

// Section for Game Balancing

                UIHelperBase group_balance = helper.AddGroup("Gameplay & Balancing");

// Checkbox for SpeedUnitOption kmh vs mph

                checkBox = (UICheckBox)group_balance.AddCheckbox("Display Miles per Hour (mph) instead of Kilometer per Hour (km/h)", AdvancedVehicleOptionsUID.SpeedUnitOption.value, (b) =>
                {
                    AdvancedVehicleOptionsUID.SpeedUnitOption.value = b;
                });
                checkBox.tooltip = "Changes display of unit of speed from mph to km/h.";

// Checkbox for Game Balancing

                checkBox = (UICheckBox)group_balance.AddCheckbox("Enable various values for non-cargo and non-passenger vehicles", AdvancedVehicleOptionsUID.GameBalanceOptions.value, (b) =>
                {
                    AdvancedVehicleOptionsUID.GameBalanceOptions.value = b;
                });
                checkBox.tooltip = "Allows changes the Firefighting Rate and Capacity for Fire Safety, the Crime Rate Capacity\n" +
                                   "for Police Vehicles and the Maintenance and Pumping Rate for Maintenance Vehicles.\n\n" +
                                   "Can de-balance the intended gameplay. Some values are not documented.";

// Section for Compatibility

                UIHelperBase group_compatibility = helper.AddGroup("Compatibility");

// Checkbox for Overriding Incompability Warnings

                checkBox = (UICheckBox)group_compatibility.AddCheckbox("Display Compatibility Warnings for Mods", AdvancedVehicleOptionsUID.OverrideCompatibilityWarnings.value, (b) =>
                {
                    AdvancedVehicleOptionsUID.OverrideCompatibilityWarnings.value = b;
                });

                checkBox.tooltip = "If enabled, settings which can be modified in Improved Public Transport\n" +
                                   "(by BloodyPenguin) and Transport Lines Manager (by Klyte) will be shown\n" +
                                   "with warning color. Values should be edited in these mods only.\n\n" +
                                   "If disabled, the coloring will not shown.";
                //True, if AVO shall shall color shared mod setting values in red.

// Checkbox for Vehicle Color Expander

                checkBox = (UICheckBox)group_compatibility.AddCheckbox("Vehicle Color Expander: Priority over AVO vehicle coloring", AdvancedVehicleOptionsUID.OverrideVCX.value, (b) =>
                {
                    AdvancedVehicleOptionsUID.OverrideVCX.value = b;
                });

                checkBox.tooltip = "Permanent setting, if Vehicle Color Expander (by Klyte) is active.\n" +
                                   "The color management is controlled by Vehicle Color Expander.\n\n" +
                                   "Values will be configured in Vehicle Color Expander.";

                //True, if AVO shall not override Vehicle Color Expander settings. As there is not Settings for Vehicle Color Expander. AVO will show the option, but user cannot change anything as long readOnly is True.
                checkBox.readOnly        = true;
                checkBox.label.textColor = Color.gray;

                if (!VCXCompatibilityPatch.IsVCXActive())
                {
                    checkBox.enabled = false;                   //Do not show the option Checkbox, if Vehicle Color Expander is not active.
                }

// Checkbox for No Big Trucks

                checkBox = (UICheckBox)group_compatibility.AddCheckbox("No Big Trucks: Classify Generic Industry vehicles as Large Vehicle", AdvancedVehicleOptionsUID.ControlTruckDelivery.value, (b) =>
                {
                    AdvancedVehicleOptionsUID.ControlTruckDelivery.value = b;
                });

                checkBox.tooltip = "If enabled, Delivery Trucks can be tagged as Large Vehicles.\n" +
                                   "Dispatch will be blocked by No Big Trucks (by MacSergey).\n\n" +
                                   "Warning: Experimental feature and may have impact on the simulation.";
                //True, if AVO shall be enabled to classify Generic Industry vehicles as Large Vehicles, so No Big Trucks can suppress the dispatch to small buildings.

                if (!NoBigTruckCompatibilityPatch.IsNBTActive())
                {
                    checkBox.enabled = false;   //Do not show the option Checkbox, if No Big Trucks is not active.
                }

// Add a Spacer
                group_compatibility.AddSpace(20);

// Add Trailer Compatibility Reference

                TextField         = (UITextField)group_compatibility.AddTextfield("Vehicle Trailer compatibility references last updated:", TrailerRef.Revision, (value) => Debug.Log(""), (value) => Debug.Log(""));
                TextField.tooltip = "This field shows the vehicle list revision date for the Bus, Trolley Bus, Fire and Police\n" +
                                    "trailers, which are in real life industry trailers, but have been re-categorized by AVO.";
                TextField.readOnly = true;

                // Support Section with Wiki and Output-Log

                UIHelperBase group_support = helper.AddGroup("Support");

                Button = (UIButton)group_support.AddButton("Open the Advanced Vehicle Options Wiki", () =>
                {
                    SimulationManager.instance.SimulationPaused = true;
                    Application.OpenURL("https://github.com/CityGecko/CS-AdvancedVehicleOptions/wiki");
                });
                Button.textScale = 0.8f;

                Button = (UIButton)group_support.AddButton("Open Cities:Skylines log folder (output_log.txt)", () =>
                {
                    Utils.OpenInFileBrowser(Application.dataPath);
                });
                Button.textScale = 0.8f;
            }

            catch (Exception e)
            {
                DebugUtils.Log("OnSettingsUI failed");
                DebugUtils.LogException(e);
            }
        }
 public void OnSettingsUI(UIHelperBase helper)
 {
     helper.AddOptionsGroup <CatenaryReplacerConfiguration>();
 }
Exemple #36
0
 public void OnSettingsUI(UIHelperBase helper)
 {
     Settings.OnSettingsUI(helper);
 }
Exemple #37
0
 /// <summary>
 /// Create the element on the helper
 /// </summary>
 /// <param name="helper">The UIHelper to attach the element to</param>
 public abstract UIComponent Create(UIHelperBase helper);
        public static void makeSettings(UIHelperBase helper)
        {
            // tabbing code is borrowed from RushHour mod
            // https://github.com/PropaneDragon/RushHour/blob/release/RushHour/Options/OptionHandler.cs

            UIHelper    actualHelper = helper as UIHelper;
            UIComponent container    = actualHelper.self as UIComponent;

            UITabstrip tabStrip = container.AddUIComponent <UITabstrip>();

            tabStrip.relativePosition = new Vector3(0, 0);
            tabStrip.size             = new Vector2(container.width - 20, 40);

            UITabContainer tabContainer = container.AddUIComponent <UITabContainer>();

            tabContainer.relativePosition = new Vector3(0, 40);
            tabContainer.size             = new Vector2(container.width - 20, container.height - tabStrip.height - 20);
            tabStrip.tabPages             = tabContainer;

            int tabIndex = 0;

            // GENERAL

            AddOptionTab(tabStrip, Translation.GetString("General"));            // tabStrip.AddTab(Translation.GetString("General"), tabTemplate, true);
            tabStrip.selectedIndex = tabIndex;

            UIPanel currentPanel = tabStrip.tabContainer.components[tabIndex] as UIPanel;

            currentPanel.autoLayout              = true;
            currentPanel.autoLayoutDirection     = LayoutDirection.Vertical;
            currentPanel.autoLayoutPadding.top   = 5;
            currentPanel.autoLayoutPadding.left  = 10;
            currentPanel.autoLayoutPadding.right = 10;

            UIHelper panelHelper = new UIHelper(currentPanel);

            simAccuracyDropdown = panelHelper.AddDropdown(Translation.GetString("Simulation_accuracy") + ":", new string[] { Translation.GetString("Very_high"), Translation.GetString("High"), Translation.GetString("Medium"), Translation.GetString("Low"), Translation.GetString("Very_Low") }, simAccuracy, onSimAccuracyChanged) as UIDropDown;

            var featureGroup = panelHelper.AddGroup(Translation.GetString("Activated_features"));

            enablePrioritySignsToggle        = featureGroup.AddCheckbox(Translation.GetString("Priority_signs"), prioritySignsEnabled, onPrioritySignsEnabledChanged) as UICheckBox;
            enableTimedLightsToggle          = featureGroup.AddCheckbox(Translation.GetString("Timed_traffic_lights"), timedLightsEnabled, onTimedLightsEnabledChanged) as UICheckBox;
            enableCustomSpeedLimitsToggle    = featureGroup.AddCheckbox(Translation.GetString("Speed_limits"), customSpeedLimitsEnabled, onCustomSpeedLimitsEnabledChanged) as UICheckBox;
            enableVehicleRestrictionsToggle  = featureGroup.AddCheckbox(Translation.GetString("Vehicle_restrictions"), vehicleRestrictionsEnabled, onVehicleRestrictionsEnabledChanged) as UICheckBox;
            enableJunctionRestrictionsToggle = featureGroup.AddCheckbox(Translation.GetString("Junction_restrictions"), junctionRestrictionsEnabled, onJunctionRestrictionsEnabledChanged) as UICheckBox;
            enableLaneConnectorToggle        = featureGroup.AddCheckbox(Translation.GetString("Lane_connector"), laneConnectorEnabled, onLaneConnectorEnabledChanged) as UICheckBox;

            // GAMEPLAY
            ++tabIndex;

            AddOptionTab(tabStrip, Translation.GetString("Gameplay"));
            tabStrip.selectedIndex = tabIndex;

            currentPanel                         = tabStrip.tabContainer.components[tabIndex] as UIPanel;
            currentPanel.autoLayout              = true;
            currentPanel.autoLayoutDirection     = LayoutDirection.Vertical;
            currentPanel.autoLayoutPadding.top   = 5;
            currentPanel.autoLayoutPadding.left  = 10;
            currentPanel.autoLayoutPadding.right = 10;

            panelHelper = new UIHelper(currentPanel);

            var vehBehaviorGroup = panelHelper.AddGroup(Translation.GetString("Vehicle_behavior"));

            recklessDriversDropdown            = vehBehaviorGroup.AddDropdown(Translation.GetString("Reckless_driving") + ":", new string[] { Translation.GetString("Path_Of_Evil_(10_%)"), Translation.GetString("Rush_Hour_(5_%)"), Translation.GetString("Minor_Complaints_(2_%)"), Translation.GetString("Holy_City_(0_%)") }, recklessDrivers, onRecklessDriversChanged) as UIDropDown;
            realisticSpeedsToggle              = vehBehaviorGroup.AddCheckbox(Translation.GetString("Realistic_speeds"), realisticSpeeds, onRealisticSpeedsChanged) as UICheckBox;
            strongerRoadConditionEffectsToggle = vehBehaviorGroup.AddCheckbox(Translation.GetString("Road_condition_has_a_bigger_impact_on_vehicle_speed"), strongerRoadConditionEffects, onStrongerRoadConditionEffectsChanged) as UICheckBox;
            enableDespawningToggle             = vehBehaviorGroup.AddCheckbox(Translation.GetString("Enable_despawning"), enableDespawning, onEnableDespawningChanged) as UICheckBox;

            var vehAiGroup = panelHelper.AddGroup(Translation.GetString("Advanced_Vehicle_AI"));

            advancedAIToggle = vehAiGroup.AddCheckbox(Translation.GetString("Enable_Advanced_Vehicle_AI"), advancedAI, onAdvancedAIChanged) as UICheckBox;
#if DEBUG
            //if (SystemInfo.processorCount >= DYNAMIC_RECALC_MIN_PROCESSOR_COUNT)
            //dynamicPathRecalculationToggle = vehAiGroup.AddCheckbox(Translation.GetString("Enable_dynamic_path_calculation"), dynamicPathRecalculation, onDynamicPathRecalculationChanged) as UICheckBox;
#endif
            highwayRulesToggle    = vehAiGroup.AddCheckbox(Translation.GetString("Enable_highway_specific_lane_merging/splitting_rules"), highwayRules, onHighwayRulesChanged) as UICheckBox;
            preferOuterLaneToggle = vehAiGroup.AddCheckbox(Translation.GetString("Heavy_trucks_prefer_outer_lanes_on_highways"), preferOuterLane, onPreferOuterLaneChanged) as UICheckBox;

            var parkAiGroup = panelHelper.AddGroup(Translation.GetString("Parking_AI"));
            prohibitPocketCarsToggle = parkAiGroup.AddCheckbox(Translation.GetString("Enable_more_realistic_parking") + " (BETA feature)", prohibitPocketCars, onProhibitPocketCarsChanged) as UICheckBox;

            // VEHICLE RESTRICTIONS
            ++tabIndex;

            AddOptionTab(tabStrip, Translation.GetString("Policies_&_Restrictions"));
            tabStrip.selectedIndex = tabIndex;

            currentPanel                         = tabStrip.tabContainer.components[tabIndex] as UIPanel;
            currentPanel.autoLayout              = true;
            currentPanel.autoLayoutDirection     = LayoutDirection.Vertical;
            currentPanel.autoLayoutPadding.top   = 5;
            currentPanel.autoLayoutPadding.left  = 10;
            currentPanel.autoLayoutPadding.right = 10;

            panelHelper = new UIHelper(currentPanel);

            var atJunctionsGroup = panelHelper.AddGroup(Translation.GetString("At_junctions"));
#if DEBUG
            allRelaxedToggle = atJunctionsGroup.AddCheckbox(Translation.GetString("All_vehicles_may_ignore_lane_arrows"), allRelaxed, onAllRelaxedChanged) as UICheckBox;
#endif
            relaxedBussesToggle = atJunctionsGroup.AddCheckbox(Translation.GetString("Busses_may_ignore_lane_arrows"), relaxedBusses, onRelaxedBussesChanged) as UICheckBox;
            allowEnterBlockedJunctionsToggle = atJunctionsGroup.AddCheckbox(Translation.GetString("Vehicles_may_enter_blocked_junctions"), allowEnterBlockedJunctions, onAllowEnterBlockedJunctionsChanged) as UICheckBox;
            allowUTurnsToggle = atJunctionsGroup.AddCheckbox(Translation.GetString("Vehicles_may_do_u-turns_at_junctions"), allowUTurns, onAllowUTurnsChanged) as UICheckBox;
            allowLaneChangesWhileGoingStraightToggle = atJunctionsGroup.AddCheckbox(Translation.GetString("Vehicles_going_straight_may_change_lanes_at_junctions"), allowLaneChangesWhileGoingStraight, onAllowLaneChangesWhileGoingStraightChanged) as UICheckBox;

            if (SteamHelper.IsDLCOwned(SteamHelper.DLC.NaturalDisastersDLC))
            {
                var inCaseOfEmergencyGroup = panelHelper.AddGroup(Translation.GetString("In_case_of_emergency"));
                evacBussesMayIgnoreRulesToggle = inCaseOfEmergencyGroup.AddCheckbox(Translation.GetString("Evacuation_busses_may_ignore_traffic_rules"), evacBussesMayIgnoreRules, onEvacBussesMayIgnoreRulesChanged) as UICheckBox;
            }

            // OVERLAYS
            ++tabIndex;

            AddOptionTab(tabStrip, Translation.GetString("Overlays"));
            tabStrip.selectedIndex = tabIndex;

            currentPanel                         = tabStrip.tabContainer.components[tabIndex] as UIPanel;
            currentPanel.autoLayout              = true;
            currentPanel.autoLayoutDirection     = LayoutDirection.Vertical;
            currentPanel.autoLayoutPadding.top   = 5;
            currentPanel.autoLayoutPadding.left  = 10;
            currentPanel.autoLayoutPadding.right = 10;

            panelHelper = new UIHelper(currentPanel);

            prioritySignsOverlayToggle        = panelHelper.AddCheckbox(Translation.GetString("Priority_signs"), prioritySignsOverlay, onPrioritySignsOverlayChanged) as UICheckBox;
            timedLightsOverlayToggle          = panelHelper.AddCheckbox(Translation.GetString("Timed_traffic_lights"), timedLightsOverlay, onTimedLightsOverlayChanged) as UICheckBox;
            speedLimitsOverlayToggle          = panelHelper.AddCheckbox(Translation.GetString("Speed_limits"), speedLimitsOverlay, onSpeedLimitsOverlayChanged) as UICheckBox;
            vehicleRestrictionsOverlayToggle  = panelHelper.AddCheckbox(Translation.GetString("Vehicle_restrictions"), vehicleRestrictionsOverlay, onVehicleRestrictionsOverlayChanged) as UICheckBox;
            junctionRestrictionsOverlayToggle = panelHelper.AddCheckbox(Translation.GetString("Junction_restrictions"), junctionRestrictionsOverlay, onJunctionRestrictionsOverlayChanged) as UICheckBox;
            connectedLanesOverlayToggle       = panelHelper.AddCheckbox(Translation.GetString("Connected_lanes"), connectedLanesOverlay, onConnectedLanesOverlayChanged) as UICheckBox;
            nodesOverlayToggle = panelHelper.AddCheckbox(Translation.GetString("Nodes_and_segments"), nodesOverlay, onNodesOverlayChanged) as UICheckBox;
            showLanesToggle    = panelHelper.AddCheckbox(Translation.GetString("Lanes"), showLanes, onShowLanesChanged) as UICheckBox;
#if DEBUG
            vehicleOverlayToggle  = panelHelper.AddCheckbox(Translation.GetString("Vehicles"), vehicleOverlay, onVehicleOverlayChanged) as UICheckBox;
            citizenOverlayToggle  = panelHelper.AddCheckbox(Translation.GetString("Citizens"), citizenOverlay, onCitizenOverlayChanged) as UICheckBox;
            buildingOverlayToggle = panelHelper.AddCheckbox(Translation.GetString("Buildings"), buildingOverlay, onBuildingOverlayChanged) as UICheckBox;
#endif

            // MAINTENANCE
            ++tabIndex;

            AddOptionTab(tabStrip, Translation.GetString("Maintenance"));
            tabStrip.selectedIndex = tabIndex;

            currentPanel                         = tabStrip.tabContainer.components[tabIndex] as UIPanel;
            currentPanel.autoLayout              = true;
            currentPanel.autoLayoutDirection     = LayoutDirection.Vertical;
            currentPanel.autoLayoutPadding.top   = 5;
            currentPanel.autoLayoutPadding.left  = 10;
            currentPanel.autoLayoutPadding.right = 10;

            panelHelper = new UIHelper(currentPanel);

            forgetTrafficLightsBtn = panelHelper.AddButton(Translation.GetString("Forget_toggled_traffic_lights"), onClickForgetToggledLights) as UIButton;
            resetStuckEntitiesBtn  = panelHelper.AddButton(Translation.GetString("Reset_stuck_cims_and_vehicles"), onClickResetStuckEntities) as UIButton;
#if DEBUG
            resetSpeedLimitsBtn = panelHelper.AddButton(Translation.GetString("Reset_custom_speed_limits"), onClickResetSpeedLimits) as UIButton;
#endif
            reloadGlobalConfBtn = panelHelper.AddButton(Translation.GetString("Reload_global_configuration"), onClickReloadGlobalConf) as UIButton;
            resetGlobalConfBtn  = panelHelper.AddButton(Translation.GetString("Reset_global_configuration"), onClickResetGlobalConf) as UIButton;
#if DEBUG
            // DEBUG

            /*++tabIndex;
             *
             * settingsButton = tabStrip.AddTab("Debug", tabTemplate, true);
             * settingsButton.textPadding = new RectOffset(10, 10, 10, 10);
             * settingsButton.autoSize = true;
             * settingsButton.tooltip = "Debug";
             *
             * currentPanel = tabStrip.tabContainer.components[tabIndex] as UIPanel;
             * currentPanel.autoLayout = true;
             * currentPanel.autoLayoutDirection = LayoutDirection.Vertical;
             * currentPanel.autoLayoutPadding.top = 5;
             * currentPanel.autoLayoutPadding.left = 10;
             * currentPanel.autoLayoutPadding.right = 10;
             *
             * panelHelper = new UIHelper(currentPanel);
             *
             * debugSwitchFields.Clear();
             * for (int i = 0; i < debugSwitches.Length; ++i) {
             *      int index = i;
             *      string varName = $"Debug switch #{i}";
             *      debugSwitchFields.Add(panelHelper.AddCheckbox(varName, debugSwitches[i], delegate (bool newVal) { onBoolValueChanged(varName, newVal, ref debugSwitches[index]); }) as UICheckBox);
             * }
             *
             * debugValueFields.Clear();
             * for (int i = 0; i < debugValues.Length; ++i) {
             *      int index = i;
             *      string varName = $"Debug value #{i}";
             *      debugValueFields.Add(panelHelper.AddTextfield(varName, String.Format("{0:0.##}", debugValues[i]), delegate(string newValStr) { onFloatValueChanged(varName, newValStr, ref debugValues[index]); }, null) as UITextField);
             * }*/
#endif

            tabStrip.selectedIndex = 0;
        }
Exemple #39
0
        /// <summary>
        /// Define components for settings UI.
        ///
        /// Full settings are rendered at main menu; only partial settings are rendered in-game.
        /// </summary>
        ///
        /// <param name="helper">UI helper from the game.</param>
        /// <param name="scene">The currently active scene from <c>SceneManager.GetActiveScene()</c>.</param>
        public static void Render(UIHelperBase helper, string scene)
        {
            UIHelperBase group;
            bool         selected = false;
            string       path, caption;

            group = helper.AddGroup("Announcements");

            if (Announcements.Notes.Count > 0)
            {
                foreach (KeyValuePair <ulong, string> entry in Announcements.Notes)
                {
                    selected = Announce(group, entry.Key, entry.Value) || selected;
                }
            }

            if (!selected)
            {
                Announce(group, 0u, "There are currently no announcements.");
            }

            group = helper.AddGroup("Log File Options");

            if (Application.platform == RuntimePlatform.OSXPlayer)
            {
                caption = "Search for 'AutoRepair Descriptors' in this file:";
                path    = "~/Library/Logs/Unity/Player.log"; // only way I could get logging working on Macs (see also: Log.cs)
            }
            else
            {
                if (Application.platform == RuntimePlatform.WindowsPlayer)
                {
                    caption = "Copy this path in to Windows File Explorer to view log file:";
                }
                else
                {
                    caption = "Copy this path for log file location:";
                }
                path = Log.LogFile;
            }

            UITextField field = (UITextField)group.AddTextfield(caption, path, _ => { });

            field.selectOnFocus = true;
            field.width         = 650f;

            if (Application.platform == RuntimePlatform.WindowsPlayer)
            {
                group.AddButton("Open File Explorer", () => System.Diagnostics.Process.Start("explorer.exe", "/select," + path));
            }
            //Utils.OpenInFileBrowser(Application.dataPath); -- works on mac/linux, but need further testing

            if (scene == "Game")
            {
                return;
            }

            selected = Options.Instance.LogIntroText;
            group.AddCheckbox("Add notes on mod management at top of log file", selected, sel => {
                Options.Instance.LogIntroText = sel;
                Options.Instance.Save();
                Scanner.PerformScan();
            });

            selected = Options.Instance.LogLanguages;
            group.AddCheckbox("Include details of languages/translations (where applicable)", selected, sel => {
                Options.Instance.LogLanguages = sel;
                Options.Instance.Save();
                Scanner.PerformScan();
            });

            selected = Options.Instance.LogWorkshopURLs;
            group.AddCheckbox("Include URLs to Steam Workshop pages (if known)", selected, sel => {
                Options.Instance.LogWorkshopURLs = sel;
                Options.Instance.Save();
                Scanner.PerformScan();
            });

            selected = Options.Instance.LogSourceURLs;
            group.AddCheckbox("Include URLs to source files (if known)", selected, sel => {
                Options.Instance.LogSourceURLs = sel;
                Options.Instance.Save();
                Scanner.PerformScan();
            });

            selected = Options.Instance.LogDescriptorHeaders;
            group.AddCheckbox("Include descriptor headers (not recommended)", selected, sel => {
                Options.Instance.LogDescriptorHeaders = sel;
                Options.Instance.Save();
                Scanner.PerformScan();
            });

#if DEBUG
            group.AddButton("Dump CSV", () => {
                Catalog.Instance.DumpToCSV();
            });
#endif
        }
        public void OnSettingsUI(UIHelperBase helper)
        {
            LoadSettings();
            UIDropDown uIDropDown = (UIDropDown)helper.AddDropdown("Select Preset", EmergencyLightPresets, SelectedPreset, delegate(int sel)
            {
                if (sel == 1)
                {
                    CustomSettingsVisibility = true;
                }
                else
                {
                    CustomSettingsVisibility = false;
                }
                SelectedPreset = sel;
                if (loaded)
                {
                    Apply();
                }
            });
            UIScrollablePanel uIScrollablePanel = ((UIHelper)helper).self as UIScrollablePanel;

            uIScrollablePanel.autoLayout = false;
            int num  = 100;
            int num2 = 10;
            int num3 = 40;

            strip = uIScrollablePanel.AddUIComponent <UITabstrip>();
            strip.relativePosition = new Vector3(num2, num);
            strip.size             = new Vector2(744 - num2, num3);
            container = uIScrollablePanel.AddUIComponent <UITabContainer>();
            container.relativePosition = new Vector3(num2, num3 + num);
            container.size             = new Vector3(744 - num2, 713 - num);
            strip.tabPages             = container;
            UIButton uIButton  = (UIButton)UITemplateManager.Peek("OptionsButtonTemplate");
            UIButton uIButton2 = strip.AddTab("Police Car", uIButton, fillText: true);

            uIButton2.textColor         = uIButton.textColor;
            uIButton2.pressedTextColor  = uIButton.pressedTextColor;
            uIButton2.hoveredTextColor  = uIButton.hoveredTextColor;
            uIButton2.focusedTextColor  = uIButton.hoveredTextColor;
            uIButton2.disabledTextColor = uIButton.hoveredTextColor;
            UIPanel uIPanel = strip.tabContainer.components[0] as UIPanel;

            uIPanel.autoLayout          = true;
            uIPanel.wrapLayout          = true;
            uIPanel.autoLayoutDirection = LayoutDirection.Horizontal;
            UIHelper uIHelper = new UIHelper(uIPanel);

            uIHelper.AddSpace(15);
            uIHelper.AddDropdown("Left", ColorNames, Array.IndexOf(ColorNames, settings[Setting.PoliceLeft]), delegate(int sel)
            {
                settings[Setting.PoliceLeft] = ColorNames[sel];
                ExportSettings();
                if (loaded)
                {
                    Apply();
                }
            });
            uIHelper.AddDropdown("Right", ColorNames, Array.IndexOf(ColorNames, settings[Setting.PoliceRight]), delegate(int sel)
            {
                settings[Setting.PoliceRight] = ColorNames[sel];
                ExportSettings();
                if (loaded)
                {
                    Apply();
                }
            });
            uIButton2                   = strip.AddTab("Fire Truck");
            uIButton2.textColor         = uIButton.textColor;
            uIButton2.pressedTextColor  = uIButton.pressedTextColor;
            uIButton2.hoveredTextColor  = uIButton.hoveredTextColor;
            uIButton2.focusedTextColor  = uIButton.hoveredTextColor;
            uIButton2.disabledTextColor = uIButton.hoveredTextColor;
            uIPanel                     = (strip.tabContainer.components[1] as UIPanel);
            uIPanel.autoLayout          = true;
            uIPanel.wrapLayout          = true;
            uIPanel.autoLayoutDirection = LayoutDirection.Horizontal;
            uIHelper                    = new UIHelper(uIPanel);
            uIHelper.AddSpace(15);
            uIHelper.AddDropdown("Left", ColorNames, Array.IndexOf(ColorNames, settings[Setting.FireLeft]), delegate(int sel)
            {
                settings[Setting.FireLeft] = ColorNames[sel];
                ExportSettings();
                if (loaded)
                {
                    Apply();
                }
            });
            uIHelper.AddDropdown("Right", ColorNames, Array.IndexOf(ColorNames, settings[Setting.FireRight]), delegate(int sel)
            {
                settings[Setting.FireRight] = ColorNames[sel];
                ExportSettings();
                if (loaded)
                {
                    Apply();
                }
            });
            uIHelper.AddSpace(15);
            chkManualRearFire = (uIHelper.AddCheckbox("Configure Rear Lights Separately", Convert.ToBoolean(settings[Setting.ManualRearFire]), delegate(bool chkd)
            {
                settings[Setting.ManualRearFire] = chkd.ToString();
                ExportSettings();
                RearFireVisibility(chkd);
                if (loaded)
                {
                    Apply();
                }
            }) as UICheckBox);
            chkManualRearFire.width = 744f;
            uIHelper.AddSpace(15);
            ddFireLeftRear = (UIDropDown)uIHelper.AddDropdown("Left", ColorNames, Array.IndexOf(ColorNames, settings[Setting.FireLeftRear]), delegate(int sel)
            {
                settings[Setting.FireLeftRear] = ColorNames[sel];
                ExportSettings();
                if (loaded)
                {
                    Apply();
                }
            });
            ddFireRightRear = (UIDropDown)uIHelper.AddDropdown("Right", ColorNames, Array.IndexOf(ColorNames, settings[Setting.FireRightRear]), delegate(int sel)
            {
                settings[Setting.FireRightRear] = ColorNames[sel];
                ExportSettings();
                if (loaded)
                {
                    Apply();
                }
            });
            RearFireVisibility(Convert.ToBoolean(settings[Setting.ManualRearFire]));
            uIButton2                   = strip.AddTab("Ambulance");
            uIButton2.textColor         = uIButton.textColor;
            uIButton2.pressedTextColor  = uIButton.pressedTextColor;
            uIButton2.hoveredTextColor  = uIButton.hoveredTextColor;
            uIButton2.focusedTextColor  = uIButton.hoveredTextColor;
            uIButton2.disabledTextColor = uIButton.hoveredTextColor;
            uIPanel                     = (strip.tabContainer.components[2] as UIPanel);
            uIPanel.autoLayout          = true;
            uIPanel.wrapLayout          = true;
            uIPanel.autoLayoutDirection = LayoutDirection.Horizontal;
            uIHelper                    = new UIHelper(uIPanel);
            uIHelper.AddSpace(15);
            uIHelper.AddDropdown("Left", ColorNames, Array.IndexOf(ColorNames, settings[Setting.AmbulanceLeft]), delegate(int sel)
            {
                settings[Setting.AmbulanceLeft] = ColorNames[sel];
                ExportSettings();
                if (loaded)
                {
                    Apply();
                }
            });
            uIHelper.AddDropdown("Right", ColorNames, Array.IndexOf(ColorNames, settings[Setting.AmbulanceRight]), delegate(int sel)
            {
                settings[Setting.AmbulanceRight] = ColorNames[sel];
                ExportSettings();
                if (loaded)
                {
                    Apply();
                }
            });
            uIHelper.AddSpace(15);
            chkManualRearAmbulance = (uIHelper.AddCheckbox("Configure Rear Lights Separately", Convert.ToBoolean(settings[Setting.ManualRearAmbulance]), delegate(bool chkd)
            {
                settings[Setting.ManualRearAmbulance] = chkd.ToString();
                ExportSettings();
                RearAmbulanceVisibility(chkd);
                if (loaded)
                {
                    Apply();
                }
            }) as UICheckBox);
            chkManualRearAmbulance.width = 744f;
            uIHelper.AddSpace(15);
            ddAmbulanceLeftRear = (UIDropDown)uIHelper.AddDropdown("Left", ColorNames, Array.IndexOf(ColorNames, settings[Setting.AmbulanceLeftRear]), delegate(int sel)
            {
                settings[Setting.AmbulanceLeftRear] = ColorNames[sel];
                ExportSettings();
                if (loaded)
                {
                    Apply();
                }
            });
            ddAmbulanceRightRear = (UIDropDown)uIHelper.AddDropdown("Right", ColorNames, Array.IndexOf(ColorNames, settings[Setting.AmbulanceRightRear]), delegate(int sel)
            {
                settings[Setting.AmbulanceRightRear] = ColorNames[sel];
                ExportSettings();
                if (loaded)
                {
                    Apply();
                }
            });
            RearAmbulanceVisibility(Convert.ToBoolean(settings[Setting.ManualRearAmbulance]));

            uIButton2                   = strip.AddTab("Rotary (e.g. Snow Plow)", uIButton, fillText: true);
            uIButton2.textColor         = uIButton.textColor;
            uIButton2.pressedTextColor  = uIButton.pressedTextColor;
            uIButton2.hoveredTextColor  = uIButton.hoveredTextColor;
            uIButton2.focusedTextColor  = uIButton.hoveredTextColor;
            uIButton2.disabledTextColor = uIButton.hoveredTextColor;
            uIPanel                     = strip.tabContainer.components[3] as UIPanel;
            uIPanel.autoLayout          = true;
            uIPanel.wrapLayout          = true;
            uIPanel.autoLayoutDirection = LayoutDirection.Horizontal;
            uIHelper                    = new UIHelper(uIPanel);
            uIHelper.AddSpace(15);
            uIHelper.AddDropdown("Left", ColorNames, Array.IndexOf(ColorNames, settings[Setting.SnowPlowLeft]), delegate(int sel)
            {
                settings[Setting.SnowPlowLeft] = ColorNames[sel];
                ExportSettings();
                if (loaded)
                {
                    Apply();
                }
            });
            uIHelper.AddDropdown("Right", ColorNames, Array.IndexOf(ColorNames, settings[Setting.SnowPlowRight]), delegate(int sel)
            {
                settings[Setting.SnowPlowRight] = ColorNames[sel];
                ExportSettings();
                if (loaded)
                {
                    Apply();
                }
            });

            strip.selectedIndex = -1;
            strip.selectedIndex = 0;
            int selectedIndex = uIDropDown.selectedIndex;

            uIDropDown.selectedIndex = -1;
            uIDropDown.selectedIndex = selectedIndex;
        }
        public void OnSettingsUI(UIHelperBase uiHelperBase)
        {
            var uiHelper = uiHelperBase.AsStronglyTyped();

            ConfigureOptionsPanel(uiHelper);
        }
        internal static void MakeSettings_Gameplay(ExtUITabstrip tabStrip)
        {
            UIHelper panelHelper = tabStrip.AddTabPage(Translation.Options.Get("Tab:Gameplay"));

            UIHelperBase vehBehaviorGroup = panelHelper.AddGroup(
                Translation.Options.Get("Gameplay.Group:Vehicle behavior"));

            _recklessDriversDropdown
                = vehBehaviorGroup.AddDropdown(
                      Translation.Options.Get("Gameplay.Dropdown:Reckless drivers%") + ":",
                      new[] {
                Translation.Options.Get("Gameplay.Dropdown.Option:Path Of Evil (10%)"),
                Translation.Options.Get("Gameplay.Dropdown.Option:Rush Hour (5%)"),
                Translation.Options.Get("Gameplay.Dropdown.Option:Minor Complaints (2%)"),
                Translation.Options.Get("Gameplay.Dropdown.Option:Holy City (0%)"),
            },
                      Options.recklessDrivers,
                      OnRecklessDriversChanged) as UIDropDown;
            _recklessDriversDropdown.width = 350;
            _individualDrivingStyleToggle
                = vehBehaviorGroup.AddCheckbox(
                      Translation.Options.Get("Gameplay.Checkbox:Individual driving styles"),
                      Options.individualDrivingStyle,
                      onIndividualDrivingStyleChanged) as UICheckBox;

            if (SteamHelper.IsDLCOwned(SteamHelper.DLC.SnowFallDLC))
            {
                _strongerRoadConditionEffectsToggle
                    = vehBehaviorGroup.AddCheckbox(
                          Translation.Options.Get("Gameplay.Checkbox:Increase road condition impact"),
                          Options.strongerRoadConditionEffects,
                          OnStrongerRoadConditionEffectsChanged) as UICheckBox;
            }

            // TODO: Duplicates main menu button function
            _disableDespawningToggle = vehBehaviorGroup.AddCheckbox(
                Translation.Options.Get("Maintenance.Checkbox:Disable despawning"),
                Options.disableDespawning,
                onDisableDespawningChanged) as UICheckBox;

            UIHelperBase vehAiGroup = panelHelper.AddGroup(
                Translation.Options.Get("Gameplay.Group:Advanced vehicle AI"));

            _advancedAIToggle = vehAiGroup.AddCheckbox(
                Translation.Options.Get("Gameplay.Checkbox:Enable advanced vehicle AI"),
                Options.advancedAI,
                OnAdvancedAiChanged) as UICheckBox;
            _altLaneSelectionRatioSlider
                = vehAiGroup.AddSlider(
                      Translation.Options.Get("Gameplay.Slider:Dynamic lane selection") + ":",
                      0,
                      100,
                      5,
                      Options.altLaneSelectionRatio,
                      OnAltLaneSelectionRatioChanged) as UISlider;
            _altLaneSelectionRatioSlider.parent.Find <UILabel>("Label").width = 450;

            UIHelperBase parkAiGroup = panelHelper.AddGroup(
                Translation.Options.Get("Gameplay.Group:Parking AI"));

            _prohibitPocketCarsToggle
                = parkAiGroup.AddCheckbox(
                      Translation.Options.Get("Gameplay.Checkbox:Enable more realistic parking"),
                      Options.parkingAI,
                      OnProhibitPocketCarsChanged) as UICheckBox;

            UIHelperBase ptGroup = panelHelper.AddGroup(
                Translation.Options.Get("Gameplay.Group:Public transport"));

            _realisticPublicTransportToggle
                = ptGroup.AddCheckbox(
                      Translation.Options.Get("Gameplay.Checkbox:No excessive transfers"),
                      Options.realisticPublicTransport,
                      OnRealisticPublicTransportChanged) as UICheckBox;
        }
        /// <summary>
        /// Creates the log group.
        /// </summary>
        /// <param name="helper">The helper.</param>
        /// <returns>The group.</returns>
        private UIHelperBase CreateLogGroup(UIHelperBase helper)
        {
            try
            {
                UIHelperBase group = helper.AddGroup("Logging (not saved in settings)");

                UIComponent debugLog = null;
                UIComponent devLog = null;
                UIComponent objectLog = null;
                UIComponent namesLog = null;
                UIComponent fileLog = null;

                debugLog = group.AddCheckbox(
                    "Debug log",
                    Log.LogDebug,
                    value =>
                    {
                        try
                        {
                            if (!this.updatingLogControls)
                            {
                                Log.LogDebug = value;
                                UpdateLogControls(debugLog, devLog, objectLog, namesLog, fileLog);
                            }
                        }
                        catch (Exception ex)
                        {
                            Log.Error(this, "CreateLogGroup", ex, "LogDebug", value);
                        }
                    }) as UIComponent;

                devLog = group.AddCheckbox(
                    "Developer log",
                    Log.LogALot,
                    value =>
                    {
                        try
                        {
                            if (!this.updatingLogControls)
                            {
                                Log.LogALot = value;
                                UpdateLogControls(debugLog, devLog, objectLog, namesLog, fileLog);
                            }
                        }
                        catch (Exception ex)
                        {
                            Log.Error(this, "CreateLogGroup", ex, "LogALot", value);
                        }
                    }) as UIComponent;

                objectLog = group.AddCheckbox(
                    "Object list log",
                    Log.LogDebugLists,
                    value =>
                    {
                        try
                        {
                            if (!this.updatingLogControls)
                            {
                                Log.LogDebugLists = value;
                                UpdateLogControls(debugLog, devLog, objectLog, namesLog, fileLog);
                            }
                        }
                        catch (Exception ex)
                        {
                            Log.Error(this, "CreateLogGroup", ex, "LogDebugLists", value);
                        }
                    }) as UIComponent;

                namesLog = group.AddCheckbox(
                    "Log names",
                    Log.LogNames,
                    value =>
                    {
                        try
                        {
                            if (!this.updatingLogControls)
                            {
                                Log.LogNames = value;
                                UpdateLogControls(debugLog, devLog, objectLog, namesLog, fileLog);
                            }
                        }
                        catch (Exception ex)
                        {
                            Log.Error(this, "CreateLogGroup", ex, "LogNames", value);
                        }
                    }) as UIComponent;

                fileLog = group.AddCheckbox(
                    "Log to file",
                    Log.LogToFile,
                    value =>
                    {
                        try
                        {
                            if (!this.updatingLogControls)
                            {
                                Log.LogToFile = value;
                                UpdateLogControls(debugLog, devLog, objectLog, namesLog, fileLog);
                            }
                        }
                        catch (Exception ex)
                        {
                            Log.Error(this, "CreateLogGroup", ex, "LogToFile", value);
                        }
                    }) as UIComponent;

                return group;
            }
            catch (Exception ex)
            {
                Log.Error(this, "CreateLogGroup", ex);
                return null;
            }
        }
Exemple #44
0
        private void TranslateGroupItems(UIButton saveButton, UIHelperBase group, string groupTranslationId)
        {
            if (saveButton != null && group != null)
            {
                if (_toolBase.Translation.HasTranslation("OptionButton_Apply"))
                {
                    saveButton.text = _toolBase.Translation.GetTranslation("OptionButton_Apply");
                }
                else
                {
                    _toolBase.DetailedLogger.LogWarning("There is no option group translation for the options apply button!");
                }

                if (groupTranslationId != null && _toolBase.Translation.HasTranslation("OptionGroup_" + groupTranslationId))
                {
                    _toolBase.DetailedLogger.Log("Translating option " + groupTranslationId);

                    UIHelper mainHelper = group as UIHelper;

                    if (mainHelper != null)
                    {
                        _toolBase.DetailedLogger.Log("Found group helper");

                        UIComponent uiComponent = mainHelper.self as UIComponent;

                        if (uiComponent != null)
                        {
                            _toolBase.DetailedLogger.Log("Found group UIComponent");

                            UIComponent parent = uiComponent.parent;
                            UILabel     label  = parent.Find <UILabel>("Label");

                            if (label != null)
                            {
                                _toolBase.DetailedLogger.Log("Found group label");
                                label.text = _toolBase.Translation.GetTranslation("OptionGroup_" + groupTranslationId);
                            }
                            else
                            {
                                _toolBase.DetailedLogger.LogWarning("The group has no label to translate!");
                            }
                        }
                        else
                        {
                            _toolBase.DetailedLogger.LogWarning("Could not find the UIComponent for the group!");
                        }
                    }
                    else
                    {
                        _toolBase.DetailedLogger.LogWarning("There is no helper for the group!");
                    }
                }
                else
                {
                    _toolBase.DetailedLogger.LogWarning("There is no option group translation for " + groupTranslationId);
                }
            }
            else
            {
                _toolBase.DetailedLogger.LogWarning("The button or the helper are invalid");
            }
        }
 /// <summary>
 /// Called by the game when the mod options panel is setup.
 /// </summary>
 public void OnSettingsUI(UIHelperBase helper)
 {
     // Setup options panel reference.
     OptionsPanel.optionsPanel            = ((UIHelper)helper).self as UIScrollablePanel;
     OptionsPanel.optionsPanel.autoLayout = false;
 }
        internal static void MakeSettings_VehicleRestrictions(ExtUITabstrip tabStrip)
        {
            UIHelper     panelHelper      = tabStrip.AddTabPage(Translation.Options.Get("Tab:Policies & Restrictions"));
            UIHelperBase atJunctionsGroup = panelHelper.AddGroup(
                Translation.Options.Get("VR.Group:At junctions"));

#if DEBUG
            _allRelaxedToggle
                = atJunctionsGroup.AddCheckbox(
                      Translation.Options.Get("VR.Checkbox:All vehicles may ignore lane arrows"),
                      Options.allRelaxed,
                      OnAllRelaxedChanged) as UICheckBox;
#endif
            _relaxedBussesToggle
                = atJunctionsGroup.AddCheckbox(
                      Translation.Options.Get("VR.Checkbox:Buses may ignore lane arrows"),
                      Options.relaxedBusses,
                      OnRelaxedBussesChanged) as UICheckBox;
            _allowEnterBlockedJunctionsToggle
                = atJunctionsGroup.AddCheckbox(
                      Translation.Options.Get("VR.Checkbox:Vehicles may enter blocked junctions"),
                      Options.allowEnterBlockedJunctions,
                      OnAllowEnterBlockedJunctionsChanged) as UICheckBox;
            _allowUTurnsToggle
                = atJunctionsGroup.AddCheckbox(
                      Translation.Options.Get("VR.Checkbox:Vehicles may do u-turns at junctions"),
                      Options.allowUTurns,
                      OnAllowUTurnsChanged) as UICheckBox;
            _allowNearTurnOnRedToggle
                = atJunctionsGroup.AddCheckbox(
                      Translation.Options.Get("VR.Checkbox:Vehicles may turn on red"),
                      Options.allowNearTurnOnRed,
                      OnAllowNearTurnOnRedChanged) as UICheckBox;
            _allowFarTurnOnRedToggle
                = atJunctionsGroup.AddCheckbox(
                      Translation.Options.Get("VR.Checkbox:Also apply to left/right turns between one-way streets"),
                      Options.allowFarTurnOnRed,
                      OnAllowFarTurnOnRedChanged) as UICheckBox;
            _allowLaneChangesWhileGoingStraightToggle
                = atJunctionsGroup.AddCheckbox(
                      Translation.Options.Get("VR.Checkbox:Vehicles going straight may change lanes at junctions"),
                      Options.allowLaneChangesWhileGoingStraight,
                      OnAllowLaneChangesWhileGoingStraightChanged) as UICheckBox;
            _trafficLightPriorityRulesToggle
                = atJunctionsGroup.AddCheckbox(
                      Translation.Options.Get("VR.Checkbox:Vehicles follow priority rules at junctions with timedTL"),
                      Options.trafficLightPriorityRules,
                      OnTrafficLightPriorityRulesChanged) as UICheckBox;
            _automaticallyAddTrafficLightsIfApplicableToggle
                = atJunctionsGroup.AddCheckbox(
                      Translation.Options.Get("VR.Checkbox:Automatically add traffic lights if applicable"),
                      Options.automaticallyAddTrafficLightsIfApplicable,
                      OnAutomaticallyAddTrafficLightsIfApplicableChanged) as UICheckBox;

            Options.Indent(_allowFarTurnOnRedToggle);

            UIHelperBase onRoadsGroup =
                panelHelper.AddGroup(Translation.Options.Get("VR.Group:On roads"));

            _vehicleRestrictionsAggressionDropdown
                = onRoadsGroup.AddDropdown(
                      Translation.Options.Get("VR.Dropdown:Vehicle restrictions aggression") + ":",
                      new[] {
                Translation.Options.Get("VR.Dropdown.Option:Low Aggression"),
                Translation.Options.Get("VR.Dropdown.Option:Medium Aggression"),
                Translation.Options.Get("VR.Dropdown.Option:High Aggression"),
                Translation.Options.Get("VR.Dropdown.Option:Strict"),
            },
                      (int)Options.vehicleRestrictionsAggression,
                      OnVehicleRestrictionsAggressionChanged) as UIDropDown;
            _banRegularTrafficOnBusLanesToggle
                = onRoadsGroup.AddCheckbox(
                      Translation.Options.Get("VR.Checkbox:Ban private cars and trucks on bus lanes"),
                      Options.banRegularTrafficOnBusLanes,
                      OnBanRegularTrafficOnBusLanesChanged) as UICheckBox;
            _highwayRulesToggle
                = onRoadsGroup.AddCheckbox(
                      Translation.Options.Get("VR.Checkbox:Enable highway merging/splitting rules"),
                      Options.highwayRules,
                      OnHighwayRulesChanged) as UICheckBox;
            _preferOuterLaneToggle
                = onRoadsGroup.AddCheckbox(
                      Translation.Options.Get("VR.Checkbox:Heavy trucks prefer outer lanes on highways"),
                      Options.preferOuterLane,
                      OnPreferOuterLaneChanged) as UICheckBox;

            if (SteamHelper.IsDLCOwned(SteamHelper.DLC.NaturalDisastersDLC))
            {
                UIHelperBase inCaseOfEmergencyGroup =
                    panelHelper.AddGroup(
                        Translation.Options.Get("VR.Group:In case of emergency/disaster"));

                _evacBussesMayIgnoreRulesToggle
                    = inCaseOfEmergencyGroup.AddCheckbox(
                          Translation.Options.Get("VR.Checkbox:Evacuation buses may ignore traffic rules"),
                          Options.evacBussesMayIgnoreRules,
                          OnEvacBussesMayIgnoreRulesChanged) as UICheckBox;
            }

            NoDoubleCrossings.AddUI(onRoadsGroup);

            OptionsMassEditTab.MakePanel_MassEdit(panelHelper);
        }
Exemple #47
0
        public void OnSettingsUI(UIHelperBase helper)
        {
            UIHelper hp = (UIHelper)helper;
            UIScrollablePanel panel = (UIScrollablePanel)hp.self;
            panel.eventVisibilityChanged += eventVisibilityChanged;

            //string[] sOptions = new string[]{"8 - (JustTheTip)","16 - (Default)","24 - (Medium)","32 - (Large)","48 - (Very Large)","64 - (Massive)","96 - (Really WTF?)","128 - (FixYourMap!)","Custom - (SetInConfigFile)"};
            UIHelperBase group = helper.AddGroup("CSLShowMoreLimits");
            //group.AddDropdown("Number of Reserved Vehicles:", sOptions, GetOptionIndexFromValue(config.VehicleReserveAmount) , ReservedVehiclesChanged);
            group.AddCheckbox("Enable GUI (CTRL + L)", IsGuiEnabled, OnUseGuiToggle);
            group.AddCheckbox("Auto show on map load", config.AutoShowOnMapLoad, UpdateUseAutoShowOnMapLoad);
            group.AddCheckbox("Dump Stats to log on map exit", config.DumpStatsOnMapEnd, OnDumpStatsAtMapEnd);
            group.AddCheckbox("Enable Verbose Logging", DEBUG_LOG_ON, LoggingChecked);
            group.AddCheckbox("Use alternate keybinding", config.UseAlternateKeyBinding, OnUseAlternateKeyBinding);
            group.AddSpace(20);
            if (Application.platform == RuntimePlatform.WindowsPlayer)
            {
                group.AddButton("Open config file (Windows™ only)", OpenConfigFile);
            }
        }
Exemple #48
0
        public static void Create(UIHelperBase helper)
        {
            if (helper.AddButton(LocalisationHolder.Translate(LocalisationHolder.CurrentLocalisation.Settings_SaveToDisk), new OnButtonClicked(() => UserModSettings.Save())) is UIButton saveToDiskButton)
            {
                saveToDiskButton.tooltip = LocalisationHolder.Translate(LocalisationHolder.CurrentLocalisation.Settings_SaveToDisk_Tooltip);
            }

            helper.AddSpace(10);

            var core = helper.AddGroup(LocalisationHolder.Translate(LocalisationHolder.CurrentLocalisation.Settings_Group_Core));
            {
                core.AddDropdown(LocalisationHolder.Translate(LocalisationHolder.CurrentLocalisation.Settings_Core_Language), LocalisationHolder.Localisations.Select(localisation => localisation.ReadableName).ToArray(), LocalisationHolder.CurrentLocalisationIndex, new OnDropdownSelectionChanged(index => UserModSettings.Settings.Language = LocalisationHolder.Localisations[index].ReadableName));
                core.AddCheckbox(LocalisationHolder.Translate(LocalisationHolder.CurrentLocalisation.Settings_Core_Enabled), UserModSettings.Settings.Enabled, new OnCheckChanged(value => UserModSettings.Settings.Enabled = value));
                core.AddCheckbox(LocalisationHolder.Translate(LocalisationHolder.CurrentLocalisation.Settings_Core_ModifyCitizenBehaviour), UserModSettings.Settings.Citizens_Override, new OnCheckChanged(value => UserModSettings.Settings.Citizens_Override = value));
                core.AddCheckbox(LocalisationHolder.Translate(LocalisationHolder.CurrentLocalisation.Settings_Core_ModifyTouristBehaviour), UserModSettings.Settings.Tourists_Override, new OnCheckChanged(value => UserModSettings.Settings.Tourists_Override = value));
            }

            var time = helper.AddGroup(LocalisationHolder.Translate(LocalisationHolder.CurrentLocalisation.Settings_Group_Time));
            {
                time.AddCheckbox(LocalisationHolder.Translate(LocalisationHolder.CurrentLocalisation.Settings_Time_ModifyDateTimeBar), UserModSettings.Settings.DateTimeBar_Modify, new OnCheckChanged(value => UserModSettings.Settings.DateTimeBar_Modify = value));
                time.AddCheckbox(LocalisationHolder.Translate(LocalisationHolder.CurrentLocalisation.Settings_Time_24hrTime), UserModSettings.Settings.Time_24Hour, new OnCheckChanged(value => UserModSettings.Settings.Time_24Hour = value));
            }

            var schoolHours = helper.AddGroup(LocalisationHolder.Translate(LocalisationHolder.CurrentLocalisation.Settings_Group_School));
            {
                schoolHours.AddTimeSpanHoursSlider(LocalisationHolder.Translate(LocalisationHolder.CurrentLocalisation.Settings_School_StartTime), TimeSpan.FromHours(6), TimeSpan.FromHours(11), UserModSettings.Settings.StartTime_Schools, new OnValueChanged(value => UserModSettings.Settings.StartTime_Schools = TimeSpan.FromHours(value)));
                schoolHours.AddTimeSpanHoursSlider(LocalisationHolder.Translate(LocalisationHolder.CurrentLocalisation.Settings_School_Duration), TimeSpan.FromHours(5), TimeSpan.FromHours(15), UserModSettings.Settings.Duration_Schools, new OnValueChanged(value => UserModSettings.Settings.Duration_Schools    = TimeSpan.FromHours(value)), LocalisationHolder.CurrentLocalisation.Settings_School_DurationFormat);
            }

            var universityHours = helper.AddGroup(LocalisationHolder.Translate(LocalisationHolder.CurrentLocalisation.Settings_Group_University));
            {
                universityHours.AddTimeSpanHoursSlider(LocalisationHolder.Translate(LocalisationHolder.CurrentLocalisation.Settings_University_StartTime), TimeSpan.FromHours(6), TimeSpan.FromHours(11), UserModSettings.Settings.StartTime_University, new OnValueChanged(value => UserModSettings.Settings.StartTime_University = TimeSpan.FromHours(value)));
                universityHours.AddTimeSpanHoursSlider(LocalisationHolder.Translate(LocalisationHolder.CurrentLocalisation.Settings_University_Duration), TimeSpan.FromHours(5), TimeSpan.FromHours(15), UserModSettings.Settings.Duration_University, new OnValueChanged(value => UserModSettings.Settings.Duration_University    = TimeSpan.FromHours(value)), LocalisationHolder.CurrentLocalisation.Settings_University_DurationFormat);
            }

            var workHours = helper.AddGroup(LocalisationHolder.Translate(LocalisationHolder.CurrentLocalisation.Settings_Group_Work));
            {
                workHours.AddTimeSpanHoursSlider(LocalisationHolder.Translate(LocalisationHolder.CurrentLocalisation.Settings_Work_StartTime), TimeSpan.FromHours(6), TimeSpan.FromHours(11), UserModSettings.Settings.StartTime_Work, new OnValueChanged(value => UserModSettings.Settings.StartTime_Work = TimeSpan.FromHours(value)));
                workHours.AddTimeSpanHoursSlider(LocalisationHolder.Translate(LocalisationHolder.CurrentLocalisation.Settings_Work_Duration), TimeSpan.FromHours(5), TimeSpan.FromHours(15), UserModSettings.Settings.Duration_Work, new OnValueChanged(value => UserModSettings.Settings.Duration_Work    = TimeSpan.FromHours(value)), LocalisationHolder.CurrentLocalisation.Settings_Work_DurationFormat);
                workHours.AddCheckbox(LocalisationHolder.Translate(LocalisationHolder.CurrentLocalisation.Settings_Work_AllowLeisure), UserModSettings.Settings.Citizens_AllowLeisureAfterWork, new OnCheckChanged(value => { UserModSettings.Settings.Citizens_AllowLeisureAfterWork = value; }));
            }

            var citizens = helper.AddGroup(LocalisationHolder.Translate(LocalisationHolder.CurrentLocalisation.Settings_Group_Citizens));
            {
                citizens.AddCheckbox(LocalisationHolder.Translate(LocalisationHolder.CurrentLocalisation.Settings_Citizens_ReactToWeather), UserModSettings.Settings.Citizens_ReactToWeather, new OnCheckChanged(value => { UserModSettings.Settings.Citizens_ReactToWeather = value; }));
            }

            var dangerZone = helper.AddGroup(LocalisationHolder.Translate(LocalisationHolder.CurrentLocalisation.Settings_Group_DangerZone));
            {
                if (dangerZone.AddCheckbox(LocalisationHolder.Translate(LocalisationHolder.CurrentLocalisation.Settings_DangerZone_IgnoreVehiclePercentages), UserModSettings.Settings.Citizens_IgnoreVehicleCount, new OnCheckChanged(value => UserModSettings.Settings.Citizens_IgnoreVehicleCount = value)) is UICheckBox ignoreVehiclePercentagesCheckbox)
                {
                    ignoreVehiclePercentagesCheckbox.tooltip = LocalisationHolder.Translate(LocalisationHolder.CurrentLocalisation.Settings_DangerZone_IgnoreVehiclePercentages_Tooltip);
                }

                if (dangerZone.AddCheckbox(LocalisationHolder.Translate(LocalisationHolder.CurrentLocalisation.Settings_DangerZone_EnableMessageBoxes), UserModSettings.Settings.MessageBoxes_Enabled, new OnCheckChanged(value => UserModSettings.Settings.MessageBoxes_Enabled = value)) is UICheckBox enableMessageBoxesCheckbox)
                {
                    enableMessageBoxesCheckbox.tooltip = string.Format(LocalisationHolder.Translate(LocalisationHolder.CurrentLocalisation.Settings_DangerZone_EnableMessageBoxes_Tooltip), Details.BaseModName);
                }
            }

            var logging = helper.AddGroup(LocalisationHolder.Translate(LocalisationHolder.CurrentLocalisation.Settings_Group_Logging));
            {
                logging.AddCheckbox(LocalisationHolder.Translate(LocalisationHolder.CurrentLocalisation.Settings_Logging_LogToFile), UserModSettings.Settings.Logging_ToFile, new OnCheckChanged(value => UserModSettings.Settings.Logging_ToFile          = value));
                logging.AddCheckbox(LocalisationHolder.Translate(LocalisationHolder.CurrentLocalisation.Settings_Logging_LogToDebugPanel), UserModSettings.Settings.Logging_ToDebug, new OnCheckChanged(value => UserModSettings.Settings.Logging_ToDebug  = value));
                logging.AddCheckbox(LocalisationHolder.Translate(LocalisationHolder.CurrentLocalisation.Settings_Logging_LogToConsole), UserModSettings.Settings.Logging_ToConsole, new OnCheckChanged(value => UserModSettings.Settings.Logging_ToConsole = value));
                logging.AddTimeSpanSecondsSlider(LocalisationHolder.Translate(LocalisationHolder.CurrentLocalisation.Settings_Logging_LogToFileInterval), TimeSpan.FromSeconds(1), TimeSpan.FromMinutes(2), UserModSettings.Settings.Logging_ToFile_Duration, new OnValueChanged(value => UserModSettings.Settings.Logging_ToFile_Duration = TimeSpan.FromSeconds(value)), LocalisationHolder.CurrentLocalisation.Settings_Logging_LogToFileIntervalFormat);
            }
        }
 public void OnSettingsUI(UIHelperBase helper)
 {
     var group = helper.AddGroup("UI");
     group.AddDropdown("Font Size", new [] {"Normal", "Large", "X-Large"}, ModSettings.FontSize,
         OnFontSizeChanged);
 }
Exemple #50
0
 /// <summary>
 /// Create the element on the helper
 /// </summary>
 /// <param name="helper">The UIHelper to attach the element to</param>
 public override UIComponent Create(UIHelperBase helper)
 {
     return(helper.AddSpace(spacing) as UIComponent);
 }
Exemple #51
0
        public void OnSettingsUI(UIHelperBase helper)
        {
            try
            {
                UIHelper group = helper.AddGroup(Name) as UIHelper;
                UIPanel  panel = group.self as UIPanel;

                // Integrate main button with UUI
                UICheckBox integrateMainButtonUUI = (UICheckBox)group.AddCheckbox(Translations.Translate("YAT_SET_UUI"), Settings.integrateMainButtonUUI, (b) =>
                {
                    Settings.integrateMainButtonUUI = b;
                    XMLUtils.SaveSettings();
                    if (YetAnotherToolbar.instance?.mainButton != null)
                    {
                        if (Settings.integrateMainButtonUUI)
                        {
                            UUIIntegration.AttachMainButton();
                        }
                        else
                        {
                            UUIIntegration.DetachMainButton();
                        }
                    }
                });
                group.AddSpace(10);

                // Hide main button
                UICheckBox hideMainButton = (UICheckBox)group.AddCheckbox(Translations.Translate("YAT_SET_HMB"), Settings.hideMainButton, (b) =>
                {
                    Settings.hideMainButton = b;
                    XMLUtils.SaveSettings();
                    if (YetAnotherToolbar.instance?.mainButton != null)
                    {
                        YetAnotherToolbar.instance.mainButton.isVisible = !Settings.hideMainButton;
                    }
                });
                group.AddSpace(10);

                UIButton mainButtonPositionReset = (UIButton)group.AddButton(Translations.Translate("YAT_SET_HMBRST"), () =>
                {
                    Settings.mainButtonX = 538.0f;
                    Settings.mainButtonY = 947.0f;
                    XMLUtils.SaveSettings();
                    if (YetAnotherToolbar.instance?.mainButton != null)
                    {
                        UIView view = UIView.GetAView();
                        Vector2 screenResolution = view.GetScreenResolution();
                        YetAnotherToolbar.instance.mainButton.absolutePosition = new Vector3(Settings.mainButtonX * screenResolution.x / 1920f, Settings.mainButtonY * screenResolution.y / 1080f);// advisorButton.absolutePosition + new Vector3(advisorButton.width, 0);
                    }
                });
                group.AddSpace(10);

                // Hide Advisor Button
                UICheckBox hideAdvisorButton = (UICheckBox)group.AddCheckbox(Translations.Translate("YAT_SET_HAB"), Settings.hideAdvisorButton, (b) =>
                {
                    Settings.hideAdvisorButton = b;
                    XMLUtils.SaveSettings();
                    if (YetAnotherToolbar.instance != null)
                    {
                        YetAnotherToolbar.instance.SetAdvisorButtonVisibility();
                    }
                });
                group.AddSpace(10);

                /*
                 * // Hide Filter Panels
                 * UICheckBox hideFilterPanels = (UICheckBox)group.AddCheckbox(Translations.Translate("YAT_SET_HFP"), Settings.hideFilterPanels, (b) =>
                 * {
                 *  Settings.hideFilterPanels = b;
                 *  XMLUtils.SaveSettings();
                 *  if (YetAnotherToolbar.instance != null)
                 *  {
                 *      YetAnotherToolbar.instance.hideFilterPanels = Settings.hideFilterPanels;
                 *      YetAnotherToolbar.instance.SetFilterPanelsVisibility();
                 *  }
                 * });
                 * group.AddSpace(10);
                 */

                // Disable update notice
                UICheckBox disableUpdateNotice = (UICheckBox)group.AddCheckbox(Translations.Translate("YAT_SET_DUN"), Settings.disableUpdateNotice, (b) =>
                {
                    Settings.disableUpdateNotice = b;
                    XMLUtils.SaveSettings();
                });
                group.AddSpace(10);

                // languate settings
                UIDropDown languageDropDown = (UIDropDown)group.AddDropdown(Translations.Translate("TRN_CHOICE"), Translations.LanguageList, Translations.Index, (value) =>
                {
                    Translations.Index = value;
                    XMLUtils.SaveSettings();
                });

                languageDropDown.width = 300;
                group.AddSpace(10);

                // show path to YetAnotherToolbarConfig.xml
                string      path           = Path.Combine(DataLocation.executableDirectory, "YetAnotherToolbarConfig.xml");
                UITextField ConfigFilePath = (UITextField)group.AddTextfield($"{Translations.Translate("YAT_SET_CFP")} - YetAnotherToolbarConfig.xml", path, _ => { }, _ => { });
                ConfigFilePath.width = panel.width - 30;

                group.AddButton(Translations.Translate("YAT_SET_OFE"), () => System.Diagnostics.Process.Start(DataLocation.executableDirectory));

                // shortcut keys
                panel.gameObject.AddComponent <ModeToggleKeyMapping>();
                panel.gameObject.AddComponent <QuickMenuKeyMapping>();
                panel.gameObject.AddComponent <HideMenuKeyMapping>();
                group.AddSpace(10);
            }
            catch (Exception e)
            {
                Debugging.Message("OnSettingsUI failed");
                Debugging.LogException(e);
            }
        }
Exemple #52
0
 public void OnSettingsUI(UIHelperBase helper)
 {
     sm_optionsManager.CreateSettings(helper);
 }
        public void OnSettingsUI(UIHelperBase helper)
        {
            DifficultyManager d = Singleton<DifficultyManager>.instance;

            ddDifficulty = (UIDropDown)helper.AddDropdown(
                DTMLang.Text("DIFFICULTY_LEVEL"),
                d.DifficultiesStr,
                (int)d.Difficulty,
                DifficultyLevelOnSelected
                );
            ddDifficulty.width = 350;
            ddDifficulty.height -= 2;

            //DebugOutputPanel.AddMessage(PluginManager.MessageType.Message, ddDifficulty.parent.parent.ToString());

            UIScrollablePanel scrollablePanel = (UIScrollablePanel)ddDifficulty.parent.parent;
            scrollablePanel.autoLayout = false;

            scrollablePanel.eventVisibilityChanged += ScrollablePanel_eventVisibilityChanged;

            float x1 = 15;
            float x2 = x1 + 140;
            float x3 = x1 + 375;
            float x4 = x3 + 140;
            float y = 0;
            float dy1 = 24;
            float dy2 = 44;
            float w1 = 150;
            float w2 = w1 + 140;

            ddDifficulty.parent.relativePosition = new Vector3(5, y);
            y += ddDifficulty.parent.height + 20;

            //
            // Custom options
            //
            sliders.Clear();

            //addLabel(scrollablePanel, DTMLang.Text("CUSTOM_OPTIONS"), new Vector3(5, y), textScaleBig);
            //y += dy2;

            // Construction cost
            addLabel(scrollablePanel, truncateSemicolon(Locale.Get("TOOL_CONSTRUCTION_COST")), new Vector3(x2, y), textScaleMedium);
            addLabel(scrollablePanel, DTMLang.Text("SERVICE_BUILDINGS"), new Vector3(x1, y + dy1), textScaleSmall);
            addSlider(scrollablePanel, new Vector3(x2, y + dy1), w1, OnCustomValueChanged, d.ConstructionCostMultiplier_Service);
            addLabel(scrollablePanel, DTMLang.Text("PUBLIC_TRANSPORT"), new Vector3(x1, y + dy1 * 2), textScaleSmall);
            addSlider(scrollablePanel, new Vector3(x2, y + dy1 * 2), w1, OnCustomValueChanged, d.ConstructionCostMultiplier_Public);
            addLabel(scrollablePanel, DTMLang.Text("ROADS"), new Vector3(x1, y + dy1 * 3), textScaleSmall);
            addSlider(scrollablePanel, new Vector3(x2, y + dy1 * 3), w1, OnCustomValueChanged, d.ConstructionCostMultiplier_Road);
            addLabel(scrollablePanel, DTMLang.Text("OTHERS"), new Vector3(x1, y + dy1 * 4), textScaleSmall);
            addSlider(scrollablePanel, new Vector3(x2, y + dy1 * 4), w1, OnCustomValueChanged, d.ConstructionCostMultiplier);

            // Maintenance cost
            addLabel(scrollablePanel, truncateSemicolon(Locale.Get("AIINFO_UPKEEP")), new Vector3(x4, y), textScaleMedium);
            addLabel(scrollablePanel, DTMLang.Text("SERVICE_BUILDINGS"), new Vector3(x3, y + dy1), textScaleSmall);
            addSlider(scrollablePanel, new Vector3(x4, y + dy1), w1, OnCustomValueChanged, d.MaintenanceCostMultiplier_Service);
            addLabel(scrollablePanel, DTMLang.Text("PUBLIC_TRANSPORT"), new Vector3(x3, y + dy1 * 2), textScaleSmall);
            addSlider(scrollablePanel, new Vector3(x4, y + dy1 * 2), w1, OnCustomValueChanged, d.MaintenanceCostMultiplier_Public);
            addLabel(scrollablePanel, DTMLang.Text("ROADS"), new Vector3(x3, y + dy1 * 3), textScaleSmall);
            addSlider(scrollablePanel, new Vector3(x4, y + dy1 * 3), w1, OnCustomValueChanged, d.MaintenanceCostMultiplier_Road);
            addLabel(scrollablePanel, DTMLang.Text("OTHERS"), new Vector3(x3, y + dy1 * 4), textScaleSmall);
            addSlider(scrollablePanel, new Vector3(x4, y + dy1 * 4), w1, OnCustomValueChanged, d.MaintenanceCostMultiplier);
            y += dy1 * 4;
            y += dy2;

            // Relocate cost
            addLabel(scrollablePanel, truncateSemicolon(Locale.Get("TOOL_RELOCATE_COST")), new Vector3(x1, y), textScaleMedium);
            y += dy1;
            addSlider(scrollablePanel, new Vector3(x1, y), w2, OnCustomValueChanged, d.RelocationCostMultiplier);
            y += dy1;

            // Area purchase cost
            addLabel(scrollablePanel, DTMLang.Text("AREA_COST_MULTIPLIER"), new Vector3(x1, y), textScaleMedium);
            y += dy1;
            addSlider(scrollablePanel, new Vector3(x1, y), w2, OnCustomValueChanged, d.AreaCostMultiplier);

            // Pollution
            y -= 3 * dy1;
            addLabel(scrollablePanel, DTMLang.Text("POLLUTION_RADIUS"), new Vector3(x4, y), textScaleMedium);
            y += dy1;
            // Ground pollution radius multiplier
            addLabel(scrollablePanel, DTMLang.Text("GROUND_POLLUTION"), new Vector3(x3, y), textScaleSmall);
            addSlider(scrollablePanel, new Vector3(x4, y), w1, OnCustomValueChanged, d.GroundPollutionRadiusMultiplier);
            y += dy1;
            addLabel(scrollablePanel, Locale.Get("INFO_NOISEPOLLUTION_TITLE"), new Vector3(x3, y), textScaleSmall);
            addSlider(scrollablePanel, new Vector3(x4, y), w1, OnCustomValueChanged, d.NoisePollutionRadiusMultiplier);
            y += dy1;
            addLabel(scrollablePanel, DTMLang.Text("ONLY_POWER_WATER_GARBAGE"), new Vector3(x3, y), textScaleSmall);
            y += dy2;

            // Economy
            addLabel(scrollablePanel, Locale.Get("ECONOMY_TITLE"), new Vector3(x2, y), textScaleMedium);
            y += dy1;
            // Initial money
            addLabel(scrollablePanel, DTMLang.Text("INITIAL_MONEY"), new Vector3(x1, y), textScaleSmall);
            addSlider(scrollablePanel, new Vector3(x2, y), w1, OnCustomValueChanged, d.InitialMoney);
            y += dy1;
            // Reward amount
            addLabel(scrollablePanel, DTMLang.Text("REWARD"), new Vector3(x1, y), textScaleSmall);
            addSlider(scrollablePanel, new Vector3(x2, y), w1, OnCustomValueChanged, d.RewardMultiplier);
            y += dy1;
            // Loan amount and length
            addLabel(scrollablePanel, Locale.Get("ECONOMY_LOANS"), new Vector3(x1, y), textScaleSmall);
            addSlider(scrollablePanel, new Vector3(x2, y), w1, OnCustomValueChanged, d.LoanMultiplier);

            // Demand
            y -= dy1 * 3;
            addLabel(scrollablePanel, Locale.Get("MAIN_ZONING_DEMAND"), new Vector3(x4, y), textScaleMedium);
            y += dy1;
            addLabel(scrollablePanel, DTMLang.Text("DEMAND_OFFSET"), new Vector3(x3, y), textScaleSmall);
            addSlider(scrollablePanel, new Vector3(x4, y), w1, OnCustomValueChanged, d.DemandOffset);
            y += dy1;
            addLabel(scrollablePanel, DTMLang.Text("DEMAND_MULTIPLIER"), new Vector3(x3, y), textScaleSmall);
            addSlider(scrollablePanel, new Vector3(x4, y), w1, OnCustomValueChanged, d.DemandMultiplier);
            y += dy1;
            addLabel(scrollablePanel, DTMLang.Text("DEMAND_FORMULA"), new Vector3(x3, y), textScaleSmall);
            y += dy2;

            // Population target multiplier
            addLabel(scrollablePanel, DTMLang.Text("POPULATION_TARGET_MULTIPLIER"), new Vector3(x1, y), textScaleMedium);
            y += dy1;
            addSlider(scrollablePanel, new Vector3(x1, y), w2, OnCustomValueChanged, d.PopulationTargetMultiplier);
            y += dy2;

            // Target land value
            addLabel(scrollablePanel, DTMLang.Text("TAGRET_LANDVALUE"), new Vector3(x1, y), textScaleMedium);
            y += dy1;
            addLabel(scrollablePanel, DTMLang.Text("RESIDENTIAL"), new Vector3(x1, y), textScaleSmall);
            addSlider(scrollablePanel, new Vector3(x2, y), w2, OnCustomValueChanged, d.ResidentialTargetLandValue);
            y += dy1;
            addLabel(scrollablePanel, DTMLang.Text("COMMERCIAL"), new Vector3(x1, y), textScaleSmall);
            addSlider(scrollablePanel, new Vector3(x2, y), w2, OnCustomValueChanged, d.CommercialTargetLandValue);
            y += dy2;

            // Target service score
            addLabel(scrollablePanel, DTMLang.Text("TAGRET_SCORE"), new Vector3(x1, y), textScaleMedium);
            y += dy1;
            addLabel(scrollablePanel, DTMLang.Text("INDUSTRIAL"), new Vector3(x1, y), textScaleSmall);
            addSlider(scrollablePanel, new Vector3(x2, y), w2, OnCustomValueChanged, d.IndustrialTargetScore);
            y += dy1;
            addLabel(scrollablePanel, DTMLang.Text("OFFICE"), new Vector3(x1, y), textScaleSmall);
            addSlider(scrollablePanel, new Vector3(x2, y), w2, OnCustomValueChanged, d.OfficeTargetScore);

            freeze = false;
        }
        internal static void MakeSettings_General(ExtUITabstrip tabStrip)
        {
            UIHelper panelHelper = tabStrip.AddTabPage(T("Tab:General"));

            UIHelperBase generalGroup = panelHelper.AddGroup(T("Tab:General"));

            string[] languageLabels = new string[Translation.AvailableLanguageCodes.Count + 1];
            languageLabels[0] = T("General.Dropdown.Option:Game language");

            for (int i = 0; i < Translation.AvailableLanguageCodes.Count; ++i)
            {
                languageLabels[i + 1] = Translation.Options.Get(
                    lang: Translation.AvailableLanguageCodes[i],
                    key: "General.Dropdown.Option:Language Name");
            }

            int    languageIndex = 0;
            string curLangCode   = GlobalConfig.Instance.LanguageCode;

            if (curLangCode != null)
            {
                languageIndex = Translation.AvailableLanguageCodes.IndexOf(curLangCode);
                if (languageIndex < 0)
                {
                    languageIndex = 0;
                }
                else
                {
                    ++languageIndex;
                }
            }

            _languageDropdown = generalGroup.AddDropdown(
                text: T("General.Dropdown:Select language") + ":",
                options: languageLabels,
                defaultSelection: languageIndex,
                eventCallback: OnLanguageChanged) as UIDropDown;
            _lockButtonToggle = generalGroup.AddCheckbox(
                text: T("General.Checkbox:Lock main menu button position"),
                defaultValue: GlobalConfig.Instance.Main.MainMenuButtonPosLocked,
                eventCallback: OnLockButtonChanged) as UICheckBox;
            _lockMenuToggle = generalGroup.AddCheckbox(
                text: T("General.Checkbox:Lock main menu window position"),
                defaultValue: GlobalConfig.Instance.Main.MainMenuPosLocked,
                eventCallback: OnLockMenuChanged) as UICheckBox;

            _guiScaleSlider = generalGroup.AddSlider(
                text: T("General.Slider:GUI scale") + ":",
                min: 50,
                max: 200,
                step: 5,
                defaultValue: GlobalConfig.Instance.Main.GuiScale,
                eventCallback: OnGuiScaleChanged) as UISlider;
            _guiScaleSlider.parent.Find <UILabel>("Label").width = 500;

            _guiOpacitySlider = generalGroup.AddSlider(
                text: T("General.Slider:Window transparency") + ":",
                min: 10,
                max: 100,
                step: 5,
                defaultValue: GlobalConfig.Instance.Main.GuiOpacity,
                eventCallback: OnGuiOpacityChanged) as UISlider;
            _guiOpacitySlider.parent.Find <UILabel>("Label").width = 500;

            _overlayTransparencySlider = generalGroup.AddSlider(
                text: T("General.Slider:Overlay transparency") + ":",
                min: 0,
                max: 90,
                step: 5,
                defaultValue: GlobalConfig.Instance.Main.OverlayTransparency,
                eventCallback: OnOverlayTransparencyChanged) as UISlider;
            _overlayTransparencySlider.parent.Find <UILabel>("Label").width = 500;
            _enableTutorialToggle = generalGroup.AddCheckbox(
                T("General.Checkbox:Enable tutorials"),
                GlobalConfig.Instance.Main.EnableTutorial,
                OnEnableTutorialsChanged) as UICheckBox;
            _showCompatibilityCheckErrorToggle
                = generalGroup.AddCheckbox(
                      T("General.Checkbox:Notify me about TM:PE startup conflicts"),
                      GlobalConfig.Instance.Main.ShowCompatibilityCheckErrorMessage,
                      OnShowCompatibilityCheckErrorChanged) as UICheckBox;
            _scanForKnownIncompatibleModsToggle
                = generalGroup.AddCheckbox(
                      Translation.ModConflicts.Get("Checkbox:Scan for known incompatible mods on startup"),
                      GlobalConfig.Instance.Main.ScanForKnownIncompatibleModsAtStartup,
                      OnScanForKnownIncompatibleModsChanged) as UICheckBox;
            _ignoreDisabledModsToggle = generalGroup.AddCheckbox(
                text: Translation.ModConflicts.Get("Checkbox:Ignore disabled mods"),
                defaultValue: GlobalConfig.Instance.Main.IgnoreDisabledMods,
                eventCallback: OnIgnoreDisabledModsChanged) as UICheckBox;
            Options.Indent(_ignoreDisabledModsToggle);

            // General: Speed Limits
            SetupSpeedLimitsPanel(generalGroup);

            // General: Simulation
            UIHelperBase simGroup = panelHelper.AddGroup(T("General.Group:Simulation"));

            _simulationAccuracyDropdown = simGroup.AddDropdown(
                text: T("General.Dropdown:Simulation accuracy") + ":",
                options: new[] {
                T("General.Dropdown.Option:Very low"),
                T("General.Dropdown.Option:Low"),
                T("General.Dropdown.Option:Medium"),
                T("General.Dropdown.Option:High"),
                T("General.Dropdown.Option:Very high"),
            },
                defaultSelection: (int)Options.simulationAccuracy,
                eventCallback: OnSimulationAccuracyChanged) as UIDropDown;

            _instantEffectsToggle = simGroup.AddCheckbox(
                text: T("General.Checkbox:Apply AI changes right away"),
                defaultValue: Options.instantEffects,
                eventCallback: OnInstantEffectsChanged) as UICheckBox;
        }
 public void OnSettingsUI(UIHelperBase helper)
 {
     UIHelperBase group = helper.AddGroup("Building Themes");
     group.AddCheckbox("Unlock Policies Panel From Start", PolicyPanelEnabler.Unlock, delegate(bool c) { PolicyPanelEnabler.Unlock = c; });
     group.AddCheckbox("Create Prefab Duplicates (required for some themes)", BuildingVariationManager.Enabled, delegate(bool c) { BuildingVariationManager.Enabled = c; });
     group.AddGroup("Warning: When you disable this option, spawned duplicates will disappear!");
     group.AddSpace(1);
     group.AddCheckbox("Generate Debug Output", Debugger.Enabled, delegate(bool c) { Debugger.Enabled = c; });
 }
Exemple #56
0
        public void OnSettingsUI(UIHelperBase helper)
        {
            var config = Configuration <AutosaveOnPauseConfiguration> .Load();

            var saveName = helper.AddTextfield("Save name", config.SaveName, value => config.SaveName = value) as UITextField;

            saveName.width += 300;
            var nameHelperGroup = helper.AddGroup("Tags to insert into the save name:") as UIHelper;

            var component = nameHelperGroup.self as UIPanel;

            component.autoLayoutDirection = LayoutDirection.Horizontal;
            component.autoLayoutPadding   = new UnityEngine.RectOffset(5, 5, 0, 0);

            nameHelperGroup.AddButton("City Name", () => saveName.text  += "{{CityName}}");
            nameHelperGroup.AddButton("Game Year", () => saveName.text  += "{{Year}}");
            nameHelperGroup.AddButton("Game Month", () => saveName.text += "{{Month}}");
            nameHelperGroup.AddButton("Game Day", () => saveName.text   += "{{Day}}");

            var throttleGroup     = helper.AddGroup("Autosave Timing:\r\nThese settings do not affect and are not affected by the in-game autosaves.") as UIHelper;
            var limitFrequency    = throttleGroup.AddCheckbox("Limit Autosave Frequency", config.LimitAutosaves, value => config.LimitAutosaves = value) as UICheckBox;
            var autosaveFrequency = throttleGroup.AddSlider("Cooldown", 1, 60, 1, config.AutosaveInterval, value => config.AutosaveInterval = (float)Math.Round(value)) as UISlider;

            autosaveFrequency.tooltip = $"{autosaveFrequency.value} minutes";
            autosaveFrequency.width  += 300;

            var bottomPanel = throttleGroup.self as UIPanel;
            var time        = bottomPanel.AddUIComponent <UILabel>();

            time.padding = new UnityEngine.RectOffset(0, 0, 15, 0);

            if (config.LimitAutosaves)
            {
                time.text = $"At least {config.AutosaveInterval} minutes must pass between autosaves.";
            }
            else
            {
                time.text = "The game will save everytime you pause.";
            }

            autosaveFrequency.eventValueChanged += (sender, value) =>
            {
                if (config.LimitAutosaves)
                {
                    time.text = $"At least {value} minutes must pass between autosaves.";
                }
                else
                {
                    time.text = "The game will save everytime you pause.";
                }
            };

            limitFrequency.eventCheckChanged += (sender, value) =>
            {
                if (value)
                {
                    time.text = $"At least {config.AutosaveInterval} minutes must pass between autosaves.";
                }
                else
                {
                    time.text = "The game will save everytime you pause.";
                }
            };

            var savePanel = bottomPanel.AddUIComponent <UIPanel>();

            savePanel.autoLayoutDirection = LayoutDirection.Horizontal;
            savePanel.height = 50;

            throttleGroup.AddButton("Save", () => Configuration <AutosaveOnPauseConfiguration> .Save());
            throttleGroup.AddButton("Cancel", () =>
            {
                config                    = Configuration <AutosaveOnPauseConfiguration> .Load();
                saveName.text             = config.SaveName;
                limitFrequency.isChecked  = config.LimitAutosaves;
                autosaveFrequency.value   = config.AutosaveInterval;
                autosaveFrequency.enabled = config.LimitAutosaves;
            });
        }