Jump to content

[Solved][Dev Question] Accessing the Time Warp Panel MET Area


Recommended Posts

Hello,

before releasing a 0.24.2 compatible update of my KSP Calendar mod I wish to "integrate" (or overlay) the output of my mod with the Time Warp Panel in the top left corner.

The best solution I can imagine is that the button next to the area has a 3rd option, "MET", "UT" and "KT" (for Kerbin Time). Clicking on "MET" and "UT" display the default texts and clicking on "KT" displays the Kerbin time from my mod.

But I guess thats not possible directly, instead I probably have to "fake" such a button with 3 options.

I took a look at the sources of RemoteTech2, especially the "UI/TimeWarDecorator.cs" and got an idea of how to at least "attach" something to this area. Thinking further on from this point I can now create a new overlay GUI window and just position it over the "MET timer" area.

But somehow I don't like this idea in the first place. I'd rather access the "MET timer" box itself and override the text in it, if possible. But there is so little documentation about that ... :(

So anyone got some hints for an old man? :kiss:

Edited by nuclearping
Link to comment
Share on other sites

Ok. That was easier than I thought.

You can change the text of the MET timer simply by ...

var metTimerGUI = mTimewarpObject.timeQuadrantTab.transform.FindChild ("MET timer").GetComponent<ScreenSafeGUIText>();
metTimerGUI.text = "Hello World!";

Now to figure out how to hook the button ... :D

EDIT:

Another way to access the MET timer panel is by using the FlightUIController.

FlightUIController flightUICtrl = FlightUIController.fetch;
if (flightUICtrl == null)
return;

So you can simply change the text by:

flightUICtrl.met.text = "...";

And hooking the button-click:

flightUICtrl.timeModeBtn.OnStatePress += new ScreenSafeUIStateButton.StateButtonPressCallback (this.metTimerBtnGUIClicked);

private void metTimerBtnGUIClicked(int st) {
print ("MET State: " + st.ToString());
}

:cool:

Edited by nuclearping
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...