Skip to content

Commit 430e16a

Browse files
committed
Final Patches for KSP 1.1.3 release, version 2.0.2.
1 parent a300b85 commit 430e16a

File tree

8 files changed

+463
-140
lines changed

8 files changed

+463
-140
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
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":0,"PATCH":0,"BUILD":0},"KSP_VERSION":{"MAJOR":1,"MINOR":1,"PATCH":3},"KSP_VERSION_MIN":{"MAJOR":1,"MINOR":1,"PATCH":3},"KSP_VERSION_MAX":{"MAJOR":1,"MINOR":1,"PATCH":3}}
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":0,"PATCH":1,"BUILD":0},"KSP_VERSION":{"MAJOR":1,"MINOR":1,"PATCH":3},"KSP_VERSION_MIN":{"MAJOR":1,"MINOR":1,"PATCH":3},"KSP_VERSION_MAX":{"MAJOR":1,"MINOR":1,"PATCH":3}}

TimeControl/KeyboardInputManager.cs

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ private void Update()
8282

8383
private void UpdateKSPKeyBindings()
8484
{
85-
// TODO UpdateKSPKeyBindings
85+
// TODO UpdateKSPKeyBindings. Maybe make a full fledged input manager
8686

8787
/*
8888
@@ -287,9 +287,7 @@ private void SpeedUpKeyPress(TCKeyBinding k)
287287
if (TimeController.Instance.CurrentWarpState == TimeControllable.Hyper)
288288
{
289289
if (keysPressedDown.Contains( k.KeyCombination.Last() ))
290-
{
291-
TimeController.Instance.HyperMaxRate += 1;
292-
}
290+
TimeController.Instance.SpeedUpTime();
293291
}
294292
else
295293
{
@@ -307,9 +305,7 @@ private void SlowDownKeyPress(TCKeyBinding k)
307305
if (TimeController.Instance.CurrentWarpState == TimeControllable.Hyper)
308306
{
309307
if (keysPressedDown.Contains( k.KeyCombination.Last() ))
310-
{
311-
TimeController.Instance.HyperMaxRate -= 1;
312-
}
308+
TimeController.Instance.SlowDownTime();
313309
}
314310
else
315311
{
@@ -350,7 +346,7 @@ private void PauseKeyPress(TCKeyBinding k)
350346
if (keysPressedDown.Contains( k.KeyCombination.Last() ))
351347
{
352348
LogKeyPress( k, "PauseKeyPress" );
353-
TimeController.Instance.TogglePause();
349+
TimeController.Instance.TimePaused = !TimeController.Instance.TimePaused;
354350
}
355351
}
356352

@@ -473,15 +469,24 @@ internal static List<KeyCode> GetKeyCombinationFromString(string s)
473469
string parse = s.Trim();
474470

475471
// Must start with [ and end with ]
476-
if (parse[0] != '[' || parse[parse.Length-1] != ']')
477-
return null;
472+
if (parse[0] != '[' || parse[parse.Length - 1] != ']')
473+
{
474+
Log.Warning( "Key Codes must be surrounded by [ ] ", logCaller );
475+
}
478476

479477
// Strip start and end characters
480478
parse = parse.Substring( 1, parse.Length - 2 );
481479

482-
// Split On ][
483-
IEnumerable<string> keys = s.Split( new string[] { "][" }, StringSplitOptions.None ).Select( x => x.Trim() );
484-
480+
IEnumerable<string> keys;
481+
if (s.Contains( "][" ))
482+
{
483+
// Split On ][
484+
keys = s.Split( new string[] { "][" }, StringSplitOptions.None ).Select( x => x.Trim() );
485+
} else
486+
{
487+
keys = new List<string>() { parse };
488+
}
489+
485490
List<KeyCode> lkc = new List<KeyCode>();
486491

487492
bool AllKeysDefined = true;
@@ -490,21 +495,25 @@ internal static List<KeyCode> GetKeyCombinationFromString(string s)
490495
if (key == "Ctrl")
491496
{
492497
lkc.Add( KeyCode.LeftControl );
498+
Log.Trace( "Adding Control to key list from string " + s, logCaller );
493499
continue;
494500
}
495501
if (key == "Alt")
496502
{
497503
lkc.Add( KeyCode.LeftAlt );
504+
Log.Trace( "Adding LeftAlt to key list from string " + s, logCaller );
498505
continue;
499506
}
500507
if (key == "Cmd")
501508
{
502509
lkc.Add( KeyCode.LeftCommand );
510+
Log.Trace( "Adding LeftCommand to key list from string " + s, logCaller );
503511
continue;
504512
}
505513
if (key == "Shift")
506514
{
507515
lkc.Add( KeyCode.LeftShift );
516+
Log.Trace( "Adding LeftShift to key list from string " + s, logCaller );
508517
continue;
509518
}
510519

@@ -513,7 +522,9 @@ internal static List<KeyCode> GetKeyCombinationFromString(string s)
513522
AllKeysDefined = false;
514523
break;
515524
}
516-
lkc.Add( (KeyCode)Enum.Parse( typeof( KeyCode ), key ) );
525+
KeyCode parsedKeyCode = (KeyCode)Enum.Parse( typeof( KeyCode ), key );
526+
Log.Trace( "Adding "+ parsedKeyCode.ToString() + " to key list from string " + s, logCaller );
527+
lkc.Add( parsedKeyCode );
517528
}
518529

519530
if (!AllKeysDefined)

TimeControl/PerformanceManager.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
* License: MIT
55
*/
66

7-
//TODO make this a standalone and include FPS display in it
8-
97
using System;
108
using System.Collections;
119
using System.Collections.Generic;

TimeControl/Properties/AssemblyInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
3535
[assembly: AssemblyVersion("2.0.*")]
36-
[assembly: AssemblyFileVersion("2.0.1")]
36+
[assembly: AssemblyFileVersion("2.0.2")]

TimeControl/Settings.cs

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ private void Start()
8585
GameEvents.onGameSceneLoadRequested.Add( this.onGameSceneLoadRequested );
8686
GameEvents.onLevelWasLoaded.Add( this.onLevelWasLoaded );
8787

88-
StartCoroutine( ReloadConfig() );
88+
StartCoroutine( ReloadConfigWhenTimeWarpReady() );
8989

9090
Log.Trace( "method end", logCaller );
9191
}
@@ -134,18 +134,20 @@ private void onLevelWasLoaded(GameScenes gs)
134134

