-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathTagEditorControl.xaml.cs
1760 lines (1509 loc) · 58.5 KB
/
TagEditorControl.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
using System;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using InfiniteRuntimeTagViewer.Halo.TagObjects;
using InfiniteRuntimeTagViewer.Interface.Windows;
using AvalonDock.Controls;
using AvalonDock.Layout;
using Memory;
using System.Linq;
using static InfiniteRuntimeTagViewer.MainWindow;
using InfiniteRuntimeTagViewer.Halo;
namespace InfiniteRuntimeTagViewer.Interface.Controls
{
/// <summary>
/// Interaction logic for TagEditorControl.xaml
/// </summary>
public partial class TagEditorControl : IDisposable
{
private MainWindow _mainWindow;
private readonly Mem _m;
public LayoutDocument? LayoutDocument { get; internal set; }
public Button? TheLastTagrefButtonWePressed { get; set; } // since we did it for the window why not also do it for the button
private bool disposedValue;
public TagEditorControl(MainWindow mw)
{
_mainWindow = mw;
_m = _mainWindow.M;
InitializeComponent();
}
protected virtual void Dispose(bool disposing)
{
if (!disposedValue)
{
if (disposing)
{
// TODO: dispose managed state (managed objects)
}
// TODO: free unmanaged resources (unmanaged objects) and override finalizer
// TODO: set large fields to null
disposedValue = true;
}
}
// TODO: override finalizer only if 'Dispose(bool disposing)' has code to free unmanaged resources
~TagEditorControl()
{
int debugMeme = 0;
}
public void Inhale_tag(string tagID) // i love dictionaries
{
TagStruct loadingTag = _mainWindow.TagsList[tagID];
Tagname_text.Text = _mainWindow.convert_ID_to_tag_name(loadingTag.ObjectId);
tagID_text.Text = "ID: " + loadingTag.ObjectId;
tagdatnum_text.Text = "Datnum: " + loadingTag.Datnum;
tagdata_text.Text = "Tag data address: 0x" + loadingTag.TagData.ToString("X");
tagfilter_text.Text = "";
tagview_panels.Children.Clear();
// OK, now we do a proper check to see if this tag is loaded, finally looked into this
try // never done this before and i hope im doing it terribly wrong
{
// pointer check
TagValueBlock p_block = new() { HorizontalAlignment = HorizontalAlignment.Left };
p_block.value_type.Text = "Pointer check";
p_block.value.Text = _m.ReadLong((loadingTag.TagData).ToString("X")).ToString("X");
tagview_panels.Children.Add(p_block);
// ID check
TagValueBlock id_block = new() { HorizontalAlignment = HorizontalAlignment.Left };
id_block.value_type.Text = "ID check";
string checked_ID = BitConverter.ToString(_m.ReadBytes((loadingTag.TagData + 8).ToString("X"), 4)).Replace("-", string.Empty);
id_block.value.Text = checked_ID;
tagview_panels.Children.Add(id_block);
// Datnum check
TagValueBlock dat_block = new() { HorizontalAlignment = HorizontalAlignment.Left };
dat_block.value_type.Text = "Datnum check";
string checked_datnum = BitConverter.ToString(_m.ReadBytes((loadingTag.TagData + 12).ToString("X"), 4)).Replace("-", string.Empty);
dat_block.value.Text = checked_datnum;
tagview_panels.Children.Add(dat_block);
if (checked_ID != loadingTag.ObjectId || checked_datnum != loadingTag.Datnum)
{
TextBox tb1 = new TextBox { Text = "Datnum/ID mismatch; Tag appears to be unloaded, meaning it may not be active on the map, else try reloading the tags" };
tagview_panels.Children.Add(tb1);
return;
}
//if (TagLayouts.Tags.ContainsKey(loadingTag.TagGroup))
//{
Dictionary<long, TagLayouts.C> tags = TagLayouts.Tags(loadingTag.TagGroup);
readTagsAndCreateControls(loadingTag, 0, tags, loadingTag.TagData, tagview_panels, tagID+":");
//}
//else
//{
// TextBox tb = new TextBox { Text = "This tag isn't mapped out ):" };
// tagview_panels.Children.Add(tb);
//}
}
catch
{
TextBox tb = new TextBox { Text = "ran into an oopsie woopsie, this tag is probably broken/unloaded right now" };
tagview_panels.Children.Add(tb);
}
}
// hmm we need a system that reads the pointer and adds it
// also, we need to beable to read multiple tag things but i may put that on hold
public void recall_blockloop(TagStruct tagStruct, long tagOffset, KeyValuePair<long, TagLayouts.C> entry, long loadingTag, StackPanel parentpanel, string abso_whatever_it_was)
{
parentpanel.Children.Clear();
if (entry.Value.B != null)
{
try
{
readTagsAndCreateControls(tagStruct, tagOffset, entry.Value.B, loadingTag, parentpanel, abso_whatever_it_was);
}
catch
{
TextBox tb = new TextBox { Text = "this tagblock is fucked uwu" };
parentpanel.Children.Add(tb);
}
}
}
// for text boxes
private void value_TextChanged(object sender, TextChangedEventArgs e)
{
TextBox? tb = sender as TextBox;
TagEditorDefinition ted = tb.Tag as TagEditorDefinition;
System.Diagnostics.Debug.Assert(ted != null);
_mainWindow.AddPokeChange(ted, tb.Text);
// string[] s = tb.Tag.ToString().Split(":");
// _mainWindow.AddPokeChange(long.Parse(s[0]), s[1], tb.Text);
}
// for tag group
private void taggroup_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
ComboBox? cb = sender as ComboBox;
TagEditorDefinition ted = cb.Tag as TagEditorDefinition;
System.Diagnostics.Debug.Assert(ted != null);
string new_group = cb.SelectedValue.ToString();
if (new_group != "Null")
{
ted.MemoryType = "TagrefGroup";
_mainWindow.AddPokeChange(ted, new_group);
}
else
{
ted.MemoryType = "4Byte";
_mainWindow.AddPokeChange(ted, "-1");
}
//_mainWindow.AddPokeChange(long.Parse(s: cb.Tag.ToString()), "TagrefGroup", value: cb.SelectedValue.ToString());
// What the actual fuck is all of this? // it wouldnt let me get the owner UI element so i did what i needed
Grid? td = cb.Parent as Grid;
Button? b = td.Children[1] as Button;
TED_TagRefGroup? btnTed = b.Tag as TED_TagRefGroup;
btnTed.TagGroup = cb.SelectedValue.ToString();
//string[] s = b.Tag.ToString().Split(":");
//b.Tag = s[0] + ":" + cb.SelectedValue.ToString();
// THAT WAS PROBABLY THE MOST DODGY THING IVE EVER DONE WTFFFF
}
public void Gotobutton(object sender, RoutedEventArgs e)
{
Button? b = sender as Button;
string? sTagId = b.Tag.ToString();
//int iTagId = int.Parse(sTagId);
//if (sTagId != -1) // i forsee this becoming a problematic fix
_mainWindow.CreateTagEditorTabByTagIndex(sTagId);
}
private DependencyObject GetTopLevelControl(DependencyObject control)
{
DependencyObject? tmp = control;
DependencyObject? parent = null;
while ((tmp = VisualTreeHelper.GetParent(tmp)) != null)
{
parent = tmp;
}
return parent;
}
private T? GetTopLevelControlOfType<T>(DependencyObject control) where T : DependencyObject
{
DependencyObject? tmp = control;
T? target = default(T);
while ((tmp = VisualTreeHelper.GetParent(tmp)) != null)
{
// System.Diagnostics.Debug.WriteLine("- " + tmp.GetType());
if (tmp is T dependencyObject)
{
target = dependencyObject;
}
}
return target;
}
TagRefDropdown? trd;
private void TagRefButton(object sender, RoutedEventArgs e)
{
Button? b = sender as Button;
TED_TagRefGroup ted = b.Tag as TED_TagRefGroup;
System.Diagnostics.Debug.Assert(ted != null);
trd = new TagRefDropdown();
double trdWidth = trd.Width = b.ActualWidth + 116;
double trdHeight = trd.Height = 400;
//
{
Window? controlsWindow = GetTopLevelControlOfType<Window>((DependencyObject) sender);
// There seems to be no way to get the window, so we will find the LayoutDocumentPaneGroupControl
// instead and we can use that to crawl backwards through the Windows to find it.
LayoutDocumentPaneGroupControl? dockingPaneGroup = GetTopLevelControlOfType<LayoutDocumentPaneGroupControl>(b);
bool foundDockingWindow = false;
// Handle if we have a popped out window.
if (controlsWindow == null && dockingPaneGroup != null)
{
// Check if we can figure out where this docking pane is located
foreach (Window appWindow in Application.Current.Windows)
{
LayoutDocumentFloatingWindowControl? floatingWind = appWindow as LayoutDocumentFloatingWindowControl;
if (floatingWind == null)
{
continue;
}
// Make sure we have a FloatingWindowContentHost
object? floatingWindContHost = floatingWind.Content; // AvalonDock.Controls.LayoutFloatingWindowControl.FloatingWindowContentHost
if (floatingWindContHost == null && floatingWindContHost.GetType().Name != "FloatingWindowContentHost")
{
continue;
}
// Get the public property "Content", we cant get this normally because this
// is a internal / sealed class. We need to use reflection to get our
// grubby mitts on it.
System.Reflection.PropertyInfo? prop = floatingWindContHost.GetType().GetProperty("Content");
LayoutDocumentPaneGroupControl? contentResult = prop.GetValue(floatingWindContHost) as LayoutDocumentPaneGroupControl;
// Check if this is our DockingPanelGroup
if (contentResult == dockingPaneGroup)
{
// Get the control's point relative to the parent window.
Point relativeControlLocation = b.TranslatePoint(new Point(0, b.ActualHeight), appWindow);
// Set the location to the parent window + control location
// This sets it to just above the control, by adding the height by a factor of 1.5 it seems
// to be an almost fit.
trd.Left = appWindow.GetWindowLeft() + relativeControlLocation.X;
trd.Top = appWindow.GetWindowTop() + relativeControlLocation.Y;
foundDockingWindow = true;
break;
}
}
}
// If we can get the topmost window, use a precise approach
if (controlsWindow != null)
{
// Get the control's point relative to the parent window.
Point relativeControlLocation = b.TranslatePoint(new Point(0, b.ActualHeight), controlsWindow);
// Set the location to the parent window + control location
// This sets it to just above the control, by adding the height by a factor of 1.5 it seems
// to be an almost fit.
trd.Left = controlsWindow.GetWindowLeft() + relativeControlLocation.X;
trd.Top = controlsWindow.GetWindowTop() + relativeControlLocation.Y;
}
else if (foundDockingWindow == false)
{
Point myButtonLocation = b.PointToScreen(new Point(0, 0));
trd.Left = myButtonLocation.X - 8;
trd.Top = myButtonLocation.Y + 1;
}
}
trd.MainWindow = _mainWindow;
TheLastTagrefButtonWePressed = b;
List<string> big = new();
List<string> targets = new();
// Null type
//TreeViewItem? tvi = new()
//{
// Header = _mainWindow.convert_ID_to_tag_name("FFFFFFFF"),
// Tag = new TED_TagRefGroup(ted)
// {
// MemoryType = "TagrefTag",
// DatNum = "FFFFFFFF"
// } //s[0] + ":" + "FFFFFFFF"
//};
big.Add(_mainWindow.convert_ID_to_tag_name("FFFFFFFF"));
targets.Add("FFFFFFFF");
//trd.tag_select_panel.Items.Add(tvi);
//tvi.Selected += update_tagref;
bool filter_unmapped = _mainWindow.CbxFilterUnloaded.IsChecked;
foreach (KeyValuePair<string, TagStruct> tg in _mainWindow.TagsList.OrderBy(key => key.Value.TagFullName)) // should probably store this instead of sorting everytime
{
if (tg.Value.TagGroup == ted.TagGroup)
{
if (filter_unmapped && tg.Value.unloaded == true)
{
continue;
}
big.Add(_mainWindow.convert_ID_to_tag_name(tg.Key));
targets.Add(tg.Value.Datnum);
//TreeViewItem? tvi2 = new()
//{
// Header = _mainWindow.convert_ID_to_tag_name(tg.Key),
// //Tag = s[0] + ":" + tg.Datnum
// Tag = new TED_TagRefGroup(ted)
// {
// MemoryType = "TagrefTag",
// DatNum = tg.Value.Datnum
// }
//};
//trd.tag_select_panel.Items.Add(tvi2);
//tvi2.Selected += update_tagref;
}
}
trd.TheLastTagrefButtonWePressed = TheLastTagrefButtonWePressed;
trd.ted = ted;
trd.datnums = targets;
trd.source = big;
trd.tag_select_panel.ItemsSource = big;
trd.Show();
return;
}
// this is for our dropdown thingo for changing tag refs
// had to adapt this to bealbe to read tagblocks and forgot to allow it to iterate through them *sigh* good enough for now
// second time this happened, i wish i had more time in a day to get this all done
private void readTagsAndCreateControls(TagStruct tagStruct, long startingTagOffset, Dictionary<long, TagLayouts.C> tagDefinitions, long address, StackPanel parentpanel, string absolute_address_chain)
{
// im hoping no one was using 'startingTagOffset' for anything spefic // repurposed
KeyValuePair<long, TagLayouts.C> prevEntry;
foreach (KeyValuePair<long, TagLayouts.C> entry in tagDefinitions)
{
entry.Value.MemoryAddress = address + entry.Key;
entry.Value.AbsoluteTagOffset = absolute_address_chain +"," +(entry.Key + startingTagOffset);
switch (entry.Value.T)
{
case "Comment":
CommentBlock? vb0 = new() { HorizontalAlignment = HorizontalAlignment.Left };
parentpanel.Children.Add(vb0);
vb0.comment.Text = entry.Value.N;
break;
case "FUNCTION":
long functAddress = _m.ReadLong((address + entry.Key).ToString("X"));
FunctionBlock? fb1 = new(this, tagStruct){HorizontalAlignment = HorizontalAlignment.Left};
// BASE ADDRESS FOR FUNCTION
fb1.tagblock_address.Text = "0x" + functAddress.ToString("X");
fb1.tagblock_title.Text = entry.Value.N;
string BytelengthCount = _m.ReadInt((address + entry.Key + 20).ToString("X")).ToString();
fb1.tagblock_count.Text = BytelengthCount;
parentpanel.Children.Add(fb1);
fb1.tagblock_address.Tag = new TagEditorDefinition()
{
MemoryType = "Pointer",
TagDef = entry.Value,
TagStruct = tagStruct,
OffsetOverride = entry.Value.AbsoluteTagOffset
};
fb1.tagblock_address.TextChanged += value_TextChanged;
fb1.tagblock_count.Tag = new TagEditorDefinition()
{
MemoryType = "4Byte",
TagDef = entry.Value,
TagStruct = tagStruct,
OffsetOverride = SUSSY_BALLS(entry.Value.AbsoluteTagOffset, 20),
};
fb1.tagblock_count.TextChanged += value_TextChanged;
try
{
fb1.BlockAddress = functAddress;
// next base for thingos
if (functAddress != 0)
{
// 1st byte
TagValueBlock? fb_vb1 = new() { HorizontalAlignment = HorizontalAlignment.Left };
fb_vb1.value_type.Text = "Byte";
fb_vb1.value.Text = _m.ReadByte((functAddress).ToString("X")).ToString();
fb_vb1.value.Tag = new TagEditorDefinition()
{
MemoryType = "Byte",
TagDef = entry.Value,
TagStruct = tagStruct,
OffsetOverride = entry.Value.AbsoluteTagOffset + ",0"
};
fb_vb1.value.TextChanged += value_TextChanged;
fb_vb1.value_name.Text = "Function Type1";
fb1.dockpanel.Children.Add(fb_vb1);
// 2nd byte
TagValueBlock? fb_vb2 = new() { HorizontalAlignment = HorizontalAlignment.Left };
fb_vb2.value_type.Text = "Byte";
fb_vb2.value.Text = _m.ReadByte((functAddress + 1).ToString("X")).ToString();
fb_vb2.value.Tag = new TagEditorDefinition()
{
MemoryType = "Byte",
TagDef = entry.Value,
TagStruct = tagStruct,
OffsetOverride = entry.Value.AbsoluteTagOffset + ",1"
};
fb_vb2.value.TextChanged += value_TextChanged;
fb_vb2.value_name.Text = "Function Type2";
fb1.dockpanel.Children.Add(fb_vb2);
// 3rd byte
TagValueBlock? fb_vb3 = new() { HorizontalAlignment = HorizontalAlignment.Left };
fb_vb3.value_type.Text = "Byte";
fb_vb3.value.Text = _m.ReadByte((functAddress + 2).ToString("X")).ToString();
fb_vb3.value.Tag = new TagEditorDefinition()
{
MemoryType = "Byte",
TagDef = entry.Value,
TagStruct = tagStruct,
OffsetOverride = entry.Value.AbsoluteTagOffset + ",2"
};
fb_vb3.value.TextChanged += value_TextChanged;
fb_vb3.value_name.Text = "Function Type3";
fb1.dockpanel.Children.Add(fb_vb3);
// 4th byte
TagValueBlock? fb_vb4 = new() { HorizontalAlignment = HorizontalAlignment.Left };
fb_vb4.value_type.Text = "Byte";
fb_vb4.value.Text = _m.ReadByte((functAddress + 3).ToString("X")).ToString();
fb_vb4.value.Tag = new TagEditorDefinition()
{
MemoryType = "Byte",
TagDef = entry.Value,
TagStruct = tagStruct,
OffsetOverride = entry.Value.AbsoluteTagOffset + ",3"
};
fb_vb4.value.TextChanged += value_TextChanged;
fb_vb4.value_name.Text = "Function Type4";
fb1.dockpanel.Children.Add(fb_vb4);
// MIN FLOAT
TagValueBlock? fb_vb5 = new() { HorizontalAlignment = HorizontalAlignment.Left };
fb_vb5.value_type.Text = "Float";
fb_vb5.value.Text = _m.ReadFloat((functAddress + 4).ToString("X"), "", false).ToString();
fb_vb5.value.Tag = new TagEditorDefinition()
{
MemoryType = "Float",
TagDef = entry.Value,
TagStruct = tagStruct,
OffsetOverride = entry.Value.AbsoluteTagOffset + ",4"
};
fb_vb5.value.TextChanged += value_TextChanged;
fb_vb5.value_name.Text = "Min";
fb1.dockpanel.Children.Add(fb_vb5);
// MAX FLOAT
TagValueBlock? fb_vb6 = new() { HorizontalAlignment = HorizontalAlignment.Left };
fb_vb6.value_type.Text = "Float";
fb_vb6.value.Text = _m.ReadFloat((functAddress + 8).ToString("X"), "", false).ToString();
fb_vb6.value.Tag = new TagEditorDefinition()
{
MemoryType = "Float",
TagDef = entry.Value,
TagStruct = tagStruct,
OffsetOverride = entry.Value.AbsoluteTagOffset + ",8"
};
fb_vb6.value.TextChanged += value_TextChanged;
fb_vb6.value_name.Text = "Max";
fb1.dockpanel.Children.Add(fb_vb6);
// UNKNOWN1
TagValueBlock? fb_vb7 = new() { HorizontalAlignment = HorizontalAlignment.Left };
fb_vb7.value_type.Text = "Float";
fb_vb7.value.Text = _m.ReadFloat((functAddress + 12).ToString("X"), "", false).ToString();
fb_vb7.value.Tag = new TagEditorDefinition()
{
MemoryType = "Float",
TagDef = entry.Value,
TagStruct = tagStruct,
OffsetOverride = entry.Value.AbsoluteTagOffset + ",12"
};
fb_vb7.value.TextChanged += value_TextChanged;
fb_vb7.value_name.Text = "Unknown1";
fb1.dockpanel.Children.Add(fb_vb7);
// UNKNOWN2
TagValueBlock? fb_vb8 = new() { HorizontalAlignment = HorizontalAlignment.Left };
fb_vb8.value_type.Text = "Float";
fb_vb8.value.Text = _m.ReadFloat((functAddress + 16).ToString("X"), "", false).ToString();
fb_vb8.value.Tag = new TagEditorDefinition()
{
MemoryType = "Float",
TagDef = entry.Value,
TagStruct = tagStruct,
OffsetOverride = entry.Value.AbsoluteTagOffset + ",16"
};
fb_vb8.value.TextChanged += value_TextChanged;
fb_vb8.value_name.Text = "Unknown2";
fb1.dockpanel.Children.Add(fb_vb8);
// UNK MIN
TagValueBlock? fb_vb9 = new() { HorizontalAlignment = HorizontalAlignment.Left };
fb_vb9.value_type.Text = "Float";
fb_vb9.value.Text = _m.ReadFloat((functAddress + 20).ToString("X"), "", false).ToString();
fb_vb9.value.Tag = new TagEditorDefinition()
{
MemoryType = "Float",
TagDef = entry.Value,
TagStruct = tagStruct,
OffsetOverride = entry.Value.AbsoluteTagOffset + ",20"
};
fb_vb9.value.TextChanged += value_TextChanged;
fb_vb9.value_name.Text = "Unk Min";
fb1.dockpanel.Children.Add(fb_vb9);
// UNK MAX
TagValueBlock? fb_vb10 = new() { HorizontalAlignment = HorizontalAlignment.Left };
fb_vb10.value_type.Text = "Float";
fb_vb10.value.Text = _m.ReadFloat((functAddress + 24).ToString("X"), "", false).ToString();
fb_vb10.value.Tag = new TagEditorDefinition()
{
MemoryType = "Float",
TagDef = entry.Value,
TagStruct = tagStruct,
OffsetOverride = entry.Value.AbsoluteTagOffset + ",24"
};
fb_vb10.value.TextChanged += value_TextChanged;
fb_vb10.value_name.Text = "Unk Max";
fb1.dockpanel.Children.Add(fb_vb10);
// leftover bytes -- used for the curvature information
int leftoverbytes = _m.ReadInt((functAddress + 28).ToString("X"));
//
TagValueBlock? fb_vb11 = new() { HorizontalAlignment = HorizontalAlignment.Left };
fb_vb11.value_type.Text = "4Byte";
fb_vb11.value.Text = leftoverbytes.ToString();
fb_vb11.value.Tag = new TagEditorDefinition()
{
MemoryType = "4Byte",
TagDef = entry.Value,
TagStruct = tagStruct,
OffsetOverride = entry.Value.AbsoluteTagOffset + ",28"
};
fb_vb11.value.TextChanged += value_TextChanged;
fb_vb11.value_name.Text = "Curvature Bytecount";
fb1.dockpanel.Children.Add(fb_vb11);
// write the rest of the junk to here
if (leftoverbytes > 0)
{
TagValueBlock? fb_vb12 = new() { HorizontalAlignment = HorizontalAlignment.Left };
fb_vb12.value_type.Text = "Bytes or something";
fb_vb12.value.Text = BitConverter.ToString(_m.ReadBytes((address + entry.Key).ToString("X"), leftoverbytes)).Replace("-", string.Empty);
fb_vb12.value.Tag = new TagEditorDefinition()
{
MemoryType = "mmr3Hash",
TagDef = entry.Value,
TagStruct = tagStruct,
OffsetOverride = entry.Value.AbsoluteTagOffset + ",32"
};
fb_vb12.value.TextChanged += value_TextChanged;
fb_vb12.value_name.Text = "Curvature Bytes";
fb1.dockpanel.Children.Add(fb_vb12);
}
else
{
CommentBlock? vb99 = new() { HorizontalAlignment = HorizontalAlignment.Left };
fb1.dockpanel.Children.Add(vb99);
vb99.comment.Text = "no curvature";
}
}
}
catch
{
CommentBlock? vb99 = new() { HorizontalAlignment = HorizontalAlignment.Left };
fb1.dockpanel.Children.Add(vb99);
vb99.comment.Text = "this is what happens when i only add partial support for things";
}
break;
case "EnumGroup":
// make sure we got a enumgroup def
if (!(entry.Value is TagLayouts.EnumGroup))
{
continue;
}
TagLayouts.EnumGroup? fg3 = entry.Value as TagLayouts.EnumGroup;
EnumBlock eb1 = new EnumBlock() { HorizontalAlignment = HorizontalAlignment.Left };
foreach (KeyValuePair<int, string> gvsdahb in fg3.STR)
{
ComboBoxItem cbi = new() { Content=gvsdahb.Value };
eb1.enums.Items.Add(cbi);
}
if (fg3.A == 1)
{
int test_this = _m.ReadByte((address + entry.Key).ToString("X"));
if (eb1.enums.Items.Count >= test_this)
{
eb1.enums.SelectedIndex = test_this;
}
else
{
TextBox tb = new TextBox { Text = "the enum below is broken :(" };
parentpanel.Children.Add(tb);
}
eb1.ValueDefinition = new TagEditorDefinition()
{
MemoryType = "Byte",
TagDef = entry.Value,
TagStruct = tagStruct,
OffsetOverride = entry.Value.AbsoluteTagOffset
};
}
else if (fg3.A == 2)
{
int test_this = _m.Read2Byte((address + entry.Key).ToString("X"));
if (eb1.enums.Items.Count >= test_this)
{
eb1.enums.SelectedIndex = test_this;
}
else
{
TextBox tb = new TextBox { Text = "the enum below is broken :(" };
parentpanel.Children.Add(tb);
}
eb1.ValueDefinition = new TagEditorDefinition()
{
MemoryType = "2Byte",
TagDef = entry.Value,
TagStruct = tagStruct,
OffsetOverride = entry.Value.AbsoluteTagOffset
};
}
else if (fg3.A == 4)
{
int test_this = _m.ReadInt((address + entry.Key).ToString("X"));
if (eb1.enums.Items.Count >= test_this)
{
eb1.enums.SelectedIndex = test_this;
}
else
{
TextBox tb = new TextBox { Text = "the enum below is broken :(" };
parentpanel.Children.Add(tb);
}
eb1.ValueDefinition = new TagEditorDefinition()
{
MemoryType = "4Byte",
TagDef = entry.Value,
TagStruct = tagStruct,
OffsetOverride = entry.Value.AbsoluteTagOffset
};
}
else
{
string put_breakpoint_here;
eb1.ValueDefinition = new TagEditorDefinition()
{
MemoryType = "Enums",
TagDef = entry.Value,
TagStruct = tagStruct,
OffsetOverride = entry.Value.AbsoluteTagOffset
};
}
// add appropriate values to combobox
// read selected
parentpanel.Children.Add(eb1);
eb1.value_name.Text = fg3.N;
eb1.main = _mainWindow;
break;
case "4Byte":
TagValueBlock? vb1 = new() { HorizontalAlignment = HorizontalAlignment.Left };
vb1.value_type.Text = "4 Byte";
vb1.value.Text = _m.ReadInt((address + entry.Key).ToString("X")).ToString(); // (+entry.Key?) lmao, no wonder why it wasn't working
parentpanel.Children.Add(vb1);
//vb1.value.Tag = address + entry.Key + ":4Byte";
vb1.value.Tag = new TagEditorDefinition()
{
MemoryType = "4Byte",
TagDef = entry.Value,
TagStruct = tagStruct,
OffsetOverride = entry.Value.AbsoluteTagOffset
};
vb1.value.TextChanged += value_TextChanged;
vb1.value_name.Text = entry.Value.N;
break;
case "2Byte":
TagValueBlock? vb6 = new() { HorizontalAlignment = HorizontalAlignment.Left };
vb6.value_type.Text = "2 Byte";
vb6.value.Text = _m.Read2Byte((address + entry.Key).ToString("X")).ToString();
parentpanel.Children.Add(vb6);
vb6.value.Tag = new TagEditorDefinition()
{
MemoryType = "2Byte",
TagDef = entry.Value,
TagStruct = tagStruct,
OffsetOverride = entry.Value.AbsoluteTagOffset
};
vb6.value.TextChanged += value_TextChanged;
vb6.value_name.Text = entry.Value.N;
break;
case "Byte":
TagValueBlock? vb19 = new() { HorizontalAlignment = HorizontalAlignment.Left };
vb19.value_type.Text = "Byte";
vb19.value.Text = _m.ReadByte((address + entry.Key).ToString("X")).ToString();
parentpanel.Children.Add(vb19);
vb19.value.Tag = new TagEditorDefinition()
{
MemoryType = "Byte",
TagDef = entry.Value,
TagStruct = tagStruct,
OffsetOverride = entry.Value.AbsoluteTagOffset
};
vb19.value.TextChanged += value_TextChanged;
vb19.value_name.Text = entry.Value.N;
break;
case "Float":
TagValueBlock? vb2 = new() { HorizontalAlignment = HorizontalAlignment.Left };
vb2.value_type.Text = "Float";
vb2.value.Text = _m.ReadFloat((address + entry.Key).ToString("X")).ToString();
parentpanel.Children.Add(vb2);
vb2.value.Tag = new TagEditorDefinition()
{
MemoryType = "Float",
TagDef = entry.Value,
TagStruct = tagStruct,
OffsetOverride = entry.Value.AbsoluteTagOffset
};
vb2.value.TextChanged += value_TextChanged;
vb2.value_name.Text = entry.Value.N;
break;
case "TagRef":
TagRefBlock? tfb1 = new() { HorizontalAlignment = HorizontalAlignment.Left };
//tfb1.taggroup.Items.Add("Null");
List<string> swrign = new() { "Null" };
swrign.AddRange(_mainWindow.TagGroups.Keys);
//foreach (string s in _mainWindow.TagGroups.Keys)
//{
// tfb1.taggroup.Items.Add(s);
//}
tfb1.taggroup.ItemsSource = swrign;
string tagGroup = ReverseString(_m.ReadString((address + entry.Key + 20).ToString("X"), "", 4));
tfb1.taggroup.SelectedItem = tagGroup;
// read tagID rather than datnum // or rather, convert datnum to ID
try
{
string datNum = BitConverter.ToString(_m.ReadBytes((address + entry.Key + 24).ToString("X"), 4)).Replace("-", string.Empty);
string tagId = _mainWindow.get_tagid_by_datnum(datNum);
string tagName = _mainWindow.convert_ID_to_tag_name(tagId);
tfb1.tag_button.Content = tagName;
parentpanel.Children.Add(tfb1);
//tfb1.taggroup.Tag = (address + entry.Key + 20);
tfb1.taggroup.Tag = new TED_TagRefGroup()
{
MemoryType = "TagrefGroup",
TagId = tagId,
DatNum = datNum,
TagDef = entry.Value,
TagStruct = tagStruct,
OffsetOverride = SUSSY_BALLS(entry.Value.AbsoluteTagOffset, 20),
TagGroup = tagGroup
};
tfb1.taggroup.SelectionChanged += taggroup_SelectionChanged;
//tfb1.tag_button.Tag = (address + entry.Key + 24) + ":" + testGroup;
tfb1.tag_button.Tag = new TED_TagRefGroup()
{
MemoryType = tagGroup,
TagId = tagId,
DatNum = datNum,
TagDef = entry.Value,
TagStruct = tagStruct,
OffsetOverride = SUSSY_BALLS(entry.Value.AbsoluteTagOffset, 24),
TagGroup = tagGroup
};
tfb1.tag_button.Click += TagRefButton;
string id = _mainWindow.get_tagID_by_datnum(datNum);
// tag
tfb1.goto_button.Tag = id; //
tfb1.goto_button.Click += Gotobutton;
tfb1.value_name.Text = entry.Value.N;
}
catch
{
break;
}
break;
case "Pointer":
TagValueBlock? vb3 = new() { HorizontalAlignment = HorizontalAlignment.Left };
vb3.value_type.Text = "Pointer";
vb3.value.Text = _m.ReadLong((address + entry.Key).ToString("X")).ToString("X");
parentpanel.Children.Add(vb3);
vb3.value.Tag = new TagEditorDefinition()
{
MemoryType = "Pointer",
TagDef = entry.Value,
TagStruct = tagStruct,
OffsetOverride = entry.Value.AbsoluteTagOffset
};
vb3.value.TextChanged += value_TextChanged;
vb3.value_name.Text = entry.Value.N;
break;
case "Tagblock":
TagBlock? tb1 = new(this, tagStruct)
{
HorizontalAlignment = HorizontalAlignment.Left
};
long newAddress = _m.ReadLong((address + entry.Key).ToString("X"));
tb1.tagblock_address.Text = "0x" + newAddress.ToString("X");
long stringAddress = _m.ReadLong((address + entry.Key + 8).ToString("X"));
// switch either reading from mem or reading OUR tagblock name, just incase someone has to rename something for convienience or whatever
string our_name = entry.Value.N;
if (our_name == null)
{
tb1.tagblock_title.Text = _m.ReadString((address + entry.Key + 8).ToString("X") + ",0,0", "", 100); // this is the only thing that causes errors with unloaded tags
}
else
{
tb1.tagblock_title.Text = our_name;
}
//tb1.tagblock_title.Text = "Error: tag Unloaded";
//parentpanel.Children.Add(tb1);
string childrenCount = _m.ReadInt((address + entry.Key + 16).ToString("X")).ToString();
tb1.tagblock_count.Text = childrenCount;
parentpanel.Children.Add(tb1);
//tb1.tagblock_address.Tag = (address + entry.Key) + ":Pointer";
tb1.tagblock_address.Tag = new TagEditorDefinition()
{
MemoryType = "Pointer",
TagDef = entry.Value,
TagStruct = tagStruct,
OffsetOverride = entry.Value.AbsoluteTagOffset
};
tb1.tagblock_address.TextChanged += value_TextChanged;
//tb1.tagblock_count.Tag = (address + entry.Key + 16) + ":4Byte";
tb1.tagblock_count.Tag = new TagEditorDefinition()
{
MemoryType = "4Byte",
TagDef = entry.Value,
TagStruct = tagStruct,
OffsetOverride = SUSSY_BALLS(entry.Value.AbsoluteTagOffset, 16),
};
tb1.tagblock_count.TextChanged += value_TextChanged;
//tb1.indexbox.SelectionChanged += new SelectionChangedEventHandler(indexbox_SelectionChanged);
tb1.Children = entry;
tb1.BlockAddress = newAddress;
int childs = int.Parse(childrenCount);
if (childs > 2000000)
{
TextBox tb = new TextBox { Text = "ran into a major fucky wucky, some tagblock exceeded 2million entries" };
tagview_panels.Children.Add(tb);
return;
}
if (entry.Value.B != null) // this should optimize the hell outta opening tags // like we were literally instaniating 1million items for the levl tag
{
List<string> source_yummy = new List<string>();
for (int y = 0; y < childs; y++)
{
source_yummy.Add(y.ToString());
//tb1.indexbox.Items.Add(new ComboBoxItem { Content = y }); // this should be a combobox item?
}
tb1.indexbox.ItemsSource = source_yummy;
if (childs > 0)
{
tb1.indexbox.SelectedIndex = -1;
}
else
{
tb1.Expand_Collapse_Button.IsEnabled = false;
tb1.Expand_Collapse_Button.Content = "";
tb1.indexbox.IsEnabled = false;
}
}
else
{
tb1.Expand_Collapse_Button.IsEnabled = false;
tb1.Expand_Collapse_Button.Content = "";
tb1.indexbox.IsEnabled = false;
}
tb1.stored_num_on_index = 0;
//recall_blockloop(entry, new_address, tb1.dockpanel);
break;
case "TagStructBlock":
//--THIS DOESN'T WORK, DON'T USE. IF YOU WANT TO TRY TO GET IT WORKING, GOOD LUCK.
TagStructBlock? ts1 = new(this, tagStruct, entry, address + entry.Key)
{
HorizontalAlignment = HorizontalAlignment.Left
};
parentpanel.Children.Add(ts1);
ts1.tagblock_title.Text = entry.Value.N;
ts1.Children = entry;
break;
case "String":
TagValueBlock? vb4 = new() { HorizontalAlignment = HorizontalAlignment.Left };
vb4.value_type.Text = "String";
vb4.value.Text = _m.ReadString((address + entry.Key).ToString("X"), "", 100).ToString();
parentpanel.Children.Add(vb4);
//vb4.value.Tag = address + entry.Key + ":String";
vb4.value.Tag = new TagEditorDefinition()
{
MemoryType = "String",
TagDef = entry.Value,
TagStruct = tagStruct,
OffsetOverride = entry.Value.AbsoluteTagOffset
};
vb4.value.TextChanged += value_TextChanged;
vb4.value_name.Text = entry.Value.N;