-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Part highlighting is available again.
Blizzy’s toolbar support. Hiding UI when F2 is pressed.
- Loading branch information
Showing
20 changed files
with
1,365 additions
and
194 deletions.
There are no files selected for viewing
Binary file modified
BIN
+13.5 KB
(160%)
GameData/CriticalTemperatureGauge/Plugins/CriticalTemperatureGauge.dll
Binary file not shown.
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 |
---|---|---|
|
@@ -13,7 +13,7 @@ | |
"MAJOR": 1, | ||
"MINOR": 1, | ||
"PATCH": 3, | ||
"BUILD": 3 | ||
"BUILD": 4 | ||
}, | ||
"KSP_VERSION": | ||
{ | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
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,131 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using KSP.UI.Screens; | ||
using UnityEngine; | ||
|
||
namespace CriticalTemperatureGauge | ||
{ | ||
/// <summary> | ||
/// Class that adds the AppLauncher button. | ||
/// </summary> | ||
[KSPAddon(KSPAddon.Startup.Flight, false)] | ||
public class AppLauncher : MonoBehaviour | ||
{ | ||
// Resources | ||
static readonly Texture2D AppLauncherButtonTexture = | ||
GameDatabase.Instance.GetTexture(Static.TexturePath + "AppLauncherButton", false); | ||
|
||
ApplicationLauncherButton _appLauncherButton; | ||
readonly SettingsWindow _settingsWindow = new SettingsWindow(); | ||
|
||
public void Update() | ||
{ | ||
if(_appLauncherButton != null) | ||
_appLauncherButton.VisibleInScenes = Static.Settings.ShowAppLauncherButton | ||
? ApplicationLauncher.AppScenes.FLIGHT | ApplicationLauncher.AppScenes.MAPVIEW | ||
: ApplicationLauncher.AppScenes.NEVER; | ||
} | ||
|
||
public bool ButtonState | ||
{ | ||
get | ||
{ | ||
return _settingsWindow.IsLogicallyVisible; | ||
} | ||
set | ||
{ | ||
if(value) | ||
_appLauncherButton?.SetTrue(); | ||
else | ||
_appLauncherButton?.SetFalse(); | ||
} | ||
} | ||
|
||
// KSP events: | ||
|
||
public void Start() | ||
{ | ||
OnGUIApplicationLauncherReady(); | ||
Static.AppLauncher = this; | ||
} | ||
|
||
public void Awake() | ||
{ | ||
GameEvents.onGUIApplicationLauncherReady.Add(OnGUIApplicationLauncherReady); | ||
GameEvents.onGameSceneLoadRequested.Add(OnSceneChangeRequest); | ||
GameEvents.onShowUI.Add(OnShowUI); | ||
GameEvents.onHideUI.Add(OnHideUI); | ||
} | ||
|
||
internal void OnDestroy() | ||
{ | ||
GameEvents.onGUIApplicationLauncherReady.Remove(OnGUIApplicationLauncherReady); | ||
GameEvents.onGameSceneLoadRequested.Remove(OnSceneChangeRequest); | ||
GameEvents.onShowUI.Remove(OnShowUI); | ||
GameEvents.onHideUI.Remove(OnHideUI); | ||
RemoveAppLauncherButton(); | ||
Static.AppLauncher = null; | ||
} | ||
|
||
public void OnGUI() | ||
{ | ||
_settingsWindow.DrawGUI(); | ||
} | ||
|
||
void OnGUIApplicationLauncherReady() | ||
{ | ||
AddAppLauncherButton(); | ||
} | ||
|
||
void OnSceneChangeRequest(GameScenes scene) | ||
{ | ||
RemoveAppLauncherButton(); | ||
} | ||
|
||
void OnShowUI() | ||
{ | ||
_settingsWindow.CanShow = true; | ||
} | ||
|
||
void OnHideUI() | ||
{ | ||
_settingsWindow.CanShow = false; | ||
} | ||
|
||
/// <summary>Shows the settings window when the button is pressed.</summary> | ||
void OnButtonOn() | ||
{ | ||
_settingsWindow.Show(); | ||
} | ||
|
||
/// <summary>Hides the settings window when the button is pressed again.</summary> | ||
void OnButtonOff() | ||
{ | ||
_settingsWindow.Hide(); | ||
} | ||
|
||
/// <summary>Adds the button to the appLauncher.</summary> | ||
void AddAppLauncherButton() | ||
{ | ||
if(_appLauncherButton == null) | ||
_appLauncherButton = ApplicationLauncher.Instance.AddModApplication( | ||
onTrue: OnButtonOn, | ||
onFalse: OnButtonOff, | ||
onHover: null, | ||
onHoverOut: null, | ||
onEnable: null, | ||
onDisable: null, | ||
visibleInScenes: ApplicationLauncher.AppScenes.NEVER, | ||
texture: AppLauncherButtonTexture); | ||
Update(); | ||
} | ||
|
||
/// <summary>Removes the button from the appLauncher.</summary> | ||
void RemoveAppLauncherButton() | ||
{ | ||
if(_appLauncherButton != null) | ||
ApplicationLauncher.Instance.RemoveModApplication(_appLauncherButton); | ||
} | ||
} | ||
} |
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,34 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
namespace CriticalTemperatureGauge | ||
{ | ||
public class BlizzysToolbar | ||
{ | ||
const string ButtonId = "Settings"; | ||
const string ButtonTexturePath = Static.TexturePath + "BizzysToolbarButton"; | ||
|
||
IButton _toolbarButton; | ||
|
||
public void Start() | ||
{ | ||
if(ToolbarManager.ToolbarAvailable) | ||
{ | ||
_toolbarButton = ToolbarManager.Instance.add(nameof(CriticalTemperatureGauge), nameof(CriticalTemperatureGauge) + ButtonId); | ||
_toolbarButton.TexturePath = ButtonTexturePath; | ||
_toolbarButton.ToolTip = Static.PluginTitle; | ||
_toolbarButton.OnClick += e => | ||
{ | ||
if(Static.AppLauncher != null && e.MouseButton == 0 /* Left mouse button */) | ||
Static.AppLauncher.ButtonState = !Static.AppLauncher.ButtonState; | ||
}; | ||
} | ||
} | ||
|
||
public void Destroy() | ||
{ | ||
_toolbarButton?.Destroy(); | ||
} | ||
} | ||
} |
Oops, something went wrong.