Exemple #1
0
        public void MaxParamterColumnWidthCanBeCustomized(string initialLongText, int maxParameterColumnWidth, string expectedDisplayText)
        {
            var summaryStyle = SummaryStyle.Default.WithMaxParameterColumnWidth(maxParameterColumnWidth);
            var parameter    = new ParameterInstance(definition, initialLongText, summaryStyle);

            Assert.Equal(expectedDisplayText, parameter.ToDisplayText());
        }
Exemple #2
0
    public ParameterInstance getParameter(string name)
    {
        ParameterInstance result = null;

        this.ERRCHECK(this.evt.getParameter(name, out result));
        return(result);
    }
 public ParameterData(ParameterInstance _parameterInstance, string _parameterName, float _minParameter, float _maxParameter, float _currentVale)
 {
     m_parameterInstance = _parameterInstance;
     m_parameterName     = _parameterName;
     m_minIndex          = _minParameter;
     m_maxIndex          = _maxParameter;
     m_value             = _currentVale;
 }
Exemple #4
0
        public void VeryLongParameterValuesAreTrimmed(string initialLongText, string expectedDisplayText)
        {
            var parameter = new ParameterInstance(definition, initialLongText);

            Assert.NotEqual(initialLongText, parameter.ToDisplayText());

            Assert.Equal(expectedDisplayText, parameter.ToDisplayText());
        }
Exemple #5
0
 private void StopOnFireEvent()
 {
     if (this.onFireEventInstance != null)
     {
         UnityUtil.ERRCHECK(this.onFireEventInstance.stop(STOP_MODE.ALLOWFADEOUT));
         UnityUtil.ERRCHECK(this.onFireEventInstance.release());
         this.onFireEventInstance   = null;
         this.onFireHealthParameter = null;
     }
 }
Exemple #6
0
 private void StopBurningEvent()
 {
     if (this.burningEventInstance != null)
     {
         UnityUtil.ERRCHECK(this.burningEventInstance.stop(STOP_MODE.ALLOWFADEOUT));
         this.burningEventInstance = null;
         this.sizeParameter        = null;
         this.flareUpParameter     = null;
     }
 }
        /// <summary>
        /// Get all important information of ParameterInstance
        /// Return a parameterInfo with:
        /// -ParameterName
        /// -ParameterRange(start,end)
        /// </summary>
        /// <param name="instance">current ParameterInstance</param>
        /// <returns></returns>
        private ParameterData GetParameterName(ParameterInstance instance)
        {
            ///Create the parameter description
            ///useflue to get all information
            PARAMETER_DESCRIPTION desc = new PARAMETER_DESCRIPTION();

            instance.getDescription(out desc);
            ParameterData parameterInfo = new ParameterData(instance, desc.name, desc.minimum, desc.maximum, desc.defaultvalue);

            return(parameterInfo);
        }
        /// <summary>
        /// Force the contents of the a parameter back into the program parameters storage.
        /// </summary>
        ///
        /// This function fires as the user is pressing a new key in a parameter entry field.
        /// It will force the resulting value back into the storage record for the parameters.
        ///
        /// //TODO consider another attempt to see if the text editor can be bound directly
        ///   to the parameter in the backing store. That way WPF can take care of maintaining
        ///   the value in the store.
        ///
        /// <param name="sender"></param>
        /// <param name="e"></param>
        ///
        private void ParameterEntry_PreviewLostKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e)
        {
            int selectedIndex = ProgramParametersLB.SelectedIndex;

            if (selectedIndex >= 0)
            {
                TextBox box = (TextBox)sender;

                try
                {
                    ParameterInstance pi = (ParameterInstance)Parameters[selectedIndex];
                    Parameters[selectedIndex].Value = box.Text;
                }
                catch (Exception /*ex*/)
                {
                    /* //TODO do something with the error */
                }
                RefreshCommandList();
            }
        }
Exemple #9
0
            public RESULT getParameter(string name, out ParameterInstance instance)
            {
                instance = null;

                IntPtr newPtr = new IntPtr();
                RESULT result = FMOD_Studio_EventInstance_GetParameter(rawPtr, Encoding.UTF8.GetBytes(name + Char.MinValue), out newPtr);
                if (result != RESULT.OK)
                {
                return result;
                }
                instance = new ParameterInstance(newPtr);

                return result;
            }
Exemple #10
0
        public void ShortParameterValuesDisplayOriginalValue(object value)
        {
            var parameter = new ParameterInstance(definition, value);

            Assert.Equal(value.ToString(), parameter.ToDisplayText());
        }
