private Vector2 getFreeHorizontal(Vector2 p1, Vector2 p2) { TLMUtils.doLog("------------------------------------------------"); if (p1.y != p2.y) { return(p2); } int targetX = (int)p2.x; TLMUtils.doLog("getFreeHorizontal idx: {0} hRanges.ContainsKey(index)={1}; p1={2}; p2={3}", (int)p2.y, hRanges.ContainsKey((int)p2.y), p1, p2); if (hRanges.ContainsKey((int)p2.y)) { Range <int> lineXs = new Range <int>((int)Math.Min(p1.x, p2.x), (int)Math.Max(p1.x, p2.x)); var searchResult = hRanges[(int)p2.y].FindAll(x => x.IntersectRange(lineXs)); TLMUtils.doLog(" getFreeHorizontal idx: {0}; X={1};LIST = [{3}] ; SRC = {2}", (int)p2.y, lineXs, searchResult.Count, string.Join(",", hRanges[(int)p2.y].Select(x => x.ToString()).ToArray())); if (searchResult.Count > 0) { if (Math.Sign((p2.x - p1.x)) > 0) { targetX = Math.Max(searchResult.Select(x => x.Minimum - 1).Max(), (int)p1.x); } else { targetX = Math.Min(searchResult.Select(x => x.Maximum + 1).Min(), (int)p1.x); } } } TLMUtils.doLog(" getFreeHorizontal RESULT=({0}, {1})", targetX, p2.y); TLMUtils.doLog("------------------------------------------------"); return(new Vector2(targetX, p2.y)); }
private void CreateColorSelector() { TLMUtils.createUIElement(out UIPanel panelColorSelector, m_subpanel.self.transform, "ColorSelector", new Vector4(500, 60, 0, 0)); panelColorSelector.autoLayout = true; panelColorSelector.autoLayoutDirection = LayoutDirection.Horizontal; panelColorSelector.autoLayoutPadding = new RectOffset(3, 3, 0, 0); panelColorSelector.autoFitChildrenHorizontally = true; panelColorSelector.autoFitChildrenVertically = true; TLMUtils.createUIElement(out UILabel lbl, panelColorSelector.transform, "PrefixColorLabel", new Vector4(5, 12, 250, 40)); TLMUtils.LimitWidth(lbl, 250, true); lbl.localeID = "TLM_PREFIX_COLOR_LABEL"; lbl.verticalAlignment = UIVerticalAlignment.Middle; lbl.font = UIHelperExtension.defaultFontCheckbox; m_prefixColor = KlyteUtils.CreateColorField(panelColorSelector); m_prefixColor.eventSelectedColorChanged += onChangePrefixColor; TLMUtils.createUIElement(out UIButton resetColor, panelColorSelector.transform, "PrefixColorReset", new Vector4(290, 0, 0, 0)); TLMUtils.initButton(resetColor, false, "ButtonMenu"); TLMUtils.LimitWidth(resetColor, 200); resetColor.textPadding = new RectOffset(5, 5, 5, 2); resetColor.autoSize = true; resetColor.localeID = "TLM_RESET_COLOR"; resetColor.eventClick += onResetColor; }
public static void doAutomation(ushort lineID, TransportLine.Flags __state) { TLMUtils.doLog("OLD: " + __state + " ||| NEW: " + Singleton <TransportManager> .instance.m_lines.m_buffer[lineID].m_flags); if (lineID > 0 && (__state & TransportLine.Flags.Complete) == TransportLine.Flags.None && (__state & TransportLine.Flags.Temporary) == TransportLine.Flags.None) { if ((Singleton <TransportManager> .instance.m_lines.m_buffer[lineID].m_flags & TransportLine.Flags.Complete) != TransportLine.Flags.None && (Singleton <TransportManager> .instance.m_lines.m_buffer[lineID].m_flags & (TransportLine.Flags.Temporary)) == TransportLine.Flags.None) { if (TLMConfigWarehouse.getCurrentConfigBool(TLMConfigWarehouse.ConfigIndex.AUTO_COLOR_ENABLED)) { TLMController.instance.AutoColor(lineID); } if (TLMConfigWarehouse.getCurrentConfigBool(TLMConfigWarehouse.ConfigIndex.AUTO_NAME_ENABLED)) { TLMController.instance.AutoName(lineID); } TLMController.instance.LineCreationToolbox.incrementNumber(); TLMTransportLineExtension.instance.SafeCleanEntry(lineID); } } if ((Singleton <TransportManager> .instance.m_lines.m_buffer[lineID].m_flags & TransportLine.Flags.Complete) == TransportLine.Flags.None && (Singleton <TransportManager> .instance.m_lines.m_buffer[lineID].m_flags & TransportLine.Flags.CustomColor) != TransportLine.Flags.None ) { Singleton <TransportManager> .instance.m_lines.m_buffer[lineID].m_flags &= ~TransportLine.Flags.CustomColor; } }
public VehicleInfo getRandomModel(uint prefix) { var assetList = getAssetListForPrefix(prefix); if (assetList.Count == 0) { return(null); } Randomizer r = new Randomizer(new System.Random().Next()); if (TransportLinesManagerMod.instance != null && TransportLinesManagerMod.debugMode) { TLMUtils.doLog("POSSIBLE VALUES FOR {2} PREFIX {1}: {0} ", string.Join(",", assetList.ToArray()), prefix, definition.ToString()); } string model = assetList[r.Int32(0, assetList.Count - 1)]; if (TransportLinesManagerMod.instance != null && TransportLinesManagerMod.debugMode) { TLMUtils.doLog("MODEL FOR {2} PREFIX {1}: {0} ", model, prefix, definition.ToString()); } var saida = PrefabCollection <VehicleInfo> .FindLoaded(model); if (saida == null) { if (TransportLinesManagerMod.instance != null && TransportLinesManagerMod.debugMode) { TLMUtils.doLog("MODEL DOESN'T EXIST!"); } removeAssetFromPrefixList(prefix, model); return(getRandomModel(prefix)); } return(saida); }
private void CreateMainPanel() { TLMUtils.createUIElement(out m_mainPanel, m_parent.transform); m_mainPanel.Hide(); m_mainPanel.relativePosition = new Vector3(m_parent.width, 0.0f); m_mainPanel.width = 250; m_mainPanel.height = m_parent.height; m_mainPanel.zOrder = 50; m_mainPanel.color = new Color32(255, 255, 255, 255); m_mainPanel.backgroundSprite = "MenuPanel2"; m_mainPanel.name = "AssetSelectorWindow"; m_mainPanel.autoLayoutPadding = new RectOffset(5, 5, 10, 10); m_mainPanel.autoLayout = false; m_mainPanel.useCenter = true; m_mainPanel.wrapLayout = false; m_mainPanel.canFocus = true; TLMUtils.createDragHandle(m_mainPanel, m_mainPanel, 35f); m_parent.eventVisibilityChanged += (component, value) => { m_mainPanel.isVisible = value; }; TLMUtils.createUIElement(out m_title, m_mainPanel.transform); m_title.textAlignment = UIHorizontalAlignment.Center; m_title.autoSize = false; m_title.autoHeight = true; m_title.width = m_mainPanel.width - 30f; m_title.relativePosition = new Vector3(5, 5); m_title.textScale = 0.9f; }
private void loadPrefixConfigList(bool global, bool force = false) { if (cached_prefixConfigList == null || globalLoaded != global) { if (TransportLinesManagerMod.instance != null && TransportLinesManagerMod.debugMode) { TLMUtils.doLog("loadSubcategoryList: pre loadAuxiliarVars"); } loadAuxiliarVars(global, force); if (TransportLinesManagerMod.instance != null && TransportLinesManagerMod.debugMode) { TLMUtils.doLog("loadSubcategoryList: pos loadAuxiliarVars"); } if (global) { cached_prefixConfigList = cached_prefixConfigListGlobal; } else { cached_prefixConfigList = cached_prefixConfigListNonGlobal; } globalLoaded = global; } }
public uint[] getBudgetsMultiplier(uint prefix, bool global = false) { loadPrefixConfigList(global); if (needReload) { readVehicles(global); if (needReload) { return new uint[] { 100 } } ; } if (cached_prefixConfigList.ContainsKey(prefix) && cached_prefixConfigList[prefix].ContainsKey(PrefixConfigIndex.BUDGET_MULTIPLIER)) { string[] savedMultipliers = cached_prefixConfigList[prefix][PrefixConfigIndex.BUDGET_MULTIPLIER].Split(PROPERTY_VALUE_COMMA.ToCharArray()); uint[] result = new uint[savedMultipliers.Length]; for (int i = 0; i < result.Length; i++) { uint parsed; if (uint.TryParse(savedMultipliers[i], out parsed)) { result[i] = parsed; } else { return(new uint[] { 100 }); } } TLMUtils.doLog("LENGTH SIZE BG PFX= {0}", result.Length); return(result); } return(new uint[] { 100 }); }
public uint getTicketPrice(uint prefix, bool global = false) { loadPrefixConfigList(global); if (needReload) { readVehicles(global); if (needReload) { if (TransportLinesManagerMod.instance != null && TransportLinesManagerMod.debugMode) { TLMUtils.doLog("getTicketPrice: RELOAD FAILED!"); } return(100); } } if (cached_prefixConfigList.ContainsKey(prefix) && cached_prefixConfigList[prefix].ContainsKey(PrefixConfigIndex.TICKET_PRICE)) { uint result; if (uint.TryParse(cached_prefixConfigList[prefix][PrefixConfigIndex.TICKET_PRICE], out result)) { return(result); } } return(getDefaultTicketPrice()); }
public void setTicketPrice(uint prefix, uint price, bool global = false) { if (TransportLinesManagerMod.instance != null && TransportLinesManagerMod.debugMode) { TLMUtils.doLog("setTicketPrice! {0} {1} {2} {3}", definition.ToString(), prefix, price, global); } loadPrefixConfigList(global); if (needReload) { readVehicles(global); if (needReload) { if (TransportLinesManagerMod.instance != null && TransportLinesManagerMod.debugMode) { TLMUtils.doLog("setTicketPrice: RELOAD FAILED!"); } return; } } if (!cached_prefixConfigList.ContainsKey(prefix)) { cached_prefixConfigList[prefix] = new Dictionary <PrefixConfigIndex, string>(); } cached_prefixConfigList[prefix][PrefixConfigIndex.TICKET_PRICE] = price.ToString(); saveSubcategoryList(global); }
public void Awake() { #region Automation Hooks MethodInfo onEnable = typeof(TransportToolOverrides).GetMethod("OnEnable", allFlags); MethodInfo onDisable = typeof(TransportToolOverrides).GetMethod("OnDisable", allFlags); MethodInfo AfterEveryAction = typeof(TransportToolOverrides).GetMethod("AfterEveryAction", allFlags); MethodInfo AfterEveryActionZeroable = typeof(TransportToolOverrides).GetMethod("AfterEveryActionZeroable", allFlags); TLMUtils.doLog($"Loading TransportToolOverrides Hook"); try { var tt = new TransportTool(); RedirectorInstance.AddRedirect(typeof(TransportTool).GetMethod("OnEnable", allFlags), onEnable); RedirectorInstance.AddRedirect(typeof(TransportTool).GetMethod("OnDisable", allFlags), onDisable); RedirectorInstance.AddRedirect(typeof(TransportTool).GetMethod("NewLine", allFlags).Invoke(tt, new object[0]).GetType().GetMethod("MoveNext", RedirectorUtils.allFlags), AfterEveryAction); RedirectorInstance.AddRedirect(typeof(TransportTool).GetMethod("AddStop", allFlags).Invoke(tt, new object[0]).GetType().GetMethod("MoveNext", RedirectorUtils.allFlags), AfterEveryAction); RedirectorInstance.AddRedirect(typeof(TransportTool).GetMethod("RemoveStop", allFlags).Invoke(tt, new object[0]).GetType().GetMethod("MoveNext", RedirectorUtils.allFlags), AfterEveryActionZeroable); RedirectorInstance.AddRedirect(typeof(TransportTool).GetMethod("CancelPrevStop", allFlags).Invoke(tt, new object[0]).GetType().GetMethod("MoveNext", RedirectorUtils.allFlags), AfterEveryActionZeroable); RedirectorInstance.AddRedirect(typeof(TransportTool).GetMethod("CancelMoveStop", allFlags).Invoke(tt, new object[0]).GetType().GetMethod("MoveNext", RedirectorUtils.allFlags), AfterEveryActionZeroable); RedirectorInstance.AddRedirect(typeof(TransportTool).GetMethod("MoveStop", allFlags).Invoke(tt, new object[] { false }).GetType().GetMethod("MoveNext", RedirectorUtils.allFlags), AfterEveryAction); Destroy(tt); } catch (Exception e) { TLMUtils.doErrorLog("ERRO AO CARREGAR HOOKS: {0}\n{1}", e.Message, e.StackTrace); } #endregion }
public void setBudgetMultiplier(uint prefix, uint[] multipliers, bool global = false) { if (TransportLinesManagerMod.instance != null && TransportLinesManagerMod.debugMode) { TLMUtils.doLog("setBudgetMultiplier! {0} {1} {2} {3}", definition.ToString(), prefix, multipliers, global); } loadPrefixConfigList(global); if (needReload) { readVehicles(global); if (needReload) { if (TransportLinesManagerMod.instance != null && TransportLinesManagerMod.debugMode) { TLMUtils.doLog("getTicketPrice: RELOAD FAILED!"); } return; } } if (!cached_prefixConfigList.ContainsKey(prefix)) { cached_prefixConfigList[prefix] = new Dictionary <PrefixConfigIndex, string>(); } cached_prefixConfigList[prefix][PrefixConfigIndex.BUDGET_MULTIPLIER] = string.Join(PROPERTY_VALUE_COMMA, multipliers.Select(x => x.ToString()).ToArray()); saveSubcategoryList(global); }
protected Dictionary <T, string> GetValueFromStringArray(string x) { string[] array = x.Split(KvSepLvl1.ToCharArray()); var saida = new Dictionary <T, string>(); if (array.Length != 2) { return(saida); } var value = array[1]; foreach (string item in value.Split(ItSepLvl2.ToCharArray())) { var kv = item.Split(KvSepLvl2.ToCharArray()); if (kv.Length != 2) { continue; } try { T subkey = (T)Enum.Parse(typeof(T), kv[0]); saida[subkey] = kv[1]; } catch (Exception e) { TLMUtils.doLog("ERRO AO OBTER VALOR STR ARR: {0}\r\n{1}", e.Message, e.StackTrace); continue; } } return(saida); }
private Vector2 getFreeD2Point(Vector2 p1, Vector2 p2) { if (p1.x - p1.y != p2.x - p2.y) { return(p2); } int targetX = (int)p2.x; int index = (int)(p2.x - p2.y); TLMUtils.doLog(" getFreeHorizontalD2Point idx: {0} d2Ranges.ContainsKey(index)={1}", index, d2Ranges.ContainsKey(index)); if (d2Ranges.ContainsKey(index)) { Range <int> lineXs = new Range <int>((int)Math.Min(p1.x, p2.x), (int)Math.Max(p1.x, p2.x)); var searchResult = d2Ranges[index].FindAll(x => x.IntersectRange(lineXs)); TLMUtils.doLog(" getFreeHorizontalD2Point idx: {0}; X={1};LIST = [{3}] ; SRC = {2}", index, lineXs, searchResult.Count, string.Join(",", d2Ranges[index].Select(x => x.ToString()).ToArray())); if (searchResult.Count > 0) { if (Math.Sign((p2.x - p1.x)) > 0) { targetX = Math.Max(searchResult.Select(x => x.Minimum - 1).Max(), (int)p1.x); } else { targetX = Math.Min(searchResult.Select(x => x.Maximum + 1).Min(), (int)p1.x); } } } return(new Vector2(targetX, targetX - index)); }
private Vector2 getFreeVertical(Vector2 p1, Vector2 p2) { if (p1.x != p2.x) { return(p2); } int targetY = (int)p2.y; TLMUtils.doLog("------------------------------------------------"); TLMUtils.doLog(" getFreeVertical idx: {0} vRanges.ContainsKey(index)={1}; p1={2}; p2={3}", (int)p2.x, vRanges.ContainsKey((int)p2.x), p1, p2); if (vRanges.ContainsKey((int)p2.x)) { Range <int> lineYs = new Range <int>((int)Math.Min(p1.y, p2.y), (int)Math.Max(p1.y, p2.y)); var searchResult = vRanges[(int)p2.x].FindAll(x => x.IntersectRange(lineYs)); TLMUtils.doLog(" getFreeVertical idx: {0}; X={1};LIST = [{3}] ; SRC = {2}", (int)p2.x, lineYs, searchResult.Count, string.Join(",", vRanges[(int)p2.x].Select(x => x.ToString()).ToArray())); if (searchResult.Count > 0) { if (Math.Sign((p2.y - p1.y)) > 0) { targetY = Math.Max(searchResult.Select(x => x.Minimum - 1).Max(), (int)p1.y); } else { targetY = Math.Min(searchResult.Select(x => x.Maximum + 1).Min(), (int)p1.y); } } } TLMUtils.doLog(" getFreeVertical RESULT=({1}, {0})", targetY, p2.x); TLMUtils.doLog("------------------------------------------------"); return(new Vector2(p2.x, targetY)); }
public static AutoColorPalette parseFromString(string data) { string[] parts = data.Split(SERIALIZER_SEPARATOR); if (parts.Length <= 1) { return(null); } string name = parts[0]; List <Color32> colors = new List <Color32>(parts.Length - 1); for (int i = 1; i < parts.Length; i++) { string thisColor = parts[i]; string[] thisColorCompounds = thisColor.Split(COLOR_COMP_SEPARATOR); if (thisColorCompounds.Length != 3) { TLMUtils.doErrorLog("[TLM Palette '" + name + "'] Corrupted serialized color: " + thisColor); return(null); } bool success = byte.TryParse(thisColorCompounds[0], out byte r); success &= byte.TryParse(thisColorCompounds[1], out byte g); success &= byte.TryParse(thisColorCompounds[2], out byte b); if (!success) { TLMUtils.doErrorLog("[TLM Palette '" + name + "'] Corrupted serialized color: invalid number in " + thisColor); return(null); } colors.Add(new Color32(r, g, b, 255)); } return(new AutoColorPalette(name, colors)); }
private void criaFatiaELegenda(Color c, UIRadialChartAge chart, UIPanel legendPanel, string localeID, float offsetY) { chart.AddSlice(c, c); UIPanel legendItemContainer = null; TLMUtils.createUIElement <UIPanel>(ref legendItemContainer, legendPanel.transform); legendItemContainer.width = legendPanel.width; legendItemContainer.relativePosition = new Vector3(0f, offsetY); legendItemContainer.name = "LegendItem"; legendItemContainer.autoLayout = false; legendItemContainer.useCenter = true; legendItemContainer.wrapLayout = false; legendItemContainer.height = 20; UILabel legendColor = null; TLMUtils.createUIElement <UILabel>(ref legendColor, legendItemContainer.transform); legendColor.backgroundSprite = "EmptySprite"; legendColor.width = 10; legendColor.height = 10; legendColor.relativePosition = new Vector3(0, 0); legendColor.color = c; UILabel legendName = null; TLMUtils.createUIElement <UILabel>(ref legendName, legendItemContainer.transform); legendName.textAlignment = UIHorizontalAlignment.Right; legendName.width = legendItemContainer.width - 10; legendName.localeID = localeID; legendName.textScale = 0.6f; legendName.relativePosition = new Vector3(15f, 2f); legendName.verticalAlignment = UIVerticalAlignment.Middle; }
private static void OnDisable() { TLMUtils.doLog("OnDisableTransportTool"); TLMController.instance.setCurrentSelectedId(0); TLMController.instance.LinearMapCreatingLine?.setVisible(false); TLMController.instance.LineCreationToolbox?.setVisible(false); }
private void CreateTitleRowBuilding(ref UIPanel titleLine, UIComponent parent) { TLMUtils.createUIElement(out titleLine, parent.transform, "TLMtitleline", new Vector4(5, 80, parent.width - 10, 40)); TLMUtils.createUIElement(out UILabel districtNameLabel, titleLine.transform, "districtNameLabel"); districtNameLabel.autoSize = false; districtNameLabel.area = new Vector4(0, 10, 175, 18); districtNameLabel.textAlignment = UIHorizontalAlignment.Center; districtNameLabel.text = Locale.Get("TUTORIAL_ADVISER_TITLE", "District"); TLMUtils.createUIElement(out UILabel buildingNameLabel, titleLine.transform, "buildingNameLabel"); buildingNameLabel.autoSize = false; buildingNameLabel.area = new Vector4(200, 10, 198, 18); buildingNameLabel.textAlignment = UIHorizontalAlignment.Center; buildingNameLabel.text = Locale.Get("TLM_BUILDING_NAME_LABEL"); TLMUtils.createUIElement(out UILabel vehicleCapacityLabel, titleLine.transform, "vehicleCapacityLabel"); vehicleCapacityLabel.autoSize = false; vehicleCapacityLabel.area = new Vector4(400, 10, 200, 18); vehicleCapacityLabel.textAlignment = UIHorizontalAlignment.Center; vehicleCapacityLabel.text = Locale.Get("TLM_VEHICLE_CAPACITY_LABEL"); TLMUtils.createUIElement(out m_directionLabel, titleLine.transform, "directionLabel"); m_directionLabel.autoSize = false; m_directionLabel.area = new Vector4(600, 10, 200, 18); m_directionLabel.textAlignment = UIHorizontalAlignment.Center; m_directionLabel.text = Locale.Get("TLM_DIRECTION_LABEL"); }
private void saveSubcategoryList(bool global) { if (global == globalLoaded) { TLMConfigWarehouse loadedConfig; if (global) { loadedConfig = TLMConfigWarehouse.getConfig(TLMConfigWarehouse.GLOBAL_CONFIG_INDEX, TLMConfigWarehouse.GLOBAL_CONFIG_INDEX); } else { loadedConfig = TransportLinesManagerMod.instance.currentLoadedCityConfig; } var value = string.Join(PREFIX_COMMA, cached_prefixConfigList.Select(x => x.Key.ToString() + PREFIX_SEPARATOR + string.Join(PROPERTY_COMMA, x.Value.Select(y => y.Key.ToString() + PROPERTY_SEPARATOR + y.Value).ToArray())).ToArray()); if (TransportLinesManagerMod.instance != null && TransportLinesManagerMod.debugMode) { TLMUtils.doLog("NEW VALUE ({0}): {1}", definition.ToString(), value); } loadedConfig.setString(configKeyForAssets, value); if (global) { cached_prefixConfigListGlobal = cached_prefixConfigList; } else { cached_prefixConfigListNonGlobal = cached_prefixConfigList; } } else { TLMUtils.doErrorLog("Trying to save a different global file subcategory list!!!"); } }
internal void doOnLevelLoad(LoadMode mode) { TLMUtils.doLog("LEVEL LOAD"); if (mode != LoadMode.LoadGame && mode != LoadMode.NewGame && mode != LoadMode.NewGameFromScenario) { TLMUtils.doLog("NOT GAME ({0})", mode); return; } if (TLMController.taTLM == null) { TLMController.taTLM = CreateTextureAtlas("UI.Images.sprites.png", "TransportLinesManagerSprites", GameObject.FindObjectOfType <UIView>().FindUIComponent <UIPanel>("InfoPanel").atlas.material, 64, 64, new string[] { "TransportLinesManagerIcon", "TransportLinesManagerIconHovered", "AutoNameIcon", "AutoColorIcon", "RemoveUnwantedIcon", "ConfigIcon", "24hLineIcon", "PerHourIcon" }); } if (TLMController.taLineNumber == null) { TLMController.taLineNumber = CreateTextureAtlas("UI.Images.lineFormat.png", "TransportLinesManagerLinearLineSprites", GameObject.FindObjectOfType <UIView>().FindUIComponent <UIPanel>("InfoPanel").atlas.material, 64, 64, new string[] { "EvacBusIcon", "DepotIcon", "LinearHalfStation", "LinearStation", "LinearBg", "PlaneLineIcon", "TramIcon", "ShipLineIcon", "FerryIcon", "CableCarIcon", "BlimpIcon", "BusIcon", "SubwayIcon", "TrainIcon", "MonorailIcon", "ShipIcon", "AirplaneIcon", "TaxiIcon", "DayIcon", "NightIcon", "DisabledIcon", "NoBudgetIcon", "BulletTrainImage", "LowBusImage", "HighBusImage", "VehicleLinearMap", "RegionalTrainIcon" }); } Assembly asm = Assembly.GetAssembly(typeof(TLMSingleton)); Type[] types = asm.GetTypes(); TLMController.instance.Awake(); }
public void removeAssetFromPrefixList(uint prefix, string assetId, bool global = false) { loadPrefixConfigList(global); if (TransportLinesManagerMod.instance != null && TransportLinesManagerMod.debugMode) { TLMUtils.doLog("removeAssetFromPrefixList: {0} => {1}", assetId, prefix); } List <string> temp; if (!cached_prefixConfigList.ContainsKey(prefix)) { cached_prefixConfigList[prefix] = new Dictionary <PrefixConfigIndex, string>(); cached_prefixConfigList[prefix][PrefixConfigIndex.MODELS] = ""; temp = getAssetListForPrefix(0, global); } else { temp = cached_prefixConfigList[prefix][PrefixConfigIndex.MODELS].Split(PROPERTY_VALUE_COMMA.ToCharArray()).ToList(); } if (!temp.Contains(assetId)) { return; } temp.Remove(assetId); cached_prefixConfigList[prefix][PrefixConfigIndex.MODELS] = string.Join(PROPERTY_VALUE_COMMA, temp.ToArray()); saveSubcategoryList(global); readVehicles(global); }
private void reloadData(int selection) { if (TLMSingleton.instance != null && TLMSingleton.debugMode) { TLMUtils.doLog("OPÇÔES RECARREGANDO ARQUIVO", currentSelectedConfigEditor); } foreach (var i in dropDowns) { if (TLMSingleton.instance != null && TLMSingleton.debugMode) { TLMUtils.doLog("OPÇÔES RECARREGANDO {0}", i); } try { switch (i.Key & TLMConfigWarehouse.ConfigIndex.TYPE_PART) { case TLMConfigWarehouse.ConfigIndex.TYPE_INT: i.Value.selectedIndex = currentConfigWarehouseEditor.getInt(i.Key); break; case TLMConfigWarehouse.ConfigIndex.TYPE_STRING: int selectedIndex = i.Value.items.ToList().IndexOf(currentConfigWarehouseEditor.getString(i.Key)); i.Value.selectedIndex = Math.Max(selectedIndex, 0); break; default: if (TLMSingleton.instance != null && TLMSingleton.debugMode) { TLMUtils.doLog("TIPO INVÁLIDO!", i); } break; } } #pragma warning disable CS0168 // Variable is declared but never used catch (Exception e) #pragma warning restore CS0168 // Variable is declared but never used { if (TLMSingleton.instance != null && TLMSingleton.debugMode) { TLMUtils.doLog("EXCEPTION! {0} | {1} | [{2}]", i.Key, currentConfigWarehouseEditor.getString(i.Key), string.Join(",", i.Value.items)); } } } foreach (var i in checkBoxes) { if (TLMSingleton.instance != null && TLMSingleton.debugMode) { TLMUtils.doLog("OPÇÔES RECARREGANDO {0}", i); } i.Value.isChecked = currentConfigWarehouseEditor.getBool(i.Key); } foreach (var i in textFields) { if (TLMSingleton.instance != null && TLMSingleton.debugMode) { TLMUtils.doLog("OPÇÔES RECARREGANDO {0}", i); } i.Value.text = currentConfigWarehouseEditor.getString(i.Key); } }
public static void removeAllUnwantedVehicles() { for (ushort lineId = 1; lineId < Singleton <TransportManager> .instance.m_lines.m_size; lineId++) { if ((Singleton <TransportManager> .instance.m_lines.m_buffer[lineId].m_flags & TransportLine.Flags.Created) != TransportLine.Flags.None) { if (TransportLinesManagerMod.instance != null && TransportLinesManagerMod.debugMode) { TLMUtils.doLog("removeAllUnwantedVehicles: line #{0}", lineId); } TransportLine tl = Singleton <TransportManager> .instance.m_lines.m_buffer[lineId]; uint prefix = 0; if (TLMConfigWarehouse.getCurrentConfigInt(TLMConfigWarehouse.getConfigIndexForTransportInfo(tl.Info) | TLMConfigWarehouse.ConfigIndex.PREFIX) != (int)ModoNomenclatura.Nenhum) { prefix = tl.m_lineNumber / 1000u; } VehicleManager instance3 = Singleton <VehicleManager> .instance; VehicleInfo info = instance3.m_vehicles.m_buffer[Singleton <TransportManager> .instance.m_lines.m_buffer[lineId].GetVehicle(0)].Info; if (TransportLinesManagerMod.instance != null && TransportLinesManagerMod.debugMode) { TLMUtils.doLog("removeAllUnwantedVehicles: pre model list; type = {0}", info.GetAI()); } var def = TransportSystemDefinition.from(info); if (def == default(TransportSystemDefinition)) { if (TransportLinesManagerMod.instance != null && TransportLinesManagerMod.debugMode) { TLMUtils.doLog("NULL TSysDef! {0}+{1}+{2}", info.GetAI().GetType(), info.m_class.m_subService, info.m_vehicleType); } continue; } var modelList = BasicTransportExtensionSingleton.instance(def).getAssetListForPrefix(prefix); if (TransportLinesManagerMod.instance != null && TransportLinesManagerMod.debugMode) { TLMUtils.doLog("removeAllUnwantedVehicles: models found: {0}", modelList == null ? "?!?" : modelList.Count.ToString()); } if (modelList.Count > 0) { Dictionary <ushort, VehicleInfo> vehiclesToRemove = new Dictionary <ushort, VehicleInfo>(); for (int i = 0; i < tl.CountVehicles(lineId); i++) { var vehicle = tl.GetVehicle(i); if (vehicle != 0) { VehicleInfo info2 = instance3.m_vehicles.m_buffer[(int)vehicle].Info; if (!modelList.Contains(info2.name)) { vehiclesToRemove[vehicle] = info2; } } } foreach (var item in vehiclesToRemove) { item.Value.m_vehicleAI.SetTransportLine(item.Key, ref instance3.m_vehicles.m_buffer[item.Key], 0); } } } } }
private void CreateMainPanel() { TLMUtils.createUIElement(out m_mainPanel, m_parent.transform); m_mainPanel.Hide(); m_mainPanel.relativePosition = new Vector3(510f, 0.0f); m_mainPanel.width = 350; m_mainPanel.height = m_parent.GetComponent <UIComponent>().height; m_mainPanel.zOrder = 50; m_mainPanel.color = new Color32(255, 255, 255, 255); m_mainPanel.name = "AssetSelectorWindow"; m_mainPanel.autoLayoutPadding = new RectOffset(5, 5, 10, 10); m_mainPanel.autoLayout = false; m_mainPanel.useCenter = true; m_mainPanel.wrapLayout = false; m_mainPanel.canFocus = true; TLMUtils.createUIElement(out m_title, m_mainPanel.transform); m_title.textAlignment = UIHorizontalAlignment.Center; m_title.autoSize = false; m_title.autoHeight = true; m_title.width = m_mainPanel.width - 30f; m_title.relativePosition = new Vector3(5, 5); m_title.textScale = 0.9f; m_title.localeID = "TLM_ASSETS_FOR_PREFIX"; }
private void ReloadPrefixOptions() { int selIdx = m_prefixSelector.selectedIndex; m_prefixSelector.items = TLMUtils.getStringOptionsForPrefix(Singleton <T> .instance.GetTSD().toConfigIndex(), true, false); m_prefixSelector.selectedIndex = selIdx; }
private void CreateCheckboxes() { foreach (var i in m_checkboxes?.Keys) { UnityEngine.Object.Destroy(m_checkboxes[i].gameObject); } m_defaultAssets = extension.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 || m_prefixIdx < 0) { return; } if (x) { extension.AddAsset((uint)m_prefixIdx, i); } else { extension.RemoveAsset((uint)m_prefixIdx, 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 - 70) / checkbox.label.width, 1), 1); m_checkboxes[i] = checkbox; } }
private void Awake() { if (m_instance != null) { throw new Exception("MULTIPLE INSTANTIATION!!!!!!!!"); } m_instance = this; mainPanel = GetComponentInChildren <UIScrollablePanel>(); mainPanel.autoLayout = true; mainPanel.autoLayoutDirection = LayoutDirection.Vertical; m_uiHelper = new UIHelperExtension(mainPanel); TLMUtils.doLog("PrefixDD"); m_prefixSelector = m_uiHelper.AddDropdownLocalized("TLM_PREFIX", new string[0], -1, onChangePrefix); ReloadPrefixOptions(); TLMUtils.doLog("PrefixDD Panel"); var ddPanel = m_prefixSelector.GetComponentInParent <UIPanel>(); ConfigComponentPanel(m_prefixSelector); TLMUtils.doLog("SubPanel"); TLMUtils.createUIElement(out UIPanel subpanel, mainPanel.transform, "Subpanel", new Vector4(0, 0, 500, 180)); subpanel.autoLayout = true; subpanel.autoLayoutDirection = LayoutDirection.Vertical; subpanel.autoSize = true; m_subpanel = new UIHelperExtension(subpanel); TLMUtils.doLog("AssetSelector"); TLMUtils.createUIElement(out m_panelAssetSelector, mainPanel.transform, "AssetSelector", new Vector4(0, 0, 0, 0.0001f)); m_assetSelectorWindow = TLMUtils.createElement(ImplClassChildren, m_panelAssetSelector.transform).GetComponent <TLMAssetSelectorWindowPrefixTab <T> >(); m_subpanel.self.isVisible = false; m_assetSelectorWindow.mainPanel.isVisible = false; TLMUtils.doLog("Name"); m_prefixName = m_subpanel.AddTextField(Locale.Get("TLM_PREFIX_NAME"), null, "", onPrefixNameChange); ConfigComponentPanel(m_prefixName); TLMUtils.doLog("Price"); m_prefixTicketPrice = m_subpanel.AddTextField(Locale.Get("TLM_TICKET_PRICE_LABEL"), null, "", onTicketChange); ConfigComponentPanel(m_prefixTicketPrice); TLMUtils.doLog("ColorForModel"); m_useColorForModel = m_subpanel.AddCheckboxLocale("TLM_USE_PREFIX_COLOR_FOR_VEHICLE", false, onUseColorVehicleChange); TLMUtils.LimitWidth(m_useColorForModel.label, 420, true); TLMUtils.doLog("ColorSel"); CreateColorSelector(); TLMUtils.doLog("Budget"); TLMUtils.createUIElement(out UIPanel m_budgetPanel, subpanel.transform, "BudgetPanel", new Vector4(0, 0, 460, 180)); CreateBudgetSliders(m_budgetPanel); CreateToggleBudgetButtons(m_budgetPanel); GetComponent <UIComponent>().eventVisibilityChanged += (x, y) => forceRefresh(); TLMConfigWarehouse.eventOnPropertyChanged += OnWarehouseChange; }
private static void load() { string serializedInfo = TLMSingleton.savedPalettes.value; if (TLMSingleton.instance != null && TLMSingleton.debugMode) { TLMUtils.doLog("Loading palettes - separator: {1} ; save Value: {0}", serializedInfo, SERIALIZER_ITEM_SEPARATOR); } string[] items = serializedInfo.Split(SERIALIZER_ITEM_SEPARATOR); foreach (string item in items) { if (TLMSingleton.instance != null && TLMSingleton.debugMode) { TLMUtils.doLog("Loading palette {0}", items); } AutoColorPalette acp = AutoColorPalette.parseFromString(item); if (acp != null) { m_palettes.Add(acp.name, acp); } } foreach (AutoColorPalette p in defaultPaletteArray) { m_palettes[p.name] = p; } }
private void InitPrefixesSelector() { m_prefixSelectorPanel = new UIHelperExtension(m_PrefixEditor); ((UIScrollablePanel)m_prefixSelectorPanel.self).autoLayoutDirection = LayoutDirection.Horizontal; ((UIScrollablePanel)m_prefixSelectorPanel.self).autoLayoutPadding = new RectOffset(5, 5, 0, 0); ((UIScrollablePanel)m_prefixSelectorPanel.self).wrapLayout = true; ((UIScrollablePanel)m_prefixSelectorPanel.self).autoLayout = true; string[] optionList = new string[m_transportTypeOrder.Length + 1]; optionList[0] = "--" + Locale.Get("SELECT") + "--"; for (int i = 1; i < optionList.Length; i++) { optionList[i] = TLMCW.getNameForTransportType(m_transportTypeOrder[i - 1]); } TLMUtils.doLog("INIT m_systemTypeDropDown"); m_systemTypeDropDown = (UIDropDown)m_prefixSelectorPanel.AddDropdown(Locale.Get("TLM_TRANSPORT_SYSTEM"), optionList, 0, loadPrefixes); m_prefixSelection = (UIDropDown)m_prefixSelectorPanel.AddDropdown(Locale.Get("TLM_PREFIX"), new string[] { "" }, 0, selectPrefixAction); foreach (Transform t in m_prefixSelectorPanel.self.transform) { var panel = t.gameObject.GetComponent <UIPanel>(); if (panel) { panel.width = 340; } } }
private List <Vector2> getMidPointsD1D2(Vector2 p1, Vector2 p2, Vector2 dirP1, Vector2 dirP2, int indexSumP1, int indexSubP2) { List <Vector2> saida = new List <Vector2>(); Vector2 intersection = getIntersectionPoint(indexSumP1, indexSubP2); int currentMidx = (int)(indexSumP1 - intersection.y); int targetMidx = (int)(indexSubP2 + intersection.y); bool currentReachble = currentMidx / dirP1.x > 0; bool targetReachble = targetMidx / dirP2.x > 0; if (currentReachble && targetReachble) { if (p2.x != p1.x && p2.y != p1.y) { var Δx = (int)Math.Abs(p1.x - p2.x); var Δy = (int)Math.Abs(p1.y - p2.y); var sigx = Math.Sign(p2.x - p1.x); var sigy = Math.Sign(p2.y - p1.y); if (Δx < Δy) { saida.Add(p1 + new Vector2(Δx * sigx, Δx * sigy)); } else { saida.Add(p1 + new Vector2(Δy * sigx, Δy * sigy)); } } } else { TLMUtils.doErrorLog("WORST CASE (currentReachble= {0}; targetReachble={1})", currentReachble, targetReachble); } return(saida); }