/
AppLauncher.cs
105 lines (90 loc) · 3.89 KB
/
AppLauncher.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using KSP;
using KSP.UI.Screens;
using UnityEngine;
using KSPPluginFramework;
namespace TransferWindowPlanner
{
public partial class TransferWindowPlanner
{
/// <summary>
/// Sets up the App Button - no longer called by the event as that only happens on StartMenu->SpaceCenter now
/// </summary>
void OnGUIAppLauncherReady()
{
MonoBehaviourExtended.LogFormatted_DebugOnly("AppLauncherReady");
if (settings.ButtonStyleChosen == Settings.ButtonStyleEnum.Launcher )
{
btnAppLauncher = InitAppLauncherButton();
}
}
void OnGameSceneLoadRequestedForAppLauncher(GameScenes SceneToLoad)
{
LogFormatted_DebugOnly("GameSceneLoadRequest");
DestroyAppLauncherButton();
}
internal ApplicationLauncherButton btnAppLauncher = null;
internal ApplicationLauncherButton InitAppLauncherButton()
{
ApplicationLauncherButton retButton = null;
//ApplicationLauncherButton[] lstButtons = TransferWindowPlanner.FindObjectsOfType<ApplicationLauncherButton>();
//LogFormatted("AppLauncher: Creating Button-BEFORE", lstButtons.Length);
try
{
retButton = ApplicationLauncher.Instance.AddModApplication(
onAppLaunchToggleOn, onAppLaunchToggleOff,
onAppLaunchHoverOn, onAppLaunchHoverOff,
null, null,
ApplicationLauncher.AppScenes.ALWAYS,
(Texture)Resources.texAppLaunchIcon);
//AppLauncherButtonMutuallyExclusive(settings.AppLauncherMutuallyExclusive);
//appButton = ApplicationLauncher.Instance.AddApplication(
// onAppLaunchToggleOn, onAppLaunchToggleOff,
// onAppLaunchHoverOn, onAppLaunchHoverOff,
// null, null,
// (Texture)Resources.texAppLaunchIcon);
//appButton.VisibleInScenes = ApplicationLauncher.AppScenes.FLIGHT;
}
catch (Exception ex)
{
MonoBehaviourExtended.LogFormatted("AppLauncher: Failed to set up App Launcher Button\r\n{0}", ex.Message);
retButton = null;
}
//lstButtons = TransferWindowPlanner.FindObjectsOfType<ApplicationLauncherButton>();
//LogFormatted("AppLauncher: Creating Button-AFTER", lstButtons.Length);
return retButton;
}
internal void DestroyAppLauncherButton()
{
//LogFormatted("AppLauncher: Destroying Button-BEFORE NULL CHECK");
if (btnAppLauncher != null)
{
ApplicationLauncherButton[] lstButtons = TransferWindowPlanner.FindObjectsOfType<ApplicationLauncherButton>();
//LogFormatted("AppLauncher: Destroying Button-Button Count:{0}", lstButtons.Length);
ApplicationLauncher.Instance.RemoveModApplication(btnAppLauncher);
btnAppLauncher = null;
}
//LogFormatted("AppLauncher: Destroying Button-AFTER NULL CHECK");
}
void onAppLaunchToggleOn() {
MonoBehaviourExtended.LogFormatted_DebugOnly("TOn");
windowMain.Visible = true;
}
void onAppLaunchToggleOff() {
MonoBehaviourExtended.LogFormatted_DebugOnly("TOff");
windowMain.Visible = false;
}
void onAppLaunchHoverOn() {
MonoBehaviourExtended.LogFormatted_DebugOnly("HovOn");
//MouseOverAppLauncherBtn = true;
}
void onAppLaunchHoverOff() {
MonoBehaviourExtended.LogFormatted_DebugOnly("HovOff");
//MouseOverAppLauncherBtn = false;
}
//Boolean MouseOverAppLauncherBtn = false;
}
}