Skip to content

Commit 05a9b8b

Browse files
authored
Merge pull request #535 from krzychu124/320-remove-disable-traffic-lights
Function to Disable & Remove Traffic Lights
2 parents 2d58a88 + b765636 commit 05a9b8b

14 files changed

+177
-72
lines changed

TLM/TLM/Manager/Impl/OptionsManager.cs

+6-1
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,10 @@ public bool LoadData(byte[] data) {
193193
OptionsVehicleRestrictionsTab.SetAllowFarTurnOnRed(data[40] == 1);
194194
}
195195

196+
if (data.Length >= 42) {
197+
OptionsVehicleRestrictionsTab.SetAddTrafficLightsIfApplicable(data[41] == 1);
198+
}
199+
196200
return true;
197201
}
198202

@@ -238,7 +242,8 @@ public byte[] SaveData(ref bool success) {
238242
(byte)(Options.realisticPublicTransport ? 1 : 0),
239243
(byte)(Options.turnOnRedEnabled ? 1 : 0),
240244
(byte)(Options.allowNearTurnOnRed ? 1 : 0),
241-
(byte)(Options.allowFarTurnOnRed ? 1 : 0)
245+
(byte)(Options.allowFarTurnOnRed ? 1 : 0),
246+
(byte)(Options.automaticallyAddTrafficLightsIfApplicable ? 1 : 0)
242247
};
243248
}
244249
}

TLM/TLM/Manager/Impl/TrafficLightManager.cs

+7
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,13 @@ public bool RemoveTrafficLight(ushort nodeId,
108108
return SetTrafficLight(nodeId, false, ref node, out reason);
109109
}
110110

