Exemple #1
0
        private void ApplyTextToSave()
        {
            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();
            statusBar1.Text = "Applying data...";
            InputParser parser = new InputParser(this.mTool);
            //parser.UseExistingNames = reuseNamesToConserveNameSpaceToolStripMenuItem.Checked;

            parser.ProcessText(mTextBox.Text);
            sw.Stop();
            statusBar1.Text = "Done Applying data." + (sw.ElapsedMilliseconds / 1000.0) + "s";
            StaticUtils.ShowErrors(false);
        }
Exemple #2
0
        static void Main(string[] args)
        {
            if (args.Length == 0) //GUI mode
            {
                GUI_MODE = true;
                ShowWindow(GetConsoleWindow(), WindowShowStyle.Hide);

                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new MainForm());

                ShowWindow(GetConsoleWindow(), WindowShowStyle.Show);
            }
            else
            {
                GamesaveTool tool = null;
                // arguments
                string saveFileName, outputFileName, dataToApplyTextFile;
                saveFileName = outputFileName = dataToApplyTextFile = null;

                bool showAppearance, showSpecialteams, showAbilities, showPlaybooks, showSchedule, readFromStdIn,
                    autoUpdateDepthChart, autoUpdatePbp, autoUpdatePhoto, showFreeAgents, showDraftClass;
                showAppearance = showSpecialteams = showAbilities = showPlaybooks = showSchedule = readFromStdIn =
                    autoUpdateDepthChart = autoUpdatePbp = autoUpdatePhoto= showFreeAgents = showDraftClass = 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 "-help":   // common help message arguments
                        case "--help":
                        case "/help":
                        case "/?":
                            PrintUsage();
                            return;
                        default:
                            if ( arg.StartsWith("-") )
                            {
                                Console.Error.WriteLine("Invalid argument: " + arg);
                            }
                            break;
                    }
                    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];
                }
                #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

                #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;
                    }
                    InputParser parser = new InputParser(tool);
                    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);
                    }
                }
                #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 (showSchedule)
                        builder.Append(tool.GetSchedule());
                    Console.Write(builder.ToString());
                }
                else
                {
                    Console.Error.WriteLine("Error! you need to specify a valid save file.");
                    PrintUsage();
                    return;
                }
                #endregion

                StaticUtils.ShowErrors(true);
            }
        }
Exemple #3
0
        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);
                }
            }
        }