question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

API for external mods to query TM:PE mod options

See original GitHub issue

As part of #1356 there is likely going to be a lot of chainsawing of mod options, UI, etc. This could break external mods if they query stuff directly.

Is there already a stable API they can use and, if not, should we make one? That way any mod breakages can at least know the updates will be the last they’ll need for a long time due to proper API.

If my understnading is correct, we’d update TrafficManager.API.Manager.IOptionsManager to give it some new method signatures, and then implement those methods in TrafficManager.Manager.Impl.OptionsManager?

The methods I suggest are as follows:

// returns true if options are in a stable state to query
// eg. it would be false from Main Menu, false while loading/saving options, etc.
bool AreOptionsSafeToQuery();

// returns null if option not found or some other error
bool? GetBoolOptionByName(string optionName);

// returns null if option not found or some other error
string? GetStringOptionByName(string optionName);

The string one can be useful for stuff like language code, icon theme name, or anything enum based.

The benefit of specifying options by name is that if we rename an option we can do a simple lookup table to get new option name, thus no need for external mods to update. Additionally, if we change from fields to properties, we can handle that change internally with no action required by external mods.

LMK if this makes sense and I’ll send in a PR to get things started. The API should be available on both STABLE and TEST workshop pages before #1356 start getting merged.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
DaEgi01commented, Feb 13, 2022

Question is: do we really want to expose those options to “the outside”? Why would any mod want to mess with TM:PE options? I always thought that API should contain only things you want to expose and… you maintain that way to be as reliable as possible.

I’d say, readonly is fine. Other mods should not be able to mess with the options but check the options to see what the user picked via our API.

0reactions
originalfoocommented, Feb 7, 2022

Question is: do we really want to expose those options to “the outside”? Why would any mod want to mess with TM:PE options? I always thought that API should contain only things you want to expose and… you maintain that way to be as reliable as possible.

I’m thinking of stuff like Roundabout Builder mod, which, if memory serves, can customise the roads it places with some TMPE stuff but obviously only if those TMPE features are active. Also, I suspect Kian’s mods might need similar info.

The goal is to ensure there is already an API interface available on TEST/STABLE prior to me chainsawing the existing options code as part of https://github.com/CitiesSkylinesMods/TMPE/issues/1356

Read more comments on GitHub >

github_iconTop Results From Across the Web

Complete TMPE API · Issue #685 · CitiesSkylinesMods/TMPE
API API for external mods docs Documentation help wanted Seeking assistance meta Build environment, github environment, etc. Milestone. Planned ...
Read more >
Options - Traffic Manager: President Edition - ViaThinkSoft
To configure the mod, please first start/load a game, then press Escape (or click the "gear" icon in the upper right corner), click...
Read more >
Improved Camera SE - Preview Release 4 (AE PR3 as well)
Scripted/Animation from external mods can be viewed in first person instead of third person. ... Please check the mod's webpage for updates.
Read more >
Guide:Mod Organizer - Step Mods | Change The Game
At the top left of the MO window, click the View menu option. Hover the mouse over Toolbars. Select Icons and Text. Change...
Read more >
[TIP/TUT] Basic settings/tricks/mods (webMAN MOD) ...
Basic settings/tricks/mods (webMAN MOD) [ONLY FOR ADVANCED USERS] What you need to know, first i writen tutorial how to compile Webman MOD.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found