Jump to content
Elektrix

Elektrix: Net Picker Tool, Segment Slope Smoother Mod, and more!

24 posts in this topic Last Reply

Highlighted Posts

Posted:
Last Online:  
 

Well, I decided to make a simple mod finally:

2c47f8d7e2b089da13e003770ee7eb48.gif

It allows users to select a series of nodes they want to be smoothed in any order and smooth them out linearly. If anyone wants to test it out before I finalize it and publish it, (first of all thank you so much! I need to find and fix as many bugs as possible!) you can either download the beta from this post (or from Github) and install it manually, or friend me on Steam and subscribe to it there (I have the beta version uploaded and marked as friends only). 

Here is the source code in its current state (unrefined and definitely not polished).

I've had a few smaller issues that are not technically too important to the final development and release of the mod, but I've been confused about:
1. How do I include custom icons for buttons? I experimented with SamsamTS's ResourceLoader.cs (used in MoveIt and other mods by him), but I simply couldn't get it to work correctly in my setup so I eventually gave up. And ultimately, I'm not even sure if I have the right to use his ResourceLoader (even with credit), and I'd hate to get my first uploaded mod taken down.

2. How do I use non-textured UIPanels correctly? Whenever I don't specify a bgSprite texture for UIPanels, I can no longer locate them in the ModTools Scene Explorer or using UIView.Find("PanelName"), yet the cinematic camera button has an invisible UIPanel behind it and seems to be normal and working fine. All I really want is for all the elements to not be subject to the same events as the parent element.

I have a bunch of other ideas for simple mods once I get this one polished and done, so I figure I'll just post them and any other future assets I create in this thread. :) 

Sorry if I sound rushed or anything, it's nearly midnight where I live and I'm pretty tired (although classes are finally over for winter so I won't be tired for long!). Thanks for any help.

All My Other C:SL Projects
Sketchup to Cities: Skylines Helper + Tutorial
JavaScript to create Steam collections of unused assets

NodeTools.dll

  • Like 6
  • Thanks 1

Hello! Salut! Привет! | My Workshop (follow me? :]) • My Github • My Twitter

 

Share this post


Link to post
Share on other sites
Posted:
Last Online:  
 

Hey !

Really great l! What a simple but very very useful idea to correct networks after you build them !! No need to demolish and rebuild them anymore or to spend to much 

time correcting them manually one by one (that s what I do the whole time ... :/ ) .... Thanks for that ! 

 

  • Like 1

Share this post


Link to post
Share on other sites
Posted:
Last Online:  
 

Regarding 1.: For NetworkSkins, I used a library made by PropaneDragon. It's called CimTools. This class in particular:

https://github.com/PropaneDragon/CimTools/blob/master/CimTools/v2/Utilities/SpriteUtilities.cs

Usage:

https://github.com/boformer/NetworkSkins/blob/master/NetworkSkins/UI/UINetworkSkinsPanel.cs#L148-L178

https://github.com/boformer/NetworkSkins/blob/master/NetworkSkins/UI/UINetworkSkinsPanel.cs#L54-L56

I bundled the DLL with my mod. Probably it would be better to just copy the class. At some point SamsamTS also used it. I'm sure that SamsamTS doesn't mind it if you use his code, just give him credit.

Share this post


