Skip to content

Commit

Permalink
Initial version
Browse files Browse the repository at this point in the history
  • Loading branch information
radistmorse committed Sep 28, 2016
0 parents commit d7e8b1e
Show file tree
Hide file tree
Showing 5 changed files with 375 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

/obj
/.vs
253 changes: 253 additions & 0 deletions InputLockTester.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,253 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
using KSP.UI.Screens;

namespace KSPInputLockTester {
[KSPAddon (KSPAddon.Startup.MainMenu, true)]
public class InputLockTester : MonoBehaviour {
private ApplicationLauncherButton appButton = null;
private Texture2D appButtonTexture;

private bool mainWindowShown = false;
private readonly int mainWindowId = 841358683;
private Rect mainWindowPos = new Rect (Screen.width / 10, 20, 900, 0);

internal void Awake () {
DontDestroyOnLoad (this);
appButtonTexture = new Texture2D (64, 64);
appButtonTexture.LoadImage (new byte[] {
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d,
0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x40,
0x08, 0x06, 0x00, 0x00, 0x00, 0xaa, 0x69, 0x71, 0xde, 0x00, 0x00, 0x05,
0xf6, 0x49, 0x44, 0x41, 0x54, 0x78, 0xda, 0xed, 0x9a, 0x6b, 0x88, 0x55,
0x55, 0x14, 0xc7, 0x7f, 0xfb, 0xce, 0x9d, 0xb1, 0xd7, 0x14, 0x65, 0x96,
0x65, 0x99, 0xa9, 0xbd, 0x45, 0xf3, 0x91, 0xcf, 0xb2, 0x90, 0x32, 0x28,
0xfc, 0x62, 0x86, 0x09, 0x56, 0x6a, 0x7e, 0x48, 0x08, 0x31, 0x7c, 0x7c,
0xc8, 0x07, 0x62, 0xf8, 0x29, 0x53, 0x88, 0xc0, 0x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cf, 0x21, 0x4e, 0xdd, 0x24, 0x00,
0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
});

GameEvents.onGUIApplicationLauncherReady.Add (OnGUIApplicationLauncherReady);
GameEvents.onGUIApplicationLauncherUnreadifying.Add (OnGUIApplicationLauncherUnreadifying);
GameEvents.onHideUI.Add (OnHideUI);
GameEvents.onShowUI.Add (OnShowUI);

}
protected virtual void OnDestroy () {
// unsubscribe event listeners
GameEvents.onGUIApplicationLauncherReady.Remove (OnGUIApplicationLauncherReady);
GameEvents.onGUIApplicationLauncherUnreadifying.Remove (OnGUIApplicationLauncherUnreadifying);
}
private void OnGUIApplicationLauncherReady () {
// create button
if (ApplicationLauncher.Ready && appButton == null)
appButton = ApplicationLauncher.Instance.AddModApplication (ShowMainWindow, HideMainWindow, null, null, Enable, Disable,
ApplicationLauncher.AppScenes.ALWAYS, appButtonTexture);
}

private void OnGUIApplicationLauncherUnreadifying (GameScenes scene) {
// remove button
if (appButton != null) {
mainWindowShown = false;
ApplicationLauncher.Instance.RemoveModApplication (appButton);
appButton = null;
}
}
private void OnHideUI () {
mainWindowShown = false;
}
private void OnShowUI () {
if (appButton != null)
mainWindowShown = (appButton.toggleButton.CurrentState == KSP.UI.UIRadioButton.State.True);
}
protected void ShowMainWindow () {
mainWindowShown = true;
}
private void HideMainWindow () {
mainWindowShown = false;
}
public void Disable () {
if (appButton != null && appButton.toggleButton.Interactable)
appButton.Disable ();
}
public void Enable () {
if (appButton != null && appButton.toggleButton.Interactable == false)
appButton.Enable ();
}

internal void OnGUI () {
if (mainWindowShown)
mainWindowPos = GUILayout.Window (mainWindowId, mainWindowPos, (id) => DrawMainWindow (), "Input Lock Tester", GUILayout.ExpandHeight (true));
}

private void DrawMainWindow () {
ulong curlock = InputLockManager.LockMask;
ControlTypes ourlock = InputLockManager.GetControlLock("InputLockTester");
bool changed = false;
int num = 0;
foreach (ControlTypes type in Enum.GetValues (typeof (ControlTypes))) {
if (type == ControlTypes.None)
continue;

bool locked = (curlock & (ulong)type) == (ulong)type;//InputLockManager.IsLocked (type);
bool lockedbyus = (ourlock & type) == type;

if (num % 3 == 0)
GUILayout.BeginHorizontal ();
if (locked && !lockedbyus)
GUI.enabled = false;
bool rez = GUILayout.Toggle (lockedbyus, "Lock", "button", GUILayout.Width(50));
GUI.enabled = true;
GUILayout.Label (type.ToString (), GUILayout.Width(250));
if (num % 3 == 2)
GUILayout.EndHorizontal ();

if (rez != lockedbyus) {
changed = true;
if (rez)
ourlock |= type;
else
ourlock &= ~type;
}
num++;
}
if (num % 3 != 0)
GUILayout.EndHorizontal ();

if (changed)
if (ourlock == ControlTypes.None)
InputLockManager.RemoveControlLock ("InputLockTester");
else
InputLockManager.SetControlLock (ourlock, "InputLockTester");

GUI.DragWindow ();
}
}
}
61 changes: 61 additions & 0 deletions KSPInputLockTester.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{6FA127EB-44DA-4B61-8618-E6038FA9F31A}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>InputLockTester</RootNamespace>
<AssemblyName>InputLockTester</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>none</DebugType>
<Optimize>true</Optimize>
<OutputPath>BUILD\</OutputPath>
<DefineConstants>
</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Assembly-CSharp">
<HintPath>D:\codeworks\Libs\Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="UnityEngine">
<HintPath>D:\codeworks\Libs\UnityEngine.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="InputLockTester.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
22 changes: 22 additions & 0 deletions KSPInputLockTester.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25123.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KSPInputLockTester", "KSPInputLockTester.csproj", "{6FA127EB-44DA-4B61-8618-E6038FA9F31A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{6FA127EB-44DA-4B61-8618-E6038FA9F31A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6FA127EB-44DA-4B61-8618-E6038FA9F31A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6FA127EB-44DA-4B61-8618-E6038FA9F31A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6FA127EB-44DA-4B61-8618-E6038FA9F31A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
Loading

0 comments on commit d7e8b1e

Please sign in to comment.