BrawlCrate v0.41
Wii File Editor
Loading...
Searching...
No Matches
Public Member Functions | Static Protected Member Functions | Properties | List of all members
BrawlCrate.NodeWrappers.MDefWrapper Class Reference
Inheritance diagram for BrawlCrate.NodeWrappers.MDefWrapper:
BrawlCrate.NodeWrappers.GenericWrapper BrawlCrate.NodeWrappers.BaseWrapper BrawlCrate.NodeWrappers.MultiSelectableWrapper

Public Member Functions

 MDefWrapper ()
 
void LoadModel ()
 
void SaveEvents ()
 
void SaveParameters ()
 
void SaveEventSyntax ()
 
void SaveAttributes ()
 
void SaveRequirements ()
 
void SaveEnums ()
 
void SaveMovesetData ()
 
- Public Member Functions inherited from BrawlCrate.NodeWrappers.GenericWrapper
 GenericWrapper (IWin32Window owner)
 
 GenericWrapper ()
 
virtual void Sort ()
 
void MoveUp ()
 
virtual void MoveUp (bool select)
 
void MoveDown ()
 
virtual void MoveDown (bool select)
 
void DeleteSelected ()
 
void ExportSelected ()
 
virtual string Export ()
 
virtual void OnExport (string outPath)
 
virtual void Replace ()
 
virtual void OnReplace (string inStream)
 
void Restore ()
 
virtual void Delete ()
 
void Rename ()
 
virtual ResourceNode Duplicate ()
 
virtual ResourceNode Duplicate (bool changeName)
 
- Public Member Functions inherited from BrawlCrate.NodeWrappers.BaseWrapper
void Link (ResourceNode res)
 
void Unlink ()
 

Static Protected Member Functions

static void LoadModelAction (object sender, EventArgs e)
 
static void SaveDataAction (object sender, EventArgs e)
 
- Static Protected Member Functions inherited from BrawlCrate.NodeWrappers.GenericWrapper
static void MoveUpAction (object sender, EventArgs e)
 
static void MoveDownAction (object sender, EventArgs e)
 
static void ExportAction (object sender, EventArgs e)
 
static void ExportSelectedAction (object sender, EventArgs e)
 
static void DeleteSelectedAction (object sender, EventArgs e)
 
static void DuplicateAction (object sender, EventArgs e)
 
static void ReplaceAction (object sender, EventArgs e)
 
static void RestoreAction (object sender, EventArgs e)
 
static void DeleteAction (object sender, EventArgs e)
 
static void RenameAction (object sender, EventArgs e)
 
static void SortAction (object sender, EventArgs e)
 
- Static Protected Member Functions inherited from BrawlCrate.NodeWrappers.BaseWrapper
static T GetInstance< T > ()
 
static IEnumerable< T > GetInstances< T > ()
 

Properties

override string ExportFilter [get]
 
- Properties inherited from BrawlCrate.NodeWrappers.GenericWrapper
virtual ContextMenuStrip MultiSelectMenuStrip [get]
 
virtual string DefaultName [get]
 
virtual string ExportFilter [get]
 
virtual string ImportFilter [get]
 
virtual string ReplaceFilter [get]
 
- Properties inherited from BrawlCrate.NodeWrappers.BaseWrapper
ResourceNode Resource [get]
 
virtual ? Color DefaultBackColor [get]
 
virtual ? Color DefaultForeColor [get]
 
- Properties inherited from BrawlCrate.NodeWrappers.MultiSelectableWrapper
ContextMenuStrip MultiSelectMenuStrip [get]
 

Additional Inherited Members

- Static Public Member Functions inherited from BrawlCrate.NodeWrappers.BaseWrapper
static BaseWrapper[] GetAllNodes (BaseWrapper root)
 
static BaseWrapper Wrap (ResourceNode node)
 
static BaseWrapper Wrap (IWin32Window owner, ResourceNode node)
 
- Static Public Attributes inherited from BrawlCrate.NodeWrappers.BaseWrapper
static IWin32Window _owner
 