Link to post
Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     

    Net Picker Mod!

    Since I have half a trillion subscribed roads and it takes forever to scroll to them in my browser I'm once again making a simple mod to facilitate my laziness. I can't really take credit for the idea though; it was spoken of in passing by AmiPolizeiFunk, so... thanks, I stole your idea :). This mod is basically a color picker, but instead of colors, you can pick net types. (You can click on a road to select its type and then use it.) Here's me using it in REALLY REALLY LOW RES (be warned!) (The game looks awful because I'm on my modding computer and I don't have any graphical mods installed.) This is a very simple mod and it took less than two days of off-and-on writing, testing, and bugfixing to finish; I'm actually surprised it's not in the base game already. The UI integrates with Segment Slope Smoother's panel and if Segment Slope Smoother is not subscribed then it creates its own. Hooray for compatibility! I plan on releasing it at midnight on January 1st so that it's the first mod of the year (at least in my time zone).

    Speaking of SSS, it received a bugfix; I was unaware that the Default Tool had to be re-enabled if another custom tool is used... you would think that it would be obvious to me, but apparently not.

    • Like 3
    • Thanks 1

    Hello! Salut! Привет! | My Workshop (follow me? :]) • My Github • My Twitter

     

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     

    Awesome !!! Really !!! I got rid of the extended toolbar during my "cleaning session" to improve my fps a little bit ..... But without that mod finding the right assets is defenetly really time consuming ... :/ this one will bring back some wasted time scrolling through the menu... Thanks a lot... both of you guys...I haven't had such an idea in mind ;)

    • Like 1

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     

    Did you test it with elevated, bridge and underground segments?

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     

    Yes; at this point I have the following code to turn those segments back to the default elevation after searching and failing to find a built-in method that does it:

    string correctedName = m_netInfo.name
    	.Replace("Elevated", "")
    	.Replace("Bridge", "")
    	.Replace("Tunnel", "")
    	.Replace("Slope", "");
    NetInfo correctedInfo = PrefabCollection<NetInfo>.FindLoaded(correctedName);
    if (correctedInfo == null) return;
    m_netInfo = correctedInfo;
    
    m_netTool.Prefab = m_netInfo;

    The only thing that is currently bothering me is 1) incorrectly named elevations of modded roads and 2) metro tunnels. I really wish there were a simple hook to find the default for any given NetInfo, but I can't seem to figure out how the game does it in NetTool. I'm currently looking through NetAI to find something like it as it has some promising functions (as well as going through ElectricityManager for that other project).

    Phone edit: I think it’s in RoadAI. I can check the current NetInfo against each of the prefabs there and then choose the default accordingly. I’ll look some more (and make sure that I have it totally figured out) when I have ILSpy at home and not just text files on my phone.:)

    Phone Edit #2: I was at home for a brief second and had a chance to assure that what I think I saw exists. It turns out that there’s a simple hook to get every elevation for nets except the default one, so I’ve reverse engineered that function and hopefully gotten what I think will be the default elevation, although I did not have time to test it. 


      Edited by Elektrix  

    Phone edit #2

    Hello! Salut! Привет! | My Workshop (follow me? :]) • My Github • My Twitter

     

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     

    Wow you went and made it. Nice! This little mod would have made working with the 150+ CSUE/CSUR roads a million times easier. 

     

    So it's just for roads tho? Really it would be awesome if it was a universal eyedropper for anything in the game. *:8)

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     

    Well, I had figured that since Move It had a copy and paste feature, other thing-pickers wouldn’t really be necessary. That being said, I figure it wouldn’t be that hard to make another part of this mod, and as I’ve already stolen one of your ideas I see no reason why I can’t steal more... ;) 


    Hello! Salut! Привет! | My Workshop (follow me? :]) • My Github • My Twitter

     

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     

    I guess you're right about the copying w MoveIt. I'm trying to think of other cases where an eyedropper would be useful but I'm coming up short. Sometimes you just want to know what a thing is or what it's called... like a prop. It would be cool if the eyedropper would put you in the UI menu where the thing is from, so you could see its name.

    • Like 1

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     
    On 30.12.2018 at 3:39 PM, Elektrix said:

    Phone edit: I think it’s in RoadAI. I can check the current NetInfo against each of the prefabs there and then choose the default accordingly. I’ll look some more (and make sure that I have it totally figured out) when I have ILSpy at home and not just text files on my phone.:)

    Yes, you are on the right track. There are also AIs for train tracks, pedestrian paths, monorail etc. with similar fields.

    There's also a RoadTunnelAI which doesn't seem to have those fields.

    Maybe you could perform a reverse search: Iterate through all NetInfos are visible in the roads menu (m_availableIn), then check if their AI contains the variation the user selected.

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     
    On 12/31/2018 at 9:55 AM, boformer said:

    Yes, you are on the right track. There are also AIs for train tracks, pedestrian paths, monorail etc. with similar fields.

    There's also a RoadTunnelAI which doesn't seem to have those fields.

    Maybe you could perform a reverse search: Iterate through all NetInfos are visible in the roads menu (m_availableIn), then check if their AI contains the variation the user selected.

    Yeah, that's more or less what I have now:

    public NetInfo FindDefaultElevation(NetInfo info){
      for (uint i = 0; i < PrefabCollection<NetInfo>.LoadedCount(); i++)
      {
        NetInfo prefab = PrefabCollection<NetInfo>.GetLoaded(i);
        if((AssetEditorRoadUtils.TryGetBridge(prefab) != null && AssetEditorRoadUtils.TryGetBridge(prefab).name == info.name) || 
           (AssetEditorRoadUtils.TryGetElevated(prefab) != null && AssetEditorRoadUtils.TryGetElevated(prefab).name == info.name) || 
           (AssetEditorRoadUtils.TryGetSlope(prefab) != null && AssetEditorRoadUtils.TryGetSlope(prefab).name == info.name) || 
           (AssetEditorRoadUtils.TryGetTunnel(prefab) != null && AssetEditorRoadUtils.TryGetTunnel(prefab).name == info.name) ){
          return prefab;
        }
      }
      return info;
    }

    Additionally, I didn't get the promotional pictures done in time to release in 40 minutes and I'm honestly super tired from some other work, so I'll have to do them tomorrow (or later today depending on where one may live), and I'll release it later. Also, happy 2019.

    On an unrelated note, I've discovered a weird quirk when loading external .dll libraries alongside mod executables: if you return to the main menu and turn off a mod that uses the same external .dll library in a different place, the library is turned off for the other mods too. I got super confused when I saw the no-icons fallback version of the mod on my screen after reloading.

    January 1 edit: I can't upload anything to the Steam workshop. Whenever I try to upload, the workshop makes 30 blank and permanently hidden assets on my profile. I looked up the issue to see if anyone else had it, and other people do. I'm not really sure how to fix this, as I tried uploading it manually through the ModTools console and still came up with blank assets. Rats!


    Hello! Salut! Привет! | My Workshop (follow me? :]) • My Github • My Twitter

     

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     

    I like the idea of this eye dropper tool for networks but can you consider restricting it to networks that aren't inside assets? (like moveit now excludes them) as there are some cases where there are custom networks embedded in an asset that really should not be used in the open game - and they are deliberately hidden by default but with mods like this and findIt! people are taking it upon themselves to try and use these and tehn complain when they can't get them to work (even though they're not supposed to try :( )


    Come follow me on Twitter @CS_badpeanut 🥜 or Facebook!

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     

    Didn't we convince Samsam to re-include them in MoveIt? We all made a big fuss because we sometimes need to use "TouchThis" and MoveIt to adjust tracks in stations. I think he re-included them in the end and I'm glad.

     

    If somebody breaks a station by using touchthis and moveit, it's their own damn fault imo. Who cares if they complain, just ignore them. We already have the power to massively break stuff w moveit so I don't think there's any reason to take that approach when it comes to stations.

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     
    15 minutes ago, AmiPolizeiFunk said:

    MoveIt to adjust tracks in stations. I think he re-included them in the end and I'm glad.

    THIS IS WHAT BREAKS TRAIN STATIONS hahahaha

    it's so frustrating - i get at least one person a week complaining about no passengers using a station and it's because they've chosen to move the tracks around which disrupts the placement of the hidden paths. hahahaa i think he added it back as an option if you hold down alt, but it doesn't do it by default

    but yeah i just tell them not to interfere with it.


    Come follow me on Twitter @CS_badpeanut 🥜 or Facebook!

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     

    It would be cool if it was compatible with NetworkSkins. Or I will steal the idea with your permission and include a pipette tool in NetworkSkins

    • Like 2

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     

    I'm not quite sure how to programmatically detect when specific networks should be "hidden" or not; else, I would have already included a checkbox that enables "dev mode" so that normal people won't have access to these offending prefabs. On the other hand, I would hate to not be able to select MoM tracks anymore, because they're technically hidden too. If I can find a way to do that, I will make said update because I've already received a few very questionable bug reports on both mods.

    Ultimately I agree with AmiPolizeiFunk though. That's the caveat with using many mods: they introduce the probability of breaking your game that the vanilla game is specifically fine-tuned not to offer. If users refuse to live with the fact that one can very possibly break something when using an (in-some-cases-advanced) mod in an advanced or unintended fashion, then they should probably go back to the vanilla game or use mods that don't offer said experience.

    Anyway, as for Network Skins compatibility, I too would be interested in that; I suppose I misunderstood how it worked internally (although I didn't take a look at the source so I didn't really educate myself well enough). I'll take a look at it soon and hopefully make an update of some sort (I really need to figure out making the icon draggable anyway).


    Hello! Salut! Привет! | My Workshop (follow me? :]) • My Github • My Twitter

     

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     
    14 hours ago, Elektrix said:

    Anyway, as for Network Skins compatibility, I too would be interested in that; I suppose I misunderstood how it worked internally (although I didn't take a look at the source so I didn't really educate myself well enough). I'll take a look at it soon and hopefully make an update of some sort (I really need to figure out making the icon draggable anyway).

    The NetworkSkins code is a bit messy. I would advise you to use reflection. SegmentDataManager stores both the selected options and the segment data:

    https://github.com/boformer/NetworkSkins/blob/master/NetworkSkins/Data/SegmentDataManager.cs

    I think you have to run this code (translated to reflection code) before activating the net tool:

    // ID and prefab of the segment the user selected with your tool
    ushort segmentId;
    NetInfo prefab;
    
    // Get the NetworkSkins options of the segment (can be null)
    var segmentData = SegmentDataManager.Instance.SegmentToSegmentDataMap[segmentId];
    
    // Select options
    SegmentDataManager.Instance.SetActiveOptions(prefab, segmentData);

     

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     

    What I currently have (which neither works nor even compiles) is this:

    ushort segmentId = m_hover;
    NetInfo prefab = m_netInfo;
    
    Type SegmentDataManager = m_networkSkinsAssembly.GetType("NetworkSkins.Data.SegmentDataManager");
    
    object networkSkins = Activator.CreateInstance(SegmentDataManager);
    
    var segmentData = SegmentDataManager.GetField("SegmentToSegmentDataMap").GetValue(networkSkins)[segmentId];
    
    MethodInfo m = SegmentDataManager.GetMethod("SetActiveOptions");
    m.Invoke(networkSkins, new object[] { prefab, segmentData });

    My main issue is getting the segment data. I'm honestly not sure how to get at it. I've tried the above method (which doesn't compile) and I also tried casting the SegmentToSegmentDataMap to something other than a generic object, but I wasn't quite sure what to cast it to, since its actual type is SegmentData[] which is a class from Network Skins.

    I feel like I'm probably doing the whole thing wrong, as I'm honestly not really familiar with reflection at all.

     

    In other news, I'm trying to merge Segment Slope Smoother with Quboid's new version of Move It, which is going much better overall; it's nearly done, and I'll probably submit a PR by the weekend.


    Hello! Salut! Привет! | My Workshop (follow me? :]) • My Github • My Twitter

     

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     
    On 14.1.2019 at 6:21 PM, Elektrix said:

    I feel like I'm probably doing the whole thing wrong, as I'm honestly not really familiar with reflection at all.

    I'm also not really familiar with it. I don't think that you have to cast it to something else, as you don't want to change the options.

    If you are still interested in this: I will have some free time this weekend, so maybe we can chat.

    Share this post


    Link to post
    Share on other sites

    Sign In or register to comment...

    To comment in reply, you must be a community member

    Sign In  

    Already have an account? Sign in here.

    Sign In Now

    Create an Account  

    Sign up to join our friendly community. It's easy!  

    Register a New Account


    ×

    Thank You for the Continued Support!

    Simtropolis depends on donations to fund site maintenance costs.
    Without your support, we just would not be in our 24th year online!  You really help make this a great community. *:thumb:

    But we still need your support to stay online. If you're able to, please consider a donation to help us stay up and running. This helps sustain a platform where we can share our community creations for years to come.

    Make a Donation, Get a Gift!

    Expand your city with the best from the Simtropolis Exchange.
    Make a Donation and get one or all three discs today!

    STEX Collections

    By way of a "Thank You" gift, we'd like to send you our STEX Collector's DVD. It's some of the best buildings, lots, maps and mods collected for you over the years. Check out the STEX Collections for more info.

    Each donation helps keep Simtropolis online, open and free!

    Thank you for reading and enjoy the site!

    More About STEX Collections