joaofarias / csl-traffic

A WIP mod for Cities: Skylines to improve traffic.
91 stars 30 forks source link

Mouse over/out RC button deselects active tool #37

Closed originalfoo closed 9 years ago

originalfoo commented 9 years ago

Steps to reproduce:

Open transport menu, subway. Select subway tube tool. Move mouse over towards bulldozer button, crossing over the RC button en route. As soon as the mouse leaves RC button, underground view is disabled.

Also had a user report that it breaks the terraform tool - most likely same issue, moving over then out of the RC button, without clicking, deselects the currently active tool.

joaofarias commented 9 years ago

I haven't been able to fix this yet... Have I said that I hate this UI? :@

originalfoo commented 9 years ago

IIRC the terraform tool button has the same issue.

Might be worth looking at the Favorite Cims mod as that seems to have fixed it: https://github.com/Gianxs/CitiesSkylineFavoriteCimsMod

joaofarias commented 9 years ago

It looks like he uses a panel, instead of a button. Really weird... I'll need some sleep before I can figure it out. :p I'll release the fix in another update.

Archomeda commented 9 years ago

Hmm... well... as I said in the other issue, I have taken a quick look. I can't find anything substantial that might be causing the issue. However, I do notice that you are adding the tool manually to the toolstrip here, while the game itself adds stuff to it by calling a certain method.

The methods are located in Assembly-CSharp. Take a look at GameMainToolbar.RefreshPanel(). It seems that they are adding new entries by calling base.SpawnSubEntry(...), which is located in MainToolbar. This method is protected, so you would have to do some reflection before you can call that. Another note, it seems that the current MainToolbar is accessible as ToolsModifierControl.mainToolbar, which is thankfully public static.

Now, of course, I'm not claiming that this is the issue here, because I really don't know. What I'm doing here is just pure guesswork. But I do think it's worth investigating, especially if you can just call a built-in method to place your tool on the toolbar instead of creating your own code :smile:

joaofarias commented 9 years ago

Well, I'm adding it to the main toolbar strip using a built-in method (AddUIComponent) but I'm not adding it to the GameMainToolbar object. Maybe that's the issue.

Thanks for taking a look. I'll check it out later today and let you know what I find.

Archomeda commented 9 years ago

Well, I'm adding it to the main toolbar strip using a built-in method (AddUIComponent) but I'm not adding it to the GameMainToolbar object.

Yeah, that's what I meant with "adding the tool manually to the toolstrip". Good luck!

joaofarias commented 9 years ago

Will be fixed in next release.