- Protected Member Functions inherited from BrawlCrate.NodeWrappers.BaseWrapper
 BaseWrapper ()
 
- Protected Attributes inherited from BrawlCrate.NodeWrappers.BaseWrapper
bool _discovered
 
ResourceNode _resource
 
- Static Protected Attributes inherited from BrawlCrate.NodeWrappers.BaseWrapper
static readonly ContextMenuStrip _emptyMenu = new ContextMenuStrip()
 

Constructor & Destructor Documentation

◆ MDefWrapper()

BrawlCrate.NodeWrappers.MDefWrapper.MDefWrapper ( )
inline
59 {
60 ContextMenuStrip = _menu;
61 }

Member Function Documentation

◆ LoadModel()

void BrawlCrate.NodeWrappers.MDefWrapper.LoadModel ( )
inline
66 {
67 OpenFileDialog o = new OpenFileDialog();
68 o.Filter = "All Available Formats (*.mdl0, *.pac)|*.mdl0;*.pac|" + "MDL0 Raw Model (*.mdl0)|*.mdl0|" +
69 "PAC Archive (*.pac)|*.pac";
70 o.Title = "Please select a file to load a model from.";
71 if (o.ShowDialog() == DialogResult.OK)
72 {
73 if (o.FileName.EndsWith(".pac", StringComparison.OrdinalIgnoreCase))
74 {
75 ResourceNode r = (ARCNode) NodeFactory.FromFile(null, o.FileName);
76 for (int i = 0; i < 3; i++)
77 {
78 if (r.Children.Count > 0)
79 {
80 r = r.Children[0];
81 }
82 }
83
84 if (r is MDL0Node)
85 {
86 if ((((MoveDefNode) _resource)._model = (MDL0Node) r) != null)
87 {
88 ((MoveDefNode) _resource)._model.Populate();
89 }
90 }
91 }
92 else if (o.FileName.EndsWith(".mdl0", StringComparison.OrdinalIgnoreCase))
93 {
94 if ((((MoveDefNode) _resource)._model = (MDL0Node) NodeFactory.FromFile(null, o.FileName)) != null)
95 {
96 ((MoveDefNode) _resource)._model.Populate();
97 }
98 }
99 }
100 }
ResourceNode _resource
Definition: BaseWrapper.cs:76
Definition: ARCNode.cs:16
Definition: MDL0Node.cs:24
Definition: MoveDefNode.cs:287
Definition: NodeFactory.cs:18
static ResourceNode FromFile(ResourceNode parent, string path)
Definition: NodeFactory.cs:69
Definition: ResourceNode.cs:129
List< ResourceNode > Children
Definition: ResourceNode.cs:262

◆ LoadModelAction()

static void BrawlCrate.NodeWrappers.MDefWrapper.LoadModelAction ( object  sender,
EventArgs  e 
)
inlinestaticprotected
36 {
37 GetInstance<MDefWrapper>().LoadModel();
38 }

◆ SaveAttributes()

