public void TargetXboxMakeLinearLoadIso()
        {
            // Optimize all the data
            string output    = "";
            string sourceDir = mainForm.mAssetManager.GetTargetPath();

            string userName   = mMog.GetUser().GetUserName();
            bool   useDefault = false;

            CallbackDialogForm bigProgress = new CallbackDialogForm();

            bigProgress.DialogInitialize("Make Linear Load Build", "Creating linear maps...\nThis could take many hours", "Cancel");

            // Use 'default' as user, if the Default checkbox is checked.  This is used for the programmers who debug their code using the default.xbe
            if (mainForm.AssetManagerLocalDataXboxDefaultCheckBox.Checked)
            {
                userName   = "******";
                useDefault = true;
            }

            // Check for user cancel
            Application.DoEvents();
            if (bigProgress.DialogProcess())
            {
                bigProgress.DialogKill();
                return;
            }

            // Get the tool listed on the startup page
            string command = "[ProjectPath]\\Mog\\Tools\\Xbox\\Optimize\\Optimize.bat";

            if (command.IndexOf("[ProjectPath]") != -1)
            {
                command = string.Concat(command.Substring(0, command.IndexOf("[")), mainForm.mAssetManager.GetTargetPath(), command.Substring(command.IndexOf("]") + 1));
            }

            bigProgress.DialogUpdate(10, "Optimizing the newly merged data");

            // Make sure the tool we need exits
            if (DosUtils.FileExist(command))
            {
                // Check for user cancel
                Application.DoEvents();
                if (bigProgress.DialogProcess())
                {
                    bigProgress.DialogKill();
                    return;
                }

                if (guiCommandLine.ShellExecute(command, mainForm.mAssetManager.GetTargetPath() + "\\System", ProcessWindowStyle.Normal, ref output) != 0)
                {
                    MOG_REPORT.ShowMessageBox("XBox Tools", string.Concat(output), MessageBoxButtons.OK);
                }

                // Check for user cancel
                Application.DoEvents();
                if (bigProgress.DialogProcess())
                {
                    bigProgress.DialogKill();
                    return;
                }

                bigProgress.DialogUpdate(20, "Syncing to Build Xbox for linear load tool execution...");

                // Sync to the Linear Build xbox
                string buildXbox = "LinearBuild";

                // Logon to correct xbox
                XboxUtils.SetXboxName(buildXbox, false);

                guiPlatformSinc sinc = new guiPlatformSinc(buildXbox, mainForm.mAssetManager.GetTargetPath(), mainForm, userName, useDefault, false, false, false);
                sinc.mProjectSyncFile = "xbox.opt.ls.sync";
                sinc.mUserSyncFile    = "";
                sinc.TargetConsoleSync();

                // Check for user cancel
                Application.DoEvents();
                if (bigProgress.DialogProcess())
                {
                    bigProgress.DialogKill();
                    return;
                }

                // Run the linear load tool
                string xboxExe = "xE:\\" + mMog.GetProject().GetProjectName() + "\\defaultls.xbe";

                bigProgress.DialogUpdate(30, "Preparing for linear load tool execution...");

                // Kill the Linear load complete file in the root before we call the tool
                if (XboxUtils.FileExist("xQ:\\LoadComplete.sys"))
                {
                    XboxUtils.FileDelete("xQ:\\LoadComplete.sys");
                }

                // Check for user cancel
                Application.DoEvents();
                if (bigProgress.DialogProcess())
                {
                    bigProgress.DialogKill();
                    return;
                }


                // Kill all previous linear files
                string LinearLoadFiles = XboxUtils.GetFiles("xE:\\" + mMog.GetProject().GetProjectName() + "\\System\\");
                if (LinearLoadFiles.Length != 0 && LinearLoadFiles.IndexOf(",") != -1)
                {
                    CallbackDialogForm progress1 = new CallbackDialogForm();
                    progress1.DialogInitialize("Make Linear Load Build", "Deleting previous linear load maps...", "Cancel");

                    string [] files = LinearLoadFiles.Split(",".ToCharArray());
                    foreach (string file in files)
                    {
                        if (string.Compare(Path.GetExtension(file), ".lin", true) == 0)
                        {
                            progress1.DialogUpdate(0, file);
                            XboxUtils.FileDelete(file);

                            // Check for user cancel
                            Application.DoEvents();
                            if (bigProgress.DialogProcess())
                            {
                                progress1.DialogKill();
                                bigProgress.DialogKill();
                                return;
                            }

                            if (progress1.DialogProcess())
                            {
                                progress1.DialogKill();
                                return;
                            }
                        }
                    }

                    progress1.DialogKill();
                }

                // Check for user cancel
                Application.DoEvents();
                if (bigProgress.DialogProcess())
                {
                    bigProgress.DialogKill();
                    return;
                }

                MOG_Ini buttonDefaults = null;
                if (mMog.IsProject())
                {
                    // Get the project defaults
                    string projectDefaultButtonsFile = mMog.GetProject().GetProjectToolsPath() + "\\" + mMog.GetProject().GetProjectName() + ".Client.Buttons.Default.info";
                    if (DosUtils.FileExist(projectDefaultButtonsFile))
                    {
                        buttonDefaults = new MOG_Ini(projectDefaultButtonsFile);
                    }
                }

                // Get the tool listed on the startup page
                if (buttonDefaults != null)
                {
                    if (buttonDefaults.SectionExist(mMog.GetProject().GetProjectName() + ".Buttons"))
                    {
                        if (buttonDefaults.KeyExist(mMog.GetProject().GetProjectName() + ".Buttons", "Run"))
                        {
                            command = buttonDefaults.GetString(mMog.GetProject().GetProjectName() + ".Buttons", "Run");
                        }
                    }
                }

                if (command.IndexOf("[ProjectPath]") != -1)
                {
                    command = string.Concat(command.Substring(0, command.IndexOf("[")), mainForm.mAssetManager.GetTargetPath(), command.Substring(command.IndexOf("]") + 1));
                }

                // Check for user cancel
                Application.DoEvents();
                if (bigProgress.DialogProcess())
                {
                    bigProgress.DialogKill();
                    return;
                }

                bigProgress.DialogUpdate(50, "Starting the linear load creation tool...");

                // Make sure the tool we need exits
                if (DosUtils.FileExist(command))
                {
                    if (guiCommandLine.ShellExecute(command, string.Concat("/x ", buildXbox, " ", xboxExe), ProcessWindowStyle.Hidden, ref output) != 0)
                    {
                        MOG_REPORT.ShowMessageBox("XBox Tools", string.Concat(output), MessageBoxButtons.OK);
                    }

                    // Wait till the LinearLoad.sys file exists before continuing...
                    while (XboxUtils.FileExist("Q:\\LoadComplete.sys") == false)
                    {
                        Application.DoEvents();
                        if (bigProgress.DialogProcess())
                        {
                            bigProgress.DialogKill();
                            return;
                        }

                        Thread.Sleep(500);
                    }
                }
                else
                {
                    MOG_REPORT.ShowMessageBox("XBox Tools", string.Concat("This tool is missing, have you updated to the latest version?"), MessageBoxButtons.OK);
                }

                // Kill the Linear load complete file once we are done
                if (XboxUtils.FileExist("xQ:\\LoadComplete.sys"))
                {
                    XboxUtils.FileDelete("xQ:\\LoadComplete.sys");
                }

                // Check for user cancel
                Application.DoEvents();
                if (bigProgress.DialogProcess())
                {
                    bigProgress.DialogKill();
                    return;
                }

                bigProgress.DialogUpdate(80, "Retrieving linear load maps from Build Xbox...");

                // Copy off the data
                LinearLoadFiles = XboxUtils.GetFiles("xE:\\" + mMog.GetProject().GetProjectName() + "\\System\\");

                if (LinearLoadFiles.Length != 0 && LinearLoadFiles.IndexOf(",") != -1)
                {
                    CallbackDialogForm progress = new CallbackDialogForm();
                    progress.DialogInitialize("Make Linear Load Build", "Copying completed linear load maps...", "Cancel");

                    string [] files = LinearLoadFiles.Split(",".ToCharArray());
                    foreach (string file in files)
                    {
                        if (string.Compare(Path.GetExtension(file), ".lin", true) == 0)
                        {
                            string target = mMog.GetActivePlatform().mPlatformTargetPath + "\\xboxdata\\maps\\" + Path.GetFileName(file);

                            progress.DialogUpdate(0, target);

                            // Check for user cancel
                            Application.DoEvents();
                            if (bigProgress.DialogProcess())
                            {
                                progress.DialogKill();
                                bigProgress.DialogKill();
                                return;
                            }

                            if (progress.DialogProcess())
                            {
                                progress.DialogKill();
                                break;
                            }

                            if (!XboxUtils.FileGet(file, target, false))
                            {
                                MOG_REPORT.ShowMessageBox("Make Linear Load Build", "Error copying file(" + file + ") from build xbox!", MessageBoxButtons.OK);
                            }
                        }
                    }

                    progress.DialogKill();
                }
                else
                {
                    MOG_REPORT.ShowMessageBox("Make Linear Load Build", "There were no Linear Load files found on the Xbox Build machine(" + buildXbox + ")", MessageBoxButtons.OK);
                    return;
                }


                // Check for user cancel
                Application.DoEvents();
                if (bigProgress.DialogProcess())
                {
                    bigProgress.DialogKill();
                    return;
                }

                bigProgress.DialogUpdate(90, "Syncing to target Xbox...");

                // Sync
                sinc = new guiPlatformSinc(mTargetXbox, mainForm.mAssetManager.GetTargetPath(), mainForm, userName, useDefault, false, false, false);
                sinc.mProjectSyncFile = "xbox.opt.ll.sync";
                sinc.mUserSyncFile    = "";
                sinc.TargetConsoleSync();
            }
            else
            {
                MOG_REPORT.ShowMessageBox("XBox Tools", string.Concat("This tool is missing, have you updated to the latest version?"), MessageBoxButtons.OK);
            }

            bigProgress.DialogUpdate(100, "Done!");
            bigProgress.DialogKill();
        }
