-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
239 additions
and
101 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,24 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd"> | ||
<metadata> | ||
<id>$id$</id> | ||
<version>$version$</version> | ||
<authors>$authors$</authors> | ||
<requireLicenseAcceptance>false</requireLicenseAcceptance> | ||
<licenseUrl>https://raw.githubusercontent.com/jan-bures/UitkForKsp2/main/LICENSE</licenseUrl> | ||
<description>$description$</description> | ||
<tags>ksp ksp2 mod library</tags> | ||
<projectUrl>$repositoryUrl$</projectUrl> | ||
<repository type="$repositoryType$" url="$repositoryUrl$" /> | ||
<readme>README.md</readme> | ||
<dependencies> | ||
<group targetFramework=".NETStandard2.1" /> | ||
</dependencies> | ||
</metadata> | ||
<files> | ||
<file src="README.md" target="" /> | ||
<file src="LICENSE" target="LICENSE" /> | ||
<file src="temp_nuget\*.dll" target="lib/netstandard2.1/" /> | ||
<file src="temp_nuget\*.xml" target="lib/netstandard2.1/" /> | ||
</files> | ||
</package> |
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,52 @@ | ||
using KSP.Game; | ||
using KSP.Input; | ||
using UnityEngine; | ||
using UnityEngine.UIElements; | ||
|
||
namespace UitkForKsp2.API; | ||
|
||
/// <summary> | ||
/// Allows hiding a VisualElement with the F2 key. | ||
/// </summary> | ||
public class HideManipulator : IManipulator | ||
{ | ||
private bool _isHidden; | ||
private DisplayStyle _originalDisplayStyle; | ||
|
||
private VisualElement _target; | ||
|
||
/// <summary> | ||
/// The target element that will be hidden. | ||
/// </summary> | ||
public VisualElement target | ||
{ | ||
get => _target; | ||
set | ||
{ | ||
var game = GameManager.Instance.Game; | ||
if (game.InputManager.TryGetInputDefinition<GlobalInputDefinition>(out var definition)) | ||
{ | ||
Debug.Log("HideManipulator: Binding ToggleHidden to GlobalInputDefinition"); | ||
definition.BindAction(game.Input.Global.ToggleUIVisibility.name, ToggleHidden); | ||
} | ||
_target = value; | ||
} | ||
} | ||
|
||
private void ToggleHidden() | ||
{ | ||
if (_isHidden) | ||
{ | ||
Debug.Log("HideManipulator: Unhiding."); | ||
_isHidden = false; | ||
_target.style.display = _originalDisplayStyle; | ||
} | ||
else | ||
{ | ||
Debug.Log("HideManipulator: Hiding."); | ||
_isHidden = true; | ||
_originalDisplayStyle = _target.style.display.value; | ||
_target.style.display = DisplayStyle.None; | ||
} | ||
} | ||
} |
Oops, something went wrong.