private void CreateTsdTabstrip(out UITabstrip strip, UIComponent parent, UiCategoryTab category) { TLMUtils.createUIElement(out strip, parent.transform, "TLMTabstrip", new Vector4(5, 0, parent.width - 10, 40)); var effectiveOffsetY = strip.height; TLMUtils.createUIElement(out UITabContainer tabContainer, parent.transform, "TLMTabContainer", new Vector4(0, 40, parent.width, parent.height - 40)); strip.tabPages = tabContainer; UIButton tabTemplate = CreateTabSubStripTemplate(); UIComponent bodyContent = CreateContentTemplate(parent.width, parent.height - effectiveOffsetY - 10, category.isScrollable()); foreach (var kv in TransportSystemDefinition.sysDefinitions) { Type[] components; Type targetType; try { targetType = KlyteUtils.GetImplementationForGenericType(category.getTabGenericContentImpl(), kv.Value); components = new Type[] { targetType }; } catch { continue; } GameObject tab = Instantiate(tabTemplate.gameObject); GameObject body = Instantiate(bodyContent.gameObject); var configIdx = kv.Key.toConfigIndex(); String name = kv.Value.Name; TLMUtils.doLog($"configIdx = {configIdx};kv.Key = {kv.Key}; kv.Value= {kv.Value} "); String bgIcon = TLMConfigWarehouse.getBgIconForIndex(configIdx); String fgIcon = kv.Key.getTransportTypeIcon(); UIButton tabButton = tab.GetComponent <UIButton>(); tabButton.tooltip = TLMConfigWarehouse.getNameForTransportType(configIdx); tabButton.hoveredBgSprite = bgIcon; tabButton.focusedBgSprite = bgIcon; tabButton.normalBgSprite = bgIcon; tabButton.disabledBgSprite = bgIcon; tabButton.focusedColor = Color.green; tabButton.hoveredColor = new Color(0, 0.5f, 0f); tabButton.color = Color.black; tabButton.disabledColor = Color.gray; if (!string.IsNullOrEmpty(fgIcon)) { TLMUtils.createUIElement(out UIButton secSprite, tabButton.transform, "OverSprite", new Vector4(5, 5, 30, 30)); secSprite.normalFgSprite = fgIcon; secSprite.foregroundSpriteMode = UIForegroundSpriteMode.Scale; secSprite.isInteractive = false; secSprite.disabledColor = Color.black; } strip.AddTab(name, tab, body, components); } }
private void CreateTsdTabstrip() { UIButton tabTemplate = CreateTabSubStripTemplate(); UIComponent bodyContent = CreateContentTemplate(m_stripMain.tabContainer.width, m_stripMain.tabContainer.height, false); foreach (KeyValuePair <TransportSystemDefinition, Func <ITLMSysDef> > kv in TransportSystemDefinition.SysDefinitions) { Type[] components; Type targetType; try { targetType = ReflectionUtils.GetImplementationForGenericType(typeof(UVMLinesPanel <>), kv.Value().GetType()); components = new Type[] { targetType }; } catch { continue; } TransportSystemDefinition tsd = kv.Key; GameObject tab = Instantiate(tabTemplate.gameObject); GameObject body = Instantiate(bodyContent.gameObject); var configIdx = kv.Key.ToConfigIndex(); string name = kv.Value().GetType().Name; TLMUtils.doLog($"configIdx = {configIdx};kv.Key = {kv.Key}; kv.Value= {kv.Value} "); string bgIcon = KlyteResourceLoader.GetDefaultSpriteNameFor(TLMUtils.GetLineIcon(0, configIdx, ref tsd), true); string fgIcon = kv.Key.GetTransportTypeIcon(); UIButton tabButton = tab.GetComponent <UIButton>(); tabButton.tooltip = TLMConfigWarehouse.getNameForTransportType(configIdx); tabButton.hoveredBgSprite = bgIcon; tabButton.focusedBgSprite = bgIcon; tabButton.normalBgSprite = bgIcon; tabButton.disabledBgSprite = bgIcon; tabButton.focusedColor = Color.green; tabButton.hoveredColor = new Color(0, 0.5f, 0f); tabButton.color = Color.black; tabButton.disabledColor = Color.gray; if (!string.IsNullOrEmpty(fgIcon)) { KlyteMonoUtils.CreateUIElement(out UIButton secSprite, tabButton.transform, "OverSprite", new Vector4(5, 5, 30, 30)); secSprite.normalFgSprite = fgIcon; secSprite.foregroundSpriteMode = UIForegroundSpriteMode.Scale; secSprite.isInteractive = false; secSprite.disabledColor = Color.black; } m_stripMain.AddTab(name, tab, body, components); } }
private void updateDepotEditShortcutButton(UIComponent parent) { if (parent != null) { UIButton depotShortcut = parent.Find <UIButton>("TLMDepotShortcut"); if (!depotShortcut) { depotShortcut = initDepotShortcutOnWorldInfoPanel(parent); } var prop = typeof(WorldInfoPanel).GetField("m_InstanceID", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); ushort buildingId = ((InstanceID)(prop.GetValue(parent.gameObject.GetComponent <WorldInfoPanel>()))).Building; if (Singleton <BuildingManager> .instance.m_buildings.m_buffer[buildingId].Info.GetAI() is DepotAI ai) { byte count = 0; List <string> lines = new List <string>(); if (ai.m_transportInfo != null && ai.m_maxVehicleCount > 0 && TransportSystemDefinition.from(ai.m_transportInfo).isPrefixable()) { lines.Add(string.Format("{0}: {1}", TLMConfigWarehouse.getNameForTransportType(TransportSystemDefinition.from(ai.m_transportInfo).toConfigIndex()), TLMLineUtils.getPrefixesServedString(buildingId, false))); count++; } if (ai.m_secondaryTransportInfo != null && ai.m_maxVehicleCount2 > 0 && TransportSystemDefinition.from(ai.m_secondaryTransportInfo).isPrefixable()) { lines.Add(string.Format("{0}: {1}", TLMConfigWarehouse.getNameForTransportType(TransportSystemDefinition.from(ai.m_secondaryTransportInfo).toConfigIndex()), TLMLineUtils.getPrefixesServedString(buildingId, true))); count++; } depotShortcut.isVisible = count > 0; if (depotShortcut.isVisible) { UILabel label = depotShortcut.GetComponentInChildren <UILabel>(); label.text = string.Join("\n", lines.ToArray()); } } else { depotShortcut.isVisible = false; } } }
private void Awake() { instance = this; mainPanel = GetComponent <UIPanel>(); mainPanel.autoLayout = true; mainPanel.autoLayoutDirection = LayoutDirection.Vertical; m_uiHelper = new UIHelperExtension(mainPanel); var transportType = m_tsd.ToConfigIndex(); m_uiHelper.AddLabel(string.Format(Locale.Get("K45_TLM_CONFIGS_FOR"), TLMConfigWarehouse.getNameForTransportType(transportType))); UIPanel panel = m_uiHelper.Self.GetComponentInParent <UIPanel>(); ((UIPanel)m_uiHelper.Self).autoLayoutDirection = LayoutDirection.Horizontal; ((UIPanel)m_uiHelper.Self).backgroundSprite = KlyteResourceLoader.GetDefaultSpriteNameFor(CommonsSpriteNames.K45_MenuPanel_color); ((UIPanel)m_uiHelper.Self).wrapLayout = true; ((UIPanel)m_uiHelper.Self).padding = new RectOffset(10, 10, 10, 15); ((UIPanel)m_uiHelper.Self).color = TLMConfigWarehouse.getColorForTransportType(transportType); ((UIPanel)m_uiHelper.Self).width = 730; m_uiHelper.AddSpace(30); prefixDD = m_tlmCo.generateDropdownConfig(m_uiHelper, Locale.Get("K45_TLM_PREFIX"), m_tlmCo.namingOptionsPrefixo, transportType | TLMConfigWarehouse.ConfigIndex.PREFIX); separatorContainer = m_tlmCo.generateDropdownConfig(m_uiHelper, Locale.Get("K45_TLM_SEPARATOR"), m_tlmCo.namingOptionsSeparador, transportType | TLMConfigWarehouse.ConfigIndex.SEPARATOR).transform.parent.GetComponent <UIPanel>(); suffixDD = m_tlmCo.generateDropdownConfig(m_uiHelper, Locale.Get("K45_TLM_SUFFIX"), m_tlmCo.namingOptionsSufixo, transportType | TLMConfigWarehouse.ConfigIndex.SUFFIX); suffixDDContainer = suffixDD.transform.parent.GetComponent <UIPanel>(); nonPrefixDD = m_tlmCo.generateDropdownConfig(m_uiHelper, Locale.Get("K45_TLM_IDENTIFIER_NON_PREFIXED"), m_tlmCo.namingOptionsSufixo, transportType | TLMConfigWarehouse.ConfigIndex.NON_PREFIX); paletteContainer = m_tlmCo.generateDropdownStringValueConfig(m_uiHelper, Locale.Get("K45_TLM_PALETTE"), TLMAutoColorPalettes.paletteList, transportType | TLMConfigWarehouse.ConfigIndex.PALETTE_MAIN).transform.parent.GetComponent <UIPanel>(); m_tlmCo.generateDropdownEnumStringValueConfig <LineIconSpriteNames>(m_uiHelper, Locale.Get("K45_TLM_ICON"), TLMLineIconExtension.getDropDownOptions(), transportType | TLMConfigWarehouse.ConfigIndex.TRANSPORT_ICON_TLM); zerosContainer = m_tlmCo.generateCheckboxConfig(m_uiHelper, Locale.Get("K45_TLM_LEADING_ZEROS_SUFFIX"), transportType | TLMConfigWarehouse.ConfigIndex.LEADING_ZEROS); prefixAsSuffixContainer = m_tlmCo.generateCheckboxConfig(m_uiHelper, Locale.Get("K45_TLM_INVERT_PREFIX_SUFFIX_ORDER"), transportType | TLMConfigWarehouse.ConfigIndex.INVERT_PREFIX_SUFFIX); m_tlmCo.generateCheckboxConfig(m_uiHelper, Locale.Get("K45_TLM_RANDOM_ON_PALETTE_OVERFLOW"), transportType | TLMConfigWarehouse.ConfigIndex.PALETTE_RANDOM_ON_OVERFLOW); autoColorBasedContainer = m_tlmCo.generateCheckboxConfig(m_uiHelper, Locale.Get("K45_TLM_AUTO_COLOR_BASED_ON_PREFIX"), transportType | TLMConfigWarehouse.ConfigIndex.PALETTE_PREFIX_BASED); prefixIncrement = m_tlmCo.generateCheckboxConfig(m_uiHelper, Locale.Get("K45_TLM_LINENUMBERING_BASED_IN_PREFIX"), transportType | TLMConfigWarehouse.ConfigIndex.PREFIX_INCREMENT); prefixDD.eventSelectedIndexChanged += OnPrefixOptionChange; suffixDD.eventSelectedIndexChanged += OnSuffixOptionChange; OnPrefixOptionChange(prefixDD, prefixDD.selectedIndex); }
private void BindParentChanges() { m_lineInfo.EventOnLineChanged += (lineId) => { TLMUtils.doLog("EventOnLineChanged"); m_isLoading = true; bool isCustomLine = TLMTransportLineExtension.instance.GetUseCustomConfig(lineId); TransportSystemDefinition tsd = TransportSystemDefinition.from(lineId); TLMUtils.doLog("tsd = {0}", tsd); if (m_lastDef != tsd) { foreach (var i in m_checkboxes.Keys) { UnityEngine.Object.Destroy(m_checkboxes[i].gameObject); } m_defaultAssets = tsd.GetTransportExtension().GetAllBasicAssets(0); m_checkboxes = new Dictionary <string, UICheckBox>(); TLMUtils.doLog("m_defaultAssets Size = {0} ({1})", m_defaultAssets?.Count, string.Join(",", m_defaultAssets.Keys?.ToArray() ?? new string[0])); foreach (var i in m_defaultAssets.Keys) { var checkbox = (UICheckBox)m_uiHelper.AddCheckbox(m_defaultAssets[i], false, (x) => { ushort lineIdx = m_lineInfo.CurrentSelectedId; if (m_isLoading) { return; } if (x) { if (TLMTransportLineExtension.instance.GetUseCustomConfig(lineIdx)) { TLMTransportLineExtension.instance.AddAsset(lineIdx, i); } else { tsd.GetTransportExtension().AddAsset(TLMLineUtils.getPrefix(lineIdx), i); } } else { if (TLMTransportLineExtension.instance.GetUseCustomConfig(lineIdx)) { TLMTransportLineExtension.instance.RemoveAsset(lineIdx, i); } else { tsd.GetTransportExtension().RemoveAsset(TLMLineUtils.getPrefix(lineIdx), i); } } }); CreateModelCheckBox(i, checkbox); checkbox.label.tooltip = checkbox.label.text; checkbox.label.textScale = 0.9f; checkbox.label.transform.localScale = new Vector3(Math.Min((m_mainPanel.width - 50) / checkbox.label.width, 1), 1); m_checkboxes[i] = checkbox; } } m_lastDef = tsd; List <string> selectedAssets; if (isCustomLine) { selectedAssets = TLMTransportLineExtension.instance.GetAssetList(lineId); } else { selectedAssets = tsd.GetTransportExtension().GetAssetList(TLMLineUtils.getPrefix(lineId)); } TLMUtils.doLog("selectedAssets Size = {0} ({1})", selectedAssets?.Count, string.Join(",", selectedAssets?.ToArray() ?? new string[0])); foreach (var i in m_checkboxes.Keys) { m_checkboxes[i].isChecked = selectedAssets.Contains(i); } if (isCustomLine) { m_title.text = string.Format(Locale.Get("TLM_ASSET_SELECT_WINDOW_TITLE"), TLMLineUtils.getLineStringId(lineId), TLMConfigWarehouse.getNameForTransportType(tsd.toConfigIndex())); } else { TLMConfigWarehouse.ConfigIndex transportType = tsd.toConfigIndex(); ModoNomenclatura mnPrefixo = (ModoNomenclatura)TLMConfigWarehouse.getCurrentConfigInt(TLMConfigWarehouse.ConfigIndex.PREFIX | transportType); var prefix = TLMLineUtils.getPrefix(lineId); m_title.text = string.Format(Locale.Get("TLM_ASSET_SELECT_WINDOW_TITLE_PREFIX"), prefix > 0 ? TLMUtils.getStringFromNumber(TLMUtils.getStringOptionsForPrefix(mnPrefixo), (int)prefix + 1) : Locale.Get("TLM_UNPREFIXED"), TLMConfigWarehouse.getNameForTransportType(tsd.toConfigIndex())); } m_isLoading = false; m_previewPanel.isVisible = false; }; }
private void BindParentChanges() { TLMTabControllerPrefixList <T> .eventOnPrefixChange += (prefix) => { TLMUtils.doLog("EventOnLineChanged"); TransportSystemDefinition tsd = Singleton <T> .instance.GetTSD(); if (!tsd.hasVehicles()) { m_mainPanel.isVisible = false; return; } m_isLoading = true; TLMUtils.doLog("tsd = {0}", tsd); if (!loaded) { foreach (var i in m_checkboxes.Keys) { UnityEngine.Object.Destroy(m_checkboxes[i].gameObject); } m_defaultAssets = tsd.GetTransportExtension().GetAllBasicAssets(0); m_checkboxes = new Dictionary <string, UICheckBox>(); TLMUtils.doLog("m_defaultAssets Size = {0} ({1})", m_defaultAssets?.Count, string.Join(",", m_defaultAssets.Keys?.ToArray() ?? new string[0])); foreach (var i in m_defaultAssets.Keys) { var checkbox = (UICheckBox)m_uiHelper.AddCheckbox(m_defaultAssets[i], false, (x) => { if (!m_isLoading) { ushort lineIdx = (ushort)m_parent.SelectedPrefix; if (lineIdx > 100) { return; } if (x) { tsd.GetTransportExtension().AddAsset(TLMLineUtils.getPrefix(lineIdx), i); } else { tsd.GetTransportExtension().RemoveAsset(TLMLineUtils.getPrefix(lineIdx), i); } } }); CreateModelCheckBox(i, checkbox); checkbox.label.tooltip = checkbox.label.text; checkbox.label.textScale = 0.9f; checkbox.label.transform.localScale = new Vector3(Math.Min((m_mainPanel.width - 50) / checkbox.label.width, 1), 1); m_checkboxes[i] = checkbox; } } loaded = true; List <string> selectedAssets; selectedAssets = tsd.GetTransportExtension().GetAssetList((uint)prefix); TLMUtils.doLog("selectedAssets Size = {0} ({1})", selectedAssets?.Count, string.Join(",", selectedAssets?.ToArray() ?? new string[0])); foreach (var i in m_checkboxes.Keys) { m_checkboxes[i].isChecked = selectedAssets.Contains(i); } TLMConfigWarehouse.ConfigIndex transportType = tsd.toConfigIndex(); ModoNomenclatura mnPrefixo = (ModoNomenclatura)TLMConfigWarehouse.getCurrentConfigInt(TLMConfigWarehouse.ConfigIndex.PREFIX | transportType); m_title.text = string.Format(Locale.Get("TLM_ASSET_SELECT_WINDOW_TITLE_PREFIX"), prefix > 0 ? TLMUtils.getStringFromNumber(TLMUtils.getStringOptionsForPrefix(mnPrefixo), (int)prefix + 1) : Locale.Get("TLM_UNPREFIXED"), TLMConfigWarehouse.getNameForTransportType(tsd.toConfigIndex())); m_isLoading = false; }; TLMTabControllerPrefixList <T> .eventOnColorChange += (Color x) => m_lastColor = x; }
internal void LoadSettingsUI(UIHelperExtension helper) { try { foreach (Transform child in helper.self.transform) { GameObject.Destroy(child.gameObject); } } catch { } if (TLMSingleton.instance != null && TLMSingleton.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)), Locale.Get("TLM_MODO_NOMENCLATURA", Enum.GetName(typeof(ModoNomenclatura), 14)) }; 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)), Locale.Get("TLM_MODO_NOMENCLATURA", Enum.GetName(typeof(ModoNomenclatura), 14)) }; 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)), }; helper.self.eventVisibilityChanged += delegate(UIComponent component, bool b) { if (b) { showVersionInfoPopup(); } }; overrideWorldInfoPanelLineOption = (UICheckBox)helper.AddCheckboxLocale("TLM_OVERRIDE_DEFAULT_LINE_INFO", m_savedOverrideDefaultLineInfoPanel.value, toggleOverrideDefaultLineInfoPanel); helper.AddSpace(10); configSelector = (UIDropDown)helper.AddDropdownLocalized("TLM_SHOW_CONFIG_FOR", optionsForLoadConfig, 0, reloadData); if (TLMSingleton.instance != null && TLMSingleton.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.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); var prefixIncrement = generateCheckboxConfig(group1, Locale.Get("TLM_LINENUMBERING_BASED_IN_PREFIX"), transportType | TLMConfigWarehouse.ConfigIndex.PREFIX_INCREMENT); PropertyChangedEventHandler <int> updateFunction = delegate(UIComponent c, int sel) { bool isPrefixed = (ModoNomenclatura)sel != ModoNomenclatura.Nenhum; separatorContainer.isVisible = isPrefixed; prefixedPaletteContainer.isVisible = isPrefixed; prefixIncrement.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.prefixEditor.m_systemTypeDropDown != null) { TLMPublicTransportDetailPanel.instance.prefixEditor.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 (TLMSingleton.instance != null && TLMSingleton.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_FERRY"), TLMConfigWarehouse.ConfigIndex.FERRY_SHOW_IN_LINEAR_MAP); generateCheckboxConfig(group7, Locale.Get("TLM_NEAR_LINES_SHOW_BLIMP"), TLMConfigWarehouse.ConfigIndex.BLIMP_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 (TLMSingleton.instance != null && TLMSingleton.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 (TLMSingleton.instance != null && TLMSingleton.debugMode) { TLMUtils.doLog("Loading Group 3½"); } paletteName.enabled = false; colorEditor.Disable(); colorList.Disable(); if (TLMSingleton.instance != null && TLMSingleton.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(TLMSingleton).Assembly.GetName().Version.Revision); group9.AddLabel(Locale.Get("TLM_ORIGINAL_KC_VERSION") + " " + string.Join(".", ResourceLoader.loadResourceString("TLMVersion.txt").Split(".".ToCharArray()).Take(3).ToArray())); group9.AddButton(Locale.Get("TLM_RELEASE_NOTES"), delegate() { showVersionInfoPopup(true); }); if (TLMSingleton.instance != null && TLMSingleton.debugMode) { TLMUtils.doLog("End Loading Options"); } }
public void openDepotInfo(ushort buildingID, bool secondary) { isLoading = true; WorldInfoPanel.HideAllWorldInfoPanels(); m_buildingIdSelecionado = default(InstanceID); m_buildingIdSelecionado.Building = buildingID; DepotAI depotAI = Singleton <BuildingManager> .instance.m_buildings.m_buffer[buildingID].Info.GetAI() as DepotAI; if (depotAI == null) { return; } depotNameField.text = Singleton <BuildingManager> .instance.GetBuildingName(buildingID, default(InstanceID)); bool hasPrimary = depotAI.m_transportInfo != null && depotAI.m_maxVehicleCount > 0; bool hasSecondary = depotAI.m_secondaryTransportInfo != null && depotAI.m_maxVehicleCount2 > 0; if (!hasPrimary && !hasSecondary) { closeDepotInfo(null, null); return; } m_secondary = !hasPrimary || (secondary && hasSecondary); TransportInfo currentTransportInfo = m_secondary ? depotAI.m_secondaryTransportInfo : depotAI.m_transportInfo; TransportInfo otherInfo = !m_secondary && depotAI.m_secondaryTransportInfo != null ? depotAI.m_secondaryTransportInfo : depotAI.m_transportInfo; var tsd = TransportSystemDefinition.from(currentTransportInfo); depotInfoPanel.color = Color.Lerp(TLMCW.getColorForTransportType(tsd.toConfigIndex()), Color.white, 0.5f); lineTransportIconTypeLabel.relativePosition = new Vector3(10f, 12f); lineTransportIconTypeLabel.height = 20; lineTransportIconTypeLabel.normalBgSprite = PublicTransportWorldInfoPanel.GetVehicleTypeIcon(currentTransportInfo.m_transportType); lineTransportIconTypeLabel.disabledBgSprite = PublicTransportWorldInfoPanel.GetVehicleTypeIcon(currentTransportInfo.m_transportType); lineTransportIconTypeLabel.focusedBgSprite = PublicTransportWorldInfoPanel.GetVehicleTypeIcon(currentTransportInfo.m_transportType); lineTransportIconTypeLabel.hoveredBgSprite = PublicTransportWorldInfoPanel.GetVehicleTypeIcon(otherInfo.m_transportType); if (depotAI.m_secondaryTransportInfo != null) { lineTransportIconTypeLabel.tooltip = string.Format(Locale.Get("TLM_SEE_OTHER_DEPOT"), TLMConfigWarehouse.getNameForTransportType(TransportSystemDefinition.from(otherInfo).toConfigIndex())); } else { lineTransportIconTypeLabel.tooltip = ""; } Show(); m_controller.defaultListingLinesPanel.Hide(); updateCheckboxes(); isLoading = false; }
public void OnSetTarget(Type source) { if (source == GetType()) { return; } m_isLoading = true; uint sel = SelectedPrefix; m_prefixColor.selectedColor = Extension.GetColor(sel); m_useColorForModel.isChecked = Extension.IsUsingColorForModel(sel); m_prefixName.text = Extension.GetName(sel) ?? ""; m_paletteDD.selectedIndex = Math.Max(0, m_paletteDD.items.ToList().IndexOf(Extension.GetCustomPalette(sel))); m_formatDD.selectedIndex = Math.Max(0, (int)Extension.GetCustomFormat(sel)); m_title.text = string.Format(Locale.Get("K45_TLM_PREFIX_TAB_WIP_TITLE"), sel > 0 ? NumberingUtils.GetStringFromNumber(TLMUtils.GetStringOptionsForPrefix(TransportSystem), (int)sel + 1) : Locale.Get("K45_TLM_UNPREFIXED"), TLMConfigWarehouse.getNameForTransportType(TransportSystem.ToConfigIndex())); m_isLoading = false; }
public void Awake() { m_parent = GetComponentInParent <UIComponent>(); var group72 = new UIHelperExtension(m_parent.GetComponentInChildren <UIScrollablePanel>()); ((UIScrollablePanel)group72.Self).autoLayoutDirection = LayoutDirection.Horizontal; ((UIScrollablePanel)group72.Self).wrapLayout = true; ((UIScrollablePanel)group72.Self).width = 730; group72.AddLabel(Locale.Get("K45_TLM_DEFAULT_COST_PER_PASSENGER")); group72.AddSpace(15); foreach (TLMConfigWarehouse.ConfigIndex ci in TLMConfigWarehouse.configurableTicketTransportCategories) { UITextField textField = TLMConfigOptions.instance.generateNumberFieldConfig(group72, TLMConfigWarehouse.getNameForTransportType(ci), TLMConfigWarehouse.ConfigIndex.DEFAULT_COST_PER_PASSENGER_CAPACITY | ci); UIPanel textFieldPanel = textField.GetComponentInParent <UIPanel>(); textFieldPanel.autoLayoutDirection = LayoutDirection.Horizontal; textFieldPanel.autoFitChildrenVertically = true; UILabel label = textFieldPanel.GetComponentInChildren <UILabel>(); label.minimumSize = new Vector2(420, 0); KlyteMonoUtils.LimitWidth(label); if (TLMConfigWarehouse.IsCityLoaded) { label.eventVisibilityChanged += (x, y) => { if (y) { float defaultCost = TLMConfigWarehouse.GetTransportSystemDefinitionForConfigTransport(ci).GetDefaultPassengerCapacityCost(); if (defaultCost >= 0) { label.suffix = $" ({(defaultCost).ToString("C3", LocaleManager.cultureInfo)})"; } else { label.suffix = $" (N/A)"; textField.isVisible = false; } } }; } group72.AddSpace(2); } }
private void Awake() { parent = GetComponentInParent <UIComponent>(); var group13 = new UIHelperExtension(parent.GetComponentInChildren <UIScrollablePanel>()); ((UIScrollablePanel)group13.Self).autoLayoutDirection = LayoutDirection.Horizontal; ((UIScrollablePanel)group13.Self).wrapLayout = true; ((UIScrollablePanel)group13.Self).width = 730; group13.AddLabel(Locale.Get("K45_TLM_AUTO_NAME_SETTINGS_PUBLIC_TRANSPORT")); group13.AddSpace(1); group13.AddLabel(Locale.Get("K45_TLM_AUTO_NAME_SETTINGS_PUBLIC_TRANSPORT_DESC")); group13.AddSpace(15); foreach (TLMConfigWarehouse.ConfigIndex ci in TLMConfigWarehouse.configurableAutoNameTransportCategories) { UICheckBox checkbox = TLMConfigOptions.instance.generateCheckboxConfig(group13, TLMConfigWarehouse.getNameForTransportType(ci), TLMConfigWarehouse.ConfigIndex.PUBLICTRANSPORT_USE_FOR_AUTO_NAMING_REF | ci, 200); UITextField textField = TLMConfigOptions.instance.generateTextFieldConfig(group13, Locale.Get("K45_TLM_PREFIX_OPTIONAL"), TLMConfigWarehouse.ConfigIndex.PUBLICTRANSPORT_AUTO_NAMING_REF_TEXT | ci); UIPanel textFieldPanel = textField.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; } }; group13.AddSpace(1); } }
private void Awake() { parent = GetComponentInChildren <UIScrollablePanel>(); int parentWidth = 730; KlyteMonoUtils.CreateUIElement(out UITabstrip strip, parent.transform, "TLMTabstrip", new Vector4(5, 0, parentWidth - 10, 40)); float effectiveOffsetY = strip.height; KlyteMonoUtils.CreateUIElement(out UITabContainer tabContainer, parent.transform, "TLMTabContainer", new Vector4(0, 40, parentWidth - 10, 320)); tabContainer.autoSize = true; strip.tabPages = tabContainer; UIButton tabTemplate = CreateTabSubStripTemplate(); UIComponent bodyContent = CreateContentTemplate(parentWidth, 320, false); foreach (System.Collections.Generic.KeyValuePair <TransportSystemDefinition, Func <ITLMSysDef> > kv in TransportSystemDefinition.SysDefinitions) { Type[] components; Type targetType; try { targetType = ReflectionUtils.GetImplementationForGenericType(typeof(TLMShowConfigTab <>), kv.Value().GetType()); components = new Type[] { targetType }; } catch { continue; } GameObject tab = Instantiate(tabTemplate.gameObject); GameObject body = Instantiate(bodyContent.gameObject); var configIdx = kv.Key.ToConfigIndex(); TransportSystemDefinition tsd = kv.Key; string name = kv.Value().GetType().Name; TLMUtils.doLog($"configIdx = {configIdx};kv.Key = {kv.Key}; kv.Value= {kv.Value} "); string bgIcon = KlyteResourceLoader.GetDefaultSpriteNameFor(TLMUtils.GetLineIcon(0, configIdx, ref tsd), true); string fgIcon = kv.Key.GetTransportTypeIcon(); UIButton tabButton = tab.GetComponent <UIButton>(); tabButton.tooltip = TLMConfigWarehouse.getNameForTransportType(configIdx); tabButton.hoveredBgSprite = bgIcon; tabButton.focusedBgSprite = bgIcon; tabButton.normalBgSprite = bgIcon; tabButton.disabledBgSprite = bgIcon; tabButton.focusedColor = Color.green; tabButton.hoveredColor = new Color(0, 0.5f, 0f); tabButton.color = Color.white; tabButton.disabledColor = Color.gray; if (!string.IsNullOrEmpty(fgIcon)) { KlyteMonoUtils.CreateUIElement(out UIButton secSprite, tabButton.transform, "OverSprite", new Vector4(5, 5, 30, 30)); secSprite.normalFgSprite = fgIcon; secSprite.foregroundSpriteMode = UIForegroundSpriteMode.Scale; secSprite.isInteractive = false; secSprite.disabledColor = Color.black; } strip.AddTab(name, tab, body, components); } strip.selectedIndex = -1; strip.selectedIndex = 0; }
private void Awake() { parent = GetComponentInParent <UIComponent>(); UIHelperExtension group72 = new UIHelperExtension(parent.GetComponentInChildren <UIScrollablePanel>()); ((UIScrollablePanel)group72.Self).autoLayoutDirection = LayoutDirection.Horizontal; ((UIScrollablePanel)group72.Self).wrapLayout = true; ((UIScrollablePanel)group72.Self).width = 730; group72.AddLabel(Locale.Get("K45_TLM_DEFAULT_PRICE")); group72.AddSpace(15); foreach (TLMConfigWarehouse.ConfigIndex ci in TLMConfigWarehouse.configurableTicketTransportCategories) { var textField = TLMConfigOptions.instance.generateNumberFieldConfig(group72, TLMConfigWarehouse.getNameForTransportType(ci), TLMConfigWarehouse.ConfigIndex.DEFAULT_TICKET_PRICE | ci); var textFieldPanel = textField.GetComponentInParent <UIPanel>(); textFieldPanel.autoLayoutDirection = LayoutDirection.Horizontal; textFieldPanel.autoFitChildrenVertically = true; textFieldPanel.GetComponentInChildren <UILabel>().minimumSize = new Vector2(420, 0); group72.AddSpace(2); } }
public void RefreshData(bool updateColors, bool updateVisibility) { if (this.m_LineOperation == null || this.m_LineOperation.completedOrFailed) { TLMLineUtils.getLineActive(ref Singleton <TransportManager> .instance.m_lines.m_buffer[m_LineID], out bool dayActive, out bool nightActive); bool zeroed; unchecked { zeroed = (Singleton <TransportManager> .instance.m_lines.m_buffer[m_LineID].m_flags & (TransportLine.Flags)TLMTransportLineFlags.ZERO_BUDGET_CURRENT) != 0; } if (!dayActive || !nightActive || zeroed) { m_LineColor.normalBgSprite = zeroed ? "NoBudgetIcon" : dayActive ? "DayIcon" : nightActive ? "NightIcon" : "DisabledIcon"; } else { m_LineColor.normalBgSprite = ""; } this.m_DayLine.isChecked = (dayActive && !nightActive); this.m_NightLine.isChecked = (nightActive && !dayActive); this.m_DayNightLine.isChecked = (dayActive && nightActive); this.m_DisabledLine.isChecked = (!dayActive && !nightActive); m_DisabledLine.relativePosition = new Vector3(730, 8); } else { m_LineColor.normalBgSprite = "DisabledIcon"; } this.m_LineName.text = Singleton <TransportManager> .instance.GetLineName(this.m_LineID); m_LineNumber = Singleton <TransportManager> .instance.m_lines.m_buffer[(int)this.m_LineID].m_lineNumber; this.m_LineStops.text = Singleton <TransportManager> .instance.m_lines.m_buffer[(int)this.m_LineID].CountStops(this.m_LineID).ToString("N0"); this.m_LineVehicles.text = Singleton <TransportManager> .instance.m_lines.m_buffer[(int)this.m_LineID].CountVehicles(this.m_LineID).ToString("N0"); uint prefix = 0; var tsd = Singleton <T> .instance.GetTSD(); if (TLMConfigWarehouse.getCurrentConfigInt(tsd.toConfigIndex() | TLMConfigWarehouse.ConfigIndex.PREFIX) != (int)ModoNomenclatura.Nenhum) { prefix = Singleton <TransportManager> .instance.m_lines.m_buffer[lineID].m_lineNumber / 1000u; } int averageCount = (int)Singleton <TransportManager> .instance.m_lines.m_buffer[(int)this.m_LineID].m_passengers.m_residentPassengers.m_averageCount; int averageCount2 = (int)Singleton <TransportManager> .instance.m_lines.m_buffer[(int)this.m_LineID].m_passengers.m_touristPassengers.m_averageCount; this.m_LinePassengers.text = (averageCount + averageCount2).ToString("N0"); this.m_LinePassengers.tooltip = string.Format("{0}", LocaleFormatter.FormatGeneric("TRANSPORT_LINE_PASSENGERS", new object[] { averageCount, averageCount2 })); TLMLineUtils.setLineNumberCircleOnRef(lineID, m_LineNumberFormatted, 0.8f); m_LineColor.normalFgSprite = TLMLineUtils.getIconForLine(lineID); this.m_PassengerCount = averageCount + averageCount2; this.m_lineIncompleteWarning.isVisible = ((Singleton <TransportManager> .instance.m_lines.m_buffer[(int)this.m_LineID].m_flags & TransportLine.Flags.Complete) == TransportLine.Flags.None); if (updateColors) { this.m_LineColor.selectedColor = Singleton <TransportManager> .instance.GetLineColor(this.m_LineID); } if (updateVisibility) { this.m_LineIsVisible.isChecked = ((Singleton <TransportManager> .instance.m_lines.m_buffer[(int)this.m_LineID].m_flags & TransportLine.Flags.Hidden) == TransportLine.Flags.None); } if (tsd.hasVehicles()) { TransportInfo info = Singleton <TransportManager> .instance.m_lines.m_buffer[(int)this.m_LineID].Info; float overallBudget = Singleton <EconomyManager> .instance.GetBudget(info.m_class) / 100f; string vehTooltip = string.Format("{0} {1}", this.m_LineVehicles.text, Locale.Get("PUBLICTRANSPORT_VEHICLES")); this.m_LineVehicles.tooltip = vehTooltip; if (!TLMTransportLineExtension.instance.IsUsingCustomConfig(this.lineID) || !TLMTransportLineExtension.instance.IsUsingAbsoluteVehicleCount(this.lineID)) { this.m_lineBudgetLabel.text = string.Format("{0:0%}", TLMLineUtils.getEffectiveBugdet(lineID));//585+1/7 = frames/week m_lineBudgetLabel.tooltip = string.Format(Locale.Get("TLM_LINE_BUDGET_EXPLAIN_2"), TLMConfigWarehouse.getNameForTransportType(tsd.toConfigIndex()), overallBudget, Singleton <TransportManager> .instance.m_lines.m_buffer[lineID].m_budget / 100f, TLMLineUtils.getEffectiveBugdet(lineID)); m_lineBudgetLabel.relativePosition = new Vector3(m_LineVehicles.relativePosition.x, 19, 0); m_lineBudgetLabel.isVisible = true; } else { m_lineBudgetLabel.isVisible = false; } bool tlmPerHour = TLMLineUtils.isPerHourBudget(m_LineID); m_DayLine.isVisible = !tlmPerHour; m_DayNightLine.isVisible = !tlmPerHour; m_NightLine.isVisible = !tlmPerHour; m_DisabledLine.isVisible = !tlmPerHour; m_perHourBudgetInfo.isVisible = tlmPerHour; m_perHourBudgetInfo.relativePosition = new Vector3(615, 2); } else { m_DayLine.isVisible = true; m_DayNightLine.isVisible = true; m_NightLine.isVisible = true; m_DisabledLine.isVisible = true; } }
internal void LoadSettingsUI(UIHelperExtension helper) { try { foreach (Transform child in helper.self.transform) { GameObject.Destroy(child.gameObject); } } catch { } if (TLMSingleton.instance != null && TLMSingleton.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)), Locale.Get("TLM_MODO_NOMENCLATURA", Enum.GetName(typeof(ModoNomenclatura), 14)) }; 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)), Locale.Get("TLM_MODO_NOMENCLATURA", Enum.GetName(typeof(ModoNomenclatura), 14)) }; 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)), }; helper.self.eventVisibilityChanged += delegate(UIComponent component, bool b) { if (b) { showVersionInfoPopup(); } }; overrideWorldInfoPanelLineOption = (UICheckBox)helper.AddCheckboxLocale("TLM_OVERRIDE_DEFAULT_LINE_INFO", m_savedOverrideDefaultLineInfoPanel.value, toggleOverrideDefaultLineInfoPanel); helper.AddSpace(10); configSelector = (UIDropDown)helper.AddDropdownLocalized("TLM_SHOW_CONFIG_FOR", optionsForLoadConfig, 0, reloadData); if (TLMSingleton.instance != null && TLMSingleton.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.BUS_CONFIG, TLMConfigWarehouse.ConfigIndex.TRAM_CONFIG, TLMConfigWarehouse.ConfigIndex.MONORAIL_CONFIG, TLMConfigWarehouse.ConfigIndex.METRO_CONFIG, TLMConfigWarehouse.ConfigIndex.TRAIN_CONFIG, TLMConfigWarehouse.ConfigIndex.TOUR_PED_CONFIG, TLMConfigWarehouse.ConfigIndex.TOUR_BUS_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); var prefixIncrement = generateCheckboxConfig(group1, Locale.Get("TLM_LINENUMBERING_BASED_IN_PREFIX"), transportType | TLMConfigWarehouse.ConfigIndex.PREFIX_INCREMENT); PropertyChangedEventHandler <int> updateFunction = delegate(UIComponent c, int sel) { bool isPrefixed = (ModoNomenclatura)sel != ModoNomenclatura.Nenhum; separatorContainer.isVisible = isPrefixed; prefixedPaletteContainer.isVisible = isPrefixed; prefixIncrement.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"); }; 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); } UIHelperExtension group72 = helper.AddGroupExtended(Locale.Get("TLM_DEFAULT_PRICE")); ((UIPanel)group72.self).autoLayoutDirection = LayoutDirection.Horizontal; ((UIPanel)group72.self).wrapLayout = true; ((UIPanel)group72.self).width = 730; foreach (TLMConfigWarehouse.ConfigIndex ci in TLMConfigWarehouse.configurableTicketTransportCategories) { var textField = generateNumberFieldConfig(group72, TLMConfigWarehouse.getNameForTransportType(ci), TLMConfigWarehouse.ConfigIndex.DEFAULT_TICKET_PRICE | ci); var textFieldPanel = textField.GetComponentInParent <UIPanel>(); textFieldPanel.autoLayoutDirection = LayoutDirection.Horizontal; textFieldPanel.autoFitChildrenVertically = true; textFieldPanel.GetComponentInChildren <UILabel>().minimumSize = new Vector2(420, 0); group72.AddSpace(2); } if (TLMSingleton.instance != null && TLMSingleton.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_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); if (Singleton <LoadingManager> .instance.SupportsExpansion(ICities.Expansion.AfterDark)) { generateCheckboxConfig(group7, Locale.Get("TLM_NEAR_LINES_SHOW_TAXI"), TLMConfigWarehouse.ConfigIndex.TAXI_SHOW_IN_LINEAR_MAP); } if (Singleton <LoadingManager> .instance.SupportsExpansion(ICities.Expansion.Snowfall)) { generateCheckboxConfig(group7, Locale.Get("TLM_NEAR_LINES_SHOW_TRAM"), TLMConfigWarehouse.ConfigIndex.TRAM_SHOW_IN_LINEAR_MAP); } if (Singleton <LoadingManager> .instance.SupportsExpansion(ICities.Expansion.NaturalDisasters)) { generateCheckboxConfig(group7, Locale.Get("TLM_NEAR_LINES_SHOW_EVAC_BUS"), TLMConfigWarehouse.ConfigIndex.EVAC_BUS_SHOW_IN_LINEAR_MAP); } if (Singleton <LoadingManager> .instance.SupportsExpansion(ICities.Expansion.InMotion)) { generateCheckboxConfig(group7, Locale.Get("TLM_NEAR_LINES_SHOW_FERRY"), TLMConfigWarehouse.ConfigIndex.FERRY_SHOW_IN_LINEAR_MAP); generateCheckboxConfig(group7, Locale.Get("TLM_NEAR_LINES_SHOW_BLIMP"), TLMConfigWarehouse.ConfigIndex.BLIMP_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); } if (Singleton <LoadingManager> .instance.SupportsExpansion(ICities.Expansion.Parks)) { generateCheckboxConfig(group7, Locale.Get("TLM_NEAR_LINES_SHOW_TOUR_BUS"), TLMConfigWarehouse.ConfigIndex.TOUR_BUS_CONFIG_SHOW_IN_LINEAR_MAP); generateCheckboxConfig(group7, Locale.Get("TLM_NEAR_LINES_SHOW_TOUR_PED"), TLMConfigWarehouse.ConfigIndex.TOUR_PED_CONFIG_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); } UIHelperExtension group15 = helper.AddGroupExtended(Locale.Get("TLM_AUTO_NAME_SETTINGS_PUBLIC_AREAS")); ((UIPanel)group15.self).autoLayoutDirection = LayoutDirection.Horizontal; ((UIPanel)group15.self).wrapLayout = true; ((UIPanel)group15.self).width = 730; foreach (TLMConfigWarehouse.ConfigIndex ci in TLMConfigWarehouse.extraAutoNameCategories) { generateCheckboxConfig(group15, TLMConfigWarehouse.getNameForServiceType(ci), TLMConfigWarehouse.ConfigIndex.USE_FOR_AUTO_NAMING_REF | ci).width = 300; var textFieldPanel = generateTextFieldConfig(group15, Locale.Get("TLM_PREFIX_OPTIONAL"), TLMConfigWarehouse.ConfigIndex.AUTO_NAMING_REF_TEXT | ci).GetComponentInParent <UIPanel>(); textFieldPanel.autoLayoutDirection = LayoutDirection.Horizontal; textFieldPanel.autoFitChildrenVertically = true; group15.AddSpace(2); } TLMUtils.doLog("Loading Group 3"); var fiPalette = TLMUtils.EnsureFolderCreation(TLMSingleton.palettesFolder); UIHelperExtension group6 = helper.AddGroupExtended(Locale.Get("TLM_CUSTOM_PALETTE_CONFIG")); ((group6.self) as UIPanel).autoLayoutDirection = LayoutDirection.Horizontal; ((group6.self) as UIPanel).wrapLayout = true; group6.AddLabel(Locale.Get("TLM_PALETTE_FOLDER_LABEL") + ":"); var namesFilesButton = ((UIButton)group6.AddButton("/", () => { ColossalFramework.Utils.OpenInFileBrowser(fiPalette.FullName); })); namesFilesButton.textColor = Color.yellow; TLMUtils.LimitWidth(namesFilesButton, 710); namesFilesButton.text = fiPalette.FullName + Path.DirectorySeparatorChar; ((UIButton)group6.AddButton(Locale.Get("TLM_RELOAD_PALETTES"), delegate() { TLMAutoColorPalettes.Reload(); updateDropDowns(); })).width = 710; NumberedColorList colorList = null; editorSelector = group6.AddDropdown(Locale.Get("TLM_PALETTE_VIEW"), TLMAutoColorPalettes.paletteListForEditing, 0, delegate(int sel) { if (sel <= 0 || sel >= TLMAutoColorPalettes.paletteListForEditing.Length) { colorList.Disable(); } else { colorList.colorList = TLMAutoColorPalettes.getColors(TLMAutoColorPalettes.paletteListForEditing[sel]); colorList.Enable(); } }) as UIDropDown; editorSelector.GetComponentInParent <UIPanel>().width = 710; editorSelector.width = 710; colorList = group6.AddNumberedColorList(null, new List <Color32>(), (c) => { }, null, null); colorList.m_atlasToUse = TLMController.taLineNumber; colorList.m_spriteName = "SubwayIcon"; if (TLMSingleton.instance != null && TLMSingleton.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(TLMSingleton).Assembly.GetName().Version.Revision); group9.AddLabel(Locale.Get("TLM_ORIGINAL_KC_VERSION") + " " + string.Join(".", TLMResourceLoader.instance.loadResourceString("TLMVersion.txt").Split(".".ToCharArray()).Take(3).ToArray())); group9.AddButton(Locale.Get("TLM_RELEASE_NOTES"), delegate() { showVersionInfoPopup(true); }); if (TLMSingleton.instance != null && TLMSingleton.debugMode) { TLMUtils.doLog("End Loading Options"); } }
private void updateSliders() { if (TLMSingleton.isIPTLoaded) { m_lineBudgetSlidersTitle.parent.isVisible = false; return; } TLMConfigWarehouse.ConfigIndex transportType = tsd.toConfigIndex(); ModoNomenclatura mnPrefixo = (ModoNomenclatura)TLMConfigWarehouse.getCurrentConfigInt(TLMConfigWarehouse.ConfigIndex.PREFIX | transportType); uint[] multipliers; IBudgetableExtension bte; uint idx; var tsdRef = tsd; idx = (uint)SelectedPrefix; bte = TLMLineUtils.getExtensionFromTransportSystemDefinition(ref tsdRef); multipliers = bte.GetBudgetsMultiplier(idx); m_lineBudgetSlidersTitle.text = string.Format(Locale.Get("TLM_BUDGET_MULTIPLIER_TITLE_PREFIX"), idx > 0 ? TLMUtils.getStringFromNumber(TLMUtils.getStringOptionsForPrefix(mnPrefixo), (int)idx + 1) : Locale.Get("TLM_UNPREFIXED"), TLMConfigWarehouse.getNameForTransportType(tsdRef.toConfigIndex())); bool budgetPerHourEnabled = multipliers.Length == 8; m_disableBudgetPerHour.isVisible = budgetPerHourEnabled; m_enableBudgetPerHour.isVisible = !budgetPerHourEnabled && tsdRef.hasVehicles(); for (int i = 0; i < m_budgetSliders.Length; i++) { UILabel budgetSliderLabel = m_budgetSliders[i].transform.parent.GetComponentInChildren <UILabel>(); if (i == 0) { if (multipliers.Length == 1) { budgetSliderLabel.prefix = Locale.Get("TLM_BUDGET_MULTIPLIER_PERIOD_LABEL_ALL"); } else { budgetSliderLabel.prefix = Locale.Get("TLM_BUDGET_MULTIPLIER_PERIOD_LABEL", 0); } } else { m_budgetSliders[i].isEnabled = budgetPerHourEnabled; m_budgetSliders[i].parent.isVisible = budgetPerHourEnabled; } if (i < multipliers.Length) { m_budgetSliders[i].value = multipliers[i] / 100f; } } }
public void OnSetTarget(Type source) { if (source == GetType()) { return; } TransportSystemDefinition tsd = TransportSystem; if (!tsd.HasVehicles()) { MainPanel.isVisible = false; return; } m_isLoading = true; TLMUtils.doLog("tsd = {0}", tsd); IBasicExtension config = TLMLineUtils.GetEffectiveExtensionForLine(GetLineID()); if (TransportSystem != m_lastSystem) { m_defaultAssets = tsd.GetTransportExtension().GetAllBasicAssetsForLine(0); UIPanel[] depotChecks = m_checkboxTemplateList.SetItemCount(m_defaultAssets.Count); TLMUtils.doLog("m_defaultAssets Size = {0} ({1})", m_defaultAssets?.Count, string.Join(",", m_defaultAssets.Keys?.ToArray() ?? new string[0])); for (int i = 0; i < m_defaultAssets.Count; i++) { string assetName = m_defaultAssets.Keys.ElementAt(i); UICheckBox checkbox = depotChecks[i].GetComponentInChildren <UICheckBox>(); checkbox.objectUserData = assetName; UITextField capacityEditor = depotChecks[i].GetComponentInChildren <UITextField>(); capacityEditor.text = VehicleUtils.GetCapacity(PrefabCollection <VehicleInfo> .FindLoaded(assetName)).ToString("0"); if (checkbox.label.objectUserData == null) { checkbox.eventCheckChanged += (x, y) => { if (m_isLoading) { return; } ushort lineId = GetLineID(); IBasicExtension extension = TLMLineUtils.GetEffectiveExtensionForLine(lineId); TLMUtils.doErrorLog($"checkbox event: {x.objectUserData} => {y} at {extension}[{lineId}]"); if (y) { extension.AddAssetToLine(lineId, x.objectUserData.ToString()); } else { extension.RemoveAssetFromLine(lineId, x.objectUserData.ToString()); } }; CreateModelCheckBox(checkbox); KlyteMonoUtils.LimitWidthAndBox(checkbox.label, 280); capacityEditor.eventTextSubmitted += CapacityEditor_eventTextSubmitted;; capacityEditor.eventMouseEnter += (x, y) => { m_lastInfo = PrefabCollection <VehicleInfo> .FindLoaded(checkbox.objectUserData.ToString()); RedrawModel(); }; checkbox.label.objectUserData = true; } checkbox.text = m_defaultAssets[assetName]; } m_lastSystem = TransportSystem; } else { List <string> allowedAssets = config.GetAssetListForLine(GetLineID()); for (int i = 0; i < m_checkboxTemplateList.items.Count; i++) { UICheckBox checkbox = m_checkboxTemplateList.items[i].GetComponentInChildren <UICheckBox>(); checkbox.isChecked = allowedAssets.Contains(checkbox.objectUserData.ToString()); } } if (TransportLinesManagerMod.DebugMode) { List <string> allowedAssets = config.GetAssetListForLine(GetLineID()); TLMUtils.doLog($"selectedAssets Size = {allowedAssets?.Count} ({ string.Join(",", allowedAssets?.ToArray() ?? new string[0])}) {config?.GetType()}"); } if (config is TLMTransportLineConfiguration) { m_title.text = string.Format(Locale.Get("K45_TLM_ASSET_SELECT_WINDOW_TITLE"), TLMLineUtils.getLineStringId(GetLineID())); } else { int prefix = (int)TLMLineUtils.getPrefix(GetLineID()); m_title.text = string.Format(Locale.Get("K45_TLM_ASSET_SELECT_WINDOW_TITLE_PREFIX"), prefix > 0 ? NumberingUtils.GetStringFromNumber(TLMUtils.GetStringOptionsForPrefix(tsd), prefix + 1) : Locale.Get("K45_TLM_UNPREFIXED"), TLMConfigWarehouse.getNameForTransportType(tsd.ToConfigIndex())); } m_isLoading = false; }