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 }
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); }
public override void Awake() { title = AddUIComponent<UILabel>(); disastersCheck = AddUIComponent<UICustomCheckbox2>(); disastersLabel = AddUIComponent<UILabel>(); difficultySelect = AddUIComponent<UIDropDown>(); selButton = AddUIComponent<UIButton>(); difficultyLabel = AddUIComponent<UILabel>(); infoLabel = AddUIComponent<UILabel>(); okButton = AddUIComponent<UIButton>(); width = 300; height = 200; base.Awake(); }
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; } OptionsMassEditTab.MakePanel_MassEdit(panelHelper); }
public override void Start() { instance = this; // tag dropdown filter checkbox tagDropDownCheckBox = SamsamTS.UIUtils.CreateCheckBox(this); tagDropDownCheckBox.isChecked = false; tagDropDownCheckBox.width = 20; tagDropDownCheckBox.tooltip = Translations.Translate("FIF_TAG_DDTP"); tagDropDownCheckBox.relativePosition = new Vector3(10, 10); tagDropDownCheckBox.eventCheckChanged += (c, i) => { if (customTagListStrArray.Length == 0) { tagDropDownCheckBox.isChecked = false; } ((UISearchBox)parent).Search(); }; // tag dropdown tagDropDownMenu = SamsamTS.UIUtils.CreateDropDown(this); tagDropDownMenu.size = new Vector2(200, 25); tagDropDownMenu.tooltip = Translations.Translate("FIF_POP_SCR"); tagDropDownMenu.listHeight = 300; tagDropDownMenu.itemHeight = 30; tagDropDownMenu.relativePosition = new Vector3(tagDropDownCheckBox.relativePosition.x + tagDropDownCheckBox.width + 5, 5); UpdateCustomTagList(); tagDropDownMenu.eventSelectedIndexChanged += (c, p) => { if (tagDropDownCheckBox.isChecked) { ((UISearchBox)parent).Search(); } }; // refresh button refreshButton = SamsamTS.UIUtils.CreateButton(this); refreshButton.size = new Vector2(80, 25); refreshButton.text = Translations.Translate("FIF_TAG_REF"); refreshButton.textScale = 0.8f; refreshButton.textPadding = new RectOffset(0, 0, 5, 0); refreshButton.tooltip = Translations.Translate("FIF_TAG_REFTP"); refreshButton.relativePosition = new Vector3(tagDropDownMenu.relativePosition.x + tagDropDownMenu.width + 15, 5); refreshButton.eventClick += (c, p) => { UpdateCustomTagList(); ((UISearchBox)parent).Search(); }; // rename button renameButton = SamsamTS.UIUtils.CreateButton(this); renameButton.size = new Vector2(80, 25); renameButton.text = Translations.Translate("FIF_TAG_REN"); renameButton.textScale = 0.8f; renameButton.textPadding = new RectOffset(0, 0, 5, 0); renameButton.tooltip = Translations.Translate("FIF_TAG_RENTP"); renameButton.relativePosition = new Vector3(refreshButton.relativePosition.x + refreshButton.width + 5, 5); renameButton.eventClick += (c, p) => { if (customTagListStrArray.Length != 0) { UITagsRenamePopUp.ShowAt(renameButton, GetDropDownListKey()); } else { Debugging.Message("Custom tag rename button pressed, but no custom tag exists"); } }; // merge button mergeButton = SamsamTS.UIUtils.CreateButton(this); mergeButton.size = new Vector2(80, 25); mergeButton.text = Translations.Translate("FIF_TAG_COM"); mergeButton.textScale = 0.8f; mergeButton.textPadding = new RectOffset(0, 0, 5, 0); mergeButton.tooltip = Translations.Translate("FIF_TAG_COMTP"); mergeButton.relativePosition = new Vector3(renameButton.relativePosition.x + renameButton.width + 5, 5); mergeButton.eventClick += (c, p) => { if (customTagListStrArray.Length != 0) { UITagsMergePopUp.ShowAt(mergeButton, GetDropDownListKey()); } else { Debugging.Message("Custom tag combine button pressed, but no custom tag exists"); } }; // delete button deleteButton = SamsamTS.UIUtils.CreateButton(this); deleteButton.size = new Vector2(80, 25); deleteButton.text = Translations.Translate("FIF_TAG_DEL"); deleteButton.textScale = 0.8f; deleteButton.textPadding = new RectOffset(0, 0, 5, 0); deleteButton.tooltip = Translations.Translate("FIF_TAG_DELTP"); deleteButton.relativePosition = new Vector3(mergeButton.relativePosition.x + mergeButton.width + 5, 5); deleteButton.eventClick += (c, p) => { if (customTagListStrArray.Length != 0) { UITagsDeletePopUp.ShowAt(deleteButton, GetDropDownListKey()); } else { Debugging.Message("Custom tag delete button pressed, but no custom tag exists"); } }; // batch add button batchAddButton = SamsamTS.UIUtils.CreateButton(this); batchAddButton.size = new Vector2(80, 25); batchAddButton.text = Translations.Translate("FIF_TAG_ADD"); batchAddButton.textScale = 0.8f; batchAddButton.textPadding = new RectOffset(0, 0, 5, 0); batchAddButton.isVisible = false; batchAddButton.tooltip = Translations.Translate("FIF_TAG_ADDTP"); batchAddButton.relativePosition = new Vector3(refreshButton.relativePosition.x + refreshButton.width + 5, 5); batchAddButton.eventClick += (c, p) => { UITagsBatchAddPopUp.ShowAt(batchAddButton); }; // batch remove button batchRemoveButton = SamsamTS.UIUtils.CreateButton(this); batchRemoveButton.size = new Vector2(80, 25); batchRemoveButton.text = Translations.Translate("FIF_TAG_REM"); batchRemoveButton.textScale = 0.8f; batchRemoveButton.textPadding = new RectOffset(0, 0, 5, 0); batchRemoveButton.isVisible = false; batchRemoveButton.tooltip = Translations.Translate("FIF_TAG_REMTP"); batchRemoveButton.relativePosition = new Vector3(batchAddButton.relativePosition.x + batchAddButton.width + 5, 5); batchRemoveButton.eventClick += (c, p) => { UITagsBatchRemovePopUp.ShowAt(batchRemoveButton); }; // batch select all button batchSelectAllButton = SamsamTS.UIUtils.CreateButton(this); batchSelectAllButton.size = new Vector2(80, 25); batchSelectAllButton.text = Translations.Translate("FIF_TAG_SA"); batchSelectAllButton.textScale = 0.8f; batchSelectAllButton.textPadding = new RectOffset(0, 0, 5, 0); batchSelectAllButton.isVisible = false; batchSelectAllButton.tooltip = Translations.Translate("FIF_TAG_SATP"); batchSelectAllButton.relativePosition = new Vector3(batchRemoveButton.relativePosition.x + batchRemoveButton.width + 5, 5); batchSelectAllButton.eventClick += (c, p) => { if (UISearchBox.instance.matches != null) { foreach (Asset asset in UISearchBox.instance.matches) { batchAssetSet.Add(asset); } } UISearchBox.instance.scrollPanel.Refresh(); }; // batch clear selection button batchClearButton = SamsamTS.UIUtils.CreateButton(this); batchClearButton.size = new Vector2(80, 25); batchClearButton.text = Translations.Translate("FIF_TAG_CLE"); batchClearButton.textScale = 0.8f; batchClearButton.textPadding = new RectOffset(0, 0, 5, 0); batchClearButton.isVisible = false; batchClearButton.tooltip = Translations.Translate("FIF_TAG_CLETP"); batchClearButton.relativePosition = new Vector3(batchSelectAllButton.relativePosition.x + batchSelectAllButton.width + 5, 5); batchClearButton.eventClick += (c, p) => { batchAssetSet.Clear(); UISearchBox.instance.scrollPanel.Refresh(); }; // batch button batchButton = SamsamTS.UIUtils.CreateButton(this); batchButton.size = new Vector2(80, 25); batchButton.text = Translations.Translate("FIF_TAG_BAT"); batchButton.tooltip = Translations.Translate("FIF_TAG_BATTP"); batchButton.textScale = 0.8f; batchButton.textPadding = new RectOffset(0, 0, 5, 0); batchButton.relativePosition = new Vector3(deleteButton.relativePosition.x + deleteButton.width + 5, 5); batchButton.eventClick += (c, p) => { isBatchActionsEnabled = !isBatchActionsEnabled; renameButton.isVisible = !isBatchActionsEnabled; mergeButton.isVisible = !isBatchActionsEnabled; deleteButton.isVisible = !isBatchActionsEnabled; batchAddButton.isVisible = isBatchActionsEnabled; batchRemoveButton.isVisible = isBatchActionsEnabled; batchClearButton.isVisible = isBatchActionsEnabled; batchSelectAllButton.isVisible = isBatchActionsEnabled; if (isBatchActionsEnabled) { batchAssetSet.Clear(); batchButton.text = Translations.Translate("FIF_TAG_BAC"); batchButton.relativePosition = new Vector3(batchClearButton.relativePosition.x + batchClearButton.width + 5, 5); width = UISearchBox.instance.sizeFilterX.position.x + batchClearButton.width + 5; } else { batchButton.text = Translations.Translate("FIF_TAG_BAT"); batchButton.relativePosition = new Vector3(deleteButton.relativePosition.x + deleteButton.width + 5, 5); width = UISearchBox.instance.sizeFilterX.position.x; } UISearchBox.instance.scrollPanel.Refresh(); }; }
public override void Start() { name = "FindIt_TagsWindow"; atlas = SamsamTS.UIUtils.GetAtlas("Ingame"); backgroundSprite = "GenericPanelWhite"; size = new Vector2(320, 300); UILabel title = AddUIComponent <UILabel>(); title.text = Translations.Translate("FIF_CT_TIT"); title.textScale = 0.9f; title.textColor = new Color32(0, 0, 0, 255); title.relativePosition = new Vector3(spacing, spacing); UIButton close = AddUIComponent <UIButton>(); close.size = new Vector2(30f, 30f); close.text = "X"; close.textScale = 0.9f; close.textColor = new Color32(0, 0, 0, 255); close.focusedTextColor = new Color32(0, 0, 0, 255); close.hoveredTextColor = new Color32(109, 109, 109, 255); close.pressedTextColor = new Color32(128, 128, 128, 102); close.textPadding = new RectOffset(8, 8, 8, 8); close.canFocus = false; close.playAudioEvents = true; close.relativePosition = new Vector3(width - close.width, 0); close.eventClicked += (c, p) => Close(); m_tagsPanel = AddUIComponent <UIPanel>(); m_tagsPanel.size = new Vector2(width - 2 * spacing, height - 70); m_tagsPanel.autoFitChildrenVertically = true; m_tagsPanel.autoLayout = true; m_tagsPanel.autoLayoutDirection = LayoutDirection.Horizontal; m_tagsPanel.autoLayoutPadding = new RectOffset(0, 0, 0, 0); m_tagsPanel.autoLayoutStart = LayoutStart.TopLeft; m_tagsPanel.wrapLayout = true; m_tagsPanel.relativePosition = new Vector3(spacing, title.relativePosition.y + title.height + spacing); tagDropDownMenuMessage = AddUIComponent <UILabel>(); tagDropDownMenuMessage.text = Translations.Translate("FIF_CT_DDMSG"); tagDropDownMenuMessage.textScale = 0.9f; tagDropDownMenuMessage.textColor = new Color32(0, 0, 0, 255); tagDropDownMenuMessage.relativePosition = new Vector3(spacing, m_tagsPanel.relativePosition.y + m_tagsPanel.height + spacing * 6); // tag dropdown tagDropDownMenu = SamsamTS.UIUtils.CreateDropDown(this); tagDropDownMenu.normalBgSprite = "TextFieldPanelHovered"; tagDropDownMenu.size = new Vector2(width - 2 * spacing - 50, 30); tagDropDownMenu.tooltip = Translations.Translate("FIF_POP_SCR"); tagDropDownMenu.listHeight = 300; tagDropDownMenu.itemHeight = 30; tagDropDownMenu.relativePosition = new Vector3(spacing, tagDropDownMenuMessage.relativePosition.y + tagDropDownMenuMessage.height + spacing); UpdateCustomTagList(); SamsamTS.UIUtils.CreateDropDownScrollBar(tagDropDownMenu); // tag dropdown add button tagDropDownAddButton = SamsamTS.UIUtils.CreateButton(this); tagDropDownAddButton.size = new Vector2(35, 30); tagDropDownAddButton.text = "+"; tagDropDownAddButton.tooltip = Translations.Translate("FIF_CT_DDTP"); tagDropDownAddButton.relativePosition = new Vector3(spacing + tagDropDownMenu.width + 5, tagDropDownMenu.relativePosition.y); tagDropDownAddButton.eventClick += (c, p) => { if (customTagListStrArray.Length == 0) { return; } string newTag = GetDropDownListKey(); if (!m_asset.tagsCustom.Contains(newTag)) { AssetTagList.instance.AddCustomTags(m_asset, newTag); } Display(m_asset); }; inputMessage = AddUIComponent <UILabel>(); inputMessage.text = Translations.Translate("FIF_CT_ILBL1") + "\n" + Translations.Translate("FIF_CT_ILBL2"); inputMessage.textScale = 0.9f; inputMessage.textColor = new Color32(0, 0, 0, 255); inputMessage.relativePosition = new Vector3(spacing, tagDropDownMenu.relativePosition.y + tagDropDownMenu.height + spacing * 2); input = SamsamTS.UIUtils.CreateTextField(this); input.size = new Vector2(width - 2 * spacing, 30); input.padding.top = 7; input.tooltip = Translations.Translate("FIF_CT_ITP"); input.relativePosition = new Vector3(spacing, inputMessage.relativePosition.y + inputMessage.height + spacing); input.submitOnFocusLost = false; input.eventTextSubmitted += (c, t) => { AssetTagList.instance.AddCustomTags(m_asset, t); Display(m_asset); }; Display(m_asset); }
protected override void Initialize() { DropDown = UIUtil.CreateDropDownWithLabel(out label, this, Description, ParentWidth); DropDown.eventSelectedIndexChanged += DropDown_eventSelectedIndexChanged; }
/// <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; OptionsPanel.LocaleChanged(); }); 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; }); // 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; }); // 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; }); // 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; }); }
public UIDropDown GetDropDownValues() { UIDropDown uIDropDown = new UIDropDown(); string query = "select * FROM [ApplicationType] where IsActive = 1"; using (SqlCommand applicationCmd = new SqlCommand(query, this.conn)) { SqlDataReader reader = applicationCmd.ExecuteReader(); // reader.Read(); while (reader.Read()) { ApplicationType applicationType = new ApplicationType(); applicationType.Id = (int)reader["Id"]; applicationType.Name = (string)reader["Name"]; uIDropDown.ApplicationType.Add(applicationType); } reader.Close(); } query = "select * FROM [Clients] where IsActive = 1"; using (SqlCommand applicationCmd = new SqlCommand(query, this.conn)) { SqlDataReader reader = applicationCmd.ExecuteReader(); // reader.Read(); while (reader.Read()) { Client client = new Client(); client.Id = (int)reader["Id"]; client.Name = (string)reader["Name"]; uIDropDown.Client.Add(client); } reader.Close(); } query = "select * FROM [Environment] where IsActive = 1"; using (SqlCommand applicationCmd = new SqlCommand(query, this.conn)) { SqlDataReader reader = applicationCmd.ExecuteReader(); // reader.Read(); while (reader.Read()) { Models.Environment env = new Models.Environment(); env.Id = (int)reader["Id"]; env.Name = (string)reader["Name"]; uIDropDown.Environment.Add(env); } reader.Close(); } query = "select * FROM [Server] where IsActive = 1"; using (SqlCommand applicationCmd = new SqlCommand(query, this.conn)) { SqlDataReader reader = applicationCmd.ExecuteReader(); // reader.Read(); while (reader.Read()) { Models.Server server = new Models.Server(); server.Id = (int)reader["Id"]; server.Name = (string)reader["Name"]; uIDropDown.Server.Add(server); } reader.Close(); } query = "select * FROM [Technology] where IsActive = 1"; using (SqlCommand applicationCmd = new SqlCommand(query, this.conn)) { SqlDataReader reader = applicationCmd.ExecuteReader(); // reader.Read(); while (reader.Read()) { Models.Technology technology = new Models.Technology(); technology.Id = (int)reader["Id"]; technology.Name = (string)reader["Name"]; uIDropDown.Technology.Add(technology); } reader.Close(); } return(uIDropDown); }
private void CreateComponents() { int headerHeight = 40; // Label UILabel label = AddUIComponent <UILabel>(); label.text = "Doors"; label.relativePosition = new Vector3(WIDTH / 2 - label.width / 2, 10); // Drag handle UIDragHandle handle = AddUIComponent <UIDragHandle>(); handle.target = this; handle.constrainToScreen = true; handle.width = WIDTH; handle.height = headerHeight; handle.relativePosition = Vector3.zero; // Door selection label = AddUIComponent <UILabel>(); label.text = "Door:"; label.relativePosition = new Vector3(10, headerHeight + 15); m_doorDropdown = UIUtils.CreateDropDown(this); m_doorDropdown.width = WIDTH - 30 - label.width; m_doorDropdown.relativePosition = new Vector3(label.relativePosition.x + label.width + 10, headerHeight + 10); m_doorDropdown.eventSelectedIndexChanged += OnDoorSelectionChanged; // Door pos fields m_posFieldX = UIFloatField.CreateField("Pos X:", this); m_posFieldX.panel.relativePosition = new Vector3(10, headerHeight + 90); m_posFieldX.textField.eventTextChanged += (c, s) => { if (!m_checkEvents || m_selectedInfo == null || m_selectedInfo.m_doors == null || m_selectedInfo.m_doors.Length == 0) { return; } UIFloatField.FloatFieldHandler(m_posFieldX.textField, s, ref m_selectedInfo.m_doors[m_doorDropdown.selectedIndex].m_location.x); UpdateMarkerVisibility(); }; m_posFieldX.buttonUp.eventClicked += (c, b) => { if (!m_checkEvents || m_selectedInfo == null || m_selectedInfo.m_doors == null || m_selectedInfo.m_doors.Length == 0) { return; } m_posFieldX.SetValue(m_selectedInfo.m_doors[m_doorDropdown.selectedIndex].m_location.x + 0.1f); }; m_posFieldX.buttonDown.eventClicked += (c, b) => { if (!m_checkEvents || m_selectedInfo == null || m_selectedInfo.m_doors == null || m_selectedInfo.m_doors.Length == 0) { return; } m_posFieldX.SetValue(m_selectedInfo.m_doors[m_doorDropdown.selectedIndex].m_location.x - 0.1f); }; m_posFieldY = UIFloatField.CreateField("Pos Y:", this); m_posFieldY.panel.relativePosition = new Vector3(10, headerHeight + 120); m_posFieldY.textField.eventTextChanged += (c, s) => { if (!m_checkEvents || m_selectedInfo == null || m_selectedInfo.m_doors == null || m_selectedInfo.m_doors.Length == 0) { return; } UIFloatField.FloatFieldHandler(m_posFieldY.textField, s, ref m_selectedInfo.m_doors[m_doorDropdown.selectedIndex].m_location.y); UpdateMarkerVisibility(); }; m_posFieldY.buttonUp.eventClicked += (c, b) => { if (!m_checkEvents || m_selectedInfo == null || m_selectedInfo.m_doors == null || m_selectedInfo.m_doors.Length == 0) { return; } m_posFieldY.SetValue(m_selectedInfo.m_doors[m_doorDropdown.selectedIndex].m_location.y + 0.1f); }; m_posFieldY.buttonDown.eventClicked += (c, b) => { if (!m_checkEvents || m_selectedInfo == null || m_selectedInfo.m_doors == null || m_selectedInfo.m_doors.Length == 0) { return; } m_posFieldY.SetValue(m_selectedInfo.m_doors[m_doorDropdown.selectedIndex].m_location.y - 0.1f); }; m_posFieldZ = UIFloatField.CreateField("Pos Z:", this); m_posFieldZ.panel.relativePosition = new Vector3(10, headerHeight + 150); m_posFieldZ.textField.eventTextChanged += (c, s) => { if (!m_checkEvents || m_selectedInfo == null || m_selectedInfo.m_doors == null || m_selectedInfo.m_doors.Length == 0) { return; } UIFloatField.FloatFieldHandler(m_posFieldZ.textField, s, ref m_selectedInfo.m_doors[m_doorDropdown.selectedIndex].m_location.z); UpdateMarkerVisibility(); }; m_posFieldZ.buttonUp.eventClicked += (c, b) => { if (!m_checkEvents || m_selectedInfo == null || m_selectedInfo.m_doors == null || m_selectedInfo.m_doors.Length == 0) { return; } m_posFieldZ.SetValue(m_selectedInfo.m_doors[m_doorDropdown.selectedIndex].m_location.z + 0.1f); }; m_posFieldZ.buttonDown.eventClicked += (c, b) => { if (!m_checkEvents || m_selectedInfo == null || m_selectedInfo.m_doors == null || m_selectedInfo.m_doors.Length == 0) { return; } m_posFieldZ.SetValue(m_selectedInfo.m_doors[m_doorDropdown.selectedIndex].m_location.z - 0.1f); }; // Add and remove buttons m_addButton = UIUtils.CreateButton(this); m_addButton.text = "Add"; m_addButton.relativePosition = new Vector3(WIDTH / 2 - m_addButton.width - 10, headerHeight + 50); m_addButton.eventClicked += (c, b) => { if (!m_checkEvents || m_selectedInfo == null) { return; } TryAddDoor(); }; m_removeButton = UIUtils.CreateButton(this); m_removeButton.text = "Remove"; m_removeButton.relativePosition = new Vector3(WIDTH / 2 + 10, headerHeight + 50); m_removeButton.eventClicked += (c, b) => { if (!m_checkEvents || m_selectedInfo == null) { return; } TryRemoveDoor(); }; // m_checkEvents = true; }
public void OnSettingsUI(UIHelperBase helperDefault) { if (TransportLinesManagerMod.instance != null && TransportLinesManagerMod.debugMode) { TLMUtils.doLog("Loading Options"); } loadTLMLocale(false); string[] namingOptionsSufixo = new string[] { Locale.Get("TLM_MODO_NOMENCLATURA", Enum.GetName(typeof(ModoNomenclatura), 0)), Locale.Get("TLM_MODO_NOMENCLATURA", Enum.GetName(typeof(ModoNomenclatura), 1)), Locale.Get("TLM_MODO_NOMENCLATURA", Enum.GetName(typeof(ModoNomenclatura), 2)), Locale.Get("TLM_MODO_NOMENCLATURA", Enum.GetName(typeof(ModoNomenclatura), 3)), Locale.Get("TLM_MODO_NOMENCLATURA", Enum.GetName(typeof(ModoNomenclatura), 4)), Locale.Get("TLM_MODO_NOMENCLATURA", Enum.GetName(typeof(ModoNomenclatura), 5)), Locale.Get("TLM_MODO_NOMENCLATURA", Enum.GetName(typeof(ModoNomenclatura), 6)), }; string[] namingOptionsPrefixo = new string[] { Locale.Get("TLM_MODO_NOMENCLATURA", Enum.GetName(typeof(ModoNomenclatura), 0)), Locale.Get("TLM_MODO_NOMENCLATURA", Enum.GetName(typeof(ModoNomenclatura), 1)), Locale.Get("TLM_MODO_NOMENCLATURA", Enum.GetName(typeof(ModoNomenclatura), 2)), Locale.Get("TLM_MODO_NOMENCLATURA", Enum.GetName(typeof(ModoNomenclatura), 3)), Locale.Get("TLM_MODO_NOMENCLATURA", Enum.GetName(typeof(ModoNomenclatura), 4)), Locale.Get("TLM_MODO_NOMENCLATURA", Enum.GetName(typeof(ModoNomenclatura), 5)), Locale.Get("TLM_MODO_NOMENCLATURA", Enum.GetName(typeof(ModoNomenclatura), 6)), Locale.Get("TLM_MODO_NOMENCLATURA", Enum.GetName(typeof(ModoNomenclatura), 7)), Locale.Get("TLM_MODO_NOMENCLATURA", Enum.GetName(typeof(ModoNomenclatura), 8)), Locale.Get("TLM_MODO_NOMENCLATURA", Enum.GetName(typeof(ModoNomenclatura), 9)), Locale.Get("TLM_MODO_NOMENCLATURA", Enum.GetName(typeof(ModoNomenclatura), 10)), Locale.Get("TLM_MODO_NOMENCLATURA", Enum.GetName(typeof(ModoNomenclatura), 11)), Locale.Get("TLM_MODO_NOMENCLATURA", Enum.GetName(typeof(ModoNomenclatura), 12)), Locale.Get("TLM_MODO_NOMENCLATURA", Enum.GetName(typeof(ModoNomenclatura), 13)), }; string[] namingOptionsSeparador = new string[] { Locale.Get("TLM_SEPARATOR", Enum.GetName(typeof(Separador), 0)), Locale.Get("TLM_SEPARATOR", Enum.GetName(typeof(Separador), 1)), Locale.Get("TLM_SEPARATOR", Enum.GetName(typeof(Separador), 2)), Locale.Get("TLM_SEPARATOR", Enum.GetName(typeof(Separador), 3)), Locale.Get("TLM_SEPARATOR", Enum.GetName(typeof(Separador), 4)), Locale.Get("TLM_SEPARATOR", Enum.GetName(typeof(Separador), 5)), }; UIHelperExtension helper = new UIHelperExtension((UIHelper)helperDefault); helper.self.eventVisibilityChanged += delegate(UIComponent component, bool b) { if (b) { showVersionInfoPopup(); } }; OnCheckChanged iptToggle = delegate(bool value) { overrideWorldInfoPanelLineOption.isVisible = !value; m_IPTCompatibilityMode.value = value; }; helper.AddCheckboxLocalized("TLM_IPT_COMP_MODE_DESC", m_IPTCompatibilityMode.value, iptToggle); overrideWorldInfoPanelLineOption = (UICheckBox)helper.AddCheckboxLocalized("TLM_OVERRIDE_DEFAULT_LINE_INFO", m_savedOverrideDefaultLineInfoPanel.value, toggleOverrideDefaultLineInfoPanel); helper.AddSpace(10); configSelector = (UIDropDown)helper.AddDropdownLocalized("TLM_SHOW_CONFIG_FOR", getOptionsForLoadConfig(), 0, reloadData); if (TransportLinesManagerMod.instance != null && TransportLinesManagerMod.debugMode) { TLMUtils.doLog("Loading Group 1"); } foreach (TLMConfigWarehouse.ConfigIndex transportType in new TLMConfigWarehouse.ConfigIndex[] { TLMConfigWarehouse.ConfigIndex.PLANE_CONFIG, TLMConfigWarehouse.ConfigIndex.BLIMP_CONFIG, TLMConfigWarehouse.ConfigIndex.SHIP_CONFIG, TLMConfigWarehouse.ConfigIndex.FERRY_CONFIG, TLMConfigWarehouse.ConfigIndex.CABLE_CAR_CONFIG, TLMConfigWarehouse.ConfigIndex.BUS_CONFIG, TLMConfigWarehouse.ConfigIndex.TRAM_CONFIG, TLMConfigWarehouse.ConfigIndex.MONORAIL_CONFIG, TLMConfigWarehouse.ConfigIndex.METRO_CONFIG, TLMConfigWarehouse.ConfigIndex.TRAIN_CONFIG }) { UIHelperExtension group1 = helper.AddGroupExtended(string.Format(Locale.Get("TLM_CONFIGS_FOR"), TLMConfigWarehouse.getNameForTransportType(transportType))); lineTypesPanels[transportType] = group1.self.GetComponentInParent <UIPanel>(); ((UIPanel)group1.self).autoLayoutDirection = LayoutDirection.Horizontal; ((UIPanel)group1.self).backgroundSprite = "EmptySprite"; ((UIPanel)group1.self).wrapLayout = true; var systemColor = TLMConfigWarehouse.getColorForTransportType(transportType); ((UIPanel)group1.self).color = new Color32((byte)(systemColor.r * 0.7f), (byte)(systemColor.g * 0.7f), (byte)(systemColor.b * 0.7f), 0xff); ((UIPanel)group1.self).width = 730; group1.AddSpace(30); UIDropDown prefixDD = generateDropdownConfig(group1, Locale.Get("TLM_PREFIX"), namingOptionsPrefixo, transportType | TLMConfigWarehouse.ConfigIndex.PREFIX); var separatorContainer = generateDropdownConfig(group1, Locale.Get("TLM_SEPARATOR"), namingOptionsSeparador, transportType | TLMConfigWarehouse.ConfigIndex.SEPARATOR).transform.parent.GetComponent <UIPanel>(); UIDropDown suffixDD = generateDropdownConfig(group1, Locale.Get("TLM_SUFFIX"), namingOptionsSufixo, transportType | TLMConfigWarehouse.ConfigIndex.SUFFIX); var suffixDDContainer = suffixDD.transform.parent.GetComponent <UIPanel>(); UIDropDown nonPrefixDD = generateDropdownConfig(group1, Locale.Get("TLM_IDENTIFIER_NON_PREFIXED"), namingOptionsSufixo, transportType | TLMConfigWarehouse.ConfigIndex.NON_PREFIX); var prefixedPaletteContainer = generateDropdownStringValueConfig(group1, Locale.Get("TLM_PALETTE_PREFIXED"), TLMAutoColorPalettes.paletteList, transportType | TLMConfigWarehouse.ConfigIndex.PALETTE_MAIN).transform.parent.GetComponent <UIPanel>(); var paletteLabel = generateDropdownStringValueConfig(group1, Locale.Get("TLM_PALETTE_UNPREFIXED"), TLMAutoColorPalettes.paletteList, transportType | TLMConfigWarehouse.ConfigIndex.PALETTE_SUBLINE).transform.parent.GetComponentInChildren <UILabel>(); var zerosContainer = generateCheckboxConfig(group1, Locale.Get("TLM_LEADING_ZEROS_SUFFIX"), transportType | TLMConfigWarehouse.ConfigIndex.LEADING_ZEROS); var prefixAsSuffixContainer = generateCheckboxConfig(group1, Locale.Get("TLM_INVERT_PREFIX_SUFFIX_ORDER"), transportType | TLMConfigWarehouse.ConfigIndex.INVERT_PREFIX_SUFFIX); generateCheckboxConfig(group1, Locale.Get("TLM_RANDOM_ON_PALETTE_OVERFLOW"), transportType | TLMConfigWarehouse.ConfigIndex.PALETTE_RANDOM_ON_OVERFLOW); var autoColorBasedContainer = generateCheckboxConfig(group1, Locale.Get("TLM_AUTO_COLOR_BASED_ON_PREFIX"), transportType | TLMConfigWarehouse.ConfigIndex.PALETTE_PREFIX_BASED); PropertyChangedEventHandler <int> updateFunction = delegate(UIComponent c, int sel) { bool isPrefixed = (ModoNomenclatura)sel != ModoNomenclatura.Nenhum; separatorContainer.isVisible = isPrefixed; prefixedPaletteContainer.isVisible = isPrefixed; suffixDDContainer.isVisible = isPrefixed; zerosContainer.isVisible = isPrefixed && (ModoNomenclatura)suffixDD.selectedIndex == ModoNomenclatura.Numero; prefixAsSuffixContainer.isVisible = isPrefixed && (ModoNomenclatura)suffixDD.selectedIndex == ModoNomenclatura.Numero && (ModoNomenclatura)prefixDD.selectedIndex != ModoNomenclatura.Numero; autoColorBasedContainer.isVisible = isPrefixed; paletteLabel.text = isPrefixed ? Locale.Get("TLM_PALETTE_UNPREFIXED") : Locale.Get("TLM_PALETTE"); if (TLMPublicTransportDetailPanel.instance != null && TLMPublicTransportDetailPanel.instance.m_systemTypeDropDown != null) { TLMPublicTransportDetailPanel.instance.m_systemTypeDropDown.selectedIndex = 0; } }; prefixDD.eventSelectedIndexChanged += updateFunction; suffixDD.eventSelectedIndexChanged += delegate(UIComponent c, int sel) { bool isPrefixed = (ModoNomenclatura)prefixDD.selectedIndex != ModoNomenclatura.Nenhum; zerosContainer.isVisible = isPrefixed && (ModoNomenclatura)sel == ModoNomenclatura.Numero; prefixAsSuffixContainer.isVisible = isPrefixed && (ModoNomenclatura)sel == ModoNomenclatura.Numero && (ModoNomenclatura)prefixDD.selectedIndex != ModoNomenclatura.Numero; }; updateFunction.Invoke(null, prefixDD.selectedIndex); } if (TransportLinesManagerMod.instance != null && TransportLinesManagerMod.debugMode) { TLMUtils.doLog("Loading Group 2"); } UIHelperExtension group7 = helper.AddGroupExtended(Locale.Get("TLM_NEAR_LINES_CONFIG")); group7.AddCheckbox(Locale.Get("TLM_NEAR_LINES_SHOW_IN_SERVICES_BUILDINGS"), m_savedShowNearLinesInCityServicesWorldInfoPanel.value, toggleShowNearLinesInCityServicesWorldInfoPanel); group7.AddCheckbox(Locale.Get("TLM_NEAR_LINES_SHOW_IN_ZONED_BUILDINGS"), m_savedShowNearLinesInZonedBuildingWorldInfoPanel.value, toggleShowNearLinesInZonedBuildingWorldInfoPanel); group7.AddSpace(20); generateCheckboxConfig(group7, Locale.Get("TLM_NEAR_LINES_SHOW_BUS"), TLMConfigWarehouse.ConfigIndex.BUS_SHOW_IN_LINEAR_MAP); generateCheckboxConfig(group7, Locale.Get("TLM_NEAR_LINES_SHOW_TRAM"), TLMConfigWarehouse.ConfigIndex.TRAM_SHOW_IN_LINEAR_MAP); generateCheckboxConfig(group7, Locale.Get("TLM_NEAR_LINES_SHOW_METRO"), TLMConfigWarehouse.ConfigIndex.METRO_SHOW_IN_LINEAR_MAP); generateCheckboxConfig(group7, Locale.Get("TLM_NEAR_LINES_SHOW_TRAIN"), TLMConfigWarehouse.ConfigIndex.TRAIN_SHOW_IN_LINEAR_MAP); generateCheckboxConfig(group7, Locale.Get("TLM_NEAR_LINES_SHOW_SHIP"), TLMConfigWarehouse.ConfigIndex.SHIP_SHOW_IN_LINEAR_MAP); generateCheckboxConfig(group7, Locale.Get("TLM_NEAR_LINES_SHOW_PLANE"), TLMConfigWarehouse.ConfigIndex.PLANE_SHOW_IN_LINEAR_MAP); generateCheckboxConfig(group7, Locale.Get("TLM_NEAR_LINES_SHOW_TAXI"), TLMConfigWarehouse.ConfigIndex.TAXI_SHOW_IN_LINEAR_MAP); generateCheckboxConfig(group7, Locale.Get("TLM_NEAR_LINES_SHOW_MONORAIL"), TLMConfigWarehouse.ConfigIndex.MONORAIL_SHOW_IN_LINEAR_MAP); generateCheckboxConfig(group7, Locale.Get("TLM_NEAR_LINES_SHOW_CABLE_CAR"), TLMConfigWarehouse.ConfigIndex.CABLE_CAR_SHOW_IN_LINEAR_MAP); UIHelperExtension group8 = helper.AddGroupExtended(Locale.Get("TLM_AUTOMATION_CONFIG")); generateCheckboxConfig(group8, Locale.Get("TLM_AUTO_COLOR_ENABLED"), TLMConfigWarehouse.ConfigIndex.AUTO_COLOR_ENABLED); generateCheckboxConfig(group8, Locale.Get("TLM_AUTO_NAME_ENABLED"), TLMConfigWarehouse.ConfigIndex.AUTO_NAME_ENABLED); generateCheckboxConfig(group8, Locale.Get("TLM_USE_CIRCULAR_AUTO_NAME"), TLMConfigWarehouse.ConfigIndex.CIRCULAR_IN_SINGLE_DISTRICT_LINE); generateCheckboxConfig(group8, Locale.Get("TLM_ADD_LINE_NUMBER_AUTO_NAME"), TLMConfigWarehouse.ConfigIndex.ADD_LINE_NUMBER_IN_AUTONAME); UIHelperExtension group13 = helper.AddGroupExtended(Locale.Get("TLM_AUTO_NAME_SETTINGS_PUBLIC_TRANSPORT")); ((UIPanel)group13.self).autoLayoutDirection = LayoutDirection.Horizontal; ((UIPanel)group13.self).wrapLayout = true; ((UIPanel)group13.self).width = 730; group13.AddSpace(1); group13.AddLabel(Locale.Get("TLM_AUTO_NAME_SETTINGS_PUBLIC_TRANSPORT_DESC")); group13.AddSpace(1); foreach (TLMConfigWarehouse.ConfigIndex ci in TLMConfigWarehouse.configurableAutoNameTransportCategories) { generateCheckboxConfig(group13, TLMConfigWarehouse.getNameForTransportType(ci), TLMConfigWarehouse.ConfigIndex.PUBLICTRANSPORT_USE_FOR_AUTO_NAMING_REF | ci).width = 300; var textFieldPanel = generateTextFieldConfig(group13, Locale.Get("TLM_PREFIX_OPTIONAL"), TLMConfigWarehouse.ConfigIndex.PUBLICTRANSPORT_AUTO_NAMING_REF_TEXT | ci).GetComponentInParent <UIPanel>(); textFieldPanel.autoLayoutDirection = LayoutDirection.Horizontal; textFieldPanel.autoFitChildrenVertically = true; group13.AddSpace(1); } UIHelperExtension group14 = helper.AddGroupExtended(Locale.Get("TLM_AUTO_NAME_SETTINGS_OTHER")); ((UIPanel)group14.self).autoLayoutDirection = LayoutDirection.Horizontal; ((UIPanel)group14.self).wrapLayout = true; ((UIPanel)group14.self).width = 730; foreach (TLMConfigWarehouse.ConfigIndex ci in TLMConfigWarehouse.configurableAutoNameCategories) { generateCheckboxConfig(group14, TLMConfigWarehouse.getNameForServiceType(ci), TLMConfigWarehouse.ConfigIndex.USE_FOR_AUTO_NAMING_REF | ci).width = 300; var textFieldPanel = generateTextFieldConfig(group14, Locale.Get("TLM_PREFIX_OPTIONAL"), TLMConfigWarehouse.ConfigIndex.AUTO_NAMING_REF_TEXT | ci).GetComponentInParent <UIPanel>(); textFieldPanel.autoLayoutDirection = LayoutDirection.Horizontal; textFieldPanel.autoFitChildrenVertically = true; group14.AddSpace(2); } if (TransportLinesManagerMod.instance != null && TransportLinesManagerMod.debugMode) { TLMUtils.doLog("Loading Group 3"); } UIHelperExtension group6 = helper.AddGroupExtended(Locale.Get("TLM_CUSTOM_PALETTE_CONFIG") + " [" + UIHelperExtension.version + "]"); ((group6.self) as UIPanel).autoLayoutDirection = LayoutDirection.Horizontal; ((group6.self) as UIPanel).wrapLayout = true; UITextField paletteName = null; DropDownColorSelector colorEditor = null; NumberedColorList colorList = null; editorSelector = group6.AddDropdown(Locale.Get("TLM_PALETTE_SELECT"), TLMAutoColorPalettes.paletteListForEditing, 0, delegate(int sel) { if (sel <= 0 || sel >= TLMAutoColorPalettes.paletteListForEditing.Length) { paletteName.enabled = false; colorEditor.Disable(); colorList.Disable(); } else { paletteName.enabled = true; colorEditor.Disable(); colorList.colorList = TLMAutoColorPalettes.getColors(TLMAutoColorPalettes.paletteListForEditing[sel]); colorList.Enable(); paletteName.text = TLMAutoColorPalettes.paletteListForEditing[sel]; } }) as UIDropDown; group6.AddButton(Locale.Get("CREATE"), delegate() { string newName = TLMAutoColorPalettes.addPalette(); updateDropDowns("", ""); editorSelector.selectedValue = newName; }); group6.AddButton(Locale.Get("TLM_DELETE"), delegate() { TLMAutoColorPalettes.removePalette(editorSelector.selectedValue); updateDropDowns("", ""); }); paletteName = group6.AddTextField(Locale.Get("TLM_PALETTE_NAME"), delegate(string val) { }, "", (string value) => { string oldName = editorSelector.selectedValue; paletteName.text = TLMAutoColorPalettes.renamePalette(oldName, value); updateDropDowns(oldName, value); }); paletteName.parent.width = 500; colorEditor = group6.AddColorField(Locale.Get("TLM_COLORS"), Color.black, delegate(Color c) { TLMAutoColorPalettes.setColor(colorEditor.id, editorSelector.selectedValue, c); colorList.colorList = TLMAutoColorPalettes.getColors(editorSelector.selectedValue); }, delegate { TLMAutoColorPalettes.removeColor(editorSelector.selectedValue, colorEditor.id); colorList.colorList = TLMAutoColorPalettes.getColors(editorSelector.selectedValue); }); colorList = group6.AddNumberedColorList(null, new List <Color32>(), delegate(int c) { colorEditor.id = c; colorEditor.selectedColor = TLMAutoColorPalettes.getColor(c, editorSelector.selectedValue, false); colorEditor.title = c.ToString(); colorEditor.Enable(); }, colorEditor.parent.GetComponentInChildren <UILabel>(), delegate() { TLMAutoColorPalettes.addColor(editorSelector.selectedValue); }); if (TransportLinesManagerMod.instance != null && TransportLinesManagerMod.debugMode) { TLMUtils.doLog("Loading Group 3½"); } paletteName.enabled = false; colorEditor.Disable(); colorList.Disable(); iptToggle.Invoke(isIPTCompatibiltyMode); if (TransportLinesManagerMod.instance != null && TransportLinesManagerMod.debugMode) { TLMUtils.doLog("Loading Group 4"); } UIHelperExtension group9 = helper.AddGroupExtended(Locale.Get("TLM_BETAS_EXTRA_INFO")); group9.AddDropdownLocalized("TLM_MOD_LANG", TLMLocaleUtils.getLanguageIndex(), currentLanguageId.value, delegate(int idx) { currentLanguageId.value = idx; loadTLMLocale(true); }); group9.AddButton(Locale.Get("TLM_DRAW_CITY_MAP"), TLMMapDrawer.drawCityMap); group9.AddCheckbox(Locale.Get("TLM_DEBUG_MODE"), m_debugMode.value, delegate(bool val) { m_debugMode.value = val; }); group9.AddLabel("Version: " + version + " rev" + typeof(TransportLinesManagerMod).Assembly.GetName().Version.Revision); group9.AddButton(Locale.Get("TLM_RELEASE_NOTES"), delegate() { showVersionInfoPopup(true); }); if (TransportLinesManagerMod.instance != null && TransportLinesManagerMod.debugMode) { TLMUtils.doLog("End Loading Options"); } }
private void ShowInPanelResolveGrowables(PrefabInfo pInfo) { if (!(pInfo is BuildingInfo)) { ShowInPanel(pInfo); return; } BuildingInfo info = pInfo as BuildingInfo; //BuildingInfo info = PrefabCollection<BuildingInfo>.FindLoaded("4x3_Beach Hotel3"); if (info != null && ((info.m_class.m_service == ItemClass.Service.Residential) || (info.m_class.m_service == ItemClass.Service.Industrial) || (info.m_class.m_service == ItemClass.Service.Commercial) || (info.m_class.m_service == ItemClass.Service.Office) || (info.m_class.m_service == ItemClass.Service.Tourism))) { Debug.LogWarning("Info " + info.name + " is a growable (or RICO)."); bool Pass1 = false; // Try to locate in Find It! UIComponent SearchBoxPanel = UIView.Find("UISearchBox"); if (SearchBoxPanel != null && SearchBoxPanel.isVisible == false) { UIButton FIButton = UIView.Find <UIButton>("FindItMainButton"); if (FIButton == null) { return; } FIButton.SimulateClick(); } if (SearchBoxPanel == null) { return; } UIDropDown FilterDropdown = SearchBoxPanel.Find <UIDropDown>("UIDropDown"); FilterDropdown.selectedValue = "Growable"; UITextField TextField = SearchBoxPanel.Find <UITextField>("UITextField"); TextField.text = ""; UIComponent UIFilterGrowable = SearchBoxPanel.Find("UIFilterGrowable"); UIFilterGrowable.GetComponentInChildren <UIButton>().SimulateClick(); // Reflect into the scroll panel, starting with the growable panel: if (!ReflectIntoFindIt(info)) { // And then if that fails, RICO: FilterDropdown.selectedValue = "Rico"; if (!ReflectIntoFindIt(info)) { // And then if that fails, give up and get a drink Debug.Log("Could not be found in Growable or Rico menus."); } } } else { Debug.LogWarning("Info " + info.name + " is not a growable."); ShowInPanel(pInfo); } }
public void OnSettingsUI(UIHelperBase helper) { ExtendedGameOptionsSerializable o = Singleton <ExtendedGameOptionsManager> .instance.values; //////////// General //////////// helper.AddCheckbox("Enable achievements", o.EnableAchievements, delegate(bool isChecked) { o.EnableAchievements = isChecked; Achievements.Update(); modified = true; }); helper.AddCheckbox("Info View buttons are always enabled", o.InfoViewButtonsAlwaysEnabled, delegate(bool isChecked) { o.InfoViewButtonsAlwaysEnabled = isChecked; modified = true; }); helper.AddSpace(20); //////////// Unlocks //////////// UIHelperBase unlockGroup = helper.AddGroup("Unlocks (requires game reload)"); unlockGroup.AddCheckbox("Basic roads are available from the start", o.BasicRoadsAvailableBromStart, delegate(bool isChecked) { o.BasicRoadsAvailableBromStart = isChecked; modified = true; }); unlockGroup.AddCheckbox("Train tracks can be constructed without a train station", o.TrainTrackUnlock, delegate(bool isChecked) { o.TrainTrackUnlock = isChecked; modified = true; }); unlockGroup.AddCheckbox("Metro tunnels can be constructed without a metro station", o.MetroTrackUnlock, delegate(bool isChecked) { o.MetroTrackUnlock = isChecked; modified = true; }); unlockGroup.AddCheckbox("Unlock everything up to the following milestone", o.UnlockMilestone, delegate(bool isChecked) { o.UnlockMilestone = isChecked; modified = true; }); unlockGroup.AddDropdown(" (select Megalopolis to unlock all)", Milestones.MilestoneLocalizedNames, o.UnlockMilestoneIndex - 1, delegate(int sel) { o.UnlockMilestoneIndex = sel + 1; modified = true; }); //////////// Economy //////////// UIHelperBase economyGroup = helper.AddGroup("Economy"); economyGroup.AddTextfield("Initial money", o.InitialMoney.ToString(), delegate(string text) { }, delegate(string text) { int value; if (int.TryParse(text, out value)) { value = Mathf.Clamp(value, 0, 10 * 1000 * 1000); o.InitialMoney = value; Economy.UpdateInitialMoney(); modified = true; } }); economyGroup.AddCheckbox("Bulldozing structures built recently gives full refund", o.FullRefund, delegate(bool isChecked) { o.FullRefund = isChecked; modified = true; }); //////////// Others //////////// if (SteamHelper.IsDLCOwned(SteamHelper.DLC.NaturalDisastersDLC)) { helper.AddCheckbox("Enable random disasters for scenarios", o.EnableRandomDisastersForScenarios, delegate(bool isChecked) { o.EnableRandomDisastersForScenarios = isChecked; modified = true; }); } helper.AddCheckbox("Set number of purchasable areas (uncheck this if using 81 tiles mod)", o.EnableAreasMaxCountOption, delegate(bool isChecked) { Singleton <ExtendedGameOptionsManager> .instance.values.EnableAreasMaxCountOption = isChecked; if (isChecked) { Areas.Update(); } else { Areas.Reset(); } modified = true; }); UIDropDown areasMaxCountDropdown = (UIDropDown)helper.AddDropdown("Areas", Areas.GetAvailableValuesStr(), o.AreasMaxCount - 1, delegate(int sel) { o.AreasMaxCount = sel + 1; Areas.Update(); modified = true; }); helper.AddSpace(20); //////////// Resources //////////// UIHelperBase resourcesHelper = helper.AddGroup("Resources depletion rate"); addLabelToResourceSlider(resourcesHelper.AddSlider("Oil depletion rate", 0, 100, 1, o.OilDepletionRate, delegate(float val) { o.OilDepletionRate = (int)val; modified = true; })); addLabelToResourceSlider(resourcesHelper.AddSlider("Ore depletion rate", 0, 100, 1, o.OreDepletionRate, delegate(float val) { o.OreDepletionRate = (int)val; modified = true; })); UIComponent optionPanel = areasMaxCountDropdown.parent.parent; optionPanel.eventVisibilityChanged += OptionPanel_eventVisibilityChanged; }
private void CreatePrefixSelectorUI() { this.m_prefixOptions = UIHelperExtension.CloneBasicDropDownNoLabel(new string[] { }, onChangePrefixSelected, gameObject.GetComponent <UIPanel>()); m_prefixOptions.area = new Vector4(550, 3, 80, 33); m_prefixesServed = base.Find <UILabel>("LineVehicles"); m_prefixesServed.autoSize = true; m_prefixesServed.textScale = 0.6f; m_prefixesServed.pivot = UIPivotPoint.TopLeft; m_prefixesServed.verticalAlignment = UIVerticalAlignment.Middle; m_prefixesServed.minimumSize = new Vector2(210, 35); TLMUtils.LimitWidth(m_prefixesServed); //Buttons TLMUtils.createUIElement(out m_addPrefixButton, transform); m_addPrefixButton.pivot = UIPivotPoint.TopRight; m_addPrefixButton.relativePosition = new Vector3(680, 2); m_addPrefixButton.text = Locale.Get("TLM_ADD"); m_addPrefixButton.textScale = 0.6f; m_addPrefixButton.width = 50; m_addPrefixButton.height = 15; m_addPrefixButton.tooltip = Locale.Get("TLM_ADD_PREFIX_TOOLTIP"); TLMUtils.initButton(m_addPrefixButton, true, "ButtonMenu"); m_addPrefixButton.name = "Add"; m_addPrefixButton.isVisible = true; m_addPrefixButton.eventClick += (component, eventParam) => { uint prefix = m_prefixOptions.selectedIndex == m_prefixOptions.items.Length - 1 ? 65 : (uint)m_prefixOptions.selectedIndex; TLMDepotAI.addPrefixToDepot(buildingId, prefix, secondary); m_addPrefixButton.isVisible = false; m_removePrefixButton.isVisible = true; }; TLMUtils.createUIElement(out m_removePrefixButton, transform); m_removePrefixButton.pivot = UIPivotPoint.TopRight; m_removePrefixButton.relativePosition = new Vector3(730, 2); m_removePrefixButton.text = Locale.Get("TLM_REMOVE"); m_removePrefixButton.textScale = 0.6f; m_removePrefixButton.width = 50; m_removePrefixButton.height = 15; m_removePrefixButton.tooltip = Locale.Get("TLM_REMOVE_PREFIX_TOOLTIP"); TLMUtils.initButton(m_removePrefixButton, true, "ButtonMenu"); m_removePrefixButton.name = "Remove"; m_removePrefixButton.isVisible = true; m_removePrefixButton.eventClick += (component, eventParam) => { uint prefix = m_prefixOptions.selectedIndex == m_prefixOptions.items.Length - 1 ? 65 : (uint)m_prefixOptions.selectedIndex; TLMDepotAI.removePrefixFromDepot(buildingId, prefix, secondary); m_addPrefixButton.isVisible = true; m_removePrefixButton.isVisible = false; }; TLMUtils.createUIElement(out m_addAllPrefixesButton, transform); m_addAllPrefixesButton.pivot = UIPivotPoint.TopRight; m_addAllPrefixesButton.relativePosition = new Vector3(680, 20); m_addAllPrefixesButton.text = Locale.Get("TLM_ADD_ALL_SHORT"); ; m_addAllPrefixesButton.textScale = 0.6f; m_addAllPrefixesButton.width = 50; m_addAllPrefixesButton.height = 15; m_addAllPrefixesButton.tooltip = Locale.Get("TLM_ADD_ALL_PREFIX_TOOLTIP"); TLMUtils.initButton(m_addAllPrefixesButton, true, "ButtonMenu"); m_addAllPrefixesButton.name = "AddAll"; m_addAllPrefixesButton.isVisible = true; m_addAllPrefixesButton.eventClick += (component, eventParam) => { TLMDepotAI.addAllPrefixesToDepot(buildingId, secondary); m_addPrefixButton.isVisible = false; m_removePrefixButton.isVisible = true; }; TLMUtils.createUIElement(out m_removeAllPrefixesButton, transform); m_removeAllPrefixesButton.pivot = UIPivotPoint.TopRight; m_removeAllPrefixesButton.relativePosition = new Vector3(730, 20); m_removeAllPrefixesButton.text = Locale.Get("TLM_REMOVE_ALL_SHORT"); m_removeAllPrefixesButton.textScale = 0.6f; m_removeAllPrefixesButton.width = 50; m_removeAllPrefixesButton.height = 15; m_removeAllPrefixesButton.tooltip = Locale.Get("TLM_REMOVE_ALL_PREFIX_TOOLTIP"); TLMUtils.initButton(m_removeAllPrefixesButton, true, "ButtonMenu"); m_removeAllPrefixesButton.name = "RemoveAll"; m_removeAllPrefixesButton.isVisible = true; m_removeAllPrefixesButton.eventClick += (component, eventParam) => { TLMDepotAI.removeAllPrefixesFromDepot(buildingId, secondary); m_addPrefixButton.isVisible = true; m_removePrefixButton.isVisible = false; }; }
public void OnSettingsUI(UIHelperBase helper) { helper.AddSpace(20); useSavegameDataCheckbox = (UICheckBox)helper.AddCheckbox("Save data to savegame file", Settings.UseSavegameData, (b) => { Settings.UseSavegameData = b; Settings.Save(); saveGlobalDataOnDataChangedCheckbox.isEnabled = !b; saveGlobalDataOnDataChangedCheckbox.opacity = b ? 0.25f : 1f; }); useSavegameDataCheckbox.tooltip = "Enable this option to save building settings on a per-city\n" + "basis. Disabling this option makes all changes global ( ie.\n" + "buildings will load your customized settings on all cities.)"; saveGlobalDataOnDataChangedCheckbox = (UICheckBox)helper.AddCheckbox("Save global data each time you modify a building's settings", Settings.SaveGlobalDataOnDataChanged, (b) => { Settings.SaveGlobalDataOnDataChanged = b; Settings.Save(); }); saveGlobalDataOnDataChangedCheckbox.isEnabled = !Settings.UseSavegameData; saveGlobalDataOnDataChangedCheckbox.opacity = Settings.UseSavegameData ? 0.25f : 1f; saveGlobalDataOnDataChangedCheckbox.tooltip = "Enable this option to save data each time you modify a building's\n" + "settings. This option only works when using Global Data (ie.\n" + "only when the 'Save data to savegame file' option is disabled.)"; displayPlacementModeCheckbox = (UICheckBox)helper.AddCheckbox("Display Placement Mode in the construction cost tooltip", Settings.DisplayPlacementMode, (b) => { Settings.DisplayPlacementMode = b; Settings.Save(); }); displayFlattenTerrainCheckbox = (UICheckBox)helper.AddCheckbox("Display Flatten Terrain enabled state in the construction cost tooltip", Settings.DisplayFlattenTerrain, (b) => { Settings.DisplayFlattenTerrain = b; Settings.Save(); }); displayFullGravelCheckbox = (UICheckBox)helper.AddCheckbox("Display Full Gravel enabled state in the construction cost tooltip", Settings.DisplayFullGravel, (b) => { Settings.DisplayFullGravel = b; Settings.Save(); }); displayFullPavementCheckbox = (UICheckBox)helper.AddCheckbox("Display Full Pavement enabled state in the construction cost tooltip", Settings.DisplayFullPavement, (b) => { Settings.DisplayFullPavement = b; Settings.Save(); }); helper.AddSpace(20); shortcutsDropdown = (UIDropDown)helper.AddDropdown("Select Placement Mode keyboard shortcut preference", shortcutOptions, SelectedShortcutIndex, (i) => { Settings.UseArrowKeys = i == 0 ? true : false; Settings.Save(); keyboardShortcutsHelpTextField.text = GenerateKeyboardShortcutText(); }); shortcutsDropdown.width = 480f; helper.AddSpace(20); keyboardShortcutsHelpTextField = (UITextField)helper.AddTextfield(" ", GenerateKeyboardShortcutText(), (s) => { }, (s) => { }); keyboardShortcutsHelpTextField.size = new Vector2(700f, 300f); keyboardShortcutsHelpTextField.Disable(); }
private void SetupControls() { float offset = 40f; //Beta Testing Timestamp //DateTime now = DateTime.Now; //m_title.title = "Advanced Vehicle Options " + ModInfo.version + " " + now; // Title Bar m_title = AddUIComponent <UITitleBar>(); m_title.iconSprite = "InfoIconTrafficCongestion"; m_title.title = "Advanced Vehicle Options " + ModInfo.version; // Category DropDown UILabel label = AddUIComponent <UILabel>(); label.textScale = 0.8f; label.padding = new RectOffset(0, 0, 8, 0); label.relativePosition = new Vector3(10f, offset); label.text = "Category :"; m_category = UIUtils.CreateDropDown(this); m_category.width = 175; for (int i = 0; i < categoryList.Length; i++) { m_category.AddItem(categoryList[i]); } m_category.selectedIndex = 0; m_category.tooltip = "Select a category to display\nTip: Use the mouse wheel to switch between categories faster"; m_category.relativePosition = label.relativePosition + new Vector3(75f, 0f); m_category.eventSelectedIndexChanged += (c, t) => { m_category.enabled = false; PopulateList(); m_category.enabled = true; }; // Search m_search = UIUtils.CreateTextField(this); m_search.width = 145f; m_search.height = 30f; m_search.padding = new RectOffset(6, 6, 6, 6); m_search.tooltip = "Type the name of a vehicle type"; m_search.relativePosition = new Vector3(WIDTHLEFT - m_search.width, offset); m_search.eventTextChanged += (c, t) => PopulateList(); label = AddUIComponent <UILabel>(); label.textScale = 0.8f; label.padding = new RectOffset(0, 0, 8, 0); label.relativePosition = m_search.relativePosition - new Vector3(60f, 0f); label.text = "Search :"; // FastList m_fastList = UIFastList.Create <UIVehicleItem>(this); m_fastList.backgroundSprite = "UnlockingPanel"; m_fastList.width = WIDTHLEFT - 5; m_fastList.height = height - offset - 110; m_fastList.canSelect = true; m_fastList.relativePosition = new Vector3(5, offset + 35); // Configuration file buttons UILabel configLabel = this.AddUIComponent <UILabel>(); configLabel.text = "Actions for Vehicle Configuration:"; configLabel.textScale = 0.8f; configLabel.relativePosition = new Vector3(16, height - 65); m_import = UIUtils.CreateButton(this); m_import.text = "Import"; m_import.width = 80; m_import.tooltip = "Import the configuration"; m_import.relativePosition = new Vector3(10, height - 45); m_export = UIUtils.CreateButton(this); m_export.text = "Export"; m_export.width = 80; m_export.tooltip = "Export the configuration"; m_export.relativePosition = new Vector3(95, height - 45); m_resetall = UIUtils.CreateButton(this); m_resetall.text = "Reset all"; m_resetall.width = 80; m_resetall.tooltip = "Reset full configuration"; m_resetall.relativePosition = new Vector3(180, height - 45); // Preview UIPanel panel = AddUIComponent <UIPanel>(); panel.backgroundSprite = "GenericPanel"; panel.width = WIDTHRIGHT - 10; panel.height = HEIGHT - 420; panel.relativePosition = new Vector3(WIDTHLEFT + 5, offset); m_preview = panel.AddUIComponent <UITextureSprite>(); m_preview.size = panel.size; m_preview.relativePosition = Vector3.zero; m_previewRenderer = gameObject.AddComponent <PreviewRenderer>(); m_previewRenderer.size = m_preview.size * 2; // Twice the size for anti-aliasing m_preview.texture = m_previewRenderer.texture; // Follow a vehicle if (m_cameraController != null) { m_followVehicle = AddUIComponent <UISprite>(); m_followVehicle.spriteName = "LocationMarkerFocused"; m_followVehicle.width = m_followVehicle.spriteInfo.width; m_followVehicle.height = m_followVehicle.spriteInfo.height; m_followVehicle.tooltip = "Click here to cycle through the existing vehicles of that type.\nHold Shift Key down for zooming directly to vehicle."; m_followVehicle.relativePosition = new Vector3(panel.relativePosition.x + panel.width - m_followVehicle.width - 5, panel.relativePosition.y + 5); m_followVehicle.eventClick += (c, p) => FollowNextVehicle(); } //Remove the followed vehicle { m_removeVehicle = AddUIComponent <UISprite>(); m_removeVehicle.Hide(); m_removeVehicle.spriteName = "IconPolicyOldTown"; m_removeVehicle.width = m_removeVehicle.spriteInfo.width - 12; m_removeVehicle.height = m_removeVehicle.spriteInfo.height - 12; m_removeVehicle.tooltip = "Click here to remove the selected vehicle."; m_removeVehicle.relativePosition = new Vector3(panel.relativePosition.x + panel.width - m_removeVehicle.width - 33, panel.relativePosition.y + 7); m_removeVehicle.eventClick += (c, p) => RemoveThisVehicle(); } // Option panel m_optionPanel = AddUIComponent <UIOptionPanel>(); m_optionPanel.relativePosition = new Vector3(WIDTHLEFT, height - 370); // Event handlers m_fastList.eventSelectedIndexChanged += OnSelectedItemChanged; m_optionPanel.eventEnableCheckChanged += OnEnableStateChanged; m_import.eventClick += (c, t) => { DefaultOptions.RestoreAll(); AdvancedVehicleOptionsUID.ImportConfig(); optionList = AdvancedVehicleOptionsUID.config.options; }; m_export.eventClick += (c, t) => AdvancedVehicleOptionsUID.ExportConfig(); m_resetall.eventClick += (c, t) => { ConfirmPanel.ShowModal("Confirm Reset Configuration", "Customized settings for all vehicles will be reset.\n\n" + "Proceed with Configuration reset ?", (comp, ret) => { if (ret != 1) { return; } DefaultOptions.RestoreAll(); AdvancedVehicleOptionsUID.ResetConfig(); optionList = AdvancedVehicleOptionsUID.config.options; ExceptionPanel resetpanel = UIView.library.ShowModal <ExceptionPanel>("ExceptionPanel"); resetpanel.SetMessage("Advanced Vehicle Options", "All vehicle configuration and customized settings\n" + "have been reset to the Game Defaults.", false); }); }; panel.eventMouseDown += (c, p) => { eventMouseMove += RotateCamera; if (m_optionPanel.m_options != null && m_optionPanel.m_options.useColorVariations) { m_previewRenderer.RenderVehicle(m_optionPanel.m_options.prefab, m_previewColor); } else { m_previewRenderer.RenderVehicle(m_optionPanel.m_options.prefab); } }; panel.eventMouseUp += (c, p) => { eventMouseMove -= RotateCamera; if (m_optionPanel.m_options != null && m_optionPanel.m_options.useColorVariations) { m_previewRenderer.RenderVehicle(m_optionPanel.m_options.prefab, m_previewColor); } else { m_previewRenderer.RenderVehicle(m_optionPanel.m_options.prefab); } }; panel.eventMouseWheel += (c, p) => { m_previewRenderer.zoom -= Mathf.Sign(p.wheelDelta) * 0.25f; if (m_optionPanel.m_options != null && m_optionPanel.m_options.useColorVariations) { m_previewRenderer.RenderVehicle(m_optionPanel.m_options.prefab, m_previewColor); } else { m_previewRenderer.RenderVehicle(m_optionPanel.m_options.prefab); } }; }
protected void CreateSoundSlider(UIHelperBase helper, ISound sound) { // Initialize variables var configuration = Mod.Instance.Settings.GetSoundsByCategoryId <string>(sound.CategoryId); var customAudioFiles = SoundPacksManager.instance.AudioFiles.Where(kvp => kvp.Key.StartsWith(string.Format("{0}.{1}", sound.CategoryId, sound.Id))).ToDictionary(kvp => kvp.Key, kvp => kvp.Value); float volume = 0; if (configuration.ContainsKey(sound.Id)) { volume = configuration[sound.Id].Volume; } else { Mod.Instance.Log.Info("No volume configuration found for {0}.{1}, using default value", sound.CategoryId, sound.Id); volume = sound.DefaultVolume; } // Add UI components UISlider uiSlider = null; UIPanel uiPanel = null; UILabel uiLabel = null; UIDropDown uiDropDown = null; var maxVolume = sound.MaxVolume; if (customAudioFiles.Count > 0 && configuration.ContainsKey(sound.Id) && !string.IsNullOrEmpty(configuration[sound.Id].SoundPack)) { // Custom sound, determine custom max volume var audioFile = SoundPacksManager.instance.GetAudioFileByName(sound.CategoryId, sound.Id, configuration[sound.Id].SoundPack); maxVolume = Mathf.Max(audioFile.AudioInfo.MaxVolume, audioFile.AudioInfo.Volume); } uiSlider = (UISlider)helper.AddSlider(sound.Name, 0, maxVolume, 0.01f, volume, v => this.SoundVolumeChanged(sound, v)); uiPanel = (UIPanel)uiSlider.parent; uiLabel = uiPanel.Find <UILabel>("Label"); if (customAudioFiles.Count > 0) { uiDropDown = uiPanel.AttachUIComponent(GameObject.Instantiate((UITemplateManager.Peek(UITemplateDefs.ID_OPTIONS_DROPDOWN_TEMPLATE) as UIPanel).Find <UIDropDown>("Dropdown").gameObject)) as UIDropDown; uiDropDown.items = new[] { "Default" }.Union(customAudioFiles.Select(kvp => kvp.Value.Name)).ToArray(); uiDropDown.height = 28; uiDropDown.textFieldPadding.top = 4; if (configuration.ContainsKey(sound.Id) && !string.IsNullOrEmpty(configuration[sound.Id].SoundPack)) { uiDropDown.selectedValue = configuration[sound.Id].SoundPack; } else { uiDropDown.selectedIndex = 0; } uiDropDown.eventSelectedIndexChanged += (c, i) => this.SoundPackChanged(sound, i > 0 ? ((UIDropDown)c).items[i] : null, uiSlider); this.soundSelections[string.Format("{0}.{1}", sound.CategoryId, sound.Id)] = uiDropDown; } // Configure UI components uiPanel.autoLayout = false; uiLabel.anchor = UIAnchorStyle.Left | UIAnchorStyle.CenterVertical; uiLabel.width = 250; uiSlider.anchor = UIAnchorStyle.CenterVertical; uiSlider.builtinKeyNavigation = false; uiSlider.width = 207; uiSlider.relativePosition = new Vector3(uiLabel.relativePosition.x + uiLabel.width + 20, 0); if (customAudioFiles.Count > 0) { uiDropDown.anchor = UIAnchorStyle.CenterVertical; uiDropDown.width = 180; uiDropDown.relativePosition = new Vector3(uiSlider.relativePosition.x + uiSlider.width + 20, 0); uiPanel.size = new Vector2(uiDropDown.relativePosition.x + uiDropDown.width, 32); } else { uiPanel.size = new Vector2(uiSlider.relativePosition.x + uiSlider.width, 32); } }
internal static void MakeSettings_VehicleRestrictions(UITabstrip tabStrip, int tabIndex) { Options.AddOptionTab(tabStrip, T("Policies_&_Restrictions")); tabStrip.selectedIndex = tabIndex; var 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; var panelHelper = new UIHelper(currentPanel); UIHelperBase atJunctionsGroup = panelHelper.AddGroup(T("At_junctions")); #if DEBUG _allRelaxedToggle = atJunctionsGroup.AddCheckbox( T("All_vehicles_may_ignore_lane_arrows"), Options.allRelaxed, OnAllRelaxedChanged) as UICheckBox; #endif _relaxedBussesToggle = atJunctionsGroup.AddCheckbox( T("Busses_may_ignore_lane_arrows"), Options.relaxedBusses, OnRelaxedBussesChanged) as UICheckBox; _allowEnterBlockedJunctionsToggle = atJunctionsGroup.AddCheckbox( T("Vehicles_may_enter_blocked_junctions"), Options.allowEnterBlockedJunctions, onAllowEnterBlockedJunctionsChanged) as UICheckBox; _allowUTurnsToggle = atJunctionsGroup.AddCheckbox( T("Vehicles_may_do_u-turns_at_junctions"), Options.allowUTurns, onAllowUTurnsChanged) as UICheckBox; _allowNearTurnOnRedToggle = atJunctionsGroup.AddCheckbox( T("Vehicles_may_turn_on_red"), Options.allowNearTurnOnRed, onAllowNearTurnOnRedChanged) as UICheckBox; _allowFarTurnOnRedToggle = atJunctionsGroup.AddCheckbox( T("Also_apply_to_left/right_turns_between_one-way_streets"), Options.allowFarTurnOnRed, onAllowFarTurnOnRedChanged) as UICheckBox; _allowLaneChangesWhileGoingStraightToggle = atJunctionsGroup.AddCheckbox( T("Vehicles_going_straight_may_change_lanes_at_junctions"), Options.allowLaneChangesWhileGoingStraight, onAllowLaneChangesWhileGoingStraightChanged) as UICheckBox; _trafficLightPriorityRulesToggle = atJunctionsGroup.AddCheckbox( T("Vehicles_follow_priority_rules_at_junctions_with_timed_traffic_lights"), Options.trafficLightPriorityRules, OnTrafficLightPriorityRulesChanged) as UICheckBox; Options.Indent(_allowFarTurnOnRedToggle); UIHelperBase onRoadsGroup = panelHelper.AddGroup(T("On_roads")); _vehicleRestrictionsAggressionDropdown = onRoadsGroup.AddDropdown( T("Vehicle_restrictions_aggression") + ":", new[] { T("Low"), T("Medium"), T("High"), T("Strict") }, (int)Options.vehicleRestrictionsAggression, OnVehicleRestrictionsAggressionChanged) as UIDropDown; _banRegularTrafficOnBusLanesToggle = onRoadsGroup.AddCheckbox( T("Ban_private_cars_and_trucks_on_bus_lanes"), Options.banRegularTrafficOnBusLanes, OnBanRegularTrafficOnBusLanesChanged) as UICheckBox; _highwayRulesToggle = onRoadsGroup.AddCheckbox( T("Enable_highway_specific_lane_merging/splitting_rules"), Options.highwayRules, OnHighwayRulesChanged) as UICheckBox; _preferOuterLaneToggle = onRoadsGroup.AddCheckbox( T("Heavy_trucks_prefer_outer_lanes_on_highways"), Options.preferOuterLane, OnPreferOuterLaneChanged) as UICheckBox; if (SteamHelper.IsDLCOwned(SteamHelper.DLC.NaturalDisastersDLC)) { UIHelperBase inCaseOfEmergencyGroup = panelHelper.AddGroup(T("In_case_of_emergency")); _evacBussesMayIgnoreRulesToggle = inCaseOfEmergencyGroup.AddCheckbox( T("Evacuation_busses_may_ignore_traffic_rules"), Options.evacBussesMayIgnoreRules, OnEvacBussesMayIgnoreRulesChanged) as UICheckBox; } }
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; }
public override void Start() { instance = this; // extra filter checkbox optionDropDownCheckBox = SamsamTS.UIUtils.CreateCheckBox(this); optionDropDownCheckBox.isChecked = false; optionDropDownCheckBox.width = 20; optionDropDownCheckBox.relativePosition = new Vector3(10, 10); optionDropDownCheckBox.eventCheckChanged += (c, i) => { if (optionDropDownMenu.selectedIndex == (int)DropDownOptions.SubBuildings) { if (optionDropDownCheckBox.isChecked) { UISearchBox.instance.typeFilter.selectedIndex = (int)UISearchBox.DropDownOptions.All; } } ((UISearchBox)parent).Search(); }; // extra filter dropdown optionDropDownMenu = SamsamTS.UIUtils.CreateDropDown(this); optionDropDownMenu.size = new Vector2(230, 25); optionDropDownMenu.listHeight = 300; optionDropDownMenu.itemHeight = 30; optionDropDownMenu.items = options; optionDropDownMenu.selectedIndex = 0; optionDropDownMenu.relativePosition = new Vector3(optionDropDownCheckBox.relativePosition.x + optionDropDownCheckBox.width + 5, 5); SamsamTS.UIUtils.CreateDropDownScrollBar(UIFilterExtra.instance.optionDropDownMenu); optionDropDownMenu.eventSelectedIndexChanged += (c, p) => { HideAll(); if (optionDropDownMenu.selectedIndex == (int)DropDownOptions.AssetCreator) { UpdateAssetCreatorOptionVisibility(true); } else if (optionDropDownMenu.selectedIndex == (int)DropDownOptions.BuildingHeight) { UpdateBuildingHeightOptionVisibility(true); } else if (optionDropDownMenu.selectedIndex == (int)DropDownOptions.BuildingLevel) { UpdateBuildingLevelOptionVisibility(true); } else if (optionDropDownMenu.selectedIndex == (int)DropDownOptions.UnusedAssets) { UpdateUnusedAssetsVisibility(true); } else if (optionDropDownMenu.selectedIndex == (int)DropDownOptions.UsedAssets) { UpdateUsedAssetsVisibility(true); } else if (optionDropDownMenu.selectedIndex == (int)DropDownOptions.DLC) { UpdateDLCVisibility(true); } else if (optionDropDownMenu.selectedIndex == (int)DropDownOptions.SubBuildings) { if (optionDropDownCheckBox.isChecked) { UISearchBox.instance.typeFilter.selectedIndex = (int)UISearchBox.DropDownOptions.All; } } if (optionDropDownCheckBox.isChecked) { ((UISearchBox)parent).Search(); } }; // asset creator assetCreatorInput = SamsamTS.UIUtils.CreateTextField(this); assetCreatorInput.size = new Vector2(110, 25); assetCreatorInput.padding.top = 5; assetCreatorInput.isVisible = true; assetCreatorInput.text = ""; assetCreatorInput.textScale = 0.9f; assetCreatorInput.relativePosition = new Vector3(optionDropDownMenu.relativePosition.x + optionDropDownMenu.width + 20, 5); assetCreatorInput.eventTextChanged += (c, p) => { if (assetCreatorInput.text == "") { return; } for (int i = 0; i < assetCreatorDropDownMenu.items.Length; ++i) { if (assetCreatorDropDownMenu.items[i].ToLower().StartsWith(assetCreatorInput.text.ToLower())) { assetCreatorDropDownMenu.selectedIndex = i; return; } } for (int i = 0; i < assetCreatorDropDownMenu.items.Length; ++i) { if (assetCreatorDropDownMenu.items[i].ToLower().Contains(assetCreatorInput.text.ToLower())) { assetCreatorDropDownMenu.selectedIndex = i; return; } } }; // search icon assetCreatorSearchIcon = AddUIComponent <UISprite>(); assetCreatorSearchIcon.size = new Vector2(25, 30); assetCreatorSearchIcon.atlas = FindIt.atlas; assetCreatorSearchIcon.spriteName = "FindItDisabled"; assetCreatorSearchIcon.isVisible = true; assetCreatorSearchIcon.relativePosition = new Vector3(optionDropDownMenu.relativePosition.x + optionDropDownMenu.width + 20, 3); assetCreatorDropDownMenu = SamsamTS.UIUtils.CreateDropDown(this); assetCreatorDropDownMenu.size = new Vector2(270, 25); assetCreatorDropDownMenu.tooltip = Translations.Translate("FIF_POP_SCR"); assetCreatorDropDownMenu.listHeight = 300; assetCreatorDropDownMenu.itemHeight = 30; UpdateAssetCreatorList(); assetCreatorDropDownMenu.isVisible = true; assetCreatorDropDownMenu.relativePosition = new Vector3(assetCreatorInput.relativePosition.x + assetCreatorInput.width + 10, 5); SamsamTS.UIUtils.CreateDropDownScrollBar(UIFilterExtra.instance.assetCreatorDropDownMenu); assetCreatorDropDownMenu.eventSelectedIndexChanged += (c, p) => { if (optionDropDownCheckBox.isChecked) { ((UISearchBox)parent).Search(); } }; // building height min label minLabel = this.AddUIComponent <UILabel>(); minLabel.textScale = 0.8f; minLabel.padding = new RectOffset(0, 0, 8, 0); minLabel.text = "Min:"; minLabel.isVisible = false; minLabel.relativePosition = new Vector3(optionDropDownMenu.relativePosition.x + optionDropDownMenu.width + 50, 5); // building height min input box minInput = SamsamTS.UIUtils.CreateTextField(this); minInput.size = new Vector2(60, 25); minInput.padding.top = 5; minInput.isVisible = false; minInput.text = ""; minInput.relativePosition = new Vector3(minLabel.relativePosition.x + minLabel.width + 10, 5); minInput.eventTextChanged += (c, p) => { if (float.TryParse(minInput.text, out minBuildingHeight)) { if (builingHeightUnit.selectedIndex == 1) { minBuildingHeight *= 0.3048f; } ((UISearchBox)parent).Search(); } if (minInput.text == "") { minBuildingHeight = float.MinValue; ((UISearchBox)parent).Search(); } }; // building height max label maxLabel = this.AddUIComponent <UILabel>(); maxLabel.textScale = 0.8f; maxLabel.padding = new RectOffset(0, 0, 8, 0); maxLabel.text = "Max:"; maxLabel.isVisible = false; maxLabel.relativePosition = new Vector3(minInput.relativePosition.x + minInput.width + 20, 5); // building height max input box maxInput = SamsamTS.UIUtils.CreateTextField(this); maxInput.size = new Vector2(60, 25); maxInput.padding.top = 5; maxInput.isVisible = false; maxInput.text = ""; maxInput.relativePosition = new Vector3(maxLabel.relativePosition.x + maxLabel.width + 10, 5); maxInput.eventTextChanged += (c, p) => { if (float.TryParse(maxInput.text, out maxBuildingHeight)) { if (builingHeightUnit.selectedIndex == 1) { maxBuildingHeight *= 0.3048f; } ((UISearchBox)parent).Search(); } if (maxInput.text == "") { maxBuildingHeight = float.MaxValue; ((UISearchBox)parent).Search(); } }; // building height unit builingHeightUnit = SamsamTS.UIUtils.CreateDropDown(this); builingHeightUnit.size = new Vector2(80, 25); builingHeightUnit.listHeight = 210; builingHeightUnit.itemHeight = 30; builingHeightUnit.AddItem(Translations.Translate("FIF_EF_MET")); builingHeightUnit.AddItem(Translations.Translate("FIF_EF_FEE")); builingHeightUnit.selectedIndex = 0; builingHeightUnit.isVisible = false; builingHeightUnit.relativePosition = new Vector3(maxInput.relativePosition.x + maxInput.width + 30, 5); builingHeightUnit.eventSelectedIndexChanged += (c, p) => { if (float.TryParse(minInput.text, out minBuildingHeight)) { if (builingHeightUnit.selectedIndex == 1) { minBuildingHeight *= 0.3048f; } } if (float.TryParse(maxInput.text, out maxBuildingHeight)) { if (builingHeightUnit.selectedIndex == 1) { maxBuildingHeight *= 0.3048f; } } if (minInput.text == "") { minBuildingHeight = float.MinValue; } if (maxInput.text == "") { maxBuildingHeight = float.MaxValue; } ((UISearchBox)parent).Search(); }; // building level dropdown buildingLevelDropDownMenu = SamsamTS.UIUtils.CreateDropDown(this); buildingLevelDropDownMenu.size = new Vector2(80, 25); buildingLevelDropDownMenu.listHeight = 300; buildingLevelDropDownMenu.itemHeight = 30; buildingLevelDropDownMenu.AddItem("1"); buildingLevelDropDownMenu.AddItem("2"); buildingLevelDropDownMenu.AddItem("3"); buildingLevelDropDownMenu.AddItem("4"); buildingLevelDropDownMenu.AddItem("5"); buildingLevelDropDownMenu.isVisible = false; buildingLevelDropDownMenu.selectedIndex = 0; buildingLevelDropDownMenu.relativePosition = new Vector3(optionDropDownMenu.relativePosition.x + optionDropDownMenu.width + 50, 5); buildingLevelDropDownMenu.eventSelectedIndexChanged += (c, p) => { if (optionDropDownCheckBox.isChecked) { ((UISearchBox)parent).Search(); } }; // export all unused asset list exportAllUnusedButton = SamsamTS.UIUtils.CreateButton(this); exportAllUnusedButton.size = new Vector2(80, 25); exportAllUnusedButton.text = Translations.Translate("FIF_EF_UNEXP"); exportAllUnusedButton.textScale = 0.8f; exportAllUnusedButton.textPadding = new RectOffset(0, 0, 5, 0); exportAllUnusedButton.tooltip = Translations.Translate("FIF_EF_UNEXPTP"); exportAllUnusedButton.isVisible = false; exportAllUnusedButton.relativePosition = new Vector3(optionDropDownMenu.relativePosition.x + optionDropDownMenu.width + 15, 5); exportAllUnusedButton.eventClick += (c, p) => { ExportUnusedTool.ExportUnused(true); }; // export searched unused asset list exportSearchedUnusedButton = SamsamTS.UIUtils.CreateButton(this); exportSearchedUnusedButton.size = new Vector2(130, 25); exportSearchedUnusedButton.text = Translations.Translate("FIF_EF_UNEXPSE"); exportSearchedUnusedButton.textScale = 0.8f; exportSearchedUnusedButton.textPadding = new RectOffset(0, 0, 5, 0); exportSearchedUnusedButton.tooltip = Translations.Translate("FIF_EF_UNEXPTPSE"); exportSearchedUnusedButton.isVisible = false; exportSearchedUnusedButton.relativePosition = new Vector3(exportAllUnusedButton.relativePosition.x + exportAllUnusedButton.width + 5, 5); exportSearchedUnusedButton.eventClick += (c, p) => { ExportUnusedTool.ExportUnused(false); }; // export all used asset list exportAllUsedButton = SamsamTS.UIUtils.CreateButton(this); exportAllUsedButton.size = new Vector2(80, 25); exportAllUsedButton.text = Translations.Translate("FIF_EF_UNEXP"); exportAllUsedButton.textScale = 0.8f; exportAllUsedButton.textPadding = new RectOffset(0, 0, 5, 0); exportAllUsedButton.tooltip = Translations.Translate("FIF_EF_USEXPTP"); exportAllUsedButton.isVisible = false; exportAllUsedButton.relativePosition = new Vector3(optionDropDownMenu.relativePosition.x + optionDropDownMenu.width + 15, 5); exportAllUsedButton.eventClick += (c, p) => { ExportUsedTool.ExportUsed(true); }; // export searched used asset list exportSearchedUsedButton = SamsamTS.UIUtils.CreateButton(this); exportSearchedUsedButton.size = new Vector2(130, 25); exportSearchedUsedButton.text = Translations.Translate("FIF_EF_UNEXPSE"); exportSearchedUsedButton.textScale = 0.8f; exportSearchedUsedButton.textPadding = new RectOffset(0, 0, 5, 0); exportSearchedUsedButton.tooltip = Translations.Translate("FIF_EF_USEXPTPSE"); exportSearchedUsedButton.isVisible = false; exportSearchedUsedButton.relativePosition = new Vector3(exportAllUsedButton.relativePosition.x + exportAllUsedButton.width + 5, 5); exportSearchedUsedButton.eventClick += (c, p) => { ExportUsedTool.ExportUsed(false); }; // DLC & CCP DLCDropDownMenu = SamsamTS.UIUtils.CreateDropDown(this); DLCDropDownMenu.size = new Vector2(300, 25); DLCDropDownMenu.listHeight = 300; DLCDropDownMenu.itemHeight = 30; DLCDropDownMenu.AddItem("Base Game"); DLCDropDownMenu.AddItem("After Dark DLC"); DLCDropDownMenu.AddItem("Campus DLC"); DLCDropDownMenu.AddItem("Green Cities DLC"); DLCDropDownMenu.AddItem("Industries DLC"); DLCDropDownMenu.AddItem("Mass Transit DLC"); DLCDropDownMenu.AddItem("Natural Disasters DLC"); DLCDropDownMenu.AddItem("Parklife DLC"); DLCDropDownMenu.AddItem("Snow Fall DLC"); DLCDropDownMenu.AddItem("Sunset Harbor DLC"); DLCDropDownMenu.AddItem("Art Deco CCP"); DLCDropDownMenu.AddItem("High-Tech Buildings CCP"); DLCDropDownMenu.AddItem("European Suburbias CCP"); DLCDropDownMenu.AddItem("University City CCP"); DLCDropDownMenu.AddItem("Modern City Center CCP"); DLCDropDownMenu.AddItem("Modern Japan CCP"); DLCDropDownMenu.AddItem("Train Stations CCP"); DLCDropDownMenu.AddItem("Bridges & Piers CCP"); DLCDropDownMenu.AddItem("Concerts DLC"); DLCDropDownMenu.AddItem("Deluxe Upgrade Pack"); DLCDropDownMenu.AddItem("Match Day DLC"); DLCDropDownMenu.AddItem("Pearls from the East DLC"); DLCDropDownMenu.AddItem("Stadiums: European Club Pack DLC"); DLCDropDownMenu.isVisible = false; DLCDropDownMenu.selectedIndex = 0; DLCDropDownMenu.relativePosition = new Vector3(optionDropDownMenu.relativePosition.x + optionDropDownMenu.width + 50, 5); SamsamTS.UIUtils.CreateDropDownScrollBar(UIFilterExtra.instance.DLCDropDownMenu); DLCDropDownMenu.eventSelectedIndexChanged += (c, p) => { if (optionDropDownCheckBox.isChecked) { ((UISearchBox)parent).Search(); } }; }
private void Awake() { instance = this; controlContainer = GetComponent <UIPanel>(); controlContainer.area = new Vector4(0, 0, 0, 0); controlContainer.isVisible = false; controlContainer.name = "SVMPanel"; SVMUtils.createUIElement(out mainPanel, controlContainer.transform, "SVMListPanel", new Vector4(0, 0, 875, 550)); mainPanel.backgroundSprite = "MenuPanel2"; CreateTitleBar(); SVMUtils.createUIElement(out m_StripMain, mainPanel.transform, "SVMTabstrip", new Vector4(5, 40, mainPanel.width - 10, 40)); SVMUtils.createUIElement(out UITabContainer tabContainer, mainPanel.transform, "SVMTabContainer", new Vector4(0, 80, mainPanel.width, mainPanel.height - 80)); m_StripMain.tabPages = tabContainer; UIButton tabPerBuilding = CreateTabTemplate(); tabPerBuilding.normalFgSprite = "ToolbarIconMonuments"; tabPerBuilding.tooltip = Locale.Get("SVM_CONFIG_PER_BUILDING_TAB"); SVMUtils.createUIElement(out UIPanel contentContainerPerBuilding, null); contentContainerPerBuilding.name = "Container"; contentContainerPerBuilding.area = new Vector4(0, 40, mainPanel.width, mainPanel.height - 80); m_StripMain.AddTab("SVMPerBuilding", tabPerBuilding.gameObject, contentContainerPerBuilding.gameObject); CreateTitleRowBuilding(ref m_titleLineBuildings, contentContainerPerBuilding); CreateSsdTabstrip(ref m_StripBuilings, ref m_StripBuilingsStrips, m_titleLineBuildings, contentContainerPerBuilding, true); UIButton tabPerDistrict = CreateTabTemplate(); tabPerDistrict.normalFgSprite = "ToolbarIconDistrict"; tabPerDistrict.tooltip = Locale.Get("SVM_CONFIG_PER_DISTRICT_TAB"); SVMUtils.createUIElement(out UIPanel contentContainerPerDistrict, mainPanel.transform); contentContainerPerDistrict.name = "Container2"; contentContainerPerDistrict.area = new Vector4(0, 40, mainPanel.width, mainPanel.height - 80); m_StripMain.AddTab("SVMPerDistrict", tabPerDistrict.gameObject, contentContainerPerDistrict.gameObject); CreateSsdTabstrip(ref m_StripDistricts, ref m_StripDistrictsStrips, null, contentContainerPerDistrict); m_cachedDistricts = SVMUtils.getValidDistricts(); m_selectDistrict = UIHelperExtension.CloneBasicDropDownLocalized("SVM_DISTRICT_TITLE", m_cachedDistricts.Keys.OrderBy(x => x).ToArray(), OnDistrictSelect, 0, contentContainerPerDistrict); UIPanel container = m_selectDistrict.GetComponentInParent <UIPanel>(); container.autoLayoutDirection = LayoutDirection.Horizontal; container.autoFitChildrenHorizontally = true; container.autoFitChildrenVertically = true; container.pivot = UIPivotPoint.TopRight; container.anchor = UIAnchorStyle.Top | UIAnchorStyle.Right; container.relativePosition = new Vector3(contentContainerPerDistrict.width - container.width - 10, -40); UILabel label = container.GetComponentInChildren <UILabel>(); label.padding.top = 10; label.padding.right = 10; DistrictManagerOverrides.eventOnDistrictRenamed += reloadDistricts; m_StripMain.selectedIndex = -1; m_StripBuilings.selectedIndex = -1; m_StripDistricts.selectedIndex = -1; mainPanel.eventVisibilityChanged += (x, y) => { if (y) { ServiceVehiclesManagerMod.instance.showVersionInfoPopup(); } }; }
public override void Start() { instance = this; UnityEngine.Random.InitState(System.Environment.TickCount); // panel for search input box, type filter and building filters inputPanel = AddUIComponent <UIPanel>(); inputPanel.atlas = SamsamTS.UIUtils.GetAtlas("Ingame"); inputPanel.backgroundSprite = "GenericTab"; inputPanel.color = new Color32(196, 200, 206, 255); inputPanel.size = new Vector2(parent.width, 35); inputPanel.relativePosition = new Vector2(0, -inputPanel.height - 40); // search input box input = SamsamTS.UIUtils.CreateTextField(inputPanel); input.size = new Vector2(250, 28); input.padding.top = 6; input.relativePosition = new Vector3(5, 4); string search = null; input.eventTextChanged += (c, p) => { search = p; Search(); }; input.eventTextCancelled += (c, p) => { if (search != null) { input.text = search; } }; input.eventKeyDown += (component, eventParam) => { if (eventParam.keycode != KeyCode.DownArrow && eventParam.keycode != KeyCode.UpArrow) { return; } if (typeFilter != null) { typeFilter.selectedIndex = Mathf.Clamp(typeFilter.selectedIndex + (eventParam.keycode == KeyCode.DownArrow ? 1 : -1), 0, typeFilter.items.Length); } }; // search icon searchIcon = inputPanel.AddUIComponent <UISprite>(); searchIcon.size = new Vector2(25, 30); searchIcon.atlas = FindIt.atlas; searchIcon.spriteName = "FindItDisabled"; searchIcon.relativePosition = new Vector3(5, 4); // change custom tag panel visibility clearButton = inputPanel.AddUIComponent <UISprite>(); clearButton.size = new Vector2(30, 30); clearButton.atlas = FindIt.atlas; clearButton.spriteName = "Clear"; clearButton.tooltip = Translations.Translate("FIF_SE_SEBTP"); clearButton.opacity = 0.5f; clearButton.relativePosition = new Vector3(input.relativePosition.x + input.width + 5, 2.5f); clearButton.eventClicked += (c, p) => { input.text = ""; //PickerRandomTest(); }; clearButton.eventMouseEnter += (c, p) => { clearButton.opacity = 1.0f; }; clearButton.eventMouseLeave += (c, p) => { clearButton.opacity = 0.5f; }; // asset type filter. Also Manipulated by the Picker mod through reflection. // Need to notify Quboid if a new dropdown item is added, or the item order is changed typeFilter = SamsamTS.UIUtils.CreateDropDown(inputPanel); typeFilter.name = "FindIt_AssetTypeFilter"; typeFilter.size = new Vector2(105, 25); typeFilter.tooltip = Translations.Translate("FIF_POP_SCR"); typeFilter.relativePosition = new Vector3(clearButton.relativePosition.x + clearButton.width + 15, 5); if (FindIt.isRicoEnabled) { string[] items = { Translations.Translate("FIF_SE_IA"), // All Translations.Translate("FIF_SE_IN"), // Network Translations.Translate("FIF_SE_IP"), // Ploppable Translations.Translate("FIF_SE_IG"), // Growable Translations.Translate("FIF_SE_IR"), // RICO Translations.Translate("FIF_SE_IGR"), // Growable/RICO Translations.Translate("FIF_SE_IPR"), // Prop Translations.Translate("FIF_SE_ID"), // Decal Translations.Translate("FIF_SE_IT") // Tree }; typeFilter.items = items; } else { string[] items = { Translations.Translate("FIF_SE_IA"), // All Translations.Translate("FIF_SE_IN"), // Network Translations.Translate("FIF_SE_IP"), // Ploppable Translations.Translate("FIF_SE_IG"), // Growable Translations.Translate("FIF_SE_IPR"), // Prop Translations.Translate("FIF_SE_ID"), // Decal Translations.Translate("FIF_SE_IT") // Tree }; typeFilter.items = items; } typeFilter.selectedIndex = 0; typeFilter.eventSelectedIndexChanged += (c, p) => { UpdateFilterPanels(); Search(); }; // workshop filter checkbox (custom assets saved in local asset folder are also included) workshopFilter = SamsamTS.UIUtils.CreateCheckBox(inputPanel); workshopFilter.isChecked = true; workshopFilter.width = 80; workshopFilter.label.text = Translations.Translate("FIF_SE_WF"); workshopFilter.label.textScale = 0.8f; workshopFilter.relativePosition = new Vector3(typeFilter.relativePosition.x + typeFilter.width + 12, 10); workshopFilter.eventCheckChanged += (c, i) => Search(); // vanilla filter checkbox vanillaFilter = SamsamTS.UIUtils.CreateCheckBox(inputPanel); vanillaFilter.isChecked = true; vanillaFilter.width = 80; vanillaFilter.label.text = Translations.Translate("FIF_SE_VF"); vanillaFilter.label.textScale = 0.8f; vanillaFilter.relativePosition = new Vector3(workshopFilter.relativePosition.x + workshopFilter.width, 10); vanillaFilter.eventCheckChanged += (c, i) => Search(); // change custom tag panel visibility tagToolIcon = inputPanel.AddUIComponent <UISprite>(); tagToolIcon.size = new Vector2(26, 21); tagToolIcon.atlas = FindIt.atlas; tagToolIcon.spriteName = "Tag"; tagToolIcon.tooltip = Translations.Translate("FIF_SE_SCTP"); tagToolIcon.opacity = 0.5f; tagToolIcon.relativePosition = new Vector3(vanillaFilter.relativePosition.x + vanillaFilter.width + 5, 7); tagToolIcon.eventClicked += (c, p) => { if (tagPanel == null) { tagToolIcon.opacity = 1.0f; CreateCustomTagPanel(); } else { tagToolIcon.opacity = 0.5f; DestroyCustomTagPanel(); Search(); } UpdateTopPanelsPosition(); }; tagToolIcon.eventMouseEnter += (c, p) => { tagToolIcon.opacity = 1.0f; }; tagToolIcon.eventMouseLeave += (c, p) => { if (tagPanel != null) { tagToolIcon.opacity = 1.0f; } else { tagToolIcon.opacity = 0.5f; } }; // change extra filters panel visibility extraFiltersIcon = inputPanel.AddUIComponent <UISprite>(); extraFiltersIcon.size = new Vector2(26, 23); extraFiltersIcon.atlas = FindIt.atlas; extraFiltersIcon.spriteName = "ExtraFilters"; extraFiltersIcon.tooltip = Translations.Translate("FIF_SE_EFI"); extraFiltersIcon.opacity = 0.5f; extraFiltersIcon.relativePosition = new Vector3(tagToolIcon.relativePosition.x + tagToolIcon.width + 5, 6); extraFiltersIcon.eventClicked += (c, p) => { if (extraFiltersPanel == null) { extraFiltersIcon.opacity = 1.0f; CreateExtraFiltersPanel(); } else { extraFiltersIcon.opacity = 0.5f; DestroyExtraFiltersPanel(); Search(); } UpdateTopPanelsPosition(); }; extraFiltersIcon.eventMouseEnter += (c, p) => { extraFiltersIcon.opacity = 1.0f; }; extraFiltersIcon.eventMouseLeave += (c, p) => { if (extraFiltersPanel != null) { extraFiltersIcon.opacity = 1.0f; } else { extraFiltersIcon.opacity = 0.5f; } }; quickMenuIcon = inputPanel.AddUIComponent <UISprite>(); quickMenuIcon.size = new Vector2(26, 23); quickMenuIcon.atlas = FindIt.atlas; quickMenuIcon.spriteName = "QuickMenu"; quickMenuIcon.tooltip = Translations.Translate("FIF_QM_TIT"); quickMenuIcon.opacity = 0.5f; quickMenuIcon.relativePosition = new Vector3(extraFiltersIcon.relativePosition.x + extraFiltersIcon.width + 5, 6); quickMenuIcon.eventClicked += (c, p) => { UIQuickMenuPopUp.ShowAt(quickMenuIcon); quickMenuVisible = true; quickMenuIcon.opacity = 1.0f; }; quickMenuIcon.eventMouseEnter += (c, p) => { quickMenuIcon.opacity = 1.0f; }; quickMenuIcon.eventMouseLeave += (c, p) => { if (quickMenuVisible) { quickMenuIcon.opacity = 1.0f; } else { quickMenuIcon.opacity = 0.5f; } }; // building size filter sizeLabel = inputPanel.AddUIComponent <UILabel>(); sizeLabel.textScale = 0.8f; sizeLabel.padding = new RectOffset(0, 0, 8, 0); sizeLabel.text = Translations.Translate("FIF_SE_SZ"); sizeLabel.relativePosition = new Vector3(quickMenuIcon.relativePosition.x + quickMenuIcon.width + 10, 5); sizeFilterX = SamsamTS.UIUtils.CreateDropDown(inputPanel); sizeFilterX.size = new Vector2(55, 25); sizeFilterX.items = filterItemsGrowable; sizeFilterX.selectedIndex = 0; sizeFilterX.relativePosition = new Vector3(sizeLabel.relativePosition.x + sizeLabel.width + 5, 5); sizeFilterY = SamsamTS.UIUtils.CreateDropDown(inputPanel); sizeFilterY.size = new Vector2(55, 25); sizeFilterY.items = filterItemsGrowable; sizeFilterY.selectedIndex = 0; sizeFilterY.relativePosition = new Vector3(sizeFilterX.relativePosition.x + sizeFilterX.width + 10, 5); sizeFilterX.eventSelectedIndexChanged += (c, i) => Search(); sizeFilterY.eventSelectedIndexChanged += (c, i) => Search(); // panel of sort button and filter toggle tabs panel = AddUIComponent <UIPanel>(); panel.atlas = SamsamTS.UIUtils.GetAtlas("Ingame"); panel.backgroundSprite = "GenericTabHovered"; panel.size = new Vector2(parent.width, 45); panel.relativePosition = new Vector3(0, -panel.height + 5); // sort button sortButton = SamsamTS.UIUtils.CreateButton(panel); sortButton.size = new Vector2(100, 35); sortButton.text = Translations.Translate("FIF_SO_RE"); sortButton.tooltip = Translations.Translate("FIF_SO_RETP"); sortButton.relativePosition = new Vector3(5, 5); sortButton.eventClick += (c, p) => { if (sortButtonTextState) { sortButton.text = Translations.Translate("FIF_SO_NE"); sortButtonTextState = false; sortButton.tooltip = Translations.Translate("FIF_SO_NETP"); } else { sortButton.text = Translations.Translate("FIF_SO_RE"); sortButtonTextState = true; sortButton.tooltip = Translations.Translate("FIF_SO_RETP"); } Search(); if (FindIt.isPOEnabled) { FindIt.instance.POTool.UpdatePOInfoList(); } }; // ploppable filter tabs filterPloppable = panel.AddUIComponent <UIFilterPloppable>(); filterPloppable.isVisible = false; filterPloppable.relativePosition = new Vector3(sortButton.relativePosition.x + sortButton.width, 0); filterPloppable.eventFilteringChanged += (c, p) => Search(); // growable filter tabs filterGrowable = panel.AddUIComponent <UIFilterGrowable>(); filterGrowable.isVisible = false; filterGrowable.relativePosition = new Vector3(sortButton.relativePosition.x + sortButton.width, 0); filterGrowable.eventFilteringChanged += (c, p) => Search(); // prop filter tabs filterProp = panel.AddUIComponent <UIFilterProp>(); filterProp.isVisible = false; filterProp.relativePosition = new Vector3(sortButton.relativePosition.x + sortButton.width, 0); filterProp.eventFilteringChanged += (c, p) => Search(); // tree filter tabs filterTree = panel.AddUIComponent <UIFilterTree>(); filterTree.isVisible = false; filterTree.relativePosition = new Vector3(sortButton.relativePosition.x + sortButton.width, 0); filterTree.eventFilteringChanged += (c, p) => Search(); // network filter tabs filterNetwork = panel.AddUIComponent <UIFilterNetwork>(); filterNetwork.isVisible = false; filterNetwork.relativePosition = new Vector3(sortButton.relativePosition.x + sortButton.width, 0); filterNetwork.eventFilteringChanged += (c, p) => Search(); // decal filter tabs filterDecal = panel.AddUIComponent <UIFilterDecal>(); filterDecal.isVisible = false; filterDecal.relativePosition = new Vector3(sortButton.relativePosition.x + sortButton.width, 0); UpdateFilterPanels(); size = Vector2.zero; }
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( Translation.AvailableLanguageCodes[i], "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( T("General.Dropdown:Select language") + ":", languageLabels, languageIndex, OnLanguageChanged) as UIDropDown; _lockButtonToggle = generalGroup.AddCheckbox( T("General.Checkbox:Lock main menu button position"), GlobalConfig.Instance.Main.MainMenuButtonPosLocked, OnLockButtonChanged) as UICheckBox; _lockMenuToggle = generalGroup.AddCheckbox( T("General.Checkbox:Lock main menu window position"), GlobalConfig.Instance.Main.MainMenuPosLocked, OnLockMenuChanged) as UICheckBox; _guiScaleSlider = generalGroup.AddSlider( T("General.Slider:GUI scale") + ":", 65, 200, 5, GlobalConfig.Instance.Main.GuiScale, OnGuiScaleChanged) as UISlider; _guiScaleSlider.parent.Find <UILabel>("Label").width = 500; _guiTransparencySlider = generalGroup.AddSlider( T("General.Slider:Window transparency") + ":", 0, 90, 5, GlobalConfig.Instance.Main.GuiTransparency, OnGuiTransparencyChanged) as UISlider; _guiTransparencySlider.parent.Find <UILabel>("Label").width = 500; _overlayTransparencySlider = generalGroup.AddSlider( T("General.Slider:Overlay transparency") + ":", 0, 90, 5, GlobalConfig.Instance.Main.OverlayTransparency, 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( Translation.ModConflicts.Get("Checkbox:Ignore disabled mods"), GlobalConfig.Instance.Main.IgnoreDisabledMods, OnIgnoreDisabledModsChanged) as UICheckBox; Options.Indent(_ignoreDisabledModsToggle); // General: Speed Limits SetupSpeedLimitsPanel(generalGroup); // General: Simulation UIHelperBase simGroup = panelHelper.AddGroup(T("General.Group:Simulation")); _simulationAccuracyDropdown = simGroup.AddDropdown( T("General.Dropdown:Simulation accuracy") + ":", 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") }, (int)Options.simulationAccuracy, OnSimulationAccuracyChanged) as UIDropDown; _instantEffectsToggle = simGroup.AddCheckbox( T("General.Checkbox:Apply AI changes right away"), Options.instantEffects, OnInstantEffectsChanged) as UICheckBox; }
public override void Start() { instance = this; // extra filter checkbox optionDropDownCheckBox = SamsamTS.UIUtils.CreateCheckBox(this); optionDropDownCheckBox.isChecked = false; optionDropDownCheckBox.width = 20; optionDropDownCheckBox.relativePosition = new Vector3(10, 10); optionDropDownCheckBox.eventCheckChanged += (c, i) => { ((UISearchBox)parent).Search(); }; // extra filter dropdown optionDropDownMenu = SamsamTS.UIUtils.CreateDropDown(this); optionDropDownMenu.size = new Vector2(200, 25); optionDropDownMenu.listHeight = 210; optionDropDownMenu.itemHeight = 30; optionDropDownMenu.items = options; optionDropDownMenu.selectedIndex = 0; optionDropDownMenu.relativePosition = new Vector3(optionDropDownCheckBox.relativePosition.x + optionDropDownCheckBox.width + 5, 5); optionDropDownMenu.eventSelectedIndexChanged += (c, p) => { HideAll(); if (optionDropDownMenu.selectedIndex == (int)DropDownOptions.AssetCreator) { UpdateAssetCreatorOptionVisibility(true); } else if (optionDropDownMenu.selectedIndex == (int)DropDownOptions.BuildingHeight) { UpdateBuildingHeightOptionVisibility(true); } else if (optionDropDownMenu.selectedIndex == (int)DropDownOptions.BuildingLevel) { UpdateBuildingLevelOptionVisibility(true); } if (optionDropDownCheckBox.isChecked) { ((UISearchBox)parent).Search(); } }; // asset creator assetCreatorInput = SamsamTS.UIUtils.CreateTextField(this); assetCreatorInput.size = new Vector2(120, 25); assetCreatorInput.padding.top = 5; assetCreatorInput.isVisible = true; assetCreatorInput.text = ""; assetCreatorInput.textScale = 0.9f; assetCreatorInput.relativePosition = new Vector3(optionDropDownMenu.relativePosition.x + optionDropDownMenu.width + 30, 5); assetCreatorInput.eventTextChanged += (c, p) => { if (assetCreatorInput.text == "") { return; } for (int i = 0; i < assetCreatorDropDownMenu.items.Length; ++i) { if (assetCreatorDropDownMenu.items[i].ToLower().StartsWith(assetCreatorInput.text.ToLower())) { assetCreatorDropDownMenu.selectedIndex = i; return; } } for (int i = 0; i < assetCreatorDropDownMenu.items.Length; ++i) { if (assetCreatorDropDownMenu.items[i].ToLower().Contains(assetCreatorInput.text.ToLower())) { assetCreatorDropDownMenu.selectedIndex = i; return; } } }; // search icon assetCreatorSearchIcon = AddUIComponent <UISprite>(); assetCreatorSearchIcon.size = new Vector2(25, 30); assetCreatorSearchIcon.atlas = FindIt.atlas; assetCreatorSearchIcon.spriteName = "FindItDisabled"; assetCreatorSearchIcon.isVisible = true; assetCreatorSearchIcon.relativePosition = new Vector3(optionDropDownMenu.relativePosition.x + optionDropDownMenu.width + 30, 3); assetCreatorDropDownMenu = SamsamTS.UIUtils.CreateDropDown(this); assetCreatorDropDownMenu.size = new Vector2(270, 25); assetCreatorDropDownMenu.tooltip = Translations.Translate("FIF_POP_SCR"); assetCreatorDropDownMenu.listHeight = 300; assetCreatorDropDownMenu.itemHeight = 30; UpdateAssetCreatorList(); SamsamTS.UIUtils.CreateDropDownScrollBar(assetCreatorDropDownMenu); assetCreatorDropDownMenu.isVisible = true; assetCreatorDropDownMenu.relativePosition = new Vector3(assetCreatorInput.relativePosition.x + assetCreatorInput.width + 10, 5); assetCreatorDropDownMenu.eventSelectedIndexChanged += (c, p) => { if (optionDropDownCheckBox.isChecked) { ((UISearchBox)parent).Search(); } }; // building height min label minLabel = this.AddUIComponent <UILabel>(); minLabel.textScale = 0.8f; minLabel.padding = new RectOffset(0, 0, 8, 0); minLabel.text = "Min:"; minLabel.isVisible = false; minLabel.relativePosition = new Vector3(optionDropDownMenu.relativePosition.x + optionDropDownMenu.width + 50, 5); // building height min input box minInput = SamsamTS.UIUtils.CreateTextField(this); minInput.size = new Vector2(60, 25); minInput.padding.top = 5; minInput.isVisible = false; minInput.text = ""; minInput.relativePosition = new Vector3(minLabel.relativePosition.x + minLabel.width + 10, 5); minInput.eventTextChanged += (c, p) => { if (float.TryParse(minInput.text, out minBuildingHeight)) { if (builingHeightUnit.selectedIndex == 1) { minBuildingHeight *= 0.3048f; } ((UISearchBox)parent).Search(); } if (minInput.text == "") { minBuildingHeight = float.MinValue; ((UISearchBox)parent).Search(); } }; // building height max label maxLabel = this.AddUIComponent <UILabel>(); maxLabel.textScale = 0.8f; maxLabel.padding = new RectOffset(0, 0, 8, 0); maxLabel.text = "Max:"; maxLabel.isVisible = false; maxLabel.relativePosition = new Vector3(minInput.relativePosition.x + minInput.width + 20, 5); // building height max input box maxInput = SamsamTS.UIUtils.CreateTextField(this); maxInput.size = new Vector2(60, 25); maxInput.padding.top = 5; maxInput.isVisible = false; maxInput.text = ""; maxInput.relativePosition = new Vector3(maxLabel.relativePosition.x + maxLabel.width + 10, 5); maxInput.eventTextChanged += (c, p) => { if (float.TryParse(maxInput.text, out maxBuildingHeight)) { if (builingHeightUnit.selectedIndex == 1) { maxBuildingHeight *= 0.3048f; } ((UISearchBox)parent).Search(); } if (maxInput.text == "") { maxBuildingHeight = float.MaxValue; ((UISearchBox)parent).Search(); } }; // building height unit builingHeightUnit = SamsamTS.UIUtils.CreateDropDown(this); builingHeightUnit.size = new Vector2(80, 25); builingHeightUnit.listHeight = 210; builingHeightUnit.itemHeight = 30; builingHeightUnit.AddItem(Translations.Translate("FIF_EF_MET")); builingHeightUnit.AddItem(Translations.Translate("FIF_EF_FEE")); builingHeightUnit.selectedIndex = 0; builingHeightUnit.isVisible = false; builingHeightUnit.relativePosition = new Vector3(maxInput.relativePosition.x + maxInput.width + 30, 5); builingHeightUnit.eventSelectedIndexChanged += (c, p) => { if (float.TryParse(minInput.text, out minBuildingHeight)) { if (builingHeightUnit.selectedIndex == 1) { minBuildingHeight *= 0.3048f; } } if (float.TryParse(maxInput.text, out maxBuildingHeight)) { if (builingHeightUnit.selectedIndex == 1) { maxBuildingHeight *= 0.3048f; } } if (minInput.text == "") { minBuildingHeight = float.MinValue; } if (maxInput.text == "") { maxBuildingHeight = float.MaxValue; } ((UISearchBox)parent).Search(); }; // building level dropdown buildingLevelDropDownMenu = SamsamTS.UIUtils.CreateDropDown(this); buildingLevelDropDownMenu.size = new Vector2(80, 25); buildingLevelDropDownMenu.listHeight = 300; buildingLevelDropDownMenu.itemHeight = 30; buildingLevelDropDownMenu.AddItem("1"); buildingLevelDropDownMenu.AddItem("2"); buildingLevelDropDownMenu.AddItem("3"); buildingLevelDropDownMenu.AddItem("4"); buildingLevelDropDownMenu.AddItem("5"); buildingLevelDropDownMenu.isVisible = false; buildingLevelDropDownMenu.selectedIndex = 0; buildingLevelDropDownMenu.relativePosition = new Vector3(optionDropDownMenu.relativePosition.x + optionDropDownMenu.width + 50, 5); buildingLevelDropDownMenu.eventSelectedIndexChanged += (c, p) => { if (optionDropDownCheckBox.isChecked) { ((UISearchBox)parent).Search(); } }; }
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(10); group.AddCheckbox(Translation.Instance.GetTranslation("FOREST-BRUSH-OPTIONS-SINGLETREE-EFFECT"), Settings.PlayEffect, (b) => { Settings.PlayEffect = b; SaveSettings(); }); group.AddSpace(20); optionKeys = panel.gameObject.AddComponent <OptionsKeyBinding>(); group.AddSpace(10); } catch (Exception) { Debug.LogWarning("OnSettingsUI failure."); } }
private void Awake() { TLMUtils.clearAllVisibilityEvents(this.GetComponent <UIPanel>()); base.component.eventZOrderChanged += delegate(UIComponent c, int r) { this.SetBackgroundColor(); }; GameObject.Destroy(base.Find <UICheckBox>("LineVisible").gameObject); GameObject.Destroy(base.Find <UIColorField>("LineColor").gameObject); this.m_depotName = base.Find <UILabel>("LineName"); this.m_depotNameField = this.m_depotName.Find <UITextField>("LineNameField"); this.m_depotNameField.maxLength = 256; this.m_depotNameField.eventTextChanged += new PropertyChangedEventHandler <string>(this.OnRename); this.m_depotName.eventMouseEnter += delegate(UIComponent c, UIMouseEventParameter r) { this.m_depotName.backgroundSprite = "TextFieldPanelHovered"; }; this.m_depotName.eventMouseLeave += delegate(UIComponent c, UIMouseEventParameter r) { this.m_depotName.backgroundSprite = string.Empty; }; this.m_depotName.eventClick += delegate(UIComponent c, UIMouseEventParameter r) { this.m_depotNameField.Show(); this.m_depotNameField.text = this.m_depotName.text; this.m_depotNameField.Focus(); }; this.m_depotNameField.eventLeaveFocus += delegate(UIComponent c, UIFocusEventParameter r) { this.m_depotNameField.Hide(); this.m_depotName.text = this.m_depotNameField.text; }; GameObject.Destroy(base.Find <UICheckBox>("DayLine").gameObject); GameObject.Destroy(base.Find <UICheckBox>("NightLine").gameObject); GameObject.Destroy(base.Find <UICheckBox>("DayNightLine").gameObject); this.m_prefixOptions = UIHelperExtension.CloneBasicDropDownNoLabel(new string[] { }, onChangePrefixSelected, gameObject.GetComponent <UIPanel>()); m_prefixOptions.area = new Vector4(600, 3, 80, 33); var m_DayLine = base.Find <UICheckBox>("DayLine"); GameObject.Destroy(base.Find <UICheckBox>("NightLine").gameObject); GameObject.Destroy(base.Find <UICheckBox>("DayNightLine").gameObject); GameObject.Destroy(m_DayLine.gameObject); m_districtName = base.Find <UILabel>("LineStops"); m_districtName.size = new Vector2(175, 18); m_districtName.relativePosition = new Vector3(0, 10); m_districtName.pivot = UIPivotPoint.MiddleCenter; m_districtName.wordWrap = true; m_districtName.autoHeight = true; GameObject.Destroy(base.Find <UILabel>("LinePassengers").gameObject); this.m_prefixesServed = base.Find <UILabel>("LineVehicles"); this.m_prefixesServed.size = new Vector2(220, 35); this.m_prefixesServed.autoHeight = true; this.m_prefixesServed.maximumSize = new Vector2(0, 36); this.m_prefixesServed.textScale = 0.7f; this.m_prefixesServed.width = 170; this.m_Background = base.Find("Background"); this.m_BackgroundColor = this.m_Background.color; this.m_mouseIsOver = false; base.component.eventMouseEnter += new MouseEventHandler(this.OnMouseEnter); base.component.eventMouseLeave += new MouseEventHandler(this.OnMouseLeave); GameObject.Destroy(base.Find <UIButton>("DeleteLine").gameObject); base.Find <UIButton>("ViewLine").eventClick += delegate(UIComponent c, UIMouseEventParameter r) { if (this.m_buildingID != 0) { Vector3 position = Singleton <BuildingManager> .instance.m_buildings.m_buffer[(int)this.m_buildingID].m_position; InstanceID instanceID = default(InstanceID); instanceID.Building = this.m_buildingID; TLMController.instance.depotInfoPanel.openDepotInfo(m_buildingID); ToolsModifierControl.cameraController.SetTarget(instanceID, position, true); TLMController.instance.defaultListingLinesPanel.Hide(); } }; base.component.eventVisibilityChanged += delegate(UIComponent c, bool v) { if (v) { this.m_prefixOptions.items = new string[] { }; this.RefreshData(); } }; //Buttons TLMUtils.createUIElement <UIButton>(ref m_addPrefixButton, transform); m_addPrefixButton.pivot = UIPivotPoint.TopRight; m_addPrefixButton.relativePosition = new Vector3(730, 2); m_addPrefixButton.text = Locale.Get("TLM_ADD"); m_addPrefixButton.textScale = 0.6f; m_addPrefixButton.width = 50; m_addPrefixButton.height = 15; m_addPrefixButton.tooltip = Locale.Get("TLM_ADD_PREFIX_TOOLTIP"); TLMUtils.initButton(m_addPrefixButton, true, "ButtonMenu"); m_addPrefixButton.name = "Add"; m_addPrefixButton.isVisible = true; m_addPrefixButton.eventClick += (component, eventParam) => { uint prefix = m_prefixOptions.selectedIndex == m_prefixOptions.items.Length - 1 ? 65 : (uint)m_prefixOptions.selectedIndex; TLMDepotAI.addPrefixToDepot(buildingId, prefix); m_addPrefixButton.isVisible = false; m_removePrefixButton.isVisible = true; }; TLMUtils.createUIElement <UIButton>(ref m_removePrefixButton, transform); m_removePrefixButton.pivot = UIPivotPoint.TopRight; m_removePrefixButton.relativePosition = new Vector3(780, 2); m_removePrefixButton.text = Locale.Get("TLM_REMOVE"); m_removePrefixButton.textScale = 0.6f; m_removePrefixButton.width = 50; m_removePrefixButton.height = 15; m_removePrefixButton.tooltip = Locale.Get("TLM_REMOVE_PREFIX_TOOLTIP"); TLMUtils.initButton(m_removePrefixButton, true, "ButtonMenu"); m_removePrefixButton.name = "Remove"; m_removePrefixButton.isVisible = true; m_removePrefixButton.eventClick += (component, eventParam) => { uint prefix = m_prefixOptions.selectedIndex == m_prefixOptions.items.Length - 1 ? 65 : (uint)m_prefixOptions.selectedIndex; TLMDepotAI.removePrefixFromDepot(buildingId, prefix); m_addPrefixButton.isVisible = true; m_removePrefixButton.isVisible = false; }; TLMUtils.createUIElement <UIButton>(ref m_addAllPrefixesButton, transform); m_addAllPrefixesButton.pivot = UIPivotPoint.TopRight; m_addAllPrefixesButton.relativePosition = new Vector3(730, 20); m_addAllPrefixesButton.text = Locale.Get("TLM_ADD_ALL_SHORT");; m_addAllPrefixesButton.textScale = 0.6f; m_addAllPrefixesButton.width = 50; m_addAllPrefixesButton.height = 15; m_addAllPrefixesButton.tooltip = Locale.Get("TLM_ADD_ALL_PREFIX_TOOLTIP"); TLMUtils.initButton(m_addAllPrefixesButton, true, "ButtonMenu"); m_addAllPrefixesButton.name = "AddAll"; m_addAllPrefixesButton.isVisible = true; m_addAllPrefixesButton.eventClick += (component, eventParam) => { TLMDepotAI.addAllPrefixesToDepot(buildingId); m_addPrefixButton.isVisible = false; m_removePrefixButton.isVisible = true; }; TLMUtils.createUIElement <UIButton>(ref m_removeAllPrefixesButton, transform); m_removeAllPrefixesButton.pivot = UIPivotPoint.TopRight; m_removeAllPrefixesButton.relativePosition = new Vector3(780, 20); m_removeAllPrefixesButton.text = Locale.Get("TLM_REMOVE_ALL_SHORT"); m_removeAllPrefixesButton.textScale = 0.6f; m_removeAllPrefixesButton.width = 50; m_removeAllPrefixesButton.height = 15; m_removeAllPrefixesButton.tooltip = Locale.Get("TLM_REMOVE_ALL_PREFIX_TOOLTIP"); TLMUtils.initButton(m_removeAllPrefixesButton, true, "ButtonMenu"); m_removeAllPrefixesButton.name = "RemoveAll"; m_removeAllPrefixesButton.isVisible = true; m_removeAllPrefixesButton.eventClick += (component, eventParam) => { TLMDepotAI.removeAllPrefixesFromDepot(buildingId); m_addPrefixButton.isVisible = true; m_removePrefixButton.isVisible = false; }; }
private UIDropDown CreateCargoDropDown(UIComponent parent) { UIDropDown dropCargo = parent.AddUIComponent <UIDropDown>(); dropCargo.anchor = UIAnchorStyle.Top | UIAnchorStyle.Left; dropCargo.height = 30f; dropCargo.width = 250f; dropCargo.relativePosition = new Vector3(25f, 59f); dropCargo.size = new Vector2(250f, 30f); dropCargo.listBackground = "GenericPanelLight"; dropCargo.itemHeight = 30; dropCargo.itemHover = "ListItemHover"; dropCargo.itemHighlight = "ListItemHighlight"; dropCargo.normalBgSprite = "ButtonMenu"; dropCargo.disabledBgSprite = "ButtonMenuDisabled"; dropCargo.hoveredBgSprite = "ButtonMenuHovered"; dropCargo.focusedBgSprite = "ButtonMenu"; dropCargo.listWidth = 250; dropCargo.listHeight = 720; dropCargo.foregroundSpriteMode = UIForegroundSpriteMode.Stretch; dropCargo.popupColor = new Color32(45, 52, 61, 255); dropCargo.popupTextColor = new Color32(170, 170, 170, 255); dropCargo.zOrder = 1; dropCargo.textScale = 0.8f; dropCargo.verticalAlignment = UIVerticalAlignment.Middle; dropCargo.horizontalAlignment = UIHorizontalAlignment.Left; dropCargo.selectedIndex = 0; dropCargo.textFieldPadding = new RectOffset(8, 0, 8, 0); dropCargo.itemPadding = new RectOffset(14, 0, 8, 0); UIButton button = dropCargo.AddUIComponent <UIButton>(); dropCargo.triggerButton = button; button.text = ""; button.size = dropCargo.size; button.relativePosition = new Vector3(0f, 0f); button.textVerticalAlignment = UIVerticalAlignment.Middle; button.textHorizontalAlignment = UIHorizontalAlignment.Left; button.normalFgSprite = "IconDownArrow"; button.hoveredFgSprite = "IconDownArrowHovered"; button.pressedFgSprite = "IconDownArrowPressed"; button.focusedFgSprite = "IconDownArrowFocused"; button.disabledFgSprite = "IconDownArrowDisabled"; button.foregroundSpriteMode = UIForegroundSpriteMode.Fill; button.horizontalAlignment = UIHorizontalAlignment.Right; button.verticalAlignment = UIVerticalAlignment.Middle; button.zOrder = 0; button.textScale = 0.8f; dropCargo.eventSizeChanged += new PropertyChangedEventHandler <Vector2>((c, t) => { button.size = t; dropCargo.listWidth = (int)t.x; }); Dictionary <string, ushort> cargoTypes = new Dictionary <string, ushort> { { "none", 255 }, { "Oil", 13 }, { "Ore", 14 }, { "Logs", 15 }, { "Crops", 16 }, // Looks like it was called Grain before Industries DLC, but never displayed to user? { "Goods", 17 }, { "Coal", 19 }, { "Petrol", 31 }, { "Food", 32 }, { "Lumber", 37 }, { "AnimalProducts", 97 }, { "Flours", 98 }, { "Paper", 99 }, { "PlanedTimber", 100 }, { "Petroleum", 101 }, { "Plastics", 102 }, { "Glass", 103 }, { "Metals", 104 }, { "LuxuryProducts", 105 }, { "Fish", 108 }, { "ZI-Oil", (13 << 8) + 31 }, // 3359 { "ZI-Ore", (14 << 8) + 19 }, // 3603 { "ZI-Forestry", (15 << 8) + 37 }, // 3877 { "ZI-Farming", (16 << 8) + 32 } // 4128 }; foreach (KeyValuePair <string, ushort> kvp in cargoTypes) { dropCargo.AddItem(kvp.Key); } dropCargo.eventSelectedIndexChanged += (c, e) => { cargoTypes.TryGetValue(dropCargo.selectedValue, out ushort myResource); if (myResource > 255) // if top byte present { m_selectedResource2 = (byte)((myResource & 0xFF00) >> 8); // Extract top byte } else { m_selectedResource2 = 0; } m_selectedResource = (byte)(myResource & 0xFF); // Extract low byte m_selectedBuilding = 0; m_forceRefresh = true; }; dropCargo.selectedIndex = 3; dropCargo.selectedValue = "Grain"; return(dropCargo); }
public static UIDropDown CreateDropDown(UIComponent parent, float offset, string label) { UIPanel container = parent.AddUIComponent <UIPanel>(); container.height = 25; container.relativePosition = new Vector3(0, offset, 0); UILabel serviceLabel = container.AddUIComponent <UILabel>(); serviceLabel.textScale = 0.8f; serviceLabel.text = label; serviceLabel.relativePosition = new Vector3(15, 6, 0); UIDropDown dropDown = container.AddUIComponent <UIDropDown>(); dropDown.size = new Vector2(120f, 25f); dropDown.listBackground = "GenericPanelLight"; dropDown.itemHeight = 20; dropDown.itemHover = "ListItemHover"; dropDown.itemHighlight = "ListItemHighlight"; dropDown.normalBgSprite = "ButtonMenu"; dropDown.disabledBgSprite = "ButtonMenuDisabled"; dropDown.hoveredBgSprite = "ButtonMenuHovered"; dropDown.focusedBgSprite = "ButtonMenu"; dropDown.listWidth = 120; dropDown.listHeight = 500; dropDown.foregroundSpriteMode = UIForegroundSpriteMode.Stretch; dropDown.popupColor = new Color32(45, 52, 61, 255); dropDown.popupTextColor = new Color32(170, 170, 170, 255); dropDown.zOrder = 1; dropDown.textScale = 0.7f; dropDown.verticalAlignment = UIVerticalAlignment.Middle; dropDown.horizontalAlignment = UIHorizontalAlignment.Left; dropDown.textFieldPadding = new RectOffset(8, 0, 8, 0); dropDown.itemPadding = new RectOffset(14, 0, 8, 0); dropDown.relativePosition = new Vector3(112, 0, 0); UIButton button = dropDown.AddUIComponent <UIButton>(); dropDown.triggerButton = button; button.text = ""; button.size = new Vector2(120f, 25f); button.relativePosition = new Vector3(0f, 0f); button.textVerticalAlignment = UIVerticalAlignment.Middle; button.textHorizontalAlignment = UIHorizontalAlignment.Left; button.normalFgSprite = "IconDownArrow"; button.hoveredFgSprite = "IconDownArrowHovered"; button.pressedFgSprite = "IconDownArrowPressed"; button.focusedFgSprite = "IconDownArrowFocused"; button.disabledFgSprite = "IconDownArrowDisabled"; button.spritePadding = new RectOffset(3, 3, 3, 3); button.foregroundSpriteMode = UIForegroundSpriteMode.Fill; button.horizontalAlignment = UIHorizontalAlignment.Right; button.verticalAlignment = UIVerticalAlignment.Middle; button.zOrder = 0; button.textScale = 0.8f; dropDown.eventSizeChanged += new PropertyChangedEventHandler <Vector2>((c, t) => { button.size = t; dropDown.listWidth = (int)t.x; }); return(dropDown); }
private void SetupControls() { float offset = 40f; // Title Bar m_title = AddUIComponent <UITitleBar>(); m_title.iconSprite = "IconCitizenVehicle"; m_title.title = "Advanced Vehicle Options " + ModInfo.version; // Category DropDown UILabel label = AddUIComponent <UILabel>(); label.textScale = 0.8f; label.padding = new RectOffset(0, 0, 8, 0); label.relativePosition = new Vector3(10f, offset); label.text = "Category :"; m_category = UIUtils.CreateDropDown(this); m_category.width = 150; for (int i = 0; i < categoryList.Length; i++) { m_category.AddItem(categoryList[i]); } m_category.selectedIndex = 0; m_category.tooltip = "Select a category to display\nTip: Use the mouse wheel to switch between categories faster"; m_category.relativePosition = label.relativePosition + new Vector3(70f, 0f); m_category.eventSelectedIndexChanged += (c, t) => { m_category.enabled = false; PopulateList(); m_category.enabled = true; }; // Search m_search = UIUtils.CreateTextField(this); m_search.width = 150f; m_search.height = 30f; m_search.padding = new RectOffset(6, 6, 6, 6); m_search.tooltip = "Type the name of a vehicle type"; m_search.relativePosition = new Vector3(WIDTHLEFT - m_search.width, offset); m_search.eventTextChanged += (c, t) => PopulateList(); label = AddUIComponent <UILabel>(); label.textScale = 0.8f; label.padding = new RectOffset(0, 0, 8, 0); label.relativePosition = m_search.relativePosition - new Vector3(60f, 0f); label.text = "Search :"; // FastList m_fastList = UIFastList.Create <UIVehicleItem>(this); m_fastList.backgroundSprite = "UnlockingPanel"; m_fastList.width = WIDTHLEFT - 5; m_fastList.height = height - offset - 110; m_fastList.canSelect = true; m_fastList.relativePosition = new Vector3(5, offset + 35); // Configuration file buttons UILabel configLabel = this.AddUIComponent <UILabel>(); configLabel.text = "Configuration file:"; configLabel.textScale = 0.8f; configLabel.relativePosition = new Vector3(10, height - 60); m_reload = UIUtils.CreateButton(this); m_reload.text = "Reload"; m_reload.tooltip = "Discard any changes since the last time the configuration has been saved"; m_reload.relativePosition = new Vector3(10, height - 40); m_save = UIUtils.CreateButton(this); m_save.text = "Save"; m_save.tooltip = "Save the configuration"; m_save.relativePosition = new Vector3(105, height - 40); // Preview UIPanel panel = AddUIComponent <UIPanel>(); panel.backgroundSprite = "GenericPanel"; panel.width = WIDTHRIGHT - 10; panel.height = HEIGHT - 375; panel.relativePosition = new Vector3(WIDTHLEFT + 5, offset); m_preview = panel.AddUIComponent <UITextureSprite>(); m_preview.size = panel.size; m_preview.relativePosition = Vector3.zero; m_previewRenderer = gameObject.AddComponent <PreviewRenderer>(); m_previewRenderer.size = m_preview.size * 2; // Twice the size for anti-aliasing m_preview.texture = m_previewRenderer.texture; // Follow if (m_cameraController != null) { m_followVehicle = AddUIComponent <UISprite>(); m_followVehicle.spriteName = "LocationMarkerFocused"; m_followVehicle.width = m_followVehicle.spriteInfo.width; m_followVehicle.height = m_followVehicle.spriteInfo.height; m_followVehicle.tooltip = "Click here to cycle through the existing vehicles of that type"; m_followVehicle.relativePosition = new Vector3(panel.relativePosition.x + panel.width - m_followVehicle.width - 5, panel.relativePosition.y + 5); m_followVehicle.eventClick += (c, p) => FollowNextVehicle(); } // Option panel m_optionPanel = AddUIComponent <UIOptionPanel>(); m_optionPanel.relativePosition = new Vector3(WIDTHLEFT, height - 330); // Event handlers m_fastList.eventSelectedIndexChanged += OnSelectedItemChanged; m_optionPanel.eventEnableCheckChanged += OnEnableStateChanged; m_reload.eventClick += (c, t) => { AdvancedVehicleOptions.RestoreBackup(); AdvancedVehicleOptions.LoadConfig(); optionList = AdvancedVehicleOptions.config.options; }; m_save.eventClick += (c, t) => AdvancedVehicleOptions.SaveBackup(); panel.eventMouseDown += (c, p) => { eventMouseMove += RotateCamera; if (m_optionPanel.m_options != null && m_optionPanel.m_options.useColorVariations) { m_previewRenderer.RenderVehicle(m_optionPanel.m_options.prefab, m_previewColor); } else { m_previewRenderer.RenderVehicle(m_optionPanel.m_options.prefab); } }; panel.eventMouseUp += (c, p) => { eventMouseMove -= RotateCamera; if (m_optionPanel.m_options != null && m_optionPanel.m_options.useColorVariations) { m_previewRenderer.RenderVehicle(m_optionPanel.m_options.prefab, m_previewColor); } else { m_previewRenderer.RenderVehicle(m_optionPanel.m_options.prefab); } }; panel.eventMouseWheel += (c, p) => { m_previewRenderer.zoom -= Mathf.Sign(p.wheelDelta) * 0.25f; if (m_optionPanel.m_options != null && m_optionPanel.m_options.useColorVariations) { m_previewRenderer.RenderVehicle(m_optionPanel.m_options.prefab, m_previewColor); } else { m_previewRenderer.RenderVehicle(m_optionPanel.m_options.prefab); } }; }
public static float someValue4 = 50f; // debug value public static void makeSettings(UIHelperBase helper) { mainGroup = helper.AddGroup(Translation.GetString("TMPE_Title")); simAccuracyDropdown = mainGroup.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; recklessDriversDropdown = mainGroup.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; //publicTransportUsageDropdown = mainGroup.AddDropdown(Translation.GetString("Citizens_use_public_transportation") + ":", new string[] { Translation.GetString("Very_often"), Translation.GetString("Often"), Translation.GetString("Sometimes"), Translation.GetString("Rarely"), Translation.GetString("Very_rarely") }, recklessDrivers, onRecklessDriversChanged) as UIDropDown; relaxedBussesToggle = mainGroup.AddCheckbox(Translation.GetString("Busses_may_ignore_lane_arrows"), relaxedBusses, onRelaxedBussesChanged) as UICheckBox; #if DEBUG allRelaxedToggle = mainGroup.AddCheckbox(Translation.GetString("All_vehicles_may_ignore_lane_arrows"), allRelaxed, onAllRelaxedChanged) as UICheckBox; #endif allowEnterBlockedJunctionsToggle = mainGroup.AddCheckbox(Translation.GetString("Vehicles_may_enter_blocked_junctions"), allowEnterBlockedJunctions, onAllowEnterBlockedJunctionsChanged) as UICheckBox; allowUTurnsToggle = mainGroup.AddCheckbox(Translation.GetString("Vehicles_may_do_u-turns_at_junctions"), allowUTurns, onAllowUTurnsChanged) as UICheckBox; allowLaneChangesWhileGoingStraightToggle = mainGroup.AddCheckbox(Translation.GetString("Vehicles_going_straight_may_change_lanes_at_junctions"), allowLaneChangesWhileGoingStraight, onAllowLaneChangesWhileGoingStraightChanged) as UICheckBox; strongerRoadConditionEffectsToggle = mainGroup.AddCheckbox(Translation.GetString("Road_condition_has_a_bigger_impact_on_vehicle_speed"), strongerRoadConditionEffects, onStrongerRoadConditionEffectsChanged) as UICheckBox; enableDespawningToggle = mainGroup.AddCheckbox(Translation.GetString("Enable_despawning"), enableDespawning, onEnableDespawningChanged) as UICheckBox; aiGroup = helper.AddGroup("Advanced Vehicle AI"); advancedAIToggle = aiGroup.AddCheckbox(Translation.GetString("Enable_Advanced_Vehicle_AI"), advancedAI, onAdvancedAIChanged) as UICheckBox; highwayRulesToggle = aiGroup.AddCheckbox(Translation.GetString("Enable_highway_specific_lane_merging/splitting_rules")+" (BETA feature)", highwayRules, onHighwayRulesChanged) as UICheckBox; laneChangingRandomizationDropdown = aiGroup.AddDropdown(Translation.GetString("Drivers_want_to_change_lanes_(only_applied_if_Advanced_AI_is_enabled):"), new string[] { Translation.GetString("Very_often") + " (50 %)", Translation.GetString("Often") + " (25 %)", Translation.GetString("Sometimes") + " (10 %)", Translation.GetString("Rarely") + " (5 %)", Translation.GetString("Very_rarely") + " (2.5 %)", Translation.GetString("Only_if_necessary") }, laneChangingRandomization, onLaneChangingRandomizationChanged) as UIDropDown; overlayGroup = helper.AddGroup(Translation.GetString("Persistently_visible_overlays")); prioritySignsOverlayToggle = overlayGroup.AddCheckbox(Translation.GetString("Priority_signs"), prioritySignsOverlay, onPrioritySignsOverlayChanged) as UICheckBox; timedLightsOverlayToggle = overlayGroup.AddCheckbox(Translation.GetString("Timed_traffic_lights"), timedLightsOverlay, onTimedLightsOverlayChanged) as UICheckBox; speedLimitsOverlayToggle = overlayGroup.AddCheckbox(Translation.GetString("Speed_limits"), speedLimitsOverlay, onSpeedLimitsOverlayChanged) as UICheckBox; vehicleRestrictionsOverlayToggle = overlayGroup.AddCheckbox(Translation.GetString("Vehicle_restrictions"), vehicleRestrictionsOverlay, onVehicleRestrictionsOverlayChanged) as UICheckBox; nodesOverlayToggle = overlayGroup.AddCheckbox(Translation.GetString("Nodes_and_segments"), nodesOverlay, onNodesOverlayChanged) as UICheckBox; showLanesToggle = overlayGroup.AddCheckbox(Translation.GetString("Lanes"), showLanes, onShowLanesChanged) as UICheckBox; maintenanceGroup = helper.AddGroup(Translation.GetString("Maintenance")); forgetTrafficLightsBtn = maintenanceGroup.AddButton(Translation.GetString("Forget_toggled_traffic_lights"), onClickForgetToggledLights) as UIButton; #if DEBUG disableSomething1Toggle = maintenanceGroup.AddCheckbox("Enable path-finding debugging", disableSomething1, onDisableSomething1Changed) as UICheckBox; disableSomething2Toggle = maintenanceGroup.AddCheckbox("Disable something #2", disableSomething2, onDisableSomething2Changed) as UICheckBox; disableSomething3Toggle = maintenanceGroup.AddCheckbox("Disable something #3", disableSomething3, onDisableSomething3Changed) as UICheckBox; disableSomething4Toggle = maintenanceGroup.AddCheckbox("Disable something #4", disableSomething4, onDisableSomething4Changed) as UICheckBox; disableSomething5Toggle = maintenanceGroup.AddCheckbox("Disable something #5", disableSomething5, onDisableSomething5Changed) as UICheckBox; pathCostMultiplicatorField = maintenanceGroup.AddTextfield("Pathcost multiplicator (mult)", String.Format("{0:0.##}", pathCostMultiplicator), onPathCostMultiplicatorChanged) as UITextField; pathCostMultiplicator2Field = maintenanceGroup.AddTextfield("Pathcost multiplicator (div)", String.Format("{0:0.##}", pathCostMultiplicator2), onPathCostMultiplicator2Changed) as UITextField; someValueField = maintenanceGroup.AddTextfield("Some value #1", String.Format("{0:0.##}", someValue), onSomeValueChanged) as UITextField; someValue2Field = maintenanceGroup.AddTextfield("Some value #2", String.Format("{0:0.##}", someValue2), onSomeValue2Changed) as UITextField; someValue3Field = maintenanceGroup.AddTextfield("Some value #3", String.Format("{0:0.##}", someValue3), onSomeValue3Changed) as UITextField; someValue4Field = maintenanceGroup.AddTextfield("Some value #4", String.Format("{0:0.##}", someValue4), onSomeValue4Changed) as UITextField; #endif }
internal static void MakeSettings_Gameplay(UITabstrip tabStrip, int tabIndex) { Options.AddOptionTab(tabStrip, T("Gameplay")); tabStrip.selectedIndex = tabIndex; var 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; var panelHelper = new UIHelper(currentPanel); UIHelperBase vehBehaviorGroup = panelHelper.AddGroup(T("Vehicle_behavior")); _recklessDriversDropdown = vehBehaviorGroup.AddDropdown( T("Reckless_driving") + ":", new[] { T("Path_Of_Evil_(10_%)"), T("Rush_Hour_(5_%)"), T("Minor_Complaints_(2_%)"), T("Holy_City_(0_%)") }, Options.recklessDrivers, OnRecklessDriversChanged) as UIDropDown; _recklessDriversDropdown.width = 300; _individualDrivingStyleToggle = vehBehaviorGroup.AddCheckbox( T("Individual_driving_styles"), Options.individualDrivingStyle, onIndividualDrivingStyleChanged) as UICheckBox; if (SteamHelper.IsDLCOwned(SteamHelper.DLC.SnowFallDLC)) { _strongerRoadConditionEffectsToggle = vehBehaviorGroup.AddCheckbox( T("Road_condition_has_a_bigger_impact_on_vehicle_speed"), Options.strongerRoadConditionEffects, OnStrongerRoadConditionEffectsChanged) as UICheckBox; } _disableDespawningToggle = vehBehaviorGroup.AddCheckbox( T("Disable_despawning"), Options.disableDespawning, onDisableDespawningChanged) as UICheckBox; UIHelperBase vehAiGroup = panelHelper.AddGroup(T("Advanced_Vehicle_AI")); _advancedAIToggle = vehAiGroup.AddCheckbox( T("Enable_Advanced_Vehicle_AI"), Options.advancedAI, OnAdvancedAiChanged) as UICheckBox; _altLaneSelectionRatioSlider = vehAiGroup.AddSlider( T("Dynamic_lane_section") + ":", 0, 100, 5, Options.altLaneSelectionRatio, OnAltLaneSelectionRatioChanged) as UISlider; _altLaneSelectionRatioSlider.parent.Find <UILabel>("Label").width = 450; UIHelperBase parkAiGroup = panelHelper.AddGroup(T("Parking_AI")); _prohibitPocketCarsToggle = parkAiGroup.AddCheckbox( T("Enable_more_realistic_parking"), Options.parkingAI, OnProhibitPocketCarsChanged) as UICheckBox; UIHelperBase ptGroup = panelHelper.AddGroup(T("Public_transport")); _realisticPublicTransportToggle = ptGroup.AddCheckbox( T( "Prevent_excessive_transfers_at_public_transport_stations"), Options.realisticPublicTransport, OnRealisticPublicTransportChanged) as UICheckBox; }
public override void Start() { base.Start(); // Zoning zoningToggles = new UICheckBox[NumOfCategories]; for (int i = 0; i < NumOfCategories; i++) { zoningToggles[i] = UIUtils.CreateIconToggle(this, CategoryIcons.atlases[i], CategoryIcons.spriteNames[i], CategoryIcons.spriteNames[i] + "Disabled"); zoningToggles[i].tooltip = CategoryIcons.tooltips[i]; zoningToggles[i].relativePosition = new Vector3(40 * i, 0); zoningToggles[i].isChecked = true; zoningToggles[i].readOnly = true; zoningToggles[i].checkedBoxObject.isInteractive = false; // Don't eat my double click event please zoningToggles[i].eventClick += (c, p) => { ((UICheckBox)c).isChecked = !((UICheckBox)c).isChecked; eventFilteringChanged(this, 0); }; zoningToggles[i].eventDoubleClick += (c, p) => { for (int j = 0; j < NumOfCategories; j++) zoningToggles[j].isChecked = false; ((UICheckBox)c).isChecked = true; eventFilteringChanged(this, 0); }; } allZones = UIUtils.CreateButton(this); allZones.width = 55; allZones.text = "All"; allZones.relativePosition = new Vector3(480, 5); allZones.eventClick += (c, p) => { for (int i = 0; i < NumOfCategories; i++) { zoningToggles[i].isChecked = true; } eventFilteringChanged(this, 0); }; noZones = UIUtils.CreateButton(this); noZones.width = 55; noZones.text = "None"; noZones.relativePosition = new Vector3(540, 5); noZones.eventClick += (c, p) => { for (int i = 0; i < NumOfCategories; i++) { zoningToggles[i].isChecked = false; } eventFilteringChanged(this, 0); }; // Display UILabel display = AddUIComponent<UILabel>(); display.textScale = 0.8f; display.padding = new RectOffset(0, 0, 8, 0); display.text = "Display: "; display.relativePosition = new Vector3(0, 40); origin = UIUtils.CreateDropDown(this); origin.width = 90; origin.AddItem("All"); origin.AddItem("Default"); origin.AddItem("Custom"); origin.AddItem("Cloned"); origin.selectedIndex = 0; origin.relativePosition = new Vector3(display.relativePosition.x + display.width + 5, 40); origin.eventSelectedIndexChanged += (c, i) => eventFilteringChanged(this, 1); status = UIUtils.CreateDropDown(this); status.width = 90; status.AddItem("All"); status.AddItem("Included"); status.AddItem("Excluded"); status.selectedIndex = 0; status.relativePosition = new Vector3(origin.relativePosition.x + origin.width + 5, 40); status.eventSelectedIndexChanged += (c, i) => eventFilteringChanged(this, 2); // Level UILabel levelLabel = AddUIComponent<UILabel>(); levelLabel.textScale = 0.8f; levelLabel.padding = new RectOffset(0, 0, 8, 0); levelLabel.text = "Level: "; levelLabel.relativePosition = new Vector3(status.relativePosition.x + status.width + 10, 40); levelFilter = UIUtils.CreateDropDown(this); levelFilter.width = 55; levelFilter.AddItem("All"); levelFilter.AddItem("1"); levelFilter.AddItem("2"); levelFilter.AddItem("3"); levelFilter.AddItem("4"); levelFilter.AddItem("5"); levelFilter.selectedIndex = 0; levelFilter.relativePosition = new Vector3(levelLabel.relativePosition.x + levelLabel.width + 5, 40); levelFilter.eventSelectedIndexChanged += (c, i) => eventFilteringChanged(this, 3); // Size UILabel sizeLabel = AddUIComponent<UILabel>(); sizeLabel.textScale = 0.8f; sizeLabel.padding = new RectOffset(0, 0, 8, 0); sizeLabel.text = "Size: "; sizeLabel.relativePosition = new Vector3(levelFilter.relativePosition.x + levelFilter.width + 10, 40); sizeFilterX = UIUtils.CreateDropDown(this); sizeFilterX.width = 55; sizeFilterX.AddItem("All"); sizeFilterX.AddItem("1"); sizeFilterX.AddItem("2"); sizeFilterX.AddItem("3"); sizeFilterX.AddItem("4"); sizeFilterX.selectedIndex = 0; sizeFilterX.relativePosition = new Vector3(sizeLabel.relativePosition.x + sizeLabel.width + 5, 40); UILabel XLabel = AddUIComponent<UILabel>(); XLabel.textScale = 0.8f; XLabel.padding = new RectOffset(0, 0, 8, 0); XLabel.text = "X"; XLabel.isVisible = false; XLabel.relativePosition = new Vector3(sizeFilterX.relativePosition.x + sizeFilterX.width - 5, 40); sizeFilterY = UIUtils.CreateDropDown(this); sizeFilterY.width = 45; sizeFilterY.AddItem("1"); sizeFilterY.AddItem("2"); sizeFilterY.AddItem("3"); sizeFilterY.AddItem("4"); sizeFilterY.selectedIndex = 0; sizeFilterY.isVisible = false; sizeFilterY.relativePosition = new Vector3(XLabel.relativePosition.x + XLabel.width + 5, 40); sizeFilterX.eventSelectedIndexChanged += (c, i) => { if (i == 0) { sizeFilterX.width = 55; XLabel.isVisible = false; sizeFilterY.isVisible = false; } else { sizeFilterX.width = 45; XLabel.isVisible = true; sizeFilterY.isVisible = true; } eventFilteringChanged(this, 4); }; sizeFilterY.eventSelectedIndexChanged += (c, i) => eventFilteringChanged(this, 4); // Name filter UILabel nameLabel = AddUIComponent<UILabel>(); nameLabel.textScale = 0.8f; nameLabel.padding = new RectOffset(0, 0, 8, 0); nameLabel.relativePosition = new Vector3(width - 250, 0); nameLabel.text = "Name: "; nameFilter = UIUtils.CreateTextField(this); nameFilter.width = 200; nameFilter.height = 30; nameFilter.padding = new RectOffset(6, 6, 6, 6); nameFilter.relativePosition = new Vector3(width - nameFilter.width, 0); nameFilter.eventTextChanged += (c, s) => eventFilteringChanged(this, 5); nameFilter.eventTextSubmitted += (c, s) => eventFilteringChanged(this, 5); }
/* The mod window turns on when RoadsIntersectionPanel or RoadsRoadTollsPanel is visible. */ public override void Start() { name = "SmartIntersectionsPanel"; if (!ModLoadingExtension.roadAnarchyDetected) { enabled = false; return; } atlas = ResourceLoader.GetAtlas("Ingame"); backgroundSprite = "SubcategoriesPanel"; size = new Vector2(204, 100); //Vector2 resolution = GetUIView().GetScreenResolution(); absolutePosition = new Vector3(ModInfo.savedWindowX.value, ModInfo.savedWindowY.value); isVisible = false; clipChildren = true; eventPositionChanged += (c, p) => { if (absolutePosition.x < 0) { absolutePosition = new Vector2(100, GetUIView().GetScreenResolution().y - height - 150); } Vector2 resolution = GetUIView().GetScreenResolution(); absolutePosition = new Vector2( Mathf.Clamp(absolutePosition.x, 0, resolution.x - width), Mathf.Clamp(absolutePosition.y, 0, resolution.y - height)); ModInfo.savedWindowX.value = (int)absolutePosition.x; ModInfo.savedWindowY.value = (int)absolutePosition.y; }; UIDragHandle dragHandle = AddUIComponent <UIDragHandle>(); dragHandle.width = width; dragHandle.relativePosition = Vector3.zero; dragHandle.target = parent; // From Elektrix's Road Tools UIButton openDescription = AddUIComponent <UIButton>(); openDescription.relativePosition = new Vector3(width - 24f, 8f); openDescription.size = new Vector3(15f, 15f); openDescription.normalFgSprite = "ToolbarIconHelp"; openDescription.name = "RAB_workshopButton"; openDescription.tooltip = "Smart Intersection Builder [" + ModInfo.VERSION_STRING + "] by Strad\nOpen in Steam Workshop"; UI.SetupButtonStateSprites(ref openDescription, "OptionBase", true); if (!PlatformService.IsOverlayEnabled()) { openDescription.isVisible = false; openDescription.isEnabled = false; } openDescription.eventClicked += delegate(UIComponent component, UIMouseEventParameter click) { if (PlatformService.IsOverlayEnabled() && ModInfo.WORKSHOP_FILE_ID != null) { PlatformService.ActivateGameOverlayToWorkshopItem(ModInfo.WORKSHOP_FILE_ID); } openDescription.Unfocus(); }; // -- Elektrix float cumulativeHeight = 8; UILabel label = AddUIComponent <UILabel>(); label.textScale = 0.9f; label.text = "Smart Intersections"; label.relativePosition = new Vector2(8, cumulativeHeight); label.SendToBack(); cumulativeHeight += label.height + 8; dragHandle.height = cumulativeHeight; m_enabledCheckBox = UI.CreateCheckBox(this); m_enabledCheckBox.name = "SI_Enabled"; m_enabledCheckBox.label.text = "Enabled"; m_enabledCheckBox.tooltip = "Enable Smart Intersections Tool"; m_enabledCheckBox.isChecked = SavedEnabled.value; m_enabledCheckBox.relativePosition = new Vector3(8, cumulativeHeight); m_enabledCheckBox.eventCheckChanged += (c, state) => { SmartIntersections.instance.Active = state; SavedEnabled.value = state; }; cumulativeHeight += m_enabledCheckBox.height + 8; m_connectRoadsCheckBox = UI.CreateCheckBox(this); m_connectRoadsCheckBox.name = "SI_ConnectRoads"; m_connectRoadsCheckBox.label.text = "Connect roads"; m_connectRoadsCheckBox.tooltip = "Try connecting dead ends of roads"; m_connectRoadsCheckBox.isChecked = SavedConnectRoads.value; m_connectRoadsCheckBox.relativePosition = new Vector3(8, cumulativeHeight); m_connectRoadsCheckBox.eventCheckChanged += (c, state) => { SavedConnectRoads.value = state; }; cumulativeHeight += m_connectRoadsCheckBox.height + 8; label = AddUIComponent <UILabel>(); label.textScale = 0.9f; label.text = "Snapping"; label.relativePosition = new Vector2(8, cumulativeHeight); label.SendToBack(); cumulativeHeight += label.height + 8; m_dropDown = UI.CreateDropDown(this); m_dropDown.AddItem("Enabled"); m_dropDown.AddItem("Low"); m_dropDown.AddItem("Off"); m_dropDown.relativePosition = new Vector3(8, cumulativeHeight); m_dropDown.width = width - 16; m_dropDown.eventSelectedIndexChanged += (component, state) => { SmartIntersections.instance.Snapping = (SmartIntersections.SnappingMode)state; SavedSnapping.value = state; }; m_dropDown.selectedIndex = SavedSnapping.value; m_dropDown.listPosition = UIDropDown.PopupListPosition.Above; cumulativeHeight += m_dropDown.height + 8; m_undoButton = UI.CreateButton(this); m_undoButton.text = "Undo"; m_undoButton.tooltip = "Remove last built intersection"; m_undoButton.relativePosition = new Vector2(8, cumulativeHeight); m_undoButton.width = width - 16; m_undoButton.isEnabled = false; m_undoButton.eventClick += (c, p) => { SmartIntersections.instance.Undo(); }; cumulativeHeight += m_undoButton.height + 8; height = cumulativeHeight; //absolutePosition = ModInfo.defWindowPosition; m_intersectionPanel = UIView.Find("RoadsIntersectionPanel"); if (m_intersectionPanel != null) { m_intersectionPanel.eventVisibilityChanged += (comp, value) => { //Debug.Log("Roads panel: visibility " + value); isVisible = IsIntersetionsPanelVisible(); }; } m_tollPanel = UIView.Find("RoadsRoadTollsPanel"); if (m_tollPanel != null) { m_tollPanel.eventVisibilityChanged += (comp, value) => { //Debug.Log("Tolls panel: visibility " + value); isVisible = IsIntersetionsPanelVisible(); }; } }
public override void Start() { backgroundSprite = "GenericPanel"; width = 400; height = 800; anchor = UIAnchorStyle.CenterHorizontal | UIAnchorStyle.CenterVertical; ////allow resizing. Don't know why it's not showing up. //UIResizeHandle resizeHandle = AddUIComponent<UIResizeHandle>(); //resizeHandle.backgroundSprite = "buttonresize"; //Container for the titlebar stuff. UISlicedSprite caption = AddUIComponent <UISlicedSprite>(); caption.anchor = UIAnchorStyle.Top | UIAnchorStyle.Left | UIAnchorStyle.Right; caption.fillDirection = UIFillDirection.Horizontal; caption.fillAmount = 1; caption.relativePosition = new Vector3(0, 0, 0); caption.width = 400; caption.height = 40; //Window title UILabel label = caption.AddUIComponent <UILabel>(); label.autoSize = true; label.textAlignment = UIHorizontalAlignment.Center; label.verticalAlignment = UIVerticalAlignment.Top; label.textScale = 1.3f; label.text = "Extended Properties"; label.anchor = UIAnchorStyle.CenterVertical | UIAnchorStyle.CenterHorizontal; label.relativePosition = new Vector3(0, 0, 0); //Window dragging. UIDragHandle dragHandle = caption.AddUIComponent <UIDragHandle>(); dragHandle.width = 400; dragHandle.height = 40; dragHandle.relativePosition = new Vector3(0, 0, 0); dragHandle.target = this; // Allow automated layout this.autoLayoutDirection = LayoutDirection.Vertical; this.autoLayoutStart = LayoutStart.TopLeft; this.autoLayoutPadding = new RectOffset(10, 10, 0, 10); this.autoLayout = true; //setup the building label buildingType = AddUIComponent <UILabel>(); buildingAISelection = AddUIComponent <UIDropDown>(); buildingAISelection.listBackground = "InfoDisplay"; buildingAISelection.itemHover = "ListItemHover"; buildingAISelection.itemHighlight = "ListItemHilight"; buildingAISelection.normalBgSprite = "InfoDisplay"; buildingAISelection.width = 300; buildingAISelection.height = 28; buildingAISelection.listWidth = 300; buildingAISelection.eventSelectedIndexChanged += buildingAISelection_eventSelectedIndexChanged; UIButton buildingAISelectionButton = buildingAISelection.AddUIComponent <UIButton>(); buildingAISelectionButton.normalFgSprite = "IconUpArrow"; buildingAISelectionButton.width = 47; buildingAISelectionButton.height = 26; buildingAISelectionButton.verticalAlignment = UIVerticalAlignment.Middle; buildingAISelectionButton.horizontalAlignment = UIHorizontalAlignment.Right; buildingAISelectionButton.relativePosition = new Vector3(1, 2); buildingAISelection.triggerButton = buildingAISelectionButton; RefreshBuildingAIs(); RefreshItemClasses(); }
public static UIDropDown CreateStyledDropDown(UIComponent parent) { UIDropDown dropDown = parent.AddUIComponent <UIDropDown>(); dropDown.size = new Vector2(105f, 24f); //dropDown.listBackground = "GenericPanelLight"; dropDown.listWidth = 105; dropDown.listHeight = 500; dropDown.listBackground = "LevelBarBackground"; dropDown.disabledBgSprite = "LevelBarBackground"; dropDown.focusedBgSprite = "LevelBarBackground"; //dropDown.hoveredBgSprite = "LevelBarBackground"; dropDown.normalBgSprite = "LevelBarBackground"; dropDown.foregroundSpriteMode = UIForegroundSpriteMode.Stretch; dropDown.textColor = new Color32(255, 255, 255, 255); dropDown.popupColor = new Color32(255, 255, 255, 255); dropDown.popupTextColor = new Color32(255, 255, 255, 255); dropDown.textScale = 0.8f; dropDown.verticalAlignment = UIVerticalAlignment.Middle; dropDown.horizontalAlignment = UIHorizontalAlignment.Left; dropDown.textFieldPadding = new RectOffset(4, 0, 7, 0); dropDown.itemHeight = 24; dropDown.itemPadding = new RectOffset(4, 0, 7, 0); //dropDown.itemHover = "LevelBarBackground"; //dropDown.itemHighlight = "LevelBarBackground"; dropDown.selectedIndex = 0; dropDown.zOrder = 1; // UIButton button = dropDown.AddUIComponent <UIButton>(); dropDown.triggerButton = button; //button.text = ""; button.size = new Vector2(105f, 24f); button.relativePosition = new Vector3(0f, 0f); button.foregroundSpriteMode = UIForegroundSpriteMode.Fill; button.textPadding = new RectOffset(0, 0, 5, 0); button.horizontalAlignment = UIHorizontalAlignment.Right; button.verticalAlignment = UIVerticalAlignment.Middle; //button.color = new Color32(238, 238, 238, 255); button.textColor = new Color32(255, 255, 255, 255); button.hoveredTextColor = new Color32(200, 200, 200, 255); button.pressedTextColor = new Color32(200, 200, 200, 255); button.focusedTextColor = new Color32(200, 200, 200, 255); button.disabledTextColor = new Color32(155, 155, 155, 255); button.textScale = 0.8f; //button.hoveredBgSprite = "TextFieldUnderline"; //button.pressedBgSprite = "TextFieldUnderline"; //button.focusedBgSprite = "TextFieldUnderline"; button.zOrder = 0; dropDown.eventSizeChanged += new PropertyChangedEventHandler <Vector2>((c, t) => { button.size = t; dropDown.listWidth = (int)t.x; }); return(dropDown); }
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; if (scrollablePanel == null) { return; } 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; // Relocate cost y += dy2; 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); // Area purchase cost y += dy1; 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); // Economy y += dy2; addLabel(scrollablePanel, Locale.Get("ECONOMY_TITLE"), new Vector3(x2, y), textScaleMedium); // Initial money y += dy1; addLabel(scrollablePanel, DTMLang.Text("INITIAL_MONEY"), new Vector3(x1, y), textScaleSmall); addSlider(scrollablePanel, new Vector3(x2, y), w1, OnCustomValueChanged, d.InitialMoney); // Reward amount y += dy1; addLabel(scrollablePanel, DTMLang.Text("REWARD"), new Vector3(x1, y), textScaleSmall); addSlider(scrollablePanel, new Vector3(x2, y), w1, OnCustomValueChanged, d.RewardMultiplier); // Loan amount and length y += dy1; 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); // Population target multiplier y += dy2; addLabel(scrollablePanel, DTMLang.Text("POPULATION_TARGET_MULTIPLIER"), new Vector3(x1, y), textScaleMedium); y += dy1; addSlider(scrollablePanel, new Vector3(x1, y), w2, OnCustomValueChanged, d.PopulationTargetMultiplier); // Max slope y -= dy1; addLabel(scrollablePanel, DTMLang.Text("MAX_SLOPE"), new Vector3(x3, y), textScaleMedium); y += dy1; addSlider(scrollablePanel, new Vector3(x3, y), w2, OnCustomValueChanged, d.MaxSlope); 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); // Target service score y += dy2; 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; }
private UIPanel CreateQuartzPanel() { var uiView = GameObject.Find("UIView").GetComponent<UIView>(); if (uiView == null) { Debug.LogError("UIView is null!"); return null; } var panel = uiView.AddUIComponent(typeof(UIPanel)) as UIPanel; if (panel != null) { panel.size = new Vector2(300, 290); panel.isVisible = false; panel.atlas = EmbeddedResources.GetQuartzAtlas(); panel.backgroundSprite = "DefaultPanelBackground"; Vector2 viewSize = uiView.GetScreenResolution(); panel.relativePosition = _currentModuleClass == Skin.ModuleClass.MainMenu ? new Vector3(viewSize.x - 2.0f - panel.size.x, 34.0f) : new Vector3(viewSize.x - 2.0f - panel.size.x, 34.0f + 64.0f); panel.name = "QuartzSkinManager"; var title = panel.AddUIComponent<UILabel>(); title.relativePosition = new Vector3(2.0f, 2.0f); title.text = "Quartz Skin Manager"; title.textColor = Color.black; } float y = 32.0f; UIUtil.MakeCheckbox(panel, "ShowIconInGame", "Show Quartz icon in-game", new Vector2(4.0f, y), ConfigManager.ShowQuartzIconInGame, value => { ConfigManager.ShowQuartzIconInGame = value; if (_quartzButton != null && !ConfigManager.ShowQuartzIconInGame && _currentModuleClass == Skin.ModuleClass.InGame) { _quartzButton.isVisible = false; if (_quartzPanel != null) { _quartzPanel.isVisible = false; } } else if(_quartzButton != null) { _quartzButton.isVisible = true; } }); y += 28.0f; UIUtil.MakeCheckbox(panel, "AutoApplySkin", "Apply skin on start-up", new Vector2(4.0f, y), ConfigManager.ApplySkinOnStartup, value => { ConfigManager.ApplySkinOnStartup = value; }); y += 28.0f; UIUtil.MakeCheckbox(panel, "DrawDebugInfo", "Developer mode (Ctrl+D)", new Vector2(4.0f, y), false, value => { if (_debugRenderer != null) { _debugRenderer.drawDebugInfo = value; } }); y += 28.0f; UIUtil.MakeCheckbox(panel, "AutoReload", "Auto-reload active skin on file change", new Vector2(4.0f, y), false, value => { _autoReloadSkinOnChange = value; ReloadAndApplyActiveSkin(); }); y += 28.0f; UIUtil.MakeCheckbox(panel, "IgnoreMissing", "Force load (May break stuff)", new Vector2(4.0f, y), ConfigManager.IgnoreMissingComponents, value => { ConfigManager.IgnoreMissingComponents = value; }); y += 28.0f; _skinsDropdown = panel.AddUIComponent<UIDropDown>(); _skinsDropdown.AddItem("Vanilla (by Colossal Order)"); foreach (var skin in _availableSkins) { _skinsDropdown.AddItem(String.Format("{0} (by {1}){2}", skin.Name, skin.Author, skin.Legacy ? " [LEGACY]" : string.Empty)); } _skinsDropdown.size = new Vector2(296.0f, 32.0f); _skinsDropdown.relativePosition = new Vector3(2.0f, y); _skinsDropdown.listBackground = "GenericPanelLight"; _skinsDropdown.itemHeight = 32; _skinsDropdown.itemHover = "ListItemHover"; _skinsDropdown.itemHighlight = "ListItemHighlight"; _skinsDropdown.normalBgSprite = "ButtonMenu"; _skinsDropdown.listWidth = 300; _skinsDropdown.listHeight = 500; _skinsDropdown.foregroundSpriteMode = UIForegroundSpriteMode.Stretch; _skinsDropdown.popupColor = new Color32(45, 52, 61, 255); _skinsDropdown.popupTextColor = new Color32(170, 170, 170, 255); _skinsDropdown.zOrder = 1; _skinsDropdown.textScale = 0.8f; _skinsDropdown.verticalAlignment = UIVerticalAlignment.Middle; _skinsDropdown.horizontalAlignment = UIHorizontalAlignment.Center; _skinsDropdown.textFieldPadding = new RectOffset(8, 0, 8, 0); _skinsDropdown.itemPadding = new RectOffset(8, 0, 2, 0); _skinsDropdown.selectedIndex = 0; if(_currentSkin != null) { int i = 1; foreach (var skin in _availableSkins) { if (skin.Path == _currentSkin.SapphirePath) { _skinsDropdown.selectedIndex = i; } i++; } } _skinsDropdown.eventSelectedIndexChanged += (component, index) => { if (index == 0) { if (_currentSkin != null) { _currentSkin.Dispose(); } _currentSkin = null; return; } var skin = _availableSkins[index-1]; if (_currentSkin != null && _currentSkin.SapphirePath == skin.Path) { return; } if (_currentSkin != null) { _currentSkin.Dispose(); } _currentSkin = Skin.FromXmlFile(Path.Combine(skin.Path, "skin.xml"), _autoReloadSkinOnChange); if (_currentSkin.IsValid) { _currentSkin.Apply(_currentModuleClass); } else { Debug.LogWarning("Skin is invalid, will not apply.. (check messages above for errors)"); } ConfigManager.SelectedSkinPath = _currentSkin.SapphirePath; panel.isVisible = false; }; var skinsDropdownButton = _skinsDropdown.AddUIComponent<UIButton>(); _skinsDropdown.triggerButton = skinsDropdownButton; skinsDropdownButton.text = ""; skinsDropdownButton.size = _skinsDropdown.size; skinsDropdownButton.relativePosition = new Vector3(0.0f, 0.0f); skinsDropdownButton.textVerticalAlignment = UIVerticalAlignment.Middle; skinsDropdownButton.textHorizontalAlignment = UIHorizontalAlignment.Center; skinsDropdownButton.normalFgSprite = "IconDownArrow"; skinsDropdownButton.hoveredFgSprite = "IconDownArrowHovered"; skinsDropdownButton.pressedFgSprite = "IconDownArrowPressed"; skinsDropdownButton.focusedFgSprite = "IconDownArrowFocused"; skinsDropdownButton.disabledFgSprite = "IconDownArrowDisabled"; skinsDropdownButton.foregroundSpriteMode = UIForegroundSpriteMode.Fill; skinsDropdownButton.horizontalAlignment = UIHorizontalAlignment.Right; skinsDropdownButton.verticalAlignment = UIVerticalAlignment.Middle; skinsDropdownButton.zOrder = 0; skinsDropdownButton.textScale = 0.8f; y += 40.0f; UIUtil.MakeButton(panel, "ReloadSkin", "Reload active skin (Ctrl+Shift+S)", new Vector2(4.0f, y), ReloadAndApplyActiveSkin); y += 36.0f; UIUtil.MakeButton(panel, "RefreshSkins", "Refresh available skins", new Vector2(4.0f, y), RefreshSkinsList); return panel; }
/// <summary> /// Performs initial setup for the panel; we no longer use Start() as that's not sufficiently reliable (race conditions), and is no longer needed, with the new create/destroy process. /// </summary> internal void Setup() { // Basic setup. isVisible = true; canFocus = true; isInteractive = true; backgroundSprite = "UnlockingPanel"; // Layout. autoLayout = true; autoLayoutDirection = LayoutDirection.Vertical; autoLayoutPadding.top = 5; autoLayoutPadding.right = 5; clipChildren = true; // Controls. builtinKeyNavigation = true; // Subpanels. labelpanel = this.AddUIComponent <UIPanel>(); labelpanel.height = 20; // Title panel. label = labelpanel.AddUIComponent <UILabel>(); label.relativePosition = new Vector3(80, 0); label.width = 270; label.textAlignment = UIHorizontalAlignment.Center; label.text = Translations.Translate("PRR_SET_HASNON"); // RICO enabled. ricoEnabled = UIUtils.CreateCheckBar(this, Translations.Translate("PRR_OPT_ENA")); enableRICOPanel = this.AddUIComponent <UIPanel>(); enableRICOPanel.height = 0; enableRICOPanel.isVisible = false; enableRICOPanel.name = "OptionsPanel"; ricoEnabled.eventCheckChanged += (c, state) => { if (!state) { enableRICOPanel.height = 0; enableRICOPanel.isVisible = false; } else { enableRICOPanel.height = 240; enableRICOPanel.isVisible = true; } }; // Dropdown menu - service. service = UIUtils.CreateDropDown(enableRICOPanel, 30, Translations.Translate("PRR_OPT_SER")); service.items = Service; service.selectedIndex = 0; service.eventSelectedIndexChanged += UpdateService; // Dropdown menu - sub-service. subService = UIUtils.CreateDropDown(enableRICOPanel, 60, Translations.Translate("PRR_OPT_SUB")); subService.selectedIndex = 0; subService.eventSelectedIndexChanged += UpdateSubService; // Dropdown menu - UI category. uiCategory = UIUtils.CreateDropDown(enableRICOPanel, 90, Translations.Translate("PRR_OPT_UIC")); uiCategory.selectedIndex = 0; uiCategory.items = (new UICategories()).names; // Dropdown menu - building level. level = UIUtils.CreateDropDown(enableRICOPanel, 120, Translations.Translate("PRR_LEVEL")); level.selectedIndex = 0; level.items = Level; // Update workplace allocations on level, service, and subservice change. level.eventSelectedIndexChanged += (c, value) => { UpdateWorkplaces(); }; service.eventSelectedIndexChanged += (c, value) => { UpdateWorkplaces(); }; subService.eventSelectedIndexChanged += (c, value) => { UpdateWorkplaces(); }; // Base text fields. construction = UIUtils.CreateTextField(enableRICOPanel, 150, Translations.Translate("PRR_OPT_CST")); manual = UIUtils.CreateTextField(enableRICOPanel, 180, Translations.Translate("PRR_OPT_CNT")); // Base checkboxes. realityIgnored = UIUtils.CreateCheckBox(enableRICOPanel, 210, Translations.Translate("PRR_OPT_POP")); pollutionEnabled = UIUtils.CreateCheckBox(enableRICOPanel, 240, Translations.Translate("PRR_OPT_POL")); growable = UIUtils.CreateCheckBox(enableRICOPanel, 0, Translations.Translate("PRR_OPT_GRO")); // Workplace breakdown by education level. uneducated = UIUtils.CreateTextField(enableRICOPanel, 300, Translations.Translate("PRR_OPT_JB0")); educated = UIUtils.CreateTextField(enableRICOPanel, 330, Translations.Translate("PRR_OPT_JB1")); welleducated = UIUtils.CreateTextField(enableRICOPanel, 360, Translations.Translate("PRR_OPT_JB2")); highlyeducated = UIUtils.CreateTextField(enableRICOPanel, 390, Translations.Translate("PRR_OPT_JB3")); }
public override void Start() { base.Start(); // Zoning zoningToggles = new UICheckBox[10]; zoningToggles[(int)Category.ResidentialLow] = UIUtils.CreateIconToggle(this, "Thumbnails", "ZoningResidentialLow", "ZoningResidentialLowDisabled"); zoningToggles[(int)Category.ResidentialHigh] = UIUtils.CreateIconToggle(this, "Thumbnails", "ZoningResidentialHigh", "ZoningResidentialHighDisabled"); zoningToggles[(int)Category.CommercialLow] = UIUtils.CreateIconToggle(this, "Thumbnails", "ZoningCommercialLow", "ZoningCommercialLowDisabled"); zoningToggles[(int)Category.CommercialHigh] = UIUtils.CreateIconToggle(this, "Thumbnails", "ZoningCommercialHigh", "ZoningCommercialHighDisabled"); zoningToggles[(int)Category.Industrial] = UIUtils.CreateIconToggle(this, "Thumbnails", "ZoningIndustrial", "ZoningIndustrialDisabled"); zoningToggles[(int)Category.Farming] = UIUtils.CreateIconToggle(this, "Ingame", "IconPolicyFarming", "IconPolicyFarmingDisabled"); zoningToggles[(int)Category.Forestry] = UIUtils.CreateIconToggle(this, "Ingame", "IconPolicyForest", "IconPolicyForestDisabled"); zoningToggles[(int)Category.Oil] = UIUtils.CreateIconToggle(this, "Ingame", "IconPolicyOil", "IconPolicyOilDisabled"); zoningToggles[(int)Category.Ore] = UIUtils.CreateIconToggle(this, "Ingame", "IconPolicyOre", "IconPolicyOreDisabled"); zoningToggles[(int)Category.Office] = UIUtils.CreateIconToggle(this, "Thumbnails", "ZoningOffice", "ZoningOfficeDisabled"); for (int i = 0; i < 10; i++) { zoningToggles[i].relativePosition = new Vector3(40 * i, 0); zoningToggles[i].isChecked = true; zoningToggles[i].readOnly = true; zoningToggles[i].checkedBoxObject.isInteractive = false; // Don't eat my double click event please zoningToggles[i].eventClick += (c, p) => { ((UICheckBox)c).isChecked = !((UICheckBox)c).isChecked; eventFilteringChanged(this, 0); }; zoningToggles[i].eventDoubleClick += (c, p) => { for (int j = 0; j < 10; j++) zoningToggles[j].isChecked = false; ((UICheckBox)c).isChecked = true; eventFilteringChanged(this, 0); }; } allZones = UIUtils.CreateButton(this); allZones.width = 55; allZones.text = "All"; allZones.relativePosition = new Vector3(400, 5); allZones.eventClick += (c, p) => { for (int i = 0; i < 10; i++) { zoningToggles[i].isChecked = true; } eventFilteringChanged(this, 0); }; noZones = UIUtils.CreateButton(this); noZones.width = 55; noZones.text = "None"; noZones.relativePosition = new Vector3(460, 5); noZones.eventClick += (c, p) => { for (int i = 0; i < 10; i++) { zoningToggles[i].isChecked = false; } eventFilteringChanged(this, 0); }; // Display UILabel display = AddUIComponent<UILabel>(); display.textScale = 0.8f; display.padding = new RectOffset(0, 0, 8, 0); display.text = "Display: "; display.relativePosition = new Vector3(0, 40); origin = UIUtils.CreateDropDown(this); origin.width = 90; origin.AddItem("All"); origin.AddItem("Default"); origin.AddItem("Custom"); origin.selectedIndex = 0; origin.relativePosition = new Vector3(display.relativePosition.x + display.width + 5, 40); origin.eventSelectedIndexChanged += (c, i) => eventFilteringChanged(this, 1); status = UIUtils.CreateDropDown(this); status.width = 90; status.AddItem("All"); status.AddItem("Included"); status.AddItem("Excluded"); status.selectedIndex = 0; status.relativePosition = new Vector3(origin.relativePosition.x + origin.width + 5, 40); status.eventSelectedIndexChanged += (c, i) => eventFilteringChanged(this, 2); // Level UILabel levelLabel = AddUIComponent<UILabel>(); levelLabel.textScale = 0.8f; levelLabel.padding = new RectOffset(0, 0, 8, 0); levelLabel.text = "Level: "; levelLabel.relativePosition = new Vector3(status.relativePosition.x + status.width + 10, 40); levelFilter = UIUtils.CreateDropDown(this); levelFilter.width = 55; levelFilter.AddItem("All"); levelFilter.AddItem("1"); levelFilter.AddItem("2"); levelFilter.AddItem("3"); levelFilter.AddItem("4"); levelFilter.AddItem("5"); levelFilter.selectedIndex = 0; levelFilter.relativePosition = new Vector3(levelLabel.relativePosition.x + levelLabel.width + 5, 40); levelFilter.eventSelectedIndexChanged += (c, i) => eventFilteringChanged(this, 3); // Size UILabel sizeLabel = AddUIComponent<UILabel>(); sizeLabel.textScale = 0.8f; sizeLabel.padding = new RectOffset(0, 0, 8, 0); sizeLabel.text = "Size: "; sizeLabel.relativePosition = new Vector3(levelFilter.relativePosition.x + levelFilter.width + 10, 40); sizeFilterX = UIUtils.CreateDropDown(this); sizeFilterX.width = 55; sizeFilterX.AddItem("All"); sizeFilterX.AddItem("1"); sizeFilterX.AddItem("2"); sizeFilterX.AddItem("3"); sizeFilterX.AddItem("4"); sizeFilterX.selectedIndex = 0; sizeFilterX.relativePosition = new Vector3(sizeLabel.relativePosition.x + sizeLabel.width + 5, 40); UILabel XLabel = AddUIComponent<UILabel>(); XLabel.textScale = 0.8f; XLabel.padding = new RectOffset(0, 0, 8, 0); XLabel.text = "X"; XLabel.isVisible = false; XLabel.relativePosition = new Vector3(sizeFilterX.relativePosition.x + sizeFilterX.width - 5, 40); sizeFilterY = UIUtils.CreateDropDown(this); sizeFilterY.width = 45; sizeFilterY.AddItem("1"); sizeFilterY.AddItem("2"); sizeFilterY.AddItem("3"); sizeFilterY.AddItem("4"); sizeFilterY.selectedIndex = 0; sizeFilterY.isVisible = false; sizeFilterY.relativePosition = new Vector3(XLabel.relativePosition.x + XLabel.width + 5, 40); sizeFilterX.eventSelectedIndexChanged += (c, i) => { if (i == 0) { sizeFilterX.width = 55; XLabel.isVisible = false; sizeFilterY.isVisible = false; } else { sizeFilterX.width = 45; XLabel.isVisible = true; sizeFilterY.isVisible = true; } eventFilteringChanged(this, 4); }; sizeFilterY.eventSelectedIndexChanged += (c, i) => eventFilteringChanged(this, 4); // Name filter UILabel nameLabel = AddUIComponent<UILabel>(); nameLabel.textScale = 0.8f; nameLabel.padding = new RectOffset(0, 0, 8, 0); nameLabel.relativePosition = new Vector3(width - 250, 0); nameLabel.text = "Name: "; nameFilter = UIUtils.CreateTextField(this); nameFilter.width = 200; nameFilter.height = 30; nameFilter.padding = new RectOffset(6, 6, 6, 6); nameFilter.relativePosition = new Vector3(width - nameFilter.width, 0); nameFilter.eventTextChanged += (c, s) => eventFilteringChanged(this, 5); nameFilter.eventTextSubmitted += (c, s) => eventFilteringChanged(this, 5); }
public override void Start() { base.Start(); backgroundSprite = "UnlockingPanel2"; isVisible = false; canFocus = true; isInteractive = true; width = 350; // Title Bar m_title = AddUIComponent<UITitleBar>(); m_title.title = "Clone Building"; m_title.iconSprite = "ToolbarIconZoomOutCity"; m_title.isModal = true; // Name UILabel name = AddUIComponent<UILabel>(); name.height = 30; name.text = "Building name:"; name.relativePosition = new Vector3(5, m_title.height); m_name = UIUtils.CreateTextField(this); m_name.width = width - 115; m_name.height = 30; m_name.padding = new RectOffset(6, 6, 6, 6); m_name.relativePosition = new Vector3(5, name.relativePosition.y + name.height + 5); m_name.Focus(); m_name.eventTextChanged += (c, s) => CheckValidity(); // Level m_level = UIUtils.CreateDropDown(this); m_level.width = 100; m_level.height = 30; (m_level.triggerButton as UIButton).textPadding = new RectOffset(6, 6, 6, 0); m_level.relativePosition = new Vector3(m_name.relativePosition.x + m_name.width + 5, m_name.relativePosition.y); m_level.eventSelectedIndexChanged += (c, i) => CheckValidity(); // Ok m_ok = UIUtils.CreateButton(this); m_ok.text = "Clone"; m_ok.isEnabled = false; m_ok.relativePosition = new Vector3(5, m_name.relativePosition.y + m_name.height + 5); m_ok.eventClick += (c, p) => { UIThemeManager.instance.CloneBuilding(m_item, m_cloneName, m_selectedLevel); UIView.PopModal(); Hide(); }; // Cancel m_cancel = UIUtils.CreateButton(this); m_cancel.text = "Cancel"; m_cancel.relativePosition = new Vector3(width - m_cancel.width - 5, m_ok.relativePosition.y); m_cancel.eventClick += (c, p) => { UIView.PopModal(); Hide(); }; height = m_cancel.relativePosition.y + m_cancel.height + 5; relativePosition = new Vector3(Mathf.Floor((GetUIView().fixedWidth - width) / 2), Mathf.Floor((GetUIView().fixedHeight - height) / 2)); isVisible = true; }