private void DrawProfileSettings() { if (ScienceAlertProfileManager.HasActiveProfile) { GUILayout.BeginHorizontal(); GUILayout.Box(Localizer.Format("#ScienceAlert_label11", ScienceAlertProfileManager.ActiveProfile.DisplayName), GUILayout.ExpandHeight(true), GUILayout.ExpandWidth(true));//$"Profile: <<1>>{}" if (AudibleButton(new GUIContent(renameButton), GUILayout.MaxWidth(24f))) { SpawnRenamePopup(ScienceAlertProfileManager.ActiveProfile); } GUI.enabled = ScienceAlertProfileManager.ActiveProfile.modified; if (AudibleButton(new GUIContent(saveButton), GUILayout.MaxWidth(24f))) { SpawnSavePopup(); } GUI.enabled = true; if (AudibleButton(new GUIContent(openButton), GUILayout.MaxWidth(24f))) { submenu = OpenPane.LoadProfiles; } GUILayout.EndHorizontal(); scrollPos = GUILayout.BeginScrollView(scrollPos, Settings.Skin.scrollView); GUI.skin = Settings.Skin; GUILayout.Space(4f); GUI.SetNextControlName("ThresholdHeader"); GUILayout.Box(Localizer.Format("#ScienceAlert_label12"));//"Alert Threshold" GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true), GUILayout.MinHeight(14f)); if (ScienceAlertProfileManager.ActiveProfile.ScienceThreshold > 0f) { GUILayout.Label(Localizer.Format("#ScienceAlert_label13", ScienceAlertProfileManager.ActiveProfile.ScienceThreshold.ToString("F2", formatter)));//$"Alert Threshold: <<1>>" } else { Color color = GUI.color; GUI.color = XKCDColors.Salmon; GUILayout.Label(Localizer.Format("#ScienceAlert_label14"));//"(disabled)" GUI.color = color; } GUILayout.FlexibleSpace(); if (string.IsNullOrEmpty(thresholdValue)) { thresholdValue = ScienceAlertProfileManager.ActiveProfile.scienceThreshold.ToString("F2", formatter); } GUI.SetNextControlName("ThresholdText"); string s = GUILayout.TextField(thresholdValue, GUILayout.MinWidth(60f)); if (Event.current.keyCode == KeyCode.Escape) { GUI.FocusControl("ThresholdHeader"); } if (GUI.GetNameOfFocusedControl() == "ThresholdText") { try { float scienceThreshold = float.Parse(s, formatter); ScienceAlertProfileManager.ActiveProfile.ScienceThreshold = scienceThreshold; thresholdValue = s; } catch (System.Exception) { // ignored } if (!InputLockManager.IsLocked(ControlTypes.ACTIONS_ALL)) { InputLockManager.SetControlLock(ControlTypes.ACTIONS_ALL, "ScienceAlertThreshold"); } } else if (InputLockManager.GetControlLock("ScienceAlertThreshold") != ControlTypes.None) { InputLockManager.RemoveControlLock("ScienceAlertThreshold"); } GUILayout.EndHorizontal(); GUILayout.Space(3f); var num = GUILayout.HorizontalSlider(ScienceAlertProfileManager.ActiveProfile.ScienceThreshold, 0f, 100f, GUILayout.ExpandWidth(true), GUILayout.Height(14f)); if (num != ScienceAlertProfileManager.ActiveProfile.scienceThreshold) { ScienceAlertProfileManager.ActiveProfile.ScienceThreshold = num; thresholdValue = num.ToString("F2", formatter); } GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true), GUILayout.MaxHeight(10f)); GUILayout.Label("0", miniLabelLeft); GUILayout.FlexibleSpace(); GUILayout.Label(Localizer.Format("#ScienceAlert_label15"), miniLabelCenter);//"Science Amount" GUILayout.FlexibleSpace(); GUILayout.Label("100", miniLabelRight); GUILayout.EndHorizontal(); GUILayout.Space(10f); List <string> list = new List <string>(experimentIds.Keys); for (int i = list.Count - 1; i >= 0; i--) { string current = list[i]; GUILayout.Space(4f); ExperimentSettings experimentSettings = ScienceAlertProfileManager.ActiveProfile[current]; string experimentTitle = ResearchAndDevelopment.GetExperiment(current).experimentTitle; GUILayout.Box(experimentTitle, GUILayout.ExpandWidth(true)); experimentSettings.Enabled = AudibleToggle(experimentSettings.Enabled, Localizer.Format("#ScienceAlert_toggle6")); //"Enabled" experimentSettings.AnimationOnDiscovery = AudibleToggle(experimentSettings.AnimationOnDiscovery, Localizer.Format("#ScienceAlert_toggle7")); //"Animation on discovery" experimentSettings.SoundOnDiscovery = AudibleToggle(experimentSettings.SoundOnDiscovery, Localizer.Format("#ScienceAlert_toggle8")); //"Sound on discovery" experimentSettings.StopWarpOnDiscovery = AudibleToggle(experimentSettings.StopWarpOnDiscovery, Localizer.Format("#ScienceAlert_toggle9")); //"Stop warp on discovery" GUILayout.Label(new GUIContent(Localizer.Format("#ScienceAlert_toggle10")), GUILayout.ExpandWidth(true), GUILayout.MinHeight(24f)); //"Filter Method" int num2 = experimentIds[current]; experimentIds[current] = AudibleSelectionGrid(num2, ref experimentSettings); } GUILayout.EndScrollView(); return; } GUI.color = Color.red; GUILayout.Label(Localizer.Format("#ScienceAlert_label16"));//"No profile active" }
/// <summary> /// Update FOV cones in the Editor, update pan/tilt in flight. /// </summary> public void Update() { if (HighLogic.LoadedSceneIsEditor) { Vector3 origin = cameraTransform.TransformPoint(Vector3.zero); Vector3 direction = cameraTransform.forward; // TODO: Renderers don't show up if the part is added. // only when a craft is loaded with camera attached. // RPM used callbacks for onattach / ondetach - maybe // they need to be used here. if (minFovRenderer != null) { minFovRenderer.enabled = showFov; minFovRenderer.SetPosition(0, origin); minFovRenderer.SetPosition(1, origin + direction * rayLength); } if (maxFovRenderer != null) { maxFovRenderer.enabled = showFov; maxFovRenderer.SetPosition(0, origin); maxFovRenderer.SetPosition(1, origin + direction * rayLength); } } if (showGui) { if (nameMenu == null) { ShowNameMenu(); } } else if (nameMenu != null) { InputLockManager.RemoveControlLock("MASCamera-UI"); nameMenu.Dismiss(); nameMenu = null; } if (HighLogic.LoadedSceneIsFlight) { if (goalFov != currentFov) { if (fovRate > 0.0f) { float fovDelta = Mathf.Min(Mathf.Abs(goalFov - currentFov), panRate * TimeWarp.deltaTime); if (goalFov > currentFov) { currentFov += fovDelta; } else { currentFov -= fovDelta; } } else { currentFov = goalFov; } } if (goalPan != currentPan) { if (panRate > 0.0f) { float panDelta = Mathf.Min(Mathf.Abs(goalPan - currentPan), panRate * TimeWarp.deltaTime); if (goalPan > currentPan) { currentPan += panDelta; } else { currentPan -= panDelta; } } else { currentPan = goalPan; } } if (goalTilt != currentTilt) { if (tiltRate > 0.0f) { float tiltDelta = Mathf.Min(Mathf.Abs(goalTilt - currentTilt), tiltRate * TimeWarp.deltaTime); if (goalTilt > currentTilt) { currentTilt += tiltDelta; } else { currentTilt -= tiltDelta; } } else { currentTilt = goalTilt; } } if (cameraLive != (renderCallback != null)) { cameraLive = (renderCallback != null); if (cameraLive) { if (cameraRentex == null) { cameraRentex = new RenderTexture(mode[activeMode].cameraResolution, mode[activeMode].cameraResolution, 24); } } else { cameraRentex.Release(); cameraRentex = null; } for (int i = cameraBody.Length - 1; i >= 0; --i) { if (cameras[i] == null) { ConstructCamera(i); } // It looks like the FXCamera can be null when the vessel being loaded isn't the current vessel // (such as when entering physics range), so we have to null-check here. if (cameras[i] != null) { cameras[i].enabled = cameraLive; cameras[i].targetTexture = cameraRentex; } } } if (cameraLive) { if (!cameraRentex.IsCreated()) { cameraRentex.Create(); } cameraRotation = cameraTransform.rotation * Quaternion.Euler(-currentTilt, currentPan, 0.0f); if (refreshRate == 1 || (frameCount % refreshRate) == 0) { renderCallback.Invoke(cameraRentex, mode[activeMode].postProcShader); cameraRentex.DiscardContents(); } ++frameCount; } } }
public void UnlockKeyboard() { InputLockManager.RemoveControlLock(lockID); }
private void OnDeselectTextInput(string s) { InputLockManager.RemoveControlLock(CONTROL_LOCK_ID); }
private void UnlockControls() { InputLockManager.RemoveControlLock(this.name); }
void ClearControlLock(string str = null) { InputLockManager.RemoveControlLock("KKValueAdjuster_lock"); }
private void OnPopupDialogDestroy() { InputLockManager.RemoveControlLock(CONTROL_LOCK_ID); }
/// <summary> /// Lock the Controls. /// </summary> private void ControlLock() { InputLockManager.SetControlLock(ControlTypes.EDITOR_LOCK | ControlTypes.EDITOR_EDIT_STAGES, "KompLog_ResViewer"); }
/// <summary> /// Unlock the Controls. /// </summary> private void ControlUnlock() { InputLockManager.RemoveControlLock("KompLog_ResViewer"); }
private static void RemoveVesselFromPlans() { InputLockManager.RemoveControlLock("KCTPopupLock"); plansList.RemoveAt(planToDelete); }
private void drawGUI() { if ((vessel == FlightGlobals.ActiveVessel) && (vessels[vessel].controller == this) && (state == PartStates.ACTIVE) && isControllable && InputLockManager.IsUnlocked(ControlTypes.THROTTLE) && !gamePaused) { if (winPos.x == 0 && winPos.y == 0) { winPos = new Rect(Screen.width / 2, Screen.height / 2, 10, 10); } GUI.skin = MuUtils.DefaultSkin; winPos = GUILayout.Window(123, winPos, WindowGUI, "Engine control", GUILayout.MinWidth(150)); } }
private static void DrawBuildPlansWindow(int id) { int butW = 20; GUILayout.BeginVertical(); if (HighLogic.LoadedSceneIsEditor) { if (EditorLogic.fetch.ship != null && EditorLogic.fetch.ship.Parts != null && EditorLogic.fetch.ship.Parts.Count > 0) { if (EditorLogic.fetch.ship.shipName == "Untitled Space Craft" || EditorLogic.fetch.ship.shipName == "") { if (GUILayout.Button("Cannot Add a Plan Without a Valid Name", GUILayout.Height(2 * 22))) { if (EditorLogic.fetch.ship.shipName == "Untitled Space Craft") { var message = new ScreenMessage("[KCT] Vessel must have a name other than 'Untitled Space Craft'.", 4.0f, ScreenMessageStyle.UPPER_CENTER); ScreenMessages.PostScreenMessage(message); } else { var message = new ScreenMessage("[KCT] Vessel must have a name", 4.0f, ScreenMessageStyle.UPPER_CENTER); ScreenMessages.PostScreenMessage(message); } } } else { GUILayout.BeginHorizontal(); if (GUILayout.Button("Add To Building Plans", GUILayout.Height(2 * 22))) { AddVesselToPlansList(); } GUILayout.EndHorizontal(); //if (!KCT_GameStates.settings.OverrideLaunchButton) { GUILayout.BeginHorizontal(); if (GUILayout.Button("Build", GUILayout.Height(2 * 22))) { KCT_Utilities.AddVesselToBuildList(); //SwitchCurrentPartCategory(); KCT_Utilities.RecalculateEditorBuildTime(EditorLogic.fetch.ship); } GUILayout.EndHorizontal(); } } } else { GUILayout.Button("No vessel available", GUILayout.Height(2 * 22)); } } GUILayout.Space(10); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); GUILayout.Label("Available Building Plans"); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); bool VABSelectedNew = GUILayout.Toggle(VABSelected, "VAB", GUI.skin.button); bool SPHSelectedNew = GUILayout.Toggle(SPHSelected, "SPH", GUI.skin.button); if (VABSelectedNew != VABSelected) { SelectList("VAB"); } else if (SPHSelectedNew != SPHSelected) { SelectList("SPH"); } GUILayout.EndHorizontal(); { switch (listWindow) { case 0: plansList = KCT_GameStates.ActiveKSC.VABPlans; break; case 1: plansList = KCT_GameStates.ActiveKSC.SPHPlans; break; } if (listWindow >= 0 && plansList != null) { GUILayout.BeginHorizontal(); // GUILayout.Space((butW + 4) * 3); GUILayout.Label("Name:"); GUILayout.EndHorizontal(); buildPlanScrollPos = GUILayout.BeginScrollView(buildPlanScrollPos, GUILayout.Height(250)); if (plansList.Count == 0) { GUILayout.Label("No vessels in plans."); } for (int i = 0; i < plansList.Count; i++) { KCT_BuildListVessel b = plansList.Values[i]; if (!b.allPartsValid) { continue; } GUILayout.BeginHorizontal(); { if (GUILayout.Button("X", redButton, GUILayout.Width(butW))) { planToDelete = i; InputLockManager.SetControlLock(ControlTypes.EDITOR_SOFT_LOCK, "KCTPopupLock"); IDSelected = b.id; DialogGUIBase[] options = new DialogGUIBase[2]; options[0] = new DialogGUIButton("Yes", RemoveVesselFromPlans); options[1] = new DialogGUIButton("No", DummyVoid); MultiOptionDialog diag = new MultiOptionDialog("scrapVesselPopup", "Are you sure you want to remove this vessel from the plans?", "Delete plan", null, options: options); PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), diag, false, HighLogic.UISkin); } if (GUILayout.Button(b.shipName)) { KCT_Utilities.AddVesselToBuildList(b.NewCopy(true)); } } GUILayout.EndHorizontal(); } GUILayout.EndScrollView(); } GUILayout.FlexibleSpace(); if (GUILayout.Button("Close")) { showBuildPlansWindow = false; } } GUILayout.EndVertical(); GUI.DragWindow(); }
void OnDestroy() { InputLockManager.ClearControlLocks(); }
private void LockControls(string lockName) { this.lockName = lockName; InputLockManager.SetControlLock(ControlTypes.ACTIONS_ALL, lockName); }
private void DrawContent(int windowID) { bool pressedEnter = (Event.current.type == EventType.KeyDown && !Event.current.shift && Event.current.character == '\n'); GUILayout.BeginVertical(); GUI.DragWindow(moveRect); GUILayout.BeginHorizontal(); DrawRooms(); GUILayout.FlexibleSpace(); if (selectedChannel != null && selectedChannel != consoleIdentifier || selectedPMChannel != null) { if (GUILayout.Button("Leave", buttonStyle)) { leaveEventHandled = false; } } DrawConsole(); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); chatScrollPos = GUILayout.BeginScrollView(chatScrollPos, scrollStyle); if (selectedChannel == null && selectedPMChannel == null) { if (!channelMessages.ContainsKey("")) { channelMessages.Add("", new List <string>()); } foreach (string channelMessage in channelMessages[""]) { GUILayout.Label(channelMessage, labelStyle); } } if (selectedChannel != null && selectedChannel != consoleIdentifier) { if (!channelMessages.ContainsKey(selectedChannel)) { channelMessages.Add(selectedChannel, new List <string>()); } foreach (string channelMessage in channelMessages[selectedChannel]) { GUILayout.Label(channelMessage, labelStyle); } } if (selectedChannel == consoleIdentifier) { foreach (string consoleMessage in consoleMessages) { GUILayout.Label(consoleMessage, labelStyle); } } if (selectedPMChannel != null) { if (!privateMessages.ContainsKey(selectedPMChannel)) { privateMessages.Add(selectedPMChannel, new List <string>()); } foreach (string privateMessage in privateMessages[selectedPMChannel]) { GUILayout.Label(privateMessage, labelStyle); } } GUILayout.EndScrollView(); playerScrollPos = GUILayout.BeginScrollView(playerScrollPos, scrollStyle, smallSizeOption); GUILayout.BeginVertical(); GUILayout.Label(Settings.fetch.playerName, labelStyle); if (selectedPMChannel != null) { GUILayout.Label(selectedPMChannel, labelStyle); } else { if (selectedChannel == null) { //Global chat foreach (PlayerStatus player in PlayerStatusWorker.fetch.playerStatusList) { if (joinedPMChannels.Contains(player.playerName)) { GUI.enabled = false; } if (GUILayout.Button(player.playerName, labelStyle)) { if (!joinedPMChannels.Contains(player.playerName)) { joinedPMChannels.Add(player.playerName); } } GUI.enabled = true; } } else { foreach (KeyValuePair <string, List <string> > playerEntry in playerChannels) { if (playerEntry.Key != Settings.fetch.playerName) { if (playerEntry.Value.Contains(selectedChannel)) { if (joinedPMChannels.Contains(playerEntry.Key)) { GUI.enabled = false; } if (GUILayout.Button(playerEntry.Key, labelStyle)) { if (!joinedPMChannels.Contains(playerEntry.Key)) { joinedPMChannels.Add(playerEntry.Key); } } GUI.enabled = true; } } } } } GUILayout.EndVertical(); GUILayout.EndScrollView(); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUI.SetNextControlName("SendTextArea"); string tempSendText = GUILayout.TextArea(sendText, textAreaStyle); //When a control is inserted or removed from the GUI, Unity's focusing starts tripping balls. This is a horrible workaround for unity that shouldn't exist... int newTextID = GUIUtility.GetControlID(FocusType.Keyboard); if (previousTextID != newTextID) { previousTextID = newTextID; if (chatLocked) { selectTextBox = true; } } //Don't add the newline to the messages, queue a send if (!ignoreChatInput) { if (pressedEnter) { sendEventHandled = false; } else { sendText = tempSendText; } } if (sendText == "") { GUI.enabled = false; } if (GUILayout.Button("Send", buttonStyle, smallSizeOption)) { sendEventHandled = false; } GUI.enabled = true; GUILayout.EndHorizontal(); GUILayout.EndVertical(); if (!selectTextBox) { if ((GUI.GetNameOfFocusedControl() == "SendTextArea") && !chatLocked) { chatLocked = true; InputLockManager.SetControlLock(DMPGuiUtil.BLOCK_ALL_CONTROLS, DMP_CHAT_LOCK); } if ((GUI.GetNameOfFocusedControl() != "SendTextArea") && chatLocked) { chatLocked = false; InputLockManager.RemoveControlLock(DMP_CHAT_LOCK); } } else { selectTextBox = false; GUI.FocusControl("SendTextArea"); } }
/** * Returns whether staging is locked (disabled). */ public bool ButtonStageLockState() { return(InputLockManager.IsLocked(ControlTypes.STAGING)); }
void SetControlLock(string str = null) { InputLockManager.SetControlLock("KKValueAdjuster_lock"); }
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(); }
private IEnumerator QStart() { while (!Ready || !QuickStart_Persistent.Ready) { yield return(0); } yield return(new WaitForEndOfFrame()); yield return(new WaitForSecondsRealtime(QSettings.Instance.WaitLoading)); yield return(new WaitForEndOfFrame()); QuickStart.Log("SpaceCenter Loaded", "QSpaceCenter"); if (QSettings.Instance.gameScene == (int)GameScenes.FLIGHT) { string _saveGame = GamePersistence.SaveGame(HighLogic.CurrentGame, QSaveGame.File, HighLogic.SaveFolder, SaveMode.OVERWRITE); if (!string.IsNullOrEmpty(QuickStart_Persistent.vesselID)) { int _idx = HighLogic.CurrentGame.flightState.protoVessels.FindLastIndex(pv => pv.vesselID == QuickStart_Persistent.VesselID); if (_idx != -1) { QuickStart.Log(string.Format("StartAndFocusVessel: {0}({1})[{2}] idx: {3}", QSaveGame.vesselName, QSaveGame.vesselType, QuickStart_Persistent.vesselID, _idx), "QSpaceCenter"); FlightDriver.StartAndFocusVessel(_saveGame, _idx); } else { QuickStart.Warning("QStart: invalid idx", "QSpaceCenter"); DestroyThis(); } } else { QuickStart.Warning("QStart: No vessel found", "QSpaceCenter"); DestroyThis(); } } if (QSettings.Instance.gameScene == (int)GameScenes.TRACKSTATION) { HighLogic.LoadScene(GameScenes.LOADINGBUFFER); HighLogic.LoadScene(GameScenes.TRACKSTATION); InputLockManager.ClearControlLocks(); QuickStart.Log("Goto Tracking Station", "QSpaceCenter"); DestroyThis(); } if (QSettings.Instance.gameScene == (int)GameScenes.EDITOR) { if (QSettings.Instance.enableEditorLoadAutoSave && File.Exists(QuickStart_Persistent.shipPath)) { EditorDriver.StartAndLoadVessel(QuickStart_Persistent.shipPath, (EditorFacility)QSettings.Instance.editorFacility); QuickStart.Log("StartAndLoadVessel: " + QuickStart_Persistent.shipPath, "QSpaceCenter"); } else { EditorDriver.StartupBehaviour = EditorDriver.StartupBehaviours.START_CLEAN; EditorDriver.StartEditor((EditorFacility)QSettings.Instance.editorFacility); QuickStart.Log("StartEditor", "QSpaceCenter"); } InputLockManager.ClearControlLocks(); QuickStart.Log("Goto " + (QSettings.Instance.editorFacility == (int)EditorFacility.VAB ? "Vehicle Assembly Building" : "Space Plane Hangar"), "QSpaceCenter"); DestroyThis(); } Destroy(this); yield break; }
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; }
private void OnSelectTextInput(string s) { InputLockManager.SetControlLock(ControlTypes.EDITOR_GIZMO_TOOLS | ControlTypes.EDITOR_ROOT_REFLOW, CONTROL_LOCK_ID); }
void DrawSettings(int id) { Debug.Log("DrawSettings 1"); GUILayout.BeginVertical(); if (QFlight.data.PostInitStateIsSaved) { if (QFlight.data.VesselExists) { GUILayout.BeginHorizontal(); GUILayout.Box("Revert Saved", GUILayout.Height(30)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label(Localizer.Format("quickrevert_revertLastV", QFlight.data.pVessel.vesselType, QFlight.data.pVessel.vesselName), GUILayout.Width(400)); Debug.Log("DrawSettings 2"); // GUILayout.FlexibleSpace (); if (GUILayout.Button(Localizer.Format("quickrevert_loseIt"))) { QFlight.data.Reset(); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); Debug.Log("DrawSettings 3"); // GUILayout.FlexibleSpace (); if (GUILayout.Button(Localizer.Format("quickrevert_gotoV"))) { Settings(); string _saveGame = GamePersistence.SaveGame("persistent", HighLogic.SaveFolder, SaveMode.OVERWRITE); FlightDriver.StartAndFocusVessel(_saveGame, QFlight.data.currentActiveVesselIdx); InputLockManager.ClearControlLocks(); } GUILayout.EndHorizontal(); GUILayout.Space(5); if (!QFlight.data.PreLaunchStateIsSaved) { GUILayout.BeginHorizontal(); GUILayout.Label(Localizer.Format("quickrevert_onlyRevertLaunch"), GUILayout.Width(500)); GUILayout.EndHorizontal(); } } } GUILayout.BeginHorizontal(); GUILayout.Box("Options", GUILayout.Height(30)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); QSettings.Instance.EnableRevertLoss = GUILayout.Toggle(QSettings.Instance.EnableRevertLoss, Planetarium.fetch.Home.atmosphere ? Localizer.Format("quickrevert_revertLossAtm") : Localizer.Format("quickrevert_revertLossSOI"), GUILayout.Width(450)); GUILayout.EndHorizontal(); Debug.Log("DrawSettings 4"); // GUILayout.FlexibleSpace (); GUILayout.BeginHorizontal(); Debug.Log("DrawSettings 5"); // GUILayout.FlexibleSpace (); if (GUILayout.Button(Localizer.Format("quickrevert_close"), GUILayout.Height(30))) { Settings(); } GUILayout.EndHorizontal(); GUILayout.EndVertical(); Debug.Log("DrawSettings 6"); }
private ControlTypes LockControls() { return(InputLockManager.SetControlLock((ControlTypes)lockMask, this.name)); }
void DrawSettings(int id) { GUILayout.BeginVertical(); if (QFlight.data.PostInitStateIsSaved) { if (QFlight.data.VesselExists) { GUILayout.BeginHorizontal(); GUILayout.Box("Revert Saved", GUILayout.Height(30)); GUILayout.EndHorizontal(); GUILayout.Space(5); GUILayout.BeginHorizontal(); GUILayout.Label(string.Format("Revert of the last Vessel saved: <color=#FFFFFF><b>({0}){1}</b></color>", QFlight.data.pVessel.vesselType, QFlight.data.pVessel.vesselName), GUILayout.Width(400)); GUILayout.FlexibleSpace(); if (GUILayout.Button("Lose it")) { QFlight.data.Reset(); } GUILayout.EndHorizontal(); GUILayout.Space(5); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Goto this vessel")) { Settings(); string _saveGame = GamePersistence.SaveGame("persistent", HighLogic.SaveFolder, SaveMode.OVERWRITE); FlightDriver.StartAndFocusVessel(_saveGame, QFlight.data.currentActiveVesselIdx); InputLockManager.ClearControlLocks(); } GUILayout.EndHorizontal(); GUILayout.Space(5); if (!QFlight.data.PreLaunchStateIsSaved) { GUILayout.BeginHorizontal(); GUILayout.Label("<color=#FF0000><b>Only the revert to launch is saved!</b></color>", GUILayout.Width(500)); GUILayout.EndHorizontal(); GUILayout.Space(5); } } } GUILayout.BeginHorizontal(); GUILayout.Box("Options", GUILayout.Height(30)); GUILayout.EndHorizontal(); GUILayout.Space(5); GUILayout.BeginHorizontal(); QSettings.Instance.EnableRevertLoss = GUILayout.Toggle(QSettings.Instance.EnableRevertLoss, "Enable the revert loss when you escape " + (Planetarium.fetch.Home.atmosphere ? "atmosphere" : "sphere of influence"), GUILayout.Width(250)); GUILayout.EndHorizontal(); GUILayout.Space(5); GUILayout.BeginHorizontal(); QSettings.Instance.StockToolBar = GUILayout.Toggle(QSettings.Instance.StockToolBar, "Use the Stock ToolBar", GUILayout.Width(250)); if (QBlizzyToolbar.isAvailable) { QSettings.Instance.BlizzyToolBar = GUILayout.Toggle(QSettings.Instance.BlizzyToolBar, "Use the Blizzy ToolBar", GUILayout.Width(250)); } GUILayout.EndHorizontal(); GUILayout.Space(5); GUILayout.BeginHorizontal(); if (GUILayout.Button("Close and Save", GUILayout.Height(30))) { Settings(); } GUILayout.EndHorizontal(); GUILayout.Space(5); GUILayout.EndVertical(); }
public static void ClearLocks() { // remove control locks InputLockManager.RemoveControlLock("eva_dead_lock"); InputLockManager.RemoveControlLock("no_signal_lock"); }
public void LockControls() { InputLockManager.SetControlLock(ControlTypes.ALL_SHIP_CONTROLS, lockID); }
public void LockKeyboard() { InputLockManager.SetControlLock(ControlTypes.ACTIONS_ALL, lockID); }
public void UnlockControls() { InputLockManager.RemoveControlLock(lockID); }
private ControlTypes LockControls() { return(InputLockManager.SetControlLock(ControlTypes.ALLBUTTARGETING, this.name)); }
private void Update() { safeDisplay = display; ignoreChatInput = false; if (chatButtonHighlighted && display) { chatButtonHighlighted = false; } if (chatLocked && !display) { chatLocked = false; InputLockManager.RemoveControlLock(DMP_CHAT_LOCK); } if (workerEnabled) { //Handle leave event if (!leaveEventHandled) { if (selectedChannel != null) { using (MessageWriter mw = new MessageWriter()) { mw.Write <int>((int)ChatMessageType.LEAVE); mw.Write <string>(Settings.fetch.playerName); mw.Write <string>(selectedChannel); NetworkWorker.fetch.SendChatMessage(mw.GetMessageBytes()); } if (joinedChannels.Contains(selectedChannel)) { joinedChannels.Remove(selectedChannel); } selectedChannel = null; selectedPMChannel = null; } if (selectedPMChannel != null) { if (joinedPMChannels.Contains(selectedPMChannel)) { joinedPMChannels.Remove(selectedPMChannel); } selectedChannel = null; selectedPMChannel = null; } leaveEventHandled = true; } //Handle send event if (!sendEventHandled) { if (sendText != "") { if (!sendText.StartsWith("/") || sendText.StartsWith("//")) { if (sendText.StartsWith("//")) { sendText = sendText.Substring(1); } if (selectedChannel == null && selectedPMChannel == null) { //Sending a global chat message using (MessageWriter mw = new MessageWriter()) { mw.Write <int>((int)ChatMessageType.CHANNEL_MESSAGE); mw.Write <string>(Settings.fetch.playerName); //Global channel name is empty string. mw.Write <string>(""); mw.Write <string>(sendText); NetworkWorker.fetch.SendChatMessage(mw.GetMessageBytes()); } } if (selectedChannel != null) { using (MessageWriter mw = new MessageWriter()) { mw.Write <int>((int)ChatMessageType.CHANNEL_MESSAGE); mw.Write <string>(Settings.fetch.playerName); mw.Write <string>(selectedChannel); mw.Write <string>(sendText); NetworkWorker.fetch.SendChatMessage(mw.GetMessageBytes()); } } if (selectedPMChannel != null) { using (MessageWriter mw = new MessageWriter()) { mw.Write <int>((int)ChatMessageType.PRIVATE_MESSAGE); mw.Write <string>(Settings.fetch.playerName); mw.Write <string>(selectedPMChannel); mw.Write <string>(sendText); NetworkWorker.fetch.SendChatMessage(mw.GetMessageBytes()); } } } else { //Handle command if (sendText.StartsWith("/join ") && sendText.Length > 7) { string channelName = sendText.Substring(6); if (channelName != "" || channelName != "Global") { DarkLog.Debug("Joining channel " + channelName); joinedChannels.Add(channelName); selectedChannel = channelName; selectedPMChannel = null; using (MessageWriter mw = new MessageWriter()) { mw.Write <int>((int)ChatMessageType.JOIN); mw.Write <string>(Settings.fetch.playerName); mw.Write <string>(channelName); NetworkWorker.fetch.SendChatMessage(mw.GetMessageBytes()); } } else { ScreenMessages.PostScreenMessage("Couln't join '" + channelName + "', channel name not valid!", 5f, ScreenMessageStyle.UPPER_CENTER); } } if (sendText.StartsWith("/query ") && sendText.Length > 8) { string playerName = sendText.Substring(7); bool playerFound = false; if (playerName != consoleIdentifier) { foreach (PlayerStatus ps in PlayerStatusWorker.fetch.playerStatusList) { if (ps.playerName == playerName) { playerFound = true; } } } else { //Make sure we can always query the server. playerFound = true; } if (playerFound) { DarkLog.Debug("Starting query with " + playerName); joinedPMChannels.Add(playerName); selectedChannel = null; selectedPMChannel = playerName; } else { DarkLog.Debug("Couln't start query with '" + playerName + "', player not found!"); ScreenMessages.PostScreenMessage("Couln't start query with '" + playerName + "', player not found!", 5f, ScreenMessageStyle.UPPER_CENTER); } } if (sendText == "/part" || sendText == "/leave") { leaveEventHandled = false; } if (sendText == "/ping") { NetworkWorker.fetch.SendPingRequest(); } if (sendText == "/motd") { NetworkWorker.fetch.SendMotdRequest(); } } } sendText = ""; sendEventHandled = true; } //Handle join messages while (newJoinMessages.Count > 0) { JoinLeaveMessage jlm = newJoinMessages.Dequeue(); if (!playerChannels.ContainsKey(jlm.fromPlayer)) { playerChannels.Add(jlm.fromPlayer, new List <string>()); } if (!playerChannels[jlm.fromPlayer].Contains(jlm.channel)) { playerChannels[jlm.fromPlayer].Add(jlm.channel); } } //Handle leave messages while (newLeaveMessages.Count > 0) { JoinLeaveMessage jlm = newLeaveMessages.Dequeue(); if (playerChannels.ContainsKey(jlm.fromPlayer)) { if (playerChannels[jlm.fromPlayer].Contains(jlm.channel)) { playerChannels[jlm.fromPlayer].Remove(jlm.channel); } if (playerChannels[jlm.fromPlayer].Count == 0) { playerChannels.Remove(jlm.fromPlayer); } } } //Handle channel messages while (newChannelMessages.Count > 0) { ChannelEntry ce = newChannelMessages.Dequeue(); if (!channelMessages.ContainsKey(ce.channel)) { channelMessages.Add(ce.channel, new List <string>()); } //Highlight if the channel isn't selected. if (selectedChannel != null && ce.channel == "") { if (!highlightChannel.Contains(ce.channel)) { highlightChannel.Add(ce.channel); } } if (ce.channel != selectedChannel && ce.channel != "") { if (!highlightChannel.Contains(ce.channel)) { highlightChannel.Add(ce.channel); } } //Move the bar to the bottom on a new message if (selectedChannel == null && selectedPMChannel == null && ce.channel == "") { chatScrollPos.y = float.PositiveInfinity; } if (selectedChannel != null && selectedPMChannel == null && ce.channel == selectedChannel) { chatScrollPos.y = float.PositiveInfinity; } channelMessages[ce.channel].Add(ce.fromPlayer + ": " + ce.message); } //Handle private messages while (newPrivateMessages.Count > 0) { PrivateEntry pe = newPrivateMessages.Dequeue(); if (pe.fromPlayer != Settings.fetch.playerName) { if (!privateMessages.ContainsKey(pe.fromPlayer)) { privateMessages.Add(pe.fromPlayer, new List <string>()); } //Highlight if the player isn't selected if (!joinedPMChannels.Contains(pe.fromPlayer)) { joinedPMChannels.Add(pe.fromPlayer); } if (selectedPMChannel != pe.fromPlayer) { if (!highlightPM.Contains(pe.fromPlayer)) { highlightPM.Add(pe.fromPlayer); } } } //Move the bar to the bottom on a new message if (selectedPMChannel != null && selectedChannel == null && (pe.fromPlayer == selectedPMChannel || pe.fromPlayer == Settings.fetch.playerName)) { chatScrollPos.y = float.PositiveInfinity; } if (pe.fromPlayer != Settings.fetch.playerName) { privateMessages[pe.fromPlayer].Add(pe.fromPlayer + ": " + pe.message); } else { privateMessages[pe.toPlayer].Add(pe.fromPlayer + ": " + pe.message); } } while (disconnectingPlayers.Count > 0) { string disconnectingPlayer = disconnectingPlayers.Dequeue(); if (playerChannels.ContainsKey(disconnectingPlayer)) { playerChannels.Remove(disconnectingPlayer); } if (joinedPMChannels.Contains(disconnectingPlayer)) { joinedPMChannels.Remove(disconnectingPlayer); } if (highlightPM.Contains(disconnectingPlayer)) { highlightPM.Remove(disconnectingPlayer); } if (privateMessages.ContainsKey(disconnectingPlayer)) { privateMessages.Remove(disconnectingPlayer); } } } }