Example #1
0
 public GlobalEditForm(GamesaveTool tool)
 {
     Tool = tool;
     InitializeComponent();
     PopulateAttributeComboBox();
     intAttrControl1.Text = stringSelectionControl1.Text = "To";
 }
Example #2
0
 private void LoadSaveFile(string filename)
 {
     if (filename.EndsWith(".txt", StringComparison.InvariantCultureIgnoreCase) ||
         filename.EndsWith(".csv", StringComparison.InvariantCultureIgnoreCase)
         )
     {
         SetText(File.ReadAllText(filename));
         return;
     }
     mTool = new GamesaveTool();
     if (mTool.LoadSaveFile(filename))
     {
         string shortName = filename.Substring(filename.LastIndexOf(Path.DirectorySeparatorChar) + 1);
         Text            = "NFL2K5Tool - " + shortName;
         statusBar1.Text = filename + " loaded";
         EnableControls(true);
     }
     else
     {
         statusBar1.Text = "Unable to load: " + filename;
         EnableControls(false);
         mTool = null;
         MessageBox.Show("Is the requested file a .txt, .csv, .zip or .dat file?", "Error!");
     }
 }
Example #3
0
        public void GetScheduleTest()
        {
            string       compareAgainst = GameSaveToolTest.GetTextFileContents("BaseSchedule.txt").Replace("\r\n", "\n");
            GamesaveTool tool           = new GamesaveTool();

            tool.LoadSaveFile(GetFilePath("Base_NFL2K5_SAVEGAME.DAT"));
            string schedule = tool.GetSchedule();
            int    index    = compareAgainst.IndexOf(schedule);

            Assert.IsTrue(index > -1, "Error! there is a difference form the base to what we got.");
        }
Example #4
0
        public void GetDraftClassTest()
        {
            string       compareAgainst = GameSaveToolTest.GetTextFileContents("AllBasePlayers.txt").Replace("\r\n", "\n");
            GamesaveTool tool           = new GamesaveTool();

            tool.LoadSaveFile(GetFilePath("Base_NFL2K5_SAVEGAME.DAT"));
            string leaguePlayers = tool.GetTeamPlayers("DraftClass", true, true).Replace("\r\n", "\n");
            int    index         = compareAgainst.IndexOf(leaguePlayers);

            Assert.IsTrue(index > -1, "Error! there is a difference form the base to what we got.");
        }
Example #5
0
        public void SaveScheduleDataTest()
        {
            GamesaveTool tool = new GamesaveTool();

            tool.LoadSaveFile(GetFilePath("Base_NFL2K5_SAVEGAME.DAT"));
            Byte[] baseData = new byte[tool.GameSaveData.Length];
            Array.Copy(tool.GameSaveData, baseData, baseData.Length);

            InputParser parser = new InputParser(tool);

            parser.ProcessText(GameSaveToolTest.GetTextFileContents("BaseSchedule.txt"));

            Byte[] modifiedData = new byte[tool.GameSaveData.Length];
            Array.Copy(tool.GameSaveData, modifiedData, baseData.Length);

            int loc = CompareArrays(baseData, modifiedData);

            Assert.AreEqual(-1, loc, "Error! data differs at location " + loc.ToString("X"));
        }