135135
private void onHideUI()
136136
{
137-
string logCaller = "onHideUI";
137+
string logCaller = "Settings.onHideUI";
138138
Log.Trace( "method start", logCaller );
139139

140+
Log.Info( "Hiding GUI for Settings Lock", logCaller );
140141
TempHideGUI( "Settings" );
141142

142143
Log.Trace( "method end", logCaller );
143144
}
144145
private void onShowUI()
145146
{
146-
string logCaller = "onShowUI";
147+
string logCaller = "Settings.onShowUI";
147148
Log.Trace( "method start", logCaller );
148149

150+
Log.Info( "Unhiding GUI for Settings Lock", logCaller );
149151
TempUnHideGUI( "Settings" );
150152

151153
Log.Trace( "method end", logCaller );
@@ -155,21 +157,40 @@ private void onShowUI()
155157

156158

157159
#region Coroutines
158-
public IEnumerator ReloadConfig()
160+
public IEnumerator ReloadConfigWhenTimeWarpReady()
159161
{
162+
string logCaller = "Settings.ReloadConfig";
163+
Log.Trace( "coroutine start", logCaller );
164+
160165
while (TimeWarp.fetch == null)
161166
yield return null;
162167

168+
ResetConfigs();
169+
170+
Log.Trace( "coroutine end", logCaller );
171+
yield break;
172+
}
173+
174+
private void ResetConfigs()
175+
{
176+
string logCaller = "Settings.ResetConfigs";
177+
Log.Trace( "method start", logCaller );
178+
163179
resetKeyBindingsToDefault();
164180
resetWarpRatesToDefault();
165181
resetAltitudeLimitsToDefault();
166182
loadConfig();
167183
warpLevels = customWarpRates.Count;
168184

169185
IsReady = configLoadSuccessful;
186+
if (IsReady)
187+
Log.Info( "TimeController.Settings is Ready!", logCaller );
188+
else
189+
Log.Error( "Something went wrong loading the time controller settings!", logCaller );
170190

171-
yield break;
191+
Log.Trace( "method end", logCaller );
172192
}
193+
173194
#endregion
174195
#region Key Bindings
175196
private void resetKeyBindingsToDefault()
@@ -238,8 +259,15 @@ private void configLoadKeyBinds(ConfigNode cn)
238259
Log.Warning( "Key combination is not defined correctly: " + keycombo + " - Using default for user action " + userAction, logCaller );
239260
continue;
240261
}
241-
k.KeyCombination = new List<KeyCode>( iekc );
242-
k.KeyCombinationString = keycombo;
262+
if (iekc.Contains( KeyCode.None ))
263+
{
264+
k.KeyCombination = new List<KeyCode>();
265+
}
266+
else
267+
{
268+
k.KeyCombination = new List<KeyCode>( iekc );
269+
k.KeyCombinationString = keycombo;
270+
}
243271
}
244272
}
245273

@@ -1082,9 +1110,9 @@ public bool ShowScreenMessages {
10821110
return showScreenMessages;
10831111
}
10841112
set {
1085-
if (visible != value)
1113+
if (showScreenMessages != value)
10861114
{
1087-
visible = value;
1115+
showScreenMessages = value;
10881116
OnPropertyChanged( PropertyStrings.ShowScreenMessages );
10891117
SetNeedsSavedFlag();
10901118
}

0 commit comments

Comments
 (0)