-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathModuleCrewIndicatorToggle.cs
More file actions
72 lines (64 loc) · 2.41 KB
/
Copy pathModuleCrewIndicatorToggle.cs
File metadata and controls
72 lines (64 loc) · 2.41 KB
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
namespace IndicatorLights
{
/// <summary>
/// A specialized toggle for turning crew indicators on/off.
/// </summary>
public class ModuleCrewIndicatorToggle : PartModule, Identifiers.IIdentifiable, IToggle
{
[KSPField(guiName = "Crew LEDs", isPersistant = true, guiActive = true, guiActiveEditor = true),
UI_Toggle(affectSymCounterparts = UI_Scene.Editor, controlEnabled = true, enabledText = "On", disabledText = "Off")]
public bool status = true;
private BaseField StatusField { get { return Fields["status"]; } }
[KSPField]
public string toggleName = null;
/// <summary>
/// Determines where the toggle UI is visible.
/// </summary>
[KSPField]
public UI_Scene uiToggle = UI_Scene.Editor;
/// <summary>
/// Action-group method for toggling status.
/// </summary>
/// <param name="actionParam"></param>
[KSPAction("Toggle Crew LEDs")]
public void OnToggleAction(KSPActionParam actionParam)
{
status = actionParam.type != KSPActionType.Deactivate;
}
private BaseAction ToggleAction { get { return Actions["OnToggleAction"]; } }
/// <summary>
/// Action-group method for setting status to true.
/// </summary>
/// <param name="actionParam"></param>
[KSPAction("Activate Crew LEDs")]
public void OnActivateAction(KSPActionParam actionParam)
{
status = true;
}
private BaseAction ActivateAction { get { return Actions["OnActivateAction"]; } }
/// <summary>
/// Action-group method for setting status to false.
/// </summary>
/// <param name="actionParam"></param>
[KSPAction("Deactivate Crew LEDs")]
public void OnDeactivateAction(KSPActionParam actionParam)
{
status = false;
}
private BaseAction DeactivateAction { get { return Actions["OnDeactivateAction"]; } }
public string Identifier
{
get { return toggleName; }
}
public bool ToggleStatus
{
get { return status; }
}
public override void OnStart(StartState state)
{
base.OnStart(state);
StatusField.guiActive = uiToggle.IsFlightEnabled();
StatusField.guiActiveEditor = uiToggle.IsEditorEnabled();
}
}
}