-
Notifications
You must be signed in to change notification settings - Fork 33
/
ModSettingsWindow.cs
106 lines (83 loc) · 3.67 KB
/
ModSettingsWindow.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
106
using System;
using System.Collections.Generic;
using UnityEngine;
namespace KSPAdvancedFlyByWire
{
class ModSettingsWindow
{
private Rect windowRect = new Rect(0, 648, 420, 256);
//private Vector2 m_ScrollPosition = new Vector2(0, 0);
public bool shouldBeDestroyed = false;
public string inputLockHash = "AFBW Settings";
private bool FloatField(float value, out float retValue)
{
string text = GUILayout.TextField(value.ToString("0.00"), GUILayout.Width(128));
float newValue;
if (float.TryParse(text, out newValue))
{
retValue = newValue;
return true;
}
retValue = value;
return false;
}
public void DoWindow(int window)
{
GUI.DragWindow(new Rect(0, 0, 10000, 20));
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
if (GUILayout.Button("X", GUILayout.Height(16)))
{
shouldBeDestroyed = true;
return;
}
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();
GUILayout.Label("Use stock skin");
AdvancedFlyByWire.Instance.m_UseKSPSkin = GUILayout.Toggle(AdvancedFlyByWire.Instance.m_UseKSPSkin, "");
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();
GUILayout.Label("Use old presets editor");
AdvancedFlyByWire.Instance.m_UseOldPresetsWindow = GUILayout.Toggle(AdvancedFlyByWire.Instance.m_UseOldPresetsWindow, "");
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();
GUILayout.Label("PrecisionMode Factor");
AdvancedFlyByWire.Instance.m_UsePrecisionModeFactor = GUILayout.Toggle(AdvancedFlyByWire.Instance.m_UsePrecisionModeFactor, "");
GUILayout.FlexibleSpace();
GUILayout.Label(AdvancedFlyByWire.Instance.m_PrecisionModeFactor.ToString("0.000"));
AdvancedFlyByWire.Instance.m_PrecisionModeFactor = GUILayout.HorizontalSlider(AdvancedFlyByWire.Instance.m_PrecisionModeFactor, 0.0f, 1.0f, GUILayout.Width(150));
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();
GUILayout.Label("AFBW input overrides SAS and other control inputs");
AdvancedFlyByWire.Instance.m_IgnoreFlightCtrlState = GUILayout.Toggle(AdvancedFlyByWire.Instance.m_IgnoreFlightCtrlState, "");
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();
GUILayout.Label("AtmosphereAutopilot compatibility");
AdvancedFlyByWire.Instance.m_UseOnPreInsteadOfOnFlyByWire = GUILayout.Toggle(AdvancedFlyByWire.Instance.m_UseOnPreInsteadOfOnFlyByWire, "");
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();
if (GUILayout.Button("Save configuration"))
{
AdvancedFlyByWire.Instance.SaveState(null);
}
GUILayout.EndHorizontal();
}
public void OnGUI()
{
if (Utility.RectContainsMouse(windowRect))
{
InputLockManager.SetControlLock(inputLockHash);
}
else
{
InputLockManager.RemoveControlLock(inputLockHash);
}
windowRect = GUI.Window(8721, windowRect, DoWindow, inputLockHash);
windowRect = Utility.ClampRect(windowRect, new Rect(0, 0, Screen.width, Screen.height));
}
}
}