Skip to content

Commit 2f5cfc3

Browse files
committed
Cleanup
1 parent 109ada5 commit 2f5cfc3

File tree

5 files changed

+19
-197
lines changed

5 files changed

+19
-197
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,3 +396,5 @@ FodyWeavers.xsd
396396

397397
# JetBrains Rider
398398
*.sln.iml
399+
400+
*.dll

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
# SkipSplashScreen
2-
1+
# SkipSplashScreen - a Kerbal Space Program 2 plugin
2+
Skips the spash screen and health warning.
3+
To be used only for developing mods for KSP2.
Lines changed: 11 additions & 192 deletions
Original file line numberDiff line numberDiff line change
@@ -1,229 +1,48 @@
11
using BepInEx;
22
using HarmonyLib;
3-
using KSP.UI.Binding;
43
using SpaceWarp;
5-
using SpaceWarp.API.Assets;
64
using SpaceWarp.API.Mods;
7-
using SpaceWarp.API.Game;
8-
using SpaceWarp.API.Game.Extensions;
9-
using SpaceWarp.API.UI;
10-
using SpaceWarp.API.UI.Appbar;
11-
using UnityEngine;
125
using KSP.Game;
136
using KSP.Game.Flow;
14-
using static GUIUtil;
15-
using UnityEngine.UIElements.UIR;
16-
using BepInEx.Logging;
17-
using KSP.Game.StartupFlow;
187

198
namespace SkipSplashScreen;
209

