BrawlCrate v0.41
Wii File Editor
Loading...
Searching...
No Matches
Public Member Functions | Properties | List of all members
BrawlLib.Internal.AttributeInterpretation Class Reference

Public Member Functions

 AttributeInterpretation (AttributeInfo[] array, string saveToFile)
 
 AttributeInterpretation (string filename, int index)
 
override string ToString ()
 
void Save ()
 

Properties

AttributeInfo[] Array [get]
 
string Filename [get]
 
int NumEntries [get]
 

Constructor & Destructor Documentation

◆ AttributeInterpretation() [1/2]

BrawlLib.Internal.AttributeInterpretation.AttributeInterpretation ( AttributeInfo[]  array,
string  saveToFile 
)
inline
29 {
30 Array = array;
31 Filename = saveToFile;
32 }
string Filename
Definition: AttributeInfo.cs:25
AttributeInfo[] Array
Definition: AttributeInfo.cs:24

◆ AttributeInterpretation() [2/2]

BrawlLib.Internal.AttributeInterpretation.AttributeInterpretation ( string  filename,
int  index 
)
inline
35 {
36 Filename = filename;
37
38 List<AttributeInfo> list = new List<AttributeInfo>();
39 if (filename != null && File.Exists(filename))
40 {
41 using (StreamReader sr = new StreamReader(filename))
42 {
43 for (int i = 0; !sr.EndOfStream; i++)
44 {
45 AttributeInfo attr = new AttributeInfo
46 {
47 _name = sr.ReadLine(),
48 _description = ""
49 };
50 string temp = sr.ReadLine();
51 while (temp != null && !temp.Equals("\t/EndDescription"))
52 {
53 attr._description += temp;
54 attr._description += '\n';
55 temp = sr.ReadLine();
56 }
57
58 if (temp == null)
59 {
60 return;
61 }
62
63 if (attr._description.EndsWith("\n"))
64 {
65 attr._description = attr._description.Substring(0, attr._description.Length - 1);
66 }
67
68 string num = sr.ReadLine();
69 try
70 {
71 attr._type = int.Parse(num);
72 }
73 catch (FormatException ex)
74 {
75 throw new FormatException(
76 "Invalid type \"" + num + "\" in " + Path.GetFileName(filename) + ".", ex);
77 }
78
79 if (attr._description == "")
80 {
81 attr._description = "No Description Available.";
82 }
83
84 list.Add(attr);
85 sr.ReadLine();
86 index++;
87 }
88 }
89 }
90
91 Array = list.ToArray();
92 }

Member Function Documentation

◆ Save()

void BrawlLib.Internal.AttributeInterpretation.Save ( )
inline
100 {
101 string dir = Path.GetDirectoryName(Filename);
102 if (!Directory.Exists(dir))
103 {
104 Directory.CreateDirectory(dir);
105 }
106
107 if (File.Exists(Filename))
108 {
109 if (MessageBox.Show("Overwrite " + Filename + "?", "Overwrite", MessageBoxButtons.YesNo)
110 != DialogResult.Yes)
111 {
112 return;
113 }
114 }
115
116 using (StreamWriter sw = new StreamWriter(Filename))
117 {
118 for (int i = 0; i < Array.Length; i++)
119 {
120 AttributeInfo attr = Array[i];
121 sw.WriteLine(attr._name);
122 sw.WriteLine(attr._description);
123 sw.WriteLine("\t/EndDescription");
124 if (i == Array.Length - 1)
125 {
126 sw.Write(attr._type);
127 }
128 else
129 {
130 sw.WriteLine(attr._type);
131 sw.WriteLine();
132 }
133 }
134
135 sw.Close();
136 }
137 }

◆ ToString()

override string BrawlLib.Internal.AttributeInterpretation.ToString ( )
inline
95 {
96 return Path.GetFileNameWithoutExtension(Filename);
97 }

Property Documentation

◆ Array

AttributeInfo [] BrawlLib.Internal.AttributeInterpretation.Array
get
24{ get; private set; }

◆ Filename

string BrawlLib.Internal.AttributeInterpretation.Filename
get
25{ get; private set; }

◆ NumEntries

int BrawlLib.Internal.AttributeInterpretation.NumEntries
get

The documentation for this class was generated from the following file: