コード例 #1
0
ファイル: RBRCITModel.cs プロジェクト: TGDSimware/RBRCIT
        public void ExtractPhysicsRBZ(bool overwriteSubFolder)
        {
            if (!Directory.Exists("Physics") && !File.Exists("physics.rbz"))
            {
                DialogResult dr = MessageBox.Show(Loc.String(13), "", MessageBoxButtons.OKCancel);
                if (dr == DialogResult.OK)
                {
                    DownloadPluginNGP();
                }
                else
                {
                    Environment.Exit(-1);
                }
            }

            if (Directory.Exists("Physics"))
            {
                if (overwriteSubFolder)
                {
                    //Directory.Delete("Physics", true);
                    //while (Directory.Exists("Physics")) System.Threading.Thread.Sleep(10);
                    HelperFunctions.DirectoryDeleteAllFilesRecursively("Physics");
                }
                else
                {
                    return;
                }
            }
            if (File.Exists("physics.rbz"))
            {
                ZipManager.ExtractToDirectory("physics.rbz", ".");
            }
        }
コード例 #2
0
        public void ExtractPhysicsRBZ(bool overwriteSubFolder)
        {
            if (!Directory.Exists("Physics") && !File.Exists("physics.rbz"))
            {
                DialogResult dr = MessageBox.Show("Neither the file 'physics.rbz' nor the subfolder 'Physics' could be found." +
                                                  "\nPlease start this tool from inside an RBR folder." +
                                                  "\nIf this is already the case, please restore 'physics.rbz'." +
                                                  "\n\nAlternatively, the NGP plugin could be downloaded now to rectify the situation. Download now?", "", MessageBoxButtons.OKCancel);
                if (dr == DialogResult.OK)
                {
                    DownloadPluginNGP();
                }
                else
                {
                    Environment.Exit(-1);
                }
            }

            if (Directory.Exists("Physics"))
            {
                if (overwriteSubFolder)
                {
                    //Directory.Delete("Physics", true);
                    //while (Directory.Exists("Physics")) System.Threading.Thread.Sleep(10);
                    HelperFunctions.DirectoryDeleteAllFilesRecursively("Physics");
                }
                else
                {
                    return;
                }
            }
            if (File.Exists("physics.rbz"))
            {
                ZipManager.ExtractToDirectory("physics.rbz", ".");
            }
        }
コード例 #3
0
        //force=true: do it even if there is no desired change, required for updating physics.rbz after an NGP plugin download/update
        private void CopyNGPPhysics(bool replaceSchoolFiles, bool force)
        {
            for (int i = 0; i < 8; i++)
            {
                if (!force && DesiredCarList[i].Equals(CurrentCarList[i]))
                {
                    continue;
                }
                Car c = DesiredCarList[i];

                //if it is a car unknown in carList.ini skip it
                if (c.physics == null)
                {
                    continue;
                }

                //copy NGP physics if it exists
                string sourceFolder = "RBRCIT\\physics\\" + c.physics;
                string destFolder   = "Physics\\" + PhysicsFolders[i];

                if (Directory.Exists(sourceFolder))
                {
                    if (Directory.Exists(destFolder))
                    {
                        HelperFunctions.DirectoryDeleteAllFilesRecursively(destFolder);
                    }
                    HelperFunctions.DirectoryCopy(sourceFolder, destFolder);
                }
            }

            //special handling for school car
            if (replaceSchoolFiles)
            {
                File.Copy("RBRCIT\\physics\\" + DesiredCarList[5].physics + "\\setups\\d_gravel.lsp", "Physics\\school\\gravel.lsp", true);
                File.Copy("RBRCIT\\physics\\" + DesiredCarList[5].physics + "\\setups\\d_gravel.lsp", "Physics\\school\\sfgravel.lsp", true);
                File.Copy("RBRCIT\\physics\\" + DesiredCarList[5].physics + "\\setups\\d_tarmac.lsp", "Physics\\school\\tarmac.lsp", true);

                string[] lines = File.ReadAllLines("Physics\\school\\sfgravel.lsp");
                int      j     = 0;
                foreach (string line in lines)
                {
                    if (line.Contains("FrontRollBarStiffness"))
                    {
                        lines[j] = "   FrontRollBarStiffness\t\t\t0";
                    }
                    if (line.Contains("RearRollBarStiffness"))
                    {
                        lines[j] = "   RearRollBarStiffness\t\t\t\t0";
                    }
                    j++;
                }
                File.WriteAllLines("Physics\\school\\sfgravel.lsp", lines);
            }
            else
            {
                HelperFunctions.DirectoryCopy("RBRCIT\\physics\\school", "Physics\\school");
            }

            //create physics.rbz from subfolder
            ZipManager.CreateFromDirectory("Physics", "physics.rbz", true);
        }