Exemple #1
0
            /// <summary>
            /// Writes the given EightCC to the given BinaryWriter.
            /// </summary>
            static public void WriteTo(EightCC inEightCC, BinaryWriter inWriter)
            {
                byte[] bytes = RequireStreamBytes();

                Unpack(inEightCC.m_Value, bytes);
                inWriter.Write(bytes);
            }
            public RegistryEntry(EightCC inValue, string inName, string inDescription)
            {
                Value = inValue;

                if (string.IsNullOrEmpty(inName))
                {
                    Display = Value.ToString();

                    if (string.IsNullOrEmpty(inDescription))
                    {
                        Tooltip = Display;
                    }
                    else
                    {
                        Tooltip = Display + "\n- " + inDescription;
                    }
                }
                else
                {
                    Display = inName + " [" + Value.ToString() + "]";

                    if (string.IsNullOrEmpty(inDescription))
                    {
                        Tooltip = Display;
                    }
                    else
                    {
                        Tooltip = Display + "\n- " + inDescription;
                    }
                }
            }
Exemple #3
0
            /// <summary>
            /// Writes the given EightCC to the given StringBuilder.
            /// Note that this will write spaces in place of empty bytes if trim is off.
            /// </summary>
            static public void WriteTo(EightCC inEightCC, StringBuilder inBuilder, bool inbTrimSpaces)
            {
                long value = inEightCC.m_Value;

                if (value == 0)
                {
                    if (!inbTrimSpaces)
                    {
                        inBuilder.Append(EmptyString);
                    }

                    return;
                }

                char[] chars = RequireStreamChars();

                for (int i = 0; i < Size; ++i)
                {
                    char ch = (char)(value >> (MaxShift - i * 8) & 0xFF);
                    if (ch == 0)
                    {
                        if (inbTrimSpaces)
                        {
                            inBuilder.Append(chars, 0, i);
                            return;
                        }
                        ch = CharUtils.PaddingChar;
                    }

                    chars[i] = ch;
                }

                inBuilder.Append(chars, 0, Size);
            }
Exemple #4
0
            /// <summary>
            /// Writes the given EightCC to the given byte array.
            /// </summary>
            static public void WriteTo(EightCC inEightCC, byte[] inBytes, int inOffset = 0)
            {
                byte[] bytes = RequireStreamBytes();

                Unpack(inEightCC.m_Value, bytes);
                Array.Copy(bytes, 0, inBytes, inOffset, Size);
            }
Exemple #5
0
            /// <summary>
            /// Writes the given EightCC to the given Stream.
            /// </summary>
            static public void WriteTo(EightCC inEightCC, Stream inStream)
            {
                byte[] bytes = RequireStreamBytes();

                Unpack(inEightCC.m_Value, bytes);
                inStream.Write(bytes, 0, Size);
            }
Exemple #6
0
            public int GetContentIndex(EightCC inValue)
            {
                for (int i = m_Options.Length - 1; i >= 0; --i)
                {
                    if (m_Options[i] == inValue)
                    {
                        return(i);
                    }
                }

                return(-1);
            }
            public void AddEntry(EightCC inCode, string inName, string inDescription)
            {
                RegistryEntry entry;

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

                entry = new RegistryEntry(inCode, inName, inDescription);
                m_EntryList.Add(entry);
                m_EntryMap.Add(inCode, entry);
            }
            public bool RemoveEntry(EightCC inCode)
            {
                RegistryEntry entry;

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

                return(false);
            }
Exemple #9
0
            /// <summary>
            /// Writes the given EightCC to the given TextWriter.
            /// Note that this will write spaces in place of empty bytes.
            /// </summary>
            static public void WriteTo(EightCC inEightCC, TextWriter inWriter)
            {
                byte[] bytes = RequireStreamBytes();
                char[] chars = RequireStreamChars();

                Unpack(inEightCC.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);
            }
Exemple #10
0
            private void StringInput(Rect inRect, SerializedProperty inProperty)
            {
                string currentValue;

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

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

                if (EditorGUI.EndChangeCheck() && currentValue != nextValue)
                {
                    EightCC parsedValue;
                    bool    bSuccess = EightCC.TryParse(nextValue, out parsedValue);
                    if (!bSuccess)
                    {
                        UnityEngine.Debug.LogErrorFormat("[EightCC] Unable to parse value '{0}' as a EightCC", nextValue);
                    }
                    else
                    {
                        inProperty.longValue = (long)parsedValue;
                    }
                }
            }
Exemple #11
0
 /// <summary>
 /// Writes an EightCC value to this StringBuilder, optionally trimming spaces from the end.
 /// </summary>
 static public StringBuilder Append(this StringBuilder inBuilder, EightCC inEightCC, bool inbTrimSpaces = false)
 {
     EightCC.Serialization.WriteTo(inEightCC, inBuilder, inbTrimSpaces);
     return(inBuilder);
 }
Exemple #12
0
 /// <summary>
 /// Writes an EightCC value to this BinaryWriter.
 /// </summary>
 static public void Write(this BinaryWriter inWriter, EightCC inEightCC)
 {
     EightCC.Serialization.WriteTo(inEightCC, inWriter);
 }