forked from RemoteTechnologiesGroup/RemoteTech
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFlightComputerWindow.cs
More file actions
110 lines (100 loc) · 3.38 KB
/
Copy pathFlightComputerWindow.cs
File metadata and controls
110 lines (100 loc) · 3.38 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
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
106
107
108
109
110
using System;
using UnityEngine;
namespace RemoteTech.UI
{
public class FlightComputerWindow : AbstractWindow
{
private enum FragmentTab
{
Attitude = 0,
Rover = 1,
}
private FragmentTab mTab = FragmentTab.Attitude;
private readonly AttitudeFragment mAttitude;
private readonly RoverFragment mRover;
private readonly QueueFragment mQueue;
private bool mQueueEnabled;
private FlightComputer.FlightComputer mFlightComputer;
private FragmentTab Tab
{
get
{
return mTab;
}
set
{
int NumberOfTabs = 2;
if ((int)value >= NumberOfTabs) {
mTab = (FragmentTab)0;
} else if ((int)value < 0) {
mTab = (FragmentTab)(NumberOfTabs - 1);
} else {
mTab = value;
}
}
}
public FlightComputerWindow(FlightComputer.FlightComputer fc)
: base(Guid.NewGuid(), "FlightComputer", new Rect(100, 100, 0, 0), WindowAlign.Floating)
{
mSavePosition = true;
mFlightComputer = fc;
mAttitude = new AttitudeFragment(fc, () => mQueueEnabled = !mQueueEnabled);
mRover = new RoverFragment(fc, () => mQueueEnabled = !mQueueEnabled);
mQueue = new QueueFragment(fc);
mQueueEnabled = false;
}
public override void Show()
{
base.Show();
mFlightComputer.onActiveCommandAbort += mAttitude.Reset;
mFlightComputer.onNewCommandPop += mAttitude.getActiveFlightMode;
mAttitude.getActiveFlightMode();
}
public override void Hide()
{
mFlightComputer.onActiveCommandAbort -= mAttitude.Reset;
mFlightComputer.onNewCommandPop -= mAttitude.getActiveFlightMode;
base.Hide();
}
public override void Window(int id)
{
GUI.skin = null;
GUILayout.BeginHorizontal();
{
GUILayout.BeginHorizontal();
{
switch (mTab) {
case FragmentTab.Attitude:
mAttitude.Draw();
break;
case FragmentTab.Rover:
mRover.Draw();
break;
}
}
GUILayout.EndHorizontal();
// Disabled RoverComputer
// We will add this feature on a later release
//
//if (GUI.Button(new Rect(2, 2, 16, 16), "<")) {
// Tab--;
//}
//if (GUI.Button(new Rect(16, 2, 16, 16), ">")) {
// Tab++;
//}
if (mQueueEnabled) {
mQueue.Draw();
} else {
GUILayout.BeginVertical();
{
GUILayout.BeginScrollView(Vector2.zero, GUILayout.ExpandHeight(true));
GUILayout.EndScrollView();
}
GUILayout.EndVertical();
}
}
GUILayout.EndHorizontal();
base.Window(id);
}
}
}