Prp for 1.0.11.0 release.
Prp for 1.0.11.0 release.

1.0.10.0 1.0.11.0
  Added: New readouts to the orbital category:
  - Current SOI
  - Manoeuvre Node DeltaV (Prograde)
  - Manoeuvre Node DeltaV (Normal)
  - Manoeuvre Node DeltaV (Radial)
  - Manoeuvre Node DeltaV (Total)
  - Manoeuvre Node Burn Time
  - Manoeuvre Node Half Burn Time
  - Manoeuvre Node Angle to Prograde
  - Manoeuvre Node Angle to Retrograde
  - Time to Manoeuvre Node
  - Time to Manoeuvre Burn
   
  Added: Readout help strings by ClassyJakey.
   
  Fixed: Issue with separators in HUDs.
  Fixed: Issue with HUDs with backgrounds that have no displayed lines.
   
  Padishar's Fixes:
  Fixed: Issue with multicouplers when attached to parent by bottom node.
  Fixed: Issue with sepratrons on solid rocket boosters.
   
  1.0.10.0, 19-10-2014
UPDATE NOTICE: If you are updating from a previous version of Kerbal Engineer 1.0, please UPDATE NOTICE: If you are updating from a previous version of Kerbal Engineer 1.0, please
delete the 'Settings/SectionLibrary.xml' file, or remove the old install first. This will delete the 'Settings/SectionLibrary.xml' file, or remove the old install first. This will
reset the Flight Engineer sections to their default values and enable the new HUD functionality. reset the Flight Engineer sections to their default values and enable the new HUD functionality.
   
Added: New reaouts to the vessel category: Added: New reaouts to the vessel category:
- Suicide Burn Altitude (height above terrain to start burn) - Suicide Burn Altitude (height above terrain to start burn)
- Suicide Burn Distance (distance to suicide burn altitude) - Suicide Burn Distance (distance to suicide burn altitude)
- Suicide Burn DeltaV (velocity change required to zero vertical speed) - Suicide Burn DeltaV (velocity change required to zero vertical speed)
*** F5 for safety and use at your own risk! *** *** F5 for safety and use at your own risk! ***
   
Added: HUD type sections to the Flight Engineer. Added: HUD type sections to the Flight Engineer.
Added: HUD sections can have a smoked background for easy visibility. Added: HUD sections can have a smoked background for easy visibility.
Added: 'Switch to Target' button on the Target Selector readout. Added: 'Switch to Target' button on the Target Selector readout.
Changed: The default installed readouts to reduce new user brain melt. Changed: The default installed readouts to reduce new user brain melt.
Fixed: Flight Engineer not saving its hidden state. Fixed: Flight Engineer not saving its hidden state.
Fixed: Bug in the phase angle calculations. Fixed: Bug in the phase angle calculations.
Fixed: Bug where the Build Engineer would stay locked after hiding with the shortcut key. Fixed: Bug where the Build Engineer would stay locked after hiding with the shortcut key.
   
1.0.9.3 1.0.9.3, 08-10-2014
Added: Title of the build engineer in compact mode now shows if you are using atmospheric data. Added: Title of the build engineer in compact mode now shows if you are using atmospheric data.
Added: New readout to the surface category: Added: New readout to the surface category:
- Vertical Acceleration - Vertical Acceleration
- Horizontal Acceleration - Horizontal Acceleration
Changed: Atmospheric efficiency readout now shows as a percentage. Changed: Atmospheric efficiency readout now shows as a percentage.
Changed: Atmospheric settings (pressure/velocity) in the editor condensed onto a single line. Changed: Atmospheric settings (pressure/velocity) in the editor condensed onto a single line.
Fixed: Bug where the overlays in the editor would stay open outside of parts screen. Fixed: Bug where the overlays in the editor would stay open outside of parts screen.
   
1.0.9.2 1.0.9.2, 07-10-2014
Updated for KSP v0.25.0 Updated for KSP v0.25.0
Changed: Prettyfied Latitude and Longitude readouts. Changed: Prettyfied Latitude and Longitude readouts.
Changed: ModuleLandingGear now uses the physical significance flag. Changed: ModuleLandingGear now uses the physical significance flag.
Changed: Updated MiniAVC to 1.0.2.4. Changed: Updated MiniAVC to 1.0.2.4.
   
1.0.9.1 1.0.9.1, 17-09-2014
Fixed: Part size bug caused by TweakScale's cost calculator. Fixed: Part size bug caused by TweakScale's cost calculator.
   
1.0.9.0 1.0.9.0, 15-09-2014
Added: Build Engineer now also implements the '\' backslash show/hide shortcut. Added: Build Engineer now also implements the '\' backslash show/hide shortcut.
Added: New readouts to the vessel category: Added: New readouts to the vessel category:
- Current Stage DeltaV - Current Stage DeltaV
- Surface Thrust to Weight Ratio - Surface Thrust to Weight Ratio
   
Added: New editor overlay system. Added: New editor overlay system.
- Sleeker design. - Sleeker design.
- Hover over part information options: - Hover over part information options:
- Name only - Name only
- Middle click to show - Middle click to show
- Always show - Always show
- Slide out overlay displays: - Slide out overlay displays:
- Vessel information - Vessel information
- Resources list - Resources list
   
Fixed: Cost calculation now works with mods implementing IPartCostModifier. Fixed: Cost calculation now works with mods implementing IPartCostModifier.
   
1.0.8.1 1.0.8.1, 06-09-2014
Fixed: Bug which caused rendezvous readouts to freeze the game or show all zeros. Fixed: Bug which caused rendezvous readouts to freeze the game or show all zeros.
   
1.0.8.0 1.0.8.0, 06-09-2014
Added: New readouts to the vessel category: Added: New readouts to the vessel category:
- Intake Air (Usage) - Intake Air (Usage)
   
Added: New readouts to the rendezvous category: Added: New readouts to the rendezvous category:
- Relative Velocity - Relative Velocity
- Relative Speed - Relative Speed
   
Fixed: An issue where deltaV would not be calculated whilst flying. Fixed: An issue where deltaV would not be calculated whilst flying.
Fixed: NullRef whilst loading the in flight Action Menu. Fixed: NullRef whilst loading the in flight Action Menu.
   
1.0.7.1 1.0.7.1, 02-09-2014
Changed: Reversed Intake Air readout from 'S/D' to 'D/S' for easier reading. Changed: Reversed Intake Air readout from 'S/D' to 'D/S' for easier reading.
Changed: Increased Intake Air readout precision to 4 decimal places. Changed: Increased Intake Air readout precision to 4 decimal places.
Fixed: Issue where Intake Air supply was not representative of total supply. Fixed: Issue where Intake Air supply was not representative of total supply.
Fixed: Bug where actual thrust does not reset to zero on deactivated engines. Fixed: Bug where actual thrust does not reset to zero on deactivated engines.
Fixed: Thrust now scales with velocity for atmospheric engines. (Padishar's fix) Fixed: Thrust now scales with velocity for atmospheric engines. (Padishar's fix)
   
1.0.7.0 1.0.7.0, 01-09-2014
Added: Part count information to the Build Engineer. Added: Part count information to the Build Engineer.
Added: Reset button to the G-Force readout. Added: Reset button to the G-Force readout.
Added: Preset system to the Flight Engineer. Added: Preset system to the Flight Engineer.
Added: New stock presets: Added: New stock presets:
- Orbital - Orbital
- Surface - Surface
- Vessel - Vessel
- Rendezvous - Rendezvous
   
Added: New readouts to the orbital category: Added: New readouts to the orbital category:
- True Anomaly - True Anomaly
- Eccentric Anomaly - Eccentric Anomaly
- Mean Anomaly - Mean Anomaly
- Argument of Periapsis - Argument of Periapsis
- Angle to Prograde - Angle to Prograde
- Angle to Retrograde - Angle to Retrograde
   
Added: New readouts to the vessel category: Added: New readouts to the vessel category:
- Intake Air (Demand) - Intake Air (Demand)
- Intake Air (Supply) - Intake Air (Supply)
- Intake Air (Supply/Demand) - Intake Air (Supply/Demand)
   
Added: New readouts to the rendezvous category. Added: New readouts to the rendezvous category.
- Semi-major Axis - Semi-major Axis
- Semi-minor Axis - Semi-minor Axis
   
Added: Time formatter which can show time as referenced by any celestial body. Added: Time formatter which can show time as referenced by any celestial body.
Added: New readouts to the miscellaneous category: Added: New readouts to the miscellaneous category:
- Time Reference Adjuster - Time Reference Adjuster
   
Changed: Moved Sim Delay readout into the Miscellaneous category. Changed: Moved Sim Delay readout into the Miscellaneous category.
Changed: Updated MiniAVC to v1.0.2.3. Changed: Updated MiniAVC to v1.0.2.3.
Fixed: Issues with large value wrap around in the Flight Engineer. Fixed: Issues with large value wrap around in the Flight Engineer.
Fixed: Bug in the phase angle calculation. Fixed: Bug in the phase angle calculation.
   
1.0.6.0 1.0.6.0, 23-08-2014
Added: Time and Angle to equatorial ascending/descending nodes in the orbital display. Added: Time and Angle to equatorial ascending/descending nodes in the orbital display.
Added: Time and Angle to relative ascending/descending nodes in the rendezvous display. Added: Time and Angle to relative ascending/descending nodes in the rendezvous display.
Added: Overlay tooltip information delay adjustment slider to the Build Engineer settings. Added: Overlay tooltip information delay adjustment slider to the Build Engineer settings.
Added: Ability to rename the stock displays in the Flight Engineer. Added: Ability to rename the stock displays in the Flight Engineer.
Changed: Build Engineer is now hidden when not in parts view. Changed: Build Engineer is now hidden when not in parts view.
Changed: Custom display panels will only show in the control bar if an abbreviation is set. Changed: Custom display panels will only show in the control bar if an abbreviation is set.
Changed: Licensing and readme structures are now more verbose to satisfy the new add-on rules. Changed: Licensing and readme structures are now more verbose to satisfy the new add-on rules.
Fixed: Updated MiniAVC to v1.0.2.1 (fixes remote check bug as well as other minor bugs). Fixed: Updated MiniAVC to v1.0.2.1 (fixes remote check bug as well as other minor bugs).
   
1.0.5.0 1.0.5.0, 13-08-2014
Added: Acceleration readout to the Vessel category (current / maximum). Added: Acceleration readout to the Vessel category (current / maximum).
Added: Category library system for the Flight Engineer readouts. Added: Category library system for the Flight Engineer readouts.
Added: Drop-down category selection to better support the new system. Added: Drop-down category selection to better support the new system.
Changed: Misc category now called Miscellaneous (this will cause previously added readouts from this category to vanish). Changed: Misc category now called Miscellaneous (this will cause previously added readouts from this category to vanish).
Fixed: Bug with the Build Engineer toolbar button. Fixed: Bug with the Build Engineer toolbar button.
Fixed: Some buggyness when trying to close the bodies drop-down in the Build Engineer via the button. Fixed: Some buggyness when trying to close the bodies drop-down in the Build Engineer via the button.
Fixed: Flight Engineer toolbar menu now hides when hiding the GUI with F2. Fixed: Flight Engineer toolbar menu now hides when hiding the GUI with F2.
Fixed: Flight Engineer toolbar button now disables when in module mode and no engineer is running. Fixed: Flight Engineer toolbar button now disables when in module mode and no engineer is running.
   
1.0.4.0 1.0.4.0, 12-08-2014
Added: Better stock toolbar support in the flight engineer. Added: Better stock toolbar support in the flight engineer.
Added: Dynamically generated celestial body library for supporting add-ons that modify the star system. Added: Dynamically generated celestial body library for supporting add-ons that modify the star system.
Changed: Reference bodies are now listed with a nestable menu system. Changed: Reference bodies are now listed with a nestable menu system.
Changed: Extended logging system has been improved. Changed: Extended logging system has been improved.
Changed: Swapped out integrated MiniAVC in place of the official bundle version. Changed: Swapped out integrated MiniAVC in place of the official bundle version.
Changed: Increased general distance precision to 1 decimal place. Changed: Increased general distance precision to 1 decimal place.
Changed: Increased Semi-major/minor axis precision to 3 decimal places. Changed: Increased Semi-major/minor axis precision to 3 decimal places.
Fixed: Impact altitude was mistakenly formatted as an angle, it is now formatted correctly as a distance. Fixed: Impact altitude was mistakenly formatted as an angle, it is now formatted correctly as a distance.
   
1.0.3.0 1.0.3.0, 30-07-2014
Added: Integrated KSP-AVC support with MiniAVC. Added: Integrated KSP-AVC support with MiniAVC.
Added: Setting to change the simulation delay in the Build Engineer. Added: Setting to change the simulation delay in the Build Engineer.
Added: Setting to enable and disable the build overlay system. Added: Setting to enable and disable the build overlay system.
Added: Burn time to Delta-V readouts. Added: Burn time to Delta-V readouts.
Added: Atmospheric readouts fully support FAR. Added: Atmospheric readouts fully support FAR.
Added: Atmospheric readouts are disabled with NEAR. Added: Atmospheric readouts are disabled with NEAR.
Changed: Force formatting inversely scales decimal precision with value. Changed: Force formatting inversely scales decimal precision with value.
Fixed: Flickering in VAB and Vessel display. Fixed: Flickering in VAB and Vessel display.
Fixed: Bug saving the GUI display size. Fixed: Bug saving the GUI display size.
   
1.0.2.0 1.0.2.0, 27-07-2014
Added: Separator readout module under Misc in the Flight Engineer. Added: Separator readout module under Misc in the Flight Engineer.
Added: Adjustable GUI display size. Added: Adjustable GUI display size.
Added: Display size can be adjusted in the Build Engineer settings. Added: Display size can be adjusted in the Build Engineer settings.
Added: Misc readout for adjusting display size in the Flight Engineer. Added: Misc readout for adjusting display size in the Flight Engineer.
Changed: The rendezvous readout for the target's Orbital Period has higher precision. Changed: The rendezvous readout for the target's Orbital Period has higher precision.
Fixed: White toolbar icon by manually importing the texture if it cannot be found in the game database. Fixed: White toolbar icon by manually importing the texture if it cannot be found in the game database.
Fixed: Engines that have a minimum thrust are now calculated properly. (Thanks to nosscire.) Fixed: Engines that have a minimum thrust are now calculated properly. (Thanks to nosscire.)
Fixed: Compact collapse mode is now saved in the Build Engineer. Fixed: Compact collapse mode is now saved in the Build Engineer.
   
1.0.1.0 1.0.1.0, 26-07-2014
Added: Part-less Flight Engineer. Added: Part-less Flight Engineer.
Added: Ability to collapse the Build Engineer into compact mode from left or right. Added: Ability to collapse the Build Engineer into compact mode from left or right.
Added: Settings in Build Engineer for compact collapse mode and partless/module Flight Engineer. Added: Settings in Build Engineer for compact collapse mode and partless/module Flight Engineer.
Added: Biome, Impact Biome and Slope readouts. Added: Biome, Impact Biome and Slope readouts.
Added: Extra logging and exception handling. Added: Extra logging and exception handling.
Added: The original Engineer Chip part. Added: The original Engineer Chip part.
Added: "Show Engineer" toggle on the Flight Engineer toolbar. Added: "Show Engineer" toggle on the Flight Engineer toolbar.
Changed: Extended logging system now also writes to the standard KSP logs. Changed: Extended logging system now also writes to the standard KSP logs.
Changed: Extended logging saves next to the .dll file. Changed: Extended logging saves next to the .dll file.
Changed: ER7500 part has no physical significance. Changed: ER7500 part has no physical significance.
Fixed: ActionMenu and DisplayStack destruction bug. Fixed: ActionMenu and DisplayStack destruction bug.
   
1.0.0.1 1.0.0.1, 24-07-2014
Added: Stock toolbar support in the Flight Engineer. Added: Stock toolbar support in the Flight Engineer.
Changed: Orbital Period has higher precision. Changed: Orbital Period has higher precision.
Fixed: Various NullRefs in editor window and overlay. Fixed: Various NullRefs in editor window and overlay.
1.0.0.0 1.0.0.0, 24-07-2014
Initial release for public testing. Initial release for public testing.
  GNU GENERAL PUBLIC LICENSE
  Version 3, 29 June 2007
 
  Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
  Everyone is permitted to copy and distribute verbatim copies
  of this license document, but changing it is not allowed.
 
  Preamble
 
  The GNU General Public License is a free, copyleft license for
  software and other kinds of works.
 
  The licenses for most software and other practical works are designed
  to take away your freedom to share and change the works. By contrast,
  the GNU General Public License is intended to guarantee your freedom to
  share and change all versions of a program--to make sure it remains free
  software for all its users. We, the Free Software Foundation, use the
  GNU General Public License for most of our software; it applies also to
  any other work released this way by its authors. You can apply it to
  your programs, too.
 
  When we speak of free software, we are referring to freedom, not
  price. Our General Public Licenses are designed to make sure that you
  have the freedom to distribute copies of free software (and charge for
  them if you wish), that you receive source code or can get it if you
  want it, that you can change the software or use pieces of it in new
  free programs, and that you know you can do these things.
 
  To protect your rights, we need to prevent others from denying you
  these rights or asking you to surrender the rights. Therefore, you have
  certain responsibilities if you distribute copies of the software, or if
  you modify it: responsibilities to respect the freedom of others.
 
  For example, if you distribute copies of such a program, whether
  gratis or for a fee, you must pass on to the recipients the same
  freedoms that you received. You must make sure that they, too, receive
  or can get the source code. And you must show them these terms so they
  know their rights.
 
  Developers that use the GNU GPL protect your rights with two steps:
  (1) assert copyright on the software, and (2) offer you this License
  giving you legal permission to copy, distribute and/or modify it.
 
  For the developers' and authors' protection, the GPL clearly explains
  that there is no warranty for this free software. For both users' and
  authors' sake, the GPL requires that modified versions be marked as
  changed, so that their problems will not be attributed erroneously to
  authors of previous versions.
 
  Some devices are designed to deny users access to install or run
  modified versions of the software inside them, although the manufacturer
  can do so. This is fundamentally incompatible with the aim of
  protecting users' freedom to change the software. The systematic
  pattern of such abuse occurs in the area of products for individuals to
  use, which is precisely where it is most unacceptable. Therefore, we
  have designed this version of the GPL to prohibit the practice for those
  products. If such problems arise substantially in other domains, we
  stand ready to extend this provision to those domains in future versions
  of the GPL, as needed to protect the freedom of users.
 
  Finally, every program is threatened constantly by software patents.
  States should not allow patents to restrict development and use of
  software on general-purpose computers, but in those that do, we wish to
  avoid the special danger that patents applied to a free program could
  make it effectively proprietary. To prevent this, the GPL assures that
  patents cannot be used to render the program non-free.
 
  The precise terms and conditions for copying, distribution and
  modification follow.
 
  TERMS AND CONDITIONS
 
  0. Definitions.
 
  "This License" refers to version 3 of the GNU General Public License.
 
  "Copyright" also means copyright-like laws that apply to other kinds of
  works, such as semiconductor masks.
 
  "The Program" refers to any copyrightable work licensed under this
  License. Each licensee is addressed as "you". "Licensees" and
  "recipients" may be individuals or organizations.
 
  To "modify" a work means to copy from or adapt all or part of the work
  in a fashion requiring copyright permission, other than the making of an
  exact copy. The resulting work is called a "modified version" of the
  earlier work or a work "based on" the earlier work.
 
  A "covered work" means either the unmodified Program or a work based
  on the Program.
 
  To "propagate" a work means to do anything with it that, without
  permission, would make you directly or secondarily liable for
  infringement under applicable copyright law, except executing it on a
  computer or modifying a private copy. Propagation includes copying,
  distribution (with or without modification), making available to the
  public, and in some countries other activities as well.
 
  To "convey" a work means any kind of propagation that enables other
  parties to make or receive copies. Mere interaction with a user through
  a computer network, with no transfer of a copy, is not conveying.
 
  An interactive user interface displays "Appropriate Legal Notices"
  to the extent that it includes a convenient and prominently visible
  feature that (1) displays an appropriate copyright notice, and (2)
  tells the user that there is no warranty for the work (except to the
  extent that warranties are provided), that licensees may convey the
  work under this License, and how to view a copy of this License. If
  the interface presents a list of user commands or options, such as a
  menu, a prominent item in the list meets this criterion.
 
  1. Source Code.
 
  The "source code" for a work means the preferred form of the work
  for making modifications to it. "Object code" means any non-source
  form of a work.
 
  A "Standard Interface" means an interface that either is an official
  standard defined by a recognized standards body, or, in the case of
  interfaces specified for a particular programming language, one that
  is widely used among developers working in that language.
 
  The "System Libraries" of an executable work include anything, other
  than the work as a whole, that (a) is included in the normal form of
  packaging a Major Component, but which is not part of that Major
  Component, and (b) serves only to enable use of the work with that
  Major Component, or to implement a Standard Interface for which an
  implementation is available to the public in source code form. A
  "Major Component", in this context, means a major essential component
  (kernel, window system, and so on) of the specific operating system
  (if any) on which the executable work runs, or a compiler used to
  produce the work, or an object code interpreter used to run it.
 
  The "Corresponding Source" for a work in object code form means all
  the source code needed to generate, install, and (for an executable
  work) run the object code and to modify the work, including scripts to
  control those activities. However, it does not include the work's
  System Libraries, or general-purpose tools or generally available free
  programs which are used unmodified in performing those activities but
  which are not part of the work. For example, Corresponding Source
  includes interface definition files associated with source files for
  the work, and the source code for shared libraries and dynamically
  linked subprograms that the work is specifically designed to require,
  such as by intimate data communication or control flow between those
  subprograms and other parts of the work.
 
  The Corresponding Source need not include anything that users
  can regenerate automatically from other parts of the Corresponding
  Source.
 
  The Corresponding Source for a work in source code form is that
  same work.
 
  2. Basic Permissions.
 
  All rights granted under this License are granted for the term of
  copyright on the Program, and are irrevocable provided the stated
  conditions are met. This License explicitly affirms your unlimited
  permission to run the unmodified Program. The output from running a
  covered work is covered by this License only if the output, given its
  content, constitutes a covered work. This License acknowledges your
  rights of fair use or other equivalent, as provided by copyright law.
 
  You may make, run and propagate covered works that you do not
  convey, without conditions so long as your license otherwise remains
  in force. You may convey covered works to others for the sole purpose
  of having them make modifications exclusively for you, or provide you
  with facilities for running those works, provided that you comply with
  the terms of this License in conveying all material for which you do
  not control copyright. Those thus making or running the covered works
  for you must do so exclusively on your behalf, under your direction
  and control, on terms that prohibit them from making any copies of
  your copyrighted material outside their relationship with you.
 
  Conveying under any other circumstances is permitted solely under
  the conditions stated below. Sublicensing is not allowed; section 10
  makes it unnecessary.
 
  3. Protecting Users' Legal Rights From Anti-Circumvention Law.
 
  No covered work shall be deemed part of an effective technological
  measure under any applicable law fulfilling obligations under article
  11 of the WIPO copyright treaty adopted on 20 December 1996, or
  similar laws prohibiting or restricting circumvention of such
  measures.
 
  When you convey a covered work, you waive any legal power to forbid
  circumvention of technological measures to the extent such circumvention
  is effected by exercising rights under this License with respect to
  the covered work, and you disclaim any intention to limit operation or
  modification of the work as a means of enforcing, against the work's
  users, your or third parties' legal rights to forbid circumvention of
  technological measures.
 
  4. Conveying Verbatim Copies.
 
  You may convey verbatim copies of the Program's source code as you
  receive it, in any medium, provided that you conspicuously and
  appropriately publish on each copy an appropriate copyright notice;
  keep intact all notices stating that this License and any
  non-permissive terms added in accord with section 7 apply to the code;
  keep intact all notices of the absence of any warranty; and give all
  recipients a copy of this License along with the Program.
 
  You may charge any price or no price for each copy that you convey,
  and you may offer support or warranty protection for a fee.
 
  5. Conveying Modified Source Versions.
 
  You may convey a work based on the Program, or the modifications to
  produce it from the Program, in the form of source code under the
  terms of section 4, provided that you also meet all of these conditions:
 
  a) The work must carry prominent notices stating that you modified
  it, and giving a relevant date.
 
  b) The work must carry prominent notices stating that it is
  released under this License and any conditions added under section
  7. This requirement modifies the requirement in section 4 to
  "keep intact all notices".
 
  c) You must license the entire work, as a whole, under this
  License to anyone who comes into possession of a copy. This
  License will therefore apply, along with any applicable section 7
  additional terms, to the whole of the work, and all its parts,
  regardless of how they are packaged. This License gives no
  permission to license the work in any other way, but it does not
  invalidate such permission if you have separately received it.
 
  d) If the work has interactive user interfaces, each must display
  Appropriate Legal Notices; however, if the Program has interactive
  interfaces that do not display Appropriate Legal Notices, your
  work need not make them do so.
 
  A compilation of a covered work with other separate and independent
  works, which are not by their nature extensions of the covered work,
  and which are not combined with it such as to form a larger program,
  in or on a volume of a storage or distribution medium, is called an
  "aggregate" if the compilation and its resulting copyright are not
  used to limit the access or legal rights of the compilation's users
  beyond what the individual works permit. Inclusion of a covered work
  in an aggregate does not cause this License to apply to the other
  parts of the aggregate.
 
  6. Conveying Non-Source Forms.
 
  You may convey a covered work in object code form under the terms
  of sections 4 and 5, provided that you also convey the
  machine-readable Corresponding Source under the terms of this License,
  in one of these ways:
 
  a) Convey the object code in, or embodied in, a physical product
  (including a physical distribution medium), accompanied by the
  Corresponding Source fixed on a durable physical medium
  customarily used for software interchange.
 
  b) Convey the object code in, or embodied in, a physical product
  (including a physical distribution medium), accompanied by a
  written offer, valid for at least three years and valid for as
  long as you offer spare parts or customer support for that product
  model, to give anyone who possesses the object code either (1) a
  copy of the Corresponding Source for all the software in the
  product that is covered by this License, on a durable physical
  medium customarily used for software interchange, for a price no
  more than your reasonable cost of physically performing this
  conveying of source, or (2) access to copy the
  Corresponding Source from a network server at no charge.
 
  c) Convey individual copies of the object code with a copy of the
  written offer to provide the Corresponding Source. This
  alternative is allowed only occasionally and noncommercially, and
  only if you received the object code with such an offer, in accord
  with subsection 6b.
 
  d) Convey the object code by offering access from a designated
  place (gratis or for a charge), and offer equivalent access to the
  Corresponding Source in the same way through the same place at no
  further charge. You need not require recipients to copy the
  Corresponding Source along with the object code. If the place to
  copy the object code is a network server, the Corresponding Source
  may be on a different server (operated by you or a third party)
  that supports equivalent copying facilities, provided you maintain
  clear directions next to the object code saying where to find the
  Corresponding Source. Regardless of what server hosts the
  Corresponding Source, you remain obligated to ensure that it is
  available for as long as needed to satisfy these requirements.
 
  e) Convey the object code using peer-to-peer transmission, provided
  you inform other peers where the object code and Corresponding
  Source of the work are being offered to the general public at no
  charge under subsection 6d.
 
  A separable portion of the object code, whose source code is excluded
  from the Corresponding Source as a System Library, need not be
  included in conveying the object code work.
 
  A "User Product" is either (1) a "consumer product", which means any
  tangible personal property which is normally used for personal, family,
  or household purposes, or (2) anything designed or sold for incorporation
  into a dwelling. In determining whether a product is a consumer product,
  doubtful cases shall be resolved in favor of coverage. For a particular
  product received by a particular user, "normally used" refers to a
  typical or common use of that class of product, regardless of the status
  of the particular user or of the way in which the particular user
  actually uses, or expects or is expected to use, the product. A product
  is a consumer product regardless of whether the product has substantial
  commercial, industrial or non-consumer uses, unless such uses represent
  the only significant mode of use of the product.
 
  "Installation Information" for a User Product means any methods,
  procedures, authorization keys, or other information required to install
  and execute modified versions of a covered work in that User Product from
  a modified version of its Corresponding Source. The information must
  suffice to ensure that the continued functioning of the modified object
  code is in no case prevented or interfered with solely because
  modification has been made.
 
  If you convey an object code work under this section in, or with, or
  specifically for use in, a User Product, and the conveying occurs as
  part of a transaction in which the right of possession and use of the
  User Product is transferred to the recipient in perpetuity or for a
  fixed term (regardless of how the transaction is characterized), the
  Corresponding Source conveyed under this section must be accompanied
  by the Installation Information. But this requirement does not apply
  if neither you nor any third party retains the ability to install
  modified object code on the User Product (for example, the work has
  been installed in ROM).
 
  The requirement to provide Installation Information does not include a
  requirement to continue to provide support service, warranty, or updates
  for a work that has been modified or installed by the recipient, or for
  the User Product in which it has been modified or installed. Access to a
  network may be denied when the modification itself materially and
  adversely affects the operation of the network or violates the rules and
  protocols for communication across the network.
 
  Corresponding Source conveyed, and Installation Information provided,
  in accord with this section must be in a format that is publicly
  documented (and with an implementation available to the public in
  source code form), and must require no special password or key for
  unpacking, reading or copying.
 
  7. Additional Terms.
 
  "Additional permissions" are terms that supplement the terms of this
  License by making exceptions from one or more of its conditions.
  Additional permissions that are applicable to the entire Program shall
  be treated as though they were included in this License, to the extent
  that they are valid under applicable law. If additional permissions
  apply only to part of the Program, that part may be used separately
  under those permissions, but the entire Program remains governed by
  this License without regard to the additional permissions.
 
  When you convey a copy of a covered work, you may at your option
  remove any additional permissions from that copy, or from any part of
  it. (Additional permissions may be written to require their own
  removal in certain cases when you modify the work.) You may place
  additional permissions on material, added by you to a covered work,
  for which you have or can give appropriate copyright permission.
 
  Notwithstanding any other provision of this License, for material you
  add to a covered work, you may (if authorized by the copyright holders of
  that material) supplement the terms of this License with terms:
 
  a) Disclaiming warranty or limiting liability differently from the
  terms of sections 15 and 16 of this License; or
 
  b) Requiring preservation of specified reasonable legal notices or
  author attributions in that material or in the Appropriate Legal
  Notices displayed by works containing it; or
 
  c) Prohibiting misrepresentation of the origin of that material, or
  requiring that modified versions of such material be marked in
  reasonable ways as different from the original version; or
 
  d) Limiting the use for publicity purposes of names of licensors or
  authors of the material; or
 
  e) Declining to grant rights under trademark law for use of some
  trade names, trademarks, or service marks; or
 
  f) Requiring indemnification of licensors and authors of that
  material by anyone who conveys the material (or modified versions of
  it) with contractual assumptions of liability to the recipient, for
  any liability that these contractual assumptions directly impose on
  those licensors and authors.
 
  All other non-permissive additional terms are considered "further
  restrictions" within the meaning of section 10. If the Program as you
  received it, or any part of it, contains a notice stating that it is
  governed by this License along with a term that is a further
  restriction, you may remove that term. If a license document contains
  a further restriction but permits relicensing or conveying under this
  License, you may add to a covered work material governed by the terms
  of that license document, provided that the further restriction does
  not survive such relicensing or conveying.
 
  If you add terms to a covered work in accord with this section, you
  must place, in the relevant source files, a statement of the
  additional terms that apply to those files, or a notice indicating
  where to find the applicable terms.
 
  Additional terms, permissive or non-permissive, may be stated in the
  form of a separately written license, or stated as exceptions;
  the above requirements apply either way.
 
  8. Termination.
 
  You may not propagate or modify a covered work except as expressly
  provided under this License. Any attempt otherwise to propagate or
  modify it is void, and will automatically terminate your rights under
  this License (including any patent licenses granted under the third
  paragraph of section 11).
 
  However, if you cease all violation of this License, then your
  license from a particular copyright holder is reinstated (a)
  provisionally, unless and until the copyright holder explicitly and
  finally terminates your license, and (b) permanently, if the copyright
  holder fails to notify you of the violation by some reasonable means
  prior to 60 days after the cessation.
 
  Moreover, your license from a particular copyright holder is
  reinstated permanently if the copyright holder notifies you of the
  violation by some reasonable means, this is the first time you have
  received notice of violation of this License (for any work) from that
  copyright holder, and you cure the violation prior to 30 days after
  your receipt of the notice.
 
  Termination of your rights under this section does not terminate the
  licenses of parties who have received copies or rights from you under
  this License. If your rights have been terminated and not permanently
  reinstated, you do not qualify to receive new licenses for the same
  material under section 10.
 
  9. Acceptance Not Required for Having Copies.
 
  You are not required to accept this License in order to receive or
  run a copy of the Program. Ancillary propagation of a covered work
  occurring solely as a consequence of using peer-to-peer transmission
  to receive a copy likewise does not require acceptance. However,
  nothing other than this License grants you permission to propagate or
  modify any covered work. These actions infringe copyright if you do
  not accept this License. Therefore, by modifying or propagating a
  covered work, you indicate your acceptance of this License to do so.
 
  10. Automatic Licensing of Downstream Recipients.
 
  Each time you convey a covered work, the recipient automatically
  receives a license from the original licensors, to run, modify and
  propagate that work, subject to this License. You are not responsible
  for enforcing compliance by third parties with this License.
 
  An "entity transaction" is a transaction transferring control of an
  organization, or substantially all assets of one, or subdividing an
  organization, or merging organizations. If propagation of a covered
  work results from an entity transaction, each party to that
  transaction who receives a copy of the work also receives whatever
  licenses to the work the party's predecessor in interest had or could
  give under the previous paragraph, plus a right to possession of the
  Corresponding Source of the work from the predecessor in interest, if
  the predecessor has it or can get it with reasonable efforts.
 
  You may not impose any further restrictions on the exercise of the
  rights granted or affirmed under this License. For example, you may
  not impose a license fee, royalty, or other charge for exercise of
  rights granted under this License, and you may not initiate litigation
  (including a cross-claim or counterclaim in a lawsuit) alleging that
  any patent claim is infringed by making, using, selling, offering for
  sale, or importing the Program or any portion of it.
 
  11. Patents.
 
  A "contributor" is a copyright holder who authorizes use under this
  License of the Program or a work on which the Program is based. The
  work thus licensed is called the contributor's "contributor version".
 
  A contributor's "essential patent claims" are all patent claims
  owned or controlled by the contributor, whether already acquired or
  hereafter acquired, that would be infringed by some manner, permitted
  by this License, of making, using, or selling its contributor version,
  but do not include claims that would be infringed only as a
  consequence of further modification of the contributor version. For
  purposes of this definition, "control" includes the right to grant
  patent sublicenses in a manner consistent with the requirements of
  this License.
 
  Each contributor grants you a non-exclusive, worldwide, royalty-free
  patent license under the contributor's essential patent claims, to
  make, use, sell, offer for sale, import and otherwise run, modify and
  propagate the contents of its contributor version.
 
  In the following three paragraphs, a "patent license" is any express
  agreement or commitment, however denominated, not to enforce a patent
  (such as an express permission to practice a patent or covenant not to
  sue for patent infringement). To "grant" such a patent license to a
  party means to make such an agreement or commitment not to enforce a
  patent against the party.
 
  If you convey a covered work, knowingly relying on a patent license,
  and the Corresponding Source of the work is not available for anyone
  to copy, free of charge and under the terms of this License, through a
  publicly available network server or other readily accessible means,
  then you must either (1) cause the Corresponding Source to be so
  available, or (2) arrange to deprive yourself of the benefit of the
  patent license for this particular work, or (3) arrange, in a manner
  consistent with the requirements of this License, to extend the patent
  license to downstream recipients. "Knowingly relying" means you have
  actual knowledge that, but for the patent license, your conveying the
  covered work in a country, or your recipient's use of the covered work
  in a country, would infringe one or more identifiable patents in that
  country that you have reason to believe are valid.
 
  If, pursuant to or in connection with a single transaction or
  arrangement, you convey, or propagate by procuring conveyance of, a
  covered work, and grant a patent license to some of the parties
  receiving the covered work authorizing them to use, propagate, modify
  or convey a specific copy of the covered work, then the patent license
  you grant is automatically extended to all recipients of the covered
  work and works based on it.
 
  A patent license is "discriminatory" if it does not include within
  the scope of its coverage, prohibits the exercise of, or is
  conditioned on the non-exercise of one or more of the rights that are
  specifically granted under this License. You may not convey a covered
  work if you are a party to an arrangement with a third party that is
  in the business of distributing software, under which you make payment
  to the third party based on the extent of your activity of conveying
  the work, and under which the third party grants, to any of the
  parties who would receive the covered work from you, a discriminatory
  patent license (a) in connection with copies of the covered work
  conveyed by you (or copies made from those copies), or (b) primarily
  for and in connection with specific products or compilations that
  contain the covered work, unless you entered into that arrangement,
  or that patent license was granted, prior to 28 March 2007.
 
  Nothing in this License shall be construed as excluding or limiting
  any implied license or other defenses to infringement that may
  otherwise be available to you under applicable patent law.
 
  12. No Surrender of Others' Freedom.
 
  If conditions are imposed on you (whether by court order, agreement or
  otherwise) that contradict the conditions of this License, they do not
  excuse you from the conditions of this License. If you cannot convey a
  covered work so as to satisfy simultaneously your obligations under this
  License and any other pertinent obligations, then as a consequence you may
  not convey it at all. For example, if you agree to terms that obligate you
  to collect a royalty for further conveying from those to whom you convey
  the Program, the only way you could satisfy both those terms and this
  License would be to refrain entirely from conveying the Program.
 
  13. Use with the GNU Affero General Public License.
 
  Notwithstanding any other provision of this License, you have
  permission to link or combine any covered work with a work licensed
  under version 3 of the GNU Affero General Public License into a single
  combined work, and to convey the resulting work. The terms of this
  License will continue to apply to the part which is the covered work,
  but the special requirements of the GNU Affero General Public License,
  section 13, concerning interaction through a network will apply to the
  combination as such.
 
  14. Revised Versions of this License.
 
  The Free Software Foundation may publish revised and/or new versions of
  the GNU General Public License from time to time. Such new versions will
  be similar in spirit to the present version, but may differ in detail to
  address new problems or concerns.
 
  Each version is given a distinguishing version number. If the
  Program specifies that a certain numbered version of the GNU General
  Public License "or any later version" applies to it, you have the
  option of following the terms and conditions either of that numbered
  version or of any later version published by the Free Software
  Foundation. If the Program does not specify a version number of the
  GNU General Public License, you may choose any version ever published
  by the Free Software Foundation.
 
  If the Program specifies that a proxy can decide which future
  versions of the GNU General Public License can be used, that proxy's
  public statement of acceptance of a version permanently authorizes you
  to choose that version for the Program.
 
  Later license versions may give you additional or different
  permissions. However, no additional obligations are imposed on any
  author or copyright holder as a result of your choosing to follow a
  later version.
 
  15. Disclaimer of Warranty.
 
  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
  APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
  HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
  OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
  IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
  ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
 
  16. Limitation of Liability.
 
  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
  WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
  THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
  GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
  USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
  DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
  PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
  EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
  SUCH DAMAGES.
 
  17. Interpretation of Sections 15 and 16.
 
  If the disclaimer of warranty and limitation of liability provided
  above cannot be given local legal effect according to their terms,
  reviewing courts shall apply local law that most closely approximates
  an absolute waiver of all civil liability in connection with the
  Program, unless a warranty or assumption of liability accompanies a
  copy of the Program in return for a fee.
 
  END OF TERMS AND CONDITIONS
 
  How to Apply These Terms to Your New Programs
 
  If you develop a new program, and you want it to be of the greatest
  possible use to the public, the best way to achieve this is to make it
  free software which everyone can redistribute and change under these terms.
 
  To do so, attach the following notices to the program. It is safest
  to attach them to the start of each source file to most effectively
  state the exclusion of warranty; and each file should have at least
  the "copyright" line and a pointer to where the full notice is found.
 
  <one line to give the program's name and a brief idea of what it does.>
  Copyright (C) <year> <name of author>
 
  This program is free software: you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.
 
  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  GNU General Public License for more details.
 
  You should have received a copy of the GNU General Public License
  along with this program. If not, see <http://www.gnu.org/licenses/>.
 
  Also add information on how to contact you by electronic and paper mail.
 
  If the program does terminal interaction, make it output a short
  notice like this when it starts in an interactive mode:
 
  <program> Copyright (C) <year> <name of author>
  This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
  This is free software, and you are welcome to redistribute it
  under certain conditions; type `show c' for details.
 
  The hypothetical commands `show w' and `show c' should show the appropriate
  parts of the General Public License. Of course, your program's commands
  might be different; for a GUI interface, you would use an "about box".
 
  You should also get your employer (if you work as a programmer) or school,
  if any, to sign a "copyright disclaimer" for the program, if necessary.
  For more information on this, and how to apply and follow the GNU GPL, see
  <http://www.gnu.org/licenses/>.
 
  The GNU General Public License does not permit incorporating your program
  into proprietary programs. If your program is a subroutine library, you
  may consider it more useful to permit linking proprietary applications with
  the library. If this is what you want to do, use the GNU Lesser General
  Public License instead of this License. But first, please read
  <http://www.gnu.org/philosophy/why-not-lgpl.html>.
 
