Ejemplo n.º 1
0
        void splitGame(string game, SAModel.SAEditorCommon.UI.ProgressDialog progress)
        {
            string appPath    = Path.GetDirectoryName(Application.ExecutablePath);
            string dataFolder = template.GameInfo.DataFolder;
            string gamePath   = SAToolsHub.gameDirectory;
            string projFolder = SAToolsHub.projectDirectory;
            string iniFolder;

            progress.SetMaxSteps(splitEntries.Count + splitMDLEntries.Count + 1);

            if (Directory.Exists(Path.Combine(appPath, "GameConfig", dataFolder)))
            {
                iniFolder = Path.Combine(appPath, "GameConfig", dataFolder);
            }
            else
            {
                iniFolder = Path.Combine(appPath, "..\\GameConfig", dataFolder);
            }

            progress.SetTask("Splitting Game Content");
            foreach (Templates.SplitEntry splitEntry in splitEntries)
            {
                ProjectFunctions.SplitTemplateEntry(splitEntry, progress, gamePath, iniFolder, projFolder, overwrite);
            }
            // Split MDL files for SA2
            if (splitMDLEntries.Count > 0)
            {
                progress.SetTask("Splitting Character Models");
                foreach (Templates.SplitEntryMDL splitMDL in splitMDLEntries)
                {
                    ProjectFunctions.SplitTemplateMDLEntry(splitMDL, progress, gamePath, projFolder, overwrite);
                }
            }
            // Project folders for buildable PC games
            progress.SetTask("Updating Project File");
            UpdateProjectFile(progress);
            progress.StepProgress();
        }
Ejemplo n.º 2
0
        ProjectSplitResult splitGame(string game, SAModel.SAEditorCommon.UI.ProgressDialog progress, DoWorkEventArgs e)
        {
            string appPath = Path.GetDirectoryName(Application.ExecutablePath);
            string iniFolder;

            progress.SetMaxSteps(setProgressMaxStep());

            if (Directory.Exists(Path.Combine(appPath, "GameConfig", dataFolder)))
            {
                iniFolder = Path.Combine(appPath, "GameConfig", dataFolder);
            }
            else
            {
                iniFolder = Path.Combine(appPath, "..\\GameConfig", dataFolder);
            }

            progress.SetTask("Splitting Game Content");
            // Delete log if it exists
            if (File.Exists(Path.Combine(projFolder, "SplitLog.log")))
            {
                File.Delete(Path.Combine(projFolder, "SplitLog.log"));
            }
            foreach (Templates.SplitEntry splitEntry in splitEntries)
            {
                if (backgroundWorker1.CancellationPending == true)
                {
                    e.Cancel = true;
                    return(ProjectSplitResult.Cancelled);
                }
                ProjectFunctions.SplitTemplateEntry(splitEntry, progress, gamePath, iniFolder, projFolder, nometa: comboBoxLabels.SelectedIndex == 2, nolabel: comboBoxLabels.SelectedIndex != 1);
                if (File.Exists(Path.Combine(projFolder, "SplitLog.log")))
                {
                    return(ProjectSplitResult.ItemFailure);
                }
            }
            // SALVL stuff
            if (File.Exists(Path.Combine(iniFolder, "sadxlvl.ini")))
            {
                progress.SetStep("Copying Object Definitions");
                string objdefsPath       = GetObjDefsDirectory();
                string outputObjdefsPath = Path.Combine(projFolder, "objdefs");
                if (Directory.Exists(objdefsPath))
                {
                    CopyFolder(objdefsPath, outputObjdefsPath);
                }
                progress.SetTask("Finalizing SALVL Supported Setup");
                File.Copy(Path.Combine(iniFolder, "sadxlvl.ini"), Path.Combine(projFolder, "sadxlvl.ini"), true);
                File.Copy(Path.Combine(iniFolder, "objdefs.ini"), Path.Combine(projFolder, "objdefs.ini"), true);
            }
            if (File.Exists(Path.Combine(iniFolder, "sa2lvl.ini")))
            {
                progress.SetStep("Copying Object Definitions");
                string objdefsPath       = GetObjDefsDirectory(true);
                string outputObjdefsPath = Path.Combine(projFolder, "objdefs");
                if (Directory.Exists(objdefsPath))
                {
                    CopyFolder(objdefsPath, outputObjdefsPath);
                }
                progress.SetTask("Finalizing SALVL Supported Setup");
                File.Copy(Path.Combine(iniFolder, "sa2lvl.ini"), Path.Combine(projFolder, "sa2lvl.ini"), true);
                File.Copy(Path.Combine(iniFolder, "objdefs.ini"), Path.Combine(projFolder, "objdefs.ini"), true);
            }
            // Split MDL files for SA2
            if (splitMdlEntries.Count > 0)
            {
                progress.SetTask("Splitting Character Models");
                foreach (Templates.SplitEntryMDL splitMDL in splitMdlEntries)
                {
                    if (backgroundWorker1.CancellationPending == true)
                    {
                        e.Cancel = true;
                        return(ProjectSplitResult.Cancelled);
                    }
                    ProjectFunctions.SplitTemplateMDLEntry(splitMDL, progress, gamePath, projFolder);
                }
            }
            // Project folders for buildable PC games
            if (game == "SADXPC" || game == "SA2PC")
            {
                progress.SetTask("Finalizing Project Setup");
                makeProjectFolders(projFolder, progress, game);
                GenerateModFile(game, progress, projFolder, Path.GetFileNameWithoutExtension(projName));
                progress.StepProgress();
            }

            return(ProjectSplitResult.Success);
        }