void BrawlCrate.NodeWrappers.MDefWrapper.SaveAttributes ( )
inline
274 {
275 if (!Directory.Exists(Application.StartupPath + "/MovesetData"))
276 {
277 Directory.CreateDirectory(Application.StartupPath + "/MovesetData");
278 }
279
281
282 if (node.iRequirements == null ||
283 node.AttributeArray == null ||
284 node.iAirGroundStats == null ||
285 node.iCollisionStats == null)
286 {
287 node.LoadOtherData();
288 }
289
290 bool go = true;
291 string attributes = Application.StartupPath + "/MovesetData/Attributes.txt";
292
293 if (File.Exists(attributes))
294 {
295 if (MessageBox.Show("Do you want to overwrite Attributes.txt in the MovesetData folder?",
296 "Overwrite Permission", MessageBoxButtons.YesNo) == DialogResult.Yes)
297 {
298 go = true;
299 }
300 else
301 {
302 go = false;
303 }
304 }
305 else
306 {
307 go = true;
308 }
309
310 if (go)
311 {
312 using (StreamWriter file = new StreamWriter(attributes))
313 {
314 foreach (AttributeInfo i in node.AttributeArray)
315 {
316 file.WriteLine(i._name);
317 file.WriteLine(i._description);
318 file.WriteLine(i._type);
319 file.WriteLine();
320 }
321 }
322 }
323
324 go = true;
325
326 if (!Directory.Exists(Application.StartupPath + "/MovesetData/CharSpecific"))
327 {
328 Directory.CreateDirectory(Application.StartupPath + "/MovesetData/CharSpecific");
329 }
330
331 string Params = Application.StartupPath + "/MovesetData/CharSpecific/" + _resource.Parent.Name + ".txt";
332
333 if (File.Exists(Params))
334 {
335 if (MessageBox.Show(
336 "Do you want to overwrite " + _resource.Parent.Name +
337 ".txt in the MovesetData/CharSpecific folder?", "Overwrite Permission",
338 MessageBoxButtons.YesNo) == DialogResult.Yes)
339 {
340 go = true;
341 }
342 else
343 {
344 go = false;
345 }
346 }
347 else
348 {
349 go = true;
350 }
351
352 if (go)
353 {
354 using (StreamWriter file = new StreamWriter(Params))
355 {
356 foreach (KeyValuePair<string, SectionParamInfo> i in node.Params)
357 {
358 file.WriteLine(i.Key);
359 file.WriteLine(i.Value._newName);
360 foreach (AttributeInfo a in i.Value._attributes)
361 {
362 file.WriteLine(a._name);
363 file.WriteLine(a._description);
364 file.WriteLine(a._type);
365 file.WriteLine();
366 }
367
368 file.WriteLine();
369 }
370 }
371 }
372 }
Definition: AttributeInfo.cs:9
string _name
Definition: AttributeInfo.cs:10
int _type
Definition: AttributeInfo.cs:12
string _description
Definition: AttributeInfo.cs:11
AttributeInfo[] AttributeArray
Definition: MoveDefNode.cs:3442
string[] iRequirements
Definition: MoveDefNode.cs:3438
string[] iAirGroundStats
Definition: MoveDefNode.cs:3439
string[] iCollisionStats
Definition: MoveDefNode.cs:3440
Dictionary< string, SectionParamInfo > Params
Definition: MoveDefNode.cs:3443
void LoadOtherData()
Definition: MoveDefNode.cs:3509
ResourceNode Parent
Definition: ResourceNode.cs:245
virtual string Name
Definition: ResourceNode.cs:223

◆ SaveDataAction()

static void BrawlCrate.NodeWrappers.MDefWrapper.SaveDataAction ( object  sender,
EventArgs  e 
)
inlinestaticprotected
41 {
42 GetInstance<MDefWrapper>().SaveMovesetData();
43 }

◆ SaveEnums()

void BrawlCrate.NodeWrappers.MDefWrapper.SaveEnums ( )
inline
424 {
425 if (!Directory.Exists(Application.StartupPath + "/MovesetData"))
426 {
427 Directory.CreateDirectory(Application.StartupPath + "/MovesetData");
428 }
429
431
432 if (node.iRequirements == null ||
433 node.AttributeArray == null ||
434 node.iAirGroundStats == null ||
435 node.iCollisionStats == null)
436 {
437 node.LoadOtherData();
438 }
439
440 if (MoveDefNode.EventDictionary == null)
441 {
443 }
444
445 bool go = true;
446 string airground = Application.StartupPath + "/MovesetData/AirGroundStats.txt";
447 string collision = Application.StartupPath + "/MovesetData/CollisionStats.txt";
448 string gfx = Application.StartupPath + "/MovesetData/GFXFiles.txt";
449 string enums = Application.StartupPath + "/MovesetData/Enums.txt";
450
451 if (File.Exists(airground))
452 {
453 if (MessageBox.Show("Do you want to overwrite AirGroundStats.txt in the MovesetData folder?",
454 "Overwrite Permission", MessageBoxButtons.YesNo) == DialogResult.Yes)
455 {
456 go = true;
457 }
458 else
459 {
460 go = false;
461 }
462 }
463 else
464 {
465 go = true;
466 }
467
468 if (go)
469 {
470 using (StreamWriter file = new StreamWriter(airground))
471 {
472 foreach (string i in node.iAirGroundStats)
473 {
474 file.WriteLine(i);
475 }
476 }
477 }
478
479 if (File.Exists(collision))
480 {
481 if (MessageBox.Show("Do you want to overwrite CollisionStats.txt in the MovesetData folder?",
482 "Overwrite Permission", MessageBoxButtons.YesNo) == DialogResult.Yes)
483 {
484 go = true;
485 }
486 else
487 {
488 go = false;
489 }
490 }
491 else
492 {
493 go = true;
494 }
495
496 if (go)
497 {
498 using (StreamWriter file = new StreamWriter(collision))
499 {
500 foreach (string i in node.iCollisionStats)
501 {
502 file.WriteLine(i);
503 }
504 }
505 }
506
507 if (File.Exists(gfx))
508 {
509 if (MessageBox.Show("Do you want to overwrite GFXFiles.txt in the MovesetData folder?",
510 "Overwrite Permission", MessageBoxButtons.YesNo) == DialogResult.Yes)
511 {
512 go = true;
513 }
514 else
515 {
516 go = false;
517 }
518 }
519 else
520 {
521 go = true;
522 }
523
524 if (go)
525 {
526 using (StreamWriter file = new StreamWriter(gfx))
527 {
528 foreach (string i in node.iGFXFiles)
529 {
530 file.WriteLine(i);
531 }
532 }
533 }
534
535 if (File.Exists(enums))
536 {
537 if (MessageBox.Show("Do you want to overwrite Enums.txt in the MovesetData folder?",
538 "Overwrite Permission", MessageBoxButtons.YesNo) == DialogResult.Yes)
539 {
540 go = true;
541 }
542 else
543 {
544 go = false;
545 }
546 }
547 else
548 {
549 go = true;
550 }
551
552 if (go)
553 {
554 //list of enum dictionaries
555 List<Dictionary<int, List<string>>> EnumList = new List<Dictionary<int, List<string>>>();
556 //enum index, event id, param index list
557 Dictionary<int, Dictionary<long, List<int>>> EnumIds =
558 new Dictionary<int, Dictionary<long, List<int>>>();
559 //remap events and enums
560 foreach (ActionEventInfo info in MoveDefNode.EventDictionary.Values)
561 {
562 if (info.Enums != null && info.Enums.Count > 0)
563 {
564 List<int> p = new List<int>();
565
566 bool has = false;
567 int index = -1;
568 foreach (Dictionary<int, List<string>> t in EnumList)
569 {
570 bool match = true;
571 index++;
572 foreach (int g in info.Enums.Keys)
573 {
574 if (t.ContainsKey(g))
575 {
576 int r = 0;
577 foreach (string s in t[g])
578 {
579 if (s != info.Enums[g][r++])
580 {
581 match = false;
582 break;
583 }
584 }
585 }
586 else
587 {
588 match = false;
589 }
590 }
591
592 if (match)
593 {
594 has = true;
595 break;
596 }
597
598 continue;
599 }
600
601 if (!has)
602 {
603 EnumList.Add(info.Enums);
604 index = EnumList.Count - 1;
605 }
606
607 if (!EnumIds.ContainsKey(index))
608 {
609 EnumIds.Add(index, new Dictionary<long, List<int>>());
610 }
611
612 foreach (int i in info.Enums.Keys)
613 {
614 p.Add(i);
615 }
616
617 EnumIds[index].Add(info.idNumber, p);
618 }
619 }
620
621 using (StreamWriter file = new StreamWriter(enums))
622 {
623 int i = 0;
624 foreach (Dictionary<int, List<string>> d in EnumList)
625 {
626 Dictionary<long, List<int>> events = EnumIds[i];
627 foreach (KeyValuePair<long, List<int>> ev in events)
628 {
629 file.WriteLine(Helpers.Hex8(ev.Key));
630 foreach (int v in ev.Value)
631 {
632 file.WriteLine(v);
633 }
634
635 file.WriteLine();
636 }
637
638 file.WriteLine();
639 foreach (int x in d.Keys)
640 {
641 if (d[x] != null && d[x].Count > 0)
642 {
643 foreach (string value in d[x])
644 {
645 file.WriteLine(value);
646 }
647 }
648 }
649
650 file.WriteLine();
651 i++;
652 }
653 }
654 }
655 }
Definition: ActionEventInfo.cs:7
long idNumber
Definition: ActionEventInfo.cs:80
Dictionary< int, List< string > > Enums
Definition: ActionEventInfo.cs:90
Definition: Helpers.cs:7
static string Hex8(int val)
Definition: Helpers.cs:33
string[] iGFXFiles
Definition: MoveDefNode.cs:3441
static SortedDictionary< long, ActionEventInfo > EventDictionary
Definition: MoveDefNode.cs:305
static void LoadEventDictionary()
Definition: MoveDefNode.cs:312

