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

New Speed Limits UI #1168

Merged
merged 61 commits into from
Dec 9, 2021
Merged
Show file tree
Hide file tree
Changes from 52 commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
7ae637e
Speedlimits UI changes preparation: Changes to U library
kvakvs Sep 12, 2021
b250236
Remove Redirection Framework
kvakvs Oct 3, 2021
0e415a9
Speed Limits UI: New textures, new overlay and util classes
kvakvs Oct 18, 2021
3301b4b
Rebase on fresh master
kvakvs Oct 18, 2021
6ed359a
Merge branch 'master' into u-speedlimits-tool-7
kvakvs Nov 14, 2021
22ec96a
Fixes for after master was merged
kvakvs Nov 14, 2021
4d80bfb
laneSpeedLimit and laneSpeedLimitArray use game units for speed
kvakvs Nov 15, 2021
31448bd
SetLaneSpeedLimit accepts action with null override, but requires it …
kvakvs Nov 15, 2021
b47ff59
Tooltip position for speedlimits is now corrected for UIScale. UI fon…
kvakvs Nov 16, 2021
60b58ed
Do not recreate Speed Limits tool window if MPH setting was not chang…
kvakvs Nov 16, 2021
01d9291
On tool reactivation, visible segments and segment centers cache is c…
kvakvs Nov 16, 2021
ae77565
Check for Null when rendering overlay, if window has not been yet cre…
kvakvs Nov 16, 2021
ec7897a
SetSpeedLimitAction.cs: Speed limit value is now guarded, and only ac…
kvakvs Nov 21, 2021
cbe20d5
Minor cosmetics for SegmentLaneMarker.cs, moved useful function IsUnd…
kvakvs Nov 22, 2021
d327e4a
WIP render segment center signs
kvakvs Nov 26, 2021
05c126b
Merge Master into U-Speedlimits-Tool-7
kvakvs Nov 26, 2021
42eec09
Show single speed limit mode for segments; average value for both dir…
kvakvs Nov 27, 2021
4940d9c
Set speed limits for segment
kvakvs Nov 27, 2021
8353d1e
Render seg-default speed limit if Alt is held
kvakvs Nov 27, 2021
8929f32
Triple mode for edit Segments, Lanes and Defaults. Holding alt shows …
kvakvs Nov 27, 2021
10a7518
Draw circle with default speed limit, when no override. Fix for recta…
kvakvs Nov 27, 2021
d0f02ca
Review cleanup
kvakvs Nov 28, 2021
1a9a15f
Null window check for getting the mouse coords
kvakvs Dec 1, 2021
ad8cb8e
Krzychu's fix to parking manager freeze bug
kvakvs Dec 1, 2021
f408bfa
Merge master
kvakvs Dec 1, 2021
5d5ac2b
Keybind for speed limits now opens speed limits; Holding Alt will not…
kvakvs Dec 3, 2021
ab8fb29
Draw hovered segments and lanes (even more than one if mouse hovers o…
kvakvs Dec 3, 2021
d324e73
Speed limits Translations: English, Russian, Ukrainian
kvakvs Dec 4, 2021
e243837
Events in ModUI grouped into a inner class; New event for UI Language…
kvakvs Dec 4, 2021
4352e6f
Lane highlight for speed limits lane mode with Shift; Warning for che…
kvakvs Dec 4, 2021
caa2faa
Overlay drawing code moved
kvakvs Dec 4, 2021
c4c8bfb
Down arrow is rendered for speed limit icons of underground nodes
kvakvs Dec 4, 2021
9b4a9df
Disabled sign fading due to bug in screen UI scaling calculations
kvakvs Dec 4, 2021
f10a565
Fixed screen position calculations for GUI rects and fading signs
kvakvs Dec 4, 2021
aad56e0
Underground nodes don't show in overground mode. Added hint for that
kvakvs Dec 4, 2021
294d562
Language change makes the speed limits window wonky. Close it.
kvakvs Dec 4, 2021
14b216e
Merge branch 'master' into u-speedlimits-tool-7
kvakvs Dec 4, 2021
26ee314
More review/testing fixes: Cosmetic window sizing and special palette…
kvakvs Dec 5, 2021
dc5d80d
UI Changes: Default button moved left; Text labels in form removed; B…
kvakvs Dec 5, 2021
e9d42c5
New event for display MPH checkbox change (when switching road sign s…
kvakvs Dec 5, 2021
c09f33d
Window draghandle size fix; Reset defaults now working again.
kvakvs Dec 6, 2021
6d62ddf
Tooltips hide over GUI
kvakvs Dec 6, 2021
46a6039
Increase max overlay distance for road signs. Render road without ove…
kvakvs Dec 6, 2021
1a408d2
Aubergine10: Buttons contain themed signs, replace with blue sausages
kvakvs Dec 6, 2021
2506eca
Draw large blue speed limit defaults in lane mode
kvakvs Dec 6, 2021
a693735
Reload atlases in debug but keep in release
kvakvs Dec 6, 2021
39d2618
Green road signs; / and Delete keybinds; No numbered keybinds, no +- …
kvakvs Dec 6, 2021
6c8ce5f
Ctrl, select +- keys, slash, delete keys; Translations for new keybinds
kvakvs Dec 6, 2021
491fc62
Form is now focused to allow keybinds to work; Esc now closes tool an…
kvakvs Dec 7, 2021
d0936ef
Overlay icons do not fade; UI intersection test now checks OSD panel.
kvakvs Dec 7, 2021
aa20d01
Unlimited button is now placed 2nd, is blue and behaves like a speed …
kvakvs Dec 7, 2021
73ab6fa
Keypress does not work as good as Keyup.
kvakvs Dec 7, 2021
061be92
Holding Alt shows defauls; Holding Alt in defaults shows override; Al…
kvakvs Dec 7, 2021
eaf4eda
Merge branch 'master' into u-speedlimits-tool-7
kvakvs Dec 8, 2021
f668a8f
notify speed limit changes in the new speed limit manager
kianzarrin Dec 8, 2021
623cdbe
Check IsValid() on segments
kvakvs Dec 8, 2021
bd35801
Destroy tool window on language change; Rebuild on tool activation
kvakvs Dec 8, 2021
0680159
Unlimited button goes right most, but label hangs out and its fine fo…
kvakvs Dec 8, 2021
0c04d80
In debug build, fade overlay under debug menu while speed limits tool…
kvakvs Dec 8, 2021
a4af5b5
Test netinfo name vs vanilla asset names collection, to filter out te…
kvakvs Dec 8, 2021
cc74853
Translations; UI buttons 40px now to match main menu; Minor corrections
kvakvs Dec 9, 2021
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
18 changes: 17 additions & 1 deletion TLM/TLM/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ namespace TrafficManager {
using TrafficManager.API.Manager;
using UnityEngine;
using TrafficManager.API.Notifier;
using TrafficManager.U;

public static class Constants {
/// <summary>
Expand All @@ -22,8 +23,23 @@ public static class Constants {
public const float SPEED_TO_MPH = 32.06f; // 50 km/h converted to mph

/// <summary>
/// The maximum amount of segments a node can hold.
/// Screen pixel size for overlay signs, such as one-per-segment speed limits.
/// </summary>
public static float OverlaySignVisibleSize => 100.0f * UIScaler.UIScale;

/// <summary>
/// World size for clickable signs used in overlays. Larger than readonly signs.
/// This is used as offset in grids of signs such as lane speed limit signs.
/// </summary>
public const float OVERLAY_INTERACTIVE_SIGN_SIZE = 6.0f;

/// <summary>
/// World size for readonly signs used in overlays.
/// This is used as offset in grids of signs such as lane speed limit signs.
/// </summary>
public const float OVERLAY_READONLY_SIGN_SIZE = 3.8f;

/// <summary>The maximum amount of segments a node can hold.</summary>
public const int MAX_SEGMENTS_OF_NODE = 8;

public static float ByteToFloat(byte b) {
Expand Down
2 changes: 2 additions & 0 deletions TLM/TLM/Manager/Impl/AdvancedParkingManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2551,6 +2551,8 @@ bool LoopHandler(int i, int j) {
} // if find parking prop at building

buildingId = building.m_nextGridBuilding;
building = ref buildingId.ToBuilding();

if (++numIterations >= 49152) {
CODebugBase<LogChannel>.Error(
LogChannel.Core,
Expand Down
34 changes: 19 additions & 15 deletions TLM/TLM/Manager/Impl/SpeedLimitManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,12 @@ private bool MayHaveCustomSpeedLimits([NotNull] NetInfo.Lane laneInfo) {
laneIndex++;
}

if (validLanes > 0) {
meanSpeedLimit = meanSpeedLimit.Scale(1.0f / validLanes);
switch (validLanes) {
case 0:
return null;
case > 0:
return meanSpeedLimit.Scale(1.0f / validLanes);
}

return meanSpeedLimit;
}

/// <summary>
Expand Down Expand Up @@ -511,10 +512,13 @@ public bool SetLaneSpeedLimit(ushort segmentId,
return false;
}

Log._Assert(action.Override != null, "action.Override != null");
if (action.Type == SetSpeedLimitAction.ActionType.ResetToDefault) {
Flags.RemoveLaneSpeedLimit(laneId);
return true;
}

if (action.Type != SetSpeedLimitAction.ActionType.ResetToDefault
&& !IsValidRange(action.Override.Value.GameUnits)) {
&& !IsValidRange(action.GuardedValue.Override.GameUnits)) {
return false;
}

Expand All @@ -523,15 +527,17 @@ public bool SetLaneSpeedLimit(ushort segmentId,
return false;
}

if (action.Type != SetSpeedLimitAction.ActionType.ResetToDefault) {
Flags.SetLaneSpeedLimit(segmentId, laneIndex, laneId, action);
} else {
Flags.RemoveLaneSpeedLimit(laneId);
}
Flags.SetLaneSpeedLimit(segmentId, laneIndex, laneId, action);

return true;
}

public void ResetCustomDefaultSpeedlimit([NotNull] string netinfoName) {
if (this.customLaneSpeedLimitByNetInfoName_.ContainsKey(netinfoName)) {
this.customLaneSpeedLimitByNetInfoName_.Remove(netinfoName);
}
}

/// <summary>Sets speed limit for all configurable lanes.</summary>
/// <param name="action">Speed limit in game units, or null to restore defaults.</param>
/// <returns>
Expand Down Expand Up @@ -562,10 +568,8 @@ public bool SetSegmentSpeedLimit(ushort segmentId,
return false;
}

Log._Assert(action.Override != null, "action.Override != null");

if (action.Type == SetSpeedLimitAction.ActionType.SetOverride
&& !IsValidRange(action.Override.Value.GameUnits)) {
&& !IsValidRange(action.GuardedValue.Override.GameUnits)) {
return false;
}

Expand Down Expand Up @@ -601,7 +605,7 @@ public bool SetSegmentSpeedLimit(ushort segmentId,
Flags.RemoveLaneSpeedLimit(curLaneId);
} else {
bool showMph = GlobalConfig.Instance.Main.DisplaySpeedLimitsMph;
string overrideStr = action.Override.Value.FormatStr(showMph);
string overrideStr = action.GuardedValue.Override.FormatStr(showMph);

Log._Debug(
$"SpeedLimitManager: Setting lane {curLaneId} to {overrideStr}");
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading