public static Toggle ( bool value, |
||
value | bool | |
content | ||
Résultat | bool |
protected virtual void OnGUI() { if (!SetPivot && Selection.activeGameObject) { oldpos = Selection.activeGameObject.transform.position; } GUI.BeginHorizontal(); SetPivot = (GUI.Toggle(SetPivot, "Pivot", GUI.ExpandWidth(false)) && Selection.activeGameObject != null); var old = SetCam; SetCam = (GUI.Toggle(SetCam && Camera.main != null, "Cam", GUI.ExpandHeight(false))); //camset if (SetCam != old && SetCam == false) { ResetCam(); } if (GUI.Button("Apply")) { ApplyAll(); } if (GUI.Button("Add")) { if (!instances.Contains(Selection.activeObject.name)) { instances.Add(Selection.activeObject.name); SaveParams(); } } GUI.EndHorizontal(); DrawObjects(); DrawSearch(); }
protected virtual void OnGUI() { if (GUI.Button("Init")) { foreach (var go in Selection.gameObjects) { foreach (var scr in go.GetComponents <Base>()) { scr.Init(); } } } foreach (var a in GameObject.FindGameObjectsWithTag("EditorGUI").Where(a => a != Selection.activeGameObject)) { a.GetComponent <Base>().OnEditorGui(); } if (Selection.activeGameObject != null) { var bs2 = Selection.activeGameObject.GetComponent <Base>(); if (bs2 != null) { bs2.OnEditorGui(); } } GUI.BeginHorizontal(); Base.debug = GUI.Toggle(Base.debug, "debug", GUI.ExpandWidth(false)); GUI.EndHorizontal(); DrawSearch(); }
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(); }
protected virtual void OnGUI() { if (Camera.main == null) { return; } if (!SetPivot && Selection.activeGameObject) { oldpos = Selection.activeGameObject.transform.position; } GUI.BeginHorizontal(); SetPivot = (GUI.Toggle(SetPivot, "Pivot", GUI.ExpandWidth(false)) && Selection.activeGameObject != null); var old = SetCam; SetCam = (GUI.Toggle(SetCam && Camera.main != null, "Cam", GUI.ExpandHeight(false))); //camset Camera.main.renderingPath = (RenderingPath)gui.EnumPopup(Camera.main.renderingPath); if (SetCam != old && SetCam == false) { ResetCam(); } if (GUI.Button("Apply")) { ApplyAll(); } if (GUI.Button("Add")) { if (!instances.Contains(Selection.activeObject.name)) { instances.Add(Selection.activeObject.name); SaveParams(); } } if (GUI.Button("Init")) { foreach (var a in Selection.gameObjects.Select(a => a.GetComponent <MonoBehaviour>())) { a.SendMessage("Init", SendMessageOptions.DontRequireReceiver); } } GUI.EndHorizontal(); QualitySettings.shadowDistance = gui.FloatField("LightmapDist", QualitySettings.shadowDistance); if (Selection.activeGameObject != null) { LayerDistances(); var bs = Selection.activeGameObject.GetComponent <Base>(); if (bs != null) { bs.OnInspectorGUI(); } } DrawObjects(); DrawSearch(); }
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); }
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); }
protected virtual void OnGUI() { if (!SetPivot && Selection.activeGameObject) { oldpos = Selection.activeGameObject.transform.position; } GUI.BeginHorizontal(); SetPivot = (GUI.Toggle(SetPivot, "Pivot", GUI.ExpandWidth(false)) && Selection.activeGameObject != null); var old = SetCam; SetCam = (GUI.Toggle(SetCam && Camera.main != null, "Cam", GUI.ExpandHeight(false))); //camset if (SetCam != old && SetCam == false) { ResetCam(); } if (GUI.Button("NextCam")) { NextCamera(); } if (GUI.Button("Init")) { Inits(); } GUI.EndHorizontal(); QualitySettings.shadowDistance = gui.FloatField("LightmapDist", QualitySettings.shadowDistance); GUI.BeginHorizontal(); GUI.EndHorizontal(); GUI.BeginHorizontal(); Base.debug = GUI.Toggle(Base.debug, "debug", GUI.ExpandWidth(false)); GUI.EndHorizontal(); foreach (var a in GameObject.FindGameObjectsWithTag("EditorGUI").Where(a => a != Selection.activeGameObject)) { a.GetComponent <bs>().OnEditorGui(); } if (Selection.activeGameObject != null) { var bs2 = Selection.activeGameObject.GetComponent <Base>(); if (bs2 != null) { bs2.OnEditorGui(); } } DrawSearch(); }
public void OnGUI() { if (mapHolder == null) { mapHolder = GameObject.Find("Atom Map List").transform; if (mapHolder == null) { GUI.Label(new Rect((position.width - 100) / 2, (position.height - 20) / 2, 100, 20), "NO ATOM MAP LIST"); return; } } if (map == null) { SetTargetMap(0); } GL.Label("Radius:"); radiusIndex = GL.Toolbar(radiusIndex, radiusLabels); GL.Label("Subdivision:"); subdivIndex = GL.Toolbar(subdivIndex, subdivLabels); subdivOffset = EGL.IntField("Subdiv Offset:", subdivOffset); GL.Label("Levels:"); numLevelsIndex = GL.Toolbar(numLevelsIndex, numLevelsLabels); bool prevEditingState = isEditing; GL.BeginHorizontal(); //GL.Label(""); isEditing = GL.Toggle(isEditing, "Enable/Disable Editing"); if (isEditing != prevEditingState) { ToggleEditing(isEditing); } int prevTarget = targetMapIndex; targetMapIndex = (int)Mathf.Clamp(EGL.IntField("Target Map", targetMapIndex), 0, mapHolder.childCount - 1); if (prevTarget != targetMapIndex) { SetTargetMap(targetMapIndex); } GL.EndHorizontal(); radius = radiusOptions[radiusIndex]; subdiv = subdivOptions[subdivIndex]; numLevels = numLevelsIndex + 1; }
private static void OnGUIOther() { if (GUI.Button("Init")) { foreach (var go in Selection.gameObjects) { foreach (var scr in go.GetComponents <Base>()) { scr.Init(); } } } Base.debug = GUI.Toggle(Base.debug, "debug", GUI.ExpandWidth(false)); }
protected virtual void OnGUI() { if (!SetPivot && Selection.activeGameObject) { oldPivot = Selection.activeGameObject.transform.position; } SetPivot = (GUI.Toggle(SetPivot, "Pivot", GUI.ExpandWidth(false)) && Selection.activeGameObject != null); SetCam = (GUI.Toggle(SetCam && Camera.mainCamera != null, "Cam", GUI.ExpandHeight(false))); //camset QualitySettings.shadowDistance = gui.FloatField("LightmapDist", QualitySettings.shadowDistance); //OnGUIOther(); OnGUIMono(); DrawSearch(); }
public static void Toggle(Setting <bool> val, GUILayoutOption[] opts) { val.Value = UGUI.Toggle(val.Value, string.Empty, Style.Toggle, opts); }
public static void Toggle(Setting <bool> val) { val.Value = UGUI.Toggle(val.Value, string.Empty, Style.Toggle, DefaultOption); }
public void OnGUI() { EditorGUIUtility.labelWidth = 75; if (atomMapHolder == null) { atomMapHolder = GameObject.Find("Atom Map List").transform; if (atomMapHolder == null) { GUI.Label(new Rect((position.width - 100) / 2, (position.height - 20) / 2, 100, 20), "NO ATOM MAP LIST"); return; } } if (ionMapHolder == null) { ionMapHolder = GameObject.Find("Ion Map List").transform; if (ionMapHolder == null) { GUI.Label(new Rect((position.width - 100) / 2, (position.height - 20) / 2, 100, 20), "NO ION MAP LIST"); return; } } if (atomMap == null || ionMap == null) { SetTargetMap(0); } GL.BeginHorizontal(); type = (IonType)EGL.EnumPopup("Ion Type:", type); behaviour = (IonBehaviour)EGL.EnumPopup("Behaviour:", behaviour); GL.EndHorizontal(); radiusIndex = EGL.IntSlider("Radius:", radiusIndex, 0, 500); GL.Label("Subdivision:"); subdivIndex = GL.Toolbar(subdivIndex, subdivLabels); subdivOffset = EGL.IntField("Subdiv Offset:", subdivOffset); if (behaviour == IonBehaviour.Orbit) { orbitFreq = EGL.FloatField("Orbit Speed:", orbitFreq); resetTrigger = (Atom)EGL.ObjectField("Reset Trig:", resetTrigger, typeof(Atom)); } bool prevEditingState = isEditing; GL.BeginHorizontal(); //GL.Label(""); isEditing = GL.Toggle(isEditing, "Enable/Disable Editing"); if (isEditing != prevEditingState) { ToggleEditing(isEditing); } int prevTarget = targetMapIndex; targetMapIndex = (int)Mathf.Clamp(EGL.IntField("Target Map", targetMapIndex), 0, atomMapHolder.childCount - 1); if (prevTarget != targetMapIndex) { SetTargetMap(targetMapIndex); } GL.EndHorizontal(); radius = radiusIndex * baseRadiusUnit; subdiv = subdivOptions[subdivIndex]; }
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(); }
public static bool Toggle(bool val, GUILayoutOption[] opts) { return(UGUI.Toggle(val, string.Empty, Style.Toggle, opts)); }
protected override void OnGUI() { GUI.BeginHorizontal(); web = GUI.Toggle(web, "web", GUI.ExpandWidth(false)); var old = buildall; buildall = GUI.Toggle(buildall, "all", GUI.ExpandWidth(false)); if (buildall && buildall != old) { disablePathFinding = debug = disableSounds = stopZombies = false; } if (GUILayout.Button("Build")) { EditorUtility.SetDirty(_Loader); Build(); return; } if (GUI.Button("Refresh")) { if (!isPlaying) { var c = EditorApplication.currentScene; EditorApplication.SaveScene(c); for (int i = 0; i < 4; i++) { EditorApplication.OpenScene("Assets/scenes/Menu.unity"); EditorApplication.OpenScene("Assets/scenes/Pitt.unity"); } EditorApplication.OpenScene(c); return; } } GUI.EndHorizontal(); BuildButtons(); GUI.BeginHorizontal(); if (GUI.Button("loader")) { EditorUtility.SetDirty(loader); } debug = GUI.Toggle(debug, "Debug"); _Loader.build = !debug; disablePathFinding = GUI.Toggle(disablePathFinding, "DPath"); _Loader.disablePathFinding = disablePathFinding; disableSounds = GUI.Toggle(disableSounds, "Dsounds"); _Loader.disableSounds = disableSounds; stopZombies = GUI.Toggle(stopZombies, "DZombies"); _Loader.stopZombies = stopZombies; client = GUI.Toggle(client, "client"); _Loader.host = !client; GUI.EndHorizontal(); GUI.BeginHorizontal(); bake = GUI.Toggle(bake, "Bake"); lfactor = EditorGUILayout.FloatField(lfactor, GUI.Width(20)); dfactor = EditorGUILayout.FloatField(dfactor, GUI.Width(20)); if (GUI.Button("SetupLevel")) { LevelSetup(); } if (GUI.Button("InitV")) { foreach (GameObject a in GameObject.FindObjectsOfTypeIncludingAssets(typeof(GameObject))) { if (AssetDatabase.IsMainAsset(a)) { bool mod = false; var ar = a.transform.GetTransforms().ToArray(); foreach (var b in ar) { var bs = b.GetComponent <bs>(); if (bs != null) { bs.InitValues(); mod = true; } } if (mod) { EditorUtility.SetDirty(a); } } else if (EditorApplication.isPlaying) { a.SendMessage("InitValues", SendMessageOptions.DontRequireReceiver); } } } if (GUI.Button("Init")) { Undo.RegisterSceneUndo("SceneInit"); SetupMaterials(); if (Selection.activeGameObject != null) { Inits(cspath); } } GUI.EndHorizontal(); //BuildGUI(); //GUI.Space(10); //if (Application.isPlaying && Base2._Game != null) //{ // foreach (Player p in Base2._Game.players) // if (p != null) // if (GUI.Button(p.name + ":" + p.OwnerID)) // Selection.activeObject = p; //} base.OnGUI(); }
protected virtual void OnGUI() { if (Camera.main == null) { return; } if (!SetPivot && Selection.activeGameObject) { oldpos = Selection.activeGameObject.transform.position; } GUI.BeginHorizontal(); SetPivot = (GUI.Toggle(SetPivot, "Pivot", GUI.ExpandWidth(false)) && Selection.activeGameObject != null); var old = SetCam; SetCam = (GUI.Toggle(SetCam && Camera.main != null, "Cam", GUI.ExpandHeight(false))); //camset Camera.main.renderingPath = (RenderingPath)gui.EnumPopup(Camera.main.renderingPath); if (SetCam != old && SetCam == false) { ResetCam(); } if (GUI.Button("Apply")) { ApplyAll(); } if (GUI.Button("Add")) { if (!instances.Contains(Selection.activeObject.name)) { instances.Add(Selection.activeObject.name); SaveParams(); } } if (GUI.Button("Init")) { Inits(); } GUI.EndHorizontal(); QualitySettings.shadowDistance = gui.FloatField("LightmapDist", QualitySettings.shadowDistance); GUI.BeginHorizontal(); GUI.EndHorizontal(); GUI.BeginHorizontal(); //EditorPrefs.SetBool("Debug", GUI.Toggle(EditorPrefs.GetBool("Debug"), "debug", GUI.ExpandWidth(false))); Base.debug = GUI.Toggle(Base.debug, "debug", GUI.ExpandWidth(false)); Base.disableScripts = GUI.Toggle(Base.disableScripts, "disableScripts", GUI.ExpandWidth(false)); GUI.EndHorizontal(); if (Selection.activeGameObject != null) { var bs2 = Selection.activeGameObject.GetComponent <Base>(); if (bs2 != null) { bs2.OnEditorGui(); } } DrawObjects(); DrawSearch(); }
protected virtual void OnGUI() { if (Camera.main == null) { return; } if (!SetPivot && Selection.activeGameObject) { oldpos = Selection.activeGameObject.transform.position; } GUI.BeginHorizontal(); SetPivot = (GUI.Toggle(SetPivot, "Pivot", GUI.ExpandWidth(false)) && Selection.activeGameObject != null); var old = SetCam; SetCam = (GUI.Toggle(SetCam && Camera.main != null, "Cam", GUI.ExpandHeight(false))); //camset Camera.main.renderingPath = (RenderingPath)gui.EnumPopup(Camera.main.renderingPath); if (SetCam != old && SetCam == false) { ResetCam(); } if (GUI.Button("Apply")) { ApplyAll(); } if (GUI.Button("Add")) { if (!instances.Contains(Selection.activeObject.name)) { instances.Add(Selection.activeObject.name); SaveParams(); } } if (GUI.Button("Init")) { Inits(); } GUI.EndHorizontal(); QualitySettings.shadowDistance = gui.FloatField("LightmapDist", QualitySettings.shadowDistance); if (Selection.activeGameObject != null) // Layer Distances { var ls = Camera.main.layerCullDistances; var lr = Selection.activeGameObject.layer; var oldv = ls[lr]; ls[lr] = gui.FloatField("LayerDist", ls[lr]); if (oldv != ls[lr]) { Camera.main.layerCullDistances = ls; } } GUI.BeginHorizontal(); bake = GUI.Toggle(bake, "Bake", GUI.ExpandWidth(false)); lfactor = EditorGUILayout.FloatField(lfactor, GUI.Width(30)); GUI.Label("ambient", GUI.Width(30)); dfactor = EditorGUILayout.FloatField(dfactor, GUI.Width(30)); GUI.Label("Directional", GUI.Width(30)); //if (GUI.Button("SetupLevel")) // LevelSetup(); GUI.EndHorizontal(); GUI.BeginHorizontal(); EditorPrefs.SetBool("Debug", GUI.Toggle(EditorPrefs.GetBool("Debug"), "debug", GUI.ExpandWidth(false))); web = GUI.Toggle(web, "web", GUI.ExpandWidth(false)); GUI.EndHorizontal(); if (GUI.Button("Build")) { Build(); return; } if (Selection.activeGameObject != null) { var bs2 = Selection.activeGameObject.GetComponent <Base>(); if (bs2 != null) { bs2.OnEditorGui(); } } DrawObjects(); DrawSearch(); }
/// <summary> /// Field drawing utility used when a field of an object needs to be drawn /// </summary> private static object DrawPropertyObject(object property, Type type, int indent = 0) { var _val = property; // UnityEngine.Object if (typeof(U.Object).IsAssignableFrom(type)) { U.Object _elementAsObject = null; _val.TryCast <U.Object>(out _elementAsObject); #if UNITY_EDITOR _elementAsObject = EGl.ObjectField(_elementAsObject, type, true); #else Gl.Label(_elementAsObject.ToString()); #endif _elementAsObject.TryCast <object>(out _val); return(_val); } // Initialize new if null (and newable). // Doing this after the Unity Object check will assure no GameObjects are spawned in the current scene if (_val == null) { var _constructorInfo = type.GetConstructor(Type.EmptyTypes); if (_constructorInfo != null) { _val = _constructorInfo.Invoke(null); } else { _val = default(object); } } // Implements the iDrawableProperty if (_val is iDrawableProperty) { iDrawableProperty _asDrawable = (iDrawableProperty)_val; _asDrawable.DrawAsProperty(); return(_val); } // Bool if (_val is bool) { bool _elementAsBool = default(bool); if (_val.TryCast <bool>(out _elementAsBool)) { _elementAsBool = Gl.Toggle(_elementAsBool, ""); } _elementAsBool.TryCast <object>(out _val); return(_val); } // Int if (_val is int) { int _elementAsInt = default(int); if (_val.TryCast <int>(out _elementAsInt)) { #if UNITY_EDITOR _elementAsInt = EGl.IntField(_elementAsInt); #else int.TryParse(Gl.TextField(_elementAsInt.ToString()), out _elementAsInt); #endif } _elementAsInt.TryCast <object>(out _val); return(_val); } // Float if (_val is float) { float _elementAsFloat = default(float); if (_val.TryCast <float>(out _elementAsFloat)) { #if UNITY_EDITOR _elementAsFloat = EGl.FloatField(_elementAsFloat); #else float.TryParse(Gl.TextField(_elementAsFloat.ToString()), out _elementAsFloat); #endif } _elementAsFloat.TryCast <object>(out _val); return(_val); } // String if (_val is string || typeof(string).IsAssignableFrom(type)) { string _elementAsString = string.Empty; if (_val != null) { if (_val.TryCast <string>(out _elementAsString)) { _elementAsString = Gl.TextField(_elementAsString); } } else { Gl.Label("EMPTY STRING"); } _elementAsString.TryCast <object>(out _val); return(_val); } // Try drawing using reflection, // expecting that it is a newable type that is already initialized in the code above if (_val != null) { var _valType = _val.GetType(); if (indent == 0) { Gl.Label(_valType.Name); } var _fieldInfo = _valType.GetFields(BindingFlags.Public | BindingFlags.Instance); if (indent < PROPERTY_DEPTH_LIMIT) { indent++; OpenIndent(indent); foreach (var _field in _fieldInfo) { Gl.BeginHorizontal(); Gl.Label(StringUtil.WordSplit(_field.Name, true), Gl.ExpandWidth(false)); Gl.BeginVertical(); var _fieldValue = _field.GetValue(_val); _field.SetValue(_val, DrawPropertyObject(_fieldValue, _field.FieldType, indent)); Gl.EndVertical(); Gl.EndHorizontal(); } CloseIndent(); } else { Gl.Label(string.Format("[!] MAX DRAWING DEPTH ({0}) REACHED", PROPERTY_DEPTH_LIMIT)); } return(_val); } Gl.Label("[ERROR] Unknown Type"); return(null); }
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(); }
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 void OnGUI(UnityModManager.ModEntry modEntry) { if (!Mod.Enabled) { return; } if (toggleStyle == null) { toggleStyle = new GUIStyle(GUI.skin.toggle) { wordWrap = true } } ; using (new GL.VerticalScope("box")) { ToggleVendorProgression = GL.Toggle(ToggleVendorProgression, Local["Menu_Tog_VenProgress"], Array.Empty <GLO>()); } using (new GL.VerticalScope("box")) { ToggleHighlightScrolls = GL.Toggle(ToggleHighlightScrolls, Local["Menu_Tog_HLScrolls"], Array.Empty <GLO>()); using (new GUISubScope()) ScrollColor = OnGUIColorSlider(ScrollColor, Local["Menu_Txt_Unlearned"]); } using (new GL.VerticalScope("box")) { ToggleVendorTrash = GL.Toggle(ToggleVendorTrash, Local["Menu_Tog_VendorTrash"], toggleStyle, GL.ExpandWidth(false)); using (new GUISubScope()) { TrashColor = OnGUIColorSlider(TrashColor, Local["Menu_Txt_VendorTrash"]); ToggleAutoSell = GL.Toggle(ToggleAutoSell, Local["Menu_Tog_AutoSell"], toggleStyle, GL.ExpandWidth(false)); using (new GL.HorizontalScope()) { if (GL.Button(ToggleShowTrash ? Local["Menu_Tog_HideTrash"] : Local["Menu_Tog_ShowTrash"], GL.ExpandWidth(false))) { ToggleShowTrash = !ToggleShowTrash; } if (GL.Button(Local["Menu_Btn_ClearTrash"], GL.ExpandWidth(false))) { VendorTrashItems.Clear(); } } if (ToggleShowTrash) { using (new GUISubScope()) { string remove = ""; foreach (string trash in VendorTrashItems) { using (new GL.VerticalScope("box", GL.ExpandWidth(false))) { using (new GL.HorizontalScope()) { bool hasKeep = TrashItemsKeep.ContainsKey(trash); GL.Label($"{library.Get<BlueprintItem>(trash).Name} x{((hasKeep) ? TrashItemsKeep[trash] : 0)} {Local["Menu_Txt_Kept"]}", GL.MaxHeight(screenWidth), GL.MaxHeight(lineHeight)); if (GL.Button("+", GL.ExpandWidth(false))) { if (hasKeep) { TrashItemsKeep[trash]++; } else { TrashItemsKeep.Add(trash, 1); } } if (GL.Button("-", GL.ExpandWidth(false))) { if (hasKeep && TrashItemsKeep[trash] > 0) { TrashItemsKeep[trash]--; } else if (hasKeep) { TrashItemsKeep.Remove(trash); } } if (GL.Button(Local["Menu_Btn_Remove"], GL.ExpandWidth(false))) { remove = trash; } if (Event.current.type == EventType.Repaint) { screenWidth = GUILayoutUtility.GetLastRect().width; } } } } if (remove != "") { VendorTrashItems.Remove(remove); } } } } } using (new GL.VerticalScope("box")) { using (new GUISubScope()) OnGUILang(); } }
public static bool Toggle(bool val) { return(UGUI.Toggle(val, string.Empty, Style.Toggle, DefaultOption)); }
protected override void OnGUI() { GUI.BeginHorizontal(); web = GUI.Toggle(web, "web", GUI.ExpandWidth(false)); var old = _Loader.completeBuild; _Loader.completeBuild = GUI.Toggle(_Loader.completeBuild, "all", GUI.ExpandWidth(false)); if (_Loader.completeBuild && _Loader.completeBuild != old) { proxy = disablePathFinding = debug = disableSounds = stopZombies = false; } if (GUILayout.Button("Build")) { Build(); return; } if (GUI.Button("Refresh")) { if (!isPlaying) { var c = EditorApplication.currentScene; EditorApplication.SaveScene(c); for (int i = 0; i < 4; i++) { EditorApplication.OpenScene("Assets/scenes/Menu.unity"); EditorApplication.OpenScene("Assets/scenes/Pitt.unity"); } EditorApplication.OpenScene(c); return; } } GUI.EndHorizontal(); BuildButtons(); GUI.BeginHorizontal(); proxy = GUI.Toggle(proxy, "proxy"); _Loader.proxy = proxy; debug = GUI.Toggle(debug, "Debug"); _Loader.build = !debug; disablePathFinding = GUI.Toggle(disablePathFinding, "DPath"); _Loader.disablePathFinding = disablePathFinding; disableSounds = GUI.Toggle(disableSounds, "Dsounds"); _Loader.disableSounds = disableSounds; stopZombies = GUI.Toggle(stopZombies, "DZombies"); _Loader.stopZombies = stopZombies; client = GUI.Toggle(client, "client"); _Loader.host = !client; GUI.EndHorizontal(); GUI.BeginHorizontal(); bake = GUI.Toggle(bake, "Bake", GUI.ExpandWidth(false)); lfactor = EditorGUILayout.FloatField(lfactor, GUI.Width(30)); dfactor = EditorGUILayout.FloatField(dfactor, GUI.Width(30)); if (GUI.Button("SetupLevel")) { LevelSetup(); } if (GUI.Button("Init")) { Undo.RegisterSceneUndo("SceneInit"); SetupMaterials(); FixMaterials(); if (Selection.activeGameObject != null) { Inits(cspath); } else { InitValues(); } } GUI.EndHorizontal(); base.OnGUI(); }
public static void Render() { GL.BeginVertical("box"); GL.BeginHorizontal(); settings.showPartyStatisticsCategory = GL.Toggle(settings.showPartyStatisticsCategory, RichTextUtils.MainCategoryFormat(Strings.GetText("mainCategory_PartyStats")), GL.ExpandWidth(false)); if (!settings.showPartyStatisticsCategory) { GL.EndHorizontal(); } else { MenuTools.FlexibleSpaceCategoryMenuElementsEndHorizontal("PartyOptions"); GL.Space(10); MenuTools.ToggleButton(ref settings.toggleAccessRemoteCharacters, "buttonToggle_AccessRemoteCharacters", "tooltip_AccessRemoteCharacters", nameof(settings.toggleAccessRemoteCharacters)); MenuTools.ToggleButtonActions(ref settings.toggleShowAllPartyPortraits, GroupControllerUtils.NaviBlockShowAllPartyMembers, GroupControllerUtils.NaviBlockShowDefault, "buttonToggle_ShowAllPartyPortraits", "tooltip_ShowAllPartyPortraits", nameof(settings.toggleShowAllPartyPortraits)); GL.Space(10); GL.BeginHorizontal(); Storage.statsFilterUnitEntityDataIndex = GL.SelectionGrid(Storage.statsFilterUnitEntityDataIndex, unitEntityDataFiltersArray, 3); GL.EndHorizontal(); Player player = Game.Instance.Player; switch (Storage.statsFilterUnitEntityDataIndex) { case 0: Storage.statsUnitEntityData = player.Party; break; case 1: Storage.statsUnitEntityData = player.ControllableCharacters; break; case 2: Storage.statsUnitEntityData = player.ActiveCompanions; break; case 3: Storage.statsUnitEntityData = player.AllCharacters; break; case 4: Storage.statsUnitEntityData = PartyUtils.GetRemoteCompanions(); break; case 5: Storage.statsUnitEntityData = PartyUtils.GetCustomCompanions(); break; case 6: Storage.statsUnitEntityData = PartyUtils.GetPets(); break; } if (Storage.statsFilterUnitEntityDataIndex != Storage.statsFilterUnitEntityDataIndexOld) { Storage.reloadPartyStats = true; Storage.statsFilterUnitEntityDataIndexOld = Storage.statsFilterUnitEntityDataIndex; } GL.Space(10); if (Storage.statsUnitEntityData.Any()) { if (Storage.reloadPartyStats) { Storage.statsSelectedControllableCharacterIndex = 0; Storage.statsPartyMembers = Storage.statsUnitEntityData; Storage.statsControllableCharacterNamesList.Clear(); foreach (UnitEntityData controllableCharacter in Storage.statsUnitEntityData) { Storage.statsControllableCharacterNamesList.Add(controllableCharacter.CharacterName); } Storage.reloadPartyStats = false; } if (!Storage.reloadPartyStats) { GL.BeginHorizontal(); Storage.statsSelectedControllableCharacterIndex = GL.SelectionGrid(Storage.statsSelectedControllableCharacterIndex, Storage.statsControllableCharacterNamesList.ToArray(), 6); GL.EndHorizontal(); GL.Space(10); GL.BeginVertical("box"); if (Storage.statsFilterUnitEntityDataIndex != 4) { MenuTools.SingleLineLabelGt("warning_SelectRemoteCharacters"); } else { if (GL.Button(MenuTools.TextWithTooltip("button_AddRemoteCompanionToParty", "tooltip_AddRemoteCompanionToParty", false), GL.ExpandWidth(false))) { UnitEntityDataUtils.AddCompanion(Storage.statsPartyMembers[Storage.statsSelectedControllableCharacterIndex]); } GL.Space(10); if (!StringUtils.ToToggleBool(settings.toggleShowAllPartyPortraits) && Game.Instance.Player.Party.Count > 6) { MenuTools.SingleLineLabelGt("warning_PartyLimitShowAllPartyPortraits"); } } GL.EndVertical(); GL.Space(10); MainMenu.CurrentHitPointsOptions(); GL.Space(10); MainMenu.ChangeName(); GL.Space(10); MainMenu.ChangeGender(); GL.Space(10); MainMenu.ClassData(); GL.Space(10); //Menu.RaceData(); //GL.Space(10); /* * if (GL.Button(MenuTools.TextWithTooltip("button_RemoveEquippedItems", "tooltip_RemoveEquippedItems", false), GL.ExpandWidth(false))) * { * foreach (ItemEntity itemEntity in Storage.statsPartyMembers[Storage.statsSelectedControllableCharacterIndex].Inventory.Items) * { * if (itemEntity.Owner == Storage.statsPartyMembers[Storage.statsSelectedControllableCharacterIndex].Descriptor) * { * itemEntity.HoldingSlot.RemoveItem(); * } * } * } * GL.Space(10);*/ GL.BeginVertical("box"); GL.BeginHorizontal(); if (GL.Button(MenuTools.TextWithTooltip("button_ResetCharacterLevel", "tooltip_ResetCharacterLevel", false), GL.ExpandWidth(false))) { int level = 21; int xp = Storage.statsPartyMembers[Storage.statsSelectedControllableCharacterIndex].Descriptor.Progression.Experience; BlueprintStatProgression xpTable = BlueprintRoot.Instance.Progression.XPTable; for (int i = 20; i >= 1; i--) { int xpBonus = xpTable.GetBonus(i); modLogger.Log(i + ": " + xpBonus + " | " + xp); if ((xp - xpBonus) >= 0) { modLogger.Log(i + ": " + (xp - xpBonus)); level = i; break; } } Type type = Storage.statsPartyMembers[Storage.statsSelectedControllableCharacterIndex].Descriptor.Progression.GetType(); PropertyInfo propertyInfo = type.GetProperty("CharacterLevel"); propertyInfo.SetValue(Storage.statsPartyMembers[Storage.statsSelectedControllableCharacterIndex].Descriptor.Progression, level, null); } GL.EndHorizontal(); GL.Space(10); GL.BeginHorizontal(); Storage.setCharLevel = GL.HorizontalSlider(Storage.setCharLevel, 1f, 20f, GL.Width(250f)); GL.Label($" {Mathf.RoundToInt(Storage.setCharLevel)}", GL.ExpandWidth(false)); GL.EndHorizontal(); GL.BeginHorizontal(); if (GL.Button(MenuTools.TextWithTooltip("button_SetCharacterLevel", "tooltip_SetCharacterLevel", "", $" {Mathf.RoundToInt(Storage.setCharLevel)}" + " " + StringUtils.PutInParenthesis(Storage.statsPartyMembers[Storage.statsSelectedControllableCharacterIndex].CharacterName)), GL.ExpandWidth(false))) { Type type = Storage.statsPartyMembers[Storage.statsSelectedControllableCharacterIndex].Descriptor.Progression.GetType(); PropertyInfo propertyInfoLvl = type.GetProperty("CharacterLevel"); propertyInfoLvl.SetValue(Storage.statsPartyMembers[Storage.statsSelectedControllableCharacterIndex].Descriptor.Progression, Mathf.RoundToInt(Storage.setCharLevel), null); int newXp = BlueprintRoot.Instance.Progression.XPTable.GetBonus(Mathf.RoundToInt(Storage.setCharLevel)); PropertyInfo propertyInfoXp = type.GetProperty("Experience"); propertyInfoXp.SetValue(Storage.statsPartyMembers[Storage.statsSelectedControllableCharacterIndex].Descriptor.Progression, newXp, null); } GL.EndHorizontal(); MenuTools.SingleLineLabel(Strings.GetText("warning_SetCharacterLevel")); GL.EndVertical(); GL.Space(10); MenuTools.UnitAlignment(Storage.statsPartyMembers[Storage.statsSelectedControllableCharacterIndex]); GL.Space(10); GL.BeginVertical("box"); MenuTools.SingleLineLabel(RichTextUtils.Bold(Strings.GetText("header_Size"))); GL.BeginHorizontal(); Storage.partySelectedSizeIndex = GL.SelectionGrid(Storage.partySelectedSizeIndex, Storage.charSizeArray, 4); GL.EndHorizontal(); GL.Space(10); GL.BeginHorizontal(); if (GL.Button(MenuTools.TextWithTooltip("button_SetSizeTo", "tooltip_SetSize", "", $" {Storage.charSizeArray[Storage.partySelectedSizeIndex]}"), GL.ExpandWidth(false))) { Storage.statsPartyMembers[Storage.statsSelectedControllableCharacterIndex].Descriptor.State.Size = (Size)Storage.partySelectedSizeIndex; } GL.EndHorizontal(); GL.BeginHorizontal(); if (GL.Button(MenuTools.TextWithTooltip("button_SetToOriginalSize", "tooltip_SetToOriginalSize", "", $" ({Storage.statsPartyMembers[Storage.statsSelectedControllableCharacterIndex].Descriptor.OriginalSize})"), GL.ExpandWidth(false))) { Storage.statsPartyMembers[Storage.statsSelectedControllableCharacterIndex].Descriptor.State.Size = Storage.statsPartyMembers[Storage.statsSelectedControllableCharacterIndex].Descriptor.OriginalSize; } GL.EndHorizontal(); MenuTools.SingleLineLabel(Strings.GetText("label_CurrentSize") + ": " + Common.SizeToString(Storage.statsPartyMembers[Storage.statsSelectedControllableCharacterIndex].Descriptor.State.Size)); GL.EndVertical(); GL.Space(10); GL.BeginHorizontal(); GL.Label(MenuTools.TextWithTooltip("header_Statistics", "tooltip_Statistics", true)); GL.EndHorizontal(); GL.BeginHorizontal(); settings.partyStatsAmount = GL.TextField(settings.partyStatsAmount, 10, GL.Width(85f)); MenuTools.SettingParse(ref settings.partyStatsAmount, ref settings.partyFinalStatsAmount); GL.EndHorizontal(); CharacterStats charStats = Storage.statsPartyMembers[Storage.statsSelectedControllableCharacterIndex].Descriptor.Stats; MenuTools.SingleLineLabel(RichTextUtils.Bold(Strings.GetText("header_AttributesBaseValues"))); foreach (KeyValuePair <string, StatType> entry in Storage.statsAttributesDict) { MenuTools.CreateStatInterface(entry.Key, charStats, entry.Value, settings.partyFinalStatsAmount); } MenuTools.SingleLineLabel(RichTextUtils.Bold(Strings.GetText("header_SkillsRanks"))); MenuTools.ToggleButton(ref settings.toggleShowOnlyClassSkills, "buttonToggle_ShowOnlyClassSkills", "tooltip_ShowOnlyClassSkills"); foreach (KeyValuePair <string, StatType> entry in Storage.statsSkillsDict) { if (StringUtils.ToToggleBool(settings.toggleShowOnlyClassSkills)) { ModifiableValueSkill stat = charStats.GetStat(entry.Value) as ModifiableValueSkill; if (stat.ClassSkill && stat.BaseValue > 0) { MenuTools.CreateStatInterface(entry.Key, charStats, entry.Value, settings.partyFinalStatsAmount); } } else { MenuTools.CreateStatInterface(entry.Key, charStats, entry.Value, settings.partyFinalStatsAmount, true); } } MenuTools.SingleLineLabel(RichTextUtils.Bold(Strings.GetText("header_SocialSkillsBaseValues"))); foreach (KeyValuePair <string, StatType> entry in Storage.statsSocialSkillsDict) { MenuTools.CreateStatInterface(entry.Key, charStats, entry.Value, settings.partyFinalStatsAmount); } MenuTools.SingleLineLabel(RichTextUtils.Bold(Strings.GetText("header_StatsSaves"))); foreach (KeyValuePair <string, StatType> entry in Storage.statsSavesDict) { MenuTools.CreateStatInterface(entry.Key, charStats, entry.Value, settings.partyFinalStatsAmount); } MenuTools.SingleLineLabel(RichTextUtils.Bold(Strings.GetText("header_StatsCombat"))); foreach (KeyValuePair <string, StatType> entry in Storage.statsCombatDict) { MenuTools.CreateStatInterface(entry.Key, charStats, entry.Value, settings.partyFinalStatsAmount); } GL.Space(10); GL.BeginHorizontal(); GL.Label(MenuTools.TextWithTooltip("header_PartyMultipliers", "tooltip_PartyMultipliers", true)); GL.EndHorizontal(); GL.BeginHorizontal(); settings.partyStatMultiplier = GL.HorizontalSlider(settings.partyStatMultiplier, 0.1f, 10f, GL.Width(300f)); GL.Label($" {Math.Round(settings.partyStatMultiplier, 1)}", GL.ExpandWidth(false)); GL.EndHorizontal(); MenuTools.SingleLineLabel(RichTextUtils.Bold(Strings.GetText("header_Attributes"))); foreach (KeyValuePair <string, StatType> entry in Storage.statsAttributesDict) { MenuTools.CreateStatMultiplierInterface(entry.Key, charStats, entry.Value, Storage.statsPartyMembers, settings.partyStatMultiplier); } MenuTools.SingleLineLabel(RichTextUtils.Bold(Strings.GetText("header_Skills"))); foreach (KeyValuePair <string, StatType> entry in Storage.statsSkillsDict) { MenuTools.CreateStatMultiplierInterface(entry.Key, charStats, entry.Value, Storage.statsPartyMembers, settings.partyStatMultiplier); } MenuTools.SingleLineLabel(RichTextUtils.Bold(Strings.GetText("header_SocialSkills"))); foreach (KeyValuePair <string, StatType> entry in Storage.statsSocialSkillsDict) { MenuTools.CreateStatMultiplierInterface(entry.Key, charStats, entry.Value, Storage.statsPartyMembers, settings.partyStatMultiplier); } MenuTools.SingleLineLabel(RichTextUtils.Bold(Strings.GetText("header_Saves"))); foreach (KeyValuePair <string, StatType> entry in Storage.statsSavesDict) { MenuTools.CreateStatMultiplierInterface(entry.Key, charStats, entry.Value, Storage.statsPartyMembers, settings.partyStatMultiplier); } MenuTools.SingleLineLabel(RichTextUtils.Bold(Strings.GetText("header_Combat"))); foreach (KeyValuePair <string, StatType> entry in Storage.statsCombatDict) { MenuTools.CreateStatMultiplierInterface(entry.Key, charStats, entry.Value, Storage.statsPartyMembers, settings.partyStatMultiplier); } GL.BeginHorizontal(); if (GL.Button(MenuTools.TextWithTooltip("button_ExportCharInfo", "tooltip_ExportCharInfo", false), GL.ExpandWidth(false))) { List <string> charInfoTxt = new List <string>(); charInfoTxt.Add($"{Storage.statsPartyMembers[Storage.statsSelectedControllableCharacterIndex].CharacterName}"); charInfoTxt.Add(""); charInfoTxt.Add(Strings.GetText("header_AttributesBaseValues")); foreach (KeyValuePair <string, StatType> entry in Storage.statsAttributesDict) { charInfoTxt.Add(($"{entry.Key}: {charStats.GetStat(entry.Value).BaseValue} ({charStats.GetStat(entry.Value).ModifiedValue})")); } charInfoTxt.Add(""); charInfoTxt.Add(Strings.GetText("header_SkillsRanks")); foreach (KeyValuePair <string, StatType> entry in Storage.statsSkillsDict) { charInfoTxt.Add(($"{entry.Key}: {charStats.GetStat(entry.Value).BaseValue} ({charStats.GetStat(entry.Value).ModifiedValue})")); } charInfoTxt.Add(""); charInfoTxt.Add(Strings.GetText("header_SocialSkillsBaseValues")); foreach (KeyValuePair <string, StatType> entry in Storage.statsSocialSkillsDict) { charInfoTxt.Add(($"{entry.Key}: {charStats.GetStat(entry.Value).BaseValue} ({charStats.GetStat(entry.Value).ModifiedValue})")); } charInfoTxt.Add(""); charInfoTxt.Add(Strings.GetText("header_StatsSaves")); foreach (KeyValuePair <string, StatType> entry in Storage.statsSavesDict) { charInfoTxt.Add(($"{entry.Key}: {charStats.GetStat(entry.Value).BaseValue} ({charStats.GetStat(entry.Value).ModifiedValue})")); } charInfoTxt.Add(""); charInfoTxt.Add(Strings.GetText("header_StatsCombat")); foreach (KeyValuePair <string, StatType> entry in Storage.statsCombatDict) { charInfoTxt.Add(($"{entry.Key}: {charStats.GetStat(entry.Value).BaseValue} ({charStats.GetStat(entry.Value).ModifiedValue})")); } File.WriteAllLines(Path.Combine(Common.ExportPath(), $"{Storage.statsPartyMembers[Storage.statsSelectedControllableCharacterIndex].CharacterName}.txt"), charInfoTxt.ToArray()); } GL.Label(" " + Strings.GetText("label_Location") + $": {Path.Combine(Common.ExportPath(), $"{Storage.statsPartyMembers[Storage.statsSelectedControllableCharacterIndex].CharacterName}.txt")}"); GL.EndHorizontal(); if (File.Exists(Storage.modEntryPath + Storage.charactersImportFolder + "\\" + Storage.statsPartyMembers[Storage.statsSelectedControllableCharacterIndex].CharacterName + ".txt")) { if (GL.Button(MenuTools.TextWithTooltip("button_ImportStatsFrom", "tooltip_ImportStatsFrom", "", $" { Storage.statsPartyMembers[Storage.statsSelectedControllableCharacterIndex].CharacterName}.txt"), GL.ExpandWidth(false))) { if (settings.settingCreateBackupBeforeImport) { List <string> charInfoTxt = new List <string>(); charInfoTxt.Add($"{Storage.statsPartyMembers[Storage.statsSelectedControllableCharacterIndex].CharacterName}"); charInfoTxt.Add(""); charInfoTxt.Add(Strings.GetText("header_AttributesBaseValues")); foreach (KeyValuePair <string, StatType> entry in Storage.statsAttributesDict) { charInfoTxt.Add(($"{entry.Key}: {charStats.GetStat(entry.Value).BaseValue} ({charStats.GetStat(entry.Value).ModifiedValue})")); } charInfoTxt.Add(""); charInfoTxt.Add(Strings.GetText("header_SkillsRanks")); foreach (KeyValuePair <string, StatType> entry in Storage.statsSkillsDict) { charInfoTxt.Add(($"{entry.Key}: {charStats.GetStat(entry.Value).BaseValue} ({charStats.GetStat(entry.Value).ModifiedValue})")); } charInfoTxt.Add(""); charInfoTxt.Add(Strings.GetText("header_SocialSkillsBaseValues")); foreach (KeyValuePair <string, StatType> entry in Storage.statsSocialSkillsDict) { charInfoTxt.Add(($"{entry.Key}: {charStats.GetStat(entry.Value).BaseValue} ({charStats.GetStat(entry.Value).ModifiedValue})")); } charInfoTxt.Add(""); charInfoTxt.Add(Strings.GetText("header_StatsSaves")); foreach (KeyValuePair <string, StatType> entry in Storage.statsSavesDict) { charInfoTxt.Add(($"{entry.Key}: {charStats.GetStat(entry.Value).BaseValue} ({charStats.GetStat(entry.Value).ModifiedValue})")); } charInfoTxt.Add(""); charInfoTxt.Add(Strings.GetText("header_StatsCombat")); foreach (KeyValuePair <string, StatType> entry in Storage.statsCombatDict) { charInfoTxt.Add(($"{entry.Key}: {charStats.GetStat(entry.Value).BaseValue} ({charStats.GetStat(entry.Value).ModifiedValue})")); } File.WriteAllLines(Path.Combine(Storage.modEntryPath + Storage.charactersImportFolder + "\\" + Storage.statsPartyMembers[Storage.statsSelectedControllableCharacterIndex].CharacterName + "_Backup.txt"), charInfoTxt.ToArray()); } string[] lines = File.ReadAllLines(Storage.modEntryPath + Storage.charactersImportFolder + "\\" + Storage.statsPartyMembers[Storage.statsSelectedControllableCharacterIndex].CharacterName + ".txt"); lines = lines.Where(x => !string.IsNullOrEmpty(x)).ToArray(); lines = lines.Where(x => !string.IsNullOrWhiteSpace(x)).ToArray(); for (int i = 0; i < lines.Length; i++) { if (Regex.IsMatch(lines[i], @"[\x20A-Za-z()]+:\s*[0-9]+")) { Match match = Regex.Match(lines[i], @"[\x20A-Za-z()]+:\s*[0-9]+"); lines[i] = match.Value; string[] splitLine = lines[i].Split(':'); Dictionary <string, StatType> allStats = Storage.statsAttributesDict.Union(Storage.statsSkillsDict).Union(Storage.statsSocialSkillsDict).Union(Storage.statsSavesDict).Union(Storage.statsCombatDict).ToDictionary(k => k.Key, v => v.Value); if (allStats.TryGetValue(splitLine[0], out StatType statType) && int.TryParse(splitLine[1], out int baseValue)) { charStats.GetStat(statType).BaseValue = baseValue; } } else { } } } } } } else { MenuTools.SingleLineLabel(Strings.GetText("message_NoUnitFound")); } } GL.EndVertical(); }