◆ SaveEvents()

void BrawlCrate.NodeWrappers.MDefWrapper.SaveEvents ( )
inline
103 {
104 if (!Directory.Exists(Application.StartupPath + "/MovesetData"))
105 {
106 Directory.CreateDirectory(Application.StartupPath + "/MovesetData");
107 }
108
110
111 if (MoveDefNode.EventDictionary == null)
112 {
114 }
115
116 bool go = true;
117 string events = Application.StartupPath + "/MovesetData/Events.txt";
118 if (File.Exists(events))
119 {
120 if (MessageBox.Show("Do you want to overwrite Events.txt in the MovesetData folder?",
121 "Overwrite Permission", MessageBoxButtons.YesNo) == DialogResult.Yes)
122 {
123 go = true;
124 }
125 else
126 {
127 go = false;
128 }
129 }
130 else
131 {
132 go = true;
133 }
134
135 if (go)
136 {
137 using (StreamWriter file = new StreamWriter(events))
138 {
139 foreach (ActionEventInfo info in MoveDefNode.EventDictionary.Values)
140 {
141 file.WriteLine(Helpers.Hex8(info.idNumber));
142 file.WriteLine(info._name);
143 file.WriteLine(info._description);
144 string s = "";
145 foreach (int i in info.defaultParams)
146 {
147 s += i;
148 }
149
150 file.WriteLine(s);
151 file.WriteLine();
152 }
153 }
154 }
155 }
string _description
Definition: ActionEventInfo.cs:82
long[] defaultParams
Definition: ActionEventInfo.cs:88
string _name
Definition: ActionEventInfo.cs:81

◆ SaveEventSyntax()

void BrawlCrate.NodeWrappers.MDefWrapper.SaveEventSyntax ( )
inline
221 {
222 if (!Directory.Exists(Application.StartupPath + "/MovesetData"))
223 {
224 Directory.CreateDirectory(Application.StartupPath + "/MovesetData");
225 }
226
228
229 if (MoveDefNode.EventDictionary == null)
230 {
232 }
233
234 bool go = true;
235 string syntax = Application.StartupPath + "/MovesetData/EventSyntax.txt";
236
237 if (File.Exists(syntax))
238 {
239 if (MessageBox.Show("Do you want to overwrite EventSyntax.txt in the MovesetData folder?",
240 "Overwrite Permission", MessageBoxButtons.YesNo) == DialogResult.Yes)
241 {
242 go = true;
243 }
244 else
245 {
246 go = false;
247 }
248 }
249 else
250 {
251 go = true;
252 }
253
254 if (go)
255 {
256 using (StreamWriter file = new StreamWriter(syntax))
257 {
258 foreach (ActionEventInfo info in MoveDefNode.EventDictionary.Values)
259 {
260 if (string.IsNullOrEmpty(info._syntax))
261 {
262 continue;
263 }
264
265 file.WriteLine(Helpers.Hex8(info.idNumber));
266 file.WriteLine(info._syntax);
267 file.WriteLine();
268 }
269 }
270 }
271 }
string _syntax
Definition: ActionEventInfo.cs:83