file:a/Documents/LICENSE.txt (deleted)
GNU GENERAL PUBLIC LICENSE  
Version 3, 29 June 2007  
 
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>  
Everyone is permitted to copy and distribute verbatim copies  
of this license document, but changing it is not allowed.  
 
Preamble  
 
The GNU General Public License is a free, copyleft license for  
software and other kinds of works.  
 
The licenses for most software and other practical works are designed  
to take away your freedom to share and change the works. By contrast,  
the GNU General Public License is intended to guarantee your freedom to  
share and change all versions of a program--to make sure it remains free  
software for all its users. We, the Free Software Foundation, use the  
GNU General Public License for most of our software; it applies also to  
any other work released this way by its authors. You can apply it to  
your programs, too.  
 
When we speak of free software, we are referring to freedom, not  
price. Our General Public Licenses are designed to make sure that you  
have the freedom to distribute copies of free software (and charge for  
them if you wish), that you receive source code or can get it if you  
want it, that you can change the software or use pieces of it in new  
free programs, and that you know you can do these things.  
 
To protect your rights, we need to prevent others from denying you  
these rights or asking you to surrender the rights. Therefore, you have  
certain responsibilities if you distribute copies of the software, or if  
you modify it: responsibilities to respect the freedom of others.  
 
For example, if you distribute copies of such a program, whether  
gratis or for a fee, you must pass on to the recipients the same  
freedoms that you received. You must make sure that they, too, receive  
or can get the source code. And you must show them these terms so they  
know their rights.  
 
Developers that use the GNU GPL protect your rights with two steps:  
(1) assert copyright on the software, and (2) offer you this License  
giving you legal permission to copy, distribute and/or modify it.  
 
For the developers' and authors' protection, the GPL clearly explains  
that there is no warranty for this free software. For both users' and  
authors' sake, the GPL requires that modified versions be marked as  
changed, so that their problems will not be attributed erroneously to  
authors of previous versions.  
 
Some devices are designed to deny users access to install or run  
modified versions of the software inside them, although the manufacturer  
can do so. This is fundamentally incompatible with the aim of  
protecting users' freedom to change the software. The systematic  
pattern of such abuse occurs in the area of products for individuals to  
use, which is precisely where it is most unacceptable. Therefore, we  
have designed this version of the GPL to prohibit the practice for those  
products. If such problems arise substantially in other domains, we  
stand ready to extend this provision to those domains in future versions  
of the GPL, as needed to protect the freedom of users.  
 
Finally, every program is threatened constantly by software patents.  
States should not allow patents to restrict development and use of  
software on general-purpose computers, but in those that do, we wish to  
avoid the special danger that patents applied to a free program could  
make it effectively proprietary. To prevent this, the GPL assures that  
patents cannot be used to render the program non-free.  
 
The precise terms and conditions for copying, distribution and  
modification follow.  
 
TERMS AND CONDITIONS  
 
0. Definitions.  
 
"This License" refers to version 3 of the GNU General Public License.  
 
"Copyright" also means copyright-like laws that apply to other kinds of  
works, such as semiconductor masks.  
 
"The Program" refers to any copyrightable work licensed under this  
License. Each licensee is addressed as "you". "Licensees" and  
"recipients" may be individuals or organizations.  
 
To "modify" a work means to copy from or adapt all or part of the work  
in a fashion requiring copyright permission, other than the making of an  
exact copy. The resulting work is called a "modified version" of the  
earlier work or a work "based on" the earlier work.  
 
A "covered work" means either the unmodified Program or a work based  
on the Program.  
 
To "propagate" a work means to do anything with it that, without  
permission, would make you directly or secondarily liable for  
infringement under applicable copyright law, except executing it on a  
computer or modifying a private copy. Propagation includes copying,  
distribution (with or without modification), making available to the  
public, and in some countries other activities as well.  
 
To "convey" a work means any kind of propagation that enables other  
parties to make or receive copies. Mere interaction with a user through  
a computer network, with no transfer of a copy, is not conveying.  
 
An interactive user interface displays "Appropriate Legal Notices"  
to the extent that it includes a convenient and prominently visible  
feature that (1) displays an appropriate copyright notice, and (2)  
tells the user that there is no warranty for the work (except to the  
extent that warranties are provided), that licensees may convey the  
work under this License, and how to view a copy of this License. If  
the interface presents a list of user commands or options, such as a  
menu, a prominent item in the list meets this criterion.  
 
1. Source Code.  
 
The "source code" for a work means the preferred form of the work  
for making modifications to it. "Object code" means any non-source  
form of a work.  
 
A "Standard Interface" means an interface that either is an official  
standard defined by a recognized standards body, or, in the case of  
interfaces specified for a particular programming language, one that  
is widely used among developers working in that language.  
 
The "System Libraries" of an executable work include anything, other  
than the work as a whole, that (a) is included in the normal form of  
packaging a Major Component, but which is not part of that Major  
Component, and (b) serves only to enable use of the work with that  
Major Component, or to implement a Standard Interface for which an  
implementation is available to the public in source code form. A  
"Major Component", in this context, means a major essential component  
(kernel, window system, and so on) of the specific operating system  
(if any) on which the executable work runs, or a compiler used to  
produce the work, or an object code interpreter used to run it.  
 
The "Corresponding Source" for a work in object code form means all  
the source code needed to generate, install, and (for an executable  
work) run the object code and to modify the work, including scripts to  
control those activities. However, it does not include the work's  
System Libraries, or general-purpose tools or generally available free  
programs which are used unmodified in performing those activities but  
which are not part of the work. For example, Corresponding Source  
includes interface definition files associated with source files for  
the work, and the source code for shared libraries and dynamically  
linked subprograms that the work is specifically designed to require,  
such as by intimate data communication or control flow between those  
subprograms and other parts of the work.  
 
The Corresponding Source need not include anything that users  
can regenerate automatically from other parts of the Corresponding  
Source.  
 
The Corresponding Source for a work in source code form is that  
same work.  
 
2. Basic Permissions.  
 
All rights granted under this License are granted for the term of  
copyright on the Program, and are irrevocable provided the stated  
conditions are met. This License explicitly affirms your unlimited  
permission to run the unmodified Program. The output from running a  
covered work is covered by this License only if the output, given its  
content, constitutes a covered work. This License acknowledges your  
rights of fair use or other equivalent, as provided by copyright law.  
 
You may make, run and propagate covered works that you do not  
convey, without conditions so long as your license otherwise remains  
in force. You may convey covered works to others for the sole purpose  
of having them make modifications exclusively for you, or provide you  
with facilities for running those works, provided that you comply with  
the terms of this License in conveying all material for which you do  
not control copyright. Those thus making or running the covered works  
for you must do so exclusively on your behalf, under your direction  
and control, on terms that prohibit them from making any copies of  
your copyrighted material outside their relationship with you.  
 
Conveying under any other circumstances is permitted solely under  
the conditions stated below. Sublicensing is not allowed; section 10  
makes it unnecessary.  
 
3. Protecting Users' Legal Rights From Anti-Circumvention Law.  
 
No covered work shall be deemed part of an effective technological  
measure under any applicable law fulfilling obligations under article  
11 of the WIPO copyright treaty adopted on 20 December 1996, or  
similar laws prohibiting or restricting circumvention of such  
measures.  
 
When you convey a covered work, you waive any legal power to forbid  
circumvention of technological measures to the extent such circumvention  
is effected by exercising rights under this License with respect to  
the covered work, and you disclaim any intention to limit operation or  
modification of the work as a means of enforcing, against the work's  
users, your or third parties' legal rights to forbid circumvention of  
technological measures.  
 
4. Conveying Verbatim Copies.  
 
You may convey verbatim copies of the Program's source code as you  
receive it, in any medium, provided that you conspicuously and  
appropriately publish on each copy an appropriate copyright notice;  
keep intact all notices stating that this License and any  
non-permissive terms added in accord with section 7 apply to the code;  
keep intact all notices of the absence of any warranty; and give all  
recipients a copy of this License along with the Program.  
 
You may charge any price or no price for each copy that you convey,  
and you may offer support or warranty protection for a fee.  
 
5. Conveying Modified Source Versions.  
 
You may convey a work based on the Program, or the modifications to  
produce it from the Program, in the form of source code under the  
terms of section 4, provided that you also meet all of these conditions:  
 
a) The work must carry prominent notices stating that you modified  
it, and giving a relevant date.  
 
b) The work must carry prominent notices stating that it is  
released under this License and any conditions added under section  
7. This requirement modifies the requirement in section 4 to  
"keep intact all notices".  
 
c) You must license the entire work, as a whole, under this  
License to anyone who comes into possession of a copy. This  
License will therefore apply, along with any applicable section 7  
additional terms, to the whole of the work, and all its parts,  
regardless of how they are packaged. This License gives no  
permission to license the work in any other way, but it does not  
invalidate such permission if you have separately received it.  
 
d) If the work has interactive user interfaces, each must display  
Appropriate Legal Notices; however, if the Program has interactive  
interfaces that do not display Appropriate Legal Notices, your  
work need not make them do so.  
 
A compilation of a covered work with other separate and independent  
works, which are not by their nature extensions of the covered work,  
and which are not combined with it such as to form a larger program,  
in or on a volume of a storage or distribution medium, is called an  
"aggregate" if the compilation and its resulting copyright are not  
used to limit the access or legal rights of the compilation's users  
beyond what the individual works permit. Inclusion of a covered work  
in an aggregate does not cause this License to apply to the other  
parts of the aggregate.  
 
6. Conveying Non-Source Forms.  
 
You may convey a covered work in object code form under the terms  
of sections 4 and 5, provided that you also convey the  
machine-readable Corresponding Source under the terms of this License,  
in one of these ways:  
 
a) Convey the object code in, or embodied in, a physical product  
(including a physical distribution medium), accompanied by the  
Corresponding Source fixed on a durable physical medium  
customarily used for software interchange.  
 
b) Convey the object code in, or embodied in, a physical product  
(including a physical distribution medium), accompanied by a  
written offer, valid for at least three years and valid for as  
long as you offer spare parts or customer support for that product  
model, to give anyone who possesses the object code either (1) a  
copy of the Corresponding Source for all the software in the  
product that is covered by this License, on a durable physical  
medium customarily used for software interchange, for a price no  
more than your reasonable cost of physically performing this  
conveying of source, or (2) access to copy the  
Corresponding Source from a network server at no charge.  
 
c) Convey individual copies of the object code with a copy of the  
written offer to provide the Corresponding Source. This  
alternative is allowed only occasionally and noncommercially, and  
only if you received the object code with such an offer, in accord  
with subsection 6b.  
 
d) Convey the object code by offering access from a designated  
place (gratis or for a charge), and offer equivalent access to the  
Corresponding Source in the same way through the same place at no  
further charge. You need not require recipients to copy the  
Corresponding Source along with the object code. If the place to  
copy the object code is a network server, the Corresponding Source  
may be on a different server (operated by you or a third party)  
that supports equivalent copying facilities, provided you maintain  
clear directions next to the object code saying where to find the  
Corresponding Source. Regardless of what server hosts the  
Corresponding Source, you remain obligated to ensure that it is  
available for as long as needed to satisfy these requirements.  
 
e) Convey the object code using peer-to-peer transmission, provided  
you inform other peers where the object code and Corresponding  
Source of the work are being offered to the general public at no  
charge under subsection 6d.  
 
A separable portion of the object code, whose source code is excluded  
from the Corresponding Source as a System Library, need not be  
included in conveying the object code work.  
 
A "User Product" is either (1) a "consumer product", which means any  
tangible personal property which is normally used for personal, family,  
or household purposes, or (2) anything designed or sold for incorporation  
into a dwelling. In determining whether a product is a consumer product,  
doubtful cases shall be resolved in favor of coverage. For a particular  
product received by a particular user, "normally used" refers to a  
typical or common use of that class of product, regardless of the status  
of the particular user or of the way in which the particular user  
actually uses, or expects or is expected to use, the product. A product  
is a consumer product regardless of whether the product has substantial  
commercial, industrial or non-consumer uses, unless such uses represent  
the only significant mode of use of the product.  
 
"Installation Information" for a User Product means any methods,  
procedures, authorization keys, or other information required to install  
and execute modified versions of a covered work in that User Product from  
a modified version of its Corresponding Source. The information must  
suffice to ensure that the continued functioning of the modified object  
code is in no case prevented or interfered with solely because  
modification has been made.  
 
If you convey an object code work under this section in, or with, or  
specifically for use in, a User Product, and the conveying occurs as  
part of a transaction in which the right of possession and use of the  
User Product is transferred to the recipient in perpetuity or for a  
fixed term (regardless of how the transaction is characterized), the  
Corresponding Source conveyed under this section must be accompanied  
by the Installation Information. But this requirement does not apply  
if neither you nor any third party retains the ability to install  
modified object code on the User Product (for example, the work has  
been installed in ROM).  
 
The requirement to provide Installation Information does not include a  
requirement to continue to provide support service, warranty, or updates  
for a work that has been modified or installed by the recipient, or for  
the User Product in which it has been modified or installed. Access to a  
network may be denied when the modification itself materially and  
adversely affects the operation of the network or violates the rules and  
protocols for communication across the network.  
 
Corresponding Source conveyed, and Installation Information provided,  
in accord with this section must be in a format that is publicly  
documented (and with an implementation available to the public in  
source code form), and must require no special password or key for  
unpacking, reading or copying.  
 
7. Additional Terms.  
 
"Additional permissions" are terms that supplement the terms of this  
License by making exceptions from one or more of its conditions.  
Additional permissions that are applicable to the entire Program shall  
be treated as though they were included in this License, to the extent  
that they are valid under applicable law. If additional permissions  
apply only to part of the Program, that part may be used separately  
under those permissions, but the entire Program remains governed by  
this License without regard to the additional permissions.  
 
When you convey a copy of a covered work, you may at your option  
remove any additional permissions from that copy, or from any part of  
it. (Additional permissions may be written to require their own  
removal in certain cases when you modify the work.) You may place  
additional permissions on material, added by you to a covered work,  
for which you have or can give appropriate copyright permission.  
 
Notwithstanding any other provision of this License, for material you  
add to a covered work, you may (if authorized by the copyright holders of  
that material) supplement the terms of this License with terms:  
 
a) Disclaiming warranty or limiting liability differently from the  
terms of sections 15 and 16 of this License; or  
 
b) Requiring preservation of specified reasonable legal notices or  
author attributions in that material or in the Appropriate Legal  
Notices displayed by works containing it; or  
 
c) Prohibiting misrepresentation of the origin of that material, or  
requiring that modified versions of such material be marked in  
reasonable ways as different from the original version; or  
 
d) Limiting the use for publicity purposes of names of licensors or  
authors of the material; or  
 
e) Declining to grant rights under trademark law for use of some  
trade names, trademarks, or service marks; or  
 
f) Requiring indemnification of licensors and authors of that  
material by anyone who conveys the material (or modified versions of  
it) with contractual assumptions of liability to the recipient, for  
any liability that these contractual assumptions directly impose on  
those licensors and authors.  
 
All other non-permissive additional terms are considered "further  
restrictions" within the meaning of section 10. If the Program as you  
received it, or any part of it, contains a notice stating that it is  
governed by this License along with a term that is a further  
restriction, you may remove that term. If a license document contains  
a further restriction but permits relicensing or conveying under this  
License, you may add to a covered work material governed by the terms  
of that license document, provided that the further restriction does  
not survive such relicensing or conveying.  
 
If you add terms to a covered work in accord with this section, you  
must place, in the relevant source files, a statement of the  
additional terms that apply to those files, or a notice indicating  
where to find the applicable terms.  
 
Additional terms, permissive or non-permissive, may be stated in the  
form of a separately written license, or stated as exceptions;  
the above requirements apply either way.  
 
8. Termination.  
 
You may not propagate or modify a covered work except as expressly  
provided under this License. Any attempt otherwise to propagate or  
modify it is void, and will automatically terminate your rights under  
this License (including any patent licenses granted under the third  
paragraph of section 11).  
 
However, if you cease all violation of this License, then your  
license from a particular copyright holder is reinstated (a)  
provisionally, unless and until the copyright holder explicitly and  
finally terminates your license, and (b) permanently, if the copyright  
holder fails to notify you of the violation by some reasonable means  
prior to 60 days after the cessation.  
 
Moreover, your license from a particular copyright holder is  
reinstated permanently if the copyright holder notifies you of the  
violation by some reasonable means, this is the first time you have  
received notice of violation of this License (for any work) from that  
copyright holder, and you cure the violation prior to 30 days after  
your receipt of the notice.  
 
Termination of your rights under this section does not terminate the  
licenses of parties who have received copies or rights from you under  
this License. If your rights have been terminated and not permanently  
reinstated, you do not qualify to receive new licenses for the same  
material under section 10.  
 
9. Acceptance Not Required for Having Copies.  
 
You are not required to accept this License in order to receive or  
run a copy of the Program. Ancillary propagation of a covered work  
occurring solely as a consequence of using peer-to-peer transmission  
to receive a copy likewise does not require acceptance. However,  
nothing other than this License grants you permission to propagate or  
modify any covered work. These actions infringe copyright if you do  
not accept this License. Therefore, by modifying or propagating a  
covered work, you indicate your acceptance of this License to do so.  
 
10. Automatic Licensing of Downstream Recipients.  
 
Each time you convey a covered work, the recipient automatically  
receives a license from the original licensors, to run, modify and  
propagate that work, subject to this License. You are not responsible  
for enforcing compliance by third parties with this License.  
 
An "entity transaction" is a transaction transferring control of an  
organization, or substantially all assets of one, or subdividing an  
organization, or merging organizations. If propagation of a covered  
work results from an entity transaction, each party to that  
transaction who receives a copy of the work also receives whatever  
licenses to the work the party's predecessor in interest had or could  
give under the previous paragraph, plus a right to possession of the  
Corresponding Source of the work from the predecessor in interest, if  
the predecessor has it or can get it with reasonable efforts.  
 
You may not impose any further restrictions on the exercise of the  
rights granted or affirmed under this License. For example, you may  
not impose a license fee, royalty, or other charge for exercise of  
rights granted under this License, and you may not initiate litigation  
(including a cross-claim or counterclaim in a lawsuit) alleging that  
any patent claim is infringed by making, using, selling, offering for  
sale, or importing the Program or any portion of it.  
 
11. Patents.  
 
A "contributor" is a copyright holder who authorizes use under this  
License of the Program or a work on which the Program is based. The  
work thus licensed is called the contributor's "contributor version".  
 
A contributor's "essential patent claims" are all patent claims  
owned or controlled by the contributor, whether already acquired or  
hereafter acquired, that would be infringed by some manner, permitted  
by this License, of making, using, or selling its contributor version,  
but do not include claims that would be infringed only as a  
consequence of further modification of the contributor version. For  
purposes of this definition, "control" includes the right to grant  
patent sublicenses in a manner consistent with the requirements of  
this License.  
 
Each contributor grants you a non-exclusive, worldwide, royalty-free  
patent license under the contributor's essential patent claims, to  
make, use, sell, offer for sale, import and otherwise run, modify and  
propagate the contents of its contributor version.  
 
In the following three paragraphs, a "patent license" is any express  
agreement or commitment, however denominated, not to enforce a patent  
(such as an express permission to practice a patent or covenant not to  
sue for patent infringement). To "grant" such a patent license to a  
party means to make such an agreement or commitment not to enforce a  
patent against the party.  
 
If you convey a covered work, knowingly relying on a patent license,  
and the Corresponding Source of the work is not available for anyone  
to copy, free of charge and under the terms of this License, through a  
publicly available network server or other readily accessible means,  
then you must either (1) cause the Corresponding Source to be so  
available, or (2) arrange to deprive yourself of the benefit of the  
patent license for this particular work, or (3) arrange, in a manner  
consistent with the requirements of this License, to extend the patent  
license to downstream recipients. "Knowingly relying" means you have  
actual knowledge that, but for the patent license, your conveying the  
covered work in a country, or your recipient's use of the covered work  
in a country, would infringe one or more identifiable patents in that  
country that you have reason to believe are valid.  
 
If, pursuant to or in connection with a single transaction or  
arrangement, you convey, or propagate by procuring conveyance of, a  
covered work, and grant a patent license to some of the parties  
receiving the covered work authorizing them to use, propagate, modify  
or convey a specific copy of the covered work, then the patent license  
you grant is automatically extended to all recipients of the covered  
work and works based on it.  
 
A patent license is "discriminatory" if it does not include within  
the scope of its coverage, prohibits the exercise of, or is  
conditioned on the non-exercise of one or more of the rights that are  
specifically granted under this License. You may not convey a covered  
work if you are a party to an arrangement with a third party that is  
in the business of distributing software, under which you make payment  
to the third party based on the extent of your activity of conveying  
the work, and under which the third party grants, to any of the  
parties who would receive the covered work from you, a discriminatory  
patent license (a) in connection with copies of the covered work  
conveyed by you (or copies made from those copies), or (b) primarily  
for and in connection with specific products or compilations that  
contain the covered work, unless you entered into that arrangement,  
or that patent license was granted, prior to 28 March 2007.  
 
Nothing in this License shall be construed as excluding or limiting  
any implied license or other defenses to infringement that may  
otherwise be available to you under applicable patent law.  
 
12. No Surrender of Others' Freedom.  
 
If conditions are imposed on you (whether by court order, agreement or  
otherwise) that contradict the conditions of this License, they do not  
excuse you from the conditions of this License. If you cannot convey a  
covered work so as to satisfy simultaneously your obligations under this  
License and any other pertinent obligations, then as a consequence you may  
not convey it at all. For example, if you agree to terms that obligate you  
to collect a royalty for further conveying from those to whom you convey  
the Program, the only way you could satisfy both those terms and this  
License would be to refrain entirely from conveying the Program.  
 
13. Use with the GNU Affero General Public License.  
 
Notwithstanding any other provision of this License, you have  
permission to link or combine any covered work with a work licensed  
under version 3 of the GNU Affero General Public License into a single  
combined work, and to convey the resulting work. The terms of this  
License will continue to apply to the part which is the covered work,  
but the special requirements of the GNU Affero General Public License,  
section 13, concerning interaction through a network will apply to the  
combination as such.  
 
14. Revised Versions of this License.  
 
The Free Software Foundation may publish revised and/or new versions of  
the GNU General Public License from time to time. Such new versions will  
be similar in spirit to the present version, but may differ in detail to  
address new problems or concerns.  
 
Each version is given a distinguishing version number. If the  
Program specifies that a certain numbered version of the GNU General  
Public License "or any later version" applies to it, you have the  
option of following the terms and conditions either of that numbered  
version or of any later version published by the Free Software  
Foundation. If the Program does not specify a version number of the  
GNU General Public License, you may choose any version ever published  
by the Free Software Foundation.  
 
If the Program specifies that a proxy can decide which future  
versions of the GNU General Public License can be used, that proxy's  
public statement of acceptance of a version permanently authorizes you  
to choose that version for the Program.  
 
Later license versions may give you additional or different  
permissions. However, no additional obligations are imposed on any  
author or copyright holder as a result of your choosing to follow a  
later version.  
 
15. Disclaimer of Warranty.  
 
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY  
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT  
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY  
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,  
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR  
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM  
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF  
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.  
 
16. Limitation of Liability.  
 
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING  
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS  
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY  
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE  
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF  
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD  
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),  
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF  
SUCH DAMAGES.  
 
17. Interpretation of Sections 15 and 16.  
 
If the disclaimer of warranty and limitation of liability provided  
above cannot be given local legal effect according to their terms,  
reviewing courts shall apply local law that most closely approximates  
an absolute waiver of all civil liability in connection with the  
Program, unless a warranty or assumption of liability accompanies a  
copy of the Program in return for a fee.  
 
END OF TERMS AND CONDITIONS  
 
How to Apply These Terms to Your New Programs  
 
If you develop a new program, and you want it to be of the greatest  
possible use to the public, the best way to achieve this is to make it  
free software which everyone can redistribute and change under these terms.  
 
To do so, attach the following notices to the program. It is safest  
to attach them to the start of each source file to most effectively  
state the exclusion of warranty; and each file should have at least  
the "copyright" line and a pointer to where the full notice is found.  
 
<one line to give the program's name and a brief idea of what it does.>  
Copyright (C) <year> <name of author>  
 
This program is free software: you can redistribute it and/or modify  
it under the terms of the GNU General Public License as published by  
the Free Software Foundation, either version 3 of the License, or  
(at your option) any later version.  
 
This program is distributed in the hope that it will be useful,  
but WITHOUT ANY WARRANTY; without even the implied warranty of  
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the  
GNU General Public License for more details.  
 
You should have received a copy of the GNU General Public License  
along with this program. If not, see <http://www.gnu.org/licenses/>.  
 
Also add information on how to contact you by electronic and paper mail.  
 
If the program does terminal interaction, make it output a short  
notice like this when it starts in an interactive mode:  
 
<program> Copyright (C) <year> <name of author>  
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.  
This is free software, and you are welcome to redistribute it  
under certain conditions; type `show c' for details.  
 
The hypothetical commands `show w' and `show c' should show the appropriate  
parts of the General Public License. Of course, your program's commands  
might be different; for a GUI interface, you would use an "about box".  
 
You should also get your employer (if you work as a programmer) or school,  
if any, to sign a "copyright disclaimer" for the program, if necessary.  
For more information on this, and how to apply and follow the GNU GPL, see  
<http://www.gnu.org/licenses/>.  
 
The GNU General Public License does not permit incorporating your program  
into proprietary programs. If your program is a subroutine library, you  
may consider it more useful to permit linking proprietary applications with  
the library. If this is what you want to do, use the GNU Lesser General  
Public License instead of this License. But first, please read  
<http://www.gnu.org/philosophy/why-not-lgpl.html>.  
 
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<meta charset='UTF-8'> <meta charset='UTF-8'>
<title>Kerbal Engineer Redux - README</title> <title>Kerbal Engineer Redux - README</title>
<link href='http://fonts.googleapis.com/css?family=PT+Sans:400,700' rel='stylesheet' type='text/css'> <link href='http://fonts.googleapis.com/css?family=PT+Sans:400,700' rel='stylesheet' type='text/css'>
<script> <script>
function resizeIframe(obj) { function resizeIframe(obj) {
obj.style.height = obj.contentWindow.document.body.scrollHeight + 'px'; obj.style.height = obj.contentWindow.document.body.scrollHeight + 'px';
} }
</script> </script>
<style> <style>
* { * {
margin: 0; padding: 0; margin: 0; padding: 0;
box-sizing: border-box; moz-box-sizing: border-box; webkit-box-sizing: border-box; box-sizing: border-box; moz-box-sizing: border-box; webkit-box-sizing: border-box;
} }
   
html, body { html, body {
height: 100%; height: 100%;
font-family: 'PT Sans', Verdana, Geneva, sans-serif; font-family: 'PT Sans', Verdana, Geneva, sans-serif;
} }
   
a { a {
text-decoration: none; text-decoration: none;
font-weight: 700; font-weight: 700;
color: inherit; color: inherit;
} }
   
a:hover { a:hover {
text-decoration: underline; text-decoration: underline;
} }
   
h3 { h3 {
display: block; display: block;
line-height: 1.5em; line-height: 1.5em;
font-size: 1.1em; font-size: 1.1em;
font-weight: 700; font-weight: 700;
} }
   
p { p {
display: block; display: block;
margin: 0 0.5em; margin: 0 0.5em;
text-align: justify; text-align: justify;
} }
   
ul { ul {
display: block; display: block;
margin-left: 1.5em; margin-left: 1.5em;
list-style-type: square; list-style-type: square;
} }
   
li { li {
margin-top: 0.5em; margin-top: 0.5em;
text-align: justify; text-align: justify;
} }
   
iframe { iframe {
width: 100%; width: 100%;
border: none; border: none;
} }
   
header { header {
display: block; display: block;
padding: 25px; padding: 25px;
text-align: center; text-align: center;
font-size: 3rem; font-size: 3rem;
font-weight: 700; font-weight: 700;
letter-spacing: 0.2em; letter-spacing: 0.2em;
color: white; color: white;
background-color: black; background-color: black;
} }
   
section { section {
display: block; display: block;
margin: 10px; margin: 10px;
padding: 0.5em 1em; padding: 0.5em 1em;
line-height: 1.5em; line-height: 1.5em;
background-color: #DDD; background-color: #DDD;
} }
   
footer { footer {
display: block; display: block;
text-align: center; text-align: center;
line-height: 50px; line-height: 50px;
font-size: 0.8rem; font-size: 0.8rem;
letter-spacing: 0.2em; letter-spacing: 0.2em;
color: white; color: white;
background-color: black; background-color: black;
} }
   
.nested_list > li { .nested_list > li {
margin-top: 1em; margin-top: 1em;
} }
   
.nested_list > li:first-child { .nested_list > li:first-child {
margin-top: 0.5em; margin-top: 0.5em;
} }
   
#root { #root {
clear: both; clear: both;
min-height: 100%; min-height: 100%;
height: auto !important; height: auto !important;
height: 100%; height: 100%;
margin-bottom: -50px; margin-bottom: -50px;
} }
   
#root > #root_footer { #root > #root_footer {
height: 50px; height: 50px;
} }
   
#footer { #footer {
clear: both; clear: both;
position: relative; position: relative;
height: 50px; height: 50px;
} }
</style> </style>
</head> </head>
<body> <body>
<div id='root'> <div id='root'>
<header>Kerbal Engineer Redux v1.0</header> <header>Kerbal Engineer Redux v1.0</header>
   
<section> <section>
<h3>Developers</h3> <h3>Developers</h3>
<p> <p>
CYBUTEK: Primary Development<br> CYBUTEK: Primary Development<br>
Padishar: Simulation Logic Padishar: Simulation Logic
</p> </p>
</section> </section>
   
<section> <section>
<h3>Honourable Mentions</h3> <h3>Honourable Mentions</h3>
<p> <p>
Mic_E: Impact Readouts Mic_E: Impact Readouts
</p> </p>
</section> </section>
   
<section> <section>
<h3>Goto the Forum Thread</h3> <h3>Goto the Forum Thread</h3>
<p> <p>
<a href="http://forum.kerbalspaceprogram.com/threads/18230" target='_blank'>http://forum.kerbalspaceprogram.com/threads/18230</a> <a href="http://forum.kerbalspaceprogram.com/threads/18230" target='_blank'>http://forum.kerbalspaceprogram.com/threads/18230</a>
</p> </p>
</section> </section>
   
<section> <section>
<h3>KSP-AVC Ready</h3> <h3>KSP-AVC Ready</h3>
<p> <p>
KSP Add-on Version Checker is a standardised system for versioning mods. You can get more information on this KSP Add-on Version Checker is a standardised system for versioning mods. You can get more information on this
<a href='http://forum.kerbalspaceprogram.com/threads/79745' target='_blank'>forum thread</a>. <a href='http://forum.kerbalspaceprogram.com/threads/79745' target='_blank'>forum thread</a>.
</p> </p>
</section> </section>
   
