0
|
1 // This file is a part of the Relic Tools and is copyright 2006-2018 IBBoard.
|
|
2 //
|
|
3 // The file and the library/program it is in are licensed under the GNU GPL license, either version 3 of the License or (at your option) any later version. Please see COPYING for more information and the full license.
|
|
4 using System;
|
|
5 using System.IO;
|
|
6 using System.Text;
|
|
7 using IBBoard.Relic.RelicTools;
|
|
8 using IBBoard.Relic.RelicTools.Collections;
|
|
9
|
|
10 namespace IBBoard.Relic.RelicTools
|
|
11 {
|
|
12 /// <summary>
|
|
13 /// Summary description for RelicChunkyStructure.
|
|
14 /// </summary>
|
|
15 public class RelicChunkyStructure
|
|
16 {
|
|
17 protected ChunkyCollection chunkCol;
|
|
18 int unknownInt1;
|
|
19 int unknownInt2;
|
|
20 int unknownInt3;
|
|
21
|
|
22 public static readonly byte[] ChunkyHeader = new byte[]{0x52, 0x65, 0x6C, 0x69, 0x63, 0x20, 0x43, 0x68, 0x75, 0x6E, 0x6B, 0x79, 0x0D, 0x0A, 0x1A, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00};
|
|
23
|
|
24 public RelicChunkyStructure(ChunkyFolder chunkyRoot):this(chunkyRoot, 0, 0, 0){}
|
|
25
|
|
26 public RelicChunkyStructure(ChunkyFolder chunkyRoot, int unknown1, int unknown2, int unknown3)
|
|
27 {
|
|
28 chunkCol = new ChunkyCollection();
|
|
29 chunkCol.Add(chunkyRoot);
|
|
30 unknownInt1 = unknown1;
|
|
31 unknownInt2 = unknown2;
|
|
32 unknownInt3 = unknown3;
|
|
33 }
|
|
34
|
|
35 public RelicChunkyStructure(ChunkyCollection col):this(col, 0, 0, 0){}
|
|
36
|
|
37 public RelicChunkyStructure(ChunkyCollection col, int unknown1, int unknown2, int unknown3)
|
|
38 {
|
|
39 chunkCol = col;
|
|
40 unknownInt1 = unknown1;
|
|
41 unknownInt2 = unknown2;
|
|
42 unknownInt3 = unknown3;
|
|
43 }
|
|
44
|
|
45 public RelicChunkyFile ParentFile
|
|
46 {
|
|
47 get{ return (chunkCol.Count>0)?chunkCol[0].ParentFile:null; }
|
|
48 set{
|
|
49 for (int i = 0; i<chunkCol.Count; i++)
|
|
50 {
|
|
51 chunkCol[i].ParentFile = value;
|
|
52 }
|
|
53 }
|
|
54 }
|
|
55
|
|
56 public ChunkyCollection RootChunks
|
|
57 {
|
|
58 get{ return chunkCol; }
|
|
59 }
|
|
60
|
|
61 public void Save(BinaryWriter bw)
|
|
62 {
|
|
63 bw.Write(ChunkyHeader);
|
|
64
|
|
65 foreach(ChunkyChunk chunk in RootChunks)
|
|
66 {
|
|
67 bw.Write(chunk.GetBytes());
|
|
68 }
|
|
69 }
|
|
70
|
|
71 public string GetValidationString()
|
|
72 {
|
|
73 int childCount = this.RootChunks.Count;
|
|
74
|
|
75 if (childCount>1)
|
|
76 {
|
|
77 StringBuilder sb = new StringBuilder();
|
|
78 childCount--;
|
|
79
|
|
80 for (int i = 0; i<childCount; i++)
|
|
81 {
|
|
82 sb.Append(RootChunks[i].GetValidationString()+" ");
|
|
83 }
|
|
84
|
|
85 sb.Append(RootChunks[childCount].GetValidationString());
|
|
86
|
|
87 return sb.ToString();
|
|
88 }
|
|
89 else
|
|
90 {
|
|
91 return RootChunks[0].GetValidationString();
|
|
92 }
|
|
93 }
|
|
94 }
|
|
95 }
|