Exemple #11
0
    void OnGUI()
    {
        boundactive = false;
        GUI.depth   = -5000;
        if (editing == this)
        {
            if (Vector3.Dot(Camera.main.transform.forward, (transform.position - Camera.main.transform.position).normalized) > 0.1f)
            {
                GUI.skin = gskin;
                Vector3 screenPoint = Camera.main.WorldToScreenPoint(transform.position);
                screenPoint.x -= 30f;
                screenPoint.y -= 25f;

                int height = 120;
                if (audioSrc.audioInst != null)
                {
                    int slidercnt = 0;
                    audioSrc.audioInst.getParameterCount(out slidercnt);
                    height = 304 + 25 * slidercnt;
                }

                GUI.BeginGroup(new Rect(screenPoint.x, Screen.height - screenPoint.y, 300, height));
                GUI.Box(new Rect(0, 0, 300, height), "");
                GUILayout.BeginHorizontal();
                GUILayout.Space(5);
                GUILayout.BeginVertical();
                GUILayout.Space(8);
                {
                    GUILayout.Label("Load Event");
                    GUILayout.BeginHorizontal();
                    {
                        GUILayout.Space(13);
                        inputPath = GUILayout.TextField(inputPath, GUILayout.Width(200));
                        if (GUILayout.Button("Load", GUILayout.Width(50)))
                        {
                            audioSrc.path = inputPath;
                        }
                    }
                    GUILayout.EndHorizontal();
                    GUILayout.Space(15);
                    GUILayout.Label("Audio Settings");
                    if (audioSrc.audioInst != null)
                    {
                        EventDescription desc = null;
                        audioSrc.audioInst.getDescription(out desc);
                        if (desc != null && desc.isValid())
                        {
                            bool is3D = false;
                            desc.is3D(out is3D);
                            bool isOneshot = false;
                            desc.isOneshot(out isOneshot);
                            float mindist = 0, maxdist = 0;
                            if (is3D)
                            {
                                desc.getMinimumDistance(out mindist);
                                desc.getMaximumDistance(out maxdist);
                                boundactive = true;
                                bound.transform.localScale = Vector3.one * audioSrc.maxDistance * 2f;
                            }
                            string is3Dstr = is3D ? "3D Sound" : "2D Sound";
                            string diststr = is3D ? ("Distance Area ( " + mindist.ToString("0.##") + "m ~ " + maxdist.ToString("0.##") + "m )") : ("");

                            if (listener != null)
                            {
                                LabelField("Distance", listenDist.ToString("#,##0.00") + " m");
                            }
                            else
                            {
                                LabelField("Distance", "-");
                            }

                            LabelField(is3Dstr, diststr);

                            audioSrc.minDistance = FloatField("Min Dist", audioSrc.minDistance);
                            audioSrc.maxDistance = FloatField("Max Dist", audioSrc.maxDistance);

                            LabelField("Is Oneshot", isOneshot.ToString());

                            audioSrc.volume = Slider("Volume", audioSrc.volume, 0f, 1f);
                            audioSrc.pitch  = Slider("Pitch", audioSrc.pitch, 0f, 4f);

                            int pcnt = 0;
                            audioSrc.audioInst.getParameterCount(out pcnt);

                            for (int i = 0; i < pcnt; ++i)
                            {
                                ParameterInstance pinst = null;
                                audioSrc.audioInst.getParameterByIndex(i, out pinst);
                                PARAMETER_DESCRIPTION pdesc = new PARAMETER_DESCRIPTION();
                                pinst.getDescription(out pdesc);
                                float val = 0f, _val = 0f;
                                pinst.getValue(out val);
                                _val = Slider(pdesc.name, val, pdesc.minimum, pdesc.maximum);
                                if (_val != val)
                                {
                                    pinst.setValue(_val);
                                }
                            }

                            GUILayout.Space(8);
                            GUILayout.BeginHorizontal();
                            {
                                GUILayout.Space(17);
                                if (GUILayout.Button("Play", GUILayout.Width(80)))
                                {
                                    audioSrc.Play();
                                }
                                GUILayout.Space(4);
                                if (GUILayout.Button("Stop", GUILayout.Width(80)))
                                {
                                    audioSrc.Stop();
                                }
                                GUILayout.Space(4);
                                if (GUILayout.Button("Unload", GUILayout.Width(80)))
                                {
                                    audioSrc.path = "";
                                }
                            }
                            GUILayout.EndHorizontal();
                        }
                    }
                    else
                    {
                        GUILayout.BeginHorizontal();
                        {
                            GUILayout.Space(13);
                            GUILayout.Label("No Event Loaded");
                        }
                        GUILayout.EndHorizontal();
                    }
                }
                GUILayout.EndVertical();
                GUILayout.EndHorizontal();
                GUI.EndGroup();
            }
            else
            {
                if (audioSrc.is3D)
                {
                    boundactive = true;
                    bound.transform.localScale = Vector3.one * audioSrc.maxDistance * 2f;
                }
            }
        }
    }
            public RESULT getParameterByIndex(int index, out ParameterInstance instance)
            {
                RESULT result = RESULT.OK;
                IntPtr parameterinstanceraw = new IntPtr();
                instance = null;

                try
                {
                result = FMOD_Studio_EventInstance_GetParameterByIndex(rawPtr, index, out parameterinstanceraw);
                }
                catch
                {
                result = RESULT.ERR_INVALID_PARAM;
                }
                if (result != RESULT.OK)
                {
                return result;
                }
                instance = new ParameterInstance();
                instance.setRaw(parameterinstanceraw);

                return result;
            }
            public RESULT getParameter(string name, out ParameterInstance instance)
            {
                RESULT result = RESULT.OK;
                IntPtr parameterinstanceraw = new IntPtr();
                instance = null;

                try
                {
                result = FMOD_Studio_EventInstance_GetParameter(rawPtr, Encoding.UTF8.GetBytes(name + Char.MinValue), out parameterinstanceraw);
                }
                catch
                {
                result = RESULT.ERR_INVALID_PARAM;
                }
                if (result != RESULT.OK)
                {
                return result;
                }
                instance = new ParameterInstance();
                instance.setRaw(parameterinstanceraw);

                return result;
            }
