public void load() { if (TransportLinesManagerMod.instance != null && TransportLinesManagerMod.debugMode) { TLMUtils.doLog("TLMStopsExtension.load()"); } var file = TLMConfigWarehouse.getCurrentConfigString(CONFIG).Split(COMMA.ToCharArray()); cached_list = new Dictionary <uint, Dictionary <Property, string> >(); if (file.Length > 0) { if (TransportLinesManagerMod.instance != null && TransportLinesManagerMod.debugMode) { TLMUtils.doLog("TLMStopsExtension.load(): file.Length > 0"); } foreach (string s in file) { uint key = getIndexFromStringArray(s); var value = TLMUtils.getValueFromStringArray <Property>(s, SEPARATOR, SUBCOMMA, SUBSEPARATOR); cached_list[key] = value; } if (TransportLinesManagerMod.instance != null && TransportLinesManagerMod.debugMode) { TLMUtils.doLog("TLMStopsExtension.load(): dic done"); } cached_list.Remove(0); } }
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(); }
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 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)); }
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 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)); }
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)); }
public void SetRandomBuilding(ref TransportSystemDefinition tsd, ushort lineId, ref ushort currentId) { Interfaces.IBasicExtension config = TLMLineUtils.GetEffectiveExtensionForLine(lineId); List <ushort> allowedDepots = config.GetAllowedDepots(ref tsd, lineId); if (allowedDepots.Count == 0 || allowedDepots.Contains(currentId)) { if (TransportLinesManagerMod.DebugMode) { TLMUtils.doLog("allowedDepots.Count --{0}-- == 0|| allowedDepots.Contains({1}): --{2}-- ", allowedDepots.Count, currentId, string.Join(",", allowedDepots.Select(x => x.ToString()).ToArray())); } return; } var r = new Randomizer(new System.Random().Next()); if (TransportLinesManagerMod.DebugMode) { TLMUtils.doLog("DEPOT POSSIBLE VALUES FOR {2} LINE {1}: {0} ", string.Join(",", allowedDepots.Select(x => x.ToString()).ToArray()), lineId, tsd); } currentId = allowedDepots[r.Int32(0, allowedDepots.Count - 1)]; if (TransportLinesManagerMod.DebugMode) { TLMUtils.doLog("DEPOT FOR {2} LINE {1}: {0} ", currentId, lineId, tsd); } }
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 }
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); } }
private static int ticketPriceForPrefix(ushort vehicleID, ref Vehicle vehicleData, int defaultPrice) { var def = TransportSystemDefinition.from(vehicleData.Info); if (def == default(TransportSystemDefinition)) { if (TLMSingleton.instance != null && TLMSingleton.debugMode) { TLMUtils.doLog("NULL TSysDef! {0}+{1}+{2}", vehicleData.Info.GetAI().GetType(), vehicleData.Info.m_class.m_subService, vehicleData.Info.m_vehicleType); } return(defaultPrice); } if (vehicleData.m_transportLine == 0) { var value = (int)def.GetTransportExtension().GetDefaultTicketPrice(0); return(value); } else { if (TLMTransportLineExtension.instance.GetUseCustomConfig(vehicleData.m_transportLine)) { return((int)TLMTransportLineExtension.instance.GetTicketPrice(vehicleData.m_transportLine)); } else { return((int)def.GetTransportExtension().GetTicketPrice(TLMLineUtils.getPrefix(vehicleData.m_transportLine))); } } }
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); } } } } }
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); }
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 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!!!"); } }
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 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); }
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 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; } }
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 static bool LoadLegacy(SavedString oldFile) { string serializedInfo = oldFile.value; if (!string.IsNullOrEmpty(serializedInfo)) { 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) { TLMUtils.doLog("Loading palette {0}", items); AutoColorPalette acp = AutoColorPalette.parseFromString_Legacy(item); if (acp != null) { m_palettes.Add(acp.name, acp); } } } else { return(false); } foreach (AutoColorPalette p in defaultPaletteArray) { m_palettes[p.name] = p; } return(true); }
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; } }
public static void AddRedirect(Type target, MethodInfo newMethod, ref Dictionary <MethodInfo, RedirectCallsState> redirects, string type1MethodName = null) { var parameters = newMethod.GetParameters(); Type[] types; if (parameters.Length > 0 && parameters[0].ParameterType == target) { types = parameters.Skip(1).Select(p => p.ParameterType).ToArray(); } else { types = parameters.Select(p => p.ParameterType).ToArray(); } var originalMethod = target.GetMethod(type1MethodName != null ? type1MethodName : newMethod.Name, allFlags, null, types, null); if (originalMethod == null) { if (TransportLinesManagerMod.instance != null && TransportLinesManagerMod.debugMode) { TLMUtils.doLog("Cannot find " + newMethod.Name); } } redirects.Add(originalMethod, RedirectionHelper.RedirectCalls(originalMethod, newMethod)); }
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 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()); }
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 OnDisable() { TLMUtils.doLog("OnDisableTransportTool"); TLMController.instance.setCurrentSelectedId(0); TLMController.instance.LinearMapCreatingLine?.setVisible(false); TLMController.instance.LineCreationToolbox?.setVisible(false); }
private static void init() { if (TLMSingleton.instance != null && TLMSingleton.debugMode) { TLMUtils.doLog("TLMAutoColorPalettes init()"); } Reload(); }
public static void OnEnable() { TLMUtils.doLog("OnEnableTransportTool"); TransportLinesManagerMod.Instance.ShowVersionInfoPopup(); TLMController.instance.LinearMapCreatingLine?.setVisible(TLMController.LinearMapWhileCreatingLineVisibility); TLMController.instance.LineCreationToolbox?.setVisible(true); TLMController.instance.SetCurrentSelectedId(0); }
private static void init() { if (TLMSingleton.instance != null && TLMSingleton.debugMode) { TLMUtils.doLog("TLMAutoColorPalettes init()"); } m_palettes = new Dictionary <string, AutoColorPalette>(); load(); }