using System; using System.Collections.Generic; using System.Text; /** * Edited by Lauren */ namespace EALABuild { class BuildScript : EALABuildScript { #region Member variables Dictionary currentGUIData; static int MOD_BUILD_STEPS = 11; static string DEFAULT_GAME_VERSION = "1.12"; #endregion #region Implementation of EALABuildScript interface. /* * This function is called immediately after the script constructor in the GUI load process. */ public void initialize() { /* * This will automatically reset the counter in BuildHelper, and the GUI will * set the type of build in BuildHelper. If it is not enabled, call * BuildHelper.Reset, and set BuildHelper.CurrentBuildType = to either BuildType.ModBuild * or BuildType.MapBuild in the buildMap and buildMod functions */ BuildHelper.AutomaticallyResetBuildHelper = true; BuildHelper.EnableBenchmarking = true; } /* * This function is called on the successful completion of a build step. */ public void onStepSuccess(int stepId) { if (BuildHelper.GetNextExecutableStep() != -1) { executeModBuildStep(BuildHelper.CurrentStep); } else { BuildHelper.OnBuildComplete(); } } /* * This function is called on the failure of a build step. */ public void onStepFailure(int stepId) { BuildHelper.DisplayLine(String.Format("Build failed on step {0}", BuildHelper.CurrentStep)); } /* * This function is called to determine if a step should execute. */ public bool shouldExecuteStep(int stepId) { if (currentGUIData.ContainsKey("step" + stepId)) { if ((bool)currentGUIData["step" + stepId]) { return true; } else { return false; } } return true; } /* * This function is called when the user elects to build a mod */ public void buildMod(string modName, Dictionary GUIResults) { currentGUIData = GUIResults; BuildHelper.CurrentBuildSteps = MOD_BUILD_STEPS; executeModBuildStep(BuildHelper.GetNextExecutableStep()); } /* * This function is called during the GUI initialization to generate * the GUI for the mod build options section. */ public List GetModBuildGUIData() { List modGUIData = new List(); modGUIData.Add(new GUIElementData("step1", "Build Data", GUIElementData.CheckBoxType, ScriptIndex.ModScript)); modGUIData.Add(new GUIElementData("step2", "Build Medium LOD", GUIElementData.CheckBoxType, ScriptIndex.ModScript)); modGUIData.Add(new GUIElementData("step3", "Build Low LOD", GUIElementData.CheckBoxType, ScriptIndex.ModScript)); modGUIData.Add(new GUIElementData("step4", "Assetmerge Data", GUIElementData.CheckBoxType, ScriptIndex.ModScript)); modGUIData.Add(new GUIElementData("step5", "Assetmerge Medium LOD", GUIElementData.CheckBoxType, ScriptIndex.ModScript)); modGUIData.Add(new GUIElementData("step6", "Assetmerge Low LOD", GUIElementData.CheckBoxType, ScriptIndex.ModScript)); modGUIData.Add(new GUIElementData("step7", "Copy STR File", GUIElementData.CheckBoxType, ScriptIndex.ModScript)); modGUIData.Add(new GUIElementData("step8", "Include Shaders", GUIElementData.CheckBoxType, ScriptIndex.ModScript)); modGUIData.Add(new GUIElementData("step9", "Make Big File", GUIElementData.CheckBoxType, ScriptIndex.ModScript)); modGUIData.Add(new GUIElementData("step10", "Copy Big File", GUIElementData.CheckBoxType, ScriptIndex.ModScript)); modGUIData.Add(new GUIElementData("step11", "Create SKUDEF", GUIElementData.CheckBoxType, ScriptIndex.ModScript)); modGUIData.Add(new GUIElementData("", "Game Version", GUIElementData.LabelType, ScriptIndex.ModScript)); modGUIData.Add(new GUIElementData("gameversion", DEFAULT_GAME_VERSION, GUIElementData.InputBoxType, ScriptIndex.ModScript)); return modGUIData; } #endregion private void executeModBuildStep(int stepId) { switch(stepId) { case 1: // first step, this gets called right away when buildMod is called RunExecutableArguments args = new RunExecutableArguments(StaticPaths.BinaryAssetBuilderPath); args.Arguments = String.Format("\"{0}\" /od:\"{1}\" /iod:\"{2}\" /ls:true /gui:false /pc:true /vf:false /el:0", StaticPaths.convertModNameToBABProjPath(BuildHelper.BuildTarget), StaticPaths.BuiltModsPath, StaticPaths.BuiltModsPath); BuildHelper.RunStep(StepType.RunExecutable, args); break; case 2: RunExecutableArguments mediumLODArgs = new RunExecutableArguments(StaticPaths.BinaryAssetBuilderPath); mediumLODArgs.Arguments = String.Format("\"{0}\" /od:\"{1}\" /iod:\"{2}\" /ls:true /gui:false /pc:true /vf:false /el:0 /bcn:MediumLOD /bps:\"{3}\"", StaticPaths.convertModNameToBABProjPath(BuildHelper.BuildTarget), StaticPaths.BuiltModsPath, StaticPaths.BuiltModsPath, StaticPaths.getBuiltModManifestPath(BuildHelper.BuildTarget)); BuildHelper.RunStep(StepType.RunExecutable, mediumLODArgs); break; case 3: RunExecutableArguments lowLODArgs = new RunExecutableArguments(StaticPaths.BinaryAssetBuilderPath); lowLODArgs.Arguments = String.Format("\"{0}\" /od:\"{1}\" /iod:\"{2}\" /ls:true /gui:false /pc:true /vf:false /el:0 /bcn:LowLOD /bps:\"{3}\"", StaticPaths.convertModNameToBABProjPath(BuildHelper.BuildTarget), StaticPaths.BuiltModsPath, StaticPaths.BuiltModsPath, StaticPaths.getBuiltModManifestPath(BuildHelper.BuildTarget)); BuildHelper.RunStep(StepType.RunExecutable,lowLODArgs); break; case 4: RunExecutableArguments mergeArgs = new RunExecutableArguments("tools/assetmerge.exe"); mergeArgs.Arguments = String.Format("\"{0}\" \"{1}\"", StaticPaths.getBuiltModPath(BuildHelper.BuildTarget) + "\\data\\mod", StaticPaths.convertModNameToBaseDataPath(BuildHelper.BuildTarget) + "\\assets"); BuildHelper.RunStep(StepType.RunExecutable, mergeArgs); break; case 5: RunExecutableArguments mergeMediumLODArgs = new RunExecutableArguments("tools/assetmerge.exe"); mergeMediumLODArgs.Arguments = String.Format("\"{0}\" \"{1}\"", StaticPaths.getBuiltModPath(BuildHelper.BuildTarget) + "\\data\\mod_m", StaticPaths.convertModNameToBaseDataPath(BuildHelper.BuildTarget) + "\\assets"); BuildHelper.RunStep(StepType.RunExecutable, mergeMediumLODArgs); break; case 6: RunExecutableArguments mergeLowLODArgs = new RunExecutableArguments("tools/assetmerge.exe"); mergeLowLODArgs.Arguments = String.Format("\"{0}\" \"{1}\"", StaticPaths.getBuiltModPath(BuildHelper.BuildTarget) + "\\data\\mod_l", StaticPaths.convertModNameToBaseDataPath(BuildHelper.BuildTarget) + "\\assets"); BuildHelper.RunStep(StepType.RunExecutable, mergeLowLODArgs); break; case 7: CopyFileArguments copyFileFilteredArgs = new CopyFileArguments(StaticPaths.convertModNameToFullDataPath(BuildHelper.BuildTarget), StaticPaths.getBuiltModDataPath(BuildHelper.BuildTarget)); copyFileFilteredArgs.Filter = "*.str"; BuildHelper.RunStep(StepType.CopyFile, copyFileFilteredArgs); break; case 8: CopyFileArguments copyFileShadersArgs = new CopyFileArguments(StaticPaths.convertModNameToBaseDataPath(BuildHelper.BuildTarget)+"\\Shaders", StaticPaths.getBuiltModShaderPath(BuildHelper.BuildTarget)); copyFileShadersArgs.Filter = "*.fx"; BuildHelper.RunStep(StepType.CopyFile, copyFileShadersArgs); break; case 9: RunExecutableArguments makeBigArgs = new RunExecutableArguments(StaticPaths.MakeBigPath); makeBigArgs.Arguments = String.Format("-f \"{0}\" -x:*.asset -o:\"{1}\"", StaticPaths.getBuiltModPath(BuildHelper.BuildTarget), StaticPaths.getBuiltModBigPath(BuildHelper.BuildTarget)); BuildHelper.RunStep(StepType.RunExecutable, makeBigArgs); break; case 10: CopyFileArguments copyBigFileArgs = new CopyFileArguments(StaticPaths.getBuiltModBigPath(BuildHelper.BuildTarget), StaticPaths.getModInstallBigFilePath(BuildHelper.BuildTarget)); BuildHelper.DisplayLine(StaticPaths.getModInstallBigFilePath(BuildHelper.BuildTarget)); BuildHelper.RunStep(StepType.CopyFile, copyBigFileArgs); break; case 11: WriteFileArguments writeSKUDEFArgs = new WriteFileArguments(StaticPaths.getModInstallSKUDefPath(BuildHelper.BuildTarget, "1.0")); writeSKUDEFArgs.Content = "mod-game " + (string)currentGUIData["gameversion"] + "\r\nadd-big " + BuildHelper.BuildTarget + ".big"; BuildHelper.RunStep(StepType.WriteFile, writeSKUDEFArgs); break; default: // unknown build step, this is probably the end break; } } } }