Skip to content

Commit cf1a3f9

Browse files
committed
Version 2.8.2
1 parent e97f36e commit cf1a3f9

File tree

10 files changed

+63
-14
lines changed

10 files changed

+63
-14
lines changed
1 KB
Binary file not shown.

TimeControl/GlobalSettings.cs

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ public bool AssignFromConfigNode(ConfigNode pCN)
139139
private EventData<float> OnTimeControlHyperWarpPhysicsAccuracyChangedEvent { get; set; }
140140
private EventData<float> OnTimeControlSlowMoRateChangedEvent { get; set; }
141141
private EventData<TimeControlKeyBinding> OnTimeControlKeyBindingsChangedEvent;
142+
private EventData<bool> OnTimeControlSlowMoDeltaLockedChangedEvent { get; set; }
142143

143144
private const float saveTimeDelta = 10f;
144145
private float saveTimeDelay = 0f;
@@ -207,6 +208,17 @@ public float SlowMoRate
207208
}
208209
}
209210

211+
private bool deltaLocked = true;
212+
public bool DeltaLocked
213+
{
214+
get => deltaLocked;
215+
set
216+
{
217+
deltaLocked = value;
218+
mainNode?.SetValue( nameof( DeltaLocked ), value, true );
219+
saveOnNextUpdate = true;
220+
}
221+
}
210222
private float resetAltitudeToValue = 1000f;
211223
public float ResetAltitudeToValue
212224
{
@@ -262,7 +274,7 @@ public int KeyRepeatInterval
262274
}
263275

264276
// This is managed in the time control parameters screen, but is applied globally by the settings
265-
private LogSeverity loggingLevel;
277+
private LogSeverity loggingLevel = LogSeverity.Warning;
266278
public LogSeverity LoggingLevel
267279
{
268280
get => loggingLevel;
@@ -299,6 +311,7 @@ public bool UseKerbinTime
299311
}
300312
}
301313

314+
302315
private string version = TimeControl.PluginAssemblyUtilities.VERSION;
303316

304317
#region MonoBehavior
@@ -331,6 +344,7 @@ private void Start()
331344
mainNode.SetValue( nameof( HyperWarpPhysicsAccuracy ), HyperWarpPhysicsAccuracy, true );
332345
mainNode.SetValue( nameof( HyperWarpMaxAttemptedRate ), HyperWarpMaxAttemptedRate, true );
333346
mainNode.SetValue( nameof( SlowMoRate ), SlowMoRate, true );
347+
mainNode.SetValue( nameof( DeltaLocked ), DeltaLocked, true );
334348
mainNode.SetValue( nameof( ResetAltitudeToValue ), ResetAltitudeToValue, true );
335349
mainNode.SetValue( nameof( LoggingLevel ), LoggingLevel.ToString(), true );
336350
mainNode.SetValue( nameof( CameraZoomFix ), CameraZoomFix, true );
@@ -382,6 +396,9 @@ private void SubscribeToEvents()
382396
OnTimeControlSlowMoRateChangedEvent = GameEvents.FindEvent<EventData<float>>( nameof( TimeControlEvents.OnTimeControlSlowMoRateChanged ) );
383397
OnTimeControlSlowMoRateChangedEvent?.Add( OnTimeControlSlowMoRateChanged );
384398

399+
OnTimeControlSlowMoDeltaLockedChangedEvent = GameEvents.FindEvent<EventData<bool>>( nameof( TimeControlEvents.OnTimeControlSlowMoDeltaLockedChanged ) );
400+
OnTimeControlSlowMoDeltaLockedChangedEvent?.Add( OnTimeControlSlowMoDeltaLockedChanged );
401+
385402
SpaceCenterWindow.OnChanged += GUIWindowsChanged;
386403
TrackStationWindow.OnChanged += GUIWindowsChanged;
387404
FlightWindow.OnChanged += GUIWindowsChanged;
@@ -491,6 +508,18 @@ private void OnTimeControlSlowMoRateChanged(float data)
491508
}
492509
}
493510