<section> <section>
<h3>Contains MiniAVC</h3> <h3>Contains MiniAVC</h3>
<p> <p>
This mod includes version checking using <a href="http://forum.kerbalspaceprogram.com/threads/79745">MiniAVC</a>. If you opt-in, it will use the internet to check whether there is a new version available. Data is only read from the internet and no personal information is sent. For a more comprehensive version checking experience, please download the <a href="http://forum.kerbalspaceprogram.com/threads/79745">KSP-AVC Plugin</a>. This mod includes version checking using <a href="http://forum.kerbalspaceprogram.com/threads/79745">MiniAVC</a>. If you opt-in, it will use the internet to check whether there is a new version available. Data is only read from the internet and no personal information is sent. For a more comprehensive version checking experience, please download the <a href="http://forum.kerbalspaceprogram.com/threads/79745">KSP-AVC Plugin</a>.
</p> </p>
</section> </section>
   
<section> <section>
<h3>Description</h3> <h3>Description</h3>
<p> <p>
This plugin will allow you to view important statistics about your ship on the fly, whilst constructing and in flight. This plugin will allow you to view important statistics about your ship on the fly, whilst constructing and in flight.
</p> </p>
</section> </section>
   
<section> <section>
<h3>Installation</h3> <h3>Installation</h3>
<ul> <ul>
<li>Copy the 'KerbalEngineer' folder into the 'GameData' folder located within your Kerbal Space Program installation directory.</li> <li>Copy the 'KerbalEngineer' folder into the 'GameData' folder located within your Kerbal Space Program installation directory.</li>
<li>The 'Parts' folder including the 'ER7500' and 'EngineerChip' is optional and are only required if running in module mode.</li> <li>The 'Parts' folder including the 'ER7500' and 'EngineerChip' is optional and are only required if running in module mode.</li>
</ul> </ul>
</section> </section>
   
<section> <section>
<h3>Change Log</h3> <h3>Change Log</h3>
<iframe src='CHANGES.txt' onload="this.style.height = this.contentWindow.document.body.scrollHeight + 'px'"></iframe> <iframe src='CHANGES.txt' onload="this.style.height = this.contentWindow.document.body.scrollHeight + 'px'"></iframe>
</section> </section>
   
<section> <section>
<h3>Software License</h3> <h3>Software License</h3>
<p> <p>
Licensed under the <a href='LICENSE.txt'>GNU General Public License v3</a>. Licensed under the <a href='LICENCE.txt'>GNU General Public License v3</a>.
</p> </p>
</section> </section>
   
<div id='root_footer'></div> <div id='root_footer'></div>
</div> </div>
   
<footer id='footer'> <footer id='footer'>
README design by <a href='http://ksp.cybutek.net' target='_blank'><strong>CYBUTEK</strong></a> (GPLv3) README design by <a href='http://ksp.cybutek.net' target='_blank'><strong>CYBUTEK</strong></a> (GPLv3)
</footer> </footer>
</body> </body>
</html> </html>
// //
// Kerbal Engineer Redux // Kerbal Engineer Redux
// //
// Copyright (C) 2014 CYBUTEK // Copyright (C) 2014 CYBUTEK
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
// //
   
#region Using Directives #region Using Directives
   
using System.IO; using System.IO;
using System.Reflection; using System.Reflection;
   
#endregion #endregion
   
namespace KerbalEngineer namespace KerbalEngineer
{ {
public class EngineerGlobals public class EngineerGlobals
{ {
#region Constants #region Constants
   
/// <summary> /// <summary>
/// Current version of the Kerbal Engineer assembly. /// Current version of the Kerbal Engineer assembly.
/// </summary> /// </summary>
public const string AssemblyVersion = "1.0.10"; public const string AssemblyVersion = "1.0.11";
   
#endregion #endregion
   
#region Fields #region Fields
   
private static string assemblyFile; private static string assemblyFile;
private static string assemblyName; private static string assemblyName;
private static string assemblyPath; private static string assemblyPath;
   
#endregion #endregion
   
#region Properties #region Properties
   
/// <summary> /// <summary>
/// Gets the Kerbal Engineer assembly's path including the file name. /// Gets the Kerbal Engineer assembly's path including the file name.
/// </summary> /// </summary>
public static string AssemblyFile public static string AssemblyFile
{ {
get { return assemblyFile ?? (assemblyFile = Assembly.GetExecutingAssembly().Location); } get { return assemblyFile ?? (assemblyFile = Assembly.GetExecutingAssembly().Location); }
} }
   
/// <summary> /// <summary>
/// Gets the Kerbal Engineer assembly's file name. /// Gets the Kerbal Engineer assembly's file name.
/// </summary> /// </summary>
public static string AssemblyName public static string AssemblyName
{ {
get { return assemblyName ?? (assemblyName = new FileInfo(AssemblyFile).Name); } get { return assemblyName ?? (assemblyName = new FileInfo(AssemblyFile).Name); }
} }
   
/// <summary> /// <summary>
/// Gets the Kerbal Engineer assembly's path excluding the file name. /// Gets the Kerbal Engineer assembly's path excluding the file name.
/// </summary> /// </summary>
public static string AssemblyPath public static string AssemblyPath
{ {
get { return assemblyPath ?? (assemblyPath = AssemblyFile.Replace(new FileInfo(AssemblyFile).Name, "")); } get { return assemblyPath ?? (assemblyPath = AssemblyFile.Replace(new FileInfo(AssemblyFile).Name, "")); }
} }
   
#endregion #endregion
} }
} }
// //
// Kerbal Engineer Redux // Kerbal Engineer Redux
// //
// Copyright (C) 2014 CYBUTEK // Copyright (C) 2014 CYBUTEK
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
// //
   
#region Using Directives #region Using Directives
   
using System; using System;
   
using KerbalEngineer.Helpers; using KerbalEngineer.Helpers;
   
using UnityEngine; using UnityEngine;
   
#endregion #endregion
   
namespace KerbalEngineer.Extensions namespace KerbalEngineer.Extensions
{ {
public static class OrbitExtensions public static class OrbitExtensions
{ {
#region Constants #region Constants
   
public const double Tau = Math.PI * 2.0; public const double Tau = Math.PI * 2.0;
   
#endregion #endregion
   
#region Methods: public #region Methods: public
   
public static double GetAngleToAscendingNode(this Orbit orbit) public static double GetAngleToAscendingNode(this Orbit orbit)
{ {
return GetAngleToTrueAnomaly(orbit, GetTrueAnomalyOfAscendingNode(orbit)); return GetAngleToTrueAnomaly(orbit, GetTrueAnomalyOfAscendingNode(orbit));
} }
   
public static double GetAngleToDescendingNode(this Orbit orbit) public static double GetAngleToDescendingNode(this Orbit orbit)
{ {
return GetAngleToTrueAnomaly(orbit, GetTrueAnomalyOfDescendingNode(orbit)); return GetAngleToTrueAnomaly(orbit, GetTrueAnomalyOfDescendingNode(orbit));
} }
   
public static double GetAngleToPrograde(this Orbit orbit) public static double GetAngleToPrograde(this Orbit orbit)
{ {
  return GetAngleToPrograde(orbit, Planetarium.GetUniversalTime());
  }
   
  public static double GetAngleToPrograde(this Orbit orbit, double universalTime)
  {
if (orbit.referenceBody == CelestialBodies.SystemBody.CelestialBody) if (orbit.referenceBody == CelestialBodies.SystemBody.CelestialBody)
{ {
return 0.0; return 0.0;
} }
   
var angle = AngleHelper.GetAngleBetweenVectors(orbit.getRelativePositionAtUT(Planetarium.GetUniversalTime()), var angle = AngleHelper.GetAngleBetweenVectors(orbit.getRelativePositionAtUT(universalTime),
Vector3d.Exclude(orbit.GetOrbitNormal(), orbit.referenceBody.orbit.getRelativePositionAtUT(Planetarium.GetUniversalTime()))); Vector3d.Exclude(orbit.GetOrbitNormal(), orbit.referenceBody.orbit.getRelativePositionAtUT(universalTime)));
   
angle = AngleHelper.Clamp360(angle - 90.0); angle = AngleHelper.Clamp360(angle - 90.0);
   
return orbit.inclination > 90.0 ? angle : 360.0 - angle; return orbit.inclination > 90.0 ? angle : 360.0 - angle;
} }
   
public static double GetAngleToRetrograde(this Orbit orbit) public static double GetAngleToRetrograde(this Orbit orbit)
{ {
  return GetAngleToRetrograde(orbit, Planetarium.GetUniversalTime());
  }
   
  public static double GetAngleToRetrograde(this Orbit orbit, double universalTime)
  {
if (orbit.referenceBody == CelestialBodies.SystemBody.CelestialBody) if (orbit.referenceBody == CelestialBodies.SystemBody.CelestialBody)
{ {
return 0.0; return 0.0;
} }
   
var angle = AngleHelper.GetAngleBetweenVectors(orbit.getRelativePositionAtUT(Planetarium.GetUniversalTime()), var angle = AngleHelper.GetAngleBetweenVectors(orbit.getRelativePositionAtUT(universalTime),
Vector3d.Exclude(orbit.GetOrbitNormal(), orbit.referenceBody.orbit.getRelativePositionAtUT(Planetarium.GetUniversalTime()))); Vector3d.Exclude(orbit.GetOrbitNormal(), orbit.referenceBody.orbit.getRelativePositionAtUT(universalTime)));
   
angle = AngleHelper.Clamp360(angle + 90.0); angle = AngleHelper.Clamp360(angle + 90.0);
   
return orbit.inclination > 90.0 ? angle : 360.0 - angle; return orbit.inclination > 90.0 ? angle : 360.0 - angle;
} }
   
public static double GetAngleToTrueAnomaly(this Orbit orbit, double trueAnomaly) public static double GetAngleToTrueAnomaly(this Orbit orbit, double trueAnomaly)
{ {
return AngleHelper.Clamp360(trueAnomaly - orbit.trueAnomaly); return AngleHelper.Clamp360(trueAnomaly - orbit.trueAnomaly);
} }
   
public static double GetAngleToVector(this Orbit orbit, Vector3d vector) public static double GetAngleToVector(this Orbit orbit, Vector3d vector)
{ {
return GetAngleToTrueAnomaly(orbit, GetTrueAnomalyFromVector(orbit, Vector3d.Exclude(orbit.GetOrbitNormal(), vector))); return GetAngleToTrueAnomaly(orbit, GetTrueAnomalyFromVector(orbit, Vector3d.Exclude(orbit.GetOrbitNormal(), vector)));
} }
   
public static double GetPhaseAngle(this Orbit orbit, Orbit target) public static double GetPhaseAngle(this Orbit orbit, Orbit target)
{ {
var angle = AngleHelper.GetAngleBetweenVectors(Vector3d.Exclude(orbit.GetOrbitNormal(), target.pos), orbit.pos); var angle = AngleHelper.GetAngleBetweenVectors(Vector3d.Exclude(orbit.GetOrbitNormal(), target.pos), orbit.pos);
return (orbit.semiMajorAxis < target.semiMajorAxis) ? angle : angle - 360.0; return (orbit.semiMajorAxis < target.semiMajorAxis) ? angle : angle - 360.0;
} }
   
public static double GetRelativeInclination(this Orbit orbit, Orbit target) public static double GetRelativeInclination(this Orbit orbit, Orbit target)
{ {
return Vector3d.Angle(orbit.GetOrbitNormal(), target.GetOrbitNormal()); return Vector3d.Angle(orbit.GetOrbitNormal(), target.GetOrbitNormal());
} }
   
public static double GetTimeToAscendingNode(this Orbit orbit) public static double GetTimeToAscendingNode(this Orbit orbit)
{ {
return GetTimeToTrueAnomaly(orbit, GetTrueAnomalyOfAscendingNode(orbit)); return GetTimeToTrueAnomaly(orbit, GetTrueAnomalyOfAscendingNode(orbit));
} }
   
public static double GetTimeToDescendingNode(this Orbit orbit) public static double GetTimeToDescendingNode(this Orbit orbit)
{ {
return GetTimeToTrueAnomaly(orbit, GetTrueAnomalyOfDescendingNode(orbit)); return GetTimeToTrueAnomaly(orbit, GetTrueAnomalyOfDescendingNode(orbit));
} }
   
public static double GetTimeToTrueAnomaly(this Orbit orbit, double trueAnomaly) public static double GetTimeToTrueAnomaly(this Orbit orbit, double trueAnomaly)
{ {
var time = orbit.GetDTforTrueAnomaly(trueAnomaly * Mathf.Deg2Rad, orbit.period); var time = orbit.GetDTforTrueAnomaly(trueAnomaly * Mathf.Deg2Rad, orbit.period);
return time < 0.0 ? time + orbit.period : time; return time < 0.0 ? time + orbit.period : time;
} }
   
public static double GetTimeToVector(this Orbit orbit, Vector3d vector) public static double GetTimeToVector(this Orbit orbit, Vector3d vector)
{ {
return GetTimeToTrueAnomaly(orbit, GetTrueAnomalyFromVector(orbit, vector)); return GetTimeToTrueAnomaly(orbit, GetTrueAnomalyFromVector(orbit, vector));
} }
   
public static double GetTrueAnomalyFromVector(this Orbit orbit, Vector3d vector) public static double GetTrueAnomalyFromVector(this Orbit orbit, Vector3d vector)
{ {
return orbit.GetTrueAnomalyOfZupVector(vector) * Mathf.Rad2Deg; return orbit.GetTrueAnomalyOfZupVector(vector) * Mathf.Rad2Deg;
} }
   
public static double GetTrueAnomalyOfAscendingNode(this Orbit orbit) public static double GetTrueAnomalyOfAscendingNode(this Orbit orbit)
{ {
return 360.0 - orbit.argumentOfPeriapsis; return 360.0 - orbit.argumentOfPeriapsis;
} }
   
public static double GetTrueAnomalyOfDescendingNode(this Orbit orbit) public static double GetTrueAnomalyOfDescendingNode(this Orbit orbit)
{ {
return 180.0 - orbit.argumentOfPeriapsis; return 180.0 - orbit.argumentOfPeriapsis;
} }
   
#endregion #endregion
} }
} }
// //
// Kerbal Engineer Redux // Kerbal Engineer Redux
// //
// Copyright (C) 2014 CYBUTEK // Copyright (C) 2014 CYBUTEK
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
// //
   
#region Using Directives #region Using Directives
   
using System.Linq; using System.Linq;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
   
#endregion #endregion
   
namespace KerbalEngineer.Flight.Presets namespace KerbalEngineer.Flight.Presets
{ {
public class Preset public class Preset
{ {
#region Properties #region Properties
   
public string Abbreviation { get; set; } public string Abbreviation { get; set; }
   
public string FileName public string FileName
{ {
get { return Regex.Replace(this.Name, @"[^\d\w]", string.Empty) + ".xml"; } get { return Regex.Replace(this.Name, @"[^\d\w]", string.Empty) + ".xml"; }
} }
   
  public bool IsHud { get; set; }
   
  public bool IsHudBackground { get; set; }
   
public string Name { get; set; } public string Name { get; set; }
   
public string[] ReadoutNames { get; set; } public string[] ReadoutNames { get; set; }
   
#endregion #endregion
   
#region Methods: public #region Methods: public
   
public override string ToString() public override string ToString()
{ {
return this.Name + this.ReadoutNames.Select(r => "\n\t" + r); return this.Name + this.ReadoutNames.Select(r => "\n\t" + r);
} }
   
#endregion #endregion
} }
} }
// //
// Kerbal Engineer Redux // Kerbal Engineer Redux
// //
// Copyright (C) 2014 CYBUTEK // Copyright (C) 2014 CYBUTEK
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
// //
   
#region Using Directives #region Using Directives
   
  using System;
   
using KerbalEngineer.Flight.Sections; using KerbalEngineer.Flight.Sections;
  using KerbalEngineer.Helpers;
   
using UnityEngine; using UnityEngine;
   
#endregion #endregion
   
namespace KerbalEngineer.Flight.Readouts.Miscellaneous namespace KerbalEngineer.Flight.Readouts.Miscellaneous
{ {
public class Separator : ReadoutModule public class Separator : ReadoutModule
{ {
#region Fields #region Fields
   
private readonly Texture2D texture; private GUIStyle boxStyle;
  private GUIStyle boxStyleHud;
   
#endregion #endregion
   
#region Constructors #region Constructors
   
public Separator() public Separator()
{ {
this.Name = "Separator"; this.Name = "Separator";
this.Category = ReadoutCategory.GetCategory("Miscellaneous"); this.Category = ReadoutCategory.GetCategory("Miscellaneous");
this.HelpString = string.Empty; this.HelpString = String.Empty;
this.IsDefault = false; this.IsDefault = false;
this.Cloneable = true; this.Cloneable = true;
   
this.texture = new Texture2D(1, 1, TextureFormat.RGBA32, false); this.InitialiseStyles();
this.texture.SetPixel(0, 0, new Color(1.0f, 1.0f, 1.0f, 0.5f));  
this.texture.Apply(); GuiDisplaySize.OnSizeChanged += this.InitialiseStyles;
} }
   
#endregion #endregion
   
#region Methods: public #region Methods: public
   
public override void Draw(SectionModule section) public override void Draw(SectionModule section)
{ {
GUILayout.Box(string.Empty, GUIStyle.none, new[] {GUILayout.Width(this.ContentWidth), GUILayout.Height(1.0f)}); GUILayout.Box(String.Empty, section.IsHud ? this.boxStyleHud : this.boxStyle);
GUI.DrawTexture(GUILayoutUtility.GetLastRect(), this.texture, ScaleMode.StretchToFill); }
   
  #endregion
   
  #region Methods: private
   
  private void InitialiseStyles()
  {
  this.boxStyle = new GUIStyle
  {
  normal =
  {
  background = TextureHelper.CreateTextureFromColour(new Color(1.0f, 1.0f, 1.0f, 0.5f))
  },
  fixedHeight = 1.0f,
  stretchWidth = true
  };
   
  this.boxStyleHud = new GUIStyle(this.boxStyle)
  {
  margin = new RectOffset(0, 0, (int)(8 * GuiDisplaySize.Offset), 0)
  };
} }
   
#endregion #endregion
} }
} }
// //
// Kerbal Engineer Redux // Kerbal Engineer Redux
// //
// Copyright (C) 2014 CYBUTEK // Copyright (C) 2014 CYBUTEK
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
// //
   
#region Using Directives #region Using Directives
   
  using System;
   
using KerbalEngineer.Extensions; using KerbalEngineer.Extensions;
using KerbalEngineer.Flight.Sections; using KerbalEngineer.Flight.Sections;
   
#endregion #endregion
   
namespace KerbalEngineer.Flight.Readouts.Orbital namespace KerbalEngineer.Flight.Readouts.Orbital
{ {
public class CurrentSoi : ReadoutModule public class CurrentSoi : ReadoutModule
{ {
#region Constructors #region Constructors
   
public CurrentSoi() public CurrentSoi()
{ {
this.Name = "Current SOI"; this.Name = "Current SOI";
this.Category = ReadoutCategory.GetCategory("Orbital"); this.Category = ReadoutCategory.GetCategory("Orbital");
this.HelpString = "Shows the SOI of the current body the vessel is orbiting."; this.HelpString = "Shows the SOI of the current body the vessel is orbiting.";
this.IsDefault = false; this.IsDefault = false;
} }
   
#endregion #endregion
   
#region Methods: public #region Methods: public
   
public override void Draw(SectionModule section) public override void Draw(SectionModule section)
{ {
this.DrawLine(FlightGlobals.currentMainBody.sphereOfInfluence.ToDistance(), section.IsHud); if (!Double.IsInfinity(FlightGlobals.currentMainBody.sphereOfInfluence))
  {
  this.DrawLine(FlightGlobals.currentMainBody.sphereOfInfluence.ToDistance(), section.IsHud);
  }
} }
   
#endregion #endregion
} }
} }
  //
  // Kerbal Engineer Redux
  //
  // Copyright (C) 2014 CYBUTEK
  //
  // This program is free software: you can redistribute it and/or modify
  // it under the terms of the GNU General Public License as published by
  // the Free Software Foundation, either version 3 of the License, or
  // (at your option) any later version.
  //
  // This program is distributed in the hope that it will be useful,
  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  // GNU General Public License for more details.
  //
  // You should have received a copy of the GNU General Public License
  // along with this program. If not, see <http://www.gnu.org/licenses/>.
  //
 
  #region Using Directives
 
  using System;
 
  using KerbalEngineer.Extensions;
  using KerbalEngineer.Flight.Readouts.Vessel;
 
  using UnityEngine;
 
  #endregion
 
  namespace KerbalEngineer.Flight.Readouts.Orbital.ManoeuvreNode
  {
  public class ManoeuvreProcessor : IUpdatable, IUpdateRequest
  {
  #region Fields
 
  private static readonly ManoeuvreProcessor instance = new ManoeuvreProcessor();
 
  #endregion
 
  #region Properties
 
  public static double AngleToPrograde { get; private set; }
 
  public static double AngleToRetrograde { get; private set; }
 
  public static double AvailableDeltaV { get; private set; }
 
  public static double BurnTime { get; private set; }
  public static int FinalStage { get; private set; }
 
  public static double HalfBurnTime { get; private set; }
 
  public static bool HasDeltaV { get; private set; }
 
  public static ManoeuvreProcessor Instance
  {
  get { return instance; }
  }
 
  public static double NormalDeltaV { get; private set; }
 
  public static double ProgradeDeltaV { get; private set; }
 
  public static double RadialDeltaV { get; private set; }
 
  public static bool ShowDetails { get; set; }
 
  public static double TotalDeltaV { get; private set; }
 
  public static double UniversalTime { get; private set; }
 
  public bool UpdateRequested { get; set; }
 
  #endregion
 
  #region Methods: public
 
  public static void RequestUpdate()
  {
  instance.UpdateRequested = true;
  SimulationProcessor.RequestUpdate();
  }
 
  public static void Reset()
  {
  FlightEngineerCore.Instance.AddUpdatable(SimulationProcessor.Instance);
  FlightEngineerCore.Instance.AddUpdatable(instance);
  }
 
  public void Update()
  {
  if (FlightGlobals.ActiveVessel.patchedConicSolver.maneuverNodes.Count == 0 || !SimulationProcessor.ShowDetails)
  {
  ShowDetails = false;
  return;
  }
 
  var node = FlightGlobals.ActiveVessel.patchedConicSolver.maneuverNodes[0];
  var deltaV = node.DeltaV;
 
  ProgradeDeltaV = deltaV.z;
  NormalDeltaV = deltaV.y;
  RadialDeltaV = deltaV.x;
  TotalDeltaV = node.GetBurnVector(FlightGlobals.ship_orbit).magnitude;
 
  UniversalTime = FlightGlobals.ActiveVessel.patchedConicSolver.maneuverNodes[0].UT;
  AngleToPrograde = FlightGlobals.ActiveVessel.patchedConicSolver.maneuverNodes[0].patch.GetAngleToPrograde(UniversalTime);
  AngleToRetrograde = FlightGlobals.ActiveVessel.patchedConicSolver.maneuverNodes[0].patch.GetAngleToRetrograde(UniversalTime);
 
  var burnTime = 0.0;
  var midPointTime = 0.0;
  HasDeltaV = GetBurnTime((float)TotalDeltaV, ref burnTime, ref midPointTime);
  AvailableDeltaV = SimulationProcessor.LastStage.totalDeltaV;
 
  BurnTime = burnTime;
  HalfBurnTime = midPointTime;
 
  ShowDetails = true;
  }
 
  #endregion
 
  #region Methods: private
 
  private static bool GetBurnTime(float deltaV, ref double burnTime, ref double midPointTime)
  {
  var setMidPoint = false;
  var deltaVMidPoint = deltaV * 0.5f;
 
  for (var i = SimulationProcessor.Stages.Length - 1; i >= 0; i--)
  {
  var stage = SimulationProcessor.Stages[i];
  var stageDeltaV = (float)stage.deltaV;
 
  ProcessStageDrain:
  if (deltaV <= Single.Epsilon)
  {
  FinalStage = ++i;
  return true;
  }
  if (stageDeltaV <= Single.Epsilon)
  {
  continue;
  }
 
  float deltaVDrain;
  if (deltaVMidPoint > 0.0)
  {
  deltaVDrain = Mathf.Clamp(deltaV, 0.0f, Mathf.Clamp(deltaVMidPoint, 0.0f, stageDeltaV));
  deltaVMidPoint -= deltaVDrain;
  setMidPoint = deltaVMidPoint <= Single.Epsilon;
  }
  else
  {
  deltaVDrain = Mathf.Clamp(deltaV, 0.0f, stageDeltaV);
  }
 
  var startMass = stage.totalMass - (stage.resourceMass * (1.0f - (stageDeltaV / stage.deltaV)));
  var endMass = startMass - (stage.resourceMass * (deltaVDrain / stageDeltaV));
  var minimumAcceleration = stage.thrust / startMass;
  var maximumAcceleration = stage.thrust / endMass;
 
  burnTime += deltaVDrain / ((minimumAcceleration + maximumAcceleration) * 0.5);
  deltaV -= deltaVDrain;
  stageDeltaV -= deltaVDrain;
 
  if (setMidPoint)
  {
  midPointTime = burnTime;
  setMidPoint = false;
  goto ProcessStageDrain;
  }
  }
  return false;
  }
 
  #endregion
  }
  }
  //
  // Kerbal Engineer Redux
  //
  // Copyright (C) 2014 CYBUTEK
  //
  // This program is free software: you can redistribute it and/or modify
  // it under the terms of the GNU General Public License as published by
  // the Free Software Foundation, either version 3 of the License, or
  // (at your option) any later version.
  //
  // This program is distributed in the hope that it will be useful,
  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  // GNU General Public License for more details.
  //
  // You should have received a copy of the GNU General Public License
  // along with this program. If not, see <http://www.gnu.org/licenses/>.
  //
 
  #region Using Directives
 
  using System;
 
  using KerbalEngineer.Extensions;
  using KerbalEngineer.Flight.Sections;
 
  #endregion
 
  namespace KerbalEngineer.Flight.Readouts.Orbital.ManoeuvreNode
  {
  public class NodeAngleToPrograde : ReadoutModule
  {
  #region Constructors
 
  public NodeAngleToPrograde()
  {
  this.Name = "Manoeuvre Node Angle to Prograde";
  this.Category = ReadoutCategory.GetCategory("Orbital");
  this.HelpString = String.Empty;
  this.IsDefault = true;
  }
 
  #endregion
 
  #region Methods: public
 
  public override void Draw(SectionModule section)
  {
  if (!ManoeuvreProcessor.ShowDetails)
  {
  return;
  }
 
  this.DrawLine("Node Angle to Prograde", ManoeuvreProcessor.AngleToPrograde.ToAngle(), section.IsHud);
  }
 
  public override void Reset()
  {
  ManoeuvreProcessor.Reset();
  }
 
  public override void Update()
  {
  ManoeuvreProcessor.RequestUpdate();
  }
 
  #endregion
  }
  }
  //
  // Kerbal Engineer Redux
  //
  // Copyright (C) 2014 CYBUTEK
  //
  // This program is free software: you can redistribute it and/or modify
  // it under the terms of the GNU General Public License as published by
  // the Free Software Foundation, either version 3 of the License, or
  // (at your option) any later version.
  //
  // This program is distributed in the hope that it will be useful,
  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  // GNU General Public License for more details.
  //
  // You should have received a copy of the GNU General Public License
  // along with this program. If not, see <http://www.gnu.org/licenses/>.
  //
 
  #region Using Directives
 
  using System;
 
  using KerbalEngineer.Extensions;
  using KerbalEngineer.Flight.Sections;
 
  #endregion
 
  namespace KerbalEngineer.Flight.Readouts.Orbital.ManoeuvreNode
  {
  public class NodeAngleToRetrograde : ReadoutModule
  {
  #region Constructors
 
  public NodeAngleToRetrograde()
  {
  this.Name = "Manoeuvre Node Angle to Retrograde";
  this.Category = ReadoutCategory.GetCategory("Orbital");
  this.HelpString = String.Empty;
  this.IsDefault = true;
  }
 
  #endregion
 
  #region Methods: public
 
  public override void Draw(SectionModule section)
  {
  if (!ManoeuvreProcessor.ShowDetails)
  {
  return;
  }
 
  this.DrawLine("Node Angle to Retrograde", ManoeuvreProcessor.AngleToRetrograde.ToAngle(), section.IsHud);
  }
 
  public override void Reset()
  {
  ManoeuvreProcessor.Reset();
  }
 
  public override void Update()
  {
  ManoeuvreProcessor.RequestUpdate();
  }
 
  #endregion
  }
  }
  //
  // Kerbal Engineer Redux
  //
  // Copyright (C) 2014 CYBUTEK
  //
  // This program is free software: you can redistribute it and/or modify
  // it under the terms of the GNU General Public License as published by
  // the Free Software Foundation, either version 3 of the License, or
  // (at your option) any later version.
  //
  // This program is distributed in the hope that it will be useful,
  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  // GNU General Public License for more details.
  //
  // You should have received a copy of the GNU General Public License
  // along with this program. If not, see <http://www.gnu.org/licenses/>.
  //
 
  #region Using Directives
 
  using System;
 
  using KerbalEngineer.Flight.Sections;
  using KerbalEngineer.Helpers;
 
  #endregion
 
  namespace KerbalEngineer.Flight.Readouts.Orbital.ManoeuvreNode
  {
  public class NodeBurnTime : ReadoutModule
  {
  #region Constructors
 
  public NodeBurnTime()
  {
  this.Name = "Manoeuvre Node Burn Time";
  this.Category = ReadoutCategory.GetCategory("Orbital");
  this.HelpString = String.Empty;
  this.IsDefault = true;
  }
 
  #endregion
 
  #region Methods: public
 
  public override void Draw(SectionModule section)
  {
  if (!ManoeuvreProcessor.ShowDetails)
  {
  return;
  }
 
  this.DrawLine("Node Burn Time", TimeFormatter.ConvertToString(ManoeuvreProcessor.BurnTime), section.IsHud);
  }
 
  public override void Reset()
  {
  ManoeuvreProcessor.Reset();
  }
 
  public override void Update()
  {
  ManoeuvreProcessor.RequestUpdate();
  }
 
  #endregion
  }
  }
  //
  // Kerbal Engineer Redux
  //
  // Copyright (C) 2014 CYBUTEK
  //
  // This program is free software: you can redistribute it and/or modify
  // it under the terms of the GNU General Public License as published by
  // the Free Software Foundation, either version 3 of the License, or
  // (at your option) any later version.
  //
  // This program is distributed in the hope that it will be useful,
  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  // GNU General Public License for more details.
  //
  // You should have received a copy of the GNU General Public License
  // along with this program. If not, see <http://www.gnu.org/licenses/>.
  //
 
  #region Using Directives
 
  using System;
 
  using KerbalEngineer.Flight.Sections;
  using KerbalEngineer.Helpers;
 
  #endregion
 
  namespace KerbalEngineer.Flight.Readouts.Orbital.ManoeuvreNode
  {
  public class NodeHalfBurnTime : ReadoutModule
  {
  #region Constructors
 
  public NodeHalfBurnTime()
  {
  this.Name = "Manoeuvre Node Half Burn Time";
  this.Category = ReadoutCategory.GetCategory("Orbital");
  this.HelpString = String.Empty;
  this.IsDefault = true;
  }
 
  #endregion
 
  #region Methods: public
 
  public override void Draw(SectionModule section)
  {
  if (!ManoeuvreProcessor.ShowDetails)
  {
  return;
  }
 
  this.DrawLine("Node Burn Time (½)", TimeFormatter.ConvertToString(ManoeuvreProcessor.HalfBurnTime), section.IsHud);
  }
 
  public override void Reset()
  {
  ManoeuvreProcessor.Reset();
  }
 
  public override void Update()
  {
  ManoeuvreProcessor.RequestUpdate();
  }
 
  #endregion
  }
  }
  //
  // Kerbal Engineer Redux
  //
  // Copyright (C) 2014 CYBUTEK
  //
  // This program is free software: you can redistribute it and/or modify
  // it under the terms of the GNU General Public License as published by
  // the Free Software Foundation, either version 3 of the License, or
  // (at your option) any later version.
  //
  // This program is distributed in the hope that it will be useful,
  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  // GNU General Public License for more details.
  //
  // You should have received a copy of the GNU General Public License
  // along with this program. If not, see <http://www.gnu.org/licenses/>.
  //
 
  #region Using Directives
 
  using System;
 
  using KerbalEngineer.Extensions;
  using KerbalEngineer.Flight.Sections;
 
  #endregion
 
  namespace KerbalEngineer.Flight.Readouts.Orbital.ManoeuvreNode
  {
  public class NodeNormalDeltaV : ReadoutModule
  {
  #region Constructors
 
  public NodeNormalDeltaV()
  {
  this.Name = "Manoeuvre Node DeltaV (Normal)";
  this.Category = ReadoutCategory.GetCategory("Orbital");
  this.HelpString = String.Empty;
  this.IsDefault = true;
  }
 
  #endregion
 
  #region Methods: public
 
  public override void Draw(SectionModule section)
  {
  if (!ManoeuvreProcessor.ShowDetails)
  {
  return;
  }
 
  this.DrawLine("Node DeltaV (Normal)", ManoeuvreProcessor.NormalDeltaV.ToSpeed(), section.IsHud);
  }
 
  public override void Reset()
  {
  ManoeuvreProcessor.Reset();
  }
 
  public override void Update()
  {
  ManoeuvreProcessor.RequestUpdate();
  }
 
  #endregion
  }
  }
  //
  // Kerbal Engineer Redux
  //
  // Copyright (C) 2014 CYBUTEK
  //
  // This program is free software: you can redistribute it and/or modify
  // it under the terms of the GNU General Public License as published by
  // the Free Software Foundation, either version 3 of the License, or
  // (at your option) any later version.
  //
  // This program is distributed in the hope that it will be useful,
  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  // GNU General Public License for more details.
  //
  // You should have received a copy of the GNU General Public License
  // along with this program. If not, see <http://www.gnu.org/licenses/>.
  //
 
  #region Using Directives
 
  using System;
 
  using KerbalEngineer.Extensions;
  using KerbalEngineer.Flight.Sections;
 
  #endregion
 
  namespace KerbalEngineer.Flight.Readouts.Orbital.ManoeuvreNode
  {
  public class NodeProgradeDeltaV : ReadoutModule
  {
  #region Constructors
 
  public NodeProgradeDeltaV()
  {
  this.Name = "Manoeuvre Node DeltaV (Prograde)";
  this.Category = ReadoutCategory.GetCategory("Orbital");
  this.HelpString = String.Empty;
  this.IsDefault = true;
  }
 
  #endregion
 
  #region Methods: public
 
  public override void Draw(SectionModule section)
  {
  if (!ManoeuvreProcessor.ShowDetails)
  {
  return;
  }
 
  this.DrawLine("Node DeltaV (Prograde)", ManoeuvreProcessor.ProgradeDeltaV.ToSpeed(), section.IsHud);
  }
 
  public override void Reset()
  {
  ManoeuvreProcessor.Reset();
  }
 
  public override void Update()
  {
  ManoeuvreProcessor.RequestUpdate();
  }
 
  #endregion
  }
  }
  //
  // Kerbal Engineer Redux
  //
  // Copyright (C) 2014 CYBUTEK
  //
  // This program is free software: you can redistribute it and/or modify
  // it under the terms of the GNU General Public License as published by
  // the Free Software Foundation, either version 3 of the License, or
  // (at your option) any later version.
  //
  // This program is distributed in the hope that it will be useful,
  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  // GNU General Public License for more details.
  //
  // You should have received a copy of the GNU General Public License
  // along with this program. If not, see <http://www.gnu.org/licenses/>.
  //
 
  #region Using Directives
 
  using System;
 
  using KerbalEngineer.Extensions;
  using KerbalEngineer.Flight.Sections;
 
  #endregion
 
  namespace KerbalEngineer.Flight.Readouts.Orbital.ManoeuvreNode
  {
  public class NodeRadialDeltaV : ReadoutModule
  {
  #region Constructors
 
  public NodeRadialDeltaV()
  {
  this.Name = "Manoeuvre Node DeltaV (Radial)";
  this.Category = ReadoutCategory.GetCategory("Orbital");
  this.HelpString = String.Empty;
  this.IsDefault = true;
  }
 
  #endregion
 
  #region Methods: public
 
  public override void Draw(SectionModule section)
  {
  if (!ManoeuvreProcessor.ShowDetails)
  {
  return;
  }
 
  this.DrawLine("Node DeltaV (Radial)", ManoeuvreProcessor.RadialDeltaV.ToSpeed(), section.IsHud);
  }
 
  public override void Reset()
  {
  ManoeuvreProcessor.Reset();
  }
 
  public override void Update()
  {
  ManoeuvreProcessor.RequestUpdate();
  }
 
  #endregion
  }
  }
  //
  // Kerbal Engineer Redux
  //
  // Copyright (C) 2014 CYBUTEK
  //
  // This program is free software: you can redistribute it and/or modify
  // it under the terms of the GNU General Public License as published by
  // the Free Software Foundation, either version 3 of the License, or
  // (at your option) any later version.
  //
  // This program is distributed in the hope that it will be useful,
  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  // GNU General Public License for more details.
  //
  // You should have received a copy of the GNU General Public License
  // along with this program. If not, see <http://www.gnu.org/licenses/>.
  //
 
  #region Using Directives
 
  using System;
 
  using KerbalEngineer.Flight.Sections;
  using KerbalEngineer.Helpers;
 
  #endregion
 
  namespace KerbalEngineer.Flight.Readouts.Orbital.ManoeuvreNode
  {
  public class NodeTimeToHalfBurn : ReadoutModule
  {
  #region Constructors
 
  public NodeTimeToHalfBurn()
  {
  this.Name = "Time to Manoeuvre Burn";
  this.Category = ReadoutCategory.GetCategory("Orbital");
  this.HelpString = String.Empty;
  this.IsDefault = true;
  }
 
  #endregion
 
  #region Methods: public
 
  public override void Draw(SectionModule section)
  {
  if (!ManoeuvreProcessor.ShowDetails)
  {
  return;
  }
 
  this.DrawLine("Time to Node Burn", TimeFormatter.ConvertToString(ManoeuvreProcessor.UniversalTime - ManoeuvreProcessor.HalfBurnTime - Planetarium.GetUniversalTime()), section.IsHud);
  }
 
  public override void Reset()
  {
  ManoeuvreProcessor.Reset();
  }
 
  public override void Update()
  {
  ManoeuvreProcessor.RequestUpdate();
  }
 
  #endregion
  }
  }
  //
  // Kerbal Engineer Redux
  //
  // Copyright (C) 2014 CYBUTEK
  //
  // This program is free software: you can redistribute it and/or modify
  // it under the terms of the GNU General Public License as published by
  // the Free Software Foundation, either version 3 of the License, or
  // (at your option) any later version.
  //
  // This program is distributed in the hope that it will be useful,
  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  // GNU General Public License for more details.
  //
  // You should have received a copy of the GNU General Public License
  // along with this program. If not, see <http://www.gnu.org/licenses/>.
  //
 
  #region Using Directives
 
  using System;
 
  using KerbalEngineer.Flight.Sections;
  using KerbalEngineer.Helpers;
 
  #endregion
 
  namespace KerbalEngineer.Flight.Readouts.Orbital.ManoeuvreNode
  {
  public class NodeTimeToManoeuvre : ReadoutModule
  {
  #region Constructors
 
  public NodeTimeToManoeuvre()
  {
  this.Name = "Time to Manoeuvre Node";
  this.Category = ReadoutCategory.GetCategory("Orbital");
  this.HelpString = String.Empty;
  this.IsDefault = true;
  }
 
  #endregion
 
  #region Methods: public
 
  public override void Draw(SectionModule section)
  {
  if (!ManoeuvreProcessor.ShowDetails)
  {
  return;
  }
 
  this.DrawLine("Time to Node", TimeFormatter.ConvertToString(ManoeuvreProcessor.UniversalTime - Planetarium.GetUniversalTime()), section.IsHud);
  }
 
  public override void Reset()
  {
  ManoeuvreProcessor.Reset();
  }
 
  public override void Update()
  {
  ManoeuvreProcessor.RequestUpdate();
  }
 
  #endregion
  }
  }
  //
  // Kerbal Engineer Redux
  //
  // Copyright (C) 2014 CYBUTEK
  //
  // This program is free software: you can redistribute it and/or modify
  // it under the terms of the GNU General Public License as published by
  // the Free Software Foundation, either version 3 of the License, or
  // (at your option) any later version.
  //
  // This program is distributed in the hope that it will be useful,
  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  // GNU General Public License for more details.
  //
  // You should have received a copy of the GNU General Public License
  // along with this program. If not, see <http://www.gnu.org/licenses/>.
  //
 
  #region Using Directives
 
  using System;
 
  using KerbalEngineer.Extensions;
  using KerbalEngineer.Flight.Sections;
 
  #endregion
 
  namespace KerbalEngineer.Flight.Readouts.Orbital.ManoeuvreNode
  {
  public class NodeTotalDeltaV : ReadoutModule
  {
  #region Constructors
 
  public NodeTotalDeltaV()
  {
  this.Name = "Manoeuvre Node DeltaV (Total)";
  this.Category = ReadoutCategory.GetCategory("Orbital");
  this.HelpString = String.Empty;
  this.IsDefault = true;
  }
 
  #endregion
 
  #region Methods: public
 
  public override void Draw(SectionModule section)
  {
  if (!ManoeuvreProcessor.ShowDetails)
  {
  return;
  }
 
  this.DrawLine("Node DeltaV (Total)", ManoeuvreProcessor.TotalDeltaV.ToSpeed() + " (" + (ManoeuvreProcessor.HasDeltaV ? "S" + ManoeuvreProcessor.FinalStage : "X") + ")", section.IsHud);
  }
 
  public override void Reset()
  {
  ManoeuvreProcessor.Reset();
  }
 
  public override void Update()
  {
  ManoeuvreProcessor.RequestUpdate();
  }
 
  #endregion
  }
  }