◆ SaveMovesetData()

void BrawlCrate.NodeWrappers.MDefWrapper.SaveMovesetData ( )
inline
658 {
659 SaveEvents();
664 SaveEnums();
665 }
void SaveRequirements()
Definition: MDefWrapper.cs:374
void SaveParameters()
Definition: MDefWrapper.cs:157
void SaveAttributes()
Definition: MDefWrapper.cs:273
void SaveEventSyntax()
Definition: MDefWrapper.cs:220
void SaveEvents()
Definition: MDefWrapper.cs:102
void SaveEnums()
Definition: MDefWrapper.cs:423

◆ SaveParameters()

void BrawlCrate.NodeWrappers.MDefWrapper.SaveParameters ( )
inline
158 {
159 if (!Directory.Exists(Application.StartupPath + "/MovesetData"))
160 {
161 Directory.CreateDirectory(Application.StartupPath + "/MovesetData");
162 }
163
165
166 if (MoveDefNode.EventDictionary == null)
167 {
169 }
170
171 bool go = true;
172 string parameters = Application.StartupPath + "/MovesetData/Parameters.txt";
173
174 if (File.Exists(parameters))
175 {
176 if (MessageBox.Show("Do you want to overwrite Parameters.txt in the MovesetData folder?",
177 "Overwrite Permission", MessageBoxButtons.YesNo) == DialogResult.Yes)
178 {
179 go = true;
180 }
181 else
182 {
183 go = false;
184 }
185 }
186 else
187 {
188 go = true;
189 }
190
191 if (go)
192 {
193 using (StreamWriter file = new StreamWriter(parameters))
194 {
195 foreach (ActionEventInfo info in MoveDefNode.EventDictionary.Values)
196 {
197 if (info.Params != null && info.Params.Length > 0)
198 {
199 file.WriteLine(Helpers.Hex8(info.idNumber));
200 for (int i = 0; i < info.Params.Length; i++)
201 {
202 file.WriteLine(info.Params[i]);
203 if (info.pDescs.Length > i)
204 {
205 file.WriteLine(info.pDescs[i]);
206 }
207 else
208 {
209 file.WriteLine();
210 }
211 }
212
213 file.WriteLine();
214 }
215 }
216 }
217 }
218 }
string[] pDescs
Definition: ActionEventInfo.cs:86
string[] Params
Definition: ActionEventInfo.cs:85

◆ SaveRequirements()

void BrawlCrate.NodeWrappers.MDefWrapper.SaveRequirements ( )
inline
375 {
376 if (!Directory.Exists(Application.StartupPath + "/MovesetData"))
377 {
378 Directory.CreateDirectory(Application.StartupPath + "/MovesetData");
379 }
380
382
383 if (node.iRequirements == null ||
384 node.AttributeArray == null ||
385 node.iAirGroundStats == null ||
386 node.iCollisionStats == null)
387 {
388 node.LoadOtherData();
389 }
390
391 bool go = true;
392 string requirements = Application.StartupPath + "/MovesetData/Requirements.txt";
393
394 if (File.Exists(requirements))
395 {
396 if (MessageBox.Show("Do you want to overwrite Requirements.txt in the MovesetData folder?",
397 "Overwrite Permission", MessageBoxButtons.YesNo) == DialogResult.Yes)
398 {
399 go = true;
400 }
401 else
402 {
403 go = false;
404 }
405 }
406 else
407 {
408 go = true;
409 }
410
411 if (go)
412 {
413 using (StreamWriter file = new StreamWriter(requirements))
414 {
415 foreach (string i in node.iRequirements)
416 {
417 file.WriteLine(i);
418 }
419 }
420 }
421 }

Property Documentation

◆ ExportFilter

override string BrawlCrate.NodeWrappers.MDefWrapper.ExportFilter
get

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