public virtual void DrawStringParam(ref string CurrentParams, string StringLabel, string StringParam) { string CurrentStringValue = IgorRuntimeUtils.GetStringParam(CurrentParams, StringParam); CurrentStringValue = EditorGUILayout.TextField(new GUIContent(StringLabel, StringLabel), string.IsNullOrEmpty(CurrentStringValue) ? string.Empty : CurrentStringValue); CurrentParams = IgorRuntimeUtils.SetStringParam(CurrentParams, StringParam, CurrentStringValue); }
public static void SetStringParam(string ParamKey, string ParamValue) { IgorJobConfig Inst = GetConfig(); if (Inst != null) { Inst.Persistent.JobCommandLineParams = IgorRuntimeUtils.SetStringParam(Inst.Persistent.JobCommandLineParams, ParamKey, ParamValue); Inst.Save(IgorJobConfigPath); } }
public virtual string DrawJobInspectorAndGetEnabledParams(string CurrentParams) { // TODO: We also need to add in platform stuff to the monstertestcore module and to this inspector call // Also probably add in a checkbox to say if we should run in the editor for platforms that allow it...or would it ever make sense to trigger from the editor? string EnabledParams = CurrentParams; bool bIsBuilding = IgorRuntimeUtils.IsBoolParamSet(CurrentParams, IgorBuildCommon.BuildFlag); bool bBuildTestableApp = false; if (bIsBuilding) { bBuildTestableApp = DrawBoolParam(ref EnabledParams, "Built executable should be testable", MonsterTestCore.BuildTestableAppFlag); if (bBuildTestableApp) { DrawBoolParam(ref EnabledParams, "Rebuild Launchers On Build", MonsterTestCore.RebuildLaunchersFlag); if (GUILayout.Button("Rebuild Launcher Executables Now")) { RebuildLaunchers(); } } } if (!bIsBuilding || bBuildTestableApp) { bool bRunTests = DrawBoolParam(ref EnabledParams, "Run tests", MonsterTestCore.RunTestFlag); if (bRunTests) { string CurrentTestName = IgorRuntimeUtils.GetStringParam(EnabledParams, MonsterTestCore.TestNameFlag); CurrentTestName = DrawTestDropdown(CurrentTestName); EnabledParams = IgorRuntimeUtils.SetStringParam(EnabledParams, MonsterTestCore.TestNameFlag, CurrentTestName); DrawStringParam(ref EnabledParams, "Explicit executable path", MonsterTestCore.ExplicitAppPathFlag); } } return(EnabledParams); }
public override string DrawJobInspectorAndGetEnabledParams(string CurrentParams) { string EnabledParams = CurrentParams; DrawBoolParam(ref EnabledParams, "Build the game", BuildFlag); DrawStringOptionsParam(ref EnabledParams, "Platform to build", PlatformFlag, AvailablePlatforms); DrawBoolParam(ref EnabledParams, "Append commit info", IgorBuildCommon.AppendCommitInfoFlag); string BuildOptionsAsString = IgorRuntimeUtils.GetStringParam(EnabledParams, IgorBuildCommon.BuildOptionsFlag).Trim('"'); if (!string.IsNullOrEmpty(BuildOptionsAsString)) { int OutResult = 0; if (Int32.TryParse(BuildOptionsAsString, out OutResult)) { SetBuildOptionsBitfield = OutResult; } } int newValue = EditorGUILayout.MaskField("Build options", SetBuildOptionsBitfield, BuildOptionNames); if (newValue != SetBuildOptionsBitfield) { SetBuildOptionsBitfield = newValue; if (SetBuildOptionsBitfield != 0) { EnabledParams = IgorRuntimeUtils.SetStringParam(EnabledParams, IgorBuildCommon.BuildOptionsFlag, ((int)SetBuildOptionsBitfield).ToString()); } else { EnabledParams = IgorRuntimeUtils.ClearParam(EnabledParams, IgorBuildCommon.BuildOptionsFlag); } } return(EnabledParams); }
public virtual void DrawFloatParam(ref string CurrentParams, string FloatLabel, string FloatParam, string NumberFormatter = "F0", float UnsetValue = float.NegativeInfinity) { string CurrentFloatValue = IgorRuntimeUtils.GetStringParam(CurrentParams, FloatParam); float CurrentFloatNum = UnsetValue; if (!string.IsNullOrEmpty(CurrentFloatValue)) { float.TryParse(CurrentFloatValue, out CurrentFloatNum); } CurrentFloatNum = EditorGUILayout.FloatField(new GUIContent(FloatLabel, FloatLabel), CurrentFloatNum); if (CurrentFloatNum == UnsetValue) { CurrentFloatValue = ""; } else { CurrentFloatValue = CurrentFloatNum.ToString(NumberFormatter); } CurrentParams = IgorRuntimeUtils.SetStringParam(CurrentParams, FloatParam, CurrentFloatValue); }
public virtual void DrawStringOptionsParam(ref string CurrentParams, string StringLabel, string StringParam, string[] ValidOptions) { string CurrentStringValue = IgorRuntimeUtils.GetStringParam(CurrentParams, StringParam); if (CurrentStringValue == "") { CurrentStringValue = "Not set"; } List <GUIContent> AllOptions = new List <GUIContent>(); AllOptions.Add(new GUIContent("Not set", "Not set")); foreach (string CurrentOption in ValidOptions) { AllOptions.Add(new GUIContent(CurrentOption, CurrentOption)); } int ChosenIndex = -1; for (int CurrentIndex = 0; CurrentIndex < AllOptions.Count; ++CurrentIndex) { if (AllOptions[CurrentIndex].text == CurrentStringValue) { ChosenIndex = CurrentIndex; } } if (ChosenIndex == -1) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(new GUIContent(StringLabel, StringLabel)); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(CurrentStringValue); if (GUILayout.Button(new GUIContent("Reset invalid value", "This value is set to an invalid value."))) { CurrentStringValue = ""; CurrentParams = IgorRuntimeUtils.SetStringParam(CurrentParams, StringParam, CurrentStringValue); } EditorGUILayout.EndHorizontal(); EditorGUILayout.EndHorizontal(); } else { int NewIndex = EditorGUILayout.Popup(new GUIContent(StringLabel, StringLabel), ChosenIndex, AllOptions.ToArray()); if (NewIndex != ChosenIndex) { ChosenIndex = NewIndex; CurrentStringValue = AllOptions[ChosenIndex].text; if (CurrentStringValue == "Not set") { CurrentStringValue = ""; } CurrentParams = IgorRuntimeUtils.SetStringParam(CurrentParams, StringParam, CurrentStringValue); } } }
public virtual void DrawStringConfigParamDifferentOverride(ref string CurrentParams, string StringLabel, string StringOverrideParam, string ConfigKey, string OverrideCurrentValue = null) { string CurrentStringValue = ""; string CurrentConfigValue = IgorConfig.GetModuleString(this, ConfigKey); bool bDisplayConfigValue = false; if (OverrideCurrentValue == null) { if (IgorRuntimeUtils.IsStringParamSet(CurrentParams, StringOverrideParam)) { CurrentStringValue = IgorRuntimeUtils.GetStringParam(CurrentParams, StringOverrideParam); } else { bDisplayConfigValue = true; } } else { if (CurrentConfigValue == OverrideCurrentValue) { bDisplayConfigValue = true; } else { CurrentStringValue = OverrideCurrentValue; } } EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(new GUIContent(StringLabel, StringLabel), GUILayout.MaxWidth(100.0f)); EditorGUILayout.BeginHorizontal(); string DisplayString = bDisplayConfigValue ? CurrentConfigValue : CurrentStringValue; GUIStyle TextFieldStyle = new GUIStyle(GUI.skin.textField); if (!bDisplayConfigValue) { TextFieldStyle.normal.background = GetTextFieldBGGreenNormal(); TextFieldStyle.focused.background = GetTextFieldBGGreenActive(); } string NewStringValue = GUILayout.TextField(DisplayString, TextFieldStyle, GUILayout.ExpandWidth(true), GUILayout.MinWidth(100.0f)); if (!NewStringValue.Contains("\"") && !(NewStringValue.Length == 1 && NewStringValue[0] == ' ')) { CurrentStringValue = NewStringValue; } if (bDisplayConfigValue && CurrentStringValue == CurrentConfigValue) { CurrentStringValue = ""; } GUIStyle ButtonStyle = new GUIStyle(GUI.skin.button); ButtonStyle.border = new RectOffset(); ButtonStyle.margin = new RectOffset(); if (GUILayout.Button(new GUIContent("<-", "Use the config value"), ButtonStyle, GUILayout.Width(25.0f))) { CurrentStringValue = ""; } if (GUILayout.Button(new GUIContent("->", "Update the config value to the current value (This will change all other jobs that haven't overridden this value!)"), ButtonStyle, GUILayout.Width(25.0f))) { if (!bDisplayConfigValue) { CurrentConfigValue = CurrentStringValue; } IgorConfig.SetModuleString(this, ConfigKey, CurrentConfigValue); } string ConfigLabel = CurrentConfigValue + " - From Global Config Key: " + GetModuleName() + "." + ConfigKey; // string ConfigLabel = "Global Config: \"" + CurrentConfigValue + "\" from Key: \"" + GetModuleName() + "." + ConfigKey + "\""; GUIStyle LabelFieldStyle = new GUIStyle(GUI.skin.label); LabelFieldStyle.alignment = TextAnchor.MiddleLeft; LabelFieldStyle.border = new RectOffset(); LabelFieldStyle.contentOffset = new Vector2(); LabelFieldStyle.margin = new RectOffset(); if (bDisplayConfigValue) { LabelFieldStyle.normal.background = GetLabelFieldBGGreen(); } GUILayout.Label(new GUIContent(ConfigLabel, ConfigLabel), LabelFieldStyle, GUILayout.MinWidth(20.0f)); if (GUILayout.Button(new GUIContent("X", "Clear the config value (This will change all other jobs that haven't overridden this value!)"), ButtonStyle, GUILayout.Width(25.0f))) { CurrentConfigValue = ""; IgorConfig.SetModuleString(this, ConfigKey, CurrentConfigValue); } EditorGUILayout.EndHorizontal(); EditorGUILayout.EndHorizontal(); CurrentParams = IgorRuntimeUtils.SetStringParam(CurrentParams, StringOverrideParam, CurrentStringValue); }
public override string DrawJobInspectorAndGetEnabledParams(string CurrentParams) { string EnabledParams = CurrentParams; IgorConfigWindow ConfigurationWindow = IgorConfigWindow.OpenOrGetConfigWindow(); IgorPersistentJobConfig CurrentJob = ConfigurationWindow.CurrentJobInst; string CurrentJobAsString = CurrentJob != null ? CurrentJob.JobName : string.Empty; string TargetDirectory = kPlayerSettingsFolder + "/" + CurrentJobAsString; GUILayout.BeginHorizontal(); { string SelectedProjectSettingsAsString = IgorRuntimeUtils.GetStringParam(EnabledParams, PlayerSettingFilesToOverrideFlag).Trim('"'); if (!string.IsNullOrEmpty(SelectedProjectSettingsAsString)) { int OutResult = 0; if (Int32.TryParse(SelectedProjectSettingsAsString, out OutResult)) { SelectedProjectSettingsAsInt = OutResult; } } int newValue = EditorGUILayout.MaskField(SelectedProjectSettingsAsInt, kProjectSettingFiles); if (newValue != SelectedProjectSettingsAsInt) { SelectedProjectSettingsAsInt = newValue; if (newValue != 0) { EnabledParams = IgorRuntimeUtils.SetStringParam(EnabledParams, PlayerSettingFilesToOverrideFlag, SelectedProjectSettingsAsInt.ToString()); EnabledParams = IgorRuntimeUtils.SetStringParam(EnabledParams, PlayerSettingsPathFlag, '"' + TargetDirectory + '"'); } else { EnabledParams = IgorRuntimeUtils.ClearParam(EnabledParams, PlayerSettingFilesToOverrideFlag); EnabledParams = IgorRuntimeUtils.ClearParam(EnabledParams, PlayerSettingsPathFlag); } } } GUILayout.EndHorizontal(); string FilesToSave = string.Empty; for (int i = 0; i < kProjectSettingFiles.Length; ++i) { if (((1 << i) & SelectedProjectSettingsAsInt) != 0) { FilesToSave += ((string.IsNullOrEmpty(FilesToSave) ? string.Empty : ", ") + kProjectSettingFiles[i].Replace(".asset", string.Empty)); } } GUILayout.Space(5f); GUILayout.Label("Files to save: " + FilesToSave); if (Directory.Exists(TargetDirectory)) { GUILayout.Space(5f); string[] SourceFilesPaths = Directory.GetFiles(TargetDirectory); string ExistingOverrides = string.Empty; foreach (string SourceFilePath in SourceFilesPaths) { ExistingOverrides += ((string.IsNullOrEmpty(ExistingOverrides) ? string.Empty : ", ") + Path.GetFileName(SourceFilePath).Replace(kIgorProjectSettingExtension, string.Empty)); } GUILayout.Label("Existing overrides on disk: " + ExistingOverrides); GUILayout.Space(5f); } GUILayout.BeginHorizontal(); { GUI.enabled = CurrentJob != null && SelectedProjectSettingsAsInt != 0; if (GUILayout.Button("Save", GUILayout.ExpandWidth(false))) { if (!Directory.Exists(kPlayerSettingsFolder)) { Directory.CreateDirectory(kPlayerSettingsFolder); } IgorRuntimeUtils.DeleteDirectory(TargetDirectory); Directory.CreateDirectory(TargetDirectory); string[] SourceFilesPaths = Directory.GetFiles("ProjectSettings"); foreach (string SourceFilePath in SourceFilesPaths) { if (!SourceFilePath.EndsWith(".meta")) { string FileName = Path.GetFileName(SourceFilePath); int IndexInKnownAssetList = Array.IndexOf(kProjectSettingFiles, FileName, 0, kProjectSettingFiles.Length); if (IndexInKnownAssetList != -1) { if ((((1 << IndexInKnownAssetList) & SelectedProjectSettingsAsInt) != 0) || SelectedProjectSettingsAsInt == -1) { string DestFilePath = SourceFilePath.Replace("ProjectSettings\\", string.Empty); DestFilePath = TargetDirectory + "/" + Path.ChangeExtension(DestFilePath, kIgorProjectSettingExtension); IgorRuntimeUtils.CopyFile(SourceFilePath, DestFilePath); } } } } AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate); } string Tooltip = Directory.Exists(TargetDirectory) ? string.Empty : "Expected PlayerSettings directory " + " doesn't exist."; GUI.enabled &= Directory.Exists(TargetDirectory); if (GUILayout.Button(new GUIContent("Load saved settings file", Tooltip), GUILayout.ExpandWidth(false))) { CopyStoredPlayerSettingsOverCurrent(TargetDirectory); } GUI.enabled = true; } GUILayout.EndHorizontal(); return(EnabledParams); }