Ejemplo n.º 1
0
            public int GetContentIndex(FourCC inValue)
            {
                for (int i = m_Options.Length - 1; i >= 0; --i)
                {
                    if (m_Options[i] == inValue)
                    {
                        return(i);
                    }
                }

                return(-1);
            }
Ejemplo n.º 2
0
            public void AddEntry(FourCC inCode, string inName, string inDescription)
            {
                RegistryEntry entry;

                if (m_EntryMap.TryGetValue(inCode, out entry))
                {
                    throw new ArgumentException("FourCC with code " + inCode.ToString() + " has already been registered", "inCode");
                }

                entry = new RegistryEntry(inCode, inName, inDescription);
                m_EntryList.Add(entry);
                m_EntryMap.Add(inCode, entry);
            }
Ejemplo n.º 3
0
            public bool RemoveEntry(FourCC inCode)
            {
                RegistryEntry entry;

                if (m_EntryMap.TryGetValue(inCode, out entry))
                {
                    m_EntryMap.Remove(inCode);
                    m_EntryList.Remove(entry);
                    return(true);
                }

                return(false);
            }
Ejemplo n.º 4
0
            /// <summary>
            /// Writes the given FourCC to the given TextWriter.
            /// Note that this will write spaces in place of empty bytes.
            /// </summary>
            static public void WriteTo(FourCC inFourCC, TextWriter inWriter)
            {
                RequireStreamBytes();
                RequireStreamChars();

                Unpack(inFourCC.m_Value, s_StreamBytes);
                for (int i = 0; i < LENGTH; ++i)
                {
                    byte val = s_StreamBytes[i];
                    s_StreamChars[i] = (val == 0) ? ' ' : (char)val;
                }

                inWriter.Write(s_StreamChars);
            }
Ejemplo n.º 5
0
            /// <summary>
            /// Writes the given FourCC to the given TextWriter.
            /// Note that this will write spaces in place of empty bytes.
            /// </summary>
            static internal void WriteTo(FourCC inFourCC, TextWriter inWriter)
            {
                byte[] bytes = RequireStreamBytes();
                char[] chars = RequireStreamChars();

                Unpack(inFourCC.m_Value, bytes);
                for (int i = 0; i < Size; ++i)
                {
                    byte val = bytes[i];
                    chars[i] = (val == 0) ? CharUtils.PaddingChar : (char)val;
                }

                inWriter.Write(chars);
            }
Ejemplo n.º 6
0
            private void StringInput(Rect inRect, SerializedProperty inProperty)
            {
                string currentValue;

                if (inProperty.hasMultipleDifferentValues)
                {
                    currentValue = "[multiple]";
                }
                else
                {
                    try
                    {
                        currentValue = FourCC.Stringify(inProperty.intValue, true);
                    }
                    catch
                    {
                        currentValue = "[invalid]";
                    }
                }

                EditorGUI.BeginChangeCheck();
                string nextValue = EditorGUI.DelayedTextField(inRect, currentValue);

                if (EditorGUI.EndChangeCheck() && currentValue != nextValue)
                {
                    FourCC parsedValue;
                    bool   bSuccess = FourCC.TryParse(nextValue, out parsedValue);
                    if (!bSuccess)
                    {
                        UnityEngine.Debug.LogErrorFormat("[FourCC] Unable to parse value '{0}' as a FourCC", nextValue);
                    }
                    else
                    {
                        inProperty.intValue = (int)parsedValue;
                    }
                }
            }
Ejemplo n.º 7
0
 /// <summary>
 /// Writes a FourCC value to this StringBuilder, optionally trimming spaces from the end.
 /// </summary>
 static public StringBuilder Append(this StringBuilder inBuilder, FourCC inFourCC, bool inbTrimSpaces = false)
 {
     FourCC.Serialization.WriteTo(inFourCC, inBuilder, inbTrimSpaces);
     return(inBuilder);
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Writes a FourCC value to this BinaryWriter.
 /// </summary>
 static public void Write(this BinaryWriter inWriter, FourCC inFourCC)
 {
     FourCC.Serialization.WriteTo(inFourCC, inWriter);
 }