2110
[BepInPlugin(MyPluginInfo.PLUGIN_GUID, MyPluginInfo.PLUGIN_NAME, MyPluginInfo.PLUGIN_VERSION)]
2211
[BepInDependency(SpaceWarpPlugin.ModGuid, SpaceWarpPlugin.ModVer)]
12+
[HarmonyPatch(typeof(SequentialFlow))]
2313
public class SkipSplashScreenPlugin : BaseSpaceWarpPlugin
2414
{
2515
// These are useful in case some other mod wants to add a dependency to this one
2616
public const string ModGuid = MyPluginInfo.PLUGIN_GUID;
2717
public const string ModName = MyPluginInfo.PLUGIN_NAME;
2818
public const string ModVer = MyPluginInfo.PLUGIN_VERSION;
29-
30-
private bool _isWindowOpen;
31-
private Rect _windowRect;
32-
33-
private const string ToolbarFlightButtonID = "BTN-SkipSplashScreenFlight";
34-
private const string ToolbarOABButtonID = "BTN-SkipSplashScreenOAB";
3519

36-
public static SkipSplashScreenPlugin Instance { get; set; }
37-
38-
/// <summary>
39-
/// Runs when the mod is first initialized.
40-
/// </summary>
41-
public override void OnInitialized()
20+
public void Start()
4221
{
43-
base.OnInitialized();
44-
45-
Instance = this;
46-
47-
// Register Flight AppBar button
48-
Appbar.RegisterAppButton(
49-
"SkipSplashScreen",
50-
ToolbarFlightButtonID,
51-
AssetManager.GetAsset<Texture2D>($"{SpaceWarpMetadata.ModID}/images/icon.png"),
52-
isOpen =>
53-
{
54-
_isWindowOpen = isOpen;
55-
GameObject.Find(ToolbarFlightButtonID)?.GetComponent<UIValue_WriteBool_Toggle>()?.SetValue(isOpen);
56-
}
57-
);
58-
59-
// Register OAB AppBar Button
60-
Appbar.RegisterOABAppButton(
61-
"SkipSplashScreen",
62-
ToolbarOABButtonID,
63-
AssetManager.GetAsset<Texture2D>($"{SpaceWarpMetadata.ModID}/images/icon.png"),
64-
isOpen =>
65-
{
66-
_isWindowOpen = isOpen;
67-
GameObject.Find(ToolbarOABButtonID)?.GetComponent<UIValue_WriteBool_Toggle>()?.SetValue(isOpen);
68-
}
69-
);
70-
71-
// Fetch a configuration value or create a default one if it does not exist
72-
var defaultValue = "my_value";
73-
var configValue = Config.Bind<string>("Settings section", "Option 1", defaultValue, "Option description");
74-
75-
// Log the config value into <KSP2 Root>/BepInEx/LogOutput.log
76-
Logger.LogInfo($"Option 1: {configValue.Value}");
77-
78-
//Harmony.CreateAndPatchAll(typeof(SkipSplashScreenPlugin).Assembly);
22+
Harmony.CreateAndPatchAll(typeof(SkipSplashScreenPlugin).Assembly);
7923
}
8024

8125
public void Update()
8226
{
83-
if (GameManager.Instance.Game.GlobalGameState.GetState() == GameState.MainMenu)
84-
Destroy(this);
85-
}
86-
87-
private static FlowAction lastFlowAction = null;
88-
private static List<FlowAction> flowActions = new List<FlowAction>();
89-
90-
/// <summary>
91-
/// Defines the content of the UI window drawn in the <code>OnGui</code> method.
92-
/// </summary>
93-
/// <param name="windowID"></param>
94-
private static void FillWindow(int windowID)
95-
{
96-
GUILayout.BeginHorizontal();
97-
GUILayout.Label("GameManager.Instance: ");
98-
GUILayout.FlexibleSpace();
99-
GUILayout.Label($"{GameManager.Instance}");
100-
GUILayout.EndHorizontal();
27+
var gameState = GameManager.Instance?.Game.GlobalGameState?.GetState();
10128

102-
GUILayout.BeginHorizontal();
103-
GUILayout.Label("GameManager.Instance.Game.GlobalGameState: ");
104-
GUILayout.FlexibleSpace();
105-
GUILayout.Label($"{GameManager.Instance.Game.GlobalGameState}");
106-
GUILayout.EndHorizontal();
107-
108-
GUILayout.BeginHorizontal();
109-
GUILayout.Label("GameManager.Instance.Game.GlobalGameState.GetState: ");
110-
GUILayout.FlexibleSpace();
111-
GUILayout.Label($"{GameManager.Instance.Game.GlobalGameState.GetState()}");
112-
GUILayout.EndHorizontal();
113-
114-
//GUILayout.Label($"{}");
115-
116-
117-
GameManager instance = GameManager.Instance;
118-
FlowAction flowAction;
119-
if (instance == null)
120-
{
121-
flowAction = null;
122-
}
123-
else
124-
{
125-
SequentialFlow loadingFlow = instance.LoadingFlow;
126-
flowAction = loadingFlow?.GetCurrentAction();
127-
128-
if (flowAction != lastFlowAction)
129-
{
130-
GUILayout.Label("Flow changed");
131-
lastFlowAction = flowAction;
132-
flowActions.Add(lastFlowAction);
133-
}
134-
135-
GUILayout.BeginHorizontal();
136-
GUILayout.Label("FlowAction name: ");
137-
GUILayout.FlexibleSpace();
138-
GUILayout.Label($"{flowAction.Name}");
139-
GUILayout.EndHorizontal();
140-
141-
GUILayout.BeginHorizontal();
142-
GUILayout.Label("FlowAction Timeout: ");
143-
GUILayout.FlexibleSpace();
144-
GUILayout.Label($"{flowAction.Timeout}");
145-
GUILayout.EndHorizontal();
146-
147-
GUILayout.BeginHorizontal();
148-
GUILayout.Label("FlowAction Description: ");
149-
GUILayout.FlexibleSpace();
150-
GUILayout.Label($"{flowAction.Description}");
151-
GUILayout.EndHorizontal();
152-
153-
}
154-
if (flowAction == null || flowAction.Name != "Creating Splash Screens Prefab")
155-
{
29+
if (gameState == null)
15630
return;
157-
}
158-
flowAction.Timeout = 0;
159-
//this.showNotice = true;
160-
161-
//GameObject.Find(ToolbarOABButtonID)?.GetComponent<UIValue_WriteBool_Toggle>()?.SetValue(isOpen);
162-
var splashScreenManager = GameObject.FindObjectOfType(typeof(SplashScreensManager)); // .Find(ToolbarOABButtonID)?.GetComponent<UIValue_WriteBool_Toggle>()?.SetValue(isOpen);
163-
SplashScreensManager man = new SplashScreensManager();
164-
165-
166-
167-
168-
169-
GUI.DragWindow(new Rect(0, 0, Screen.width, Screen.height));
170-
}
171-
172-
public void Start()
173-
{
174-
Harmony.CreateAndPatchAll(typeof(SkipSplashScreenPlugin).Assembly);
175-
}
176-
}
177-
178-
[HarmonyPatch(typeof(SplashScreensManager))]
179-
[HarmonyPatch("StartAnimations")]
180-
public class SplashScreensManagerPatch
181-
{
182-
private static ManualLogSource Logger = BepInEx.Logging.Logger.CreateLogSource("SkipSplashScreenPlugin.SplashScreensManagerPatch");
18331

184-
private static void Prefix(SplashScreensManager __instance)
185-
{
186-
Logger.LogInfo("StartAnimations harmony patch hit");
187-
//__instance.ResolveSplashScreens();
188-
}
189-
}
190-
191-
[HarmonyPatch(typeof(SequentialFlow))]
192-
public class SplashScreensManagerPatch2
193-
{
194-
private static ManualLogSource Logger = BepInEx.Logging.Logger.CreateLogSource("SkipSplashScreenPlugin.SplashScreensManagerPatch2");
32+
if (GameManager.Instance.Game.GlobalGameState.GetState() == GameState.MainMenu)
33+
Destroy(this);
34+
}
19535