// //
// Kerbal Engineer Redux // Kerbal Engineer Redux
// //
// Copyright (C) 2014 CYBUTEK // Copyright (C) 2014 CYBUTEK
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
// //
   
#region Using Directives #region Using Directives
   
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
   
using KerbalEngineer.Flight.Readouts.Miscellaneous; using KerbalEngineer.Flight.Readouts.Miscellaneous;
using KerbalEngineer.Flight.Readouts.Orbital; using KerbalEngineer.Flight.Readouts.Orbital;
  using KerbalEngineer.Flight.Readouts.Orbital.ManoeuvreNode;
using KerbalEngineer.Flight.Readouts.Rendezvous; using KerbalEngineer.Flight.Readouts.Rendezvous;
using KerbalEngineer.Flight.Readouts.Surface; using KerbalEngineer.Flight.Readouts.Surface;
using KerbalEngineer.Flight.Readouts.Vessel; using KerbalEngineer.Flight.Readouts.Vessel;
using KerbalEngineer.Settings; using KerbalEngineer.Settings;
   
using AltitudeSeaLevel = KerbalEngineer.Flight.Readouts.Surface.AltitudeSeaLevel; using AltitudeSeaLevel = KerbalEngineer.Flight.Readouts.Surface.AltitudeSeaLevel;
using ApoapsisHeight = KerbalEngineer.Flight.Readouts.Orbital.ApoapsisHeight; using ApoapsisHeight = KerbalEngineer.Flight.Readouts.Orbital.ApoapsisHeight;
using OrbitalPeriod = KerbalEngineer.Flight.Readouts.Orbital.OrbitalPeriod; using OrbitalPeriod = KerbalEngineer.Flight.Readouts.Orbital.OrbitalPeriod;
using PeriapsisHeight = KerbalEngineer.Flight.Readouts.Orbital.PeriapsisHeight; using PeriapsisHeight = KerbalEngineer.Flight.Readouts.Orbital.PeriapsisHeight;
using SemiMajorAxis = KerbalEngineer.Flight.Readouts.Orbital.SemiMajorAxis; using SemiMajorAxis = KerbalEngineer.Flight.Readouts.Orbital.SemiMajorAxis;
using SemiMinorAxis = KerbalEngineer.Flight.Readouts.Orbital.SemiMinorAxis; using SemiMinorAxis = KerbalEngineer.Flight.Readouts.Orbital.SemiMinorAxis;
using TimeToApoapsis = KerbalEngineer.Flight.Readouts.Orbital.TimeToApoapsis; using TimeToApoapsis = KerbalEngineer.Flight.Readouts.Orbital.TimeToApoapsis;
using TimeToPeriapsis = KerbalEngineer.Flight.Readouts.Orbital.TimeToPeriapsis; using TimeToPeriapsis = KerbalEngineer.Flight.Readouts.Orbital.TimeToPeriapsis;
   
#endregion #endregion
   
namespace KerbalEngineer.Flight.Readouts namespace KerbalEngineer.Flight.Readouts
{ {
public static class ReadoutLibrary public static class ReadoutLibrary
{ {
#region Fields #region Fields
   
private static List<ReadoutModule> readouts = new List<ReadoutModule>(); private static List<ReadoutModule> readouts = new List<ReadoutModule>();
   
#endregion #endregion
   
#region Constructors #region Constructors
   
/// <summary> /// <summary>
/// Sets up and populates the readout library with the stock readouts. /// Sets up and populates the readout library with the stock readouts.
/// </summary> /// </summary>
static ReadoutLibrary() static ReadoutLibrary()
{ {
try try
{ {
ReadoutCategory.SetCategory("Orbital", "Readout for orbital manovoeures."); ReadoutCategory.SetCategory("Orbital", "Readout for orbital manovoeures.");
ReadoutCategory.SetCategory("Surface", "Surface and atmospheric readouts."); ReadoutCategory.SetCategory("Surface", "Surface and atmospheric readouts.");
ReadoutCategory.SetCategory("Vessel", "Vessel performance statistics."); ReadoutCategory.SetCategory("Vessel", "Vessel performance statistics.");
ReadoutCategory.SetCategory("Rendezvous", "Readouts for rendezvous manovoeures."); ReadoutCategory.SetCategory("Rendezvous", "Readouts for rendezvous manovoeures.");
ReadoutCategory.SetCategory("Miscellaneous", "Miscellaneous readouts."); ReadoutCategory.SetCategory("Miscellaneous", "Miscellaneous readouts.");
   
// Orbital // Orbital
readouts.Add(new ApoapsisHeight()); readouts.Add(new ApoapsisHeight());
readouts.Add(new PeriapsisHeight()); readouts.Add(new PeriapsisHeight());
readouts.Add(new TimeToApoapsis()); readouts.Add(new TimeToApoapsis());
readouts.Add(new TimeToPeriapsis()); readouts.Add(new TimeToPeriapsis());
readouts.Add(new Inclination()); readouts.Add(new Inclination());
readouts.Add(new TimeToEquatorialAscendingNode()); readouts.Add(new TimeToEquatorialAscendingNode());
readouts.Add(new TimeToEquatorialDescendingNode()); readouts.Add(new TimeToEquatorialDescendingNode());
readouts.Add(new AngleToEquatorialAscendingNode()); readouts.Add(new AngleToEquatorialAscendingNode());
readouts.Add(new AngleToEquatorialDescendingNode()); readouts.Add(new AngleToEquatorialDescendingNode());
readouts.Add(new Eccentricity()); readouts.Add(new Eccentricity());
readouts.Add(new OrbitalSpeed()); readouts.Add(new OrbitalSpeed());
readouts.Add(new OrbitalPeriod()); readouts.Add(new OrbitalPeriod());
readouts.Add(new CurrentSoi()); readouts.Add(new CurrentSoi());
readouts.Add(new LongitudeOfAscendingNode()); readouts.Add(new LongitudeOfAscendingNode());
readouts.Add(new LongitudeOfPeriapsis()); readouts.Add(new LongitudeOfPeriapsis());
readouts.Add(new ArgumentOfPeriapsis()); readouts.Add(new ArgumentOfPeriapsis());
readouts.Add(new TrueAnomaly()); readouts.Add(new TrueAnomaly());
readouts.Add(new MeanAnomaly()); readouts.Add(new MeanAnomaly());
readouts.Add(new EccentricAnomaly()); readouts.Add(new EccentricAnomaly());
readouts.Add(new SemiMajorAxis()); readouts.Add(new SemiMajorAxis());
readouts.Add(new SemiMinorAxis()); readouts.Add(new SemiMinorAxis());
readouts.Add(new AngleToPrograde()); readouts.Add(new AngleToPrograde());
readouts.Add(new AngleToRetrograde()); readouts.Add(new AngleToRetrograde());
  readouts.Add(new NodeProgradeDeltaV());
  readouts.Add(new NodeNormalDeltaV());
  readouts.Add(new NodeRadialDeltaV());
  readouts.Add(new NodeTotalDeltaV());
  readouts.Add(new NodeBurnTime());
  readouts.Add(new NodeHalfBurnTime());
  readouts.Add(new NodeTimeToManoeuvre());
  readouts.Add(new NodeTimeToHalfBurn());
  readouts.Add(new NodeAngleToPrograde());
  readouts.Add(new NodeAngleToRetrograde());
   
// Surface // Surface
readouts.Add(new AltitudeSeaLevel()); readouts.Add(new AltitudeSeaLevel());
readouts.Add(new AltitudeTerrain()); readouts.Add(new AltitudeTerrain());
readouts.Add(new VerticalSpeed()); readouts.Add(new VerticalSpeed());
readouts.Add(new VerticalAcceleration()); readouts.Add(new VerticalAcceleration());
readouts.Add(new HorizontalSpeed()); readouts.Add(new HorizontalSpeed());
readouts.Add(new HorizontalAcceleration()); readouts.Add(new HorizontalAcceleration());
readouts.Add(new Latitude()); readouts.Add(new Latitude());
readouts.Add(new Longitude()); readouts.Add(new Longitude());
readouts.Add(new GeeForce()); readouts.Add(new GeeForce());
readouts.Add(new TerminalVelocity()); readouts.Add(new TerminalVelocity());
readouts.Add(new AtmosphericEfficiency()); readouts.Add(new AtmosphericEfficiency());
readouts.Add(new Biome()); readouts.Add(new Biome());
  readouts.Add(new Situation());
readouts.Add(new Slope()); readouts.Add(new Slope());
readouts.Add(new ImpactTime()); readouts.Add(new ImpactTime());
readouts.Add(new ImpactLongitude()); readouts.Add(new ImpactLongitude());
readouts.Add(new ImpactLatitude()); readouts.Add(new ImpactLatitude());
readouts.Add(new ImpactAltitude()); readouts.Add(new ImpactAltitude());
readouts.Add(new ImpactBiome()); readouts.Add(new ImpactBiome());
   
// Vessel // Vessel
readouts.Add(new DeltaVStaged()); readouts.Add(new DeltaVStaged());
readouts.Add(new DeltaVCurrent()); readouts.Add(new DeltaVCurrent());
readouts.Add(new DeltaVTotal()); readouts.Add(new DeltaVTotal());
  readouts.Add(new DeltaVCurrentTotal());
readouts.Add(new SpecificImpulse()); readouts.Add(new SpecificImpulse());
readouts.Add(new Mass()); readouts.Add(new Mass());
readouts.Add(new Thrust()); readouts.Add(new Thrust());
readouts.Add(new ThrustToWeight()); readouts.Add(new ThrustToWeight());
readouts.Add(new SurfaceThrustToWeight()); readouts.Add(new SurfaceThrustToWeight());
readouts.Add(new Acceleration()); readouts.Add(new Acceleration());
readouts.Add(new SuicideBurnAltitude()); readouts.Add(new SuicideBurnAltitude());
readouts.Add(new SuicideBurnDistance()); readouts.Add(new SuicideBurnDistance());
readouts.Add(new SuicideBurnDeltaV()); readouts.Add(new SuicideBurnDeltaV());
readouts.Add(new IntakeAirUsage()); readouts.Add(new IntakeAirUsage());
readouts.Add(new IntakeAirDemand()); readouts.Add(new IntakeAirDemand());
readouts.Add(new IntakeAirSupply()); readouts.Add(new IntakeAirSupply());
readouts.Add(new IntakeAirDemandSupply()); readouts.Add(new IntakeAirDemandSupply());
   
// Rendezvous // Rendezvous
readouts.Add(new TargetSelector()); readouts.Add(new TargetSelector());
readouts.Add(new PhaseAngle()); readouts.Add(new PhaseAngle());
readouts.Add(new InterceptAngle()); readouts.Add(new InterceptAngle());
readouts.Add(new RelativeVelocity()); readouts.Add(new RelativeVelocity());
readouts.Add(new RelativeSpeed()); readouts.Add(new RelativeSpeed());
readouts.Add(new RelativeInclination()); readouts.Add(new RelativeInclination());
readouts.Add(new TimeToRelativeAscendingNode()); readouts.Add(new TimeToRelativeAscendingNode());
readouts.Add(new TimeToRelativeDescendingNode()); readouts.Add(new TimeToRelativeDescendingNode());
readouts.Add(new AngleToRelativeAscendingNode()); readouts.Add(new AngleToRelativeAscendingNode());
readouts.Add(new AngleToRelativeDescendingNode()); readouts.Add(new AngleToRelativeDescendingNode());
readouts.Add(new Rendezvous.AltitudeSeaLevel()); readouts.Add(new Rendezvous.AltitudeSeaLevel());
readouts.Add(new Rendezvous.ApoapsisHeight()); readouts.Add(new Rendezvous.ApoapsisHeight());
readouts.Add(new Rendezvous.PeriapsisHeight()); readouts.Add(new Rendezvous.PeriapsisHeight());
readouts.Add(new Rendezvous.TimeToApoapsis()); readouts.Add(new Rendezvous.TimeToApoapsis());
readouts.Add(new Rendezvous.TimeToPeriapsis()); readouts.Add(new Rendezvous.TimeToPeriapsis());
readouts.Add(new Distance()); readouts.Add(new Distance());
readouts.Add(new Rendezvous.OrbitalPeriod()); readouts.Add(new Rendezvous.OrbitalPeriod());
readouts.Add(new Rendezvous.SemiMajorAxis()); readouts.Add(new Rendezvous.SemiMajorAxis());
readouts.Add(new Rendezvous.SemiMinorAxis()); readouts.Add(new Rendezvous.SemiMinorAxis());
   
// Misc // Misc
readouts.Add(new Separator()); readouts.Add(new Separator());
readouts.Add(new GuiSizeAdjustor()); readouts.Add(new GuiSizeAdjustor());
readouts.Add(new SimulationDelay()); readouts.Add(new SimulationDelay());
readouts.Add(new TimeReference()); readouts.Add(new TimeReference());
   
LoadHelpStrings(); LoadHelpStrings();
} }
catch (Exception ex) catch (Exception ex)
{ {
Logger.Exception(ex); Logger.Exception(ex);
} }
} }
   
#endregion #endregion
   
#region Properties #region Properties
   
/// <summary> /// <summary>
/// Gets and sets the available readout modules. /// Gets and sets the available readout modules.
/// </summary> /// </summary>
public static List<ReadoutModule> Readouts public static List<ReadoutModule> Readouts
{ {
get { return readouts; } get { return readouts; }
set { readouts = value; } set { readouts = value; }
} }
   
#endregion #endregion
   
#region Methods: public #region Methods: public
   
/// <summary> /// <summary>
/// Gets a list of readout modules which are associated with the specified category. /// Gets a list of readout modules which are associated with the specified category.
/// </summary> /// </summary>
public static List<ReadoutModule> GetCategory(ReadoutCategory category) public static List<ReadoutModule> GetCategory(ReadoutCategory category)
{ {
return readouts.Where(r => r.Category == category).ToList(); return readouts.Where(r => r.Category == category).ToList();
} }
   
/// <summary> /// <summary>
/// Gets a readout module with the specified name or class name. (Returns null if not found.) /// Gets a readout module with the specified name or class name. (Returns null if not found.)
/// </summary> /// </summary>
public static ReadoutModule GetReadout(string name) public static ReadoutModule GetReadout(string name)
{ {
return readouts.FirstOrDefault(r => r.Name == name || r.GetType().Name == name || r.Category + "." + r.GetType().Name == name); return readouts.FirstOrDefault(r => r.Name == name || r.GetType().Name == name || r.Category + "." + r.GetType().Name == name);
} }
   
/// <summary> /// <summary>
/// Resets all the readout modules. /// Resets all the readout modules.
/// </summary> /// </summary>
public static void Reset() public static void Reset()
{ {
foreach (var readout in readouts) foreach (var readout in readouts)
{ {
readout.Reset(); readout.Reset();
} }
} }
   
#endregion #endregion
   
#region Methods: private #region Methods: private
   
/// <summary> /// <summary>
/// Loads the help strings from file. /// Loads the help strings from file.
/// </summary> /// </summary>
private static void LoadHelpStrings() private static void LoadHelpStrings()
{ {
try try
{ {
var handler = SettingHandler.Load("HelpStrings.xml"); var handler = SettingHandler.Load("HelpStrings.xml");
foreach (var readout in readouts) foreach (var readout in readouts)
{ {
readout.HelpString = handler.GetSet(readout.Category + "." + readout.GetType().Name, readout.HelpString); readout.HelpString = handler.GetSet(readout.Category + "." + readout.GetType().Name, readout.HelpString);
} }
handler.Save("HelpStrings.xml"); handler.Save("HelpStrings.xml");
} }
catch (Exception ex) catch (Exception ex)
{ {
Logger.Exception(ex); Logger.Exception(ex);
} }
} }
   
#endregion #endregion
} }
} }
// //
// Kerbal Engineer Redux // Kerbal Engineer Redux
// //
// Copyright (C) 2014 CYBUTEK // Copyright (C) 2014 CYBUTEK
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
// //
   
#region Using Directives #region Using Directives
   
using System; using System;
   
using KerbalEngineer.Flight.Sections; using KerbalEngineer.Flight.Sections;
   
using UnityEngine; using UnityEngine;
   
#endregion #endregion
   
namespace KerbalEngineer.Flight.Readouts namespace KerbalEngineer.Flight.Readouts
{ {
public abstract class ReadoutModule public abstract class ReadoutModule
{ {
#region Fields #region Fields
   
private int lineCountEnd; private int lineCountEnd;
private int lineCountStart; private int lineCountStart;
   
#endregion #endregion
   
#region Constructors #region Constructors
   
protected ReadoutModule() protected ReadoutModule()
{ {
this.InitialiseStyles(); this.InitialiseStyles();
GuiDisplaySize.OnSizeChanged += this.OnSizeChanged; GuiDisplaySize.OnSizeChanged += this.OnSizeChanged;
} }
   
#endregion #endregion
   
#region Properties #region Properties
   
/// <summary> /// <summary>
/// Gets and sets the button style. /// Gets and sets the button style.
/// </summary> /// </summary>
public GUIStyle ButtonStyle { get; set; } public GUIStyle ButtonStyle { get; set; }
   
/// <summary> /// <summary>
/// Gets ans sets the readout category. /// Gets ans sets the readout category.
/// </summary> /// </summary>
public ReadoutCategory Category { get; set; } public ReadoutCategory Category { get; set; }
   
/// <summary> /// <summary>
/// Gets and sets whether the readout can be added to a section multiple times. /// Gets and sets whether the readout can be added to a section multiple times.
/// </summary> /// </summary>
public bool Cloneable { get; set; } public bool Cloneable { get; set; }
   
/// <summary> /// <summary>
/// Gets the width of the content. (Sum of NameStyle + ValueStyle widths.) /// Gets the width of the content. (Sum of NameStyle + ValueStyle widths.)
/// </summary> /// </summary>
public float ContentWidth public float ContentWidth
{ {
get { return 230.0f * GuiDisplaySize.Offset; } get { return 230.0f * GuiDisplaySize.Offset; }
} }
   
/// <summary> /// <summary>
/// Gets and sets the flexible label style. /// Gets and sets the flexible label style.
/// </summary> /// </summary>
public GUIStyle FlexiLabelStyle { get; set; } public GUIStyle FlexiLabelStyle { get; set; }
   
/// <summary> /// <summary>
/// Gets and sets the help string which is shown in the editor. /// Gets and sets the help string which is shown in the editor.
/// </summary> /// </summary>
public string HelpString { get; set; } public string HelpString { get; set; }
   
/// <summary> /// <summary>
/// Gets and sets whether the readout should be shown on new installs. /// Gets and sets whether the readout should be shown on new installs.
/// </summary> /// </summary>
public bool IsDefault { get; set; } public bool IsDefault { get; set; }
   
/// <summary> /// <summary>
  /// Gets the number of drawn lines.
  /// </summary>
  public int LineCount { get; private set; }
   
  /// <summary>
/// Gets and sets the message style. /// Gets and sets the message style.
/// </summary> /// </summary>
public GUIStyle MessageStyle { get; set; } public GUIStyle MessageStyle { get; set; }
   
/// <summary> /// <summary>
/// Gets and sets the readout name. /// Gets and sets the readout name.
/// </summary> /// </summary>
public string Name { get; set; } public string Name { get; set; }
   
/// <summary> /// <summary>
/// Gets and sets the name style. /// Gets and sets the name style.
/// </summary> /// </summary>
public GUIStyle NameStyle { get; set; } public GUIStyle NameStyle { get; set; }
   
/// <summary> /// <summary>
/// Gets and sets whether the readout has requested a section resize. /// Gets and sets whether the readout has requested a section resize.
/// </summary> /// </summary>
public bool ResizeRequested { get; set; } public bool ResizeRequested { get; set; }
   
/// <summary> /// <summary>
/// Gets and sets whether the help string is being shown in the editor. /// Gets and sets whether the help string is being shown in the editor.
/// </summary> /// </summary>
public bool ShowHelp { get; set; } public bool ShowHelp { get; set; }
   
/// <summary> /// <summary>
/// Gets and sets the text field style. /// Gets and sets the text field style.
/// </summary> /// </summary>
public GUIStyle TextFieldStyle { get; set; } public GUIStyle TextFieldStyle { get; set; }
   
/// <summary> /// <summary>
/// Gets and sets the value style. /// Gets and sets the value style.
/// </summary> /// </summary>
public GUIStyle ValueStyle { get; set; } public GUIStyle ValueStyle { get; set; }
   
#endregion #endregion
   
#region Methods: public #region Methods: public
   
/// <summary> /// <summary>
/// Called when a readout is asked to draw its self. /// Called when a readout is asked to draw its self.
/// </summary> /// </summary>
public virtual void Draw(SectionModule section) { } public virtual void Draw(SectionModule section) { }
   
/// <summary> /// <summary>
/// Called on each fixed update frame where the readout is visible. /// Called on each fixed update frame where the readout is visible.
/// </summary> /// </summary>
public virtual void FixedUpdate() { } public virtual void FixedUpdate() { }
   
public void LineCountEnd() public void LineCountEnd()
{ {
  this.LineCount = this.lineCountEnd;
if (this.lineCountEnd.CompareTo(this.lineCountStart) < 0) if (this.lineCountEnd.CompareTo(this.lineCountStart) < 0)
{ {
this.ResizeRequested = true; this.ResizeRequested = true;
} }
} }
   
public void LineCountStart() public void LineCountStart()
{ {
this.lineCountStart = this.lineCountEnd; this.lineCountStart = this.lineCountEnd;
this.lineCountEnd = 0; this.lineCountEnd = 0;
} }
   
/// <summary> /// <summary>
/// Called when FlightEngineerCore is started. /// Called when FlightEngineerCore is started.
/// </summary> /// </summary>
public virtual void Reset() { } public virtual void Reset() { }
   
/// <summary> /// <summary>
/// Called on each update frame when the readout is visible. /// Called on each update frame when the readout is visible.
/// </summary> /// </summary>
public virtual void Update() { } public virtual void Update() { }
   
#endregion #endregion
   
#region Methods: protected #region Methods: protected
   
protected void DrawLine(string value, bool compact = false) protected void DrawLine(string value, bool compact = false)
{ {
GUILayout.BeginHorizontal(GUILayout.Width(this.ContentWidth)); GUILayout.BeginHorizontal(GUILayout.Width(this.ContentWidth));
if (!compact) if (!compact)
{ {
GUILayout.Label(this.Name, this.NameStyle); GUILayout.Label(this.Name, this.NameStyle);
GUILayout.FlexibleSpace(); GUILayout.FlexibleSpace();
GUILayout.Label(value, this.ValueStyle); GUILayout.Label(value, this.ValueStyle);
} }
else else
{ {
GUILayout.Label(this.Name, this.NameStyle, GUILayout.Height(this.NameStyle.fontSize * 1.2f)); GUILayout.Label(this.Name, this.NameStyle, GUILayout.Height(this.NameStyle.fontSize * 1.2f));
GUILayout.FlexibleSpace(); GUILayout.FlexibleSpace();
GUILayout.Label(value, this.ValueStyle, GUILayout.Height(this.ValueStyle.fontSize * 1.2f)); GUILayout.Label(value, this.ValueStyle, GUILayout.Height(this.ValueStyle.fontSize * 1.2f));
} }
GUILayout.EndHorizontal(); GUILayout.EndHorizontal();
   
this.lineCountEnd++; this.lineCountEnd++;
} }
   
protected void DrawLine(string name, string value, bool compact = false) protected void DrawLine(string name, string value, bool compact = false)
{ {
GUILayout.BeginHorizontal(GUILayout.Width(this.ContentWidth)); GUILayout.BeginHorizontal(GUILayout.Width(this.ContentWidth));
if (!compact) if (!compact)
{ {
GUILayout.Label(name, this.NameStyle); GUILayout.Label(name, this.NameStyle);
GUILayout.FlexibleSpace(); GUILayout.FlexibleSpace();
GUILayout.Label(value, this.ValueStyle); GUILayout.Label(value, this.ValueStyle);
} }
else else
{ {
GUILayout.Label(name, this.NameStyle, GUILayout.Height(this.NameStyle.fontSize * 1.2f)); GUILayout.Label(name, this.NameStyle, GUILayout.Height(this.NameStyle.fontSize * 1.2f));
GUILayout.FlexibleSpace(); GUILayout.FlexibleSpace();
GUILayout.Label(value, this.ValueStyle, GUILayout.Height(this.ValueStyle.fontSize * 1.2f)); GUILayout.Label(value, this.ValueStyle, GUILayout.Height(this.ValueStyle.fontSize * 1.2f));
} }
GUILayout.EndHorizontal(); GUILayout.EndHorizontal();
   
this.lineCountEnd++; this.lineCountEnd++;
} }
   
protected void DrawLine(Action drawAction, bool showName = true, bool compact = false) protected void DrawLine(Action drawAction, bool showName = true, bool compact = false)
{ {
GUILayout.BeginHorizontal(GUILayout.Width(this.ContentWidth)); GUILayout.BeginHorizontal(GUILayout.Width(this.ContentWidth));
if (showName) if (showName)
{ {
if (!compact) if (!compact)
{ {
GUILayout.Label(this.Name, this.NameStyle); GUILayout.Label(this.Name, this.NameStyle);
} }
else else
{ {
GUILayout.Label(this.Name, this.NameStyle, GUILayout.Height(this.NameStyle.fontSize * 1.2f)); GUILayout.Label(this.Name, this.NameStyle, GUILayout.Height(this.NameStyle.fontSize * 1.2f));
} }
GUILayout.FlexibleSpace(); GUILayout.FlexibleSpace();
} }
drawAction(); drawAction();
GUILayout.EndHorizontal(); GUILayout.EndHorizontal();
this.lineCountEnd++; this.lineCountEnd++;
} }
   
protected void DrawMessageLine(string value, bool compact = false) protected void DrawMessageLine(string value, bool compact = false)
{ {
GUILayout.BeginHorizontal(GUILayout.Width(this.ContentWidth)); GUILayout.BeginHorizontal(GUILayout.Width(this.ContentWidth));
if (!compact) if (!compact)
{ {
GUILayout.Label(value, this.MessageStyle); GUILayout.Label(value, this.MessageStyle);
} }
else else
{ {
GUILayout.Label(value, this.MessageStyle, GUILayout.Height(this.MessageStyle.fontSize * 1.2f)); GUILayout.Label(value, this.MessageStyle, GUILayout.Height(this.MessageStyle.fontSize * 1.2f));
} }
GUILayout.EndHorizontal(); GUILayout.EndHorizontal();
this.lineCountEnd++; this.lineCountEnd++;
} }
   
#endregion #endregion
   
#region Methods: private #region Methods: private
   
/// <summary> /// <summary>
/// Initialises all the styles required for this object. /// Initialises all the styles required for this object.
/// </summary> /// </summary>
private void InitialiseStyles() private void InitialiseStyles()
{ {
this.NameStyle = new GUIStyle(HighLogic.Skin.label) this.NameStyle = new GUIStyle(HighLogic.Skin.label)
{ {
normal = normal =
{ {
textColor = Color.white textColor = Color.white
}, },
margin = new RectOffset(), margin = new RectOffset(),
padding = new RectOffset(5, 0, 0, 0), padding = new RectOffset(5, 0, 0, 0),
alignment = TextAnchor.MiddleLeft, alignment = TextAnchor.MiddleLeft,
fontSize = (int)(11 * GuiDisplaySize.Offset), fontSize = (int)(11 * GuiDisplaySize.Offset),
fontStyle = FontStyle.Bold, fontStyle = FontStyle.Bold,
fixedHeight = 20.0f * GuiDisplaySize.Offset fixedHeight = 20.0f * GuiDisplaySize.Offset
}; };
   
this.ValueStyle = new GUIStyle(HighLogic.Skin.label) this.ValueStyle = new GUIStyle(HighLogic.Skin.label)
{ {
margin = new RectOffset(), margin = new RectOffset(),
padding = new RectOffset(0, 5, 0, 0), padding = new RectOffset(0, 5, 0, 0),
alignment = TextAnchor.MiddleRight, alignment = TextAnchor.MiddleRight,
fontSize = (int)(11 * GuiDisplaySize.Offset), fontSize = (int)(11 * GuiDisplaySize.Offset),
fontStyle = FontStyle.Normal, fontStyle = FontStyle.Normal,
fixedHeight = 20.0f * GuiDisplaySize.Offset fixedHeight = 20.0f * GuiDisplaySize.Offset
}; };
   
this.MessageStyle = new GUIStyle(HighLogic.Skin.label) this.MessageStyle = new GUIStyle(HighLogic.Skin.label)
{ {
normal = normal =
{ {
textColor = Color.white textColor = Color.white
}, },
margin = new RectOffset(), margin = new RectOffset(),
padding = new RectOffset(), padding = new RectOffset(),
alignment = TextAnchor.MiddleCenter, alignment = TextAnchor.MiddleCenter,
fontSize = (int)(11 * GuiDisplaySize.Offset), fontSize = (int)(11 * GuiDisplaySize.Offset),
fontStyle = FontStyle.Normal, fontStyle = FontStyle.Normal,
fixedHeight = 20.0f * GuiDisplaySize.Offset, fixedHeight = 20.0f * GuiDisplaySize.Offset,
stretchWidth = true stretchWidth = true
}; };
   
this.FlexiLabelStyle = new GUIStyle(this.NameStyle) this.FlexiLabelStyle = new GUIStyle(this.NameStyle)
{ {
fixedWidth = 0, fixedWidth = 0,
stretchWidth = true stretchWidth = true
}; };
   
this.ButtonStyle = new GUIStyle(HighLogic.Skin.button) this.ButtonStyle = new GUIStyle(HighLogic.Skin.button)
{ {
normal = normal =
{ {
textColor = Color.white textColor = Color.white
}, },
margin = new RectOffset(0, 0, 1, 1), margin = new RectOffset(0, 0, 1, 1),
padding = new RectOffset(), padding = new RectOffset(),
alignment = TextAnchor.MiddleCenter, alignment = TextAnchor.MiddleCenter,
fontSize = (int)(11 * GuiDisplaySize.Offset), fontSize = (int)(11 * GuiDisplaySize.Offset),
fixedHeight = 18.0f * GuiDisplaySize.Offset fixedHeight = 18.0f * GuiDisplaySize.Offset
}; };
   
this.TextFieldStyle = new GUIStyle(HighLogic.Skin.textField) this.TextFieldStyle = new GUIStyle(HighLogic.Skin.textField)
{ {
margin = new RectOffset(0, 0, 1, 1), margin = new RectOffset(0, 0, 1, 1),
padding = new RectOffset(5, 5, 0, 0), padding = new RectOffset(5, 5, 0, 0),
alignment = TextAnchor.MiddleLeft, alignment = TextAnchor.MiddleLeft,
fontSize = (int)(11 * GuiDisplaySize.Offset), fontSize = (int)(11 * GuiDisplaySize.Offset),
fixedHeight = 18.0f * GuiDisplaySize.Offset fixedHeight = 18.0f * GuiDisplaySize.Offset
}; };
} }
   
private void OnSizeChanged() private void OnSizeChanged()
{ {
this.InitialiseStyles(); this.InitialiseStyles();
this.ResizeRequested = true; this.ResizeRequested = true;
} }
   
#endregion #endregion
} }
} }
  //
  // Kerbal Engineer Redux
  //
  // Copyright (C) 2014 CYBUTEK
  //
  // This program is free software: you can redistribute it and/or modify
  // it under the terms of the GNU General Public License as published by
  // the Free Software Foundation, either version 3 of the License, or
  // (at your option) any later version.
  //
  // This program is distributed in the hope that it will be useful,
  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  // GNU General Public License for more details.
  //
  // You should have received a copy of the GNU General Public License
  // along with this program. If not, see <http://www.gnu.org/licenses/>.
  //
 
  #region Using Directives
 
  using KerbalEngineer.Flight.Sections;
 
  #endregion
 
  namespace KerbalEngineer.Flight.Readouts.Surface
  {
  public class Situation : ReadoutModule
  {
  #region Constructors
 
  public Situation()
  {
  this.Name = "Situation";
  this.Category = ReadoutCategory.GetCategory("Surface");
  this.HelpString = string.Empty;
  this.IsDefault = true;
  }
 
  #endregion
 
  #region Methods: public
 
  public override void Draw(SectionModule section)
  {
  switch (ScienceUtil.GetExperimentSituation(FlightGlobals.ActiveVessel))
  {
  case ExperimentSituations.SrfLanded:
  this.DrawLine("Landed");
  break;
 
  case ExperimentSituations.SrfSplashed:
  this.DrawLine("Splashed");
  break;
 
  case ExperimentSituations.FlyingLow:
  this.DrawLine("Flying Low");
  break;
 
  case ExperimentSituations.FlyingHigh:
  this.DrawLine("Flying High");
  break;
 
  case ExperimentSituations.InSpaceLow:
  this.DrawLine("In Space Low");
  break;
 
  case ExperimentSituations.InSpaceHigh:
  this.DrawLine("In Space High");
  break;
  }
  }
 
  #endregion
 
  #region Methods: private
 
  private static string GetBiome()
  {
  return ScienceUtil.GetExperimentBiome(FlightGlobals.ActiveVessel.mainBody, FlightGlobals.ActiveVessel.latitude, FlightGlobals.ActiveVessel.longitude);
  }
 
  private static string GetBodyPlural()
  {
  return FlightGlobals.currentMainBody.bodyName.EndsWith("s") ? FlightGlobals.currentMainBody.bodyName + "\'" : FlightGlobals.currentMainBody.bodyName + "\'s";
  }
 
  #endregion
  }
  }
  //
  // Kerbal Engineer Redux
  //
  // Copyright (C) 2014 CYBUTEK
  //
  // This program is free software: you can redistribute it and/or modify
  // it under the terms of the GNU General Public License as published by
  // the Free Software Foundation, either version 3 of the License, or
  // (at your option) any later version.
  //
  // This program is distributed in the hope that it will be useful,
  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  // GNU General Public License for more details.
  //
  // You should have received a copy of the GNU General Public License
  // along with this program. If not, see <http://www.gnu.org/licenses/>.
  //
 
  #region Using Directives
 
  using KerbalEngineer.Flight.Sections;
  using KerbalEngineer.Helpers;
 
  #endregion
 
  namespace KerbalEngineer.Flight.Readouts.Vessel
  {
  public class DeltaVCurrentTotal : ReadoutModule
  {
  #region Constructors
 
  public DeltaVCurrentTotal()
  {
  this.Name = "DeltaV (C/T)";
  this.Category = ReadoutCategory.GetCategory("Vessel");
  this.HelpString = "Shows the vessel's current stage delta velocity and total.";
  this.IsDefault = false;
  }
 
  #endregion
 
  #region Methods: public
 
  public override void Draw(SectionModule section)
  {
  if (SimulationProcessor.ShowDetails)
  {
  this.DrawLine(SimulationProcessor.LastStage.deltaV.ToString("N0") + "m/s" + " / " + SimulationProcessor.LastStage.totalDeltaV.ToString("N0") + "m/s", section.IsHud);
  }
  }
 
  public override void Reset()
  {
  FlightEngineerCore.Instance.AddUpdatable(SimulationProcessor.Instance);
  }
 
  public override void Update()
  {
  SimulationProcessor.RequestUpdate();
  }
 
  #endregion
  }
  }