511+
private void OnTimeControlSlowMoDeltaLockedChanged(bool data)
512+
{
513+
const string logBlockName = nameof( GlobalSettings ) + "." + nameof( OnTimeControlSlowMoDeltaLockedChanged );
514+
using (EntryExitLogger.EntryExitLog( logBlockName, EntryExitLoggerOptions.All ))
515+
{
516+
if (SlowMoController.IsReady)
517+
{
518+
DeltaLocked = SlowMoController.Instance.DeltaLocked;
519+
}
520+
}
521+
}
522+
494523
private void OnTimeControlKeyBindingsChanged(TimeControlKeyBinding tckb)
495524
{
496525
const string logBlockName = nameof( GlobalSettings ) + "." + nameof( OnTimeControlKeyBindingsChanged );
@@ -662,6 +691,18 @@ private void LoadFromConfig()
662691
Log.Warning( nameof( SlowMoRate ) + " has error in configuration file. Using default.", logBlockName );
663692
}
664693

694+
////////////////////////////////////////////////
695+
// DeltaLocked
696+
////////////////////////////////////////////////
697+
if (tmpConfigMain.TryAssignFromConfigBool( nameof( DeltaLocked ), out bool tmpDeltaLocked ))
698+
{
699+
DeltaLocked = tmpDeltaLocked;
700+
}
701+
else
702+
{
703+
Log.Warning( nameof( DeltaLocked ) + " has error in configuration file. Using default.", logBlockName );
704+
}
705+
665706
////////////////////////////////////////////////
666707
// ResetAltitudeToValue
667708
////////////////////////////////////////////////

TimeControl/IMGUI/KeyBindingsAddIMGUI.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@ public bool KeyBindingsAddGUI()
118118
}
119119
if (GUILayout.Button( "ADD", GUILayout.Width( 40 ) ))
120120
{
121-
KeyboardInputManager.Instance.AddKeyBinding( kb );
121+
var newkb = TimeControlKeyBindingFactory.LoadFromConfigNode( kb.GetConfigNode() );
122+
KeyboardInputManager.Instance.AddKeyBinding( newkb );
122123
return true;
123124
}
124125
}

TimeControl/IMGUI/KeyBindingsEditorIMGUI.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ public void KeyBindingsEditorGUI()
135135
{
136136
GUILayout.BeginHorizontal();
137137
{
138-
GUILayout.Label( "Adding New User-Defined Key Binding Action" );
139-
if (GUILayout.Button( "Cancel" ))
138+
GUILayout.Label( "Adding New User-Defined Key Binding Actions" );
139+
if (GUILayout.Button( "DONE" ))
140140
{
141141
addingNewKeyBinding = false;
142142
}
@@ -151,7 +151,6 @@ public void KeyBindingsEditorGUI()
151151
{
152152
if (kbadd.KeyBindingsAddGUI())
153153
{
154-
addingNewKeyBinding = false;
155154
refreshKBCache = true;
156155
}
157156
}

TimeControl/IMGUI/TimeControlIMGUI.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ private void onLevelWasLoaded(GameScenes gs)
357357
WindowVisible = flightModeWindowIsDisplayed;
358358
}
359359
windowRect.ClampToScreen();
360-
onShowUI();
360+
TempUnHideGUI();
361361
}
362362
}
363363

TimeControl/KeyBindings/TimeControlKeyBindingFactory.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ private static TimeControlKeyBinding GetFromAction(TimeControlKeyAction tcka)
162162

