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

Static Public Member Functions

static string TruncateLeft (string strIn, int totalWidth)
 
static string Hex (int val)
 
static string Hex (long val)
 
static string Hex8 (int val)
 
static string Hex8 (long val)
 
static int UnHex (string val)
 
static string WordH (string val, int wordNum)
 
static string WordB (string val, int byteNum)
 
static long Float (float val)
 
static float UnFloat (long val)
 
static long RoundUp (long val, long factor)
 
static long RoundDown (long val, long factor)
 
static int FindFirst (string str, int begin, char chr)
 
static int FindLast (string str, int begin, char chr)
 
static int FindCount (string str, int begin, char chr)
 
static int[] IndiciesOf (string str, int begin, char chr)
 
static int FindFirstOf (string str, int begin, char[] chr, ref char chrFound)
 
static int FindFirstIgnoreNest (string str, int begin, char chr)
 
static int FindFirstOfIgnoreNest (string str, int begin, char[] chr, ref char chrFound)
 
static int FindFirstNot (string str, int begin, char chr)
 
static int FindFirstNotDual (string str, int begin, char chr1, char chr2)
 
static string InsString (string str, string insString, int begin)
 
static string DelSubstring (string str, int begin, int len)
 
static string ClearWhiteSpace (string str)
 
static string GetComparisonSign (long value)
 
static int TabUpEvents (uint eventId)
 
static int TabDownEvents (uint eventId)
 
static float UnScalar (long value)
 

Member Function Documentation

◆ ClearWhiteSpace()

static string BrawlLib.Internal.Helpers.ClearWhiteSpace ( string  str)
inlinestatic
314 {
315 int whiteSpace = FindFirstNot(str, 0, ' ');
316 if (whiteSpace > 0)
317 {
318 str = DelSubstring(str, 0, whiteSpace);
319 }
320
321 whiteSpace = -1;
322 for (int i = str.Length - 1; i >= 0; i--)
323 {
324 if (str[i] == ' ')
325 {
326 whiteSpace = i;
327 }
328 else
329 {
330 break;
331 }
332 }
333
334 if (whiteSpace != -1)
335 {
336 str = DelSubstring(str, whiteSpace, str.Length - whiteSpace);
337 }
338
339 return str;
340 }
static int FindFirstNot(string str, int begin, char chr)
Definition: Helpers.cs:273
static string DelSubstring(string str, int begin, int len)
Definition: Helpers.cs:307

◆ DelSubstring()

static string BrawlLib.Internal.Helpers.DelSubstring ( string  str,
int  begin,
int  len 
)
inlinestatic
308 {
309 return str.Substring(0, begin) + str.Substring(begin + len);
310 }

◆ FindCount()

static int BrawlLib.Internal.Helpers.FindCount ( string  str,
int  begin,
char  chr 
)
inlinestatic
172 {
173 int x = 0;
174 for (int i = begin; i < str.Length; i++)
175 {
176 if (str[i] == chr)
177 {
178 x++;
179 }
180 }
181
182 return x;
183 }

◆ FindFirst()

static int BrawlLib.Internal.Helpers.FindFirst ( string  str,
int  begin,
char  chr 
)
inlinestatic
144 {
145 for (int i = begin; i < str.Length; i++)
146 {
147 if (str[i] == chr)
148 {
149 return i;
150 }
151 }
152
153 return -1;
154 }

◆ FindFirstIgnoreNest()

static int BrawlLib.Internal.Helpers.FindFirstIgnoreNest ( string  str,
int  begin,
char  chr 
)
inlinestatic
221 {
222 if (chr == '(')
223 {
224 return FindFirst(str, begin, chr);
225 }
226
227 char[] searchCharacters = {chr, '(', ')'};
228 char chrResult = '\0';
229 int searchResult = begin;
230 int nested = 0;
231
232 do
233 {
234 if (chrResult == ')' && nested > 0)
235 {
236 nested--;
237 }
238
239 searchResult = FindFirstOf(str, searchResult, searchCharacters, ref chrResult);
240 if (chrResult == '(')
241 {
242 nested++;
243 }
244
245 searchResult++;
246 } while ((nested > 0 || chrResult != chr) && chrResult != '\0');
247
248 searchResult--;
249
250 return searchResult;
251 }
static int FindFirst(string str, int begin, char chr)
Definition: Helpers.cs:143
static int FindFirstOf(string str, int begin, char[] chr, ref char chrFound)
Definition: Helpers.cs:201

◆ FindFirstNot()

static int BrawlLib.Internal.Helpers.FindFirstNot ( string  str,
int  begin,
char  chr 
)
inlinestatic
274 {
275 for (int i = begin; i < str.Length; i++)
276 {
277 if (str[i] != chr)
278 {
279 return i;
280 }
281 }
282
283 return -1;
284 }