// //
// Kerbal Engineer Redux // Kerbal Engineer Redux
// //
// Copyright (C) 2014 CYBUTEK // Copyright (C) 2014 CYBUTEK
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
// //
   
#region Using Directives #region Using Directives
   
using System; using System;
   
using KerbalEngineer.VesselSimulator; using KerbalEngineer.VesselSimulator;
   
#endregion #endregion
   
namespace KerbalEngineer.Flight.Readouts.Vessel namespace KerbalEngineer.Flight.Readouts.Vessel
{ {
public class SimulationProcessor : IUpdatable, IUpdateRequest public class SimulationProcessor : IUpdatable, IUpdateRequest
{ {
#region Instance #region Instance
   
#region Fields #region Fields
   
private static readonly SimulationProcessor instance = new SimulationProcessor(); private static readonly SimulationProcessor instance = new SimulationProcessor();
   
#endregion #endregion
   
#region Properties #region Properties
   
/// <summary> /// <summary>
/// Gets the current instance of the simulation processor. /// Gets the current instance of the simulation processor.
/// </summary> /// </summary>
public static SimulationProcessor Instance public static SimulationProcessor Instance
{ {
get { return instance; } get { return instance; }
} }
   
#endregion #endregion
   
#endregion #endregion
   
#region Properties #region Properties
   
/// <summary> /// <summary>
/// Gets the currently active vessel stage. /// Gets the currently active vessel stage.
/// </summary> /// </summary>
public static Stage LastStage { get; private set; } public static Stage LastStage { get; private set; }
   
/// <summary> /// <summary>
/// Gets whether the details are ready to be shown. /// Gets whether the details are ready to be shown.
/// </summary> /// </summary>
public static bool ShowDetails { get; private set; } public static bool ShowDetails { get; private set; }
   
/// <summary> /// <summary>
/// Gets an array of the vessel stages. /// Gets an array of the vessel stages.
/// </summary> /// </summary>
public static Stage[] Stages { get; private set; } public static Stage[] Stages { get; private set; }
   
public bool UpdateRequested { get; set; } public bool UpdateRequested { get; set; }
   
#endregion #endregion
   
#region Methods: public #region Methods: public
   
public static void RequestUpdate() public static void RequestUpdate()
{ {
instance.UpdateRequested = true; instance.UpdateRequested = true;
} }
   
public void Update() public void Update()
{ {
SimManager.RequestSimulation(); SimManager.RequestSimulation();
  SimManager.TryStartSimulation();
   
if (!SimManager.ResultsReady()) if (!SimManager.ResultsReady())
{ {
return; return;
} }
   
Stages = SimManager.Stages; Stages = SimManager.Stages;
LastStage = SimManager.LastStage; LastStage = SimManager.LastStage;
   
if (Stages != null && LastStage != null) if (Stages != null && LastStage != null)
{ {
ShowDetails = true; ShowDetails = true;
} }
   
if (FlightGlobals.ActiveVessel != null) if (FlightGlobals.ActiveVessel != null)
{ {
SimManager.Gravity = FlightGlobals.ActiveVessel.mainBody.gravParameter / SimManager.Gravity = FlightGlobals.ActiveVessel.mainBody.gravParameter /
Math.Pow(FlightGlobals.ActiveVessel.mainBody.Radius + Math.Pow(FlightGlobals.ActiveVessel.mainBody.Radius +
FlightGlobals.ActiveVessel.mainBody.GetAltitude(FlightGlobals.ActiveVessel.CoM), 2); FlightGlobals.ActiveVessel.mainBody.GetAltitude(FlightGlobals.ActiveVessel.CoM), 2);
SimManager.Velocity = FlightGlobals.ActiveVessel.srfSpeed; SimManager.Velocity = FlightGlobals.ActiveVessel.srfSpeed;
} }
   
// Cybutek: We should be allowing this to be set too but not sure where you want to put the control // Cybutek: We should be allowing this to be set too but not sure where you want to put the control
//SimManager.vectoredThrust = vectoredThrust; //SimManager.vectoredThrust = vectoredThrust;
SimManager.TryStartSimulation();  
} }
   
#endregion #endregion
} }
} }
// //
// Kerbal Engineer Redux // Kerbal Engineer Redux
// //
// Copyright (C) 2014 CYBUTEK // Copyright (C) 2014 CYBUTEK
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
// //
   
#region Using Directives #region Using Directives
   
using System; using System;
   
using KerbalEngineer.Extensions; using KerbalEngineer.Extensions;
using KerbalEngineer.Flight.Sections; using KerbalEngineer.Flight.Sections;
   
#endregion #endregion
   
namespace KerbalEngineer.Flight.Readouts.Vessel namespace KerbalEngineer.Flight.Readouts.Vessel
{ {
public class SuicideBurnDeltaV : ReadoutModule public class SuicideBurnDeltaV : ReadoutModule
{ {
#region Constructors #region Constructors
   
public SuicideBurnDeltaV() public SuicideBurnDeltaV()
{ {
this.Name = "Suicide Burn (dV)"; this.Name = "Suicide Burn (dV)";
this.Category = ReadoutCategory.GetCategory("Vessel"); this.Category = ReadoutCategory.GetCategory("Vessel");
this.HelpString = "Shows the DeltaV of a suicide burn."; this.HelpString = "Shows the DeltaV of a suicide burn.";
this.IsDefault = true; this.IsDefault = true;
} }
   
#endregion #endregion
   
#region Methods: public #region Methods: public
   
public override void Draw(SectionModule section) public override void Draw(SectionModule section)
{ {
if (!SimulationProcessor.ShowDetails) if (!SuicideBurnProcessor.ShowDetails)
{ {
return; return;
} }
   
this.DrawLine(SuicideBurnProcessor.DeltaV.ToString("N1") + "m/s", section.IsHud); this.DrawLine(SuicideBurnProcessor.DeltaV.ToString("N1") + "m/s", section.IsHud);
} }
   
public override void Reset() public override void Reset()
{ {
SuicideBurnProcessor.Reset(); SuicideBurnProcessor.Reset();
} }
   
public override void Update() public override void Update()
{ {
SuicideBurnProcessor.RequestUpdate(); SuicideBurnProcessor.RequestUpdate();
} }
   
#endregion #endregion
} }
} }
// //
// Kerbal Engineer Redux // Kerbal Engineer Redux
// //
// Copyright (C) 2014 CYBUTEK // Copyright (C) 2014 CYBUTEK
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
// //
   
#region Using Directives #region Using Directives
   
using KerbalEngineer.Extensions; using KerbalEngineer.Extensions;
using KerbalEngineer.Flight.Sections; using KerbalEngineer.Flight.Sections;
   
#endregion #endregion
   
namespace KerbalEngineer.Flight.Readouts.Vessel namespace KerbalEngineer.Flight.Readouts.Vessel
{ {
public class SuicideBurnDistance : ReadoutModule public class SuicideBurnDistance : ReadoutModule
{ {
#region Constructors #region Constructors
   
public SuicideBurnDistance() public SuicideBurnDistance()
{ {
this.Name = "Suicide Burn (Dist.)"; this.Name = "Suicide Burn (Dist.)";
this.Category = ReadoutCategory.GetCategory("Vessel"); this.Category = ReadoutCategory.GetCategory("Vessel");
this.HelpString = "Shows the distance to the point at which to start a suicide burn."; this.HelpString = "Shows the distance to the point at which to start a suicide burn.";
this.IsDefault = true; this.IsDefault = true;
} }
   
#endregion #endregion
   
#region Methods: public #region Methods: public
   
public override void Draw(SectionModule section) public override void Draw(SectionModule section)
{ {
if (!SimulationProcessor.ShowDetails) if (!SuicideBurnProcessor.ShowDetails)
{ {
return; return;
} }
   
this.DrawLine(SuicideBurnProcessor.Distance.ToDistance(), section.IsHud); this.DrawLine(SuicideBurnProcessor.Distance.ToDistance(), section.IsHud);
} }
   
public override void Reset() public override void Reset()
{ {
SuicideBurnProcessor.Reset(); SuicideBurnProcessor.Reset();
} }
   
public override void Update() public override void Update()
{ {
SuicideBurnProcessor.RequestUpdate(); SuicideBurnProcessor.RequestUpdate();
} }
   
#endregion #endregion
} }
} }
// //
// Kerbal Engineer Redux // Kerbal Engineer Redux
// //
// Copyright (C) 2014 CYBUTEK // Copyright (C) 2014 CYBUTEK
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
// //
   
#region Using Directives #region Using Directives
   
using System; using System;
   
#endregion #endregion
   
namespace KerbalEngineer.Flight.Readouts.Vessel namespace KerbalEngineer.Flight.Readouts.Vessel
{ {
public class SuicideBurnProcessor : IUpdatable, IUpdateRequest public class SuicideBurnProcessor : IUpdatable, IUpdateRequest
{ {
#region Fields #region Fields
   
private static readonly SuicideBurnProcessor instance = new SuicideBurnProcessor(); private static readonly SuicideBurnProcessor instance = new SuicideBurnProcessor();
private double acceleration; private double acceleration;
private double gravity; private double gravity;
private double radarAltitude; private double radarAltitude;
   
#endregion #endregion
   
#region Properties #region Properties
   
public static double Altitude { get; private set; } public static double Altitude { get; private set; }
   
public static double DeltaV { get; private set; } public static double DeltaV { get; private set; }
   
public static double Distance { get; private set; } public static double Distance { get; private set; }
   
public static SuicideBurnProcessor Instance public static SuicideBurnProcessor Instance
{ {
get { return instance; } get { return instance; }
} }
   
public static bool ShowDetails { get; set; } public static bool ShowDetails { get; set; }
   
public bool UpdateRequested { get; set; } public bool UpdateRequested { get; set; }
   
#endregion #endregion
   
#region Methods: public #region Methods: public
   
public static void RequestUpdate() public static void RequestUpdate()
{ {
instance.UpdateRequested = true; instance.UpdateRequested = true;
SimulationProcessor.RequestUpdate(); SimulationProcessor.RequestUpdate();
} }
   
public static void Reset() public static void Reset()
{ {
FlightEngineerCore.Instance.AddUpdatable(SimulationProcessor.Instance); FlightEngineerCore.Instance.AddUpdatable(SimulationProcessor.Instance);
FlightEngineerCore.Instance.AddUpdatable(instance); FlightEngineerCore.Instance.AddUpdatable(instance);
} }
   
public void Update() public void Update()
{ {
if (FlightGlobals.ship_orbit.PeA >= 0.0 || !SimulationProcessor.ShowDetails) if (FlightGlobals.ship_orbit.PeA >= 0.0 || !SimulationProcessor.ShowDetails)
{ {
ShowDetails = false; ShowDetails = false;
return; return;
} }
   
ShowDetails = true;  
   
this.gravity = FlightGlobals.currentMainBody.gravParameter / Math.Pow(FlightGlobals.currentMainBody.Radius, 2.0); this.gravity = FlightGlobals.currentMainBody.gravParameter / Math.Pow(FlightGlobals.currentMainBody.Radius, 2.0);
this.acceleration = SimulationProcessor.LastStage.thrust / SimulationProcessor.LastStage.totalMass; this.acceleration = SimulationProcessor.LastStage.thrust / SimulationProcessor.LastStage.totalMass;
this.radarAltitude = FlightGlobals.ship_altitude - FlightGlobals.ActiveVessel.terrainAltitude; this.radarAltitude = FlightGlobals.ship_altitude - FlightGlobals.ActiveVessel.terrainAltitude;
   
DeltaV = Math.Sqrt((2 * this.gravity * this.radarAltitude) + Math.Pow(FlightGlobals.ship_verticalSpeed, 2.0)); DeltaV = Math.Sqrt((2 * this.gravity * this.radarAltitude) + Math.Pow(FlightGlobals.ship_verticalSpeed, 2.0));
Altitude = Math.Pow(DeltaV, 2.0) / (2.0 * this.acceleration); Altitude = Math.Pow(DeltaV, 2.0) / (2.0 * this.acceleration);
Distance = this.radarAltitude - Altitude; Distance = this.radarAltitude - Altitude;
   
  ShowDetails = !Double.IsInfinity(Distance);
} }
   
#endregion #endregion
} }
} }
// //
// Kerbal Engineer Redux // Kerbal Engineer Redux
// //
// Copyright (C) 2014 CYBUTEK // Copyright (C) 2014 CYBUTEK
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
// //
   
#region Using Directives #region Using Directives
   
using System; using System;
   
using KerbalEngineer.Extensions; using KerbalEngineer.Extensions;
using KerbalEngineer.Flight.Presets; using KerbalEngineer.Flight.Presets;
using KerbalEngineer.Flight.Readouts; using KerbalEngineer.Flight.Readouts;
using KerbalEngineer.UIControls; using KerbalEngineer.UIControls;
   
using UnityEngine; using UnityEngine;
   
#endregion #endregion
   
namespace KerbalEngineer.Flight.Sections namespace KerbalEngineer.Flight.Sections
{ {
public class SectionEditor : MonoBehaviour public class SectionEditor : MonoBehaviour
{ {
#region Constants #region Constants
   
public const float Height = 500.0f; public const float Height = 500.0f;
public const float Width = 500.0f; public const float Width = 500.0f;
   
#endregion #endregion
   
#region Fields #region Fields
   
private GUIStyle categoryButtonActiveStyle; private GUIStyle categoryButtonActiveStyle;
private GUIStyle categoryButtonStyle; private GUIStyle categoryButtonStyle;
private DropDown categoryList; private DropDown categoryList;
private GUIStyle categoryTitleButtonStyle; private GUIStyle categoryTitleButtonStyle;
private GUIStyle helpBoxStyle; private GUIStyle helpBoxStyle;
private GUIStyle helpTextStyle; private GUIStyle helpTextStyle;
private GUIStyle panelTitleStyle; private GUIStyle panelTitleStyle;
private Rect position; private Rect position;
private DropDown presetList; private DropDown presetList;
private GUIStyle readoutButtonStyle; private GUIStyle readoutButtonStyle;
private GUIStyle readoutNameStyle; private GUIStyle readoutNameStyle;
private Vector2 scrollPositionAvailable; private Vector2 scrollPositionAvailable;
private Vector2 scrollPositionInstalled; private Vector2 scrollPositionInstalled;
private GUIStyle textStyle; private GUIStyle textStyle;
private GUIStyle windowStyle; private GUIStyle windowStyle;
   
#endregion #endregion
   
#region Properties #region Properties
   
/// <summary> /// <summary>
/// Gets and sets the parent section for the section editor. /// Gets and sets the parent section for the section editor.
/// </summary> /// </summary>
public SectionModule ParentSection { get; set; } public SectionModule ParentSection { get; set; }
   
/// <summary> /// <summary>
/// Gets and sets the window position. /// Gets and sets the window position.
/// </summary> /// </summary>
public Rect Position public Rect Position
{ {
get { return this.position; } get { return this.position; }
set { this.position = value; } set { this.position = value; }
} }
   
#endregion #endregion
   
#region Methods: protected #region Methods: protected
   
protected void Awake() protected void Awake()
{ {
try try
{ {
this.categoryList = this.gameObject.AddComponent<DropDown>(); this.categoryList = this.gameObject.AddComponent<DropDown>();
this.categoryList.DrawCallback = this.DrawCategories; this.categoryList.DrawCallback = this.DrawCategories;
this.presetList = this.gameObject.AddComponent<DropDown>(); this.presetList = this.gameObject.AddComponent<DropDown>();
this.presetList.DrawCallback = this.DrawPresets; this.presetList.DrawCallback = this.DrawPresets;
} }
catch (Exception ex) catch (Exception ex)
{ {
Logger.Exception(ex); Logger.Exception(ex);
} }
} }
   
/// <summary> /// <summary>
/// Runs when the object is destroyed. /// Runs when the object is destroyed.
/// </summary> /// </summary>
protected void OnDestroy() protected void OnDestroy()
{ {
try try
{ {
RenderingManager.RemoveFromPostDrawQueue(0, this.Draw); RenderingManager.RemoveFromPostDrawQueue(0, this.Draw);
} }
catch (Exception ex) catch (Exception ex)
{ {
Logger.Exception(ex); Logger.Exception(ex);
} }
} }
   
/// <summary> /// <summary>
/// Initialises the object's state on creation. /// Initialises the object's state on creation.
/// </summary> /// </summary>
protected void Start() protected void Start()
{ {
try try
{ {
this.InitialiseStyles(); this.InitialiseStyles();
ReadoutCategory.Selected = ReadoutCategory.GetCategory("Orbital"); ReadoutCategory.Selected = ReadoutCategory.GetCategory("Orbital");
RenderingManager.AddToPostDrawQueue(0, this.Draw); RenderingManager.AddToPostDrawQueue(0, this.Draw);
} }
catch (Exception ex) catch (Exception ex)
{ {
Logger.Exception(ex); Logger.Exception(ex);
} }
} }
   
#endregion #endregion
   
#region Methods: private #region Methods: private
   
/// <summary> /// <summary>
/// Called to draw the editor when the UI is enabled. /// Called to draw the editor when the UI is enabled.
/// </summary> /// </summary>
private void Draw() private void Draw()
{ {
this.position = GUILayout.Window(this.GetInstanceID(), this.position, this.Window, "EDIT SECTION - " + this.ParentSection.Name.ToUpper(), this.windowStyle).ClampToScreen(); this.position = GUILayout.Window(this.GetInstanceID(), this.position, this.Window, "EDIT SECTION - " + this.ParentSection.Name.ToUpper(), this.windowStyle).ClampToScreen();
this.ParentSection.EditorPositionX = this.position.x; this.ParentSection.EditorPositionX = this.position.x;
this.ParentSection.EditorPositionY = this.position.y; this.ParentSection.EditorPositionY = this.position.y;
} }
   
/// <summary> /// <summary>
/// Draws the available readouts panel. /// Draws the available readouts panel.
/// </summary> /// </summary>
private void DrawAvailableReadouts() private void DrawAvailableReadouts()
{ {
GUI.skin = HighLogic.Skin; GUI.skin = HighLogic.Skin;
this.scrollPositionAvailable = GUILayout.BeginScrollView(this.scrollPositionAvailable, false, true, GUILayout.Height(200.0f)); this.scrollPositionAvailable = GUILayout.BeginScrollView(this.scrollPositionAvailable, false, true, GUILayout.Height(200.0f));
GUI.skin = null; GUI.skin = null;
   
GUILayout.Label("AVAILABLE", this.panelTitleStyle); GUILayout.Label("AVAILABLE", this.panelTitleStyle);
   
foreach (var readout in ReadoutLibrary.GetCategory(ReadoutCategory.Selected)) foreach (var readout in ReadoutLibrary.GetCategory(ReadoutCategory.Selected))
{ {
if (!this.ParentSection.ReadoutModules.Contains(readout) || readout.Cloneable) if (!this.ParentSection.ReadoutModules.Contains(readout) || readout.Cloneable)
{ {
GUILayout.BeginHorizontal(GUILayout.Height(30.0f)); GUILayout.BeginHorizontal(GUILayout.Height(30.0f));
GUILayout.Label(readout.Name, this.readoutNameStyle); GUILayout.Label(readout.Name, this.readoutNameStyle);
readout.ShowHelp = GUILayout.Toggle(readout.ShowHelp, "?", this.readoutButtonStyle, GUILayout.Width(30.0f)); readout.ShowHelp = GUILayout.Toggle(readout.ShowHelp, "?", this.readoutButtonStyle, GUILayout.Width(30.0f));
if (GUILayout.Button("INSTALL", this.readoutButtonStyle, GUILayout.Width(125.0f))) if (GUILayout.Button("INSTALL", this.readoutButtonStyle, GUILayout.Width(125.0f)))
{ {
this.ParentSection.ReadoutModules.Add(readout); this.ParentSection.ReadoutModules.Add(readout);
} }
GUILayout.EndHorizontal(); GUILayout.EndHorizontal();
   
this.ShowHelpMessage(readout); this.ShowHelpMessage(readout);
} }
} }
   
GUILayout.EndScrollView(); GUILayout.EndScrollView();
} }
   
/// <summary> /// <summary>
/// Draws the categories list drop down UI. /// Draws the categories list drop down UI.
/// </summary> /// </summary>
private void DrawCategories() private void DrawCategories()
{ {
foreach (var category in ReadoutCategory.Categories) foreach (var category in ReadoutCategory.Categories)
{ {
var description = category.Description; var description = category.Description;
if (description.Length > 50) if (description.Length > 50)
{ {
description = description.Substring(0, 50 - 1) + "..."; description = description.Substring(0, 50 - 1) + "...";
} }
   
if (GUILayout.Button("<b>" + category.Name.ToUpper() + "</b>" + (string.IsNullOrEmpty(category.Description) ? string.Empty : "\n<i>" + description + "</i>"), category == ReadoutCategory.Selected ? this.categoryButtonActiveStyle : this.categoryButtonStyle)) if (GUILayout.Button("<b>" + category.Name.ToUpper() + "</b>" + (string.IsNullOrEmpty(category.Description) ? string.Empty : "\n<i>" + description + "</i>"), category == ReadoutCategory.Selected ? this.categoryButtonActiveStyle : this.categoryButtonStyle))
{ {
ReadoutCategory.Selected = category; ReadoutCategory.Selected = category;
this.categoryList.enabled = false; this.categoryList.enabled = false;
} }
} }
} }
   
/// <summary> /// <summary>
/// Draws the readoutCategories selection list. /// Draws the readoutCategories selection list.
/// </summary> /// </summary>
private void DrawCategorySelector() private void DrawCategorySelector()
{ {
this.categoryList.enabled = GUILayout.Toggle(this.categoryList.enabled, "▼ SELECTED CATEGORY: " + ReadoutCategory.Selected.ToString().ToUpper() + " ▼", this.categoryTitleButtonStyle); this.categoryList.enabled = GUILayout.Toggle(this.categoryList.enabled, "▼ SELECTED CATEGORY: " + ReadoutCategory.Selected.ToString().ToUpper() + " ▼", this.categoryTitleButtonStyle);
if (Event.current.type == EventType.repaint) if (Event.current.type == EventType.repaint)
{ {
this.categoryList.SetPosition(GUILayoutUtility.GetLastRect().Translate(this.position)); this.categoryList.SetPosition(GUILayoutUtility.GetLastRect().Translate(this.position));
} }
} }
   
/// <summary> /// <summary>
/// Draws the options for editing custom sections. /// Draws the options for editing custom sections.
/// </summary> /// </summary>
private void DrawCustomOptions() private void DrawCustomOptions()
{ {
GUILayout.BeginHorizontal(GUILayout.Height(25.0f)); GUILayout.BeginHorizontal(GUILayout.Height(25.0f));
this.ParentSection.Name = GUILayout.TextField(this.ParentSection.Name, this.textStyle); this.ParentSection.Name = GUILayout.TextField(this.ParentSection.Name, this.textStyle);
var isShowingInControlBar = !string.IsNullOrEmpty(this.ParentSection.Abbreviation); var isShowingInControlBar = !string.IsNullOrEmpty(this.ParentSection.Abbreviation);
this.ParentSection.Abbreviation = GUILayout.TextField(this.ParentSection.Abbreviation, this.textStyle, GUILayout.Width(75.0f)); this.ParentSection.Abbreviation = GUILayout.TextField(this.ParentSection.Abbreviation, this.textStyle, GUILayout.Width(75.0f));
if (this.ParentSection.IsCustom) if (this.ParentSection.IsCustom)
{ {
if (isShowingInControlBar && string.IsNullOrEmpty(this.ParentSection.Abbreviation)) if (isShowingInControlBar && string.IsNullOrEmpty(this.ParentSection.Abbreviation))
{ {
DisplayStack.Instance.RequestResize(); DisplayStack.Instance.RequestResize();
} }
if (this.ParentSection.IsHud = GUILayout.Toggle(this.ParentSection.IsHud, "HUD", this.readoutButtonStyle, GUILayout.Width(50.0f))) if (this.ParentSection.IsHud = GUILayout.Toggle(this.ParentSection.IsHud, "HUD", this.readoutButtonStyle, GUILayout.Width(50.0f)))
{ {
this.ParentSection.IsHudBackground = GUILayout.Toggle(this.ParentSection.IsHudBackground, "BG", this.readoutButtonStyle, GUILayout.Width(50.0f)); this.ParentSection.IsHudBackground = GUILayout.Toggle(this.ParentSection.IsHudBackground, "BG", this.readoutButtonStyle, GUILayout.Width(50.0f));
} }
   
if (GUILayout.Button("DELETE SECTION", this.readoutButtonStyle, GUILayout.Width(150.0f))) if (GUILayout.Button("DELETE SECTION", this.readoutButtonStyle, GUILayout.Width(150.0f)))
{ {
this.ParentSection.IsFloating = false; this.ParentSection.IsFloating = false;
this.ParentSection.IsEditorVisible = false; this.ParentSection.IsEditorVisible = false;
SectionLibrary.CustomSections.Remove(this.ParentSection); SectionLibrary.CustomSections.Remove(this.ParentSection);
DisplayStack.Instance.RequestResize(); DisplayStack.Instance.RequestResize();
} }
} }
GUILayout.EndHorizontal(); GUILayout.EndHorizontal();
} }
   
/// <summary> /// <summary>
/// Draws the installed readouts panel. /// Draws the installed readouts panel.
/// </summary> /// </summary>
private void DrawInstalledReadouts() private void DrawInstalledReadouts()
{ {
GUI.skin = HighLogic.Skin; GUI.skin = HighLogic.Skin;
this.scrollPositionInstalled = GUILayout.BeginScrollView(this.scrollPositionInstalled, false, true); this.scrollPositionInstalled = GUILayout.BeginScrollView(this.scrollPositionInstalled, false, true);
GUI.skin = null; GUI.skin = null;
   
GUILayout.Label("INSTALLED", this.panelTitleStyle); GUILayout.Label("INSTALLED", this.panelTitleStyle);
var removeReadout = false; var removeReadout = false;
var removeReadoutIndex = 0; var removeReadoutIndex = 0;
   
for (var i = 0; i < this.ParentSection.ReadoutModules.Count; i++) for (var i = 0; i < this.ParentSection.ReadoutModules.Count; i++)
{ {
var readout = this.ParentSection.ReadoutModules[i]; var readout = this.ParentSection.ReadoutModules[i];
   
GUILayout.BeginHorizontal(GUILayout.Height(30.0f)); GUILayout.BeginHorizontal(GUILayout.Height(30.0f));
GUILayout.Label(readout.Name, this.readoutNameStyle); GUILayout.Label(readout.Name, this.readoutNameStyle);
if (GUILayout.Button("▲", this.readoutButtonStyle, GUILayout.Width(30.0f))) if (GUILayout.Button("▲", this.readoutButtonStyle, GUILayout.Width(30.0f)))
{ {
if (i > 0) if (i > 0)
{ {
this.ParentSection.ReadoutModules[i] = this.ParentSection.ReadoutModules[i - 1]; this.ParentSection.ReadoutModules[i] = this.ParentSection.ReadoutModules[i - 1];
this.ParentSection.ReadoutModules[i - 1] = readout; this.ParentSection.ReadoutModules[i - 1] = readout;
} }
} }
if (GUILayout.Button("▼", this.readoutButtonStyle, GUILayout.Width(30.0f))) if (GUILayout.Button("▼", this.readoutButtonStyle, GUILayout.Width(30.0f)))
{ {
if (i < this.ParentSection.ReadoutModules.Count - 1) if (i < this.ParentSection.ReadoutModules.Count - 1)
{ {
this.ParentSection.ReadoutModules[i] = this.ParentSection.ReadoutModules[i + 1]; this.ParentSection.ReadoutModules[i] = this.ParentSection.ReadoutModules[i + 1];
this.ParentSection.ReadoutModules[i + 1] = readout; this.ParentSection.ReadoutModules[i + 1] = readout;
} }
} }
readout.ShowHelp = GUILayout.Toggle(readout.ShowHelp, "?", this.readoutButtonStyle, GUILayout.Width(30.0f)); readout.ShowHelp = GUILayout.Toggle(readout.ShowHelp, "?", this.readoutButtonStyle, GUILayout.Width(30.0f));
if (GUILayout.Button("REMOVE", this.readoutButtonStyle, GUILayout.Width(125.0f))) if (GUILayout.Button("REMOVE", this.readoutButtonStyle, GUILayout.Width(125.0f)))
{ {
removeReadout = true; removeReadout = true;
removeReadoutIndex = i; removeReadoutIndex = i;
} }
GUILayout.EndHorizontal(); GUILayout.EndHorizontal();
   
this.ShowHelpMessage(readout); this.ShowHelpMessage(readout);
} }
   
GUILayout.EndScrollView(); GUILayout.EndScrollView();
   
if (removeReadout) if (removeReadout)
{ {
this.ParentSection.ReadoutModules.RemoveAt(removeReadoutIndex); this.ParentSection.ReadoutModules.RemoveAt(removeReadoutIndex);
} }
} }
   
private void DrawPresetButton(Preset preset) private void DrawPresetButton(Preset preset)
{ {
if (!GUILayout.Button("<b>" + preset.Name.ToUpper() + "</b>", this.categoryButtonStyle)) if (!GUILayout.Button("<b>" + preset.Name.ToUpper() + "</b>", this.categoryButtonStyle))
{ {
return; return;
} }
   
this.ParentSection.Name = preset.Name; this.ParentSection.Name = preset.Name;
this.ParentSection.Abbreviation = preset.Abbreviation; this.ParentSection.Abbreviation = preset.Abbreviation;
this.ParentSection.ReadoutModuleNames = preset.ReadoutNames; this.ParentSection.ReadoutModuleNames = preset.ReadoutNames;
  this.ParentSection.IsHud = preset.IsHud;
  this.ParentSection.IsHudBackground = preset.IsHudBackground;
this.presetList.enabled = false; this.presetList.enabled = false;
} }
   
private void DrawPresetSaveButton() private void DrawPresetSaveButton()
{ {
if (!GUILayout.Button("<b>SAVE PRESET</b>", this.categoryButtonStyle)) if (!GUILayout.Button("<b>SAVE PRESET</b>", this.categoryButtonStyle))
{ {
return; return;
} }
   
this.SavePreset(PresetLibrary.Presets.Find(p => String.Equals(p.Name, this.ParentSection.Name, StringComparison.CurrentCultureIgnoreCase))); this.SavePreset(PresetLibrary.Presets.Find(p => String.Equals(p.Name, this.ParentSection.Name, StringComparison.CurrentCultureIgnoreCase)));
} }
   
/// <summary> /// <summary>
/// Draws the presetsList selection list. /// Draws the presetsList selection list.
/// </summary> /// </summary>
private void DrawPresetSelector() private void DrawPresetSelector()
{ {
this.presetList.enabled = GUILayout.Toggle(this.presetList.enabled, "▼ PRESETS ▼", this.categoryTitleButtonStyle, GUILayout.Width(150.0f)); this.presetList.enabled = GUILayout.Toggle(this.presetList.enabled, "▼ PRESETS ▼", this.categoryTitleButtonStyle, GUILayout.Width(150.0f));
if (Event.current.type == EventType.repaint) if (Event.current.type == EventType.repaint)
{ {
this.presetList.SetPosition(GUILayoutUtility.GetLastRect().Translate(this.position)); this.presetList.SetPosition(GUILayoutUtility.GetLastRect().Translate(this.position));
} }
} }
   
/// <summary> /// <summary>
/// Draws the preset list drop down UI. /// Draws the preset list drop down UI.
/// </summary> /// </summary>
private void DrawPresets() private void DrawPresets()
{ {
Preset removePreset = null; Preset removePreset = null;
foreach (var preset in PresetLibrary.Presets) foreach (var preset in PresetLibrary.Presets)
{ {
GUILayout.BeginHorizontal(); GUILayout.BeginHorizontal();
this.DrawPresetButton(preset); this.DrawPresetButton(preset);
if (GUILayout.Button("<b>X</b>", this.categoryButtonStyle, GUILayout.Width(30.0f))) if (GUILayout.Button("<b>X</b>", this.categoryButtonStyle, GUILayout.Width(30.0f)))
{ {
removePreset = preset; removePreset = preset;
} }
GUILayout.EndHorizontal(); GUILayout.EndHorizontal();
} }
if (removePreset != null && PresetLibrary.Remove(removePreset)) if (removePreset != null && PresetLibrary.Remove(removePreset))
{ {
this.presetList.Resize = true; this.presetList.Resize = true;
} }
   
this.DrawPresetSaveButton(); this.DrawPresetSaveButton();
} }
   
/// <summary> /// <summary>
/// Initialises all the styles required for this object. /// Initialises all the styles required for this object.
/// </summary> /// </summary>
private void InitialiseStyles() private void InitialiseStyles()
{ {
this.windowStyle = new GUIStyle(HighLogic.Skin.window); this.windowStyle = new GUIStyle(HighLogic.Skin.window);
   
this.categoryButtonStyle = new GUIStyle(HighLogic.Skin.button) this.categoryButtonStyle = new GUIStyle(HighLogic.Skin.button)
{ {
normal = normal =
{ {
textColor = Color.white textColor = Color.white
}, },
margin = new RectOffset(0, 0, 2, 0), margin = new RectOffset(0, 0, 2, 0),
padding = new RectOffset(5, 5, 5, 5), padding = new RectOffset(5, 5, 5, 5),
alignment = TextAnchor.MiddleCenter, alignment = TextAnchor.MiddleCenter,
fontSize = 12, fontSize = 12,
fontStyle = FontStyle.Normal, fontStyle = FontStyle.Normal,
richText = true richText = true
}; };
   
this.categoryButtonActiveStyle = new GUIStyle(this.categoryButtonStyle) this.categoryButtonActiveStyle = new GUIStyle(this.categoryButtonStyle)
{ {
normal = this.categoryButtonStyle.onNormal, normal = this.categoryButtonStyle.onNormal,
hover = this.categoryButtonStyle.onHover hover = this.categoryButtonStyle.onHover
}; };
   
this.panelTitleStyle = new GUIStyle(HighLogic.Skin.label) this.panelTitleStyle = new GUIStyle(HighLogic.Skin.label)
{ {
normal = normal =
{ {
textColor = Color.white textColor = Color.white
}, },
margin = new RectOffset(), margin = new RectOffset(),
padding = new RectOffset(), padding = new RectOffset(),
alignment = TextAnchor.MiddleLeft, alignment = TextAnchor.MiddleLeft,
fontSize = 12, fontSize = 12,
fontStyle = FontStyle.Bold, fontStyle = FontStyle.Bold,
fixedHeight = 30.0f, fixedHeight = 30.0f,
stretchWidth = true stretchWidth = true
}; };
   
this.textStyle = new GUIStyle(HighLogic.Skin.textField) this.textStyle = new GUIStyle(HighLogic.Skin.textField)
{ {
margin = new RectOffset(3, 3, 3, 3), margin = new RectOffset(3, 3, 3, 3),
alignment = TextAnchor.MiddleLeft, alignment = TextAnchor.MiddleLeft,
stretchWidth = true, stretchWidth = true,
stretchHeight = true stretchHeight = true
}; };
   
this.readoutNameStyle = new GUIStyle(HighLogic.Skin.label) this.readoutNameStyle = new GUIStyle(HighLogic.Skin.label)
{ {
normal = normal =
{ {
textColor = Color.white textColor = Color.white
}, },
margin = new RectOffset(), margin = new RectOffset(),
padding = new RectOffset(10, 0, 0, 0), padding = new RectOffset(10, 0, 0, 0),
alignment = TextAnchor.MiddleLeft, alignment = TextAnchor.MiddleLeft,
fontSize = 12, fontSize = 12,
fontStyle = FontStyle.Bold, fontStyle = FontStyle.Bold,
stretchWidth = true, stretchWidth = true,
stretchHeight = true stretchHeight = true
}; };
   
this.readoutButtonStyle = new GUIStyle(HighLogic.Skin.button) this.readoutButtonStyle = new GUIStyle(HighLogic.Skin.button)
{ {
normal = normal =
{ {
textColor = Color.white textColor = Color.white
}, },
margin = new RectOffset(2, 2, 2, 2), margin = new RectOffset(2, 2, 2, 2),
padding = new RectOffset(), padding = new RectOffset(),
alignment = TextAnchor.MiddleCenter, alignment = TextAnchor.MiddleCenter,
fontSize = 12, fontSize = 12,
fontStyle = FontStyle.Bold, fontStyle = FontStyle.Bold,
stretchHeight = true stretchHeight = true
}; };
   
this.helpBoxStyle = new GUIStyle(HighLogic.Skin.box) this.helpBoxStyle = new GUIStyle(HighLogic.Skin.box)
{ {
margin = new RectOffset(2, 2, 2, 10), margin = new RectOffset(2, 2, 2, 10),
padding = new RectOffset(10, 10, 10, 10) padding = new RectOffset(10, 10, 10, 10)
}; };
   
this.helpTextStyle = new GUIStyle(HighLogic.Skin.label) this.helpTextStyle = new GUIStyle(HighLogic.Skin.label)
{ {
normal = normal =
{ {
textColor = Color.yellow textColor = Color.yellow
}, },
margin = new RectOffset(), margin = new RectOffset(),
padding = new RectOffset(), padding = new RectOffset(),
alignment = TextAnchor.MiddleLeft, alignment = TextAnchor.MiddleLeft,
fontSize = 13, fontSize = 13,
fontStyle = FontStyle.Normal, fontStyle = FontStyle.Normal,
stretchWidth = true, stretchWidth = true,
richText = true richText = true
}; };
   
this.categoryTitleButtonStyle = new GUIStyle(this.readoutButtonStyle) this.categoryTitleButtonStyle = new GUIStyle(this.readoutButtonStyle)
{ {
fixedHeight = 30.0f, fixedHeight = 30.0f,
stretchHeight = false stretchHeight = false
}; };
} }
   
private void SavePreset(Preset preset) private void SavePreset(Preset preset)
{ {
if (preset == null) if (preset == null)
{ {
preset = new Preset(); preset = new Preset();
} }
   
preset.Name = this.ParentSection.Name; preset.Name = this.ParentSection.Name;
preset.Abbreviation = this.ParentSection.Abbreviation; preset.Abbreviation = this.ParentSection.Abbreviation;
preset.ReadoutNames = this.ParentSection.ReadoutModuleNames; preset.ReadoutNames = this.ParentSection.ReadoutModuleNames;
  preset.IsHud = this.ParentSection.IsHud;
  preset.IsHudBackground = this.ParentSection.IsHudBackground;
   
PresetLibrary.Save(preset); PresetLibrary.Save(preset);
} }
   
private void ShowHelpMessage(ReadoutModule readout) private void ShowHelpMessage(ReadoutModule readout)
{ {
if (!readout.ShowHelp) if (!readout.ShowHelp)
{ {
return; return;
} }
   
GUILayout.BeginVertical(this.helpBoxStyle); GUILayout.BeginVertical(this.helpBoxStyle);
GUILayout.Label(!String.IsNullOrEmpty(readout.HelpString) ? readout.HelpString : "Sorry, no help information has been provided for this readout module.", this.helpTextStyle); GUILayout.Label(!String.IsNullOrEmpty(readout.HelpString) ? readout.HelpString : "Sorry, no help information has been provided for this readout module.", this.helpTextStyle);
GUILayout.EndVertical(); GUILayout.EndVertical();
} }
   
/// <summary> /// <summary>
/// Draws the editor window. /// Draws the editor window.
/// </summary> /// </summary>
private void Window(int windowId) private void Window(int windowId)
{ {
try try
{ {
this.DrawCustomOptions(); this.DrawCustomOptions();
GUILayout.BeginHorizontal(); GUILayout.BeginHorizontal();
this.DrawCategorySelector(); this.DrawCategorySelector();
this.DrawPresetSelector(); this.DrawPresetSelector();
GUILayout.EndHorizontal(); GUILayout.EndHorizontal();
this.DrawAvailableReadouts(); this.DrawAvailableReadouts();
GUILayout.Space(5.0f); GUILayout.Space(5.0f);
this.DrawInstalledReadouts(); this.DrawInstalledReadouts();
   
if (GUILayout.Button("CLOSE EDITOR", this.categoryTitleButtonStyle)) if (GUILayout.Button("CLOSE EDITOR", this.categoryTitleButtonStyle))
{ {
this.ParentSection.IsEditorVisible = false; this.ParentSection.IsEditorVisible = false;
} }
   
GUI.DragWindow(); GUI.DragWindow();
} }
catch (Exception ex) catch (Exception ex)
{ {
Logger.Exception(ex); Logger.Exception(ex);
} }
} }
   
#endregion #endregion
} }
} }
// //
// Kerbal Engineer Redux // Kerbal Engineer Redux
// //
// Copyright (C) 2014 CYBUTEK // Copyright (C) 2014 CYBUTEK
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
// //
   
