コード例 #1
0
ファイル: Program.cs プロジェクト: BAD-AL/NFL2K5Tool
        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);
            }
        }
コード例 #2
0
ファイル: SchedulerHelper.cs プロジェクト: BAD-AL/NFL2K5Tool
        private byte mYear = 0x04; // default 2004

        #endregion Fields

        #region Constructors

        public SchedulerHelper(GamesaveTool tool)
        {
            //this.mBinarySchedule = GetDefaultSchedule();
            this.Tool = tool;
        }
コード例 #3
0
ファイル: MainForm.cs プロジェクト: BAD-AL/NFL2K5Tool
 private void LoadSaveFile()
 {
     OpenFileDialog dlg = new OpenFileDialog();
     dlg.InitialDirectory = Directory.GetCurrentDirectory();
     dlg.RestoreDirectory = true;
     dlg.Filter = "XBOX Save files (*.DAT, *.zip)|*.DAT;*.zip";
     if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
     {
         mTool = new GamesaveTool();
         mTool.LoadSaveFile(dlg.FileName);
         string shortName = dlg.FileName.Substring(dlg.FileName.LastIndexOf(Path.DirectorySeparatorChar) + 1);
         Text = "NFL2K5Tool - " + shortName;
         statusBar1.Text = dlg.FileName + " loaded";
         EnableControls(true);
     }
     StaticUtils.ShowErrors(false);
 }
コード例 #4
0
ファイル: InputParser.cs プロジェクト: BAD-AL/NFL2K5Tool
 public InputParser(GamesaveTool tool)
 {
     this.Tool = tool;
 }