/// <summary> /// Stop playing any files. /// </summary> /// <param name="now">Whether to stop instantly or perform FadeOutOnChange if enabled.</param> public ContinuousAction StopPlayingAll(bool now = false) { ContinuousAction thisAction = new ContinuousAction(); void StopPlayingAllInternal() { Debugger.Log(MessageType.Info, MessageSource.SoundManager, $"Stopped {ToString()}."); // Stop playback, clear played buffer. AL.Source(_pointer, ALSourceb.Looping, false); AL.SourceStop(_pointer); // Remove played buffers. RemovePlayed(); Status = SoundStatus.Stopped; Helpers.CheckErrorAL("stopping"); // Reset tracker variables. PerformReset(); thisAction.Done(); } if (FadeOutOnChange && !now) { SetupForceFadeOut(StopPlayingAllInternal); } else { ALThread.ExecuteALThread(StopPlayingAllInternal); } return(thisAction); }
/// <summary> /// Play a file on the layer. If any previous file is playing it will be stopped. /// </summary> /// <param name="file">The file to play.</param> public ContinuousAction Play(SoundFile file) { ContinuousAction thisAction = new ContinuousAction(); void PlayInternal() { // Stop whatever was playing before. StopPlayingAll(true); // Queue the file. AL.SourceQueueBuffer(_pointer, file.Pointer); _playList.Add(file); Helpers.CheckErrorAL($"queuing single in source {_pointer}"); // Play it. AL.SourcePlay(_pointer); Status = SoundStatus.Playing; Helpers.CheckErrorAL($"playing single in source {_pointer}"); Debugger.Log(MessageType.Info, MessageSource.SoundManager, $"Started playing [{file.Name}] on {ToString()}."); thisAction.Done(); } // Check if forcing a fade out. if (FadeOutOnChange) { SetupForceFadeOut(PlayInternal); } else { ALThread.ExecuteALThread(PlayInternal); } return(thisAction); }
public void SetContinuousBindingInverted(ContinuousAction action, bool isInverted) { if (continuousActionsMap.ContainsKey(action)) { continuousActionsMap[action].Inverted = isInverted; } }
} // Required for XML serialization public ContinuousActionEntry(ContinuousAction action, Bitset bitset, int axis, bool inverted) { this.Action = action; this.Bitset = bitset; this.Axis = axis; this.Inverted = inverted; }
public KeyValuePair <int, Bitset> GetBitsetForContinuousBinding(ContinuousAction action) { if (!continuousActionsMap.ContainsKey(action)) { return(new KeyValuePair <int, Bitset>(0, null)); } return(new KeyValuePair <int, Bitset>(continuousActionsMap[action].Value, continuousActionsMap[action].Key)); }
private static void HandleContinuousAction(PlanetEconomy PE, ContinuousAction CA, float efficiency) { bool low_eff = (efficiency < CA.critical_efficiency); foreach (ElementaryAction EA in CA.el_actions) { GetElementaryAction(PE, EA, efficiency, low_eff, false); } }
public void SetContinuousBinding(int axis, Bitset state, ContinuousAction action, bool isInverted) { //Debug.Log("SetContBind: " + action.ToString() + " to axis " + axis + " and bitset " + state.ToString()); continuousActionsMap[action] = new KeyValuePair <Bitset, int>(state, axis); if (isInverted) { continuousActionsInvMap[action] = true; } //TODO: Remove from map if false and containsKey? Saves a little space when serializing. }
public KeyValuePair <int, Bitset> GetBitsetForContinuousBinding(ContinuousAction action) { if (!continuousActionsMap.ContainsKey(action)) { return(new KeyValuePair <int, Bitset>(0, null)); } var entry = continuousActionsMap[action]; return(new KeyValuePair <int, Bitset>(entry.Axis, entry.Bitset)); }
public void DoChooseContinuousActionWindow(int window) { if (!m_ChooseContinuousAction) { return; } var currentPreset = m_Controller.GetCurrentPreset(); if (GUILayout.Button("Cancel")) { m_ChooseContinuousAction = false; return; } m_ChooseContinuousActionScroll = GUILayout.BeginScrollView(m_ChooseContinuousActionScroll); foreach (var action in (ContinuousAction[])Enum.GetValues(typeof(ContinuousAction))) { if (action == ContinuousAction.None) { continue; } var axisBitsetPair = currentPreset.GetBitsetForContinuousBinding(action); if (axisBitsetPair.Value != null) { continue; } if (GUILayout.Button(Stringify.ContinuousActionToString(action))) { m_ChosenContinuousAction = action; m_ChooseContinuousAction = false; m_CurrentlyEditingContinuousAction = action; m_ClickSleepTimer = 0.25f; for (int i = 0; i < m_Controller.iface.GetAxesCount(); i++) { axisSnapshot[i] = m_Controller.iface.GetAxisState(i); } } } GUILayout.EndScrollView(); }
/// <summary> /// Queue a file to be played on the layer. /// </summary> /// <param name="file"></param> public ContinuousAction QueuePlay(SoundFile file) { ContinuousAction thisAction = new ContinuousAction(); void QueuePlayInternal() { Debugger.Log(MessageType.Info, MessageSource.SoundManager, $"Queued [{file.Name}] on {ToString()}."); // If playback is over but stop wasn't called then cleanup needs to be performed. if (Status == SoundStatus.Stopped) { PerformReset(); } AL.SourceQueueBuffer(_pointer, file.Pointer); _playList.Add(file); Helpers.CheckErrorAL($"queuing in source {_pointer}"); // Play if not playing. if (Status != SoundStatus.Stopped) { return; } AL.SourcePlay(_pointer); Status = SoundStatus.Playing; Helpers.CheckErrorAL($"playing source {_pointer}"); Debugger.Log(MessageType.Info, MessageSource.SoundManager, $"Started playing [{file.Name}] on {ToString()}."); thisAction.Done(); } if (FadeOutOnChange) { SetupForceFadeOut(QueuePlayInternal); } else { ALThread.ExecuteALThread(QueuePlayInternal); } return(thisAction); }
/// <summary> /// Destroy the layer freeing resources. /// </summary> public ContinuousAction Dispose() { ContinuousAction thisAction = new ContinuousAction(); ALThread.ExecuteALThread(() => { Debugger.Log(MessageType.Info, MessageSource.SoundManager, $"Destroyed {ToString()}."); StopPlayingAll(true); AL.DeleteSource(_pointer); Helpers.CheckErrorAL($"cleanup of source {_pointer}"); _pointer = -1; _playList.Clear(); thisAction.Done(); }); return(thisAction); }
public void AddIndependent(ContinuousAction action, float period, float startAfter = 0.0f) { continuousActions.Add(new ContinuousActionInfo(action, period, startAfter)); }
public void SetContinuousBinding(int axis, Bitset state, ContinuousAction action) { continuousActionsMap[action] = new KeyValuePair<Bitset, int>(state, axis); }
/// <summary> /// Instantiates object /// </summary> /// <param name="action">Action to perform</param> /// <param name="period">Duration of action performing</param> /// <param name="startAfter">Delay before action performing</param> public ContinuousActionInfo(ContinuousAction action, float period, float startAfter = 0.0f) { this.Action = action; this.StartAfter = startAfter; this.Period = period; }
public virtual void DoWindow(int window) { GUI.DragWindow(new Rect(0, 0, 10000, 20)); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("X", GUILayout.Height(16)) || m_Controller == null || m_Controller.iface == null) { shouldBeDestroyed = true; if (m_Controller != null) { m_Controller.presetEditorOpen = false; AdvancedFlyByWire.Instance.SaveState(null); } return; } GUILayout.EndHorizontal(); var currentPreset = m_Controller.GetCurrentPreset(); GUILayout.BeginHorizontal(); GUILayout.Label("Preset: "); currentPreset.name = GUILayout.TextField(currentPreset.name, GUILayout.Width(256)); if (m_Controller.currentPreset > 0) { if (GUILayout.Button("<")) { m_Controller.currentPreset--; } } else { GUI.enabled = false; GUILayout.Button("<"); GUI.enabled = true; } if (m_Controller.currentPreset < m_Controller.presets.Count - 1) { if (GUILayout.Button(">")) { m_Controller.currentPreset++; } } else { GUI.enabled = false; GUILayout.Button(">"); GUI.enabled = true; } if (GUILayout.Button("New")) { m_Controller.presets.Add(new ControllerPreset()); m_Controller.currentPreset = m_Controller.presets.Count - 1; } string destructiveRemoveLabel = "Delete"; if (m_DestructiveActionWait) { destructiveRemoveLabel = "Sure?"; } if (m_Controller.presets.Count <= 1 || m_Controller.currentPreset == 0) { GUI.enabled = false; } if (GUILayout.Button(destructiveRemoveLabel)) { if(m_DestructiveActionWait) { if(m_Controller.presets.Count > 1) { m_Controller.presets.RemoveAt(m_Controller.currentPreset); m_Controller.currentPreset--; if (m_Controller.currentPreset < 0) { m_Controller.currentPreset = 0; } m_DestructiveActionWait = false; m_DestructiveActionTimer = 0.0f; } } else { m_DestructiveActionWait = true; m_DestructiveActionTimer = 2.0f; } } GUI.enabled = true; GUILayout.EndHorizontal(); m_ScrollPosition = GUILayout.BeginScrollView(m_ScrollPosition); GUILayout.Label("Continuous actions"); foreach (var action in (ContinuousAction[])Enum.GetValues(typeof(ContinuousAction))) { if (action == ContinuousAction.None) { continue; } GUILayout.BeginHorizontal(); GUILayout.Label(Stringify.ContinuousActionToString(action)); GUILayout.FlexibleSpace(); string label = ""; var axisBitsetPair = currentPreset.GetBitsetForContinuousBinding(action); if (m_CurrentlyEditingContinuousAction == action) { label = "Press desired combination"; var buttonsMask = m_Controller.iface.GetButtonsMask(); for (int i = 0; i < m_Controller.iface.GetAxesCount(); i++) { if (Math.Abs(m_Controller.iface.GetAxisState(i) - axisSnapshot[i]) > 0.1 && m_ClickSleepTimer == 0.0f) { currentPreset.SetContinuousBinding(i, buttonsMask, action, false); m_CurrentlyEditingContinuousAction = ContinuousAction.None; } } } axisBitsetPair = currentPreset.GetBitsetForContinuousBinding(action); if (m_CurrentlyEditingContinuousAction != action) { if (axisBitsetPair.Value == null) { label = "Click to assign"; } else { label = m_Controller.iface.ConvertMaskToName(axisBitsetPair.Value, true, axisBitsetPair.Key); } } if (GUILayout.Button(label, GUILayout.Width(220))) { if (m_CurrentlyEditingContinuousAction != action) { m_CurrentlyEditingContinuousAction = action; m_CurrentlyEditingDiscreteAction = DiscreteAction.None; m_ClickSleepTimer = 0.25f; for (int i = 0; i < m_Controller.iface.GetAxesCount(); i++) { axisSnapshot[i] = m_Controller.iface.GetAxisState(i); } } m_CurrentMask = null; } GUILayout.Space(8); var inverted = GUILayout.Toggle(currentPreset.IsContinuousBindingInverted(action), ""); currentPreset.SetContinuousBindingInverted(action, inverted); GUILayout.Label("Invert"); GUILayout.Space(8); if (GUILayout.Button("X")) { currentPreset.UnsetContinuousBinding(action); m_CurrentlyEditingContinuousAction = ContinuousAction.None; m_CurrentlyEditingDiscreteAction = DiscreteAction.None; } GUILayout.EndHorizontal(); } GUILayout.Label("Discrete actions"); foreach (var action in (DiscreteAction[])Enum.GetValues(typeof(DiscreteAction))) { if (action == DiscreteAction.None) { continue; } GUILayout.BeginHorizontal(); GUILayout.Label(Stringify.DiscreteActionToString(action)); GUILayout.FlexibleSpace(); string label = ""; var bitset = currentPreset.GetBitsetForDiscreteBinding(action); if (m_CurrentlyEditingDiscreteAction == action) { label = "Press desired combination"; if (m_CurrentMask != null && m_ClickSleepTimer == 0.0f) { currentPreset.SetDiscreteBinding(m_CurrentMask, action); m_CurrentMask = null; m_CurrentlyEditingDiscreteAction = DiscreteAction.None; } } bitset = currentPreset.GetBitsetForDiscreteBinding(action); if (m_CurrentlyEditingDiscreteAction != action) { if (bitset == null) { label = "Click to assign"; } else { label = m_Controller.iface.ConvertMaskToName(bitset); } } if (GUILayout.Button(label, GUILayout.Width(256))) { if (m_CurrentlyEditingDiscreteAction != action) { m_CurrentlyEditingDiscreteAction = action; m_CurrentlyEditingContinuousAction = ContinuousAction.None; m_ClickSleepTimer = 0.25f; } m_CurrentMask = null; } if (GUILayout.Button("X")) { currentPreset.UnsetDiscreteBinding(action); m_CurrentlyEditingContinuousAction = ContinuousAction.None; m_CurrentlyEditingDiscreteAction = DiscreteAction.None; } GUILayout.EndHorizontal(); } GUILayout.EndScrollView(); }
public void EvaluateContinuousAction(ControllerConfiguration controller, ContinuousAction action, float value, FlightCtrlState state) { switch (action) { case ContinuousAction.None: return; case ContinuousAction.Yaw: m_Yaw.SetValue(value); return; case ContinuousAction.NegativeYaw: m_Yaw.SetValue(-value); return; case ContinuousAction.YawTrim: m_Yaw.SetTrim(Utility.Clamp(m_Yaw.GetTrim() + controller.incrementalActionSensitivity * value * Time.deltaTime, -1.0f, 1.0f)); return; case ContinuousAction.Pitch: m_Pitch.SetValue(value); return; case ContinuousAction.NegativePitch: m_Pitch.SetValue(-value); return; case ContinuousAction.PitchTrim: m_Pitch.SetTrim(Utility.Clamp(m_Pitch.GetTrim() + controller.incrementalActionSensitivity * value * Time.deltaTime, -1.0f, 1.0f)); return; case ContinuousAction.Roll: m_Roll.SetValue(value); return; case ContinuousAction.NegativeRoll: m_Roll.SetValue(-value); return; case ContinuousAction.RollTrim: m_Roll.SetTrim(Utility.Clamp(m_Roll.GetTrim() + controller.incrementalActionSensitivity * value * Time.deltaTime, -1.0f, 1.0f)); return; case ContinuousAction.X: m_X.SetValue(value); return; case ContinuousAction.NegativeX: m_X.SetValue(-value); return; case ContinuousAction.Y: m_Y.SetValue(value); return; case ContinuousAction.NegativeY: m_Y.SetValue(-value); return; case ContinuousAction.Z: m_Z.SetValue(value); return; case ContinuousAction.NegativeZ: m_Z.SetValue(-value); return; case ContinuousAction.Throttle: m_Throttle.SetMinMaxValues(-state.mainThrottle, 1.0f - state.mainThrottle); m_Throttle.SetValue(value - state.mainThrottle); return; case ContinuousAction.ThrottleIncrement: m_Throttle.Increment(value * controller.incrementalActionSensitivity * Time.deltaTime); return; case ContinuousAction.ThrottleDecrement: m_Throttle.Increment(-value * controller.incrementalActionSensitivity * Time.deltaTime); return; case ContinuousAction.WheelThrottle: m_WheelThrottle.SetMinMaxValues(-1.0f, 1.0f); m_WheelThrottle.SetValue(value); return; case ContinuousAction.WheelSteer: m_WheelSteer.SetValue(value); return; case ContinuousAction.WheelThrottleTrim: m_WheelThrottle.SetTrim(Utility.Clamp(m_WheelThrottle.GetTrim() + value * controller.incrementalActionSensitivity * Time.deltaTime, -1.0f, 1.0f)); return; case ContinuousAction.WheelSteerTrim: m_WheelSteer.SetTrim(Utility.Clamp(m_WheelSteer.GetTrim() + value * controller.incrementalActionSensitivity * Time.deltaTime, -1.0f, 1.0f)); return; case ContinuousAction.CameraX: m_CameraHeading.Increment(value); return; case ContinuousAction.CameraY: m_CameraPitch.Increment(value); return; case ContinuousAction.CameraZoom: m_CameraZoom.Increment(value); return; } }
public void SetContinuousBindingInverted(ContinuousAction action, bool isInverted) { continuousActionsInvMap[action] = isInverted; }
public void SetContinuousBinding(int axis, Bitset state, ContinuousAction action) { continuousActionsMap[action] = new KeyValuePair <Bitset, int>(state, axis); }
public void SetContinuousBinding(int axis, Bitset state, ContinuousAction action, bool isInverted) { continuousActionsMap[action] = new ContinuousActionEntry(action, state, axis, isInverted); }
public void SetContinuousBinding(int axis, Bitset state, ContinuousAction action, bool isInverted) { //Debug.Log("SetContBind: " + action.ToString() + " to axis " + axis + " and bitset " + state.ToString()); continuousActionsMap[action] = new KeyValuePair<Bitset, int>(state, axis); if (isInverted) { continuousActionsInvMap[action] = true; } //TODO: Remove from map if false and containsKey? Saves a little space when serializing. }
public bool IsContinuousBindingInverted(ContinuousAction action) { return continuousActionsInvMap.ContainsKey(action) ? continuousActionsInvMap[action] : false; }
public KeyValuePair<int, Bitset> GetBitsetForContinuousBinding(ContinuousAction action) { if(!continuousActionsMap.ContainsKey(action)) { return new KeyValuePair<int, Bitset>(0, null); } return new KeyValuePair<int,Bitset>(continuousActionsMap[action].Value, continuousActionsMap[action].Key); }
public override void DoWindow(int window) { GUI.DragWindow(new Rect(0, 0, 10000, 20)); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("X", GUILayout.Height(16)) || m_Controller == null || m_Controller.iface == null) { shouldBeDestroyed = true; if (m_Controller != null) { m_Controller.presetEditorOpen = false; AdvancedFlyByWire.Instance.SaveState(null); } GUILayout.EndHorizontal(); return; } GUILayout.EndHorizontal(); var currentPreset = m_Controller.GetCurrentPreset(); GUILayout.BeginHorizontal(); GUILayout.Label("Preset: "); currentPreset.name = GUILayout.TextField(currentPreset.name, GUILayout.Width(256)); if (m_Controller.currentPreset > 0) { if (GUILayout.Button("<")) { m_Controller.currentPreset--; } } else { GUI.enabled = false; GUILayout.Button("<"); GUI.enabled = true; } if (m_Controller.currentPreset < m_Controller.presets.Count - 1) { if (GUILayout.Button(">")) { m_Controller.currentPreset++; } } else { GUI.enabled = false; GUILayout.Button(">"); GUI.enabled = true; } if (GUILayout.Button("New")) { m_Controller.presets.Add(new ControllerPreset()); m_Controller.currentPreset = m_Controller.presets.Count - 1; } if (GUILayout.Button("Clone")) { var preset = m_Controller.presets[m_Controller.currentPreset]; var newPreset = new ControllerPreset(); foreach (var pair in preset.continuousActionsMap) { newPreset.continuousActionsMap.Add(pair.Key, new KeyValuePair <Bitset, int>(pair.Value.Key.Copy(), pair.Value.Value)); } foreach (var pair in preset.discreteActionsMap) { newPreset.discreteActionsMap.Add(pair.Key, pair.Value.Copy()); } m_Controller.presets.Add(newPreset); m_Controller.currentPreset = m_Controller.presets.Count - 1; } string destructiveRemoveLabel = "Delete"; if (m_DestructiveActionWait) { destructiveRemoveLabel = "Sure?"; } if (m_Controller.presets.Count <= 1 || m_Controller.currentPreset == 0) { GUI.enabled = false; } if (GUILayout.Button(destructiveRemoveLabel)) { if (m_DestructiveActionWait) { if (m_Controller.presets.Count > 1) { m_Controller.presets.RemoveAt(m_Controller.currentPreset); m_Controller.currentPreset--; if (m_Controller.currentPreset < 0) { m_Controller.currentPreset = 0; } m_DestructiveActionWait = false; m_DestructiveActionTimer = 0.0f; } } else { m_DestructiveActionWait = true; m_DestructiveActionTimer = 2.0f; } } GUI.enabled = true; GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (m_ChooseDiscreteAction || m_ChooseContinuousAction) { GUI.enabled = false; } if (GUILayout.Button("Add button")) { m_ChooseDiscreteAction = true; m_ChosenDiscreteAction = DiscreteAction.None; m_ChooseDiscreteActionRect = new Rect(Input.mousePosition.x, Screen.height - Input.mousePosition.y, 256, 512); } if (GUILayout.Button("Add axis")) { m_ChooseContinuousAction = true; m_ChosenContinuousAction = ContinuousAction.None; m_ChooseContinuousActionRect = new Rect(Input.mousePosition.x, Screen.height - Input.mousePosition.y, 256, 512); } GUI.enabled = true; GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); m_ScrollPosition = GUILayout.BeginScrollView(m_ScrollPosition); foreach (var action in (ContinuousAction[])Enum.GetValues(typeof(ContinuousAction))) { if (action == ContinuousAction.None) { continue; } var axisBitsetPair = currentPreset.GetBitsetForContinuousBinding(action); if (axisBitsetPair.Value == null) { continue; } GUILayout.BeginHorizontal(); GUILayout.Label(Stringify.ContinuousActionToString(action)); GUILayout.FlexibleSpace(); string label = ""; if (m_CurrentlyEditingContinuousAction == action) { label = "Press desired combination"; var buttonsMask = m_Controller.iface.GetButtonsMask(); for (int i = 0; i < m_Controller.iface.GetAxesCount(); i++) { if (Math.Abs(m_Controller.iface.GetAxisState(i) - axisSnapshot[i]) > 0.1 && m_ClickSleepTimer == 0.0f) { currentPreset.SetContinuousBinding(i, buttonsMask, action, false); m_CurrentlyEditingContinuousAction = ContinuousAction.None; } } } axisBitsetPair = currentPreset.GetBitsetForContinuousBinding(action); if (m_CurrentlyEditingContinuousAction != action) { if (axisBitsetPair.Value == null) { label = "Click to assign"; } else { label = m_Controller.iface.ConvertMaskToName(axisBitsetPair.Value, true, axisBitsetPair.Key); } } if (GUILayout.Button(label, GUILayout.Width(220))) { if (m_CurrentlyEditingContinuousAction != action) { m_CurrentlyEditingContinuousAction = action; m_CurrentlyEditingDiscreteAction = DiscreteAction.None; m_ClickSleepTimer = 0.25f; for (int i = 0; i < m_Controller.iface.GetAxesCount(); i++) { axisSnapshot[i] = m_Controller.iface.GetAxisState(i); } } m_CurrentMask = null; } GUILayout.Space(8); var inverted = GUILayout.Toggle(currentPreset.IsContinuousBindingInverted(action), "", GUILayout.Width(32)); currentPreset.SetContinuousBindingInverted(action, inverted); GUILayout.Label("Invert", GUILayout.Width(40)); GUILayout.Space(8); if (GUILayout.Button("X")) { currentPreset.UnsetContinuousBinding(action); m_CurrentlyEditingContinuousAction = ContinuousAction.None; m_CurrentlyEditingDiscreteAction = DiscreteAction.None; } GUILayout.EndHorizontal(); GUILayout.Space(4); } foreach (var action in (DiscreteAction[])Enum.GetValues(typeof(DiscreteAction))) { if (action == DiscreteAction.None) { continue; } var bitset = currentPreset.GetBitsetForDiscreteBinding(action); if (bitset == null) { continue; } GUILayout.BeginHorizontal(); GUILayout.Label(Stringify.DiscreteActionToString(action)); GUILayout.FlexibleSpace(); string label = ""; if (m_CurrentlyEditingDiscreteAction == action) { label = "Press desired combination"; if (m_CurrentMask != null && m_ClickSleepTimer == 0.0f) { currentPreset.SetDiscreteBinding(m_CurrentMask, action); m_CurrentMask = null; m_CurrentlyEditingDiscreteAction = DiscreteAction.None; } } bitset = currentPreset.GetBitsetForDiscreteBinding(action); if (m_CurrentlyEditingDiscreteAction != action) { if (bitset == null) { label = "Click to assign"; } else { label = m_Controller.iface.ConvertMaskToName(bitset); } } if (GUILayout.Button(label, GUILayout.Width(220))) { if (m_CurrentlyEditingDiscreteAction != action) { m_CurrentlyEditingDiscreteAction = action; m_CurrentlyEditingContinuousAction = ContinuousAction.None; m_ClickSleepTimer = 0.25f; } m_CurrentMask = null; } GUILayout.Space(96); if (GUILayout.Button("X")) { currentPreset.UnsetDiscreteBinding(action); m_CurrentlyEditingContinuousAction = ContinuousAction.None; m_CurrentlyEditingDiscreteAction = DiscreteAction.None; } GUILayout.EndHorizontal(); GUILayout.Space(0); } GUILayout.EndScrollView(); }
public bool IsContinuousBindingInverted(ContinuousAction action) { return(continuousActionsInvMap.ContainsKey(action) ? continuousActionsInvMap[action] : false); }
public virtual void DoWindow(int window) { GUI.DragWindow(new Rect(0, 0, 10000, 20)); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("X", GUILayout.Height(16)) || m_Controller == null || m_Controller.iface == null) { shouldBeDestroyed = true; if (m_Controller != null) { m_Controller.presetEditorOpen = false; } } GUILayout.EndHorizontal(); var currentPreset = m_Controller.GetCurrentPreset(); GUILayout.BeginHorizontal(); GUILayout.Label("Preset: "); currentPreset.name = GUILayout.TextField(currentPreset.name, GUILayout.Width(256)); if (m_Controller.currentPreset > 0) { if (GUILayout.Button("<")) { m_Controller.currentPreset--; } } else { GUI.enabled = false; GUILayout.Button("<"); GUI.enabled = true; } if (m_Controller.currentPreset < m_Controller.presets.Count - 1) { if (GUILayout.Button(">")) { m_Controller.currentPreset++; } } else { GUI.enabled = false; GUILayout.Button(">"); GUI.enabled = true; } if (GUILayout.Button("New")) { m_Controller.presets.Add(new ControllerPreset()); m_Controller.currentPreset = m_Controller.presets.Count - 1; } string destructiveRemoveLabel = "Delete"; if (m_DestructiveActionWait) { destructiveRemoveLabel = "Sure?"; } if (m_Controller.presets.Count <= 1) { GUI.enabled = false; } if (GUILayout.Button(destructiveRemoveLabel)) { if (m_DestructiveActionWait) { if (m_Controller.presets.Count > 1) { m_Controller.presets.RemoveAt(m_Controller.currentPreset); m_Controller.currentPreset--; if (m_Controller.currentPreset < 0) { m_Controller.currentPreset = 0; } m_DestructiveActionWait = false; m_DestructiveActionTimer = 0.0f; } } else { m_DestructiveActionWait = true; m_DestructiveActionTimer = 2.0f; } } GUI.enabled = true; GUILayout.EndHorizontal(); m_ScrollPosition = GUILayout.BeginScrollView(m_ScrollPosition); GUILayout.Label("Continuous actions"); foreach (var action in (ContinuousAction[])Enum.GetValues(typeof(ContinuousAction))) { if (action == ContinuousAction.None) { continue; } GUILayout.BeginHorizontal(); GUILayout.Label(Stringify.ContinuousActionToString(action)); GUILayout.FlexibleSpace(); string label = ""; var axisBitsetPair = currentPreset.GetBitsetForContinuousBinding(action); if (m_CurrentlyEditingContinuousAction == action) { label = "Press desired combination"; for (int i = 0; i < m_Controller.iface.GetAxesCount(); i++) { if (Math.Abs(m_Controller.iface.GetAxisState(i) - axisSnapshot[i]) > 0.1 && m_ClickSleepTimer == 0.0f) { currentPreset.SetContinuousBinding(i, m_Controller.iface.GetButtonsMask(), action); m_CurrentlyEditingContinuousAction = ContinuousAction.None; } } } axisBitsetPair = currentPreset.GetBitsetForContinuousBinding(action); if (m_CurrentlyEditingContinuousAction != action) { if (axisBitsetPair.Value == null) { label = "Click to assign"; } else { label = m_Controller.iface.ConvertMaskToName(axisBitsetPair.Value, true, axisBitsetPair.Key); } } if (GUILayout.Button(label, GUILayout.Width(256))) { if (m_CurrentlyEditingContinuousAction != action) { m_CurrentlyEditingContinuousAction = action; m_CurrentlyEditingDiscreteAction = DiscreteAction.None; m_ClickSleepTimer = 0.25f; for (int i = 0; i < m_Controller.iface.GetAxesCount(); i++) { axisSnapshot[i] = m_Controller.iface.GetAxisState(i); } } m_CurrentMask = null; } if (GUILayout.Button("X")) { currentPreset.UnsetContinuousBinding(action); m_CurrentlyEditingContinuousAction = ContinuousAction.None; m_CurrentlyEditingDiscreteAction = DiscreteAction.None; } GUILayout.EndHorizontal(); } GUILayout.Label("Discrete actions"); foreach (var action in (DiscreteAction[])Enum.GetValues(typeof(DiscreteAction))) { if (action == DiscreteAction.None) { continue; } GUILayout.BeginHorizontal(); GUILayout.Label(Stringify.DiscreteActionToString(action)); GUILayout.FlexibleSpace(); string label = ""; var bitset = currentPreset.GetBitsetForDiscreteBinding(action); if (m_CurrentlyEditingDiscreteAction == action) { label = "Press desired combination"; if (m_CurrentMask != null && m_ClickSleepTimer == 0.0f) { currentPreset.SetDiscreteBinding(m_CurrentMask, action); m_CurrentMask = null; m_CurrentlyEditingDiscreteAction = DiscreteAction.None; } } bitset = currentPreset.GetBitsetForDiscreteBinding(action); if (m_CurrentlyEditingDiscreteAction != action) { if (bitset == null) { label = "Click to assign"; } else { label = m_Controller.iface.ConvertMaskToName(bitset); } } if (GUILayout.Button(label, GUILayout.Width(256))) { if (m_CurrentlyEditingDiscreteAction != action) { m_CurrentlyEditingDiscreteAction = action; m_CurrentlyEditingContinuousAction = ContinuousAction.None; m_ClickSleepTimer = 0.25f; } m_CurrentMask = null; } if (GUILayout.Button("X")) { currentPreset.UnsetDiscreteBinding(action); m_CurrentlyEditingContinuousAction = ContinuousAction.None; m_CurrentlyEditingDiscreteAction = DiscreteAction.None; } GUILayout.EndHorizontal(); } GUILayout.EndScrollView(); }
public void UnsetContinuousBinding(ContinuousAction action) { continuousActionsMap.Remove(action); continuousActionsInvMap.Remove(action); }
public void AddToQueue(ContinuousAction action, float period, float startAfter = 0.0f) { queueActions.Enqueue(new ContinuousActionInfo(action, period, startAfter)); }
public void UnsetContinuousBinding(ContinuousAction action) { continuousActionsMap.Remove(action); }
/// <summary> /// Instantiates object /// </summary> /// <param name="action">Action to perform</param> /// <param name="period">Duration of action performing</param> /// <param name="startAfter">Delay before action performing</param> public ContinuousActionInfo(ContinuousAction action, double period, double startAfter = 0.0f) { this.Action = action; this.StartAfter = startAfter; this.Period = period; }
public bool IsContinuousBindingInverted(ContinuousAction action) { return(continuousActionsMap.ContainsKey(action) && continuousActionsMap[action].Inverted); }
public void AddIndependent(ContinuousAction action, double period, double startAfter = 0.0f) { continuousActions.Add(new ContinuousActionInfo(action, period, startAfter)); }
public static string ContinuousActionToString(ContinuousAction action) { switch (action) { case ContinuousAction.None: return("None"); case ContinuousAction.Yaw: return("Yaw"); case ContinuousAction.YawTrim: return("Yaw (Trim)"); case ContinuousAction.Pitch: return("Pitch"); case ContinuousAction.PitchTrim: return("Pitch (Trim)"); case ContinuousAction.Roll: return("Roll"); case ContinuousAction.RollTrim: return("Roll (Trim)"); case ContinuousAction.X: return("Transl. X"); case ContinuousAction.Y: return("Transl. Y"); case ContinuousAction.Z: return("Transl. Z"); case ContinuousAction.Throttle: return("Throttle"); case ContinuousAction.ThrottleIncrement: return("Throttle (Increment)"); case ContinuousAction.ThrottleDecrement: return("Throttle (Decrement)"); case ContinuousAction.WheelSteer: return("Wheel Steer"); case ContinuousAction.WheelSteerTrim: return("Wheel Steer (Trim)"); case ContinuousAction.WheelThrottle: return("Wheel Throttle"); case ContinuousAction.WheelThrottleTrim: return("Wheel Throttle (Trim)"); case ContinuousAction.CameraX: return("Camera X"); case ContinuousAction.CameraY: return("Camera Y"); case ContinuousAction.CameraZoom: return("Camera Zoom"); default: return("Unknown Action"); } }
public ActionManager AddToQueue(ContinuousAction action, double period, double startAfter = 0.0f) { queueActions.Enqueue(new ContinuousActionInfo(action, period, startAfter)); return this; }
public void EvaluateContinuousAction(ControllerConfiguration controller, ContinuousAction action, float value, FlightCtrlState state) { switch (action) { case ContinuousAction.None: return; case ContinuousAction.Yaw: m_Yaw.SetValue(value); return; case ContinuousAction.NegativeYaw: m_Yaw.SetValue(-value); return; case ContinuousAction.YawTrim: m_Yaw.SetTrim(Utility.Clamp(m_Yaw.GetTrim() + value, -1.0f, 1.0f)); return; case ContinuousAction.Pitch: m_Pitch.SetValue(value); return; case ContinuousAction.NegativePitch: m_Pitch.SetValue(-value); return; case ContinuousAction.PitchTrim: m_Pitch.SetTrim(Utility.Clamp(m_Pitch.GetTrim() + value, -1.0f, 1.0f)); return; case ContinuousAction.Roll: m_Roll.SetValue(value); return; case ContinuousAction.NegativeRoll: m_Roll.SetValue(-value); return; case ContinuousAction.RollTrim: m_Roll.SetTrim(Utility.Clamp(m_Roll.GetTrim() + value, -1.0f, 1.0f)); return; case ContinuousAction.X: m_X.SetValue(value); return; case ContinuousAction.NegativeX: m_X.SetValue(-value); return; case ContinuousAction.Y: m_Y.SetValue(value); return; case ContinuousAction.NegativeY: m_Y.SetValue(-value); return; case ContinuousAction.Z: m_Z.SetValue(value); return; case ContinuousAction.NegativeZ: m_Z.SetValue(-value); return; case ContinuousAction.Throttle: m_Throttle.SetMinMaxValues(-state.mainThrottle, 1.0f - state.mainThrottle); m_Throttle.SetValue(value - state.mainThrottle); return; case ContinuousAction.ThrottleIncrement: m_Throttle.Increment(value * controller.incrementalActionSensitivity); return; case ContinuousAction.ThrottleDecrement: m_Throttle.Increment(-value * controller.incrementalActionSensitivity); return; case ContinuousAction.WheelThrottle: m_WheelThrottle.SetMinMaxValues(-state.wheelThrottle, 1.0f - state.wheelThrottle); m_WheelThrottle.SetValue(value); return; case ContinuousAction.WheelSteer: m_WheelSteer.SetValue(value); return; case ContinuousAction.WheelThrottleTrim: m_WheelThrottle.SetTrim(Utility.Clamp(m_WheelThrottle.GetTrim() + value, 0.0f, 1.0f)); return; case ContinuousAction.WheelSteerTrim: m_WheelSteer.SetTrim(Utility.Clamp(m_WheelSteer.GetTrim() + value, -1.0f, 1.0f)); return; case ContinuousAction.CameraX: m_CameraHeading.Increment(value); return; case ContinuousAction.CameraY: m_CameraPitch.Increment(value); return; case ContinuousAction.CameraZoom: m_CameraZoom.Increment(value); return; } }
public override Dictionary <string, string> GetCharacterDisplayCalculationValues() { Dictionary <string, string> retVal = new Dictionary <string, string>(); // if (BasicStats == null) { BasicStats = new Stats(); } retVal.Add("Health", BasicStats.Health.ToString()); retVal.Add("Mana", BasicStats.Mana.ToString()); retVal.Add("Armor", BasicStats.Armor.ToString()); retVal.Add("Agility", Math.Floor(BasicStats.Agility).ToString()); retVal.Add("Stamina", Math.Floor(BasicStats.Stamina).ToString()); retVal.Add("Intellect", Math.Floor(BasicStats.Intellect).ToString()); retVal.Add("Spirit", Math.Floor(BasicStats.Spirit).ToString()); retVal.Add("Fight Length", String.Format("{0:F0}s", FightLength)); retVal.Add("Divisions", Division.Fractions.Length.ToString() + "*" + Division.GetDivisionDetailTooltip(i => String.Format("{0:F0}s ({1:F2}%)", Division.Fractions[i] * FightLength, 100 * Division.Fractions[i]))); retVal.Add("Innervates", String.Format("{0:F2}", Innervates) + ((Innervates != Math.Floor(Innervates)) ? "*Fractional values denote the reduced value of innervates near the fight beginning or end" : "")); retVal.Add("Innervate Effect Delay", String.Format("{0:F2}", InnervateEffectDelay) + ((InnervateEffect != null) ? "*Innervate when this effect is up, and it wouldn't cap mana:\n" + InnervateEffect.ToString() : "")); retVal.Add("Mean Mana", String.Format("{0:F0}", MeanMana)); retVal.Add("Innervate Mana", String.Format("{0:F0}", InnervateMana)); retVal.Add("Innervate Size", String.Format("{0:F0}", InnervateSize)); addSpellStatValues(retVal, "Spell Power", "{0:F0}", x => x.SpellPower, String.Format("{0:F0} Base Spell Power", Math.Floor(BaseSpellPower))); addSpellStatValues(retVal, "Spell Crit", "{0:F2}%", x => x.SpellCrit * 100, String.Format("{0} Crit Rating from Gear, {1:F}% Crit from Gear, {2:F}% Crit from Gear Intellect", BasicStats.CritRating, 100 * StatConversion.GetSpellCritFromRating(BasicStats.CritRating), 100 * StatConversion.GetSpellCritFromIntellect(BasicStats.Intellect))); addSpellStatValues(retVal, "Spell Haste", "{0:F2}%", x => 100 * (1 / x.Haste.HastedSecond - 1), String.Format("{0} Haste Rating from Gear, {1:F}% Haste from Gear, {2:F}% Haste from Gear and Buffs", (float)BasicStats.HasteRating, 100 * StatConversion.GetSpellHasteFromRating((float)BasicStats.HasteRating), 100 * ((1 + StatConversion.GetSpellHasteFromRating((float)BasicStats.HasteRating)) * (1.0f + BasicStats.SpellHaste) - 1) )); addSpellStatValues(retVal, "Spell Mana Cost Reduction", "{0:F0}", x => x.SpellsManaCostReduction); addSpellStatValues(retVal, "Spell Crit Extra Bonus", "{0:F0}%", x => 100 * x.BonusCritHealMultiplier); string masteryInfo = String.Format("{0:F0} Mastery Rating from Gear, {1:F2} Mastery from Gear", BasicStats.MasteryRating, 8 + StatConversion.GetMasteryFromRating(BasicStats.MasteryRating)); addSpellStatValues(retVal, "Harmony", "{0:F}%", x => 100 * x.Harmony, masteryInfo); retVal.Add("Mana Regen", String.Format("{0:F0}", ManaRegen)); retVal.Add("Base Mana Regen", String.Format("{0:F0}", BaseRegen)); retVal.Add("Initial Mana Pool Regen", String.Format("{0:F0}", ManaPoolRegen)); retVal.Add("Spirit Mana Regen", String.Format("{0:F0}", SpiritRegen)); retVal.Add("Innervate Mana Regen", String.Format("{0:F0}", InnervateRegen)); retVal.Add("Replenishment Mana Regen", String.Format("{0:F0}", ReplenishmentRegen)); retVal.Add("Revitalize Mana Regen", String.Format("{0:F0}", RevitalizeRegen)); retVal.Add("Potion Mana Regen", String.Format("{0:F0}", PotionRegen)); retVal.Add("Total Score", String.Format("{0:F2}", OverallPoints)); string[] longNames = { "Raid Sustained", "Raid Burst", "Tank Sustained", "Tank Burst" }; for (int i = 0; i < longNames.Length; ++i) { retVal.Add(longNames[i] + " HPS", String.Format("{0:F2}", Solutions[i].Distribution.TotalEPS())); retVal.Add(longNames[i] + " Directs/s", String.Format("{0:F2}", Solutions[i].Distribution.TotalCPS())); retVal.Add(longNames[i] + " Ticks/s", String.Format("{0:F2}", Solutions[i].Distribution.TotalTPS())); } retVal.Add("Proc trigger interval", String.Format("{0:F2}", ProcTriggerInterval)); retVal.Add("Proc periodic trigger interval", String.Format("{0:F2}", ProcPeriodicTriggerInterval)); ContinuousAction[] actions = ContinuousAction.AverageActionSets(Actions, Division.Fractions); for (int i = 0; i < actions.Length; ++i) { retVal.Add(CalculationsTree.ActionNames[i] + " HPCT", actions[i].EPSText + "*" + Division.GetDivisionDetailTooltip(div => Actions[div][i].EPSText)); retVal.Add(CalculationsTree.ActionNames[i] + " MPCT", actions[i].MPSText + "*" + Division.GetDivisionDetailTooltip(div => Actions[div][i].MPSText)); retVal.Add(CalculationsTree.ActionNames[i] + " HPM", actions[i].EPMText + "*" + Division.GetDivisionDetailTooltip(div => Actions[div][i].EPMText)); } string[] names = { "Raid S.", "Raid B.", "Tank S.", "Tank B." }; for (int i = 0; i < names.Length; ++i) { Solutions[i].GetProperties(retVal, names[i] + ' ', CalculationsTree.ActionNames, CalculationsTree.PassiveNames); } addSpellCalculationValues(retVal, "Time", s => s.Action.Time); addSpellCalculationValues(retVal, "Duration", s => s.Duration); addSpellCalculationValues(retVal, "Mana", s => s.Action.Mana); addSpellCalculationValues(retVal, "Direct", s => s.Action.Direct); addSpellCalculationValues(retVal, "Tick", s => s.Tick); addSpellCalculationValues(retVal, "Ticks", s => s.Ticks); addSpellCalculationValues(retVal, "Periodic", s => s.Action.Periodic); addSpellCalculationValues(retVal, "Raid Direct", s => s.RaidAction.Direct); addSpellCalculationValues(retVal, "Raid Periodic", s => s.RaidAction.Periodic); addSpellCalculationValues(retVal, "Tank Direct", s => s.TankAction.Direct); addSpellCalculationValues(retVal, "Tank Periodic", s => s.TankAction.Periodic); return(retVal); }