#region Using Directives #region Using Directives
   
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Xml.Serialization; using System.Xml.Serialization;
   
using KerbalEngineer.Flight.Readouts; using KerbalEngineer.Flight.Readouts;
   
using UnityEngine; using UnityEngine;
   
#endregion #endregion
   
namespace KerbalEngineer.Flight.Sections namespace KerbalEngineer.Flight.Sections
{ {
/// <summary> /// <summary>
/// Object for management and display of readout modules. /// Object for management and display of readout modules.
/// </summary> /// </summary>
public class SectionModule public class SectionModule
{ {
#region Fields #region Fields
   
private SectionEditor editor; private SectionEditor editor;
private bool isHud; private bool isHud;
private int numberOfReadouts; private int numberOfReadouts;
   
#endregion #endregion
   
#region Constructors #region Constructors
   
/// <summary> /// <summary>
/// Creates a new section module. /// Creates a new section module.
/// </summary> /// </summary>
public SectionModule() public SectionModule()
{ {
this.FloatingPositionX = Screen.width * 0.5f - 125.0f; this.FloatingPositionX = Screen.width * 0.5f - 125.0f;
this.FloatingPositionY = 100.0f; this.FloatingPositionY = 100.0f;
this.EditorPositionX = Screen.width * 0.5f - SectionEditor.Width * 0.5f; this.EditorPositionX = Screen.width * 0.5f - SectionEditor.Width * 0.5f;
this.EditorPositionY = Screen.height * 0.5f - SectionEditor.Height * 0.5f; this.EditorPositionY = Screen.height * 0.5f - SectionEditor.Height * 0.5f;
this.ReadoutModules = new List<ReadoutModule>(); this.ReadoutModules = new List<ReadoutModule>();
this.InitialiseStyles(); this.InitialiseStyles();
GuiDisplaySize.OnSizeChanged += this.OnSizeChanged; GuiDisplaySize.OnSizeChanged += this.OnSizeChanged;
} }
   
#endregion #endregion
   
#region Properties #region Properties
   
/// <summary> /// <summary>
/// Gets and sets the abbreviation of the section. /// Gets and sets the abbreviation of the section.
/// </summary> /// </summary>
public string Abbreviation { get; set; } public string Abbreviation { get; set; }
   
/// <summary> /// <summary>
/// Gets and sets the X position of the editor window. (Only used for serialisation.) /// Gets and sets the X position of the editor window. (Only used for serialisation.)
/// </summary> /// </summary>
public float EditorPositionX { get; set; } public float EditorPositionX { get; set; }
   
/// <summary> /// <summary>
/// Gets and sets the Y position of the editor window. (Only used for serialisation.) /// Gets and sets the Y position of the editor window. (Only used for serialisation.)
/// </summary> /// </summary>
public float EditorPositionY { get; set; } public float EditorPositionY { get; set; }
   
/// <summary> /// <summary>
/// Gets and sets the X position of the floating window. (Only used for serialisation.) /// Gets and sets the X position of the floating window. (Only used for serialisation.)
/// </summary> /// </summary>
public float FloatingPositionX { get; set; } public float FloatingPositionX { get; set; }
   
/// <summary> /// <summary>
/// Gets and sets the Y position of the floating window. (Only used for serialisation.) /// Gets and sets the Y position of the floating window. (Only used for serialisation.)
/// </summary> /// </summary>
public float FloatingPositionY { get; set; } public float FloatingPositionY { get; set; }
   
/// <summary> /// <summary>
/// Gets and sets whether the section is custom. /// Gets and sets whether the section is custom.
/// </summary> /// </summary>
public bool IsCustom { get; set; } public bool IsCustom { get; set; }
   
/// <summary> /// <summary>
/// Gets and sets whether the section editor is visible. /// Gets and sets whether the section editor is visible.
/// </summary> /// </summary>
public bool IsEditorVisible public bool IsEditorVisible
{ {
get { return this.editor != null; } get { return this.editor != null; }
set set
{ {
if (value && this.editor == null) if (value && this.editor == null)
{ {
this.editor = FlightEngineerCore.Instance.AddSectionEditor(this); this.editor = FlightEngineerCore.Instance.AddSectionEditor(this);
} }
else if (!value && this.editor != null) else if (!value && this.editor != null)
{ {
Object.Destroy(this.editor); Object.Destroy(this.editor);
} }
} }
} }
   
/// <summary> /// <summary>
/// Gets and sets whether the section is in a floating state. /// Gets and sets whether the section is in a floating state.
/// </summary> /// </summary>
public bool IsFloating public bool IsFloating
{ {
get { return this.Window != null; } get { return this.Window != null; }
set set
{ {
if (value && this.Window == null) if (value && this.Window == null)
{ {
this.Window = FlightEngineerCore.Instance.AddSectionWindow(this); this.Window = FlightEngineerCore.Instance.AddSectionWindow(this);
} }
else if (!value && this.Window != null) else if (!value && this.Window != null)
{ {
Object.Destroy(this.Window); Object.Destroy(this.Window);
} }
} }
} }
   
/// <summary> /// <summary>
/// Gets and sets whether the section module is a HUD. /// Gets and sets whether the section module is a HUD.
/// </summary> /// </summary>
public bool IsHud public bool IsHud
{ {
get { return this.isHud; } get { return this.isHud; }
set set
{ {
if (this.isHud == value) if (this.isHud == value)
{ {
return; return;
} }
   
this.isHud = value; this.isHud = value;
if (this.isHud) if (this.isHud)
{ {
this.IsFloating = true; this.IsFloating = true;
} }
if (this.Window != null) if (this.Window != null)
{ {
this.Window.RequestResize(); this.Window.RequestResize();
} }
} }
} }
   
/// <summary> /// <summary>
/// Gets and sets whether the section module has a background as a HUD. /// Gets and sets whether the section module has a background as a HUD.
/// </summary> /// </summary>
public bool IsHudBackground { get; set; } public bool IsHudBackground { get; set; }
   
/// <summary> /// <summary>
/// Gets and sets the visibility of the section. /// Gets and sets the visibility of the section.
/// </summary> /// </summary>
public bool IsVisible { get; set; } public bool IsVisible { get; set; }
   
/// <summary> /// <summary>
  /// Gets the number of drawn readout lines.
  /// </summary>
  public int LineCount { get; private set; }
   
  /// <summary>
/// Gets and sets the name of the section. /// Gets and sets the name of the section.
/// </summary> /// </summary>
public string Name { get; set; } public string Name { get; set; }
   
/// <summary> /// <summary>
/// Gets and sets the names of the installed readout modules. (Only used with serialisation.) /// Gets and sets the names of the installed readout modules. (Only used with serialisation.)
/// </summary> /// </summary>
public string[] ReadoutModuleNames public string[] ReadoutModuleNames
{ {
get { return this.ReadoutModules.Select(r => r.Category + "." + r.GetType().Name).ToArray(); } get { return this.ReadoutModules.Select(r => r.Category + "." + r.GetType().Name).ToArray(); }
set { this.ReadoutModules = value.Select(ReadoutLibrary.GetReadout).ToList(); } set { this.ReadoutModules = value.Select(ReadoutLibrary.GetReadout).ToList(); }
} }
   
/// <summary> /// <summary>
/// Gets and sets the list of readout modules. /// Gets and sets the list of readout modules.
/// </summary> /// </summary>
[XmlIgnore] [XmlIgnore]
public List<ReadoutModule> ReadoutModules { get; set; } public List<ReadoutModule> ReadoutModules { get; set; }
   
/// <summary> /// <summary>
/// Gets and sets the floating window. /// Gets and sets the floating window.
/// </summary> /// </summary>
[XmlIgnore] [XmlIgnore]
public SectionWindow Window { get; set; } public SectionWindow Window { get; set; }
   
#endregion #endregion
   
#region GUIStyles #region GUIStyles
   
#region Fields #region Fields
   
private GUIStyle boxStyle; private GUIStyle boxStyle;
private GUIStyle buttonStyle; private GUIStyle buttonStyle;
private GUIStyle messageStyle; private GUIStyle messageStyle;
private GUIStyle titleStyle; private GUIStyle titleStyle;
   
#endregion #endregion
   
/// <summary> /// <summary>
/// Initialises all the styles required for this object. /// Initialises all the styles required for this object.
/// </summary> /// </summary>
private void InitialiseStyles() private void InitialiseStyles()
{ {
this.boxStyle = new GUIStyle(HighLogic.Skin.box) this.boxStyle = new GUIStyle(HighLogic.Skin.box)
{ {
margin = new RectOffset(), margin = new RectOffset(),
padding = new RectOffset(5, 5, 5, 5) padding = new RectOffset(5, 5, 5, 5)
}; };
   
this.titleStyle = new GUIStyle(HighLogic.Skin.label) this.titleStyle = new GUIStyle(HighLogic.Skin.label)
{ {
normal = normal =
{ {
textColor = Color.white textColor = Color.white
}, },
margin = new RectOffset(), margin = new RectOffset(),
padding = new RectOffset(2, 0, 5, 2), padding = new RectOffset(2, 0, 5, 2),
fontSize = (int)(13 * GuiDisplaySize.Offset), fontSize = (int)(13 * GuiDisplaySize.Offset),
fontStyle = FontStyle.Bold, fontStyle = FontStyle.Bold,
stretchWidth = true stretchWidth = true
}; };
   
this.buttonStyle = new GUIStyle(HighLogic.Skin.button) this.buttonStyle = new GUIStyle(HighLogic.Skin.button)
{ {
normal = normal =
{ {
textColor = Color.white textColor = Color.white
}, },
margin = new RectOffset(0, 0, 5, 3), margin = new RectOffset(0, 0, 5, 3),
padding = new RectOffset(), padding = new RectOffset(),
fontSize = (int)(10 * GuiDisplaySize.Offset), fontSize = (int)(10 * GuiDisplaySize.Offset),
stretchHeight = true, stretchHeight = true,
fixedWidth = 60.0f * GuiDisplaySize.Offset fixedWidth = 60.0f * GuiDisplaySize.Offset
}; };
   
this.messageStyle = new GUIStyle(HighLogic.Skin.label) this.messageStyle = new GUIStyle(HighLogic.Skin.label)
{ {
normal = normal =
{ {
textColor = Color.white textColor = Color.white
}, },
margin = new RectOffset(), margin = new RectOffset(),
padding = new RectOffset(), padding = new RectOffset(),
alignment = TextAnchor.MiddleCenter, alignment = TextAnchor.MiddleCenter,
fontSize = (int)(12 * GuiDisplaySize.Offset), fontSize = (int)(12 * GuiDisplaySize.Offset),
fontStyle = FontStyle.Bold, fontStyle = FontStyle.Bold,
fixedWidth = 220.0f * GuiDisplaySize.Offset, fixedWidth = 220.0f * GuiDisplaySize.Offset,
fixedHeight = 20.0f * GuiDisplaySize.Offset fixedHeight = 20.0f * GuiDisplaySize.Offset
}; };
} }
   
private void OnSizeChanged() private void OnSizeChanged()
{ {
this.InitialiseStyles(); this.InitialiseStyles();
} }
   
#endregion #endregion
   
#region Updating #region Updating
   
/// <summary> /// <summary>
/// Updates all of the internal readout modules at fixed time intervals. /// Updates all of the internal readout modules at fixed time intervals.
/// </summary> /// </summary>
public void FixedUpdate() public void FixedUpdate()
{ {
if (!this.IsVisible) if (!this.IsVisible)
{ {
return; return;
} }
   
foreach (var readout in this.ReadoutModules) foreach (var readout in this.ReadoutModules)
{ {
readout.FixedUpdate(); readout.FixedUpdate();
} }
} }
   
/// <summary> /// <summary>
/// Updates all of the internal readout modules. /// Updates all of the internal readout modules.
/// </summary> /// </summary>
public void Update() public void Update()
{ {
if (!this.IsVisible) if (!this.IsVisible)
{ {
return; return;
} }
   
foreach (var readout in this.ReadoutModules) foreach (var readout in this.ReadoutModules)
{ {
readout.Update(); readout.Update();
} }
   
if (this.numberOfReadouts != this.ReadoutModules.Count) if (this.numberOfReadouts != this.ReadoutModules.Count)
{ {
this.numberOfReadouts = this.ReadoutModules.Count; this.numberOfReadouts = this.ReadoutModules.Count;
if (!this.IsFloating) if (!this.IsFloating)
{ {
DisplayStack.Instance.RequestResize(); DisplayStack.Instance.RequestResize();
} }
else else
{ {
this.Window.RequestResize(); this.Window.RequestResize();
} }
} }
} }
   
#endregion #endregion
   
#region Drawing #region Drawing
   
#region Methods: public #region Methods: public
   
/// <summary> /// <summary>
/// Draws the section and all of the internal readout modules. /// Draws the section and all of the internal readout modules.
/// </summary> /// </summary>
public void Draw() public void Draw()
{ {
if (!this.IsVisible) if (!this.IsVisible)
{ {
return; return;
} }
   
if (!this.IsHud) if (!this.IsHud)
{ {
this.DrawSectionTitleBar(); this.DrawSectionTitleBar();
} }
   
this.DrawReadoutModules(); this.DrawReadoutModules();
} }
   
#endregion #endregion
   
#region Methods: private #region Methods: private
   
/// <summary> /// <summary>
/// Draws all the readout modules. /// Draws all the readout modules.
/// </summary> /// </summary>
private void DrawReadoutModules() private void DrawReadoutModules()
{ {
if (!this.IsHud) if (!this.IsHud)
{ {
GUILayout.BeginVertical(this.boxStyle); GUILayout.BeginVertical(this.boxStyle);
} }
   
  this.LineCount = 0;
if (this.ReadoutModules.Count > 0) if (this.ReadoutModules.Count > 0)
{ {
foreach (var readout in this.ReadoutModules) foreach (var readout in this.ReadoutModules)
{ {
readout.LineCountStart(); readout.LineCountStart();
readout.Draw(this); readout.Draw(this);
readout.LineCountEnd(); readout.LineCountEnd();
  this.LineCount += readout.LineCount;
} }
} }
else else
{ {
GUILayout.Label("No readouts are installed.", this.messageStyle); GUILayout.Label("No readouts are installed.", this.messageStyle);
  this.LineCount = 1;
} }
   
if (!this.IsHud) if (!this.IsHud)
{ {
GUILayout.EndVertical(); GUILayout.EndVertical();
} }
} }
   
/// <summary> /// <summary>
/// Draws the section title and action buttons. /// Draws the section title and action buttons.
/// </summary> /// </summary>
private void DrawSectionTitleBar() private void DrawSectionTitleBar()
{ {
GUILayout.BeginHorizontal(); GUILayout.BeginHorizontal();
GUILayout.Label(this.Name.ToUpper(), this.titleStyle); GUILayout.Label(this.Name.ToUpper(), this.titleStyle);
this.IsEditorVisible = GUILayout.Toggle(this.IsEditorVisible, "EDIT", this.buttonStyle); this.IsEditorVisible = GUILayout.Toggle(this.IsEditorVisible, "EDIT", this.buttonStyle);
this.IsFloating = GUILayout.Toggle(this.IsFloating, "FLOAT", this.buttonStyle); this.IsFloating = GUILayout.Toggle(this.IsFloating, "FLOAT", this.buttonStyle);
GUILayout.EndHorizontal(); GUILayout.EndHorizontal();
} }
   
#endregion #endregion
   
#endregion #endregion
   
#region Public Methods #region Public Methods
   
public void ClearNullReadouts() public void ClearNullReadouts()
{ {
this.ReadoutModules.RemoveAll(r => r == null); this.ReadoutModules.RemoveAll(r => r == null);
} }
   
#endregion #endregion
} }
} }
// //
// Kerbal Engineer Redux // Kerbal Engineer Redux
// //
// Copyright (C) 2014 CYBUTEK // Copyright (C) 2014 CYBUTEK
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
// //
   
#region Using Directives #region Using Directives
   
using KerbalEngineer.Extensions; using KerbalEngineer.Extensions;
using KerbalEngineer.Helpers; using KerbalEngineer.Helpers;
   
using UnityEngine; using UnityEngine;
   
#endregion #endregion
   
namespace KerbalEngineer.Flight.Sections namespace KerbalEngineer.Flight.Sections
{ {
public class SectionWindow : MonoBehaviour public class SectionWindow : MonoBehaviour
{ {
#region Fields #region Fields
   
private bool resizeRequested; private bool resizeRequested;
private int windowId; private int windowId;
private Rect windowPosition; private Rect windowPosition;
   
#endregion #endregion
   
#region Properties #region Properties
   
/// <summary> /// <summary>
/// Gets and sets the parent section for the floating section window. /// Gets and sets the parent section for the floating section window.
/// </summary> /// </summary>
public SectionModule ParentSection { get; set; } public SectionModule ParentSection { get; set; }
   
/// <summary> /// <summary>
/// Gets and sets the window position. /// Gets and sets the window position.
/// </summary> /// </summary>
public Rect WindowPosition public Rect WindowPosition
{ {
get { return this.windowPosition; } get { return this.windowPosition; }
set { this.windowPosition = value; } set { this.windowPosition = value; }
} }
   
#endregion #endregion
   
#region GUIStyles #region GUIStyles
   
#region Fields #region Fields
   
  private GUIStyle hudWindowBgStyle;
private GUIStyle hudWindowStyle; private GUIStyle hudWindowStyle;
private GUIStyle hudWindowBgStyle;  
private GUIStyle windowStyle; private GUIStyle windowStyle;
   
#endregion #endregion
   
/// <summary> /// <summary>
/// Initialises all the styles required for this object. /// Initialises all the styles required for this object.
/// </summary> /// </summary>
private void InitialiseStyles() private void InitialiseStyles()
{ {
this.windowStyle = new GUIStyle(HighLogic.Skin.window) this.windowStyle = new GUIStyle(HighLogic.Skin.window)
{ {
margin = new RectOffset(), margin = new RectOffset(),
padding = new RectOffset(5, 5, 0, 5), padding = new RectOffset(5, 5, 0, 5),
}; };
   
this.hudWindowStyle = new GUIStyle(this.windowStyle) this.hudWindowStyle = new GUIStyle(this.windowStyle)
{ {
normal = normal =
{ {
background = null background = null
}, },
onNormal = onNormal =
{ {
background = null background = null
}, },
padding = new RectOffset(5, 5, 0, 8), padding = new RectOffset(5, 5, 0, 8),
}; };
   
this.hudWindowBgStyle = new GUIStyle(this.hudWindowStyle) this.hudWindowBgStyle = new GUIStyle(this.hudWindowStyle)
{ {
normal = normal =
{ {
background = TextureHelper.CreateTextureFromColour(new Color(0.0f, 0.0f, 0.0f, 0.5f)) background = TextureHelper.CreateTextureFromColour(new Color(0.0f, 0.0f, 0.0f, 0.5f))
}, },
onNormal = onNormal =
{ {
background = TextureHelper.CreateTextureFromColour(new Color(0.0f, 0.0f, 0.0f, 0.5f)) background = TextureHelper.CreateTextureFromColour(new Color(0.0f, 0.0f, 0.0f, 0.5f))
} }
}; };
} }
   
private void OnSizeChanged() private void OnSizeChanged()
{ {
this.InitialiseStyles(); this.InitialiseStyles();
this.RequestResize(); this.RequestResize();
} }
   
#endregion #endregion
   
#region Drawing #region Drawing
   
/// <summary> /// <summary>
/// Called to draw the floating section window when the UI is enabled. /// Called to draw the floating section window when the UI is enabled.
/// </summary> /// </summary>
private void Draw() private void Draw()
{ {
if (this.ParentSection == null || !this.ParentSection.IsVisible || (DisplayStack.Instance.Hidden && !this.ParentSection.IsHud)) if (this.ParentSection == null || !this.ParentSection.IsVisible || (DisplayStack.Instance.Hidden && !this.ParentSection.IsHud))
{ {
return; return;
} }
   
if (this.resizeRequested) if (this.resizeRequested)
{ {
this.windowPosition.width = 0; this.windowPosition.width = 0;
this.windowPosition.height = 0; this.windowPosition.height = 0;
this.resizeRequested = false; this.resizeRequested = false;
} }
GUI.skin = null; GUI.skin = null;
this.windowPosition = GUILayout.Window(this.windowId, this.windowPosition, this.Window, string.Empty, this.windowPosition = GUILayout.Window(this.windowId, this.windowPosition, this.Window, string.Empty,
(!this.ParentSection.IsHud || this.ParentSection.IsEditorVisible) ? this.windowStyle (!this.ParentSection.IsHud || this.ParentSection.IsEditorVisible) ? this.windowStyle
: this.ParentSection.IsHudBackground ? this.hudWindowBgStyle : this.hudWindowStyle).ClampToScreen(); : this.ParentSection.IsHudBackground && this.ParentSection.LineCount > 0
  ? this.hudWindowBgStyle
  : this.hudWindowStyle).ClampToScreen();
this.ParentSection.FloatingPositionX = this.windowPosition.x; this.ParentSection.FloatingPositionX = this.windowPosition.x;
this.ParentSection.FloatingPositionY = this.windowPosition.y; this.ParentSection.FloatingPositionY = this.windowPosition.y;
} }
   
/// <summary> /// <summary>
/// Draws the floating section window. /// Draws the floating section window.
/// </summary> /// </summary>
private void Window(int windowId) private void Window(int windowId)
{ {
this.ParentSection.Draw(); this.ParentSection.Draw();
   
if (!this.ParentSection.IsHud || this.ParentSection.IsEditorVisible) if (!this.ParentSection.IsHud || this.ParentSection.IsEditorVisible)
{ {
GUI.DragWindow(); GUI.DragWindow();
} }
} }
   
#endregion #endregion
   
#region Destruction #region Destruction
   
/// <summary> /// <summary>
/// Runs when the object is destroyed. /// Runs when the object is destroyed.
/// </summary> /// </summary>
private void OnDestroy() private void OnDestroy()
{ {
RenderingManager.RemoveFromPostDrawQueue(0, this.Draw); RenderingManager.RemoveFromPostDrawQueue(0, this.Draw);
GuiDisplaySize.OnSizeChanged -= this.OnSizeChanged; GuiDisplaySize.OnSizeChanged -= this.OnSizeChanged;
} }
   
#endregion #endregion
   
#region Methods #region Methods
   
/// <summary> /// <summary>
/// Request that the floating section window's size is reset in the next draw call. /// Request that the floating section window's size is reset in the next draw call.
/// </summary> /// </summary>
public void RequestResize() public void RequestResize()
{ {
this.resizeRequested = true; this.resizeRequested = true;
} }
   
#endregion #endregion
   
#region Methods: private #region Methods: private
   
/// <summary> /// <summary>
/// Initialises the object's state on creation. /// Initialises the object's state on creation.
/// </summary> /// </summary>
private void Start() private void Start()
{ {
this.windowId = this.GetHashCode(); this.windowId = this.GetHashCode();
this.InitialiseStyles(); this.InitialiseStyles();
RenderingManager.AddToPostDrawQueue(0, this.Draw); RenderingManager.AddToPostDrawQueue(0, this.Draw);
GuiDisplaySize.OnSizeChanged += this.OnSizeChanged; GuiDisplaySize.OnSizeChanged += this.OnSizeChanged;
} }
   
#endregion #endregion
} }
} }
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup> <PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{39806613-E0B7-46E0-89A6-A569EC538CBB}</ProjectGuid> <ProjectGuid>{39806613-E0B7-46E0-89A6-A569EC538CBB}</ProjectGuid>
<OutputType>Library</OutputType> <OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>KerbalEngineer</RootNamespace> <RootNamespace>KerbalEngineer</RootNamespace>
<AssemblyName>KerbalEngineer</AssemblyName> <AssemblyName>KerbalEngineer</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion> <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>false</DebugSymbols> <DebugSymbols>false</DebugSymbols>
<DebugType>none</DebugType> <DebugType>none</DebugType>
<Optimize>false</Optimize> <Optimize>false</Optimize>
<OutputPath>..\Output\KerbalEngineer\</OutputPath> <OutputPath>..\Output\KerbalEngineer\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants> <DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<UseVSHostingProcess>false</UseVSHostingProcess> <UseVSHostingProcess>false</UseVSHostingProcess>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>none</DebugType> <DebugType>none</DebugType>
<Optimize>true</Optimize> <Optimize>true</Optimize>
<OutputPath>..\Output\KerbalEngineer\</OutputPath> <OutputPath>..\Output\KerbalEngineer\</OutputPath>
<DefineConstants> <DefineConstants>
</DefineConstants> </DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<UseVSHostingProcess>false</UseVSHostingProcess> <UseVSHostingProcess>false</UseVSHostingProcess>
<AllowUnsafeBlocks>false</AllowUnsafeBlocks> <AllowUnsafeBlocks>false</AllowUnsafeBlocks>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Control\IControlPanel.cs" /> <Compile Include="Control\IControlPanel.cs" />
<Compile Include="Control\Panels\BuildOverlayPanel.cs" /> <Compile Include="Control\Panels\BuildOverlayPanel.cs" />
<Compile Include="Control\Panels\BuildEngineerPanel.cs" /> <Compile Include="Control\Panels\BuildEngineerPanel.cs" />
<Compile Include="Editor\BuildAdvanced.cs" /> <Compile Include="Editor\BuildAdvanced.cs" />
<Compile Include="Editor\BuildOverlay.cs" /> <Compile Include="Editor\BuildOverlay.cs" />
<Compile Include="CelestialBodies.cs" /> <Compile Include="CelestialBodies.cs" />
<Compile Include="Editor\BuildOverlayPartInfo.cs" /> <Compile Include="Editor\BuildOverlayPartInfo.cs" />
<Compile Include="Editor\BuildOverlayResources.cs" /> <Compile Include="Editor\BuildOverlayResources.cs" />
<Compile Include="Editor\BuildOverlayVessel.cs" /> <Compile Include="Editor\BuildOverlayVessel.cs" />
<Compile Include="Editor\BuildToolbar.cs" /> <Compile Include="Editor\BuildToolbar.cs" />
<Compile Include="Editor\PartInfoItem.cs" /> <Compile Include="Editor\PartInfoItem.cs" />
<Compile Include="Editor\ResourceInfoItem.cs" /> <Compile Include="Editor\ResourceInfoItem.cs" />
<Compile Include="Extensions\FloatExtensions.cs" /> <Compile Include="Extensions\FloatExtensions.cs" />
<Compile Include="Extensions\OrbitExtensions.cs" /> <Compile Include="Extensions\OrbitExtensions.cs" />
<Compile Include="Flight\ActionMenuGui.cs" /> <Compile Include="Flight\ActionMenuGui.cs" />
<Compile Include="Flight\FlightEngineerPartless.cs" /> <Compile Include="Flight\FlightEngineerPartless.cs" />
<Compile Include="Flight\Presets\Preset.cs" /> <Compile Include="Flight\Presets\Preset.cs" />
<Compile Include="Flight\Readouts\Miscellaneous\TimeReference.cs" /> <Compile Include="Flight\Readouts\Miscellaneous\TimeReference.cs" />
<Compile Include="Flight\Readouts\Miscellaneous\Separator.cs" /> <Compile Include="Flight\Readouts\Miscellaneous\Separator.cs" />
<Compile Include="Flight\Readouts\Miscellaneous\GuiSizeAdjustor.cs" /> <Compile Include="Flight\Readouts\Miscellaneous\GuiSizeAdjustor.cs" />
<Compile Include="Flight\Readouts\Orbital\AngleToEquatorialDescendingNode.cs" /> <Compile Include="Flight\Readouts\Orbital\AngleToEquatorialDescendingNode.cs" />
<Compile Include="Flight\Readouts\Orbital\AngleToEquatorialAscendingNode.cs" /> <Compile Include="Flight\Readouts\Orbital\AngleToEquatorialAscendingNode.cs" />
<Compile Include="Flight\Readouts\Orbital\AngleToRetrograde.cs" /> <Compile Include="Flight\Readouts\Orbital\AngleToRetrograde.cs" />
<Compile Include="Flight\Readouts\Orbital\AngleToPrograde.cs" /> <Compile Include="Flight\Readouts\Orbital\AngleToPrograde.cs" />
  <Compile Include="Flight\Readouts\Orbital\ManoeuvreNode\NodeRadialDeltaV.cs" />
  <Compile Include="Flight\Readouts\Orbital\ManoeuvreNode\ManoeuvreProcessor.cs" />
  <Compile Include="Flight\Readouts\Orbital\ManoeuvreNode\NodeTimeToHalfBurn.cs" />
  <Compile Include="Flight\Readouts\Orbital\ManoeuvreNode\NodeTimeToManoeuvre.cs" />
  <Compile Include="Flight\Readouts\Orbital\ManoeuvreNode\NodeHalfBurnTime.cs" />
  <Compile Include="Flight\Readouts\Orbital\ManoeuvreNode\NodeBurnTime.cs" />
  <Compile Include="Flight\Readouts\Orbital\ManoeuvreNode\NodeAngleToRetrograde.cs" />
  <Compile Include="Flight\Readouts\Orbital\ManoeuvreNode\NodeNormalDeltaV.cs" />
  <Compile Include="Flight\Readouts\Orbital\ManoeuvreNode\NodeAngleToPrograde.cs" />
  <Compile Include="Flight\Readouts\Orbital\ManoeuvreNode\NodeTotalDeltaV.cs" />
  <Compile Include="Flight\Readouts\Orbital\ManoeuvreNode\NodeProgradeDeltaV.cs" />
<Compile Include="Flight\Readouts\Orbital\MeanAnomaly.cs" /> <Compile Include="Flight\Readouts\Orbital\MeanAnomaly.cs" />
<Compile Include="Flight\Readouts\Orbital\EccentricAnomaly.cs" /> <Compile Include="Flight\Readouts\Orbital\EccentricAnomaly.cs" />
<Compile Include="Flight\Readouts\Orbital\ArgumentOfPeriapsis.cs" /> <Compile Include="Flight\Readouts\Orbital\ArgumentOfPeriapsis.cs" />
<Compile Include="Flight\Readouts\Orbital\CurrentSoi.cs" /> <Compile Include="Flight\Readouts\Orbital\CurrentSoi.cs" />
<Compile Include="Flight\Readouts\Orbital\TrueAnomaly.cs" /> <Compile Include="Flight\Readouts\Orbital\TrueAnomaly.cs" />
<Compile Include="Flight\Readouts\Orbital\TimeToEquatorialAscendingNode.cs" /> <Compile Include="Flight\Readouts\Orbital\TimeToEquatorialAscendingNode.cs" />
<Compile Include="Flight\Readouts\Orbital\TimeToEquatorialDescendingNode.cs" /> <Compile Include="Flight\Readouts\Orbital\TimeToEquatorialDescendingNode.cs" />
<Compile Include="Flight\Readouts\Rendezvous\RelativeSpeed.cs" /> <Compile Include="Flight\Readouts\Rendezvous\RelativeSpeed.cs" />
<Compile Include="Flight\Readouts\Rendezvous\RelativeVelocity.cs" /> <Compile Include="Flight\Readouts\Rendezvous\RelativeVelocity.cs" />
<Compile Include="Flight\Readouts\Rendezvous\SemiMinorAxis.cs" /> <Compile Include="Flight\Readouts\Rendezvous\SemiMinorAxis.cs" />
<Compile Include="Flight\Readouts\Rendezvous\SemiMajorAxis.cs" /> <Compile Include="Flight\Readouts\Rendezvous\SemiMajorAxis.cs" />
<Compile Include="Flight\Readouts\Rendezvous\TimeToRelativeDescendingNode.cs" /> <Compile Include="Flight\Readouts\Rendezvous\TimeToRelativeDescendingNode.cs" />
<Compile Include="Flight\Readouts\Rendezvous\TimeToRelativeAscendingNode.cs" /> <Compile Include="Flight\Readouts\Rendezvous\TimeToRelativeAscendingNode.cs" />
<Compile Include="Flight\Readouts\Surface\ImpactBiome.cs" /> <Compile Include="Flight\Readouts\Surface\ImpactBiome.cs" />
<Compile Include="Flight\Readouts\Surface\Slope.cs" /> <Compile Include="Flight\Readouts\Surface\Slope.cs" />
<Compile Include="Flight\Readouts\Surface\Biome.cs" /> <Compile Include="Flight\Readouts\Surface\Biome.cs" />
<Compile Include="Flight\Readouts\Surface\HorizontalAcceleration.cs" /> <Compile Include="Flight\Readouts\Surface\HorizontalAcceleration.cs" />
<Compile Include="Flight\Readouts\Surface\VerticalAcceleration.cs" /> <Compile Include="Flight\Readouts\Surface\VerticalAcceleration.cs" />
  <Compile Include="Flight\Readouts\Vessel\DeltaVCurrentTotal.cs" />
<Compile Include="Flight\Readouts\Vessel\SuicideBurnDeltaV.cs" /> <Compile Include="Flight\Readouts\Vessel\SuicideBurnDeltaV.cs" />
<Compile Include="Flight\Readouts\Vessel\SuicideBurnAltitude.cs" /> <Compile Include="Flight\Readouts\Vessel\SuicideBurnAltitude.cs" />
<Compile Include="Flight\Readouts\Vessel\SuicideBurnDistance.cs" /> <Compile Include="Flight\Readouts\Vessel\SuicideBurnDistance.cs" />
<Compile Include="Flight\Readouts\Vessel\DeltaVCurrent.cs" /> <Compile Include="Flight\Readouts\Vessel\DeltaVCurrent.cs" />
<Compile Include="Flight\Readouts\Vessel\IntakeAirUsage.cs" /> <Compile Include="Flight\Readouts\Vessel\IntakeAirUsage.cs" />
<Compile Include="Flight\Readouts\Vessel\IntakeAirDemandSupply.cs" /> <Compile Include="Flight\Readouts\Vessel\IntakeAirDemandSupply.cs" />
<Compile Include="Flight\Readouts\Vessel\IntakeAirSupply.cs" /> <Compile Include="Flight\Readouts\Vessel\IntakeAirSupply.cs" />
<Compile Include="Flight\Readouts\Vessel\IntakeAirDemand.cs" /> <Compile Include="Flight\Readouts\Vessel\IntakeAirDemand.cs" />
<Compile Include="Flight\Readouts\Miscellaneous\SimulationDelay.cs" /> <Compile Include="Flight\Readouts\Miscellaneous\SimulationDelay.cs" />
<Compile Include="Flight\Readouts\Vessel\SimulationProcessor.cs" /> <Compile Include="Flight\Readouts\Vessel\SimulationProcessor.cs" />
<Compile Include="Flight\Readouts\Vessel\Acceleration.cs" /> <Compile Include="Flight\Readouts\Vessel\Acceleration.cs" />
<Compile Include="Flight\Presets\PresetLibrary.cs" /> <Compile Include="Flight\Presets\PresetLibrary.cs" />
<Compile Include="Flight\Readouts\Vessel\SuicideBurnProcessor.cs" /> <Compile Include="Flight\Readouts\Vessel\SuicideBurnProcessor.cs" />
<Compile Include="Flight\Readouts\Vessel\SurfaceThrustToWeight.cs" /> <Compile Include="Flight\Readouts\Vessel\SurfaceThrustToWeight.cs" />
  <Compile Include="Flight\Readouts\Surface\Situation.cs" />
<Compile Include="GuiDisplaySize.cs" /> <Compile Include="GuiDisplaySize.cs" />
<Compile Include="Helpers\AngleHelper.cs" /> <Compile Include="Helpers\AngleHelper.cs" />
<Compile Include="Helpers\TextureHelper.cs" /> <Compile Include="Helpers\TextureHelper.cs" />
<Compile Include="Helpers\Units.cs" /> <Compile Include="Helpers\Units.cs" />
<Compile Include="Helpers\TimeFormatter.cs" /> <Compile Include="Helpers\TimeFormatter.cs" />
<Compile Include="KeyBinder.cs" /> <Compile Include="KeyBinder.cs" />
<Compile Include="Control\ControlCentre.cs" /> <Compile Include="Control\ControlCentre.cs" />
<Compile Include="UIControls\DropDown.cs" /> <Compile Include="UIControls\DropDown.cs" />
<Compile Include="Logger.cs" /> <Compile Include="Logger.cs" />
<Compile Include="EngineerGlobals.cs" /> <Compile Include="EngineerGlobals.cs" />
<Compile Include="Extensions\DoubleExtensions.cs" /> <Compile Include="Extensions\DoubleExtensions.cs" />
<Compile Include="Extensions\PartExtensions.cs" /> <Compile Include="Extensions\PartExtensions.cs" />
<Compile Include="Extensions\PartResourceExtensions.cs" /> <Compile Include="Extensions\PartResourceExtensions.cs" />
<Compile Include="Extensions\RectExtensions.cs" /> <Compile Include="Extensions\RectExtensions.cs" />
<Compile Include="Flight\ActionMenu.cs" /> <Compile Include="Flight\ActionMenu.cs" />
<Compile Include="Flight\DisplayStack.cs" /> <Compile Include="Flight\DisplayStack.cs" />
<Compile Include="Flight\FlightEngineerCore.cs" /> <Compile Include="Flight\FlightEngineerCore.cs" />
<Compile Include="Flight\FlightEngineerModule.cs" /> <Compile Include="Flight\FlightEngineerModule.cs" />
<Compile Include="Flight\IUpdatable.cs" /> <Compile Include="Flight\IUpdatable.cs" />
<Compile Include="Flight\IUpdateRequest.cs" /> <Compile Include="Flight\IUpdateRequest.cs" />
<Compile Include="Flight\Readouts\Orbital\ApoapsisHeight.cs" /> <Compile Include="Flight\Readouts\Orbital\ApoapsisHeight.cs" />
<Compile Include="Flight\Readouts\Orbital\Eccentricity.cs" /> <Compile Include="Flight\Readouts\Orbital\Eccentricity.cs" />
<Compile Include="Flight\Readouts\Orbital\Inclination.cs" /> <Compile Include="Flight\Readouts\Orbital\Inclination.cs" />
<Compile Include="Flight\Readouts\Orbital\LongitudeOfAscendingNode.cs" /> <Compile Include="Flight\Readouts\Orbital\LongitudeOfAscendingNode.cs" />
<Compile Include="Flight\Readouts\Orbital\LongitudeOfPeriapsis.cs" /> <Compile Include="Flight\Readouts\Orbital\LongitudeOfPeriapsis.cs" />
<Compile Include="Flight\Readouts\Orbital\OrbitalPeriod.cs" /> <Compile Include="Flight\Readouts\Orbital\OrbitalPeriod.cs" />
<Compile Include="Flight\Readouts\Orbital\OrbitalSpeed.cs" /> <Compile Include="Flight\Readouts\Orbital\OrbitalSpeed.cs" />
<Compile Include="Flight\Readouts\Orbital\PeriapsisHeight.cs" /> <Compile Include="Flight\Readouts\Orbital\PeriapsisHeight.cs" />
<Compile Include="Flight\Readouts\Orbital\SemiMajorAxis.cs" /> <Compile Include="Flight\Readouts\Orbital\SemiMajorAxis.cs" />
<Compile Include="Flight\Readouts\Orbital\SemiMinorAxis.cs" /> <Compile Include="Flight\Readouts\Orbital\SemiMinorAxis.cs" />
<Compile Include="Flight\Readouts\Orbital\TimeToApoapsis.cs" /> <Compile Include="Flight\Readouts\Orbital\TimeToApoapsis.cs" />
<Compile Include="Flight\Readouts\Orbital\TimeToPeriapsis.cs" /> <Compile Include="Flight\Readouts\Orbital\TimeToPeriapsis.cs" />
<Compile Include="Flight\Readouts\ReadoutCategory.cs" /> <Compile Include="Flight\Readouts\ReadoutCategory.cs" />
<Compile Include="Flight\Readouts\ReadoutLibrary.cs" /> <Compile Include="Flight\Readouts\ReadoutLibrary.cs" />
<Compile Include="Flight\Readouts\ReadoutModule.cs" /> <Compile Include="Flight\Readouts\ReadoutModule.cs" />
<Compile Include="Flight\Readouts\Rendezvous\TimeToPeriapsis.cs" /> <Compile Include="Flight\Readouts\Rendezvous\TimeToPeriapsis.cs" />
<Compile Include="Flight\Readouts\Rendezvous\TimeToApoapsis.cs" /> <Compile Include="Flight\Readouts\Rendezvous\TimeToApoapsis.cs" />
<Compile Include="Flight\Readouts\Rendezvous\PeriapsisHeight.cs" /> <Compile Include="Flight\Readouts\Rendezvous\PeriapsisHeight.cs" />
<Compile Include="Flight\Readouts\Rendezvous\ApoapsisHeight.cs" /> <Compile Include="Flight\Readouts\Rendezvous\ApoapsisHeight.cs" />
<Compile Include="Flight\Readouts\Rendezvous\InterceptAngle.cs" /> <Compile Include="Flight\Readouts\Rendezvous\InterceptAngle.cs" />
<Compile Include="Flight\Readouts\Rendezvous\OrbitalPeriod.cs" /> <Compile Include="Flight\Readouts\Rendezvous\OrbitalPeriod.cs" />
<Compile Include="Flight\Readouts\Rendezvous\Distance.cs" /> <Compile Include="Flight\Readouts\Rendezvous\Distance.cs" />
<Compile Include="Flight\Readouts\Rendezvous\AltitudeSeaLevel.cs" /> <Compile Include="Flight\Readouts\Rendezvous\AltitudeSeaLevel.cs" />
<Compile Include="Flight\Readouts\Rendezvous\AngleToRelativeDescendingNode.cs" /> <Compile Include="Flight\Readouts\Rendezvous\AngleToRelativeDescendingNode.cs" />
<Compile Include="Flight\Readouts\Rendezvous\AngleToRelativeAscendingNode.cs" /> <Compile Include="Flight\Readouts\Rendezvous\AngleToRelativeAscendingNode.cs" />
<Compile Include="Flight\Readouts\Rendezvous\PhaseAngle.cs" /> <Compile Include="Flight\Readouts\Rendezvous\PhaseAngle.cs" />
<Compile Include="Flight\Readouts\Rendezvous\RelativeInclination.cs" /> <Compile Include="Flight\Readouts\Rendezvous\RelativeInclination.cs" />
<Compile Include="Flight\Readouts\Rendezvous\RendezvousProcessor.cs" /> <Compile Include="Flight\Readouts\Rendezvous\RendezvousProcessor.cs" />
<Compile Include="Flight\Readouts\Rendezvous\TargetSelector.cs" /> <Compile Include="Flight\Readouts\Rendezvous\TargetSelector.cs" />
<Compile Include="Flight\Readouts\Surface\AltitudeSeaLevel.cs" /> <Compile Include="Flight\Readouts\Surface\AltitudeSeaLevel.cs" />
<Compile Include="Flight\Readouts\Surface\AltitudeTerrain.cs" /> <Compile Include="Flight\Readouts\Surface\AltitudeTerrain.cs" />
<Compile Include="Flight\Readouts\Surface\ImpactLatitude.cs" /> <Compile Include="Flight\Readouts\Surface\ImpactLatitude.cs" />
<Compile Include="Flight\Readouts\Surface\ImpactAltitude.cs" /> <Compile Include="Flight\Readouts\Surface\ImpactAltitude.cs" />
<Compile Include="Flight\Readouts\Surface\ImpactLongitude.cs" /> <Compile Include="Flight\Readouts\Surface\ImpactLongitude.cs" />
<Compile Include="Flight\Readouts\Surface\ImpactTime.cs" /> <Compile Include="Flight\Readouts\Surface\ImpactTime.cs" />
<Compile Include="Flight\Readouts\Surface\AtmosphericProcessor.cs" /> <Compile Include="Flight\Readouts\Surface\AtmosphericProcessor.cs" />
<Compile Include="Flight\Readouts\Surface\AtmosphericEfficiency.cs" /> <Compile Include="Flight\Readouts\Surface\AtmosphericEfficiency.cs" />
<Compile Include="Flight\Readouts\Surface\GeeForce.cs" /> <Compile Include="Flight\Readouts\Surface\GeeForce.cs" />
<Compile Include="Flight\Readouts\Surface\HorizontalSpeed.cs" /> <Compile Include="Flight\Readouts\Surface\HorizontalSpeed.cs" />
<Compile Include="Flight\Readouts\Surface\ImpactProcessor.cs" /> <Compile Include="Flight\Readouts\Surface\ImpactProcessor.cs" />
<Compile Include="Flight\Readouts\Surface\Latitude.cs" /> <Compile Include="Flight\Readouts\Surface\Latitude.cs" />
<Compile Include="Flight\Readouts\Surface\Longitude.cs" /> <Compile Include="Flight\Readouts\Surface\Longitude.cs" />
<Compile Include="Flight\Readouts\Surface\TerminalVelocity.cs" /> <Compile Include="Flight\Readouts\Surface\TerminalVelocity.cs" />
<Compile Include="Flight\Readouts\Surface\VerticalSpeed.cs" /> <Compile Include="Flight\Readouts\Surface\VerticalSpeed.cs" />
<Compile Include="Flight\Readouts\Vessel\DeltaVStaged.cs" /> <Compile Include="Flight\Readouts\Vessel\DeltaVStaged.cs" />
<Compile Include="Flight\Readouts\Vessel\DeltaVTotal.cs" /> <Compile Include="Flight\Readouts\Vessel\DeltaVTotal.cs" />
<Compile Include="Flight\Readouts\Vessel\Mass.cs" /> <Compile Include="Flight\Readouts\Vessel\Mass.cs" />
<Compile Include="Flight\Readouts\Vessel\Thrust.cs" /> <Compile Include="Flight\Readouts\Vessel\Thrust.cs" />
<Compile Include="Flight\Readouts\Vessel\SpecificImpulse.cs" /> <Compile Include="Flight\Readouts\Vessel\SpecificImpulse.cs" />
<Compile Include="Flight\Readouts\Vessel\ThrustToWeight.cs" /> <Compile Include="Flight\Readouts\Vessel\ThrustToWeight.cs" />
<Compile Include="Flight\Sections\SectionEditor.cs" /> <Compile Include="Flight\Sections\SectionEditor.cs" />
<Compile Include="Flight\Sections\SectionLibrary.cs" /> <Compile Include="Flight\Sections\SectionLibrary.cs" />
<Compile Include="Flight\Sections\SectionModule.cs" /> <Compile Include="Flight\Sections\SectionModule.cs" />
<Compile Include="Flight\Sections\SectionWindow.cs" /> <Compile Include="Flight\Sections\SectionWindow.cs" />
<Compile Include="LogMsg.cs" /> <Compile Include="LogMsg.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Settings\SettingHandler.cs" /> <Compile Include="Settings\SettingHandler.cs" />
<Compile Include="Settings\SettingItem.cs" /> <Compile Include="Settings\SettingItem.cs" />
<Compile Include="TapeDriveAnimator.cs" /> <Compile Include="TapeDriveAnimator.cs" />
<Compile Include="UIControls\WindowObject.cs" /> <Compile Include="UIControls\WindowObject.cs" />
<Compile Include="VesselSimulator\AttachNodeSim.cs" /> <Compile Include="VesselSimulator\AttachNodeSim.cs" />
<Compile Include="VesselSimulator\EngineSim.cs" /> <Compile Include="VesselSimulator\EngineSim.cs" />
<Compile Include="VesselSimulator\PartSim.cs" /> <Compile Include="VesselSimulator\PartSim.cs" />
<Compile Include="VesselSimulator\ResourceContainer.cs" /> <Compile Include="VesselSimulator\ResourceContainer.cs" />
<Compile Include="VesselSimulator\SimManager.cs" /> <Compile Include="VesselSimulator\SimManager.cs" />
<Compile Include="VesselSimulator\Simulation.cs" /> <Compile Include="VesselSimulator\Simulation.cs" />
<Compile Include="VesselSimulator\Stage.cs" /> <Compile Include="VesselSimulator\Stage.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Reference Include="Assembly-CSharp"> <Reference Include="Assembly-CSharp">
<HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\SteamApps\common\Kerbal Space Program\KSP_Data\Managed\Assembly-CSharp.dll</HintPath> <HintPath>..\Game\KSP_Data\Managed\Assembly-CSharp.dll</HintPath>
<Private>False</Private> <Private>False</Private>
</Reference> </Reference>
<Reference Include="System"> <Reference Include="System">
<HintPath>..\Game\KSP_Data\Managed\System.dll</HintPath> <HintPath>..\Game\KSP_Data\Managed\System.dll</HintPath>
<Private>False</Private> <Private>False</Private>
</Reference> </Reference>
<Reference Include="System.Xml"> <Reference Include="System.Xml">
<HintPath>..\Game\KSP_Data\Managed\System.Xml.dll</HintPath> <HintPath>..\Game\KSP_Data\Managed\System.Xml.dll</HintPath>
<Private>False</Private> <Private>False</Private>
</Reference> </Reference>
<Reference Include="UnityEngine"> <Reference Include="UnityEngine">
<HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\SteamApps\common\Kerbal Space Program\KSP_Data\Managed\UnityEngine.dll</HintPath> <HintPath>..\Game\KSP_Data\Managed\UnityEngine.dll</HintPath>
<Private>False</Private> <Private>False</Private>
</Reference> </Reference>
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="PostBuildMacros"> <Target Name="PostBuildMacros">
<GetAssemblyIdentity AssemblyFiles="$(TargetPath)"> <GetAssemblyIdentity AssemblyFiles="$(TargetPath)">
<Output TaskParameter="Assemblies" ItemName="Targets" /> <Output TaskParameter="Assemblies" ItemName="Targets" />
</GetAssemblyIdentity> </GetAssemblyIdentity>
<ItemGroup> <ItemGroup>
<VersionNumber Include="@(Targets->'%(Version)')" /> <VersionNumber Include="@(Targets->'%(Version)')" />
</ItemGroup> </ItemGroup>
</Target> </Target>
<PropertyGroup> <PropertyGroup>
<PostBuildEventDependsOn> <PostBuildEventDependsOn>
$(PostBuildEventDependsOn); $(PostBuildEventDependsOn);
PostBuildMacros; PostBuildMacros;
</PostBuildEventDependsOn> </PostBuildEventDependsOn>
<PostBuildEvent>xcopy "$(SolutionDir)Output\*" "$(SolutionDir)Game\GameData\*" /E /Y <PostBuildEvent>xcopy "$(SolutionDir)Output\*" "$(SolutionDir)Game\GameData\*" /E /Y
del "$(SolutionDir)Release\*" /Q del "$(SolutionDir)Release\*" /Q
xcopy "$(SolutionDir)Documents\*" "$(SolutionDir)Release\Documents\*" /E /Y xcopy "$(SolutionDir)Documents\*" "$(SolutionDir)Release\Documents\*" /E /Y
7z.exe a -tzip -mx3 "$(SolutionDir)Release\$(ProjectName)-@(VersionNumber).zip" "$(SolutionDir)Output\*" 7z.exe a -tzip -mx3 "$(SolutionDir)Release\$(ProjectName)-@(VersionNumber).zip" "$(SolutionDir)Output\*"
7z.exe a -tzip -mx3 "$(SolutionDir)Release\$(ProjectName)-@(VersionNumber).zip" "$(SolutionDir)Documents\*"</PostBuildEvent> 7z.exe a -tzip -mx3 "$(SolutionDir)Release\$(ProjectName)-@(VersionNumber).zip" "$(SolutionDir)Documents\*"</PostBuildEvent>
</PropertyGroup> </PropertyGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets. Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild"> <Target Name="BeforeBuild">
</Target> </Target>
<Target Name="AfterBuild"> <Target Name="AfterBuild">
</Target> </Target>
--> -->
</Project> </Project>
// //
// Kerbal Engineer Redux // Kerbal Engineer Redux
// //
// Copyright (C) 2014 CYBUTEK // Copyright (C) 2014 CYBUTEK
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
// //
   
#region Using Directives #region Using Directives
   
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
   
using KerbalEngineer.Extensions; using KerbalEngineer.Extensions;
   
using UnityEngine; using UnityEngine;
   
#endregion #endregion
   
