Jump to content

[1.12.x] Toolbar Controller (for modders)


linuxgurugamer

Recommended Posts

@linuxgurugamer I've noticed that you can't set a button to be visible only on the flight scene (not the map view) with blizzy's toolbar. It works fine with the stock toolbar.

Spoiler

toolbarController = gameObject.AddComponent<ToolbarControl> ();

				toolbarController.AddToAllToolbars (
					ToolbarButtonOnTrue,
					ToolbarButtonOnFalse,
					KSP.UI.Screens.ApplicationLauncher.AppScenes.FLIGHT,
					"AntennaHelper",
					"368879",
					"AntennaHelper/Textures/icon_sat_on",
					"AntennaHelper/Textures/icon_off",
					"AntennaHelper/Textures/icon_dish_on_small",
					"AntennaHelper/Textures/icon_dish_off_small",
					"Antenna Helper");

toolbarController.UseBlizzy (true);

With this setting I expect the button to NOT be visible in the map view.

 

Link to comment
Share on other sites

  • 3 weeks later...
1 hour ago, linuxgurugamer said:

Delete the mod and reinstall it, be sure to delete the directory as well.

I just verified that the .version file is correct

same thing, also mini avc report 3-4 times same messages.

L.E. never-mind, my fault, i copied  it in kerbal foundries too by mistake... mini avc also working fine now.

Edited by Acvila
Link to comment
Share on other sites

