KSP-KOS/KOS — pull request #217 by Dunbaratu (2014-08-15 03:36:25+00:00)
Title: Resolves #158 (with a different approach).

The design decision was made that it is better to have multiple single terminal
windows than have one tabbed window. This code implements this. It was not
as simple as it looks because Unity GUI is a messy and not well documented
if you try to do anything slightly different from the default.

The basic design is like this:

Previously:

There was exactly one TermWindow object, and it was created during
initialization of kOS mod. As the terminal is opened on different
kOS CPU's, it gets re-attached to whatever instance of SharedObjects
goes with that CPU.

Now:

There is exactly one TermWindow object PER kOSProcessor module, and it
gets created during the initialization of hat kOSProcessor module, and
the attachment to the SharedObjects happens then.

Opening and closing it merely opens and closes it, rather than
re-attaching it to a different instance of SharedObjects.

What made most of the code messy was dealing with the Unity logic of
processing stacked windows, and preventing clicks from passing through
from one window to another. Once there was more than one TermWindow,
we have to deal with the issue of what to do if TermWindows partially
overlap each other. The old code from before allowed clicks to pass through
to all the windows stacked on top of each other. Most of the code changes
here are designed to get around that problem, rather than being directly
related to just having multple terminals.

Why do it?
----------

A number of future feature ideas, including wanting to use the new KSP 0.24's
toolbar menu system, as well as possibly implementing resized terminals, first
required simply *having* the ability to have multiple terminals, which we
didn't have before. Solving that was a pre-requisite to dealing with the
other features.

How to use it?
--------------
When you rightclick a kOS part, and pick "toggle terminal", you get the
the terminal window for THAT part appearing. You can rightclick other
kOS parts to get the terminal for them to appear. The terminals can be
slid around and moved to wherever you like, and closed individually.