163163
private static List<KeyCode> GetKeyCombinationFromString(string s)
164164
{
165-
const string logBlockName = nameof( TimeControlKeyBinding ) + "." + nameof( GetKeyCombinationFromString );
165+
const string logBlockName = nameof( TimeControlKeyBindingFactory ) + "." + nameof( GetKeyCombinationFromString );
166166
using (EntryExitLogger.EntryExitLog( logBlockName, EntryExitLoggerOptions.All ))
167167
{
168168
string parse = s.Trim();
@@ -180,10 +180,10 @@ private static List<KeyCode> GetKeyCombinationFromString(string s)
180180
parse = parse.Substring( 1, parse.Length - 2 );
181181

182182
IEnumerable<string> keys;
183-
if (s.Contains( "][" ))
183+
if (parse.Contains( "][" ))
184184
{
185185
// Split On ][
186-
keys = s.Split( new string[] { "][" }, StringSplitOptions.None ).Select( x => x.Trim() );
186+
keys = parse.Split( new string[] { "][" }, StringSplitOptions.None ).Select( x => x.Trim() );
187187
}
188188
else
189189
{

TimeControl/Logging/Log.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,8 @@ static internal LogSeverity LoggingLevel
3131

3232
static Log()
3333
{
34-
// TODO Change Back to Warning
35-
//LoggingLevel = LogSeverity.Warning;
36-
LoggingLevel = LogSeverity.Trace;
34+
LoggingLevel = LogSeverity.Warning;
35+
//LoggingLevel = LogSeverity.Trace;
3736
}
3837

3938
static internal void Trace(string message, string caller = "", bool always = false)

TimeControl/SlowMoController.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,11 @@ private void SetCanRailsWarp(bool canRailsWarp)
109109
public bool DeltaLocked
110110
{
111111
get => deltaLocked;
112-
set => deltaLocked = value;
112+
set
113+
{
114+
deltaLocked = value;
115+
TimeControlEvents.OnTimeControlSlowMoDeltaLockedChanged?.Fire( deltaLocked );
116+
}
113117
}
114118
private bool deltaLocked = true;
115119

@@ -224,6 +228,7 @@ private IEnumerator Configure()
224228
}
225229

226230
this.slowMoRate = GlobalSettings.Instance.SlowMoRate;
231+
this.deltaLocked = GlobalSettings.Instance.DeltaLocked;
227232

228233
this.SetDefaults();
229234
this.SubscribeToGameEvents();
@@ -533,7 +538,7 @@ private void SetTimeScale()
533538
private void SetFixedDeltaTime()
534539
{
535540
float defaultDeltaTime = TimeController.Instance.DefaultFixedDeltaTime;
536-
TimeController.Instance.FixedDeltaTime = DeltaLocked ? defaultDeltaTime : defaultDeltaTime * this.SlowMoRate;
541+
TimeController.Instance.FixedDeltaTime = DeltaLocked ? defaultDeltaTime : (defaultDeltaTime * this.SlowMoRate);
537542
}
538543

539544
/// <summary>

TimeControl/TimeControlEvents.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public class TimeControlEvents : MonoBehaviour
2424
public static EventData<float> OnTimeControlHyperWarpStopping;
2525
public static EventData<float> OnTimeControlHyperWarpStopped;
2626

27+
public static EventData<bool> OnTimeControlSlowMoDeltaLockedChanged;
2728
public static EventData<float> OnTimeControlSlowMoRateChanged;
2829
public static EventData<float> OnTimeControlSlowMoStarting;
2930
public static EventData<float> OnTimeControlSlowMoStarted;
@@ -63,6 +64,7 @@ private void Awake()
6364

6465
// Slow Motion
6566
OnTimeControlSlowMoRateChanged = new EventData<float>( nameof( OnTimeControlSlowMoRateChanged ) );
67+
OnTimeControlSlowMoDeltaLockedChanged = new EventData<bool>( nameof( OnTimeControlSlowMoDeltaLockedChanged ) );
6668

6769
OnTimeControlSlowMoStarting = new EventData<float>( nameof( OnTimeControlSlowMoStarting ) );
6870
OnTimeControlSlowMoStarted = new EventData<float>( nameof( OnTimeControlSlowMoStarted ) );

TimeControl/TimeController.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,8 @@ private void onLevelWasLoaded(GameScenes gs)
280280
SetupKACAlarms();
281281
}
282282
}
283+
284+
TimeControlEvents.OnTimeControlTimeUnpaused?.Fire( true );
283285
}
284286
}
285287
#endregion

0 commit comments

Comments
 (0)