-
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added cleanup class to cleanup all input locks after a delay, immedi…
…ately upon changing scenes Added cleanup delay to settings page
- Loading branch information
1 parent
274dc63
commit af957c7
Showing
12 changed files
with
162 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ | |
"MAJOR": 0, | ||
"MINOR": 1, | ||
"PATCH": 10, | ||
"BUILD": 4 | ||
"BUILD": 5 | ||
}, | ||
"KSP_VERSION_MIN": { | ||
"MAJOR": 1, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,4 @@ | |
|
||
using System.Reflection; | ||
|
||
[assembly: AssemblyVersion("0.1.10.3")] | ||
[assembly: AssemblyVersion("0.1.10.5")] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
using ToolbarControl_NS; | ||
using KSP.UI.Screens; | ||
using KSP.Localization; | ||
using System; | ||
using System.IO; | ||
|
||
using KSP.IO; | ||
using UnityEngine; | ||
|
||
namespace ClearAllInputLocks | ||
{ | ||
[KSPAddon(KSPAddon.Startup.AllGameScenes, false)] | ||
public class ClearInputLocks : MonoBehaviour | ||
{ | ||
internal const string MODID = "ClearInputLocks_ns"; | ||
internal const string MODNAME = "Clear Input Locks"; | ||
static internal ToolbarControl toolbarControl = null; | ||
|
||
|
||
void Start() | ||
{ | ||
AddToolbarButton(); | ||
} | ||
|
||
void AddToolbarButton() | ||
{ | ||
if (toolbarControl == null) | ||
{ | ||
#if false | ||
public void AddToAllToolbars(TC_ClickHandler onTrue, TC_ClickHandler onFalse, TC_ClickHandler onHover, TC_ClickHandler onHoverOut, TC_ClickHandler onEnable, TC_ClickHandler onDisable, ApplicationLauncher.AppScenes visibleInScenes, string nameSpace, string toolbarId, string largeToolbarIcon, string smallToolbarIcon, string toolTip = ""); | ||
|
||
#endif | ||
toolbarControl = gameObject.AddComponent<ToolbarControl>(); | ||
toolbarControl.AddToAllToolbars(null, null, | ||
ApplicationLauncher.AppScenes.SPACECENTER | | ||
ApplicationLauncher.AppScenes.FLIGHT | | ||
ApplicationLauncher.AppScenes.MAPVIEW | | ||
ApplicationLauncher.AppScenes.VAB | | ||
ApplicationLauncher.AppScenes.SPH | | ||
ApplicationLauncher.AppScenes.TRACKSTATION, | ||
MODID, | ||
"ClearInputLocks", | ||
"000_ClickThroughBlocker/PluginData/lock-38", | ||
"000_ClickThroughBlocker/PluginData/lock-24", | ||
"Clear all input locks" | ||
); | ||
toolbarControl.AddLeftRightClickCallbacks(ClearInputLocksToggle, CallModeWindow); | ||
} | ||
} | ||
|
||
void ClearInputLocksToggle() | ||
{ | ||
InputLockManager.ClearControlLocks(); | ||
ScreenMessages.PostScreenMessage("All Input Locks Cleared", 5); | ||
} | ||
|
||
internal static MonoBehaviour modeWindow = null; | ||
void CallModeWindow() | ||
{ | ||
ClickThroughFix.Log.Info("CallModeWindow, modeWindow: " + (modeWindow != null)); | ||
if (modeWindow == null) | ||
modeWindow = gameObject.AddComponent<OneTimePopup>(); | ||
else | ||
Destroy(modeWindow); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
using System; | ||
using System.Collections; | ||
using UnityEngine; | ||
|
||
namespace ClearAllInputLocks | ||
{ | ||
[KSPAddon(KSPAddon.Startup.AllGameScenes, false)] | ||
class SceneChangeCleanup : MonoBehaviour | ||
{ | ||
void Start() | ||
{ | ||
GameEvents.onGameSceneLoadRequested.Add(onGameSceneLoadRequested); | ||
GameEvents.onGUIApplicationLauncherReady.Add(onGUIApplicationLauncherReady); | ||
GameEvents.onLevelWasLoadedGUIReady.Add(onLevelWasLoadedGUIReady); | ||
} | ||
|
||
void onGameSceneLoadRequested(GameScenes gs) | ||
{ | ||
ClickThroughFix.Log.Info("SceneChangeCleanup.onGameSceneLoadRequested"); | ||
InputLockManager.ClearControlLocks(); | ||
StartCoroutine(CleanupInputLocks()); | ||
} | ||
|
||
void onGUIApplicationLauncherReady() | ||
{ | ||
ClickThroughFix.Log.Info("SceneChangeCleanup.onGUIApplicationLauncherReady"); | ||
StartCoroutine(CleanupInputLocks()); | ||
} | ||
|
||
void onLevelWasLoadedGUIReady(GameScenes gs) | ||
{ | ||
ClickThroughFix.Log.Info("SceneChangeCleanup.onLevelWasLoadedGUIReady"); | ||
StartCoroutine(CleanupInputLocks()); | ||
} | ||
|
||
|
||
|
||
IEnumerator CleanupInputLocks() | ||
{ | ||
yield return new WaitForSeconds(HighLogic.CurrentGame.Parameters.CustomParams<ClickThroughFix.CTB>().cleanupDelay); | ||
InputLockManager.ClearControlLocks(); | ||
yield return null; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ | |
"MAJOR": 0, | ||
"MINOR": 1, | ||
"PATCH": 10, | ||
"BUILD": 3 | ||
"BUILD": 5 | ||
}, | ||
"KSP_VERSION_MIN": { | ||
"MAJOR": 1, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters