コード例 #1
0
ファイル: LSBWriter.cs プロジェクト: xenogenesi/lslib
        private void WriteAttribute(NodeAttribute attr)
        {
            switch (attr.Type)
            {
            case NodeAttribute.DataType.DT_String:
            case NodeAttribute.DataType.DT_Path:
            case NodeAttribute.DataType.DT_FixedString:
            case NodeAttribute.DataType.DT_LSString:
                WriteString((string)attr.Value, true);
                break;

            case NodeAttribute.DataType.DT_WString:
            case NodeAttribute.DataType.DT_LSWString:
                WriteWideString((string)attr.Value, true);
                break;

            case NodeAttribute.DataType.DT_TranslatedString:
                var str = (TranslatedString)attr.Value;
                WriteString(str.Value, true);
                WriteString(str.Handle, true);
                break;

            case NodeAttribute.DataType.DT_ScratchBuffer:
                var buffer = (byte[])attr.Value;
                writer.Write((UInt32)buffer.Length);
                writer.Write(buffer);
                break;

            default:
                BinUtils.WriteAttribute(writer, attr);
                break;
            }
        }
コード例 #2
0
        private void WriteAttributeValue(BinaryWriter writer, NodeAttribute attr)
        {
            switch (attr.Type)
            {
            case NodeAttribute.DataType.DT_String:
            case NodeAttribute.DataType.DT_Path:
            case NodeAttribute.DataType.DT_FixedString:
            case NodeAttribute.DataType.DT_LSString:
            case NodeAttribute.DataType.DT_WString:
            case NodeAttribute.DataType.DT_LSWString:
                WriteString(writer, (string)attr.Value);
                break;

            case NodeAttribute.DataType.DT_TranslatedString:
            {
                var ts = (TranslatedString)attr.Value;
                if (Version >= (uint)FileVersion.VerBG3)
                {
                    writer.Write(ts.Version);
                }
                else
                {
                    WriteStringWithLength(writer, ts.Value ?? "");
                }

                WriteStringWithLength(writer, ts.Handle);
                break;
            }

            case NodeAttribute.DataType.DT_TranslatedFSString:
            {
                var fs = (TranslatedFSString)attr.Value;
                WriteTranslatedFSString(writer, fs);
                break;
            }

            case NodeAttribute.DataType.DT_ScratchBuffer:
            {
                var buffer = (byte[])attr.Value;
                writer.Write(buffer);
                break;
            }

            default:
                BinUtils.WriteAttribute(writer, attr);
                break;
            }
        }
コード例 #3
0
        private void WriteAttribute(NodeAttribute attr)
        {
            switch (attr.Type)
            {
            case NodeAttribute.DataType.DT_String:
            case NodeAttribute.DataType.DT_Path:
            case NodeAttribute.DataType.DT_FixedString:
            case NodeAttribute.DataType.DT_LSString:
                WriteString((string)attr.Value, true);
                break;

            case NodeAttribute.DataType.DT_WString:
            case NodeAttribute.DataType.DT_LSWString:
                WriteWideString((string)attr.Value, true);
                break;

            case NodeAttribute.DataType.DT_TranslatedString:
            {
                var str = (TranslatedString)attr.Value;
                if (Version >= 4 && str.Value == null)
                {
                    writer.Write(str.Version);
                }
                else
                {
                    WriteString(str.Value ?? "", true);
                }

                WriteString(str.Handle, true);
                break;
            }

            case NodeAttribute.DataType.DT_ScratchBuffer:
            {
                var buffer = (byte[])attr.Value;
                writer.Write((UInt32)buffer.Length);
                writer.Write(buffer);
                break;
            }

            // DT_TranslatedFSString not supported in LSB
            default:
                BinUtils.WriteAttribute(writer, attr);
                break;
            }
        }