├── .gitattributes
├── .gitignore
├── GameData
├── GameData.projitems
├── GameData.shproj
├── GameData.shproj.user
├── LICENSE
├── README.md
└── TimeControl
│ ├── CHANGELOG.md
│ ├── Flags
│ └── TimeControl.png
│ ├── LICENSE.md
│ ├── README.md
│ ├── TimeControl.dll
│ ├── TimeControl.version
│ └── ToolbarIcons
│ ├── BlizzyToolbarIcons
│ ├── disabled.png
│ └── enabled.png
│ └── StockToolbarIcons
│ ├── disabled.png
│ └── enabled.png
├── Release
├── TimeControl-1.0.2.zip
├── TimeControl-1.0.4-hotfix1.zip
├── TimeControl-1.0.4-hotfix2.zip
├── TimeControl-1.0.4.zip
├── TimeControl-1.0.5.zip
├── TimeControl-2.0.2.zip
├── TimeControl-2.1.0.zip
├── TimeControl-2.2.0.zip
├── TimeControl-2.2.1.zip
├── TimeControl-2.2.2.zip
├── TimeControl-2.3.1.zip
├── TimeControl.netkan
└── TimeControl.version
├── Testing
└── Regression Test Checklist.xlsx
├── TimeControl.Unity
├── AssemblyVersion.cs
├── AssemblyVersion.tt
├── ITimeControlUI.cs
├── Properties
│ └── AssemblyInfo.cs
├── TimeControl.Unity.csproj
├── WarpSpeedEditor.cs
└── bin
│ └── Release
│ ├── Assembly-CSharp-firstpass.dll
│ ├── Assembly-CSharp.dll
│ ├── KSPAssets.dll
│ ├── Mono.Cecil.dll
│ ├── System.Xml.dll
│ ├── TDx.TDxInput.dll
│ ├── TimeControl.Unity.dll
│ ├── TimeControl.Unity.pdb
│ ├── TimeControl.dll
│ ├── TimeControl.pdb
│ ├── TrackIRUnity.dll
│ ├── UnityEngine.UI.dll
│ ├── UnityEngine.dll
│ └── UnityEngine.xml
├── TimeControl.sln
├── TimeControl
├── AssemblyVersion.cs
├── AssemblyVersion.tt
├── ExtensionMethods.cs
├── FPSKeeperController.cs
├── GlobalSettings.cs
├── HyperWarpController.cs
├── IMGUI
│ ├── DetailsIMGUI.cs
│ ├── HyperEditorIMGUI.cs
│ ├── HyperIMGUI.cs
│ ├── IMGUIExtensions.cs
│ ├── KeyBindingsAddIMGUI.cs
│ ├── KeyBindingsEditorIMGUI.cs
│ ├── QuickWarpToIMGUI.cs
│ ├── RailsEditorIMGUI.cs
│ ├── RailsWarpToIMGUI.cs
│ ├── SharedIMGUI.cs
│ ├── SlowMoIMGUI.cs
│ └── TimeControlIMGUI.cs
├── KeyBindings
│ ├── GUIToggle.cs
│ ├── HyperActivate.cs
│ ├── HyperDeactivate.cs
│ ├── HyperPhysicsAccuracyDown.cs
│ ├── HyperPhysicsAccuracySet.cs
│ ├── HyperPhysicsAccuracyUp.cs
│ ├── HyperRateChangeToHigherRate.cs
│ ├── HyperRateChangeToLowerRate.cs
│ ├── HyperRateSetRate.cs
│ ├── HyperRateSlowDown.cs
│ ├── HyperRateSpeedUp.cs
│ ├── HyperToggle.cs
│ ├── PauseToggle.cs
│ ├── Realtime.cs
│ ├── SlowMoActivate.cs
│ ├── SlowMoDeactivate.cs
│ ├── SlowMoSetRate.cs
│ ├── SlowMoSlowDown.cs
│ ├── SlowMoSpeedUp.cs
│ ├── SlowMoToggle.cs
│ ├── TimeControlKeyAction.cs
│ ├── TimeControlKeyBinding.cs
│ ├── TimeControlKeyBindingFactory.cs
│ ├── TimeControlKeyBindingValue.cs
│ ├── TimeStep.cs
│ ├── WarpForNOrbits.cs
│ ├── WarpForNTimeIncrements.cs
│ ├── WarpToNextKACAlarm.cs
│ └── WarpToVesselOrbitLocation.cs
├── KeyboardInputManager.cs
├── Logging
│ ├── EntryExitLogger.cs
│ ├── Log.cs
│ └── LogSeverity.cs
├── ModIntegration
│ ├── BlizzyToolbar
│ │ └── BlizzyToolbarWrapper.cs
│ └── KerbalAlarmClock
│ │ └── KACWrapper.cs
├── MuMech_OrbitExtensions.cs
├── PerformanceManager.cs
├── PluginAssemblyUtilities.cs
├── Properties
│ └── AssemblyInfo.cs
├── RailsWarpController.cs
├── ResourceConverterBugFix.cs
├── SlowMoController.cs
├── TimeControl.csproj
├── TimeControl.csproj.user
├── TimeControlEvents.cs
├── TimeControlParameters.cs
├── TimeControlScenario.cs
├── TimeController.cs
├── Toolbars.cs
└── packages.config
└── TimeControlTesting
├── Properties
└── AssemblyInfo.cs
├── TestDateTimeDisplay.cs
├── TimeControlTesting.csproj
└── bin
└── Release
├── Assembly-CSharp-firstpass.dll
├── Assembly-CSharp.dll
├── KSPAssets.dll
├── Mono.Cecil.dll
├── Mono.Security.dll
├── TDx.TDxInput.dll
├── TimeControl.Testing.dll
├── TimeControl.Testing.pdb
├── TimeControl.dll
├── TimeControl.pdb
├── TrackIRUnity.dll
├── UnityEngine.UI.dll
├── UnityEngine.dll
└── UnityEngine.xml
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | #*.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.lnk
2 | *.suo
3 | *.csproj.user
4 | obj
5 | TimeControl/bin
6 | TimeControl/libs
7 | TimeControl/obj
8 | /Release
9 | /.vs
10 | # NuGet Packages
11 | *.nupkg
12 | # The packages folder can be ignored because of Package Restore
13 | **/packages/*
14 | # except build/, which is used as an MSBuild target.
15 | !**/packages/build/
16 | # Uncomment if necessary however generally it will be regenerated when needed
17 | #!**/packages/repositories.config
--------------------------------------------------------------------------------
/GameData/GameData.projitems:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath)
5 | true
6 | cbbb7888-e232-463d-b26e-49a9e510e735
7 |
8 |
9 | GameData
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/GameData/GameData.shproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | cbbb7888-e232-463d-b26e-49a9e510e735
5 | 14.0
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/GameData/GameData.shproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | true
5 |
6 |
--------------------------------------------------------------------------------
/GameData/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Portions Copyright (c) 2014 Xaiier
4 | Portions Copyright (c) 2017 Nate West
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in all
14 | copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | SOFTWARE.
--------------------------------------------------------------------------------
/GameData/README.md:
--------------------------------------------------------------------------------
1 | This Project is simply a placeholder to manage the static GameData files in visual studio. It is not built as part of the solution.
--------------------------------------------------------------------------------
/GameData/TimeControl/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | Version 2.10 (KSP 1.10.1)
2 | - Recompile for KSP 1.10.1
3 |
4 | Version 2.9.9 (KSP 1.9.1)
5 | - Added new Hyper Warping feature - list of editable custom hyper warp rates and physics settings (like stock rails warp)
6 | - Added buttons to increse/decrease by these settings
7 | - Added key bindings to increase/decrease by these settings
8 | - Added buttons on quick and rails warp to 'start burn time' of the next manuver node (also 10 and 30 sec prior)
9 | - Added key binding for warping to start burn time - X seconds
10 |
11 | Version 2.9.8 (KSP 1.9.1)
12 | - KSP 1.9.1 Recompile
13 |
14 | Version 2.9.7 (KSP 1.8.1)
15 | - KSP 1.8.1 Recompile
16 |
17 | Version 2.9.6 (KSP 1.6.1)
18 | - KSP 1.6.1 Recompile
19 |
20 | Version 2.9.6 (KSP 1.6.1)
21 | - KSP 1.6.1 Recompile
22 |
23 | Version 2.9.5 (KSP 1.5.1)
24 | - KSP 1.5.1 Recompile
25 | - Allow warp directly from PAUSE when paused via TimeControl
26 | - Fix IndexOutOfRange exception on scene changes
27 |
28 | Version 2.9.4 (KSP 1.4.5)
29 | - KSP 1.4.5 Recompile
30 |
31 | Version 2.9.3 (KSP 1.4.4)
32 | - KSP 1.4.4 Recompile
33 |
34 | Version 2.9.2 (KSP 1.4.3)
35 | - KSP 1.4.3 Recompile
36 |
37 | Version 2.9.1 (KSP 1.4.2)
38 | - KSP 1.4.2 Recompile
39 |
40 | Version 2.9 (KSP 1.4.1)
41 | - KSP 1.4.1 Compatibility
42 | - Removed MiniAVC (kept Version file)
43 |
44 | Version 2.8.3 (KSP 1.3.1)
45 | - Automatically reset maximumDeltaTime to the PHYSICS_FRAME_DT_LIMIT after physics warp bug enhancement
46 | - Fixed Physics Accuracy +/- not working correctly on slider
47 | - Fixed Hyper-Warp/Slow Mo Screen messages do not include stats when GUI is disabled (toggle performance stats on ? screen)
48 | - Hyper Warp now allows you to set very high MaximumDeltaTime values that only apply during hyper warp. This will reduce your frame rate but possibly speed up Hyper Warp a little bit so long as the engine is not physics-limited.
49 |
50 | Version 2.8.2 (KSP 1.3.1)
51 | - Massive Keybindings update for the Discerning Gamer.
52 | - Bind nearly every TimeControl action to a hotkey or key combination. Bind multiple actions to the same set of keys e.g. (activate hyper warp + set rate to 8). Key binds for quick warp to specific times / orbit locations.
53 | - Also includes a bug fix to resource converters at high time warps using code graciously provided by @linuxgurugamer.
54 |
55 | Version 2.8.1 (KSP 1.3.1)
56 | - Release for KSP 1.3.1. Fixed version file and compile issue with prior 2.8 release.
57 |
58 | Version 2.7 (KSP 1.3)
59 | - Major Refactoring. Updated GUI, Settings, added quickwarp and warp-to tabs.
60 | - KSP 1.3 compatibility.
61 |
62 | Version 2.5 (KSP 1.2.2)
63 | - Added back MiniAVC
64 | - Thanks to @linuxgurugamer who updated for KSP 1.2.2. Also fixed up the close button on the window so it closes instead of minimizing.
65 |
66 | Version 2.4 (KSP 1.2.1)
67 |
68 | - KSP 1.2.1 Compatibility.
69 | - MiniAVC removed until AVC is updated for 1.2.1.
70 | - Fixes bug for "Homeworld Time" breaking RSS Time Formatter. Will rethink this feature...
71 |
72 | Version 2.3.1 (KSP 1.2)
73 | - Fixes toolbar integration code
74 |
75 | Version 2.3 (KSP 1.2)
76 |
77 | - KSP 1.2 Compatibility.
78 | - New KSP 1.2 version of MiniAVC.
79 | - Fixes bug where debris leaving the physics area causes hyper warp to cut out on current vessel.
80 | - Fixes bug where it was saving the game settings in the editor view, which was breaking editor extensions redux. Thanks to linuxgurugamer.
81 |
82 | Version 2.2.2 (KSP 1.1.3)
83 | - 2.2.1 had a slow-motion bug when returning to 1x. Corrected.
84 |
85 | Version 2.2.1 (KSP 1.1.3)
86 | - Bug fix: TC will no longer interfere with the stock warp to on rails.
87 | - Remove some string concatenation from the OnGUI calls.
88 |
89 | Version 2.2 (KSP 1.1.3)
90 |
91 | - Logging mode now is properly set up with the settings file as well as in the Settings GUI. Defaulting to INFO mode.
92 | - Save warp rates, altitudes, window positions, and settings every X seconds is now in the Settings GUI as well. Defaults to 5 seconds. Note that if you have made no changes, it does not perform a save.
93 | - "Homeworld Timekeeping" option added. If you have modified things with Kopernicus and this is turned on, "Use Kerbin Time" will set up your calendar so that 1 day = 1 sidereal day, and 1 year = 1 sidereal year.
94 |
95 | Version 2.1 (KSP 1.1.3)
96 |
97 | - Screen Messages now stay on until you change warp. They can be toggled off in the settings menu.
98 | - Replaced label at top right of TC window with a button that cancels the warp type as well as cancelling PAUSE.
99 | - Auto Rails Warp now uses custom code, it appears to be very accurate.
100 | - Auto Rails warp now has the ability to pause when you reach the time requested.
101 | - Rails warp when you first go to the flight window now uses the correct warp rates.
102 | - Logging mode now is properly set up with the settings file. Defaulting to INFO mode.
103 | - Corrected issue when changing a scene, if you had time paused, it would break the game.
104 |
105 |
106 | Version 2.0.2 (KSP 1.1.3)
107 |
108 | - New Icon from @Avera9eJoe
109 | - Settings window is available from the space center as well as in flight.
110 | - Rails Warp
111 | - Bugs around rails warp should be somewhat corrected, leveraging the new builtin rails warp to function
112 | - Hyper Warp
113 | - Hyper warp accuracy now scales to 1/6 (Physics delta time of .12 seconds). Using this, I was able to launch the Stock ship "ComSat LX" to 500km in about a second.
114 | - A new box has been added to the left of the slider for the accuracy, it can go from 1 to 6. This is the multiplier that is applied to the internal Fixed Delta Time settings in Unity.
115 | - Slow Motion
116 | - FPS Keeper is now controlled from the Slow-Motion tab.
117 | - Keybindings
118 | - Work again. Speed Up/Slow Down work a bit differently - if you are Hyper Warping, they increment/decrement the hyper warp max value. Otherwise they work with slow-motion as usual.
119 | - Assign a binding by left clicking the button, then pressing the key combination. Clear a binding by right clicking the button.
120 | - You can bind a key combination to a key binding instead of a single key. Note that for most bindings the final key pressed 'down' is what triggers the key.
121 | - If you bind keys that are also used by KSP, you will be triggering both your stuff and the KSP keys.
122 | - I did a massive code refactoring for hopeful performance improvement. Also added a ton of instrumentation, which by default is mostly turned off (but for bugs it will be invaluable).
123 | - FPS display is gone (for now). I added FPS in the header of the TimeControl Window, along with the current warp rate, which now shows time as a % for Hyper/Slow-Mo and a 1x-100x etc for Rails.
124 | - CamFix removed (it was causing problems with other mods). Please let me know if you experience any issues or used this feature.
125 | - Config file is sane now, handling Celestial Bodies by Name instead of 0,1,2,3,4 etc.
126 | - Version checking using MiniAVC
127 | - Removed FPS toggle
128 | - Toggle Time Control-generated on-screen messages. Sorry, normal ones will still appear.
129 | - Rails auto warp will use hyper warp if you are 'FLYING' in an atmosphere. It won't automatically change to rails warp when you leave the atmosphere (this is a todo)
130 |
--------------------------------------------------------------------------------
/GameData/TimeControl/Flags/TimeControl.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ntwest/TimeControl/4e2da160a139bbb04b7a382b95f695d3fe555127/GameData/TimeControl/Flags/TimeControl.png
--------------------------------------------------------------------------------
/GameData/TimeControl/LICENSE.md:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Portions Copyright (c) 2014 Xaiier
4 | Portions Copyright (c) 2017 Nate West
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in all
14 | copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | SOFTWARE.
--------------------------------------------------------------------------------
/GameData/TimeControl/README.md:
--------------------------------------------------------------------------------
1 | TIME CONTROL
2 |
3 | Originally designed by Xaiier as an advanced successor to the popular Dynamic Warp mod, this mod gives you complete control of time in KSP by allowing you to slow down time to get those cool explosions on video(or find out why your rocket is blowing up on the pad), boost the rate of time to ridiculous levels without loss of precision to ease those long burns, set custom warp rates and per-planet custom altitude limits, utilize automatic warping, and monitor the physics engine and game performance.
4 |
5 | Now maintained and enhanced by westamastaflash.
6 |
7 | KSP Forum Thread:
8 | https://forum.kerbalspaceprogram.com/index.php?/topic/143763-145-time-control-294/
9 |
10 |
11 |
12 | MAIN WINDOW
13 |
14 | The pause button freezes physics, and allows you to step forward one physics frame at a time, for even more precise control.
15 |
16 | DETAILS (?)
17 | Displays some detailed statistics about the current game state. Also allows you to change the max delta time slider.
18 |
19 | QUICK WARP (Q)
20 | A selection of buttons to immediately warp for a specific amount of seconds/minutes/hours/days/years/orbits, or to a vessel's Ap/Pe/AN/DN/SOI/Manuver Node and then stop.
21 |
22 | WARP-TO UT (W)
23 | Has a similar selection of buttons to Quick Warp, but these add/subtract from a Target UT value, to allow you to specify exactly the time. Left click adds to the target UT, Right click subtracts (like the PreciseNode mod does). The Vessel buttons reset the Target UT directly to that point. Also has fields where a user can enter an exact amount of years, days, hours, minutes, and seconds
24 |
25 | RAILS EDITOR (R)
26 | The rails editor gives you complete control over every part of rails warping. You can fully customize the warp rates available, as well as add more if you like, as well as set the altitude limits for each warp level for each celestial body. There are several buttons that set these to defaults which make time warping a breese. Warp Rates and Altitude limits are now set per savegame, not globally.
27 |
28 | Buttons that setup warp rates:
29 | Kerbin Time: 5s/s 15s/s, 45s/s, 60s/s, 1m/s, 5m/s, 15m/s, 45m/s, 1hr/s, 3hr/s, 1d/s, 5ds/s, 15d/s, 45d/s, 135d/s, 1yr/s
30 | (Note that Kerbin-Days are 21650.8s, And Kerbin-Years are 9203544.6s, but since rate is stored as a 32bit floating point value, I use 9203544x for the 1yr/s rate.
31 | Earth Time: 5s/s 15s/s, 45s/s, 60s/s, 1m/s, 5m/s, 15m/s, 45m/s, 1hr/s, 3hr/s, 12hr/s, 1d/s, 5d/s, 15d/s, 30d/s, 90d/s, 180d/s, 1yr/s
32 |
33 | KEY BINDINGS (K)
34 | Assign a binding by left clicking the button, then pressing the key combination. Clear a binding by right clicking the button. You can bind a key combination to a key binding instead of a single key. Note that for most bindings the final key pressed 'down' is what triggers the key. If you bind keys that are also used by KSP, you will be triggering both your stuff and the KSP keys. This should support joystick buttons but I have no joystick to test with.
35 |
36 | Toggle GUI - toggles the GUI window(s)
37 | Realtime: ends all warp and returns to realtime
38 | Pause - Stops or Resumes time.
39 | Step - Run until next physics update.
40 | Speed Up / Slow Down - If in Slow-Motion, functions to slow down or speed up time. If in Hyper Warp, increments/decrements the max hyper warp rate by 1.
41 | Slow Motion - Toggles Slow Motion on/off
42 | Hyper Warp - Toggles Hyper Warp on/off
43 |
44 | HYPER-WARP (H)
45 | The hyper warp menu gives you the ability to speed up time without sacrificing physics accuracy like phys-warp does. This has a myriad of uses, like speeding up launches or burns (especially with lower TWR craft), flying planes around the world, running Kerbals long distances, etc. The first slider sets the maximum attempted speed - note that it is unlikely that you will be able to attain that speed unless you have a very powerful computer or a very small craft. The second slider sets the minimum accuracy, from 1 to 1/6. If you know your ship can hold together in phys-warp, you can reduce the accuracy to attain better speeds and FPS. You can either manually control when hyper warp is active, or you can set it to warp for a period of time, which is particularly useful for long burns with ION or Nuclear engines. If you like, have it pause when it finishes so you can AFK while it goes and not worry about missing anything. Also provided in the hyper warp window is a throttle slider, so you can precisely control your throttle even when the standard throttle response is sped up.
46 |
47 | HYPER-WARP RATES SETTINGS (E)
48 | Much like rails warp settings, this allows you to configure the rates set by stepping up and down through the hyper warp rate with keyboard commands. You will need to
49 |
50 |
51 | SLOW-MOTION (S)
52 | The slow motion menu gives you the ability to slow down time, or completely pause time and step forward frame by frame. By default, the slider slows down both the game speed and the physics delta, resulting in a smooth slow motion. Note that this will change how the physics of your vessel behaves, joints will stiffen and become more rigid (the opposite of what happens in phys-warp). This can sometimes cause problems with launch clamps or clipped parts, so beware. If you flip on the "lock physics delta" option, time will slow down, but the physics calculations won't change, so parts will appear to stutter and motion will be choppy. This allows you to see how your ship behaves at a much slower pace, so you can determine what might be going wrong. It is also very useful because even with high part counts where your computer is struggling with physics calculations, your frame-rate will NOT be slowed, so you can maintain full control of your camera, parts on your ship, and anything else. Also provided in the slow-motion window is a throttle slider, so you can precisely control your throttle even when the standard throttle response is slowed.
53 |
54 |
55 |
56 |
57 | KERBAL ALARM CLOCK INTEGRATION
58 | Both Quick Warp and Warp-To UT are integrated with KAC to warp to the upcoming KAC alarm. Recommendation is to disable the auto-warp stop in KAC, as the TimeControl one is faster and will jump nearly instantaneously if you have a good amount of warp rates spaced out mostly evenly (I recommend using the 'standard kerbin time' settings).
59 |
60 |
61 |
62 |
63 | Features NOT enabled in current release:
64 | FPS-Keeper
65 | The FPS Keeper is a handy little tool that can automatically manage your settings based on your computer's performance and edit the maxDeltaTime and slow your time rate to keep your FPS above a limit while maximizing the time rate of your game. Note that is is still very beta technology, it isn't perfect and it won't work for every situation. Usage is fairly straight forward, but performance is highly dependent on your computer. First off, determine what kind of FPS your computer gets with a very small craft. You shouldn't set it above that because it will just slam you down to 1/64x trying to boost your FPS hopelessly. Also, note that you should give a margin for error, if you run at 60 fps, set it to 50-55, as 60 will just confuse it. Second, play around with what kind of minimum FPS you can stand, trying to set it too high will just end up making everything take ages. The main idea of it is that it can adjust on the fly to changing conditions without the typical FPS spikes and drops, so you can for example fly around in orbit at good FPS, and then when you approach your station, it will automatically account for the higher load and slow down time a bit while you dock, or have it automatically adjust the speed as your massive lifter drops off stages keeping you at the best speed without having to deal with terrible fps. Also note that results per computer may be drastically different. A computer that struggles to get 30 fps won't be able to keep the FPS when the load gets high no matter what it does, and whether your computer is CPU or GPU limited also can have a large effect.
66 |
67 |
--------------------------------------------------------------------------------
/GameData/TimeControl/TimeControl.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ntwest/TimeControl/4e2da160a139bbb04b7a382b95f695d3fe555127/GameData/TimeControl/TimeControl.dll
--------------------------------------------------------------------------------
/GameData/TimeControl/TimeControl.version:
--------------------------------------------------------------------------------
1 | {
2 | "NAME": "TimeControl",
3 | "URL": "http://ksp-avc.cybutek.net/version.php?id=310",
4 | "DOWNLOAD": "https://github.com/ntwest/TimeControl/releases",
5 | "CHANGE_LOG_URL": "https://github.com/ntwest/TimeControl/blob/master/CHANGELOG.md",
6 | "VERSION": {
7 | "MAJOR": 2,
8 | "MINOR": 10,
9 | "PATCH": 0,
10 | "BUILD": 0
11 | },
12 | "KSP_VERSION": {
13 | "MAJOR": 1,
14 | "MINOR": 10,
15 | "PATCH": 1
16 | },
17 | "KSP_VERSION_MIN": {
18 | "MAJOR": 1,
19 | "MINOR": 10,
20 | "PATCH": 1
21 | },
22 | "KSP_VERSION_MAX": {
23 | "MAJOR": 1,
24 | "MINOR": 10,
25 | "PATCH": 1
26 | }
27 | }
--------------------------------------------------------------------------------
/GameData/TimeControl/ToolbarIcons/BlizzyToolbarIcons/disabled.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ntwest/TimeControl/4e2da160a139bbb04b7a382b95f695d3fe555127/GameData/TimeControl/ToolbarIcons/BlizzyToolbarIcons/disabled.png
--------------------------------------------------------------------------------
/GameData/TimeControl/ToolbarIcons/BlizzyToolbarIcons/enabled.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ntwest/TimeControl/4e2da160a139bbb04b7a382b95f695d3fe555127/GameData/TimeControl/ToolbarIcons/BlizzyToolbarIcons/enabled.png
--------------------------------------------------------------------------------
/GameData/TimeControl/ToolbarIcons/StockToolbarIcons/disabled.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ntwest/TimeControl/4e2da160a139bbb04b7a382b95f695d3fe555127/GameData/TimeControl/ToolbarIcons/StockToolbarIcons/disabled.png
--------------------------------------------------------------------------------
/GameData/TimeControl/ToolbarIcons/StockToolbarIcons/enabled.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ntwest/TimeControl/4e2da160a139bbb04b7a382b95f695d3fe555127/GameData/TimeControl/ToolbarIcons/StockToolbarIcons/enabled.png
--------------------------------------------------------------------------------
/Release/TimeControl-1.0.2.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ntwest/TimeControl/4e2da160a139bbb04b7a382b95f695d3fe555127/Release/TimeControl-1.0.2.zip
--------------------------------------------------------------------------------
/Release/TimeControl-1.0.4-hotfix1.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ntwest/TimeControl/4e2da160a139bbb04b7a382b95f695d3fe555127/Release/TimeControl-1.0.4-hotfix1.zip
--------------------------------------------------------------------------------
/Release/TimeControl-1.0.4-hotfix2.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ntwest/TimeControl/4e2da160a139bbb04b7a382b95f695d3fe555127/Release/TimeControl-1.0.4-hotfix2.zip
--------------------------------------------------------------------------------
/Release/TimeControl-1.0.4.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ntwest/TimeControl/4e2da160a139bbb04b7a382b95f695d3fe555127/Release/TimeControl-1.0.4.zip
--------------------------------------------------------------------------------
/Release/TimeControl-1.0.5.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ntwest/TimeControl/4e2da160a139bbb04b7a382b95f695d3fe555127/Release/TimeControl-1.0.5.zip
--------------------------------------------------------------------------------
/Release/TimeControl-2.0.2.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ntwest/TimeControl/4e2da160a139bbb04b7a382b95f695d3fe555127/Release/TimeControl-2.0.2.zip
--------------------------------------------------------------------------------
/Release/TimeControl-2.1.0.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ntwest/TimeControl/4e2da160a139bbb04b7a382b95f695d3fe555127/Release/TimeControl-2.1.0.zip
--------------------------------------------------------------------------------
/Release/TimeControl-2.2.0.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ntwest/TimeControl/4e2da160a139bbb04b7a382b95f695d3fe555127/Release/TimeControl-2.2.0.zip
--------------------------------------------------------------------------------
/Release/TimeControl-2.2.1.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ntwest/TimeControl/4e2da160a139bbb04b7a382b95f695d3fe555127/Release/TimeControl-2.2.1.zip
--------------------------------------------------------------------------------
/Release/TimeControl-2.2.2.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ntwest/TimeControl/4e2da160a139bbb04b7a382b95f695d3fe555127/Release/TimeControl-2.2.2.zip
--------------------------------------------------------------------------------
/Release/TimeControl-2.3.1.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ntwest/TimeControl/4e2da160a139bbb04b7a382b95f695d3fe555127/Release/TimeControl-2.3.1.zip
--------------------------------------------------------------------------------
/Release/TimeControl.netkan:
--------------------------------------------------------------------------------
1 | {
2 | "spec_version" : 1,
3 | "identifier" : "TimeControl",
4 | "$kref" : "#/ckan/github/ntwest/TimeControl",
5 | "$vref" : "#/ckan/ksp-avc",
6 | "name" : "Time Control",
7 | "abstract" : "Slow Motion, Hyper Warp, and Rails Warp Controls",
8 | "license" : "MIT",
9 | "resources": {
10 | "homepage": "http://forum.kerbalspaceprogram.com/index.php?/topic/143763-113-time-control-202/"
11 | }
12 | }
--------------------------------------------------------------------------------
/Release/TimeControl.version:
--------------------------------------------------------------------------------
1 | {"NAME":"TimeControl","URL":"http://ksp-avc.cybutek.net/version.php?id=310","DOWNLOAD":"https://github.com/ntwest/TimeControl/releases","CHANGE_LOG_URL":"https://github.com/ntwest/TimeControl/blob/master/CHANGELOG.md","VERSION":{"MAJOR":2,"MINOR":2,"PATCH":3,"BUILD":0},"KSP_VERSION":{"MAJOR":1,"MINOR":2,"PATCH":0},"KSP_VERSION_MIN":{"MAJOR":1,"MINOR":2,"PATCH":0},"KSP_VERSION_MAX":{"MAJOR":1,"MINOR":2,"PATCH": 0}}
--------------------------------------------------------------------------------
/Testing/Regression Test Checklist.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ntwest/TimeControl/4e2da160a139bbb04b7a382b95f695d3fe555127/Testing/Regression Test Checklist.xlsx
--------------------------------------------------------------------------------
/TimeControl.Unity/AssemblyVersion.cs:
--------------------------------------------------------------------------------
1 |
2 |
3 | // This code was generated by a tool. Any changes made manually will be lost
4 | // the next time this code is regenerated.
5 | //
6 |
7 | using System.Reflection;
8 |
9 | [assembly: AssemblyVersion("2.6.0.0")]
--------------------------------------------------------------------------------
/TimeControl.Unity/AssemblyVersion.tt:
--------------------------------------------------------------------------------
1 | <#@template language="c#" hostspecific="true"#>
2 | <#@ import namespace="System.IO" #>
3 | <#@ output extension=".cs" #>
4 | <#@ parameter type="System.String" name="GameDataDirectory" #>
5 | <#
6 | int major = 0;
7 | int minor = 0;
8 | int build = 0;
9 | int patch = 0;
10 | bool versionSection = false;
11 | int i = 0;
12 | int i2 = 0;
13 | string s;
14 |
15 | // For Visual Studio / MSBuild Build-Time Template Resolution
16 | string GameDataDirectory = Host.ResolveParameterValue("-", "-", "GameDataDirectory");
17 |
18 | // For Visual Studio Design-Time Template Resolution
19 | if (GameDataDirectory == "")
20 | {
21 | GameDataDirectory = System.IO.Path.GetDirectoryName(Host.TemplateFile) + "\\..\\GameData";
22 | }
23 |
24 | string versionfile = GameDataDirectory + @"\TimeControl\TimeControl.version";
25 | if (!File.Exists(versionfile))
26 | {
27 | Write("File: " + versionfile + " missing\n");
28 | }
29 |
30 | try
31 | {
32 | foreach (var line in File.ReadAllLines(versionfile))
33 | {
34 | if (line != null)
35 | {
36 | if (!versionSection)
37 | {
38 | if (line.Contains("\"VERSION\""))
39 | versionSection = true;
40 | }
41 | else
42 | {
43 | if (line.Contains("}"))
44 | versionSection = false;
45 | i = line.IndexOf(":");
46 | i2 = line.IndexOf(",");
47 | if (i2 == -1)
48 | i2 = line.Length;
49 | if (i >= 0 && i2 >= 0)
50 | {
51 | s = line.Substring(i + 1, i2 - i - 1);
52 |
53 | if (line.Contains("MAJOR"))
54 | Int32.TryParse(s, out major);
55 |
56 | if (line.Contains("MINOR"))
57 | Int32.TryParse(s, out minor);
58 |
59 | if (line.Contains("PATCH"))
60 | Int32.TryParse(s, out patch);
61 |
62 | if (line.Contains("BUILD"))
63 | Int32.TryParse(s, out build);
64 | }
65 | }
66 | }
67 | }
68 |
69 | }
70 | catch
71 | {
72 | major = 1;
73 | minor = 0;
74 | patch = 0;
75 | build = 0;
76 | }
77 | //Write("File done");
78 |
79 | #>
80 | // This code was generated by a tool. Any changes made manually will be lost
81 | // the next time this code is regenerated.
82 | //
83 |
84 | using System.Reflection;
85 |
86 | [assembly: AssemblyVersion("<#= major #>.<#= minor #>.<#= patch #>.<#= build #>")]
--------------------------------------------------------------------------------
/TimeControl.Unity/ITimeControlUI.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace TimeControl.Unity
7 | {
8 | public interface ITimeControlUI
9 | {
10 | string Version { get; }
11 |
12 | bool ShowOrbit { get; set; }
13 |
14 | float Alpha { get; set; }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/TimeControl.Unity/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("TimeControl.Unity")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("TimeControl.Unity")]
13 | [assembly: AssemblyCopyright("Copyright © 2017")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("e6071dc5-1ba8-4e65-add9-9cbf872c162e")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // Version information is generated by the AssemblyVersion.tt text template from the KSP .version file
33 |
--------------------------------------------------------------------------------
/TimeControl.Unity/TimeControl.Unity.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {E6071DC5-1BA8-4E65-ADD9-9CBF872C162E}
8 | Library
9 | Properties
10 | TimeControl.Unity
11 | TimeControl.Unity
12 | v3.5
13 | 512
14 | Unity Subset v3.5
15 |
16 |
17 |
18 |
19 | pdbonly
20 | true
21 | bin\Release\
22 | TRACE
23 | prompt
24 | 4
25 |
26 |
27 |
28 |
29 | ..\..\..\..\KSP\KSP_win64-1.3-TEST\KSP_x64_Data\Managed\UnityEngine.dll
30 |
31 |
32 | ..\..\..\..\KSP\KSP_win64-1.3-TEST\KSP_x64_Data\Managed\UnityEngine.UI.dll
33 |
34 |
35 |
36 |
37 | AssemblyVersion.tt
38 | True
39 | True
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 | {35aee226-1a0a-4008-af68-39e9ec55173b}
48 | TimeControl
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 | 10.0
58 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)
59 |
60 |
61 |
62 | true
63 | true
64 | false
65 |
66 |
67 |
68 | $(MSBuildProjectDirectory)\..\GameData
69 |
70 |
71 |
72 |
73 | $(GameDataDirectory)
74 | false
75 |
76 |
77 |
78 |
79 | TextTemplatingFileGenerator
80 | AssemblyVersion.cs
81 |
82 |
83 |
84 | SET KSPTest=D:\KSP\KSP_win64-1.3-TEST
85 | SET GameDataTarget=%25KSPTest%25\GameData\TimeControl
86 | IF NOT EXIST %25GameDataTarget%25 (
87 | MKDIR "%25GameDataTarget%25"
88 | )
89 | copy "$(TargetPath)" "%25GameDataTarget%25"
90 | robocopy "$(SolutionDir)GameData\TimeControl" "%25GameDataTarget%25" /E
91 | exit 0
92 |
93 |
--------------------------------------------------------------------------------
/TimeControl.Unity/WarpSpeedEditor.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using UnityEngine;
3 | using UnityEngine.UI;
4 |
5 | namespace TimeControl.Unity
6 | {
7 | [RequireComponent(typeof(RectTransform))]
8 | public class WarpSpeedEditor : MonoBehaviour
9 | {
10 | [SerializeField]
11 | private Toggle m_OrbitToggle = null;
12 | [SerializeField]
13 | private Toggle m_OrbitDragToggle = null;
14 | [SerializeField]
15 | private Toggle m_OrbitSettingsToggle = null;
16 | [SerializeField]
17 | private Text m_VersionText = null;
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/TimeControl.Unity/bin/Release/Assembly-CSharp-firstpass.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ntwest/TimeControl/4e2da160a139bbb04b7a382b95f695d3fe555127/TimeControl.Unity/bin/Release/Assembly-CSharp-firstpass.dll
--------------------------------------------------------------------------------
/TimeControl.Unity/bin/Release/Assembly-CSharp.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ntwest/TimeControl/4e2da160a139bbb04b7a382b95f695d3fe555127/TimeControl.Unity/bin/Release/Assembly-CSharp.dll
--------------------------------------------------------------------------------
/TimeControl.Unity/bin/Release/KSPAssets.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ntwest/TimeControl/4e2da160a139bbb04b7a382b95f695d3fe555127/TimeControl.Unity/bin/Release/KSPAssets.dll
--------------------------------------------------------------------------------
/TimeControl.Unity/bin/Release/Mono.Cecil.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ntwest/TimeControl/4e2da160a139bbb04b7a382b95f695d3fe555127/TimeControl.Unity/bin/Release/Mono.Cecil.dll
--------------------------------------------------------------------------------
/TimeControl.Unity/bin/Release/System.Xml.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ntwest/TimeControl/4e2da160a139bbb04b7a382b95f695d3fe555127/TimeControl.Unity/bin/Release/System.Xml.dll
--------------------------------------------------------------------------------
/TimeControl.Unity/bin/Release/TDx.TDxInput.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ntwest/TimeControl/4e2da160a139bbb04b7a382b95f695d3fe555127/TimeControl.Unity/bin/Release/TDx.TDxInput.dll
--------------------------------------------------------------------------------
/TimeControl.Unity/bin/Release/TimeControl.Unity.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ntwest/TimeControl/4e2da160a139bbb04b7a382b95f695d3fe555127/TimeControl.Unity/bin/Release/TimeControl.Unity.dll
--------------------------------------------------------------------------------
/TimeControl.Unity/bin/Release/TimeControl.Unity.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ntwest/TimeControl/4e2da160a139bbb04b7a382b95f695d3fe555127/TimeControl.Unity/bin/Release/TimeControl.Unity.pdb
--------------------------------------------------------------------------------
/TimeControl.Unity/bin/Release/TimeControl.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ntwest/TimeControl/4e2da160a139bbb04b7a382b95f695d3fe555127/TimeControl.Unity/bin/Release/TimeControl.dll
--------------------------------------------------------------------------------
/TimeControl.Unity/bin/Release/TimeControl.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ntwest/TimeControl/4e2da160a139bbb04b7a382b95f695d3fe555127/TimeControl.Unity/bin/Release/TimeControl.pdb
--------------------------------------------------------------------------------
/TimeControl.Unity/bin/Release/TrackIRUnity.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ntwest/TimeControl/4e2da160a139bbb04b7a382b95f695d3fe555127/TimeControl.Unity/bin/Release/TrackIRUnity.dll
--------------------------------------------------------------------------------
/TimeControl.Unity/bin/Release/UnityEngine.UI.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ntwest/TimeControl/4e2da160a139bbb04b7a382b95f695d3fe555127/TimeControl.Unity/bin/Release/UnityEngine.UI.dll
--------------------------------------------------------------------------------
/TimeControl.Unity/bin/Release/UnityEngine.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ntwest/TimeControl/4e2da160a139bbb04b7a382b95f695d3fe555127/TimeControl.Unity/bin/Release/UnityEngine.dll
--------------------------------------------------------------------------------
/TimeControl.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 15
4 | VisualStudioVersion = 15.0.26730.16
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TimeControl", "TimeControl\TimeControl.csproj", "{35AEE226-1A0A-4008-AF68-39E9EC55173B}"
7 | EndProject
8 | Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "GameData", "GameData\GameData.shproj", "{CBBB7888-E232-463D-B26E-49A9E510E735}"
9 | EndProject
10 | Global
11 | GlobalSection(SharedMSBuildProjectFiles) = preSolution
12 | GameData\GameData.projitems*{cbbb7888-e232-463d-b26e-49a9e510e735}*SharedItemsImports = 13
13 | EndGlobalSection
14 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
15 | Debug|Any CPU = Debug|Any CPU
16 | Release|Any CPU = Release|Any CPU
17 | EndGlobalSection
18 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
19 | {35AEE226-1A0A-4008-AF68-39E9EC55173B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
20 | {35AEE226-1A0A-4008-AF68-39E9EC55173B}.Debug|Any CPU.Build.0 = Debug|Any CPU
21 | {35AEE226-1A0A-4008-AF68-39E9EC55173B}.Release|Any CPU.ActiveCfg = Release|Any CPU
22 | {35AEE226-1A0A-4008-AF68-39E9EC55173B}.Release|Any CPU.Build.0 = Release|Any CPU
23 | EndGlobalSection
24 | GlobalSection(SolutionProperties) = preSolution
25 | HideSolutionNode = FALSE
26 | EndGlobalSection
27 | GlobalSection(ExtensibilityGlobals) = postSolution
28 | SolutionGuid = {DF4D2CDD-3DE3-4792-B36F-E9D72F5D1B70}
29 | EndGlobalSection
30 | EndGlobal
31 |
--------------------------------------------------------------------------------
/TimeControl/AssemblyVersion.cs:
--------------------------------------------------------------------------------
1 |
2 |
3 | // This code was generated by a tool. Any changes made manually will be lost
4 | // the next time this code is regenerated.
5 | //
6 |
7 | using System.Reflection;
8 |
9 | [assembly: AssemblyVersion("2.10.0.0")]
--------------------------------------------------------------------------------
/TimeControl/AssemblyVersion.tt:
--------------------------------------------------------------------------------
1 | <#@template language="c#" hostspecific="true"#>
2 | <#@ import namespace="System.IO" #>
3 | <#@ output extension=".cs" #>
4 | <#@ parameter type="System.String" name="GameDataDirectory" #>
5 | <#
6 | int major = 0;
7 | int minor = 0;
8 | int build = 0;
9 | int patch = 0;
10 | bool versionSection = false;
11 | int i = 0;
12 | int i2 = 0;
13 | string s;
14 |
15 | // For Visual Studio / MSBuild Build-Time Template Resolution
16 | string GameDataDirectory = Host.ResolveParameterValue("-", "-", "GameDataDirectory");
17 |
18 | // For Visual Studio Design-Time Template Resolution
19 | if (GameDataDirectory == "")
20 | {
21 | GameDataDirectory = System.IO.Path.GetDirectoryName(Host.TemplateFile) + "\\..\\GameData";
22 | }
23 |
24 | string versionfile = GameDataDirectory + @"\TimeControl\TimeControl.version";
25 | if (!File.Exists(versionfile))
26 | {
27 | Write("File: " + versionfile + " missing\n");
28 | }
29 |
30 | try
31 | {
32 | foreach (var line in File.ReadAllLines(versionfile))
33 | {
34 | if (line != null)
35 | {
36 | if (!versionSection)
37 | {
38 | if (line.Contains("\"VERSION\""))
39 | versionSection = true;
40 | }
41 | else
42 | {
43 | if (line.Contains("}"))
44 | versionSection = false;
45 | i = line.IndexOf(":");
46 | i2 = line.IndexOf(",");
47 | if (i2 == -1)
48 | i2 = line.Length;
49 | if (i >= 0 && i2 >= 0)
50 | {
51 | s = line.Substring(i + 1, i2 - i - 1);
52 |
53 | if (line.Contains("MAJOR"))
54 | Int32.TryParse(s, out major);
55 |
56 | if (line.Contains("MINOR"))
57 | Int32.TryParse(s, out minor);
58 |
59 | if (line.Contains("PATCH"))
60 | Int32.TryParse(s, out patch);
61 |
62 | if (line.Contains("BUILD"))
63 | Int32.TryParse(s, out build);
64 | }
65 | }
66 | }
67 | }
68 |
69 | }
70 | catch
71 | {
72 | major = 1;
73 | minor = 0;
74 | patch = 0;
75 | build = 0;
76 | }
77 | //Write("File done");
78 |
79 | #>
80 | // This code was generated by a tool. Any changes made manually will be lost
81 | // the next time this code is regenerated.
82 | //
83 |
84 | using System.Reflection;
85 |
86 | [assembly: AssemblyVersion("<#= major #>.<#= minor #>.<#= patch #>.<#= build #>")]
--------------------------------------------------------------------------------
/TimeControl/FPSKeeperController.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using UnityEngine;
3 | using System.Collections;
4 | using System.Collections.Generic;
5 | using KSP.UI.Dialogs;
6 | using System.Linq;
7 |
8 | namespace TimeControl
9 | {
10 | [KSPAddon( KSPAddon.Startup.Instantly, true )]
11 | internal class FPSKeeperController : MonoBehaviour
12 | {
13 | #region Static
14 | public static FPSKeeperController Instance { get; private set; }
15 | public static bool IsReady { get; private set; } = false;
16 | #endregion
17 |
18 | #region MonoBehavior
19 | private void Awake()
20 | {
21 | const string logBlockName = nameof( FPSKeeperController ) + "." + nameof( Awake );
22 | using (EntryExitLogger.EntryExitLog( logBlockName, EntryExitLoggerOptions.All ))
23 | {
24 | DontDestroyOnLoad( this );
25 | Instance = this;
26 | }
27 | }
28 |
29 | private void Start()
30 | {
31 | const string logBlockName = nameof( FPSKeeperController ) + "." + nameof( Start );
32 | using (EntryExitLogger.EntryExitLog( logBlockName, EntryExitLoggerOptions.All ))
33 | {
34 | StartCoroutine( Configure() );
35 | }
36 | }
37 |
38 | private void OnDestroy()
39 | {
40 | /*
41 | OnTimeControlSlowMoRateChangedEvent?.Remove( SlowMoRateChanged );
42 | */
43 | }
44 | #endregion
45 |
46 | #region Initialization
47 | private IEnumerator Configure()
48 | {
49 | const string logBlockName = nameof( FPSKeeperController ) + "." + nameof( Configure );
50 | using (EntryExitLogger.EntryExitLog( logBlockName, EntryExitLoggerOptions.All ))
51 | {
52 | this.SetDefaults();
53 | this.SubscribeToGameEvents();
54 |
55 | while (TimeWarp.fetch == null || FlightGlobals.Bodies == null || FlightGlobals.Bodies.Count <= 0)
56 | {
57 | yield return new WaitForSeconds( 1f );
58 | }
59 |
60 | //Log.Info( nameof( FPSKeeperController ) + " is Ready!", logBlockName );
61 | //FPSKeeperController.IsReady = true;
62 | yield break;
63 | }
64 | }
65 |
66 | private void SetDefaults()
67 | {
68 | const string logBlockName = nameof( FPSKeeperController ) + "." + nameof( SetDefaults );
69 | using (EntryExitLogger.EntryExitLog( logBlockName, EntryExitLoggerOptions.All ))
70 | {
71 | /*
72 | defaultDeltaTime = Time.fixedDeltaTime;
73 | currentScreenMessage = null;
74 | currentScreenMessageStyle = ScreenMessageStyle.UPPER_CENTER;
75 | currentScreenMessageDuration = Mathf.Infinity;
76 | currentScreenMessagePrefix = "SLOW-MOTION";
77 | UpdateDefaultScreenMessage();
78 | */
79 | }
80 | }
81 |
82 | private void SubscribeToGameEvents()
83 | {
84 | const string logBlockName = nameof( FPSKeeperController ) + "." + nameof( SubscribeToGameEvents );
85 | using (EntryExitLogger.EntryExitLog( logBlockName, EntryExitLoggerOptions.All ))
86 | {
87 | /*
88 | GameEvents.onGamePause.Add( this.onGamePause );
89 | GameEvents.onGameUnpause.Add( this.onGameUnpause );
90 | GameEvents.onGameSceneLoadRequested.Add( this.onGameSceneLoadRequested );
91 |
92 | OnTimeControlSlowMoRateChangedEvent = GameEvents.FindEvent>( nameof( TimeControlEvents.OnTimeControlSlowMoRateChanged ) );
93 | OnTimeControlSlowMoRateChangedEvent?.Add( SlowMoRateChanged );
94 | */
95 | }
96 | }
97 | #endregion
98 |
99 | private void Update()
100 | {
101 | UpdateFPSKeeper();
102 | }
103 |
104 | private void UpdateFPSKeeper()
105 | {
106 | /*
107 | if (!IsFpsKeeperActive)
108 | return;
109 |
110 | fpsMin = (int)Mathf.Round( Settings.Instance.FpsMinSlider / 5 ) * 5;
111 | if (Mathf.Abs( PerformanceManager.Instance.FPS - fpsMin ) > 2.5)
112 | {
113 | if (PerformanceManager.Instance.FPS < fpsMin)
114 | fpsKeeperFactor += 1;
115 | else
116 | fpsKeeperFactor -= 1;
117 | }
118 | fpsKeeperFactor = Mathf.Clamp( fpsKeeperFactor, 0, 73 ); //0-10 are .01 steps down with max delta, 11-110 are steps of time scale from 1x down to 1/100x in 1/100 increments
119 |
120 | if (fpsKeeperFactor < 11)
121 | {
122 | TimeSlider = 0f;
123 | MaxDeltaTimeSlider = .12f - (fpsKeeperFactor * .01f);
124 |
125 | }
126 | else
127 | {
128 | if
129 | SlowMoController.Instance.ActivateSlowMo();
130 |
131 | MaxDeltaTimeSlider = 0.02f;
132 | TimeSlider = (float)(fpsKeeperFactor - 10) / 64f;
133 | }
134 | */
135 | }
136 | }
137 | }
138 |
139 | /*
140 | All code in this file Copyright(c) 2016 Nate West
141 |
142 | The MIT License (MIT)
143 |
144 | Permission is hereby granted, free of charge, to any person obtaining a copy
145 | of this software and associated documentation files (the "Software"), to deal
146 | in the Software without restriction, including without limitation the rights
147 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
148 | copies of the Software, and to permit persons to whom the Software is
149 | furnished to do so, subject to the following conditions:
150 |
151 | The above copyright notice and this permission notice shall be included in all
152 | copies or substantial portions of the Software.
153 |
154 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
155 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
156 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
157 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
158 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
159 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
160 | SOFTWARE.
161 | */
162 |
--------------------------------------------------------------------------------
/TimeControl/IMGUI/DetailsIMGUI.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using UnityEngine;
3 |
4 | namespace TimeControl
5 | {
6 | internal class DetailsIMGUI
7 | {
8 | public DetailsIMGUI()
9 | {
10 | }
11 |
12 | public void DetailsGUI()
13 | {
14 | GUILayout.BeginVertical();
15 | {
16 | PerformanceManager.Instance.PerformanceCountersOn = GUILayout.Toggle( PerformanceManager.Instance.PerformanceCountersOn, "Performance Counters" );
17 |
18 | GUILayout.Label( "UT: " + Math.Round( Planetarium.GetUniversalTime(), 0 ) ); // Creates garbage, but not worth caching since it's monotonically increasing
19 |
20 | GUILayout.Label( "Time Scale: ".MemoizedConcat( TimeController.Instance.TimeScale.MemoizedToString() ) );
21 | GUILayout.Label( "Physics Delta: ".MemoizedConcat( TimeController.Instance.FixedDeltaTime.MemoizedToString() ) );
22 |
23 | if ((PerformanceManager.Instance?.PerformanceCountersOn ?? false))
24 | {
25 | GUILayout.Label( "UT passing per sec: ".MemoizedConcat( Math.Round( PerformanceManager.Instance.GametimeToRealtimeRatio, 2 ).MemoizedToString() ) );
26 | GUILayout.Label( "Physics Updates per sec: ".MemoizedConcat( Math.Round( PerformanceManager.Instance.PhysicsUpdatesPerSecond, 2 ).MemoizedToString() ) );
27 | }
28 | else
29 | {
30 | GUILayout.Label( "UT passing per sec: N/A" );
31 | GUILayout.Label( "Physics Updates per sec: N/A" );
32 | }
33 |
34 | GUILayout.Label( "Current Max Delta Time: ".MemoizedConcat( TimeController.Instance.MaximumDeltaTime.MemoizedToString() ) );
35 | GUILayout.Label( "Max Delta Time Setting: ".MemoizedConcat( TimeController.Instance.MaximumDeltaTimeSetting.MemoizedToString() ) );
36 |
37 |
38 | TimeController.Instance.MaximumDeltaTimeSetting = GUILayout.HorizontalSlider( TimeController.Instance.MaximumDeltaTimeSetting, TimeController.MaximumDeltaTimeMax, TimeController.MaximumDeltaTimeMin );
39 | }
40 | GUILayout.EndVertical();
41 | }
42 | }
43 | }
44 |
45 | /*
46 | All code in this file Copyright(c) 2016 Nate West
47 |
48 | The MIT License (MIT)
49 |
50 | Permission is hereby granted, free of charge, to any person obtaining a copy
51 | of this software and associated documentation files (the "Software"), to deal
52 | in the Software without restriction, including without limitation the rights
53 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
54 | copies of the Software, and to permit persons to whom the Software is
55 | furnished to do so, subject to the following conditions:
56 |
57 | The above copyright notice and this permission notice shall be included in all
58 | copies or substantial portions of the Software.
59 |
60 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
61 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
62 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
63 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
64 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
65 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
66 | SOFTWARE.
67 |
68 | */
69 |
--------------------------------------------------------------------------------
/TimeControl/IMGUI/HyperIMGUI.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using UnityEngine;
4 |
5 | namespace TimeControl
6 | {
7 | internal class HyperIMGUI
8 | {
9 | private string hyperWarpHours = "0";
10 | private string hyperWarpMinutes = "0";
11 | private string hyperWarpSeconds = "0";
12 |
13 | private List maxDeltaButtons = new List() { 0.02f, 0.08f, 0.2f };
14 | private List maxRateButtons = new List() { 5, 10, 20, 50 };
15 | private List phyAccuracyButtons = new List() { 1, 3, 6 };
16 |
17 | SharedIMGUI sharedGUI;
18 |
19 | public HyperIMGUI()
20 | {
21 | sharedGUI = new SharedIMGUI();
22 | }
23 |
24 | public void HyperGUI()
25 | {
26 | if (!HyperWarpController.IsReady)
27 | {
28 | return;
29 | }
30 |
31 | bool priorGUIEnabled = GUI.enabled;
32 | GUI.enabled = priorGUIEnabled && HyperWarpController.Instance.CanHyperWarp;
33 |
34 | {
35 | GUILayout.BeginVertical();
36 | {
37 | GUIRateButtons();
38 | GUIMaxRate();
39 | GUIMinPhys();
40 | GUIMaxDelta();
41 | GUIButtons();
42 | GUILayout.Label( "", GUILayout.Height( 5 ) );
43 | GUIWarpTime();
44 | GUILayout.Label( "", GUILayout.Height( 5 ) );
45 | sharedGUI.GUIThrottleControl();
46 | }
47 | GUILayout.EndVertical();
48 | }
49 | GUI.enabled = priorGUIEnabled;
50 | }
51 |
52 | private void GUIRateButtons()
53 | {
54 | GUILayout.BeginHorizontal();
55 | {
56 | GUILayout.Label( "Predefined Rates" );
57 |
58 | if (GUILayout.Button( "-" , GUILayout.Width( 20 ) ) )
59 | {
60 | HyperWarpController.Instance.ChangeToLowerRate();
61 | }
62 |
63 | if (GUILayout.Button( "+", GUILayout.Width( 20 ) ) )
64 | {
65 | HyperWarpController.Instance.ChangeToHigherRate();
66 | }
67 | }
68 | GUILayout.EndHorizontal();
69 | }
70 |
71 | private void GUIMaxRate()
72 | {
73 | string hyperMaxRateLabel = "Attempted Rate: ".MemoizedConcat( Mathf.Round( HyperWarpController.Instance.MaxAttemptedRate ).MemoizedToString() );
74 | Action updateHyperMaxRate = delegate (float f) { HyperWarpController.Instance.MaxAttemptedRate = f; };
75 | // Force slider to select integer values between min and max
76 | Func modifyFieldHyperMaxRate = delegate (float f) { return Mathf.Round( f ); };
77 |
78 | IMGUIExtensions.floatTextBoxSliderPlusMinusWithButtonList( hyperMaxRateLabel, HyperWarpController.Instance.MaxAttemptedRate, HyperWarpController.AttemptedRateMin, HyperWarpController.AttemptedRateMax, 1f, updateHyperMaxRate, maxRateButtons, modifyFieldHyperMaxRate );
79 | }
80 |
81 |
82 | private void GUIMinPhys()
83 | {
84 | const float physIncrement = 0.1f;
85 |
86 | string hyperMinPhysLabel = "Physics Accuracy: ".MemoizedConcat( HyperWarpController.Instance.PhysicsAccuracy.MemoizedToString() );
87 |
88 | if (HyperWarpController.Instance.PhysicsAccuracy > 4f)
89 | {
90 | hyperMinPhysLabel = hyperMinPhysLabel.MemoizedConcat( " !!! DANGER !!!" );
91 | }
92 |
93 | Action updatehyperMinPhys = delegate (float f)
94 | {
95 | HyperWarpController.Instance.PhysicsAccuracy = f;
96 | };
97 |
98 | Func modifyFieldMinPhys = delegate (float f) { return Mathf.Round( f * (1f / physIncrement) ) / (1f / physIncrement); };
99 |
100 | IMGUIExtensions.floatTextBoxSliderPlusMinusWithButtonList( hyperMinPhysLabel, HyperWarpController.Instance.PhysicsAccuracy, HyperWarpController.PhysicsAccuracyMin, HyperWarpController.PhysicsAccuracyMax, physIncrement, updatehyperMinPhys, phyAccuracyButtons, modifyFieldMinPhys );
101 | }
102 |
103 | private void GUIMaxDelta()
104 | {
105 | const float deltaIncrement = 0.01f;
106 |
107 | string hyperMaxRateLabel = "Max Delta Time During Hyper-Warp: ".MemoizedConcat( HyperWarpController.Instance.MaximumDeltaTime.MemoizedToString() );
108 |
109 | if (HyperWarpController.Instance.MaximumDeltaTime > 0.12f)
110 | {
111 | hyperMaxRateLabel = hyperMaxRateLabel.MemoizedConcat( " - Low FPS Likely" );
112 | }
113 |
114 | Action updateHyperMaxDelta = delegate (float f) { HyperWarpController.Instance.MaximumDeltaTime = f; };
115 | // Force slider to select integer values between min and max
116 | Func modifyFieldHyperMaxDelta = delegate (float f) { return Mathf.Round( f * (1f / deltaIncrement) ) / (1f / deltaIncrement); };
117 |
118 | IMGUIExtensions.floatTextBoxSliderPlusMinus( hyperMaxRateLabel, HyperWarpController.Instance.MaximumDeltaTime, TimeController.MaximumDeltaTimeMin, TimeController.MaximumDeltaTimeMax, deltaIncrement, updateHyperMaxDelta, modifyFieldHyperMaxDelta );
119 | }
120 |
121 | private void GUIButtons()
122 | {
123 | GUILayout.BeginHorizontal();
124 | {
125 | if (!HyperWarpController.Instance.IsHyperWarping)
126 | {
127 | if (GUILayout.Button( "HyperWarp" ))
128 | {
129 | HyperWarpController.Instance.ToggleHyper();
130 | }
131 | }
132 | else
133 | {
134 | if (GUILayout.Button( "End HyperWarp" ))
135 | {
136 | HyperWarpController.Instance.DeactivateHyper();
137 | }
138 | }
139 | }
140 | GUILayout.EndHorizontal();
141 | }
142 |
143 | private void GUIWarpTime()
144 | {
145 | GUILayout.BeginHorizontal();
146 | {
147 | GUILayout.Label( "Timed Warp:" );
148 | hyperWarpHours = GUILayout.TextField( hyperWarpHours, GUILayout.Width( 35 ) );
149 | GUILayout.Label( "h " );
150 | hyperWarpMinutes = GUILayout.TextField( hyperWarpMinutes, GUILayout.Width( 35 ) );
151 | GUILayout.Label( "m " );
152 | hyperWarpSeconds = GUILayout.TextField( hyperWarpSeconds, GUILayout.Width( 35 ) );
153 | GUILayout.Label( "s" );
154 | }
155 | GUILayout.EndHorizontal();
156 |
157 | HyperWarpController.Instance.HyperPauseOnTimeReached = GUILayout.Toggle( HyperWarpController.Instance.HyperPauseOnTimeReached, "Pause on time reached" );
158 |
159 | if (GUILayout.Button( "Timed Warp" ))
160 | {
161 | int hrs = int.TryParse( hyperWarpHours, out hrs ) ? hrs : -1;
162 | int min = int.TryParse( hyperWarpMinutes, out min ) ? min : -1;
163 | int sec = int.TryParse( hyperWarpSeconds, out sec ) ? sec : -1;
164 |
165 | bool result = HyperWarpController.Instance.HyperWarpForDuration( hrs, min, sec );
166 | if (result)
167 | {
168 | hyperWarpHours = "0";
169 | hyperWarpMinutes = "0";
170 | hyperWarpSeconds = "0";
171 | }
172 | }
173 | }
174 | }
175 | }
176 |
177 | /*
178 | All code in this file Copyright(c) 2016 Nate West
179 |
180 | The MIT License (MIT)
181 |
182 | Permission is hereby granted, free of charge, to any person obtaining a copy
183 | of this software and associated documentation files (the "Software"), to deal
184 | in the Software without restriction, including without limitation the rights
185 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
186 | copies of the Software, and to permit persons to whom the Software is
187 | furnished to do so, subject to the following conditions:
188 |
189 | The above copyright notice and this permission notice shall be included in all
190 | copies or substantial portions of the Software.
191 |
192 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
193 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
194 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
195 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
196 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
197 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
198 | SOFTWARE.
199 | */
200 |
--------------------------------------------------------------------------------
/TimeControl/IMGUI/KeyBindingsAddIMGUI.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 | using TimeControl.KeyBindings;
3 |
4 | namespace TimeControl
5 | {
6 | internal class KeyBindingsAddIMGUI
7 | {
8 | private string sCurrentValue;
9 | private string sValue;
10 | private bool usePercentage;
11 | private bool valueParsed = false;
12 |
13 | TimeControlKeyBinding kb;
14 |
15 | public KeyBindingsAddIMGUI(TimeControlKeyBinding kb)
16 | {
17 | this.kb = kb;
18 |
19 | if (kb is TimeControlKeyBindingValue tckbv)
20 | {
21 | usePercentage = (tckbv is SlowMoSetRate || tckbv is SlowMoSlowDown || tckbv is SlowMoSpeedUp);
22 |
23 | if (!usePercentage)
24 | {
25 | sValue = sCurrentValue = tckbv.V.MemoizedToString();
26 | }
27 | else
28 | {
29 | sValue = sCurrentValue = Mathf.RoundToInt( tckbv.V * 100.0f ).MemoizedToString();
30 | }
31 |
32 | parseValue();
33 | }
34 | }
35 |
36 | private void parseValue()
37 | {
38 | if (kb is TimeControlKeyBindingValue tckbv)
39 | {
40 | valueParsed = float.TryParse( sValue, out float f );
41 | if (valueParsed)
42 | {
43 | if (!usePercentage)
44 | {
45 | tckbv.V = f;
46 | sValue = sCurrentValue = tckbv.V.MemoizedToString();
47 | }
48 | else
49 | {
50 | tckbv.V = (f / 100.0f);
51 | sValue = sCurrentValue = Mathf.RoundToInt( tckbv.V * 100.0f ).MemoizedToString();
52 | }
53 | }
54 | }
55 | }
56 |
57 | public bool KeyBindingsAddGUI()
58 | {
59 | if (!KeyboardInputManager.IsReady)
60 | {
61 | return true;
62 | }
63 |
64 | bool guiPriorEnabled = GUI.enabled;
65 | Color guiPriorColor = GUI.contentColor;
66 |
67 | GUILayout.BeginHorizontal();
68 | {
69 | if (kb is TimeControlKeyBindingValue tckbv)
70 | {
71 | GUILayout.Label( kb.SetDescription, GUILayout.Width( 225 ) );
72 | sValue = GUILayout.TextField( sValue, GUILayout.Width( 50 ) );
73 | if (sValue != sCurrentValue)
74 | {
75 | parseValue();
76 | }
77 | GUI.enabled = guiPriorEnabled && valueParsed;
78 | }
79 | else
80 | {
81 | GUILayout.Label( kb.SetDescription, GUILayout.Width( 280 ) );
82 | }
83 | if (GUILayout.Button( "ADD", GUILayout.Width( 40 ) ))
84 | {
85 | var newkb = TimeControlKeyBindingFactory.LoadFromConfigNode( kb.GetConfigNode() );
86 | KeyboardInputManager.Instance.AddKeyBinding( newkb );
87 | return true;
88 | }
89 | }
90 | GUILayout.EndHorizontal();
91 |
92 | GUI.contentColor = guiPriorColor;
93 | GUI.enabled = guiPriorEnabled;
94 | return false;
95 | }
96 | }
97 | }
98 |
99 | /*
100 | All code in this file Copyright(c) 2016 Nate West
101 |
102 | The MIT License (MIT)
103 |
104 | Permission is hereby granted, free of charge, to any person obtaining a copy
105 | of this software and associated documentation files (the "Software"), to deal
106 | in the Software without restriction, including without limitation the rights
107 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
108 | copies of the Software, and to permit persons to whom the Software is
109 | furnished to do so, subject to the following conditions:
110 |
111 | The above copyright notice and this permission notice shall be included in all
112 | copies or substantial portions of the Software.
113 |
114 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
115 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
116 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
117 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
118 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
119 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
120 | SOFTWARE.
121 | */
122 |
--------------------------------------------------------------------------------
/TimeControl/IMGUI/SharedIMGUI.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using UnityEngine;
4 |
5 | namespace TimeControl
6 | {
7 | internal class SharedIMGUI
8 | {
9 | private List throttleRateButtons = new List() { 0, 50, 100 };
10 |
11 | public SharedIMGUI()
12 | {
13 |
14 | }
15 |
16 | bool throttleToggle = false;
17 | float throttleSet = 0f;
18 |
19 | internal void GUIThrottleControl()
20 | {
21 | throttleToggle = GUILayout.Toggle( throttleToggle, "Throttle Control: " + Mathf.Round( throttleSet * 100 ) + "%" );
22 |
23 | Action updateThrottle = delegate (float f)
24 | {
25 | throttleSet = f / 100.0f;
26 | };
27 |
28 | if (FlightInputHandler.state != null && throttleToggle && FlightInputHandler.state.mainThrottle != throttleSet)
29 | {
30 | FlightInputHandler.state.mainThrottle = throttleSet;
31 | }
32 |
33 | // Force slider to select 1 decimal place values between min and max
34 | Func modifyFieldThrottle = delegate (float f)
35 | {
36 | return (Mathf.Floor( f ));
37 | };
38 |
39 | IMGUIExtensions.floatTextBoxSliderPlusMinusWithButtonList( null, (throttleSet * 100f), 0.0f, 100.0f, 1f, updateThrottle, throttleRateButtons, modifyFieldThrottle );
40 | }
41 | }
42 | }
43 | /*
44 | All code in this file Copyright(c) 2016 Nate West
45 |
46 | The MIT License (MIT)
47 |
48 | Permission is hereby granted, free of charge, to any person obtaining a copy
49 | of this software and associated documentation files (the "Software"), to deal
50 | in the Software without restriction, including without limitation the rights
51 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
52 | copies of the Software, and to permit persons to whom the Software is
53 | furnished to do so, subject to the following conditions:
54 |
55 | The above copyright notice and this permission notice shall be included in all
56 | copies or substantial portions of the Software.
57 |
58 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
59 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
60 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
61 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
62 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
63 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
64 | SOFTWARE.
65 | */
66 |
--------------------------------------------------------------------------------
/TimeControl/IMGUI/SlowMoIMGUI.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using UnityEngine;
3 |
4 | namespace TimeControl
5 | {
6 | internal class SlowMoIMGUI
7 | {
8 | //private int fpsMin = 5;
9 | //private int fpsKeeperFactor = 0;
10 | //private bool fpsKeeperActive;
11 |
12 | SharedIMGUI sharedGUI;
13 | //float ts = 0f;
14 | bool deltaLocked = true;
15 |
16 | public SlowMoIMGUI()
17 | {
18 | sharedGUI = new SharedIMGUI();
19 | deltaLocked = SlowMoController.Instance?.DeltaLocked ?? false;
20 | }
21 |
22 | public void SlowMoGUI()
23 | {
24 | //modeSlowmoFPSKeeper();
25 | GUITimeScale();
26 | GUIButtons();
27 | }
28 | #region Slow-Mo GUI
29 |
30 | //private void modeSlowmoFPSKeeper()
31 | //{
32 | // GUI.enabled = (TimeController.Instance.IsOperational
33 | // && (TimeController.Instance.CurrentWarpState == TimeControllable.None || TimeController.Instance.CurrentWarpState == TimeControllable.SlowMo));
34 |
35 | // bool fpsKeeperActive = GUILayout.Toggle( TimeController.Instance.IsFpsKeeperActive, "FPS Keeper: " + Mathf.Round( Settings.Instance.FpsMinSlider / 5 ) * 5 + " fps" );
36 | // if (fpsKeeperActive != TimeController.Instance.IsFpsKeeperActive)
37 | // TimeController.Instance.SetFPSKeeper( fpsKeeperActive );
38 |
39 | // Settings.Instance.FpsMinSlider = (int)GUILayout.HorizontalSlider( Settings.Instance.FpsMinSlider, 5, 60 );
40 |
41 | // GUI.enabled = true;
42 | //}
43 |
44 | private void GUITimeScale()
45 | {
46 | bool priorGUIEnabled = GUI.enabled;
47 |
48 | GUI.enabled = priorGUIEnabled && (SlowMoController.Instance?.CanSlowMo ?? false);
49 |
50 | GUILayout.BeginVertical();
51 | {
52 | SlowMoController.Instance.DeltaLocked = GUILayout.Toggle( SlowMoController.Instance.DeltaLocked, "Lock physics delta to default" );
53 |
54 | float ratePct = (float)Math.Round( SlowMoController.Instance.SlowMoRate * 100f, 0 );
55 | string slowMoSliderLabel = "Slow Motion Rate: ".MemoizedConcat( ratePct.MemoizedToString().MemoizedConcat( "%" ) );
56 |
57 | Action updateSlowMo = delegate (float f)
58 | {
59 | SlowMoController.Instance.SlowMoRate = (float)Math.Round( f / 100f, 2 );
60 | };
61 |
62 | Func modifySlowMo = delegate (float f) { return Mathf.Floor( f ); };
63 | IMGUIExtensions.floatTextBoxSliderPlusMinus( slowMoSliderLabel, ratePct, 0f, 100f, 1f, updateSlowMo, modifySlowMo, true );
64 |
65 | GUILayout.Label( "", GUILayout.Height( 5 ) );
66 |
67 | sharedGUI.GUIThrottleControl();
68 | }
69 | GUILayout.EndVertical();
70 |
71 | GUI.enabled = priorGUIEnabled;
72 | }
73 |
74 | private void GUIButtons()
75 | {
76 | GUILayout.BeginHorizontal();
77 | {
78 | if (!SlowMoController.Instance.IsSlowMo)
79 | {
80 | if (GUILayout.Button( "Activate Slow-Motion" ))
81 | {
82 | SlowMoController.Instance.ActivateSlowMo();
83 | }
84 | }
85 | else
86 | {
87 | if (GUILayout.Button( "Deactivate Slow-Motion" ))
88 | {
89 | SlowMoController.Instance.DeactivateSlowMo();
90 | }
91 | }
92 | }
93 | GUILayout.EndHorizontal();
94 | }
95 |
96 | #endregion
97 |
98 | }
99 | }
100 | /*
101 | All code in this file Copyright(c) 2016 Nate West
102 |
103 | The MIT License (MIT)
104 |
105 | Permission is hereby granted, free of charge, to any person obtaining a copy
106 | of this software and associated documentation files (the "Software"), to deal
107 | in the Software without restriction, including without limitation the rights
108 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
109 | copies of the Software, and to permit persons to whom the Software is
110 | furnished to do so, subject to the following conditions:
111 |
112 | The above copyright notice and this permission notice shall be included in all
113 | copies or substantial portions of the Software.
114 |
115 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
116 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
117 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
118 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
119 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
120 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
121 | SOFTWARE.
122 | */
123 |
--------------------------------------------------------------------------------
/TimeControl/KeyBindings/GUIToggle.cs:
--------------------------------------------------------------------------------
1 | namespace TimeControl.KeyBindings
2 | {
3 | public class GUIToggle : TimeControlKeyBinding
4 | {
5 | public GUIToggle()
6 | {
7 | TimeControlKeyActionName = TimeControlKeyAction.GUIToggle;
8 | SetDescription = Description = "Toggle GUI";
9 | }
10 |
11 | public override void Press()
12 | {
13 | if (TimeControlIMGUI.IsReady)
14 | {
15 | TimeControlIMGUI.Instance.ToggleGUIVisibility();
16 | }
17 | }
18 | }
19 | }
20 | /*
21 | All code in this file Copyright(c) 2016 Nate West
22 | Rewritten from scratch, but based on code Copyright(c) 2014 Xaiier using the same license as below
23 |
24 | The MIT License (MIT)
25 |
26 | Permission is hereby granted, free of charge, to any person obtaining a copy
27 | of this software and associated documentation files (the "Software"), to deal
28 | in the Software without restriction, including without limitation the rights
29 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
30 | copies of the Software, and to permit persons to whom the Software is
31 | furnished to do so, subject to the following conditions:
32 |
33 | The above copyright notice and this permission notice shall be included in all
34 | copies or substantial portions of the Software.
35 |
36 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
37 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
38 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
39 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
40 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
41 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
42 | SOFTWARE.
43 | */
--------------------------------------------------------------------------------
/TimeControl/KeyBindings/HyperActivate.cs:
--------------------------------------------------------------------------------
1 | namespace TimeControl.KeyBindings
2 | {
3 | public class HyperActivate : TimeControlKeyBinding
4 | {
5 | public HyperActivate()
6 | {
7 | TimeControlKeyActionName = TimeControlKeyAction.HyperActivate;
8 | SetDescription = Description = "Activate Hyper-Warp";
9 | }
10 |
11 | public override void Press()
12 | {
13 | if (HyperWarpController.IsReady)
14 | {
15 | HyperWarpController.Instance.ActivateHyper();
16 | }
17 | }
18 | }
19 | }
20 | /*
21 | All code in this file Copyright(c) 2016 Nate West
22 | Rewritten from scratch, but based on code Copyright(c) 2014 Xaiier using the same license as below
23 |
24 | The MIT License (MIT)
25 |
26 | Permission is hereby granted, free of charge, to any person obtaining a copy
27 | of this software and associated documentation files (the "Software"), to deal
28 | in the Software without restriction, including without limitation the rights
29 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
30 | copies of the Software, and to permit persons to whom the Software is
31 | furnished to do so, subject to the following conditions:
32 |
33 | The above copyright notice and this permission notice shall be included in all
34 | copies or substantial portions of the Software.
35 |
36 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
37 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
38 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
39 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
40 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
41 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
42 | SOFTWARE.
43 | */
44 |
--------------------------------------------------------------------------------
/TimeControl/KeyBindings/HyperDeactivate.cs:
--------------------------------------------------------------------------------
1 | namespace TimeControl.KeyBindings
2 | {
3 | public class HyperDeactivate : TimeControlKeyBinding
4 | {
5 | public HyperDeactivate()
6 | {
7 | TimeControlKeyActionName = TimeControlKeyAction.HyperDeactivate;
8 | SetDescription = Description = "Dectivate Hyper-Warp";
9 | }
10 |
11 | public override void Press()
12 | {
13 | if (HyperWarpController.IsReady)
14 | {
15 | HyperWarpController.Instance.DeactivateHyper();
16 | }
17 | }
18 | }
19 | }
20 | /*
21 | All code in this file Copyright(c) 2016 Nate West
22 | Rewritten from scratch, but based on code Copyright(c) 2014 Xaiier using the same license as below
23 |
24 | The MIT License (MIT)
25 |
26 | Permission is hereby granted, free of charge, to any person obtaining a copy
27 | of this software and associated documentation files (the "Software"), to deal
28 | in the Software without restriction, including without limitation the rights
29 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
30 | copies of the Software, and to permit persons to whom the Software is
31 | furnished to do so, subject to the following conditions:
32 |
33 | The above copyright notice and this permission notice shall be included in all
34 | copies or substantial portions of the Software.
35 |
36 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
37 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
38 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
39 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
40 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
41 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
42 | SOFTWARE.
43 | */
44 |
--------------------------------------------------------------------------------
/TimeControl/KeyBindings/HyperPhysicsAccuracyDown.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace TimeControl.KeyBindings
4 | {
5 | public class HyperPhysicsAccuracyDown : TimeControlKeyBindingValue
6 | {
7 | private float v = 0.5f;
8 |
9 | private void UpdateDescription()
10 | {
11 | Description = String.Format( "Hyper-Warp Accuracy -{0}", v );
12 | }
13 |
14 | public HyperPhysicsAccuracyDown()
15 | {
16 | TimeControlKeyActionName = TimeControlKeyAction.HyperPhysicsAccuracyDown;
17 | SetDescription = "Hyper-Warp Decrease Accuracy By: ";
18 | FireWhileHoldingKeyDown = true;
19 | UpdateDescription();
20 | }
21 |
22 | public override float VMax
23 | {
24 | get => 3f;
25 | }
26 |
27 | public override float VMin
28 | {
29 | get => 0.05f;
30 | }
31 |
32 | public override float V
33 | {
34 | get => v;
35 | set
36 | {
37 | if (value >= VMax)
38 | {
39 | v = VMax;
40 | }
41 | else if (value <= VMin)
42 | {
43 | v = VMin;
44 | }
45 | else
46 | {
47 | v = (float)Math.Round( value, 2 );
48 | }
49 |
50 | UpdateDescription();
51 | }
52 | }
53 |
54 | public override void Press()
55 | {
56 | if (HyperWarpController.IsReady)
57 | {
58 | HyperWarpController.Instance.DecreasePhysicsAccuracy( v );
59 | }
60 | }
61 | }
62 | }
63 | /*
64 | All code in this file Copyright(c) 2016 Nate West
65 | Rewritten from scratch, but based on code Copyright(c) 2014 Xaiier using the same license as below
66 |
67 | The MIT License (MIT)
68 |
69 | Permission is hereby granted, free of charge, to any person obtaining a copy
70 | of this software and associated documentation files (the "Software"), to deal
71 | in the Software without restriction, including without limitation the rights
72 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
73 | copies of the Software, and to permit persons to whom the Software is
74 | furnished to do so, subject to the following conditions:
75 |
76 | The above copyright notice and this permission notice shall be included in all
77 | copies or substantial portions of the Software.
78 |
79 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
80 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
81 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
82 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
83 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
84 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
85 | SOFTWARE.
86 | */
87 |
--------------------------------------------------------------------------------
/TimeControl/KeyBindings/HyperPhysicsAccuracySet.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace TimeControl.KeyBindings
4 | {
5 | public class HyperPhysicsAccuracySet : TimeControlKeyBindingValue
6 | {
7 | private float v = 1f;
8 |
9 | private void UpdateDescription()
10 | {
11 | Description = String.Format( "Set Hyper-Warp Accuracy to {0}", v );
12 | }
13 |
14 | public HyperPhysicsAccuracySet()
15 | {
16 | TimeControlKeyActionName = TimeControlKeyAction.HyperPhysicsAccuracySet;
17 | SetDescription = "Hyper-Warp Set Accuracy To: ";
18 | UpdateDescription();
19 | }
20 |
21 | public override float VMax
22 | {
23 | get => HyperWarpController.PhysicsAccuracyMax;
24 | }
25 |
26 | public override float VMin
27 | {
28 | get => HyperWarpController.PhysicsAccuracyMin;
29 | }
30 |
31 | public override float V
32 | {
33 | get => v;
34 | set
35 | {
36 | if (value >= VMax)
37 | {
38 | v = VMax;
39 | }
40 | else if (value <= VMin)
41 | {
42 | v = VMin;
43 | }
44 | else
45 | {
46 | v = (float)Math.Round( value, 2 );
47 | }
48 |
49 | UpdateDescription();
50 | }
51 | }
52 |
53 | public override void Press()
54 | {
55 | if (HyperWarpController.IsReady)
56 | {
57 | HyperWarpController.Instance.PhysicsAccuracy = v;
58 | }
59 | }
60 | }
61 | }
62 | /*
63 | All code in this file Copyright(c) 2016 Nate West
64 |
65 | The MIT License (MIT)
66 |
67 | Permission is hereby granted, free of charge, to any person obtaining a copy
68 | of this software and associated documentation files (the "Software"), to deal
69 | in the Software without restriction, including without limitation the rights
70 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
71 | copies of the Software, and to permit persons to whom the Software is
72 | furnished to do so, subject to the following conditions:
73 |
74 | The above copyright notice and this permission notice shall be included in all
75 | copies or substantial portions of the Software.
76 |
77 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
78 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
79 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
80 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
81 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
82 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
83 | SOFTWARE.
84 | */
85 |
--------------------------------------------------------------------------------
/TimeControl/KeyBindings/HyperPhysicsAccuracyUp.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace TimeControl.KeyBindings
4 | {
5 | public class HyperPhysicsAccuracyUp : TimeControlKeyBindingValue
6 | {
7 | private float v = 0.5f;
8 |
9 | private void UpdateDescription()
10 | {
11 | Description = String.Format( "Hyper-Warp Accuracy +{0}", v );
12 | }
13 |
14 | public HyperPhysicsAccuracyUp()
15 | {
16 | TimeControlKeyActionName = TimeControlKeyAction.HyperPhysicsAccuracyUp;
17 | SetDescription = "Hyper-Warp Increase Accuracy By: ";
18 | FireWhileHoldingKeyDown = true;
19 | UpdateDescription();
20 | }
21 |
22 | public override float VMax
23 | {
24 | get => 3f;
25 | }
26 |
27 | public override float VMin
28 | {
29 | get => 0.05f;
30 | }
31 |
32 | public override float V
33 | {
34 | get => v;
35 | set
36 | {
37 | if (value >= VMax)
38 | {
39 | v = VMax;
40 | }
41 | else if (value <= VMin)
42 | {
43 | v = VMin;
44 | }
45 | else
46 | {
47 | v = (float)Math.Round( value, 2 );
48 | }
49 |
50 | UpdateDescription();
51 | }
52 | }
53 |
54 | public override void Press()
55 | {
56 | if (HyperWarpController.IsReady)
57 | {
58 | HyperWarpController.Instance.IncreasePhysicsAccuracy( v );
59 | }
60 | }
61 | }
62 | }
63 | /*
64 | All code in this file Copyright(c) 2016 Nate West
65 |
66 | The MIT License (MIT)
67 |
68 | Permission is hereby granted, free of charge, to any person obtaining a copy
69 | of this software and associated documentation files (the "Software"), to deal
70 | in the Software without restriction, including without limitation the rights
71 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
72 | copies of the Software, and to permit persons to whom the Software is
73 | furnished to do so, subject to the following conditions:
74 |
75 | The above copyright notice and this permission notice shall be included in all
76 | copies or substantial portions of the Software.
77 |
78 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
79 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
80 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
81 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
82 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
83 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
84 | SOFTWARE.
85 | */
86 |
--------------------------------------------------------------------------------
/TimeControl/KeyBindings/HyperRateChangeToHigherRate.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using UnityEngine;
3 |
4 | namespace TimeControl.KeyBindings
5 | {
6 | public class HyperRateChangeToHigherRate : TimeControlKeyBinding
7 | {
8 | public HyperRateChangeToHigherRate()
9 | {
10 | TimeControlKeyActionName = TimeControlKeyAction.HyperRateChangeToHigherRate;
11 | SetDescription = Description = "Hyper-Warp Rate Step Increase";
12 | }
13 |
14 | public override void Press()
15 | {
16 | if (HyperWarpController.IsReady)
17 | {
18 | if (!HyperWarpController.Instance.IsHyperWarping)
19 | {
20 | HyperWarpController.Instance.MaxAttemptedRate = 1;
21 | HyperWarpController.Instance.ChangeToHigherRate();
22 | HyperWarpController.Instance.ActivateHyper();
23 | }
24 | else
25 | {
26 | HyperWarpController.Instance.ChangeToHigherRate();
27 | }
28 | }
29 | }
30 | }
31 | }
32 | /*
33 | All code in this file Copyright(c) 2020 Nate West
34 |
35 | The MIT License (MIT)
36 |
37 | Permission is hereby granted, free of charge, to any person obtaining a copy
38 | of this software and associated documentation files (the "Software"), to deal
39 | in the Software without restriction, including without limitation the rights
40 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
41 | copies of the Software, and to permit persons to whom the Software is
42 | furnished to do so, subject to the following conditions:
43 |
44 | The above copyright notice and this permission notice shall be included in all
45 | copies or substantial portions of the Software.
46 |
47 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
48 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
49 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
50 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
51 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
52 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
53 | SOFTWARE.
54 | */
55 |
--------------------------------------------------------------------------------
/TimeControl/KeyBindings/HyperRateChangeToLowerRate.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using UnityEngine;
3 |
4 | namespace TimeControl.KeyBindings
5 | {
6 | public class HyperRateChangeToLowerRate : TimeControlKeyBinding
7 | {
8 | public HyperRateChangeToLowerRate()
9 | {
10 | TimeControlKeyActionName = TimeControlKeyAction.HyperRateChangeToLowerRate;
11 | SetDescription = Description = "Hyper-Warp Rate Step Decrease";
12 | }
13 |
14 | public override void Press()
15 | {
16 | if (HyperWarpController.IsReady)
17 | {
18 | if (HyperWarpController.Instance.IsHyperWarping)
19 | {
20 | HyperWarpController.Instance.ChangeToLowerRate();
21 | if (HyperWarpController.Instance.MaxAttemptedRate == 1)
22 | {
23 | HyperWarpController.Instance.DeactivateHyper();
24 | }
25 | }
26 | }
27 | }
28 | }
29 | }
30 | /*
31 | All code in this file Copyright(c) 2020 Nate West
32 |
33 | The MIT License (MIT)
34 |
35 | Permission is hereby granted, free of charge, to any person obtaining a copy
36 | of this software and associated documentation files (the "Software"), to deal
37 | in the Software without restriction, including without limitation the rights
38 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
39 | copies of the Software, and to permit persons to whom the Software is
40 | furnished to do so, subject to the following conditions:
41 |
42 | The above copyright notice and this permission notice shall be included in all
43 | copies or substantial portions of the Software.
44 |
45 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
46 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
47 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
48 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
49 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
50 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
51 | SOFTWARE.
52 | */
53 |
--------------------------------------------------------------------------------
/TimeControl/KeyBindings/HyperRateSetRate.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using UnityEngine;
3 |
4 | namespace TimeControl.KeyBindings
5 | {
6 | public class HyperRateSetRate : TimeControlKeyBindingValue
7 | {
8 | private float v = 2f;
9 |
10 | private void UpdateDescription()
11 | {
12 | Description = String.Format( "Set Hyper-Warp Rate to {0}", v );
13 | }
14 |
15 | public HyperRateSetRate()
16 | {
17 | TimeControlKeyActionName = TimeControlKeyAction.HyperRateSetRate;
18 | SetDescription = "Hyper-Warp Set Rate To: ";
19 | UpdateDescription();
20 | }
21 |
22 | public override float VMax
23 | {
24 | get => HyperWarpController.AttemptedRateMax;
25 | }
26 |
27 | public override float VMin
28 | {
29 | get => HyperWarpController.AttemptedRateMin;
30 | }
31 |
32 | public override float V
33 | {
34 | get => v;
35 | set
36 | {
37 | if (value >= VMax)
38 | {
39 | v = VMax;
40 | }
41 | else if (value <= VMin)
42 | {
43 | v = VMin;
44 | }
45 | else
46 | {
47 | v = (float)Mathf.RoundToInt( value );
48 | }
49 |
50 | UpdateDescription();
51 | }
52 | }
53 |
54 | public override void Press()
55 | {
56 | if (HyperWarpController.IsReady)
57 | {
58 | HyperWarpController.Instance.MaxAttemptedRate = v;
59 | }
60 | }
61 | }
62 | }
63 | /*
64 | All code in this file Copyright(c) 2016 Nate West
65 |
66 | The MIT License (MIT)
67 |
68 | Permission is hereby granted, free of charge, to any person obtaining a copy
69 | of this software and associated documentation files (the "Software"), to deal
70 | in the Software without restriction, including without limitation the rights
71 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
72 | copies of the Software, and to permit persons to whom the Software is
73 | furnished to do so, subject to the following conditions:
74 |
75 | The above copyright notice and this permission notice shall be included in all
76 | copies or substantial portions of the Software.
77 |
78 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
79 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
80 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
81 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
82 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
83 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
84 | SOFTWARE.
85 | */
--------------------------------------------------------------------------------
/TimeControl/KeyBindings/HyperRateSlowDown.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using UnityEngine;
3 |
4 | namespace TimeControl.KeyBindings
5 | {
6 | public class HyperRateSlowDown : TimeControlKeyBindingValue
7 | {
8 | private float v = 1f;
9 |
10 | private void UpdateDescription()
11 | {
12 | Description = String.Format( "Hyper-Warp Rate -{0}x", v );
13 | }
14 |
15 | public HyperRateSlowDown()
16 | {
17 | TimeControlKeyActionName = TimeControlKeyAction.HyperRateSlowDown;
18 | SetDescription = "Hyper-Warp Decrease Rate By: ";
19 | FireWhileHoldingKeyDown = true;
20 | UpdateDescription();
21 | }
22 |
23 | public override float VMax
24 | {
25 | get => 50f;
26 | }
27 |
28 | public override float VMin
29 | {
30 | get => 1f;
31 | }
32 |
33 | public override float V
34 | {
35 | get => v;
36 | set
37 | {
38 | if (value >= VMax)
39 | {
40 | v = VMax;
41 | }
42 | else if (value <= VMin)
43 | {
44 | v = VMin;
45 | }
46 | else
47 | {
48 | v = (float)Mathf.RoundToInt( value );
49 | }
50 |
51 | UpdateDescription();
52 | }
53 | }
54 |
55 | public override void Press()
56 | {
57 | if (HyperWarpController.IsReady)
58 | {
59 | HyperWarpController.Instance.SlowDown( v );
60 | }
61 | }
62 | }
63 | }
64 | /*
65 | All code in this file Copyright(c) 2016 Nate West
66 |
67 | The MIT License (MIT)
68 |
69 | Permission is hereby granted, free of charge, to any person obtaining a copy
70 | of this software and associated documentation files (the "Software"), to deal
71 | in the Software without restriction, including without limitation the rights
72 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
73 | copies of the Software, and to permit persons to whom the Software is
74 | furnished to do so, subject to the following conditions:
75 |
76 | The above copyright notice and this permission notice shall be included in all
77 | copies or substantial portions of the Software.
78 |
79 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
80 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
81 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
82 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
83 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
84 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
85 | SOFTWARE.
86 | */
87 |
--------------------------------------------------------------------------------
/TimeControl/KeyBindings/HyperRateSpeedUp.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using UnityEngine;
3 |
4 | namespace TimeControl.KeyBindings
5 | {
6 | public class HyperRateSpeedUp : TimeControlKeyBindingValue
7 | {
8 | private float v = 1f;
9 |
10 | private void UpdateDescription()
11 | {
12 | Description = String.Format( "Hyper-Warp Rate +{0}x", v );
13 | }
14 |
15 | public HyperRateSpeedUp()
16 | {
17 | TimeControlKeyActionName = TimeControlKeyAction.HyperRateSpeedUp;
18 | SetDescription = "Hyper-Warp Increase Rate By: ";
19 | FireWhileHoldingKeyDown = true;
20 | UpdateDescription();
21 | }
22 |
23 | public override float VMax
24 | {
25 | get => 50f;
26 | }
27 |
28 | public override float VMin
29 | {
30 | get => 1f;
31 | }
32 |
33 | public override float V
34 | {
35 | get => v;
36 | set
37 | {
38 | if (value >= VMax)
39 | {
40 | v = VMax;
41 | }
42 | else if (value <= VMin)
43 | {
44 | v = VMin;
45 | }
46 | else
47 | {
48 | v = (float)Mathf.RoundToInt( value );
49 | }
50 |
51 | UpdateDescription();
52 | }
53 | }
54 |
55 | public override void Press()
56 | {
57 | if (HyperWarpController.IsReady)
58 | {
59 | HyperWarpController.Instance.SpeedUp( v );
60 | }
61 | }
62 | }
63 | }
64 | /*
65 | All code in this file Copyright(c) 2016 Nate West
66 |
67 | The MIT License (MIT)
68 |
69 | Permission is hereby granted, free of charge, to any person obtaining a copy
70 | of this software and associated documentation files (the "Software"), to deal
71 | in the Software without restriction, including without limitation the rights
72 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
73 | copies of the Software, and to permit persons to whom the Software is
74 | furnished to do so, subject to the following conditions:
75 |
76 | The above copyright notice and this permission notice shall be included in all
77 | copies or substantial portions of the Software.
78 |
79 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
80 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
81 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
82 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
83 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
84 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
85 | SOFTWARE.
86 | */
87 |
--------------------------------------------------------------------------------
/TimeControl/KeyBindings/HyperToggle.cs:
--------------------------------------------------------------------------------
1 | namespace TimeControl.KeyBindings
2 | {
3 | public class HyperToggle : TimeControlKeyBinding
4 | {
5 | public HyperToggle()
6 | {
7 | TimeControlKeyActionName = TimeControlKeyAction.HyperToggle;
8 | SetDescription = Description = "Toggle Hyper-Warp";
9 | }
10 |
11 | public override void Press()
12 | {
13 | if (HyperWarpController.IsReady)
14 | {
15 | HyperWarpController.Instance.ToggleHyper();
16 | }
17 | }
18 | }
19 | }
20 | /*
21 | All code in this file Copyright(c) 2016 Nate West
22 |
23 | The MIT License (MIT)
24 |
25 | Permission is hereby granted, free of charge, to any person obtaining a copy
26 | of this software and associated documentation files (the "Software"), to deal
27 | in the Software without restriction, including without limitation the rights
28 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
29 | copies of the Software, and to permit persons to whom the Software is
30 | furnished to do so, subject to the following conditions:
31 |
32 | The above copyright notice and this permission notice shall be included in all
33 | copies or substantial portions of the Software.
34 |
35 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
36 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
37 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
38 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
39 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
40 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
41 | SOFTWARE.
42 | */
43 |
--------------------------------------------------------------------------------
/TimeControl/KeyBindings/PauseToggle.cs:
--------------------------------------------------------------------------------
1 | namespace TimeControl.KeyBindings
2 | {
3 | public class PauseToggle : TimeControlKeyBinding
4 | {
5 | public PauseToggle()
6 | {
7 | TimeControlKeyActionName = TimeControlKeyAction.PauseToggle;
8 | SetDescription = Description = "Toggle Pause";
9 | }
10 |
11 | public override void Press()
12 | {
13 | if (TimeController.IsReady)
14 | {
15 | TimeController.Instance.TogglePause();
16 | }
17 | }
18 | }
19 | }
20 | /*
21 | All code in this file Copyright(c) 2016 Nate West
22 |
23 | The MIT License (MIT)
24 |
25 | Permission is hereby granted, free of charge, to any person obtaining a copy
26 | of this software and associated documentation files (the "Software"), to deal
27 | in the Software without restriction, including without limitation the rights
28 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
29 | copies of the Software, and to permit persons to whom the Software is
30 | furnished to do so, subject to the following conditions:
31 |
32 | The above copyright notice and this permission notice shall be included in all
33 | copies or substantial portions of the Software.
34 |
35 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
36 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
37 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
38 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
39 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
40 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
41 | SOFTWARE.
42 | */
43 |
--------------------------------------------------------------------------------
/TimeControl/KeyBindings/Realtime.cs:
--------------------------------------------------------------------------------
1 | namespace TimeControl.KeyBindings
2 | {
3 | public class Realtime: TimeControlKeyBinding
4 | {
5 | public Realtime()
6 | {
7 | TimeControlKeyActionName = TimeControlKeyAction.Realtime;
8 | SetDescription = Description = "Realtime";
9 | }
10 |
11 | public override void Press()
12 | {
13 | if (TimeController.IsReady)
14 | {
15 | TimeController.Instance.GoRealTime();
16 | }
17 | }
18 | }
19 | }
20 | /*
21 | All code in this file Copyright(c) 2016 Nate West
22 |
23 | The MIT License (MIT)
24 |
25 | Permission is hereby granted, free of charge, to any person obtaining a copy
26 | of this software and associated documentation files (the "Software"), to deal
27 | in the Software without restriction, including without limitation the rights
28 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
29 | copies of the Software, and to permit persons to whom the Software is
30 | furnished to do so, subject to the following conditions:
31 |
32 | The above copyright notice and this permission notice shall be included in all
33 | copies or substantial portions of the Software.
34 |
35 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
36 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
37 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
38 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
39 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
40 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
41 | SOFTWARE.
42 | */
43 |
--------------------------------------------------------------------------------
/TimeControl/KeyBindings/SlowMoActivate.cs:
--------------------------------------------------------------------------------
1 | namespace TimeControl.KeyBindings
2 | {
3 | public class SlowMoActivate : TimeControlKeyBinding
4 | {
5 | public SlowMoActivate()
6 | {
7 | TimeControlKeyActionName = TimeControlKeyAction.SlowMoActivate;
8 | SetDescription = Description = "Activate Slow-Motion";
9 | }
10 |
11 | public override void Press()
12 | {
13 | if (SlowMoController.IsReady)
14 | {
15 | SlowMoController.Instance.ActivateSlowMo();
16 | }
17 | }
18 | }
19 | }
20 | /*
21 | All code in this file Copyright(c) 2016 Nate West
22 |
23 | The MIT License (MIT)
24 |
25 | Permission is hereby granted, free of charge, to any person obtaining a copy
26 | of this software and associated documentation files (the "Software"), to deal
27 | in the Software without restriction, including without limitation the rights
28 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
29 | copies of the Software, and to permit persons to whom the Software is
30 | furnished to do so, subject to the following conditions:
31 |
32 | The above copyright notice and this permission notice shall be included in all
33 | copies or substantial portions of the Software.
34 |
35 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
36 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
37 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
38 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
39 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
40 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
41 | SOFTWARE.
42 | */
43 |
--------------------------------------------------------------------------------
/TimeControl/KeyBindings/SlowMoDeactivate.cs:
--------------------------------------------------------------------------------
1 | namespace TimeControl.KeyBindings
2 | {
3 | public class SlowMoDeactivate : TimeControlKeyBinding
4 | {
5 | public SlowMoDeactivate()
6 | {
7 | TimeControlKeyActionName = TimeControlKeyAction.SlowMoDeactivate;
8 | SetDescription = Description = "Deactivate Slow-Motion";
9 | }
10 |
11 | public override void Press()
12 | {
13 | if (SlowMoController.IsReady)
14 | {
15 | SlowMoController.Instance.DeactivateSlowMo();
16 | }
17 | }
18 | }
19 | }
20 | /*
21 | All code in this file Copyright(c) 2016 Nate West
22 |
23 | The MIT License (MIT)
24 |
25 | Permission is hereby granted, free of charge, to any person obtaining a copy
26 | of this software and associated documentation files (the "Software"), to deal
27 | in the Software without restriction, including without limitation the rights
28 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
29 | copies of the Software, and to permit persons to whom the Software is
30 | furnished to do so, subject to the following conditions:
31 |
32 | The above copyright notice and this permission notice shall be included in all
33 | copies or substantial portions of the Software.
34 |
35 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
36 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
37 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
38 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
39 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
40 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
41 | SOFTWARE.
42 | */
43 |
--------------------------------------------------------------------------------
/TimeControl/KeyBindings/SlowMoSetRate.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using UnityEngine;
3 |
4 | namespace TimeControl.KeyBindings
5 | {
6 | public class SlowMoSetRate : TimeControlKeyBindingValue
7 | {
8 | private float v = 1f;
9 |
10 | private float VPercent
11 | {
12 | get => Mathf.RoundToInt( v * 100 );
13 | }
14 |
15 | private void UpdateDescription()
16 | {
17 | Description = String.Format( "Set Slow-Mo Rate to {0}%", VPercent );
18 | }
19 |
20 | public SlowMoSetRate()
21 | {
22 | TimeControlKeyActionName = TimeControlKeyAction.SlowMoSetRate;
23 | SetDescription = "Slow-Motion Set Rate To: ";
24 | UpdateDescription();
25 | }
26 |
27 | public override float VMax
28 | {
29 | get => 1f;
30 | }
31 |
32 | public override float VMin
33 | {
34 | get => 0.01f;
35 | }
36 |
37 | public override float V
38 | {
39 | get => v;
40 | set
41 | {
42 | if (value >= VMax)
43 | {
44 | v = VMax;
45 | }
46 | else if (value <= VMin)
47 | {
48 | v = VMin;
49 | }
50 | else
51 | {
52 | v = (float)Math.Round( value, 2 );
53 | }
54 |
55 | UpdateDescription();
56 | }
57 | }
58 |
59 | public override void Press()
60 | {
61 | if (SlowMoController.IsReady)
62 | {
63 | SlowMoController.Instance.SlowMoRate = v;
64 | }
65 | }
66 | }
67 | }
68 | /*
69 | All code in this file Copyright(c) 2016 Nate West
70 |
71 | The MIT License (MIT)
72 |
73 | Permission is hereby granted, free of charge, to any person obtaining a copy
74 | of this software and associated documentation files (the "Software"), to deal
75 | in the Software without restriction, including without limitation the rights
76 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
77 | copies of the Software, and to permit persons to whom the Software is
78 | furnished to do so, subject to the following conditions:
79 |
80 | The above copyright notice and this permission notice shall be included in all
81 | copies or substantial portions of the Software.
82 |
83 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
84 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
85 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
86 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
87 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
88 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
89 | SOFTWARE.
90 | */
91 |
--------------------------------------------------------------------------------
/TimeControl/KeyBindings/SlowMoSlowDown.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using UnityEngine;
3 |
4 | namespace TimeControl.KeyBindings
5 | {
6 | public class SlowMoSlowDown : TimeControlKeyBindingValue
7 | {
8 | private float v = 0.01f;
9 |
10 | private float VPercent
11 | {
12 | get => Mathf.RoundToInt( v * 100 );
13 | }
14 |
15 | private void UpdateDescription()
16 | {
17 | Description = String.Format( "Slow-Mo Rate -{0}%", VPercent );
18 | }
19 |
20 | public SlowMoSlowDown()
21 | {
22 | TimeControlKeyActionName = TimeControlKeyAction.SlowMoSlowDown;
23 | SetDescription = "Slow-Motion Decrease Rate By: ";
24 | FireWhileHoldingKeyDown = true;
25 | UpdateDescription();
26 | }
27 |
28 | public override float VMax
29 | {
30 | get => 0.5f;
31 | }
32 |
33 | public override float VMin
34 | {
35 | get => 0.01f;
36 | }
37 |
38 | public override float V
39 | {
40 | get => v;
41 | set
42 | {
43 | if (value >= VMax)
44 | {
45 | v = VMax;
46 | }
47 | else if (value <= VMin)
48 | {
49 | v = VMin;
50 | }
51 | else
52 | {
53 | v = (float)Math.Round( value, 2 );
54 | }
55 |
56 | UpdateDescription();
57 | }
58 | }
59 |
60 | public override void Press()
61 | {
62 | if (SlowMoController.IsReady)
63 | {
64 | SlowMoController.Instance.SlowDown( v );
65 | }
66 | }
67 | }
68 | }
69 | /*
70 | All code in this file Copyright(c) 2016 Nate West
71 |
72 | The MIT License (MIT)
73 |
74 | Permission is hereby granted, free of charge, to any person obtaining a copy
75 | of this software and associated documentation files (the "Software"), to deal
76 | in the Software without restriction, including without limitation the rights
77 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
78 | copies of the Software, and to permit persons to whom the Software is
79 | furnished to do so, subject to the following conditions:
80 |
81 | The above copyright notice and this permission notice shall be included in all
82 | copies or substantial portions of the Software.
83 |
84 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
85 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
86 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
87 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
88 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
89 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
90 | SOFTWARE.
91 | */
92 |
--------------------------------------------------------------------------------
/TimeControl/KeyBindings/SlowMoSpeedUp.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using UnityEngine;
3 |
4 | namespace TimeControl.KeyBindings
5 | {
6 | public class SlowMoSpeedUp : TimeControlKeyBindingValue
7 | {
8 | private float v = 0.01f;
9 |
10 | private float VPercent
11 | {
12 | get => Mathf.RoundToInt( v * 100 );
13 | }
14 |
15 | private void UpdateDescription()
16 | {
17 | Description = String.Format( "Slow-Mo Rate +{0}%", VPercent );
18 | }
19 |
20 | public SlowMoSpeedUp()
21 | {
22 | TimeControlKeyActionName = TimeControlKeyAction.SlowMoSpeedUp;
23 | FireWhileHoldingKeyDown = true;
24 | SetDescription = "Slow-Motion Increase Rate By: ";
25 | UpdateDescription();
26 | }
27 |
28 | public override float VMax
29 | {
30 | get => 0.5f;
31 | }
32 |
33 | public override float VMin
34 | {
35 | get => 0.01f;
36 | }
37 |
38 | public override float V
39 | {
40 | get => v;
41 | set
42 | {
43 | if (value >= VMax)
44 | {
45 | v = VMax;
46 | }
47 | else if (value <= VMin)
48 | {
49 | v = VMin;
50 | }
51 | else
52 | {
53 | v = (float)Math.Round( value, 2 );
54 | }
55 |
56 | UpdateDescription();
57 | }
58 | }
59 |
60 | public override void Press()
61 | {
62 | if (SlowMoController.IsReady)
63 | {
64 | SlowMoController.Instance.SpeedUp( v );
65 | }
66 | }
67 | }
68 | }
69 | /*
70 | All code in this file Copyright(c) 2016 Nate West
71 |
72 | The MIT License (MIT)
73 |
74 | Permission is hereby granted, free of charge, to any person obtaining a copy
75 | of this software and associated documentation files (the "Software"), to deal
76 | in the Software without restriction, including without limitation the rights
77 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
78 | copies of the Software, and to permit persons to whom the Software is
79 | furnished to do so, subject to the following conditions:
80 |
81 | The above copyright notice and this permission notice shall be included in all
82 | copies or substantial portions of the Software.
83 |
84 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
85 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
86 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
87 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
88 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
89 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
90 | SOFTWARE.
91 | */
92 |
--------------------------------------------------------------------------------
/TimeControl/KeyBindings/SlowMoToggle.cs:
--------------------------------------------------------------------------------
1 | namespace TimeControl.KeyBindings
2 | {
3 | public class SlowMoToggle : TimeControlKeyBinding
4 | {
5 | public SlowMoToggle()
6 | {
7 | TimeControlKeyActionName = TimeControlKeyAction.SlowMoToggle;
8 | SetDescription = Description = "Toggle Slow-Motion";
9 | }
10 |
11 | public override void Press()
12 | {
13 | if (SlowMoController.IsReady)
14 | {
15 | SlowMoController.Instance.ToggleSlowMo();
16 | }
17 | }
18 | }
19 | }
20 | /*
21 | All code in this file Copyright(c) 2016 Nate West
22 |
23 | The MIT License (MIT)
24 |
25 | Permission is hereby granted, free of charge, to any person obtaining a copy
26 | of this software and associated documentation files (the "Software"), to deal
27 | in the Software without restriction, including without limitation the rights
28 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
29 | copies of the Software, and to permit persons to whom the Software is
30 | furnished to do so, subject to the following conditions:
31 |
32 | The above copyright notice and this permission notice shall be included in all
33 | copies or substantial portions of the Software.
34 |
35 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
36 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
37 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
38 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
39 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
40 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
41 | SOFTWARE.
42 | */
43 |
--------------------------------------------------------------------------------
/TimeControl/KeyBindings/TimeControlKeyAction.cs:
--------------------------------------------------------------------------------
1 | namespace TimeControl.KeyBindings
2 | {
3 | public enum TimeControlKeyAction
4 | {
5 | GUIToggle = 1,
6 | Realtime = 2,
7 | PauseToggle = 3,
8 | TimeStep = 4,
9 |
10 | HyperToggle = 5,
11 | HyperActivate = 6,
12 | HyperDeactivate = 7,
13 | HyperRateSetRate = 8,
14 | HyperRateSpeedUp = 9,
15 | HyperRateSlowDown = 10,
16 | HyperPhysicsAccuracySet = 11,
17 | HyperPhysicsAccuracyUp = 12,
18 | HyperPhysicsAccuracyDown = 13,
19 |
20 | SlowMoToggle = 14,
21 | SlowMoActivate = 15,
22 | SlowMoDeactivate = 16,
23 | SlowMoSetRate = 17,
24 | SlowMoSpeedUp = 18,
25 | SlowMoSlowDown = 19,
26 |
27 | WarpToNextKACAlarm = 20,
28 | WarpForNOrbits = 21,
29 |
30 | WarpToVesselOrbitLocation = 22,
31 | WarpForNTimeIncrements = 23,
32 |
33 | HyperRateChangeToLowerRate = 24,
34 | HyperRateChangeToHigherRate = 25,
35 |
36 | HyperAndSloMoSlowDownTime = 26,
37 | HyperAndSloMoSpeedUpTime = 27
38 | }
39 | }
40 | /*
41 | All code in this file Copyright(c) 2016 Nate West
42 |
43 | The MIT License (MIT)
44 |
45 | Permission is hereby granted, free of charge, to any person obtaining a copy
46 | of this software and associated documentation files (the "Software"), to deal
47 | in the Software without restriction, including without limitation the rights
48 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
49 | copies of the Software, and to permit persons to whom the Software is
50 | furnished to do so, subject to the following conditions:
51 |
52 | The above copyright notice and this permission notice shall be included in all
53 | copies or substantial portions of the Software.
54 |
55 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
56 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
57 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
58 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
59 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
60 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
61 | SOFTWARE.
62 | */
63 |
--------------------------------------------------------------------------------
/TimeControl/KeyBindings/TimeControlKeyBinding.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using UnityEngine;
3 |
4 | namespace TimeControl.KeyBindings
5 | {
6 | public abstract class TimeControlKeyBinding
7 | {
8 | protected const string kbNodeName = "KeyBind";
9 |
10 | public int ID { get; set; } = 0;
11 |
12 | public string Description { get; set; }
13 | public string SetDescription { get; set; } = "";
14 |
15 | private List keyCombination = new List();
16 |
17 | public List KeyCombination
18 | {
19 | get => keyCombination;
20 | set
21 | {
22 | keyCombination = value;
23 | UpdateKeyCombinationDescription();
24 | }
25 | }
26 |
27 | public string KeyCombinationDescription { get; private set; } = "[None]";
28 |
29 | public bool IsKeyAssigned { get { return KeyCombination.Count != 0; } }
30 |
31 | public bool IsUserDefined { get; set; } = false;
32 |
33 | public bool FireWhileHoldingKeyDown { get; set; } = false;
34 |
35 | public TimeControlKeyAction TimeControlKeyActionName { get; set; }
36 |
37 | private void UpdateKeyCombinationDescription()
38 | {
39 | const string logBlockName = nameof( TimeControlKeyBinding ) + "." + nameof( UpdateKeyCombinationDescription );
40 | using (EntryExitLogger.EntryExitLog( logBlockName, EntryExitLoggerOptions.All ))
41 | {
42 | string s = "";
43 |
44 | if (KeyCombination.Count == 0)
45 | {
46 | s = "[None]";
47 | }
48 | else
49 | {
50 | foreach (KeyCode kc in KeyCombination)
51 | {
52 | if (kc == KeyCode.LeftShift || kc == KeyCode.RightShift)
53 | {
54 | s += "[Shift]";
55 | continue;
56 | }
57 | if (kc == KeyCode.LeftControl || kc == KeyCode.RightControl)
58 | {
59 | s += "[Ctrl]";
60 | continue;
61 | }
62 | if (kc == KeyCode.LeftAlt || kc == KeyCode.RightAlt)
63 | {
64 | s += "[Alt]";
65 | continue;
66 | }
67 | if (kc == KeyCode.LeftCommand || kc == KeyCode.RightCommand)
68 | {
69 | s += "[Cmd]";
70 | continue;
71 | }
72 |
73 | s += "[" + kc.ToString() + "]";
74 | }
75 | }
76 |
77 | Log.Trace( "Set Key Combination to " + s, logBlockName );
78 | KeyCombinationDescription = s;
79 | }
80 | }
81 |
82 | public virtual ConfigNode GetConfigNode()
83 | {
84 | const string logBlockName = nameof( TimeControlKeyBinding ) + "." + nameof( GetConfigNode );
85 | using (EntryExitLogger.EntryExitLog( logBlockName, EntryExitLoggerOptions.All ))
86 | {
87 | Log.Trace( "Getting ConfigNode For Action "
88 | .MemoizedConcat( this.TimeControlKeyActionName.MemoizedToString() )
89 | .MemoizedConcat( " with Key Combination " )
90 | .MemoizedConcat( this.KeyCombinationDescription ) );
91 |
92 | ConfigNode newNode = new ConfigNode( kbNodeName );
93 | newNode.AddValue( "Action", this.TimeControlKeyActionName );
94 | newNode.AddValue( "ID", this.ID );
95 | newNode.AddValue( "IsUserDefined", this.IsUserDefined );
96 | newNode.AddValue( "KeyCombination", this.KeyCombinationDescription );
97 |
98 | return newNode;
99 | }
100 | }
101 |
102 | public abstract void Press();
103 | }
104 | }
105 | /*
106 | All code in this file Copyright(c) 2016 Nate West
107 |
108 | The MIT License (MIT)
109 |
110 | Permission is hereby granted, free of charge, to any person obtaining a copy
111 | of this software and associated documentation files (the "Software"), to deal
112 | in the Software without restriction, including without limitation the rights
113 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
114 | copies of the Software, and to permit persons to whom the Software is
115 | furnished to do so, subject to the following conditions:
116 |
117 | The above copyright notice and this permission notice shall be included in all
118 | copies or substantial portions of the Software.
119 |
120 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
121 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
122 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
123 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
124 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
125 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
126 | SOFTWARE.
127 | */
128 |
--------------------------------------------------------------------------------
/TimeControl/KeyBindings/TimeControlKeyBindingValue.cs:
--------------------------------------------------------------------------------
1 | namespace TimeControl.KeyBindings
2 | {
3 | public abstract class TimeControlKeyBindingValue : TimeControlKeyBinding
4 | {
5 | abstract public float VMax
6 | {
7 | get;
8 | }
9 |
10 | abstract public float VMin
11 | {
12 | get;
13 | }
14 |
15 | abstract public float V
16 | {
17 | get; set;
18 | }
19 |
20 | public override ConfigNode GetConfigNode()
21 | {
22 | ConfigNode newNode = base.GetConfigNode();
23 | newNode.AddValue( "V", V );
24 | return newNode;
25 | }
26 | }
27 | }
28 | /*
29 | All code in this file Copyright(c) 2016 Nate West
30 |
31 | The MIT License (MIT)
32 |
33 | Permission is hereby granted, free of charge, to any person obtaining a copy
34 | of this software and associated documentation files (the "Software"), to deal
35 | in the Software without restriction, including without limitation the rights
36 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
37 | copies of the Software, and to permit persons to whom the Software is
38 | furnished to do so, subject to the following conditions:
39 |
40 | The above copyright notice and this permission notice shall be included in all
41 | copies or substantial portions of the Software.
42 |
43 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
44 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
45 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
46 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
47 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
48 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
49 | SOFTWARE.
50 | */
51 |
--------------------------------------------------------------------------------
/TimeControl/KeyBindings/TimeStep.cs:
--------------------------------------------------------------------------------
1 | namespace TimeControl.KeyBindings
2 | {
3 | public class TimeStep : TimeControlKeyBinding
4 | {
5 | public TimeStep()
6 | {
7 | TimeControlKeyActionName = TimeControlKeyAction.TimeStep;
8 | SetDescription = Description = "Increment Time Step";
9 | }
10 |
11 | public override void Press()
12 | {
13 | if (TimeController.IsReady)
14 | {
15 | TimeController.Instance.IncrementTimeStep();
16 | }
17 | }
18 | }
19 | }
20 | /*
21 | All code in this file Copyright(c) 2016 Nate West
22 |
23 | The MIT License (MIT)
24 |
25 | Permission is hereby granted, free of charge, to any person obtaining a copy
26 | of this software and associated documentation files (the "Software"), to deal
27 | in the Software without restriction, including without limitation the rights
28 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
29 | copies of the Software, and to permit persons to whom the Software is
30 | furnished to do so, subject to the following conditions:
31 |
32 | The above copyright notice and this permission notice shall be included in all
33 | copies or substantial portions of the Software.
34 |
35 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
36 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
37 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
38 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
39 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
40 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
41 | SOFTWARE.
42 | */
43 |
--------------------------------------------------------------------------------
/TimeControl/KeyBindings/WarpForNOrbits.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using UnityEngine;
4 |
5 | namespace TimeControl.KeyBindings
6 | {
7 | public class WarpForNOrbits : TimeControlKeyBindingValue
8 | {
9 | private static List UnstableOrbitTransitions = new List { Orbit.PatchTransitionType.ENCOUNTER, Orbit.PatchTransitionType.ESCAPE, Orbit.PatchTransitionType.IMPACT };
10 |
11 | private float v = 1f;
12 |
13 | private double CurrentUT
14 | {
15 | get => Planetarium.GetUniversalTime();
16 | }
17 |
18 | private void UpdateDescription()
19 | {
20 | Description = String.Format( "Rails Warp for {0} Orbits", v );
21 | }
22 |
23 | public WarpForNOrbits()
24 | {
25 | TimeControlKeyActionName = TimeControlKeyAction.WarpForNOrbits;
26 | SetDescription = "Rails Warp for # Orbits: ";
27 | UpdateDescription();
28 | }
29 |
30 | public override float VMax
31 | {
32 | get => Mathf.Infinity;
33 | }
34 |
35 | public override float VMin
36 | {
37 | get => 1f;
38 | }
39 |
40 | public override float V
41 | {
42 | get => v;
43 | set
44 | {
45 | if (value >= VMax)
46 | {
47 | v = VMax;
48 | }
49 | else if (value <= VMin)
50 | {
51 | v = VMin;
52 | }
53 | else
54 | {
55 | v = (float)Mathf.RoundToInt( value );
56 | }
57 |
58 | UpdateDescription();
59 | }
60 | }
61 |
62 | public override void Press()
63 | {
64 | Vessel vsl = FlightGlobals.ActiveVessel;
65 |
66 | // If no vessel or stable orbit, don't do anything
67 | if (!RailsWarpController.IsReady || vsl?.orbit == null || vsl.Landed || UnstableOrbitTransitions.Contains( vsl.orbit.patchEndTransition ))
68 | {
69 | return;
70 | }
71 |
72 | double TargetUT = CurrentUT + (vsl.orbit.period * this.V);
73 | RailsWarpController.Instance.RailsWarpToUT( TargetUT );
74 | }
75 | }
76 | }
77 | /*
78 | All code in this file Copyright(c) 2016 Nate West
79 |
80 | The MIT License (MIT)
81 |
82 | Permission is hereby granted, free of charge, to any person obtaining a copy
83 | of this software and associated documentation files (the "Software"), to deal
84 | in the Software without restriction, including without limitation the rights
85 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
86 | copies of the Software, and to permit persons to whom the Software is
87 | furnished to do so, subject to the following conditions:
88 |
89 | The above copyright notice and this permission notice shall be included in all
90 | copies or substantial portions of the Software.
91 |
92 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
93 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
94 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
95 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
96 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
97 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
98 | SOFTWARE.
99 | */
100 |
--------------------------------------------------------------------------------
/TimeControl/KeyBindings/WarpForNTimeIncrements.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using UnityEngine;
3 |
4 | namespace TimeControl.KeyBindings
5 | {
6 | public class WarpForNTimeIncrements : TimeControlKeyBindingValue
7 | {
8 | public enum TimeIncrement
9 | {
10 | Seconds = 1,
11 | Minutes = 2,
12 | Hours = 3,
13 | Days = 4,
14 | Years = 5
15 | }
16 |
17 | private TimeIncrement ti = TimeIncrement.Seconds;
18 | public TimeIncrement TI
19 | {
20 | get => ti;
21 | set
22 | {
23 | ti = value;
24 | UpdateDescription();
25 | }
26 | }
27 |
28 | private float v = 1f;
29 |
30 | private double CurrentUT
31 | {
32 | get => Planetarium.GetUniversalTime();
33 | }
34 |
35 | private void UpdateDescription()
36 | {
37 | Description = String.Format( "Rails Warp for {0} {1}", v, ti.ToString() );
38 | SetDescription = String.Format( "Rails Warp for # {0}", ti.ToString() ); ;
39 | }
40 |
41 | public WarpForNTimeIncrements()
42 | {
43 | TimeControlKeyActionName = TimeControlKeyAction.WarpForNTimeIncrements;
44 | UpdateDescription();
45 | }
46 |
47 | public WarpForNTimeIncrements(TimeIncrement pti)
48 | {
49 | ti = pti;
50 | TimeControlKeyActionName = TimeControlKeyAction.WarpForNTimeIncrements;
51 | UpdateDescription();
52 | }
53 |
54 | public override float VMax
55 | {
56 | get => Mathf.Infinity;
57 | }
58 |
59 | public override float VMin
60 | {
61 | get => 1f;
62 | }
63 |
64 | public override float V
65 | {
66 | get => v;
67 | set
68 | {
69 | if (value >= VMax)
70 | {
71 | v = VMax;
72 | }
73 | else if (value <= VMin)
74 | {
75 | v = VMin;
76 | }
77 | else
78 | {
79 | v = (float)Mathf.RoundToInt( value );
80 | }
81 |
82 | UpdateDescription();
83 | }
84 | }
85 |
86 | public override ConfigNode GetConfigNode()
87 | {
88 | ConfigNode newNode = base.GetConfigNode();
89 | newNode.AddValue( "TI", TI );
90 | return newNode;
91 | }
92 |
93 | public override void Press()
94 | {
95 | if (!RailsWarpController.IsReady)
96 | {
97 | return;
98 | }
99 |
100 | switch (ti)
101 | {
102 | case TimeIncrement.Seconds:
103 | RailsWarpController.Instance.RailsWarpForDuration( 0, 0, 0, 0, V );
104 | break;
105 | case TimeIncrement.Minutes:
106 | RailsWarpController.Instance.RailsWarpForDuration( 0, 0, 0, V, 0 );
107 | break;
108 | case TimeIncrement.Hours:
109 | RailsWarpController.Instance.RailsWarpForDuration( 0, 0, V, 0, 0 );
110 | break;
111 | case TimeIncrement.Days:
112 | RailsWarpController.Instance.RailsWarpForDuration( 0, V, 0, 0, 0 );
113 | break;
114 | case TimeIncrement.Years:
115 | RailsWarpController.Instance.RailsWarpForDuration( V, 0, 0, 0, 0 );
116 | break;
117 | }
118 | }
119 | }
120 | }
121 | /*
122 | All code in this file Copyright(c) 2016 Nate West
123 |
124 | The MIT License (MIT)
125 |
126 | Permission is hereby granted, free of charge, to any person obtaining a copy
127 | of this software and associated documentation files (the "Software"), to deal
128 | in the Software without restriction, including without limitation the rights
129 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
130 | copies of the Software, and to permit persons to whom the Software is
131 | furnished to do so, subject to the following conditions:
132 |
133 | The above copyright notice and this permission notice shall be included in all
134 | copies or substantial portions of the Software.
135 |
136 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
137 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
138 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
139 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
140 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
141 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
142 | SOFTWARE.
143 | */
144 |
--------------------------------------------------------------------------------
/TimeControl/KeyBindings/WarpToNextKACAlarm.cs:
--------------------------------------------------------------------------------
1 | namespace TimeControl.KeyBindings
2 | {
3 | public class WarpToNextKACAlarm : TimeControlKeyBinding
4 | {
5 | private double CurrentUT
6 | {
7 | get => Planetarium.GetUniversalTime();
8 | }
9 |
10 | private void UpdateDescription()
11 | {
12 | SetDescription = Description = "Rails Warp to Next KAC Alarm";
13 | }
14 |
15 | public WarpToNextKACAlarm()
16 | {
17 | TimeControlKeyActionName = TimeControlKeyAction.WarpToNextKACAlarm;
18 | UpdateDescription();
19 | }
20 |
21 | public override void Press()
22 | {
23 | if (!TimeController.IsReady || !RailsWarpController.IsReady || !KACWrapper.InstanceExists || !(HighLogic.LoadedScene == GameScenes.FLIGHT || HighLogic.LoadedScene == GameScenes.SPACECENTER || HighLogic.LoadedScene == GameScenes.TRACKSTATION))
24 | {
25 | return;
26 | }
27 |
28 | if (TimeController.Instance.ClosestKACAlarm != null)
29 | {
30 | double TargetUT = TimeController.Instance.ClosestKACAlarm.AlarmTime;
31 | RailsWarpController.Instance.RailsWarpToUT( TargetUT );
32 | }
33 | }
34 | }
35 | }
36 | /*
37 | All code in this file Copyright(c) 2016 Nate West
38 |
39 | The MIT License (MIT)
40 |
41 | Permission is hereby granted, free of charge, to any person obtaining a copy
42 | of this software and associated documentation files (the "Software"), to deal
43 | in the Software without restriction, including without limitation the rights
44 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
45 | copies of the Software, and to permit persons to whom the Software is
46 | furnished to do so, subject to the following conditions:
47 |
48 | The above copyright notice and this permission notice shall be included in all
49 | copies or substantial portions of the Software.
50 |
51 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
52 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
53 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
54 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
55 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
56 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
57 | SOFTWARE.
58 | */
59 |
--------------------------------------------------------------------------------
/TimeControl/KeyBindings/WarpToVesselOrbitLocation.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using UnityEngine;
4 |
5 | namespace TimeControl.KeyBindings
6 | {
7 | public class WarpToVesselOrbitLocation : TimeControlKeyBindingValue
8 | {
9 | private static List SOITransitions = new List { Orbit.PatchTransitionType.ENCOUNTER, Orbit.PatchTransitionType.ESCAPE };
10 |
11 | public enum VesselOrbitLocation
12 | {
13 | Ap = 1,
14 | Pe = 2,
15 | AN = 3,
16 | DN = 4,
17 | SOI = 5,
18 | ManuverNode = 6,
19 | ManuverNodeStartBurn = 7
20 | }
21 |
22 |
23 | private VesselOrbitLocation vesselLocation;
24 | public VesselOrbitLocation VesselLocation
25 | {
26 | get => vesselLocation;
27 | set
28 | {
29 | vesselLocation = value;
30 | UpdateDescription();
31 | }
32 | }
33 |
34 | private double CurrentUT
35 | {
36 | get => Planetarium.GetUniversalTime();
37 | }
38 |
39 | private void UpdateDescription()
40 | {
41 | if (Mathf.Approximately( v, 0 ))
42 | {
43 | Description = String.Format( "Rails Warp to {0}", VesselLocation.ToString() );
44 | }
45 | else
46 | {
47 | Description = String.Format( "Rails Warp to {0} - {1} seconds", VesselLocation.ToString(), v );
48 | }
49 | SetDescription = String.Format( "Rails Warp to {0} (- X sec): ", VesselLocation.ToString() );
50 | }
51 |
52 | public WarpToVesselOrbitLocation()
53 | {
54 | TimeControlKeyActionName = TimeControlKeyAction.WarpToVesselOrbitLocation;
55 | UpdateDescription();
56 | }
57 |
58 | public WarpToVesselOrbitLocation(VesselOrbitLocation vol)
59 | {
60 | TimeControlKeyActionName = TimeControlKeyAction.WarpToVesselOrbitLocation;
61 | VesselLocation = vol;
62 | UpdateDescription();
63 | }
64 |
65 | public override float VMax
66 | {
67 | get => Mathf.Infinity;
68 | }
69 |
70 | public override float VMin
71 | {
72 | get => 0f;
73 | }
74 |
75 | private float v = 0f;
76 | public override float V
77 | {
78 | get => v;
79 | set
80 | {
81 | if (value >= VMax)
82 | {
83 | v = VMax;
84 | }
85 | else if (value <= VMin)
86 | {
87 | v = VMin;
88 | }
89 | else
90 | {
91 | v = (float)Mathf.RoundToInt( value );
92 | }
93 |
94 | UpdateDescription();
95 | }
96 | }
97 |
98 | public override ConfigNode GetConfigNode()
99 | {
100 | ConfigNode newNode = base.GetConfigNode();
101 | newNode.AddValue( "VesselOrbitLocation", VesselLocation );
102 | return newNode;
103 | }
104 |
105 | public override void Press()
106 | {
107 | Vessel vsl = FlightGlobals.ActiveVessel;
108 |
109 | // If no vessel or orbit, don't do anything
110 | if (!RailsWarpController.IsReady || vsl?.orbit == null || vsl.Landed)
111 | {
112 | return;
113 | }
114 |
115 | Orbit tgtOrbit = vsl?.targetObject?.GetOrbit();
116 | switch (VesselLocation)
117 | {
118 | case VesselOrbitLocation.Ap:
119 | if ((vsl.orbit.ApA >= 0))
120 | {
121 | double TargetUT = CurrentUT + vsl.orbit.timeToAp - V;
122 | RailsWarpController.Instance.RailsWarpToUT( TargetUT );
123 | }
124 | break;
125 | case VesselOrbitLocation.Pe:
126 | if ((vsl.orbit.PeA >= 0))
127 | {
128 | double TargetUT = CurrentUT + vsl.orbit.timeToPe - V;
129 | RailsWarpController.Instance.RailsWarpToUT( TargetUT );
130 | }
131 | break;
132 | case VesselOrbitLocation.AN:
133 | if (HighLogic.LoadedScene == GameScenes.FLIGHT)
134 | {
135 | if (tgtOrbit == null)
136 | {
137 | if ((vsl.orbit.AscendingNodeEquatorialExists()))
138 | {
139 | double TargetUT = vsl.orbit.TimeOfAscendingNodeEquatorial( CurrentUT ) - V;
140 | RailsWarpController.Instance.RailsWarpToUT( TargetUT );
141 | }
142 | }
143 | else
144 | {
145 | if ((vsl.orbit.AscendingNodeExists( tgtOrbit )))
146 | {
147 | double TargetUT = vsl.orbit.TimeOfAscendingNode( tgtOrbit, CurrentUT ) - V;
148 | RailsWarpController.Instance.RailsWarpToUT( TargetUT );
149 | }
150 | }
151 | }
152 | break;
153 | case VesselOrbitLocation.DN:
154 | if (HighLogic.LoadedScene == GameScenes.FLIGHT)
155 | {
156 | if (tgtOrbit == null)
157 | {
158 | if ((vsl.orbit.DescendingNodeEquatorialExists()))
159 | {
160 | double TargetUT = vsl.orbit.TimeOfDescendingNodeEquatorial( CurrentUT ) - V;
161 | RailsWarpController.Instance.RailsWarpToUT( TargetUT );
162 | }
163 | }
164 | else
165 | {
166 | if ((vsl.orbit.DescendingNodeExists( tgtOrbit )))
167 | {
168 | double TargetUT = vsl.orbit.TimeOfDescendingNode( tgtOrbit, CurrentUT ) - V;
169 | RailsWarpController.Instance.RailsWarpToUT( TargetUT );
170 | }
171 | }
172 | }
173 | break;
174 | case VesselOrbitLocation.SOI:
175 | if ((SOITransitions.Contains( vsl.orbit.patchEndTransition )))
176 | {
177 | double TargetUT = vsl.orbit.EndUT - V;
178 | RailsWarpController.Instance.RailsWarpToUT( TargetUT );
179 | }
180 | break;
181 | case VesselOrbitLocation.ManuverNode:
182 | var mn = vsl?.FirstUpcomingManuverNode( this.CurrentUT );
183 | if ((mn != null))
184 | {
185 | double TargetUT = mn.UT - V;
186 | RailsWarpController.Instance.RailsWarpToUT( TargetUT );
187 | }
188 | break;
189 | case VesselOrbitLocation.ManuverNodeStartBurn:
190 | var mn2 = vsl?.FirstUpcomingManuverNode( this.CurrentUT );
191 | if ((mn2 != null))
192 | {
193 | double TargetUT = (CurrentUT + mn2.startBurnIn) - V;
194 | RailsWarpController.Instance.RailsWarpToUT( TargetUT );
195 | }
196 | break;
197 | }
198 | }
199 | }
200 | }
201 | /*
202 | All code in this file Copyright(c) 2016 Nate West
203 |
204 | The MIT License (MIT)
205 |
206 | Permission is hereby granted, free of charge, to any person obtaining a copy
207 | of this software and associated documentation files (the "Software"), to deal
208 | in the Software without restriction, including without limitation the rights
209 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
210 | copies of the Software, and to permit persons to whom the Software is
211 | furnished to do so, subject to the following conditions:
212 |
213 | The above copyright notice and this permission notice shall be included in all
214 | copies or substantial portions of the Software.
215 |
216 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
217 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
218 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
219 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
220 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
221 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
222 | SOFTWARE.
223 | */
224 |
--------------------------------------------------------------------------------
/TimeControl/Logging/EntryExitLogger.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Diagnostics;
4 | using System.Linq;
5 | using System.Text;
6 |
7 | namespace TimeControl
8 | {
9 | [Flags]
10 | public enum EntryExitLoggerOptions
11 | {
12 | ///
13 | /// Don't log methods at all
14 | ///
15 | None = 0x00,
16 | ///
17 | /// Log entry into the method
18 | ///
19 | Entry = 0x01,
20 | ///
21 | /// Log exit from the method
22 | ///
23 | Exit = 0x02,
24 | ///
25 | /// Log the execution time of the method
26 | ///
27 | ExecutionTime = 0x04,
28 | ///
29 | /// Log all data
30 | ///
31 | All = Entry | Exit | ExecutionTime,
32 | ///
33 | /// Always write to log even if logging level is set to greater than trace
34 | ///
35 | AlwaysLog = 0x08,
36 | }
37 |
38 |
39 | public class EntryExitLogger : IDisposable
40 | {
41 | private bool alwaysLog;
42 | private string blockName;
43 | private EntryExitLoggerOptions options;
44 | private Stopwatch sw;
45 |
46 | ///
47 | /// Log a block of code entry, exit, and timing
48 | ///
49 | /// The name of the code block being logged
50 | /// The log options
51 | /// A disposable object or none if logging is disabled
52 | public static IDisposable EntryExitLog(string blockName, EntryExitLoggerOptions options = EntryExitLoggerOptions.AlwaysLog)
53 | {
54 | IDisposable logger = null;
55 |
56 | if (Log.LoggingLevel == LogSeverity.Trace || ((options & EntryExitLoggerOptions.AlwaysLog) == EntryExitLoggerOptions.AlwaysLog))
57 | {
58 | // Check if ExecutionTime logging is requested, and if so log if Verbose logging (or greater) is chosen
59 | bool shouldCreate = ((options & EntryExitLoggerOptions.ExecutionTime) == EntryExitLoggerOptions.ExecutionTime);
60 |
61 | // If not logging ExecutionTime log only if Entry or Exit tracing is requested
62 | if (!shouldCreate)
63 | {
64 | shouldCreate = (((options & EntryExitLoggerOptions.Entry) == EntryExitLoggerOptions.Entry) || ((options & EntryExitLoggerOptions.Exit) == EntryExitLoggerOptions.Exit));
65 | }
66 |
67 | // Check if we actually need to log anything
68 | if (shouldCreate)
69 | {
70 | logger = new EntryExitLogger( blockName, options );
71 | }
72 | }
73 |
74 | // Will return null if no method logger was needed - which will effectively be ignored in a using statement.
75 | return logger;
76 | }
77 |
78 | ///
79 | /// Ctor private - just called from the static MethodLog method
80 | ///
81 | /// The name of the method being logged
82 | /// The log options
83 | private EntryExitLogger(string blockName, EntryExitLoggerOptions options)
84 | {
85 | this.blockName = blockName;
86 | this.options = options;
87 | this.alwaysLog = ((this.options & EntryExitLoggerOptions.AlwaysLog) == EntryExitLoggerOptions.AlwaysLog);
88 |
89 | if ((this.options & EntryExitLoggerOptions.ExecutionTime) == EntryExitLoggerOptions.ExecutionTime)
90 | {
91 | this.sw = new Stopwatch();
92 | this.sw.Start();
93 | }
94 |
95 | if ((this.options & EntryExitLoggerOptions.Entry) == EntryExitLoggerOptions.Entry)
96 | {
97 | Log.Trace( "block entry", this.blockName, this.alwaysLog );
98 | }
99 | }
100 |
101 | ///
102 | /// Tidy up
103 | ///
104 | public void Dispose()
105 | {
106 | try
107 | {
108 | if ((this.options & EntryExitLoggerOptions.ExecutionTime) == EntryExitLoggerOptions.ExecutionTime)
109 | {
110 | this.sw.Stop();
111 | Log.Trace( String.Format( "block execution time {0}ms", this.sw.ElapsedMilliseconds ), this.blockName, this.alwaysLog );
112 | }
113 |
114 | if ((this.options & EntryExitLoggerOptions.Exit) == EntryExitLoggerOptions.Exit)
115 | {
116 | Log.Trace( "block exit", this.blockName, this.alwaysLog );
117 | }
118 | } catch (Exception e)
119 | {
120 | Log.Error( e.Message );
121 | Log.Error( e.StackTrace );
122 | }
123 | }
124 | }
125 | }
126 |
127 | /*
128 | All code in this file Copyright(c) 2016 Nate West
129 |
130 | The MIT License (MIT)
131 |
132 | Permission is hereby granted, free of charge, to any person obtaining a copy
133 | of this software and associated documentation files (the "Software"), to deal
134 | in the Software without restriction, including without limitation the rights
135 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
136 | copies of the Software, and to permit persons to whom the Software is
137 | furnished to do so, subject to the following conditions:
138 |
139 | The above copyright notice and this permission notice shall be included in all
140 | copies or substantial portions of the Software.
141 |
142 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
143 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
144 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
145 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
146 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
147 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
148 | SOFTWARE.
149 | */
150 |
--------------------------------------------------------------------------------
/TimeControl/Logging/Log.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Reflection;
3 | using UnityEngine;
4 | using System.Diagnostics;
5 |
6 | namespace TimeControl
7 | {
8 | static internal class Log
9 | {
10 | internal readonly static string VERSION = Assembly.GetAssembly( typeof( Log ) ).GetName().Version.Major + "." + Assembly.GetAssembly( typeof( Log ) ).GetName().Version.Minor + "." + Assembly.GetAssembly( typeof( Log ) ).GetName().Version.Build;
11 | internal readonly static string MOD = Assembly.GetAssembly( typeof( Log ) ).GetName().Name;
12 | public static readonly string logPrefix = MOD + "(" + VERSION + ")";
13 | internal readonly static string title = logPrefix + " - Serious Error";
14 |
15 | static internal LogSeverity loggingLevel;
16 |
17 | ///
18 | /// Show all messages of this level and below (e.g. Error only shows errors, while Info shows Errors, Warnings, and Info)
19 | ///
20 | static internal LogSeverity LoggingLevel
21 | {
22 | get => loggingLevel;
23 | set
24 | {
25 | loggingLevel = value;
26 | //System.Diagnostics.StackTrace t = new System.Diagnostics.StackTrace();
27 | //Log.Trace( "Logging Level Set to " + value.ToString() + "\n" + t.ToString(), "Log", true );
28 | Log.Trace( "Logging Level Set to " + value.ToString(), "Log", true );
29 | }
30 | }
31 |
32 | static Log()
33 | {
34 | #if DEBUG
35 | LoggingLevel = LogSeverity.Trace;
36 | #else
37 | LoggingLevel = LogSeverity.Warning;
38 | #endif
39 | }
40 |
41 | static internal void Trace(string message, string caller = "", bool always = false)
42 | {
43 | Log.Write( message, caller, LogSeverity.Trace, always );
44 | }
45 | static internal void Info(string message, string caller = "", bool always = false)
46 | {
47 | Log.Write( message, caller, LogSeverity.Info, always );
48 | }
49 | static internal void Warning(string message, string caller = "", bool always = false)
50 | {
51 | Log.Write( message, caller, LogSeverity.Warning, always );
52 | }
53 | static internal void Error(string message, string caller = "", bool always = false)
54 | {
55 | Log.Write( message, caller, LogSeverity.Error, always );
56 | }
57 |
58 | static internal void PopupError(string message)
59 | {
60 | PopupDialog.SpawnPopupDialog( new Vector2( 0.5f, 0.5f ), new Vector2( 0.5f, 0.5f ), Guid.NewGuid().ToString(), title, message, "OK", true, HighLogic.UISkin, false );
61 | }
62 |
63 | static internal void Write(string message, string caller = "", LogSeverity sev = LogSeverity.Warning, bool always = false)
64 | {
65 | // Return if we don't need to write messages for this severity
66 | if (!always && Log.LoggingLevel > sev)
67 | {
68 | return;
69 | }
70 |
71 | message = string.Format( "[{1}] <{2}>{3} {0} - ({4}) - {5}", DateTime.Now, logPrefix, sev, (always ? "-A" : ""), caller, message );
72 | switch (sev)
73 | {
74 | case LogSeverity.Error:
75 | UnityEngine.Debug.LogError( message );
76 | break;
77 | case LogSeverity.Warning:
78 | UnityEngine.Debug.LogWarning( message );
79 | break;
80 | default:
81 | UnityEngine.Debug.Log( message );
82 | break;
83 | }
84 | }
85 | }
86 | }
87 |
88 | /*
89 | All code in this file Copyright(c) 2016 Nate West
90 |
91 | The MIT License (MIT)
92 |
93 | Permission is hereby granted, free of charge, to any person obtaining a copy
94 | of this software and associated documentation files (the "Software"), to deal
95 | in the Software without restriction, including without limitation the rights
96 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
97 | copies of the Software, and to permit persons to whom the Software is
98 | furnished to do so, subject to the following conditions:
99 |
100 | The above copyright notice and this permission notice shall be included in all
101 | copies or substantial portions of the Software.
102 |
103 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
104 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
105 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
106 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
107 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
108 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
109 | SOFTWARE.
110 | */
111 |
--------------------------------------------------------------------------------
/TimeControl/Logging/LogSeverity.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace TimeControl
7 | {
8 | public enum LogSeverity
9 | {
10 | Trace = 0,
11 | Info = 1,
12 | Warning = 2,
13 | Error = 3
14 | }
15 | }
16 |
17 | /*
18 | All code in this file Copyright(c) 2016 Nate West
19 |
20 | The MIT License (MIT)
21 |
22 | Permission is hereby granted, free of charge, to any person obtaining a copy
23 | of this software and associated documentation files (the "Software"), to deal
24 | in the Software without restriction, including without limitation the rights
25 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
26 | copies of the Software, and to permit persons to whom the Software is
27 | furnished to do so, subject to the following conditions:
28 |
29 | The above copyright notice and this permission notice shall be included in all
30 | copies or substantial portions of the Software.
31 |
32 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
33 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
34 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
35 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
36 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
37 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
38 | SOFTWARE.
39 | */
40 |
--------------------------------------------------------------------------------
/TimeControl/PerformanceManager.cs:
--------------------------------------------------------------------------------
1 | using System.Collections;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using UnityEngine;
5 |
6 | namespace TimeControl
7 | {
8 | [KSPAddon( KSPAddon.Startup.Instantly, true )]
9 | public class PerformanceManager : MonoBehaviour
10 | {
11 | #region Singleton
12 | public static bool IsReady { get; private set; } = false;
13 | private static PerformanceManager instance;
14 | public static PerformanceManager Instance { get { return instance; } }
15 | #endregion
16 |
17 | private int frames = 0;
18 | private float lastInterval = 0f;
19 | private double ptrLast = 0d;
20 | private Queue ptrRollingQ;
21 | private double gsLastRT = 0d;
22 | private double gsLastUT = 0d;
23 | private Queue gsRollingQ;
24 | private float updateInterval = 0.5f; //half a second
25 | private bool performanceCountersOn = true;
26 |
27 | ///
28 | /// Turn on and off Performance Counters
29 | ///
30 | public bool PerformanceCountersOn {
31 | get {
32 | return performanceCountersOn;
33 | }
34 | set {
35 | if (performanceCountersOn != value)
36 | {
37 | performanceCountersOn = value;
38 | if (!performanceCountersOn)
39 | {
40 | this.ptrRollingQ.Clear();
41 | this.gsRollingQ.Clear();
42 | frames = 0;
43 | }
44 | }
45 | }
46 | }
47 | ///
48 | /// Frames Per Second
49 | ///
50 | public double FramesPerSecond { get; set; }
51 |
52 | ///
53 | /// Gametime to Realtime Ratio
54 | ///
55 | public double GametimeToRealtimeRatio { get; set; }
56 |
57 | ///
58 | /// Physics Updates Per Second
59 | ///
60 | public double PhysicsUpdatesPerSecond { get; set; }
61 |
62 | ///
63 | /// Physics Time Ratio: The ratio of real time to game time. (1 means KSP can handle the physics, less than 1 means time is being slowed by KSP because it can't process all the physics)
64 | ///
65 | public double PhysicsTimeRatio { get; set; }
66 |
67 | private void Awake()
68 | {
69 | const string logBlockName = nameof( PerformanceManager ) + "." + nameof( Awake );
70 | using (EntryExitLogger.EntryExitLog( logBlockName, EntryExitLoggerOptions.All ))
71 | {
72 | DontDestroyOnLoad( this );
73 | instance = this;
74 | }
75 | }
76 |
77 | private void Start()
78 | {
79 | const string logBlockName = nameof( PerformanceManager ) + "." + nameof( Start );
80 | using (EntryExitLogger.EntryExitLog( logBlockName, EntryExitLoggerOptions.All ))
81 | {
82 | StartCoroutine( Configure() );
83 | }
84 | }
85 |
86 | private IEnumerator Configure()
87 | {
88 | const string logBlockName = nameof( PerformanceManager ) + "." + nameof( Configure );
89 | using (EntryExitLogger.EntryExitLog( logBlockName, EntryExitLoggerOptions.All ))
90 | {
91 | ptrRollingQ = new Queue();
92 | gsRollingQ = new Queue();
93 | FramesPerSecond = 0f;
94 | PhysicsUpdatesPerSecond = 0f;
95 | PhysicsTimeRatio = 0d;
96 | PerformanceCountersOn = true;
97 |
98 | while (!GlobalSettings.IsReady || !IsValidScene())
99 | {
100 | yield return new WaitForSeconds( 1 );
101 | }
102 |
103 | Log.Info( nameof( PerformanceManager ) + " is Ready!", logBlockName );
104 | IsReady = true;
105 | yield break;
106 | }
107 | }
108 |
109 | //Functions
110 | private void Update()
111 | {
112 | if (!PerformanceCountersOn || !IsValidScene())
113 | {
114 | return;
115 | }
116 |
117 | float rtss = Time.realtimeSinceStartup;
118 |
119 | UpdateFPS( rtss );
120 | UpdatePPS( Time.timeScale, Time.fixedDeltaTime );
121 | UpdatePTR( rtss, Time.deltaTime );
122 | UpdateGTRR( rtss, Planetarium.GetUniversalTime() );
123 | }
124 |
125 | private void UpdateFPS(float rtss)
126 | {
127 | //FPS calculation
128 | frames++;
129 | if (rtss > lastInterval + updateInterval)
130 | {
131 | FramesPerSecond = frames / (rtss - lastInterval);
132 | frames = 0;
133 | lastInterval = rtss;
134 | }
135 | }
136 |
137 | private void UpdateGTRR(float rtss, double UT)
138 | {
139 | //Time Warp calculation
140 | gsRollingQ.Enqueue( (UT - gsLastUT) / (rtss - gsLastRT) );
141 | gsLastRT = rtss;
142 | gsLastUT = UT;
143 |
144 | while (gsRollingQ.Count > FramesPerSecond)
145 | {
146 | gsRollingQ.Dequeue();
147 | }
148 |
149 | if (gsRollingQ.Count > 0)
150 | {
151 | GametimeToRealtimeRatio = gsRollingQ.Average();
152 | }
153 | }
154 |
155 | private void UpdatePPS(float timeScale, float fixedDeltaTime)
156 | {
157 | PhysicsUpdatesPerSecond = timeScale / fixedDeltaTime;
158 | }
159 |
160 | private void UpdatePTR(float rtss, float deltaTime)
161 | {
162 | //PTR calculation
163 | ptrRollingQ.Enqueue( deltaTime / ((double)rtss - ptrLast) );
164 | ptrLast = rtss;
165 |
166 | while (ptrRollingQ.Count > FramesPerSecond)
167 | {
168 | ptrRollingQ.Dequeue();
169 | }
170 |
171 | if (ptrRollingQ.Count > 0)
172 | {
173 | PhysicsTimeRatio = ptrRollingQ.Average();
174 | }
175 | }
176 |
177 | private bool IsValidScene()
178 | {
179 | return (HighLogic.LoadedScene == GameScenes.EDITOR || HighLogic.LoadedScene == GameScenes.FLIGHT || HighLogic.LoadedScene == GameScenes.SPACECENTER || HighLogic.LoadedScene == GameScenes.TRACKSTATION);
180 | }
181 | }
182 | }
183 |
184 |
185 | /*
186 | All code in this file Copyright(c) 2016 Nate West
187 |
188 | The MIT License (MIT)
189 |
190 | Permission is hereby granted, free of charge, to any person obtaining a copy
191 | of this software and associated documentation files (the "Software"), to deal
192 | in the Software without restriction, including without limitation the rights
193 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
194 | copies of the Software, and to permit persons to whom the Software is
195 | furnished to do so, subject to the following conditions:
196 |
197 | The above copyright notice and this permission notice shall be included in all
198 | copies or substantial portions of the Software.
199 |
200 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
201 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
202 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
203 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
204 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
205 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
206 | SOFTWARE.
207 |
208 | */
209 |
--------------------------------------------------------------------------------
/TimeControl/PluginAssemblyUtilities.cs:
--------------------------------------------------------------------------------
1 | namespace TimeControl
2 | {
3 | static class PluginAssemblyUtilities
4 | {
5 | internal static readonly string VERSION =
6 | System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.Major + "."
7 | + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.Minor + "."
8 | + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.Build + "."
9 | + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.Revision;
10 |
11 | internal static readonly string MOD = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name;
12 |
13 | //internal static readonly string PathApp = KSPUtil.ApplicationRootPath.Replace( "\\", "/" );
14 | internal static readonly string PathPlugin = System.IO.Path.GetDirectoryName( System.Reflection.Assembly.GetExecutingAssembly().Location ).Replace( "\\", "/" );
15 | internal static readonly string PathPluginData = string.Format( "{0}/PluginData", PathPlugin );
16 |
17 | internal static readonly string GameDatabasePathStockToolbarIcons = string.Format( "{0}/ToolbarIcons/StockToolbarIcons", MOD );
18 | internal static readonly string GameDatabasePathBlizzyToolbarIcons = string.Format( "{0}/ToolbarIcons/BlizzyToolbarIcons", MOD );
19 |
20 | internal static readonly string settingsFilePath = string.Format( "{0}/settings.cfg", PathPluginData );
21 |
22 | //internal static readonly string PathTextures = string.Format( "{0}/Textures", PathPlugin );
23 | //internal static readonly string GameDatabasePathTextures = string.Format( "{0}/Textures", MOD );
24 | //internal static readonly string PathPluginSounds = string.Format( "{0}/Sounds", PathPlugin );
25 |
26 | }
27 | }
28 |
29 | /*
30 | All code in this file Copyright(c) 2016 Nate West
31 |
32 | The MIT License (MIT)
33 |
34 | Permission is hereby granted, free of charge, to any person obtaining a copy
35 | of this software and associated documentation files (the "Software"), to deal
36 | in the Software without restriction, including without limitation the rights
37 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
38 | copies of the Software, and to permit persons to whom the Software is
39 | furnished to do so, subject to the following conditions:
40 |
41 | The above copyright notice and this permission notice shall be included in all
42 | copies or substantial portions of the Software.
43 |
44 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
45 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
46 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
47 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
48 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
49 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
50 | SOFTWARE.
51 |
52 | */
53 |
--------------------------------------------------------------------------------
/TimeControl/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("TimeControl")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("TimeControl")]
13 | [assembly: AssemblyCopyright("Copyright © 2016")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | [assembly: InternalsVisibleTo("TimeControl.Testing")]
18 |
19 | // Setting ComVisible to false makes the types in this assembly not visible
20 | // to COM components. If you need to access a type in this assembly from
21 | // COM, set the ComVisible attribute to true on that type.
22 | [assembly: ComVisible(false)]
23 |
24 | // The following GUID is for the ID of the typelib if this project is exposed to COM
25 | [assembly: Guid("b968f9e7-de55-4b86-905b-8cdd38c2ab6e")]
26 |
27 | // Version information for an assembly consists of the following four values:
28 | //
29 | // Major Version
30 | // Minor Version
31 | // Build Number
32 | // Revision
33 | //
34 | // Version information is generated by the AssemblyVersion.tt text template from the KSP .version file
35 |
--------------------------------------------------------------------------------
/TimeControl/ResourceConverterBugFix.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Reflection;
4 |
5 | using UnityEngine;
6 |
7 | namespace ResourceConverterWarpFix
8 | {
9 | [KSPAddon( KSPAddon.Startup.Instantly, true )]
10 | internal class ResourceConverterWarpFix : MonoBehaviour
11 | {
12 | #region Singleton
13 | public static ResourceConverterWarpFix Instance { get; private set; }
14 | public static bool IsReady { get; private set; } = false;
15 | #endregion
16 |
17 | #region Private Fields
18 | private List resourceConverterParts;
19 | private int lastWarpRateIdx;
20 | #endregion
21 |
22 | #region MonoBehavior
23 | private void Awake()
24 | {
25 | DontDestroyOnLoad( this );
26 | Instance = this;
27 |
28 | resourceConverterParts = new List();
29 | lastWarpRateIdx = 0;
30 | }
31 | private void Start()
32 | {
33 | GameEvents.onTimeWarpRateChanged.Add( onTimeWarpRateChanged );
34 | GameEvents.onPartUnpack.Add( onPartUnpack );
35 | IsReady = true;
36 | }
37 |
38 | private void OnDestroy()
39 | {
40 | GameEvents.onTimeWarpRateChanged.Remove( onTimeWarpRateChanged );
41 | GameEvents.onPartUnpack.Remove( onPartUnpack );
42 | }
43 | #endregion MonoBehavior
44 |
45 | #region GameEvents
46 |
47 | ///
48 | /// When unpacking parts after warp, fix issue with ResourceConverter
49 | ///
50 | ///
51 | private void onPartUnpack(Part p)
52 | {
53 | if (resourceConverterParts.Contains( p ))
54 | {
55 | resourceConverterParts.Remove( p );
56 | foreach (PartModule pm in p.Modules)
57 | {
58 | if (pm is ModuleResourceConverter mrc)
59 | {
60 | CorrectLastUpdateTime( mrc );
61 | }
62 | }
63 | }
64 | }
65 |
66 | ///
67 | /// When changing warp rate, correct the last update time if the converter is active
68 | /// (or add the part to the list of parts to be corrected when warp slows)
69 | ///
70 | private void onTimeWarpRateChanged()
71 | {
72 | if (TimeWarp.fetch != null)
73 | {
74 | if (lastWarpRateIdx > 0 && TimeWarp.CurrentRate > 1)
75 | {
76 | foreach (var v in FlightGlobals.fetch.vesselsLoaded)
77 | {
78 | foreach (var p in v.Parts)
79 | {
80 | foreach (PartModule pm in p.Modules)
81 | {
82 | if (pm is ModuleResourceConverter mrc)
83 | {
84 | if (!mrc.IsActivated)
85 | {
86 | if (!resourceConverterParts.Contains( p ))
87 | {
88 | resourceConverterParts.Add( p );
89 | }
90 | }
91 | else
92 | {
93 | if (resourceConverterParts.Contains( p ))
94 | {
95 | resourceConverterParts.Remove( p );
96 | CorrectLastUpdateTime( mrc );
97 | }
98 | }
99 | }
100 | }
101 | }
102 | }
103 | }
104 | lastWarpRateIdx = TimeWarp.fetch.current_rate_index;
105 | }
106 | }
107 | #endregion GameEvents
108 |
109 | #region Private Methods
110 | private void CorrectLastUpdateTime(ModuleResourceConverter mrc)
111 | {
112 | if (mrc is null)
113 | {
114 | throw new ArgumentNullException( nameof( mrc ) );
115 | }
116 |
117 | FieldInfo fi = mrc.GetType().GetField( "lastUpdateTime", BindingFlags.NonPublic | BindingFlags.Instance );
118 | if (fi != null)
119 | {
120 | fi.SetValue( mrc, Planetarium.GetUniversalTime() );
121 | }
122 | else
123 | {
124 | throw new InvalidOperationException( "Unable to get a lastUpdateTime field on module " + mrc.moduleName );
125 | }
126 | }
127 | #endregion Private Methods
128 | }
129 | }
130 |
131 | /*
132 | All code in this file Copyright(c) 2016 Nate West
133 |
134 | Portions of the logic (but not the code) in this file is derived from code in BetterTimeWarp Continued by linuxgurugamer
135 | https://github.com/linuxgurugamer/BetterTimeWarpContinued/blob/master/BetterTimeWarp/BetterTimeWarp.cs
136 | linuxgurugamer has provided permission for me to use this code.
137 |
138 | The MIT License (MIT)
139 |
140 | Permission is hereby granted, free of charge, to any person obtaining a copy
141 | of this software and associated documentation files (the "Software"), to deal
142 | in the Software without restriction, including without limitation the rights
143 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
144 | copies of the Software, and to permit persons to whom the Software is
145 | furnished to do so, subject to the following conditions:
146 |
147 | The above copyright notice and this permission notice shall be included in all
148 | copies or substantial portions of the Software.
149 |
150 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
151 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
152 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
153 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
154 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
155 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
156 | SOFTWARE.
157 |
158 | */
159 |
--------------------------------------------------------------------------------
/TimeControl/TimeControl.csproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | ShowAllFiles
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/TimeControl/TimeControlEvents.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using UnityEngine;
6 |
7 | using TimeControl.KeyBindings;
8 |
9 | namespace TimeControl
10 | {
11 | [KSPAddon( KSPAddon.Startup.Instantly, true )]
12 | public class TimeControlEvents : MonoBehaviour
13 | {
14 | public static EventData OnTimeControlDefaultFixedDeltaTimeChanged;
15 | public static EventData OnTimeControlFixedDeltaTimeChanged;
16 | public static EventData OnTimeControlTimeScaleChanged;
17 | public static EventData OnTimeControlTimePaused;
18 | public static EventData OnTimeControlTimeUnpaused;
19 |
20 | public static EventData OnTimeControlHyperWarpMaximumDeltaTimeChanged;
21 | public static EventData OnTimeControlHyperWarpMaxAttemptedRateChanged;
22 | public static EventData OnTimeControlHyperWarpPhysicsAccuracyChanged;
23 | public static EventData OnTimeControlHyperWarpStarting;
24 | public static EventData OnTimeControlHyperWarpStarted;
25 | public static EventData OnTimeControlHyperWarpStopping;
26 | public static EventData OnTimeControlHyperWarpStopped;
27 |
28 | public static EventData OnTimeControlSlowMoDeltaLockedChanged;
29 | public static EventData OnTimeControlSlowMoRateChanged;
30 | public static EventData OnTimeControlSlowMoStarting;
31 | public static EventData OnTimeControlSlowMoStarted;
32 | public static EventData OnTimeControlSlowMoStopping;
33 | public static EventData OnTimeControlSlowMoStopped;
34 |
35 | public static EventData OnTimeControlCustomWarpRatesChanged;
36 | public static EventData OnTimeControlCustomHyperWarpRatesChanged;
37 | public static EventData OnTimeControlCustomSlowMotionRatesChanged;
38 |
39 | public static EventData OnTimeControlGlobalSettingsSaved;
40 | public static EventData OnTimeControlGlobalSettingsChanged;
41 |
42 | public static EventData OnTimeControlKeyBindingsChanged;
43 |
44 | private void Awake()
45 | {
46 | const string logBlockName = nameof( Awake );
47 | using (EntryExitLogger.EntryExitLog( logBlockName, EntryExitLoggerOptions.All ))
48 | {
49 | DontDestroyOnLoad( this );
50 |
51 | // Common
52 | OnTimeControlDefaultFixedDeltaTimeChanged = new EventData( nameof( OnTimeControlDefaultFixedDeltaTimeChanged ) );
53 | OnTimeControlFixedDeltaTimeChanged = new EventData( nameof( OnTimeControlFixedDeltaTimeChanged ) );
54 | OnTimeControlTimeScaleChanged = new EventData( nameof( OnTimeControlTimeScaleChanged ) );
55 | OnTimeControlTimePaused = new EventData( nameof( OnTimeControlTimePaused ) );
56 | OnTimeControlTimeUnpaused = new EventData( nameof( OnTimeControlTimeUnpaused ) );
57 |
58 | // Hyper Warp
59 | OnTimeControlHyperWarpMaximumDeltaTimeChanged = new EventData( nameof( OnTimeControlHyperWarpMaximumDeltaTimeChanged ) );
60 | OnTimeControlHyperWarpMaxAttemptedRateChanged = new EventData( nameof( OnTimeControlHyperWarpMaxAttemptedRateChanged ) );
61 | OnTimeControlHyperWarpPhysicsAccuracyChanged = new EventData( nameof( OnTimeControlHyperWarpPhysicsAccuracyChanged ) );
62 |
63 | OnTimeControlCustomHyperWarpRatesChanged = new EventData( nameof( OnTimeControlCustomHyperWarpRatesChanged ) );
64 | OnTimeControlCustomSlowMotionRatesChanged = new EventData( nameof( OnTimeControlCustomSlowMotionRatesChanged ) );
65 |
66 | OnTimeControlHyperWarpStarting = new EventData( nameof( OnTimeControlHyperWarpStarting ) );
67 | OnTimeControlHyperWarpStarted = new EventData( nameof( OnTimeControlHyperWarpStarted ) );
68 |
69 | OnTimeControlHyperWarpStopping = new EventData( nameof( OnTimeControlHyperWarpStopping ) );
70 | OnTimeControlHyperWarpStopped = new EventData( nameof( OnTimeControlHyperWarpStopped ) );
71 |
72 | // Slow Motion
73 | OnTimeControlSlowMoRateChanged = new EventData( nameof( OnTimeControlSlowMoRateChanged ) );
74 | OnTimeControlSlowMoDeltaLockedChanged = new EventData( nameof( OnTimeControlSlowMoDeltaLockedChanged ) );
75 |
76 | OnTimeControlSlowMoStarting = new EventData( nameof( OnTimeControlSlowMoStarting ) );
77 | OnTimeControlSlowMoStarted = new EventData( nameof( OnTimeControlSlowMoStarted ) );
78 |
79 | OnTimeControlSlowMoStopping = new EventData( nameof( OnTimeControlSlowMoStopping ) );
80 | OnTimeControlSlowMoStopped = new EventData( nameof( OnTimeControlSlowMoStopped ) );
81 |
82 | // Rails Limits Changed
83 | OnTimeControlCustomWarpRatesChanged = new EventData( nameof( OnTimeControlCustomWarpRatesChanged ) );
84 |
85 | // Global Settings
86 | OnTimeControlGlobalSettingsSaved = new EventData( nameof( OnTimeControlGlobalSettingsSaved ) );
87 | OnTimeControlGlobalSettingsChanged = new EventData( nameof( OnTimeControlGlobalSettingsChanged ) );
88 |
89 | // Key Bindings
90 | OnTimeControlKeyBindingsChanged = new EventData( nameof( OnTimeControlKeyBindingsChanged ) );
91 | }
92 | }
93 | }
94 | }
95 |
96 | /*
97 | All code in this file Copyright(c) 2016 Nate West
98 |
99 | The MIT License (MIT)
100 |
101 | Permission is hereby granted, free of charge, to any person obtaining a copy
102 | of this software and associated documentation files (the "Software"), to deal
103 | in the Software without restriction, including without limitation the rights
104 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
105 | copies of the Software, and to permit persons to whom the Software is
106 | furnished to do so, subject to the following conditions:
107 |
108 | The above copyright notice and this permission notice shall be included in all
109 | copies or substantial portions of the Software.
110 |
111 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
112 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
113 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
114 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
115 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
116 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
117 | SOFTWARE.
118 | */
119 |
--------------------------------------------------------------------------------
/TimeControl/TimeControlParameters.cs:
--------------------------------------------------------------------------------
1 | using System.Collections;
2 | using System.Reflection;
3 |
4 | namespace TimeControl
5 | {
6 | public class TimeControlParameterNode : GameParameters.CustomParameterNode
7 | {
8 | public override string Section { get { return "Time Control"; } }
9 | public override string DisplaySection { get { return Section; } }
10 | public override int SectionOrder { get { return 1; } }
11 | public override string Title { get { return "Time Control"; } }
12 |
13 | public override GameParameters.GameMode GameMode { get { return GameParameters.GameMode.ANY; } }
14 | public override bool HasPresets { get { return true; } }
15 |
16 | [GameParameters.CustomParameterUI("Use Stock Toolbar", toolTip = "")]
17 | public bool UseStockToolbar = true;
18 | [GameParameters.CustomParameterUI("Use Blizzy Toolbar", toolTip = "")]
19 | public bool UseBlizzyToolbar = true;
20 | [GameParameters.CustomParameterUI( "Use Kerbin Time", toolTip = "" )]
21 | public bool UseKerbinTime = GameSettings.KERBIN_TIME;
22 | [GameParameters.CustomParameterUI("Show Hyper-Warp Onscreen Messages", toolTip = "")]
23 | public bool ShowHyperOnscreenMessages = true;
24 | [GameParameters.CustomParameterUI( "Show Slow-Motion Onscreen Messages", toolTip = "" )]
25 | public bool ShowSlowMoOnscreenMessages = true;
26 | [GameParameters.CustomParameterUI( "Camera Zoom Fix", toolTip = "" )]
27 | public bool CameraZoomFix = true;
28 |
29 | #if DEBUG
30 | [GameParameters.CustomParameterUI( "Debug Logging Level", toolTip = "" )]
31 | public LogSeverity LoggingLevel = LogSeverity.Trace;
32 | #else
33 | [GameParameters.CustomParameterUI("Debug Logging Level", toolTip = "")]
34 | public LogSeverity LoggingLevel = LogSeverity.Warning;
35 | #endif
36 |
37 | [GameParameters.CustomIntParameterUI( "Key Repeat Start", minValue = 0, maxValue = 1000, stepSize = 100, toolTip = "For repeatable key bindings, the time in milliseconds the key must be held down before starting to repeat." )]
38 | public int KeyRepeatStart = 500;
39 | [GameParameters.CustomIntParameterUI( "Key Repeat Interval", minValue = 1, maxValue = 60, stepSize = 1, toolTip = "For repeatable key bindings, the number of times key is repeated per second." )]
40 | public int KeyRepeatInterval = 15;
41 |
42 | [GameParameters.CustomStringParameterUI("UIExperimentalFeaturesString", autoPersistance = true, lines = 2, title = "Experimental Features", toolTip = "")]
43 | public string UIExperimentalFeaturesString = "";
44 |
45 | [GameParameters.CustomParameterUI("Supress the Flight Results Dialog", toolTip = "")]
46 | public bool SupressFlightResultsDialog = false;
47 |
48 | //[GameParameters.CustomParameterUI("Custom TimeControl Date Formatter", toolTip = "")]
49 | //public bool UseCustomDateTimeFormatter = true;
50 |
51 | public override bool Enabled(MemberInfo member, GameParameters parameters)
52 | {
53 | /*
54 | if (member.Name == "MyBool") //This Field must always be enabled.
55 | return true;
56 | if (MyBool == false) //Otherwise it depends on the value of MyBool if it's false return false
57 | {
58 | if (member.Name == "UIstring" || member.Name == "MyFloat") // Example these fields are Enabled (visible) all the time.
59 | return true;
60 | return false;
61 | }
62 | */
63 |
64 | return true; //otherwise return true
65 | }
66 |
67 | public override bool Interactible(MemberInfo member, GameParameters parameters)
68 | {
69 | /*
70 | if (member.Name == "MyBool") //This Field must always be Interactible.
71 | return true;
72 | if (MyBool == false) //Otherwise it depends on the value of MyBool if it's false return false
73 | return false;
74 | */
75 |
76 | return true; //otherwise return true
77 | }
78 |
79 | public override IList ValidValues(MemberInfo member)
80 | {
81 | /*
82 | if (member.Name == "MyIlist")
83 | {
84 | List myList = new List();
85 | foreach (CelestialBody cb in FlightGlobals.Bodies)
86 | {
87 | myList.Add(cb.name);
88 | }
89 | IList myIlist = myList;
90 | return myIlist;
91 | }
92 | else
93 | {
94 | return null;
95 | }
96 | */
97 | return null;
98 | }
99 | public override void OnSave(ConfigNode node)
100 | {
101 | const string logBlockName = nameof( TimeControlParameterNode ) + "." + nameof( OnSave );
102 | using (EntryExitLogger.EntryExitLog( logBlockName, EntryExitLoggerOptions.All ))
103 | {
104 |
105 | }
106 | }
107 |
108 | public override void OnLoad(ConfigNode node)
109 | {
110 |
111 | const string logBlockName = nameof( TimeControlParameterNode ) + "." + nameof( OnLoad );
112 | using (EntryExitLogger.EntryExitLog( logBlockName, EntryExitLoggerOptions.All ))
113 | {
114 | if (GlobalSettings.IsReady)
115 | {
116 | LoggingLevel = GlobalSettings.Instance.LoggingLevel;
117 | CameraZoomFix = GlobalSettings.Instance.CameraZoomFix;
118 | KeyRepeatStart = GlobalSettings.Instance.KeyRepeatStart;
119 | KeyRepeatInterval = GlobalSettings.Instance.KeyRepeatInterval;
120 | }
121 |
122 | UseKerbinTime = GameSettings.KERBIN_TIME;
123 | }
124 | }
125 |
126 | public override void SetDifficultyPreset(GameParameters.Preset preset)
127 | {
128 | const string logBlockName = nameof( TimeControlParameterNode ) + "." + nameof( SetDifficultyPreset );
129 | using (EntryExitLogger.EntryExitLog( logBlockName, EntryExitLoggerOptions.All ))
130 | {
131 |
132 | }
133 | }
134 | }
135 | }
136 |
137 |
138 | /*
139 | All code in this file Copyright(c) 2016 Nate West
140 |
141 | The MIT License (MIT)
142 |
143 | Permission is hereby granted, free of charge, to any person obtaining a copy
144 | of this software and associated documentation files (the "Software"), to deal
145 | in the Software without restriction, including without limitation the rights
146 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
147 | copies of the Software, and to permit persons to whom the Software is
148 | furnished to do so, subject to the following conditions:
149 |
150 | The above copyright notice and this permission notice shall be included in all
151 | copies or substantial portions of the Software.
152 |
153 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
154 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
155 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
156 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
157 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
158 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
159 | SOFTWARE.
160 |
161 | */
162 |
--------------------------------------------------------------------------------
/TimeControl/TimeControlScenario.cs:
--------------------------------------------------------------------------------
1 | namespace TimeControl
2 | {
3 | [KSPScenario( ScenarioCreationOptions.AddToAllGames, GameScenes.SPACECENTER, GameScenes.FLIGHT, GameScenes.TRACKSTATION, GameScenes.EDITOR )]
4 | internal class TimeControlScenario : ScenarioModule
5 | {
6 | public override void OnLoad(ConfigNode gameNode)
7 | {
8 | base.OnLoad( gameNode );
9 |
10 | RailsWarpController.gameNode = gameNode;
11 |
12 | if (RailsWarpController.IsReady)
13 | {
14 | RailsWarpController.Instance.Load( gameNode );
15 | }
16 |
17 | HyperWarpController.gameNode = gameNode;
18 | if (HyperWarpController.IsReady)
19 | {
20 | HyperWarpController.Instance.Load( gameNode );
21 | }
22 | }
23 |
24 | public override void OnSave(ConfigNode gameNode)
25 | {
26 | base.OnSave( gameNode );
27 |
28 | if (RailsWarpController.IsReady)
29 | {
30 | RailsWarpController.Instance.Save( gameNode );
31 | }
32 |
33 | if (HyperWarpController.IsReady)
34 | {
35 | HyperWarpController.Instance.Save( gameNode );
36 | }
37 | }
38 | }
39 | }
40 | /*
41 | All code in this file Copyright(c) 2016 Nate West
42 |
43 | The MIT License (MIT)
44 |
45 | Permission is hereby granted, free of charge, to any person obtaining a copy
46 | of this software and associated documentation files (the "Software"), to deal
47 | in the Software without restriction, including without limitation the rights
48 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
49 | copies of the Software, and to permit persons to whom the Software is
50 | furnished to do so, subject to the following conditions:
51 |
52 | The above copyright notice and this permission notice shall be included in all
53 | copies or substantial portions of the Software.
54 |
55 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
56 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
57 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
58 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
59 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
60 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
61 | SOFTWARE.
62 |
63 | */
64 |
--------------------------------------------------------------------------------
/TimeControl/Toolbars.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 | using UnityEngine;
4 | using KSP.UI.Screens;
5 |
6 | namespace TimeControl
7 | {
8 | [KSPAddon( KSPAddon.Startup.Instantly, true )]
9 | internal sealed class Toolbars : MonoBehaviour
10 | {
11 | #region Singleton
12 | internal static Toolbars Instance { get; private set; }
13 | internal bool IsReady { get; private set; } = false;
14 | #endregion
15 |
16 | private ApplicationLauncher.AppScenes AppScenes = ApplicationLauncher.AppScenes.FLIGHT | ApplicationLauncher.AppScenes.MAPVIEW | ApplicationLauncher.AppScenes.SPACECENTER | ApplicationLauncher.AppScenes.TRACKSTATION;
17 | private Texture2D buttonTexture;
18 | private ApplicationLauncherButton appLauncherButton;
19 | private BlizzyToolbar.IButton toolbarButton;
20 |
21 | private bool StockToolbarEnabled
22 | {
23 | get => HighLogic.CurrentGame?.Parameters?.CustomParams()?.UseStockToolbar ?? false;
24 | }
25 |
26 | private static bool AppLauncherIsAvailable
27 | {
28 | get => ApplicationLauncher.Ready && ApplicationLauncher.Instance != null;
29 | }
30 |
31 | #region MonoBehavior
32 | private void Awake()
33 | {
34 | DontDestroyOnLoad( this );
35 | Instance = this;
36 | }
37 |
38 | private void Start()
39 | {
40 | StartCoroutine( Configure() );
41 | }
42 |
43 | #endregion
44 |
45 |
46 | ///
47 | /// Configures the Toolbars once the Settings are loaded
48 | ///
49 | public IEnumerator Configure()
50 | {
51 | while (!GlobalSettings.IsReady || !TimeControlIMGUI.IsReady)
52 | {
53 | yield return new WaitForSeconds( 1f );
54 | }
55 |
56 | buttonTexture = GameDatabase.Instance.GetTexture( PluginAssemblyUtilities.GameDatabasePathStockToolbarIcons + "/enabled", false );
57 |
58 | global::GameEvents.onGUIApplicationLauncherReady.Add( this.AppLauncherReady );
59 | global::GameEvents.onGUIApplicationLauncherDestroyed.Add( this.AppLauncherDestroyed );
60 | global::GameEvents.onLevelWasLoadedGUIReady.Add( this.AppLauncherDestroyed );
61 | global::GameEvents.OnGameSettingsApplied.Add( this.OnGameSettingsApplied );
62 |
63 | if (BlizzyToolbar.ToolbarManager.ToolbarAvailable)
64 | {
65 | toolbarButton = BlizzyToolbar.ToolbarManager.Instance.add( "TimeControl", "button" );
66 | toolbarButton.TexturePath = "TimeControl/ToolbarIcons/BlizzyToolbarIcons/enabled";
67 | toolbarButton.ToolTip = "Time Control";
68 | toolbarButton.Visibility = new BlizzyToolbar.GameScenesVisibility( GameScenes.FLIGHT, GameScenes.TRACKSTATION, GameScenes.SPACECENTER ); //Places where the button should show up
69 | toolbarButton.OnClick += BlizzyToolbarButtonClick;
70 | }
71 |
72 | IsReady = true;
73 |
74 | Reset();
75 |
76 | yield break;
77 | }
78 |
79 | private void BlizzyToolbarButtonClick(BlizzyToolbar.ClickEvent e)
80 | {
81 | TimeControlIMGUI.Instance.ToggleGUIVisibility();
82 | Set( TimeControlIMGUI.Instance.WindowVisible );
83 | }
84 |
85 | private void OnGameSettingsApplied()
86 | {
87 | Reset();
88 | }
89 |
90 | private void OnClick()
91 | {
92 | if (!IsReady)
93 | {
94 | return;
95 | }
96 |
97 | TimeControlIMGUI.Instance.ToggleGUIVisibility();
98 | Set( TimeControlIMGUI.Instance.WindowVisible );
99 | }
100 |
101 | private void AppLauncherShow()
102 | {
103 | if (!IsReady)
104 | {
105 | return;
106 | }
107 |
108 | TimeControlIMGUI.Instance.TempUnHideGUI( "StockAppLauncher" );
109 | }
110 | private void AppLancherHide()
111 | {
112 | if (!IsReady)
113 | {
114 | return;
115 | }
116 | TimeControlIMGUI.Instance.TempHideGUI( "StockAppLauncher" );
117 | }
118 |
119 | private void AppLauncherReady()
120 | {
121 | if (!StockToolbarEnabled)
122 | {
123 | return;
124 | }
125 |
126 | Init();
127 | }
128 | private void AppLauncherDestroyed(GameScenes gameScene)
129 | {
130 | if (HighLogic.LoadedSceneIsGame)
131 | {
132 | return;
133 | }
134 |
135 | Destroy();
136 | }
137 | private void AppLauncherDestroyed()
138 | {
139 | Destroy();
140 | }
141 |
142 | private void OnDestroy()
143 | {
144 | global::GameEvents.onGUIApplicationLauncherReady.Remove( this.AppLauncherReady );
145 | global::GameEvents.onGUIApplicationLauncherDestroyed.Remove( this.AppLauncherDestroyed );
146 | global::GameEvents.onLevelWasLoadedGUIReady.Remove( this.AppLauncherDestroyed );
147 | global::GameEvents.OnGameSettingsApplied.Remove( this.OnGameSettingsApplied );
148 | }
149 |
150 | private void Init()
151 | {
152 | if (!AppLauncherIsAvailable || !HighLogic.LoadedSceneIsGame)
153 | {
154 | return;
155 | }
156 |
157 | if (appLauncherButton == null)
158 | {
159 | appLauncherButton = ApplicationLauncher.Instance.AddModApplication( OnClick, OnClick, null, null, null, null, AppScenes, buttonTexture );
160 | }
161 |
162 | Set( TimeControlIMGUI.Instance.WindowVisible );
163 |
164 | ApplicationLauncher.Instance.RemoveOnHideCallback( AppLancherHide );
165 | ApplicationLauncher.Instance.RemoveOnShowCallback( AppLauncherShow );
166 | ApplicationLauncher.Instance.AddOnShowCallback( AppLauncherShow );
167 | ApplicationLauncher.Instance.AddOnHideCallback( AppLancherHide );
168 | }
169 |
170 | private void Destroy()
171 | {
172 | if (appLauncherButton != null)
173 | {
174 | ApplicationLauncher.Instance.RemoveOnHideCallback( AppLancherHide );
175 | ApplicationLauncher.Instance.RemoveOnShowCallback( AppLauncherShow );
176 | ApplicationLauncher.Instance.RemoveModApplication( appLauncherButton );
177 | ApplicationLauncher.Instance.RemoveApplication( appLauncherButton );
178 | appLauncherButton = null;
179 | }
180 | }
181 |
182 | internal void Set(bool SetTrue, bool force = false)
183 | {
184 | if (!AppLauncherIsAvailable || appLauncherButton == null)
185 | return;
186 |
187 | if (SetTrue)
188 | {
189 | if (appLauncherButton.enabled == false)
190 | {
191 | appLauncherButton.SetTrue( force );
192 | }
193 | }
194 | else
195 | {
196 | if (appLauncherButton.enabled == true)
197 | {
198 | appLauncherButton.SetFalse( force );
199 | }
200 | }
201 | }
202 |
203 | internal void Reset()
204 | {
205 | if (appLauncherButton != null)
206 | {
207 | Set( false );
208 | if (!StockToolbarEnabled)
209 | {
210 | Destroy();
211 | }
212 | }
213 | if (StockToolbarEnabled)
214 | {
215 | Init();
216 | }
217 | }
218 | }
219 | }
220 |
221 |
222 | /*
223 | All code in this file Copyright(c) 2016 Nate West
224 |
225 | The MIT License (MIT)
226 |
227 | Permission is hereby granted, free of charge, to any person obtaining a copy
228 | of this software and associated documentation files (the "Software"), to deal
229 | in the Software without restriction, including without limitation the rights
230 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
231 | copies of the Software, and to permit persons to whom the Software is
232 | furnished to do so, subject to the following conditions:
233 |
234 | The above copyright notice and this permission notice shall be included in all
235 | copies or substantial portions of the Software.
236 |
237 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
238 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
239 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
240 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
241 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
242 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
243 | SOFTWARE.
244 |
245 | */
246 |
--------------------------------------------------------------------------------
/TimeControl/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/TimeControlTesting/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("TimeControlTesting")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("TimeControlTesting")]
13 | [assembly: AssemblyCopyright("Copyright © 2017")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("f8b31e00-026b-46bd-9660-dd3793b2786f")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/TimeControlTesting/TimeControlTesting.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {F8B31E00-026B-46BD-9660-DD3793B2786F}
8 | Library
9 | Properties
10 | TimeControl.Testing
11 | TimeControl.Testing
12 | v4.5.2
13 | 512
14 |
15 |
16 | true
17 | full
18 | false
19 | bin\Debug\
20 | DEBUG;TRACE
21 | prompt
22 | 4
23 |
24 |
25 | pdbonly
26 | true
27 | bin\Release\
28 | TRACE
29 | prompt
30 | 4
31 |
32 |
33 |
34 | ..\..\..\..\KSP\KSP_win64-1.3-TEST\KSP_x64_Data\Managed\Assembly-CSharp.dll
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 | ..\..\..\..\KSP\KSP_win64-1.3-TEST\KSP_x64_Data\Managed\UnityEngine.dll
46 |
47 |
48 | ..\..\..\..\KSP\KSP_win64-1.3-TEST\KSP_x64_Data\Managed\UnityEngine.UI.dll
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 | {35aee226-1a0a-4008-af68-39e9ec55173b}
58 | TimeControl
59 |
60 |
61 |
62 |
63 |
64 |
65 |
--------------------------------------------------------------------------------
/TimeControlTesting/bin/Release/Assembly-CSharp-firstpass.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ntwest/TimeControl/4e2da160a139bbb04b7a382b95f695d3fe555127/TimeControlTesting/bin/Release/Assembly-CSharp-firstpass.dll
--------------------------------------------------------------------------------
/TimeControlTesting/bin/Release/Assembly-CSharp.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ntwest/TimeControl/4e2da160a139bbb04b7a382b95f695d3fe555127/TimeControlTesting/bin/Release/Assembly-CSharp.dll
--------------------------------------------------------------------------------
/TimeControlTesting/bin/Release/KSPAssets.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ntwest/TimeControl/4e2da160a139bbb04b7a382b95f695d3fe555127/TimeControlTesting/bin/Release/KSPAssets.dll
--------------------------------------------------------------------------------
/TimeControlTesting/bin/Release/Mono.Cecil.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ntwest/TimeControl/4e2da160a139bbb04b7a382b95f695d3fe555127/TimeControlTesting/bin/Release/Mono.Cecil.dll
--------------------------------------------------------------------------------
/TimeControlTesting/bin/Release/Mono.Security.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ntwest/TimeControl/4e2da160a139bbb04b7a382b95f695d3fe555127/TimeControlTesting/bin/Release/Mono.Security.dll
--------------------------------------------------------------------------------
/TimeControlTesting/bin/Release/TDx.TDxInput.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ntwest/TimeControl/4e2da160a139bbb04b7a382b95f695d3fe555127/TimeControlTesting/bin/Release/TDx.TDxInput.dll
--------------------------------------------------------------------------------
/TimeControlTesting/bin/Release/TimeControl.Testing.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ntwest/TimeControl/4e2da160a139bbb04b7a382b95f695d3fe555127/TimeControlTesting/bin/Release/TimeControl.Testing.dll
--------------------------------------------------------------------------------
/TimeControlTesting/bin/Release/TimeControl.Testing.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ntwest/TimeControl/4e2da160a139bbb04b7a382b95f695d3fe555127/TimeControlTesting/bin/Release/TimeControl.Testing.pdb
--------------------------------------------------------------------------------
/TimeControlTesting/bin/Release/TimeControl.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ntwest/TimeControl/4e2da160a139bbb04b7a382b95f695d3fe555127/TimeControlTesting/bin/Release/TimeControl.dll
--------------------------------------------------------------------------------
/TimeControlTesting/bin/Release/TimeControl.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ntwest/TimeControl/4e2da160a139bbb04b7a382b95f695d3fe555127/TimeControlTesting/bin/Release/TimeControl.pdb
--------------------------------------------------------------------------------
/TimeControlTesting/bin/Release/TrackIRUnity.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ntwest/TimeControl/4e2da160a139bbb04b7a382b95f695d3fe555127/TimeControlTesting/bin/Release/TrackIRUnity.dll
--------------------------------------------------------------------------------
/TimeControlTesting/bin/Release/UnityEngine.UI.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ntwest/TimeControl/4e2da160a139bbb04b7a382b95f695d3fe555127/TimeControlTesting/bin/Release/UnityEngine.UI.dll
--------------------------------------------------------------------------------
/TimeControlTesting/bin/Release/UnityEngine.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ntwest/TimeControl/4e2da160a139bbb04b7a382b95f695d3fe555127/TimeControlTesting/bin/Release/UnityEngine.dll
--------------------------------------------------------------------------------