public static void Toggle(Setting <bool> val, string label, GUILayoutOption[] labelOpts, GUILayoutOption[] tglOpts) { UGUI.BeginHorizontal(); UGUI.Label(label, Style.Label, labelOpts); UGUI.FlexibleSpace(); val.Value = UGUI.Toggle(val.Value, string.Empty, Style.Toggle, tglOpts); UGUI.EndHorizontal(); }
public static void Toggle(Setting <bool> val, string label) { UGUI.BeginHorizontal(); Label(label); UGUI.FlexibleSpace(); val.Value = UGUI.Toggle(val.Value, string.Empty, Style.Toggle); UGUI.EndHorizontal(); }
public static bool Toggle(bool val, string label, GUILayoutOption[] labelOpts, GUILayoutOption[] tglOpts) { UGUI.BeginHorizontal(); UGUI.Label(label, Style.Label, labelOpts); UGUI.FlexibleSpace(); val = UGUI.Toggle(val, string.Empty, Style.Toggle, tglOpts); UGUI.EndHorizontal(); return(val); }
static bool CenteredButton(string content) { EGL.BeginHorizontal(); GL.FlexibleSpace(); var res = GL.Button(content, GL.Width(150)); GL.FlexibleSpace(); EGL.EndHorizontal(); return res; }
public static bool Toggle(bool val, string label) { UGUI.BeginHorizontal(); Label(label); UGUI.FlexibleSpace(); val = UGUI.Toggle(val, string.Empty, Style.Toggle); UGUI.EndHorizontal(); return(val); }
void OnGUI() { if (!model.enable) { model.enable = ToggleLeft("Log", model.enable); return; } instance = this; // TODO: why do this here? BeginHorizontal(); if (GL.Button("˂", GL.ExpandWidth(false))) { model.SelectPreviousFrame(); SceneView.RepaintAll(); } GL.Button(frameNo, GL.MaxWidth(48f)); if (GL.Button("˃", GL.ExpandWidth(false))) { model.SelectNextFrame(); SceneView.RepaintAll(); } GL.FlexibleSpace(); EndHorizontal(); // scroll = BeginScrollView(scroll); GUI.backgroundColor = Color.black; var style = GUI.skin.textArea; var f = font; if (f == null) { Debug.LogError("font not available"); } style.font = f; style.fontSize = FontSize; style.normal.textColor = Color.white * 0.9f; style.focused.textColor = Color.white; style.focused.textColor = Color.white; GL.TextArea(model.output, GL.ExpandHeight(true)); EndScrollView(); // GUI.backgroundColor = Color.white; // var w30 = GL.MaxWidth(30f); BeginHorizontal(); model.enable = ToggleLeft($"Log", model.enable, GL.MaxWidth(60)); model.trails = ToggleLeft("Trails", model.trails, GL.MaxWidth(50)); GL.Label("Offset: ", GL.ExpandWidth(false)); var rs = model.renderSettings; rs.offset = FloatField(model.renderSettings.offset, w30); GL.Label("Size: ", w30); rs.size = FloatField(rs.size, w30); GL.Label("Col: ", w30); rs.color = EditorGUILayout.ColorField(rs.color); EndHorizontal(); }
public static void ItemTypesMenu() { showItemTypes = GL.Toggle(showItemTypes, RichText.Bold(Strings.GetText("toggle_ShowItemTypes"))); if (showItemTypes) { GL.Space(10); itemTypesGrid.Render(); GL.Space(10); if (selectedItemTypeOld != itemTypesGrid.selected) { selectedItemTypeOld = itemTypesGrid.selected; refreshItemTypes = true; } switch (itemTypesGrid.selected) { case 0: List <BlueprintArmorType> blueprintArmorTypes = ResourcesLibrary.GetBlueprints <BlueprintArmorType>().ToList(); if (refreshItemTypes) { itemTypeEdit.Clear(); foreach (BlueprintArmorType b in blueprintArmorTypes) { itemTypeEdit.Add(false); } refreshItemTypes = false; } for (int i = 0; i < blueprintArmorTypes.Count(); i++) { itemTypeEdit[i] = GL.Toggle(itemTypeEdit[i], blueprintArmorTypes[i].name); if (itemTypeEdit[i]) { GL.BeginVertical("box"); GL.BeginHorizontal(); GL.Label("m_ArcaneSpellFailureChance: " + blueprintArmorTypes[i].ArcaneSpellFailureChance.ToString()); itemTypesTextFieldInt.RenderFieldNoGroup(); SetModifiedValueButton <ModifiedArmourType>(itemTypesTextFieldInt.finalAmount, "m_ArcaneSpellFailureChance", blueprintArmorTypes[i].AssetGuid); GL.EndHorizontal(); GL.BeginHorizontal(); GL.Label("m_ArmorBonus: " + blueprintArmorTypes[i].ArmorBonus.ToString()); itemTypesTextFieldInt.RenderFieldNoGroup(); SetModifiedValueButton <ModifiedArmourType>(itemTypesTextFieldInt.finalAmount, "m_ArmorBonus", blueprintArmorTypes[i].AssetGuid); GL.EndHorizontal(); GL.BeginHorizontal(); GL.Label("m_ArmorChecksPenalty: " + blueprintArmorTypes[i].ArmorChecksPenalty.ToString()); itemTypesTextFieldInt.RenderFieldNoGroup(); SetModifiedValueButton <ModifiedArmourType>(itemTypesTextFieldInt.finalAmount, "m_ArmorChecksPenalty", blueprintArmorTypes[i].AssetGuid); GL.EndHorizontal(); GL.BeginHorizontal(); GL.Label("m_HasDexterityBonusLimit: " + blueprintArmorTypes[i].HasDexterityBonusLimit.ToString()); SetModifiedValueButtonBool <ModifiedArmourType>("m_HasDexterityBonusLimit", blueprintArmorTypes[i].AssetGuid); GL.EndHorizontal(); GL.BeginHorizontal(); GL.Label("m_MaxDexterityBonus: " + blueprintArmorTypes[i].MaxDexterityBonus.ToString()); itemTypesTextFieldInt.RenderFieldNoGroup(); SetModifiedValueButton <ModifiedArmourType>(itemTypesTextFieldInt.finalAmount, "m_MaxDexterityBonus", blueprintArmorTypes[i].AssetGuid); GL.EndHorizontal(); GL.BeginHorizontal(); GL.Label("m_Weight: " + blueprintArmorTypes[i].Weight.ToString()); itemTypesTextFieldFloat.RenderFieldNoGroup(); SetModifiedValueButton <ModifiedArmourType>(itemTypesTextFieldFloat.finalAmount, "m_Weight", blueprintArmorTypes[i].AssetGuid); GL.EndHorizontal(); GL.EndVertical(); } } break; case 1: List <BlueprintShieldType> blueprintShieldTypes = ResourcesLibrary.GetBlueprints <BlueprintShieldType>().ToList(); if (refreshItemTypes) { itemTypeEdit.Clear(); foreach (BlueprintShieldType b in blueprintShieldTypes) { itemTypeEdit.Add(false); } refreshItemTypes = false; } for (int i = 0; i < blueprintShieldTypes.Count(); i++) { itemTypeEdit[i] = GL.Toggle(itemTypeEdit[i], blueprintShieldTypes[i].name); if (itemTypeEdit[i]) { GL.BeginVertical("box"); GL.BeginHorizontal(); GL.Label("m_ArcaneSpellFailureChance: " + blueprintShieldTypes[i].ArcaneSpellFailureChance.ToString()); itemTypesTextFieldInt.RenderFieldNoGroup(); SetModifiedValueButton <ModifiedArmourType>(itemTypesTextFieldInt.finalAmount, "m_ArcaneSpellFailureChance", blueprintShieldTypes[i].AssetGuid); GL.EndHorizontal(); GL.BeginHorizontal(); GL.Label("m_ArmorBonus: " + blueprintShieldTypes[i].ArmorBonus.ToString()); itemTypesTextFieldInt.RenderFieldNoGroup(); SetModifiedValueButton <ModifiedArmourType>(itemTypesTextFieldInt.finalAmount, "m_ArmorBonus", blueprintShieldTypes[i].AssetGuid); GL.EndHorizontal(); GL.BeginHorizontal(); GL.Label("m_ArmorChecksPenalty: " + blueprintShieldTypes[i].ArmorChecksPenalty.ToString()); itemTypesTextFieldInt.RenderFieldNoGroup(); SetModifiedValueButton <ModifiedArmourType>(itemTypesTextFieldInt.finalAmount, "m_ArmorChecksPenalty", blueprintShieldTypes[i].AssetGuid); GL.EndHorizontal(); GL.BeginHorizontal(); GL.Label("m_HasDexterityBonusLimit: " + blueprintShieldTypes[i].HasDexterityBonusLimit.ToString()); SetModifiedValueButtonBool <ModifiedArmourType>("m_HasDexterityBonusLimit", blueprintShieldTypes[i].AssetGuid); GL.EndHorizontal(); GL.BeginHorizontal(); GL.Label("m_MaxDexterityBonus: " + blueprintShieldTypes[i].MaxDexterityBonus.ToString()); itemTypesTextFieldInt.RenderFieldNoGroup(); SetModifiedValueButton <ModifiedArmourType>(itemTypesTextFieldInt.finalAmount, "m_MaxDexterityBonus", blueprintShieldTypes[i].AssetGuid); GL.EndHorizontal(); GL.BeginHorizontal(); GL.Label("m_Weight: " + blueprintShieldTypes[i].Weight.ToString()); itemTypesTextFieldFloat.RenderFieldNoGroup(); SetModifiedValueButton <ModifiedArmourType>(itemTypesTextFieldFloat.finalAmount, "m_Weight", blueprintShieldTypes[i].AssetGuid); GL.EndHorizontal(); GL.EndVertical(); } } break; case 2: List <BlueprintWeaponType> blueprintWeaponTypes = ResourcesLibrary.GetBlueprints <BlueprintWeaponType>().ToList(); if (refreshItemTypes) { itemTypeEdit.Clear(); foreach (BlueprintWeaponType b in blueprintWeaponTypes) { itemTypeEdit.Add(false); } refreshItemTypes = false; } for (int i = 0; i < blueprintWeaponTypes.Count(); i++) { itemTypeEdit[i] = GL.Toggle(itemTypeEdit[i], blueprintWeaponTypes[i].name); if (itemTypeEdit[i]) { GL.BeginVertical("box"); GL.BeginHorizontal(); GL.Label("m_AttackType: " + blueprintWeaponTypes[i].AttackType.ToString()); SetModifiedValueButtonAttackType <ModifiedWeaponType>("m_AttackType", blueprintWeaponTypes[i].AssetGuid); GL.EndHorizontal(); GL.BeginHorizontal(); GL.Label("m_AttackRange: " + Traverse.Create(blueprintWeaponTypes[i]).Field("m_AttackRange").GetValue().ToString()); itemTypesTextFieldInt.RenderFieldNoGroup(); SetModifiedValueButton <ModifiedWeaponType>(itemTypesTextFieldInt.finalAmount.Feet(), "m_AttackRange", blueprintWeaponTypes[i].AssetGuid); GL.EndHorizontal(); MenuTools.SingleLineLabel("AttackRange = (m_AttackRange > 10) ? m_AttackRange : Math.Max(2, m_AttackRange - 4)"); GL.BeginVertical("box"); GL.BeginHorizontal(); GL.Label("m_BaseDamage: " + blueprintWeaponTypes[i].BaseDamage.ToString()); GL.EndHorizontal(); GL.BeginHorizontal(); itemTypesTextFieldInt.RenderFieldNoGroup("misc_NumberOfRolls"); GL.EndHorizontal(); diceTypesGrid.Render(); GL.BeginHorizontal(); GL.FlexibleSpace(); SetModifiedValueButtonDiceFormula <ModifiedWeaponType>(itemTypesTextFieldInt.finalAmount, Common.IntToDiceType(diceTypesGrid.selected), "m_BaseDamage", blueprintWeaponTypes[i].AssetGuid); GL.EndHorizontal(); GL.EndVertical(); GL.BeginHorizontal(); GL.Label("m_CriticalRollEdge: " + blueprintWeaponTypes[i].CriticalRollEdge.ToString()); itemTypesTextFieldInt.RenderFieldNoGroup(); SetModifiedValueButton <ModifiedWeaponType>(itemTypesTextFieldInt.finalAmount, "m_CriticalRollEdge", blueprintWeaponTypes[i].AssetGuid); GL.EndHorizontal(); GL.BeginHorizontal(); GL.Label("m_CriticalModifier: " + blueprintWeaponTypes[i].CriticalModifier.ToString()); SetModifiedValueDamageCriticalModifierType <ModifiedWeaponType>("m_CriticalModifier", blueprintWeaponTypes[i].AssetGuid); GL.EndHorizontal(); GL.BeginHorizontal(); GL.Label("m_Weight: " + blueprintWeaponTypes[i].Weight.ToString()); itemTypesTextFieldFloat.RenderFieldNoGroup(); SetModifiedValueButton <ModifiedWeaponType>(itemTypesTextFieldFloat.finalAmount, "m_Weight", blueprintWeaponTypes[i].AssetGuid); GL.EndHorizontal(); GL.BeginHorizontal(); GL.Label("m_IsTwoHanded: " + blueprintWeaponTypes[i].IsTwoHanded.ToString()); SetModifiedValueButtonBool <ModifiedWeaponType>("m_IsTwoHanded", blueprintWeaponTypes[i].AssetGuid); GL.EndHorizontal(); GL.BeginHorizontal(); GL.Label("m_IsLight: " + blueprintWeaponTypes[i].IsLight.ToString()); SetModifiedValueButtonBool <ModifiedWeaponType>("m_IsLight", blueprintWeaponTypes[i].AssetGuid); GL.EndHorizontal(); GL.BeginHorizontal(); GL.Label("m_IsMonk: " + blueprintWeaponTypes[i].IsMonk.ToString()); SetModifiedValueButtonBool <ModifiedWeaponType>("m_IsMonk", blueprintWeaponTypes[i].AssetGuid); GL.EndHorizontal(); GL.BeginHorizontal(); GL.Label("m_IsNatural: " + blueprintWeaponTypes[i].IsNatural.ToString()); SetModifiedValueButtonBool <ModifiedWeaponType>("m_IsNatural", blueprintWeaponTypes[i].AssetGuid); GL.EndHorizontal(); GL.BeginHorizontal(); GL.Label("m_IsUnarmed: " + blueprintWeaponTypes[i].IsUnarmed.ToString()); SetModifiedValueButtonBool <ModifiedWeaponType>("m_IsUnarmed", blueprintWeaponTypes[i].AssetGuid); GL.EndHorizontal(); GL.BeginHorizontal(); GL.Label("m_OverrideAttackBonusStat: " + Traverse.Create(blueprintWeaponTypes[i]).Field("m_OverrideAttackBonusStat").GetValue().ToString()); SetModifiedValueButtonBool <ModifiedWeaponType>("m_OverrideAttackBonusStat", blueprintWeaponTypes[i].AssetGuid); GL.EndHorizontal(); GL.BeginVertical("box"); GL.BeginHorizontal(); GL.Label("m_AttackBonusStatOverride: " + Traverse.Create(blueprintWeaponTypes[i]).Field("m_AttackBonusStatOverride").GetValue().ToString()); GL.EndHorizontal(); SetModifiedValueStatType <ModifiedWeaponType>("m_AttackBonusStatOverride", blueprintWeaponTypes[i].AssetGuid); GL.EndVertical(); GL.EndVertical(); } } break; } } }
public static void RenderMenu() { GL.BeginVertical("box"); GL.BeginHorizontal(); GL.Label(RichText.MainCategoryFormat(Strings.GetText("mainCategory_BlueprintModding"))); GL.FlexibleSpace(); MenuTools.AddFavouriteButton("BlueprintModdingRender"); GL.EndHorizontal(); GL.BeginHorizontal(); if (GL.Button(MenuTools.TextWithTooltip("misc_Enable", "tooltip_BlueprintModding", $"{ settings.toggleItemModding}" + " ", "", false), GL.ExpandWidth(false))) { if (settings.toggleItemModding == Storage.isFalseString) { settings.toggleItemModding = Storage.isTrueString; ModifiedBlueprintTools.Patch(); } else if (settings.toggleItemModding == Storage.isTrueString) { settings.toggleItemModding = Storage.isFalseString; } } GL.EndHorizontal(); if (Strings.ToBool(settings.toggleItemModding)) { MenuTools.SingleLineLabel(Strings.GetText("label_ItemModdingInfo")); GL.BeginHorizontal(); if (GL.Button(new GUIContent("spacehamster's JSON Blueprint Dump on github", "https://github.com/spacehamster/KingmakerCustomBlueprints/releases/tag/blueprints"), GL.ExpandWidth(false))) { Application.OpenURL("https://github.com/spacehamster/KingmakerCustomBlueprints/releases/tag/blueprints"); } GL.EndHorizontal(); GL.Space(10); GL.BeginHorizontal(); if (GL.Button(MenuTools.TextWithTooltip("button_PatchManually", "tooltip_PatchManually", true), GL.ExpandWidth(false))) { Patch(); } GL.EndHorizontal(); GL.Space(10); ItemTypesMenu(); GL.Space(10); showModifiedBlueprints = GL.Toggle(showModifiedBlueprints, RichText.Bold(Strings.GetText("toggle_ShowModifiedItems"))); if (showModifiedBlueprints) { GL.Space(10); GL.BeginHorizontal(); if (GL.Button(RichText.Bold(Strings.GetText("button_LoadRefresh")), GL.ExpandWidth(false))) { blueprintLists = false; } GL.EndHorizontal(); GL.Space(10); try { if (!blueprintLists) { blueprintsPaths.Clear(); blueprintsNames.Clear(); blueprintsTypes.Clear(); string path = Storage.modEntryPath + Storage.modifiedBlueprintsFolder; DirectoryInfo directory = new DirectoryInfo(path); if (directory.GetFiles("*.json").Any()) { foreach (FileInfo file in directory.GetFiles("*.json")) { string json = File.ReadAllText(file.FullName); string guid = Path.GetFileNameWithoutExtension(file.Name); if (guid == "Example" && directory.GetFiles("*.json").Count() == 1) { MenuTools.SingleLineLabel(Strings.GetText("message_NoModItems")); continue; } else if (guid == "Example" && directory.GetFiles("*.json").Count() > 1) { continue; } BlueprintScriptableObject blueprintScriptableObject = Utilities.GetBlueprintByGuid <BlueprintScriptableObject>(guid); if (blueprintScriptableObject != null) { if (blueprintItemCategory.Contains(blueprintScriptableObject.GetType()) || blueprintTypeArmourCategory.Contains(blueprintScriptableObject.GetType()) || blueprintScriptableObject.GetType() == blueprintWeaponType) { blueprintsPaths.Add(file.FullName); blueprintsNames.Add(blueprintScriptableObject.name); blueprintsTypes.Add(blueprintScriptableObject.GetType().ToString()); } } } } blueprintLists = true; } if (blueprintsPaths.Any()) { for (int i = 0; i < blueprintsPaths.Count(); i++) { GL.BeginVertical("box"); GL.BeginHorizontal(); GL.Label(blueprintsNames[i] + $" ({blueprintsTypes[i]})"); GL.FlexibleSpace(); if (GL.Button(MenuTools.TextWithTooltip("button_RemoveItemModification", "misc_RequiresRestart", true), GL.ExpandWidth(false))) { try { blueprintLists = false; File.Delete(blueprintsPaths[i]); } catch (Exception e) { modLogger.Log(e.ToString()); } } GL.EndHorizontal(); GL.EndVertical(); } } else { MenuTools.SingleLineLabel(Strings.GetText("message_NoModItems")); } } catch (Exception e) { modLogger.Log(e.ToString()); } } } GL.EndVertical(); }
void OnGUI() { if (!Config.enable) { Config.enable = ToggleLeft("Enable Logging", Config.enable); return; } // model.current = Selection.activeGameObject; instance = this; BeginHorizontal(); Config.useSelection = ToggleLeft("Use Selection", Config.useSelection, GL.MaxWidth(90f)); Config.allFrames = ToggleLeft("History", Config.allFrames, GL.MaxWidth(60)); // TODO - make return type filtering available with the global history if (model.applicableSelection) { GL.Label("→", GL.MaxWidth(25f)); Config.rtypeIndex = Popup(Config.rtypeIndex, rtypeOptions); } EndHorizontal(); if (!Config.useSelection) { model.current = null; } BeginHorizontal(); int frameNo = browsing ? selectedFrame.index : Time.frameCount; if (GL.Button("˂", GL.ExpandWidth(false))) { SelectPrev(); } GL.Button($"#{frameNo}", GL.MaxWidth(48f)); if (GL.Button("˃", GL.ExpandWidth(false))) { SelectNext(); } GL.FlexibleSpace(); Config.step = ToggleLeft("Step", Config.step, GL.MaxWidth(48f)); EndHorizontal(); scroll = BeginScrollView(scroll); GUI.backgroundColor = Color.black; var style = GUI.skin.textArea; var f = font; if (f == null) { Debug.LogError("font not available"); } style.font = f; style.fontSize = FontSize; style.normal.textColor = Color.white * 0.9f; style.focused.textColor = Color.white; style.focused.textColor = Color.white; string log = model.Output(useHistory, rtypeOptions[Config.rtypeIndex]); if (currentLog != log && Config.step) { Ed.isPaused = true; } currentLog = log; GL.TextArea(browsing ? selectedFrame.Format() : log, GL.ExpandHeight(true)); EndScrollView(); GUI.backgroundColor = Color.white; BeginHorizontal(); Config.enable = ToggleLeft( $"Enable Logging ({Logger.injectionTimeMs}ms)", Config.enable, GL.ExpandWidth(true)); if (!Application.isPlaying) { if (GL.Button($"Clear", GL.MaxWidth(90f))) { Clear(); } } EndHorizontal(); BeginHorizontal(); GL.Label("Trail offset: ", GL.MaxWidth(60f)); Config.trailOffset = FloatField(Config.trailOffset, GL.MaxWidth(30f)); GL.Label("Size: ", GL.MaxWidth(30f)); Config.handleSize = FloatField(Config.handleSize, GL.MaxWidth(30f)); EndHorizontal(); }
public override void OnInspectorGUI() { transition = (Transition)target; EditorGUI.BeginChangeCheck(); var fromName = transition.fromState.GetStatePreview(); var toName = transition.targetInfo; var displayName = fromName + "->" + toName; EGL.LabelField(displayName); EGL.Space(); FromStateFilterInspector(transition.profile, transition.fromState, ref fromStateRect); EGL.Space(); transition.triggerRangeType = (TriggerRangeType)EGL.EnumPopup("Trigger Range Type", transition.triggerRangeType); if (transition.triggerRangeType == TriggerRangeType.Range) { transition.triggerRange = EditorGUIUtil.FrameRangeInput("Trigger Frame", transition.triggerRange); } if (transition.triggerRangeType == TriggerRangeType.FrameSinceExec || transition.triggerRangeType == TriggerRangeType.FrameSinceExecBefore) { transition.triggerFrameSinceExec = EGL.IntField("Frame Since Exec", transition.triggerFrameSinceExec); } transition.timeBuffer = EGL.FloatField("Time Buffer", transition.timeBuffer); using (new EGL.VerticalScope(EditorStyles.helpBox)) { var conds = transition.conditions; var paramNames = transition.profile.parameters.Select(it => it.name).ToArray(); using (new EGL.HorizontalScope()) { EGL.LabelField("Conditions", EditorStyles.boldLabel); GL.FlexibleSpace(); if (GL.Button("+", GL.Width(30))) { conds.Add(new Condition()); } } for (int i = 0; i < conds.Count; ++i) { var cond = conds[i]; EGL.BeginHorizontal(); int condSelectIndex = Mathf.Max(0, Array.IndexOf(paramNames, cond.name)); // cond.name = EGL.TextField(cond.name, GL.Width(70)); condSelectIndex = EGL.Popup(condSelectIndex, paramNames); cond.name = paramNames[condSelectIndex]; var param = transition.profile.FindParam(cond.name); if (param == null) { EGL.LabelField("!Doesn't exist"); } else { var type = param.type; if (type == ParamType.Bool) { cond.boolValue = EGL.Toggle(cond.boolValue); } else if (type != ParamType.Trigger) // Trigger 不需要编辑 { cond.cmp = (Cmp)EGL.EnumPopup(cond.cmp, GL.Width(50)); if (type == ParamType.Int) { cond.intValue = EGL.IntField(cond.intValue); } else { cond.floatValue = EGL.FloatField(cond.floatValue); } } } GL.FlexibleSpace(); if (GL.Button("-", GL.Width(30))) { conds.RemoveAt(i); --i; } EGL.EndHorizontal(); } } EGL.LabelField("", GUI.skin.horizontalSlider); transition.actionType = (ActionType)EGL.EnumPopup("Action", transition.actionType); if (transition.actionType == ActionType.ChangeState) { EGL.BeginHorizontal(); EGL.PrefixLabel("Target State"); EditorGUIUtil.AutoCompleteList(transition.targetStateName, allStateNames, str => transition.targetStateName = str, ref targetStateRect); transition.targetStateFrame = EGL.IntField(transition.targetStateFrame, GL.Width(30)); EGL.LabelField("F", GUILayout.Width(20)); var targetState = transition.profile.FindState(transition.targetStateName); if (targetState) { if (GL.Button("Focus")) { Utils.FocusEditingAnimation(transition.profile, targetState.stateName); } } EGL.EndHorizontal(); if (!targetState) { EGL.HelpBox("No target state " + targetState, MessageType.Error); } } else // SendMessage { transition.messageName = EGL.TextField("Message Name", transition.messageName); EGL.Space(); transition.messageParType = (MessageParType)EGL.EnumPopup("Parameter Type", transition.messageParType); switch (transition.messageParType) { case MessageParType.Int: transition.messageParInt = EGL.IntField("Value", transition.messageParInt); break; case MessageParType.Float: transition.messageParFloat = EGL.FloatField("Value", transition.messageParFloat); break; case MessageParType.Bool: transition.messageParBool = EGL.Toggle("Value", transition.messageParBool); break; } } transition.priority = EGL.IntField("Priority", transition.priority); transition.shouldDelay = EGL.Toggle("Should Delay", transition.shouldDelay); if (transition.shouldDelay) { transition.delay = EGL.FloatField("Delay", transition.delay); } if (EditorGUI.EndChangeCheck()) { EditorUtility.SetDirty(transition); } if (transition.fromState.type == FromStateType.State) { EGL.LabelField("", GUI.skin.horizontalSlider); using (new EGL.VerticalScope(EditorStyles.helpBox)) { EGL.LabelField("From State", EditorStyles.boldLabel); ++EditorGUI.indentLevel; var fromState = transition.profile.FindState(transition.fromState.stateOrTagName); if (fromState) { GUI.enabled = false; if (!fromStateEditor || fromStateEditor.target != fromState) { if (fromStateEditor) { DestroyImmediate(fromStateEditor); } fromStateEditor = Editor.CreateEditor(fromState); } fromStateEditor.OnInspectorGUI(); GUI.enabled = true; } --EditorGUI.indentLevel; } } }
void InspectBehaviourList(List <StateBehaviour> list) { using (new EGL.HorizontalScope()) { EGL.LabelField("Behaviours", EditorStyles.boldLabel); GL.FlexibleSpace(); var listHash = list.GetHashCode(); if (GL.Button("+", GL.Width(30)) && popupRects.ContainsKey(listHash)) { PopupWindow.Show(popupRects[listHash], new AddBehaviourPopup(state.profile, list)); } if (Event.current.type == EventType.Repaint) { popupRects.Remove(listHash); popupRects.Add(listHash, GUILayoutUtility.GetLastRect()); } } for (int i = 0; i < list.Count; ++i) { var behaviour = list[i]; var active = activeBehaviours.Contains(behaviour); if (!behaviour) { list.RemoveAt(i); --i; continue; } EGL.BeginHorizontal(); active = EGL.Foldout(active, behaviour.name); if (GL.Button("-", GL.Width(30))) { DestroyImmediate(behaviour, true); list.RemoveAt(i); --i; } EGL.EndHorizontal(); if (!behaviour) { continue; } if (active) { activeBehaviours.Add(behaviour); } else { activeBehaviours.Remove(behaviour); } if (active) { ++EditorGUI.indentLevel; GetBehaviorEditor(behaviour).OnInspectorGUI(); --EditorGUI.indentLevel; } } if (GUI.enabled) { GL.BeginHorizontal(); GL.FlexibleSpace(); GL.FlexibleSpace(); GL.EndHorizontal(); } }
public static void RenderMenu() { GL.BeginVertical("box"); GL.BeginHorizontal(); GL.Label(RichText.MainCategoryFormat(Strings.GetText("label_ActionKey"))); GL.FlexibleSpace(); MenuTools.AddFavouriteButton("ActionKeyRender"); GL.EndHorizontal(); GL.BeginHorizontal(); if (GL.Button( MenuTools.TextWithTooltip("misc_Enable", "tooltip_ActionKey", $"{settings.toggleEnableActionKey}" + " ", ""), GL.ExpandWidth(false))) { if (settings.toggleEnableActionKey == Storage.isFalseString) { settings.toggleEnableActionKey = Storage.isTrueString; settings.actionKeyIndex = 0; settings.actionKeyKillIndex = 0; } else if (settings.toggleEnableActionKey == Storage.isTrueString) { settings.toggleEnableActionKey = Storage.isFalseString; settings.actionKeyIndex = 0; settings.actionKeyKillIndex = 0; } } GL.EndHorizontal(); if (settings.toggleEnableActionKey == Storage.isTrueString) { GL.Space(10); GL.BeginHorizontal(); GL.Label(Strings.GetText("label_ActionKey") + ": ", GL.ExpandWidth(false)); MenuTools.SetKeyBinding(ref settings.actionKey); GL.EndHorizontal(); GL.Space(10); GL.BeginHorizontal(); if (GL.Button( MenuTools.TextWithTooltip("label_ActionKeyEnableExperimental", "tooltip_ActionKeyEnableExperimental", $"{settings.toggleActionKeyExperimental}" + " ", ""), GL.ExpandWidth(false))) { if (settings.toggleActionKeyExperimental == Storage.isFalseString) { settings.toggleActionKeyExperimental = Storage.isTrueString; settings.actionKeyIndex = 0; settings.actionKeyKillIndex = 0; } else if (settings.toggleActionKeyExperimental == Storage.isTrueString) { settings.toggleActionKeyExperimental = Storage.isFalseString; settings.actionKeyIndex = 0; settings.actionKeyKillIndex = 0; } } GL.EndHorizontal(); MenuTools.SingleLineLabel(RichText.Bold(Strings.GetText("warning_ActionKeyExperimentalMode"))); GL.BeginHorizontal(); if (!Strings.ToBool(settings.toggleActionKeyExperimental)) { settings.actionKeyIndex = GL.SelectionGrid(settings.actionKeyIndex, mainArray, 3); } else { settings.actionKeyIndex = GL.SelectionGrid(settings.actionKeyIndex, mainExperimentalArray, 3); } GL.EndHorizontal(); GL.Space(10); switch (settings.actionKeyIndex) { case 1: MenuTools.ToggleButton(ref settings.toggleActionKeyLogInfo, "buttonToggle_LogInfoToFile", "tooltip_LogInfoToFile"); MenuTools.ToggleButton(ref settings.toggleActionKeyShowUnitInfoBox, "buttonToggle_ShowUnitInfoBox", "tooltip_ShowUnitInfoBox"); break; case 2: if (Strings.ToBool(settings.toggleActionKeyExperimental)) { GL.Space(10); GL.BeginHorizontal(); settings.actionKeyKillIndex = GL.SelectionGrid(settings.actionKeyKillIndex, experimentalKillArray, 3); GL.EndHorizontal(); } break; case 4: if (!Storage.buffFavourites.Any()) { MenuTools.SingleLineLabel(Strings.GetText("message_NoFavourites")); } else { if (Storage.buffFavouritesLoad == true) { Main.RefreshBuffFavourites(); Storage.buffFavouritesLoad = false; } GL.Space(10); GL.BeginHorizontal(); settings.actionKeyBuffIndex = GL.SelectionGrid(settings.actionKeyBuffIndex, Storage.buffFavouriteNames.ToArray(), 2); GL.EndHorizontal(); } if (Storage.buffFavourites != Storage.buffFavouritesGuids) { Storage.buffFavourites = Storage.buffFavouritesGuids; } break; case 5: if (editUnit != null && editUnit.IsInGame && !editUnit.Descriptor.State.IsFinallyDead) { ActionKeyEditStatsGui(editUnit); } else { MenuTools.SingleLineLabel(Strings.GetText("message_NoUnitSelected")); } break; case 6: if (teleportUnit != null && teleportUnit.IsInGame) { MenuTools.SingleLineLabel(Strings.GetText("label_TeleportUnit") + $": {teleportUnit.CharacterName}"); } else { MenuTools.SingleLineLabel(Strings.GetText("message_NoUnitSelected")); } break; case 7: if (Strings.ToBool(settings.toggleActionKeyExperimental)) { settings.actionKeySpawnRandomEnemy = GL.Toggle(settings.actionKeySpawnRandomEnemy, " " + Strings.GetText("toggle_SpawnRandomEnemy"), GL.ExpandWidth(false)); } GL.Space(10); MenuTools.SingleLineLabel(Strings.GetText("label_ChallengeRating") + " " + Strings.Parenthesis(Strings.GetText("misc_Bandit"))); GL.BeginHorizontal(); banidtCrIndex = GL.SelectionGrid(banidtCrIndex, numberArray0t7, 8); GL.EndHorizontal(); break; case 8: if (rotateUnit != null && rotateUnit.IsInGame) { MenuTools.SingleLineLabel(Strings.GetText("arrayItem_ActionKeyMain_RotateUnit") + $": {rotateUnit.CharacterName}"); } else { MenuTools.SingleLineLabel(Strings.GetText("message_NoUnitSelected")); } break; case 9: if (load) { animationTypes.Clear(); animationTypesNames.Clear(); foreach (var animation in (UnitAnimationType[])Enum.GetValues(typeof(UnitAnimationType))) { animationTypes.Add(animation); animationTypesNames.Add(animation.ToString()); } load = false; } GL.BeginHorizontal(); animationTypesIndex = GL.SelectionGrid(animationTypesIndex, animationTypesNames.ToArray(), 3); GL.EndHorizontal(); break; case 13: MenuTools.SingleLineLabel(Strings.GetText("message_RecreateUnitDescriptor")); break; } } GL.EndVertical(); }
private void OnGUI() { if (settings == null) { settings = ConstantGenerator.GetSettingsFile(); } if (logo == null) { logo = ConstantGenerator.GetLogo(); } if (border == null) { border = ConstantGenerator.GetBorder(); } EditorGUI.BeginChangeCheck(); StartGUI("Layers"); if (DrawGenButton()) { LayersGen.Generate(); window.Close(); } if (DrawForceGenButton()) { LayersGen.ForceGenerate(); window.Close(); } EndGUI(); // ------------------------------------------------------------------------------------- StartGUI("Tags"); if (DrawGenButton()) { TagsGen.Generate(); window.Close(); } if (DrawForceGenButton()) { TagsGen.ForceGenerate(); window.Close(); } EndGUI(); // ------------------------------------------------------------------------------------- StartGUI("Sort Layers"); if (DrawGenButton()) { SortingLayersGen.Generate(); window.Close(); } if (DrawForceGenButton()) { SortingLayersGen.ForceGenerate(); window.Close(); } EndGUI(); // ------------------------------------------------------------------------------------- StartGUI("Scenes"); if (DrawGenButton()) { ScenesGen.Generate(); window.Close(); } if (DrawForceGenButton()) { ScenesGen.ForceGenerate(); window.Close(); } EndGUI(); // ------------------------------------------------------------------------------------- StartGUI("Shader Props"); if (DrawGenButton()) { ShaderPropsGen.Generate(false); window.Close(); } if (DrawForceGenButton()) { ShaderPropsGen.ForceGenerate(); window.Close(); } EndGUI(); // ------------------------------------------------------------------------------------- StartGUI("Anim Params"); if (DrawGenButton()) { AnimParamsGen.Generate(); window.Close(); } if (DrawForceGenButton()) { AnimParamsGen.ForceGenerate(); window.Close(); } EndGUI(); // ------------------------------------------------------------------------------------- StartGUI("Anim Layers"); if (DrawGenButton()) { AnimLayersGen.Generate(); window.Close(); } if (DrawForceGenButton()) { AnimLayersGen.ForceGenerate(); window.Close(); } EndGUI(); // ------------------------------------------------------------------------------------- StartGUI("Anim States"); if (DrawGenButton()) { AnimStatesGen.Generate(); window.Close(); } if (DrawForceGenButton()) { AnimStatesGen.ForceGenerate(); window.Close(); } EndGUI(); // ------------------------------------------------------------------------------------- StartGUI("Nav Areas"); if (DrawGenButton()) { NavAreasGen.Generate(); window.Close(); } if (DrawForceGenButton()) { NavAreasGen.ForceGenerate(); window.Close(); } EndGUI(); // ========================================================================================= DrawLine(Color.white, 2, 5); GUIStyle style = new GUIStyle(GUI.skin.button); style.alignment = TextAnchor.MiddleCenter; style.fontStyle = FontStyle.Bold; EGL.BeginHorizontal(); EGL.BeginVertical(); EGL.BeginHorizontal(); if (GL.Button("GENERATE ALL", style)) { LayersGen.Generate(); TagsGen.Generate(); SortingLayersGen.Generate(); ScenesGen.Generate(); ShaderPropsGen.Generate(false); AnimParamsGen.Generate(); AnimLayersGen.Generate(); AnimStatesGen.Generate(); window.Close(); } GL.FlexibleSpace(); EGL.EndHorizontal(); EGL.BeginHorizontal(); if (GL.Button("FORCE GENERATE ALL", style)) { LayersGen.ForceGenerate(); TagsGen.ForceGenerate(); SortingLayersGen.ForceGenerate(); ScenesGen.ForceGenerate(); ShaderPropsGen.ForceGenerate(); AnimParamsGen.ForceGenerate(); AnimLayersGen.ForceGenerate(); AnimStatesGen.ForceGenerate(); window.Close(); } GL.FlexibleSpace(); EGL.EndHorizontal(); EGL.EndVertical(); EGL.BeginVertical(); // --------------------------------------------------------------------------------------- Color genOnReloadColor; Color updateOnReloadColor; if (settings.regenerateOnMissing) { genOnReloadColor = Color.green * 2; } else { genOnReloadColor = Color.white * 1.5f; } if (settings.updateOnReload) { updateOnReloadColor = Color.green * 2; } else { updateOnReloadColor = Color.white * 1.5f; } EGL.BeginHorizontal(); GUI.backgroundColor = genOnReloadColor; if (GL.Button(new GUIContent("ReGen On Missing", "Automatically re-generates the constants file is none is present."), style)) { settings.regenerateOnMissing = !settings.regenerateOnMissing; EditorUtility.SetDirty(settings); } EGL.EndHorizontal(); EGL.BeginHorizontal(); GUI.backgroundColor = updateOnReloadColor; if (GL.Button(new GUIContent("Update On Reload", "Automatically re-generates the constants on editor recompile if any changes are detected."), style)) { settings.updateOnReload = !settings.updateOnReload; EditorUtility.SetDirty(settings); } EGL.EndHorizontal(); EGL.EndVertical(); EGL.EndHorizontal(); // ========================================================================================= DrawLine(Color.white, 2, 5); GUI.backgroundColor = Color.gray; GUI.contentColor = Color.white * 10; // check for unity versions using conditional directives // NOTE: there is no "BeginFoldoutHeaderGroup" in below 2019.1 #if UNITY_2019_OR_NEWER showFoldOut = EGL.BeginFoldoutHeaderGroup(showFoldOut, "Create Generator Script"); #else showFoldOut = EGL.Foldout(showFoldOut, "Create Generator Script"); #endif if (showFoldOut) { GL.Space(5); GUI.contentColor = Color.white * 10; generatorName = EGL.TextField("Generator Name", generatorName); outputFileName = EGL.TextField("Output File Name", outputFileName); GL.Space(5); EGL.BeginHorizontal(); if (!settings.regenerateOnMissing) { EGL.BeginVertical(); GL.FlexibleSpace(); EGL.HelpBox("NOTE: Force Generate will only delete the file but will NOT generate a new one if the [ReGen On Missing] is turned off", MessageType.Warning); EGL.EndVertical(); } else { // ============================================================================ // Draw Ma Awesome Logo EGL.BeginVertical(); GL.FlexibleSpace(); Rect horiRect = EGL.BeginHorizontal(); Rect boxRect = new Rect(horiRect.x + 3, horiRect.y - 54, 125, 52); Rect backgroundRect = boxRect; backgroundRect.width = border.width; backgroundRect.height = border.height; GUI.DrawTexture(backgroundRect, border); // GUI.Box( boxRect, iconBackground, ); GUI.Label(new Rect(boxRect.x + 3, boxRect.y + 16, 100, 20), "Created BY: "); Rect logoRect = new Rect(boxRect.x + 76, boxRect.y + 2, logo.width, logo.height); GUI.DrawTexture(logoRect, logo); EGL.EndHorizontal(); EGL.EndVertical(); // ============================================================================ } GL.FlexibleSpace(); GUI.contentColor = Color.white * 5; EGL.BeginVertical(); GL.FlexibleSpace(); GUI.backgroundColor = Color.white * 2.5f; GUI.contentColor = Color.black * 5; if (GL.Button("Create", new GUIStyle(GUI.skin.button) { fontStyle = FontStyle.Bold, fontSize = 12 }, GL.Width(75), GL.Height(30))) { if (generatorName == string.Empty || outputFileName == string.Empty || generatorName == null || outputFileName == null) { Debug.LogWarning("Fill out all the fields"); } else { TemplateGen.GenerateTemplate(generatorName, outputFileName); window.Close(); } } EGL.EndVertical(); GL.Space(1); EGL.EndHorizontal(); } #if UNITY_2019_OR_NEWER EGL.EndFoldoutHeaderGroup(); #endif if (EditorGUI.EndChangeCheck()) { EditorUtility.SetDirty(settings); } }
void showRoadMapGUI() { EG.BeginDisabledGroup(!(terrainGenerated && growthMapGenerated && populationGenerated)); showRoadMapUI = EGL.Foldout(showRoadMapUI, roadmapLabel, true); if (showRoadMapUI) { GL.Label("Streets", EditorStyles.centeredGreyMiniLabel); GL.BeginHorizontal(); GL.BeginVertical(); GL.Label("Width"); GL.Label("Min Length"); GL.Label("LookAhead"); GL.Label("Pop Threshold"); GL.Label("Max Slope"); GL.EndVertical(); GL.BeginVertical(); CG.streetWidth = EGL.IntSlider(CG.streetWidth, 5, 20); CG.streetMinLength = EGL.Slider(CG.streetMinLength, 5f, 100f); CG.streetLookAhead = EGL.IntSlider(CG.streetLookAhead, 1, (int)(CG.terrainSize / CG.streetMinLength)); CG.streetPopThreshold = EGL.Slider(CG.streetPopThreshold, 0f, 1f); CG.streetMaxSlope = EGL.Slider(CG.streetMaxSlope, 0f, 1f); GL.EndVertical(); GL.EndHorizontal(); GL.Space(5); GL.Label("Highways", EditorStyles.centeredGreyMiniLabel); GL.BeginHorizontal(); GL.BeginVertical(); GL.Label("Width"); GL.Label("Min Length"); GL.Label("LookAhead"); GL.Label("Pop Threshold"); GL.Label("Max Slope"); GL.EndVertical(); GL.BeginVertical(); CG.highwayWidth = EGL.IntSlider(CG.highwayWidth, 10, 25); CG.highwayMinLength = EGL.Slider(CG.highwayMinLength, 5f, 200f); CG.highwayLookAhead = EGL.IntSlider(CG.highwayLookAhead, 1, (int)(CG.terrainSize / CG.highwayMinLength)); CG.highwayPopThreshold = EGL.Slider(CG.highwayPopThreshold, 0f, 1f); CG.highwayMaxSlope = EGL.Slider(CG.highwayMaxSlope, 0f, 1f); GL.EndVertical(); GL.EndHorizontal(); GL.Space(10); showRoadMapAdvanced = EGL.Foldout(showRoadMapAdvanced, "Advanced Settings", true); if (showRoadMapAdvanced) { EGL.HelpBox("Adjusting these settings might break the Editor or severely influence performance.", MessageType.Warning); GL.Label("General Advanced Settings", EditorStyles.centeredGreyMiniLabel); GL.BeginHorizontal(); GL.BeginVertical(); GL.Label("Legalization Attempts"); GL.Label("Min Road Correction Angle"); GL.Label("Node Check Radius"); GL.Label("Road Connect Max Distance"); GL.Label("Ray Count"); GL.EndVertical(); GL.BeginVertical(); CG.legalizationAttempts = EGL.IntSlider(CG.legalizationAttempts, 1, 100); CG.minRoadAngle = EGL.IntSlider(CG.minRoadAngle, 0, 90); CG.nodeCheckRadius = EGL.Slider(CG.nodeCheckRadius, 0f, 100f); CG.roadConnectDistance = EGL.Slider(CG.roadConnectDistance, 0f, 100f); CG.rayCount = EGL.IntSlider(CG.rayCount, 1, 32); GL.EndVertical(); GL.EndHorizontal(); GL.Label("Advanced Settings for L-system Component", EditorStyles.centeredGreyMiniLabel); EGL.HelpBox("Low values correspond to higher priority.", MessageType.Info); GL.BeginHorizontal(); GL.BeginVertical(); GL.Label("Street - Priority"); GL.Label("Highway - Priority"); GL.EndVertical(); GL.BeginVertical(); CG.streetPriority = EGL.IntSlider(CG.streetPriority, 1, 5); CG.highwayPriority = EGL.IntSlider(CG.highwayPriority, 1, 5); GL.EndVertical(); GL.EndHorizontal(); GL.Label("Advanced Settings for Growth Rules", EditorStyles.centeredGreyMiniLabel); GL.BeginHorizontal(); GL.BeginVertical(); GL.Label("Street - Straight Angle"); GL.Label("Street - Branch Angle"); GL.Space(10); GL.Label("Highway - Branch Prob"); GL.Label("Highway - Straight Angle"); GL.Label("Highway - Branch Angle"); GL.EndVertical(); GL.BeginVertical(); CG.streetStraightAngle = EGL.Slider(CG.streetStraightAngle, 0f, 90f); CG.streetBranchAngle = EGL.Slider(CG.streetBranchAngle, 0f, 90f); GL.Space(10); CG.highwayBranchProb = EGL.Slider(CG.highwayBranchProb, 0f, 1f); CG.highwayStraightAngle = EGL.Slider(CG.highwayStraightAngle, 0f, 90f); CG.highwayBranchAngle = EGL.Slider(CG.highwayBranchAngle, 0f, 90f); GL.EndVertical(); GL.EndHorizontal(); } if (roadMapGenerated) { GL.BeginHorizontal("Box"); GL.FlexibleSpace(); CG.showPop = EGL.ToggleLeft("Preview Pop Map", CG.showPop); GL.FlexibleSpace(); CG.showGrowth = EGL.ToggleLeft("Preview Growth Map", CG.showGrowth); GL.FlexibleSpace(); GL.EndHorizontal(); if (DebugMode) { showPreviewGUI(); } } EGL.HelpBox("The 'Generate Road Map' button may take several tries to generate road map due to the random nature of the algorithm.", MessageType.Info); GL.BeginHorizontal(); if (GL.Button("Generate Road Map")) { GameObject roadMap = GameObject.Find("RoadMap"); GameObject nodes = GameObject.Find("Nodes"); if (roadMap != null) { roadMap.SetActive(true); } if (nodes != null) { nodes.SetActive(true); } generator.generateRoadMap(); roadMapGenerated = true; roadMeshGenerated = false; } EG.BeginDisabledGroup(!roadMapGenerated); if (GL.Button("Generate Road Meshes & Blocks")) { generator.generateRoadMeshes(); generator.generateBlocks(); roadMeshGenerated = true; } EG.EndDisabledGroup(); GL.EndHorizontal(); EG.BeginDisabledGroup(!roadMeshGenerated); if (GL.Button("Save and Proceed")) { showRoadMapUI = false; showRoadMapAdvanced = false; showBuildingUI = true; GameObject roadMap = GameObject.Find("RoadMap"); if (roadMap != null) { roadMap.SetActive(false); } GameObject nodes = GameObject.Find("Nodes"); if (nodes != null) { nodes.SetActive(false); } roadmapLabel = "4. Road Map Generation - COMPLETED ✔"; } EG.EndDisabledGroup(); } EG.EndDisabledGroup(); }
void showGrowthMapGUI() { EG.BeginDisabledGroup(!(terrainGenerated)); showGrowthUI = EGL.Foldout(showGrowthUI, growthLabel, true); if (showGrowthUI) { GL.BeginVertical(); GL.BeginHorizontal(); GL.BeginVertical(); if (GL.Button("Basic Rule")) { CG.growthBasic = 1; CG.growthNewYork = 0; CG.growthParis = 0; } if (GL.Button("New York Rule")) { CG.growthNewYork = 1; CG.growthBasic = 0; CG.growthParis = 0; } if (GL.Button("Paris Rule")) { CG.growthParis = 1; CG.growthBasic = 0; CG.growthNewYork = 0; } GL.EndVertical(); GL.BeginVertical(); GL.Space(1); CG.growthBasic = EGL.Slider(1 - CG.growthNewYork - CG.growthParis, 0, 1); GL.Space(1); CG.growthNewYork = EGL.Slider(1 - CG.growthBasic - CG.growthParis, 0, 1); GL.Space(1); CG.growthParis = EGL.Slider(1 - CG.growthBasic - CG.growthNewYork, 0, 1); GL.EndVertical(); GL.EndHorizontal(); GL.Space(1); if (GL.Button("Default")) { CG.growthParis = 1f / 3f; CG.growthBasic = 1f / 3f; CG.growthNewYork = 1f / 3f; } GL.BeginHorizontal("box"); GL.BeginVertical(); GL.Label("Octaves"); GL.Label("Persistance"); GL.Label("Zoom"); GL.Label("Seed"); GL.EndVertical(); GL.BeginVertical(); CG.growthOctaves = EGL.IntSlider(CG.growthOctaves, 1, 6); CG.growthPersistance = EGL.Slider(CG.growthPersistance, 0, 0.7f); CG.growthZoom = EGL.Slider(CG.growthZoom, 0, 0.05f); GL.BeginHorizontal(); EG.BeginDisabledGroup(rGrowthSeed.target == false); CG.growthSeed = EGL.IntSlider(CG.growthSeed, 0, int.MaxValue); EG.EndDisabledGroup(); rGrowthSeed.target = EGL.Toggle(rGrowthSeed.target); GL.EndHorizontal(); GL.Space(20); GL.BeginHorizontal(); GL.Label("Or import your growth-rule map: "); CG.growthMapInput = (Texture2D)EGL.ObjectField(CG.growthMapInput, typeof(Texture2D), false); GL.EndHorizontal(); GL.EndVertical(); GL.EndHorizontal(); GL.EndVertical(); GL.BeginHorizontal(); if (GL.Button("Generate Growth Map")) { if (rGrowthSeed.target == false && CG.growthMapInput == null) { CG.growthSeed = Random.Range(0, int.MaxValue); } generator.generateGrowthRule(); isGrowthMap = true; CG.showGrowth = true; } EG.BeginDisabledGroup(!isGrowthMap); GL.BeginHorizontal(); GL.FlexibleSpace(); CG.showGrowth = EGL.ToggleLeft("Preview Growth Map", CG.showGrowth); GL.FlexibleSpace(); GL.EndHorizontal(); GL.EndHorizontal(); if (GL.Button("Save and Proceed")) { growthMapGenerated = true; growthLabel = "3. Growth Map Generation - COMPLETED ✔"; showGrowthUI = false; CG.showGrowth = false; showRoadMapUI = true; } EG.EndDisabledGroup(); } EG.EndDisabledGroup(); }
void showPopulationMapGUI() { EG.BeginDisabledGroup(!(terrainGenerated)); showPopUI = EGL.Foldout(showPopUI, populationLabel, true); if (showPopUI) { GL.BeginVertical(); GL.BeginHorizontal("box"); GL.BeginVertical(); GL.Label("Octaves"); GL.Label("Persistance"); GL.Label("Zoom"); GL.Label("Seed"); GL.EndVertical(); GL.BeginVertical(); CG.popOctaves = EGL.IntSlider(CG.popOctaves, 1, 6); CG.popPersistance = EGL.Slider(CG.popPersistance, 0, 0.5f); CG.popZoom = EGL.Slider(CG.popZoom, 0, 0.05f); GL.BeginHorizontal(); EG.BeginDisabledGroup(rPopSeed.target == false); CG.popSeed = EGL.IntSlider(CG.popSeed, 0, int.MaxValue); EG.EndDisabledGroup(); rPopSeed.target = EGL.Toggle(rPopSeed.target); GL.EndHorizontal(); GL.Space(20); GL.BeginHorizontal(); GL.Label("Or import your custom pop map: "); CG.popMapInput = (Texture2D)EGL.ObjectField(CG.popMapInput, typeof(Texture2D), false); GL.EndHorizontal(); GL.EndVertical(); GL.EndHorizontal(); GL.EndVertical(); GL.BeginHorizontal(); if (GL.Button("Generate Population Map")) { if (rPopSeed.target == false && CG.popMapInput == null) { CG.popSeed = Random.Range(0, int.MaxValue); } generator.generatePopulationMap(); isPopMap = true; CG.showPop = true; } EG.BeginDisabledGroup(!isPopMap); GL.BeginHorizontal(); GL.FlexibleSpace(); CG.showPop = EGL.ToggleLeft("Preview Pop Map", CG.showPop); GL.EndHorizontal(); GL.EndHorizontal(); if (GL.Button("Save and Proceed")) { populationGenerated = true; populationLabel = "2. Population Map Generation - COMPLETED ✔"; showPopUI = false; CG.showPop = false; showGrowthUI = true; } EG.EndDisabledGroup(); } EG.EndDisabledGroup(); }