Tmpe: Integration of Vanilla and TMPE priority roads

Created on 2 Nov 2019  路  39Comments  路  Source: CitiesSkylinesMods/TMPE

Currently when using the priority signs tool, holding shift highlights the road (or at least it should). if you Shift+click then it turns the whole highlighted road to priority road by requiring the connected roads to yield. It distinguishes between priority road and connected road by angle. This is done using SegmentTraverser class.

The vanilla game also has a feature to create priority road. but its done slightly differently. It allows you to click on a road and choose a road segment. then puts stop signs on connecting roads.

As you can see in the pictures bellow there is a disconnect between Vanila and TMPE priority roads:
round about segment
semi roundabouts
hover issue long road
hover issue long road2

Each approach has advantages and disadvantages:

  • Vanila: slower but more flexible in terms of selecting what constitutes a priority road (lets call it vanilla road selector). It also cannot add yield signs.
  • TMPE: Its faster to use but less flexible. many people will resort to deleting part of their road in order to limit the length of the priority road. also in complex situation its hard to select what is the priority road. Its also inconsistent with Vanilla.

I suggest to integrate the TMPE and vanilla approaches. We can discuss what the final solution would look like. possible solutions are:

  1. Best of both worlds: when you shift-click with TMPE priority sign tool, it modifies the path selected by the vanilla road selector.
  2. Get rid of the TMPE shift modifier key and instead change the Vanilla UI so that you can choose what to do with the priority road ( eg: yield, stop, etc), .
  3. Don't touch the game UI. instead modify the TMPE settings in terms of what a priority road should do( eg: yield, stop, etc).
    in approach 2 or 3 we can also add functionality for these closely related issues: closely related issues : #541 #539 .

other related issues #29 #7

MASS EDIT PRIORITY SIGNS enhancement

Most helpful comment

I don't even play this game, nor use any mods, but just some feedback. Those icons DO NOT match at all. If I used this mod, I would unsubscribe to this if those icons were posted.

All 39 comments

please assign to me.

I am trying to figure out how to get the selected road segment in my code.

Found it!
Screenshot (5)

I cannot access it from the code:

namespace testspce {
    using System.Diagnostics;
    using ColossalFramework;
    using UnityEngine;
    using UnityEngineInternal;
    using ColossalFramework;
    using ICities;
    public class testclass {
        private void testcode(uint segmentId, uint nodeId) {
            var a = Singleton<NetAdjust>.instance.m_segmentQueue; //error : m_segmentQueue does not exist
            var b = Singleton<NetManager>.instance.NetAdjust.m_segmentQueue; //error : m_segmentQueue does not exist
            var c = NetAdjust.m_segmentQueue; //error : m_segmentQueue does not exist
        }
    }
}

any ideas?

OK Its a private member so I need to use reflection

OK got reflection to work. the variable I am looking for is NetAdjust.tempPath there are other similar variables there too but tempPath is the one we can most easily traverse.

The game can store multiple paths for different roads (Segments cannot be part of 2 paths). I had no luck so far trying to find out where all these paths are stored. I can only get the active path. but maybe that is good enough depending on what we want to do.

I would keep the multi-click for different outcomes TMPE has. Usually, much faster to use than selecting from a menu.
I like the idea of integrating the vanilla priority road builder with TMPE's priority road.
But... I do want to keep the options for yield and stop signs the vanilla game has.

@brunoais That's what I want too. I suspect that's how vast majority of people would like to use this tool in vast majority of situations.
So its the best of both worlds option I talked above. If we want to do that I think I only need to look at the active NetAdjust path. less work for me :)

I am nearly done with this:
The screenshot bellow shows my new UI. The drop box values are : None, Yield, Stop, All. The "ALL" option will fix all traffic rules. The arrears both in Road adjust panel and Road world info panel because usually only one of them is visible.
Screenshot (73)

Any suggestions?

edit:

  • The algorithm shall auto-detect roundabouts (i.e. one way loop)

It's not very clear what the options are doing (unless you already know what they are doing).

Instead of a drop down list, why not use icon buttons? Something like:

When joining this road, drivers should: 馃洃 馃敾

In case of a roundabout detection, a third icon could be added when applicable, for example: 鈿笍. Clicking the roundabout button would apply special ruleset applicable to roundabouts.

The buttons would have useful tooltips, for example (this just off top of my head, needs to be much more concise):

  • Yield: Drivers must yield before joining this road
  • Stop: Drivers must stop before joining this road
  • Roundabout: Apply advanced rules specific to roundabouts

When panel opens, or route altered, scan the "smaller" side-roads linked to the route to see what most of them are using: If that's stop or yield show the associated button as selected, otherwise neither button is selected.

  • Clicking a selected button deselects it, effectively returning smaller-road junctions to vanilla
  • Clicking a non-selected button will select it, applying all relevant customisations to smaller-road junctions

