Jump to content

How To Put Multiple Buttons Per Line?


Recommended Posts

For All Y'All I'm thinking of tightening up the UI a bit, to allow both more (and more varied) functionality and less spam of lines in the right-click menu. I already feel bad that I add 2 lines per part, and any more functionality could increase that even more. Ideally, I'd like to modify (or replace) the current single line to keep things tighter and easier to use.

A picture is worth a thousand words, so in lieu of writing 3,000 words here's what I want in simple pictures:

What KSP Does Now What All Y'All Does Now What I Want All Y'All To Do
9oj9KsW.jpg DwTQLhh.jpg EmsG0rc.jpg

I THINK that what I need to do is remove the current KSPEvent that implements "Extend Panels" (which I don't know how to do) and add my own KSPEvent-type-thing that implements the original functional button and also adds the two new buttons that do their jobs (which I also don't know how to do). Could anybody offer any pointers on any of these things?

I've got the "how do you extend all panels" and "how do you extend all of the same panels" part, but not the "how do you modify the UI to put buttons where I want them" part.

Edited by 5thHorseman
Link to comment
Share on other sites

I had a quick look and have some partial answers for you (I know it may not be to the level of detail that you need/want though).

Short answer: It looks possible, but not very far from trivial.

Long answer:

How it works:

  • When the part right click menu needs displaying, the UIPartActionController will create a UIPartActionWindow (which is a Unity component on its own GameObject).
  • As part of the setup of the UIPartActionWindow it'll fire GameEvents.onPartActionUICreate (this is to allow stuff to update its internal state before the dialog is created).

How I'd hack it:

  • You can subscribe to the onPartActionUICreate event to know when a part window is being displayed.  You'd have to just flag it and look at it on your own update cycle, as that event is fired while it's still being set up.
  • When you see it get opened, use either nasty reflection or expensive Unity.Object.FindObjectOfType to get the UIPartActionWindow.
  • Use reflection to find the list of UIPartActionItem (ie widgets) to see if the one you want is there (the "Extend Panels" in this example).
  • Add additional UIPartActionButton objects "beside" it.  I didn't dig into this part at all - I have no idea how the layout works to say if that is possible (but from just looking at how other UI elements are laid out I would guess that it is).

So yeah - that should give you a fairly clear picture of the scope of what's required (hopefully).

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