Skip to content

Commit

Permalink
pr fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
kianzarrin committed Apr 30, 2020
1 parent 95eb4ae commit 3bf8c9f
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 34 deletions.
5 changes: 3 additions & 2 deletions TLM/TLM/Manager/Impl/ParkingRestrictionsManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,10 @@ public bool ToggleParkingAllowed(ushort segmentId, NetInfo.Direction finalDir) {
}

/// <summary>
/// Sets Parking allowed to <paramref name="flag"/> for all directions.
/// Sets Parking allowed to <paramref name="flag"/> for all supported directions.
/// </summary>
/// <returns><c>true</c> on success</returns>
/// <returns><c>false</c>if no there are no configurable lanes.
/// <c>true</c> if any parking rules were applied.</returns>
public bool SetParkingAllowed(ushort segmentId, bool flag) {
bool ret = SetParkingAllowed(segmentId, NetInfo.Direction.Forward, flag);
ret |= SetParkingAllowed(segmentId, NetInfo.Direction.Backward, flag);
Expand Down
3 changes: 2 additions & 1 deletion TLM/TLM/Manager/Impl/SpeedLimitManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -576,9 +576,10 @@ public bool SetSpeedLimit(ushort segmentId,
}

/// <summary>
/// Sets speed limit for all directions.
/// Sets speed limit for all configurable lanes.
/// </summary>
/// <param name="speedLimit">Speed limit in game units, or null to restore defaults</param>
/// <returns><c>false</c>if there are no configurable lanes. <c>true</c> if any speed limits were applied.</returns>
public bool SetSpeedLimit(ushort segmentId, float? speedLimit) {
bool ret = false;
foreach(NetInfo.Direction finaldir in Enum.GetValues(typeof(NetInfo.Direction))) {
Expand Down
5 changes: 2 additions & 3 deletions TLM/TLM/State/Options.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,8 @@ public class Options : MonoBehaviour {
public static bool RoundAboutQuickFix_NoCrossMainR = true;
public static bool RoundAboutQuickFix_NoCrossYieldR = false;
public static bool RoundAboutQuickFix_PrioritySigns = true;
public static bool RoundAboutQuickFix_EnterBlockedRoundabout_Enabled = !false; // TODO
public static bool RoundAboutQuickFix_EnterBlockedRoundabout_Allowed = false;
public static bool RoundAboutQuickFix_RealisticSpeedLimits = !false; // TODO
public static bool RoundAboutQuickFix_KeepClearYieldR = true;
public static bool RoundAboutQuickFix_RealisticSpeedLimits = false;
public static bool RoundAboutQuickFix_ParkingBanMainR = true;
public static bool RoundAboutQuickFix_ParkingBanYieldR = true;
public static bool PriorityRoad_CrossMainR = false;
Expand Down
19 changes: 6 additions & 13 deletions TLM/TLM/State/OptionsTabs/OptionsMassEditTab.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,12 @@ public static class OptionsMassEditTab {
Label = "Roundabout.Option:Set priority signs",
};

public static CheckboxOption RoundAboutQuickFix_EnterBlockedRoundabout_Enabled =
new CheckboxOption("RoundAboutQuickFix_EnterBlockedRoundabout_Enabled") {
Label = "Roundabout.Option:Enter blocked roundabout",
public static CheckboxOption RoundAboutQuickFix_KeepClearYieldR =
new CheckboxOption("RoundAboutQuickFix_KeepClearYieldR") {
Label = "Roundabout.Option:Keep Clear of roundabout.",
Tooltip = "Roundabout.Tooltip:Enter blocked roundabout",
};

public static CheckboxOption RoundAboutQuickFix_EnterBlockedRoundabout_Allowed =
new CheckboxOption("RoundAboutQuickFix_EnterBlockedRoundabout_Allowed") {
Label = "Roundabout.Option:Allowed(on) Banned(off)",
Indent = true,
};

public static CheckboxOption RoundAboutQuickFix_RealisticSpeedLimits =
new CheckboxOption("RoundAboutQuickFix_RealisticSpeedLimits") {
Label = "Roundabout.Option:Assign realistic speed limits to roundabouts",
Expand All @@ -75,7 +69,7 @@ public static class OptionsMassEditTab {
public static CheckboxOption PriorityRoad_AllowLeftTurns =
new CheckboxOption("PriorityRoad_AllowLeftTurns") {
Label = "Priority roads.Option:Allow far turns",
Tooltip = "Priority roads.Tooltipn:Allow far turns"
Tooltip = "Priority roads.Tooltipn:Allow far turns",
};

public static CheckboxOption PriorityRoad_EnterBlockedYeild =
Expand All @@ -86,7 +80,7 @@ public static class OptionsMassEditTab {
public static CheckboxOption PriorityRoad_StopAtEntry =
new CheckboxOption("PriorityRoad_StopAtEntry") {
Label = "Priority roads.Option:Stop signs on entry",
Tooltip = "Priority roads.Tooltip:Stop signs on entry"
Tooltip = "Priority roads.Tooltip:Stop signs on entry",
};
#endregion

Expand All @@ -104,8 +98,7 @@ internal static void MakePanel_MassEdit(UIHelperBase panelHelper) {
RoundAboutQuickFix_StayInLaneNearRabout.AddUI(raboutGroup);
RoundAboutQuickFix_DedicatedExitLanes.AddUI(raboutGroup);
RoundAboutQuickFix_PrioritySigns.AddUI(raboutGroup);
RoundAboutQuickFix_EnterBlockedRoundabout_Enabled.AddUI(raboutGroup);
RoundAboutQuickFix_EnterBlockedRoundabout_Allowed.AddUI(raboutGroup);
RoundAboutQuickFix_KeepClearYieldR.AddUI(raboutGroup);
RoundAboutQuickFix_RealisticSpeedLimits.AddUI(raboutGroup);
RoundAboutQuickFix_ParkingBanMainR.AddUI(raboutGroup);
RoundAboutQuickFix_ParkingBanYieldR.AddUI(raboutGroup);
Expand Down
12 changes: 6 additions & 6 deletions TLM/TLM/UI/SubTools/PrioritySigns/PrioritySignsTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ public enum PrioritySignsMassEditMode {

enum ModifyMode {
None,
PrioirtyRoad,
HighPrioirtyRoad,
HighPrioirtJunction,
PriorityRoad,
HighPriorityRoad,
HighPriorityJunction,
Roundabout,
}
static class PrevHoveredState {
Expand Down Expand Up @@ -189,9 +189,9 @@ ref Singleton<NetManager>.instance.m_segments.m_buffer[
});
}
if (!ControlIsPressed)
mode = ModifyMode.PrioirtyRoad;
mode = ModifyMode.PriorityRoad;
else if (!isRoundabout)
mode = ModifyMode.HighPrioirtyRoad;
mode = ModifyMode.HighPriorityRoad;
else
mode = ModifyMode.Roundabout;

Expand All @@ -200,7 +200,7 @@ ref Singleton<NetManager>.instance.m_segments.m_buffer[
}
} else if (ControlIsPressed) {
MainTool.DrawNodeCircle(cameraInfo, HoveredNodeId, Input.GetMouseButton(0));
mode = ModifyMode.HighPrioirtJunction;
mode = ModifyMode.HighPriorityJunction;
if (mode != PrevHoveredState.Mode || HoveredNodeId != PrevHoveredState.NodeId) {
massEditMode = PrioritySignsMassEditMode.Min;
}
Expand Down
6 changes: 2 additions & 4 deletions TLM/TLM/Util/PriorityRoad.cs
Original file line number Diff line number Diff line change
Expand Up @@ -630,10 +630,8 @@ public static IRecordable ClearRoad(List<ushort> segmentList) {
ParkingRestrictionsManager.Instance.SetParkingAllowed(segmentId, true);
SpeedLimitManager.Instance.SetSpeedLimit(segmentId, null);
VehicleRestrictionsManager.Instance.ClearVehicleRestrictions(segmentId);
foreach (bool startNode in Constants.ALL_BOOL) {
ushort nodeId = netService.GetSegmentNodeId(segmentId, startNode);
ClearNode(nodeId);
}
ClearNode(netService.GetSegmentNodeId(segmentId, true));
ClearNode(netService.GetSegmentNodeId(segmentId, false));
}
return record;
}
Expand Down
10 changes: 5 additions & 5 deletions TLM/TLM/Util/RoundaboutMassEdit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,11 @@ internal static void FixRulesMinor(ushort segmentId, ushort nodeId) {
JunctionRestrictionsManager.Instance.SetLaneChangingAllowedWhenGoingStraight(segmentId, startNode, true);
} // endif

if (OptionsMassEditTab.RoundAboutQuickFix_EnterBlockedRoundabout_Enabled) {
if (OptionsMassEditTab.RoundAboutQuickFix_KeepClearYieldR) {
JunctionRestrictionsManager.Instance.SetEnteringBlockedJunctionAllowed(
segmentId,
startNode,
OptionsMassEditTab.RoundAboutQuickFix_EnterBlockedRoundabout_Allowed);
false);
}

}
Expand Down Expand Up @@ -440,11 +440,11 @@ internal static float CalculateRadius(ref NetSegment segment) {
float r = CalculateRadius(ref segmentId.ToSegment());
float kmph = 11.3f * Mathf.Sqrt(r); // see https://github.com/CitiesSkylinesMods/TMPE/issues/793#issue-589462235
Log._Debug($"CalculatePreferedSpeed radius:{r} -> kmph:{kmph}");
if (float.IsNaN(kmph) || float.IsInfinity(kmph) || kmph < 1) {
if (float.IsNaN(kmph) || float.IsInfinity(kmph) || kmph < 1f) {
return null;
}
if (kmph < 10) {
kmph = 10;
if (kmph < 10f) {
kmph = 10f;
}
return SpeedValue.FromKmph((ushort)kmph);
}
Expand Down

0 comments on commit 3bf8c9f

Please sign in to comment.