2[
WorkbenchPluginAttribute(name:
"Game Mode Setup", description:
"Set ups the world for a specific game mode", wbModules: {
"WorldEditor" }, awesomeFontCode: 0xF6E8)]
3class SCR_GameModeSetupPlugin : WorkbenchPlugin
5 [
Attribute(
"{6389BA4D41B187DC}Configs/Workbench/GameModeSetup/GameMaster.conf",
desc:
"Game mode configuration rules",
params:
"conf class=GameModeSetupConfig",
category:
"Game Mode Template")]
9 protected ref GameModeSetupConfig m_Config;
11 protected bool m_bIsWorldValid;
12 protected bool m_bIsWorldAttentionNeeded;
13 protected bool m_bCanAutogenerateWorld;
14 protected bool m_bIsMissionHeaderValid;
15 protected ref array<SCR_EGameModeSetupPage> m_aPageHistory = { SCR_EGameModeSetupPage.INTRO };
17 protected string m_sDialogMessageValidation;
18 protected string m_sDialogMessageGeneration;
19 protected string m_sDialogMessageMissionHeader;
21 protected static const string CAPTION_INTRO =
"Game Mode Setup";
22 protected static const string CAPTION_VALIDATION =
"Game Mode Setup - World Scan";
23 protected static const string CAPTION_VALIDATION_RESULTS =
"Game Mode Setup - World Scan Results";
24 protected static const string CAPTION_GENERATION =
"Game Mode Setup - World Configuration";
25 protected static const string CAPTION_GENERATION_RESULTS =
"Game Mode Setup - World Configuration Completed";
26 protected static const string CAPTION_MISSION_HEADER =
"Game Mode Setup - Mission Header";
27 protected static const string CAPTION_MISSION_HEADER_RESULTS =
"Game Mode Setup - Mission Header Created";
28 protected static const string CAPTION_OUTRO_GOOD =
"Game Mode Setup - Success";
29 protected static const string CAPTION_OUTRO_BAD =
"Game Mode Setup - Actions Required";
31 protected static const string DESCRIPTION_INTRO =
"Welcome to step-by-step setup of a game mode.\nA game mode is a set of rules that define how the world will function.\nWithout it, players won't be able to try your world in game.\nEven opening the world in Game Master requires you to create a Game Master game mode for it.\n\nThe plugin will explain what's needed to get a game mode up an running,\nand offer automatic creation of required configuration.\n\nBefore we start, please select a template of the game mode you wish to set up.\n";
32 protected static const string DESCRIPTION_VALIDATION =
"To know what needs to be configured the plugin will scan all entities currently present in the world.\nDepending on the size of the world, this may take several seconds or minutes.\n\nYou can decide to skip this step, but unless you understand how to set up game mode manually,\nit's better to let the plugin check the current status first.";
33 protected static const string DESCRIPTION_VALIDATION_RESULTS =
"All entities scanned, results are listed below:\n";
35 protected static const string DESCRIPTION_GENERATION =
"The plugin can now create required entities in the world.\nThey will be created in the current layer, but you can later move them to any other layer.";
36 protected static const string DESCRIPTION_GENERATION_RESULTS =
"Required entities were created in the current layer.\nTry to re-scan the world to see if nothing is missing anymore.\n";
37 protected static const string DESCRIPTION_MISSION_HEADER =
"For the game mode to appear in main menu's scenario list, it needs a mission header.\nIt's a config file which exists outside of the world, but points to it.\n\nIn this step you can let the plugin create the file automatically.";
38 protected static const string DESCRIPTION_MISSION_HEADER_RESULTS =
"";
39 protected static const string DESCRIPTION_OUTRO_COMPLETE =
"Congratulations, the game mode is configured correctly.\n\nGive it a try and hit that Play button!";
40 protected static const string DESCRIPTION_OUTRO_INCOMPLETE =
"Configuration was not finished.\nTo ensure the game mode is set up correctly, please fix all issues and go through each step again.";
45 if (!Workbench.ScriptDialog(CAPTION_INTRO, DESCRIPTION_INTRO,
this))
49 if (!LoadConfig(
error))
52 if (Workbench.ScriptDialog(CAPTION_INTRO,
error,
new SCR_GameModeSetupPluginError()) != 0)
59 ShowPage(SCR_EGameModeSetupPage.VALIDATION);
63 protected void RunValidation()
67 SCR_GameModeSetupPluginValidation dialog =
new SCR_GameModeSetupPluginValidation();
68 if (!Workbench.ScriptDialog(CAPTION_VALIDATION, DESCRIPTION_VALIDATION, dialog))
71 m_bIsWorldValid =
false;
72 switch (dialog.m_eResult)
74 case SCR_EGameModeSetupButton.BACK:
78 case SCR_EGameModeSetupButton.NEXT:
79 m_sDialogMessageValidation =
string.Empty;
80 m_bCanAutogenerateWorld =
true;
81 m_bIsWorldValid = m_Config.ValidateWorld(m_sDialogMessageValidation, m_bCanAutogenerateWorld);
82 ShowPage(SCR_EGameModeSetupPage.VALIDATION_RESULTS);
85 case SCR_EGameModeSetupButton.SKIP:
86 ShowPage(SCR_EGameModeSetupPage.GENERATION);
92 protected void RunValidationResults()
94 SCR_GameModeSetupPluginResults dialog =
new SCR_GameModeSetupPluginResults();
95 if (!Workbench.ScriptDialog(CAPTION_VALIDATION_RESULTS, DESCRIPTION_VALIDATION_RESULTS + m_sDialogMessageValidation, dialog))
98 switch (dialog.m_eResult)
100 case SCR_EGameModeSetupButton.BACK:
104 case SCR_EGameModeSetupButton.NEXT:
107 if (m_bIsMissionHeaderValid)
108 ShowPage(SCR_EGameModeSetupPage.OUTRO);
110 ShowPage(SCR_EGameModeSetupPage.MISSION_HEADER);
112 else if (!m_bCanAutogenerateWorld)
113 ShowPage(SCR_EGameModeSetupPage.OUTRO);
115 ShowPage(SCR_EGameModeSetupPage.GENERATION);
121 protected void RunGeneration()
123 SCR_GameModeSetupPluginGeneration dialog =
new SCR_GameModeSetupPluginGeneration();
124 if (!Workbench.ScriptDialog(CAPTION_GENERATION, DESCRIPTION_GENERATION, dialog))
127 switch (dialog.m_eResult)
129 case SCR_EGameModeSetupButton.BACK:
133 case SCR_EGameModeSetupButton.NEXT:
134 m_sDialogMessageGeneration =
string.Empty;
135 m_bIsWorldValid = m_Config.GenerateWorld(m_sDialogMessageGeneration);
136 ShowPage(SCR_EGameModeSetupPage.GENERATION_RESULTS);
139 case SCR_EGameModeSetupButton.SKIP:
140 ShowPage(SCR_EGameModeSetupPage.MISSION_HEADER);
146 protected void RunGenerationResults()
148 SCR_GameModeSetupPluginGenerationResults dialog =
new SCR_GameModeSetupPluginGenerationResults();
149 if (!Workbench.ScriptDialog(CAPTION_GENERATION_RESULTS, DESCRIPTION_GENERATION_RESULTS + m_sDialogMessageGeneration, dialog))
152 switch (dialog.m_eResult)
154 case SCR_EGameModeSetupButton.BACK:
158 case SCR_EGameModeSetupButton.NEXT:
159 ShowPage(SCR_EGameModeSetupPage.MISSION_HEADER);
162 case SCR_EGameModeSetupButton.VALIDATE:
163 ShowPage(SCR_EGameModeSetupPage.VALIDATION);
169 protected void RunMissionHeader()
172 m_bIsMissionHeaderValid = m_Config.ValidateMissionHeader(m_sDialogMessageMissionHeader);
173 if (m_bIsMissionHeaderValid)
175 m_aPageHistory.Resize(m_aPageHistory.Count() - 1);
176 ShowPage(SCR_EGameModeSetupPage.MISSION_HEADER_RESULTS);
180 SCR_GameModeSetupPluginMissionHeader dialog =
new SCR_GameModeSetupPluginMissionHeader();
181 if (!Workbench.ScriptDialog(CAPTION_MISSION_HEADER, DESCRIPTION_MISSION_HEADER, dialog))
184 switch (dialog.m_eResult)
186 case SCR_EGameModeSetupButton.BACK:
190 case SCR_EGameModeSetupButton.NEXT:
191 m_sDialogMessageMissionHeader =
string.Empty;
192 m_bIsMissionHeaderValid = m_Config.GenerateMissionHeader(m_sTemplate, m_sDialogMessageMissionHeader);
193 ShowPage(SCR_EGameModeSetupPage.MISSION_HEADER_RESULTS);
196 case SCR_EGameModeSetupButton.SKIP:
197 ShowPage(SCR_EGameModeSetupPage.OUTRO);
203 protected void RunMissionHeaderResults()
205 SCR_GameModeSetupPluginResults dialog =
new SCR_GameModeSetupPluginResults();
206 if (!Workbench.ScriptDialog(CAPTION_MISSION_HEADER_RESULTS, DESCRIPTION_MISSION_HEADER_RESULTS + m_sDialogMessageMissionHeader, dialog))
209 switch (dialog.m_eResult)
211 case SCR_EGameModeSetupButton.BACK:
212 m_bIsMissionHeaderValid =
false;
216 case SCR_EGameModeSetupButton.NEXT:
217 ShowPage(SCR_EGameModeSetupPage.OUTRO);
223 protected void RunOutro()
225 SCR_GameModeSetupPluginOutro dialog =
new SCR_GameModeSetupPluginOutro();
226 if (m_bIsWorldValid && m_bIsMissionHeaderValid)
228 if (!Workbench.ScriptDialog(CAPTION_OUTRO_GOOD, DESCRIPTION_OUTRO_COMPLETE, dialog))
233 if (!Workbench.ScriptDialog(CAPTION_OUTRO_BAD, DESCRIPTION_OUTRO_INCOMPLETE, dialog))
237 switch (dialog.m_eResult)
239 case SCR_EGameModeSetupButton.BACK:
246 protected void ShowPage(SCR_EGameModeSetupPage page)
248 if (!m_aPageHistory.Contains(page))
249 m_aPageHistory.Insert(page);
253 case SCR_EGameModeSetupPage.INTRO:
Run();
break;
254 case SCR_EGameModeSetupPage.VALIDATION: RunValidation();
break;
255 case SCR_EGameModeSetupPage.VALIDATION_RESULTS: RunValidationResults();
break;
256 case SCR_EGameModeSetupPage.GENERATION: RunGeneration();
break;
257 case SCR_EGameModeSetupPage.GENERATION_RESULTS: RunGenerationResults();
break;
258 case SCR_EGameModeSetupPage.MISSION_HEADER: RunMissionHeader();
break;
259 case SCR_EGameModeSetupPage.MISSION_HEADER_RESULTS: RunMissionHeaderResults();
break;
260 case SCR_EGameModeSetupPage.OUTRO: RunOutro();
break;
265 protected void ShowPrevPage()
267 int pageHistoryCountMinus1 = m_aPageHistory.Count() - 1;
268 m_aPageHistory.Resize(pageHistoryCountMinus1);
269 ShowPage(m_aPageHistory[pageHistoryCountMinus1 - 1]);
273 protected bool LoadConfig(out
string error)
276 SCR_WorldEditorToolHelper.GetWorldEditorAPI().GetWorldPath(worldPath);
277 if (worldPath.IsEmpty())
279 error =
"No world is currently loaded, or the current world is not saved.";
283 if (m_sTemplate.IsEmpty())
285 error =
"No template defined! Please fill the Template field.";
290 if (!templateResource.IsValid())
292 error =
"Template config " +
FilePath.StripPath(m_sTemplate) +
" is invalid.";
296 BaseContainer templateContainer = templateResource.GetResource().ToBaseContainer();
297 m_Config = GameModeSetupConfig.Cast(
BaseContainerTools.CreateInstanceFromContainer(templateContainer));
300 error =
"Failed to load the " +
FilePath.StripPath(m_sTemplate) +
" template config.";
316 protected bool ButtonNext()
322class SCR_GameModeSetupPluginValidation
324 SCR_EGameModeSetupButton m_eResult;
335 protected bool ButtonSkip()
337 m_eResult = SCR_EGameModeSetupButton.SKIP;
343 protected bool ButtonBack()
345 m_eResult = SCR_EGameModeSetupButton.BACK;
351 protected bool ButtonValidate()
353 m_eResult = SCR_EGameModeSetupButton.NEXT;
358class SCR_GameModeSetupPluginResults
360 SCR_EGameModeSetupButton m_eResult;
371 protected bool ButtonBack()
373 m_eResult = SCR_EGameModeSetupButton.BACK;
379 protected bool ButtonNext()
381 m_eResult = SCR_EGameModeSetupButton.NEXT;
386class SCR_GameModeSetupPluginGenerationResults
388 SCR_EGameModeSetupButton m_eResult;
397 protected bool ButtonValidate()
399 m_eResult = SCR_EGameModeSetupButton.VALIDATE;
404 protected bool ButtonBack()
406 m_eResult = SCR_EGameModeSetupButton.BACK;
411 protected bool ButtonNext()
413 m_eResult = SCR_EGameModeSetupButton.NEXT;
418class SCR_GameModeSetupPluginGeneration
420 SCR_EGameModeSetupButton m_eResult;
431 protected bool ButtonSkip()
433 m_eResult = SCR_EGameModeSetupButton.SKIP;
439 protected bool ButtonBack()
441 m_eResult = SCR_EGameModeSetupButton.BACK;
447 protected bool ButtonGenerate()
449 m_eResult = SCR_EGameModeSetupButton.NEXT;
454class SCR_GameModeSetupPluginMissionHeader
456 SCR_EGameModeSetupButton m_eResult;
467 protected bool ButtonSkip()
469 m_eResult = SCR_EGameModeSetupButton.SKIP;
475 protected bool ButtonBack()
477 m_eResult = SCR_EGameModeSetupButton.BACK;
483 protected bool ButtonGenerate()
485 m_eResult = SCR_EGameModeSetupButton.NEXT;
490class SCR_GameModeSetupPluginOutro
492 SCR_EGameModeSetupButton m_eResult;
496 protected bool ButtonBack()
498 m_eResult = SCR_EGameModeSetupButton.BACK;
504 protected bool ButtonClose()
510class SCR_GameModeSetupPluginError
514 protected int ButtonBack()
521 protected bool ButtonClose()
528enum SCR_EGameModeSetupPage
536 MISSION_HEADER_RESULTS,
541enum SCR_EGameModeSetupButton
SCR_CampaignSeizingComponent SCR_SeizingComponent EnumLinear()] enum SCR_EBaseCaptureState
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
class WorkbenchDialog_AbortRetryIgnore ButtonAttribute("OK", true)
Object holding reference to resource. In destructor release the resource.
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
SCR_FieldOfViewSettings Attribute
@ VALIDATE
Job is doing deep validation where it attempts to find if any fragment is corrupted.