◆ FindFirstNotDual()

static int BrawlLib.Internal.Helpers.FindFirstNotDual ( string  str,
int  begin,
char  chr1,
char  chr2 
)
inlinestatic
288 {
289 for (int i = begin; i < str.Length; i++)
290 {
291 if (str[i] != chr1 && str[i] != chr2)
292 {
293 return i;
294 }
295 }
296
297 return -1;
298 }

◆ FindFirstOf()

static int BrawlLib.Internal.Helpers.FindFirstOf ( string  str,
int  begin,
char[]  chr,
ref char  chrFound 
)
inlinestatic
202 {
203 int result = -1;
204 chrFound = '\0';
205 for (int i = 0; i < chr.Length; i++)
206 {
207 int temp = FindFirst(str, begin, chr[i]);
208
209 if (temp != -1 && (temp < result || result == -1))
210 {
211 result = temp;
212 chrFound = chr[i];
213 }
214 }
215
216 return result;
217 }

◆ FindFirstOfIgnoreNest()

static int BrawlLib.Internal.Helpers.FindFirstOfIgnoreNest ( string  str,
int  begin,
char[]  chr,
ref char  chrFound 
)
inlinestatic
255 {
256 int result = -1;
257 chrFound = '\0';
258 for (int i = 0; i < chr.Length; i++)
259 {
260 int temp = FindFirstIgnoreNest(str, begin, chr[i]);
261
262 if (temp != -1 && (temp < result || result == -1))
263 {
264 result = temp;
265 chrFound = chr[i];
266 }
267 }
268
269 return result;
270 }
static int FindFirstIgnoreNest(string str, int begin, char chr)
Definition: Helpers.cs:220

◆ FindLast()

static int BrawlLib.Internal.Helpers.FindLast ( string  str,
int  begin,
char  chr 
)
inlinestatic
158 {
159 for (int i = str.Length - 1; i >= begin; i--)
160 {
161 if (str[i] == chr)
162 {
163 return i;
164 }
165 }
166
167 return -1;
168 }

◆ Float()

static long BrawlLib.Internal.Helpers.Float ( float  val)
inlinestatic
69 {
70 if (val == 0)
71 {
72 return 0;
73 }
74
75 long sign = val >= 0 ? 0 : 8;
76 long exponent = 0x7F;
77 float mantissa = Math.Abs(val);
78
79 if (mantissa > 1)
80 {
81 while (mantissa > 2)
82 {
83 mantissa /= 2;
84 exponent++;
85 }
86 }
87 else
88 {
89 while (mantissa < 1)
90 {
91 mantissa *= 2;
92 exponent--;
93 }
94 }
95
96 mantissa -= 1;
97 mantissa *= (float) Math.Pow(2, 23);
98
99 return sign * 0x10000000
100 + exponent * 0x800000
101 + (long) mantissa;
102 }

◆ GetComparisonSign()

static string BrawlLib.Internal.Helpers.GetComparisonSign ( long  value)
inlinestatic
343 {
344 switch (value)
345 {
346 case 0: return "<";
347 case 1: return "<=";
348 case 2: return "==";
349 case 3: return "!=";
350 case 4: return ">=";
351 case 5: return ">";
352 default: return "(" + value + ")";
353 }
354 }

◆ Hex() [1/2]

static string BrawlLib.Internal.Helpers.Hex ( int  val)
inlinestatic
24 {
25 return TruncateLeft(val.ToString("X"), 8);
26 }
static string TruncateLeft(string strIn, int totalWidth)
Definition: Helpers.cs:8

◆ Hex() [2/2]

static string BrawlLib.Internal.Helpers.Hex ( long  val)
inlinestatic
29 {
30 return TruncateLeft(val.ToString("X"), 8);
31 }

◆ Hex8() [1/2]

static string BrawlLib.Internal.Helpers.Hex8 ( int  val)
inlinestatic
34 {
35 return TruncateLeft(val.ToString("X"), 8).PadLeft(8, '0');
36 }

◆ Hex8() [2/2]

static string BrawlLib.Internal.Helpers.Hex8 ( long  val)
inlinestatic
39 {
40 return TruncateLeft(val.ToString("X"), 8).PadLeft(8, '0');
41 }

◆ IndiciesOf()

static int[] BrawlLib.Internal.Helpers.IndiciesOf ( string  str,
int  begin,
char  chr 
)
inlinestatic
187 {
188 List<int> indices = new List<int>();
189 for (int i = begin; i < str.Length; i++)
190 {
191 if (str[i] == chr)
192 {
193 indices.Add(i);
194 }
195 }
196
197 return indices.ToArray();
198 }

