Beispiel #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);
            }
Beispiel #2
0
            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;
                    }
                }
            }
Beispiel #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);
            }
Beispiel #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);
            }
Beispiel #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);
            }
Beispiel #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);
            }
Beispiel #7
0
            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);
            }
Beispiel #8
0
            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);
            }
Beispiel #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);
            }
Beispiel #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;
                    }
                }
            }
Beispiel #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);
 }
Beispiel #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);
 }