Example #6
0
        static void Main(string[] args)
        {
            if (args.Length == 0) //GUI mode
            {
                GUI_MODE = true;

                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new MainForm());
            }
            else
            {
                GamesaveTool tool = null;
                // arguments
                string saveFileName, outputFileName, dataToApplyTextFile;
                saveFileName = outputFileName = dataToApplyTextFile = null;
                string key      = "";
                string coachKey = "";

                bool showAppearance, showSpecialteams, showAbilities, showPlaybooks, showSchedule, readFromStdIn,
                     autoUpdateDepthChart, autoUpdatePbp, autoUpdatePhoto, showFreeAgents, showDraftClass, showCoaches;
                showAppearance           = showSpecialteams = showAbilities = showPlaybooks = showSchedule = readFromStdIn =
                    autoUpdateDepthChart = autoUpdatePbp = autoUpdatePhoto = showFreeAgents = showDraftClass =
                        showCoaches      = false;

                #region Argument processing
                string arg = "";
                for (int i = 0; i < args.Length; i++)
                {
                    arg = args[i].ToLower();
                    switch (arg)
                    {
                    case "-app":    showAppearance = true; break;

                    case "-st":     showSpecialteams = true; break;

                    case "-ab":     showAbilities = true; break;

                    case "-sch":    showSchedule = true;  break;

                    case "-stdin":  readFromStdIn = true; break;

                    case "-pb":     showPlaybooks = true; break;

                    case "-audc":   autoUpdateDepthChart = true; break;

                    case "-aupbp":  autoUpdatePbp = true; break;

                    case "-auph":   autoUpdatePhoto = true; break;

                    case "-fa":   showFreeAgents = true; break;

                    case "-dc":     showDraftClass = true; break;

                    case "-coach":  showCoaches = true; break;

                    case "-help":       // common help message arguments
                    case "--help":
                    case "/help":
                    case "/?":
                        PrintUsage();
                        return;

                    default:
                        if (args[i].StartsWith("-out:"))
                        {
                            outputFileName = args[i].Substring(5);
                        }
                        else if (args[i].EndsWith(".txt"))
                        {
                            dataToApplyTextFile = args[i];
                        }
                        else if (args[i].EndsWith(".dat", StringComparison.InvariantCultureIgnoreCase) || args[i].EndsWith(".zip", StringComparison.InvariantCultureIgnoreCase))
                        {
                            saveFileName = args[i];
                        }
                        else if (args[i].StartsWith("-Key:"))
                        {
                            key = args[i].Substring(5);
                        }
                        else if (args[i].StartsWith("-CoachKey:"))
                        {
                            coachKey = args[i].Substring(10);
                        }
                        else
                        {
                            Console.Error.WriteLine("Argument not applied: " + args[i]);
                        }
                        break;
                    }
                }
                #endregion

                #region load save file
                if (saveFileName != null)
                {
                    try
                    {
                        tool = new GamesaveTool();
                        if (!tool.LoadSaveFile(saveFileName))
                        {
                            Console.Error.WriteLine("File '{0}' does not exist. Make sure you have the correct path to the file specified. ", saveFileName);
                            return;
                        }
                    }
                    catch
                    {
                        Console.Error.WriteLine("Error loading file '{0}'. Make sure it is an actual NFL2K5 roster or franchise file. ", saveFileName);
                        return;
                    }
                }
                #endregion
                InputParser parser = new InputParser(tool);
                if (key != "")
                {
                    parser.ProcessText("Key=" + key);
                }
                if (coachKey != "")
                {
                    parser.ProcessText("CoachKey=" + coachKey);
                }

                #region apply text data
                if ((dataToApplyTextFile != null || readFromStdIn) && outputFileName != null)  // apply data to save file
                {
                    if (tool == null)
                    {
                        Console.Error.WriteLine("You must specify a valid save file name in order to apply data.");
                        PrintUsage();
                        return;
                    }
                    if (readFromStdIn)
                    {
                        parser.ReadFromStdin();
                    }
                    else
                    {
                        parser.ProcessFile(dataToApplyTextFile);
                    }
                    if (autoUpdateDepthChart)
                    {
                        tool.AutoUpdateDepthChart();
                    }
                    if (autoUpdatePbp)
                    {
                        tool.AutoUpdatePBP();
                    }
                    if (autoUpdatePhoto)
                    {
                        tool.AutoUpdatePhoto();
                    }
                    try // write to the file specified.
                    {
                        tool.SaveFile(outputFileName);
                        //return;
                    }
                    catch (Exception e)
                    {
                        Console.Error.WriteLine("Error writing to file: {0}. {1}", outputFileName,
                                                e.Message + "\n" + e.StackTrace
                                                );
                    }
                }
                #endregion

                #region printing stuff out
                //TODO: add support for showing playbooks
                if (tool != null)
                {
                    StringBuilder builder = new StringBuilder(5000);
                    if (showAbilities || showAppearance)
                    {
                        builder.Append(tool.GetKey(showAbilities, showAppearance));
                        builder.Append(tool.GetLeaguePlayers(showAbilities, showAppearance, showSpecialteams));
                        if (showFreeAgents)
                        {
                            builder.Append(tool.GetTeamPlayers("FreeAgents", showAbilities, showAppearance, false));
                        }
                        if (showDraftClass)
                        {
                            builder.Append(tool.GetTeamPlayers("DraftClass", showAbilities, showAppearance, false));
                        }
                        if (showCoaches)
                        {
                            builder.Append(tool.GetCoachData());
                        }
                    }
                    if (showSchedule && tool.SaveType == SaveType.Franchise)
                    {
                        builder.Append(tool.GetSchedule());
                    }

                    string lookupPlayers = parser.GetLookupPlayers();
                    if (lookupPlayers != null)
                    {
                        builder.Append(lookupPlayers);
                    }

                    Console.Write(builder.ToString());
                }
                else
                {
                    Console.Error.WriteLine("Error! you need to specify a valid save file.");
                    PrintUsage();
                    return;
                }
                #endregion

                StaticUtils.ShowErrors(true);
            }
        }
Example #7
0
 public SchedulerHelper(GamesaveTool tool)
 {
     //this.mBinarySchedule = GetDefaultSchedule();
     this.Tool = tool;
 }
Example #8
0
 public InputParser(GamesaveTool tool)
 {
     this.Tool = tool;
 }