-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDebugDialog.cs
1292 lines (1176 loc) · 49.3 KB
/
DebugDialog.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.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Text.RegularExpressions;
using System.IO;
using System.Runtime.Serialization;
namespace NFL2K5Tool
{
public partial class DebugDialog : Form
{
public DebugDialog()
{
InitializeComponent();
mResultsTextBox.StatusControl = mStatusLabel;
}
public GamesaveTool Tool { get; set; }
private byte[] SaveFile { get { return Tool.GameSaveData; } }
private void textBox1_TextChanged(object sender, EventArgs e)
{
UpdateText();
}
private void UpdateText()
{
int ch;
StringBuilder builder = new StringBuilder(20);
builder.Append("0x");
foreach (char c in textBox1.Text)
{
if (c == '*')
ch = 0;
else
ch = (int)c;
builder.Append(ch.ToString("X2"));
if (checkBox1.Checked)
{
builder.Append("00");
}
}
textBox2.Text = builder.ToString();
}
private void mFindButton_Click(object sender, EventArgs e)
{
FindLocations();
}
private void FindLocations()
{
mResultsTextBox.Clear();
List<long> locs = StaticUtils.FindStringInFile(textBox1.Text, SaveFile, 0, SaveFile.Length);
foreach (int loc in locs)
{
mResultsTextBox.AppendText(String.Format("{0:x}\n", loc));
}
}
private void textBox1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
FindLocations();
e.Handled = true;
}
}
// need to find pointers for non-players
private void mFindPointers_Click(object sender, EventArgs e)
{
mResultsTextBox.Clear();
List<long> locs = StaticUtils.FindStringInFile(textBox1.Text, SaveFile, 0, SaveFile.Length);
List<int> pointers;
for (int i = 0; i < locs.Count; i++)
{
pointers = FindPointersForLocation(locs[i]);
foreach (int dude in pointers)
{
mResultsTextBox.AppendText(dude.ToString("X"));
mResultsTextBox.AppendText("\r\n");
}
}
}
private List<int> FindPointersForLocation(long location)
{
List<int> pointerLocations = new List<int>();
int pointer = 0;
long dataLocation = 0;
int limit = this.SaveFile.Length - 4;
for (long i = 0; i < limit; i++)
{
pointer = SaveFile[i + 3] << 24;
pointer += SaveFile[i + 2] << 16;
pointer += SaveFile[i + 1] << 8;
pointer += SaveFile[i];
dataLocation = i + pointer - 1;
if (dataLocation == location)
{
pointerLocations.Add((int)i);
}
}
return pointerLocations;
}
private void mPointsToLocButton_Click(object sender, EventArgs e)
{
mResultsTextBox.Clear();
string val = textBox1.Text;
ShowPointersForLoc(val);
}
private void ShowPointersForLoc(string val)
{
if (val.StartsWith("0x"))
val = val.Substring(2);
try
{
mResultsTextBox.Clear();
int loc = Int32.Parse(val, System.Globalization.NumberStyles.AllowHexSpecifier);
List<int> pointers = FindPointersForLocation(loc);
foreach (int dude in pointers)
{
mResultsTextBox.AppendText(dude.ToString("X"));
mResultsTextBox.AppendText("\r\n");
}
if (pointers.Count == 0)
{
mResultsTextBox.Text = "Pointr to: "+ val + " Not found";
}
}
catch (Exception e)
{
mResultsTextBox.Text = e.Message;
}
}
private void UpdatePlayerNameTextBox()
{
int player = (int) mPlayerUpDown.Value;
mPlayerNameTextBox.Text = Tool.GetPlayerName(player, ' ');
mLocationLabel.Text = "0x" + Tool.GetPlayerDataStart(player).ToString("X");
}
private void mPlayerUpDown_ValueChanged(object sender, EventArgs e)
{
UpdatePlayerNameTextBox();
}
private void mSetFirstNameButton_Click(object sender, EventArgs e)
{
if( mNameTextBox.Text.Length > 0)
Tool.SetPlayerFirstName((int)mPlayerUpDown.Value, mNameTextBox.Text, mUsePointerButton.Checked);
}
private void mSetLastNameButton_Click(object sender, EventArgs e)
{
if (mNameTextBox.Text.Length > 0)
Tool.SetPlayerLastName((int)mPlayerUpDown.Value, mNameTextBox.Text, mUsePointerButton.Checked);
}
private void listNumberOfPlayersButton_Click(object sender, EventArgs e)
{
mResultsTextBox.Text = Tool.GetNumberOfPlayersOnAllTeams();
}
private void mGetTeamButton_Click(object sender, EventArgs e)
{
mResultsTextBox.Text = Tool.GetTeamPlayers(textBox1.Text, false, false, false);
}
private void mLocationLabel_Click(object sender, EventArgs e)
{
ShowPointersForLoc(mLocationLabel.Text);
}
private void mTeamButton_Click(object sender, EventArgs e)
{
mResultsTextBox.Text = Tool.GetPlayerTeam((int)mPlayerUpDown.Value);
}
private void mListPlayersButton2_Click(object sender, EventArgs e)
{
mResultsTextBox.Clear();
StringBuilder builder = new StringBuilder(5000);
builder.Append(Tool.GetKey(false, false));
builder.Append("\n");
string photo, pbp;
int max = (int)numericUpDown1.Value;
for (int i = 0; i < max; i++)
{
builder.Append(Tool.GetPlayerData(i, false, false));
if (includeDepthToolStripMenuItem.Checked)
{
builder.Append(" Depth:");
builder.Append(Tool.GetPlayerPositionDepth(i).ToString("X2"));
}
if (includePhotePBPToolStripMenuItem.Checked)
{
photo = Tool.GetAttribute(i, PlayerOffsets.Photo);
pbp = Tool.GetAttribute(i, PlayerOffsets.PBP);
builder.Append(photo);
builder.Append(",");
builder.Append(pbp);
builder.Append(",");
builder.Append(DataMap.GetPlayerNameForPhoto(photo));
builder.Append(",");
builder.Append(DataMap.GetPlayerNameForPBP(photo));
builder.Append(",");
if (Tool.GetAttribute(i, PlayerOffsets.Photo) != Tool.GetAttribute(i, PlayerOffsets.PBP))
{
builder.Append("****,");
}
}
if (mNumBytes.Value > 0)
{
int dataStart = Tool.GetPlayerDataStart(i) + (int)mOffsetUpDown.Value;
builder.Append(" ");
for (int j = 0; j < mNumBytes.Value; j++)
{
builder.Append(Tool.GameSaveData[dataStart + j].ToString("X2"));
}
}
builder.Append("\n");
}
mResultsTextBox.AppendText(builder.ToString());
}
private void numericUpDown1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
mListPlayersButton2_Click(sender, e);
}
private void includeDepthToolStripMenuItem_Click(object sender, EventArgs e)
{
includeDepthToolStripMenuItem.Checked = !includeDepthToolStripMenuItem.Checked;
}
private void autoUpdateDepthChartToolStripMenuItem_Click(object sender, EventArgs e)
{
Tool.AutoUpdateDepthChart();
}
private void includePhotePBPToolStripMenuItem_Click(object sender, EventArgs e)
{
includePhotePBPToolStripMenuItem.Checked = !includePhotePBPToolStripMenuItem.Checked;
}
int FirstPlayerFNamePtr = 0xe290;
int photoDistance = 0x32;
int playerSize = 0xD0;
// getting data from NFL2k2 gamesave
private string GetNFL2K2PhotoData()
{
FirstPlayerFNamePtr = 0xe290;
photoDistance = 0x32;
playerSize = 0xD0;
return GetNameData();
}
// getting data from NFL2k2 gamesave
private string GetNFL2K3PhotoData()
{
FirstPlayerFNamePtr = 0xFB28;
photoDistance = -10;
playerSize = 0x54;
return GetNameData();
}
// getting data from NFL2k4 gamesave
private string GetNFL2K4PhotoData()
{
FirstPlayerFNamePtr = 0x1132c;
photoDistance = -6;
playerSize = 0x50;
return GetNameData();
}
private string GetNameData()
{
StringBuilder builder = new StringBuilder(5000);
int ptrLoc = 0;
int photoLoc = 0;
try
{
for (int i = 0; i < numericUpDown1.Value; i++)
{
ptrLoc = FirstPlayerFNamePtr + (i * playerSize);
photoLoc = ptrLoc + photoDistance;
builder.Append(Tool.GetString(Tool.GetPointerDestination(ptrLoc + 4))); // lname
builder.Append(", ");
builder.Append(Tool.GetString(Tool.GetPointerDestination(ptrLoc))); // fname
builder.Append("=");
builder.Append(Get2BytePointer(photoLoc));
//if (Get2BytePointer(photoLoc) != Get2BytePointer(photoLoc + 2))
// builder.Append("*** " + Get2BytePointer(photoLoc + 2));
//builder.Append("," + ptrLoc.ToString("X"));
builder.Append("\n");
}
}
catch { }
return builder.ToString();
}
private string Get2BytePointer(int photoLoc)
{
string retVal = "";
int val = Tool.GameSaveData[photoLoc + 1] << 8;
val += Tool.GameSaveData[photoLoc];
if (val < 10)
retVal = "000" + val;
else if (val < 100)
retVal = "00" + val;
else if (val < 1000)
retVal = "0" + val;
else
retVal = val.ToString();
return retVal;
}
private void extractPHOHO2K2ToolStripMenuItem_Click(object sender, EventArgs e)
{
mResultsTextBox.Text = GetNFL2K2PhotoData();
}
private void extractPhoto2K3ToolStripMenuItem_Click(object sender, EventArgs e)
{
mResultsTextBox.Text = GetNFL2K3PhotoData();
}
private void extractPhoto2K4ToolStripMenuItem_Click(object sender, EventArgs e)
{
mResultsTextBox.Text = GetNFL2K4PhotoData();
}
private void mSetByteLocUpDown_ValueChanged(object sender, EventArgs e)
{
mSetByteValTextBox.Text = Tool.GameSaveData[(int)mSetByteLocUpDown.Value].ToString("X2");
}
private void SetBytes()
{
byte b1 = 0;
int loc = (int)mSetByteLocUpDown.Value;
try
{
for (int i = 0; i < mSetByteValTextBox.Text.Length; i += 2)
{
b1 = (byte)UInt16.Parse(mSetByteValTextBox.Text.Substring(i, 2), System.Globalization.NumberStyles.AllowHexSpecifier);
Tool.GameSaveData[loc] = b1;
loc++;
}
}
catch
{
mStatusLabel.Text = "Set Byte error.";
}
}
private void mSetByteButton_Click(object sender, EventArgs e)
{
SetBytes();
}
private void mSetByteValTextBox_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
SetBytes();
}
}
private void mFindBytesButton_Click(object sender, EventArgs e)
{
FindBytesInFile();
}
private void FindBytesInFile()
{
string val = textBox1.Text;
try
{
string part = "";
if (val.StartsWith("0x"))
val = val.Substring(2);
byte[] bytesToSearch = new byte[val.Length / 2];
int j = 0;
for (int i = 0; i < val.Length; i+=2)
{
part = val.Substring(i, 2);
bytesToSearch[j++] = Byte.Parse(part, System.Globalization.NumberStyles.AllowHexSpecifier);
}
mResultsTextBox.Clear();
List<long> locs = StaticUtils.FindByesInFile(bytesToSearch, Tool.GameSaveData, 0, Tool.GameSaveData.Length);
foreach (int loc in locs)
{
mResultsTextBox.AppendText(String.Format("{0:x}\n", loc));
}
}
catch (Exception)
{
MessageBox.Show("Could not search for: " + textBox1.Text +
". Ensure you are searching with valid characters [0-9A-F], even number of characters",
"Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void extractTeamSectionsToolStripMenuItem_Click(object sender, EventArgs e)
{
byte[] teamBytes;
string[] teams = GamesaveTool.Teams;
StringBuilder builder = new StringBuilder();
for (int i = 0; i < teams.Length; i++)
{
builder.Append(teams[i]);
builder.Append(",");
teamBytes = Tool.GetTeamBytes(teams[i]);
for (int j = 0; j < teamBytes.Length; j++)
{
builder.Append(teamBytes[j].ToString("X2"));
builder.Append(",");
}
builder.Append("\n");
}
mResultsTextBox.Text = builder.ToString();
}
private void mathTestToolStripMenuItem_Click(object sender, EventArgs e)
{
DataTable tab = new DataTable();
Object result= tab.Compute(mResultsTextBox.Text, "");
mResultsTextBox.Text = result.ToString();
}
private void launchTempFormToolStripMenuItem_Click(object sender, EventArgs e)
{
PictureHelper h = new PictureHelper();
h.Show();
}
private void launchPhotoDataEditorToolStripMenuItem_Click(object sender, EventArgs e)
{
PhotoDataEditor pde = new PhotoDataEditor();
pde.Show();
}
private void listDepthChartsToolStripMenuItem_Click(object sender, EventArgs e)
{
string[] teams = GamesaveTool.Teams;
StringBuilder builder = new StringBuilder();
foreach(string team in teams)
{
builder.Append(team +"\n");
builder.Append( Tool.GetSpecialTeamDepthChart(team));
}
mResultsTextBox.Text = builder.ToString();
}
private void autoUpdateYearsProToolStripMenuItem_Click(object sender, EventArgs e)
{
string baseYear = StringInputDlg.GetString("Base year:", "Enter the year for the season", "2004");
string teamsString = StringInputDlg.GetString("Teams:", "Enter the teams you wish to update (seperated by comma), blank for all teams", "");
List<string> teams = new List<string>(teamsString.Split(new char[] { ',' }));
if (teamsString == "" || teams.Count < 1)
{
teams = new List<string>(GamesaveTool.Teams);
teams.Add("FreeAgents");
teams.Add("DraftClass");
}
if (!String.IsNullOrEmpty(baseYear))
{
int year = 0;
Int32.TryParse(baseYear, out year);
Tool.AutoUpdateYearsProFromYear(year, teams.ToArray() );
}
}
private void mGetBytesButton_Click(object sender, EventArgs e)
{
try
{
int length = Int32.Parse(mGetBytesTextBox.Text, System.Globalization.NumberStyles.AllowHexSpecifier);
int start = (int)mSetByteLocUpDown.Value;
int end = start + length;
StringBuilder builder = new StringBuilder(length * 3);
for (int i = start; i < end; i++)
{
builder.Append(string.Format("{0:X2} ", Tool.GameSaveData[i]));
}
mResultsTextBox.Text = builder.ToString();
}
catch (Exception ex)
{
mStatusLabel.Text = ex.Message;
}
}
private void autoUpdatePBPToolStripMenuItem_Click(object sender, EventArgs e)
{
Tool.AutoUpdatePBP();
}
private void autoUpdatePhotosToolStripMenuItem_Click(object sender, EventArgs e)
{
Tool.AutoUpdatePhoto();
}
string mApperanceKey = "#Position,fname,lname,JerseyNumber,College,DOB,PBP,Photo,YearsPro,Hand,Weight,Height,BodyType,Skin,Face,Dreads,Helmet,FaceMask,Visor,EyeBlack,MouthPiece,LeftGlove,RightGlove,LeftWrist,RightWrist,LeftElbow,RightElbow,Sleeves,LeftShoe,RightShoe,NeckRoll,Turtleneck";
private void updatePlayerAppearanceFromFileToolStripMenuItem_Click(object sender, EventArgs e)
{
string fileName = null;
OpenFileDialog dlg = new OpenFileDialog();
dlg.RestoreDirectory = true;
dlg.Title = "Select Player appearance data file";
if (dlg.ShowDialog(this) == DialogResult.OK)
{
fileName = dlg.FileName;
}
dlg.Dispose();
if (fileName != null)
{
String text = System.IO.File.ReadAllText(fileName).Replace("\r\n", "\n");
String currentLine, playerKey;
int index = 0;
int numUpdated = 0;
int endIndex = 0;
if (text != null && text.IndexOf(mApperanceKey) < 10)
{
Tool.SetKey(mApperanceKey.Replace("#", "KEY="));
InputParser inputParser = new InputParser(Tool);
for (int i = 0; i < Tool.MaxPlayers; i++)
{
playerKey = String.Concat(Tool.GetAttribute(i, PlayerOffsets.Position), ",",
Tool.GetPlayerFirstName(i), ",",
Tool.GetPlayerLastName(i), ",");
index = text.IndexOf(playerKey);
if (index > -1)
{
endIndex = text.IndexOf('\n', index + 10);
currentLine = text.Substring(index, endIndex-index);
inputParser.SetPlayerData(i, currentLine, false);
numUpdated++;
}
}
Tool.SetKey("");
mStatusLabel.Text = "Updated " + numUpdated + " Players";
MessageBox.Show(mStatusLabel.Text);
}
else
{
MessageBox.Show(this, "Error", "Use a valid Apperance file!\nExtract only 'Apperance' from another save and stash in a file.", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void apperanceToolStripMenuItem_Click(object sender, EventArgs e)
{
StringBuilder builder = new StringBuilder();
builder.Append("#");
builder.Append(Tool.CoachKey);
builder.Append("\r\n");
for (int i = 0; i < 32; i++)
{
builder.Append( Tool.GetCoachData(i));
builder.Append("\r\n");
}
mResultsTextBox.Text = builder.ToString();
}
private void gatherFaceSkinDtaToolStripMenuItem_Click(object sender, EventArgs e)
{
StringBuilder builder = new StringBuilder();
Tool.GetSkinPhotoMappings(builder);
mResultsTextBox.Text = builder.ToString();
}
private void applyDataToCurrentSaveToolStripMenuItem_Click(object sender, EventArgs e)
{
MessageBox.Show(
"This process will apply the given data to the current save file in memory.\r\n"+
"You will be prompted for for the data, it must like be in the following example (does not need to be facemask and glove data):\r\n"+
" Key=Position,fname,lname,FaceMask,LeftGlove,RightGlove\r\n"+
" LookupAndModify \r\n" +
" QB,Steve,Young,FaceMask2,None,Team1\r\n"+
" QB,Joe,Montana,FaceMask3,Team1,None\r\n\r\n" +
"In the example above thie feature will search through all players named 'Steve Young' playing QB and\r\n"+
"set his facemask, left glove and right glove to the data given. Will do the same with 'Joe Montana'"
,"Info");
string dataToApply = MessageForm.GetString("Paste data below", "");
if (dataToApply != null)
{
dataToApply = dataToApply.Replace("Team =","#Team =");
string key = Tool.GetKey(true, true).Replace("#", "");
InputParser inputParser = new InputParser(Tool);
inputParser.ProcessText("LookupAndModify\r\n");
inputParser.ProcessText(dataToApply);
Tool.SetKey("Key=");
Tool.GetKey(true, true);
}
}
/// <summary>
/// Takes list of position , names, looks up those players (if they exist) puts their data into the textbox.
/// </summary>
private void getPlayersByPositionAndNameToolStripMenuItem_Click(object sender, EventArgs e)
{
StringBuilder builder = new StringBuilder();
List<int> playersToApplyTo = null;
List<string> attributes = null;
MessageBox.Show(
"This process willget the players specified by position,fname,lname.\r\n" +
"You will be prompted for for the data, it must like be in the following example:\r\n" +
" QB,Steve,Young\r\n" +
" QB,Joe,Montana\r\n" +
"In the example above thie feature will search through all players named 'Steve Young' and 'Joe Montana' playing QB and\r\n" +
"retrieve their data."
, "Info");
string dataToApply = MessageForm.GetString("Paste data below", "");
if (String.IsNullOrEmpty(dataToApply))
return;
string[] lines = dataToApply.Replace("\r\n", "\n").Split(new char[] { '\n' });
foreach (string line in lines)
{
if (line.StartsWith("#") || line.Length < 3)
{
// skip comments
}
else
{
attributes = InputParser.ParsePlayerLine(line);
if (attributes != null && attributes.Count > 2)
{
playersToApplyTo = Tool.FindPlayer(attributes[0], attributes[1], attributes[2]);
if (playersToApplyTo.Count > 0)
{
builder.Append(Tool.GetPlayerData(playersToApplyTo[0], true, true));
builder.Append("\r\n");
}
else
{
//builder.Append("# notFound> ");
//builder.Append(line);
//builder.Append("\r\n");
}
}
}
}
this.mResultsTextBox.Text = builder.ToString();
}
/// <summary>
/// Goes through the Text in the results text box, removes players (lookup by name) who are on teams (above FreeAgents)
/// </summary>
private void removeFreeAgentsThatAreOnATeamtextOperationToolStripMenuItem_Click(object sender, EventArgs e)
{
StringBuilder builder = new StringBuilder(mResultsTextBox.Text.Length);
int freeAgentIndex = mResultsTextBox.Text.IndexOf("FreeAgents");
if (freeAgentIndex < 100)
{
mStatusLabel.Text = "No data to process";
return;
}
string teamsText = mResultsTextBox.Text.Substring(0, freeAgentIndex);
string freeAgentText = mResultsTextBox.Text.Substring(freeAgentIndex);
string[] lines = freeAgentText.Replace("\r\n","\n").Split(new char[]{'\n'});
int commaIndex = 0;
builder.Append(teamsText);
string dude = "";
foreach (string line in lines)
{
commaIndex = InputParser.NthIndex(line, ',', 3);
if (commaIndex > -1)
{
dude = line.Substring(0, commaIndex);
if (teamsText.IndexOf(dude) > -1)
{
}
else
builder.Append(line + "\r\n");
}
}
mResultsTextBox.Text = builder.ToString();
mStatusLabel.Text = "Updated free agent data";
}
private void getPlayerBytesToolStripMenuItem_Click(object sender, EventArgs e)
{
StringBuilder builder = new StringBuilder();
List<string> attributes = null;
MessageBox.Show(
"This process will get the players specified by position,fname,lname.\r\n" +
"You will be prompted for for the data, it must like be in the following example:\r\n" +
" QB,Steve,Young\r\n" +
" QB,Joe,Montana\r\n" +
"In the example above thie feature will search through all players named 'Steve Young' and 'Joe Montana' playing QB and\r\n" +
"retrieve their data."
, "Info");
string dataToApply = MessageForm.GetString("Paste data below", "");
byte[] playerBytes = null;
if (dataToApply != null)
{
string[] lines = dataToApply.Replace("\r\n", "\n").Split(new Char[] { '\n' });
foreach (string line in lines)
{
if (line.StartsWith("#") || line.Length < 3)
{
// skip comments
}
else
{
attributes = InputParser.ParsePlayerLine(line);
if (attributes != null && attributes.Count > 2)
{
playerBytes = Tool.GetPlayerBytes(attributes[0], attributes[1], attributes[2]);
if (playerBytes != null)
{
for (int i = 0; i < playerBytes.Length; i++)
{
builder.Append(playerBytes[i].ToString("X2"));
builder.Append(" ");
}
builder.Append("\r\n");
}
else
{
builder.Append("# notFound> ");
builder.Append(line);
builder.Append("\r\n");
}
}
}
}
mResultsTextBox.Text = builder.ToString();
}
}
ScreenCaptureForm mImageCaptureForm = null;
private void imageCaptureToolStripMenuItem_Click(object sender, EventArgs e)
{
if (mImageCaptureForm == null)
mImageCaptureForm = new ScreenCaptureForm();
mImageCaptureForm.Show(this);
}
private void getCoachItem_Click(object sender, EventArgs e)
{
string number = StringInputDlg.GetString("Enter Coach number", "(0-31", "0");
try
{
int num = Int32.Parse(number);
if (num > -1 && num < 32)
{
Tool.CoachKey = Tool.CoachKeyAll;
mResultsTextBox.Text = String.Format("#coach:{0}\n{1}\n{2}",num, Tool.CoachKeyAll, Tool.GetCoachData(num));
}
}
catch {
}
}
private void getCoachBytesToolStripMenuItem_Click(object sender, EventArgs e)
{
string number = StringInputDlg.GetString("Enter Coach number", "(0-31", "0");
try
{
int num = Int32.Parse(number);
if (num > 31)
{
StringBuilder sb = new StringBuilder(5000);
for (int t = 0; t < 32; t++)
{
byte[] data = Tool.GetCoachBytes(t);
sb.Append(String.Format("Coach {0:d2}:",t));
sb.Append("0x");
for (int i = 0; i < data.Length; i++)
{
sb.Append(String.Format("{0:x2}", data[i]));
}
sb.Append("\n");
}
mResultsTextBox.Text = sb.ToString();
}
else if (num > -1 && num < 32)
{
byte[] data = Tool.GetCoachBytes(num);
StringBuilder sb = new StringBuilder(data.Length * 2 + 4);
sb.Append("0x");
for (int i = 0; i < data.Length; i++)
{
sb.Append(String.Format("{0:x2}", data[i]));
}
mResultsTextBox.Text = num + ": Coach Bytes\n" + sb.ToString();
}
}
catch
{
}
}
private void replaceStringToolStripMenuItem_Click(object sender, EventArgs e)
{
string searchStr = StringInputDlg.GetString("Enter Search String", "");
string replaceStr = StringInputDlg.GetString("Enter String to replace it with", "");
if (replaceStr.Length > searchStr.Length)
{
MessageBox.Show("Error, cannot replace a string with a longer string");
return;
}
while (replaceStr.Length < searchStr.Length)
replaceStr = replaceStr + " ";
List<long> locs = StaticUtils.FindStringInFile(searchStr, SaveFile, 0, SaveFile.Length);
for (int i = 0; i < locs.Count; i++)
{
int stringLoc = (int)locs[i];
for (int j = 0; j < replaceStr.Length; j++)
{
Tool.SetByte(stringLoc, (byte)replaceStr[j]);
Tool.SetByte(stringLoc + 1, 0);
stringLoc += 2;
}
}
}
private void fixupRookieYearsToolStripMenuItem_Click(object sender, EventArgs e)
{
List<string> teams = new List<string>( GamesaveTool.Teams);
teams.Add("FreeAgents" );
List<int> playerPointers = null;
int yearsPro =0;
for (int t = 0; t < teams.Count; t++)
{
playerPointers = Tool.GetPlayerIndexesForTeam(teams[t]);
for (int player = 0; player < playerPointers.Count; player++)
{
yearsPro = Int32.Parse( Tool.GetAttribute(playerPointers[player], PlayerOffsets.YearsPro));
if (yearsPro == 0)
Tool.SetAttribute(playerPointers[player], PlayerOffsets.YearsPro, "1");
else if (yearsPro == 1)
Tool.SetAttribute(playerPointers[player], PlayerOffsets.YearsPro, "2");
//dob = GetAttribute(playerPointers[i], PlayerOffsets.DOB); // retVal = string.Concat(new object[] { month, "/", day, "/", year });
//parts = dob.Split(chars);
//if (parts.Length > 2 && Int32.TryParse(parts[2], out birthYear))
//{
// yearsPro = currentYear - (birthYear + 22);
// if (yearsPro < 0)
// yearsPro = 0;
// SetAttribute(playerPointers[i], PlayerOffsets.YearsPro, yearsPro.ToString());
//}
}
}
}
private void findPlayersMenuItem_Click(object sender, EventArgs e)
{
String content = "LookupPlayer\r\n" +
mResultsTextBox.Text;
InputParser parser = new InputParser(Tool);
parser.ProcessText(content);
string results = Tool.GetKey(true, true) + "\r\n" +
parser.GetLookupPlayers();
MessageForm.ShowMessage("Results", results, SystemIcons.Information, false, false);
}
private void listDepthChartsToolStripMenuItem1_Click(object sender, EventArgs e)
{
//MessageForm.ShowMessage("Results", Tool.GetDepthCharts(), SystemIcons.Information, false, false);
Regex reg = new Regex("(QB),|(RB),|(FB),|(WR),|(TE),|(C),|(G),|(T),|(DE),|(DT),|(OLB),|(ILB),|(CB),|(FS),|(SS),|(K),|(P),|(KR1),|(KR2),|(PR),|(LS),");
MessageForm mf = new MessageForm(SystemIcons.Information);
mf.MessageEditable = false;
mf.Text = "Results";
mf.MessageText = Tool.GetDepthCharts();
mf.Colorize(reg, Color.Blue);
mf.Colorize(new Regex("(#.*)\\n"), Color.Green);
mf.Colorize(new Regex("(,)"), Color.Fuchsia);
mf.ShowCancelButton = false;
mf.ShowDialog();
mf.Dispose();
}
private void checkFacesskinMismatchToolStripMenuItem_Click(object sender, EventArgs e)
{
CheckFaces();
}
private void tryPS2FileToolStripMenuItem_Click(object sender, EventArgs e)
{
ARMaxTestForm form = new ARMaxTestForm();
form.Show();
}
private void checkDreadsToolStripMenuItem_Click(object sender, EventArgs e)
{
CheckDreads();
}
private void CheckFaces()
{
FaceForm ff = new FaceForm();
StringBuilder sb = new StringBuilder();
Tool.SetKey("Key=Position,fname,lname,Photo,Skin");
sb.Append(Tool.GetKey(true, true).Replace("#", "Key="));
sb.Append("\nLookupAndModify\n"+
"#Team=FreeAgents (This line is a comment, but allows the player editor to function on this data)\n\n");
string skin = "";
string face = "";
int faceInt = 0;
int playerLimit = 1928;
for (int player = 0; player < playerLimit; player++)
{
skin = Tool.GetPlayerField(player, "Skin");
face = Tool.GetAttribute(player, PlayerOffsets.Photo);
faceInt = Int32.Parse(face);
switch (skin)
{
case "Skin1": // white guys
case "Skin9":
case "Skin17":
if (!ff.CheckFace(faceInt, "lightPlayers"))
{
sb.Append(Tool.GetPlayerData(player, true, true));
sb.Append("\n");
}
break;
case "Skin2": // mixed White&black(light) guys, Samoans
case "Skin18": // mixed White&black(light) guys, Samoans, Latino, White,
break;
// dark guys
case "Skin3": // inconsistently assigned
case "Skin4":
case "Skin5":
case "Skin6":
case "Skin10":
case "Skin11":
case "Skin12":
case "Skin13":
case "Skin14":
case "Skin19":
case "Skin20":
case "Skin21":
case "Skin22":
if (!ff.CheckFace(faceInt, "darkPlayers"))
{
sb.Append(Tool.GetPlayerData(player, true, true));
sb.Append("\n");
}
break;
}
}
MessageForm.ShowMessage("Results", sb.ToString(), SystemIcons.Information, false, false);
}
private void CheckDreads()
{
StringBuilder sb = new StringBuilder();
FaceForm ff = new FaceForm();
string dreads, photo;
int photo_i = 0;
int playerLimit = 1928;
for (int i = 0; i < playerLimit; i++)
{
photo = Tool.GetPlayerField(i, "Photo");
photo_i = Int32.Parse(photo);
if (ff.CheckFace(photo_i, "Dreads"))
{