Skip to content

Commit d42dd25

Browse files
committed
Fix ignoring auto saves
1 parent 0bac09b commit d42dd25

File tree

4 files changed

+130
-113
lines changed

4 files changed

+130
-113
lines changed

Assets/Plugins.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 88 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,90 @@
11
{
2-
"name": "SkipSplashScreen",
3-
"rootNamespace": "SkipSplashScreen",
4-
"allowUnsafeCode": true,
5-
"overrideReferences": true,
6-
"precompiledReferences": [
7-
"0Harmony.dll",
8-
"Ak.Wwise.Api.WAAPI.dll",
9-
"AK.Wwise.Unity.API.dll",
10-
"AK.Wwise.Unity.API.WwiseTypes.dll",
11-
"AK.Wwise.Unity.MonoBehaviour.dll",
12-
"AK.Wwise.Unity.Timeline.dll",
13-
"AmplifyShaderEditor.Samples.BuiltIn.dll",
14-
"Antlr4.Runtime.Standard.dll",
15-
"Assembly-CSharp-firstpass.dll",
16-
"Assembly-CSharp.dll",
17-
"Backtrace.Unity.dll",
18-
"Castle.Core.dll",
19-
"com.rlabrecque.steamworks.net.dll",
20-
"DataLink.Shared.Net.dll",
21-
"DebugTools.UI.dll",
22-
"DemiLib.dll",
23-
"DOTween.dll",
24-
"DOTweenPro.dll",
25-
"Febucci.Attributes.Runtime.dll",
26-
"Febucci.TextAnimator.Demo.Runtime.dll",
27-
"Febucci.TextAnimator.Runtime.dll",
28-
"Febucci.TextAnimator.TMP.Runtime.dll",
29-
"HoudiniEngineUnity.dll",
30-
"IGTools.dll",
31-
"Intercept.Metrics.dll",
32-
"KSPLogging.dll",
33-
"Microsoft.CSharp.dll",
34-
"Moq.dll",
35-
"Mortoc.Compute.TestTools.dll",
36-
"Newtonsoft.Json.UnityConverters.dll",
37-
"PriorityQueue.dll",
38-
"Redux.UI.Component.dll",
39-
"ReduxLib.dll",
40-
"ShapesRuntime.dll",
41-
"ShapesSamples.dll",
42-
"SpaceWarp2.dll",
43-
"SpaceWarp2.Game.dll",
44-
"SpaceWarp2.Sound.dll",
45-
"SpaceWarp2.UI.dll",
46-
"SpaceWarp2.VersionChecking.dll",
47-
"System.Buffers.dll",
48-
"System.ComponentModel.Composition.dll",
49-
"System.Data.DataSetExtensions.dll",
50-
"System.Data.dll",
51-
"System.Drawing.dll",
52-
"System.EnterpriseServices.dll",
53-
"System.IO.Compression.dll",
54-
"System.IO.Compression.FileSystem.dll",
55-
"System.Memory.dll",
56-
"System.Security.dll",
57-
"System.Transactions.dll",
58-
"TrackIRUnity.dll",
59-
"uitkforksp2.controls.Runtime.dll",
60-
"UitkForKsp2.dll",
61-
"UniTask.Addressables.dll",
62-
"UniTask.dll",
63-
"UniTask.DOTween.dll",
64-
"UniTask.Linq.dll",
65-
"UniTask.TextMeshPro.dll",
66-
"Unity.AI.Navigation.dll",
67-
"Unity.InternalAPIEngineBridge.003.dll",
68-
"Unity.Recorder.Base.dll",
69-
"Unity.Recorder.dll",
70-
"Unity.RenderPipelines.Core.Runtime.dll",
71-
"Unity.RenderPipelines.Core.ShaderLibrary.dll",
72-
"Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary.dll",
73-
"Unity.VectorGraphics.dll",
74-
"UnityEngine.SpatialTracking.dll",
75-
"UnityEngine.XR.LegacyInputHelpers.dll",
76-
"UnityMvvmToolkit.Common.dll",
77-
"UnityMvvmToolkit.Core.dll",
78-
"UnityMvvmToolkit.UGUI.dll",
79-
"UnityMvvmToolkit.UITK.dll",
80-
"UnityMvvmToolkit.UniTask.dll",
81-
"Newtonsoft.Json.dll"
82-
],
83-
"autoReferenced": true,
84-
"noEngineReferences": false
2+
"name": "SkipSplashScreen",
3+
"rootNamespace": "SkipSplashScreen",
4+
"references": [],
5+
"includePlatforms": [],
6+
"excludePlatforms": [],
7+
"allowUnsafeCode": true,
8+
"overrideReferences": true,
9+
"precompiledReferences": [
10+
"0Harmony.dll",
11+
"Ak.Wwise.Api.WAAPI.dll",
12+
"AK.Wwise.Unity.API.dll",
13+
"AK.Wwise.Unity.API.WwiseTypes.dll",
14+
"AK.Wwise.Unity.MonoBehaviour.dll",
15+
"AK.Wwise.Unity.Timeline.dll",
16+
"AmplifyShaderEditor.Samples.BuiltIn.dll",
17+
"Antlr4.Runtime.Standard.dll",
18+
"Assembly-CSharp-firstpass.dll",
19+
"Assembly-CSharp.dll",
20+
"Backtrace.Unity.dll",
21+
"Castle.Core.dll",
22+
"com.rlabrecque.steamworks.net.dll",
23+
"DataLink.Shared.Net.dll",
24+
"DebugTools.UI.dll",
25+
"DemiLib.dll",
26+
"DOTween.dll",
27+
"DOTweenPro.dll",
28+
"Febucci.Attributes.Runtime.dll",
29+
"Febucci.TextAnimator.Demo.Runtime.dll",
30+
"Febucci.TextAnimator.Runtime.dll",
31+
"Febucci.TextAnimator.TMP.Runtime.dll",
32+
"HoudiniEngineUnity.dll",
33+
"IGTools.dll",
34+
"Intercept.Metrics.dll",
35+
"KSPLogging.dll",
36+
"Microsoft.CSharp.dll",
37+
"Moq.dll",
38+
"Mortoc.Compute.TestTools.dll",
39+
"Newtonsoft.Json.UnityConverters.dll",
40+
"PriorityQueue.dll",
41+
"Redux.UI.Component.dll",
42+
"ReduxLib.dll",
43+
"ShapesRuntime.dll",
44+
"ShapesSamples.dll",
45+
"SpaceWarp2.dll",
46+
"SpaceWarp2.Game.dll",
47+
"SpaceWarp2.Sound.dll",
48+
"SpaceWarp2.UI.dll",
49+
"SpaceWarp2.VersionChecking.dll",
50+
"System.Buffers.dll",
51+
"System.ComponentModel.Composition.dll",
52+
"System.Data.DataSetExtensions.dll",
53+
"System.Data.dll",
54+
"System.Drawing.dll",
55+
"System.EnterpriseServices.dll",
56+
"System.IO.Compression.dll",
57+
"System.IO.Compression.FileSystem.dll",
58+
"System.Memory.dll",
59+
"System.Security.dll",
60+
"System.Transactions.dll",
61+
"TrackIRUnity.dll",
62+
"uitkforksp2.controls.Runtime.dll",
63+
"UitkForKsp2.dll",
64+
"UniTask.Addressables.dll",
65+
"UniTask.dll",
66+
"UniTask.DOTween.dll",
67+
"UniTask.Linq.dll",
68+
"UniTask.TextMeshPro.dll",
69+
"Unity.AI.Navigation.dll",
70+
"Unity.InternalAPIEngineBridge.003.dll",
71+
"Unity.Recorder.Base.dll",
72+
"Unity.Recorder.dll",
73+
"Unity.RenderPipelines.Core.Runtime.dll",
74+
"Unity.RenderPipelines.Core.ShaderLibrary.dll",
75+
"Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary.dll",
76+
"Unity.VectorGraphics.dll",
77+
"UnityEngine.SpatialTracking.dll",
78+
"UnityEngine.XR.LegacyInputHelpers.dll",
79+
"UnityMvvmToolkit.Common.dll",
80+
"UnityMvvmToolkit.Core.dll",
81+
"UnityMvvmToolkit.UGUI.dll",
82+
"UnityMvvmToolkit.UITK.dll",
83+
"UnityMvvmToolkit.UniTask.dll",
84+
"Newtonsoft.Json.dll"
85+
],
86+
"autoReferenced": true,
87+
"defineConstraints": [],
88+
"versionDefines": [],
89+
"noEngineReferences": false
8590
}

