|
1 | | -namespace TrafficManager.UI.Textures { |
| 1 | +namespace TrafficManager.UI.Textures { |
2 | 2 | using System; |
3 | 3 | using System.Collections.Generic; |
4 | 4 | using CSUtil.Commons; |
5 | 5 | using JetBrains.Annotations; |
6 | 6 | using TrafficManager.API.Traffic.Data; |
7 | 7 | using TrafficManager.API.Traffic.Enums; |
| 8 | + using TrafficManager.API.UI; |
| 9 | + using TrafficManager.Manager.Impl; |
8 | 10 | using TrafficManager.State; |
9 | 11 | using TrafficManager.UI.SubTools; |
10 | 12 | using TrafficManager.Util; |
|
15 | 17 | /// Defines one theme for road signs. All themes are accessible via, and stored in |
16 | 18 | /// <see cref="RoadSignThemeManager"/>. |
17 | 19 | /// </summary> |
18 | | - public class RoadSignTheme { |
| 20 | + public class RoadSignTheme : ITheme { |
19 | 21 | public enum OtherRestriction { |
20 | 22 | Crossing, |
21 | 23 | EnterBlockedJunction, |
@@ -148,6 +150,39 @@ public Texture2D GetOtherRestriction(OtherRestriction type, bool allow) { |
148 | 150 | : this.ParentTheme.GetOtherRestriction(type, allow: false); |
149 | 151 | } |
150 | 152 |
|
| 153 | + public Texture2D JunctionRestriction(JunctionRestrictionFlags rule, bool allowed) { |
| 154 | + bool rht = Shortcuts.RHT; |
| 155 | + switch (rule) { |
| 156 | + case JunctionRestrictionFlags.AllowPedestrianCrossing: |
| 157 | + return GetOtherRestriction(OtherRestriction.Crossing, allowed); |
| 158 | + case JunctionRestrictionFlags.AllowUTurn: |
| 159 | + return GetOtherRestriction(OtherRestriction.UTurn, allowed); |
| 160 | + case JunctionRestrictionFlags.AllowEnterWhenBlocked: |
| 161 | + return GetOtherRestriction(OtherRestriction.EnterBlockedJunction, allowed); |
| 162 | + case JunctionRestrictionFlags.AllowForwardLaneChange: |
| 163 | + return GetOtherRestriction(OtherRestriction.LaneChange, allowed); |
| 164 | + case JunctionRestrictionFlags.AllowFarTurnOnRed when rht: |
| 165 | + case JunctionRestrictionFlags.AllowNearTurnOnRed when !rht: |
| 166 | + return GetOtherRestriction(OtherRestriction.LeftOnRed, allowed); |
| 167 | + case JunctionRestrictionFlags.AllowNearTurnOnRed when rht: |
| 168 | + case JunctionRestrictionFlags.AllowFarTurnOnRed when !rht: |
| 169 | + return GetOtherRestriction(OtherRestriction.RightOnRed, allowed); |
| 170 | + default: |
| 171 | + Log.Error($"could not get texture for {rule}."); |
| 172 | + return null; |
| 173 | + } |
| 174 | + } |
| 175 | + |
| 176 | + public Texture2D TrafficLightIcon(ushort nodeId) { |
| 177 | + if (!TrafficLightManager.Instance.HasTrafficLight(nodeId)) { |
| 178 | + return TrafficLightTextures.Instance.TrafficLightDisabled; |
| 179 | + } else if (TrafficLightSimulationManager.Instance.HasSimulation(nodeId)) { |
| 180 | + return TrafficLightTextures.Instance.TrafficLightEnabledTimed; |
| 181 | + } else { |
| 182 | + return TrafficLightTextures.Instance.TrafficLightEnabled; |
| 183 | + } |
| 184 | + } |
| 185 | + |
151 | 186 | public RoadSignTheme Load(bool whiteTexture = false) { |
152 | 187 | if (this.AttemptedToLoad) { |
153 | 188 | return this; |
|
0 commit comments