Note also: When adding yield or stop rules, the vanilla stop rule (Junctions tab of Traffic Routes info view) should also be applied. TM:PE will still take precedence but most segment prefabs will show additional on-map signage/decals when the vanilla stop flag is set.

THanks @aubergine10 . you are right. I have to trash my work and use your approach. I need One more Sprite for #541 with the icon of go through blocked junction and/or no left turn.

The "ALL" option will fix all traffic rules.

Could you elaborate on this?

I assume that if user clicks one of the other three (yield, stop, roundabout) it would automatically apply relevant customisations for:

  • Priority signs
  • Junction restrictions
  • Lane arrows (as per #538)
  • And, potentially, even traffic lights where applicable?

@aubergine10

The "ALL" option will fix all traffic rules.

Could you elaborate on this?

it does exactly what #541 does but for the segments selected by the user. that means no left turns go through blocked junctions no zebra crossing on avenue, yield, etc ... and its according to the settings set it in the options.

Are user's choices retained for the road? For example, if I click Yield button, it will set the existing smaller-roads to yield when entering the road, but what if I add new connecting roads, or alter the road route?

Are user's choices retained for the road? For example, if I click Yield button, it will set the existing smaller-roads to yield when entering the road, but what if I add new connecting roads, or alter the road route?

No, but this is not the case in vanilla case either. the vanilla priority road option does not remember your last choice. this is how The vanilla works:

  • if the user turns on the priority road toggle, then put stop signs on all the roads that join the priory road.
  • the next time the user selects the road if: all the roads connected to the current selection have stop signs then automatically turn on the priority button.
  • if the user turns off the priority toggle then remove the stop signs.
  • I think there is also a bug that sometimes it forgets to remove traffic lights.

I am not planning to remember the last choice either. not in my first commit at least.

EDIT: I don't even know where the computer stores selected segments (although I know it does remember the selection). I only know how to access a private variable that has the last selection.

EDIT 2: The vanilla functionality is way too basic and stupid. I never use.

road-edit-btns
My new button textures to put in the adjust road selection panel

Some of those textures already exist, so we should reuse existing ones if possible.

Screenshot (107)
My new UI.

Intended functionality:

  • clicking on any button will highlight that button and set traffic rules. it also removes highlights from other buttons.
  • clicking again on the button removes the highlight and unsets traffic rules.
  • clicking on clear button will clear all traffic rules. This button cannot get activated
  • modifying the road selection will remove highlight from all buttons
  • the code does not remember past road selections. clicking on a different road selection removes highlight from all buttons.
  • clikcing on roundabout button is like #539
  • clickin on enterblocked_allowed button is like #541

tagging @aubergine10

things left to do:

  • [x] Hide Priority road toggle.
  • [ ] put a label for the panels: "set traffic rules"
  • [ ] Implement button functions (blocked by #541 #539 #553 )

Looking good!

Roundabout button

I would expect the roundabout button to only appear if the named road forms a closed loop.

Enter blocked junction button

Do we need the separate Enter blocked junction button? My assumption (and I think users will make the same assumption) would be that selecting either Yield, Stop, or Roundabout, would automatically add/remove the Enter blocked junction where applicable.

Vanilla Stop signs

When applying our Yield/Stop/Roundabout rules, I would expect the vanilla Stop sign (as seen on Junctions tab of Traffic Routes info view) to be applied at any segments that are given a TM:PE-styled Stop or Yield sign.

This is to integrate with roads assets designed to adapt to yeilding/stopping traffic. A good example is the UK Roads Revived roads, which will show a "Give Way" sign and additional decals when vanilla Stop sign is placed.

What if junction has traffic lights?

My assumption is that any junctions with traffic lights will remain unaltered; they will not get Yield, Stop (or vanilla Stop) signs, and will retain their traffic light.

However, I note that TM:PE timed traffic lights has some integration with TM:PE priority signs (if enabled in mod options) so that might need some extra thought?

Vanilla priority road checkbox

I agree that the vanilla "Priority road" checkbox should be removed.

Note however, that vanilla game "remembers" the priority road setting - I just did a quick test and confirmed this.

At a guess, it just checks to see if all applicable side roads have a vanilla Stop sign set. Or it could be setting an as-yet undiscovered flag somewhere (on the road segments perhaps)? Either way, you will have to track down code that sets default state to avoid exceptions once that checkbox has been removed from UI.

If checkbox is removed from UI, disabling or unsubbing TM:PE from main menu should revive it.

Display existing state if possible

This could be done as a later PR, as I expect it is somewhat cumbersome to implement.

I would expect it, if possible, to scan the road to see if applicable side roads are set to one of the configurations. That way I can click a road and see if anything needs updating (if icon is highlighted, I know all the side roads are already configured, otherwise I can choose what config to apply).

Note: _If_ vanilla sets an as-yet undiscovered 'Priority Road' flag somewhere, then we should ideally also set that flag should user choose either Yield, Stop or Roundabout.

Without this, I have no way of knowing if the whole road is configured as I expect it to be and would end up re-applying rules each time "just in case".

UI layout

In terms of UI, it might be worth having a method that adds an extra panel (with the lighter grey background like that shown on Adjust Roads tab) and then put everything in to that. That way, all the functionality will be gathered together coherently and we can add extra stuff to it in future if applicable.

Rough mockup of panel contents:

Which traffic rules should be applied to this road?

馃敾 馃洃 鈿笍 =

Tooltips of icons could be something like (just an initial draft):

  • Yield: Traffic on the road has priority; joining traffic must yield
  • Stop: Traffic on the road has priority; joining traffic must stop
  • Roundabout: Apply special roundabout rules
  • Equal: Treat all traffic equally; remove any priority rules

On the Adjust Roads tab, the panel would be added below the existing vanilla panel. On the Road info popup, the panel would be added below the existing content.

Some additional stuff to check:

  • What happens if user tries using this on tram/rail/monorail/metro/etc?

    • In vanilla, stand-alone dedicated tram tracks can be marked "Priority road"

    • In vanilla, train tracks can have stop signs, both at junctions (including the outer side of "X" junctions either side of stations), level crossings and tunnel entrances.

    • I've never personally tried on monorail or metro, so no idea what happens there.

  • Speaking of level crossings, make sure to test those ;)
  • Do the buttons auto-apply things like separate turning lanes and lane arrows where applicable (maybe via mod option?)

    • If so, I assume it will still allow traffic to cross to opposite side on small roads (or roads with m_canCrossLanes flag)?

These buttons look so ugly! The back ground button shape is a circle that is barely bigger than the symbol itself. I think it should be a bigger square. Also the sprites do not have to be filled in.
Screenshot (107)

EDIT: I might take some sprites from #523

I am struggling to find a good sprite to use for the button responsible for quick-setup of priority road. any ideas?
tagging @kvakvs @aubergine10

Make a temporary ugly sprite. Show it to us and we might be able to improve it.
Or someone can feel inspiration and combine 1-2 free icons for you in Ms Paint.

@kvakvs well now I am going to use this:
sign_priority
EDIT: the edges are supposed to be white.

New sprites
road-edit-btns2

I modified LinearSpirte to add support for disabled buttons. The buttons can now have 3 states(the number of states is configurable).

  • State disabled: when user has not selected any road/roundabout
  • State deactive: when the user has a valid road selection. Clicking will results in setting up traffic rules and sending the button to active state.
  • State active: Clicking will clears the changes the user has done. ( in future we can have a more clever undo. related: #568).
    road-edit-btns3.

Added Created OnSelectionChange event for when user changes path selection.

This task is nearly complete.

  • [x] I am going to improve the sprites a little bit more
  • [x] I will disable the yellow diamond button because it depends on #541.
  • [x] The functionality of Clear button is limited (only removes priority signs) pending #623.
  • [ ] I will enable traffic rule overlay when road selection panel is open even when the tool is not active

The images bellow show the round about button in disabled(selection is not a round about), enabled (selection is a roundabout), active states(round about rules applied). clicking an active button again will undo traffic rules (undo is simplistic pending #568)

Screenshot (335)
Screenshot (337)
Screenshot (338)
Screenshot (339)

Ok now that i've seen it on the real UI not just sprites.
The style you've chosen for icons, background, and size does not match game UI at all. Can you copy game colors more closely at least for the backgrounds?

@kvakvs thanks for the feedback.
I wish to create pull review for this soon. Is there anything else you want to add?
tagging @aubergine10

New sprites
road-edit-btns

screenshots show how buttons appear.
Screenshot (349)

Mass edit overlay is enable while road selection panel is active.
Screenshot (348)

this work is complete. I will polish the code and put it for review.

I don't even play this game, nor use any mods, but just some feedback. Those icons DO NOT match at all. If I used this mod, I would unsubscribe to this if those icons were posted.

And what would you make them look like @Goomig ? We're always open to suggestions :)

Idk man they look really poppy

They look to 'noticeable'

I can make them smaller. Icon design is not my specialty.
The colors are the same as game colors. The size is bigger. I was struggling with circular borders so I made it rectangle.

The game buttons have fewer states than my. when the game button is in active state it does not change face when mouse hovers or mouse is pressed.

The UI stuff @kvakvs is working on should make button states easier.

I can make them smaller. Icon design is not my specialty.
The colors are the same as game colors. The size is bigger. I was struggling with circular borders so I made it rectangle.

The game buttons have fewer states than my. when the game button is in active state it does not change face when mouse hovers or mouse is pressed.

I apologize for being a douche about the icons. They do look really nice, the only thing I would change is the gradient on the boxes. I'm getting a very nice Flat UI Feel.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

aubergine10 picture aubergine10  路  41Comments

aubergine10 picture aubergine10  路  32Comments

scottmcm picture scottmcm  路  29Comments

kianzarrin picture kianzarrin  路  68Comments

aubergine10 picture aubergine10  路  25Comments