Assets/SkipSplashScreen/Code/SkipSplashScreenPlugin.cs

Lines changed: 33 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
1-
using System;
2-
using System.Collections.Generic;
1+
using System.Reflection;
32
using HarmonyLib;
43
using JetBrains.Annotations;
54
using KSP.Game;
65
using KSP.Game.Flow;
7-
using KSP.Modules;
86
using PatchManager.Core.Flow;
97
using Redux.ExtraModTypes;
108
using ReduxLib.Configuration;
119
using UnityEngine;
1210

1311
namespace SkipSplashScreen
1412
{
15-
/* Extend KerbalMod instead if you need the MonoBehaviour update loop/references to game stuff like SW 1.x mods */
1613
[HarmonyPatch]
1714
public class SkipSplashScreenPlugin : KerbalMod
1815
{
@@ -31,21 +28,6 @@ public class SkipSplashScreenPlugin : KerbalMod
3128
private ConfigValue<bool> _loadLastSavedCampaign;
3229
private ConfigValue<bool> _loadIgnoreAutoSaves;
3330

34-
public override void OnPreInitialized()
35-
{
36-
SWLogger.LogInfo("Skip Splash Screen PreInitialized");
37-
}
38-
39-
public override void OnInitialized()
40-
{
41-
SWLogger.LogInfo("Hello World!");
42-
}
43-
44-
public override void OnPostInitialized()
45-
{
46-
SWLogger.LogInfo("anchor2 OnPostInitialized");
47-
}
48-
4931
public void Start()
5032
{
5133
Instance = this;
@@ -55,13 +37,13 @@ public void Start()
5537
_loadLastSavedCampaign = new (SWConfiguration.Bind(
5638
ModName,
5739
"Auto load last played campaign",
58-
false,
40+
false,
5941
"Automatically loads the last save game file after main menu is finished loading."));
6042

6143
_loadIgnoreAutoSaves = new (SWConfiguration.Bind(
6244
ModName,
6345
"Ignore auto-saves when loading last save game",
64-
false,
46+
false,
6547
"If enabled, auto-saves are ignored when automatically loading last save game."));
6648
}
6749

@@ -98,15 +80,17 @@ public void Update()
9880
[HarmonyPatch(typeof(FlowManager), "AddActionsToFlow"), HarmonyPrefix]
9981
private static bool FlowManager_AddActionsToFlow(SequentialFlow loadingFlow)
10082
{
101-
var removeCount = loadingFlow.FlowActions.RemoveAll(action => action.Name == "Creating Splash Screens Prefab");
83+
var actionToSkip = "Creating Splash Screens Prefab";
84+
85+
var removeCount = loadingFlow.FlowActions.RemoveAll(action => action.Name == actionToSkip);
10286

10387
if (removeCount > 0)
10488
{
105-
Instance.SWLogger.LogInfo("'Creating Splash Screens Prefab' successfully removed from FlowActions.");
89+
Instance.SWLogger.LogInfo($"'{actionToSkip}' successfully removed from FlowActions.");
10690
}
10791
else
10892
{
109-
Instance.SWLogger.LogInfo("'Creating Splash Screens Prefab' not found in FlowActions.");
93+
Instance.SWLogger.LogInfo($"'{actionToSkip}' not found in FlowActions.");
11094
}
11195

11296
GameManager.Instance.HasPhotosensitivityWarningBeenShown = true;
@@ -149,15 +133,35 @@ private void LoadLastSinglePlayerGame()
149133

150134
for (var i = 0; i < saveGamesList.transform.childCount; ++i)
151135
{
152-
/*
153-
string curr_save_name = save_components[i]._labelSaveName.text;
154-
if (_loadIgnoreAutoSaves.Value && curr_save_name.StartsWith("autosave")) continue;
155-
SWLogger.LogInfo($"Auto loading save '{curr_save_name}'.");
136+
//var currentSaveName = save_components[i]._labelSaveName.text;
137+
FieldInfo labelField = save_components[i].GetType().GetField("_labelSaveName", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
138+
if (labelField == null)
139+
{
140+
SWLogger.LogError($"No field '_labelSaveName' found in save_components[{i}]. Skipping.");
141+
continue;
142+
}
143+
144+
var label = labelField.GetValue(save_components[i]);
145+
PropertyInfo labelTextField = label.GetType().GetProperty("text");
146+
if (labelTextField == null)
147+
{
148+
SWLogger.LogError($"No property 'text' found in save_components[{i}]._labelSaveName. Skipping.");
149+
continue;
150+
}
151+
152+
var currentSaveName = labelTextField.GetValue(label) as string;
153+
154+
if (_loadIgnoreAutoSaves.Value && currentSaveName.ToLowerInvariant().StartsWith("autosave"))
155+
{
156+
SWLogger.LogInfo($"'Ignore auto-saves' is enabled. Skipping '{currentSaveName}'.");
157+
continue;
158+
}
159+
160+
SWLogger.LogInfo($"Auto loading save '{currentSaveName}'.");
156161

157162
// It's called "lastPlayed" but it's actually just "lastSelected"
158163
// (this is remembered after closing the menu, but not after restarting the game)
159164
save_components[i].SetCurrentToggleState(lastPlayed: true);
160-
*/
161165

162166
break;
163167
}

Assets/ThunderKitSettings/ThunderKitSettings.asset

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ MonoBehaviour:
1212
m_Script: {fileID: 11500000, guid: f9057f7f601990a4883b2cb295c4f43e, type: 3}
1313
m_Name: ThunderKitSettings
1414
m_EditorClassIdentifier:
15-
FirstLoad: 1
15+
FirstLoad: 0
1616
ShowOnStartup: 1
1717
GameExecutable: KSP2_x64.exe
1818
GamePath: D:\SteamLibrary\steamapps\common\Kerbal Space Program 2 Redux

0 commit comments

Comments
 (0)