private void OnWarehouseChange(TLMConfigWarehouse.ConfigIndex idx, bool?newValueBool, int?newValueInt, string newValueString) { if (idx == (tsd.toConfigIndex() | TLMConfigWarehouse.ConfigIndex.PREFIX)) { ReloadPrefixOptions(); } }
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 static bool isLineNamingEnabled(this TLMConfigWarehouse.ConfigIndex idx) { switch (idx) { case TLMConfigWarehouse.ConfigIndex.ADDRESS_NAME_CONFIG: return(true); case TLMConfigWarehouse.ConfigIndex.RESIDENTIAL_SERVICE_CONFIG: case TLMConfigWarehouse.ConfigIndex.COMMERCIAL_SERVICE_CONFIG: case TLMConfigWarehouse.ConfigIndex.INDUSTRIAL_SERVICE_CONFIG: case TLMConfigWarehouse.ConfigIndex.NATURAL_SERVICE_CONFIG: case TLMConfigWarehouse.ConfigIndex.UNUSED2_SERVICE_CONFIG: case TLMConfigWarehouse.ConfigIndex.CITIZEN_SERVICE_CONFIG: case TLMConfigWarehouse.ConfigIndex.TOURISM_SERVICE_CONFIG: case TLMConfigWarehouse.ConfigIndex.OFFICE_SERVICE_CONFIG: case TLMConfigWarehouse.ConfigIndex.ROAD_SERVICE_CONFIG: case TLMConfigWarehouse.ConfigIndex.ELECTRICITY_SERVICE_CONFIG: case TLMConfigWarehouse.ConfigIndex.WATER_SERVICE_CONFIG: case TLMConfigWarehouse.ConfigIndex.BEAUTIFICATION_SERVICE_CONFIG: case TLMConfigWarehouse.ConfigIndex.GARBAGE_SERVICE_CONFIG: case TLMConfigWarehouse.ConfigIndex.HEALTHCARE_SERVICE_CONFIG: case TLMConfigWarehouse.ConfigIndex.POLICEDEPARTMENT_SERVICE_CONFIG: case TLMConfigWarehouse.ConfigIndex.EDUCATION_SERVICE_CONFIG: case TLMConfigWarehouse.ConfigIndex.MONUMENT_SERVICE_CONFIG: case TLMConfigWarehouse.ConfigIndex.FIREDEPARTMENT_SERVICE_CONFIG: case TLMConfigWarehouse.ConfigIndex.PUBLICTRANSPORT_SERVICE_CONFIG: case TLMConfigWarehouse.ConfigIndex.DISASTER_SERVICE_CONFIG: return(TLMConfigWarehouse.getCurrentConfigBool(TLMConfigWarehouse.ConfigIndex.USE_FOR_AUTO_NAMING_REF | idx)); case TLMConfigWarehouse.ConfigIndex.PLANE_CONFIG: case TLMConfigWarehouse.ConfigIndex.BUS_CONFIG: case TLMConfigWarehouse.ConfigIndex.METRO_CONFIG: case TLMConfigWarehouse.ConfigIndex.TRAIN_CONFIG: case TLMConfigWarehouse.ConfigIndex.TRAM_CONFIG: case TLMConfigWarehouse.ConfigIndex.CABLE_CAR_CONFIG: case TLMConfigWarehouse.ConfigIndex.MONORAIL_CONFIG: case TLMConfigWarehouse.ConfigIndex.BLIMP_CONFIG: case TLMConfigWarehouse.ConfigIndex.FERRY_CONFIG: case TLMConfigWarehouse.ConfigIndex.SHIP_CONFIG: case TLMConfigWarehouse.ConfigIndex.TAXI_CONFIG: case TLMConfigWarehouse.ConfigIndex.BALLOON_CONFIG: case TLMConfigWarehouse.ConfigIndex.TOUR_BUS_CONFIG: case TLMConfigWarehouse.ConfigIndex.TOUR_PED_CONFIG: return(TLMConfigWarehouse.getCurrentConfigBool(TLMConfigWarehouse.ConfigIndex.PUBLICTRANSPORT_USE_FOR_AUTO_NAMING_REF | idx)); default: return(false); } }
private void loadPrefixes(int sel) { if (sel == 0) { m_prefixSelection.isVisible = false; m_prefixSelection.selectedIndex = 0; m_StripAsteriskTab.tabPages.enabled = false; return; } m_prefixSelection.isVisible = true; m_StripAsteriskTab.tabPages.enabled = false; TLMConfigWarehouse.ConfigIndex transportIndex = getConfigIndexFromDropDownSelection(sel); m_defaultAssets.itemsList = getBasicAssetListFromDropDownSelection(m_systemTypeDropDown.selectedIndex); m_defaultAssets.root.color = TLMConfigWarehouse.getColorForTransportType(transportIndex); var m = (ModoNomenclatura)TLMConfigWarehouse.getCurrentConfigInt(transportIndex | TLMConfigWarehouse.ConfigIndex.PREFIX); m_prefixSelection.items = TLMUtils.getStringOptionsForPrefix(m, true, transportIndex); m_prefixSelection.selectedIndex = 0; }
public Dictionary <uint, Dictionary <T, string> > LoadConfig(TLMConfigWarehouse.ConfigIndex idx, bool global = false) { var result = new Dictionary <uint, Dictionary <T, string> >(); if (TLMSingleton.instance != null && TLMSingleton.debugMode) { TLMUtils.doLog("{0} load()", idx); } string[] itemListLvl1; if (global && !AllowGlobal) { throw new Exception("CONFIGURAÇÂO NÃO GLOBAL TENTOU SER CARREGADA COMO GLOBAL: " + typeof(U)); } if (global) { itemListLvl1 = TLMConfigWarehouse.getConfig().getString(idx).Split(ItSepLvl1.ToCharArray()); } else { itemListLvl1 = TLMConfigWarehouse.getCurrentConfigString(idx).Split(ItSepLvl1.ToCharArray()); } if (itemListLvl1.Length > 0) { if (TLMSingleton.instance != null && TLMSingleton.debugMode) { TLMUtils.doLog("{0} load(): file.Length > 0", idx); } foreach (string s in itemListLvl1) { uint key = GetIndexFromStringArray(s); var value = GetValueFromStringArray(s); result[key] = value; } if (TLMSingleton.instance != null && TLMSingleton.debugMode) { TLMUtils.doLog("{0} load(): dic done", idx); } result.Remove(~0u); } return(result); }
protected void SaveConfig(Dictionary <uint, Dictionary <T, string> > target, TLMConfigWarehouse.ConfigIndex idx, bool global = false) { TLMConfigWarehouse loadedConfig; if (global && !AllowGlobal) { throw new Exception("CONFIGURAÇÂO NÃO GLOBAL TENTOU SER SALVA COMO GLOBAL: " + typeof(U)); } if (global) { loadedConfig = TLMConfigWarehouse.getConfig(TLMConfigWarehouse.GLOBAL_CONFIG_INDEX, TLMConfigWarehouse.GLOBAL_CONFIG_INDEX); } else { loadedConfig = TLMSingleton.instance.currentLoadedCityConfig; } var value = RecursiveEncode(target); if (TLMSingleton.instance != null && TLMSingleton.debugMode) { TLMUtils.doLog("saveConfig ({0}) NEW VALUE: {1}", idx, value); } loadedConfig.setString(idx, value); }
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]); }
internal UIDropDown generateDropdownEnumStringValueConfig <T>(UIHelperExtension group, string title, string[] options, TLMConfigWarehouse.ConfigIndex configIndex) where T : struct, IConvertible { int currentValue; try { currentValue = (int)Enum.Parse(typeof(T), currentConfigWarehouseEditor.GetString(configIndex)); } catch { currentValue = 0; } dropDowns[configIndex] = group.AddDropdown(title, options, currentValue, delegate(int i) { if (!isLoading && i >= 0) { currentConfigWarehouseEditor.SetString(configIndex, Enum.GetNames(typeof(T))[i]); } }, true); return(dropDowns[configIndex]); }
internal UITextField generateTextFieldConfig(UIHelperExtension group, string title, TLMConfigWarehouse.ConfigIndex configIndex) { textFields[configIndex] = group.AddTextField(title, delegate(string s) { if (!isLoading) { currentConfigWarehouseEditor.SetString(configIndex, s); } }, currentConfigWarehouseEditor.GetString(configIndex)); return(textFields[configIndex]); }
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; }
private UITextField generateTextFieldConfig(UIHelperExtension group, string title, TLMConfigWarehouse.ConfigIndex configIndex) { textFields[configIndex] = group.AddTextField(title, delegate(string s) { currentConfigWarehouseEditor.setString(configIndex, s); }, currentConfigWarehouseEditor.getString(configIndex)); return(textFields[configIndex]); }
private UIDropDown generateDropdownStringValueConfig(UIHelperExtension group, string title, string[] options, TLMConfigWarehouse.ConfigIndex configIndex) { dropDowns[configIndex] = group.AddDropdown(title, options, currentConfigWarehouseEditor.getString(configIndex), delegate(int i) { currentConfigWarehouseEditor.setString(configIndex, options[i]); }); return(dropDowns[configIndex]); }
private UICheckBox generateCheckboxConfig(UIHelperExtension group, string title, TLMConfigWarehouse.ConfigIndex configIndex) { checkBoxes[configIndex] = (UICheckBox)group.AddCheckbox(title, currentConfigWarehouseEditor.getBool(configIndex), delegate(bool b) { currentConfigWarehouseEditor.setBool(configIndex, b); }); return(checkBoxes[configIndex]); }
internal UIDropDown generateDropdownStringValueConfig(UIHelperExtension group, string title, string[] options, TLMConfigWarehouse.ConfigIndex configIndex) { dropDowns[configIndex] = group.AddDropdown(title, options, currentConfigWarehouseEditor.GetString(configIndex), delegate(int i) { if (!isLoading) { currentConfigWarehouseEditor.SetString(configIndex, options[i]); } }, true); return(dropDowns[configIndex]); }
public static uint getPriority(this TLMConfigWarehouse.ConfigIndex idx) { uint saida; switch (idx) { case TLMConfigWarehouse.ConfigIndex.ADDRESS_NAME_CONFIG: return((uint)TLMConfigWarehouse.namingOrder.Length); case TLMConfigWarehouse.ConfigIndex.RESIDENTIAL_SERVICE_CONFIG: case TLMConfigWarehouse.ConfigIndex.COMMERCIAL_SERVICE_CONFIG: case TLMConfigWarehouse.ConfigIndex.INDUSTRIAL_SERVICE_CONFIG: case TLMConfigWarehouse.ConfigIndex.NATURAL_SERVICE_CONFIG: case TLMConfigWarehouse.ConfigIndex.UNUSED2_SERVICE_CONFIG: case TLMConfigWarehouse.ConfigIndex.CITIZEN_SERVICE_CONFIG: case TLMConfigWarehouse.ConfigIndex.TOURISM_SERVICE_CONFIG: case TLMConfigWarehouse.ConfigIndex.OFFICE_SERVICE_CONFIG: case TLMConfigWarehouse.ConfigIndex.ROAD_SERVICE_CONFIG: case TLMConfigWarehouse.ConfigIndex.ELECTRICITY_SERVICE_CONFIG: case TLMConfigWarehouse.ConfigIndex.WATER_SERVICE_CONFIG: case TLMConfigWarehouse.ConfigIndex.BEAUTIFICATION_SERVICE_CONFIG: case TLMConfigWarehouse.ConfigIndex.GARBAGE_SERVICE_CONFIG: case TLMConfigWarehouse.ConfigIndex.HEALTHCARE_SERVICE_CONFIG: case TLMConfigWarehouse.ConfigIndex.POLICEDEPARTMENT_SERVICE_CONFIG: case TLMConfigWarehouse.ConfigIndex.EDUCATION_SERVICE_CONFIG: case TLMConfigWarehouse.ConfigIndex.MONUMENT_SERVICE_CONFIG: case TLMConfigWarehouse.ConfigIndex.FIREDEPARTMENT_SERVICE_CONFIG: case TLMConfigWarehouse.ConfigIndex.PUBLICTRANSPORT_SERVICE_CONFIG: case TLMConfigWarehouse.ConfigIndex.DISASTER_SERVICE_CONFIG: saida = TLMConfigWarehouse.getCurrentConfigBool(TLMConfigWarehouse.ConfigIndex.USE_FOR_AUTO_NAMING_REF | idx) ? (uint)Array.IndexOf(TLMConfigWarehouse.namingOrder, idx) : uint.MaxValue; break; case TLMConfigWarehouse.ConfigIndex.PLANE_CONFIG: case TLMConfigWarehouse.ConfigIndex.SHIP_CONFIG: saida = TLMConfigWarehouse.getCurrentConfigBool(TLMConfigWarehouse.ConfigIndex.PUBLICTRANSPORT_USE_FOR_AUTO_NAMING_REF | idx) ? (uint)Array.IndexOf(TLMConfigWarehouse.namingOrder, idx) : uint.MaxValue; break; case TLMConfigWarehouse.ConfigIndex.TAXI_CONFIG: case TLMConfigWarehouse.ConfigIndex.CABLE_CAR_CONFIG: case TLMConfigWarehouse.ConfigIndex.MONORAIL_CONFIG: case TLMConfigWarehouse.ConfigIndex.FERRY_CONFIG: case TLMConfigWarehouse.ConfigIndex.BLIMP_CONFIG: case TLMConfigWarehouse.ConfigIndex.BUS_CONFIG: case TLMConfigWarehouse.ConfigIndex.METRO_CONFIG: case TLMConfigWarehouse.ConfigIndex.TRAIN_CONFIG: case TLMConfigWarehouse.ConfigIndex.TRAM_CONFIG: case TLMConfigWarehouse.ConfigIndex.BALLOON_CONFIG: case TLMConfigWarehouse.ConfigIndex.TOUR_BUS_CONFIG: case TLMConfigWarehouse.ConfigIndex.TOUR_PED_CONFIG: saida = TLMConfigWarehouse.getCurrentConfigBool(TLMConfigWarehouse.ConfigIndex.PUBLICTRANSPORT_USE_FOR_AUTO_NAMING_REF | idx) ? 3 : uint.MaxValue; break; default: saida = uint.MaxValue; break; } if (TLMSingleton.instance != null && TLMSingleton.debugMode) { TLMUtils.doLog("ConfigIndex.getPriority(): {0} ==> {1}", idx.ToString(), saida); } return(saida); }
private UITextField generateNumberFieldConfig(UIHelperExtension group, string title, TLMConfigWarehouse.ConfigIndex configIndex) { textFields[configIndex] = group.AddTextField(title, delegate(string s) { if (int.TryParse(s, out int val)) { currentConfigWarehouseEditor.setInt(configIndex, val); } }, currentConfigWarehouseEditor.getInt(configIndex).ToString()); textFields[configIndex].numericalOnly = true; return(textFields[configIndex]); }