public void OnSettingsUI(UIHelperBase helper) { try { UIHelper group = helper.AddGroup(Name) as UIHelper; UICheckBox checkBox = (UICheckBox)group.AddCheckbox("Disable button capture", MoreShortcuts.disableCapture.value, (b) => { MoreShortcuts.disableCapture.value = b; }); checkBox.tooltip = "If checked, you will not be able to add new shortcuts.\nThe capture key will no longer highlight buttons.\n"; group.AddSpace(10); UIDropDown dropDown = (UIDropDown)group.AddDropdown("Capture key:", new string[] { "Alt", "Ctrl", "Shift", "Alt + Ctrl", "Alt + Shift", "Ctrl + Shift", "Ctrl + Alt + Shift" }, MoreShortcuts.captureKey.value, (b) => { MoreShortcuts.captureKey.value = b; }); dropDown.tooltip = "Select the desired capture key combination"; group.AddSpace(10); UIPanel panel = group.self as UIPanel; UILabel label = panel.AddUIComponent <UILabel>(); label.textScale = 1.125f; label.text = "Shortcuts:"; panel.gameObject.AddComponent <OptionsKeymapping>(); } catch (Exception e) { DebugUtils.Log("OnSettingsUI failed"); DebugUtils.LogException(e); } }
public void OnSettingsUI(UIHelperBase helper) { try { UIHelper group = helper.AddGroup(Name) as UIHelper; UIPanel panel = group.self as UIPanel; UICheckBox checkBox = (UICheckBox)group.AddCheckbox(Translations.Translate("NTCP_SET_VAN"), Settings.skipVanillaProps, (b) => { Settings.skipVanillaProps = b; XMLUtils.SaveSettings(); }); checkBox.tooltip = Translations.Translate("NTCP_SET_VANTP"); 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 NonTerrainConformingPropsConfig.xml string path = Path.Combine(DataLocation.executableDirectory, "NonTerrainConformingPropsConfig.xml"); UITextField customTagsFilePath = (UITextField)group.AddTextfield(Translations.Translate("NTCP_SET_CONF") + " - NonTerrainConformingPropsConfig.xml", path, _ => { }, _ => { }); customTagsFilePath.width = panel.width - 30; group.AddButton(Translations.Translate("NTCP_SET_CONFFE"), () => System.Diagnostics.Process.Start(DataLocation.executableDirectory)); } catch (Exception e) { Debug.Log("OnSettingsUI failed"); Debug.LogException(e); } }
public void OnSettingsUI(UIHelperBase helper) { try { UIHelper group = helper.AddGroup(Name) as UIHelper; UIPanel panel = group.self as UIPanel; group.AddSpace(10); group.AddDropdown(Translation.Instance.GetTranslation("FOREST-BRUSH-OPTIONS-SORTING"), new string[] { Translation.Instance.GetTranslation("FOREST-BRUSH-DATA-NAME"), Translation.Instance.GetTranslation("FOREST-BRUSH-DATA-AUTHOR"), Translation.Instance.GetTranslation("FOREST-BRUSH-DATA-TEXTURE"), Translation.Instance.GetTranslation("FOREST-BRUSH-DATA-TRIANGLES") }, (int)Settings.Sorting, (index) => { Settings.Sorting = (TreeSorting)index; SaveSettings(); }); group.AddSpace(10); group.AddDropdown(Translation.Instance.GetTranslation("FOREST-BRUSH-OPTIONS-SORTING-ORDER"), new string[] { Translation.Instance.GetTranslation("FOREST-BRUSH-OPTIONS-SORTING-DESCENDING"), Translation.Instance.GetTranslation("FOREST-BRUSH-OPTIONS-SORTING-ASCENDING") }, (int)Settings.SortingOrder, (index) => { Settings.SortingOrder = (SortingOrder)index; SaveSettings(); }); group.AddSpace(10); searchLogic = (UIDropDown)group.AddDropdown(Translation.Instance.GetTranslation("FOREST-BRUSH-OPTIONS-FILTERING-LOGIC"), new string[] { Translation.Instance.GetTranslation("FOREST-BRUSH-OPTIONS-FILTERING-AND"), Translation.Instance.GetTranslation("FOREST-BRUSH-OPTIONS-FILTERING-OR"), Translation.Instance.GetTranslation("FOREST-BRUSH-OPTIONS-FILTERING-SIMPLE") }, (int)Settings.FilterStyle, (index) => { Settings.FilterStyle = (FilterStyle)index; SaveSettings(); }); searchLogic.width = 500.0f; group.AddSpace(10); newBrushBehaviour = (UIDropDown)group.AddDropdown(Translation.Instance.GetTranslation("FOREST-BRUSH-OPTIONS-NEWBRUSH"), new string[] { Translation.Instance.GetTranslation("FOREST-BRUSH-OPTIONS-NEWBRUSH-CLEAR"), Translation.Instance.GetTranslation("FOREST-BRUSH-OPTIONS-NEWBRUSH-KEEP") }, Settings.KeepTreesInNewBrush ? 1 : 0, (index) => { Settings.KeepTreesInNewBrush = index == 1 ? true : false; SaveSettings(); }); newBrushBehaviour.width = 500.0f; group.AddSpace(10); group.AddCheckbox(Translation.Instance.GetTranslation("FOREST-BRUSH-OPTIONS-SHOWMESHDATA"), Settings.ShowTreeMeshData, (b) => { Settings.ShowTreeMeshData = b; SaveSettings(); }); group.AddSpace(10); group.AddCheckbox(Translation.Instance.GetTranslation("FOREST-BRUSH-OPTIONS-IGNORE-VANILLA"), Settings.IgnoreVanillaTrees, (b) => { Settings.IgnoreVanillaTrees = b; SaveSettings(); if (LoadingManager.instance.m_loadingComplete) { ForestBrush.Instance.LoadTrees(); ForestBrush.Instance.ForestBrushPanel.BrushEditSection.SetupFastlist(); } }); group.AddSpace(20); optionKeys = panel.gameObject.AddComponent <OptionsKeyBinding>(); group.AddSpace(10); } catch (Exception) { Debug.LogWarning("OnSettingsUI failure."); } }
/// <summary> /// Adds mod options tab to tabstrip. /// </summary> /// <param name="tabStrip">Tab strip to add to</param> /// <param name="tabIndex">Index number of tab</param> internal ModOptions(UITabstrip tabStrip, int tabIndex) { // Add tab and helper. UIPanel panel = PanelUtils.AddTab(tabStrip, Translations.Translate("PRR_OPTION_MOD"), tabIndex, true); UIHelper helper = new UIHelper(panel); UIDropDown translationDropDown = (UIDropDown)helper.AddDropdown(Translations.Translate("TRN_CHOICE"), Translations.LanguageList, Translations.Index, (value) => { Translations.Index = value; SettingsUtils.SaveSettings(); }); translationDropDown.autoSize = false; translationDropDown.width = 270f; // Game options. /*UIHelperBase gameGroup = helper.AddGroup(Translations.Translate("PRR_OPTION_LOA")); * * // Add reset on load checkbox. * gameGroup.AddCheckbox(Translations.Translate("PRR_OPTION_FORCERESET"), ModSettings.resetOnLoad, isChecked => * { * ModSettings.resetOnLoad = isChecked; * SettingsUtils.SaveSettings(); * });*/ // Notification options. UIHelperBase notificationGroup = helper.AddGroup(Translations.Translate("PRR_OPTION_NOT")); // Add logging checkbox. notificationGroup.AddCheckbox(Translations.Translate("PRR_OPTION_WHATSNEW"), ModSettings.showWhatsNew, isChecked => { ModSettings.showWhatsNew = isChecked; SettingsUtils.SaveSettings(); }); // Logging options. UIHelperBase logGroup = helper.AddGroup(Translations.Translate("PRR_OPTION_LOG")); // Add logging checkbox. logGroup.AddCheckbox(Translations.Translate("PRR_OPTION_MOREDEBUG"), Logging.detailLogging, isChecked => { Logging.detailLogging = isChecked; SettingsUtils.SaveSettings(); }); // Thumbnail options. UIHelperBase thumbGroup = helper.AddGroup(Translations.Translate("PRR_OPTION_TMB")); // Add thumbnail background dropdown. thumbGroup.AddDropdown(Translations.Translate("PRR_OPTION_THUMBACK"), ModSettings.ThumbBackNames, ModSettings.thumbBacks, (value) => { ModSettings.thumbBacks = value; SettingsUtils.SaveSettings(); }); // Add regenerate thumbnails button. thumbGroup.AddButton(Translations.Translate("PRR_OPTION_REGENTHUMBS"), () => PloppableTool.Instance.RegenerateThumbnails()); // Add speed boost checkbox. UIHelperBase speedGroup = helper.AddGroup(Translations.Translate("PRR_OPTION_SPDHDR")); speedGroup.AddCheckbox(Translations.Translate("PRR_OPTION_SPEED"), ModSettings.speedBoost, isChecked => { ModSettings.speedBoost = isChecked; SettingsUtils.SaveSettings(); }); }
/// <summary> /// Called by the game when the mod options panel is setup. /// </summary> public void OnSettingsUI(UIHelperBase helper) { try { if (FindIt.instance == null) { AssetTagList.instance = new AssetTagList(); } UIHelper group = helper.AddGroup(Name) as UIHelper; UIPanel panel = group.self as UIPanel; // Disable debug messages logging UICheckBox checkBox = (UICheckBox)group.AddCheckbox(Translations.Translate("FIF_SET_DM"), Settings.hideDebugMessages, (b) => { Settings.hideDebugMessages = b; XMLUtils.SaveSettings(); }); checkBox.tooltip = Translations.Translate("FIF_SET_DMTP"); group.AddSpace(10); // Center the main toolbar checkBox = (UICheckBox)group.AddCheckbox(Translations.Translate("FIF_SET_CMT"), Settings.centerToolbar, (b) => { Settings.centerToolbar = b; XMLUtils.SaveSettings(); if (FindIt.instance != null) { FindIt.instance.UpdateMainToolbar(); } }); checkBox.tooltip = Translations.Translate("FIF_SET_CMTTP"); group.AddSpace(10); // Unlock all checkBox = (UICheckBox)group.AddCheckbox(Translations.Translate("FIF_SET_UL"), Settings.unlockAll, (b) => { Settings.unlockAll = b; XMLUtils.SaveSettings(); }); checkBox.tooltip = Translations.Translate("FIF_SET_ULTP"); group.AddSpace(10); // Fix bad props next loaded save // Implemented by samsamTS. Need to figure out why this is needed. UICheckBox fixProps = (UICheckBox)group.AddCheckbox(Translations.Translate("FIF_SET_BP"), false, (b) => { Settings.fixBadProps = b; XMLUtils.SaveSettings(); }); fixProps.tooltip = Translations.Translate("FIF_SET_BPTP"); group.AddSpace(10); // Use system default browser instead of steam overlay UICheckBox useDefaultBrowser = (UICheckBox)group.AddCheckbox(Translations.Translate("FIF_SET_DB"), Settings.useDefaultBrowser, (b) => { Settings.useDefaultBrowser = b; XMLUtils.SaveSettings(); }); useDefaultBrowser.tooltip = Translations.Translate("FIF_SET_DBTP"); group.AddSpace(10); // Disable update notice UICheckBox disableUpdateNotice = (UICheckBox)group.AddCheckbox(Translations.Translate("FIF_SET_DUN"), Settings.disableUpdateNotice, (b) => { Settings.disableUpdateNotice = b; XMLUtils.SaveSettings(); }); useDefaultBrowser.tooltip = Translations.Translate("FIF_SET_DBTP"); group.AddSpace(10); // Disable update notice UICheckBox separateSearchKeyword = (UICheckBox)group.AddCheckbox(Translations.Translate("FIF_SET_SSK"), Settings.separateSearchKeyword, (b) => { Settings.separateSearchKeyword = b; XMLUtils.SaveSettings(); }); separateSearchKeyword.tooltip = Translations.Translate("FIF_SET_SSKTP"); 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 FindItCustomTags.xml string path = Path.Combine(DataLocation.localApplicationData, "FindItCustomTags.xml"); UITextField customTagsFilePath = (UITextField)group.AddTextfield(Translations.Translate("FIF_SET_CTFL"), path, _ => { }, _ => { }); customTagsFilePath.width = panel.width - 30; // from aubergine10's AutoRepair if (Application.platform == RuntimePlatform.WindowsPlayer) { group.AddButton(Translations.Translate("FIF_SET_CTFOP"), () => System.Diagnostics.Process.Start("explorer.exe", "/select," + path)); } // shortcut keys panel.gameObject.AddComponent <MainButtonKeyMapping>(); panel.gameObject.AddComponent <AllKeyMapping>(); panel.gameObject.AddComponent <NetworkKeyMapping>(); panel.gameObject.AddComponent <PloppableKeyMapping>(); panel.gameObject.AddComponent <GrowableKeyMapping>(); panel.gameObject.AddComponent <RicoKeyMapping>(); panel.gameObject.AddComponent <GrwbRicoKeyMapping>(); panel.gameObject.AddComponent <PropKeyMapping>(); panel.gameObject.AddComponent <DecalKeyMapping>(); panel.gameObject.AddComponent <TreeKeyMapping>(); panel.gameObject.AddComponent <RandomSelectionKeyMapping>(); group.AddSpace(10); } catch (Exception e) { Debugging.Message("OnSettingsUI failed"); Debugging.LogException(e); } }
public void OnSettingsUI(UIHelperBase helper) { try { if (FindIt.instance == null) { AssetTagList.instance = new AssetTagList(); } UIHelper group = helper.AddGroup(Name) as UIHelper; UIPanel panel = group.self as UIPanel; UICheckBox checkBox = (UICheckBox)group.AddCheckbox(Translations.Translate("FIF_SET_DM"), Debugging.hideDebugMessages.value, (b) => { Debugging.hideDebugMessages.value = b; }); checkBox.tooltip = Translations.Translate("FIF_SET_DMTP"); group.AddSpace(10); checkBox = (UICheckBox)group.AddCheckbox(Translations.Translate("FIF_SET_CMT"), FindIt.centerToolbar.value, (b) => { FindIt.centerToolbar.value = b; if (FindIt.instance != null) { FindIt.instance.UpdateMainToolbar(); } }); checkBox.tooltip = Translations.Translate("FIF_SET_CMTTP"); checkBox = (UICheckBox)group.AddCheckbox(Translations.Translate("FIF_SET_UL"), FindIt.unlockAll.value, (b) => { FindIt.unlockAll.value = b; }); checkBox.tooltip = Translations.Translate("FIF_SET_ULTP"); group.AddSpace(10); UICheckBox fixProps = (UICheckBox)group.AddCheckbox(Translations.Translate("FIF_SET_BP"), false, (b) => { FindIt.fixBadProps = b; }); fixProps.tooltip = Translations.Translate("FIF_SET_BPTP"); group.AddSpace(10); panel.gameObject.AddComponent <OptionsKeymapping>(); group.AddSpace(10); UIDropDown languageDropDown = (UIDropDown)group.AddDropdown(Translations.Translate("TRN_CHOICE"), Translations.LanguageList, Translations.Index, (value) => { Translations.Index = value; }); group.AddSpace(10); } catch (Exception e) { Debugging.Message("OnSettingsUI failed"); Debugging.LogException(e); } }
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 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; }
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); } }