Exemplo n.º 1
0
        private GffStruct ReadStruct(BinaryReader reader, int index)
        {
            reader.BaseStream.Position = _structOffset + index * 12;
            reader.ReadInt32();  // skip type - we don't care
            int dataOrDataOffset = reader.ReadInt32();
            int fieldCount       = reader.ReadInt32();

            GffStruct result = new GffStruct();

            if (fieldCount == 1)
            {
                ReadField(result, reader, dataOrDataOffset);
            }
            else
            {
                reader.BaseStream.Position = _fieldIndicesOffset + dataOrDataOffset;
                int[] indices = new int[fieldCount];
                for (int i = 0; i < fieldCount; i++)
                {
                    indices[i] = reader.ReadInt32();
                }
                foreach (int fieldIndex in indices)
                {
                    ReadField(result, reader, fieldIndex);
                }
            }
            return(result);
        }
Exemplo n.º 2
0
 private void ShowStruct(GffStruct gff, TreeNodeCollection nodes)
 {
     foreach (string name in gff.FieldNames)
     {
         object value = gff [name];
         if (value is List <GffStruct> )
         {
             List <GffStruct> list = (List <GffStruct>)value;
             TreeNode         node = nodes.Add(name);
             for (int i = 0; i < list.Count; i++)
             {
                 TreeNode structNode = node.Nodes.Add(i.ToString());
                 ShowStruct(list [i], structNode.Nodes);
             }
         }
         else if (value is TalkRef)
         {
             TalkRef talkRef = (TalkRef)value;
             nodes.Add(name + "=\"" + _game.TalkFile[talkRef.Index] + "\"");
         }
         else
         {
             nodes.Add(name + "=" + value);
         }
     }
 }
Exemplo n.º 3
0
 public Dialog(Game game, GffStruct gffStruct)
 {
     _game         = game;
     _struct       = gffStruct;
     _tagList      = (List <GffStruct>)_struct ["TagList"];
     _entryList    = (List <GffStruct>)_struct ["EntryList"];
     _replyList    = (List <GffStruct>)_struct ["ReplyList"];
     _startingList = (List <GffStruct>)_struct ["StartingList"];
 }
Exemplo n.º 4
0
        private void ReadField(GffStruct gffStruct, BinaryReader reader, int index)
        {
            reader.BaseStream.Position = _fieldOffset + 12 * index;
            int    type             = reader.ReadInt32();
            int    labelIndex       = reader.ReadInt32();
            int    dataOrDataOffset = reader.ReadInt32();
            object value            = ReadValue(reader, type, dataOrDataOffset);

            gffStruct.SetValue(_labels [labelIndex], value);
        }
Exemplo n.º 5
0
 public DialogNode(Dialog dialog, GffStruct gffStruct, bool isReply)
 {
     _dialog     = dialog;
     _syncStruct = gffStruct;
     _isReply    = isReply;
     if (gffStruct.HasField(INDEX))
     {
         if (_isReply)
         {
             _mainStruct = _dialog.GetReplyNode((int)gffStruct[INDEX]);
         }
         else
         {
             _mainStruct = _dialog.GetEntryNode((int)gffStruct[INDEX]);
         }
     }
 }
Exemplo n.º 6
0
        private GffReader(Stream data)
        {
            BinaryReader reader = new BinaryReader(data, Encoding.Default);

            data.Position = 8;
            _structOffset = reader.ReadInt32();
            reader.ReadInt32();     // skip struct count
            _fieldOffset = ReadOffsetSkipCount(reader);
            int labelOffset = reader.ReadInt32();
            int labelCount  = reader.ReadInt32();

            _fieldDataOffset    = ReadOffsetSkipCount(reader);
            _fieldIndicesOffset = ReadOffsetSkipCount(reader);
            _listIndicesOffset  = ReadOffsetSkipCount(reader);

            LoadLabels(reader, labelOffset, labelCount);

            _root = ReadStruct(reader, 0);
        }
Exemplo n.º 7
0
        private void DisplayDialog(Resource resource)
        {
            ClearView();
            GffStruct gff = GffReader.Read(resource.Data);
            Dialog    dlg = new Dialog(_game, gff);

            _structureTree.BeginUpdate();
            try
            {
                ShowStruct(gff, _structureTree.Nodes);
            }
            finally
            {
                _structureTree.EndUpdate();
            }
            foreach (DialogNode node in dlg.StartingNodes)
            {
                AddDialogNode(node, _dialogTree.Nodes);
            }
        }