Jump to content

Displaying a window in the RnD interface


Recommended Posts

Here's a shot of something from stock that I'd like to do:

pySheAx.png

I'm trying to call a window when a tech is researched. I can get the code to display basic text, but nothing else. It just seems to ignore the window call.


[KSPAddon(KSPAddon.Startup.EveryScene, false)]
public class TestingMain : MonoBehaviour


Rect windowRect = new Rect(400, 0, 150, 150);


public void Start()
{
GameEvents.OnTechnologyResearched.Add(DrawWind);
}


public void DrawCall(GameEvents.HostTargetAction<RDTech, RDTech.OperationResult> ev)
{
//ScreenMessages.PostScreenMessage("KHAAAAAAN!!!", 4.0f, ScreenMessageStyle.UPPER_LEFT);
windowRect = GUILayout.Window(50, windowRect, DrawWindow, "Steeeeve", HighLogic.Skin.window);
}


void DrawWindow(Int32 id)
{
GUILayout.BeginVertical();
GUILayout.Label("HEy-ooo!");
GUILayout.EndVertical();
}

When I uncomment the ScreenMessages line and comment out the window call, it displays the text when a tech is researched just fine. The problem is that I'd like to interrupt the process with an additional dialog box.

Link to comment
Share on other sites

That window is only going to display for a single frame (or maybe not even that since the event probably doesn't count as a GUI function). You need to set a flag in the event handler and display your window based on the flag state

EDIT

Don't know if you can interrupt the stock window.

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