19636
[HarmonyPatch("AddAction")]
19737
[HarmonyPrefix]
198-
private static bool AddActionPrefix(FlowAction action)
38+
private static bool SequentialFlow_AddAction(FlowAction action)
19939
{
200-
Logger.LogInfo($"SequentialFlow harmony patch hit. Action name: {action.Name}");
201-
if (action.Name == "Creating Splash Screens Prefab" || action.Name == "Parsing Loading Screens" || action.Name == "Set Loading Optimizations")
40+
if (action.Name == "Creating Splash Screens Prefab")
20241
{
20342
GameManager.Instance.HasPhotosensitivityWarningBeenShown = true;
20443
return false;
20544
}
206-
20745
else
20846
return true;
209-
//__instance.ResolveSplashScreens();
210-
}
211-
}
212-
213-
[HarmonyPatch(typeof(LandingHUD))]
214-
public class SplashScreensManagerPatch3
215-
{
216-
private static ManualLogSource Logger = BepInEx.Logging.Logger.CreateLogSource("SkipSplashScreenPlugin.LandingHUD");
217-
218-
[HarmonyPatch("Start")]
219-
[HarmonyPrefix]
220-
private static bool StartPrefix(LandingHUD __instance)
221-
{
222-
Logger.LogInfo($"LandingHUD harmony patch hit.");
223-
224-
//GameManager.Instance.HasPhotosensitivityWarningBeenShown = true;
225-
226-
return true;
227-
//__instance.ResolveSplashScreens();
22847
}
229-
}
48+
}

external_dlls/COPY_Assembly-CSharp_dll_HERE

Whitespace-only changes.

skip_splash_screen/swinfo.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
"mod_id": "skip_splash_screen",
33
"author": "Falki",
44
"name": "SkipSplashScreen",
5-
"description": "Skips the splashscreen",
6-
"source": "",
5+
"description": "Skips the splashscreen and health warning",
6+
"source": "https://github.com/Falki-git/SkipSplashScreen",
77
"version": "1.0.0",
8-
"version_check": "",
8+
"version_check": "https://github.com/Falki-git/SkipSplashScreen/blob/master/skip_splash_screen/swinfo.json",
99
"dependencies": [
1010
{
1111
"id": "SpaceWarp",

0 commit comments

Comments
 (0)