namespace KerbalEngineer.VesselSimulator namespace KerbalEngineer.VesselSimulator
{ {
public class PartSim public class PartSim
{ {
private readonly List<AttachNodeSim> attachNodes = new List<AttachNodeSim>(); private readonly List<AttachNodeSim> attachNodes = new List<AttachNodeSim>();
public double baseMass = 0d; public double baseMass = 0d;
public double cost; public double cost;
public int decoupledInStage; public int decoupledInStage;
public bool fuelCrossFeed; public bool fuelCrossFeed;
public List<PartSim> fuelTargets = new List<PartSim>(); public List<PartSim> fuelTargets = new List<PartSim>();
public bool hasModuleEngines; public bool hasModuleEngines;
public bool hasModuleEnginesFX; public bool hasModuleEnginesFX;
public bool hasMultiModeEngine; public bool hasMultiModeEngine;
   
public bool hasVessel; public bool hasVessel;
public String initialVesselName; public String initialVesselName;
public int inverseStage; public int inverseStage;
public bool isDecoupler; public bool isDecoupler;
public bool isEngine; public bool isEngine;
public bool isFuelLine; public bool isFuelLine;
public bool isFuelTank; public bool isFuelTank;
public bool isLanded; public bool isLanded;
public bool isNoPhysics; public bool isNoPhysics;
public bool isSepratron; public bool isSepratron;
public bool localCorrectThrust; public bool localCorrectThrust;
public String name; public String name;
public String noCrossFeedNodeKey; public String noCrossFeedNodeKey;
public PartSim parent; public PartSim parent;
public AttachModes parentAttach; public AttachModes parentAttach;
public Part part; // This is only set while the data structures are being initialised public Part part; // This is only set while the data structures are being initialised
public int partId = 0; public int partId = 0;
public ResourceContainer resourceDrains = new ResourceContainer(); public ResourceContainer resourceDrains = new ResourceContainer();
public ResourceContainer resourceFlowStates = new ResourceContainer(); public ResourceContainer resourceFlowStates = new ResourceContainer();
public ResourceContainer resources = new ResourceContainer(); public ResourceContainer resources = new ResourceContainer();
public double startMass = 0d; public double startMass = 0d;
public String vesselName; public String vesselName;
public VesselType vesselType; public VesselType vesselType;
   
public PartSim(Part thePart, int id, double atmosphere, LogMsg log) public PartSim(Part thePart, int id, double atmosphere, LogMsg log)
{ {
this.part = thePart; this.part = thePart;
this.partId = id; this.partId = id;
this.name = this.part.partInfo.name; this.name = this.part.partInfo.name;
   
if (log != null) if (log != null)
{ {
log.buf.AppendLine("Create PartSim for " + this.name); log.buf.AppendLine("Create PartSim for " + this.name);
} }
   
this.parent = null; this.parent = null;
this.parentAttach = part.attachMode; this.parentAttach = part.attachMode;
this.fuelCrossFeed = this.part.fuelCrossFeed; this.fuelCrossFeed = this.part.fuelCrossFeed;
this.noCrossFeedNodeKey = this.part.NoCrossFeedNodeKey; this.noCrossFeedNodeKey = this.part.NoCrossFeedNodeKey;
this.decoupledInStage = this.DecoupledInStage(this.part); this.decoupledInStage = this.DecoupledInStage(this.part);
this.isFuelLine = this.part is FuelLine; this.isFuelLine = this.part is FuelLine;
this.isFuelTank = this.part is FuelTank; this.isFuelTank = this.part is FuelTank;
this.isSepratron = this.IsSepratron(); this.isSepratron = this.IsSepratron();
this.inverseStage = this.part.inverseStage; this.inverseStage = this.part.inverseStage;
//MonoBehaviour.print("inverseStage = " + inverseStage); //MonoBehaviour.print("inverseStage = " + inverseStage);
   
this.cost = this.part.GetCostWet(); this.cost = this.part.GetCostWet();
   
// Work out if the part should have no physical significance // Work out if the part should have no physical significance
this.isNoPhysics = this.part.HasModule<LaunchClamp>() || this.isNoPhysics = this.part.HasModule<LaunchClamp>() ||
this.part.physicalSignificance == Part.PhysicalSignificance.NONE || this.part.physicalSignificance == Part.PhysicalSignificance.NONE ||
this.part.PhysicsSignificance == 1; this.part.PhysicsSignificance == 1;
   
if (!this.isNoPhysics) if (!this.isNoPhysics)
{ {
this.baseMass = this.part.mass; this.baseMass = this.part.mass;
} }
   
if (SimManager.logOutput) if (SimManager.logOutput)
{ {
MonoBehaviour.print((this.isNoPhysics ? "Ignoring" : "Using") + " part.mass of " + this.part.mass); MonoBehaviour.print((this.isNoPhysics ? "Ignoring" : "Using") + " part.mass of " + this.part.mass);
} }
   
foreach (PartResource resource in this.part.Resources) foreach (PartResource resource in this.part.Resources)
{ {
// Make sure it isn't NaN as this messes up the part mass and hence most of the values // Make sure it isn't NaN as this messes up the part mass and hence most of the values
// This can happen if a resource capacity is 0 and tweakable // This can happen if a resource capacity is 0 and tweakable
if (!Double.IsNaN(resource.amount)) if (!Double.IsNaN(resource.amount))
{ {
if (SimManager.logOutput) if (SimManager.logOutput)
{ {
MonoBehaviour.print(resource.resourceName + " = " + resource.amount); MonoBehaviour.print(resource.resourceName + " = " + resource.amount);
} }
   
this.resources.Add(resource.info.id, resource.amount); this.resources.Add(resource.info.id, resource.amount);
this.resourceFlowStates.Add(resource.info.id, resource.flowState ? 1 : 0); this.resourceFlowStates.Add(resource.info.id, resource.flowState ? 1 : 0);
} }
else else
{ {
MonoBehaviour.print(resource.resourceName + " is NaN. Skipping."); MonoBehaviour.print(resource.resourceName + " is NaN. Skipping.");
} }
} }
   
this.startMass = this.GetMass(); this.startMass = this.GetMass();
   
this.hasVessel = (this.part.vessel != null); this.hasVessel = (this.part.vessel != null);
this.isLanded = this.hasVessel && this.part.vessel.Landed; this.isLanded = this.hasVessel && this.part.vessel.Landed;
if (this.hasVessel) if (this.hasVessel)
{ {
this.vesselName = this.part.vessel.vesselName; this.vesselName = this.part.vessel.vesselName;
this.vesselType = this.part.vesselType; this.vesselType = this.part.vesselType;
} }
this.initialVesselName = this.part.initialVesselName; this.initialVesselName = this.part.initialVesselName;
   
this.hasMultiModeEngine = this.part.HasModule<MultiModeEngine>(); this.hasMultiModeEngine = this.part.HasModule<MultiModeEngine>();
this.hasModuleEnginesFX = this.part.HasModule<ModuleEnginesFX>(); this.hasModuleEnginesFX = this.part.HasModule<ModuleEnginesFX>();
this.hasModuleEngines = this.part.HasModule<ModuleEngines>(); this.hasModuleEngines = this.part.HasModule<ModuleEngines>();
   
this.isEngine = this.hasMultiModeEngine || this.hasModuleEnginesFX || this.hasModuleEngines; this.isEngine = this.hasMultiModeEngine || this.hasModuleEnginesFX || this.hasModuleEngines;
   
if (SimManager.logOutput) if (SimManager.logOutput)
{ {
MonoBehaviour.print("Created " + this.name + ". Decoupled in stage " + this.decoupledInStage); MonoBehaviour.print("Created " + this.name + ". Decoupled in stage " + this.decoupledInStage);
} }
} }
   
public ResourceContainer Resources public ResourceContainer Resources
{ {
get { return this.resources; } get { return this.resources; }
} }
   
public ResourceContainer ResourceDrains public ResourceContainer ResourceDrains
{ {
get { return this.resourceDrains; } get { return this.resourceDrains; }
} }
   
public void CreateEngineSims(List<EngineSim> allEngines, double atmosphere, double velocity, bool vectoredThrust, LogMsg log) public void CreateEngineSims(List<EngineSim> allEngines, double atmosphere, double velocity, bool vectoredThrust, LogMsg log)
{ {
bool correctThrust = SimManager.DoesEngineUseCorrectedThrust(this.part); bool correctThrust = SimManager.DoesEngineUseCorrectedThrust(this.part);
if (log != null) if (log != null)
{ {
log.buf.AppendLine("CreateEngineSims for " + this.name); log.buf.AppendLine("CreateEngineSims for " + this.name);
   
foreach (PartModule partMod in this.part.Modules) foreach (PartModule partMod in this.part.Modules)
{ {
log.buf.AppendLine("Module: " + partMod.moduleName); log.buf.AppendLine("Module: " + partMod.moduleName);
} }
   
log.buf.AppendLine("correctThrust = " + correctThrust); log.buf.AppendLine("correctThrust = " + correctThrust);
} }
   
if (this.hasMultiModeEngine) if (this.hasMultiModeEngine)
{ {
// A multi-mode engine has multiple ModuleEnginesFX but only one is active at any point // A multi-mode engine has multiple ModuleEnginesFX but only one is active at any point
// The mode of the engine is the engineID of the ModuleEnginesFX that is active // The mode of the engine is the engineID of the ModuleEnginesFX that is active
string mode = this.part.GetModule<MultiModeEngine>().mode; string mode = this.part.GetModule<MultiModeEngine>().mode;
   
foreach (ModuleEnginesFX engine in this.part.GetModules<ModuleEnginesFX>()) foreach (ModuleEnginesFX engine in this.part.GetModules<ModuleEnginesFX>())
{ {
if (engine.engineID == mode) if (engine.engineID == mode)
{ {
if (log != null) if (log != null)
{ {
log.buf.AppendLine("Module: " + engine.moduleName); log.buf.AppendLine("Module: " + engine.moduleName);
} }
   
Vector3 thrustvec = this.CalculateThrustVector(vectoredThrust ? engine.thrustTransforms : null, log); Vector3 thrustvec = this.CalculateThrustVector(vectoredThrust ? engine.thrustTransforms : null, log);
   
EngineSim engineSim = new EngineSim(this, EngineSim engineSim = new EngineSim(this,
atmosphere, atmosphere,
velocity, velocity,
engine.maxThrust, engine.maxThrust,
engine.minThrust, engine.minThrust,
engine.thrustPercentage, engine.thrustPercentage,
engine.requestedThrust, engine.requestedThrust,
thrustvec, thrustvec,
engine.realIsp, engine.realIsp,
engine.atmosphereCurve, engine.atmosphereCurve,
engine.useVelocityCurve ? engine.velocityCurve : null, engine.useVelocityCurve ? engine.velocityCurve : null,
engine.throttleLocked, engine.throttleLocked,
engine.propellants, engine.propellants,
engine.isOperational, engine.isOperational,
correctThrust); correctThrust);
allEngines.Add(engineSim); allEngines.Add(engineSim);
} }
} }
} }
else else
{ {
if (this.hasModuleEnginesFX) if (this.hasModuleEnginesFX)
{ {
foreach (ModuleEnginesFX engine in this.part.GetModules<ModuleEnginesFX>()) foreach (ModuleEnginesFX engine in this.part.GetModules<ModuleEnginesFX>())
{ {
if (log != null) if (log != null)
{ {
log.buf.AppendLine("Module: " + engine.moduleName); log.buf.AppendLine("Module: " + engine.moduleName);
} }
   
Vector3 thrustvec = this.CalculateThrustVector(vectoredThrust ? engine.thrustTransforms : null, log); Vector3 thrustvec = this.CalculateThrustVector(vectoredThrust ? engine.thrustTransforms : null, log);
   
EngineSim engineSim = new EngineSim(this, EngineSim engineSim = new EngineSim(this,
atmosphere, atmosphere,
velocity, velocity,
engine.maxThrust, engine.maxThrust,
engine.minThrust, engine.minThrust,
engine.thrustPercentage, engine.thrustPercentage,
engine.requestedThrust, engine.requestedThrust,
thrustvec, thrustvec,
engine.realIsp, engine.realIsp,
engine.atmosphereCurve, engine.atmosphereCurve,
engine.useVelocityCurve ? engine.velocityCurve : null, engine.useVelocityCurve ? engine.velocityCurve : null,
engine.throttleLocked, engine.throttleLocked,
engine.propellants, engine.propellants,
engine.isOperational, engine.isOperational,
correctThrust); correctThrust);
allEngines.Add(engineSim); allEngines.Add(engineSim);
} }
} }
   
if (this.hasModuleEngines) if (this.hasModuleEngines)
{ {
foreach (ModuleEngines engine in this.part.GetModules<ModuleEngines>()) foreach (ModuleEngines engine in this.part.GetModules<ModuleEngines>())
{ {
if (log != null) if (log != null)
{ {
log.buf.AppendLine("Module: " + engine.moduleName); log.buf.AppendLine("Module: " + engine.moduleName);
} }
   
Vector3 thrustvec = this.CalculateThrustVector(vectoredThrust ? engine.thrustTransforms : null, log); Vector3 thrustvec = this.CalculateThrustVector(vectoredThrust ? engine.thrustTransforms : null, log);
   
EngineSim engineSim = new EngineSim(this, EngineSim engineSim = new EngineSim(this,
atmosphere, atmosphere,
velocity, velocity,
engine.maxThrust, engine.maxThrust,
engine.minThrust, engine.minThrust,
engine.thrustPercentage, engine.thrustPercentage,
engine.requestedThrust, engine.requestedThrust,
thrustvec, thrustvec,
engine.realIsp, engine.realIsp,
engine.atmosphereCurve, engine.atmosphereCurve,
engine.useVelocityCurve ? engine.velocityCurve : null, engine.useVelocityCurve ? engine.velocityCurve : null,
engine.throttleLocked, engine.throttleLocked,
engine.propellants, engine.propellants,
engine.isOperational, engine.isOperational,
correctThrust); correctThrust);
allEngines.Add(engineSim); allEngines.Add(engineSim);
} }
} }
} }
   
if (log != null) if (log != null)
{ {
log.Flush(); log.Flush();
} }
} }
   
private Vector3 CalculateThrustVector(List<Transform> thrustTransforms, LogMsg log) private Vector3 CalculateThrustVector(List<Transform> thrustTransforms, LogMsg log)
{ {
if (thrustTransforms == null) if (thrustTransforms == null)
{ {
return Vector3.forward; return Vector3.forward;
} }
   
Vector3 thrustvec = Vector3.zero; Vector3 thrustvec = Vector3.zero;
foreach (Transform trans in thrustTransforms) foreach (Transform trans in thrustTransforms)
{ {
if (log != null) if (log != null)
{ {
log.buf.AppendFormat("Transform = ({0:g6}, {1:g6}, {2:g6}) length = {3:g6}\n", trans.forward.x, trans.forward.y, trans.forward.z, trans.forward.magnitude); log.buf.AppendFormat("Transform = ({0:g6}, {1:g6}, {2:g6}) length = {3:g6}\n", trans.forward.x, trans.forward.y, trans.forward.z, trans.forward.magnitude);
} }
   
thrustvec -= trans.forward; thrustvec -= trans.forward;
} }
   
if (log != null) if (log != null)
{ {
log.buf.AppendFormat("ThrustVec = ({0:g6}, {1:g6}, {2:g6}) length = {3:g6}\n", thrustvec.x, thrustvec.y, thrustvec.z, thrustvec.magnitude); log.buf.AppendFormat("ThrustVec = ({0:g6}, {1:g6}, {2:g6}) length = {3:g6}\n", thrustvec.x, thrustvec.y, thrustvec.z, thrustvec.magnitude);
} }
   
thrustvec.Normalize(); thrustvec.Normalize();
   
if (log != null) if (log != null)
{ {
log.buf.AppendFormat("ThrustVecN = ({0:g6}, {1:g6}, {2:g6}) length = {3:g6}\n", thrustvec.x, thrustvec.y, thrustvec.z, thrustvec.magnitude); log.buf.AppendFormat("ThrustVecN = ({0:g6}, {1:g6}, {2:g6}) length = {3:g6}\n", thrustvec.x, thrustvec.y, thrustvec.z, thrustvec.magnitude);
} }
   
return thrustvec; return thrustvec;
} }
   
public void SetupParent(Dictionary<Part, PartSim> partSimLookup, LogMsg log) public void SetupParent(Dictionary<Part, PartSim> partSimLookup, LogMsg log)
{ {
if (this.part.parent != null) if (this.part.parent != null)
{ {
this.parent = null; this.parent = null;
if (partSimLookup.TryGetValue(this.part.parent, out this.parent)) if (partSimLookup.TryGetValue(this.part.parent, out this.parent))
{ {
if (log != null) if (log != null)
{ {
log.buf.AppendLine("Parent part is " + this.parent.name + ":" + this.parent.partId); log.buf.AppendLine("Parent part is " + this.parent.name + ":" + this.parent.partId);
} }
} }
else else
{ {
if (log != null) if (log != null)
{ {
log.buf.AppendLine("No PartSim for parent part (" + this.part.parent.partInfo.name + ")"); log.buf.AppendLine("No PartSim for parent part (" + this.part.parent.partInfo.name + ")");
} }
} }
} }
} }
   
public void SetupAttachNodes(Dictionary<Part, PartSim> partSimLookup, LogMsg log) public void SetupAttachNodes(Dictionary<Part, PartSim> partSimLookup, LogMsg log)
{ {
if (log != null) if (log != null)
{ {
log.buf.AppendLine("SetupAttachNodes for " + this.name + ":" + this.partId + ""); log.buf.AppendLine("SetupAttachNodes for " + this.name + ":" + this.partId + "");
} }
   
this.attachNodes.Clear(); this.attachNodes.Clear();
foreach (AttachNode attachNode in this.part.attachNodes) foreach (AttachNode attachNode in this.part.attachNodes)
{ {
if (log != null) if (log != null)
{ {
log.buf.AppendLine("AttachNode " + attachNode.id + " = " + (attachNode.attachedPart != null ? attachNode.attachedPart.partInfo.name : "null")); log.buf.AppendLine("AttachNode " + attachNode.id + " = " + (attachNode.attachedPart != null ? attachNode.attachedPart.partInfo.name : "null"));
} }
   
if (attachNode.attachedPart != null && attachNode.id != "Strut") if (attachNode.attachedPart != null && attachNode.id != "Strut")
{ {
PartSim attachedSim; PartSim attachedSim;
if (partSimLookup.TryGetValue(attachNode.attachedPart, out attachedSim)) if (partSimLookup.TryGetValue(attachNode.attachedPart, out attachedSim))
{ {
if (log != null) if (log != null)
{ {
log.buf.AppendLine("Adding attached node " + attachedSim.name + ":" + attachedSim.partId + ""); log.buf.AppendLine("Adding attached node " + attachedSim.name + ":" + attachedSim.partId + "");
} }
   
this.attachNodes.Add(new AttachNodeSim(attachedSim, attachNode.id, attachNode.nodeType)); this.attachNodes.Add(new AttachNodeSim(attachedSim, attachNode.id, attachNode.nodeType));
} }
else else
{ {
if (log != null) if (log != null)
{ {
log.buf.AppendLine("No PartSim for attached part (" + attachNode.attachedPart.partInfo.name + ")"); log.buf.AppendLine("No PartSim for attached part (" + attachNode.attachedPart.partInfo.name + ")");
} }
} }
} }
} }
   
foreach (Part p in this.part.fuelLookupTargets) foreach (Part p in this.part.fuelLookupTargets)
{ {
if (p != null) if (p != null)
{ {
PartSim targetSim; PartSim targetSim;
if (partSimLookup.TryGetValue(p, out targetSim)) if (partSimLookup.TryGetValue(p, out targetSim))
{ {
if (log != null) if (log != null)
{ {
log.buf.AppendLine("Fuel target: " + targetSim.name + ":" + targetSim.partId); log.buf.AppendLine("Fuel target: " + targetSim.name + ":" + targetSim.partId);
} }
   
this.fuelTargets.Add(targetSim); this.fuelTargets.Add(targetSim);
} }
else else
{ {
if (log != null) if (log != null)
{ {
log.buf.AppendLine("No PartSim for fuel target (" + p.name + ")"); log.buf.AppendLine("No PartSim for fuel target (" + p.name + ")");
} }
} }
} }
} }
} }
   
private int DecoupledInStage(Part thePart, int stage = -1) private int DecoupledInStage(Part thePart, int stage = -1)
{ {
if (this.IsDecoupler(thePart)) if (this.IsDecoupler(thePart))
{ {
if (thePart.inverseStage > stage) if (thePart.inverseStage > stage)
{ {
stage = thePart.inverseStage; stage = thePart.inverseStage;
} }
} }
   
if (thePart.parent != null) if (thePart.parent != null)
{ {
stage = this.DecoupledInStage(thePart.parent, stage); stage = this.DecoupledInStage(thePart.parent, stage);
} }
   
return stage; return stage;
} }
   
private bool IsDecoupler(Part thePart) private bool IsDecoupler(Part thePart)
{ {
return thePart.HasModule<ModuleDecouple>() || return thePart.HasModule<ModuleDecouple>() ||
thePart.HasModule<ModuleAnchoredDecoupler>(); thePart.HasModule<ModuleAnchoredDecoupler>();
} }
   
private bool IsActiveDecoupler(Part thePart) private bool IsActiveDecoupler(Part thePart)
{ {
return thePart.FindModulesImplementing<ModuleDecouple>().Any(mod => !mod.isDecoupled) || return thePart.FindModulesImplementing<ModuleDecouple>().Any(mod => !mod.isDecoupled) ||
thePart.FindModulesImplementing<ModuleAnchoredDecoupler>().Any(mod => !mod.isDecoupled); thePart.FindModulesImplementing<ModuleAnchoredDecoupler>().Any(mod => !mod.isDecoupled);
} }
   
private bool IsSepratron() private bool IsSepratron()
{ {
if (!this.part.ActivatesEvenIfDisconnected) if (!this.part.ActivatesEvenIfDisconnected)
{ {
return false; return false;
} }
   
if (this.part is SolidRocket) if (this.part is SolidRocket)
{ {
return true; return true;
} }
   
var modList = this.part.Modules.OfType<ModuleEngines>(); var modList = this.part.Modules.OfType<ModuleEngines>();
if (modList.Count() == 0) if (modList.Count() == 0)
{ {
return false; return false;
} }
   
if (modList.First().throttleLocked) if (modList.First().throttleLocked)
{ {
return true; return true;
} }
   
return false; return false;
} }
   
public void ReleasePart() public void ReleasePart()
{ {
this.part = null; this.part = null;
} }
   
// All functions below this point must not rely on the part member (it may be null) // All functions below this point must not rely on the part member (it may be null)
// //
   
public HashSet<PartSim> GetSourceSet(int type, List<PartSim> allParts, HashSet<PartSim> visited, LogMsg log, String indent) public HashSet<PartSim> GetSourceSet(int type, List<PartSim> allParts, HashSet<PartSim> visited, LogMsg log, String indent)
{ {
if (log != null) if (log != null)
{ {
log.buf.AppendLine(indent + "GetSourceSet(" + ResourceContainer.GetResourceName(type) + ") for " + this.name + ":" + this.partId); log.buf.AppendLine(indent + "GetSourceSet(" + ResourceContainer.GetResourceName(type) + ") for " + this.name + ":" + this.partId);
indent += " "; indent += " ";
} }
   
HashSet<PartSim> allSources = new HashSet<PartSim>(); HashSet<PartSim> allSources = new HashSet<PartSim>();
HashSet<PartSim> partSources = null; HashSet<PartSim> partSources = null;
   
// Rule 1: Each part can be only visited once, If it is visited for second time in particular search it returns empty list. // Rule 1: Each part can be only visited once, If it is visited for second time in particular search it returns empty list.
if (visited.Contains(this)) if (visited.Contains(this))
{ {
if (log != null) if (log != null)
{ {
log.buf.AppendLine(indent + "Returning empty set, already visited (" + this.name + ":" + this.partId + ")"); log.buf.AppendLine(indent + "Returning empty set, already visited (" + this.name + ":" + this.partId + ")");
} }
   
return allSources; return allSources;
} }
   
//if (log != null) //if (log != null)
// log.buf.AppendLine(indent + "Adding this to visited"); // log.buf.AppendLine(indent + "Adding this to visited");
   
visited.Add(this); visited.Add(this);
   
// Rule 2: Part performs scan on start of every fuel pipe ending in it. This scan is done in order in which pipes were installed. // Rule 2: Part performs scan on start of every fuel pipe ending in it. This scan is done in order in which pipes were installed.
// Then it makes an union of fuel tank sets each pipe scan returned. If the resulting list is not empty, it is returned as result. // Then it makes an union of fuel tank sets each pipe scan returned. If the resulting list is not empty, it is returned as result.
//MonoBehaviour.print("foreach fuel line"); //MonoBehaviour.print("foreach fuel line");
   
foreach (PartSim partSim in this.fuelTargets) foreach (PartSim partSim in this.fuelTargets)
{ {
if (visited.Contains(partSim)) if (visited.Contains(partSim))
{ {
//if (log != null) //if (log != null)
// log.buf.AppendLine(indent + "Fuel target already visited, skipping (" + partSim.name + ":" + partSim.partId + ")"); // log.buf.AppendLine(indent + "Fuel target already visited, skipping (" + partSim.name + ":" + partSim.partId + ")");
} }
else else
{ {
//if (log != null) //if (log != null)
// log.buf.AppendLine(indent + "Adding fuel target as source (" + partSim.name + ":" + partSim.partId + ")"); // log.buf.AppendLine(indent + "Adding fuel target as source (" + partSim.name + ":" + partSim.partId + ")");
   
partSources = partSim.GetSourceSet(type, allParts, visited, log, indent); partSources = partSim.GetSourceSet(type, allParts, visited, log, indent);
if (partSources.Count > 0) if (partSources.Count > 0)
{ {
allSources.UnionWith(partSources); allSources.UnionWith(partSources);
partSources.Clear(); partSources.Clear();
} }
} }
} }
   
if (allSources.Count > 0) if (allSources.Count > 0)
{ {
if (log != null) if (log != null)
{ {
log.buf.AppendLine(indent + "Returning " + allSources.Count + " fuel target sources (" + this.name + ":" + this.partId + ")"); log.buf.AppendLine(indent + "Returning " + allSources.Count + " fuel target sources (" + this.name + ":" + this.partId + ")");
} }
   
return allSources; return allSources;
} }
   
// Rule 3: This rule has been removed and merged with rules 4 and 7 to fix issue with fuel tanks with disabled crossfeed // Rule 3: This rule has been removed and merged with rules 4 and 7 to fix issue with fuel tanks with disabled crossfeed
   
// Rule 4: Part performs scan on each of its axially mounted neighbors. // Rule 4: Part performs scan on each of its axially mounted neighbors.
// Couplers (bicoupler, tricoupler, ...) are an exception, they only scan one attach point on the single attachment side, // Couplers (bicoupler, tricoupler, ...) are an exception, they only scan one attach point on the single attachment side,
// skip the points on the side where multiple points are. [Experiment] // skip the points on the side where multiple points are. [Experiment]
// Again, the part creates union of scan lists from each of its neighbor and if it is not empty, returns this list. // Again, the part creates union of scan lists from each of its neighbor and if it is not empty, returns this list.
// The order in which mount points of a part are scanned appears to be fixed and defined by the part specification file. [Experiment] // The order in which mount points of a part are scanned appears to be fixed and defined by the part specification file. [Experiment]
if (this.fuelCrossFeed) if (this.fuelCrossFeed)
{ {
//MonoBehaviour.print("foreach attach node"); //MonoBehaviour.print("foreach attach node");
foreach (AttachNodeSim attachSim in this.attachNodes) foreach (AttachNodeSim attachSim in this.attachNodes)
{ {
if (attachSim.attachedPartSim != null) if (attachSim.attachedPartSim != null)
{ {
if (attachSim.nodeType == AttachNode.NodeType.Stack) if (attachSim.nodeType == AttachNode.NodeType.Stack)
{ {
if (!(this.noCrossFeedNodeKey != null && this.noCrossFeedNodeKey.Length > 0 && attachSim.id.Contains(this.noCrossFeedNodeKey))) if (!(this.noCrossFeedNodeKey != null && this.noCrossFeedNodeKey.Length > 0 && attachSim.id.Contains(this.noCrossFeedNodeKey)))
{ {
if (visited.Contains(attachSim.attachedPartSim)) if (visited.Contains(attachSim.attachedPartSim))
{ {
//if (log != null) //if (log != null)
// log.buf.AppendLine(indent + "Attached part already visited, skipping (" + attachSim.attachedPartSim.name + ":" + attachSim.attachedPartSim.partId + ")"); // log.buf.AppendLine(indent + "Attached part already visited, skipping (" + attachSim.attachedPartSim.name + ":" + attachSim.attachedPartSim.partId + ")");
} }
else else
{ {
//if (log != null) //if (log != null)
// log.buf.AppendLine(indent + "Adding attached part as source (" + attachSim.attachedPartSim.name + ":" + attachSim.attachedPartSim.partId + ")"); // log.buf.AppendLine(indent + "Adding attached part as source (" + attachSim.attachedPartSim.name + ":" + attachSim.attachedPartSim.partId + ")");
   
partSources = attachSim.attachedPartSim.GetSourceSet(type, allParts, visited, log, indent); partSources = attachSim.attachedPartSim.GetSourceSet(type, allParts, visited, log, indent);
if (partSources.Count > 0) if (partSources.Count > 0)
{ {
allSources.UnionWith(partSources); allSources.UnionWith(partSources);
partSources.Clear(); partSources.Clear();
} }
} }
} }
} }
} }
} }
   
if (allSources.Count > 0) if (allSources.Count > 0)
{ {
if (log != null) if (log != null)
{ {
log.buf.AppendLine(indent + "Returning " + allSources.Count + " attached sources (" + this.name + ":" + this.partId + ")"); log.buf.AppendLine(indent + "Returning " + allSources.Count + " attached sources (" + this.name + ":" + this.partId + ")");
} }
   
return allSources; return allSources;
} }
} }
   
// Rule 5: If the part is fuel container for searched type of fuel (i.e. it has capability to contain that type of fuel and the fuel // Rule 5: If the part is fuel container for searched type of fuel (i.e. it has capability to contain that type of fuel and the fuel
// type was not disabled [Experiment]) and it contains fuel, it returns itself. // type was not disabled [Experiment]) and it contains fuel, it returns itself.
// Rule 6: If the part is fuel container for searched type of fuel (i.e. it has capability to contain that type of fuel and the fuel // Rule 6: If the part is fuel container for searched type of fuel (i.e. it has capability to contain that type of fuel and the fuel
// type was not disabled) but it does not contain the requested fuel, it returns empty list. [Experiment] // type was not disabled) but it does not contain the requested fuel, it returns empty list. [Experiment]
if (this.resources.HasType(type) && this.resourceFlowStates[type] != 0) if (this.resources.HasType(type) && this.resourceFlowStates[type] != 0)
{ {
if (this.resources[type] > SimManager.RESOURCE_MIN) if (this.resources[type] > SimManager.RESOURCE_MIN)
{ {
allSources.Add(this); allSources.Add(this);
   
if (log != null) if (log != null)
{ {
log.buf.AppendLine(indent + "Returning enabled tank as only source (" + this.name + ":" + this.partId + ")"); log.buf.AppendLine(indent + "Returning enabled tank as only source (" + this.name + ":" + this.partId + ")");
} }
} }
   
return allSources; return allSources;
} }
   
// Rule 7: If the part is radially attached to another part and it is child of that part in the ship's tree structure, it scans its // Rule 7: If the part is radially attached to another part and it is child of that part in the ship's tree structure, it scans its
// parent and returns whatever the parent scan returned. [Experiment] [Experiment] // parent and returns whatever the parent scan returned. [Experiment] [Experiment]
if (this.parent != null && parentAttach == AttachModes.SRF_ATTACH) if (this.parent != null && this.parentAttach == AttachModes.SRF_ATTACH)
{ {
if (this.fuelCrossFeed) if (this.fuelCrossFeed)
{ {
if (visited.Contains(this.parent)) if (visited.Contains(this.parent))
{ {
//if (log != null) //if (log != null)
// log.buf.AppendLine(indent + "Parent part already visited, skipping (" + parent.name + ":" + parent.partId + ")"); // log.buf.AppendLine(indent + "Parent part already visited, skipping (" + parent.name + ":" + parent.partId + ")");
} }
else else
{ {
allSources = this.parent.GetSourceSet(type, allParts, visited, log, indent); allSources = this.parent.GetSourceSet(type, allParts, visited, log, indent);
if (allSources.Count > 0) if (allSources.Count > 0)
{ {
if (log != null) if (log != null)
{ {
log.buf.AppendLine(indent + "Returning " + allSources.Count + " parent sources (" + this.name + ":" + this.partId + ")"); log.buf.AppendLine(indent + "Returning " + allSources.Count + " parent sources (" + this.name + ":" + this.partId + ")");
} }
   
return allSources; return allSources;
} }
} }
} }
} }
   
// Rule 8: If all preceding rules failed, part returns empty list. // Rule 8: If all preceding rules failed, part returns empty list.
//if (log != null) //if (log != null)
// log.buf.AppendLine(indent + "Returning empty set, no sources found (" + name + ":" + partId + ")"); // log.buf.AppendLine(indent + "Returning empty set, no sources found (" + name + ":" + partId + ")");
   
return allSources; return allSources;
} }
   
public void RemoveAttachedParts(HashSet<PartSim> partSims) public void RemoveAttachedParts(HashSet<PartSim> partSims)
{ {
// Loop through the attached parts // Loop through the attached parts
foreach (AttachNodeSim attachSim in this.attachNodes) foreach (AttachNodeSim attachSim in this.attachNodes)
{ {
// If the part is in the set then "remove" it by clearing the PartSim reference // If the part is in the set then "remove" it by clearing the PartSim reference
if (partSims.Contains(attachSim.attachedPartSim)) if (partSims.Contains(attachSim.attachedPartSim))
{ {
attachSim.attachedPartSim = null; attachSim.attachedPartSim = null;
} }
} }
} }
   
public void DrainResources(double time) public void DrainResources(double time)
{ {
//MonoBehaviour.print("DrainResources(" + name + ":" + partId + ", " + time + ")"); //MonoBehaviour.print("DrainResources(" + name + ":" + partId + ", " + time + ")");
foreach (int type in this.resourceDrains.Types) foreach (int type in this.resourceDrains.Types)
{ {
//MonoBehaviour.print("draining " + (time * resourceDrains[type]) + " " + ResourceContainer.GetResourceName(type)); //MonoBehaviour.print("draining " + (time * resourceDrains[type]) + " " + ResourceContainer.GetResourceName(type));
this.resources.Add(type, -time * this.resourceDrains[type]); this.resources.Add(type, -time * this.resourceDrains[type]);
//MonoBehaviour.print(ResourceContainer.GetResourceName(type) + " left = " + resources[type]); //MonoBehaviour.print(ResourceContainer.GetResourceName(type) + " left = " + resources[type]);
} }
} }
   
public double TimeToDrainResource() public double TimeToDrainResource()
{ {
//MonoBehaviour.print("TimeToDrainResource(" + name + ":" + partId + ")"); //MonoBehaviour.print("TimeToDrainResource(" + name + ":" + partId + ")");
double time = double.MaxValue; double time = double.MaxValue;
   
foreach (int type in this.resourceDrains.Types) foreach (int type in this.resourceDrains.Types)
{ {
if (this.resourceDrains[type] > 0) if (this.resourceDrains[type] > 0)
{ {
time = Math.Min(time, this.resources[type] / this.resourceDrains[type]); time = Math.Min(time, this.resources[type] / this.resourceDrains[type]);
//MonoBehaviour.print("type = " + ResourceContainer.GetResourceName(type) + " amount = " + resources[type] + " rate = " + resourceDrains[type] + " time = " + time); //MonoBehaviour.print("type = " + ResourceContainer.GetResourceName(type) + " amount = " + resources[type] + " rate = " + resourceDrains[type] + " time = " + time);
} }
} }
   
//if (time < double.MaxValue) //if (time < double.MaxValue)
// MonoBehaviour.print("TimeToDrainResource(" + name + ":" + partId + ") = " + time); // MonoBehaviour.print("TimeToDrainResource(" + name + ":" + partId + ") = " + time);
return time; return time;
} }
   
public int DecouplerCount() public int DecouplerCount()
{ {
int count = 0; int count = 0;
PartSim partSim = this; PartSim partSim = this;
while (partSim != null) while (partSim != null)
{ {
if (partSim.isDecoupler) if (partSim.isDecoupler)
{ {
count++; count++;
} }
   
partSim = partSim.parent; partSim = partSim.parent;
} }
return count; return count;
} }
   
public double GetStartMass() public double GetStartMass()
{ {
return this.startMass; return this.startMass;
} }
   
public double GetMass() public double GetMass()
{ {
double mass = this.baseMass; double mass = this.baseMass;
   
foreach (int type in this.resources.Types) foreach (int type in this.resources.Types)
{ {
mass += this.resources.GetResourceMass(type); mass += this.resources.GetResourceMass(type);
} }
   
return mass; return mass;
} }
   
public String DumpPartAndParentsToBuffer(StringBuilder buffer, String prefix) public String DumpPartAndParentsToBuffer(StringBuilder buffer, String prefix)
{ {
if (this.parent != null) if (this.parent != null)
{ {
prefix = this.parent.DumpPartAndParentsToBuffer(buffer, prefix) + " "; prefix = this.parent.DumpPartAndParentsToBuffer(buffer, prefix) + " ";
} }
   
this.DumpPartToBuffer(buffer, prefix); this.DumpPartToBuffer(buffer, prefix);
   
return prefix; return prefix;
} }
   
public void DumpPartToBuffer(StringBuilder buffer, String prefix, List<PartSim> allParts = null) public void DumpPartToBuffer(StringBuilder buffer, String prefix, List<PartSim> allParts = null)
{ {
buffer.Append(prefix); buffer.Append(prefix);
buffer.Append(this.name); buffer.Append(this.name);
buffer.AppendFormat(":[id = {0:d}, decouple = {1:d}, invstage = {2:d}", this.partId, this.decoupledInStage, this.inverseStage); buffer.AppendFormat(":[id = {0:d}, decouple = {1:d}, invstage = {2:d}", this.partId, this.decoupledInStage, this.inverseStage);
   
buffer.AppendFormat(", vesselName = '{0}'", this.vesselName); buffer.AppendFormat(", vesselName = '{0}'", this.vesselName);
buffer.AppendFormat(", vesselType = {0}", SimManager.GetVesselTypeString(this.vesselType)); buffer.AppendFormat(", vesselType = {0}", SimManager.GetVesselTypeString(this.vesselType));
buffer.AppendFormat(", initialVesselName = '{0}'", this.initialVesselName); buffer.AppendFormat(", initialVesselName = '{0}'", this.initialVesselName);
   
buffer.AppendFormat(", fuelCF = {0}", this.fuelCrossFeed); buffer.AppendFormat(", fuelCF = {0}", this.fuelCrossFeed);
buffer.AppendFormat(", noCFNKey = '{0}'", this.noCrossFeedNodeKey); buffer.AppendFormat(", noCFNKey = '{0}'", this.noCrossFeedNodeKey);
   
buffer.AppendFormat(", isSep = {0}", this.isSepratron); buffer.AppendFormat(", isSep = {0}", this.isSepratron);
   
foreach (int type in this.resources.Types) foreach (int type in this.resources.Types)
{ {
buffer.AppendFormat(", {0} = {1:g6}", ResourceContainer.GetResourceName(type), this.resources[type]); buffer.AppendFormat(", {0} = {1:g6}", ResourceContainer.GetResourceName(type), this.resources[type]);
} }
   
if (this.attachNodes.Count > 0) if (this.attachNodes.Count > 0)
{ {
buffer.Append(", attached = <"); buffer.Append(", attached = <");
this.attachNodes[0].DumpToBuffer(buffer); this.attachNodes[0].DumpToBuffer(buffer);
for (int i = 1; i < this.attachNodes.Count; i++) for (int i = 1; i < this.attachNodes.Count; i++)
{ {
buffer.Append(", "); buffer.Append(", ");
this.attachNodes[i].DumpToBuffer(buffer); this.attachNodes[i].DumpToBuffer(buffer);
} }
buffer.Append(">"); buffer.Append(">");
} }
   
// Add more info here // Add more info here
   
buffer.Append("]\n"); buffer.Append("]\n");
   
if (allParts != null) if (allParts != null)
{ {
String newPrefix = prefix + " "; String newPrefix = prefix + " ";
foreach (PartSim partSim in allParts) foreach (PartSim partSim in allParts)
{ {
if (partSim.parent == this) if (partSim.parent == this)
{ {
partSim.DumpPartToBuffer(buffer, newPrefix, allParts); partSim.DumpPartToBuffer(buffer, newPrefix, allParts);
} }
} }
} }
} }
} }
} }
// //
// Kerbal Engineer Redux // Kerbal Engineer Redux
// //
// Copyright (C) 2014 CYBUTEK // Copyright (C) 2014 CYBUTEK
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
// //
   
#region Using Directives #region Using Directives
   
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Text; using System.Text;
   
using UnityEngine; using UnityEngine;
   
#endregion #endregion
   
namespace KerbalEngineer.VesselSimulator namespace KerbalEngineer.VesselSimulator
{ {
public class Simulation public class Simulation
{ {
private const double STD_GRAVITY = 9.81d; private const double STD_GRAVITY = 9.81d;
private const double SECONDS_PER_DAY = 86400d; private const double SECONDS_PER_DAY = 86400d;
private readonly Stopwatch _timer = new Stopwatch(); private readonly Stopwatch _timer = new Stopwatch();
private List<EngineSim> activeEngines; private List<EngineSim> activeEngines;
private List<EngineSim> allEngines; private List<EngineSim> allEngines;
private List<PartSim> allFuelLines; private List<PartSim> allFuelLines;
private List<PartSim> allParts; private List<PartSim> allParts;
private double atmosphere; private double atmosphere;
private int currentStage; private int currentStage;
private double currentisp; private double currentisp;
private bool doingCurrent; private bool doingCurrent;
private List<PartSim> dontStageParts; private List<PartSim> dontStageParts;
private HashSet<PartSim> drainingParts; private HashSet<PartSim> drainingParts;
private HashSet<int> drainingResources; private HashSet<int> drainingResources;
private double gravity; private double gravity;
   
private int lastStage; private int lastStage;
private List<Part> partList; private List<Part> partList;
private double simpleTotalThrust; private double simpleTotalThrust;
private double stageStartMass; private double stageStartMass;
private double stageTime; private double stageTime;
private double stepEndMass; private double stepEndMass;
private double stepStartMass; private double stepStartMass;
private double totalStageActualThrust; private double totalStageActualThrust;
private double totalStageFlowRate; private double totalStageFlowRate;
private double totalStageIspFlowRate; private double totalStageIspFlowRate;
private double totalStageThrust; private double totalStageThrust;
private Vector3 vecActualThrust; private Vector3 vecActualThrust;
private Vector3 vecStageDeltaV; private Vector3 vecStageDeltaV;
private Vector3 vecThrust; private Vector3 vecThrust;
private double velocity; private double velocity;
public String vesselName; public String vesselName;
public VesselType vesselType; public VesselType vesselType;
   
public Simulation() public Simulation()
{ {
if (SimManager.logOutput) if (SimManager.logOutput)
{ {
MonoBehaviour.print("Simulation created"); MonoBehaviour.print("Simulation created");
} }
} }
   
private double ShipStartMass private double ShipStartMass
{ {
get get
{ {
double mass = 0d; double mass = 0d;
   
foreach (PartSim partSim in this.allParts) foreach (PartSim partSim in this.allParts)
{ {
mass += partSim.GetStartMass(); mass += partSim.GetStartMass();
} }
   
return mass; return mass;
} }
} }
   
private double ShipMass private double ShipMass
{ {
get get
{ {
double mass = 0d; double mass = 0d;
   
foreach (PartSim partSim in this.allParts) foreach (PartSim partSim in this.allParts)
{ {
mass += partSim.GetMass(); mass += partSim.GetMass();
} }
   
return mass; return mass;
} }
} }
   
// This function prepares the simulation by creating all the necessary data structures it will // This function prepares the simulation by creating all the necessary data structures it will
// need during the simulation. All required data is copied from the core game data structures // need during the simulation. All required data is copied from the core game data structures
// so that the simulation itself can be run in a background thread without having issues with // so that the simulation itself can be run in a background thread without having issues with
// the core game changing the data while the simulation is running. // the core game changing the data while the simulation is running.
public bool PrepareSimulation(List<Part> parts, double theGravity, double theAtmosphere = 0, double theVelocity = 0, bool dumpTree = false, bool vectoredThrust = false) public bool PrepareSimulation(List<Part> parts, double theGravity, double theAtmosphere = 0, double theVelocity = 0, bool dumpTree = false, bool vectoredThrust = false)
{ {
LogMsg log = null; LogMsg log = null;
if (SimManager.logOutput) if (SimManager.logOutput)
{ {
log = new LogMsg(); log = new LogMsg();
log.buf.AppendLine("PrepareSimulation started"); log.buf.AppendLine("PrepareSimulation started");
dumpTree = true; dumpTree = true;
} }
this._timer.Start(); this._timer.Start();
   
// Store the parameters in members for ease of access in other functions // Store the parameters in members for ease of access in other functions
this.partList = parts; this.partList = parts;
this.gravity = theGravity; this.gravity = theGravity;
this.atmosphere = theAtmosphere; this.atmosphere = theAtmosphere;
this.velocity = theVelocity; this.velocity = theVelocity;
this.lastStage = Staging.lastStage; this.lastStage = Staging.lastStage;
//MonoBehaviour.print("lastStage = " + lastStage); //MonoBehaviour.print("lastStage = " + lastStage);
   
// Create the lists for our simulation parts // Create the lists for our simulation parts
this.allParts = new List<PartSim>(); this.allParts = new List<PartSim>();
this.allFuelLines = new List<PartSim>(); this.allFuelLines = new List<PartSim>();
this.drainingParts = new HashSet<PartSim>(); this.drainingParts = new HashSet<PartSim>();
this.allEngines = new List<EngineSim>(); this.allEngines = new List<EngineSim>();
this.activeEngines = new List<EngineSim>(); this.activeEngines = new List<EngineSim>();
this.drainingResources = new HashSet<int>(); this.drainingResources = new HashSet<int>();
   
// A dictionary for fast lookup of Part->PartSim during the preparation phase // A dictionary for fast lookup of Part->PartSim during the preparation phase
Dictionary<Part, PartSim> partSimLookup = new Dictionary<Part, PartSim>(); Dictionary<Part, PartSim> partSimLookup = new Dictionary<Part, PartSim>();
   
if (this.partList.Count > 0 && this.partList[0].vessel != null) if (this.partList.Count > 0 && this.partList[0].vessel != null)
{ {
this.vesselName = this.partList[0].