Jump to content

Mechjeb window not resizing properly


Recommended Posts

I am writing a plugin that allows me to list a number of altitude-pitch control points and have Mechjeb's SmartASS fly to the correct pitch interpolated between the control points. The window is handled using a Mechjeb DisplayModule. I got this working well and can change the number of control points dynamically just fine. The window resizes itself larger to accommodate more points, but does not shrink itself when the number of points is decreased (see image). This is persistent across closing and restarting KSP. Looking at the code for custom info windows in Mechjeb there doesn't seem to be anything special to make them shrink, so I'm confused why mine only grow. Any ideas?

lkX51O1.jpg

Link to comment
Share on other sites

Note the following code in MechJebModuleCustomInfoWindow:

public override GUILayoutOption[] WindowOptions()
{
return new GUILayoutOption[] { GUILayout.Width(250), GUILayout.Height(30) };
}

This function returns an array of GUILayoutOptions that are passed to GUILayout.Window(). The GUILayout.Height(30) essentially says "Make this window at least 30 pixels tall, but allow it to stretch to be taller if needed to fit the contents." If you just copy this function into your DisplayModule you'll get your desired window resizing behavior.

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