Jump to content

Using the new Application bar or whatever it is called?


Recommended Posts

It seems to me that the place to look is RUI* I'm an idiot :blush:

If past is any indication, Mu will post some documentation within the next week or so. Also if past is any indication, someone will figure it out by then too :D

Edited by kujuman
Link to comment
Share on other sites

documentation!?

lolololololol

jjk. The most complete documentation I've found is here:

https://github.com/Anatid/XML-Documentation-for-the-KSP-API

Not specific for your purposes, but I've yet to find a better resource.

I meant community documentation. Some people have figured it out as i've seen mod updates saying they support it.

- - - Updated - - -

It seems to me that the place to look is RUI*

If past is any indication, Mu will post some documentation within the next week or so. Also if past is any indication, someone will figure it out by then too :D

Yeah some already support it :)

- - - Updated - - -

I have some stuff figured, I'll post something tonight when I get home if no-one else has anything

That would be nice, thanks.

Link to comment
Share on other sites

So heres what I've got thus far, its not too hard, but there are some tricks to know, so here's the notes I have and have made:

  • There are AddModApplication and AddApplication methods on the ApplicationLauncher - the AddMod option places the button to the left of a separator, the other puts the button in with the KSP Mods
  • The icon texture that is expected is 38x38 pixels, I'm pretty sure

Issues

  • Because the AddModApplication (and Add Application) functions have a PackedSprite parameter on one of the versions, you have to add a reference to the Assembly-CSharp-firstpass assembly to be able to compile the code
  • The toggle state is maintained separately for the KSP apps and the Mod Apps lists. So here's an example to explain. If you toggle on the default resources display when you hover over the messages app it sends a toggle off to the resources display and then when you stop hovering sends a toggle on to resources to display that again. If you have a AppMod button it does not receive a toggle off message when an App button is hovered over so you can end up with two things displayed on top of each other.
  • I cant figure out the right code to get something to start toggled on and receive all the events, but after togglng the display once when the game is running they seem to fire (excluding the issue above)

[table]

[tr]

[td]App Button[/td]

[td]AppMod Button[/td]

[td]Toggle issue[/td]

[/tr]

[tr]

[td]xRVb89N.png[/td]

[td]nXFcGc7.png[/td]

[td]Zj4WoUa.png[/td]

[/tr]

[/table]

And here's a really basic code example (no guarantees here, but it should be enough to see how it works):


void Awake() {
//Register for the Ready event
GameEvents.onGUIApplicationLauncherReady.Add(OnGUIAppLauncherReady);
}
void OnDestroy() {
//Clean up
GameEvents.onGUIApplicationLauncherReady.Remove(OnGUIAppLauncherReady);
if (appButton != null)
ApplicationLauncher.Instance.RemoveModApplication(appButton);
// this one was a mistake - ApplicationLauncher.RemoveModApplication(appButton);
}

ApplicationLauncherButton appButton = null;
void OnGUIAppLauncherReady()
{
if (ApplicationLauncher.Ready) {
appButton = ApplicationLauncher.Instance.AddModApplication (
onAppLaunchToggleOn,
onAppLaunchToggleOff,
onAppLaunchHoverOn,
onAppLaunchHoverOff,
onAppLaunchEnable,
onAppLaunchDisable,
ApplicationLauncher.AppScenes.FLIGHT,
(Texture)GameDatabase.Instance.GetTexture("Plugin/Texture/AppLaunchIcon");
);
}
}
void onAppLaunchToggleOn() { /*Your code goes in here to toggle display on regardless of hover*/ }
void onAppLaunchToggleOff() { /*Your code goes in here to toggle display off regardless of hover*/ }
void onAppLaunchHoverOn() { /*Your code goes in here to show display on*/ }
void onAppLaunchHoverOff() { /*Your code goes in here to show display off*/ }
void onAppLaunchEnable() { /*Your code goes in here for if it gets enabled*/ }
void onAppLaunchDisable() { /*Your code goes in here for if it gets disabled*/ }

Hopefully tomorrow I can get it into ARP properly and you can look at that code too

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...