Beispiel #2
0
        public void TargetConsoleRemoveSync()
        {
            // Build a list of exactly what should be on the xbox
            mGetFileCount     = true;
            mTotalFilesToCopy = 0;
            bool success = true;

            string CopyFileMap = mSourcePath + "\\MOG\\platformSincMap." + mMog.GetActivePlatform().mPlatformName + ".info";

            if (DosUtils.FileExist(CopyFileMap))
            {
                if (!DosUtils.FileDelete(CopyFileMap))
                {
                    return;
                }
            }

            // Create the new map
            mPendingCopy = new MOG_Ini(CopyFileMap);

            InitializeFileMap();
            mFileMapCreate = true;

            // Initialize our progress dialog
            mProgress = new CallbackDialogForm();
            string message = "Preforming platform remove data Sync: \n" +
                             "   Project Sync file map:" + mProjectSyncFile + "\n" +
                             "   User Sync file map:" + mUserSyncFile + "\n";

            mProgress.DialogInitialize("(" + mTargetConsole + ")Platform Remove Data Sync", message, "");
            Application.DoEvents();

            for (int i = 0; i < mPlatformSync.CountKeys("FileMap"); i++)
            {
                string sourcePath  = FormatString(mPlatformSync.GetKeyNameByIndex("FileMap", i).ToLower());
                string targetPath  = sourcePath.Replace(mSourcePath, mSyncRoot);
                string filePattern = mPlatformSync.GetKeyByIndex("FileMap", i).ToLower();
                success = SyncDirectories(sourcePath, filePattern, mSyncRoot);

                mProgress.DialogUpdate((i * 100) / mPlatformSync.CountKeys("FileMap"), sourcePath + "\n" + targetPath);
                Application.DoEvents();

                // Create the needed directory on the xbox
                string newDirName = RemapDirectoryString(targetPath);
                if (mConsoleCopy)
                {
                    if (!XboxUtils.FileExist(newDirName))
                    {
                        mPendingCopy.PutSectionString("CREATE_DIR", newDirName);
                        mPendingCopy.Save();
                    }
                }
                else
                {
                    if (!DosUtils.FileExist(newDirName))
                    {
                        mPendingCopy.PutSectionString("CREATE_DIR", newDirName);
                        mPendingCopy.Save();
                    }
                }
            }

            if (mConsoleCopy)
            {
                // Logon to correct xbox
                XboxUtils.SetXboxName(mTargetConsole, false);
            }

            mProgress.DialogInitialize("Sync Remove", "Scanning console for non-needed assets", "");

            ArrayList deletableAssets = new ArrayList();

            // Verify the xbox for each of these files
            for (int j = 0; j < mPlatformSync.CountKeys("FileMap"); j++)
            {
                string sourcePath = FormatString(mPlatformSync.GetKeyNameByIndex("FileMap", j).ToLower());
                string targetPath = sourcePath.Replace(mSourcePath, mSyncRoot);
                string walkFiles  = XboxUtils.GetFiles(targetPath + "\\");

                mProgress.DialogUpdate((j * 100) / mPlatformSync.CountKeys("FileMap"), sourcePath + "\n" + targetPath);
                Application.DoEvents();

                if (walkFiles.Length != 0 && walkFiles.IndexOf(",") != -1)
                {
                    string [] files = walkFiles.Split(",".ToCharArray());
                    for (int k = 0; k < files.Length; k++)
                    {
                        string targetFile = files[k];

                        if (Path.GetExtension(targetFile) != "")
                        {
                            // Check to see if this file exists in the map
                            if (!mPendingCopy.KeyExist("MAP", targetFile))
                            {
                                // Get the list of deletable assets
                                deletableAssets.Add(targetFile);
                            }
                        }
                    }
                }
            }

            mProgress.DialogKill();
            mProgress = null;

            if (deletableAssets.Count != 0)
            {
                if (guiConfirmDialog.MessageBoxDialog("Console Remove Sync", "Is is OK to Delete the Following Assets?", deletableAssets, MessageBoxButtons.OKCancel) == DialogResult.OK)
                {
                    // Delete the assets in the list from off the xbox
                    foreach (string str in guiConfirmDialog.SelectedItems)
                    {
                        string [] parts = str.Split(",;".ToCharArray());
                        if (parts != null && parts.Length >= 2)
                        {
                            string assetDeleteName = parts[0];
                            XboxUtils.FileDelete(assetDeleteName);
                        }
                    }
                }
            }
            else
            {
                MOG_REPORT.ShowMessageBox("Sync Remove", "This target does not have any files that need to be deleted", MessageBoxButtons.OK);
            }
        }