public void Awake() { Instance = this; MainContainer = GetComponent <UIComponent>(); m_uiHelperNeighbors = new UIHelperExtension(MainContainer); ((UIPanel)m_uiHelperNeighbors.Self).autoLayoutDirection = LayoutDirection.Horizontal; ((UIPanel)m_uiHelperNeighbors.Self).wrapLayout = true; ((UIPanel)m_uiHelperNeighbors.Self).autoLayout = true; UILabel titleLabel = m_uiHelperNeighbors.AddLabel(""); titleLabel.autoSize = true; titleLabel.textAlignment = UIHorizontalAlignment.Center; titleLabel.wordWrap = false; titleLabel.minimumSize = new Vector2(MainContainer.width - 10, 0); titleLabel.localeID = "K45_TLM_PER_HOUR_BUDGET_TITLE"; m_uiHelperNeighbors.AddSpace(5); KlyteMonoUtils.CreateElement(out m_clockChart, m_uiHelperNeighbors.Self.transform, "DailyClock"); m_showAbsoluteCheckbox = m_uiHelperNeighbors.AddCheckboxLocale("K45_TLM_SHOW_ABSOLUTE_VALUE", false, (x) => { RebuildList(UVMPublicTransportWorldInfoPanel.GetLineID()); }); KlyteMonoUtils.LimitWidthAndBox(m_showAbsoluteCheckbox.label, m_uiHelperNeighbors.Self.width - 40f); KlyteMonoUtils.CreateElement(out m_titleContainer, m_uiHelperNeighbors.Self.transform, "Title"); PopulateTitlePanel(m_titleContainer); KlyteMonoUtils.CreateScrollPanel(m_uiHelperNeighbors.Self, out m_entryListContainer, out _, m_uiHelperNeighbors.Self.width - 20f, m_uiHelperNeighbors.Self.height - 150, Vector3.zero); }
protected override void AwakeActions() { KlyteMonoUtils.CreateUIElement(out UIPanel layoutPanel, MainPanel.transform, "LayoutPanel", new Vector4(0, 40, PanelWidth, PanelHeight - 40)); layoutPanel.padding = new RectOffset(8, 8, 10, 10); layoutPanel.autoLayout = true; layoutPanel.autoLayoutDirection = LayoutDirection.Vertical; layoutPanel.autoLayoutPadding = new RectOffset(0, 0, 10, 10); var uiHelper = new UIHelperExtension(layoutPanel); CreateSlider(uiHelper, "K45_TR_TREES_IN_TERRAIN", new Action <int>(FactorsData.Instance.SetMultiplierTree), new Func <int>(FactorsData.Instance.GetMultiplierTree)); CreateSlider(uiHelper, "K45_TR_TREES_IN_LOTS", new Action <int>(FactorsData.Instance.SetMultiplierBuilding), new Func <int>(FactorsData.Instance.GetMultiplierBuilding)); CreateSlider(uiHelper, "K45_TR_TREES_IN_ROADS", new Action <int>(FactorsData.Instance.SetMultiplierNet), new Func <int>(FactorsData.Instance.GetMultiplierNet)); UILabel labelAccuracy = null; UISlider accuracySlider = uiHelper.AddSlider(Locale.Get("K45_TR_SIMULATION_ACCURACY"), 1, TRController.MAX_ACCURACY_VALUE, 1, FactorsData.Instance.GetSimulationAccuracy(), (x) => { FactorsData.Instance.SetSimulationAccuracy(Mathf.RoundToInt(x)); labelAccuracy.suffix = (1 << Mathf.RoundToInt(x + 3)).ToString(); TreesRespirationMod.Controller.UpdateDivisors(); }, out labelAccuracy); accuracySlider.width = PanelWidth - 15; labelAccuracy.width = PanelWidth - 15; labelAccuracy.minimumSize = new Vector2(PanelWidth - 15, 0); labelAccuracy.suffix = (1 << Mathf.RoundToInt(FactorsData.Instance.GetSimulationAccuracy() + 3)).ToString(); labelAccuracy.parent.tooltip = Locale.Get("K45_TR_SIMULATION_ACCURACY_TOOLTIP"); labelAccuracy.wordWrap = false; ((UIPanel)(labelAccuracy.parent)).autoLayoutPadding = new RectOffset(); KlyteMonoUtils.LimitWidthAndBox(labelAccuracy); }
public static UIDropDown CloneBasicDropDownLocalized(string text, string[] options, OnDropdownSelectionChanged eventCallback, int defaultSelection, UIComponent parent, out UILabel label, out UIPanel container, bool limitLabelByPanelWidth = false) { if (eventCallback != null && !string.IsNullOrEmpty(text)) { container = parent.AttachUIComponent(UITemplateManager.GetAsGameObject(kDropdownTemplate)) as UIPanel; container.transform.localScale = Vector3.one; label = container.Find <UILabel>("Label"); label.localeID = text; label.isLocalized = true; if (limitLabelByPanelWidth) { KlyteMonoUtils.LimitWidthAndBox(label, (uint)container.width); } UIDropDown uIDropDown = container.Find <UIDropDown>("Dropdown"); uIDropDown.items = options; uIDropDown.selectedIndex = defaultSelection; uIDropDown.eventSelectedIndexChanged += delegate(UIComponent c, int sel) { eventCallback(sel); }; return(uIDropDown); } DebugOutputPanel.AddMessage(PluginManager.MessageType.Warning, "Cannot create dropdown with no name or no event"); label = null; container = null; return(null); }
private void Awake() { parent = GetComponentInParent <UIComponent>(); var group15 = new UIHelperExtension(parent.GetComponentInChildren <UIScrollablePanel>()); ((UIScrollablePanel)group15.Self).autoLayoutDirection = LayoutDirection.Horizontal; ((UIScrollablePanel)group15.Self).wrapLayout = true; ((UIScrollablePanel)group15.Self).width = 730; group15.AddLabel(Locale.Get("K45_TLM_AUTO_NAME_SETTINGS_PUBLIC_AREAS")); group15.AddSpace(1); group15.AddLabel(Locale.Get("K45_TLM_AUTO_NAME_SETTINGS_PUBLIC_TRANSPORT_DESC")); group15.AddSpace(15); foreach (TLMConfigWarehouse.ConfigIndex ci in TLMConfigWarehouse.extraAutoNameCategories) { UICheckBox checkbox = TLMConfigOptions.instance.generateCheckboxConfig(group15, TLMConfigWarehouse.GetNameForServiceType(ci), TLMConfigWarehouse.ConfigIndex.USE_FOR_AUTO_NAMING_REF | ci, 200); UIPanel textFieldPanel = TLMConfigOptions.instance.generateTextFieldConfig(group15, Locale.Get("K45_TLM_PREFIX_OPTIONAL"), TLMConfigWarehouse.ConfigIndex.AUTO_NAMING_REF_TEXT | ci).GetComponentInParent <UIPanel>(); textFieldPanel.autoLayoutDirection = LayoutDirection.Horizontal; textFieldPanel.autoFitChildrenVertically = true; UILabel title = textFieldPanel.GetComponentInChildren <UILabel>(); title.textAlignment = UIHorizontalAlignment.Center; KlyteMonoUtils.LimitWidthAndBox(title, 220, true); textFieldPanel.AttachUIComponent(checkbox.gameObject); checkbox.eventVisibilityChanged += (x, y) => { if (x) { checkbox.zOrder = 0; } }; group15.AddSpace(2); } }
public static void AddVector2Field(string label, out UITextField[] fieldArray, UIHelperExtension parentHelper, Action <Vector2> onChange, bool addRollEvent = true, bool integerOnly = false) { fieldArray = parentHelper.AddVector2Field(label, Vector3.zero, onChange, integerOnly); KlyteMonoUtils.LimitWidthAndBox(fieldArray[0].parent.GetComponentInChildren <UILabel>(), (parentHelper.Self.width / 2) - 10, true); if (addRollEvent) { fieldArray.ForEach(x => { if (integerOnly) { x.eventMouseWheel += RollInteger; } else { x.eventMouseWheel += RollFloat; } x.tooltip = Locale.Get("K45_CMNS_FLOAT_EDITOR_TOOLTIP_HELP"); }); } fieldArray[0].zOrder = 1; fieldArray[1].zOrder = 2; if (integerOnly) { fieldArray.ForEach(x => x.allowFloats = false); } }
public static void OverrideStart(PublicTransportWorldInfoPanel __instance) { m_obj.origInstance = __instance; __instance.component.width = 800; BindComponents(__instance); SetNameFieldProperties(); KlyteMonoUtils.CreateTabsComponent(out m_obj.m_lineConfigTabs, out _, __instance.transform, "LineConfig", new Vector4(15, 45, 365, 30), new Vector4(15, 80, 380, 445)); m_obj.m_childControls.Add("Default", TabCommons.CreateTab <UVMMainWIPTab>(m_obj.m_lineConfigTabs, "ThumbStatistics", "K45_TLM_WIP_STATS_TAB", "Default", false)); m_obj.m_childControls.Add("Reports", TabCommons.CreateTab <TLMReportsTab>(m_obj.m_lineConfigTabs, "IconMessage", "K45_TLM_WIP_REPORT_TAB", "Reports", false)); m_obj.m_childControls.Add("Budget", TabCommons.CreateTab <UVMBudgetConfigTab>(m_obj.m_lineConfigTabs, "InfoPanelIconCurrency", "K45_TLM_WIP_BUDGET_CONFIGURATION_TAB", "Budget", false)); m_obj.m_childControls.Add("Ticket", TabCommons.CreateTab <TLMTicketConfigTab>(m_obj.m_lineConfigTabs, "FootballTicketIcon", "K45_TLM_WIP_TICKET_CONFIGURATION_TAB", "Ticket", false)); m_obj.m_childControls.Add("AssetSelection", TabCommons.CreateTab <TLMAssetSelectorTab>(m_obj.m_lineConfigTabs, "IconPolicyFreePublicTransport", "K45_TLM_WIP_ASSET_SELECTION_TAB", "AssetSelection", false)); m_obj.m_childControls.Add("DepotSelection", TabCommons.CreateTab <TLMDepotSelectorTab>(m_obj.m_lineConfigTabs, "UIFilterBigBuildings", "K45_TLM_WIP_DEPOT_SELECTION_TAB", "DepotSelection", false)); m_obj.m_childControls.Add("PrefixConfig", TabCommons.CreateTab <TLMPrefixOptionsTab>(m_obj.m_lineConfigTabs, "InfoIconLevel", "K45_TLM_WIP_PREFIX_CONFIG_TAB", "PrefixConfig", false)); m_obj.m_childControls.Add("StopsPanel", __instance.Find <UIPanel>("StopsPanel").parent.gameObject.AddComponent <UVMTransportLineLinearMap>()); DestroyNotUsed(__instance); m_obj.m_specificConfig = UIHelperExtension.AddCheckboxLocale(__instance.component, "K45_TLM_USE_SPECIFIC_CONFIG", false, (x) => { TLMTransportLineExtension.Instance.SetUseCustomConfig(GetLineID(), x); MarkDirty(typeof(UVMPublicTransportWorldInfoPanel)); }); m_obj.m_specificConfig.relativePosition = new Vector3(10, 530); m_obj.m_specificConfig.isInteractive = false; KlyteMonoUtils.LimitWidthAndBox(m_obj.m_specificConfig.label, 400); }
private UIDropDown CreateMiniDropdown(string localeId, OnDropdownSelectionChanged onValueChanged, string[] values) { UIDropDown ddObj = UIHelperExtension.CloneBasicDropDownLocalized(localeId, values, onValueChanged, 0, MainPanel, out UILabel label, out UIPanel container); container.autoFitChildrenHorizontally = false; container.autoLayoutDirection = LayoutDirection.Horizontal; container.autoLayout = true; container.autoFitChildrenHorizontally = true; container.autoFitChildrenVertically = true; ReflectionUtils.GetEventField(typeof(UIDropDown), "eventMouseWheel")?.SetValue(ddObj, null); ddObj.isLocalized = false; ddObj.autoSize = false; ddObj.horizontalAlignment = UIHorizontalAlignment.Center; ddObj.itemPadding = new RectOffset(2, 2, 6, 6); ddObj.textFieldPadding = new RectOffset(4, 40, 4, 4); ddObj.name = localeId; ddObj.size = new Vector3(240, 22); ddObj.textScale = 0.8f; ddObj.listPosition = UIDropDown.PopupListPosition.Automatic; //KlyteMonoUtils.InitButtonFull(ddObj, false, "OptionsDropboxListbox"); ddObj.horizontalAlignment = UIHorizontalAlignment.Center; KlyteMonoUtils.LimitWidthAndBox(label, 130); label.textScale = 1; label.padding.top = 4; label.position = Vector3.zero; label.verticalAlignment = UIVerticalAlignment.Middle; label.textAlignment = UIHorizontalAlignment.Left; return(ddObj); }
public static void AddFloatField(string label, out UITextField field, UIHelperExtension parentHelper, Action <float> onChange, bool acceptNegative) { field = parentHelper.AddFloatField(label, 0, onChange, acceptNegative); field.width = 90; KlyteMonoUtils.LimitWidthAndBox(field.parent.GetComponentInChildren <UILabel>(), (parentHelper.Self.width / 2) - 10, true); field.eventMouseWheel += RollFloat; }
private UITextField CreateMiniTextField(string localeId, OnTextSubmitted onValueChanged) { UITextField ddObj = UIHelperExtension.AddTextfield(MainPanel, localeId, "", out UILabel label, out UIPanel container); container.autoFitChildrenHorizontally = false; container.autoLayoutDirection = LayoutDirection.Horizontal; container.autoLayout = true; container.autoFitChildrenHorizontally = true; container.autoFitChildrenVertically = true; ddObj.isLocalized = false; ddObj.autoSize = false; ddObj.eventTextSubmitted += (x, y) => onValueChanged(y); ddObj.name = localeId; ddObj.size = new Vector3(240, 22); ddObj.textScale = 1; KlyteMonoUtils.LimitWidthAndBox(label, 130); label.textScale = 1; label.padding.top = 4; label.position = Vector3.zero; label.isLocalized = true; label.localeID = localeId; label.verticalAlignment = UIVerticalAlignment.Middle; label.textAlignment = UIHorizontalAlignment.Left; return(ddObj); }
public void Awake() { m_bg = component as UIScrollablePanel; PublicTransportWorldInfoPanel ptwip = UVMPublicTransportWorldInfoPanel.m_obj.origInstance; AddNewStopTemplate(); ptwip.component.width = 800; BindComponents(ptwip); AdjustLineStopsPanel(ptwip); KlyteMonoUtils.CreateUIElement(out m_panelModeSelector, m_bg.parent.transform); m_panelModeSelector.autoFitChildrenHorizontally = true; m_panelModeSelector.autoFitChildrenVertically = true; m_panelModeSelector.autoLayout = true; m_panelModeSelector.autoLayoutDirection = LayoutDirection.Horizontal; m_mapModeDropDown = UIHelperExtension.CloneBasicDropDownNoLabel(Enum.GetNames(typeof(MapMode)).Select(x => Locale.Get("K45_TLM_LINEAR_MAP_VIEW_MODE", x)).ToArray(), (int idx) => { m_currentMode = (MapMode)idx; RefreshVehicleButtons(GetLineID()); }, m_panelModeSelector); m_mapModeDropDown.textScale = 0.75f; m_mapModeDropDown.size = new Vector2(200, 25); m_mapModeDropDown.itemHeight = 16; UICheckBox unscaledCheck = UIHelperExtension.AddCheckboxLocale(m_panelModeSelector, "K45_TLM_LINEAR_MAP_SHOW_UNSCALED", m_unscaledMode, (val) => m_unscaledMode = val); KlyteMonoUtils.LimitWidthAndBox(unscaledCheck.label, 165); InstanceManagerOverrides.EventOnBuildingRenamed += (x) => m_dirtyNames = true; }
public void Awake() { MainContainer = GetComponent <UIPanel>(); MainContainer.autoLayout = true; MainContainer.autoLayoutDirection = LayoutDirection.Vertical; MainContainer.autoLayoutPadding = new RectOffset(5, 5, 5, 5); var m_uiHelperHS = new UIHelperExtension(MainContainer); m_buttonTool = (UIButton)m_uiHelperHS.AddButton(Locale.Get("K45_ADR_PICK_A_SEGMENT"), EnablePickTool); KlyteMonoUtils.LimitWidth(m_buttonTool, (m_uiHelperHS.Self.width - 20), true); AddLabel("", m_uiHelperHS, out m_labelSelectionDescription, out m_topContainerBar, false); m_labelSelectionDescription.prefix = Locale.Get("K45_ADR_CURRENTSELECTION") + ": "; m_labelSelectionDescription.padding.top = 8; AddButtonInEditorRow(m_labelSelectionDescription, Commons.UI.SpriteNames.CommonsSpriteNames.K45_PaintBucket, EnterPaintBucketMode, "K45_ADR_PAINTSEED", true, 30); AddButtonInEditorRow(m_labelSelectionDescription, Commons.UI.SpriteNames.CommonsSpriteNames.K45_Reload, OnSegmentNewSeed, "K45_ADR_CHANGESEED_INTERCROSS", true, 30); KlyteMonoUtils.LimitWidthAndBox(m_labelSelectionDescription, (m_labelSelectionDescription.width), true); KlyteMonoUtils.CreateUIElement(out m_editingContainer, MainContainer.transform, "SecContainer", new Vector4(0, 0, MainContainer.width, MainContainer.height - 10 - m_topContainerBar.height)); m_editingContainer.autoLayout = true; m_editingContainer.autoLayoutDirection = LayoutDirection.Vertical; m_editingContainer.autoLayoutPadding = new RectOffset(0, 0, 5, 5); var m_editingHelper = new UIHelperExtension(m_editingContainer); AddFilterableInput(Locale.Get("K45_ADR_HIGHWAYITEM_TYPE"), m_editingHelper, out m_hwType, out _, OnFilterHwTypes, OnSetHwType); AddTextField(Locale.Get("K45_ADR_HIGHWAYITEM_ID"), out m_hwId, m_editingHelper, OnSetHwId); AddTextField(Locale.Get("K45_ADR_HIGHWAYITEM_FORCEDNAME"), out m_hwName, m_editingHelper, OnSetHwForcedName); AddIntField(Locale.Get("K45_ADR_HIGHWAYITEM_MILEAGEOFFSET"), out m_hwMileageOffset, m_editingHelper, OnSetMileageOffset, false); AddCheckboxLocale("K45_ADR_HIGHWAYITEM_INVERTMILEAGE", out m_hwInvertMileage, m_editingHelper, OnSetMileageInvert); AddColorField(m_editingHelper, Locale.Get("K45_ADR_HIGHWAYITEM_COLOR"), out m_hwColor, OnSetHwColor); m_hwMileageOffset.width = 120; MainContainer.eventVisibilityChanged += (x, y) => { if (y) { eraseSeedBuffer = -1; DoEraseSeed(); } else { if (ToolsModifierControl.toolController.CurrentTool is RoadSegmentTool) { ToolsModifierControl.SetTool <DefaultTool>(); } OnSegmentSet(0); } }; OnSegmentSet(0); }
private static void AddFolderButton(string filePath, UIHelperExtension helper, string localeId) { FileInfo fileInfo = FileUtils.EnsureFolderCreation(filePath); helper.AddLabel(Locale.Get(localeId) + ":"); var namesFilesButton = ((UIButton)helper.AddButton("/", () => ColossalFramework.Utils.OpenInFileBrowser(fileInfo.FullName))); namesFilesButton.textColor = Color.yellow; KlyteMonoUtils.LimitWidthAndBox(namesFilesButton, 710); namesFilesButton.text = fileInfo.FullName + Path.DirectorySeparatorChar; }
private void Awake() { parent = GetComponentInParent <UIComponent>(); var group6 = new UIHelperExtension(parent.GetComponentInChildren <UIScrollablePanel>()); ((UIScrollablePanel)group6.Self).autoLayoutDirection = LayoutDirection.Horizontal; ((UIScrollablePanel)group6.Self).wrapLayout = true; ((UIScrollablePanel)group6.Self).width = 730; group6.AddLabel(Locale.Get("K45_TLM_CUSTOM_PALETTE_CONFIG")); group6.AddSpace(15); FileInfo fiPalette = FileUtils.EnsureFolderCreation(TLMController.PalettesFolder); group6.AddLabel(Locale.Get("K45_TLM_PALETTE_FOLDER_LABEL") + ":"); var namesFilesButton = ((UIButton)group6.AddButton("/", () => ColossalFramework.Utils.OpenInFileBrowser(fiPalette.FullName))); namesFilesButton.textColor = Color.yellow; KlyteMonoUtils.LimitWidthAndBox(namesFilesButton, 710); namesFilesButton.text = fiPalette.FullName + Path.DirectorySeparatorChar; ((UIButton)group6.AddButton(Locale.Get("K45_TLM_RELOAD_PALETTES"), delegate() { TLMAutoColorPaletteContainer.Reload(); ReloadData(); OnPaletteReloaded?.Invoke(); })).width = 710; UIPanel m_listColorContainer = null; m_paletteSelect = group6.AddDropdown(Locale.Get("K45_TLM_PALETTE_VIEW"), TLMAutoColorPaletteContainer.PaletteListForEditing, 0, delegate(int sel) { if (sel <= 0 || sel >= TLMAutoColorPaletteContainer.PaletteListForEditing.Length) { m_listColorContainer?.Disable(); m_colorFieldTemplateListColors?.SetItemCount(0); } else { m_listColorContainer?.Enable(); UpdateColorList(TLMAutoColorPaletteContainer.GetColors(TLMAutoColorPaletteContainer.PaletteListForEditing[sel])); } }) as UIDropDown; m_paletteSelect.GetComponentInParent <UIPanel>().width = 720; m_paletteSelect.GetComponentInParent <UIPanel>().autoLayoutDirection = LayoutDirection.Horizontal; m_paletteSelect.GetComponentInParent <UIPanel>().wrapLayout = true; m_paletteSelect.width = 710; KlyteMonoUtils.CreateUIElement(out m_listColorContainer, group6.Self.transform, "listColors", new UnityEngine.Vector4(0, 0, group6.Self.width, group6.Self.height - 250)); KlyteMonoUtils.CreateScrollPanel(m_listColorContainer, out m_colorListScroll, out _, m_listColorContainer.width - 20, m_listColorContainer.height); m_colorListScroll.backgroundSprite = "OptionsScrollbarTrack"; m_colorListScroll.autoLayout = true; m_colorListScroll.autoLayoutDirection = LayoutDirection.Horizontal; m_colorListScroll.wrapLayout = true; }
public static void AddVector3Field(string label, out UITextField[] fieldArray, UIHelperExtension parentHelper, Action <Vector3> onChange) { fieldArray = parentHelper.AddVector3Field(label, Vector3.zero, onChange); KlyteMonoUtils.LimitWidthAndBox(fieldArray[0].parent.GetComponentInChildren <UILabel>(), (parentHelper.Self.width / 2) - 10, true); fieldArray.ForEach(x => { x.eventMouseWheel += RollFloat; x.tooltip = Locale.Get("K45_CMNS_FLOAT_EDITOR_TOOLTIP_HELP"); }); fieldArray[0].zOrder = 1; fieldArray[1].zOrder = 2; fieldArray[2].zOrder = 3; }
protected float InitField(out UILabel label, string name, string tooltipLocale, float xAdvance, float columnWidth) { KlyteMonoUtils.CreateUIElement(out label, m_container.transform, name); label.autoSize = false; label.minimumSize = new Vector2(columnWidth, 24); label.textScale = 1f; label.relativePosition = new Vector3(xAdvance, 3); label.textAlignment = UIHorizontalAlignment.Right; label.verticalAlignment = UIVerticalAlignment.Middle; label.padding = new RectOffset(3, 3, 5, 3); label.isTooltipLocalized = true; label.tooltipLocaleID = tooltipLocale; KlyteMonoUtils.LimitWidthAndBox(label); return(label.minimumSize.x); }
private void CreateSlider(UIHelperExtension uiHelper, string labelContent, Action <int> setter, Func <int> getter) { UILabel label = null; UISlider slider = uiHelper.AddSlider(Locale.Get(labelContent), 0, 9, 1, getter(), (x) => { setter(x < 0.1 ? 0 : 1 << Mathf.RoundToInt(x - 1)); label.suffix = getter().ToString(); }, out label); slider.width = PanelWidth - 15; label.minimumSize = new Vector2(PanelWidth - 15, 0); label.suffix = getter().ToString(); label.wordWrap = false; KlyteMonoUtils.LimitWidthAndBox(label); ((UIPanel)(label.parent)).autoLayoutPadding = new RectOffset(); }
public static void GenerateExportButtons(UIHelperExtension helperSettings, string assetKind, out UIPanel m_exportButtonContainer, out UIButton m_exportButton, OnButtonClicked OnExport, out UIPanel m_exportButtonContainerLocal, out UIButton m_exportButtonLocal, OnButtonClicked OnExportLocal) { KlyteMonoUtils.CreateUIElement(out m_exportButtonContainer, helperSettings.Self.transform, $"ExportContainer{assetKind}", new Vector4(0, 0, helperSettings.Self.width, 45)); m_exportButtonContainer.autoLayout = true; m_exportButtonContainer.autoLayoutPadding = new RectOffset(0, 6, 0, 0); m_exportButton = UIHelperExtension.AddButton(m_exportButtonContainer, Locale.Get($"K45_ACE_EXPORTDATA_TOASSET{assetKind.ToUpper()}"), OnExport); KlyteMonoUtils.LimitWidthAndBox(m_exportButton, m_exportButtonContainer.width * 0.7f); KlyteMonoUtils.CreateUIElement(out m_exportButtonContainerLocal, helperSettings.Self.transform, $"ExportContainerLocal{assetKind}", new Vector4(0, 0, helperSettings.Self.width, 45)); m_exportButtonContainerLocal.autoLayout = true; m_exportButtonContainerLocal.autoLayoutPadding = new RectOffset(0, 6, 0, 0); m_exportButtonLocal = UIHelperExtension.AddButton(m_exportButtonContainerLocal, Locale.Get($"K45_ACE_EXPORTDATA_TOLOCAL{assetKind.ToUpper()}"), OnExportLocal); KlyteMonoUtils.LimitWidthAndBox(m_exportButtonLocal, m_exportButtonContainerLocal.width * 0.7f); }
internal UICheckBox generateCheckboxConfig(UIHelperExtension group, string title, TLMConfigWarehouse.ConfigIndex configIndex, int maxWidth = 650) { checkBoxes[configIndex] = (UICheckBox)group.AddCheckbox(title, currentConfigWarehouseEditor.GetBool(configIndex), delegate(bool b) { if (!isLoading) { currentConfigWarehouseEditor.SetBool(configIndex, b); } }); Vector3 labelPos = checkBoxes[configIndex].label.relativePosition; KlyteMonoUtils.LimitWidthAndBox(checkBoxes[configIndex].label, maxWidth, out UIPanel box); box.padding = new RectOffset((int)labelPos.x, 0, (int)labelPos.y, 0); checkBoxes[configIndex].width = maxWidth + labelPos.x + 5; return(checkBoxes[configIndex]); }
public static void AddSlider(string label, out UISlider slider, UIHelperExtension parentHelper, OnValueChanged onChange, float min, float max, float step, Func <float, string> valueLabelFunc) { UILabel labelValue = null; slider = (UISlider)parentHelper.AddSlider(label, min, max, step, min, (x) => { onChange(x); labelValue.text = valueLabelFunc(x); }); slider.GetComponentInParent <UIPanel>().autoLayoutDirection = LayoutDirection.Horizontal; slider.GetComponentInParent <UIPanel>().autoFitChildrenVertically = true; KlyteMonoUtils.LimitWidthAndBox(slider.parent.GetComponentInChildren <UILabel>(), (parentHelper.Self.width / 2) - 10, true); labelValue = slider.GetComponentInParent <UIPanel>().AddUIComponent <UILabel>(); labelValue.textAlignment = UIHorizontalAlignment.Center; labelValue.padding = new RectOffset(4, 4, 0, 0); KlyteMonoUtils.LimitWidthAndBox(labelValue, (parentHelper.Self.width / 2) - slider.width, true); }
public void Awake() { MainPanel = GetComponent <UIPanel>(); MainPanel.relativePosition = new Vector3(510f, 0.0f); MainPanel.width = 350; MainPanel.height = GetComponentInParent <UIComponent>().height; MainPanel.zOrder = 50; MainPanel.color = new Color32(255, 255, 255, 255); MainPanel.name = "AssetSelectorWindow"; MainPanel.autoLayoutPadding = new RectOffset(5, 5, 10, 10); MainPanel.autoLayout = true; MainPanel.autoLayoutDirection = LayoutDirection.Vertical; KlyteMonoUtils.CreateUIElement(out m_title, MainPanel.transform); m_title.textAlignment = UIHorizontalAlignment.Center; m_title.autoSize = false; m_title.autoHeight = true; m_title.width = MainPanel.width - 30f; m_title.relativePosition = new Vector3(5, 5); m_title.textScale = 0.9f; m_title.localeID = "K45_TLM_ASSETS_FOR_PREFIX"; m_helper = new UIHelperExtension(MainPanel); LogUtils.DoLog("Name"); m_prefixName = CreateMiniTextField("K45_TLM_PREFIX_NAME", OnPrefixNameChange); LogUtils.DoLog("ColorForModel"); m_useColorForModel = m_helper.AddCheckboxLocale("K45_TLM_USE_PREFIX_COLOR_FOR_VEHICLE", false, OnUseColorVehicleChange); KlyteMonoUtils.LimitWidthAndBox(m_useColorForModel.label, 340, true); m_useColorForModel.label.textScale = 1; LogUtils.DoLog("ColorSel"); CreateColorSelector(); LogUtils.DoLog("Palette"); m_paletteDD = CreateMiniDropdown("K45_TLM_PALETTE", SetPalettePrefix, new string[1]); ReloadPalettes(); TLMPaletteOptionsTab.OnPaletteReloaded += ReloadPalettes; LogUtils.DoLog("Format"); m_formatDD = CreateMiniDropdown("K45_TLM_ICON", SetFormatPrefix, TLMLineIconExtension.GetDropDownOptions(Locale.Get("K45_TLM_LINE_ICON_ENUM_TT_DEFAULT"))); }
private void CreateTitleLabel(UIPanel container, out UILabel label, string name, string text, uint width) { KlyteMonoUtils.CreateUIElement(out UIPanel nameContainer, container.transform, "GenNameContainer"); nameContainer.autoSize = false; nameContainer.width = width; nameContainer.height = 30; nameContainer.autoLayout = true; nameContainer.autoLayoutDirection = LayoutDirection.Horizontal; KlyteMonoUtils.CreateUIElement(out label, nameContainer.transform, name); KlyteMonoUtils.LimitWidthAndBox(label, width); label.autoSize = true; label.height = 30; label.padding = new RectOffset(3, 3, 4, 3); label.textAlignment = UIHorizontalAlignment.Center; label.text = text; label.verticalAlignment = UIVerticalAlignment.Middle; label.minimumSize = new Vector2(width, 0); }
private void CreateColorSelector() { m_prefixColor = m_helper.AddColorPicker("A", Color.clear, OnChangePrefixColor, out UILabel lbl, out UIPanel container); KlyteMonoUtils.LimitWidthAndBox(lbl, 260, true); lbl.isLocalized = true; lbl.localeID = "K45_TLM_PREFIX_COLOR_LABEL"; lbl.verticalAlignment = UIVerticalAlignment.Middle; lbl.font = UIHelperExtension.defaultFontCheckbox; lbl.textScale = 1; KlyteMonoUtils.CreateUIElement(out UIButton resetColor, container.transform, "PrefixColorReset", new Vector4(290, 0, 0, 0)); KlyteMonoUtils.InitButton(resetColor, false, "ButtonMenu"); KlyteMonoUtils.LimitWidth(resetColor, 80, true); resetColor.textPadding = new RectOffset(5, 5, 5, 2); resetColor.autoSize = true; resetColor.localeID = "K45_TLM_RESET_COLOR"; resetColor.eventClick += OnResetColor; }
public void Update() { if (m_childControls.Count == 0 && m_bg.isVisible) { float heightCheck = 0f; if (!TLMController.IsRealTimeEnabled) { var uiHelper = new UIHelperExtension(m_bg); UICheckBox m_checkChangeDateLabel = uiHelper.AddCheckboxLocale("K45_TLM_SHOW_DAYTIME_INSTEAD_DATE", false, (x) => m_showDayTime = x && SimulationManager.instance.m_enableDayNight); KlyteMonoUtils.LimitWidthAndBox(m_checkChangeDateLabel.label, m_bg.width - 50); heightCheck = m_checkChangeDateLabel.height; } KlyteMonoUtils.CreateTabsComponent(out m_reportTabstrip, out _, m_bg.transform, "LineConfig", new Vector4(0, 0, m_bg.width, 30), new Vector4(0, 30, m_bg.width, m_bg.height - heightCheck - 30)); m_childControls.Add("FinanceReport", TabCommons.CreateTabLocalized <TLMLineFinanceReportTab>(m_reportTabstrip, "InfoPanelIconCurrency", "K45_TLM_WIP_FINANCE_REPORT_TAB", "FinanceReport", false)); m_childControls.Add("PassengerAgeReport", TabCommons.CreateTabLocalized <TLMLinePassengerAgeReportTab>(m_reportTabstrip, "InfoIconAge", "K45_TLM_WIP_PASSENGER_AGE_REPORT_TAB", "PassengerAgeReport", false)); m_childControls.Add("PassengerStudentTouristReport", TabCommons.CreateTabLocalized <TLMLinePassengerStudentTouristsReportTab>(m_reportTabstrip, "InfoIconTourism", "K45_TLM_WIP_PASSENGER_REPORT_TAB", "PassengerStudentTouristReport", false)); m_childControls.Add("PassengerWealthReport", TabCommons.CreateTabLocalized <TLMLinePassengerWealthReportTab>(m_reportTabstrip, "InfoIconLandValue", "K45_TLM_WIP_PASSENGER_WEALTH_REPORT_TAB", "PassengerWealthReport", false)); m_childControls.Add("PassengerGenderReport", TabCommons.CreateTabLocalized <TLMLinePassengerGenderReportTab>(m_reportTabstrip, "InfoIconPopulation", "K45_TLM_WIP_PASSENGER_GENDER_REPORT_TAB", "PassengerGenderReport", false)); } }
public void Awake() { m_container = GetComponent <UIPanel>(); m_container.width = transform.GetComponentInParent <UIComponent>().width; m_container.height = 30; m_container.autoLayout = false; m_container.autoLayoutDirection = LayoutDirection.Horizontal; m_container.autoLayoutPadding = new RectOffset(2, 2, 2, 2); m_container.wrapLayout = false; m_container.name = "WealthReportLine"; m_container.eventSizeChanged += (x, y) => m_background.size = y; KlyteMonoUtils.CreateUIElement(out m_background, transform, "BG"); m_background.backgroundSprite = "InfoviewPanel"; Color32 backgroundColor = BackgroundColor; backgroundColor.a = (byte)((m_container.zOrder % 2 != 0) ? 127 : 255); m_background.color = backgroundColor; m_background.relativePosition = Vector3.zero; m_background.size = m_container.size; float xAdvance = 0; KlyteMonoUtils.CreateUIElement(out m_dateTime, m_container.transform, "DateTime"); m_dateTime.autoSize = true; m_dateTime.minimumSize = new Vector2(DATE_COLUMN_WIDTH, 30); m_dateTime.textScale = 0.7f; m_dateTime.textAlignment = UIHorizontalAlignment.Center; m_dateTime.relativePosition = new Vector3(0, 0); m_dateTime.verticalAlignment = UIVerticalAlignment.Middle; m_dateTime.padding = new RectOffset(3, 3, 5, 3); m_dateTime.text = "00:00\n25/12/2020"; KlyteMonoUtils.LimitWidthAndBox(m_dateTime); xAdvance += m_dateTime.minimumSize.x; AddColumns(ref xAdvance); }
protected void CreateTitleRow(out UIPanel titleLine, UIComponent parent) { LogUtils.DoLog("Creating Title Row "); KlyteMonoUtils.CreateUIElement(out titleLine, parent.transform, "TLMtitleline", new Vector4(5, 0, parent.width - 10, 40)); titleLine.padding = new RectOffset(0, 0, 50, 0); m_createdTitleLine = titleLine; KlyteMonoUtils.CreateUIElement(out UILabel codColor, titleLine.transform, "codColor"); codColor.minimumSize = new Vector2(60, 0); codColor.area = new Vector4(80, 10, codColor.minimumSize.x, 18); KlyteMonoUtils.LimitWidthAndBox(codColor, (uint)codColor.width); codColor.textAlignment = UIHorizontalAlignment.Center; codColor.prefix = Locale.Get("PUBLICTRANSPORT_LINECOLOR"); codColor.text = "/"; codColor.suffix = Locale.Get("K45_TLM_CODE_SHORT"); codColor.eventClicked += CodColor_eventClicked; KlyteMonoUtils.CreateUIElement(out UILabel lineName, titleLine.transform, "lineName"); lineName.minimumSize = new Vector2(200, 0); lineName.area = new Vector4(140, 10, lineName.minimumSize.x, 18); KlyteMonoUtils.LimitWidthAndBox(lineName, (uint)lineName.width); lineName.textAlignment = UIHorizontalAlignment.Center; lineName.text = Locale.Get("PUBLICTRANSPORT_LINENAME"); lineName.eventClicked += LineName_eventClicked; KlyteMonoUtils.CreateUIElement(out UILabel stops, titleLine.transform, "stops"); stops.minimumSize = new Vector2(80, 0); stops.area = new Vector4(340, 10, stops.minimumSize.x, 18); KlyteMonoUtils.LimitWidthAndBox(stops, (uint)stops.width); stops.textAlignment = UIHorizontalAlignment.Center; stops.text = Locale.Get("PUBLICTRANSPORT_LINESTOPS"); stops.eventClicked += Stops_eventClicked; KlyteMonoUtils.CreateUIElement(out UILabel vehicles, titleLine.transform, "vehicles"); vehicles.minimumSize = new Vector2(110, 0); vehicles.area = new Vector4(430, 10, vehicles.minimumSize.x, 18); KlyteMonoUtils.LimitWidthAndBox(vehicles, (uint)vehicles.width); vehicles.textAlignment = UIHorizontalAlignment.Center; vehicles.text = Locale.Get("PUBLICTRANSPORT_VEHICLES"); vehicles.eventClicked += Vehicles_eventClicked; KlyteMonoUtils.CreateUIElement(out UILabel passengers, titleLine.transform, "passengers"); passengers.minimumSize = new Vector2(80, 0); passengers.area = new Vector4(540, 10, passengers.minimumSize.x, 18); KlyteMonoUtils.LimitWidthAndBox(passengers, (uint)passengers.width); passengers.textAlignment = UIHorizontalAlignment.Center; passengers.text = Locale.Get("PUBLICTRANSPORT_PASSENGERS"); passengers.eventClicked += Passengers_eventClicked; KlyteMonoUtils.CreateUIElement(out UILabel profitLW, titleLine.transform, "profit"); profitLW.minimumSize = new Vector2(150, 0); profitLW.area = new Vector4(625, 10, profitLW.minimumSize.x, 18); KlyteMonoUtils.LimitWidthAndBox(profitLW, (uint)profitLW.width); profitLW.textAlignment = UIHorizontalAlignment.Center; profitLW.text = Locale.Get(TLMController.IsRealTimeEnabled ? "K45_TLM_BALANCE_LAST_HOUR_HALF" : "K45_TLM_BALANCE_LAST_WEEK"); profitLW.eventClicked += Profit_eventClicked; AwakeShowLineButton(); LogUtils.DoLog("End creating Title Row "); }
protected override void AwakeActions() { CreateTopButton(MainPanel, "ExportAsDefault", "K45_ER_EXPORT_DEFAULT_BTN", CommonsSpriteNames.K45_Save.ToString(), new Vector2(10, 50), (x, y) => ClassesData.Instance.SaveAsDefault()); CreateTopButton(MainPanel, "ImportDefault", "K45_ER_IMPORT_DEFAULT_BTN", CommonsSpriteNames.K45_Load.ToString(), new Vector2(95, 50), (x, y) => ClassesData.Instance.LoadDefaults()); CreateTopButton(MainPanel, "SelectAll", "K45_ER_SELECT_ALL_BTN", "check-checked", new Vector2(180, 50), (x, y) => ClassesData.Instance.SelectAll()); CreateTopButton(MainPanel, "SelectNone", "K45_ER_SELECT_NONE_BTN", "check-unchecked", new Vector2(265, 50), (x, y) => ClassesData.Instance.UnselectAll()); CreateTopButton(MainPanel, "Reset", "K45_ER_RESET_BTN", CommonsSpriteNames.K45_Reload.ToString(), new Vector2(350, 50), (x, y) => ClassesData.Instance.SafeCleanAll(m_allClasses.Keys)); KlyteMonoUtils.CreateScrollPanel(MainPanel, out UIScrollablePanel scrollPanel, out _, MainPanel.width - 25, MainPanel.height - 105, new Vector3(5, 100)); scrollPanel.autoLayout = true; scrollPanel.autoLayoutDirection = LayoutDirection.Vertical; scrollPanel.autoLayoutPadding = new RectOffset(0, 0, 5, 5); scrollPanel.backgroundSprite = "ScrollbarTrack"; scrollPanel.scrollPadding = new RectOffset(5, 5, 5, 5); m_allClasses = ((FastList <PrefabCollection <NetInfo> .PrefabData>) typeof(PrefabCollection <NetInfo>).GetField("m_scenePrefabs", RedirectorUtils.allFlags).GetValue(null)) .m_buffer .Select(x => x.m_prefab) .Where(x => x?.m_class != null && (x.m_class.m_layer == ItemClass.Layer.Default || x.m_class.m_layer == ItemClass.Layer.MetroTunnels || x.m_class.m_layer == ItemClass.Layer.WaterPipes || x.m_class.m_layer == ItemClass.Layer.WaterStructures)) .GroupBy(x => x.m_class.name) .ToDictionary(x => x.First().m_class, x => x.ToList()); foreach (KeyValuePair <ItemClass, List <NetInfo> > clazz in m_allClasses) { List <NetInfo> itemList = clazz.Value; ItemClass clazzKey = clazz.Key; string className = clazzKey.name; KlyteMonoUtils.CreateUIElement(out UIPanel row, scrollPanel.transform, $"{clazz.Key.name}", new Vector4(0, 0, scrollPanel.width, 20)); row.autoLayout = true; row.padding = new RectOffset(5, 5, 0, 0); row.stringUserData = className; UICheckBox uiCheckbox = UIHelperExtension.AddCheckbox(row, $"{clazz.Key.name}", ClassesData.Instance.GetConductibility(clazzKey)); uiCheckbox.name = "ClassCheckbox"; uiCheckbox.height = 20f; uiCheckbox.width = 335f; uiCheckbox.label.processMarkup = true; uiCheckbox.label.textScale = 0.8f; uiCheckbox.objectUserData = clazzKey; uiCheckbox.eventCheckChanged += SetItemClassValue; KlyteMonoUtils.LimitWidthAndBox(uiCheckbox.label, 325); ClassesData.Instance.eventOnValueChanged += (x, y) => { if (x == className && y is bool b) { SetNewValue(uiCheckbox, b); } }; ClassesData.Instance.eventAllChanged += () => SetNewValue(uiCheckbox, ClassesData.Instance.GetConductibility(clazzKey)); KlyteMonoUtils.CreateUIElement(out UIButton help, row.transform, "?", new Vector4(0, 0, 20, 20)); help.text = "?"; help.hoveredTextColor = Color.blue; KlyteMonoUtils.InitButtonFull(help, false, "OptionBase"); help.eventClicked += (x, y) => { K45DialogControl.ShowModal(new K45DialogControl.BindProperties() { icon = ElectricRoadsMod.Instance.IconName, messageAlign = UIHorizontalAlignment.Left, showButton1 = true, showButton2 = true, showButton3 = true, showClose = true, textButton1 = Locale.Get("K45_ER_ACTIVATE_CLASS_BTN"), textButton2 = Locale.Get("K45_ER_DEACTIVATE_CLASS_BTN"), textButton3 = Locale.Get("K45_ER_RETURN_BTN"), title = string.Format(Locale.Get("K45_ER_TITLE_NET_LIST_WINDOW"), className), message = string.Format(Locale.Get(itemList.Count <= 20 ? "K45_ER_PATTERN_NET_LIST_FEW" : "K45_ER_PATTERN_NET_LIST_FULL"), string.Join("\n", itemList.Take(20).Select(x => $"\t- {x.GetLocalizedTitle()}").ToArray()), itemList.Count - 20) }, (x) => { if (x == 1) { uiCheckbox.isChecked = true; } else if (x == 2) { uiCheckbox.isChecked = false; } return(true); }); }; } Quicksort(scrollPanel.components, new Comparison <UIComponent>(CompareNames), false); }
public void Awake() { MainContainer = GetComponent <UIPanel>(); MainContainer.autoLayout = true; MainContainer.autoLayoutDirection = LayoutDirection.Vertical; MainContainer.autoLayoutPadding = new RectOffset(0, 0, 2, 2); m_uiHelperGlobal = new UIHelperExtension(MainContainer); CreateGroupFileSelect("K45_ADR_DISTRICT_GEN_PREFIX_FILE", OnChangeSelectedDistrictPrefix, ReloadDistrictPrefixesFiles, out m_districtPrefixGenFile); CreateGroupFileSelect("K45_ADR_DISTRICT_GEN_NAME_FILE", OnChangeSelectedDistrictName, ReloadDistrictNamesFiles, out m_districtNameGenFile); isLoading = true; AddIntField(Locale.Get("K45_ADR_DISTRICT_POSTAL_CODE"), out m_prefixPostalCodeCity, m_uiHelperGlobal, OnChangePostalCodePrefixCity, false); m_prefixPostalCodeCity.maxLength = 3; AddTextField(Locale.Get("K45_ADR_POSTAL_CODE_FORMAT_2"), out m_postalCodeFormat, m_uiHelperGlobal, OnChangePostalCodeFormat, AdrController.CurrentConfig.GlobalConfig.AddressingConfig.PostalCodeFormat); AddButtonInEditorRow(m_postalCodeFormat, CommonsSpriteNames.K45_QuestionMark, () => K45DialogControl.ShowModal(new K45DialogControl.BindProperties { showButton1 = true, textButton1 = Locale.Get("EXCEPTION_OK"), title = Locale.Get("K45_ADR_POSTAL_CODE_FORMAT_LEGEND_TITLE"), message = GetPostalCodeLegendText() }, (x) => true), null, true, 30); AddLabel(Locale.Get("K45_ADR_ADDRESS_LINES"), m_uiHelperGlobal, out _, out _); AddTextField(Locale.Get("K45_ADR_ADDRESS_LINE1"), out m_addressLine1Format, m_uiHelperGlobal, OnChangeAddressLine1, AdrController.CurrentConfig.GlobalConfig.AddressingConfig.AddressLine1); AddTextField(Locale.Get("K45_ADR_ADDRESS_LINE2"), out m_addressLine2Format, m_uiHelperGlobal, OnChangeAddressLine2, AdrController.CurrentConfig.GlobalConfig.AddressingConfig.AddressLine2); AddTextField(Locale.Get("K45_ADR_ADDRESS_LINE3"), out m_addressLine3Format, m_uiHelperGlobal, OnChangeAddressLine3, AdrController.CurrentConfig.GlobalConfig.AddressingConfig.AddressLine3); var commonPopupConfigHelpAddress = new K45DialogControl.BindProperties { showButton1 = true, textButton1 = Locale.Get("EXCEPTION_OK"), title = Locale.Get("K45_ADR_ADDRESS_LINES_FORMAT_LEGEND_TITLE"), message = GetAddressLegendText() }; AddButtonInEditorRow(m_addressLine1Format, CommonsSpriteNames.K45_QuestionMark, () => K45DialogControl.ShowModal(commonPopupConfigHelpAddress, (x) => true), null, true, 30); AddButtonInEditorRow(m_addressLine2Format, CommonsSpriteNames.K45_QuestionMark, () => K45DialogControl.ShowModal(commonPopupConfigHelpAddress, (x) => true), null, true, 30); AddButtonInEditorRow(m_addressLine3Format, CommonsSpriteNames.K45_QuestionMark, () => K45DialogControl.ShowModal(commonPopupConfigHelpAddress, (x) => true), null, true, 30); m_uiHelperGlobal.AddSpace(15); var nameGenConfig = AdrController.CurrentConfig.GlobalConfig.BuildingConfig.StationsNameGenerationConfig; AdrStationNamesGenerationConfig getGenConfig() => AdrController.CurrentConfig.GlobalConfig.BuildingConfig.StationsNameGenerationConfig; AdrRicoNamesGenerationConfig getRicoGenConfig() => AdrController.CurrentConfig.GlobalConfig.BuildingConfig.RicoNamesGenerationConfig; KlyteMonoUtils.CreateUIElement(out UIPanel buildingTogglePanel, m_uiHelperGlobal.Self.transform); buildingTogglePanel.width = MainContainer.width; buildingTogglePanel.autoLayout = true; buildingTogglePanel.autoLayoutPadding = new RectOffset(2, 2, 2, 2); buildingTogglePanel.autoLayoutDirection = LayoutDirection.Horizontal; buildingTogglePanel.autoFitChildrenVertically = true; buildingTogglePanel.wrapLayout = true; var buildingTogglePanelHelper = new UIHelperExtension(buildingTogglePanel); void AddBuildingCheckbox(string icon, string locale, Action <bool> onChange, Func <bool> getCurrentVal) => AddIconCheckbox(icon, locale, out _, buildingTogglePanelHelper, (x) => { onChange(x); AdrFacade.TriggerBuildingNameStrategyChanged(); }, new Vector2(45, 30), getCurrentVal()); AddLabel(Locale.Get("K45_ADR_BUILDING_PASSENGERS"), buildingTogglePanelHelper, out UILabel lbl, out _); lbl.padding.top = 5; lbl.padding.bottom = 5; KlyteMonoUtils.LimitWidthAndBox(lbl, 200, out UIPanel panel); panel.maximumSize = new Vector2(210, 0); panel.minimumSize = new Vector2(210, 0); AddBuildingCheckbox("SubBarPublicTransportBus", "K45_ADR_AUTONAME_BUS_STATIONS", x => getGenConfig().Bus = x, () => getGenConfig().Bus); AddBuildingCheckbox("IconPolicyFreePublicTransport", "K45_ADR_AUTONAME_INTERCITYBUS_STATIONS", x => getGenConfig().IntercityBus = x, () => getGenConfig().IntercityBus); AddBuildingCheckbox("SubBarPublicTransportTrolleybus", "K45_ADR_AUTONAME_TROLLEYBUS_STATIONS", x => getGenConfig().Trolleybus = x, () => getGenConfig().Trolleybus); AddBuildingCheckbox("SubBarPublicTransportTram", "K45_ADR_AUTONAME_TRAM_STATIONS", x => getGenConfig().Tram = x, () => getGenConfig().Tram); AddBuildingCheckbox("SubBarPublicTransportTrain", "K45_ADR_AUTONAME_TRAIN_STATIONS", x => getGenConfig().TrainsPassenger = x, () => getGenConfig().TrainsPassenger); AddBuildingCheckbox("SubBarPublicTransportMonorail", "K45_ADR_AUTONAME_MONORAIL_STATIONS", x => getGenConfig().Monorail = x, () => getGenConfig().Monorail); AddBuildingCheckbox("SubBarPublicTransportMetro", "K45_ADR_AUTONAME_METRO_STATIONS", x => getGenConfig().Metro = x, () => getGenConfig().Metro); AddBuildingCheckbox("SubBarPublicTransportCableCar", "K45_ADR_AUTONAME_CABLE_CAR_STATIONS", x => getGenConfig().CableCar = x, () => getGenConfig().CableCar); AddBuildingCheckbox("FeatureFerry", "K45_ADR_AUTONAME_FERRY_STATIONS", x => getGenConfig().Ferry = x, () => getGenConfig().Ferry); AddBuildingCheckbox("SubBarPublicTransportShip", "K45_ADR_AUTONAME_SHIP_STATIONS", x => getGenConfig().ShipPassenger = x, () => getGenConfig().ShipPassenger); AddBuildingCheckbox("IconPolicyHelicopterPriority", "K45_ADR_AUTONAME_HELICOPTER_STATIONS", x => getGenConfig().Helicopter = x, () => getGenConfig().Helicopter); AddBuildingCheckbox("FeatureBlimp", "K45_ADR_AUTONAME_BLIMP_STATIONS", x => getGenConfig().Blimp = x, () => getGenConfig().Blimp); AddBuildingCheckbox("SubBarPublicTransportPlane", "K45_ADR_AUTONAME_AIRPLANE_STATIONS", x => getGenConfig().AirplanePassenger = x, () => getGenConfig().AirplanePassenger); buildingTogglePanelHelper.AddSpace(5); AddLabel(Locale.Get("K45_ADR_BUILDING_CARGO"), buildingTogglePanelHelper, out lbl, out _); lbl.padding.top = 5; lbl.padding.bottom = 5; KlyteMonoUtils.LimitWidthAndBox(lbl, 260, out panel); panel.maximumSize = new Vector2(270, 0); panel.minimumSize = new Vector2(270, 0); AddBuildingCheckbox("SubBarPublicTransportShip", "K45_ADR_ENABLE_CUSTOM_NAMING_CARGO_SHIP", x => getGenConfig().ShipCargo = x, () => getGenConfig().ShipCargo); AddBuildingCheckbox("SubBarPublicTransportTrain", "K45_ADR_ENABLE_CUSTOM_NAMING_CARGO_TRAIN", x => getGenConfig().TrainsCargo = x, () => getGenConfig().TrainsCargo); AddBuildingCheckbox("SubBarPublicTransportPlane", "K45_ADR_ENABLE_CUSTOM_NAMING_CARGO_AIRPLANE", x => getGenConfig().AirplaneCargo = x, () => getGenConfig().AirplaneCargo); buildingTogglePanelHelper.AddSpace(5); AddLabel(Locale.Get("K45_ADR_BUILDING_USE_ADDRESS"), buildingTogglePanelHelper, out lbl, out _); lbl.padding.top = 5; lbl.padding.bottom = 5; KlyteMonoUtils.LimitWidthAndBox(lbl, 260, out panel); panel.maximumSize = new Vector2(270, 0); panel.minimumSize = new Vector2(270, 0); AddBuildingCheckbox("SubBarDistrictSpecializationResidential", "K45_ADR_ENABLE_ADDRESS_NAMING_RES", x => getRicoGenConfig().Residence = x ? GenerationMethod.ADDRESS : GenerationMethod.NONE, () => getRicoGenConfig().Residence == GenerationMethod.ADDRESS); AddBuildingCheckbox("SubBarDistrictSpecializationIndustrial", "K45_ADR_ENABLE_ADDRESS_NAMING_IND", x => getRicoGenConfig().Industry = x ? GenerationMethod.ADDRESS : GenerationMethod.NONE, () => getRicoGenConfig().Industry == GenerationMethod.ADDRESS); AddBuildingCheckbox("SubBarDistrictSpecializationCommercial", "K45_ADR_ENABLE_ADDRESS_NAMING_COM", x => getRicoGenConfig().Commerce = x ? GenerationMethod.ADDRESS : GenerationMethod.NONE, () => getRicoGenConfig().Commerce == GenerationMethod.ADDRESS); AddBuildingCheckbox("SubBarDistrictSpecializationOffice", "K45_ADR_ENABLE_ADDRESS_NAMING_OFF", x => getRicoGenConfig().Office = x ? GenerationMethod.ADDRESS : GenerationMethod.NONE, () => getRicoGenConfig().Office == GenerationMethod.ADDRESS); isLoading = false; ReloadDistrictPrefixesFiles(); ReloadDistrictNamesFiles(); }
private static void AddNewStopTemplate() { var go = new GameObject(); UIPanel panel = go.AddComponent <UIPanel>(); panel.size = new Vector2(36, 36); UIButton button = UITemplateManager.Get <UIButton>("StopButton"); panel.AttachUIComponent(button.gameObject).transform.localScale = Vector3.one; button.relativePosition = Vector2.zero; button.name = "StopButton"; button.scaleFactor = 1f; button.spritePadding.top = 2; button.isTooltipLocalized = true; KlyteMonoUtils.InitButtonFg(button, false, "DistrictOptionBrushMedium"); KlyteMonoUtils.InitButtonSameSprite(button, ""); UILabel uilabel = button.Find <UILabel>("PassengerCount"); panel.AttachUIComponent(uilabel.gameObject).transform.localScale = Vector3.one; uilabel.relativePosition = new Vector3(38, 12); uilabel.processMarkup = true; uilabel.isVisible = true; uilabel.minimumSize = new Vector2(175, 50); uilabel.verticalAlignment = UIVerticalAlignment.Middle; KlyteMonoUtils.LimitWidthAndBox(uilabel, 175, true); UIPanel connectionPanel = panel.AddUIComponent <UIPanel>(); connectionPanel.name = "ConnectionPanel"; connectionPanel.relativePosition = new Vector3(-50, 5); connectionPanel.size = new Vector3(50, 40); connectionPanel.autoLayout = true; connectionPanel.wrapLayout = true; connectionPanel.autoLayoutDirection = LayoutDirection.Vertical; connectionPanel.autoLayoutStart = LayoutStart.TopRight; UILabel distLabel = panel.AddUIComponent <UILabel>(); distLabel.name = "Distance"; distLabel.relativePosition = new Vector3(-12, 37); distLabel.textAlignment = UIHorizontalAlignment.Center; distLabel.textScale = 0.65f; distLabel.suffix = "m"; distLabel.useOutline = true; distLabel.minimumSize = new Vector2(60, 0); distLabel.outlineColor = Color.black; KlyteMonoUtils.CreateUIElement(out UITextField lineNameField, panel.transform, "StopNameField", new Vector4(38, -6, 175, 50)); lineNameField.maxLength = 256; lineNameField.isVisible = false; lineNameField.verticalAlignment = UIVerticalAlignment.Middle; lineNameField.horizontalAlignment = UIHorizontalAlignment.Left; lineNameField.selectionSprite = "EmptySprite"; lineNameField.builtinKeyNavigation = true; lineNameField.textScale = uilabel.textScale; lineNameField.padding.top = 18; lineNameField.padding.left = 5; lineNameField.padding.bottom = 14; KlyteMonoUtils.InitButtonFull(lineNameField, false, "TextFieldPanel"); TLMUiTemplateUtils.GetTemplateDict()["StopButtonPanel"] = panel; }
public static void AddColorField(UIHelperExtension helper, string text, out UIColorField m_colorEditor, PropertyChangedEventHandler <Color> onSelectedColorChanged) { m_colorEditor = helper.AddColorPicker(text, Color.white, (x) => { }); KlyteMonoUtils.LimitWidthAndBox(m_colorEditor.parent.GetComponentInChildren <UILabel>(), helper.Self.width / 2, true); m_colorEditor.eventSelectedColorChanged += onSelectedColorChanged; }
public void Awake() { LogUtils.DoLog("AWAKE TLMTicketPriceTimeChart!"); UIPanel panel = transform.gameObject.AddComponent <UIPanel>(); panel.width = 370; panel.height = 70; panel.autoLayout = false; panel.useCenter = true; panel.wrapLayout = false; panel.tooltipLocaleID = "K45_TLM_TICKET_PRICE_CLOCK"; KlyteMonoUtils.CreateUIElement(out m_container, transform, "ClockContainer"); m_container.relativePosition = new Vector3((panel.width / 2f) - 70, 0); m_container.width = 140; m_container.height = 70; m_container.autoLayout = false; m_container.useCenter = true; m_container.wrapLayout = false; m_container.tooltipLocaleID = "K45_TLM_TICKET_PRICE_CLOCK"; KlyteMonoUtils.CreateUIElement(out m_clock, m_container.transform, "Clock"); m_clock.spriteName = "K45_24hClock"; m_clock.relativePosition = new Vector3(0, 0); m_clock.width = 70; m_clock.height = 70; KlyteMonoUtils.CreateUIElement(out m_minutePointer, m_container.transform, "Minute"); m_minutePointer.width = 2; m_minutePointer.height = 27; m_minutePointer.pivot = UIPivotPoint.TopCenter; m_minutePointer.relativePosition = new Vector3(35, 35); m_minutePointer.spriteName = "EmptySprite"; m_minutePointer.color = new Color32(35, 35, 35, 255); KlyteMonoUtils.CreateUIElement(out m_hourPointer, m_container.transform, "Hour"); m_hourPointer.width = 3; m_hourPointer.height = 14; m_hourPointer.pivot = UIPivotPoint.TopCenter; m_hourPointer.relativePosition = new Vector3(35, 35); m_hourPointer.spriteName = "EmptySprite"; m_hourPointer.color = new Color32(5, 5, 5, 255); KlyteMonoUtils.CreateUIElement(out UILabel titleEffective, m_container.transform, "TitleEffective"); titleEffective.width = 70; titleEffective.height = 30; KlyteMonoUtils.LimitWidthAndBox(titleEffective, 70, out UIPanel container, true); container.relativePosition = new Vector3(70, 0); titleEffective.textScale = 0.8f; titleEffective.color = Color.white; titleEffective.isLocalized = true; titleEffective.localeID = "K45_TLM_EFFECTIVE_TICKET_PRICE_NOW"; titleEffective.textAlignment = UIHorizontalAlignment.Center; KlyteMonoUtils.CreateUIElement(out UIPanel effectiveContainer, m_container.transform, "ValueEffectiveContainer"); effectiveContainer.width = 70; effectiveContainer.height = 40; effectiveContainer.relativePosition = new Vector3(70, 30); effectiveContainer.color = Color.white; effectiveContainer.autoLayout = false; KlyteMonoUtils.CreateUIElement(out m_effectiveLabel, effectiveContainer.transform, "BarLabel"); m_effectiveLabel.width = 70; m_effectiveLabel.height = 40; m_effectiveLabel.relativePosition = new Vector3(0, 0); m_effectiveLabel.color = Color.white; m_effectiveLabel.isLocalized = false; m_effectiveLabel.textAlignment = UIHorizontalAlignment.Center; m_effectiveLabel.verticalAlignment = UIVerticalAlignment.Middle; m_effectiveLabel.useOutline = true; m_effectiveLabel.backgroundSprite = "PlainWhite"; m_effectiveLabel.padding.top = 3; KlyteMonoUtils.LimitWidthAndBox(m_effectiveLabel, 70, true); AwakeActionButtons(); }