I'm experiencing a nasty bug with this mod and KAC. Anytime the cursor changes to a different icon, it disappears when it tries to change back. For example, when I click "unlock position and size", it will change to the new icon, but it will disappear instead of switching back to regular cursor. The logs don't show anything of value. KAC has similar bug with its window resizer cursor that appears on the right side of the KAC window (I know you don't work on that mod, just elaborating). In both instances, everything still works it's just impossible to know where my cursor is and requires a restart to fix.

Thanks!

Ubuntu 17.10 build 1.4.1.2089

Link to comment
Share on other sites

1 hour ago, bkerman said:

I'm experiencing a nasty bug with this mod and KAC. Anytime the cursor changes to a different icon, it disappears when it tries to change back. For example, when I click "unlock position and size", it will change to the new icon, but it will disappear instead of switching back to regular cursor. The logs don't show anything of value. KAC has similar bug with its window resizer cursor that appears on the right side of the KAC window (I know you don't work on that mod, just elaborating). In both instances, everything still works it's just impossible to know where my cursor is and requires a restart to fix.

Thanks!

Ubuntu 17.10 build 1.4.1.2089

Just letting you know, that this bug is being worked on and is known.

 

Link to comment
Share on other sites

  • 3 weeks later...

An idea I had, related to this an the stock problem of to many preference pages:

With more and more mods using this, I'm starting to get a lot of preference panes with only the one button: Whether to use the toolbar or not.  Would it be possible for *this* mod to create a preference pane, and aggregate the mods that are using it, so that you just have an array of buttons?  I'd guess you'd want to make it opt-in on the other mod's part, so if they have other options they don't need to have this one option be on it's own - but for the mods which only have this one option, opting in would greatly reduce clutter for the user, and the amount of clicks it takes to start a new save.

Link to comment
Share on other sites

3 hours ago, DStaal said:

An idea I had, related to this an the stock problem of to many preference pages:

With more and more mods using this, I'm starting to get a lot of preference panes with only the one button: Whether to use the toolbar or not.  Would it be possible for *this* mod to create a preference pane, and aggregate the mods that are using it, so that you just have an array of buttons?  I'd guess you'd want to make it opt-in on the other mod's part, so if they have other options they don't need to have this one option be on it's own - but for the mods which only have this one option, opting in would greatly reduce clutter for the user, and the amount of clicks it takes to start a new save.

Most if not all of those mods are mine, I'd be interested in hearing about another mod which is using this.

It's a great idea, but I have to think about how to do it  Shouldn't be that difficult, maybe just a call to register the mod and get/set the value 

Link to comment
Share on other sites

New release, 0.1.6:

  • Added code for mods to register with the toolbar Controller
  • Added functions for mods to set and get the setting for the Blizzy toolbar
  • Added window to allow users to change setting without having to go into the mod
  • Added following methods, see the README for details:
    • public void toolbarControl.UseButtons(string NameSpace);
    • public static bool RegisterMod(string NameSpace, string DisplayName = "", bool useBlizzy = false, bool useStock = true, bool NoneAllowed = true)
    • public static bool BlizzyActive(string NameSpace, bool? useBlizzy = null)
    • public static bool StockActive(string NameSpace, bool? useStock = null)
    • public static void ButtonsActive(string NameSpace, bool? useStock, bool? useBlizzy)
    • public void UseStock(bool useStock)
  • Cleaned up old commented-out code

Current mods which use the previous version will remain compatible, but as new mods get updated and released,  this version will be required

Link to comment
Share on other sites

On 14/01/2018 at 9:34 AM, linuxgurugamer said:

Sorry, but its necessary to be sure everything gets loaded in in the correct order

Once this starts to be used, I’ll package the toolbar dll in the same zip file, and will set up ckan to not have a problem with that

Really late to the party here, but in case you're unaware of KSPAssembly and KSPAssemblyDependency I figured I'd pipe in.  If you add this to you AssemblyInfo.cs:

[assembly: KSPAssembly("ToolbarController", 1, 0)]

Others can then do a:

[assembly: KSPAssemblyDependency("ToolbarController", 1, 0)]

... which will guarantee the load order.  One benefit is that KSP will output a warning and won't load an assembly if it's dependencies aren't met (which may be better than puking out a bunch of exceptions).  The only other real problem with the forced to the top of the sort list method is that technically there's a couple characters before zero ('~', '!', '@', etc.) and dlls directly in GameData come first too.  Of course someone pretty much has to be trying to break things if you have to worry about this particular case.

Link to comment
Share on other sites

9 minutes ago, nightingale said:

Really late to the party here, but in case you're unaware of KSPAssembly and KSPAssemblyDependency I figured I'd pipe in.  If you add this to you AssemblyInfo.cs:


[assembly: KSPAssembly("ToolbarController", 1, 0)]

Others can then do a:


[assembly: KSPAssemblyDependency("ToolbarController", 1, 0)]

... which will guarantee the load order.  One benefit is that KSP will output a warning and won't load an assembly if it's dependencies aren't met (which may be better than puking out a bunch of exceptions).  The only other real problem with the forced to the top of the sort list method is that technically there's a couple characters before zero ('~', '!', '@', etc.) and dlls directly in GameData come first too.  Of course someone pretty much has to be trying to break things if you have to worry about this particular case.

I wasn't, thanks, will be updating with this immediately, will also update the OP.

Greatly appreciate it

New release, 0.1.6.1, The Nightingale Update

  • Added KSPAssembly to AssemblyInfo.cs, will help with load order of DLLs

Mod authors should add the following line to their AssemblyInfo.cs to control the loading order:

[assembly: KSPAssemblyDependency("ToolbarController", 1, 0)]

Thanks to @nightingale for the information about this

Link to comment
Share on other sites

On 4/13/2018 at 11:43 AM, releansol said:

Is there a way to change the sequence in stock bar (without coding)?  

No

On 4/8/2018 at 11:40 AM, DStaal said:

An idea I had, related to this an the stock problem of to many preference pages:

With more and more mods using this, I'm starting to get a lot of preference panes with only the one button: Whether to use the toolbar or not.  Would it be possible for *this* mod to create a preference pane, and aggregate the mods that are using it, so that you just have an array of buttons?  I'd guess you'd want to make it opt-in on the other mod's part, so if they have other options they don't need to have this one option be on it's own - but for the mods which only have this one option, opting in would greatly reduce clutter for the user, and the amount of clicks it takes to start a new save.

Thanks for the suggestion.  It took a week, but is now available.

Once I finish all my mod updates, I'll be go8ng back and updating the ones I did earlier

Link to comment
Share on other sites

Although I think ToolbarController's new stock/Blizzy switching option is a great idea, it's currently a little dangerous because it allows you to select the Blizzy option even when the Blizzy toolbar isn't installed — including for ToolbarController itself.  I don't use Blizzy, but if I click the ToolbarController button in the space center and then click the Blizzy checkbox on the ToolbarController line, the ToolbarController button immediately disappears from the stock toolbar (and a NullReferenceException is thrown).  If I were to close the window at that point, I'd have no way to get it back (except by installing the Blizzy toolbar, I guess).

I'd suggest disabling the checkboxes in the Blizzy column when that mod isn't installed.  They can still be visible, to make it clear that the option exists, but there's no sense in having the option be selectable when it isn't actually usable.

On a related but separate note, going forward you may want to think about how ToolbarController interacts with Adjustable Mod Panel, since they now both have options to hide and show toolbar buttons.  They do slightly different things: AMP only controls the stock toolbar, but it lets you hide buttons in specific scenes rather than just globally.  But they overlap, and it's a little awkward that a mod can be configured as hidden in TC but visible in AMP, or vice versa; maybe the two could integrate together somehow when both are installed.

Link to comment
Share on other sites

So you found a bug regards the window, but if Blizzy isnt available should be shown on stock regardless, I’ll have to fix that and add some supporting text to the help window.

Regarding AMP, its buggy and quirky. The overlap is there, but AMP runs after this (in a manner of speaking) and shouldn’t interfere.

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...