Exemple #14
0
 protected override void OnExit(ExitEventArgs e)
 {
     ParameterInstance.Uninit();
     base.OnExit(e);
 }
Exemple #15
0
 protected override void OnStartup(StartupEventArgs e)
 {
     ParameterInstance.Init();
     base.OnStartup(e);
 }
Exemple #16
0
            public RESULT getParameterByIndex(int index, out ParameterInstance instance)
            {
                instance = null;

                IntPtr newPtr = new IntPtr();
                RESULT result = FMOD_Studio_EventInstance_GetParameterByIndex(rawPtr, index, out newPtr);
                if (result != RESULT.OK)
                {
                return result;
                }
                instance = new ParameterInstance(newPtr);

                return result;
            }
Exemple #17
0
        public void TrimmingTheValuesMakesThemActuallyShorter(string initialLongText, string expectedDisplayText)
        {
            var parameter = new ParameterInstance(definition, initialLongText);

            Assert.Equal(expectedDisplayText, parameter.ToDisplayText());
        }
Exemple #18
0
 private static bool IsParameterValid(ParameterInstance parameter)
 {
     return(parameter != null && parameter.isValid());
 }
Exemple #19
0
 private void Update()
 {
     if (base.transform.hasChanged)
     {
         base.transform.hasChanged = false;
         this.UpdateUnderwaterEvent();
     }
     if (this.Buoyancy && this.Buoyancy.InWater)
     {
         bool inWater = false;
         if (this.Buoyancy.IsOcean && WaterEngine.Ocean)
         {
             this.WaterLevel = WaterEngine.Ocean.HeightAt(this.WaterLevelSensor.position);
         }
         else if (this.Buoyancy.WaterCollider)
         {
             this.WaterLevel = this.Buoyancy.WaterLevel;
             if (!this.Buoyancy.IsOcean)
             {
                 MeshFilter component = this.Buoyancy.WaterCollider.transform.parent.GetComponent <MeshFilter>();
                 if (component)
                 {
                     Vector3 position   = base.transform.position;
                     Vector3 position2  = position + base.transform.forward * 2f;
                     Vector3 center     = this.Buoyancy.WaterCollider.transform.parent.InverseTransformPoint(position2);
                     Mesh    sharedMesh = component.sharedMesh;
                     sharedMesh.bounds = new Bounds(center, sharedMesh.bounds.size);
                 }
             }
         }
         else
         {
             this.WaterLevel = -10000f;
         }
         if (this.WaterLevel < this.Buoyancy.WaterLevel && this.WaterLevel > -10000f)
         {
             this.WaterLevel = this.Buoyancy.WaterLevel;
         }
         this.WaterLevel -= this.Offset;
         if (this.WaterLevelSensor.position.y <= this.CalculateAdjustedWaterLevel())
         {
             this.CalculateScreenCoverage();
             inWater = true;
             if (this.UnderwaterInstance == null && FMOD_StudioSystem.instance)
             {
                 this.UnderwaterInstance = FMOD_StudioSystem.instance.GetEvent((!this.Buoyancy.IsOcean) ? this.UnderwaterEvent : this.OceanUnderwaterEvent);
                 UnityUtil.ERRCHECK(this.UnderwaterInstance.getParameter("depth", out this.DepthParameter));
                 this.UpdateUnderwaterEvent();
                 UnityUtil.ERRCHECK(this.UnderwaterInstance.start());
             }
             this.TurnOnRebreatherLights();
             if (this.ScreenCoverage > 0.8f)
             {
                 this.Bubbles.SetActive(true);
             }
             else
             {
                 this.Bubbles.SetActive(false);
             }
         }
         else
         {
             this.AudioOff();
             this.DepthParameter = null;
             this.ScreenCoverage = 0f;
         }
         this.InWater = inWater;
     }
     else if (this.InWater)
     {
         this.AudioOff();
         this.InWater        = false;
         this.ScreenCoverage = 0f;
     }
 }
Exemple #20
0
        public void TypeParameterValuesDisplayNotTrimmedTypeNameWithoutNamespace(Type type, string expectedName)
        {
            var parameter = new ParameterInstance(definition, type);

            Assert.Equal(expectedName, parameter.ToDisplayText());
        }
 /// <summary>
 /// Chang event parameter with a new value (Integer)
 /// </summary>
 /// <param name="_eventParameter"></param>
 /// <param name="_value"></param>
 public FMOD.RESULT ChangeParameter(ref ParameterInstance _eventParameter, int _value)
 {
     return(_eventParameter.setValue(_value));
 }