void OnGUI() { if (m_UIHidden || !m_UIActive) { return; } GUISkin oldSkin = GUI.skin; if (settings.m_UseKSPSkin) { GUI.skin = HighLogic.Skin; } if (Utility.RectContainsMouse(m_WindowRect)) { InputLockManager.SetControlLock(ControlTypes.All, "AdvancedFlyByWireMainWindow"); } else { InputLockManager.RemoveControlLock("AdvancedFlyByWireMainWindow"); } m_WindowRect = ClickThruBlocker.GUIWindow(0, m_WindowRect, DoMainWindow, "Advanced Fly-By-Wire"); m_WindowRect = Utility.ClampRect(m_WindowRect, new Rect(0, 0, Screen.width, Screen.height)); for (int i = 0; i < m_PresetEditors.Count; i++) { if (m_PresetEditors[i].shouldBeDestroyed) { InputLockManager.RemoveControlLock(m_PresetEditors[i].inputLockHash); m_PresetEditors.RemoveAt(i); break; } } foreach (var presetEditor in m_PresetEditors) { presetEditor.OnGUI(); } for (int i = 0; i < m_ControllerTests.Count; i++) { if (m_ControllerTests[i].shouldBeDestroyed) { InputLockManager.RemoveControlLock(m_ControllerTests[i].inputLockHash); m_ControllerTests.RemoveAt(i); break; } } foreach (var controllerTest in m_ControllerTests) { controllerTest.OnGUI(); } if (m_ModSettings != null) { if (m_ModSettings.shouldBeDestroyed) { InputLockManager.RemoveControlLock(m_ModSettings.inputLockHash); m_ModSettings = null; } else { m_ModSettings.OnGUI(); } } GUI.skin = oldSkin; }
void DoMainWindow(int index) { GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUI.Button(new Rect(m_WindowRect.width - 24, 4, 20, 20), "X")) // if (GUILayout.Button("X", GUILayout.Height(16))) { m_UIActive = false; InputLockManager.RemoveControlLock("AdvancedFlyByWireMainWindow"); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Mod settings", GUILayout.Width(m_WindowRect.width / 2))) { if (m_ModSettings == null) { m_ModSettings = new ModSettingsWindow(); } } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); m_ScrollPosition = GUILayout.BeginScrollView(m_ScrollPosition); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); GUILayout.Label("Controllers"); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); var controllers = IController.EnumerateAllControllers(); foreach (var controller in controllers) { GUILayout.BeginHorizontal(); ControllerConfiguration config = m_Configuration.GetConfigurationByControllerType(controller.Key, controller.Value.Key); bool isEnabled = config != null && config.iface != null && config.isEnabled; bool newIsEnabled = GUILayout.Toggle(isEnabled, ""); GUILayout.Label(controller.Value.Value); GUILayout.FlexibleSpace(); if (!isEnabled && newIsEnabled) { isEnabled = true; m_Configuration.ActivateController ( controller.Key, controller.Value.Key, ButtonPressedCallback, ButtonReleasedCallback ); } else if (isEnabled && !newIsEnabled) { m_Configuration.DeactivateController(controller.Key, controller.Value.Key); } if (!isEnabled || config == null || config.presetEditorOpen) { GUI.enabled = false; } if (GUILayout.Button("Presets", GUILayout.Height(32))) { if (settings.m_UseOldPresetsWindow) { m_PresetEditors.Add(new PresetEditorWindow(config, m_PresetEditors.Count)); } else { m_PresetEditors.Add(new PresetEditorWindowNG(config, m_PresetEditors.Count)); } config.presetEditorOpen = true; } if (isEnabled) { GUI.enabled = true; } if (!isEnabled || config == null || config.controllerConfigurationOpen) { GUI.enabled = false; } if (GUILayout.Button("Configuration", GUILayout.Height(32))) { m_ControllerTests.Add(new ControllerConfigurationWindow(config, m_ControllerTests.Count)); config.controllerConfigurationOpen = true; } if (isEnabled) { GUI.enabled = true; } GUILayout.EndHorizontal(); if (isEnabled && config != null) { GUILayout.Space(4); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); GUILayout.Label("Preset: " + config.GetCurrentPreset().name); if (config.currentPreset <= 0) { GUI.enabled = false; } if (GUILayout.Button("<", GUILayout.Width(32))) { config.currentPreset--; } GUI.enabled = true; GUILayout.Space(4); if (config.currentPreset >= config.presets.Count - 1) { GUI.enabled = false; } if (GUILayout.Button(">", GUILayout.Width(32))) { config.currentPreset++; } GUI.enabled = true; GUILayout.EndHorizontal(); } GUILayout.Space(24); GUI.enabled = true; } GUILayout.EndScrollView(); GUI.DragWindow(); }