void DialogKillCallback(int dialogId) { mainForm.ProcessTimer.Stop(); //Application.DoEvents(); CallbackDialogForm dialog = null; foreach (CallbackDialogForm temp in mDialogs) { if ((int)temp.Tag == dialogId) { dialog = temp; } } if (dialog == null) { return; } mDialogs.Remove(dialog); dialog.Dispose(); mainForm.ProcessTimer.Start(); }
void DialogUpdateCallback(int dialogId, int percent, string description) { Application.DoEvents(); CallbackDialogForm dialog = null; foreach (CallbackDialogForm temp in mDialogs) { if ((int)temp.Tag == dialogId) { dialog = temp; } } if (dialog == null) { return; } if (description.Length != 0) { dialog.CallbackDialogFilenameLabel.Visible = true; dialog.CallbackDialogFilenameLabel.Text = description; dialog.CallbackDialogFilesProgressBar.Visible = true; // Check for the special '-1' specifier? if (percent == -1) { // Just increment the bar by the increment value dialog.CallbackDialogFilesProgressBar.Increment(1); // Check if we just exceeded our maximum? if (dialog.CallbackDialogFilesProgressBar.Value == dialog.CallbackDialogFilesProgressBar.Maximum) { dialog.CallbackDialogFilesProgressBar.Value = dialog.CallbackDialogFilesProgressBar.Minimum; } } else { dialog.CallbackDialogFilesProgressBar.Value = percent; } } }
void DialogKillCallback(int dialogId) { Application.DoEvents(); CallbackDialogForm dialog = null; foreach (CallbackDialogForm temp in mDialogs) { if ((int)temp.Tag == dialogId) { dialog = temp; } } if (dialog == null) { return; } mDialogs.Remove(dialog); dialog.Dispose(); }
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(); }
int DialogInitCallback(string title, string message, string button) { mainForm.ProcessTimer.Stop(); CallbackDialogForm dialog = new CallbackDialogForm(); dialog.Text = title; dialog.CallbackDialogFilenameLabel.Visible = false; dialog.CallbackDialogFilesProgressBar.Visible = false; dialog.CallbackDialoglMessageLabel.Text = message; // Check if the button string needs to be parsed if (button.IndexOf("/") != -1) { string[] buttons = button.Split(new Char[] { '/' }); dialog.buttons = buttons; for (int i = 0; i < buttons.Length; i++) { switch (i) { case 0: dialog.CallbackDialogOptional1Button.Text = buttons[i]; dialog.CallbackDialogOptional1Button.Visible = true; break; case 1: dialog.CallbackDialogOptional2Button.Text = buttons[i]; dialog.CallbackDialogOptional2Button.Visible = true; break; case 2: dialog.CallbackDialogOptional3Button.Text = buttons[i]; dialog.CallbackDialogOptional3Button.Visible = true; break; case 3: dialog.CallbackDialogOptional4Button.Text = buttons[i]; dialog.CallbackDialogOptional4Button.Visible = true; break; default: // Error break; } } } else { dialog.CallbackDialogCancelButton.Visible = true; dialog.CallbackDialogCancelButton.Text = button; } mainForm.Activate(); // This dialog should be pushed to topmost when it doesn't have a parent or else it can ger lost behind other apps. // You would think this is simple but for some reason MOG has really struggled with these dialogs being kept on top... // We have tried it all and finally ended up with this...toggling the TopMost mode seems to be working 100% of the time. dialog.TopMost = true; dialog.TopMost = false; dialog.TopMost = true; dialog.Show(); // Record the window tag for this form dialog.Tag = windowId++; mDialogs.Add(dialog); mainForm.ProcessTimer.Start(); dialog.Refresh(); return((int)dialog.Tag); }
void DialogUpdateCallback(int dialogId, int percent, string description) { mainForm.ProcessTimer.Stop(); //Application.DoEvents(); CallbackDialogForm dialog = null; foreach (CallbackDialogForm temp in mDialogs) { if ((int)temp.Tag == dialogId) { dialog = temp; } } if (dialog == null) { return; } dialog.TopMost = false; if (description.Length != 0) { dialog.CallbackDialogFilenameLabel.Visible = true; string formatedDescription = ""; string[] parts = description.Split("\n".ToCharArray()); if (parts != null && parts.Length > 0) { foreach (string part in parts) { int strLength = (int)dialog.CallbackDialogFilenameLabel.CreateGraphics().MeasureString(part, dialog.CallbackDialogFilenameLabel.Font).Width; string line = part; if (strLength > dialog.CallbackDialogFilenameLabel.Width) { int increment = 5; while (strLength > dialog.CallbackDialogFilenameLabel.Width) { line = "..." + part.Substring(increment); strLength = (int)dialog.CallbackDialogFilenameLabel.CreateGraphics().MeasureString(line, dialog.CallbackDialogFilenameLabel.Font).Width; increment += 3; } } if (formatedDescription.Length == 0) { formatedDescription = line; } else { formatedDescription = formatedDescription + "\n" + line; } } } dialog.CallbackDialogFilenameLabel.Text = formatedDescription; dialog.CallbackDialogFilesProgressBar.Visible = true; dialog.CallbackDialogFilesProgressBar.Value = percent; dialog.Text = "OLD!!! " + percent + "% Complete..."; } mainForm.ProcessTimer.Start(); }
int DialogInitCallback(string title, string message, string button) { CallbackDialogForm dialog = new CallbackDialogForm(); dialog.Text = title; dialog.CallbackDialogFilenameLabel.Visible = false; dialog.CallbackDialogFilesProgressBar.Visible = false; dialog.CallbackDialoglMessageLabel.Text = message; // Check if the button string needs to be parsed if (button.IndexOf("/") != -1) { string [] buttons = button.Split(new Char[] { '/' }); dialog.buttons = buttons; for (int i = 0; i < buttons.Length; i++) { switch (i) { case 0: dialog.CallbackDialogOptional1Button.Text = buttons[i]; dialog.CallbackDialogOptional1Button.Visible = true; break; case 1: dialog.CallbackDialogOptional2Button.Text = buttons[i]; dialog.CallbackDialogOptional2Button.Visible = true; break; case 2: dialog.CallbackDialogOptional3Button.Text = buttons[i]; dialog.CallbackDialogOptional3Button.Visible = true; break; case 3: dialog.CallbackDialogOptional4Button.Text = buttons[i]; dialog.CallbackDialogOptional4Button.Visible = true; break; default: // Error break; } } } else if (button == "") { dialog.CallbackDialogCancelButton.Visible = false; } else { dialog.CallbackDialogCancelButton.Visible = true; dialog.CallbackDialogCancelButton.Text = button; } dialog.Show(); // Record the window tag for this form dialog.Tag = windowId++; mDialogs.Add(dialog); Application.DoEvents(); return((int)dialog.Tag); }
public void TargetConsoleSync() { bool success = true; string summaryFile = ""; try { // Initialize our progress dialog mProgress = new CallbackDialogForm(); // Initialize our summery files for reporting what was copied summaryFile = InitializeSummaryMap(); // Initialize our file map to tell us what patterns to copy InitializeFileMap(); // Initialize a timestamp map to help us not copy over the same stuff every time InitializeTimeStampMap(); if (mConsoleCopy) { // Logon to correct xbox XboxUtils.SetXboxName(mTargetConsole, false); } // Create initial console directory InitializeTargetDirectory(); // Get the total number of files to be copied success = InitializeFileCounts(); string message = "Preforming platform data Sync: \n" + " Project Sync file map:" + mProjectSyncFile + "\n" + " User Sync file map:" + mUserSyncFile + "\n"; mProgress.DialogInitialize("(" + mTargetConsole + ")Platform Data Sync", message, "Cancel"); Application.DoEvents(); // Walk the 'FileMap' and compare to our local game directory and sync to the Xbox if (success) { mGetFileCount = false; mFileNumber = 0; mProgress.CallbackDialogFilesProgressBar.Maximum = mTotalFilesToCopy + 2; // Walk the map file directories for (int i = 0; i < mPlatformSync.CountKeys("FileMap"); i++) { string sourcePath = FormatString(mPlatformSync.GetKeyNameByIndex("FileMap", i).ToLower()); string targetPath = ""; string filePattern = mPlatformSync.GetKeyByIndex("FileMap", i).ToLower(); if (RemapString(sourcePath, ref targetPath)) { success = SyncDirectories(sourcePath, filePattern, mSyncRoot); // Check if the user has canceled if (!success) { break; } } } } } catch (Exception e) { MOG_REPORT.ShowMessageBox("Console Sync", e.Message.ToString(), MessageBoxButtons.OK); } // Clean up our progress dialog if (mProgress != null) { mProgress.DialogKill(); mProgress.CallbackDialogFilesProgressBar.Maximum = 100; mProgress = null; } // Close and save the timestamps file if (mTargetTimestamps != null) { mTargetTimestamps.Save(); mTargetTimestamps.Close(); } // Close the platform.sinc.info if (mPlatformSync != null) { mPlatformSync.CloseNoSave(); } // Close the summary file if (mSummary != null) { mSummary.Save(); } // Check if we are supposed to launch the game after the sync if (mRunAfterSync) { RunXbox(); } // Show the update summary form if (mShowSummary) { UpdateBuildSummaryForm summary = new UpdateBuildSummaryForm(summaryFile); summary.ShowDialog(); } }
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); } }