Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Speed Limit tool - Lane highlighting #709

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 24 additions & 14 deletions TLM/TLM/Manager/Impl/SpeedLimitManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -546,26 +546,30 @@ private void UpdateNetInfoGameSpeedLimit(NetInfo info, float gameSpeedLimit) {
/// <param name="laneIndex"></param>
/// <param name="laneInfo"></param>
/// <param name="laneId"></param>
/// <param name="speedLimit">Game speed units, 0=unlimited</param>
/// <param name="speedLimit">Game speed units, 0=unlimited, null=default</param>
/// <returns>Returns <c>true</c> if successful, otherwise <c>false</c>.</returns>
public bool SetSpeedLimit(ushort segmentId,
uint laneIndex,
NetInfo.Lane laneInfo,
uint laneId,
float speedLimit) {
float ?speedLimit) {
if (!MayHaveCustomSpeedLimits(laneInfo)) {
return false;
}

if (!IsValidRange(speedLimit)) {
if (speedLimit != null && !IsValidRange((float)speedLimit)) {
return false;
}

if (!Services.NetService.IsLaneValid(laneId)) {
return false;
}

Flags.SetLaneSpeedLimit(segmentId, laneIndex, laneId, speedLimit);
if (speedLimit != null) {
Flags.SetLaneSpeedLimit(segmentId, laneIndex, laneId, speedLimit);
} else {
Flags.RemoveLaneSpeedLimit(laneId);
}
return true;
}

Expand All @@ -574,16 +578,16 @@ public bool SetSpeedLimit(ushort segmentId,
/// </summary>
/// <param name="segmentId"></param>
/// <param name="finalDir"></param>
/// <param name="speedLimit"></param>
/// <param name="speedLimit">Game speed units, 0=unlimited, null=default</param>
/// <returns></returns>
public bool SetSpeedLimit(ushort segmentId, NetInfo.Direction finalDir, float speedLimit) {
public bool SetSpeedLimit(ushort segmentId, NetInfo.Direction finalDir, float ?speedLimit) {
if (!MayHaveCustomSpeedLimits(
segmentId,
ref Singleton<NetManager>.instance.m_segments.m_buffer[segmentId])) {
return false;
}

if (!IsValidRange(speedLimit)) {
if (speedLimit != null && !IsValidRange((float)speedLimit)) {
return false;
}

Expand All @@ -599,7 +603,7 @@ public bool SetSpeedLimit(ushort segmentId, NetInfo.Direction finalDir, float sp

if (segmentInfo.m_lanes == null) {
#if DEBUG
Log.Warning($"SpeedLimitManager.SetSpeedLimit: info.name is null!");
Log.Warning($"SpeedLimitManager.SetSpeedLimit: info.m_lanes is null!");
#endif
return false;
}
Expand All @@ -617,12 +621,18 @@ public bool SetSpeedLimit(ushort segmentId, NetInfo.Direction finalDir, float sp
if (!MayHaveCustomSpeedLimits(laneInfo)) {
goto nextIter;
}
#if DEBUG
Log._Debug(
$"SpeedLimitManager: Setting speed limit of lane {curLaneId} " +
$"to {speedLimit * Constants.SPEED_TO_KMPH}");
#endif
Flags.SetLaneSpeedLimit(curLaneId, speedLimit);

if (speedLimit != null) {
Log._Debug(
$"SpeedLimitManager: Setting speed limit of lane {curLaneId} " +
$"to {speedLimit * Constants.SPEED_TO_KMPH}");
Flags.SetLaneSpeedLimit(curLaneId, speedLimit);
} else {
Log._Debug(
$"SpeedLimitManager: Setting speed limit of lane {curLaneId} " +
$"to default");
Flags.RemoveLaneSpeedLimit(curLaneId);
}

nextIter:
curLaneId = Singleton<NetManager>.instance.m_lanes.m_buffer[curLaneId].m_nextLane;
Expand Down
Binary file removed TLM/TLM/Resources/RoadUI/remove_signs.png
Binary file not shown.
2 changes: 2 additions & 0 deletions TLM/TLM/Resources/Translations/SpeedLimits.csv
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@
"Defaults.Label:Road type","Straßentyp","Road type","Tipo de carretera","Type de route","Út típusa","Tipo di strada","道路の種類","도로 유형","Wegtype","Typ drogi","Tipo de pista","Тип дороги","道路類型","道路类型","Road type","Yol tipi","Тип дороги"
"Button:Save & Apply","Anwenden","Apply","Aplicar","Appliquer","Alkalmaz","Applica","適用","적용","Toepassen","Zastosuj","Aplicar","Применить","儲存並套用","应用","Apply","Uygula","Зберегти і застосувати"
"Checkbox:Show lane-wise speed limits","Zeige spurweise Geschwindigkeitsbeschränkungen","Show lane-wise speed limits","Mostrar límite de velocidad en el carril","Afficher les limites de vitesse par voie","Mutassa meg a sáv szerinti sebességkorlátozásokat","Mostra i limiti di velocità per ogni corsia","車線毎の制限速度を表示する","차선별 속도 제한 표시","Toon rijstrookspecifieke snelheidslimieten","Pokaż limity prędkości dla pasów","Mostrar limites de velocidade por faixa.","Показывать ограничения по каждой полосе","顯示車道速限","显示各车道道路限速设置","Show lane-wise speed limits","Şerite göre azami hızları göster","Показувати обмеження в кожній смузі"
"Checkbox:Apply to entire road","","Apply to entire road","","","","","","","","","","","","","Apply to entire road","",""
"Button:Default","","Default","","","","","","","","","","","","","Default","",""
Binary file added TLM/TLM/Resources/clear.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions TLM/TLM/TLM.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
Expand Down Expand Up @@ -351,6 +351,7 @@
<EmbeddedResource Include="Resources\MainMenu\noimage.png" />
<EmbeddedResource Include="Resources\MainMenu\remove-btn.png" />
<EmbeddedResource Include="Resources\MainMenu\WindowBackground.png" />
<EmbeddedResource Include="Resources\clear.png" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Resources\RoadUI\bicycle_infosign.png" />
Expand All @@ -362,7 +363,6 @@
<EmbeddedResource Include="Resources\RoadUI\parking_disallowed.png" />
<EmbeddedResource Include="Resources\RoadUI\passengercar_infosign.png" />
<EmbeddedResource Include="Resources\RoadUI\passengertrain_infosign.png" />
<EmbeddedResource Include="Resources\RoadUI\remove_signs.png" />
<EmbeddedResource Include="Resources\RoadUI\service_infosign.png" />
<EmbeddedResource Include="Resources\RoadUI\sign_none.png" />
<EmbeddedResource Include="Resources\RoadUI\sign_priority.png" />
Expand Down
3 changes: 2 additions & 1 deletion TLM/TLM/UI/Helpers/SegmentLaneMarker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ internal SegmentLaneMarker(Bezier3 bezier) {
}

internal Bezier3 Bezier;
internal float Size = 1.1f;

private Bounds[] bounds;

Expand Down Expand Up @@ -103,7 +104,7 @@ internal void RenderOverlay(RenderManager.CameraInfo cameraInfo, Color color, bo
cameraInfo,
color,
Bezier,
enlarge ? 1.55f : 1.1f,
enlarge ? Size * 1.41f : Size,
0,
0,
minH - 100f,
Expand Down
2 changes: 1 addition & 1 deletion TLM/TLM/UI/SubTools/PrioritySignsTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ private void ShowGUI(bool viewOnly) {
// draw remove button and handle click
if (showRemoveButton
&& MainTool.DrawHoverableSquareOverlayTexture(
RoadUI.SignRemove,
RoadUI.SignClear,
camPos,
nodePos,
90f)
Expand Down
Loading