◆ InsString()

static string BrawlLib.Internal.Helpers.InsString ( string  str,
string  insString,
int  begin 
)
inlinestatic
302 {
303 return str.Substring(0, begin) + insString + str.Substring(begin);
304 }

◆ RoundDown()

static long BrawlLib.Internal.Helpers.RoundDown ( long  val,
long  factor 
)
inlinestatic
138 {
139 return val - val % factor;
140 }

◆ RoundUp()

static long BrawlLib.Internal.Helpers.RoundUp ( long  val,
long  factor 
)
inlinestatic
133 {
134 return val + (factor - 1) - (val + (factor - 1)) % factor;
135 }

◆ TabDownEvents()

static int BrawlLib.Internal.Helpers.TabDownEvents ( uint  eventId)
inlinestatic
386 {
387 switch (eventId)
388 {
389 case 0x00050000:
390 case 0x000B0100:
391 case 0x000B0200:
392 case 0x000B0300:
393 case 0x000B0400:
394 case 0x000C0100:
395 case 0x000C0200:
396 case 0x000C0300:
397 case 0x000C0400:
398 case 0x000D0200:
399 case 0x000D0400:
400 case 0x000E0000:
401 case 0x000F0000:
402 case 0x00110100:
403 case 0x00120000:
404 case 0x00130000:
405 return 1;
406 default:
407 return 0;
408 }
409 }

◆ TabUpEvents()

static int BrawlLib.Internal.Helpers.TabUpEvents ( uint  eventId)
inlinestatic
357 {
358 switch (eventId)
359 {
360 case 0x00040100:
361 case 0x000A0100:
362 case 0x000A0200:
363 case 0x000A0300:
364 case 0x000A0400:
365 case 0x000B0100:
366 case 0x000B0200:
367 case 0x000B0300:
368 case 0x000B0400:
369 case 0x000C0100:
370 case 0x000C0200:
371 case 0x000C0300:
372 case 0x000C0400:
373 case 0x000D0200:
374 case 0x000D0400:
375 case 0x000E0000:
376 case 0x00100200:
377 case 0x00110100:
378 case 0x00120000:
379 return 1;
380 default:
381 return 0;
382 }
383 }

◆ TruncateLeft()

static string BrawlLib.Internal.Helpers.TruncateLeft ( string  strIn,
int  totalWidth 
)
inlinestatic
9 {
10 if (totalWidth <= 0)
11 {
12 return "";
13 }
14
15 if (totalWidth > strIn.Length)
16 {
17 return strIn;
18 }
19
20 return strIn.Substring(strIn.Length - totalWidth);
21 }

◆ UnFloat()

static float BrawlLib.Internal.Helpers.UnFloat ( long  val)
inlinestatic
105 {
106 if (val == 0)
107 {
108 return 0;
109 }
110
111 float sign = (val & 0x80000000) == 0 ? 1 : -1;
112 int exponent = (int) (val & 0x7F800000) / 0x800000 - 0x7F;
113 float mantissa = val & 0x7FFFFF;
114 long mantissaBits = 23;
115
116 if (mantissa != 0)
117 {
118 while (((long) mantissa & 0x1) != 1)
119 {
120 mantissa /= 2;
121 mantissaBits--;
122 }
123 }
124
125 mantissa /= (float) Math.Pow(2, mantissaBits);
126 mantissa += 1;
127
128 mantissa *= (float) Math.Pow(2, exponent);
129 return mantissa *= sign;
130 }

◆ UnHex()

static int BrawlLib.Internal.Helpers.UnHex ( string  val)
inlinestatic
44 {
45 return int.Parse(val, System.Globalization.NumberStyles.HexNumber);
46 }

◆ UnScalar()

static float BrawlLib.Internal.Helpers.UnScalar ( long  value)
inlinestatic
412 {
413 return (float) value / 60000f;
414 }

◆ WordB()

static string BrawlLib.Internal.Helpers.WordB ( string  val,
int  byteNum 
)
inlinestatic
59 {
60 if (byteNum >= 4)
61 {
62 return "";
63 }
64
65 return TruncateLeft(val, 8).PadLeft(8, '0').Substring(byteNum * 2, 2);
66 }

◆ WordH()

static string BrawlLib.Internal.Helpers.WordH ( string  val,
int  wordNum 
)
inlinestatic
49 {
50 if (wordNum >= 2)
51 {
52 return "";
53 }
54
55 return TruncateLeft(val, 8).PadLeft(8, '0').Substring(wordNum * 4, 4);
56 }

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