111+
public void RemoveAllExistingTrafficLights() {
112+
Array16<NetNode> nodes = NetManager.instance.m_nodes;
113+
for (ushort i = 0; i < nodes.m_size; i++) {
114+
RemoveTrafficLight(i, ref nodes.m_buffer[i]);
115+
}
116+
}
117+
111118
public bool ToggleTrafficLight(ushort nodeId, ref NetNode node) {
112119
return SetTrafficLight(nodeId, !HasTrafficLight(nodeId, ref node), ref node);
113120
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
namespace TrafficManager.Patch._RoadBaseAI {
2+
using ColossalFramework;
3+
using Harmony;
4+
using JetBrains.Annotations;
5+
using Manager.Impl;
6+
using State;
7+
8+
[HarmonyPatch(typeof(RoadBaseAI), "UpdateNode")]
9+
[UsedImplicitly]
10+
public class UpdateNodePatch {
11+
[HarmonyPostfix]
12+
[UsedImplicitly]
13+
public static void Postfix(ushort nodeID, ref NetNode data) {
14+
15+
if (Options.automaticallyAddTrafficLightsIfApplicable)
16+
{
17+
return;
18+
}
19+
20+
// test for not Flags.Junction is unnecessary because tested in IsTrafficLightToggleable
21+
// but it's a simple and fast exit, while IsTrafficLightToggleable is quite complex
22+
if(!data.m_flags.IsFlagSet(NetNode.Flags.Junction) || !TrafficLightManager.Instance.CanToggleTrafficLight(nodeID, false, ref data, out _))
23+
{
24+
return;
25+
}
26+
27+
// UpdateNode is called for new nodes and changed nodes (-> existing AND new junctions)
28+
// For new junctions this method is called BEFORE traffic lights are set (done in UpdateNodeFlags)
29+
// Marking junction with CustomTrafficLights prevents the setting of traffic lights
30+
// For existing junctions this has the additional benefit of not removing the lights when the junction changed
31+
32+
data.m_flags |= NetNode.Flags.CustomTrafficLights;
33+
}
34+
}
35+
}
+8-8
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
"","de","en","es","fr","hu","it","ja","ko","nl","pl","pt","ru","zh-tw","zh","en-gb"
2-
"Tooltip:Switch traffic lights","Ampeln setzen","Switch traffic lights","Agregar/Borrar semáforos","(Dés)activer les feux tricolores","Kapcsolja be a lámpákat","Attiva/Disattiva semaforo","信号の付け外し","신호등 추가/제거","Stoplichten omwisselen","Włącznik sygnalizacji","Interruptor de Semáforos","Включение/выключение светофора","增刪號誌燈","红绿灯增删","Switch traffic lights"
3-
"Tooltip:Add priority signs","Vorfahrtsschilder","Add priority signs","Agregar señales de tránsito","Ajouter des signes de priorité","Adjon hozzá prioritási jeleket","Aggiungi segnale stradale","優先関係標識の追加","교통 표지판 추가","Plaats voorrangsborden","Dodaj znaki pierwszeństwa","Placas de preferência","Знаки приоритета","增訂優先通行權","添加路口优先权","Add priority signs"
2+
"Tooltip:Switch traffic lights","Ampeln setzen","Switch traffic lights","Agregar/Borrar semáforos","(Dés)activer les feux tricolores","Kapcsolja be a lámpákat","Attiva/Disattiva semaforo","信号の付け外し","신호등 추가/제거","Stoplichten omwisselen","Włącznik sygnalizacji","Alternar semáforos","Включение/выключение светофора","增刪號誌燈","红绿灯增删","Switch traffic lights"
3+
"Tooltip:Add priority signs","Vorfahrtsschilder","Add priority signs","Agregar señales de tránsito","Ajouter des signes de priorité","Adjon hozzá prioritási jeleket","Aggiungi segnale stradale","優先関係標識の追加","교통 표지판 추가","Plaats voorrangsborden","Dodaj znaki pierwszeństwa","Adicionar placas de preferência","Знаки приоритета","增訂優先通行權","添加路口优先权","Add priority signs"
44
"Tooltip:Manual traffic lights","Manuelle Ampeln","Manual traffic lights","Semáforos manuales","Feux tricolores manuels","Kézi közlekedési lámpák","Semaforo (manuale)","信号の手動切替","신호등 직접 통제","Handmatige stoplichten","Sygnalizacja Ręczna","Semáforo manual","Светофор вручную","手控號誌燈","手动控制红绿灯","Manual traffic lights"
55
"Tooltip:Timed traffic lights","Zeitgesteuerte Ampeln","Timed traffic lights","Semáforos programados","Feux tricolores chronométrés","Időzített közlekedési lámpák","Semaforo (temporizzato)","時間設定付き信号","신호등 시간표 설정","Tijdgestuurde stoplichten","Sygnalizacja Czasowa","Semáforos cronometrados","Настраиваемый светофор","號誌燈時相設定","红绿灯定时设置","Timed traffic lights"
6-
"Tooltip:Change lane arrows","Richtungspfeile","Change lane arrows","Editar flechas de pistas","Changer les directions de voies","Változtasson a sáv nyilait","Modifica frecce di direzione","車線矢印の変更","도로 화살표 변경","Voorsorteerpijlen aanpassen","Zmień strzałki pasów","Alterar setas de pista","Стрелки поворота на полосах движения","改變車道遵行方向","变更车道方向","Change lane arrows"
6+
"Tooltip:Change lane arrows","Richtungspfeile","Change lane arrows","Editar flechas de pistas","Changer les directions de voies","Változtasson a sáv nyilait","Modifica frecce di direzione","車線矢印の変更","도로 화살표 변경","Voorsorteerpijlen aanpassen","Zmień strzałki pasów","Alterar setas da faixa","Стрелки поворота на полосах движения","改變車道遵行方向","变更车道方向","Change lane arrows"
77
"Tooltip:Clear traffic","Verkehr löschen","Clear Traffic","Limpiar Tráfico","Nettoyer le trafic","Tiszta forgalom","Resetta traffico","移動中車両の除去","모든 교통차량 초기화","Wegen vrijmaken","Wyczyść ruch","Limpar tráfego","Очистить весь транспорт","消除所有車輛","清除所有车辆","Clear Traffic"
88
"Dialog.Text:Clear traffic, confirmation","Verkehr löschen?","Are you sure you want to clear all traffic?","¿Limpiar Tráfico?","Nettoyer le trafic ?","Tiszta forgalom?","Resetta traffico?","移動中車両の除去","모든 교통차량 초기화","Wegen vrijmaken?","Wyczyść ruch?","Limpar tráfego?","Очистить весь транспорт?","消除所有車輛確認","清除所有车辆","Are you sure you want to clear all traffic?"
99
"Tooltip:Speed limits","Geschwindigkeitsbeschränkungen","Speed limits","Límites de velocidad","Limitations de vitesse","Sebesség határok","Limiti di velocità","速度制限","속도 제한","Snelheidslimiet","Ograniczenia prędkości","Limite de Velocidade","Ограничения скорости","速限","道路限速设置","Speed limits"
1010
"Tooltip:Vehicle restrictions","Fahrzeugbeschränkungen","Vehicle restrictions","Restricción vehicular","Restrictions des véhicules","Jármű-korlátozások","Restrizioni veicoli","車両規制","차량 제한","Voertuigbeperkingen","Ograniczenia ruchu pojazdów","Restrições de veículos","Ограничения видов транспорта","車種限定","道路车种限制","Vehicle restrictions"
1111
"Tooltip:Parking restrictions","Parkverbote","Parking restrictions","Restricciones de los estacionamientos","Restrictions de stationnement","Parkolási korlátozások","Divieti di sosta","駐車規制","주차 제한","Parkeerbeperkingen","Ograniczenia parkingowe","Restrições de estacionamento","Ограничения парковки","停車限制","路边停车限制","Parking restrictions"
12-
"Button:Remove this citizen","Diesen Cim entfernen","Remove this citizen","Remove this citizen","Retirer ce citoyen","Távolítsa el ezt a polgárt","Remove this citizen","この市民を削除する","해당 시민 삭제","Remove this citizen","Usuń tego mieszkańca","Remove this citizen","Удалить этого сима","移除此市民","移除此居民","Remove this citizen"
13-
"Button:Remove this vehicle","Dieses Fahrzeug entfernen","Remove this vehicle","Remove this vehicle","Retirer ce véhicule","Távolítsa el ezt a járművet","Rimuovi questo veicolo","この車両を削除する","해당 차량을 제거합니다","Remove this vehicle","Usuń ten pojazd","Remove this vehicle","Удалить этот транспорт","移除此車輛","移除此车辆","Remove this vehicle"
14-
"Tooltip:Toggle Main Menu","TM:PE-Hauptmenü umschalten","Toggle TM:PE Main Menu","","Bascule vers le Menu Principal de TM:PE","Toggle TM: PE Főmenü","","","","","Menu TM:PE","","Показать или скрыть меню TM:PE","調整主選單","TM:PE主菜单","Toggle TM:PE Main Menu"
15-
"Button:Switch view","Ansicht wechseln","Switch view","Cambiar vista","Changer de vue","Nézet váltása","Cambia vista","ビューを切り替える","보기 전환","Aanzicht wisselen","Zmień widok","Trocar visão","Переключение вида","切換檢視","切换视图","Switch view"
12+
"Button:Remove this citizen","Diesen Cim entfernen","Remove this citizen","Remove this citizen","Retirer ce citoyen","Távolítsa el ezt a polgárt","Remove this citizen","この市民を削除する","해당 시민 삭제","Remove this citizen","Usuń tego mieszkańca","Remover este cidadão","Удалить этого сима","移除此市民","移除此居民","Remove this citizen"
13+
"Button:Remove this vehicle","Dieses Fahrzeug entfernen","Remove this vehicle","Remove this vehicle","Retirer ce véhicule","Távolítsa el ezt a járművet","Rimuovi questo veicolo","この車両を削除する","해당 차량을 제거합니다","Remove this vehicle","Usuń ten pojazd","Remover este veículo","Удалить этот транспорт","移除此車輛","移除此车辆","Remove this vehicle"
14+
"Tooltip:Toggle Main Menu","TM:PE-Hauptmenü umschalten","Toggle TM:PE Main Menu","","Bascule vers le Menu Principal de TM:PE","Toggle TM: PE Főmenü","","メインメニューの切り替え","","","Menu TM:PE","Alternar Menu Principal","Показать или скрыть меню TM:PE","調整主選單","TM:PE主菜单","Toggle TM:PE Main Menu"
15+
"Button:Switch view","Ansicht wechseln","Switch view","Cambiar vista","Changer de vue","Nézet váltása","Cambia vista","ビューを切り替える","보기 전환","Aanzicht wisselen","Zmień widok","Alternar visão","Переключение вида","切換檢視","切换视图","Switch view"
1616
"Label:Outgoing demand","Ausgehende Nachfrage","Outgoing demand","Demanda saliente","Demande sortante","Kimenő kereslet","","出ていく需要","나가는 수요","Uitgaande vraag","Zapotrzebowanie - wychodzące","Demanda de saída","Исходящий спрос","出貨需求","出货需求","Outgoing demand"
1717
"Label:Incoming demand","Eingehende Nachfrage","Incoming demand","Demanda entrante","Demande entrante","Bejövő kereslet","","入っていく需要","들어오는 수요","Inkomende vraag","Zapotrzebowanie - przychodzące","Demanda de entrada","Входящий спрос","進貨需求","进货需求","Incoming demand"
18-
"Tooltip:Lane connector","Fahrspurverbinder","Lane connector","Conector de carriles","Connecteur de voies","Sávcsatlakozó","Connettore corsia","車線を接続","차선 연결","Rijstrookverbinder","Połącz pasy ruchu","Conector de pistas","Соединения полос движения","車道連接工具","车道连接工具","Lane connector"
18+
"Tooltip:Lane connector","Fahrspurverbinder","Lane connector","Conector de carriles","Connecteur de voies","Sávcsatlakozó","Connettore corsia","車線を接続","차선 연결","Rijstrookverbinder","Połącz pasy ruchu","Conector de faixas","Соединения полос движения","車道連接工具","车道连接工具","Lane connector"
1919
"Tooltip:Junction restrictions","Kreuzungsbeschränkungen","Junction restrictions","Restricciones del cruce","Restrictions des intersections","Csomópont korlátozások","Restrizioni incrocio","交差点の制限","교차로 규칙","Splitsingsbeperkingen","Ograniczenia na skrzyżowaniach","Restrições de junção","Ограничения на перекрёстках","交岔路口動線連接制定","路口管制","Junction restrictions"
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"","de","en","es","fr","hu","it","ja","ko","nl","pl","pt","ru","zh-tw","zh","en-gb"
22
"Button:Delete mod","Löschen","Delete","Borrar","Suppr.","Töröl","Elimina","削除","삭제","Verwijderen","Skasuj","Apagar","Удалить","刪除模組","删除","Delete"
3-
"Button:Unsubscribe mod","Abmelden","Unsubscribe","Desuscribir","Désabonner","Leiratkozás","","","","Afmeld","Odsubskrybuj","","Отписаться","取消訂閱模組","取消订阅","Unsubscribe"
4-
"Window.Title:Detected incompatible mods","detected incompatible mods","detected incompatible mods","detected incompatible mods","a détecté des mods incompatibles","nem kompatibilis modokat észlelt","detected incompatible mods","detected incompatible mods","와 비호환되는 모드 감지","detected incompatible mods","wykrył niekompatybilne mody","detected incompatible mods","обнаружил несовместимые моды","偵測不相容的模組","检测到的不兼容MOD","detected incompatible mods"
5-
"Checkbox:Scan for known incompatible mods on startup","Scan for known incompatible mods on startup","Scan for known incompatible mods on startup","Scan for known incompatible mods on startup","Rechercher les mods incompatibles au lancement","Keressen induláskor az ismert, nem kompatibilis modokat","Scan for known incompatible mods on startup","Scan for known incompatible mods on startup","게임 실행시 비호환되는 모드 스캔","Scan for known incompatible mods on startup","Uruchamiaj sprawdzanie przy starcie gry","Scan for known incompatible mods on startup","Сканирование известных несовместимых модов при запуске","在遊戲開始時偵測已知的不相容模組","启动时检测是否存在已知不兼容MOD","Scan for known incompatible mods on startup"
6-
"Checkbox:Ignore disabled mods","","Ignore disabled mods","","Ignorer les mods désactivés","Figyeljen a letiltott modokra","","","비활성화된 모드 무시하기","Negeer uitgeschakelde mods","Ignoruj wyłączone mody","","Игнорировать отключённые моды","忽略已停用的模組","忽略未启用MOD","Ignore disabled mods"
3+
"Button:Unsubscribe mod","Abmelden","Unsubscribe","Desuscribir","Désabonner","Leiratkozás","","登録解除","","Afmeld","Odsubskrybuj","Desinscrever do mod","Отписаться","取消訂閱模組","取消订阅","Unsubscribe"
4+
"Window.Title:Detected incompatible mods","detected incompatible mods","detected incompatible mods","detected incompatible mods","a détecté des mods incompatibles","nem kompatibilis modokat észlelt","detected incompatible mods","detected incompatible mods","와 비호환되는 모드 감지","detected incompatible mods","wykrył niekompatybilne mody","Mods incompatíveis detectados","обнаружил несовместимые моды","偵測不相容的模組","检测到的不兼容MOD","detected incompatible mods"
5+
"Checkbox:Scan for known incompatible mods on startup","Scan for known incompatible mods on startup","Scan for known incompatible mods on startup","Scan for known incompatible mods on startup","Rechercher les mods incompatibles au lancement","Keressen induláskor az ismert, nem kompatibilis modokat","Scan for known incompatible mods on startup","Scan for known incompatible mods on startup","게임 실행시 비호환되는 모드 스캔","Scan for known incompatible mods on startup","Uruchamiaj sprawdzanie przy starcie gry","Procurar por mods incompatíveis conhecidos ao iniciar","Сканирование известных несовместимых модов при запуске","在遊戲開始時偵測已知的不相容模組","启动时检测是否存在已知不兼容MOD","Scan for known incompatible mods on startup"
6+
"Checkbox:Ignore disabled mods","Deaktivierte Mods ignorieren","Ignore disabled mods","","Ignorer les mods désactivés","Figyeljen a letiltott modokra","","無効なMODを無視する","비활성화된 모드 무시하기","Negeer uitgeschakelde mods","Ignoruj wyłączone mody","Ignorar mods desabilitados","Игнорировать отключённые моды","忽略已停用的模組","忽略未启用MOD","Ignore disabled mods"

0 commit comments

Comments
 (0)