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

Themed default speed signs #1320

Closed
wants to merge 14 commits into from
Closed

Conversation

originalfoo
Copy link
Member

@originalfoo originalfoo commented Jan 26, 2022

TMPE.zip

This is based on user-feedback resulting from 11.6.4.0 STABLE release #1221 (comment)

image

This PR adds a new mod option, Options.differentiateDefaultSpeedsInNormalView, which is false by default. It is modified via a CheckboxOption on the General options tab:

image

In normal view / persistent overlays:

  • false: themed icons depict default speeds
  • true: unthemed icons depict default speeds

In defaults view:

  • Unthemed icons always used (existing functionality)

Also fixes the issue with overly large lane icons #1221 (comment)

Screenshots...

Normal mode, option is false (default state):

image

Normal mode, option is true:

image

Defaults mode, regardless of option state:

image

Persistent overlay, option is false:

image

Persistent overlay, option is true:

image

Todo:

  • Localisations

Possible future enhancements:

  • Overlay a small green circle (filled) at bottom of sign to indicate it's default speed limit?

It's placed under existing speed theme stuff on general options tab.
In normal view / persistent overlays:
- Default off, so themed icons shown for default speeds
- When on, unthemed icons will be shown for default speeds
In defaults view:
- Unthemed icons always used (existing functionality)
@originalfoo originalfoo added Localisation Localised text and features DO NOT MERGE YET Don't merge this PR, even if approved, until further notice SPEED LIMITS Feature: Speed limits Settings Road config, mod options, config xml labels Jan 26, 2022
@originalfoo originalfoo added this to the 11.6.5 milestone Jan 26, 2022
@originalfoo originalfoo self-assigned this Jan 26, 2022
@originalfoo
Copy link
Member Author

Might have got a little carried away ...and refactored the segment and lane overlay code. Found what was causing the weird sizing of lane icons so fixed that too. Also, LanePos struct now has finalDirection field which is probably useful in lots of code that uses GetSortedLanes.

Hopefully speed limit overlays are a little faster but I'm not sure how to properly benchmark stuff.

Note: I've not tested the monorail stuff (where it adds an extra icon on roads which contain monorail).

@originalfoo originalfoo added the code cleanup Refactor code, remove old code, improve maintainability label Jan 27, 2022
@originalfoo
Copy link
Member Author

originalfoo commented Jan 28, 2022

@kvakvs In ShowSigns_GUI(), what is the purpose of bool hover - it never seems to get used for anything...? Can it be removed or were there plans to do something with it?

EDIT: I guess if we know mouse hovering an icon in one segment, we don't need to check for hover in any other segments? But rather than passing it around through method returns, it would be better to add to drawEnv?

@originalfoo
Copy link
Member Author

Goal to beat:

11.6.4.2 - Render latency: 23 ms

@kvakvs
Copy link
Collaborator

kvakvs commented Jan 28, 2022

@kvakvs In ShowSigns_GUI(), what is the purpose of bool hover - it never seems to get used for anything...? Can it be removed or were there plans to do something with it?

I think this was used to add to the hovered boxes list on render, but later the code was moved deeper into sub-functions.

@krzychu124
Copy link
Member

Goal to beat:

11.6.4.2 - Render latency: 23 ms

how did you measure that? Stopwatch around the method call or something different? (I usually use ThreadProfiler because of builti-in auto avg time, peak per 64 calls, last call time - nicely browsable with ModTools)

- Most fields in `DrawEnv` now `private set` properties
- Some logic moved to new `ResetCacheIfNecessary()`
- Simplified params of the segment/lane rendering methods
- Cull excess `ContainsMouse()` checks where possible
- Reduced instantiations of `OverlayHandleColorController()`
- Removed some old `hover` code
@originalfoo
Copy link
Member Author

how did you measure that? Stopwatch around the method call or something different? (I usually use ThreadProfiler because of builti-in auto avg time, peak per 64 calls, last call time - nicely browsable with ModTools)

I used nvidia Alt+R overlay which shows total latency for the scene ( game + TM:PE stuff ). Managed to get up to 250ms latency at one point 😂 so did some chainsawing and now it's running about 18-20ms latency. Obviously not a very accurate measure, but at least the framerate isn't tanking like it was earlier today.

If you want to do proper test your way - 11.6.4.2 vs. this PR - that would be much appreciated; for all I know I might still have made it slower than it was before.

I'm going to re-ponder what best field name & text for the new mod option should be, then I'll set that up on Crowdin.

Note there's a blocking PR required to be merged prior to this one; #1321


// Ignore: Bad segments
if (!segment.IsValid()) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed this because it's already included in segment.MayHaveCustomSpeedLimits()

/// <param name="segCenter">Bezier center for the segment to draw at.</param>
/// <param name="camPos">Camera.</param>
/// <param name="args">Render args.</param>
private bool DrawSpeedLimitHandles_PerSegment(ushort segmentId,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This wrapper method became superfluous after refactoring so removed it.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Glad you're having fun 😀

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't find any references to it so hopefully it doesn't break anything heh.

@krzychu124
Copy link
Member

I assume this will also go in 11.6.5 as planned?

@originalfoo
Copy link
Member Author

I assume this will also go in 11.6.5 as planned?

@krzychu124 I'm not sure now. Maybe a better approach would be to always show themed signs in normal/overlay mods but with a "green dot" sub-icon if the speed is same as default for the network. I think that would lead to much smaller code change and be better for end-users.

@originalfoo originalfoo removed this from the 11.6.5 milestone Feb 13, 2022
@krzychu124
Copy link
Member

Question is if they want to know if speed is different than default🤔

@originalfoo
Copy link
Member Author

Question is if they want to know if speed is different than default🤔

Well, if we're adding green blob to bottom of themed sign, it will indicate that segment/lane is using default speed.

No green blob = fully custom speed.

We could flip it the other way round, eg. show some sort of "customised" indicator on the non-default speed icons, but I'm not sure what that icon could look like.

@krzychu124
Copy link
Member

Question is if they want to know if speed is different than default🤔

Well, if we're adding green blob to bottom of themed sign, it will indicate that segment/lane is using default speed.

No green blob = fully custom speed.

Not bad idea, maybe it won't be annoying for users like green signs in US/UK theme or others where signs are not round - you know.. AN (replace speed signs, add stop/yield signs), full immersion 😄

I assume that "defaults speeds mode" remains as is - full green sings?

@originalfoo
Copy link
Member Author

Yes, default speeds will remain with unthemed signs.

I'll have a go later tonight at doing a smaller PR that does the green blobs thing.

I think ideally we need a separate OverlayManager to centralise things like node/segment caches, determination of what mouse is hovering in terms of nodes/segments, persistent overlays (including dev overlays which are currently buried in non-related classes).

@krzychu124
Copy link
Member

I think ideally we need a separate OverlayManager to centralise things like node/segment caches, determination of what mouse is hovering in terms of nodes/segments, persistent overlays (including dev overlays which are currently buried in non-related classes

Yup, I already have some scraps for most performant access to node/segment/vehicles on screen in PF-Sandbox mod. I just need a bit of free time to glue up everything into single overlay manager

@originalfoo originalfoo added this to the Not Applicable milestone Feb 14, 2022
@originalfoo
Copy link
Member Author

Closing in favor of #1404

@originalfoo originalfoo deleted the themed-default-speed-signs branch February 14, 2022 05:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code cleanup Refactor code, remove old code, improve maintainability DO NOT MERGE YET Don't merge this PR, even if approved, until further notice Localisation Localised text and features Settings Road config, mod options, config xml SPEED LIMITS Feature: Speed limits
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants