From 21c58255dc723d9719ca792de38027bc7f33cf0d Mon Sep 17 00:00:00 2001 From: Codenade Date: Mon, 26 Aug 2024 13:16:13 +0200 Subject: [PATCH 1/2] Show initial, intermediate and final values in processors section Changed 'Save' to 'Apply' in edit processor values section --- .../Assets/Prefabs/ProcessorSaveButton.prefab | 6 +- .../Prefabs/ProcessorWindowContent.prefab | 179 ++++++++++++++++-- ksp2-inputbinder/ProcessorUtilities.cs | 56 +++++- ksp2-inputbinder/ksp2-inputbinder.csproj | 1 + ksp2-inputbinder/ui/Page1ListPopulator.cs | 57 +++++- 5 files changed, 281 insertions(+), 18 deletions(-) diff --git a/ksp2-inputbinder-assets/Assets/Prefabs/ProcessorSaveButton.prefab b/ksp2-inputbinder-assets/Assets/Prefabs/ProcessorSaveButton.prefab index 297a793..941de4d 100644 --- a/ksp2-inputbinder-assets/Assets/Prefabs/ProcessorSaveButton.prefab +++ b/ksp2-inputbinder-assets/Assets/Prefabs/ProcessorSaveButton.prefab @@ -28,9 +28,9 @@ RectTransform: m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 5116417121060861808} - m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 1, y: 1} @@ -65,7 +65,7 @@ MonoBehaviour: m_OnCullStateChanged: m_PersistentCalls: m_Calls: [] - m_text: Save + m_text: Apply m_isRightToLeft: 0 m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} @@ -164,10 +164,10 @@ RectTransform: m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 m_Children: - {fileID: 8152111216060116498} m_Father: {fileID: 0} - m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} diff --git a/ksp2-inputbinder-assets/Assets/Prefabs/ProcessorWindowContent.prefab b/ksp2-inputbinder-assets/Assets/Prefabs/ProcessorWindowContent.prefab index 52c4bc7..1883473 100644 --- a/ksp2-inputbinder-assets/Assets/Prefabs/ProcessorWindowContent.prefab +++ b/ksp2-inputbinder-assets/Assets/Prefabs/ProcessorWindowContent.prefab @@ -29,10 +29,10 @@ RectTransform: m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 m_Children: - {fileID: 1270871443995391932} m_Father: {fileID: 1270871443436255870} - m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} @@ -117,11 +117,11 @@ RectTransform: m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 m_Children: - {fileID: 5074258553313709405} - {fileID: 1270871443811412285} m_Father: {fileID: 1270871443995391932} - m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 1} m_AnchorMax: {x: 0, y: 1} @@ -181,12 +181,13 @@ RectTransform: m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 m_Children: - {fileID: 5590239601663679738} - {fileID: 5261023518752025834} + - {fileID: 8609084857017548466} - {fileID: 1270871443381220763} m_Father: {fileID: 1270871443995391932} - m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 1} m_AnchorMax: {x: 0, y: 1} @@ -246,9 +247,9 @@ RectTransform: m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 1270871443186402786} - m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 1} m_AnchorMax: {x: 0, y: 1} @@ -310,11 +311,11 @@ RectTransform: m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 m_Children: - {fileID: 1270871442902592211} - {fileID: 1270871444194003788} m_Father: {fileID: 0} - m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5} @@ -416,12 +417,12 @@ RectTransform: m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 m_Children: - {fileID: 5590239602625455646} - {fileID: 3912228579438252192} - {fileID: 1270871444206273172} m_Father: {fileID: 1270871443995391932} - m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 1} m_AnchorMax: {x: 0, y: 1} @@ -481,9 +482,9 @@ RectTransform: m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 1270871443037968783} - m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 1} m_AnchorMax: {x: 0, y: 1} @@ -544,9 +545,9 @@ RectTransform: m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 1270871443968477037} - m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} @@ -617,10 +618,10 @@ RectTransform: m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 m_Children: - {fileID: 1270871443883074262} m_Father: {fileID: 1270871444194003788} - m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 1, y: 1} @@ -655,12 +656,12 @@ RectTransform: m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 m_Children: - {fileID: 1270871443186402786} - {fileID: 1270871443037968783} - {fileID: 1270871443555904178} m_Father: {fileID: 1270871442902592211} - m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 1} m_AnchorMax: {x: 1, y: 1} @@ -736,10 +737,10 @@ RectTransform: m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 m_Children: - {fileID: 1270871443968477037} m_Father: {fileID: 1270871443436255870} - m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 1, y: 0} m_AnchorMax: {x: 1, y: 1} @@ -860,9 +861,9 @@ RectTransform: m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 1270871443555904178} - m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 1} m_AnchorMax: {x: 0, y: 1} @@ -895,11 +896,146 @@ MonoBehaviour: m_ChildScaleWidth: 0 m_ChildScaleHeight: 0 m_ReverseArrangement: 0 +--- !u!1 &7636621036918834461 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 8609084857017548466} + - component: {fileID: 5670778205235396274} + - component: {fileID: 8584136711572514353} + m_Layer: 5 + m_Name: TextValue + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &8609084857017548466 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7636621036918834461} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 1270871443186402786} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 20} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &5670778205235396274 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7636621036918834461} + m_CullTransparentMesh: 1 +--- !u!114 &8584136711572514353 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7636621036918834461} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_text: + m_isRightToLeft: 0 + m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} + m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} + m_fontSharedMaterials: [] + m_fontMaterial: {fileID: 0} + m_fontMaterials: [] + m_fontColor32: + serializedVersion: 2 + rgba: 4294967295 + m_fontColor: {r: 1, g: 1, b: 1, a: 1} + m_enableVertexGradient: 0 + m_colorMode: 3 + m_fontColorGradient: + topLeft: {r: 1, g: 1, b: 1, a: 1} + topRight: {r: 1, g: 1, b: 1, a: 1} + bottomLeft: {r: 1, g: 1, b: 1, a: 1} + bottomRight: {r: 1, g: 1, b: 1, a: 1} + m_fontColorGradientPreset: {fileID: 0} + m_spriteAsset: {fileID: 0} + m_tintAllSprites: 0 + m_StyleSheet: {fileID: 0} + m_TextStyleHashCode: -1183493901 + m_overrideHtmlColors: 0 + m_faceColor: + serializedVersion: 2 + rgba: 4294967295 + m_fontSize: 22 + m_fontSizeBase: 22 + m_fontWeight: 400 + m_enableAutoSizing: 0 + m_fontSizeMin: 18 + m_fontSizeMax: 72 + m_fontStyle: 0 + m_HorizontalAlignment: 1 + m_VerticalAlignment: 256 + m_textAlignment: 65535 + m_characterSpacing: 0 + m_wordSpacing: 0 + m_lineSpacing: 0 + m_lineSpacingMax: 0 + m_paragraphSpacing: 0 + m_charWidthMaxAdj: 0 + m_enableWordWrapping: 1 + m_wordWrappingRatios: 0.4 + m_overflowMode: 0 + m_linkedTextComponent: {fileID: 0} + parentLinkedComponent: {fileID: 0} + m_enableKerning: 1 + m_enableExtraPadding: 0 + checkPaddingRequired: 0 + m_isRichText: 1 + m_parseCtrlCharacters: 1 + m_isOrthographic: 1 + m_isCullingEnabled: 0 + m_horizontalMapping: 0 + m_verticalMapping: 0 + m_uvLineOffset: 0 + m_geometrySortingOrder: 0 + m_IsTextObjectScaleStatic: 0 + m_VertexBufferAutoSizeReduction: 0 + m_useMaxVisibleDescender: 1 + m_pageToDisplay: 1 + m_margin: {x: 0, y: 0, z: 0, w: 0} + m_isUsingLegacyAnimationComponent: 0 + m_isVolumetricText: 0 + m_hasFontAssetChanged: 0 + m_baseMaterial: {fileID: 0} + m_maskOffset: {x: 0, y: 0, z: 0, w: 0} --- !u!1001 &1270871443237806995 PrefabInstance: m_ObjectHideFlags: 0 serializedVersion: 2 m_Modification: + serializedVersion: 3 m_TransformParent: {fileID: 1270871443186402786} m_Modifications: - target: {fileID: 3541106057085378520, guid: 5c674c30542c7f64084331bbddae68c7, type: 3} @@ -995,6 +1131,9 @@ PrefabInstance: value: ProcessorCancelButton objectReference: {fileID: 0} m_RemovedComponents: [] + m_RemovedGameObjects: [] + m_AddedGameObjects: [] + m_AddedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 5c674c30542c7f64084331bbddae68c7, type: 3} --- !u!224 &5590239601663679738 stripped RectTransform: @@ -1006,6 +1145,7 @@ PrefabInstance: m_ObjectHideFlags: 0 serializedVersion: 2 m_Modification: + serializedVersion: 3 m_TransformParent: {fileID: 1270871443555904178} m_Modifications: - target: {fileID: 6644937643226087273, guid: 5c674c30542c7f64084331bbddae68c7, type: 3} @@ -1097,6 +1237,9 @@ PrefabInstance: value: ProcessorCancelButton objectReference: {fileID: 0} m_RemovedComponents: [] + m_RemovedGameObjects: [] + m_AddedGameObjects: [] + m_AddedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 5c674c30542c7f64084331bbddae68c7, type: 3} --- !u!224 &5590239602625455646 stripped RectTransform: @@ -1108,6 +1251,7 @@ PrefabInstance: m_ObjectHideFlags: 0 serializedVersion: 2 m_Modification: + serializedVersion: 3 m_TransformParent: {fileID: 1270871443037968783} m_Modifications: - target: {fileID: 6644937643226087273, guid: 5c674c30542c7f64084331bbddae68c7, type: 3} @@ -1199,6 +1343,9 @@ PrefabInstance: value: ProcessorCancelButton objectReference: {fileID: 0} m_RemovedComponents: [] + m_RemovedGameObjects: [] + m_AddedGameObjects: [] + m_AddedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 5c674c30542c7f64084331bbddae68c7, type: 3} --- !u!224 &5074258553313709405 stripped RectTransform: @@ -1210,6 +1357,7 @@ PrefabInstance: m_ObjectHideFlags: 0 serializedVersion: 2 m_Modification: + serializedVersion: 3 m_TransformParent: {fileID: 1270871443555904178} m_Modifications: - target: {fileID: 5116417121060861808, guid: 5fb5680935354694bb69a32ebbbc2956, type: 3} @@ -1301,6 +1449,9 @@ PrefabInstance: value: ProcessorSaveButton objectReference: {fileID: 0} m_RemovedComponents: [] + m_RemovedGameObjects: [] + m_AddedGameObjects: [] + m_AddedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 5fb5680935354694bb69a32ebbbc2956, type: 3} --- !u!224 &3912228579438252192 stripped RectTransform: @@ -1312,6 +1463,7 @@ PrefabInstance: m_ObjectHideFlags: 0 serializedVersion: 2 m_Modification: + serializedVersion: 3 m_TransformParent: {fileID: 1270871443186402786} m_Modifications: - target: {fileID: 1025797152624248629, guid: b2517bd3c137096419d4959e713fc03e, type: 3} @@ -1415,6 +1567,9 @@ PrefabInstance: value: -1 objectReference: {fileID: 0} m_RemovedComponents: [] + m_RemovedGameObjects: [] + m_AddedGameObjects: [] + m_AddedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: b2517bd3c137096419d4959e713fc03e, type: 3} --- !u!224 &5261023518752025834 stripped RectTransform: diff --git a/ksp2-inputbinder/ProcessorUtilities.cs b/ksp2-inputbinder/ProcessorUtilities.cs index eb7e9ba..cd8a304 100644 --- a/ksp2-inputbinder/ProcessorUtilities.cs +++ b/ksp2-inputbinder/ProcessorUtilities.cs @@ -1,4 +1,8 @@ -namespace Codenade.Inputbinder +using System; +using System.Reflection; +using UnityEngine.InputSystem; + +namespace Codenade.Inputbinder { public static class ProcessorUtilities { @@ -24,5 +28,55 @@ public static bool ExtractSingleProcessor(string input, string processorName, ou output = input.Substring(start, end - start + 1); return true; } + + public static object Process(string processorString, object value, InputControl control) + { + var processorName = processorString.Substring(0, processorString.IndexOf('(')); + Type processorType = InputSystem.TryGetProcessor(processorName); + if (processorType is null) + return value; + InputProcessor processorObj = (InputProcessor)Activator.CreateInstance(processorType); + foreach (var parameterStr in processorString.Substring(processorName.Length + 1, processorString.IndexOf(')', processorName.Length) - (processorName.Length + 1)).Split(',')) + { + string[] splits = parameterStr.Split('='); + if (splits.Length == 2) + { + var fldInf = processorType.GetField(splits[0], BindingFlags.Instance | BindingFlags.Public); + if (fldInf is null) + continue; + object procFldValue = null; + var fldType = fldInf.FieldType; + if (fldType.IsValueType) + procFldValue = Activator.CreateInstance(fldType); + if (fldType == typeof(string)) + procFldValue = splits[1]; + else if (fldType.GetMethod("TryParse", new Type[] { typeof(string), fldType.MakeByRefType() }) is MethodInfo tryParseMethod) + { + object[] mParams = new object[] { splits[1], procFldValue }; + if (!(bool)tryParseMethod.Invoke(null, mParams)) + continue; + procFldValue = mParams[1]; + } + else if (fldType.GetMethod("Parse", new Type[] { typeof(string) }) is MethodInfo parseMethod) + { + try + { + procFldValue = parseMethod.Invoke(null, new object[] { splits[1] }); + } + catch (Exception) + { + continue; + } + } + else + { + continue; + } + + fldInf.SetValue(processorObj, procFldValue); + } + } + return processorObj.ProcessAsObject(value, control); + } } } diff --git a/ksp2-inputbinder/ksp2-inputbinder.csproj b/ksp2-inputbinder/ksp2-inputbinder.csproj index 8717901..aaf3ecc 100644 --- a/ksp2-inputbinder/ksp2-inputbinder.csproj +++ b/ksp2-inputbinder/ksp2-inputbinder.csproj @@ -3,6 +3,7 @@ netstandard2.1 Codenade.Inputbinder + true 0.6.0 diff --git a/ksp2-inputbinder/ui/Page1ListPopulator.cs b/ksp2-inputbinder/ui/Page1ListPopulator.cs index 8837b6e..f4c0718 100644 --- a/ksp2-inputbinder/ui/Page1ListPopulator.cs +++ b/ksp2-inputbinder/ui/Page1ListPopulator.cs @@ -1,20 +1,69 @@ -using TMPro; +using System.Reflection; +using TMPro; using UnityEngine; +using UnityEngine.InputSystem; namespace Codenade.Inputbinder { internal class Page1ListPopulator : MonoBehaviour { + private TextMeshProUGUI _textValue; + private TextMeshProUGUI[] _intermediates; + private string[] _processors; + private InputAction _action; + + private void Awake() + { + _textValue = transform.parent.Find("TextValue").GetComponent(); + } + + private unsafe void ValueUpdate(InputAction.CallbackContext ctx) + { + object originalValue; + var propInfo = typeof(InputControl).GetProperty("currentStatePtr", BindingFlags.Instance | BindingFlags.NonPublic); + var propVal = propInfo.GetMethod.Invoke(ctx.control, null); + void* ptr = System.Reflection.Pointer.Unbox(propVal); + originalValue = ctx.control.ReadValueFromStateAsObject(ptr); + _textValue.text = originalValue.ToString() ?? string.Empty; + if (originalValue is object) + { + int idx = 0; + foreach (var i in _intermediates) + { + if (idx == _intermediates.Length - 1) + originalValue = _action.ReadValueAsObject(); + else + originalValue = ProcessorUtilities.Process(_processors[idx], originalValue, ctx.control); + i.text = originalValue?.ToString() ?? string.Empty; + idx++; + } + } + } + private void OnEnable() { Reload(); + _action.started += ValueUpdate; + _action.performed += ValueUpdate; + _action.canceled += ValueUpdate; + } + + private void OnDisable() + { + _action.started -= ValueUpdate; + _action.performed -= ValueUpdate; + _action.canceled -= ValueUpdate; } public void Reload() { for (var j = gameObject.transform.childCount - 1; j >= 0; j--) DestroyImmediate(gameObject.transform.GetChild(j).gameObject); - foreach (var p in (Inputbinder.Instance.ActionManager.ProcBindInfo.Binding.overrideProcessors ?? "").Split(';')) + _action = Inputbinder.Instance.ActionManager.ProcBindInfo.Action; + _processors = (Inputbinder.Instance.ActionManager.ProcBindInfo.Binding.overrideProcessors ?? string.Empty).Split(';'); + _intermediates = new TextMeshProUGUI[_processors.Length]; + int idx = 0; + foreach (var p in _processors) { if (p.IsNullOrEmpty() || p.IndexOf('(') < 0 || p.IndexOf(')') < 0) continue; @@ -27,6 +76,10 @@ public void Reload() infoGroup.GetChild("ProcessorValues").GetComponent().text = values; temp.GetChild("ProcessorEditButton").AddComponent().Initialize(name); temp.GetChild("ProcessorRemoveButton").AddComponent().Initialize(name); + var intermediateValueGameObject = Instantiate(_textValue.gameObject, gameObject.transform); + intermediateValueGameObject.name = p + " Intermediate"; + _intermediates[idx] = intermediateValueGameObject.GetComponent(); + idx++; } } } From c80a67ce34343cac0d7723dd83f28bc4dd51d704 Mon Sep 17 00:00:00 2001 From: Codenade Date: Tue, 27 Aug 2024 22:27:31 +0200 Subject: [PATCH 2/2] add O before value and change text size, fix ";;" left after processor removal --- .../AssetGroups/Inputbinder.asset | 16 ++ .../Assets/Icons/ring-both.png | Bin 0 -> 857 bytes .../Assets/Icons/ring-both.png.meta | 127 ++++++++++ .../Assets/Icons/ring-bottom.png | Bin 0 -> 858 bytes .../Assets/Icons/ring-bottom.png.meta | 127 ++++++++++ .../Assets/Icons/ring-top.png | Bin 0 -> 874 bytes .../Assets/Icons/ring-top.png.meta | 127 ++++++++++ ksp2-inputbinder-assets/Assets/Icons/ring.png | Bin 0 -> 861 bytes .../Assets/Icons/ring.png.meta | 127 ++++++++++ ksp2-inputbinder-assets/Assets/Icons/ring.svg | 65 +++++ .../Assets/Icons/ring.svg.meta | 7 + .../Prefabs/ProcessorWindowContent.prefab | 229 ++++++++++++++---- ksp2-inputbinder/GameInputUtils.cs | 7 + ksp2-inputbinder/GlobalConfiguration.cs | 9 +- ksp2-inputbinder/ui/Page1ListPopulator.cs | 154 ++++++++++-- ksp2-inputbinder/ui/ProcRemoveBehaviour.cs | 11 +- 16 files changed, 931 insertions(+), 75 deletions(-) create mode 100644 ksp2-inputbinder-assets/Assets/Icons/ring-both.png create mode 100644 ksp2-inputbinder-assets/Assets/Icons/ring-both.png.meta create mode 100644 ksp2-inputbinder-assets/Assets/Icons/ring-bottom.png create mode 100644 ksp2-inputbinder-assets/Assets/Icons/ring-bottom.png.meta create mode 100644 ksp2-inputbinder-assets/Assets/Icons/ring-top.png create mode 100644 ksp2-inputbinder-assets/Assets/Icons/ring-top.png.meta create mode 100644 ksp2-inputbinder-assets/Assets/Icons/ring.png create mode 100644 ksp2-inputbinder-assets/Assets/Icons/ring.png.meta create mode 100644 ksp2-inputbinder-assets/Assets/Icons/ring.svg create mode 100644 ksp2-inputbinder-assets/Assets/Icons/ring.svg.meta diff --git a/ksp2-inputbinder-assets/Assets/AddressableAssetsData/AssetGroups/Inputbinder.asset b/ksp2-inputbinder-assets/Assets/AddressableAssetsData/AssetGroups/Inputbinder.asset index 05283ea..0b63bb5 100644 --- a/ksp2-inputbinder-assets/Assets/AddressableAssetsData/AssetGroups/Inputbinder.asset +++ b/ksp2-inputbinder-assets/Assets/AddressableAssetsData/AssetGroups/Inputbinder.asset @@ -105,6 +105,22 @@ MonoBehaviour: m_Address: Codenade.Inputbinder/SearchBox m_ReadOnly: 0 m_SerializedLabels: [] + - m_GUID: 40d436c09638a8d4c9656b4096794739 + m_Address: Codenade.Inputbinder/Icons/ring.png + m_ReadOnly: 0 + m_SerializedLabels: [] + - m_GUID: 7d227d68e3a3db84f869e22b08d3c3a5 + m_Address: Codenade.Inputbinder/Icons/ring-bottom.png + m_ReadOnly: 0 + m_SerializedLabels: [] + - m_GUID: aad6f57084e714d4fa828f6c841263cd + m_Address: Codenade.Inputbinder/Icons/ring-top.png + m_ReadOnly: 0 + m_SerializedLabels: [] + - m_GUID: de699fe0028059041b17dab217c93fb8 + m_Address: Codenade.Inputbinder/Icons/ring-both.png + m_ReadOnly: 0 + m_SerializedLabels: [] m_ReadOnly: 0 m_Settings: {fileID: 11400000, guid: 8644c698111574d4db1297cfbb2f6c1b, type: 2} m_SchemaSet: diff --git a/ksp2-inputbinder-assets/Assets/Icons/ring-both.png b/ksp2-inputbinder-assets/Assets/Icons/ring-both.png new file mode 100644 index 0000000000000000000000000000000000000000..d3eaee74f83fcd9f6d29f053bd02e022e1df018d GIT binary patch literal 857 zcmV-f1E&0mP)pF8FWQhbW?9;ba!ELWdL_~cP?peYja~^aAhuUa%Y?FJQ@H10_I6X zK~z|U?U&7O6;&9@nGR*4i2)33j9WJnS!pDqq)Lj2 z8x;Nl_FzoI#yE2Zl2Sfau9TGvKxiN)el%^pa$Xnhy*Vx1a(nNFnER~eeb0NI-#aHW zbI!=j=tgy2pE0vt0Fu7*-tX>ap6klJ4-EhV!2b-O4%h2XTJKFR%Q7Dt8rp4UZvf9H z#s>TfoRxIOdtYw|5JK1nd=0$bWuxcK?8EW#@yibcgb>~XP6An%<}KZo^ojTWXh%R@ z*Wa4izBLnn2fhbt;0A!Ckr<2KP5$f#29xKMG@9nlD0w!1#lX8qSc(F7rpnt zH~{C|k;MEi@J_ep0C}F5X0{jjcO~@*Fa@9x!l;@3oYb#c!;L6}Z~}NgNsYP~p+opWwS+C-z#xZNwDD2h2r=UTCu?QmwcIjOnOt9eT?#?)i8 z1D;NZxB3N0`Yj2caV$UY066C!?H2$%mRv76GiwuLjL-G!E-Cf6>42-r;6%RwGi!TD zy6PlNC*xb|x_-G=^Qx*|0bXjwF~(_^W!W^a*n*nbF*dNFB$A|KNxa~kn|6&x9Zt#6F3UV=enw@ z*CbWIrlgBmGdqyy`FWPN$y6%K(mUs-fLD|Jk|giFzqksp0@)+!6swK1@^^E^M@?&3aM<~EkU?ay{vmJYfWV|=?PiYsaIo?}a%=a-tz<_o|f z;IA%>|1`5t=jZ1~*P6ovjxDpZv%`yvixa?`zy$Er%FrC}gPENj9v=R2Y;0_ylgGM% jRD(a90bl@lhynir!GA3c$R9ft00000NkvXXu0mjfxJZ%e literal 0 HcmV?d00001 diff --git a/ksp2-inputbinder-assets/Assets/Icons/ring-both.png.meta b/ksp2-inputbinder-assets/Assets/Icons/ring-both.png.meta new file mode 100644 index 0000000..eeb3006 --- /dev/null +++ b/ksp2-inputbinder-assets/Assets/Icons/ring-both.png.meta @@ -0,0 +1,127 @@ +fileFormatVersion: 2 +guid: de699fe0028059041b17dab217c93fb8 +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 12 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + flipGreenChannel: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + vTOnly: 0 + ignoreMipmapLimit: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: 1 + aniso: 1 + mipBias: 0 + wrapU: 1 + wrapV: 1 + wrapW: 0 + nPOTScale: 0 + lightmap: 0 + compressionQuality: 50 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 0 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 300 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 1 + spriteTessellationDetail: -1 + textureType: 8 + textureShape: 1 + singleChannelComponent: 0 + flipbookRows: 1 + flipbookColumns: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + ignorePngGamma: 0 + applyGammaDecoding: 0 + swizzle: 50462976 + cookieLightType: 0 + platformSettings: + - serializedVersion: 3 + buildTarget: DefaultTexturePlatform + maxTextureSize: 64 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Server + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: 5e97eb03825dee720800000000000000 + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + nameFileIdTable: {} + mipmapLimitGroupName: + pSDRemoveMatte: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/ksp2-inputbinder-assets/Assets/Icons/ring-bottom.png b/ksp2-inputbinder-assets/Assets/Icons/ring-bottom.png new file mode 100644 index 0000000000000000000000000000000000000000..7c069e74b72a91627c4668085f3004209235faf0 GIT binary patch literal 858 zcmV-g1Eu_lP)pF8FWQhbW?9;ba!ELWdL_~cP?peYja~^aAhuUa%Y?FJQ@H10_RCY zK~z|U?UuW59Yqwzf8X)t;Q}F1@i2;@!J^>R1S76A>m?~bLP-!bh?a&3DiA0@WQYtQ zG=bzFpidC8(y=?6NX9%WDoBAS0trzN5)aEZm&~EC@737Jb*}HFK#{*{&zUpd@62d- zXXNe-qNZt1y8B)LNuP!g_6;)6267)k+kkDrbp}wM=glW=_9a(URg8^|?Q{1hfqODz z2Yv)jNje!qXto51G42FD1Rfu-(KGJ;>h$#V*VhEZ7+(aA1FZqgySgmtKnUS*UqI6| zAG`bh4HJI@J_8!yX8=hPDWxFkY2daE^&b^Q@yZo|7~{*p(X6loyf5j45W-(qYk7Wt z{+3Rs^P0QAPPSr6`$GuFdw{B{?l-e7gJ$4vy zdq(_aRDh)OS$K!B`o05TW;c!s0B+8nSIpge#FWzAqqqmeGyKzcs&RVV39I)Jly898faG+$8q$63pWM*^LZnrNU28y0SAFU z2QdD_-QQYVT%6o!4%fK0EG#UHFE20e0-gfy1@2rMIuHEd?x)7b$3LH%np*1Tu_@rc k(EsY{xDD6_T(5wC0qA5U4eiSaWB>pF07*qoM6N<$g1o4RCIA2c literal 0 HcmV?d00001 diff --git a/ksp2-inputbinder-assets/Assets/Icons/ring-bottom.png.meta b/ksp2-inputbinder-assets/Assets/Icons/ring-bottom.png.meta new file mode 100644 index 0000000..fbd5b0a --- /dev/null +++ b/ksp2-inputbinder-assets/Assets/Icons/ring-bottom.png.meta @@ -0,0 +1,127 @@ +fileFormatVersion: 2 +guid: 7d227d68e3a3db84f869e22b08d3c3a5 +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 12 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + flipGreenChannel: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + vTOnly: 0 + ignoreMipmapLimit: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: 1 + aniso: 1 + mipBias: 0 + wrapU: 1 + wrapV: 1 + wrapW: 0 + nPOTScale: 0 + lightmap: 0 + compressionQuality: 50 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 0 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 300 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 0 + alphaUsage: 1 + alphaIsTransparency: 1 + spriteTessellationDetail: -1 + textureType: 8 + textureShape: 1 + singleChannelComponent: 0 + flipbookRows: 1 + flipbookColumns: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + ignorePngGamma: 0 + applyGammaDecoding: 0 + swizzle: 50462976 + cookieLightType: 0 + platformSettings: + - serializedVersion: 3 + buildTarget: DefaultTexturePlatform + maxTextureSize: 64 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Server + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: 5e97eb03825dee720800000000000000 + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + nameFileIdTable: {} + mipmapLimitGroupName: + pSDRemoveMatte: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/ksp2-inputbinder-assets/Assets/Icons/ring-top.png b/ksp2-inputbinder-assets/Assets/Icons/ring-top.png new file mode 100644 index 0000000000000000000000000000000000000000..60ca9722a217fc19cd6c1025eba002c1afb9987f GIT binary patch literal 874 zcmV-w1C{)VP)pF8FWQhbW?9;ba!ELWdL_~cP?peYja~^aAhuUa%Y?FJQ@H10{2No zK~z|U?Uv1NRYe$wpWpPLc42JXps@ybHZJ_yV2wAK(_>j^VgOS&gsmHit~44yNR?C( zHz@oAZW}PBVPiaJ4kWcID^|dgpkjkD^`mL)wez~5_d31Ma(f#VP5Q3R`!T=goynY; zk(qHP&D~M;ZNN5QYXGut3nwQh`vwLEb^^@J&CQODjV*UGPV4>2Wm)EZeSQ1Q>;>Qv z{-5zOa0NIc>9qI0-Vh*!up9Ucc&?i+fpcc|=E%s%kGBPc5MBjNvVrAWv1Li`dhd^} z38?G(3o|>^G4OZbYoG>x29PuuWAu_<0`Bjq|2)t0H*Nxi5MBq4CxuPm6G@+X@BhA4 z%hS`-_coi&x6JHqk{L@n7SvOWNz4b9>Sz8jZ&FUI9f>%t|`j^380IGqYVu&3CpF-lDH2#ZtQmeoO5?=769Cnd@ngOYZGIP4{ugoQmS#y0hg2H=w<E<7)fZyz4yO4fGo=G%+5OJ zegcRw4odRCU`O2oa4^sFQ|&Hpab@o2#@YVRTFbJAU5zomTolFmGz}GyVPj-wqECFRZ1p zE+DnKu1}lUJ^)EydGGgkGj8j@O}7EtfGq&{4^e6@4Vsu@asU7T07*qoM6N<$g18Bv A?EnA( literal 0 HcmV?d00001 diff --git a/ksp2-inputbinder-assets/Assets/Icons/ring-top.png.meta b/ksp2-inputbinder-assets/Assets/Icons/ring-top.png.meta new file mode 100644 index 0000000..71e1ee9 --- /dev/null +++ b/ksp2-inputbinder-assets/Assets/Icons/ring-top.png.meta @@ -0,0 +1,127 @@ +fileFormatVersion: 2 +guid: aad6f57084e714d4fa828f6c841263cd +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 12 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + flipGreenChannel: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + vTOnly: 0 + ignoreMipmapLimit: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: 1 + aniso: 1 + mipBias: 0 + wrapU: 1 + wrapV: 1 + wrapW: 0 + nPOTScale: 0 + lightmap: 0 + compressionQuality: 50 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 0 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 300 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 0 + alphaUsage: 1 + alphaIsTransparency: 1 + spriteTessellationDetail: -1 + textureType: 8 + textureShape: 1 + singleChannelComponent: 0 + flipbookRows: 1 + flipbookColumns: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + ignorePngGamma: 0 + applyGammaDecoding: 0 + swizzle: 50462976 + cookieLightType: 0 + platformSettings: + - serializedVersion: 3 + buildTarget: DefaultTexturePlatform + maxTextureSize: 64 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Server + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: 5e97eb03825dee720800000000000000 + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + nameFileIdTable: {} + mipmapLimitGroupName: + pSDRemoveMatte: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/ksp2-inputbinder-assets/Assets/Icons/ring.png b/ksp2-inputbinder-assets/Assets/Icons/ring.png new file mode 100644 index 0000000000000000000000000000000000000000..206c40f9287222fd7bb4f03bccf697e229115388 GIT binary patch literal 861 zcmV-j1ETziP)pF8FWQhbW?9;ba!ELWdL_~cP?peYja~^aAhuUa%Y?FJQ@H10_sUb zK~z|U?UuW5R7VttzjJ&8ae-pd0KpN6CRPdpG+>mK=K2PTAR$QPG>Dca2&y0uFBy<| zr6GZTAgu)wvgmT}EJ(%)R8)Z?MFfFZAmk)iwzGH+1>R-6V6$FBVacbu=P|$U%xLb+ zh?(&|P2a2f0$>3!KLAOig?)W}Ep2UW%K(OlhljemyC)hMCo}!Yd7h^&EiGT0*;l}7 zUd?y{_!GD$B3GPquG48xoQ0Ro~3Es+p~dYHl_wUbPTH ztg%Xg1j216>jAf^+VP0whV&3k*f|J>L5hG%%B%o*pfV;*^LSi^7k9vk)EE zMNw=Pkpfs8bunmWhtf2?0n}f8lIOWo)m~sz6dxB6=bZa>3Sbh_Eh0ZNbuRW~H(8e5j)Skgi_$dxtx~Cc z3LFRiYe4v4GdnsmGSX2m4sUt33=R&qj*X3N0k#2afR86r4}m|->{@GU>o1+1oukuf n%m{cFHviwI3xEZ{JOI1^cuyq_91W8)00000NkvXXu0mjflc;<$ literal 0 HcmV?d00001 diff --git a/ksp2-inputbinder-assets/Assets/Icons/ring.png.meta b/ksp2-inputbinder-assets/Assets/Icons/ring.png.meta new file mode 100644 index 0000000..1b4f653 --- /dev/null +++ b/ksp2-inputbinder-assets/Assets/Icons/ring.png.meta @@ -0,0 +1,127 @@ +fileFormatVersion: 2 +guid: 40d436c09638a8d4c9656b4096794739 +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 12 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + flipGreenChannel: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + vTOnly: 0 + ignoreMipmapLimit: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: 1 + aniso: 1 + mipBias: 0 + wrapU: 1 + wrapV: 1 + wrapW: 0 + nPOTScale: 0 + lightmap: 0 + compressionQuality: 50 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 0 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 300 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 0 + alphaUsage: 1 + alphaIsTransparency: 1 + spriteTessellationDetail: -1 + textureType: 8 + textureShape: 1 + singleChannelComponent: 0 + flipbookRows: 1 + flipbookColumns: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + ignorePngGamma: 0 + applyGammaDecoding: 0 + swizzle: 50462976 + cookieLightType: 0 + platformSettings: + - serializedVersion: 3 + buildTarget: DefaultTexturePlatform + maxTextureSize: 64 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Server + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: 5e97eb03825dee720800000000000000 + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + nameFileIdTable: {} + mipmapLimitGroupName: + pSDRemoveMatte: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/ksp2-inputbinder-assets/Assets/Icons/ring.svg b/ksp2-inputbinder-assets/Assets/Icons/ring.svg new file mode 100644 index 0000000..70c31c7 --- /dev/null +++ b/ksp2-inputbinder-assets/Assets/Icons/ring.svg @@ -0,0 +1,65 @@ + + + + + + + + + + + + diff --git a/ksp2-inputbinder-assets/Assets/Icons/ring.svg.meta b/ksp2-inputbinder-assets/Assets/Icons/ring.svg.meta new file mode 100644 index 0000000..61b04d2 --- /dev/null +++ b/ksp2-inputbinder-assets/Assets/Icons/ring.svg.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 3037d4faf555238448395c1cb91b919c +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ksp2-inputbinder-assets/Assets/Prefabs/ProcessorWindowContent.prefab b/ksp2-inputbinder-assets/Assets/Prefabs/ProcessorWindowContent.prefab index 1883473..6ef36a7 100644 --- a/ksp2-inputbinder-assets/Assets/Prefabs/ProcessorWindowContent.prefab +++ b/ksp2-inputbinder-assets/Assets/Prefabs/ProcessorWindowContent.prefab @@ -1,5 +1,80 @@ %YAML 1.1 %TAG !u! tag:unity3d.com,2011: +--- !u!1 &60265376704322782 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 8392941439737547295} + - component: {fileID: 8498180138623673523} + - component: {fileID: 3157873713848644850} + m_Layer: 5 + m_Name: Icon + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &8392941439737547295 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 60265376704322782} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 8321961607384480341} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &8498180138623673523 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 60265376704322782} + m_CullTransparentMesh: 1 +--- !u!114 &3157873713848644850 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 60265376704322782} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 0 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 21300000, guid: de699fe0028059041b17dab217c93fb8, type: 3} + m_Type: 0 + m_PreserveAspect: 1 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 --- !u!1 &1270871442902592210 GameObject: m_ObjectHideFlags: 0 @@ -170,7 +245,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 0 + m_IsActive: 1 --- !u!224 &1270871443186402786 RectTransform: m_ObjectHideFlags: 0 @@ -185,14 +260,14 @@ RectTransform: m_Children: - {fileID: 5590239601663679738} - {fileID: 5261023518752025834} - - {fileID: 8609084857017548466} + - {fileID: 8321961607384480341} - {fileID: 1270871443381220763} m_Father: {fileID: 1270871443995391932} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 1} - m_AnchorMax: {x: 0, y: 1} - m_AnchoredPosition: {x: 90.33, y: -20} - m_SizeDelta: {x: 180.66, y: 40} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &1270871443186402787 MonoBehaviour: @@ -251,10 +326,10 @@ RectTransform: m_Children: [] m_Father: {fileID: 1270871443186402786} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 1} - m_AnchorMax: {x: 0, y: 1} - m_AnchoredPosition: {x: 90.33, y: -40} - m_SizeDelta: {x: 180.66, y: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &1270871443381220740 MonoBehaviour: @@ -896,7 +971,7 @@ MonoBehaviour: m_ChildScaleWidth: 0 m_ChildScaleHeight: 0 m_ReverseArrangement: 0 ---- !u!1 &7636621036918834461 +--- !u!1 &3748399627489724682 GameObject: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} @@ -904,50 +979,114 @@ GameObject: m_PrefabAsset: {fileID: 0} serializedVersion: 6 m_Component: - - component: {fileID: 8609084857017548466} - - component: {fileID: 5670778205235396274} - - component: {fileID: 8584136711572514353} + - component: {fileID: 8321961607384480341} + - component: {fileID: 4381604461232642093} m_Layer: 5 - m_Name: TextValue + m_Name: ValueGroup m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 ---- !u!224 &8609084857017548466 +--- !u!224 &8321961607384480341 RectTransform: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 7636621036918834461} + m_GameObject: {fileID: 3748399627489724682} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 8392941439737547295} + - {fileID: 3312148710545092697} + m_Father: {fileID: 1270871443186402786} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &4381604461232642093 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3748399627489724682} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 30649d3a9faa99c48a7b1166b86bf2a0, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Padding: + m_Left: 5 + m_Right: 0 + m_Top: 0 + m_Bottom: 0 + m_ChildAlignment: 3 + m_Spacing: 0 + m_ChildForceExpandWidth: 0 + m_ChildForceExpandHeight: 0 + m_ChildControlWidth: 1 + m_ChildControlHeight: 1 + m_ChildScaleWidth: 0 + m_ChildScaleHeight: 0 + m_ReverseArrangement: 0 +--- !u!1 &7155791252272157101 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 3312148710545092697} + - component: {fileID: 8103345695007027139} + - component: {fileID: 2368633411953927248} + m_Layer: 5 + m_Name: Value + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &3312148710545092697 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7155791252272157101} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] - m_Father: {fileID: 1270871443186402786} + m_Father: {fileID: 8321961607384480341} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 20} + m_AnchoredPosition: {x: 0, y: 0} m_SizeDelta: {x: 0, y: 0} m_Pivot: {x: 0.5, y: 0.5} ---- !u!222 &5670778205235396274 +--- !u!222 &8103345695007027139 CanvasRenderer: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 7636621036918834461} + m_GameObject: {fileID: 7155791252272157101} m_CullTransparentMesh: 1 ---- !u!114 &8584136711572514353 +--- !u!114 &2368633411953927248 MonoBehaviour: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 7636621036918834461} + m_GameObject: {fileID: 7155791252272157101} m_Enabled: 1 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3} @@ -955,13 +1094,13 @@ MonoBehaviour: m_EditorClassIdentifier: m_Material: {fileID: 0} m_Color: {r: 1, g: 1, b: 1, a: 1} - m_RaycastTarget: 1 + m_RaycastTarget: 0 m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} m_Maskable: 1 m_OnCullStateChanged: m_PersistentCalls: m_Calls: [] - m_text: + m_text: Value m_isRightToLeft: 0 m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} @@ -988,15 +1127,15 @@ MonoBehaviour: m_faceColor: serializedVersion: 2 rgba: 4294967295 - m_fontSize: 22 - m_fontSizeBase: 22 + m_fontSize: 12 + m_fontSizeBase: 12 m_fontWeight: 400 m_enableAutoSizing: 0 m_fontSizeMin: 18 m_fontSizeMax: 72 m_fontStyle: 0 m_HorizontalAlignment: 1 - m_VerticalAlignment: 256 + m_VerticalAlignment: 512 m_textAlignment: 65535 m_characterSpacing: 0 m_wordSpacing: 0 @@ -1004,16 +1143,16 @@ MonoBehaviour: m_lineSpacingMax: 0 m_paragraphSpacing: 0 m_charWidthMaxAdj: 0 - m_enableWordWrapping: 1 + m_enableWordWrapping: 0 m_wordWrappingRatios: 0.4 - m_overflowMode: 0 + m_overflowMode: 3 m_linkedTextComponent: {fileID: 0} parentLinkedComponent: {fileID: 0} m_enableKerning: 1 m_enableExtraPadding: 0 checkPaddingRequired: 0 - m_isRichText: 1 - m_parseCtrlCharacters: 1 + m_isRichText: 0 + m_parseCtrlCharacters: 0 m_isOrthographic: 1 m_isCullingEnabled: 0 m_horizontalMapping: 0 @@ -1024,7 +1163,7 @@ MonoBehaviour: m_VertexBufferAutoSizeReduction: 0 m_useMaxVisibleDescender: 1 m_pageToDisplay: 1 - m_margin: {x: 0, y: 0, z: 0, w: 0} + m_margin: {x: 5, y: 0, z: 0, w: 0} m_isUsingLegacyAnimationComponent: 0 m_isVolumetricText: 0 m_hasFontAssetChanged: 0 @@ -1060,7 +1199,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 6644937643226087273, guid: 5c674c30542c7f64084331bbddae68c7, type: 3} propertyPath: m_AnchorMax.y - value: 1 + value: 0 objectReference: {fileID: 0} - target: {fileID: 6644937643226087273, guid: 5c674c30542c7f64084331bbddae68c7, type: 3} propertyPath: m_AnchorMin.x @@ -1068,15 +1207,15 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 6644937643226087273, guid: 5c674c30542c7f64084331bbddae68c7, type: 3} propertyPath: m_AnchorMin.y - value: 1 + value: 0 objectReference: {fileID: 0} - target: {fileID: 6644937643226087273, guid: 5c674c30542c7f64084331bbddae68c7, type: 3} propertyPath: m_SizeDelta.x - value: 180.66 + value: 0 objectReference: {fileID: 0} - target: {fileID: 6644937643226087273, guid: 5c674c30542c7f64084331bbddae68c7, type: 3} propertyPath: m_SizeDelta.y - value: 20 + value: 0 objectReference: {fileID: 0} - target: {fileID: 6644937643226087273, guid: 5c674c30542c7f64084331bbddae68c7, type: 3} propertyPath: m_LocalPosition.x @@ -1108,11 +1247,11 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 6644937643226087273, guid: 5c674c30542c7f64084331bbddae68c7, type: 3} propertyPath: m_AnchoredPosition.x - value: 90.33 + value: 0 objectReference: {fileID: 0} - target: {fileID: 6644937643226087273, guid: 5c674c30542c7f64084331bbddae68c7, type: 3} propertyPath: m_AnchoredPosition.y - value: -10 + value: 0 objectReference: {fileID: 0} - target: {fileID: 6644937643226087273, guid: 5c674c30542c7f64084331bbddae68c7, type: 3} propertyPath: m_LocalEulerAnglesHint.x @@ -1488,7 +1627,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 3691881327015811145, guid: b2517bd3c137096419d4959e713fc03e, type: 3} propertyPath: m_AnchorMax.y - value: 1 + value: 0 objectReference: {fileID: 0} - target: {fileID: 3691881327015811145, guid: b2517bd3c137096419d4959e713fc03e, type: 3} propertyPath: m_AnchorMin.x @@ -1496,15 +1635,15 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 3691881327015811145, guid: b2517bd3c137096419d4959e713fc03e, type: 3} propertyPath: m_AnchorMin.y - value: 1 + value: 0 objectReference: {fileID: 0} - target: {fileID: 3691881327015811145, guid: b2517bd3c137096419d4959e713fc03e, type: 3} propertyPath: m_SizeDelta.x - value: 180.66 + value: 0 objectReference: {fileID: 0} - target: {fileID: 3691881327015811145, guid: b2517bd3c137096419d4959e713fc03e, type: 3} propertyPath: m_SizeDelta.y - value: 20 + value: 0 objectReference: {fileID: 0} - target: {fileID: 3691881327015811145, guid: b2517bd3c137096419d4959e713fc03e, type: 3} propertyPath: m_LocalPosition.x @@ -1536,11 +1675,11 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 3691881327015811145, guid: b2517bd3c137096419d4959e713fc03e, type: 3} propertyPath: m_AnchoredPosition.x - value: 90.33 + value: 0 objectReference: {fileID: 0} - target: {fileID: 3691881327015811145, guid: b2517bd3c137096419d4959e713fc03e, type: 3} propertyPath: m_AnchoredPosition.y - value: -30 + value: 0 objectReference: {fileID: 0} - target: {fileID: 3691881327015811145, guid: b2517bd3c137096419d4959e713fc03e, type: 3} propertyPath: m_LocalEulerAnglesHint.x diff --git a/ksp2-inputbinder/GameInputUtils.cs b/ksp2-inputbinder/GameInputUtils.cs index 1b96c8f..c1b60ff 100644 --- a/ksp2-inputbinder/GameInputUtils.cs +++ b/ksp2-inputbinder/GameInputUtils.cs @@ -12,6 +12,9 @@ namespace Codenade.Inputbinder { internal static class GameInputUtils { + private static readonly FieldInfo _inputControlMinValue = typeof(InputControl).GetField("m_MinValue", BindingFlags.Instance | BindingFlags.NonPublic); + private static readonly FieldInfo _inputControlMaxValue = typeof(InputControl).GetField("m_MaxValue", BindingFlags.Instance | BindingFlags.NonPublic); + // Handling for game_actions_to_add.txt public static List Load(string path) { @@ -127,6 +130,10 @@ public static void OnStateChange(this InputAction action, Action (PrimitiveValue)_inputControlMinValue.GetValue(control); + + public static PrimitiveValue GetMaxValue(this InputControl control) => (PrimitiveValue)_inputControlMaxValue.GetValue(control); + public static Dictionary GetInputSystemLayouts() { var im = typeof(InputSystem).GetField("s_Manager", BindingFlags.NonPublic | BindingFlags.Static).GetValue(null); diff --git a/ksp2-inputbinder/GlobalConfiguration.cs b/ksp2-inputbinder/GlobalConfiguration.cs index 0d2ed52..b60da14 100644 --- a/ksp2-inputbinder/GlobalConfiguration.cs +++ b/ksp2-inputbinder/GlobalConfiguration.cs @@ -12,10 +12,9 @@ internal static class GlobalConfiguration internal static readonly string profilePath = Path.Combine(BepInEx.Paths.ConfigPath, "inputbinder/defaultprofile.txt"); public static List aapBindings = new List(); - [ConfigProperty("main")] - public static float SliderMin { get; set; } = -2; - [ConfigProperty("main")] - public static float SliderMax { get; set; } = 2; + [ConfigProperty("main")] public static float SliderMin { get; set; } = -2; + [ConfigProperty("main")] public static float SliderMax { get; set; } = 2; + [ConfigProperty("main")] public static bool ShowValuesInProcessorsSection { get; set; } = true; public static string DefaultProfile { get; set; } = "input"; public static void Load() @@ -148,7 +147,7 @@ public static void Create() SaveDefaultProfile(); } - protected class ConfigPropertyAttribute : Attribute + private class ConfigPropertyAttribute : Attribute { public string Section { get; set; } diff --git a/ksp2-inputbinder/ui/Page1ListPopulator.cs b/ksp2-inputbinder/ui/Page1ListPopulator.cs index f4c0718..9234fdb 100644 --- a/ksp2-inputbinder/ui/Page1ListPopulator.cs +++ b/ksp2-inputbinder/ui/Page1ListPopulator.cs @@ -1,71 +1,134 @@ -using System.Reflection; +using System.Collections.Generic; +using System.IO; +using System.Reflection; using TMPro; using UnityEngine; +using UnityEngine.AddressableAssets; +using UnityEngine.AddressableAssets.ResourceLocators; using UnityEngine.InputSystem; +using UnityEngine.ResourceManagement.AsyncOperations; +using UnityEngine.UI; namespace Codenade.Inputbinder { internal class Page1ListPopulator : MonoBehaviour { - private TextMeshProUGUI _textValue; + private static Sprite sprtRing; + private static Sprite sprtRingTop; + private static Sprite sprtRingBottom; + private static Sprite sprtRingBoth; + private static List waitingForBoth = new List(); + private static List waitingForBottom = new List(); + + private TextMeshProUGUI _value; private TextMeshProUGUI[] _intermediates; private string[] _processors; private InputAction _action; + private MethodInfo _currentStatePointerInfo; private void Awake() { - _textValue = transform.parent.Find("TextValue").GetComponent(); + _currentStatePointerInfo = typeof(InputControl).GetProperty("currentStatePtr", BindingFlags.Instance | BindingFlags.NonPublic).GetMethod; + _value = transform.parent.Find("ValueGroup/Value").gameObject.GetComponent(); + var catOp = Addressables.LoadContentCatalogAsync(Path.Join(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), Path.Join("addressables", "catalog.json"))); + catOp.Completed += CatalogLoaded; + + void CatalogLoaded(AsyncOperationHandle hOpc) + { + if (hOpc.Status == AsyncOperationStatus.Succeeded) + { + var resLoc = hOpc.Result; + Addressables.LoadAssetAsync("Codenade.Inputbinder/Icons/ring.png").Completed += (x) => AssetLoaded(x, ref sprtRing); + Addressables.LoadAssetAsync("Codenade.Inputbinder/Icons/ring-top.png").Completed += (x) => AssetLoaded(x, ref sprtRingTop); + Addressables.LoadAssetAsync("Codenade.Inputbinder/Icons/ring-bottom.png").Completed += (x) => AssetLoaded(x, ref sprtRingBottom); + Addressables.LoadAssetAsync("Codenade.Inputbinder/Icons/ring-both.png").Completed += (x) => AssetLoaded(x, ref sprtRingBoth); + } + else + QLog.Error("Page1ListPopulator could not load Catalog!"); + } + + void AssetLoaded(AsyncOperationHandle hOp, ref Sprite sprt) + { + if (hOp.Status == AsyncOperationStatus.Succeeded) + sprt = hOp.Result; + else + QLog.Error("Page1ListPopulator could not load Asset!"); + if (sprtRing is object && sprtRingTop is object && sprtRingBottom is object && sprtRingBoth is object) + { + _value.transform.parent.Find("Icon").GetComponent().sprite = sprtRingTop; + foreach (var img in waitingForBottom) + img.sprite = sprtRingBottom; + foreach (var img in waitingForBoth) + img.sprite = sprtRingBoth; + } + } } + private unsafe void ValueUpdate(InputAction.CallbackContext ctx) { - object originalValue; - var propInfo = typeof(InputControl).GetProperty("currentStatePtr", BindingFlags.Instance | BindingFlags.NonPublic); - var propVal = propInfo.GetMethod.Invoke(ctx.control, null); - void* ptr = System.Reflection.Pointer.Unbox(propVal); - originalValue = ctx.control.ReadValueFromStateAsObject(ptr); - _textValue.text = originalValue.ToString() ?? string.Empty; + object originalValue = ctx.control.ReadValueFromStateAsObject(System.Reflection.Pointer.Unbox(_currentStatePointerInfo.Invoke(ctx.control, null))); if (originalValue is object) { + _value.text = originalValue.ToString(); int idx = 0; foreach (var i in _intermediates) { if (idx == _intermediates.Length - 1) - originalValue = _action.ReadValueAsObject(); + originalValue = $"{ctx.control.GetMinValue()} {_action.ReadValueAsObject()} {ctx.control.GetMaxValue()}"; else originalValue = ProcessorUtilities.Process(_processors[idx], originalValue, ctx.control); i.text = originalValue?.ToString() ?? string.Empty; idx++; } } + else + { + _value.text = string.Empty; + foreach (var lbl in _intermediates) + lbl.text = string.Empty; + } } private void OnEnable() { Reload(); - _action.started += ValueUpdate; - _action.performed += ValueUpdate; - _action.canceled += ValueUpdate; + if (GlobalConfiguration.ShowValuesInProcessorsSection) + { + _action.started += ValueUpdate; + _action.performed += ValueUpdate; + _action.canceled += ValueUpdate; + } } private void OnDisable() { - _action.started -= ValueUpdate; - _action.performed -= ValueUpdate; - _action.canceled -= ValueUpdate; + if (GlobalConfiguration.ShowValuesInProcessorsSection) + { + _action.started -= ValueUpdate; + _action.performed -= ValueUpdate; + _action.canceled -= ValueUpdate; + } } public void Reload() { for (var j = gameObject.transform.childCount - 1; j >= 0; j--) DestroyImmediate(gameObject.transform.GetChild(j).gameObject); + _action = Inputbinder.Instance.ActionManager.ProcBindInfo.Action; _processors = (Inputbinder.Instance.ActionManager.ProcBindInfo.Binding.overrideProcessors ?? string.Empty).Split(';'); - _intermediates = new TextMeshProUGUI[_processors.Length]; + if (_processors.Length == 1 && _processors[0] == string.Empty) + _processors = new string[0]; + if (GlobalConfiguration.ShowValuesInProcessorsSection) + _intermediates = new TextMeshProUGUI[_processors.Length]; + else + _intermediates = new TextMeshProUGUI[0]; + int idx = 0; foreach (var p in _processors) { - if (p.IsNullOrEmpty() || p.IndexOf('(') < 0 || p.IndexOf(')') < 0) + if (p == string.Empty) continue; var temp = Instantiate(Inputbinder.Instance.BindingUI.Assets[BindingUI.PrefabKeys.ProcessorGroup], gameObject.transform); var strt = p.IndexOf('('); @@ -75,12 +138,59 @@ public void Reload() infoGroup.GetChild("ProcessorName").GetComponent().text = name; infoGroup.GetChild("ProcessorValues").GetComponent().text = values; temp.GetChild("ProcessorEditButton").AddComponent().Initialize(name); - temp.GetChild("ProcessorRemoveButton").AddComponent().Initialize(name); - var intermediateValueGameObject = Instantiate(_textValue.gameObject, gameObject.transform); - intermediateValueGameObject.name = p + " Intermediate"; - _intermediates[idx] = intermediateValueGameObject.GetComponent(); + var procRemove = temp.GetChild("ProcessorRemoveButton").AddComponent(); + procRemove.Initialize(name); + procRemove.OnRemove += ProcRemove_OnRemove; + if (GlobalConfiguration.ShowValuesInProcessorsSection) + { + var intermediateValueGameObject = Instantiate(_value.transform.parent.gameObject, gameObject.transform); + intermediateValueGameObject.name = p + "_Intermediate"; + _intermediates[idx] = intermediateValueGameObject.transform.Find("Value").GetComponent(); + if (idx == _processors.Length - 1) + { + var img = _intermediates[idx].transform.parent.Find("Icon").GetComponent(); + if (sprtRingBottom == null) + waitingForBottom.Add(img); + else + img.sprite = sprtRingBottom; + } + else + { + var img = _intermediates[idx].transform.parent.Find("Icon").GetComponent(); + if (sprtRingBoth == null) + waitingForBoth.Add(img); + else + img.sprite = sprtRingBoth; + } + } + idx++; + } + _value.text = string.Empty; + foreach (var lbl in _intermediates) + lbl.text = string.Empty; + } + + private void ProcRemove_OnRemove(string toRemove) + { + if (!GlobalConfiguration.ShowValuesInProcessorsSection) + return; + var newProcessors = new List(); + var newIntermediates = new List(); + var idx = 0; + foreach (var proc in _processors) + { + if (proc != toRemove) + { + newProcessors.Add(proc); + newIntermediates.Add(_intermediates[idx]); + } + else + Destroy(_intermediates[idx].transform.parent.gameObject); idx++; } + _processors = newProcessors.ToArray(); + _intermediates = newIntermediates.ToArray(); + _intermediates[^1].transform.parent.Find("Icon").GetComponent().sprite = sprtRingBottom; } } } diff --git a/ksp2-inputbinder/ui/ProcRemoveBehaviour.cs b/ksp2-inputbinder/ui/ProcRemoveBehaviour.cs index 976b31e..4ff8bd4 100644 --- a/ksp2-inputbinder/ui/ProcRemoveBehaviour.cs +++ b/ksp2-inputbinder/ui/ProcRemoveBehaviour.cs @@ -1,4 +1,5 @@ -using UnityEngine; +using System; +using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.UI; @@ -6,6 +7,7 @@ namespace Codenade.Inputbinder { internal class ProcRemoveBehaviour : MonoBehaviour { + internal event Action OnRemove; private string _processorName; private void Awake() @@ -33,8 +35,11 @@ private void OnClick() if (_processorName == "") return; var binding = Inputbinder.Instance.ActionManager.ProcBindInfo.Binding; - if (ProcessorUtilities.ExtractSingleProcessor(binding.overrideProcessors ?? "", _processorName, out var toReplace)) - binding.overrideProcessors = binding.overrideProcessors.Replace(toReplace, "").Trim(';'); + if (ProcessorUtilities.ExtractSingleProcessor(binding.overrideProcessors ?? "", _processorName, out var toRemove)) + { + OnRemove?.Invoke(toRemove); + binding.overrideProcessors = binding.overrideProcessors.Remove(binding.overrideProcessors.IndexOf(toRemove), toRemove.Length).Trim(';').Replace(";;", ";"); + } else return; if (binding.overrideProcessors == "")