diff --git a/Icons/LocaleManager.svg b/Icons/LocaleManager.svg new file mode 100644 index 0000000..20e085b --- /dev/null +++ b/Icons/LocaleManager.svg @@ -0,0 +1,91 @@ + + diff --git a/Icons/LocaleManager.svg.import b/Icons/LocaleManager.svg.import new file mode 100644 index 0000000..fde17d2 --- /dev/null +++ b/Icons/LocaleManager.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bsm7qny5mvlo3" +path="res://.godot/imported/LocaleManager.svg-99f36ef341f5e7ee54b895bbac31c4da.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/rokojori_action_library/Icons/LocaleManager.svg" +dest_files=["res://.godot/imported/LocaleManager.svg-99f36ef341f5e7ee54b895bbac31c4da.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/Icons/LocalizedString.svg b/Icons/LocalizedString.svg new file mode 100644 index 0000000..01688f2 --- /dev/null +++ b/Icons/LocalizedString.svg @@ -0,0 +1,88 @@ + + diff --git a/Icons/LocalizedString.svg.import b/Icons/LocalizedString.svg.import new file mode 100644 index 0000000..c0f1dac --- /dev/null +++ b/Icons/LocalizedString.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://lcmu0013ne2h" +path="res://.godot/imported/LocalizedString.svg-3a59d02d2bc7086c51a04f8a6bdbf103.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/rokojori_action_library/Icons/LocalizedString.svg" +dest_files=["res://.godot/imported/LocalizedString.svg-3a59d02d2bc7086c51a04f8a6bdbf103.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/Icons/UI.svg b/Icons/UI.svg new file mode 100644 index 0000000..bbda55d --- /dev/null +++ b/Icons/UI.svg @@ -0,0 +1,91 @@ + + diff --git a/Icons/UI.svg.import b/Icons/UI.svg.import new file mode 100644 index 0000000..5514a88 --- /dev/null +++ b/Icons/UI.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://ckkgs7jyu6mln" +path="res://.godot/imported/UI.svg-2c1dbd29acf8bed567f460a1a3f0addd.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/rokojori_action_library/Icons/UI.svg" +dest_files=["res://.godot/imported/UI.svg-2c1dbd29acf8bed567f460a1a3f0addd.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/Icons/UIBorderImage.svg b/Icons/UIBorderImage.svg new file mode 100644 index 0000000..d62706c --- /dev/null +++ b/Icons/UIBorderImage.svg @@ -0,0 +1,97 @@ + + diff --git a/Icons/UIBorderImage.svg.import b/Icons/UIBorderImage.svg.import new file mode 100644 index 0000000..ef693d7 --- /dev/null +++ b/Icons/UIBorderImage.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dog4illbbf485" +path="res://.godot/imported/UIBorderImage.svg-f6615c79aa5e9b955ba62ad71b18f6b3.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/rokojori_action_library/Icons/UIBorderImage.svg" +dest_files=["res://.godot/imported/UIBorderImage.svg-f6615c79aa5e9b955ba62ad71b18f6b3.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/Icons/UIImage.svg b/Icons/UIImage.svg new file mode 100644 index 0000000..00e32cb --- /dev/null +++ b/Icons/UIImage.svg @@ -0,0 +1,126 @@ + + diff --git a/Icons/UIImage.svg.import b/Icons/UIImage.svg.import new file mode 100644 index 0000000..4691dcb --- /dev/null +++ b/Icons/UIImage.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://rmumn1ofnjcn" +path="res://.godot/imported/UIImage.svg-6f379e8066b7c9ce860269da60e5f378.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/rokojori_action_library/Icons/UIImage.svg" +dest_files=["res://.godot/imported/UIImage.svg-6f379e8066b7c9ce860269da60e5f378.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/Icons/UIInputIcon.svg b/Icons/UIInputIcon.svg new file mode 100644 index 0000000..d413911 --- /dev/null +++ b/Icons/UIInputIcon.svg @@ -0,0 +1,306 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Icons/UIInputIcon.svg.import b/Icons/UIInputIcon.svg.import new file mode 100644 index 0000000..0f124c6 --- /dev/null +++ b/Icons/UIInputIcon.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://c8t6wo7phh6hv" +path="res://.godot/imported/UIInputIcon.svg-a74c1ff64f04f884d6c9c1865a8a9a48.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/rokojori_action_library/Icons/UIInputIcon.svg" +dest_files=["res://.godot/imported/UIInputIcon.svg-a74c1ff64f04f884d6c9c1865a8a9a48.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/Icons/UIRegion.svg b/Icons/UIRegion.svg new file mode 100644 index 0000000..372425b --- /dev/null +++ b/Icons/UIRegion.svg @@ -0,0 +1,81 @@ + + diff --git a/Icons/UIRegion.svg.import b/Icons/UIRegion.svg.import new file mode 100644 index 0000000..56bf6e3 --- /dev/null +++ b/Icons/UIRegion.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://35m7k7knlg6j" +path="res://.godot/imported/UIRegion.svg-742ebe6956a1a25b816d45d4e44b7631.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/rokojori_action_library/Icons/UIRegion.svg" +dest_files=["res://.godot/imported/UIRegion.svg-742ebe6956a1a25b816d45d4e44b7631.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/Icons/UIText.svg b/Icons/UIText.svg new file mode 100644 index 0000000..67b4d7c --- /dev/null +++ b/Icons/UIText.svg @@ -0,0 +1,87 @@ + + diff --git a/Icons/UIText.svg.import b/Icons/UIText.svg.import new file mode 100644 index 0000000..a342d01 --- /dev/null +++ b/Icons/UIText.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://d3vdg0k44d7gs" +path="res://.godot/imported/UIText.svg-3361615dbe2bc7106602a6f3edf78cb7.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/rokojori_action_library/Icons/UIText.svg" +dest_files=["res://.godot/imported/UIText.svg-3361615dbe2bc7106602a6f3edf78cb7.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/Runtime/Actions/ActionList.cs b/Runtime/Actions/ActionList.cs index 6a6e70a..2d439a6 100644 --- a/Runtime/Actions/ActionList.cs +++ b/Runtime/Actions/ActionList.cs @@ -25,7 +25,7 @@ namespace Rokojori /** Actions to execute*/ [Export] - public Action[] actions; + public Action[] actions = new Action[ 0 ]; /** Whether to execute Action child nodes*/ [Export] diff --git a/Runtime/Actions/ActionSequence.cs b/Runtime/Actions/ActionSequence.cs index 08e8c1b..889e30f 100644 --- a/Runtime/Actions/ActionSequence.cs +++ b/Runtime/Actions/ActionSequence.cs @@ -193,7 +193,7 @@ namespace Rokojori { /** Actions to execute*/ [Export] - public Action[] actions; + public Action[] actions = new Action[ 0 ]; [Export] public bool triggerDirectChildren = true; diff --git a/Runtime/Actions/Node/SetNodeState.cs b/Runtime/Actions/Node/SetNodeState.cs index 00081c1..93e5743 100644 --- a/Runtime/Actions/Node/SetNodeState.cs +++ b/Runtime/Actions/Node/SetNodeState.cs @@ -8,10 +8,10 @@ namespace Rokojori public partial class SetNodeState : Action { [Export] - public Node[] enable; + public Node[] enable = new Node[ 0 ]; [Export] - public Node[] disable; + public Node[] disable = new Node[ 0 ]; protected override void _OnTrigger() diff --git a/Runtime/Actions/OnPhysicsProcess.cs b/Runtime/Actions/OnPhysicsProcess.cs index a0fe273..9340f2e 100644 --- a/Runtime/Actions/OnPhysicsProcess.cs +++ b/Runtime/Actions/OnPhysicsProcess.cs @@ -9,7 +9,7 @@ namespace Rokojori { /** Actions to execute*/ [Export] - public Action[] actions; + public Action[] actions = new Action[ 0 ]; /** Whether to execute Action child nodes*/ [Export] diff --git a/Runtime/Actions/OnProcess.cs b/Runtime/Actions/OnProcess.cs index 89d99a4..f453f21 100644 --- a/Runtime/Actions/OnProcess.cs +++ b/Runtime/Actions/OnProcess.cs @@ -9,7 +9,7 @@ namespace Rokojori { /** Actions to execute*/ [Export] - public Action[] actions; + public Action[] actions = new Action[ 0 ]; /** Whether to execute Action child nodes*/ [Export] diff --git a/Runtime/Actions/OnReady.cs b/Runtime/Actions/OnReady.cs index 562e37b..28fe0c1 100644 --- a/Runtime/Actions/OnReady.cs +++ b/Runtime/Actions/OnReady.cs @@ -9,7 +9,7 @@ namespace Rokojori { /** Actions to execute*/ [Export] - public Action[] actions; + public Action[] actions = new Action[ 0 ]; /** Whether to execute Action child nodes*/ [Export] diff --git a/Runtime/Actions/Time/TimeLooper.cs b/Runtime/Actions/OnTick.cs similarity index 89% rename from Runtime/Actions/Time/TimeLooper.cs rename to Runtime/Actions/OnTick.cs index 555c99b..11da33a 100644 --- a/Runtime/Actions/Time/TimeLooper.cs +++ b/Runtime/Actions/OnTick.cs @@ -5,10 +5,12 @@ using Godot; namespace Rokojori { [Tool] - [GlobalClass] - public partial class TimeLooper : Node + [GlobalClass, Icon("res://addons/rokojori_action_library/Icons/OnEvent.svg") ] + public partial class OnTick : Node { + [Export] + public Action action; bool _active = false; @@ -31,9 +33,6 @@ namespace Rokojori [Export] public TimeLine timeLine; - [Export] - public Action action; - int _eventID = -1; void SetActive( bool active ) diff --git a/Runtime/Actions/Sequence/Parallel.cs b/Runtime/Actions/Sequence/Parallel.cs index cb93a9a..148eb94 100644 --- a/Runtime/Actions/Sequence/Parallel.cs +++ b/Runtime/Actions/Sequence/Parallel.cs @@ -17,7 +17,7 @@ namespace Rokojori public Mode mode = Mode.Wait_For_All_To_Finish; [Export] - public Action[] actions; + public Action[] actions = new Action[ 0 ]; [Export] public bool triggerDirectChildren = true; diff --git a/Runtime/Actions/SequenceAction.cs b/Runtime/Actions/SequenceAction.cs index 828d7fc..9b63f6f 100644 --- a/Runtime/Actions/SequenceAction.cs +++ b/Runtime/Actions/SequenceAction.cs @@ -13,25 +13,7 @@ namespace Rokojori [GlobalClass, Icon("res://addons/rokojori_action_library/Icons/SequenceAction.svg")] public partial class SequenceAction : Action - { - - /* - - int dispatchStart(); - void dispatchCancelled( int id ); - void dispatchEnd( int id ); - - int getLastSequenceActionID(); - GDVIRTUAL1( cancelAction, int ); - - /* signal onSequenceDone * / - - - - */ - - - + { int _dispatchCounter = 0; public int GetLastSequenceActionID() diff --git a/Runtime/Actions/Time/DelayedList.cs b/Runtime/Actions/Time/DelayedList.cs index 0d512b7..c14c2de 100644 --- a/Runtime/Actions/Time/DelayedList.cs +++ b/Runtime/Actions/Time/DelayedList.cs @@ -19,7 +19,7 @@ namespace Rokojori public TimeLine timeLine; [Export] - public Action[] actions; + public Action[] actions = new Action[ 0 ]; /** Whether to execute Action child nodes*/ [Export] diff --git a/Runtime/Animation/Flash/Flash.cs b/Runtime/Animation/Flash/Flash.cs index bc1f659..ca0a1f8 100644 --- a/Runtime/Animation/Flash/Flash.cs +++ b/Runtime/Animation/Flash/Flash.cs @@ -14,7 +14,7 @@ namespace Rokojori public FlashEffect flashEffect; [Export] - public Node3D[] targets; + public Node3D[] targets = new Node3D[ 0 ]; int animationID = -1; int actionID = -1; diff --git a/Runtime/Animation/Highlight/Highlight.cs b/Runtime/Animation/Highlight/Highlight.cs index e5878e8..9a665d7 100644 --- a/Runtime/Animation/Highlight/Highlight.cs +++ b/Runtime/Animation/Highlight/Highlight.cs @@ -18,7 +18,7 @@ namespace Rokojori public HighlightEffect highlighter; [Export] - public Node3D[] targets; + public Node3D[] targets = new Node3D[ 0 ]; protected override void _OnTrigger() { diff --git a/Runtime/Animation/Highlight/HighlightEffect.cs b/Runtime/Animation/Highlight/HighlightEffect.cs index 8eda146..3ae701f 100644 --- a/Runtime/Animation/Highlight/HighlightEffect.cs +++ b/Runtime/Animation/Highlight/HighlightEffect.cs @@ -15,7 +15,7 @@ namespace Rokojori public class HighlightAnimation { - public Node3D[] targets; + public Node3D[] targets = new Node3D[ 0 ]; public int tweenID = -1; public List materials = new List(); diff --git a/Runtime/Animation/Shake/Shake.cs b/Runtime/Animation/Shake/Shake.cs index 3d97edc..1e9bb72 100644 --- a/Runtime/Animation/Shake/Shake.cs +++ b/Runtime/Animation/Shake/Shake.cs @@ -14,7 +14,7 @@ namespace Rokojori public ShakeEffect shakeEffect; [Export] - public Node3D[] targets; + public Node3D[] targets = new Node3D[ 0 ]; List _targetValues; diff --git a/Runtime/Animation/Transform/TransformAnimations.cs b/Runtime/Animation/Transform/TransformAnimations.cs index 23b03bb..a39c464 100644 --- a/Runtime/Animation/Transform/TransformAnimations.cs +++ b/Runtime/Animation/Transform/TransformAnimations.cs @@ -11,7 +11,7 @@ namespace Rokojori public partial class TransformAnimations:Resource { [Export] - public TransformCurve[] curves; + public TransformCurve[] curves = new TransformCurve[ 0 ]; [Export] public TimeLine timeline; diff --git a/Runtime/App/App.cs b/Runtime/App/App.cs new file mode 100644 index 0000000..0ce3c8a --- /dev/null +++ b/Runtime/App/App.cs @@ -0,0 +1,53 @@ + +using Godot; +using System.Collections.Generic; + +namespace Rokojori +{ + public enum AppPlatformOS + { + Windows, + MacOS, + iOS, + Android, + MetaHorizonOS, + Switch, + Switch2, + PS4, + PS5, + XBoxOne, + XBoxSeriesXS + } + + public enum AppLauncher + { + Native, + Steam, + Epic, + Web + } + + [Tool] + [GlobalClass,Icon("res://addons/rokojori_action_library/Icons/SensorManager.svg")] + public partial class App: Node + { + [Export] + public AppPlatformOS os; + + [Export] + public AppLauncher launcher; + + int _fps = 60; + + [Export] + public int fps + { + get => _fps; + set { _fps = value; Engine.MaxFps = _fps; } + } + + + + + } +} \ No newline at end of file diff --git a/Runtime/Audio/AudioGraph/Generators/BandLimitedWaveTable.cs b/Runtime/Audio/AudioGraph/Generators/BandLimitedWaveTable.cs index de5bb95..223392e 100644 --- a/Runtime/Audio/AudioGraph/Generators/BandLimitedWaveTable.cs +++ b/Runtime/Audio/AudioGraph/Generators/BandLimitedWaveTable.cs @@ -7,7 +7,7 @@ namespace Rokojori { public class DuoWaveTable { - float[] _samples; + float[] _samples = new float[ 0 ]; float _lowPitch; float _highPitch; int _maxSamples; diff --git a/Runtime/Audio/AudioGraph/Generators/WaveTable.cs b/Runtime/Audio/AudioGraph/Generators/WaveTable.cs index dc7ecaf..5acfbfe 100644 --- a/Runtime/Audio/AudioGraph/Generators/WaveTable.cs +++ b/Runtime/Audio/AudioGraph/Generators/WaveTable.cs @@ -7,7 +7,7 @@ namespace Rokojori { public class WaveTable:iPhaseGenerator { - float[] _samples; + float[] _samples = new float[ 0 ]; public float[] samples => _samples; diff --git a/Runtime/Audio/AudioGraph/Structure/AudioGraph.cs b/Runtime/Audio/AudioGraph/Structure/AudioGraph.cs index 9b9e3d8..a635955 100644 --- a/Runtime/Audio/AudioGraph/Structure/AudioGraph.cs +++ b/Runtime/Audio/AudioGraph/Structure/AudioGraph.cs @@ -82,7 +82,7 @@ namespace Rokojori _nodes.ForEach( n => n.UpdateBuffserSize() ); } - float[] _zeroBuffer; + float[] _zeroBuffer = new float[ 0 ]; public float[] ClearBuffer( float[] buffer ) { diff --git a/Runtime/Bits/BitView__.cs b/Runtime/Bits/BitView__.cs index ff400b0..e58474e 100644 --- a/Runtime/Bits/BitView__.cs +++ b/Runtime/Bits/BitView__.cs @@ -6,7 +6,7 @@ namespace Rokojori { public partial class BitView { - byte[] _data; + byte[] _data = new byte[ 0 ]; int _internalViewOffset = 0; public int bitOffset => _internalViewOffset; diff --git a/Runtime/Bits/ByteView.cs b/Runtime/Bits/ByteView.cs index 75aa361..b5d4ff1 100644 --- a/Runtime/Bits/ByteView.cs +++ b/Runtime/Bits/ByteView.cs @@ -7,7 +7,7 @@ namespace Rokojori { public class ByteView { - byte[] _data; + byte[] _data = new byte[ 0 ]; int _start; int _size; diff --git a/Runtime/Files/FilePath.cs b/Runtime/Files/FilePath.cs index fe2e722..454df57 100644 --- a/Runtime/Files/FilePath.cs +++ b/Runtime/Files/FilePath.cs @@ -54,7 +54,7 @@ namespace Rokojori } } - public bool hasFileExtension( string extension, bool forceDot = true ) + public bool HasFileExtension( string extension, bool forceDot = true ) { if ( fileExtension == null ) { @@ -118,6 +118,31 @@ namespace Rokojori return rp; } + public string absoluteParentPath + { + get + { + return RegexUtility.ParentPath( fullPath ); + } + } + + public FilePath ChangeFileName( string fileName ) + { + var parentPath = absoluteParentPath; + + if ( ! parentPath.EndsWith( "/" ) ) + { + parentPath += "/"; + } + + return Absolute( parentPath + fileName + fileExtension ); + } + + public FilePath AddToFileName( string fileNameAddition ) + { + return ChangeFileName( fileName + fileNameAddition ); + } + public static FilePath Absolute( string path ) { return FilePath.Create( path, FilePathType.Absolute ); diff --git a/Runtime/Godot/Generated/GodotClassGenerator.cs b/Runtime/Godot/Generated/GodotClassGenerator.cs index b6a205e..1ae4ec6 100644 --- a/Runtime/Godot/Generated/GodotClassGenerator.cs +++ b/Runtime/Godot/Generated/GodotClassGenerator.cs @@ -17,11 +17,7 @@ namespace Rokojori [Export] public string testClass; - public override void _Ready() - { - ExportFiles(); - } - + public override void _Process( double delta ) { if ( exportFlag ) diff --git a/Runtime/Godot/HierarchyName.cs b/Runtime/Godot/HierarchyName.cs index 594af31..f2153c3 100644 --- a/Runtime/Godot/HierarchyName.cs +++ b/Runtime/Godot/HierarchyName.cs @@ -6,6 +6,32 @@ namespace Rokojori { public class HierarchyName { + public static string Of( Resource resource, string seperator = " ▸ " ) + { + var path = resource.ResourcePath; + + path = RegexUtility.Replace( path, "::.*$", "" ); + path = RegexUtility.Replace( path, "^res:\\/\\/", "" ); + + var splitted = RegexUtility.SplitPaths( path ); + + + var sb = new StringBuilder(); + + for ( int i = 0; i < splitted.Count; i++ ) + { + if ( i != 0 ) + { + sb.Append( seperator ); + } + + sb.Append( splitted[ i ] ); + } + + return sb.ToString(); + + } + public static string Of( Node node, string seperator = " ▸ " ) { if ( node == null ) diff --git a/Runtime/Godot/Nodes.cs b/Runtime/Godot/Nodes.cs index 7b918b8..09adb48 100644 --- a/Runtime/Godot/Nodes.cs +++ b/Runtime/Godot/Nodes.cs @@ -81,9 +81,29 @@ namespace Rokojori return default(T); } + public static void ForEachInRoot( this Node node, Action callback ) where T:class + { + if ( node == null ) + { + return; + } + + var tree = node.IsInsideTree() ? node.GetTree() : null; + + if ( tree == null ) + { + return; + } + + + var root = tree.Root; + ForEach( root, callback ); + } + public static void ForEachInScene( Action callback ) where T:class { - var root = Root.Get().GetWindow(); + var root = Root.Window(); + RJLog.Log( "Iterating:", root ); ForEach( root, callback ); } @@ -210,6 +230,17 @@ namespace Rokojori RJLog.Error( node, messages ); } + public static void LogInfo( this Resource resource, params object[] messages ) + { + RJLog.Log( resource, messages ); + } + + public static void LogError( this Resource resource, params object[] messages ) + { + RJLog.Error( resource, messages ); + } + + public static Node DeepCopyTo( this Node node, Node parent ) { return CopyNodeHierarchy( node, parent ); @@ -463,6 +494,16 @@ namespace Rokojori return list; } + public static T FindInParents( Node child ) + { + return (T) (object) NodesWalker.Get().GetInParents( child, c => c is T ); + } + + public static T FindParentThatIs( this Node child ) + { + return FindInParents( child ); + } + public static int TypeIndex( Node parent, T child ) where T:Node { var counter = 0; diff --git a/Runtime/Godot/Root.cs b/Runtime/Godot/Root.cs index b062dd9..09041e1 100644 --- a/Runtime/Godot/Root.cs +++ b/Runtime/Godot/Root.cs @@ -35,9 +35,10 @@ namespace Rokojori return tree.Root; } - public static Root Get() + static Root Get() { var r = Window(); + return _singleton; } } diff --git a/Runtime/Godot/Scenes/Exporters/HTML/SceneFIleHTMLScriptJS.cs b/Runtime/Godot/Scenes/Exporters/HTML/SceneFIleHTMLScriptJS.cs new file mode 100644 index 0000000..d747499 --- /dev/null +++ b/Runtime/Godot/Scenes/Exporters/HTML/SceneFIleHTMLScriptJS.cs @@ -0,0 +1,86 @@ +using Godot; + +using System; +using System.Collections.Generic; + +namespace Rokojori +{ + public class SceneFileHTMLScriptJS + { + public static string script = + @" + function main() + { + let elements = document.querySelectorAll( '.closeable' ); + + for ( let i = 0; i < elements.length; i++ ) + { + let element = elements[ i ]; + + element.addEventListener( 'click', + ( ev )=> + { + + let target = element.getAttribute( 'data-close-target' ); + + let targetElement = element; + + let parentRegex = /^\.\.\s/; + + while ( parentRegex.test( target ) ) + { + target = target.replace( parentRegex, '' ); + targetElement = targetElement.parentElement; + } + + let rootRegex = /^\.\.\.\s/; + + if ( rootRegex.test( target ) ) + { + target = target.replace( rootRegex, '' ); + targetElement = document.documentElement; + } + + let closeTarget = element.parentElement.querySelector( target ); + + console.log( ev, target, closeTarget); + closeTarget.style.display = closeTarget.style.display === 'none' ? 'block' : 'none'; + + element.setAttribute( 'data-close-state', closeTarget.style.display ); + + ev.preventDefault(); + return false; + }, + true + ); + } + + let references = document.querySelectorAll( 'gd-reference' ); + + for ( let i = 0; i < references.length; i++ ) + { + let reference = references[ i ]; + + reference.addEventListener( 'click', + ( ev )=> + { + let ref = reference.getAttribute( 'reference' ); + let selector = `[id=##${ref}##]`; + + console.log( 'querying', selector ); + let referenced = document.querySelector( selector ); + + referenced.scrollIntoView( { 'behavior': 'smooth' }); + } + ); + } + + + } + + window.addEventListener( 'load', () => { main(); }); + + + ".Replace( "##", "\""); + } +} \ No newline at end of file diff --git a/Runtime/Godot/Scenes/Exporters/HTML/SceneFileHTMLExporter.cs b/Runtime/Godot/Scenes/Exporters/HTML/SceneFileHTMLExporter.cs new file mode 100644 index 0000000..7665bdc --- /dev/null +++ b/Runtime/Godot/Scenes/Exporters/HTML/SceneFileHTMLExporter.cs @@ -0,0 +1,243 @@ +using Godot; + +using System; +using System.Collections.Generic; + +namespace Rokojori +{ + public class SceneFileHTMLExporter + { + public static readonly XMLElementNodeName GD_ExternalResource = XMLElementNodeName.Create( "gd-external-resource" ); + public static readonly XMLElementNodeName GD_SubResource = XMLElementNodeName.Create( "gd-sub-resource" ); + + public static readonly XMLElementNodeName GD_Node = XMLElementNodeName.Create( "gd-node" ); + public static readonly XMLElementNodeName GD_Name = XMLElementNodeName.Create( "gd-name" ); + public static readonly XMLElementNodeName GD_Type = XMLElementNodeName.Create( "gd-type" ); + public static readonly XMLElementNodeName GD_Script = XMLElementNodeName.Create( "gd-script" ); + public static readonly XMLElementNodeName GD_Members = XMLElementNodeName.Create( "gd-members" ); + public static readonly XMLElementNodeName GD_Member = XMLElementNodeName.Create( "gd-member" ); + public static readonly XMLElementNodeName GD_Children = XMLElementNodeName.Create( "gd-children" ); + public static readonly XMLElementNodeName GD_Reference = XMLElementNodeName.Create( "gd-reference" ); + + SceneFileParser _parser; + XMLDocument _htmlDoc; + XMLElementNode body; + XMLElementNode head; + + public static void Convert( string inputPath, string outputPath ) + { + var text = FilesSync.LoadUTF8( inputPath ); + + var parser = new SceneFileParser(); + + parser.Parse( text ); + + Export( parser, outputPath ); + } + + public static void Export( SceneFileParser parser, string path ) + { + new SceneFileHTMLExporter().ParseAndExport( parser, path ); + } + + public void ParseAndExport( SceneFileParser parser, string path ) + { + _parser = parser; + CreateHTMLDocument(); + + AddExternalResources(); + AddNodes(); + + var exportPath = path.EndsWith( ".html" ) ? path : ( path + ".html" ); + + FilesSync.SaveUTF8( exportPath, new XMLSerializer().SerializeHtml( _htmlDoc.documentElement ) ); + } + + + void CreateHTMLDocument() + { + var doc = XMLDocument.HTML(); + var html = doc.documentElement; + + body = html.querySelector( HTMLElementName.body ); + head = html.querySelector( HTMLElementName.head ); + + head.AddHTMLScript( SceneFileHTMLScriptJS.script ); + head.AddHTMLStyle( SceneFileHTMLStyle.style ); + + + _htmlDoc = doc; + } + + void AddExternalResources() + { + var extResources = _parser.sceneFile.extResources; + RJLog.Log( "External Resources:", extResources.Count ); + + for ( int i = 0; i < extResources.Count; i++ ) + { + var resource = extResources[ i ]; + var attachmentElement = body; + + var resourceElement = _htmlDoc.Create( GD_ExternalResource ); + + resourceElement.SetAttribute( "class", "resource" ); + + attachmentElement.AppendChild( resourceElement ); + + var nameElement = resourceElement.AddElement( GD_Name, resource.path.value ); + + resourceElement.AddElement( GD_Type, resource.id.value + " " + resource.uid.value + " " + resource.type.value ); + + resourceElement.SetAttribute( "id", resource.id.value ); + attachmentElement.AddElement( HTMLElementName.br ); + } + + var subResources = _parser.sceneFile.subResources; + RJLog.Log( "Sub Resources:", subResources.Count ); + + for ( int i = 0; i < subResources.Count; i++ ) + { + var resource = subResources[ i ]; + var attachmentElement = body; + + var resourceElement = _htmlDoc.Create( GD_SubResource ); + + resourceElement.SetAttribute( "class", "resource" ); + + attachmentElement.AppendChild( resourceElement ); + + + var nameElement = resourceElement.AddElement( GD_Name, resource.id.value + " " + resource.type.value ); + + var scriptOrShaderMember = resource.GetMember( "script" ); + + if ( scriptOrShaderMember == null ) + { + scriptOrShaderMember = resource.GetMember( "shader" ); + } + + if ( scriptOrShaderMember != null ) + { + var scriptEntry = _parser.sceneFile.extResources.Find( e => e.id.value == scriptOrShaderMember.valueData.reference ); + var scriptType = scriptEntry == null ? "Null" : scriptEntry.path.value; + resourceElement.AddElement( GD_Type, scriptType + "@" + scriptOrShaderMember.valueData.reference ); + } + + resourceElement.SetAttribute( "id", resource.id.value ); + attachmentElement.AddElement( HTMLElementName.br ); + } + } + + void AddNodes() + { + var nodes = _parser.sceneFile.nodes; + RJLog.Log( "Nodes:", nodes.Count ); + + var elementMap = new Dictionary(); + + + for ( int i = 0; i < nodes.Count; i++ ) + { + var node = nodes[ i ]; + + //RJLog.Log( i, node.name.value ); + + var attachmentElement = body; + + var elementPath = node.elementPath; + + var parent = node.parent.value; + + if ( parent != null && elementMap.ContainsKey( parent ) ) + { + attachmentElement = elementMap[ parent ].querySelector( GD_Children ); + } + + var nodeElement = _htmlDoc.Create( GD_Node ); + + nodeElement.SetAttribute( "class", "node" ); + + var nameElement = nodeElement.AddElement( GD_Name, node.name.value ); + nameElement.SetAttribute( "class", "closeable" ); + nameElement.SetAttribute( "data-close-target", ".. " + GD_Children.selector ); + + var scriptMember = node.GetMember( "script" ); + + if ( scriptMember != null ) + { + var scriptEntry = _parser.sceneFile.extResources.Find( e => e.id.value == scriptMember.valueData.reference ); + var scriptType = scriptEntry == null ? "Null" : scriptEntry.path.value; + nodeElement.AddElement( GD_Type, scriptType + "@" + scriptMember.valueData.reference + "(" + node.type.value + ")" ); + } + else + { + nodeElement.AddElement( GD_Type, node.type.value ); + } + + + string scriptValue = null ; + + if ( scriptValue != null ) + { + nodeElement.AddElement( GD_Script, scriptValue ); + } + + var membersElement = nodeElement.AddElement( GD_Members, "" ); + + var memberData = node.data; + + memberData.ForEach( + m => + { + if ( m.member != null ) + { + var mem = m.member; + + if ( mem.valuesData != null ) + { + + } + else if ( mem.valueData != null ) + { + + if ( SceneFileValueType.Variant == mem.valueData.type ) + { + membersElement.AddElement( GD_Member, mem.name + ": " + mem.valueData ); + } + else + { + var member = membersElement.AddElement( GD_Member, mem.name ); + var reference = member.AddElement( GD_Reference, mem.valueData.reference ); + reference.SetAttribute( "reference", mem.valueData.reference ); + } + + } + + } + else + { + // membersElement.AddElement( GD_Member, "Type: " + m.type + " {" + m.line + "}"); + } + + } + ); + + nodeElement.AddElement( GD_Children ); + + + + elementMap[ elementPath ] = nodeElement; + + // RJLog.Log( "'" + elementPath + "'", node.name.value ); + + attachmentElement.AppendChild( nodeElement ); + + + } + } + + + + } +} \ No newline at end of file diff --git a/Runtime/Godot/Scenes/Exporters/HTML/SceneFileHTMLStyle.cs b/Runtime/Godot/Scenes/Exporters/HTML/SceneFileHTMLStyle.cs new file mode 100644 index 0000000..151dbf5 --- /dev/null +++ b/Runtime/Godot/Scenes/Exporters/HTML/SceneFileHTMLStyle.cs @@ -0,0 +1,86 @@ +using Godot; + +using System; +using System.Collections.Generic; + +namespace Rokojori +{ + public class SceneFileHTMLStyle + { + public static string style = + @" + + body + { + overflow-x: hidden; + margin: 2em 0em; + font-family: Helvetica, Arial, sans; + background: hsl(0,0%,10%); + color: hsl(0,0%,80%) + } + + .closeable + { + cursor: pointer; + opacity:1; + transition: opacity 300ms ease; + } + + .closeable[data-close-state='none'] + { + opacity: 0.7; + } + + .node + { + display: block; + position: relative; + left: 2em; + } + + .resource + { + display: block; + position: relative; + left: 2em; + } + + + + gd-name + { + border-radius: 0.5em; + padding: 1em 1em; + background-color: hsl(0,0%,20%); + margin: 0.5em 1em; + display: inline-block; + font-weight: bold; + } + + gd-external-resource gd-name + { + background-color: hsl(0,50%,20%); + } + + gd-sub-resource gd-name + { + background-color: hsl(120,50%,20%); + } + + + gd-type + { + display: inline-block; + opacity: 0.5; + } + + gd-reference + { + cursor:pointer; + text-decoration:underline; + + } + + " ; + } +} \ No newline at end of file diff --git a/Runtime/Godot/Scenes/Objects/ExtResourceSFO.cs b/Runtime/Godot/Scenes/Objects/ExtResourceSFO.cs index 50eb16d..6e98b4e 100644 --- a/Runtime/Godot/Scenes/Objects/ExtResourceSFO.cs +++ b/Runtime/Godot/Scenes/Objects/ExtResourceSFO.cs @@ -10,6 +10,6 @@ namespace Rokojori public readonly SFHStringAttribute path = new SFHStringAttribute( "path" ); public readonly SFHStringAttribute uid = new SFHStringAttribute( "uid" ); public readonly SFHStringAttribute type = new SFHStringAttribute( "type" ); - + public readonly SFHStringAttribute id = new SFHStringAttribute( "id" ); } } \ No newline at end of file diff --git a/Runtime/Godot/Scenes/Objects/SceneFileObject.cs b/Runtime/Godot/Scenes/Objects/SceneFileObject.cs index 476d345..0850730 100644 --- a/Runtime/Godot/Scenes/Objects/SceneFileObject.cs +++ b/Runtime/Godot/Scenes/Objects/SceneFileObject.cs @@ -7,17 +7,37 @@ namespace Rokojori { protected SceneFileEntry _headerEntry; protected List _attributes = new List(); + protected List _data = new List(); + + public List data => _data; public SceneFileObject() { SetAttributes(); } + public SceneFileNamedValue GetMember( string name ) + { + var entry = _data.Find( d => d.member != null && d.member.name == name ); + return entry == null ? null : entry.member; + } + + + public void AddData( SceneFileEntry se ) + { + if ( SceneFileLinesLexer.SeperatorMatcher.Matches( se.type ) ) + { + return; + } + + _data.Add( se ); + } + public void CreateFromHeaderEntry( SceneFileEntry headerEntry ) { ReadAttributes( headerEntry.header ); - _CreateFromHeaderEntry( headerEntry); + _CreateFromHeaderEntry( headerEntry ); } protected virtual void _CreateFromHeaderEntry( SceneFileEntry headerEntry ) diff --git a/Runtime/Godot/Scenes/Objects/SubResourceSFO.cs b/Runtime/Godot/Scenes/Objects/SubResourceSFO.cs index 07f837c..9df12fb 100644 --- a/Runtime/Godot/Scenes/Objects/SubResourceSFO.cs +++ b/Runtime/Godot/Scenes/Objects/SubResourceSFO.cs @@ -7,7 +7,7 @@ namespace Rokojori { public static readonly string headerType = "sub_resource"; - public readonly SFHStringAttribute id = new SFHStringAttribute( "uid" ); + public readonly SFHStringAttribute id = new SFHStringAttribute( "id" ); public readonly SFHStringAttribute type = new SFHStringAttribute( "type" ); } } \ No newline at end of file diff --git a/Runtime/Godot/Scenes/Parsers/SceneFileLinesLexer.cs b/Runtime/Godot/Scenes/Parsers/SceneFileLinesLexer.cs index e1daba9..0ebf480 100644 --- a/Runtime/Godot/Scenes/Parsers/SceneFileLinesLexer.cs +++ b/Runtime/Godot/Scenes/Parsers/SceneFileLinesLexer.cs @@ -4,11 +4,11 @@ using System.Text.RegularExpressions; namespace Rokojori { - public class GodotTextSceneLexer:Lexer + public class SceneFileLinesLexer:Lexer { public static List Lex( string source ) { - var lexer = new GodotTextSceneLexer(); + var lexer = new SceneFileLinesLexer(); var events = lexer.LexToList( source ); if ( lexer.hasError ) @@ -50,15 +50,15 @@ namespace Rokojori "SubMemberEnd", "\\}\\]" ); - public GodotTextSceneLexer() + public SceneFileLinesLexer() { AddAllMatchers( - GodotTextSceneLexer.HeaderMatcher, - GodotTextSceneLexer.SeperatorMatcher, - GodotTextSceneLexer.SubMemberStartMatcher, - GodotTextSceneLexer.SubMemberEndMatcher, - GodotTextSceneLexer.SubMemberMatcher, - GodotTextSceneLexer.MemberMatcher, + SceneFileLinesLexer.HeaderMatcher, + SceneFileLinesLexer.SeperatorMatcher, + SceneFileLinesLexer.SubMemberStartMatcher, + SceneFileLinesLexer.SubMemberEndMatcher, + SceneFileLinesLexer.SubMemberMatcher, + SceneFileLinesLexer.MemberMatcher, LexerMatcherLibrary.AnySymbolMatcher ); } diff --git a/Runtime/Godot/Scenes/Parsers/SceneFileMemberParser.cs b/Runtime/Godot/Scenes/Parsers/SceneFileMemberParser.cs new file mode 100644 index 0000000..a99e60e --- /dev/null +++ b/Runtime/Godot/Scenes/Parsers/SceneFileMemberParser.cs @@ -0,0 +1,127 @@ +using Godot; +using System.Collections.Generic; + +namespace Rokojori +{ + public class SceneFileMemberParser + { + public bool hasError = true; + public string errorMessage; + string line; + + public void Parse( SceneFileEntry entry ) + { + line = entry.line; + + var lexer = new SceneFileLexer(); + var tokens = lexer.LexToList( line ); + + if ( lexer.hasError || tokens.Count == 0) + { + errorMessage = "Lexing failed"; + return; + } + + tokens.RemoveAll( t => t.isDone ); + + + + lexer.GrabMatches( tokens, line ); + + if ( ! tokens[ 0 ].Is( LexerMatcherLibrary.CwordMatcher ) ) + { + hasError = true; + errorMessage = RJLog.Stringify( "Expected name as first token, got:", tokens[ 0 ].type, ">>",tokens[ 0 ].match ); + + return; + } + + var assignmentOpResult = LexerEvent.Find( tokens, 1, + t => + { + if ( t.Is( LexerMatcherLibrary.OperatorMatcher, "=" ) ) + { + return LexerEvent.FindResultType.Found; + } + + if ( t.Is( LexerMatcherLibrary.WhiteSpaceMatcher ) ) + { + return LexerEvent.FindResultType.KeepSearching; + } + + return LexerEvent.FindResultType.Error; + + } + ); + + if ( LexerEvent.FindResultType.Found != assignmentOpResult.type ) + { + hasError = true; + errorMessage = RJLog.Stringify( "Expected assignment operator:", tokens ) ; + return; + } + + var namedValue = new SceneFileNamedValue(); + entry.member = namedValue; + + + namedValue.name = tokens[ 0 ].match; + + var valueIndexResult = LexerEvent.Find( tokens, assignmentOpResult.index + 1, + ( t )=> + { + if ( t.Is( LexerMatcherLibrary.WhiteSpaceMatcher ) ) + { + return LexerEvent.FindResultType.KeepSearching; + } + + return LexerEvent.FindResultType.Found; + } + ); + + if ( LexerEvent.FindResultType.Found != valueIndexResult.type ) + { + hasError = true; + errorMessage = RJLog.Stringify( "Expected value after assignment at ", assignmentOpResult.index, "in", tokens ) ; + return; + } + + namedValue.value = LexerEvent.GetMatchFromRange( tokens, valueIndexResult.index ); + + var isList = tokens[ valueIndexResult.index ].Is( LexerMatcherLibrary.BracketMatcher, "[" ); + + if ( ! isList ) + { + namedValue.valueData = new SceneFileValue(); + namedValue.valueData.ParseValue( tokens, valueIndexResult.index, tokens.Count - valueIndexResult.index ); + return; + } + + if ( isList ){ return; } + + var separators = LexerEvent.GetSeparatorsInBrackets( tokens, valueIndexResult.index ); + + var lastIndex = valueIndexResult.index + 1; + + namedValue.valuesData = new List(); + + for ( int i = 0; i < separators.Count; i++ ) + { + var v = new SceneFileValue(); + v.ParseValue( tokens, lastIndex, separators[ i ] - lastIndex ); + namedValue.valuesData.Add( v ); + + lastIndex = separators[ i ] + 1; + } + + var lastV = new SceneFileValue(); + lastV.ParseValue( tokens, lastIndex, ( tokens.Count - 1 ) - lastIndex ); + + + + + + } + } + +} \ No newline at end of file diff --git a/Runtime/Godot/Scenes/Parsers/SceneFileParser.cs b/Runtime/Godot/Scenes/Parsers/SceneFileParser.cs index 1b5dc4a..da0b6b9 100644 --- a/Runtime/Godot/Scenes/Parsers/SceneFileParser.cs +++ b/Runtime/Godot/Scenes/Parsers/SceneFileParser.cs @@ -13,7 +13,7 @@ namespace Rokojori this.source = source; var lines = RegexUtility.SplitLines( source ); - var lexer = new GodotTextSceneLexer(); + var lexer = new SceneFileLinesLexer(); var lineIndex = 1; diff --git a/Runtime/Godot/Scenes/SceneFile.cs b/Runtime/Godot/Scenes/SceneFile.cs index 98f321c..a1dbf51 100644 --- a/Runtime/Godot/Scenes/SceneFile.cs +++ b/Runtime/Godot/Scenes/SceneFile.cs @@ -17,18 +17,30 @@ namespace Rokojori public static SceneFileEntry Seperator() { - return Create( GodotTextSceneLexer.SeperatorMatcher.type, "" ); + return Create( SceneFileLinesLexer.SeperatorMatcher.type, "" ); } + // Parsed lines public List entries = new List(); + + // Combined objects of parsed lines public List objects = new List(); + public GDSceneSFO gdScene; public NodeSFO rootNode; + + // Nodes of the scene public List nodes = new List(); - public Dictionary nodeMap = new Dictionary(); + + // NodePath -> Node + public Dictionary nodePathMap = new Dictionary(); + + // External Resources public List extResources = new List(); - public List subResourceSFOs = new List(); + + // Built-In Resources + public List subResources = new List(); public SceneFile GetSerializableJSONVersion() { @@ -40,11 +52,14 @@ namespace Rokojori public void CreateObjects() { + SceneFileObject lastSFO = null; + entries.ForEach( ( e )=> { if ( ! e.hasHeader ) { + lastSFO.AddData( e ); return; } @@ -55,6 +70,8 @@ namespace Rokojori return; } + lastSFO = sfo; + if ( sfo is GDSceneSFO ) { gdScene = (GDSceneSFO) sfo; @@ -69,7 +86,7 @@ namespace Rokojori rootNode = node; } - nodeMap[ node.elementPath ] = node; + nodePathMap[ node.elementPath ] = node; // RJLog.Log( "'" + node.elementPath + "'", node.name.value ); @@ -80,7 +97,7 @@ namespace Rokojori } else if ( sfo is SubResourceSFO ) { - subResourceSFOs.Add( (SubResourceSFO) sfo ); + subResources.Add( (SubResourceSFO) sfo ); } objects.Add( sfo ); @@ -90,7 +107,7 @@ namespace Rokojori nodes.ForEach( ( n )=> { - n.ResolveParent( nodeMap, rootNode ); + n.ResolveParent( nodePathMap, rootNode ); } ); } diff --git a/Runtime/Godot/Scenes/SceneFileEntry.cs b/Runtime/Godot/Scenes/SceneFileEntry.cs index efa307f..673f887 100644 --- a/Runtime/Godot/Scenes/SceneFileEntry.cs +++ b/Runtime/Godot/Scenes/SceneFileEntry.cs @@ -22,7 +22,7 @@ namespace Rokojori public void Parse() { - if ( type == GodotTextSceneLexer.HeaderMatcher.type ) + if ( type == SceneFileLinesLexer.HeaderMatcher.type ) { var headerParser = new SceneFileHeaderParser(); headerParser.Parse( this ); @@ -32,6 +32,16 @@ namespace Rokojori hasError = true; } } + else if ( type == SceneFileLinesLexer.MemberMatcher.type ) + { + var memberParser = new SceneFileMemberParser(); + memberParser.Parse( this ); + + if ( memberParser.hasError ) + { + hasError = true; + } + } } } diff --git a/Runtime/Godot/Scenes/SceneFileNamedValue.cs b/Runtime/Godot/Scenes/SceneFileNamedValue.cs index 5212bc5..4f64f39 100644 --- a/Runtime/Godot/Scenes/SceneFileNamedValue.cs +++ b/Runtime/Godot/Scenes/SceneFileNamedValue.cs @@ -2,12 +2,17 @@ using Godot; using System.Collections.Generic; namespace Rokojori -{ +{ + public class SceneFileNamedValue { public string name; public string value; + public SceneFileValue valueData; + public List valuesData; + + public static SceneFileNamedValue Create( string name, string value ) { var nv = new SceneFileNamedValue(); diff --git a/Runtime/Godot/Scenes/SceneFileReader.cs b/Runtime/Godot/Scenes/SceneFileReader.cs index c008c25..6e37257 100644 --- a/Runtime/Godot/Scenes/SceneFileReader.cs +++ b/Runtime/Godot/Scenes/SceneFileReader.cs @@ -13,7 +13,11 @@ namespace Rokojori public string path = ""; [Export] - public bool load = false; + public bool load + { + get => false; + set { if ( value ) LoadScene(); } + } [Export] public bool exportJSON = false; @@ -21,20 +25,8 @@ namespace Rokojori [Export] public bool exportHTML = false; - - public override void _Process( double delta ) - { - LoadScene(); - } - void LoadScene() { - if ( ! load ) - { - return; - } - - load = false; var text = FilesSync.LoadUTF8( path ); @@ -49,171 +41,11 @@ namespace Rokojori if ( exportHTML ) { - var nodes = parser.sceneFile.nodes; - RJLog.Log( "Nodes:", nodes.Count ); - - var doc = new XMLDocument(); - var html = doc.documentElement; - var body = html.querySelector( HTMLElementName.body ); - var head = html.querySelector( HTMLElementName.head ); - - head.AddHTMLScript( - @" - - function main() - { - let elements = document.querySelectorAll( '.closeable' ); - - for ( let i = 0; i < elements.length; i++ ) - { - let element = elements[ i ]; - - element.addEventListener( 'click', - ( ev )=> - { - - let target = element.getAttribute( 'data-close-target' ); - - let targetElement = element; - - let parentRegex = /^\.\.\s/; - - while ( parentRegex.test( target ) ) - { - target = target.replace( parentRegex, '' ); - targetElement = targetElement.parentElement; - } - - let rootRegex = /^\.\.\.\s/; - - if ( rootRegex.test( target ) ) - { - target = target.replace( rootRegex, '' ); - targetElement = document.documentElement; - } - - let closeTarget = element.parentElement.querySelector( target ); - - console.log( ev, target, closeTarget); - closeTarget.style.display = closeTarget.style.display === 'none' ? 'block' : 'none'; - - element.setAttribute( 'data-close-state', closeTarget.style.display ); - - ev.preventDefault(); - return false; - }, - true - ); - } - } - - window.addEventListener( 'load', () => { main(); }); - - " - ); - - head.AddHTMLStyle( - @" - body - { - overflow-x: hidden; - margin: 2em 0em; - font-family: Helvetica, Arial, sans; - background: hsl(0,0%,10%); - color: hsl(0,0%,80%) - } - - .closeable - { - cursor: pointer; - opacity:1; - transition: opacity 300ms ease; - } - - .closeable[data-close-state='none'] - { - opacity: 0.7; - } - - .node - { - display: block; - position: relative; - left: 2em; - } - - gd-name - { - border-radius: 0.5em; - padding: 1em 1em; - background-color: hsl(0,0%,20%); - margin: 0.5em 1em; - display: inline-block; - font-weight: bold; - - } - - gd-type - { - display: inline-block; - opacity: 0.5; - } - - " ); - - - - var elementMap = new Dictionary(); - - var GD_Node = XMLElementNodeName.Create( "gd-node" ); - var GD_Name = XMLElementNodeName.Create( "gd-name" ); - var GD_Type = XMLElementNodeName.Create( "gd-type" ); - var GD_Children = XMLElementNodeName.Create( "gd-children" ); - - for ( int i = 0; i < nodes.Count; i++ ) - { - var node = nodes[ i ]; - - //RJLog.Log( i, node.name.value ); - - var attachmentElement = body; - - var elementPath = node.elementPath; - - var parent = node.parent.value; - - if ( parent != null && elementMap.ContainsKey( parent ) ) - { - attachmentElement = elementMap[ parent ].querySelector( GD_Children ); - } - - var nodeElement = doc.Create( GD_Node ); - - nodeElement.SetAttribute( "class", "node" ); - - var nameElement = nodeElement.AddElement( GD_Name, node.name.value ); - nameElement.SetAttribute( "class", "closeable" ); - nameElement.SetAttribute( "data-close-target", ".. " + GD_Children.selector ); - - nodeElement.AddElement( GD_Type, node.type.value ); - - nodeElement.AddElement( GD_Children ); - - - - elementMap[ elementPath ] = nodeElement; - - // RJLog.Log( "'" + elementPath + "'", node.name.value ); - - attachmentElement.AppendChild( nodeElement ); - - - } - - - FilesSync.SaveUTF8( path + ".html", new XMLSerializer().SerializeHtml( doc.documentElement ) ); + var exporter = new SceneFileHTMLExporter(); + exporter.ParseAndExport( parser, path ); } } + } } \ No newline at end of file diff --git a/Runtime/Godot/Scenes/SceneFileValue.cs b/Runtime/Godot/Scenes/SceneFileValue.cs new file mode 100644 index 0000000..c2f45a8 --- /dev/null +++ b/Runtime/Godot/Scenes/SceneFileValue.cs @@ -0,0 +1,91 @@ +using Godot; +using System.Collections.Generic; + +namespace Rokojori +{ + public enum SceneFileValueType + { + Variant, + ExtResource, + SubResource, + NodePath + } + + public class SceneFileValue + { + public SceneFileValueType type; + public Variant variant; + public string reference; + + public static readonly List referenceTypes = new List + { + SceneFileValueType.ExtResource, + SceneFileValueType.SubResource, + SceneFileValueType.NodePath + }; + + public static readonly List referenceStringTypes = Lists.Map( + referenceTypes, ( s, i ) => s + "" + ); + + + public void ParseValue( List tokens, int start, int length ) + { + + var startToken = tokens[ start ]; + var startTokenInfo = LexerEvent.GetMatchFromRange( tokens, start, length ); + + // RJLog.Log( "ParseValue", startToken.type, startToken.IsAny( LexerMatcherLibrary.CwordMatcher ), startTokenInfo ); + + if ( startToken.IsAny( LexerMatcherLibrary.CFunctionMatcher ) ) + { + var referenceStringIndex = referenceStringTypes.IndexOf( startToken.match ); + + if ( referenceStringIndex != -1 ) + { + type = referenceTypes[ referenceStringIndex ]; + reference = JSONStringConverter.Read( tokens[ start + 2 ].match ); + + // RJLog.Log( "Reference type:", type, reference ); + + return; + } + + // RJLog.Log( "Not a reference type:", startToken ); + } + + type = SceneFileValueType.Variant; + + variant = VariantFromTokens( tokens, start, length ); + + //RJLog.Log( "Variant type:", variant ); + } + + public static Variant VariantFromTokens( List tokens, int start, int length ) + { + var startToken = tokens[ start ]; + + if ( length == 1 ) + { + if ( startToken.Is( LexerMatcherLibrary.NumberMatcher ) ) + { + return Variant.From( RegexUtility.ParseDouble( startToken.match ) ); + } + + if ( startToken.Is( LexerMatcherLibrary.DoubleQuotedStringMatcher ) ) + { + return Variant.From( JSONStringConverter.Read( startToken.match ) ); + } + + if ( startToken.IsAny( LexerMatcherLibrary.CwordMatcher, "true", "false" ) ) + { + return Variant.From( startToken.match == "true" ) ; + } + } + + return Variant.From( "" ); + } + + + } +} \ No newline at end of file diff --git a/Runtime/Godot/Unique.cs b/Runtime/Godot/Unique.cs index 0e04f61..8d70542 100644 --- a/Runtime/Godot/Unique.cs +++ b/Runtime/Godot/Unique.cs @@ -14,20 +14,32 @@ namespace Rokojori if ( _singleton != null ) { return _singleton; - } + } - var rootWindow = n == null ? Root.Window() : n.Owner; - - // RJLog.Log( "ROOT", rootWindow ); + var rootWindow = n == null ? Root.Window() : n.Owner; if ( rootWindow == null ) { - return null; + if ( Engine.IsEditorHint() ) + { + rootWindow = EditorInterface.Singleton.GetEditedSceneRoot(); + } + else + { + return null; + } } _singleton = Nodes.GetAnyChild( rootWindow ); - // RJLog.Log( "_singleton", _singleton ); + if ( _singleton == null ) + { + if ( Engine.IsEditorHint() ) + { + rootWindow = EditorInterface.Singleton.GetEditedSceneRoot(); + _singleton = Nodes.GetAnyChild( rootWindow ); + } + } return _singleton; } diff --git a/Runtime/Interactions/Pointable.cs b/Runtime/Interactions/Pointable.cs index 67db10f..3f0d59c 100644 --- a/Runtime/Interactions/Pointable.cs +++ b/Runtime/Interactions/Pointable.cs @@ -29,12 +29,12 @@ namespace Rokojori public HighlightEffect highlightEffect; [Export] - public Node3D[] highlightTargets; + public Node3D[] highlightTargets = new Node3D[ 0 ]; [ExportGroup("Read Only")] [Export] - public Pointer[] pointers; + public Pointer[] pointers = new Pointer[ 0 ]; List _pointers = new List(); diff --git a/Runtime/LOD/LODArrangement.cs b/Runtime/LOD/LODArrangement.cs index 5ba2b7d..32a913a 100644 --- a/Runtime/LOD/LODArrangement.cs +++ b/Runtime/LOD/LODArrangement.cs @@ -10,7 +10,7 @@ namespace Rokojori public partial class LODArrangement:Resource { [Export] - public LODLevel[] levels; + public LODLevel[] levels = new LODLevel[ 0 ]; public LODLevel GetLevel( LODNode node ) { diff --git a/Runtime/LOD/LODLevel.cs b/Runtime/LOD/LODLevel.cs index e319ed8..5169da3 100644 --- a/Runtime/LOD/LODLevel.cs +++ b/Runtime/LOD/LODLevel.cs @@ -10,7 +10,7 @@ namespace Rokojori public partial class LODLevel:Resource { [Export] - public LODLevelVisibilityRule[] visibilityRules; + public LODLevelVisibilityRule[] visibilityRules = new LODLevelVisibilityRule[ 0 ]; [Export] public Mesh mesh; diff --git a/Runtime/LOD/LODParent.cs b/Runtime/LOD/LODParent.cs index 43ef97b..c7c823e 100644 --- a/Runtime/LOD/LODParent.cs +++ b/Runtime/LOD/LODParent.cs @@ -22,7 +22,7 @@ namespace Rokojori [Export] public bool arrayCulling = true; [Export] - public float[] arrayTresholds; + public float[] arrayTresholds = new float[ 0 ]; [ExportGroup("Curve Mode")] [Export] @@ -36,7 +36,7 @@ namespace Rokojori [ExportGroup("LODs")] [Export] - public Node3D[] lods; + public Node3D[] lods = new Node3D[ 0 ]; [Export] public float updateDistance = 10; diff --git a/Runtime/Localization/LocaleCode.cs b/Runtime/Localization/LocaleCode.cs index 3164efc..af56f00 100644 --- a/Runtime/Localization/LocaleCode.cs +++ b/Runtime/Localization/LocaleCode.cs @@ -7,31 +7,80 @@ namespace Rokojori { public enum LocaleCode { - EN, - JA, - DE, - ES, - FR, - PT, - IT, - KO, - ZH, - RU, - PL, - TU, - AR, - NL, - SV, - HI, - TH, - ID, - VI, - EL, - CS, - FI, - UK, - RO, - HU - + af, // Afrikaans (South Africa, Namibia) + am, // Amharic (Ethiopia) + ar, // Arabic (Saudi Arabia, Egypt, UAE, Iraq, Morocco, Algeria, Jordan, and many more) + az, // Azerbaijani (Azerbaijan) + be, // Belarusian (Belarus) + bg, // Bulgarian (Bulgaria) + bn, // Bengali (Bangladesh, India) + bs, // Bosnian (Bosnia and Herzegovina) + ca, // Catalan (Spain - Catalonia, Andorra) + cs, // Czech (Czech Republic) + cy, // Welsh (Wales - UK) + da, // Danish (Denmark, Greenland) + de, // German (Germany, Austria, Switzerland, Liechtenstein, Belgium) + el, // Greek (Greece, Cyprus) + en, // English (UK, US, Australia, Canada, India, South Africa, and many more) + es, // Spanish (Spain, Mexico, Argentina, Colombia, and many more) + et, // Estonian (Estonia) + eu, // Basque (Spain - Basque Country, France - Basque areas) + fa, // Persian (Iran, Afghanistan, Tajikistan) + fi, // Finnish (Finland) + fil, // Filipino (Philippines) + fr, // French (France, Canada, Belgium, Switzerland, many African countries) + ga, // Irish (Ireland) + gl, // Galician (Spain - Galicia) + gu, // Gujarati (India, some in Pakistan) + he, // Hebrew (Israel) + hi, // Hindi (India, Fiji) + hr, // Croatian (Croatia, Bosnia and Herzegovina) + hu, // Hungarian (Hungary, some parts of Romania and Slovakia) + hy, // Armenian (Armenia) + id, // Indonesian (Indonesia) + @is, // Icelandic (Iceland) + it, // Italian (Italy, Switzerland, San Marino, Vatican City) + ja, // Japanese (Japan) + ka, // Georgian (Georgia) + kk, // Kazakh (Kazakhstan) + km, // Khmer (Cambodia) + kn, // Kannada (India - Karnataka) + ko, // Korean (South Korea, North Korea) + ky, // Kyrgyz (Kyrgyzstan) + lo, // Lao (Laos) + lt, // Lithuanian (Lithuania) + lv, // Latvian (Latvia) + mk, // Macedonian (North Macedonia) + ml, // Malayalam (India - Kerala) + mn, // Mongolian (Mongolia) + mr, // Marathi (India - Maharashtra) + ms, // Malay (Malaysia, Brunei, Singapore, Indonesia) + mt, // Maltese (Malta) + my, // Burmese (Myanmar) + ne, // Nepali (Nepal, India - Sikkim and West Bengal) + nl, // Dutch (Netherlands, Belgium, Suriname, Caribbean Netherlands) + no, // Norwegian (Norway) + pa, // Punjabi (India, Pakistan) + pl, // Polish (Poland) + ps, // Pashto (Afghanistan, Pakistan) + pt, // Portuguese (Portugal, Brazil, Mozambique, Angola, and others) + ro, // Romanian (Romania, Moldova) + ru, // Russian (Russia, Belarus, Kazakhstan, Kyrgyzstan, and others) + si, // Sinhala (Sri Lanka) + sk, // Slovak (Slovakia) + sl, // Slovenian (Slovenia) + sq, // Albanian (Albania, Kosovo, North Macedonia) + sr, // Serbian (Serbia, Bosnia and Herzegovina, Montenegro) + sv, // Swedish (Sweden, Finland - Åland) + sw, // Swahili (Tanzania, Kenya, Uganda, DRC, and others) + ta, // Tamil (India - Tamil Nadu, Sri Lanka, Singapore, Malaysia) + te, // Telugu (India - Andhra Pradesh, Telangana) + th, // Thai (Thailand) + tr, // Turkish (Turkey, Cyprus) + uk, // Ukrainian (Ukraine) + ur, // Urdu (Pakistan, India) + uz, // Uzbek (Uzbekistan) + vi, // Vietnamese (Vietnam) + zh, // Chinese (China, Taiwan, Singapore, Malaysia) } -} \ No newline at end of file +} diff --git a/Runtime/Localization/LocaleLabel3D.cs b/Runtime/Localization/LocaleLabel3D.cs new file mode 100644 index 0000000..2ccb71f --- /dev/null +++ b/Runtime/Localization/LocaleLabel3D.cs @@ -0,0 +1,42 @@ +using Godot; +using System.Collections; +using System.Collections.Generic; +using Godot.Collections; + +namespace Rokojori +{ + [Tool] + [GlobalClass] + public partial class LocaleLabel3D:Label3D, iLocalizable + { + LocalizedString _locale; + + [Export] + public LocalizedString locale + { + get + { + return _locale; + } + + set + { + _locale = value; + UpdateLocalization(); + } + } + + [Export] + public bool refreshText + { + get => false; + set { if ( value ) UpdateLocalization(); } + } + + public void UpdateLocalization() + { + Text = locale.currentValue; + } + + } +} \ No newline at end of file diff --git a/Runtime/Localization/LocaleManager.cs b/Runtime/Localization/LocaleManager.cs index 0ed69df..b582755 100644 --- a/Runtime/Localization/LocaleManager.cs +++ b/Runtime/Localization/LocaleManager.cs @@ -6,10 +6,54 @@ using Godot.Collections; namespace Rokojori { [Tool] - [GlobalClass] + [GlobalClass,Icon("res://addons/rokojori_action_library/Icons/LocaleManager.svg")] public partial class LocaleManager:Node { + LocaleCode _languageLocale = LocaleCode.en; + static LocaleCode _editorLanguageLocale = LocaleCode.en; + [Export] - public LocaleCode languageLocale; + public LocaleCode languageLocale + { + get => _languageLocale; + set { _languageLocale = value; _editorLanguageLocale = value; UpdateLocalization(); } + } + + public override void _Ready() + { + RJLog.Log( "_Ready >>", _languageLocale ); + UpdateLocalization(); + } + + public void UpdateLocalization() + { + RJLog.Log( "Updating Language >>>", _languageLocale ); + this.ForEachInRoot( i => { i.UpdateLocalization(); } ); + } + + public static LocaleCode currentLanguage + { + get + { + if ( Engine.IsEditorHint() ) + { + return _editorLanguageLocale; + } + + + + var lm = Unique.Get(); + var lc = LocaleCode.en; + + if ( lm != null ) + { + lc = lm.languageLocale; + } + + RJLog.Log( "currentLanguage", lc ); + + return lc; + } + } } } \ No newline at end of file diff --git a/Runtime/Localization/LocaleText.cs b/Runtime/Localization/LocaleText.cs index 34ee63b..6d29318 100644 --- a/Runtime/Localization/LocaleText.cs +++ b/Runtime/Localization/LocaleText.cs @@ -6,7 +6,7 @@ using Godot.Collections; namespace Rokojori { [Tool] - [GlobalClass] + [GlobalClass,Icon("res://addons/rokojori_action_library/Icons/LocalizedString.svg")] public partial class LocaleText:LocalizedString { [Export(PropertyHint.MultilineText)] @@ -14,20 +14,28 @@ namespace Rokojori [ExportGroup("Translations")] [Export] - public LocaleTextEntry[] entries; + public LocaleTextEntry[] entries = new LocaleTextEntry[ 0 ]; [ExportGroup("Context")] [Export(PropertyHint.MultilineText)] public string context; + public static LocaleText Create( string en ) + { + var lt = new LocaleText(); + lt.en = en; + + return lt; + } public override string GetLocalizedString( LocaleCode localeCode ) { - if ( localeCode == LocaleCode.EN ) + if ( localeCode == LocaleCode.en || entries == null ) { return en; } + var entry = Arrays.Find( entries, e => e.code == localeCode ); if ( entry != null ) diff --git a/Runtime/Localization/LocaleTextEntry.cs b/Runtime/Localization/LocaleTextEntry.cs index 4603e66..4a012c1 100644 --- a/Runtime/Localization/LocaleTextEntry.cs +++ b/Runtime/Localization/LocaleTextEntry.cs @@ -6,8 +6,8 @@ using Godot.Collections; namespace Rokojori { [Tool] - [GlobalClass] - public partial class LocaleTextEntry:LocalizedString + [GlobalClass,Icon("res://addons/rokojori_action_library/Icons/LocalizedString.svg")] + public partial class LocaleTextEntry:Resource { [Export] public LocaleCode code; diff --git a/Runtime/Localization/LocalizedString.cs b/Runtime/Localization/LocalizedString.cs index 07e9264..fd6f08e 100644 --- a/Runtime/Localization/LocalizedString.cs +++ b/Runtime/Localization/LocalizedString.cs @@ -6,7 +6,7 @@ using Godot.Collections; namespace Rokojori { [Tool] - [GlobalClass] + [GlobalClass,Icon("res://addons/rokojori_action_library/Icons/LocalizedString.svg")] public partial class LocalizedString:Resource { public virtual string GetLocalizedString( LocaleCode localeCode ) @@ -14,5 +14,20 @@ namespace Rokojori return ""; } + public string currentValue + { + get + { + return GetLocalizedString( LocaleManager.currentLanguage ); + } + } + + public static string Get( LocalizedString ls, string alternative = "") + { + return ls == null ? alternative : ls.currentValue; + } + + + } } \ No newline at end of file diff --git a/Runtime/Localization/iLocalizable.cs b/Runtime/Localization/iLocalizable.cs new file mode 100644 index 0000000..d729ffe --- /dev/null +++ b/Runtime/Localization/iLocalizable.cs @@ -0,0 +1,12 @@ +using Godot; +using System.Collections; +using System.Collections.Generic; +using Godot.Collections; + +namespace Rokojori +{ + public interface iLocalizable + { + public void UpdateLocalization(); + } +} \ No newline at end of file diff --git a/Runtime/Logging/RJLog.cs b/Runtime/Logging/RJLog.cs index 44cdefc..31ca7da 100644 --- a/Runtime/Logging/RJLog.cs +++ b/Runtime/Logging/RJLog.cs @@ -10,6 +10,33 @@ namespace Rokojori public class RJLog { + public static string GetInfo( object obj, params object[] values ) + { + + if ( obj == null ) + { + return ""; + } + + var sb = new StringBuilder(); + sb.Append( obj.GetType().Name ); + sb.Append( "{ " ); + + for ( int i = 0; i < values.Length; i++ ) + { + if ( i != 0 ) + { + sb.Append( ", " ); + } + + Stringify( values[ i ], sb ); + } + + sb.Append( " }" ); + + return sb.ToString(); + } + public static string Stringify( object obj ) { var sb = new StringBuilder(); @@ -38,6 +65,33 @@ namespace Rokojori if ( obj is double ) { output.Append( RegexUtility.NumberToString( (double)obj ) ); + return; + } + + if ( obj.GetType().IsArray ) + { + var array = (Array)obj; + + output.Append( "[" ); + + var first = true; + + foreach ( var it in array ) + { + if ( first ) + { + first = false; + } + else + { + output.Append( ", " ); + } + + Stringify( it, output ); + } + + output.Append( "]" ); + return; } @@ -45,7 +99,7 @@ namespace Rokojori { var list = (IList)obj; - output.Append( "[" ); + output.Append( "[" ); var first = true; @@ -64,7 +118,7 @@ namespace Rokojori Stringify( it, output ); } - output.Append( "]" ); + output.Append( "]" ); return; } @@ -72,17 +126,22 @@ namespace Rokojori output.Append( obj.ToString() ); } + public static string Stringify( params object[] objects ) + { + return GetLogString( objects ); + } + static void LogMessage( string message, int frameIndex = 3 ) { var trace = GetTrace( frameIndex ); - GD.PrintRich("\n[b]" + message + "[/b]" ); + GD.PrintRich("\n[b]" + message ); GD.PrintRich( trace ); } static void LogMessageWithFullTrace( string message ) { var trace = GetFullTrace(); - GD.PrintRich("\n[b]" + message + "[/b]" ); + GD.PrintRich("\n[b]" + message ); GD.PrintRich( trace ); } @@ -131,7 +190,7 @@ namespace Rokojori var trace = className + "." + frame.GetMethod().Name + "() ln."+ frame.GetFileLineNumber(); - return "[color=gray] " + trace + "[/color]" ; + return "[color=#888888] " + trace + "[/color]" ; } public static void LogWithFullTrace( params object[] objects) @@ -146,7 +205,12 @@ namespace Rokojori public static void Log( Node node, params object[] objects) { - LogMessage( "[color=#55aaff][ " + HierarchyName.Of( node ) + " ][/color] " + GetLogString( objects ), 4 ); + LogMessage( "[color=#55aaff]" + HierarchyName.Of( node ) + "[/color]\n" + GetLogString( objects ), 4 ); + } + + public static void Log( Resource resource, params object[] objects) + { + LogMessage( "[color=#55ffaa]" + HierarchyName.Of( resource ) + "[/color]\n" + GetLogString( objects ), 4 ); } public static void Error( params object[] objects) @@ -156,11 +220,17 @@ namespace Rokojori public static void Error( Node node, params object[] objects) { - LogErrorMessage( "[ " + HierarchyName.Of( node ) + " ] " + GetLogString( objects ), 4 ); + LogErrorMessage( "" + HierarchyName.Of( node ) + "\n" + GetLogString( objects ), 4 ); } + public static void Error( Resource resource, params object[] objects) + { + LogErrorMessage( "" + HierarchyName.Of( resource ) + "\n" + GetLogString( objects ), 4 ); + } - public static string GetLogString( object[] objects) + + + public static string GetLogString( object[] objects ) { var sb = new StringBuilder(); diff --git a/Runtime/Math/FFT.cs b/Runtime/Math/FFT.cs index 910daba..fac3c8d 100644 --- a/Runtime/Math/FFT.cs +++ b/Runtime/Math/FFT.cs @@ -6,7 +6,7 @@ namespace Rokojori { class FloatSineTable { - public float[] sineValues; + public float[] sineValues = new float[ 0 ]; public FloatSineTable( int numBits ) { @@ -22,7 +22,7 @@ namespace Rokojori class BitReverseTable { - public int[] reversedBits; + public int[] reversedBits = new int[ 0 ]; public BitReverseTable( int numBits ) { diff --git a/Runtime/Networking/Data/NetClass.cs b/Runtime/Networking/Data/NetClass.cs index 4acc8e8..55f23d3 100644 --- a/Runtime/Networking/Data/NetClass.cs +++ b/Runtime/Networking/Data/NetClass.cs @@ -6,7 +6,7 @@ namespace Rokojori { public abstract class NetClassDefinition { - protected NetMember[] _members; + protected NetMember[] _members = new NetMember[ 0 ]; public void SetMembers( params NetMember[] members ) { diff --git a/Runtime/Networking/Nodes/AddNetworkingNodes.cs b/Runtime/Networking/Nodes/AddNetworkingNodes.cs index 988eb17..0daf5dc 100644 --- a/Runtime/Networking/Nodes/AddNetworkingNodes.cs +++ b/Runtime/Networking/Nodes/AddNetworkingNodes.cs @@ -8,7 +8,7 @@ namespace Rokojori public partial class AddNetworkNodes:Action { [Export] - public Node[] nodes; + public Node[] nodes = new Node[ 0 ]; protected override void _OnTrigger() { diff --git a/Runtime/Procedural/Assets/Grass/GrassPatch.cs b/Runtime/Procedural/Assets/Grass/GrassPatch.cs index 2c05b62..77c71a3 100644 --- a/Runtime/Procedural/Assets/Grass/GrassPatch.cs +++ b/Runtime/Procedural/Assets/Grass/GrassPatch.cs @@ -187,7 +187,7 @@ namespace Rokojori [ExportGroup("LOD Levels")] [Export] - public GrassPatchLODLevel[] lodLevels; + public GrassPatchLODLevel[] lodLevels = new GrassPatchLODLevel[ 0 ]; [Export] public int currentLODLevel = -1; diff --git a/Runtime/Procedural/Baking/TextureMerger.cs b/Runtime/Procedural/Baking/TextureMerger.cs index b0fa127..6519dcc 100644 --- a/Runtime/Procedural/Baking/TextureMerger.cs +++ b/Runtime/Procedural/Baking/TextureMerger.cs @@ -39,11 +39,11 @@ namespace Rokojori public Node sourceViewportsContainer = null; [Export] - public SubViewport[] sourceViewports; + public SubViewport[] sourceViewports = new SubViewport[ 0 ]; [ExportGroup("Source/Textures")] [Export] - public Texture2D[] sourceTextures; + public Texture2D[] sourceTextures = new Texture2D[ 0 ]; [ExportGroup("Output")] [Export] @@ -60,10 +60,10 @@ namespace Rokojori [ExportGroup("Output/Custom")] [Export] - public Vector2[] customPositions; + public Vector2[] customPositions = new Vector2[ 0 ]; [Export] - public Vector2[] customSizes; + public Vector2[] customSizes = new Vector2[ 0 ]; [ExportGroup("Viewport")] [Export] diff --git a/Runtime/Procedural/Baking/Textures.cs b/Runtime/Procedural/Baking/Textures.cs index 6884ca7..596b350 100644 --- a/Runtime/Procedural/Baking/Textures.cs +++ b/Runtime/Procedural/Baking/Textures.cs @@ -32,9 +32,9 @@ namespace Rokojori var output = ".png"; if ( - fp.hasFileExtension( ".jpg" ) || - fp.hasFileExtension( ".exr" ) || - fp.hasFileExtension( ".webp" ) + fp.HasFileExtension( ".jpg" ) || + fp.HasFileExtension( ".exr" ) || + fp.HasFileExtension( ".webp" ) ) { output = fp.fileExtension; diff --git a/Runtime/Procedural/HeightMap/HeightMapData.cs b/Runtime/Procedural/HeightMap/HeightMapData.cs index 96be375..e0b0fcb 100644 --- a/Runtime/Procedural/HeightMap/HeightMapData.cs +++ b/Runtime/Procedural/HeightMap/HeightMapData.cs @@ -9,7 +9,7 @@ namespace Rokojori { int width; int height; - float[] data; + float[] data = new float[ 0 ]; public static HeightMapData Create( int w, int h, float[] data = null) { diff --git a/Runtime/Procedural/Mesh/MassRenderer.cs b/Runtime/Procedural/Mesh/MassRenderer.cs index 89fce11..a9fce4b 100644 --- a/Runtime/Procedural/Mesh/MassRenderer.cs +++ b/Runtime/Procedural/Mesh/MassRenderer.cs @@ -33,13 +33,13 @@ namespace Rokojori [ExportGroup("Layout")] [Export] - public Vector3[] positions; + public Vector3[] positions = new Vector3[ 0 ]; [Export] - public Vector4[] rotations; + public Vector4[] rotations = new Vector4[ 0 ]; [Export] - public Vector3[] scales; + public Vector3[] scales = new Vector3[ 0 ]; [ExportGroup("Outputs")] [Export] diff --git a/Runtime/Procedural/Mesh/MeshCombiner.cs b/Runtime/Procedural/Mesh/MeshCombiner.cs index fe8737a..509719f 100644 --- a/Runtime/Procedural/Mesh/MeshCombiner.cs +++ b/Runtime/Procedural/Mesh/MeshCombiner.cs @@ -12,7 +12,7 @@ namespace Rokojori public partial class MeshCombiner:Node3D { [Export] - public Node3D[] sourceNodes; + public Node3D[] sourceNodes = new Node3D[ 0 ]; [ExportGroup( "Mesh")] [Export] @@ -51,7 +51,7 @@ namespace Rokojori [Export] public MeshInstance3D outputMesh; [Export] - public Material[] outputMaterials; + public Material[] outputMaterials = new Material[ 0 ]; [Export] public bool combine = false; diff --git a/Runtime/Procedural/Mesh/Modifiers/SplinesDeformer/SplinesDeformerModifier.cs b/Runtime/Procedural/Mesh/Modifiers/SplinesDeformer/SplinesDeformerModifier.cs index 0327973..f3e3c99 100644 --- a/Runtime/Procedural/Mesh/Modifiers/SplinesDeformer/SplinesDeformerModifier.cs +++ b/Runtime/Procedural/Mesh/Modifiers/SplinesDeformer/SplinesDeformerModifier.cs @@ -17,8 +17,8 @@ namespace Rokojori public class SplinesDeformModifier { - public SplineCurve[] sourceSplines; - public SplineCurve[] targetSplines; + public SplineCurve[] sourceSplines = new SplineCurve[ 0 ]; + public SplineCurve[] targetSplines = new SplineCurve[ 0 ]; public SplinesDeformerSettings settings; diff --git a/Runtime/Procedural/MeshCreationTest.cs b/Runtime/Procedural/MeshCreationTest.cs index 61e5849..8549f2b 100644 --- a/Runtime/Procedural/MeshCreationTest.cs +++ b/Runtime/Procedural/MeshCreationTest.cs @@ -54,7 +54,7 @@ namespace Rokojori public bool createNavMesh = false; [Export] - public Node3D[] countries; + public Node3D[] countries = new Node3D[ 0 ]; [Export] public float navMeshRadius = 100; diff --git a/Runtime/Procedural/Parametric/Deformer/Deformer.cs b/Runtime/Procedural/Parametric/Deformer/Deformer.cs index 84496ce..5b1fb63 100644 --- a/Runtime/Procedural/Parametric/Deformer/Deformer.cs +++ b/Runtime/Procedural/Parametric/Deformer/Deformer.cs @@ -36,7 +36,7 @@ namespace Rokojori [ExportGroup( "Input")] [Export] - public Spline[] sourceSplines; + public Spline[] sourceSplines = new Spline[ 0 ]; [Export] public MeshInstance3D sourceMesh; @@ -46,7 +46,7 @@ namespace Rokojori [ExportGroup( "Output")] [Export] - public Spline[] deformerSplines; + public Spline[] deformerSplines = new Spline[ 0 ]; [Export] public MeshInstance3D outputMesh; @@ -72,7 +72,7 @@ namespace Rokojori - DeformerMappingData[] deformerMappings; + DeformerMappingData[] deformerMappings = new DeformerMappingData[ 0 ]; MeshGeometry meshGeometry; DeformerMappingData CreateSourceMapping( Spline s, Vector3 worldPosition, Vector3 worldNormal ) diff --git a/Runtime/Procedural/Parametric/Tube/Tube.cs b/Runtime/Procedural/Parametric/Tube/Tube.cs index 80e9736..38d3b0d 100644 --- a/Runtime/Procedural/Parametric/Tube/Tube.cs +++ b/Runtime/Procedural/Parametric/Tube/Tube.cs @@ -68,7 +68,7 @@ namespace Rokojori public bool scaleRadiusByPathTransforms = true; [Export] - public TubeShape[] shapes; + public TubeShape[] shapes = new TubeShape[ 0 ]; [Export] public bool update; diff --git a/Runtime/Procedural/Scatter/Scatterer.cs b/Runtime/Procedural/Scatter/Scatterer.cs index a7c1f45..8a9e60a 100644 --- a/Runtime/Procedural/Scatter/Scatterer.cs +++ b/Runtime/Procedural/Scatter/Scatterer.cs @@ -21,7 +21,7 @@ namespace Rokojori [Export] public bool removeDiscarded = false; [Export] - public Node3D[] streamSources; + public Node3D[] streamSources = new Node3D[ 0 ]; [Export] public float streamCullDistance = 100; @@ -34,7 +34,7 @@ namespace Rokojori [ExportGroup("Clean Up")] [Export] - public Node3D[] containersToClearNodes; + public Node3D[] containersToClearNodes = new Node3D[ 0 ]; [Export] public bool clearContainers = false; [Export] diff --git a/Runtime/Sensors/CombineSensor.cs b/Runtime/Sensors/CombineSensor.cs index 614d3fe..0dc3904 100644 --- a/Runtime/Sensors/CombineSensor.cs +++ b/Runtime/Sensors/CombineSensor.cs @@ -1,6 +1,6 @@ using Godot; - +using System.Collections.Generic; namespace Rokojori { @@ -9,8 +9,14 @@ namespace Rokojori public partial class CombineSensor : Sensor { [Export] - public Sensor[] sensors; - + public Sensor[] sensors = new Sensor[ 0 ]; + + [ExportGroup("UI")] + [Export] + public bool showOnlyVisibleIcons = false; + + [Export] + public int numVisible = 0; protected override void UpdateValue() { @@ -23,5 +29,33 @@ namespace Rokojori SetFloatValue( value ); } + + public override string ToString() + { + return RJLog.GetInfo( this, sensors ); + } + + [Export] + public InputIcon[] inputIcons = new InputIcon[ 0 ]; + + [Export] + public bool useInputIconsFromSensors = true; + + public override List GetInputIcons() + { + var list = Lists.From( inputIcons ); + + if ( useInputIconsFromSensors ) + { + var visible = showOnlyVisibleIcons ? numVisible : sensors.Length; + + for ( int i = 0; i < visible; i++ ) + { + list.AddRange( sensors[ i ].GetInputIcons() ); + } + } + + return list; + } } } \ No newline at end of file diff --git a/Runtime/Sensors/Default-Sensors/Default-Input-Icons-Library.tres b/Runtime/Sensors/Default-Sensors/Default-Input-Icons-Library.tres new file mode 100644 index 0000000..117a529 --- /dev/null +++ b/Runtime/Sensors/Default-Sensors/Default-Input-Icons-Library.tres @@ -0,0 +1,358 @@ +[gd_resource type="Resource" script_class="InputIconsLibrary" load_steps=74 format=3 uid="uid://dq52vhnqr5m6"] + +[ext_resource type="Script" path="res://addons/rokojori_action_library/Runtime/Sensors/InputIcons/Definitions/DefaultInputIconDefinition.cs" id="1_64knt"] +[ext_resource type="Script" path="res://addons/rokojori_action_library/Runtime/Sensors/InputIcons/InputIconsLibrary.cs" id="1_urlfx"] +[ext_resource type="Script" path="res://addons/rokojori_action_library/Runtime/Sensors/InputIcons/Types/MouseInputIcon.cs" id="1_vsgl5"] +[ext_resource type="SystemFont" uid="uid://bakiyyiix68n1" path="res://Research/Fonts/Jost-Font.tres" id="1_xrnc5"] +[ext_resource type="Script" path="res://addons/rokojori_action_library/Runtime/UI/Styling/UINumber.cs" id="2_4sutq"] +[ext_resource type="Script" path="res://addons/rokojori_action_library/Runtime/Sensors/InputIcons/Definitions/CombinedInputIconsTexture.cs" id="2_g15ft"] +[ext_resource type="Texture2D" uid="uid://eqplg4ydtkpf" path="res://addons/rokojori_action_library/Runtime/Sensors/InputIcons/Graphics/Mouse-Left Button.svg" id="2_q818g"] +[ext_resource type="Texture2D" uid="uid://chcls1g13v7it" path="res://addons/rokojori_action_library/Runtime/Sensors/InputIcons/Graphics/Mouse-Wheel Up & Down.svg" id="3_pm2rw"] +[ext_resource type="Texture2D" uid="uid://dcb0bhq84rs77" path="res://addons/rokojori_action_library/Runtime/Sensors/InputIcons/Graphics/Mouse-Middle Button.svg" id="3_u1h0x"] +[ext_resource type="Texture2D" uid="uid://d3q5n6ocgar6w" path="res://addons/rokojori_action_library/Runtime/Sensors/InputIcons/Graphics/Mouse-Right Button.svg" id="4_5b8av"] +[ext_resource type="Script" path="res://addons/rokojori_action_library/Runtime/Sensors/InputIcons/Definitions/CombinedIconsDefinition.cs" id="4_6ycsi"] +[ext_resource type="Script" path="res://addons/rokojori_action_library/Runtime/Sensors/InputIcons/Types/GamePadButtonIcon.cs" id="4_y5jfh"] +[ext_resource type="Script" path="res://addons/rokojori_action_library/Runtime/Sensors/InputIcons/Definitions/MouseInputIconDefinition.cs" id="5_a3fep"] +[ext_resource type="Texture2D" uid="uid://eki8sp0x0gmf" path="res://addons/rokojori_action_library/Runtime/Sensors/InputIcons/Graphics/GamePad-DPad-Background.svg" id="5_amgur"] +[ext_resource type="Script" path="res://addons/rokojori_action_library/Runtime/Sensors/InputIcons/Definitions/DirectionalInputIconDefinition.cs" id="5_sn8hr"] +[ext_resource type="Texture2D" uid="uid://ct3k2tds4d26" path="res://addons/rokojori_action_library/Runtime/Sensors/InputIcons/Graphics/GamePad-DPad-Left + Right.svg" id="5_ycc70"] +[ext_resource type="Texture2D" uid="uid://clg28ph2pawvq" path="res://addons/rokojori_action_library/Runtime/Sensors/InputIcons/Graphics/GamePad-DPad-Up.svg" id="6_0hfff"] +[ext_resource type="Texture2D" uid="uid://bip5s0jfo5ddm" path="res://addons/rokojori_action_library/Runtime/Sensors/InputIcons/Graphics/GamePad-DPad-Up + Down.svg" id="6_6nxcf"] +[ext_resource type="Texture2D" uid="uid://b48h8j7flhwyb" path="res://addons/rokojori_action_library/Runtime/Sensors/InputIcons/Graphics/Mouse-Wheel Down.svg" id="6_qyc6e"] +[ext_resource type="Texture2D" uid="uid://de5ewtb72pmdu" path="res://addons/rokojori_action_library/Runtime/Sensors/InputIcons/Graphics/Mouse-Wheel Up.svg" id="7_n1ega"] +[ext_resource type="Script" path="res://addons/rokojori_action_library/Runtime/Sensors/InputIcons/Types/GamePadAxisIcon.cs" id="7_y0txw"] +[ext_resource type="Texture2D" uid="uid://6fkkrsbdjdf" path="res://addons/rokojori_action_library/Runtime/Sensors/InputIcons/Graphics/GamePad-Axis-Left + Right.svg" id="9_eeamd"] +[ext_resource type="Texture2D" uid="uid://bih02uuga3j2u" path="res://addons/rokojori_action_library/Runtime/Sensors/InputIcons/Graphics/GamePad-Axis-Up + Down.svg" id="10_3i85w"] +[ext_resource type="Texture2D" uid="uid://bmtwa1p6j1tu8" path="res://addons/rokojori_action_library/Runtime/Sensors/InputIcons/Graphics/Keyboard-EnterKey.svg" id="10_q44jo"] +[ext_resource type="Texture2D" uid="uid://b73u16wm1h5gr" path="res://addons/rokojori_action_library/Runtime/Sensors/InputIcons/Graphics/Keyboard.svg" id="12_mf3bj"] +[ext_resource type="Texture2D" uid="uid://dg52t67wh6h54" path="res://addons/rokojori_action_library/Runtime/Sensors/InputIcons/Graphics/Keyboard-Indicator.svg" id="13_ijjqw"] +[ext_resource type="Texture2D" uid="uid://dxwnbh3a3fy8w" path="res://addons/rokojori_action_library/Runtime/Sensors/InputIcons/Graphics/GamePad-Left-Shoulder-Button.svg" id="13_omll7"] +[ext_resource type="Texture2D" uid="uid://1pfyxi7wifn8" path="res://addons/rokojori_action_library/Runtime/Sensors/InputIcons/Graphics/Keyboard-SpaceKey.svg" id="14_6vom6"] +[ext_resource type="Texture2D" uid="uid://bgi8cbw57gka0" path="res://addons/rokojori_action_library/Runtime/Sensors/InputIcons/Graphics/GamePad-MainButton.svg" id="14_n68qo"] +[ext_resource type="Texture2D" uid="uid://cb8ldiej8234h" path="res://addons/rokojori_action_library/Runtime/Sensors/InputIcons/Graphics/GamePad-Axis-Background.svg" id="18_amimm"] +[ext_resource type="Texture2D" uid="uid://ddfvjmi7sva6f" path="res://addons/rokojori_action_library/Runtime/Sensors/InputIcons/Graphics/GamePad-Axis-Pressed.svg" id="19_7x4g0"] +[ext_resource type="Script" path="res://addons/rokojori_action_library/Runtime/Localization/LocaleText.cs" id="20_55eoq"] +[ext_resource type="Texture2D" uid="uid://bajhvs0qnuj5q" path="res://addons/rokojori_action_library/Runtime/Sensors/InputIcons/Graphics/GamePad-Axis-Up.svg" id="20_r1y6a"] +[ext_resource type="Texture2D" uid="uid://b2123dcu46oy0" path="res://addons/rokojori_action_library/Runtime/Sensors/InputIcons/Graphics/GamePad-Right-Shoulder-Button.svg" id="21_hcyk3"] + +[sub_resource type="Resource" id="Resource_m53ti"] +script = ExtResource("1_vsgl5") +button = 4 + +[sub_resource type="Resource" id="Resource_a3cu1"] +script = ExtResource("1_vsgl5") +button = 5 + +[sub_resource type="Resource" id="Resource_xpfqu"] +script = ExtResource("2_g15ft") +icons = [SubResource("Resource_m53ti"), SubResource("Resource_a3cu1")] +texture = ExtResource("3_pm2rw") +widthScale = 1.0 +orderMode = 2 +isUpperCase = false +fontSizeScale = 0.0 + +[sub_resource type="Resource" id="Resource_xbpgk"] +script = ExtResource("4_y5jfh") +button = 13 + +[sub_resource type="Resource" id="Resource_laa4d"] +script = ExtResource("4_y5jfh") +button = 14 + +[sub_resource type="Resource" id="Resource_28c0y"] +script = ExtResource("2_g15ft") +icons = [SubResource("Resource_xbpgk"), SubResource("Resource_laa4d")] +texture = ExtResource("5_ycc70") +widthScale = 1.0 +orderMode = 2 +isUpperCase = false +fontSizeScale = 0.0 + +[sub_resource type="Resource" id="Resource_4mvgb"] +script = ExtResource("4_y5jfh") +button = 11 + +[sub_resource type="Resource" id="Resource_l8cwl"] +script = ExtResource("4_y5jfh") +button = 12 + +[sub_resource type="Resource" id="Resource_oje1t"] +script = ExtResource("2_g15ft") +icons = [SubResource("Resource_4mvgb"), SubResource("Resource_l8cwl")] +texture = ExtResource("6_6nxcf") +widthScale = 1.0 +orderMode = 2 +isUpperCase = false +fontSizeScale = 0.0 + +[sub_resource type="Resource" id="Resource_8bcch"] +script = ExtResource("7_y0txw") +axis = 0 +type = 0 + +[sub_resource type="Resource" id="Resource_rlnb1"] +script = ExtResource("7_y0txw") +axis = 0 +type = 1 + +[sub_resource type="Resource" id="Resource_fmatu"] +script = ExtResource("20_55eoq") +en = "L" +entries = [] +context = "" + +[sub_resource type="Resource" id="Resource_tqg5p"] +script = ExtResource("2_g15ft") +icons = [SubResource("Resource_8bcch"), SubResource("Resource_rlnb1")] +texture = ExtResource("9_eeamd") +widthScale = 1.0 +orderMode = 2 +label = SubResource("Resource_fmatu") +isUpperCase = false +fontSizeScale = 0.8 + +[sub_resource type="Resource" id="Resource_vi3u1"] +script = ExtResource("7_y0txw") +axis = 1 +type = 1 + +[sub_resource type="Resource" id="Resource_vjbhe"] +script = ExtResource("7_y0txw") +axis = 1 +type = 0 + +[sub_resource type="Resource" id="Resource_q8dch"] +script = ExtResource("20_55eoq") +en = "L" +entries = [] +context = "" + +[sub_resource type="Resource" id="Resource_3oyc0"] +script = ExtResource("2_g15ft") +icons = [SubResource("Resource_vi3u1"), SubResource("Resource_vjbhe")] +texture = ExtResource("10_3i85w") +widthScale = 1.0 +orderMode = 2 +label = SubResource("Resource_q8dch") +isUpperCase = true +fontSizeScale = 0.8 + +[sub_resource type="Resource" id="Resource_wd2xx"] +script = ExtResource("7_y0txw") +axis = 2 +type = 0 + +[sub_resource type="Resource" id="Resource_h3a17"] +script = ExtResource("7_y0txw") +axis = 2 +type = 1 + +[sub_resource type="Resource" id="Resource_07ljj"] +script = ExtResource("20_55eoq") +en = "R" +entries = [] +context = "" + +[sub_resource type="Resource" id="Resource_c6gt5"] +script = ExtResource("2_g15ft") +icons = [SubResource("Resource_wd2xx"), SubResource("Resource_h3a17")] +texture = ExtResource("9_eeamd") +widthScale = 1.0 +orderMode = 2 +label = SubResource("Resource_07ljj") +isUpperCase = false +fontSizeScale = 0.8 + +[sub_resource type="Resource" id="Resource_qmgk3"] +script = ExtResource("7_y0txw") +axis = 3 +type = 1 + +[sub_resource type="Resource" id="Resource_4ro5i"] +script = ExtResource("20_55eoq") +en = "R" +entries = [] +context = "" + +[sub_resource type="Resource" id="Resource_812y6"] +script = ExtResource("2_g15ft") +icons = [SubResource("Resource_qmgk3"), SubResource("Resource_vjbhe")] +texture = ExtResource("10_3i85w") +widthScale = 1.0 +orderMode = 2 +label = SubResource("Resource_4ro5i") +isUpperCase = true +fontSizeScale = 0.8 + +[sub_resource type="Resource" id="Resource_udrbd"] +script = ExtResource("4_6ycsi") +combined = [SubResource("Resource_xpfqu"), SubResource("Resource_28c0y"), SubResource("Resource_oje1t"), SubResource("Resource_tqg5p"), SubResource("Resource_3oyc0"), SubResource("Resource_c6gt5"), SubResource("Resource_812y6")] + +[sub_resource type="Resource" id="Resource_s3w6q"] +script = ExtResource("5_sn8hr") +backgroundTexture = ExtResource("5_amgur") +directionUpTexture = ExtResource("6_0hfff") +directionalOffset = 0.0 +fontSizeScale = 1.0 +isUpperCase = true + +[sub_resource type="Resource" id="Resource_40bf3"] +script = ExtResource("2_4sutq") +value = 0.7 +unit = "em" +isAnimated = false +animationDuration = 0.0 +animationOffset = 0.0 + +[sub_resource type="Resource" id="Resource_xrtll"] +script = ExtResource("1_64knt") +backgroundTexture = ExtResource("10_q44jo") +widthScale = 1.0 +fontSizeScale = 1.0 +fontSizeCharacterMultiply = 0.9 +fontIsUpperCase = true +hasLabel = false +borderLeft = 0.0 +borderRight = 0.0 +borderTop = 0.0 +borderBottom = 0.0 + +[sub_resource type="Resource" id="Resource_nkgsq"] +script = ExtResource("1_64knt") +backgroundTexture = ExtResource("12_mf3bj") +widthScale = 1.0 +fontSizeScale = 1.0 +fontSizeCharacterMultiply = 0.9 +fontIsUpperCase = true +hasLabel = true +borderLeft = 40.0 +borderRight = 40.0 +borderTop = 40.0 +borderBottom = 40.0 + +[sub_resource type="Resource" id="Resource_wrdp7"] +script = ExtResource("1_64knt") +backgroundTexture = ExtResource("12_mf3bj") +widthScale = 2.0 +fontSizeScale = 0.7 +fontSizeCharacterMultiply = 1.0 +fontIsUpperCase = true +hasLabel = true +borderLeft = 40.0 +borderRight = 40.0 +borderTop = 40.0 +borderBottom = 40.0 +leftIndicatorTexture = ExtResource("13_ijjqw") +rightIndicatorTexture = ExtResource("13_ijjqw") + +[sub_resource type="Resource" id="Resource_mf61p"] +script = ExtResource("1_64knt") +backgroundTexture = ExtResource("14_6vom6") +widthScale = 2.0 +fontSizeScale = 1.0 +fontSizeCharacterMultiply = 0.9 +fontIsUpperCase = true +hasLabel = false +borderLeft = 0.0 +borderRight = 0.0 +borderTop = 0.0 +borderBottom = 0.0 + +[sub_resource type="Resource" id="Resource_qt31g"] +script = ExtResource("20_55eoq") +en = "L" +entries = [] +context = "" + +[sub_resource type="Resource" id="Resource_4s1kq"] +script = ExtResource("5_sn8hr") +backgroundTexture = ExtResource("18_amimm") +directionUpTexture = ExtResource("20_r1y6a") +directionalOffset = 0.0 +label = SubResource("Resource_qt31g") +fontSizeScale = 0.8 +isUpperCase = true +buttonPressTexture = ExtResource("19_7x4g0") + +[sub_resource type="Resource" id="Resource_dr7bt"] +script = ExtResource("1_64knt") +backgroundTexture = ExtResource("13_omll7") +widthScale = 1.0 +fontSizeScale = 1.0 +fontSizeCharacterMultiply = 0.9 +fontIsUpperCase = true +hasLabel = true +borderLeft = 0.0 +borderRight = 0.0 +borderTop = 0.0 +borderBottom = 0.0 + +[sub_resource type="Resource" id="Resource_2rh0g"] +script = ExtResource("1_64knt") +backgroundTexture = ExtResource("14_n68qo") +widthScale = 1.0 +fontSizeScale = 1.0 +fontSizeCharacterMultiply = 0.9 +fontIsUpperCase = true +hasLabel = true +borderLeft = 0.0 +borderRight = 0.0 +borderTop = 0.0 +borderBottom = 0.0 + +[sub_resource type="Resource" id="Resource_34cgw"] +script = ExtResource("5_a3fep") +leftButtonTexture = ExtResource("2_q818g") +middleButtonTexture = ExtResource("3_u1h0x") +rightButtonTexture = ExtResource("4_5b8av") +wheelUpTexture = ExtResource("7_n1ega") +wheelDownTexture = ExtResource("6_qyc6e") + +[sub_resource type="Resource" id="Resource_5ywoi"] +script = ExtResource("20_55eoq") +en = "R" +entries = [] +context = "" + +[sub_resource type="Resource" id="Resource_jl0ql"] +script = ExtResource("5_sn8hr") +backgroundTexture = ExtResource("18_amimm") +directionUpTexture = ExtResource("20_r1y6a") +directionalOffset = 0.0 +label = SubResource("Resource_5ywoi") +fontSizeScale = 0.8 +isUpperCase = true +buttonPressTexture = ExtResource("19_7x4g0") + +[sub_resource type="Resource" id="Resource_b5rf1"] +script = ExtResource("1_64knt") +backgroundTexture = ExtResource("21_hcyk3") +widthScale = 1.0 +fontSizeScale = 1.0 +fontSizeCharacterMultiply = 0.9 +fontIsUpperCase = true +hasLabel = true +borderLeft = 0.0 +borderRight = 0.0 +borderTop = 0.0 +borderBottom = 0.0 + +[resource] +script = ExtResource("1_urlfx") +font = ExtResource("1_xrnc5") +fontSize = SubResource("Resource_40bf3") +iconHeightInEm = 1.5 +mouseInputIcon = SubResource("Resource_34cgw") +keyboardKeys = SubResource("Resource_nkgsq") +keyboardModifiers = SubResource("Resource_wrdp7") +keyboardSpaceKey = SubResource("Resource_mf61p") +keyboardEnterKey = SubResource("Resource_xrtll") +mainButtons = SubResource("Resource_2rh0g") +leftShouldersButtons = SubResource("Resource_dr7bt") +rightShouldersButtons = SubResource("Resource_b5rf1") +digitalPad = SubResource("Resource_s3w6q") +leftJoystick = SubResource("Resource_4s1kq") +rightJoystick = SubResource("Resource_jl0ql") +combinedInputs = SubResource("Resource_udrbd") +locales = [] diff --git a/Runtime/Sensors/Default-Sensors/Gamepad/Axis/Left-Joystick X-Negative.tres b/Runtime/Sensors/Default-Sensors/Gamepad/Axis/Left-Joystick X-Negative.tres index 53d31b3..466777f 100644 --- a/Runtime/Sensors/Default-Sensors/Gamepad/Axis/Left-Joystick X-Negative.tres +++ b/Runtime/Sensors/Default-Sensors/Gamepad/Axis/Left-Joystick X-Negative.tres @@ -5,7 +5,7 @@ [resource] script = ExtResource("1_t42o5") axis = 0 -type = 0 +type = 1 continous = true _value = 0.0 _wasActive = false diff --git a/Runtime/Sensors/Default-Sensors/Gamepad/Axis/Left-Joystick X-Positive.tres b/Runtime/Sensors/Default-Sensors/Gamepad/Axis/Left-Joystick X-Positive.tres index 6b740db..2778929 100644 --- a/Runtime/Sensors/Default-Sensors/Gamepad/Axis/Left-Joystick X-Positive.tres +++ b/Runtime/Sensors/Default-Sensors/Gamepad/Axis/Left-Joystick X-Positive.tres @@ -5,7 +5,7 @@ [resource] script = ExtResource("1_y2djh") axis = 0 -type = 1 +type = 0 continous = true _value = 0.0 _wasActive = false diff --git a/Runtime/Sensors/Default-Sensors/Gamepad/Axis/Left-Joystick Y-Negative.tres b/Runtime/Sensors/Default-Sensors/Gamepad/Axis/Left-Joystick Y-Negative.tres index d484874..dfc4c31 100644 --- a/Runtime/Sensors/Default-Sensors/Gamepad/Axis/Left-Joystick Y-Negative.tres +++ b/Runtime/Sensors/Default-Sensors/Gamepad/Axis/Left-Joystick Y-Negative.tres @@ -5,7 +5,7 @@ [resource] script = ExtResource("1_yy4wi") axis = 0 -type = 0 +type = 1 continous = true _value = 0.0 _wasActive = false diff --git a/Runtime/Sensors/Default-Sensors/Gamepad/Axis/Left-Joystick Y-Positive.tres b/Runtime/Sensors/Default-Sensors/Gamepad/Axis/Left-Joystick Y-Positive.tres index 56c2235..3d78a3d 100644 --- a/Runtime/Sensors/Default-Sensors/Gamepad/Axis/Left-Joystick Y-Positive.tres +++ b/Runtime/Sensors/Default-Sensors/Gamepad/Axis/Left-Joystick Y-Positive.tres @@ -5,7 +5,7 @@ [resource] script = ExtResource("1_wej7c") axis = 1 -type = 1 +type = 0 continous = true _value = 0.0 _wasActive = false diff --git a/Runtime/Sensors/Default-Sensors/Gamepad/Axis/Right-Joystick X-Negative.tres b/Runtime/Sensors/Default-Sensors/Gamepad/Axis/Right-Joystick X-Negative.tres index 5a8fea0..72036e6 100644 --- a/Runtime/Sensors/Default-Sensors/Gamepad/Axis/Right-Joystick X-Negative.tres +++ b/Runtime/Sensors/Default-Sensors/Gamepad/Axis/Right-Joystick X-Negative.tres @@ -5,7 +5,7 @@ [resource] script = ExtResource("1_22ykp") axis = 2 -type = 0 +type = 1 continous = true _value = 0.0 _wasActive = false diff --git a/Runtime/Sensors/Default-Sensors/Gamepad/Axis/Right-Joystick X-Positive.tres b/Runtime/Sensors/Default-Sensors/Gamepad/Axis/Right-Joystick X-Positive.tres index 6c29646..20e85ea 100644 --- a/Runtime/Sensors/Default-Sensors/Gamepad/Axis/Right-Joystick X-Positive.tres +++ b/Runtime/Sensors/Default-Sensors/Gamepad/Axis/Right-Joystick X-Positive.tres @@ -5,7 +5,7 @@ [resource] script = ExtResource("1_pxirv") axis = 2 -type = 1 +type = 0 continous = true _value = 0.0 _wasActive = false diff --git a/Runtime/Sensors/Default-Sensors/Gamepad/Axis/Right-Joystick Y-Negative.tres b/Runtime/Sensors/Default-Sensors/Gamepad/Axis/Right-Joystick Y-Negative.tres index ab0204f..2b02f3e 100644 --- a/Runtime/Sensors/Default-Sensors/Gamepad/Axis/Right-Joystick Y-Negative.tres +++ b/Runtime/Sensors/Default-Sensors/Gamepad/Axis/Right-Joystick Y-Negative.tres @@ -5,7 +5,7 @@ [resource] script = ExtResource("1_nrdau") axis = 3 -type = 0 +type = 1 continous = true _value = 0.0 _wasActive = false diff --git a/Runtime/Sensors/Default-Sensors/Gamepad/Axis/Right-Joystick Y-Positive.tres b/Runtime/Sensors/Default-Sensors/Gamepad/Axis/Right-Joystick Y-Positive.tres index 5315f10..aa1199c 100644 --- a/Runtime/Sensors/Default-Sensors/Gamepad/Axis/Right-Joystick Y-Positive.tres +++ b/Runtime/Sensors/Default-Sensors/Gamepad/Axis/Right-Joystick Y-Positive.tres @@ -5,7 +5,7 @@ [resource] script = ExtResource("1_xf3mc") axis = 3 -type = 1 +type = 0 continous = true _value = 0.0 _wasActive = false diff --git a/Runtime/Sensors/Default-Sensors/Gamepad/Axis/Trigger Left, LT, PS L2, Nin ZL.tres b/Runtime/Sensors/Default-Sensors/Gamepad/Axis/Trigger Left, LT, PS L2, Nin ZL.tres index 4de7b8e..10687e6 100644 --- a/Runtime/Sensors/Default-Sensors/Gamepad/Axis/Trigger Left, LT, PS L2, Nin ZL.tres +++ b/Runtime/Sensors/Default-Sensors/Gamepad/Axis/Trigger Left, LT, PS L2, Nin ZL.tres @@ -4,8 +4,8 @@ [resource] script = ExtResource("1_ow83o") -axis = 5 -type = 1 +axis = 4 +type = 0 continous = true _value = 0.0 _wasActive = false diff --git a/Runtime/Sensors/Default-Sensors/Gamepad/Axis/Trigger Right, RT, PS R2, Nin ZR.tres b/Runtime/Sensors/Default-Sensors/Gamepad/Axis/Trigger Right, RT, PS R2, Nin ZR.tres index d00b674..ccd6e1a 100644 --- a/Runtime/Sensors/Default-Sensors/Gamepad/Axis/Trigger Right, RT, PS R2, Nin ZR.tres +++ b/Runtime/Sensors/Default-Sensors/Gamepad/Axis/Trigger Right, RT, PS R2, Nin ZR.tres @@ -4,8 +4,8 @@ [resource] script = ExtResource("1_63g6c") -axis = 3 -type = 1 +axis = 5 +type = 0 continous = true _value = 0.0 _wasActive = false diff --git a/Runtime/Sensors/Default-Sensors/Keyboard & Mouse/Default - Keyboard & Mouse.tres b/Runtime/Sensors/Default-Sensors/Keyboard & Mouse/Default - Keyboard & Mouse.tres index f3d0200..f96da17 100644 --- a/Runtime/Sensors/Default-Sensors/Keyboard & Mouse/Default - Keyboard & Mouse.tres +++ b/Runtime/Sensors/Default-Sensors/Keyboard & Mouse/Default - Keyboard & Mouse.tres @@ -7,12 +7,12 @@ [ext_resource type="Resource" uid="uid://chwstub7bnlpp" path="res://addons/rokojori_action_library/Runtime/Sensors/Default-Sensors/Keyboard & Mouse/Mouse/Mouse-Wheel Down.tres" id="5_diio6"] [ext_resource type="Resource" uid="uid://b52horrdbgyaa" path="res://addons/rokojori_action_library/Runtime/Sensors/Default-Sensors/Keyboard & Mouse/Mouse/Mouse-Wheel Up.tres" id="6_3kcki"] [ext_resource type="Resource" uid="uid://mbnb46tah4i7" path="res://addons/rokojori_action_library/Runtime/Sensors/Default-Sensors/Keyboard & Mouse/Movement/Move Forward.tres" id="7_1jado"] -[ext_resource type="Resource" uid="uid://ds1rrltuj0mse" path="res://addons/rokojori_action_library/Runtime/Sensors/Default-Sensors/Keyboard & Mouse/Movement/Fly Up.tres" id="7_if4l6"] [ext_resource type="Resource" uid="uid://c5ueac4xt7oyb" path="res://addons/rokojori_action_library/Runtime/Sensors/Default-Sensors/Keyboard & Mouse/Movement/Move Back.tres" id="8_0us2c"] -[ext_resource type="Resource" uid="uid://dwigqkllvj8dq" path="res://addons/rokojori_action_library/Runtime/Sensors/Default-Sensors/Keyboard & Mouse/Movement/Fly Down.tres" id="8_r5hwi"] +[ext_resource type="Resource" uid="uid://ds1rrltuj0mse" path="res://addons/rokojori_action_library/Runtime/Sensors/Default-Sensors/Keyboard & Mouse/Movement/Move Down.tres" id="8_r5hwi"] [ext_resource type="Resource" uid="uid://bfxeh1y1vgkiu" path="res://addons/rokojori_action_library/Runtime/Sensors/Default-Sensors/Keyboard & Mouse/Movement/Strafe Left.tres" id="9_xdx7j"] [ext_resource type="Resource" uid="uid://bm2d6nhevcjel" path="res://addons/rokojori_action_library/Runtime/Sensors/Default-Sensors/Keyboard & Mouse/Movement/Strafe Right.tres" id="10_cwkpy"] +[ext_resource type="Resource" uid="uid://ds1rrltuj0mse" path="res://addons/rokojori_action_library/Runtime/Sensors/Default-Sensors/Keyboard & Mouse/Movement/Move Down.tres" id="11_33hna"] [resource] script = ExtResource("1_168ay") -sensors = [ExtResource("2_fxahp"), ExtResource("3_6x0mm"), ExtResource("4_4gj3k"), ExtResource("5_diio6"), ExtResource("6_3kcki"), ExtResource("7_1jado"), ExtResource("8_0us2c"), ExtResource("9_xdx7j"), ExtResource("10_cwkpy"), ExtResource("7_if4l6"), ExtResource("8_r5hwi")] +sensors = [ExtResource("2_fxahp"), ExtResource("3_6x0mm"), ExtResource("4_4gj3k"), ExtResource("5_diio6"), ExtResource("6_3kcki"), ExtResource("7_1jado"), ExtResource("8_0us2c"), ExtResource("9_xdx7j"), ExtResource("10_cwkpy"), ExtResource("11_33hna"), ExtResource("8_r5hwi")] diff --git a/Runtime/Sensors/Default-Sensors/Keyboard & Mouse/Movement/Move Back.tres b/Runtime/Sensors/Default-Sensors/Keyboard & Mouse/Movement/Move Back.tres index d73c883..a8f5a49 100644 --- a/Runtime/Sensors/Default-Sensors/Keyboard & Mouse/Movement/Move Back.tres +++ b/Runtime/Sensors/Default-Sensors/Keyboard & Mouse/Movement/Move Back.tres @@ -6,6 +6,7 @@ [sub_resource type="Resource" id="Resource_bf8g7"] script = ExtResource("2_p2364") key = 83 +keyLocation = 0 ctrlHold = 2 altHold = 2 shiftHold = 2 @@ -19,6 +20,7 @@ _activeTreshold = 0.5 [sub_resource type="Resource" id="Resource_bi0fk"] script = ExtResource("2_p2364") key = 4194322 +keyLocation = 0 ctrlHold = 2 altHold = 2 shiftHold = 2 @@ -31,7 +33,11 @@ _activeTreshold = 0.5 [resource] script = ExtResource("1_xxflt") -sensors = Array[Object]([SubResource("Resource_bf8g7"), SubResource("Resource_bi0fk")]) +sensors = [SubResource("Resource_bf8g7"), SubResource("Resource_bi0fk")] +showOnlyVisibleIcons = true +numVisible = 1 +inputIcons = [] +useInputIconsFromSensors = true continous = false _value = 0.0 _wasActive = false diff --git a/Runtime/Sensors/Default-Sensors/Keyboard & Mouse/Movement/Fly Up.tres b/Runtime/Sensors/Default-Sensors/Keyboard & Mouse/Movement/Move Down.tres similarity index 77% rename from Runtime/Sensors/Default-Sensors/Keyboard & Mouse/Movement/Fly Up.tres rename to Runtime/Sensors/Default-Sensors/Keyboard & Mouse/Movement/Move Down.tres index b7337bf..220e3b7 100644 --- a/Runtime/Sensors/Default-Sensors/Keyboard & Mouse/Movement/Fly Up.tres +++ b/Runtime/Sensors/Default-Sensors/Keyboard & Mouse/Movement/Move Down.tres @@ -1,10 +1,11 @@ [gd_resource type="Resource" script_class="KeySensor" load_steps=2 format=3 uid="uid://ds1rrltuj0mse"] -[ext_resource type="Script" path="res://addons/rokojori_action_library/Runtime/Sensors/KeySensor.cs" id="1_2vgvk"] +[ext_resource type="Script" path="res://addons/rokojori_action_library/Runtime/Sensors/KeySensor.cs" id="1_r0t8l"] [resource] -script = ExtResource("1_2vgvk") +script = ExtResource("1_r0t8l") key = 69 +keyLocation = 0 ctrlHold = 2 altHold = 2 shiftHold = 2 diff --git a/Runtime/Sensors/Default-Sensors/Keyboard & Mouse/Movement/Move Forward.tres b/Runtime/Sensors/Default-Sensors/Keyboard & Mouse/Movement/Move Forward.tres index 7b3744d..3626134 100644 --- a/Runtime/Sensors/Default-Sensors/Keyboard & Mouse/Movement/Move Forward.tres +++ b/Runtime/Sensors/Default-Sensors/Keyboard & Mouse/Movement/Move Forward.tres @@ -6,6 +6,7 @@ [sub_resource type="Resource" id="Resource_uixae"] script = ExtResource("2_rjp34") key = 87 +keyLocation = 0 ctrlHold = 2 altHold = 2 shiftHold = 2 @@ -19,6 +20,7 @@ _activeTreshold = 0.5 [sub_resource type="Resource" id="Resource_grqa0"] script = ExtResource("2_rjp34") key = 4194320 +keyLocation = 0 ctrlHold = 2 altHold = 2 shiftHold = 2 @@ -31,7 +33,11 @@ _activeTreshold = 0.5 [resource] script = ExtResource("1_vohv8") -sensors = Array[Object]([SubResource("Resource_uixae"), SubResource("Resource_grqa0")]) +sensors = [SubResource("Resource_uixae"), SubResource("Resource_grqa0")] +showOnlyVisibleIcons = true +numVisible = 1 +inputIcons = [] +useInputIconsFromSensors = true continous = false _value = 0.0 _wasActive = false diff --git a/Runtime/Sensors/Default-Sensors/Keyboard & Mouse/Movement/Fly Down.tres b/Runtime/Sensors/Default-Sensors/Keyboard & Mouse/Movement/Move Up.tres similarity index 100% rename from Runtime/Sensors/Default-Sensors/Keyboard & Mouse/Movement/Fly Down.tres rename to Runtime/Sensors/Default-Sensors/Keyboard & Mouse/Movement/Move Up.tres diff --git a/Runtime/Sensors/Default-Sensors/Keyboard & Mouse/Movement/Strafe Left.tres b/Runtime/Sensors/Default-Sensors/Keyboard & Mouse/Movement/Strafe Left.tres index 11691f8..21786f4 100644 --- a/Runtime/Sensors/Default-Sensors/Keyboard & Mouse/Movement/Strafe Left.tres +++ b/Runtime/Sensors/Default-Sensors/Keyboard & Mouse/Movement/Strafe Left.tres @@ -6,6 +6,7 @@ [sub_resource type="Resource" id="Resource_m3515"] script = ExtResource("2_m4lpr") key = 65 +keyLocation = 0 ctrlHold = 2 altHold = 2 shiftHold = 2 @@ -19,6 +20,7 @@ _activeTreshold = 0.5 [sub_resource type="Resource" id="Resource_ejgie"] script = ExtResource("2_m4lpr") key = 4194319 +keyLocation = 0 ctrlHold = 2 altHold = 2 shiftHold = 2 @@ -32,6 +34,10 @@ _activeTreshold = 0.5 [resource] script = ExtResource("1_xuikh") sensors = [SubResource("Resource_m3515"), SubResource("Resource_ejgie")] +showOnlyVisibleIcons = true +numVisible = 1 +inputIcons = [] +useInputIconsFromSensors = true continous = false _value = 0.0 _wasActive = false diff --git a/Runtime/Sensors/Default-Sensors/Keyboard & Mouse/Movement/Strafe Right.tres b/Runtime/Sensors/Default-Sensors/Keyboard & Mouse/Movement/Strafe Right.tres index 1ee9418..5a2b13f 100644 --- a/Runtime/Sensors/Default-Sensors/Keyboard & Mouse/Movement/Strafe Right.tres +++ b/Runtime/Sensors/Default-Sensors/Keyboard & Mouse/Movement/Strafe Right.tres @@ -6,6 +6,7 @@ [sub_resource type="Resource" id="Resource_n5k5a"] script = ExtResource("2_uy5s5") key = 68 +keyLocation = 0 ctrlHold = 2 altHold = 2 shiftHold = 2 @@ -19,6 +20,7 @@ _activeTreshold = 0.5 [sub_resource type="Resource" id="Resource_8vsbn"] script = ExtResource("2_uy5s5") key = 4194321 +keyLocation = 0 ctrlHold = 2 altHold = 2 shiftHold = 2 @@ -31,7 +33,11 @@ _activeTreshold = 0.5 [resource] script = ExtResource("1_t65bw") -sensors = Array[Object]([SubResource("Resource_n5k5a"), SubResource("Resource_8vsbn")]) +sensors = [SubResource("Resource_n5k5a"), SubResource("Resource_8vsbn")] +showOnlyVisibleIcons = true +numVisible = 1 +inputIcons = [] +useInputIconsFromSensors = true continous = false _value = 0.0 _wasActive = false diff --git a/Runtime/Sensors/DeviceFilters/DeviceFilter.cs b/Runtime/Sensors/DeviceFilters/DeviceFilter.cs new file mode 100644 index 0000000..c2a1629 --- /dev/null +++ b/Runtime/Sensors/DeviceFilters/DeviceFilter.cs @@ -0,0 +1,16 @@ + +using Godot; +using System.Collections.Generic; + +namespace Rokojori +{ + [Tool] + [GlobalClass,Icon("res://addons/rokojori_action_library/Icons/SensorGroup.svg")] + public partial class DeviceFilter : Resource + { + public virtual bool BelongsToDevice( InputIcon icon ) + { + return true; + } + } +} \ No newline at end of file diff --git a/Runtime/Sensors/DeviceFilters/LastActiveDeviceFilter.cs b/Runtime/Sensors/DeviceFilters/LastActiveDeviceFilter.cs new file mode 100644 index 0000000..7cea961 --- /dev/null +++ b/Runtime/Sensors/DeviceFilters/LastActiveDeviceFilter.cs @@ -0,0 +1,31 @@ + +using Godot; +using System.Collections.Generic; + +namespace Rokojori +{ + [Tool] + [GlobalClass,Icon("res://addons/rokojori_action_library/Icons/SensorGroup.svg")] + public partial class LastActiveDeviceFilter : DeviceFilter + { + public override bool BelongsToDevice( InputIcon icon ) + { + var sm = Unique.Get(); + + if ( sm == null ) + { + this.LogInfo( "No SensorManager" ); + return false; + } + + var device = sm.lastActiveDevice; + + if ( device == null ) + { + return false; + } + + return device.ContainsIcon( icon ); + } + } +} \ No newline at end of file diff --git a/Runtime/Sensors/Devices/GamePadDevice.cs b/Runtime/Sensors/Devices/GamePadDevice.cs new file mode 100644 index 0000000..b03c60a --- /dev/null +++ b/Runtime/Sensors/Devices/GamePadDevice.cs @@ -0,0 +1,49 @@ + +using Godot; +using System.Collections.Generic; + +namespace Rokojori +{ + public enum GamePadDeviceType + { + XBox, + PS, + Switch + } + + [Tool] + [GlobalClass,Icon("res://addons/rokojori_action_library/Icons/SensorGroup.svg")] + public partial class GamePadDevice: SensorDevice + { + [Export] + public int deviceIndex = 0; + + [Export] + public string deviceName; + + [Export] + public GamePadDeviceType deviceType = GamePadDeviceType.XBox; + + + public override LocalizedString GetDeviceName() + { + return LocaleText.Create( deviceName ); + } + + public override bool ContainsSensor( Sensor sensor ) + { + return ReflectionHelper.IsTypeOneOf( sensor, + typeof( GamePadAxisSensor ), + typeof( GamePadButtonSensor ) + ); + } + + public override bool ContainsIcon( InputIcon icon ) + { + return ReflectionHelper.IsTypeOneOf( icon, + typeof( GamePadAxisIcon ), + typeof( GamePadButtonIcon ) + ); + } + } +} \ No newline at end of file diff --git a/Runtime/Sensors/Devices/KeyboardDevice.cs b/Runtime/Sensors/Devices/KeyboardDevice.cs new file mode 100644 index 0000000..262357f --- /dev/null +++ b/Runtime/Sensors/Devices/KeyboardDevice.cs @@ -0,0 +1,32 @@ + +using Godot; +using System.Collections.Generic; + +namespace Rokojori +{ + [Tool] + [GlobalClass,Icon("res://addons/rokojori_action_library/Icons/SensorGroup.svg")] + public partial class KeyboardDevice: SensorDevice + { + public override LocalizedString GetDeviceName() + { + return LocaleText.Create( "Keyboard" ); + } + + public override bool ContainsSensor( Sensor sensor ) + { + return ReflectionHelper.IsTypeOneOf( sensor, + typeof( KeySensor ) + ); + } + + public override bool ContainsIcon( InputIcon icon ) + { + return ReflectionHelper.IsTypeOneOf( icon, + typeof( KeyIcon ) + ); + } + + + } +} \ No newline at end of file diff --git a/Runtime/Sensors/Devices/MouseDevice.cs b/Runtime/Sensors/Devices/MouseDevice.cs new file mode 100644 index 0000000..3b92149 --- /dev/null +++ b/Runtime/Sensors/Devices/MouseDevice.cs @@ -0,0 +1,32 @@ + +using Godot; +using System.Collections.Generic; + +namespace Rokojori +{ + [Tool] + [GlobalClass,Icon("res://addons/rokojori_action_library/Icons/SensorGroup.svg")] + public partial class MouseDevice: SensorDevice + { + public override LocalizedString GetDeviceName() + { + return LocaleText.Create( "Mouse" ); + } + + public override bool ContainsSensor( Sensor sensor ) + { + return ReflectionHelper.IsTypeOneOf( sensor, + typeof( MouseButtonSensor ), + typeof( MouseMotionDelta ), + typeof( MouseScreenRelative ) + ); + } + + public override bool ContainsIcon( InputIcon icon ) + { + return ReflectionHelper.IsTypeOneOf( icon, + typeof( MouseInputIcon ) + ); + } + } +} \ No newline at end of file diff --git a/Runtime/Sensors/Devices/MultiSensorDevice.cs b/Runtime/Sensors/Devices/MultiSensorDevice.cs new file mode 100644 index 0000000..02a9cab --- /dev/null +++ b/Runtime/Sensors/Devices/MultiSensorDevice.cs @@ -0,0 +1,43 @@ + +using Godot; +using System.Collections.Generic; + +namespace Rokojori +{ + [Tool] + [GlobalClass,Icon("res://addons/rokojori_action_library/Icons/SensorGroup.svg")] + public partial class MultiSensorDevice: SensorDevice + { + [Export] + public SensorDevice[] devices = new SensorDevice[ 0 ]; + + [Export] + public Sensor[] sensors = new Sensor[ 0 ]; + + public override bool ContainsSensor( Sensor sensor ) + { + for ( int i = 0; i < devices.Length; i++ ) + { + if ( devices[ i ].ContainsSensor( sensor ) ) + { + return true; + } + } + + return Arrays.Contains( sensors, sensor ); + } + + public override bool ContainsIcon( InputIcon icon ) + { + for ( int i = 0; i < devices.Length; i++ ) + { + if ( devices[ i ].ContainsIcon( icon ) ) + { + return true; + } + } + + return false; + } + } +} \ No newline at end of file diff --git a/Runtime/Sensors/Devices/SensorDevice.cs b/Runtime/Sensors/Devices/SensorDevice.cs new file mode 100644 index 0000000..f11d7a0 --- /dev/null +++ b/Runtime/Sensors/Devices/SensorDevice.cs @@ -0,0 +1,26 @@ + +using Godot; +using System.Collections.Generic; + +namespace Rokojori +{ + [Tool] + [GlobalClass,Icon("res://addons/rokojori_action_library/Icons/SensorGroup.svg")] + public partial class SensorDevice: Resource + { + public virtual LocalizedString GetDeviceName() + { + return LocaleText.Create( "---" ); + } + + public virtual bool ContainsSensor( Sensor sensor ) + { + return false; + } + + public virtual bool ContainsIcon( InputIcon icon ) + { + return false; + } + } +} \ No newline at end of file diff --git a/Runtime/Sensors/GamePadAxisSensor.cs b/Runtime/Sensors/GamePadAxisSensor.cs index aa9db3c..b08a057 100644 --- a/Runtime/Sensors/GamePadAxisSensor.cs +++ b/Runtime/Sensors/GamePadAxisSensor.cs @@ -1,6 +1,6 @@ using Godot; - +using System.Collections.Generic; namespace Rokojori { @@ -13,16 +13,13 @@ namespace Rokojori public override bool isMultiDevice => true; - public enum AxisType - { - Negative, - Positive - } - - [Export] - public AxisType type; + public GamePadAxisType type; + public override string ToString() + { + return RJLog.GetInfo( this, axis, type ); + } float _lastInput = 0; @@ -45,10 +42,22 @@ namespace Rokojori return; } - _lastInput = Mathf.Max( (AxisType.Negative == type ? -1 : 1 ) * joypadAxisEvent.AxisValue, 0 ); + _lastInput = Mathf.Max( (GamePadAxisType.Negative == type ? -1 : 1 ) * joypadAxisEvent.AxisValue, 0 ); + + UpdateSensorUsage( joypadAxisEvent.Device ); } + public override List GetInputIcons() + { + var icon = new GamePadAxisIcon(); + icon.axis = axis; + icon.type = type; + + return new List(){ icon }; + } + + } } \ No newline at end of file diff --git a/Runtime/Sensors/GamePadAxisType.cs b/Runtime/Sensors/GamePadAxisType.cs new file mode 100644 index 0000000..bf68fd0 --- /dev/null +++ b/Runtime/Sensors/GamePadAxisType.cs @@ -0,0 +1,12 @@ + +using Godot; + + +namespace Rokojori +{ + public enum GamePadAxisType + { + Positive, + Negative + } +} \ No newline at end of file diff --git a/Runtime/Sensors/GamePadButtonSensor.cs b/Runtime/Sensors/GamePadButtonSensor.cs index e8c7a61..965cb86 100644 --- a/Runtime/Sensors/GamePadButtonSensor.cs +++ b/Runtime/Sensors/GamePadButtonSensor.cs @@ -1,6 +1,6 @@ using Godot; - +using System.Collections.Generic; namespace Rokojori { @@ -20,6 +20,11 @@ namespace Rokojori SetFloatValue( _lastInput ); } + public override string ToString() + { + return RJLog.GetInfo( this, button ); + } + public void _Input( InputEvent ev ) { var joypadButtonEvent = ev as InputEventJoypadButton; @@ -35,9 +40,18 @@ namespace Rokojori } _lastInput = joypadButtonEvent.IsPressed() ? 1 : 0; + + UpdateSensorUsage( joypadButtonEvent.Device ); } + public override List GetInputIcons() + { + var icon = new GamePadButtonIcon(); + icon.button = button; + + return new List(){ icon }; + } } } \ No newline at end of file diff --git a/Runtime/Sensors/InputIcons/Definitions/CombinedIconsDefinition.cs b/Runtime/Sensors/InputIcons/Definitions/CombinedIconsDefinition.cs new file mode 100644 index 0000000..3ccf93e --- /dev/null +++ b/Runtime/Sensors/InputIcons/Definitions/CombinedIconsDefinition.cs @@ -0,0 +1,94 @@ + +using Godot; +using System.Collections.Generic; + +namespace Rokojori +{ + [Tool] + [GlobalClass, Icon("res://addons/rokojori_action_library/Icons/Sensor.svg")] + public partial class CombinedIconsDefinition: InputIconDefinition + { + [Export] + public CombinedInputIconsTexture[] combined = new CombinedInputIconsTexture[ 0 ]; + + + + public override int ResolveIcons( int offset, List icons ) + { + // this.LogInfo( "ResolveIcons", offset, icons ); + + var resolved = GetIconFor( offset, icons ); + + if ( resolved == null ) + { + return -1; + } + + return resolved.icons.Length; + } + + public CombinedInputIconsTexture GetIconFor( int offset, List icons ) + { + for ( int i = 0; i < combined.Length; i++ ) + { + var isIcon = combined[ i ].IsIcon( offset, icons ); + + // RJLog.Log( "isIcon -> offset:", offset, "isIcon:", isIcon, "icons:", icons ); + + if ( isIcon ) + { + return combined[ i ]; + } + } + + return null; + } + + public override List GetIconElementsForIcon( InputIcon icon ) + { + var ci = icon as CombinedIcon; + + if ( ci == null ) + { + return null; + } + + var resolved = GetIconFor( 0, Lists.From( ci.icons ) ); + + if ( resolved == null ) + { + // RJLog.Log( "CombinedIcon: null"); + return null; + } + + + + var resolvedList = new List(); + resolvedList.Add( TextureIconElement.Create( resolved.texture, resolved.widthScale ) ); + + if ( resolved.label != null ) + { + var labelText = LabelIconElement.Create( resolved.label, resolved.fontSizeScale, resolved.isUpperCase ); + resolvedList.Add( labelText ); + } + + + return resolvedList; + + } + + public override bool HasIconFor( InputIcon icon ) + { + if ( ! ( icon is CombinedIcon ci ) ) + { + return false; + } + + var ic = GetIconFor( 0, Lists.From( ci.icons ) ); + + return ic != null; + } + + + } +} \ No newline at end of file diff --git a/Runtime/Sensors/InputIcons/Definitions/CombinedInputIconsTexture.cs b/Runtime/Sensors/InputIcons/Definitions/CombinedInputIconsTexture.cs new file mode 100644 index 0000000..990ec3d --- /dev/null +++ b/Runtime/Sensors/InputIcons/Definitions/CombinedInputIconsTexture.cs @@ -0,0 +1,80 @@ + +using Godot; +using System.Collections.Generic; + +namespace Rokojori +{ + [Tool] + [GlobalClass, Icon("res://addons/rokojori_action_library/Icons/Sensor.svg")] + public partial class CombinedInputIconsTexture: Resource + { + [Export] + public InputIcon[] icons = new InputIcon[ 0 ]; + + [Export] + public Texture2D texture; + + [Export] + public float widthScale = 1; + + [Export] + public CombineIconOrderMode orderMode = CombineIconOrderMode.Any_Order; + + [Export] + public LocalizedString label; + + [Export] + public bool isUpperCase = true; + + [Export] + public float fontSizeScale = 1; + + public bool IsIcon( int offset, List iconList ) + { + var iconOrder = new List(); + + for ( int i = 0; i < icons.Length && ( i + offset ) < iconList.Count ; i++ ) + { + var icon = iconList[ offset + i ]; + + if ( icon == null ) + { + return false; + } + + if ( ! Arrays.ContainsEqual( icons, icon ) ) + { + return false; + } + + if ( Lists.ContainsEqual( iconOrder, icon ) ) + { + return false; + } + + iconOrder.Add( icon ); + } + + if ( iconOrder.Count != icons.Length ) + { + return false; + } + + if ( CombineIconOrderMode.Forward_Only == orderMode ) + { + return Lists.AreEntriesEqual( iconOrder, Lists.From( icons ) ); + } + else if ( CombineIconOrderMode.Forward_And_Reverse == orderMode ) + { + var list = Lists.From( icons ); + var listR = Lists.From( icons ); listR.Reverse(); + + return Lists.AreEntriesEqual( iconOrder, list ) || Lists.AreEntriesEqual( iconOrder, listR ); + } + + return true; + + } + + } +} \ No newline at end of file diff --git a/Runtime/Sensors/InputIcons/Definitions/DefaultInputIconDefinition.cs b/Runtime/Sensors/InputIcons/Definitions/DefaultInputIconDefinition.cs new file mode 100644 index 0000000..15ec871 --- /dev/null +++ b/Runtime/Sensors/InputIcons/Definitions/DefaultInputIconDefinition.cs @@ -0,0 +1,129 @@ + +using Godot; +using System.Collections.Generic; + +namespace Rokojori +{ + [Tool] + [GlobalClass, Icon("res://addons/rokojori_action_library/Icons/Sensor.svg")] + public partial class DefaultInputIconDefinition: InputIconDefinition + { + [Export] + public Texture2D backgroundTexture; + + [Export] + public float widthScale = 1; + + [ExportGroup("Font")] + + [Export] + public float fontSizeScale = 1; + + [Export] + public float fontSizeCharacterMultiply = 0.9f; + + [Export] + public bool fontIsUpperCase = true; + + [Export] + public bool hasLabel = true; + + [ExportGroup("Borders")] + [Export] + public float borderLeft = 0; + + [Export] + public float borderRight = 0; + + [Export] + public float borderTop = 0; + + [Export] + public float borderBottom = 0; + + + + public bool hasBorders + { + get + { + return ( borderLeft + borderRight + borderTop + borderBottom ) > 0; + } + } + + + [ExportGroup("Overlays")] + + [Export] + public Texture2D leftIndicatorTexture; + + [Export] + public Texture2D rightIndicatorTexture; + + + public override List GetIconElementsForIcon( InputIcon icon ) + { + var list = new List(); + + var bg = TextureIconElement.Create( backgroundTexture, widthScale ); + bg.SetBorders( this ); + list.Add( bg ); + + + if ( icon is KeyIcon ki ) + { + if ( hasLabel ) + { + var locale = ki.GetIconLocale(); + var fontScale = fontSizeScale * Mathf.Pow( fontSizeCharacterMultiply, locale.currentValue.Length - 1 ); + + var label = LabelIconElement.Create( locale, fontScale, fontIsUpperCase ); + list.Add( label ); + } + + if ( KeyLocation.Unspecified != ki.location ) + { + var indicatorTexture = KeyLocation.Left == ki.location ? leftIndicatorTexture : + KeyLocation.Right == ki.location ? rightIndicatorTexture : null; + + + if ( indicatorTexture != null ) + { + var indicatorElement = TextureIconElement.Create( indicatorTexture, widthScale ); + indicatorElement.alignment = KeyLocation.Left == ki.location ? TextureIconOverlayAlignment.Left : + KeyLocation.Right == ki.location ? TextureIconOverlayAlignment.Right : + TextureIconOverlayAlignment.Center; + list.Add( indicatorElement ); + } + } + } + + if ( icon is GamePadButtonIcon bi ) + { + if ( hasLabel ) + { + var locale = bi.GetIconLocale(); + var fontScale = fontSizeScale * Mathf.Pow( fontSizeCharacterMultiply, locale.currentValue.Length - 1 ); + + var label = LabelIconElement.Create( locale, fontScale, fontIsUpperCase ); + list.Add( label ); + } + } + + if ( icon is GamePadAxisIcon ai ) + { + if ( hasLabel ) + { + var locale = ai.GetIconLocale(); + var fontScale = fontSizeScale * Mathf.Pow( fontSizeCharacterMultiply, locale.currentValue.Length - 1 ); + + var label = LabelIconElement.Create( locale, fontScale, fontIsUpperCase ); + list.Add( label ); + } + } + + return list; + } + + } +} \ No newline at end of file diff --git a/Runtime/Sensors/InputIcons/Definitions/DirectionalInputIconDefinition.cs b/Runtime/Sensors/InputIcons/Definitions/DirectionalInputIconDefinition.cs new file mode 100644 index 0000000..806fbde --- /dev/null +++ b/Runtime/Sensors/InputIcons/Definitions/DirectionalInputIconDefinition.cs @@ -0,0 +1,163 @@ + +using Godot; +using System.Collections.Generic; + +namespace Rokojori +{ + [Tool] + [GlobalClass, Icon("res://addons/rokojori_action_library/Icons/Sensor.svg")] + public partial class DirectionalInputIconDefinition: InputIconDefinition + { + [Export] + public Texture2D backgroundTexture; + + + [ExportGroup("Directions")] + + + + [Export] + public Texture2D directionRightTexture; + + [Export] + public Texture2D directionDownTexture; + + [Export] + public Texture2D directionLeftTexture; + + [Export] + public Texture2D directionUpTexture; + + [Export] + public float directionalOffset = 0; + + + [ExportGroup("Overlays")] + [Export] + public LocaleText label; + + [Export] + public float fontSizeScale = 1; + + [Export] + public bool isUpperCase = true; + + [Export] + public Texture2D buttonPressTexture; + + + static int GetAngle( T value, params T[] values ) + { + var index = Arrays.IndexOf( values, value ); + + if ( index == -1 ) + { + return index; + } + + return index * 90; + } + + public static int GetAngleOfIcon( InputIcon icon ) + { + if ( icon is GamePadButtonIcon bi ) + { + return GetAngle( bi.button, JoyButton.DpadRight, JoyButton.DpadDown, JoyButton.DpadLeft, JoyButton.DpadUp ); + } + else if ( icon is GamePadAxisIcon ai ) + { + if ( JoyAxis.LeftX == ai.axis || JoyAxis.RightX == ai.axis ) + { + return GamePadAxisType.Positive == ai.type ? 0 : 180; + } + + if ( JoyAxis.LeftY == ai.axis || JoyAxis.RightY == ai.axis ) + { + return GamePadAxisType.Positive == ai.type ? 90 : 270; + } + + } + + + return -1; + } + + public override List GetIconElementsForIcon( InputIcon icon ) + { + var list = new List(); + + var bg = TextureIconElement.Create( backgroundTexture, 1 ); + list.Add( bg ); + + if ( label != null ) + { + var labelText = LabelIconElement.Create( label, fontSizeScale, isUpperCase ); + list.Add( labelText ); + } + + if ( icon is GamePadAxisIcon || icon is GamePadButtonIcon ) + { + var ai = icon as GamePadAxisIcon; + var bi = icon as GamePadButtonIcon; + var angle = ai != null ? GetAngleOfIcon( ai ) : GetAngleOfIcon( bi ); + var rotation = 0f; + var texture = GetDirectionTexture( angle, out rotation ); + + var dir = TextureIconElement.Create( texture, 1 ); + dir.alignment = TextureIconOverlayAlignment.Left; + + dir.rotation = rotation; + + list.Add( dir ); + } + + + return list; + } + + List GetAllTextures() + { + return new List(){ directionRightTexture, directionDownTexture, directionLeftTexture, directionUpTexture }; + } + + Texture2D GetDirectionTexture( int angle, out float rotation ) + { + var textures = GetAllTextures(); + + var nonNullIndex = -1; + rotation = 0; + + for ( int i = 0; i < textures.Count; i++ ) + { + if ( textures[ i ] == null ) + { + continue; + } + + if ( i * 90 == angle ) + { + return textures[ i ]; + } + + if ( nonNullIndex != -1 ) + { + continue; + } + + nonNullIndex = i; + + } + + if ( nonNullIndex == -1 ) + { + return null; + } + + rotation = angle - nonNullIndex * 90; + return textures[ nonNullIndex ]; + + + } + + } +} \ No newline at end of file diff --git a/Runtime/Sensors/InputIcons/Definitions/IconElement.cs b/Runtime/Sensors/InputIcons/Definitions/IconElement.cs new file mode 100644 index 0000000..d47895d --- /dev/null +++ b/Runtime/Sensors/InputIcons/Definitions/IconElement.cs @@ -0,0 +1,86 @@ + +using Godot; +using System.Collections.Generic; + +namespace Rokojori +{ + public class IconElement + { + } + + public class MissingIconElement:IconElement + { + + } + + public enum TextureIconOverlayAlignment + { + None, + Left, + Center, + Right + } + + public class TextureIconElement:IconElement + { + public Texture2D texture; + + public float borderLeft; + public float borderRight; + public float borderTop; + public float borderBottom; + + public float widthScale = 1; + + public float rotation = 0; + + public TextureIconOverlayAlignment alignment = TextureIconOverlayAlignment.None; + + public static TextureIconElement Create( Texture2D texture, float widthScale = 1, TextureIconOverlayAlignment alignment = TextureIconOverlayAlignment.None ) + { + var tie = new TextureIconElement(); + tie.texture = texture; + tie.widthScale = widthScale; + tie.alignment = alignment; + return tie; + } + + public void SetBorders( DefaultInputIconDefinition definition ) + { + borderLeft = definition.borderLeft; + borderRight = definition.borderRight; + borderTop = definition.borderTop; + borderBottom = definition.borderBottom; + } + + public bool hasBorders + { + get + { + return ( borderLeft + borderRight + borderTop + borderBottom ) > 0; + } + } + + + + } + + + public class LabelIconElement:IconElement + { + public LocalizedString locale; + + public float fontScale = 1; + public bool fontIsUpperCase = true; + + public static LabelIconElement Create( LocalizedString locale, float fontScale = 1, bool upperCase = true ) + { + var tie = new LabelIconElement(); + tie.locale = locale; + tie.fontScale = fontScale; + tie.fontIsUpperCase = upperCase; + return tie; + } + } + +} \ No newline at end of file diff --git a/Runtime/Sensors/InputIcons/Definitions/InputIconDefinition.cs b/Runtime/Sensors/InputIcons/Definitions/InputIconDefinition.cs new file mode 100644 index 0000000..5b5b77d --- /dev/null +++ b/Runtime/Sensors/InputIcons/Definitions/InputIconDefinition.cs @@ -0,0 +1,29 @@ + +using Godot; +using System.Collections.Generic; + +namespace Rokojori +{ + [Tool] + [GlobalClass, Icon("res://addons/rokojori_action_library/Icons/Sensor.svg")] + public partial class InputIconDefinition: Resource + { + public virtual bool HasIconFor( InputIcon icon ) + { + return false; + } + + public virtual int ResolveIcons( int offset, List icons ) + { + return -1; + } + + public virtual List GetIconElementsForIcon( InputIcon icon ) + { + return new List(); + } + + } + +} + diff --git a/Runtime/Sensors/InputIcons/Definitions/InputIconLocale.cs b/Runtime/Sensors/InputIcons/Definitions/InputIconLocale.cs new file mode 100644 index 0000000..f46e9e4 --- /dev/null +++ b/Runtime/Sensors/InputIcons/Definitions/InputIconLocale.cs @@ -0,0 +1,17 @@ + +using Godot; +using System.Collections.Generic; + +namespace Rokojori +{ + [Tool] + [GlobalClass, Icon("res://addons/rokojori_action_library/Icons/Sensor.svg")] + public partial class InputIconLocale: Resource + { + [Export] + public InputIcon icon; + + [Export] + public LocalizedString locale; + } +} \ No newline at end of file diff --git a/Runtime/Sensors/InputIcons/Definitions/MouseInputIconDefinition.cs b/Runtime/Sensors/InputIcons/Definitions/MouseInputIconDefinition.cs new file mode 100644 index 0000000..ca5b1a4 --- /dev/null +++ b/Runtime/Sensors/InputIcons/Definitions/MouseInputIconDefinition.cs @@ -0,0 +1,105 @@ + +using Godot; +using System.Collections.Generic; + +namespace Rokojori +{ + [Tool] + [GlobalClass, Icon("res://addons/rokojori_action_library/Icons/Sensor.svg")] + public partial class MouseInputIconDefinition: InputIconDefinition + { + [Export] + public Texture2D leftButtonTexture; + + [Export] + public Texture2D middleButtonTexture; + + [Export] + public Texture2D rightButtonTexture; + + [Export] + public Texture2D wheelUpTexture; + + [Export] + public Texture2D wheelDownTexture; + + [Export] + public Texture2D wheelLeftTexture; + + [Export] + public Texture2D wheelRightTexture; + + + public override List GetIconElementsForIcon( InputIcon icon ) + { + var mouseIcon = icon as MouseInputIcon; + + if ( mouseIcon == null ) + { + return null; + } + + var list = new List(); + + var button = mouseIcon.button; + + Texture2D texture = null; + + + if ( MouseButton.Left == button ) + { + texture = leftButtonTexture; + } + else if ( MouseButton.Middle == button ) + { + texture = middleButtonTexture; + } + else if ( MouseButton.Right == button ) + { + texture = rightButtonTexture; + } + else if ( MouseButton.WheelUp == button ) + { + texture = wheelUpTexture; + } + else if ( MouseButton.WheelDown == button ) + { + texture = wheelDownTexture; + } + else if ( MouseButton.WheelLeft == button ) + { + texture = wheelLeftTexture; + } + else if ( MouseButton.WheelRight == button ) + { + texture = wheelRightTexture; + } + + if ( texture == null ) + { + list.Add( new MissingIconElement() ); + } + else + { + list.Add( TextureIconElement.Create( texture ) ); + } + + return list; + } + + public override bool HasIconFor( InputIcon icon ) + { + var mouseIcon = icon as MouseInputIcon; + + if ( mouseIcon == null ) + { + return false; + } + + var list = GetIconElementsForIcon( icon ); + return list != null && list.Count == 1 && ! ( list[ 0 ] is MissingIconElement ); + } + + + } +} \ No newline at end of file diff --git a/Runtime/Sensors/InputIcons/Graphics/GamePad-Axis-Background.svg b/Runtime/Sensors/InputIcons/Graphics/GamePad-Axis-Background.svg new file mode 100644 index 0000000..fca0dc5 --- /dev/null +++ b/Runtime/Sensors/InputIcons/Graphics/GamePad-Axis-Background.svg @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/Runtime/Sensors/InputIcons/Graphics/GamePad-Axis-Background.svg.import b/Runtime/Sensors/InputIcons/Graphics/GamePad-Axis-Background.svg.import new file mode 100644 index 0000000..907be92 --- /dev/null +++ b/Runtime/Sensors/InputIcons/Graphics/GamePad-Axis-Background.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cb8ldiej8234h" +path="res://.godot/imported/GamePad-Axis-Background.svg-b018ae62e7a4eebc49a501c2660e69a8.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/rokojori_action_library/Runtime/Sensors/InputIcons/Graphics/GamePad-Axis-Background.svg" +dest_files=["res://.godot/imported/GamePad-Axis-Background.svg-b018ae62e7a4eebc49a501c2660e69a8.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/Runtime/Sensors/InputIcons/Graphics/GamePad-Axis-Left + Right.svg b/Runtime/Sensors/InputIcons/Graphics/GamePad-Axis-Left + Right.svg new file mode 100644 index 0000000..7031b77 --- /dev/null +++ b/Runtime/Sensors/InputIcons/Graphics/GamePad-Axis-Left + Right.svg @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Runtime/Sensors/InputIcons/Graphics/GamePad-Axis-Left + Right.svg.import b/Runtime/Sensors/InputIcons/Graphics/GamePad-Axis-Left + Right.svg.import new file mode 100644 index 0000000..ac58c76 --- /dev/null +++ b/Runtime/Sensors/InputIcons/Graphics/GamePad-Axis-Left + Right.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://6fkkrsbdjdf" +path="res://.godot/imported/GamePad-Axis-Left + Right.svg-b8527ae0a49506ce1fcc78771ab4d4d6.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/rokojori_action_library/Runtime/Sensors/InputIcons/Graphics/GamePad-Axis-Left + Right.svg" +dest_files=["res://.godot/imported/GamePad-Axis-Left + Right.svg-b8527ae0a49506ce1fcc78771ab4d4d6.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/Runtime/Sensors/InputIcons/Graphics/GamePad-Axis-Pressed.svg b/Runtime/Sensors/InputIcons/Graphics/GamePad-Axis-Pressed.svg new file mode 100644 index 0000000..53fbfb0 --- /dev/null +++ b/Runtime/Sensors/InputIcons/Graphics/GamePad-Axis-Pressed.svg @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/Runtime/Sensors/InputIcons/Graphics/GamePad-Axis-Pressed.svg.import b/Runtime/Sensors/InputIcons/Graphics/GamePad-Axis-Pressed.svg.import new file mode 100644 index 0000000..ac85d0e --- /dev/null +++ b/Runtime/Sensors/InputIcons/Graphics/GamePad-Axis-Pressed.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://ddfvjmi7sva6f" +path="res://.godot/imported/GamePad-Axis-Pressed.svg-ec6e7b829d0a337f3618233fc5700c5a.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/rokojori_action_library/Runtime/Sensors/InputIcons/Graphics/GamePad-Axis-Pressed.svg" +dest_files=["res://.godot/imported/GamePad-Axis-Pressed.svg-ec6e7b829d0a337f3618233fc5700c5a.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/Runtime/Sensors/InputIcons/Graphics/GamePad-Axis-Up + Down.svg b/Runtime/Sensors/InputIcons/Graphics/GamePad-Axis-Up + Down.svg new file mode 100644 index 0000000..6743bc9 --- /dev/null +++ b/Runtime/Sensors/InputIcons/Graphics/GamePad-Axis-Up + Down.svg @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Runtime/Sensors/InputIcons/Graphics/GamePad-Axis-Up + Down.svg.import b/Runtime/Sensors/InputIcons/Graphics/GamePad-Axis-Up + Down.svg.import new file mode 100644 index 0000000..24dc373 --- /dev/null +++ b/Runtime/Sensors/InputIcons/Graphics/GamePad-Axis-Up + Down.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bih02uuga3j2u" +path="res://.godot/imported/GamePad-Axis-Up + Down.svg-bfc4f86d39b6afa439f4f9daf92ade6a.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/rokojori_action_library/Runtime/Sensors/InputIcons/Graphics/GamePad-Axis-Up + Down.svg" +dest_files=["res://.godot/imported/GamePad-Axis-Up + Down.svg-bfc4f86d39b6afa439f4f9daf92ade6a.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/Runtime/Sensors/InputIcons/Graphics/GamePad-Axis-Up.svg b/Runtime/Sensors/InputIcons/Graphics/GamePad-Axis-Up.svg new file mode 100644 index 0000000..ea53494 --- /dev/null +++ b/Runtime/Sensors/InputIcons/Graphics/GamePad-Axis-Up.svg @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/Runtime/Sensors/InputIcons/Graphics/GamePad-Axis-Up.svg.import b/Runtime/Sensors/InputIcons/Graphics/GamePad-Axis-Up.svg.import new file mode 100644 index 0000000..8edae74 --- /dev/null +++ b/Runtime/Sensors/InputIcons/Graphics/GamePad-Axis-Up.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bajhvs0qnuj5q" +path="res://.godot/imported/GamePad-Axis-Up.svg-7180da91f8b02e4246a73bcc062865ba.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/rokojori_action_library/Runtime/Sensors/InputIcons/Graphics/GamePad-Axis-Up.svg" +dest_files=["res://.godot/imported/GamePad-Axis-Up.svg-7180da91f8b02e4246a73bcc062865ba.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/Runtime/Sensors/InputIcons/Graphics/GamePad-DPad-Background.svg b/Runtime/Sensors/InputIcons/Graphics/GamePad-DPad-Background.svg new file mode 100644 index 0000000..e77f979 --- /dev/null +++ b/Runtime/Sensors/InputIcons/Graphics/GamePad-DPad-Background.svg @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Runtime/Sensors/InputIcons/Graphics/GamePad-DPad-Background.svg.import b/Runtime/Sensors/InputIcons/Graphics/GamePad-DPad-Background.svg.import new file mode 100644 index 0000000..68f77b2 --- /dev/null +++ b/Runtime/Sensors/InputIcons/Graphics/GamePad-DPad-Background.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://eki8sp0x0gmf" +path="res://.godot/imported/GamePad-DPad-Background.svg-178c2d0245821ea212a2e894f6be5266.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/rokojori_action_library/Runtime/Sensors/InputIcons/Graphics/GamePad-DPad-Background.svg" +dest_files=["res://.godot/imported/GamePad-DPad-Background.svg-178c2d0245821ea212a2e894f6be5266.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/Runtime/Sensors/InputIcons/Graphics/GamePad-DPad-Left + Right.svg b/Runtime/Sensors/InputIcons/Graphics/GamePad-DPad-Left + Right.svg new file mode 100644 index 0000000..0405fcc --- /dev/null +++ b/Runtime/Sensors/InputIcons/Graphics/GamePad-DPad-Left + Right.svg @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Runtime/Sensors/InputIcons/Graphics/GamePad-DPad-Left + Right.svg.import b/Runtime/Sensors/InputIcons/Graphics/GamePad-DPad-Left + Right.svg.import new file mode 100644 index 0000000..23d470c --- /dev/null +++ b/Runtime/Sensors/InputIcons/Graphics/GamePad-DPad-Left + Right.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://ct3k2tds4d26" +path="res://.godot/imported/GamePad-DPad-Left + Right.svg-f9f881c8150d9fed3b8b560ae4520681.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/rokojori_action_library/Runtime/Sensors/InputIcons/Graphics/GamePad-DPad-Left + Right.svg" +dest_files=["res://.godot/imported/GamePad-DPad-Left + Right.svg-f9f881c8150d9fed3b8b560ae4520681.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/Runtime/Sensors/InputIcons/Graphics/GamePad-DPad-Up + Down.svg b/Runtime/Sensors/InputIcons/Graphics/GamePad-DPad-Up + Down.svg new file mode 100644 index 0000000..181bfc8 --- /dev/null +++ b/Runtime/Sensors/InputIcons/Graphics/GamePad-DPad-Up + Down.svg @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Runtime/Sensors/InputIcons/Graphics/GamePad-DPad-Up + Down.svg.import b/Runtime/Sensors/InputIcons/Graphics/GamePad-DPad-Up + Down.svg.import new file mode 100644 index 0000000..451410f --- /dev/null +++ b/Runtime/Sensors/InputIcons/Graphics/GamePad-DPad-Up + Down.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bip5s0jfo5ddm" +path="res://.godot/imported/GamePad-DPad-Up + Down.svg-249b18f4f4b74a86f173f5b80a429a2c.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/rokojori_action_library/Runtime/Sensors/InputIcons/Graphics/GamePad-DPad-Up + Down.svg" +dest_files=["res://.godot/imported/GamePad-DPad-Up + Down.svg-249b18f4f4b74a86f173f5b80a429a2c.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/Runtime/Sensors/InputIcons/Graphics/GamePad-DPad-Up.svg b/Runtime/Sensors/InputIcons/Graphics/GamePad-DPad-Up.svg new file mode 100644 index 0000000..8c50d5a --- /dev/null +++ b/Runtime/Sensors/InputIcons/Graphics/GamePad-DPad-Up.svg @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Runtime/Sensors/InputIcons/Graphics/GamePad-DPad-Up.svg.import b/Runtime/Sensors/InputIcons/Graphics/GamePad-DPad-Up.svg.import new file mode 100644 index 0000000..e1d9d10 --- /dev/null +++ b/Runtime/Sensors/InputIcons/Graphics/GamePad-DPad-Up.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://clg28ph2pawvq" +path="res://.godot/imported/GamePad-DPad-Up.svg-88b76b15bcaba72455d2e57e20905e22.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/rokojori_action_library/Runtime/Sensors/InputIcons/Graphics/GamePad-DPad-Up.svg" +dest_files=["res://.godot/imported/GamePad-DPad-Up.svg-88b76b15bcaba72455d2e57e20905e22.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/Runtime/Sensors/InputIcons/Graphics/GamePad-Left-Shoulder-Button.svg b/Runtime/Sensors/InputIcons/Graphics/GamePad-Left-Shoulder-Button.svg new file mode 100644 index 0000000..200f2b6 --- /dev/null +++ b/Runtime/Sensors/InputIcons/Graphics/GamePad-Left-Shoulder-Button.svg @@ -0,0 +1,52 @@ + + + + diff --git a/Runtime/Sensors/InputIcons/Graphics/GamePad-Left-Shoulder-Button.svg.import b/Runtime/Sensors/InputIcons/Graphics/GamePad-Left-Shoulder-Button.svg.import new file mode 100644 index 0000000..8d69195 --- /dev/null +++ b/Runtime/Sensors/InputIcons/Graphics/GamePad-Left-Shoulder-Button.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dxwnbh3a3fy8w" +path="res://.godot/imported/GamePad-Left-Shoulder-Button.svg-861d2a6e9d5a4a75dad2a75bf21b945a.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/rokojori_action_library/Runtime/Sensors/InputIcons/Graphics/GamePad-Left-Shoulder-Button.svg" +dest_files=["res://.godot/imported/GamePad-Left-Shoulder-Button.svg-861d2a6e9d5a4a75dad2a75bf21b945a.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/Runtime/Sensors/InputIcons/Graphics/GamePad-MainButton.svg b/Runtime/Sensors/InputIcons/Graphics/GamePad-MainButton.svg new file mode 100644 index 0000000..87a331c --- /dev/null +++ b/Runtime/Sensors/InputIcons/Graphics/GamePad-MainButton.svg @@ -0,0 +1,53 @@ + + + + diff --git a/Runtime/Sensors/InputIcons/Graphics/GamePad-MainButton.svg.import b/Runtime/Sensors/InputIcons/Graphics/GamePad-MainButton.svg.import new file mode 100644 index 0000000..0d2ea84 --- /dev/null +++ b/Runtime/Sensors/InputIcons/Graphics/GamePad-MainButton.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bgi8cbw57gka0" +path="res://.godot/imported/GamePad-MainButton.svg-6e8af81bd24219cce6491f200a2f647b.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/rokojori_action_library/Runtime/Sensors/InputIcons/Graphics/GamePad-MainButton.svg" +dest_files=["res://.godot/imported/GamePad-MainButton.svg-6e8af81bd24219cce6491f200a2f647b.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/Runtime/Sensors/InputIcons/Graphics/GamePad-Right-Shoulder-Button.svg b/Runtime/Sensors/InputIcons/Graphics/GamePad-Right-Shoulder-Button.svg new file mode 100644 index 0000000..5db7c2b --- /dev/null +++ b/Runtime/Sensors/InputIcons/Graphics/GamePad-Right-Shoulder-Button.svg @@ -0,0 +1,52 @@ + + + + diff --git a/Runtime/Sensors/InputIcons/Graphics/GamePad-Right-Shoulder-Button.svg.import b/Runtime/Sensors/InputIcons/Graphics/GamePad-Right-Shoulder-Button.svg.import new file mode 100644 index 0000000..1a4b46b --- /dev/null +++ b/Runtime/Sensors/InputIcons/Graphics/GamePad-Right-Shoulder-Button.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://b2123dcu46oy0" +path="res://.godot/imported/GamePad-Right-Shoulder-Button.svg-748f2a59a568dcee0c9497fabc5acd67.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/rokojori_action_library/Runtime/Sensors/InputIcons/Graphics/GamePad-Right-Shoulder-Button.svg" +dest_files=["res://.godot/imported/GamePad-Right-Shoulder-Button.svg-748f2a59a568dcee0c9497fabc5acd67.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/Runtime/Sensors/InputIcons/Graphics/Keyboard-EnterKey.svg b/Runtime/Sensors/InputIcons/Graphics/Keyboard-EnterKey.svg new file mode 100644 index 0000000..dc9063b --- /dev/null +++ b/Runtime/Sensors/InputIcons/Graphics/Keyboard-EnterKey.svg @@ -0,0 +1,85 @@ + + + + diff --git a/Runtime/Sensors/InputIcons/Graphics/Keyboard-EnterKey.svg.import b/Runtime/Sensors/InputIcons/Graphics/Keyboard-EnterKey.svg.import new file mode 100644 index 0000000..9fe7cd3 --- /dev/null +++ b/Runtime/Sensors/InputIcons/Graphics/Keyboard-EnterKey.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bmtwa1p6j1tu8" +path="res://.godot/imported/Keyboard-EnterKey.svg-df0c9a28f7bf6eef40bef1b5f9a4c720.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/rokojori_action_library/Runtime/Sensors/InputIcons/Graphics/Keyboard-EnterKey.svg" +dest_files=["res://.godot/imported/Keyboard-EnterKey.svg-df0c9a28f7bf6eef40bef1b5f9a4c720.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/Runtime/Sensors/InputIcons/Graphics/Keyboard-Indicator.svg b/Runtime/Sensors/InputIcons/Graphics/Keyboard-Indicator.svg new file mode 100644 index 0000000..99e1b53 --- /dev/null +++ b/Runtime/Sensors/InputIcons/Graphics/Keyboard-Indicator.svg @@ -0,0 +1,53 @@ + + + + diff --git a/Runtime/Sensors/InputIcons/Graphics/Keyboard-Indicator.svg.import b/Runtime/Sensors/InputIcons/Graphics/Keyboard-Indicator.svg.import new file mode 100644 index 0000000..46c8ac0 --- /dev/null +++ b/Runtime/Sensors/InputIcons/Graphics/Keyboard-Indicator.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dg52t67wh6h54" +path="res://.godot/imported/Keyboard-Indicator.svg-25ac02782892c97b7da3cb2d5d368c2f.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/rokojori_action_library/Runtime/Sensors/InputIcons/Graphics/Keyboard-Indicator.svg" +dest_files=["res://.godot/imported/Keyboard-Indicator.svg-25ac02782892c97b7da3cb2d5d368c2f.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/Runtime/Sensors/InputIcons/Graphics/Keyboard-SpaceKey.svg b/Runtime/Sensors/InputIcons/Graphics/Keyboard-SpaceKey.svg new file mode 100644 index 0000000..a963f4c --- /dev/null +++ b/Runtime/Sensors/InputIcons/Graphics/Keyboard-SpaceKey.svg @@ -0,0 +1,68 @@ + + + + diff --git a/Runtime/Sensors/InputIcons/Graphics/Keyboard-SpaceKey.svg.import b/Runtime/Sensors/InputIcons/Graphics/Keyboard-SpaceKey.svg.import new file mode 100644 index 0000000..d97b860 --- /dev/null +++ b/Runtime/Sensors/InputIcons/Graphics/Keyboard-SpaceKey.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://1pfyxi7wifn8" +path="res://.godot/imported/Keyboard-SpaceKey.svg-5b109688b82a5136866467416f067c56.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/rokojori_action_library/Runtime/Sensors/InputIcons/Graphics/Keyboard-SpaceKey.svg" +dest_files=["res://.godot/imported/Keyboard-SpaceKey.svg-5b109688b82a5136866467416f067c56.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/Runtime/Sensors/InputIcons/Graphics/Keyboard.svg b/Runtime/Sensors/InputIcons/Graphics/Keyboard.svg new file mode 100644 index 0000000..a2aca75 --- /dev/null +++ b/Runtime/Sensors/InputIcons/Graphics/Keyboard.svg @@ -0,0 +1,61 @@ + + + + diff --git a/Runtime/Sensors/InputIcons/Graphics/Keyboard.svg.import b/Runtime/Sensors/InputIcons/Graphics/Keyboard.svg.import new file mode 100644 index 0000000..bfac839 --- /dev/null +++ b/Runtime/Sensors/InputIcons/Graphics/Keyboard.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://b73u16wm1h5gr" +path="res://.godot/imported/Keyboard.svg-a70d9c256bdc77fc346c117efc258c32.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/rokojori_action_library/Runtime/Sensors/InputIcons/Graphics/Keyboard.svg" +dest_files=["res://.godot/imported/Keyboard.svg-a70d9c256bdc77fc346c117efc258c32.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/Runtime/Sensors/InputIcons/Graphics/Mouse-Left Button.svg b/Runtime/Sensors/InputIcons/Graphics/Mouse-Left Button.svg new file mode 100644 index 0000000..f4bc643 --- /dev/null +++ b/Runtime/Sensors/InputIcons/Graphics/Mouse-Left Button.svg @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/Runtime/Sensors/InputIcons/Graphics/Mouse-Left Button.svg.import b/Runtime/Sensors/InputIcons/Graphics/Mouse-Left Button.svg.import new file mode 100644 index 0000000..46f52f8 --- /dev/null +++ b/Runtime/Sensors/InputIcons/Graphics/Mouse-Left Button.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://eqplg4ydtkpf" +path="res://.godot/imported/Mouse-Left Button.svg-31ddaaa05bab8c797fa3c94e83ea8851.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/rokojori_action_library/Runtime/Sensors/InputIcons/Graphics/Mouse-Left Button.svg" +dest_files=["res://.godot/imported/Mouse-Left Button.svg-31ddaaa05bab8c797fa3c94e83ea8851.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/Runtime/Sensors/InputIcons/Graphics/Mouse-Middle Button.svg b/Runtime/Sensors/InputIcons/Graphics/Mouse-Middle Button.svg new file mode 100644 index 0000000..48609ba --- /dev/null +++ b/Runtime/Sensors/InputIcons/Graphics/Mouse-Middle Button.svg @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/Runtime/Sensors/InputIcons/Graphics/Mouse-Middle Button.svg.import b/Runtime/Sensors/InputIcons/Graphics/Mouse-Middle Button.svg.import new file mode 100644 index 0000000..ee084a7 --- /dev/null +++ b/Runtime/Sensors/InputIcons/Graphics/Mouse-Middle Button.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dcb0bhq84rs77" +path="res://.godot/imported/Mouse-Middle Button.svg-a4aeeb1173df7e3f524df86add173f6a.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/rokojori_action_library/Runtime/Sensors/InputIcons/Graphics/Mouse-Middle Button.svg" +dest_files=["res://.godot/imported/Mouse-Middle Button.svg-a4aeeb1173df7e3f524df86add173f6a.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/Runtime/Sensors/InputIcons/Graphics/Mouse-Right Button.svg b/Runtime/Sensors/InputIcons/Graphics/Mouse-Right Button.svg new file mode 100644 index 0000000..8059c0e --- /dev/null +++ b/Runtime/Sensors/InputIcons/Graphics/Mouse-Right Button.svg @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/Runtime/Sensors/InputIcons/Graphics/Mouse-Right Button.svg.import b/Runtime/Sensors/InputIcons/Graphics/Mouse-Right Button.svg.import new file mode 100644 index 0000000..738c3c5 --- /dev/null +++ b/Runtime/Sensors/InputIcons/Graphics/Mouse-Right Button.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://d3q5n6ocgar6w" +path="res://.godot/imported/Mouse-Right Button.svg-918a87670c33f9a9fde0189741225317.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/rokojori_action_library/Runtime/Sensors/InputIcons/Graphics/Mouse-Right Button.svg" +dest_files=["res://.godot/imported/Mouse-Right Button.svg-918a87670c33f9a9fde0189741225317.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/Runtime/Sensors/InputIcons/Graphics/Mouse-Wheel Down.svg b/Runtime/Sensors/InputIcons/Graphics/Mouse-Wheel Down.svg new file mode 100644 index 0000000..3c6845a --- /dev/null +++ b/Runtime/Sensors/InputIcons/Graphics/Mouse-Wheel Down.svg @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Runtime/Sensors/InputIcons/Graphics/Mouse-Wheel Down.svg.import b/Runtime/Sensors/InputIcons/Graphics/Mouse-Wheel Down.svg.import new file mode 100644 index 0000000..6d4d707 --- /dev/null +++ b/Runtime/Sensors/InputIcons/Graphics/Mouse-Wheel Down.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://b48h8j7flhwyb" +path="res://.godot/imported/Mouse-Wheel Down.svg-bedd1d77ac6b5c7b8def3e5350e9d059.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/rokojori_action_library/Runtime/Sensors/InputIcons/Graphics/Mouse-Wheel Down.svg" +dest_files=["res://.godot/imported/Mouse-Wheel Down.svg-bedd1d77ac6b5c7b8def3e5350e9d059.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/Runtime/Sensors/InputIcons/Graphics/Mouse-Wheel Up & Down.svg b/Runtime/Sensors/InputIcons/Graphics/Mouse-Wheel Up & Down.svg new file mode 100644 index 0000000..d8dd498 --- /dev/null +++ b/Runtime/Sensors/InputIcons/Graphics/Mouse-Wheel Up & Down.svg @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Runtime/Sensors/InputIcons/Graphics/Mouse-Wheel Up & Down.svg.import b/Runtime/Sensors/InputIcons/Graphics/Mouse-Wheel Up & Down.svg.import new file mode 100644 index 0000000..92226a7 --- /dev/null +++ b/Runtime/Sensors/InputIcons/Graphics/Mouse-Wheel Up & Down.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://chcls1g13v7it" +path="res://.godot/imported/Mouse-Wheel Up & Down.svg-a7428dcea335d364f2af12f2ff661037.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/rokojori_action_library/Runtime/Sensors/InputIcons/Graphics/Mouse-Wheel Up & Down.svg" +dest_files=["res://.godot/imported/Mouse-Wheel Up & Down.svg-a7428dcea335d364f2af12f2ff661037.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/Runtime/Sensors/InputIcons/Graphics/Mouse-Wheel Up.svg b/Runtime/Sensors/InputIcons/Graphics/Mouse-Wheel Up.svg new file mode 100644 index 0000000..77a6df7 --- /dev/null +++ b/Runtime/Sensors/InputIcons/Graphics/Mouse-Wheel Up.svg @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Runtime/Sensors/InputIcons/Graphics/Mouse-Wheel Up.svg.import b/Runtime/Sensors/InputIcons/Graphics/Mouse-Wheel Up.svg.import new file mode 100644 index 0000000..771a000 --- /dev/null +++ b/Runtime/Sensors/InputIcons/Graphics/Mouse-Wheel Up.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://de5ewtb72pmdu" +path="res://.godot/imported/Mouse-Wheel Up.svg-4a8f86710c89e72aec9c176585693fd7.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/rokojori_action_library/Runtime/Sensors/InputIcons/Graphics/Mouse-Wheel Up.svg" +dest_files=["res://.godot/imported/Mouse-Wheel Up.svg-4a8f86710c89e72aec9c176585693fd7.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/Runtime/Sensors/InputIcons/Graphics/_Combined/GamePad-Axis.svg b/Runtime/Sensors/InputIcons/Graphics/_Combined/GamePad-Axis.svg new file mode 100644 index 0000000..00d05b4 --- /dev/null +++ b/Runtime/Sensors/InputIcons/Graphics/_Combined/GamePad-Axis.svg @@ -0,0 +1,226 @@ + + + + diff --git a/Runtime/Sensors/InputIcons/Graphics/_Combined/GamePad-Axis.svg.import b/Runtime/Sensors/InputIcons/Graphics/_Combined/GamePad-Axis.svg.import new file mode 100644 index 0000000..3d556a3 --- /dev/null +++ b/Runtime/Sensors/InputIcons/Graphics/_Combined/GamePad-Axis.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cl0tuc8nwk31g" +path="res://.godot/imported/GamePad-Axis.svg-12c971ecda8ec77c46bf9c73d3687c94.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/rokojori_action_library/Runtime/Sensors/InputIcons/Graphics/_Combined/GamePad-Axis.svg" +dest_files=["res://.godot/imported/GamePad-Axis.svg-12c971ecda8ec77c46bf9c73d3687c94.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/Runtime/Sensors/InputIcons/Graphics/_Combined/GamePad-DPad.svg b/Runtime/Sensors/InputIcons/Graphics/_Combined/GamePad-DPad.svg new file mode 100644 index 0000000..96391a9 --- /dev/null +++ b/Runtime/Sensors/InputIcons/Graphics/_Combined/GamePad-DPad.svg @@ -0,0 +1,213 @@ + + + + diff --git a/Runtime/Sensors/InputIcons/Graphics/_Combined/GamePad-DPad.svg.import b/Runtime/Sensors/InputIcons/Graphics/_Combined/GamePad-DPad.svg.import new file mode 100644 index 0000000..e1b7dab --- /dev/null +++ b/Runtime/Sensors/InputIcons/Graphics/_Combined/GamePad-DPad.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://batw3cqxgbf61" +path="res://.godot/imported/GamePad-DPad.svg-b9f2b0701dd376673653efa44826a78a.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/rokojori_action_library/Runtime/Sensors/InputIcons/Graphics/_Combined/GamePad-DPad.svg" +dest_files=["res://.godot/imported/GamePad-DPad.svg-b9f2b0701dd376673653efa44826a78a.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/Runtime/Sensors/InputIcons/Graphics/_Combined/Mouse.svg b/Runtime/Sensors/InputIcons/Graphics/_Combined/Mouse.svg new file mode 100644 index 0000000..f1ba73f --- /dev/null +++ b/Runtime/Sensors/InputIcons/Graphics/_Combined/Mouse.svg @@ -0,0 +1,331 @@ + + + + diff --git a/Runtime/Sensors/InputIcons/Graphics/_Combined/Mouse.svg.import b/Runtime/Sensors/InputIcons/Graphics/_Combined/Mouse.svg.import new file mode 100644 index 0000000..d94870a --- /dev/null +++ b/Runtime/Sensors/InputIcons/Graphics/_Combined/Mouse.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dyvlvxcxc6n25" +path="res://.godot/imported/Mouse.svg-dda12d953145ea4771e0e41818a6abb2.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/rokojori_action_library/Runtime/Sensors/InputIcons/Graphics/_Combined/Mouse.svg" +dest_files=["res://.godot/imported/Mouse.svg-dda12d953145ea4771e0e41818a6abb2.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/Runtime/Sensors/InputIcons/InputIconsLibrary.cs b/Runtime/Sensors/InputIcons/InputIconsLibrary.cs new file mode 100644 index 0000000..a9997b2 --- /dev/null +++ b/Runtime/Sensors/InputIcons/InputIconsLibrary.cs @@ -0,0 +1,242 @@ + +using Godot; +using System.Collections.Generic; + +namespace Rokojori +{ + [Tool] + [GlobalClass, Icon("res://addons/rokojori_action_library/Icons/Sensor.svg")] + public partial class InputIconsLibrary: Resource + { + [Export] + public Font font; + + [Export] + public UINumber fontSize; + + [Export] + public float iconHeightInEm = 2f; + + [ExportGroup("Mouse & Keyboard")] + [Export] + public MouseInputIconDefinition mouseInputIcon; + + [Export] + public DefaultInputIconDefinition keyboardKeys; + + [Export] + public DefaultInputIconDefinition keyboardModifiers; + + [Export] + public DefaultInputIconDefinition keyboardSpaceKey; + + [Export] + public DefaultInputIconDefinition keyboardEnterKey; + + [ExportGroup("GamePad")] + + [Export] + public DefaultInputIconDefinition mainButtons; + + [Export] + public DefaultInputIconDefinition leftShouldersButtons; + + [Export] + public DefaultInputIconDefinition rightShouldersButtons; + + [Export] + public DirectionalInputIconDefinition digitalPad; + + [Export] + public DirectionalInputIconDefinition leftJoystick; + + [Export] + public DirectionalInputIconDefinition rightJoystick; + + + [ExportGroup("Touchpad")] + + [Export] + public DefaultInputIconDefinition touchClick; + + [Export] + public DefaultInputIconDefinition touchHold; + + [Export] + public DirectionalInputIconDefinition swipeGesture; + + + [ExportGroup("Combined")] + [Export] + public CombinedIconsDefinition combinedInputs; + + + [ExportGroup("Localization")] + [Export] + public InputIconLocale[] locales = new InputIconLocale[ 0 ]; + + public LocalizedString GetInputLabel( InputIcon icon ) + { + var index = Arrays.FindIndex( locales, il => il.icon.Equals( icon ) ); + + if ( index != -1 ) + { + return locales[ index ].locale; + } + + return icon.GetDefaultLocale(); + + } + + public List GetAllDefinitions() + { + var list = new List() + { + mouseInputIcon, keyboardKeys, + + mainButtons, leftShouldersButtons, rightShouldersButtons, + digitalPad, leftJoystick, rightJoystick, + + touchClick, touchHold, swipeGesture, + + combinedInputs + }; + + list = Lists.Filter( list, l => l != null ); + + return list; + } + + public List ResolveIcons( InputIcon[] icons ) + { + var list = new List(); + + for ( int i =0 ; i < icons.Length; i++ ) + { + var icon = icons[ i ]; + + if ( icon is SensorIcon sensorIcon ) + { + var sensor = sensorIcon.sensor; + + if ( sensor == null ) + { + continue; + } + + list.AddRange( sensor.GetInputIcons() ); + + } + else + { + list.Add( icon ); + } + + } + + var definitions = GetAllDefinitions(); + + var resolvedList = new List(); + + for ( int i = 0; i < list.Count; i++ ) + { + var d = definitions.Find( d => d.ResolveIcons( i, list ) != -1 ); + + if ( d == null ) + { + resolvedList.Add( list[ i ] ); + } + else + { + var resolvedIcon = new CombinedIcon(); + var length = d.ResolveIcons( i, list ); + resolvedIcon.icons = list.GetRange( i, length ).ToArray(); + i += length - 1; + + resolvedList.Add( resolvedIcon ); + } + } + + return resolvedList; + } + + public InputIconDefinition GetInputIconDefinition( InputIcon icon ) + { + if ( icon is MouseInputIcon ) + { + return mouseInputIcon; + } + else if ( icon is KeyIcon keyIcon) + { + if ( Key.Enter == keyIcon.key ) + { + return keyboardEnterKey; + } + + if ( Key.Space == keyIcon.key ) + { + return keyboardSpaceKey; + } + + if ( KeySensor.IsModifierKey( keyIcon.key ) ) + { + return keyboardModifiers; + } + + return keyboardKeys; + } + else if ( icon is GamePadButtonIcon gpButtonIcon ) + { + if ( JoyButton.LeftShoulder == gpButtonIcon.button ) + { + return leftShouldersButtons; + } + + if ( JoyButton.RightShoulder == gpButtonIcon.button ) + { + return rightShouldersButtons; + } + + if ( JoyButton.DpadLeft == gpButtonIcon.button || + JoyButton.DpadRight == gpButtonIcon.button || + JoyButton.DpadUp == gpButtonIcon.button || + JoyButton.DpadDown == gpButtonIcon.button + ) + { + return digitalPad; + } + + return mainButtons; + + } + else if ( icon is GamePadAxisIcon gpAxisIcon) + { + if ( JoyAxis.LeftX == gpAxisIcon.axis || JoyAxis.LeftY == gpAxisIcon.axis ) + { + return leftJoystick; + } + + if ( JoyAxis.RightX == gpAxisIcon.axis || JoyAxis.RightY == gpAxisIcon.axis ) + { + return rightJoystick; + } + + if ( JoyAxis.TriggerLeft == gpAxisIcon.axis ) + { + return leftShouldersButtons; + } + + if ( JoyAxis.TriggerRight == gpAxisIcon.axis ) + { + return rightShouldersButtons; + } + } + + + var definitions = GetAllDefinitions(); + + return definitions.Find( d => d.HasIconFor( icon ) ); + } + + } +} \ No newline at end of file diff --git a/Runtime/Sensors/InputIcons/Types/CombinedIcon.cs b/Runtime/Sensors/InputIcons/Types/CombinedIcon.cs new file mode 100644 index 0000000..f3a3932 --- /dev/null +++ b/Runtime/Sensors/InputIcons/Types/CombinedIcon.cs @@ -0,0 +1,35 @@ + +using Godot; + + +namespace Rokojori +{ + public enum CombineIconOrderMode + { + Forward_Only, + Forward_And_Reverse, + Any_Order + } + + [Tool] + [GlobalClass, Icon("res://addons/rokojori_action_library/Icons/Sensor.svg")] + public partial class CombinedIcon:InputIcon + { + [Export] + public InputIcon[] icons = new InputIcon[ 0 ]; + + + public override bool Equals( object obj ) + { + var value = obj as CombinedIcon; + + if ( value == null ) + { + return false; + } + + return Arrays.AreEntriesEqual( icons, value.icons ); + } + } +} + \ No newline at end of file diff --git a/Runtime/Sensors/InputIcons/Types/GamePadAxisIcon.cs b/Runtime/Sensors/InputIcons/Types/GamePadAxisIcon.cs new file mode 100644 index 0000000..5f23146 --- /dev/null +++ b/Runtime/Sensors/InputIcons/Types/GamePadAxisIcon.cs @@ -0,0 +1,47 @@ + +using Godot; + + +namespace Rokojori +{ + [Tool] + [GlobalClass, Icon("res://addons/rokojori_action_library/Icons/Sensor.svg")] + public partial class GamePadAxisIcon:InputIcon + { + [Export] + public JoyAxis axis; + + [Export] + public GamePadAxisType type; + + + public override LocalizedString GetDefaultLocale() + { + return LocaleText.Create( "Axis " + axis + " " + type ); + } + + public override LocalizedString GetIconLocale() + { + return LocaleText.Create( GamePadIconSymbolsMap.GetSymbol( axis, type ) ); + } + + public override bool Equals( object obj ) + { + var value = obj as GamePadAxisIcon; + + if ( value == null ) + { + return false; + } + + return value.axis == axis && value.type == type; + } + + public override string ToString() + { + return "GamePadAxisIcon{ " + axis + " " + type + " }"; + } + + } +} + \ No newline at end of file diff --git a/Runtime/Sensors/InputIcons/Types/GamePadButtonIcon.cs b/Runtime/Sensors/InputIcons/Types/GamePadButtonIcon.cs new file mode 100644 index 0000000..f0bb79a --- /dev/null +++ b/Runtime/Sensors/InputIcons/Types/GamePadButtonIcon.cs @@ -0,0 +1,43 @@ + +using Godot; + + +namespace Rokojori +{ + [Tool] + [GlobalClass, Icon("res://addons/rokojori_action_library/Icons/Sensor.svg")] + public partial class GamePadButtonIcon:InputIcon + { + [Export] + public JoyButton button; + + public override LocalizedString GetDefaultLocale() + { + return LocaleText.Create( "Button " + button ); + } + + + public override LocalizedString GetIconLocale() + { + return LocaleText.Create( GamePadIconSymbolsMap.GetSymbol( button ) ); + } + + public override bool Equals( object obj ) + { + var value = obj as GamePadButtonIcon; + + if ( value == null ) + { + return false; + } + + return value.button == button; + } + + public override string ToString() + { + return "GamePadButtonIcon{ " + button + " }"; + } + } +} + \ No newline at end of file diff --git a/Runtime/Sensors/InputIcons/Types/GamePadButtonIconSymbolsMap.cs b/Runtime/Sensors/InputIcons/Types/GamePadButtonIconSymbolsMap.cs new file mode 100644 index 0000000..27a89a2 --- /dev/null +++ b/Runtime/Sensors/InputIcons/Types/GamePadButtonIconSymbolsMap.cs @@ -0,0 +1,49 @@ + +using Godot; +using System.Collections.Generic; +using System; + +namespace Rokojori +{ + public class GamePadIconSymbolsMap + { + public static string GetSymbol( JoyButton button ) + { + if ( ! _buttonIconSymbols.ContainsKey( button ) ) + { + return ""; + } + + return _buttonIconSymbols[ button ]; + } + + static Dictionary _buttonIconSymbols = new Dictionary() + { + { JoyButton.A, "A" }, { JoyButton.B, "B" },{ JoyButton.X, "X" },{ JoyButton.Y, "Y" }, + { JoyButton.LeftStick, "LS" }, { JoyButton.RightStick, "RS" }, + { JoyButton.LeftShoulder, "LB" },{ JoyButton.RightShoulder, "RB" } + }; + + public static string GetSymbol( JoyAxis axis, GamePadAxisType axisType ) + { + if ( ! _axisIconSymbols.ContainsKey( axis ) ) + { + return ""; + } + + var tuple = _axisIconSymbols[ axis ]; + + return GamePadAxisType.Negative == axisType ? tuple.Item1 : tuple.Item2; + } + + static Dictionary> _axisIconSymbols = new Dictionary>() + { + { JoyAxis.LeftX, Tuple.Create( "L🠜","L🠞" ) }, + { JoyAxis.RightX, Tuple.Create( "R🠜","R🠞") }, + { JoyAxis.LeftY, Tuple.Create( "L🠝","L🠟") }, + { JoyAxis.RightY,Tuple.Create( "R🠝","R🠟")}, + { JoyAxis.TriggerLeft, Tuple.Create( "LT","LT")}, + { JoyAxis.TriggerRight,Tuple.Create( "RT","RT")}, + }; + } +} \ No newline at end of file diff --git a/Runtime/Sensors/InputIcons/Types/InputIcon.cs b/Runtime/Sensors/InputIcons/Types/InputIcon.cs new file mode 100644 index 0000000..8ddeb6b --- /dev/null +++ b/Runtime/Sensors/InputIcons/Types/InputIcon.cs @@ -0,0 +1,22 @@ + +using Godot; + + +namespace Rokojori +{ + [Tool] + [GlobalClass, Icon("res://addons/rokojori_action_library/Icons/Sensor.svg")] + public partial class InputIcon:Resource + { + public virtual LocalizedString GetDefaultLocale() + { + return LocaleText.Create( "Unknown Input" ); + } + + public virtual LocalizedString GetIconLocale() + { + return LocaleText.Create( "--" ); + } + } +} + \ No newline at end of file diff --git a/Runtime/Sensors/InputIcons/Types/KeyIcon.cs b/Runtime/Sensors/InputIcons/Types/KeyIcon.cs new file mode 100644 index 0000000..24cae6c --- /dev/null +++ b/Runtime/Sensors/InputIcons/Types/KeyIcon.cs @@ -0,0 +1,45 @@ + +using Godot; +using System.Collections.Generic; + +namespace Rokojori +{ + [Tool] + [GlobalClass, Icon("res://addons/rokojori_action_library/Icons/Sensor.svg")] + public partial class KeyIcon:InputIcon + { + [Export] + public Key key; + + [Export] + public KeyLocation location = KeyLocation.Unspecified; + + public override LocalizedString GetDefaultLocale() + { + return LocaleText.Create( "Key " + key ); + } + + public override LocalizedString GetIconLocale() + { + return LocaleText.Create( KeyIconSymbolsMap.GetSymbol( key ) ); + } + + public override bool Equals( object obj ) + { + var value = obj as KeyIcon; + + if ( value == null ) + { + return false; + } + + return value.key == key && value.location == location; + } + + public override string ToString() + { + return "KeyIcon{ " + key + "@" + location + " }"; + } + } +} + \ No newline at end of file diff --git a/Runtime/Sensors/InputIcons/Types/KeyIconSymbolsMap.cs b/Runtime/Sensors/InputIcons/Types/KeyIconSymbolsMap.cs new file mode 100644 index 0000000..5144c45 --- /dev/null +++ b/Runtime/Sensors/InputIcons/Types/KeyIconSymbolsMap.cs @@ -0,0 +1,218 @@ + +using Godot; +using System.Collections.Generic; + +namespace Rokojori +{ + public class KeyIconSymbolsMap + { + public static string GetSymbol( Key key ) + { + if ( ! _keyIconSymbols.ContainsKey( key ) ) + { + return ""; + } + + return _keyIconSymbols[ key ]; + } + + // Created from Key + // Matcher: // (.+)\skey.+\n\s+(\w+) = \d+ + // Replacement: { Key.$2, "$1" } + + static Dictionary _keyIconSymbols = new Dictionary() + { + + { Key.Space, " " }, + { Key.Exclam, "!" }, + { Key.Quotedbl, "\"" }, + { Key.Numbersign, "#" }, + { Key.Dollar, "$" }, + { Key.Percent, "%" }, + { Key.Ampersand, "&" }, + { Key.Apostrophe, "'" }, + { Key.Parenleft, "(" }, + { Key.Parenright, ")" }, + { Key.Asterisk, "*" }, + { Key.Plus, "+" }, + { Key.Comma, "," }, + { Key.Minus, "-" }, + { Key.Period, "." }, + { Key.Slash, "/" }, + { Key.Key0, "0" }, + { Key.Key1, "1" }, + { Key.Key2, "2" }, + { Key.Key3, "3" }, + { Key.Key4, "4" }, + { Key.Key5, "5" }, + { Key.Key6, "6" }, + { Key.Key7, "7" }, + { Key.Key8, "8" }, + { Key.Key9, "9" }, + { Key.Colon, ":" }, + { Key.Semicolon, ";" }, + { Key.Less, "<" }, + { Key.Equal, "=" }, + { Key.Greater, ">" }, + { Key.Question, "?" }, + { Key.At, "@" }, + { Key.A, "A" }, + { Key.B, "B" }, + { Key.C, "C" }, + { Key.D, "D" }, + { Key.E, "E" }, + { Key.F, "F" }, + { Key.G, "G" }, + { Key.H, "H" }, + { Key.I, "I" }, + { Key.J, "J" }, + { Key.K, "K" }, + { Key.L, "L" }, + { Key.M, "M" }, + { Key.N, "N" }, + { Key.O, "O" }, + { Key.P, "P" }, + { Key.Q, "Q" }, + { Key.R, "R" }, + { Key.S, "S" }, + { Key.T, "T" }, + { Key.U, "U" }, + { Key.V, "V" }, + { Key.W, "W" }, + { Key.X, "X" }, + { Key.Y, "Y" }, + { Key.Z, "Z" }, + { Key.Bracketleft, "[" }, + { Key.Backslash, "\\" }, + { Key.Bracketright, "]" }, + { Key.Asciicircum, "^" }, + { Key.Underscore, "_" }, + { Key.Quoteleft, "`" }, + { Key.Braceleft, "{" }, + { Key.Bar, "|" }, + { Key.Braceright, "}" }, + { Key.Asciitilde, "~" }, + { Key.Yen, "¥" }, + { Key.Section, "§" }, + { Key.Escape, "Esc" }, + { Key.Tab, "⇥" }, + { Key.Backtab, "⇤" }, + { Key.Backspace, "←" }, + { Key.Enter, "Return" }, + { Key.KpEnter, "Enter" }, + { Key.Insert, "Ins" }, + { Key.Delete, "Del" }, + { Key.Pause, "Pause" }, + { Key.Print, "Prnt" }, + { Key.Sysreq, "Sys" }, + { Key.Clear, "Clr" }, + { Key.Home, "Home" }, + { Key.End, "End" }, + { Key.Left, "◂" }, + { Key.Up, "▴" }, + { Key.Right, "▸" }, + { Key.Down, "▾" }, + { Key.Pageup, "PUp" }, + { Key.Pagedown, "PDwn" }, + { Key.Shift, "⇧" }, + { Key.Ctrl, "Ctrl" }, + { Key.Meta, "Meta" }, + { Key.Alt, "Alt" }, + { Key.Capslock, "⇩" }, + { Key.Numlock, "Num Lock" }, + { Key.Scrolllock, "Scroll Lock" }, + { Key.F1, "F1" }, + { Key.F2, "F2" }, + { Key.F3, "F3" }, + { Key.F4, "F4" }, + { Key.F5, "F5" }, + { Key.F6, "F6" }, + { Key.F7, "F7" }, + { Key.F8, "F8" }, + { Key.F9, "F9" }, + { Key.F10, "F10" }, + { Key.F11, "F11" }, + { Key.F12, "F12" }, + { Key.F13, "F13" }, + { Key.F14, "F14" }, + { Key.F15, "F15" }, + { Key.F16, "F16" }, + { Key.F17, "F17" }, + { Key.F18, "F18" }, + { Key.F19, "F19" }, + { Key.F20, "F20" }, + { Key.F21, "F21" }, + { Key.F22, "F22" }, + { Key.F23, "F23" }, + { Key.F24, "F24" }, + { Key.F25, "F25" }, + { Key.F26, "F26" }, + { Key.F27, "F27" }, + { Key.F28, "F28" }, + { Key.F29, "F29" }, + { Key.F30, "F30" }, + { Key.F31, "F31" }, + { Key.F32, "F32" }, + { Key.F33, "F33" }, + { Key.F34, "F34" }, + { Key.F35, "F35" }, + { Key.Menu, "Context menu" }, + { Key.Hyper, "Hyper" }, + { Key.Help, "Help" }, + { Key.Back, "Media back" }, + { Key.Forward, "Media forward" }, + { Key.Stop, "Media stop" }, + { Key.Refresh, "Media refresh" }, + { Key.Volumedown, "+" }, + { Key.Volumemute, "🔇" }, + { Key.Volumeup, "-" }, + { Key.Mediaplay, "Media play" }, + { Key.Mediastop, "Media stop" }, + { Key.Mediaprevious, "Previous song" }, + { Key.Medianext, "Next song" }, + { Key.Mediarecord, "Media record" }, + { Key.Homepage, "Home page" }, + { Key.Favorites, "Favorites" }, + { Key.Search, "Search" }, + { Key.Standby, "Standby" }, + { Key.Openurl, "Open URL / Launch Browser" }, + { Key.Launchmail, "Launch Mail" }, + { Key.Launchmedia, "Launch Media" }, + { Key.Launch0, "Launch Shortcut 0" }, + { Key.Launch1, "Launch Shortcut 1" }, + { Key.Launch2, "Launch Shortcut 2" }, + { Key.Launch3, "Launch Shortcut 3" }, + { Key.Launch4, "Launch Shortcut 4" }, + { Key.Launch5, "Launch Shortcut 5" }, + { Key.Launch6, "Launch Shortcut 6" }, + { Key.Launch7, "Launch Shortcut 7" }, + { Key.Launch8, "Launch Shortcut 8" }, + { Key.Launch9, "Launch Shortcut 9" }, + { Key.Launcha, "Launch Shortcut A" }, + { Key.Launchb, "Launch Shortcut B" }, + { Key.Launchc, "Launch Shortcut C" }, + { Key.Launchd, "Launch Shortcut D" }, + { Key.Launche, "Launch Shortcut E" }, + { Key.Launchf, "Launch Shortcut F" }, + { Key.Globe, "Globe" }, + { Key.Keyboard, "On-screen keyboard" }, + { Key.JisEisu, "英数" }, + { Key.JisKana, "かな" }, + { Key.KpMultiply, "*" }, + { Key.KpDivide, "/" }, + { Key.KpSubtract, "-" }, + { Key.KpPeriod, "." }, + { Key.KpAdd, "+" }, + { Key.Kp0, "0" }, + { Key.Kp1, "1" }, + { Key.Kp2, "2" }, + { Key.Kp3, "3" }, + { Key.Kp4, "4" }, + { Key.Kp5, "5" }, + { Key.Kp6, "6" }, + { Key.Kp7, "7" }, + { Key.Kp8, "8" }, + { Key.Kp9, "9" } + }; + } +} \ No newline at end of file diff --git a/Runtime/Sensors/InputIcons/Types/MouseInputIcon.cs b/Runtime/Sensors/InputIcons/Types/MouseInputIcon.cs new file mode 100644 index 0000000..1f1a383 --- /dev/null +++ b/Runtime/Sensors/InputIcons/Types/MouseInputIcon.cs @@ -0,0 +1,71 @@ + +using Godot; + + +namespace Rokojori +{ + [Tool] + [GlobalClass, Icon("res://addons/rokojori_action_library/Icons/Sensor.svg")] + public partial class MouseInputIcon:InputIcon + { + [Export] + public MouseButton button; + + public override LocalizedString GetDefaultLocale() + { + return LocaleText.Create( "Mouse " + button ); + } + + public override LocalizedString GetIconLocale() + { + if ( MouseButton.Left == button ) + { + return LocaleText.Create( "LMB" ); + } + else if ( MouseButton.Middle == button ) + { + return LocaleText.Create( "MMB" ); + } + else if ( MouseButton.Right == button ) + { + return LocaleText.Create( "RMB" ); + } + else if ( MouseButton.WheelUp == button ) + { + return LocaleText.Create( "MWU" ); + } + else if ( MouseButton.WheelDown == button ) + { + return LocaleText.Create( "MWD" ); + } + else if ( MouseButton.WheelLeft == button ) + { + return LocaleText.Create( "MWL" ); + } + else if ( MouseButton.WheelRight == button ) + { + return LocaleText.Create( "MWR" ); + } + + return GetDefaultLocale(); + } + + public override bool Equals( object obj ) + { + var value = obj as MouseInputIcon; + + if ( value == null ) + { + return false; + } + + return value.button == button; + } + + public override string ToString() + { + return "MouseInputIcon{ " + button + " }"; + } + } +} + \ No newline at end of file diff --git a/Runtime/Sensors/InputIcons/Types/SensorIcon.cs b/Runtime/Sensors/InputIcons/Types/SensorIcon.cs new file mode 100644 index 0000000..fac4797 --- /dev/null +++ b/Runtime/Sensors/InputIcons/Types/SensorIcon.cs @@ -0,0 +1,32 @@ + +using Godot; + + +namespace Rokojori +{ + [Tool] + [GlobalClass, Icon("res://addons/rokojori_action_library/Icons/Sensor.svg")] + public partial class SensorIcon:InputIcon + { + [Export] + public Sensor sensor; + + public override bool Equals( object obj ) + { + var value = obj as SensorIcon; + + if ( value == null ) + { + return false; + } + + return value.sensor == sensor; + } + + public override string ToString() + { + return "SensorIcon{ " + sensor + " }"; + } + } +} + \ No newline at end of file diff --git a/Runtime/Sensors/InputActionSensor.cs b/Runtime/Sensors/InputMapActionSensor.cs similarity index 71% rename from Runtime/Sensors/InputActionSensor.cs rename to Runtime/Sensors/InputMapActionSensor.cs index 8335580..1c3f238 100644 --- a/Runtime/Sensors/InputActionSensor.cs +++ b/Runtime/Sensors/InputMapActionSensor.cs @@ -6,7 +6,7 @@ namespace Rokojori { [Tool] [GlobalClass,Icon("res://addons/rokojori_action_library/Icons/Sensor.svg")] - public partial class InputActionSensor: Sensor + public partial class InputMapActionSensor: Sensor { [Export] public string inputActionName = ""; @@ -21,6 +21,10 @@ namespace Rokojori [Export] public PollMode pollMode = PollMode.Button; + public override string ToString() + { + return RJLog.GetInfo( this, inputActionName, pollMode ); + } protected override void UpdateValue() { @@ -37,6 +41,14 @@ namespace Rokojori SetFloatValue( Input.GetActionRawStrength( inputActionName ) ); } } + + [Export] + public InputIcon[] inputIcons = new InputIcon[ 0 ]; + + public override List GetInputIcons() + { + return Lists.From( inputIcons ); + } } } \ No newline at end of file diff --git a/Runtime/Sensors/KeySensor.cs b/Runtime/Sensors/KeySensor.cs index c3f3cf2..5dea8dd 100644 --- a/Runtime/Sensors/KeySensor.cs +++ b/Runtime/Sensors/KeySensor.cs @@ -1,6 +1,6 @@ using Godot; - +using System.Collections.Generic; namespace Rokojori { @@ -10,6 +10,9 @@ namespace Rokojori { [Export] public Key key; + + [Export] + public KeyLocation keyLocation = KeyLocation.Unspecified; [ExportGroup( "Modifiers")] [Export] @@ -34,6 +37,11 @@ namespace Rokojori float _lastInput = 0; + public override string ToString() + { + return RJLog.GetInfo( this, key, keyLocation, "Ctrl/Alt/Shift:" + ctrlHold + "/" + altHold + "/" + shiftHold ); + } + protected override void UpdateValue() { SetFloatValue( _lastInput ); @@ -43,6 +51,7 @@ namespace Rokojori { var keyEvent = ev as InputEventKey; + if ( keyEvent == null ) { return; @@ -53,6 +62,14 @@ namespace Rokojori return; } + if ( keyLocation != KeyLocation.Unspecified && keyEvent.Location != KeyLocation.Unspecified ) + { + if ( keyEvent.Location != keyLocation ) + { + return; + } + } + var checkModifiers = modifiersEnabled && ( ModifiersMode.Hold_Modifiers_All_The_Time == modifiersMode || @@ -83,9 +100,24 @@ namespace Rokojori _lastInput = keyEvent.IsPressed() ? 1 : 0; + UpdateSensorUsage(); + + } + public override List GetInputIcons() + { + var icon = new KeyIcon(); + icon.key = key; + + return new List(){ icon }; + } + + public static bool IsModifierKey( Key key ) + { + return Lists.IsOneOf( key, Key.Ctrl, Key.Alt, Key.Shift, Key.Meta ); + } } } \ No newline at end of file diff --git a/Runtime/Sensors/MouseButtonSensor.cs b/Runtime/Sensors/MouseButtonSensor.cs index bd258bc..a14bbb9 100644 --- a/Runtime/Sensors/MouseButtonSensor.cs +++ b/Runtime/Sensors/MouseButtonSensor.cs @@ -1,6 +1,6 @@ using Godot; - +using System.Collections.Generic; namespace Rokojori { @@ -34,6 +34,11 @@ namespace Rokojori float _lastInput = 0; + public override string ToString() + { + return RJLog.GetInfo( this, button, "Ctrl/Alt/Shift:" + ctrlHold + "/" + altHold + "/" + shiftHold ); + } + bool IsWheel() { @@ -105,9 +110,18 @@ namespace Rokojori _lastInput = isActive ? 1 : 0; + UpdateSensorUsage(); } + public override List GetInputIcons() + { + var icon = new MouseInputIcon(); + icon.button = button; + + return new List(){ icon }; + } + } } \ No newline at end of file diff --git a/Runtime/Sensors/MouseMotionDelta.cs b/Runtime/Sensors/MouseMotionDelta.cs index cbdbaa4..405f024 100644 --- a/Runtime/Sensors/MouseMotionDelta.cs +++ b/Runtime/Sensors/MouseMotionDelta.cs @@ -22,6 +22,11 @@ namespace Rokojori [Export] public float speedMultiply = 1; + public override string ToString() + { + return RJLog.GetInfo( this, motionType, speedMultiply ); + } + float _lastInput = 0; protected override void UpdateValue() @@ -62,6 +67,8 @@ namespace Rokojori // RJLog.Log( "Motion:", motionType, motion * speedMultiply ); _lastInput = motion * speedMultiply; + + UpdateSensorUsage(); } diff --git a/Runtime/Sensors/MouseScreenRelative.cs b/Runtime/Sensors/MouseScreenRelative.cs index ab97b93..17f2c55 100644 --- a/Runtime/Sensors/MouseScreenRelative.cs +++ b/Runtime/Sensors/MouseScreenRelative.cs @@ -26,6 +26,11 @@ namespace Rokojori SetFloatValue( _lastInput ); } + public override string ToString() + { + return RJLog.GetInfo( this, motionType ); + } + public void _Input( InputEvent ev ) { var mouseEvent = ev as InputEventMouseMotion ; diff --git a/Runtime/Sensors/Sensor.cs b/Runtime/Sensors/Sensor.cs index b0d3412..870b296 100644 --- a/Runtime/Sensors/Sensor.cs +++ b/Runtime/Sensors/Sensor.cs @@ -1,6 +1,6 @@ using Godot; - +using System.Collections.Generic; namespace Rokojori { @@ -8,6 +8,12 @@ namespace Rokojori [GlobalClass, Icon("res://addons/rokojori_action_library/Icons/Sensor.svg")] public partial class Sensor: Resource { + [Export] + public LocaleText name; + + [Export] + public LocaleText info; + [Export] public bool continous = false; @@ -66,6 +72,16 @@ namespace Rokojori _active = value > _activeTreshold; } + public virtual List GetInputIcons() + { + return new List(); + } + + protected void UpdateSensorUsage( int index = 0 ) + { + var sm = Unique.Get(); + sm.UpdateLastActiveDevice( this, index ); + } } } \ No newline at end of file diff --git a/Runtime/Sensors/SensorGroup.cs b/Runtime/Sensors/SensorGroup.cs index 89f4f2d..3c1df0e 100644 --- a/Runtime/Sensors/SensorGroup.cs +++ b/Runtime/Sensors/SensorGroup.cs @@ -9,6 +9,6 @@ namespace Rokojori public partial class SensorGroup:Resource { [Export] - public Sensor[] sensors; + public Sensor[] sensors = new Sensor[ 0 ]; } } \ No newline at end of file diff --git a/Runtime/Sensors/SensorManager.cs b/Runtime/Sensors/SensorManager.cs index 915dfda..d729b10 100644 --- a/Runtime/Sensors/SensorManager.cs +++ b/Runtime/Sensors/SensorManager.cs @@ -1,7 +1,7 @@ using Godot; using System.Collections.Generic; - +using System; namespace Rokojori { [Tool] @@ -12,25 +12,138 @@ namespace Rokojori public bool initializeOnReady = true; [Export] - public Sensor[] sensors; + public Sensor[] sensors = new Sensor[ 0 ]; [Export] - public SensorGroup[] sensorGroups; + public SensorGroup[] sensorGroups = new SensorGroup[ 0 ]; [Export] public bool processSensors = false; [Export] - public Node[] autoScanForSensors; - + public Node[] autoScanForSensors = new Node[ 0 ]; + [Export] + public bool separateMouseAndKeyboardTracking = false; + + [Export] + public Action onActiveDeviceChange; + public readonly EventSlot _onActiveDeviceChange = new EventSlot(); + + [ExportGroup("Read Only")] + [Export] + public SensorDevice[] deviceList = new SensorDevice[]{}; + + [Export] + public float[] deviceLastInputTimeStamp = new float[]{}; + + [ExportGroup("Testing")] + + [Export] + public SensorDevice testingLastActiveDevice; + + + + List runners = new List(); List inputers = new List(); Dictionary sensorToRunner = new Dictionary(); - + + + KeyboardDevice keyboardDevice = new KeyboardDevice(); + MouseDevice mouseDevice = new MouseDevice(); + GamePadDevice gamePadDevice = new GamePadDevice(); + MultiSensorDevice mouseKeyboardDevice = new MultiSensorDevice(); + + DateTime _startTime; + + + public SensorDevice lastActiveDevice + { + get + { + if ( testingLastActiveDevice != null ) + { + return testingLastActiveDevice; + } + + var highest = Lists.IndexOfHighestValue( Lists.From( deviceLastInputTimeStamp ), t => t ); + + if ( highest == -1 ) + { + return null; + } + + return deviceList[ highest ]; + } + + } + + void UpdateDevice( SensorDevice d ) + { + var lastActive = lastActiveDevice; + + var index = Arrays.IndexOf( deviceList, d ); + + if ( index == -1 ) + { + deviceList = Arrays.Add( deviceList, d ); + index = deviceList.Length - 1; + deviceLastInputTimeStamp = Arrays.Add( deviceLastInputTimeStamp, 0 ); + } + + deviceLastInputTimeStamp[ index ] = (float) ( DateTime.Now - _startTime ).TotalSeconds; + + if ( lastActive == lastActiveDevice ) + { + return; + } + + Action.Trigger( onActiveDeviceChange ); + _onActiveDeviceChange.DispatchEvent( null ); + + } + + public void UpdateLastActiveDevice( Sensor sensor, int index ) + { + if ( keyboardDevice.ContainsSensor( sensor ) ) + { + UpdateDevice( separateMouseAndKeyboardTracking ? keyboardDevice : mouseKeyboardDevice ); + + return; + } + + if ( mouseDevice.ContainsSensor( sensor ) ) + { + UpdateDevice( separateMouseAndKeyboardTracking ? mouseDevice : mouseKeyboardDevice ); + return; + } + + + + + if ( gamePadDevice.ContainsSensor( sensor ) ) + { + var device = Arrays.Find( deviceList, d => d is GamePadDevice gpd && gpd.deviceIndex == index ); + + if ( device == null ) + { + var gpd = new GamePadDevice(); + gpd.deviceIndex = index; + gpd.deviceName = Input.GetJoyName( index ); + + device = gpd; + } + + UpdateDevice( device ); + } + } public override void _Ready() { + _startTime = DateTime.Now; + mouseKeyboardDevice.devices = new SensorDevice[]{ mouseDevice, keyboardDevice }; + if ( ! initializeOnReady ) { return; @@ -81,7 +194,6 @@ namespace Rokojori { var sm = Unique.Get(); - foreach ( var s in sensors ) { if ( s == null ) @@ -89,7 +201,7 @@ namespace Rokojori continue; } - ( handler as Node ).LogInfo( "Registrating" ); + ( handler as Node ).LogInfo( "Registrating", HierarchyName.Of( (Node)handler) ); sm.Register( s, handler ); } } @@ -117,9 +229,12 @@ namespace Rokojori { if ( s == null || sensorsSet.Contains( s ) ) { + // this.LogInfo( "Not including:", HierarchyName.Of( s ) ); return; } + this.LogInfo( "Including:", HierarchyName.Of( s ) ); + AddSensorsFrom( s ); sensorsSet.Add( s ); diff --git a/Runtime/Sensors/Sensors.cs b/Runtime/Sensors/Sensors.cs index 7f26b53..6b307ab 100644 --- a/Runtime/Sensors/Sensors.cs +++ b/Runtime/Sensors/Sensors.cs @@ -6,19 +6,33 @@ namespace Rokojori { public class Sensors { + public static bool IsDown( Sensor sensor, int device = 0 ) + { + return sensor == null ? false : sensor.IsDown( device ); + } + public static bool IsActive( Sensor sensor ) { return sensor == null ? false : sensor.isActive; } - public static float GetValue( Sensor sensor, float scale = 1 ) + public static float GetValue( Sensor sensor, float scale = 1, float deadZone = 0.3f ) { - return sensor == null ? 0 : sensor.value * scale; + if ( sensor == null ) + { + return 0; + } + + var rawValue = sensor.value; + + var clamped = MathX.NormalizeClamped( rawValue, deadZone, 1 ); + + return clamped * scale; } - public static float PolarAxis( Sensor negative, Sensor positive ) + public static float PolarAxis( Sensor negative, Sensor positive, float scale = 1, float deadZone = 0.3f ) { - return GetValue( negative, -1 ) + GetValue( positive, 1 ); + return GetValue( negative, -scale, deadZone ) + GetValue( positive, scale, deadZone ); } } } \ No newline at end of file diff --git a/Runtime/Shading/Library/Line3.gdshaderinc b/Runtime/Shading/Library/Line3.gdshaderinc new file mode 100644 index 0000000..917fb0f --- /dev/null +++ b/Runtime/Shading/Library/Line3.gdshaderinc @@ -0,0 +1,43 @@ +struct Line3 +{ + vec3 start; + vec3 end; +}; + +vec3 Line3_getAt( inout Line3 line, float t ) +{ + return line.start + ( line.end - line.start ) * t; +} + +float Line3_closestParameterToPoint( inout Line3 line, vec3 point ) +{ + vec3 startP = point - line.start; + vec3 startEnd = line.end - line.start; + + float startEnd2 = dot( startEnd, startEnd ); + float startEnd_startP = dot( startEnd, startP ); + + if ( startEnd2 == 0.0 ) + { + return 0.5; + } + + float t = startEnd_startP / startEnd2; + + return t; +} + +vec3 Line3_closestPointToPoint( inout Line3 line, vec3 point ) +{ + float parameter = Line3_closestParameterToPoint( line, point ); + return Line3_getAt( line, parameter ); +} + +float Line3_getDistance( inout Line3 line, vec3 point ) +{ + float parameter = clamp( Line3_closestParameterToPoint( line, point ), 0, 1 ); + + vec3 p = Line3_getAt( line, parameter ); + + return length( point - p ); +} \ No newline at end of file diff --git a/Runtime/Shading/Library/NinePatch.gdshaderinc b/Runtime/Shading/Library/NinePatch.gdshaderinc new file mode 100644 index 0000000..7332980 --- /dev/null +++ b/Runtime/Shading/Library/NinePatch.gdshaderinc @@ -0,0 +1,64 @@ +#include "res://addons/rokojori_action_library/Runtime/Shading/Library/Math.gdshaderinc" + +void computeNinePatchBorders( vec2 _TEXTURE_PIXEL_SIZE, vec2 renderSize, vec4 pixelBorders, + out vec4 uvBorders, out vec4 scaledBorders ) +{ + vec2 texSize = vec2( 1.0 / _TEXTURE_PIXEL_SIZE.x, 1.0 / _TEXTURE_PIXEL_SIZE.y ); + + vec2 scale = texSize / renderSize; + scale = max( scale, vec2( 1, 1 ) ); + + float scaling = max( scale.x, scale.y ); + + uvBorders = vec4 + ( + pixelBorders[ 0 ] / texSize.x, ( texSize.x - pixelBorders[ 1 ] ) / texSize.x, + + pixelBorders[ 2 ] / texSize.y, ( texSize.y - pixelBorders[ 1 ] ) / texSize.y + ); + + scaledBorders = pixelBorders / scaling; + scaledBorders[ 1 ] = renderSize.x - scaledBorders[ 1 ]; + scaledBorders[ 3 ] = renderSize.y - scaledBorders[ 3 ]; +} + +float ninePatchBorderRemap( float value, float borderStart, float borderEnd, + float uvStart, float uvEnd, float maxSize ) +{ + float inMin = borderStart; + float inMax = borderEnd; + float outMin = uvStart; + float outMax = uvEnd; + + + if ( value < borderStart ) + { + inMin = 0.0; inMax = borderStart; + outMin = 0.0; outMax = uvStart; + } + else if ( value > borderEnd ) + { + inMin = borderEnd; inMax = maxSize; + outMin = uvEnd; outMax = 1.0; + } + + return map( value, inMin, inMax, outMin, outMax ); + +} + +vec2 computeNinePatchUV( vec2 _UV, vec2 renderSize, vec4 uvBorders, vec4 scaledBorders ) +{ + vec2 pixelCoord = _UV * renderSize; + + float nU = ninePatchBorderRemap( + pixelCoord.x, scaledBorders[ 0 ], scaledBorders[ 1 ], + uvBorders[ 0 ], uvBorders[ 1 ], renderSize.x + ); + + float nV = ninePatchBorderRemap( + pixelCoord.y, scaledBorders[ 2 ], scaledBorders[ 3 ], + uvBorders[ 2 ], uvBorders[ 3 ], renderSize.y + ); + + return vec2( nU, nV ); +} \ No newline at end of file diff --git a/Runtime/Shading/Library/SDF.gdshaderinc b/Runtime/Shading/Library/SDF.gdshaderinc new file mode 100644 index 0000000..1f59af6 --- /dev/null +++ b/Runtime/Shading/Library/SDF.gdshaderinc @@ -0,0 +1,29 @@ +void computeRectangleBounds( float in_offset, float in_radius, float in_maxRadius, vec2 size, out vec2 minP, out vec2 maxP, out float out_radius ) +{ + out_radius = min( in_radius, in_maxRadius ); + float borderSize = out_radius + in_offset; + minP = vec2( borderSize, borderSize ); + maxP = size - vec2( borderSize, borderSize ); +} + +float roundedRectangleDistance( vec2 minP, vec2 maxP, vec2 pos) +{ + vec2 leftTop = minP - pos; + vec2 bottomRight = pos - maxP; + + vec2 maximum = max( leftTop, bottomRight ); + maximum = max( maximum, vec2(0,0) ); + + return length( maximum ); +} + +float roundedRectangle( vec2 minP, vec2 maxP, vec2 point, float borderSize, float sharp ) +{ + float rectangleDistance = roundedRectangleDistance( minP, maxP, point ); + rectangleDistance -= borderSize; + rectangleDistance *= sharp; + + rectangleDistance = clamp( rectangleDistance, 0.0, 1.0 ); + + return 1.0 - rectangleDistance; +} \ No newline at end of file diff --git a/Runtime/Shading/Library/Transform.gdshaderinc b/Runtime/Shading/Library/Transform.gdshaderinc index ef2e82e..901b721 100644 --- a/Runtime/Shading/Library/Transform.gdshaderinc +++ b/Runtime/Shading/Library/Transform.gdshaderinc @@ -1,4 +1,9 @@ +vec3 applyMatrix( vec3 v, mat4 m ) +{ + return ( m * vec4( v, 1.0 ) ).xyz; +} + vec3 localToWorld( vec3 _VERTEX, mat4 _MODEL_MATRIX ) { return ( _MODEL_MATRIX * vec4( _VERTEX, 1.0 ) ).xyz; @@ -224,3 +229,74 @@ vec2 applyMatrixBase_m3v2( mat3 matrix, vec2 point ) return vec2( ox, oy ); } + + +mat4 identity_m4() +{ + return mat4( + vec4( 1, 0, 0, 0 ), + vec4( 0, 1, 0, 0 ), + vec4( 0, 0, 1, 0 ), + vec4( 0, 0, 0, 1 ) + ); +} + +mat4 translate_m4( vec3 translation ) +{ + return mat4( + vec4( 1, 0, 0, translation.x ), + vec4( 0, 1, 0, translation.y ), + vec4( 0, 0, 1, translation.z ), + vec4( 0, 0, 0, 1 ) + ); +} + +mat4 scale_m4( vec3 scale ) +{ + return mat4( + vec4( scale.x, 0, 0, 0 ), + vec4( 0, scale.y, 0, 0 ), + vec4( 0, 0, scale.z, 0 ), + vec4( 0, 0, 0, 1 ) + ); +} + + +mat4 rotationX_m4( float radiansAngle ) +{ + float c = cos( radiansAngle ); + float s = sin( radiansAngle ); + + return mat4( + vec4( 1, 0, 0, 0 ), + vec4( 0, c, -s, 0 ), + vec4( 0, s, c, 0 ), + vec4( 0, 0, 0, 1 ) + ); +} + +mat4 rotationY_m4( float radiansAngle ) +{ + float c = cos( radiansAngle ); + float s = sin( radiansAngle ); + + return mat4( + vec4( c, 0, s, 0 ), + vec4( 0, 1, 0, 0 ), + vec4( -s, 0, c, 0 ), + vec4( 0, 0, 0, 1 ) + ); +} + +mat4 rotationZ_m4( float radiansAngle ) +{ + float c = cos( radiansAngle ); + float s = sin( radiansAngle ); + + return mat4( + vec4( c, -s, 0, 0 ), + vec4( s, c, 0, 0 ), + vec4( 0, 0, 1, 0 ), + vec4( 0, 0, 0, 1 ) + ); +} \ No newline at end of file diff --git a/Runtime/Shading/Materials/CustomMaterial.cs b/Runtime/Shading/Materials/CustomMaterial.cs index 66d1784..9b536d9 100644 --- a/Runtime/Shading/Materials/CustomMaterial.cs +++ b/Runtime/Shading/Materials/CustomMaterial.cs @@ -4,6 +4,8 @@ using System.Collections.Generic; namespace Rokojori { + [Tool] + [GlobalClass] public partial class CustomMaterial:ShaderMaterial { public void CopyUniformsFrom( ShaderMaterial material ) diff --git a/Runtime/Shading/Materials/CustomMaterialProperty.cs b/Runtime/Shading/Materials/CustomMaterialProperty.cs index 084b2cc..a80e15a 100644 --- a/Runtime/Shading/Materials/CustomMaterialProperty.cs +++ b/Runtime/Shading/Materials/CustomMaterialProperty.cs @@ -15,6 +15,11 @@ namespace Rokojori CustomMaterial _material; ShaderPropertyName _name; + public S GetPropertyName() where S:ShaderPropertyName + { + return _name as S; + } + public T Get() { return _name._Get( _material, default( T ) ); diff --git a/Runtime/Shading/Materials/MaterialTransfer.cs b/Runtime/Shading/Materials/MaterialTransfer.cs index b0d1c4d..2aa9b72 100644 --- a/Runtime/Shading/Materials/MaterialTransfer.cs +++ b/Runtime/Shading/Materials/MaterialTransfer.cs @@ -9,7 +9,7 @@ namespace Rokojori public partial class MaterialTransfer:Resource { [Export] - public SubMaterialTransfer[] transfers; + public SubMaterialTransfer[] transfers = new SubMaterialTransfer[ 0 ]; public void Transfer( Material source, Material target ) { diff --git a/Runtime/Shading/Materials/SubMaterialTransfer.cs b/Runtime/Shading/Materials/SubMaterialTransfer.cs index fda068f..15a811a 100644 --- a/Runtime/Shading/Materials/SubMaterialTransfer.cs +++ b/Runtime/Shading/Materials/SubMaterialTransfer.cs @@ -35,7 +35,7 @@ namespace Rokojori [ExportGroup("Shader Matching/Custom Shaders")] [Export] - public Shader[] shaders; + public Shader[] shaders = new Shader[ 0 ]; public bool MatchesMaterial( Material m ) @@ -83,31 +83,31 @@ namespace Rokojori [ExportGroup("Property Transfers")] [Export] - public BoolPropertyTransfer[] bools; + public BoolPropertyTransfer[] bools = new BoolPropertyTransfer[ 0 ]; [Export] - public ColorPropertyTransfer[] colors; + public ColorPropertyTransfer[] colors = new ColorPropertyTransfer[ 0 ]; [Export] - public FloatPropertyTransfer[] floats; + public FloatPropertyTransfer[] floats = new FloatPropertyTransfer[ 0 ]; [Export] - public IntPropertyTransfer[] ints; + public IntPropertyTransfer[] ints = new IntPropertyTransfer[ 0 ]; [Export] - public Texture2DPropertyTransfer[] texture2D; + public Texture2DPropertyTransfer[] texture2D = new Texture2DPropertyTransfer[ 0 ]; [Export] - public Vector2PropertyTransfer[] vector2; + public Vector2PropertyTransfer[] vector2 = new Vector2PropertyTransfer[ 0 ]; [Export] - public Vector3PropertyTransfer[] vector3; + public Vector3PropertyTransfer[] vector3 = new Vector3PropertyTransfer[ 0 ]; [Export] - public Vector4PropertyTransfer[] vector4; + public Vector4PropertyTransfer[] vector4 = new Vector4PropertyTransfer[ 0 ]; [Export] - public CustomMaterialTransfer[] custom; + public CustomMaterialTransfer[] custom = new CustomMaterialTransfer[ 0 ]; public void Transfer( Material a, Material b ) diff --git a/Runtime/Shading/Properties/Property Library/TextureChannels/AO Texture Channel.tres b/Runtime/Shading/Properties/Property Library/TextureChannels/AO Texture Channel.tres index 2e4a796..ed0304f 100644 --- a/Runtime/Shading/Properties/Property Library/TextureChannels/AO Texture Channel.tres +++ b/Runtime/Shading/Properties/Property Library/TextureChannels/AO Texture Channel.tres @@ -4,4 +4,4 @@ [resource] script = ExtResource("1_0bu4b") -propertyName = "" +propertyName = "ao_texture_channel" diff --git a/Runtime/Shading/Properties/Property Library/TextureChannels/Roughness Texture Channel.tres b/Runtime/Shading/Properties/Property Library/TextureChannels/Roughness Texture Channel.tres index 544bb70..6143517 100644 --- a/Runtime/Shading/Properties/Property Library/TextureChannels/Roughness Texture Channel.tres +++ b/Runtime/Shading/Properties/Property Library/TextureChannels/Roughness Texture Channel.tres @@ -4,4 +4,4 @@ [resource] script = ExtResource("1_p7os4") -propertyName = "ao_texture_channel" +propertyName = "roughness_texture_channel" diff --git a/Runtime/Shading/Properties/ShaderPropertyName.cs b/Runtime/Shading/Properties/ShaderPropertyName.cs index 1a41755..ad47475 100644 --- a/Runtime/Shading/Properties/ShaderPropertyName.cs +++ b/Runtime/Shading/Properties/ShaderPropertyName.cs @@ -74,7 +74,7 @@ namespace Rokojori if ( _cSharpName != null && _cSharpName != "" && _propertyInfoCache.Has( type, _cSharpName ) ) { - RJLog.Log( type, ">>", material, "_cSharpName", _cSharpName ); + // RJLog.Log( type, ">>", material, "_cSharpName", _cSharpName ); return _propertyInfoCache[ type ][ _cSharpName ]; } diff --git a/Runtime/Shading/Shaders/Effects/FancyOutline/FancyOutline.cs b/Runtime/Shading/Shaders/Effects/FancyOutline/FancyOutlineMaterial.cs similarity index 85% rename from Runtime/Shading/Shaders/Effects/FancyOutline/FancyOutline.cs rename to Runtime/Shading/Shaders/Effects/FancyOutline/FancyOutlineMaterial.cs index 42eb1aa..b4a4d84 100644 --- a/Runtime/Shading/Shaders/Effects/FancyOutline/FancyOutline.cs +++ b/Runtime/Shading/Shaders/Effects/FancyOutline/FancyOutlineMaterial.cs @@ -2,7 +2,9 @@ using Godot; namespace Rokojori { - public class FancyOutline + // Generated by ShaderClassGenerator + + public class FancyOutlineShader { public static readonly CachedResource shader = new CachedResource( "res://addons/rokojori_action_library/Runtime/Shading/Shaders/Effects/FancyOutline/FancyOutline.gdshader" @@ -22,6 +24,8 @@ namespace Rokojori } + [Tool] + [GlobalClass] public partial class FancyOutlineMaterial:CustomMaterial { public static readonly CachedResource ScanWhite500Ms20x = CustomMaterial.Cached( @@ -42,19 +46,19 @@ namespace Rokojori public FancyOutlineMaterial() { - Shader = FancyOutline.shader.Get(); + Shader = FancyOutlineShader.shader.Get(); - albedo = new CustomMaterialProperty( this, FancyOutline.albedo ); - size = new CustomMaterialProperty( this, FancyOutline.size ); - sizeCloseScale = new CustomMaterialProperty( this, FancyOutline.sizeCloseScale ); - sizeFarScale = new CustomMaterialProperty( this, FancyOutline.sizeFarScale ); - closeDistance = new CustomMaterialProperty( this, FancyOutline.closeDistance ); - farDistance = new CustomMaterialProperty( this, FancyOutline.farDistance ); - opacityModulationStrength = new CustomMaterialProperty( this, FancyOutline.opacityModulationStrength ); - opacityModulationDuration = new CustomMaterialProperty( this, FancyOutline.opacityModulationDuration ); - scanLineAmount = new CustomMaterialProperty( this, FancyOutline.scanLineAmount ); - scanLineDivisions = new CustomMaterialProperty( this, FancyOutline.scanLineDivisions ); - scanLineSpeed = new CustomMaterialProperty( this, FancyOutline.scanLineSpeed ); + albedo = new CustomMaterialProperty( this, FancyOutlineShader.albedo ); + size = new CustomMaterialProperty( this, FancyOutlineShader.size ); + sizeCloseScale = new CustomMaterialProperty( this, FancyOutlineShader.sizeCloseScale ); + sizeFarScale = new CustomMaterialProperty( this, FancyOutlineShader.sizeFarScale ); + closeDistance = new CustomMaterialProperty( this, FancyOutlineShader.closeDistance ); + farDistance = new CustomMaterialProperty( this, FancyOutlineShader.farDistance ); + opacityModulationStrength = new CustomMaterialProperty( this, FancyOutlineShader.opacityModulationStrength ); + opacityModulationDuration = new CustomMaterialProperty( this, FancyOutlineShader.opacityModulationDuration ); + scanLineAmount = new CustomMaterialProperty( this, FancyOutlineShader.scanLineAmount ); + scanLineDivisions = new CustomMaterialProperty( this, FancyOutlineShader.scanLineDivisions ); + scanLineSpeed = new CustomMaterialProperty( this, FancyOutlineShader.scanLineSpeed ); } } diff --git a/Runtime/Shading/Shaders/Effects/FresnelOverlay/FresnelOverlay.cs b/Runtime/Shading/Shaders/Effects/FresnelOverlay/FresnelOverlayMaterial.cs similarity index 82% rename from Runtime/Shading/Shaders/Effects/FresnelOverlay/FresnelOverlay.cs rename to Runtime/Shading/Shaders/Effects/FresnelOverlay/FresnelOverlayMaterial.cs index c084906..6ff2d81 100644 --- a/Runtime/Shading/Shaders/Effects/FresnelOverlay/FresnelOverlay.cs +++ b/Runtime/Shading/Shaders/Effects/FresnelOverlay/FresnelOverlayMaterial.cs @@ -1,49 +1,49 @@ -using System.Collections; -using System.Collections.Generic; -using System.Text.RegularExpressions; -using System.Text; using Godot; namespace Rokojori { - public class FresnelOverlay + // Generated by ShaderClassGenerator + + public class FresnelOverlayShader { public static readonly CachedResource shader = new CachedResource( "res://addons/rokojori_action_library/Runtime/Shading/Shaders/Effects/FresnelOverlay/FresnelOverlay.gdshader" - ); + ); public static readonly ColorPropertyName albedo = ColorPropertyName.Create( "albedo" ); - public static readonly Texture2DPropertyName textureAlbedo = Texture2DPropertyName.Create( "texture_albedo" ); public static readonly FloatPropertyName grow = FloatPropertyName.Create( "grow" ); - public static readonly FloatPropertyName fresnelSharpness = FloatPropertyName.Create( "fresnelSharpness" ); public static readonly FloatPropertyName fresnelMultiply = FloatPropertyName.Create( "fresnelMultiply" ); public static readonly FloatPropertyName fresnelOffset = FloatPropertyName.Create( "fresnelOffset" ); + public static readonly Texture2DPropertyName textureAlbedo = Texture2DPropertyName.Create( "texture_albedo" ); } + [Tool] + [GlobalClass] public partial class FresnelOverlayMaterial:CustomMaterial { + + public readonly CustomMaterialProperty albedo; - public readonly CustomMaterialProperty textureAlbedo; public readonly CustomMaterialProperty grow; - public readonly CustomMaterialProperty fresnelSharpness; public readonly CustomMaterialProperty fresnelMultiply; public readonly CustomMaterialProperty fresnelOffset; + public readonly CustomMaterialProperty textureAlbedo; public FresnelOverlayMaterial() { - Shader = FresnelOverlay.shader.Get(); + Shader = FresnelOverlayShader.shader.Get(); - albedo = new CustomMaterialProperty( this, FresnelOverlay.albedo ); - textureAlbedo = new CustomMaterialProperty( this, FresnelOverlay.textureAlbedo ); - grow = new CustomMaterialProperty( this, FresnelOverlay.grow ); - - fresnelSharpness = new CustomMaterialProperty( this, FresnelOverlay.fresnelSharpness ); - fresnelMultiply = new CustomMaterialProperty( this, FresnelOverlay.fresnelMultiply ); - fresnelOffset = new CustomMaterialProperty( this, FresnelOverlay.fresnelOffset ); + albedo = new CustomMaterialProperty( this, FresnelOverlayShader.albedo ); + grow = new CustomMaterialProperty( this, FresnelOverlayShader.grow ); + fresnelSharpness = new CustomMaterialProperty( this, FresnelOverlayShader.fresnelSharpness ); + fresnelMultiply = new CustomMaterialProperty( this, FresnelOverlayShader.fresnelMultiply ); + fresnelOffset = new CustomMaterialProperty( this, FresnelOverlayShader.fresnelOffset ); + textureAlbedo = new CustomMaterialProperty( this, FresnelOverlayShader.textureAlbedo ); } + } } \ No newline at end of file diff --git a/Runtime/Shading/Shaders/Effects/Outline/Outline.gdshader b/Runtime/Shading/Shaders/Effects/Outline/Outline.gdshader index 6146965..c91069e 100644 --- a/Runtime/Shading/Shaders/Effects/Outline/Outline.gdshader +++ b/Runtime/Shading/Shaders/Effects/Outline/Outline.gdshader @@ -16,17 +16,17 @@ uniform float opacityModulationDuration : hint_range(0,10) = 1; varying vec4 appliedColor; -void vertex() +void vertex() { float cameraDistance = distance( VERTEX, CAMERA_POSITION_WORLD ); float outlineSize = size * mapClamped( cameraDistance, closeDistance, farDistance, sizeCloseScale, sizeFarScale ); VERTEX += NORMAL * outlineSize/500.0 * cameraDistance; - - float sinTime = sin( mod( TIME, opacityModulationDuration ) / opacityModulationDuration * PI * 2.0 ) / 2.0; + + float sinTime = sin( mod( TIME, opacityModulationDuration ) / opacityModulationDuration * PI * 2.0 ) / 2.0; float alpha = 1.0 - opacityModulationStrength * 0.5 + sinTime * opacityModulationStrength; - + appliedColor = albedo ; - appliedColor.a *= alpha; + appliedColor.a *= alpha; } void fragment() diff --git a/Runtime/Shading/Shaders/Effects/Outline/Outline.cs b/Runtime/Shading/Shaders/Effects/Outline/OutlineMaterial.cs similarity index 78% rename from Runtime/Shading/Shaders/Effects/Outline/Outline.cs rename to Runtime/Shading/Shaders/Effects/Outline/OutlineMaterial.cs index 83f2828..7dec3b7 100644 --- a/Runtime/Shading/Shaders/Effects/Outline/Outline.cs +++ b/Runtime/Shading/Shaders/Effects/Outline/OutlineMaterial.cs @@ -2,7 +2,9 @@ using Godot; namespace Rokojori { - public class Outline + // Generated by ShaderClassGenerator + + public class OutlineShader { public static readonly CachedResource shader = new CachedResource( "res://addons/rokojori_action_library/Runtime/Shading/Shaders/Effects/Outline/Outline.gdshader" @@ -16,10 +18,11 @@ namespace Rokojori public static readonly FloatPropertyName farDistance = FloatPropertyName.Create( "farDistance" ); public static readonly FloatPropertyName opacityModulationStrength = FloatPropertyName.Create( "opacityModulationStrength" ); public static readonly FloatPropertyName opacityModulationDuration = FloatPropertyName.Create( "opacityModulationDuration" ); - public static readonly FloatPropertyName opacityModulationOffset = FloatPropertyName.Create( "opacityModulationOffset" ); } + [Tool] + [GlobalClass] public partial class OutlineMaterial:CustomMaterial { public static readonly CachedResource BoldYellow = CustomMaterial.Cached( @@ -37,21 +40,19 @@ namespace Rokojori public readonly CustomMaterialProperty farDistance; public readonly CustomMaterialProperty opacityModulationStrength; public readonly CustomMaterialProperty opacityModulationDuration; - public readonly CustomMaterialProperty opacityModulationOffset; public OutlineMaterial() { - Shader = Outline.shader.Get(); + Shader = OutlineShader.shader.Get(); - albedo = new CustomMaterialProperty( this, Outline.albedo ); - size = new CustomMaterialProperty( this, Outline.size ); - sizeCloseScale = new CustomMaterialProperty( this, Outline.sizeCloseScale ); - sizeFarScale = new CustomMaterialProperty( this, Outline.sizeFarScale ); - closeDistance = new CustomMaterialProperty( this, Outline.closeDistance ); - farDistance = new CustomMaterialProperty( this, Outline.farDistance ); - opacityModulationStrength = new CustomMaterialProperty( this, Outline.opacityModulationStrength ); - opacityModulationDuration = new CustomMaterialProperty( this, Outline.opacityModulationDuration ); - opacityModulationOffset = new CustomMaterialProperty( this, Outline.opacityModulationOffset ); + albedo = new CustomMaterialProperty( this, OutlineShader.albedo ); + size = new CustomMaterialProperty( this, OutlineShader.size ); + sizeCloseScale = new CustomMaterialProperty( this, OutlineShader.sizeCloseScale ); + sizeFarScale = new CustomMaterialProperty( this, OutlineShader.sizeFarScale ); + closeDistance = new CustomMaterialProperty( this, OutlineShader.closeDistance ); + farDistance = new CustomMaterialProperty( this, OutlineShader.farDistance ); + opacityModulationStrength = new CustomMaterialProperty( this, OutlineShader.opacityModulationStrength ); + opacityModulationDuration = new CustomMaterialProperty( this, OutlineShader.opacityModulationDuration ); } } diff --git a/Runtime/Shading/Shaders/Effects/Overlay/Overlay.cs b/Runtime/Shading/Shaders/Effects/Overlay/OverlayMaterial.cs similarity index 76% rename from Runtime/Shading/Shaders/Effects/Overlay/Overlay.cs rename to Runtime/Shading/Shaders/Effects/Overlay/OverlayMaterial.cs index 1dcfc67..4291975 100644 --- a/Runtime/Shading/Shaders/Effects/Overlay/Overlay.cs +++ b/Runtime/Shading/Shaders/Effects/Overlay/OverlayMaterial.cs @@ -2,7 +2,9 @@ using Godot; namespace Rokojori { - public class Overlay + // Generated by ShaderClassGenerator + + public class OverlayShader { public static readonly CachedResource shader = new CachedResource( "res://addons/rokojori_action_library/Runtime/Shading/Shaders/Effects/Overlay/Overlay.gdshader" @@ -14,6 +16,8 @@ namespace Rokojori } + [Tool] + [GlobalClass] public partial class OverlayMaterial:CustomMaterial { @@ -24,11 +28,11 @@ namespace Rokojori public OverlayMaterial() { - Shader = Overlay.shader.Get(); + Shader = OverlayShader.shader.Get(); - albedo = new CustomMaterialProperty( this, Overlay.albedo ); - opacityModulationStrength = new CustomMaterialProperty( this, Overlay.opacityModulationStrength ); - opacityModulationDuration = new CustomMaterialProperty( this, Overlay.opacityModulationDuration ); + albedo = new CustomMaterialProperty( this, OverlayShader.albedo ); + opacityModulationStrength = new CustomMaterialProperty( this, OverlayShader.opacityModulationStrength ); + opacityModulationDuration = new CustomMaterialProperty( this, OverlayShader.opacityModulationDuration ); } } diff --git a/Runtime/Shading/Shaders/Effects/ScanGradient/ScanGradient.cs b/Runtime/Shading/Shaders/Effects/ScanGradient/ScanGradient.cs deleted file mode 100644 index 1cf0c6f..0000000 --- a/Runtime/Shading/Shaders/Effects/ScanGradient/ScanGradient.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using System.Text.RegularExpressions; -using System.Text; -using Godot; - -namespace Rokojori -{ - public class ScanGradient - { - public static readonly CachedResource shader = new CachedResource( - "res://addons/rokojori_action_library/Runtime/Shading/Shaders/Effects/ScanGradient/ScanGradient.gdshader" - ); - - public static readonly ColorPropertyName albedo = ColorPropertyName.Create( "albedo" ); - public static readonly Texture2DPropertyName textureAlbedo = Texture2DPropertyName.Create( "texture_albedo" ); - public static readonly FloatPropertyName grow = FloatPropertyName.Create( "grow" ); - public static readonly FloatPropertyName offset = FloatPropertyName.Create( "offset" ); - - } - - public partial class ScanGradientMaterial:CustomMaterial - { - public static readonly CachedResource White = CustomMaterial.Cached( - "res://addons/rokojori_action_library/Runtime/Shading/Shaders/Effects/ScanGradient/ScanGradient White.material" - ); - - public readonly CustomMaterialProperty albedo; - public readonly CustomMaterialProperty textureAlbedo; - public readonly CustomMaterialProperty grow; - - public readonly CustomMaterialProperty offset; - - public ScanGradientMaterial() - { - Shader = ScanGradient.shader.Get(); - - albedo = new CustomMaterialProperty( this, ScanGradient.albedo ); - textureAlbedo = new CustomMaterialProperty( this, ScanGradient.textureAlbedo ); - grow = new CustomMaterialProperty( this, ScanGradient.grow ); - - offset = new CustomMaterialProperty( this, ScanGradient.offset ); - } - - } - -} \ No newline at end of file diff --git a/Runtime/Shading/Shaders/Effects/ScanGradient/ScanGradientMaterial.cs b/Runtime/Shading/Shaders/Effects/ScanGradient/ScanGradientMaterial.cs new file mode 100644 index 0000000..d0e4739 --- /dev/null +++ b/Runtime/Shading/Shaders/Effects/ScanGradient/ScanGradientMaterial.cs @@ -0,0 +1,78 @@ +using Godot; + +namespace Rokojori +{ + // Generated by ShaderClassGenerator + + public class ScanGradientShader + { + public static readonly CachedResource shader = new CachedResource( + "res://addons/rokojori_action_library/Runtime/Shading/Shaders/Effects/ScanGradient/ScanGradient.gdshader" + ); + + public static readonly ColorPropertyName albedo = ColorPropertyName.Create( "albedo" ); + public static readonly FloatPropertyName grow = FloatPropertyName.Create( "grow" ); + public static readonly FloatPropertyName range = FloatPropertyName.Create( "range" ); + public static readonly FloatPropertyName offset = FloatPropertyName.Create( "offset" ); + public static readonly FloatPropertyName rangeWobble = FloatPropertyName.Create( "rangeWobble" ); + public static readonly FloatPropertyName rangeWobbleDuration = FloatPropertyName.Create( "rangeWobbleDuration" ); + public static readonly FloatPropertyName offsetWobble = FloatPropertyName.Create( "offsetWobble" ); + public static readonly FloatPropertyName offsetWobbleDuration = FloatPropertyName.Create( "offsetWobbleDuration" ); + public static readonly FloatPropertyName noiseScale = FloatPropertyName.Create( "noiseScale" ); + public static readonly Vector3PropertyName noiseOffset = Vector3PropertyName.Create( "noiseOffset" ); + public static readonly FloatPropertyName noiseAmount = FloatPropertyName.Create( "noiseAmount" ); + public static readonly FloatPropertyName rgbScale = FloatPropertyName.Create( "rgbScale" ); + public static readonly FloatPropertyName alphaScale = FloatPropertyName.Create( "alphaScale" ); + public static readonly Texture2DPropertyName textureAlbedo = Texture2DPropertyName.Create( "texture_albedo" ); + public static readonly Texture2DPropertyName scanTexture = Texture2DPropertyName.Create( "scanTexture" ); + + } + + [Tool] + [GlobalClass] + public partial class ScanGradientMaterial:CustomMaterial + { + public static readonly CachedResource White = CustomMaterial.Cached( + "res://addons/rokojori_action_library/Runtime/Shading/Shaders/Effects/ScanGradient/ScanGradient White.material" + ); + + public readonly CustomMaterialProperty albedo; + public readonly CustomMaterialProperty grow; + public readonly CustomMaterialProperty range; + public readonly CustomMaterialProperty offset; + public readonly CustomMaterialProperty rangeWobble; + public readonly CustomMaterialProperty rangeWobbleDuration; + public readonly CustomMaterialProperty offsetWobble; + public readonly CustomMaterialProperty offsetWobbleDuration; + public readonly CustomMaterialProperty noiseScale; + public readonly CustomMaterialProperty noiseOffset; + public readonly CustomMaterialProperty noiseAmount; + public readonly CustomMaterialProperty rgbScale; + public readonly CustomMaterialProperty alphaScale; + public readonly CustomMaterialProperty textureAlbedo; + public readonly CustomMaterialProperty scanTexture; + + public ScanGradientMaterial() + { + Shader = ScanGradientShader.shader.Get(); + + albedo = new CustomMaterialProperty( this, ScanGradientShader.albedo ); + grow = new CustomMaterialProperty( this, ScanGradientShader.grow ); + range = new CustomMaterialProperty( this, ScanGradientShader.range ); + offset = new CustomMaterialProperty( this, ScanGradientShader.offset ); + rangeWobble = new CustomMaterialProperty( this, ScanGradientShader.rangeWobble ); + rangeWobbleDuration = new CustomMaterialProperty( this, ScanGradientShader.rangeWobbleDuration ); + offsetWobble = new CustomMaterialProperty( this, ScanGradientShader.offsetWobble ); + offsetWobbleDuration = new CustomMaterialProperty( this, ScanGradientShader.offsetWobbleDuration ); + noiseScale = new CustomMaterialProperty( this, ScanGradientShader.noiseScale ); + noiseOffset = new CustomMaterialProperty( this, ScanGradientShader.noiseOffset ); + noiseAmount = new CustomMaterialProperty( this, ScanGradientShader.noiseAmount ); + rgbScale = new CustomMaterialProperty( this, ScanGradientShader.rgbScale ); + alphaScale = new CustomMaterialProperty( this, ScanGradientShader.alphaScale ); + textureAlbedo = new CustomMaterialProperty( this, ScanGradientShader.textureAlbedo ); + scanTexture = new CustomMaterialProperty( this, ScanGradientShader.scanTexture ); + } + + } + +} \ No newline at end of file diff --git a/Runtime/Shading/Shaders/Effects/TriPlanarOverlay/TriPlanarOverlay.cs b/Runtime/Shading/Shaders/Effects/TriPlanarOverlay/TriPlanarOverlayMaterial.cs similarity index 86% rename from Runtime/Shading/Shaders/Effects/TriPlanarOverlay/TriPlanarOverlay.cs rename to Runtime/Shading/Shaders/Effects/TriPlanarOverlay/TriPlanarOverlayMaterial.cs index d24bd98..90001b4 100644 --- a/Runtime/Shading/Shaders/Effects/TriPlanarOverlay/TriPlanarOverlay.cs +++ b/Runtime/Shading/Shaders/Effects/TriPlanarOverlay/TriPlanarOverlayMaterial.cs @@ -2,7 +2,9 @@ using Godot; namespace Rokojori { - public class TriPlanarOverlay + // Generated by ShaderClassGenerator + + public class TriPlanarOverlayShader { public static readonly CachedResource shader = new CachedResource( "res://addons/rokojori_action_library/Runtime/Shading/Shaders/Effects/TriPlanarOverlay/TriPlanarOverlay.gdshader" @@ -17,6 +19,8 @@ namespace Rokojori } + [Tool] + [GlobalClass] public partial class TriPlanarOverlayMaterial:CustomMaterial { public static readonly CachedResource BlueShield = CustomMaterial.Cached( @@ -35,14 +39,14 @@ namespace Rokojori public TriPlanarOverlayMaterial() { - Shader = TriPlanarOverlay.shader.Get(); + Shader = TriPlanarOverlayShader.shader.Get(); - albedo = new CustomMaterialProperty( this, TriPlanarOverlay.albedo ); - uvBlendSharpness = new CustomMaterialProperty( this, TriPlanarOverlay.uvBlendSharpness ); - uvScale = new CustomMaterialProperty( this, TriPlanarOverlay.uvScale ); - uvOffset = new CustomMaterialProperty( this, TriPlanarOverlay.uvOffset ); - uvMovement = new CustomMaterialProperty( this, TriPlanarOverlay.uvMovement ); - textureAlbedo = new CustomMaterialProperty( this, TriPlanarOverlay.textureAlbedo ); + albedo = new CustomMaterialProperty( this, TriPlanarOverlayShader.albedo ); + uvBlendSharpness = new CustomMaterialProperty( this, TriPlanarOverlayShader.uvBlendSharpness ); + uvScale = new CustomMaterialProperty( this, TriPlanarOverlayShader.uvScale ); + uvOffset = new CustomMaterialProperty( this, TriPlanarOverlayShader.uvOffset ); + uvMovement = new CustomMaterialProperty( this, TriPlanarOverlayShader.uvMovement ); + textureAlbedo = new CustomMaterialProperty( this, TriPlanarOverlayShader.textureAlbedo ); } } diff --git a/Runtime/Shading/Shaders/ShaderClassGeneration.tscn b/Runtime/Shading/Shaders/ShaderClassGeneration.tscn new file mode 100644 index 0000000..a215d60 --- /dev/null +++ b/Runtime/Shading/Shaders/ShaderClassGeneration.tscn @@ -0,0 +1,18 @@ +[gd_scene load_steps=11 format=3 uid="uid://jhj57wc3pi1t"] + +[ext_resource type="Script" path="res://addons/rokojori_action_library/Runtime/Shading/Tools/CSShaderClassGenerator/CSShaderClassGenerator.cs" id="1_rl4bx"] +[ext_resource type="Shader" path="res://addons/rokojori_action_library/Runtime/Shading/Shaders/Effects/FancyOutline/FancyOutline.gdshader" id="2_0634p"] +[ext_resource type="Shader" path="res://addons/rokojori_action_library/Runtime/Shading/Shaders/Effects/FresnelOverlay/FresnelOverlay.gdshader" id="3_5fksk"] +[ext_resource type="Shader" path="res://addons/rokojori_action_library/Runtime/Shading/Shaders/Effects/Outline/Outline.gdshader" id="4_jo18s"] +[ext_resource type="Shader" path="res://addons/rokojori_action_library/Runtime/Shading/Shaders/Effects/Overlay/Overlay.gdshader" id="5_wf68q"] +[ext_resource type="Shader" path="res://addons/rokojori_action_library/Runtime/Shading/Shaders/Effects/ScanGradient/ScanGradient.gdshader" id="6_84sko"] +[ext_resource type="Shader" path="res://addons/rokojori_action_library/Runtime/Shading/Shaders/Effects/TriPlanarOverlay/TriPlanarOverlay.gdshader" id="7_lj7wh"] +[ext_resource type="Shader" path="res://addons/rokojori_action_library/Runtime/Shading/Shaders/Wipes/FadeWipe/FadeWipe.gdshader" id="8_e0ipl"] +[ext_resource type="Shader" path="res://addons/rokojori_action_library/Runtime/UI/Shaders/NinePatch/UINinePatch.gdshader" id="9_7kuuo"] +[ext_resource type="Shader" path="res://addons/rokojori_action_library/Runtime/UI/Shaders/RoundedRectangle/RoundedRectangle.gdshader" id="10_xogpf"] + +[node name="ShaderClassGeneration" type="Node"] + +[node name="CSShaderClassGenerator" type="Node" parent="."] +script = ExtResource("1_rl4bx") +shaders = [ExtResource("2_0634p"), ExtResource("3_5fksk"), ExtResource("4_jo18s"), ExtResource("5_wf68q"), ExtResource("6_84sko"), ExtResource("7_lj7wh"), ExtResource("8_e0ipl"), ExtResource("9_7kuuo"), ExtResource("10_xogpf")] diff --git a/Runtime/Shading/Shaders/Wipes/FadeWipe/FadeWipe.gdshader b/Runtime/Shading/Shaders/Wipes/FadeWipe/FadeWipe.gdshader index 1c16e92..cc30e30 100644 --- a/Runtime/Shading/Shaders/Wipes/FadeWipe/FadeWipe.gdshader +++ b/Runtime/Shading/Shaders/Wipes/FadeWipe/FadeWipe.gdshader @@ -23,29 +23,29 @@ varying vec2 textureUV; varying vec4 animatedTint; void vertex() -{ +{ mat3 matrix = identity_m3(); - + float textureAspect = wipeTextureSize.x / wipeTextureSize.y; float viewAspect = outputViewSize.x / outputViewSize.y; float viewRatio = viewAspect / textureAspect; - + matrix *= rotatePivotAspect_m3( uvRotation * DegreesToRadians , uvRotationCenter, textureAspect * viewRatio ); - + vec2 rotatedScaleCenter = applyMatrix_m3v2( rotatePivot_m3( uvRotation, vec2( 0.5,0.5)), uvScaleCenter ); matrix *= scalePivot_m3( uvScale * vec2( viewRatio,1), rotatedScaleCenter ); - - + + matrix *= translate_m3( applyMatrixBase_m3v2( matrix, -uvTranslation ) ); - - vec2 uv = applyMatrix_m3v2( matrix, UV ); - textureUV = uv; - - animatedTint = wipeTextureTint; + + vec2 uv = applyMatrix_m3v2( matrix, UV ); + textureUV = uv; + + animatedTint = wipeTextureTint; animatedTint.a *= wipeState; } void fragment() -{ +{ COLOR = texture( wipeTexture, textureUV ) * animatedTint; } diff --git a/Runtime/Shading/Shaders/Wipes/FadeWipe/FadeWipe.cs b/Runtime/Shading/Shaders/Wipes/FadeWipe/FadeWipeMaterial.cs similarity index 85% rename from Runtime/Shading/Shaders/Wipes/FadeWipe/FadeWipe.cs rename to Runtime/Shading/Shaders/Wipes/FadeWipe/FadeWipeMaterial.cs index 93239d7..a5f1483 100644 --- a/Runtime/Shading/Shaders/Wipes/FadeWipe/FadeWipe.cs +++ b/Runtime/Shading/Shaders/Wipes/FadeWipe/FadeWipeMaterial.cs @@ -2,7 +2,9 @@ using Godot; namespace Rokojori { - public class FadeWipe + // Generated by ShaderClassGenerator + + public class FadeWipeShader { public static readonly CachedResource shader = new CachedResource( "res://addons/rokojori_action_library/Runtime/Shading/Shaders/Wipes/FadeWipe/FadeWipe.gdshader" @@ -21,6 +23,8 @@ namespace Rokojori } + [Tool] + [GlobalClass] public partial class FadeWipeMaterial:CustomMaterial { @@ -38,18 +42,18 @@ namespace Rokojori public FadeWipeMaterial() { - Shader = FadeWipe.shader.Get(); + Shader = FadeWipeShader.shader.Get(); - wipeState = new CustomMaterialProperty( this, FadeWipe.wipeState ); - outputViewSize = new CustomMaterialProperty( this, FadeWipe.outputViewSize ); - wipeTextureSize = new CustomMaterialProperty( this, FadeWipe.wipeTextureSize ); - wipeTextureTint = new CustomMaterialProperty( this, FadeWipe.wipeTextureTint ); - uvRotation = new CustomMaterialProperty( this, FadeWipe.uvRotation ); - uvRotationCenter = new CustomMaterialProperty( this, FadeWipe.uvRotationCenter ); - uvScale = new CustomMaterialProperty( this, FadeWipe.uvScale ); - uvScaleCenter = new CustomMaterialProperty( this, FadeWipe.uvScaleCenter ); - uvTranslation = new CustomMaterialProperty( this, FadeWipe.uvTranslation ); - wipeTexture = new CustomMaterialProperty( this, FadeWipe.wipeTexture ); + wipeState = new CustomMaterialProperty( this, FadeWipeShader.wipeState ); + outputViewSize = new CustomMaterialProperty( this, FadeWipeShader.outputViewSize ); + wipeTextureSize = new CustomMaterialProperty( this, FadeWipeShader.wipeTextureSize ); + wipeTextureTint = new CustomMaterialProperty( this, FadeWipeShader.wipeTextureTint ); + uvRotation = new CustomMaterialProperty( this, FadeWipeShader.uvRotation ); + uvRotationCenter = new CustomMaterialProperty( this, FadeWipeShader.uvRotationCenter ); + uvScale = new CustomMaterialProperty( this, FadeWipeShader.uvScale ); + uvScaleCenter = new CustomMaterialProperty( this, FadeWipeShader.uvScaleCenter ); + uvTranslation = new CustomMaterialProperty( this, FadeWipeShader.uvTranslation ); + wipeTexture = new CustomMaterialProperty( this, FadeWipeShader.wipeTexture ); } } diff --git a/Runtime/Shading/Tools/CSShaderClassGenerator/CSShaderClassGenerator.cs b/Runtime/Shading/Tools/CSShaderClassGenerator/CSShaderClassGenerator.cs index 62df5cd..416b656 100644 --- a/Runtime/Shading/Tools/CSShaderClassGenerator/CSShaderClassGenerator.cs +++ b/Runtime/Shading/Tools/CSShaderClassGenerator/CSShaderClassGenerator.cs @@ -9,7 +9,7 @@ namespace Rokojori public partial class CSShaderClassGenerator:Node { [Export] - public Shader shader; + public Shader[] shaders; [Export] public bool generate; @@ -32,7 +32,12 @@ namespace Rokojori public void Generate() { - var resourcePath = this.shader.ResourcePath; + Arrays.ForEach( shaders, s => Generate( s ) ); + } + + public void Generate( Shader shaderFile ) + { + var resourcePath = shaderFile.ResourcePath; var shader = ResourceLoader.Load( resourcePath ); var resourceParentPath = RegexUtility.ParentPath( resourcePath ); var absoluteFilePath = FilePath.Absolute( ProjectSettings.GlobalizePath( resourcePath ) ); @@ -63,7 +68,7 @@ namespace Rokojori var declaration = "public static readonly ${type}PropertyName ${csName} = ${type}PropertyName.Create( \"${name}\" );"; var instance = "public readonly CustomMaterialProperty<${csType}> ${csName};"; - var init = "${csName} = new CustomMaterialProperty<${csType}>( this, ${ShaderName}.${csName} );"; + var init = "${csName} = new CustomMaterialProperty<${csType}>( this, ${ShaderName}Shader.${csName} );"; var csType = type; @@ -96,7 +101,7 @@ namespace Rokojori var materials = FilesSync.GetFiles( absoluteParentPath.fullPath, ( f ) => { - return f.hasFileExtension( "material" ); + return f.HasFileExtension( "material" ); } ); @@ -150,7 +155,7 @@ namespace Rokojori var shaderClass = variables.ReplaceAll( template ); - var outputPath = absoluteFilePath.WithExtension( "cs" ); + var outputPath = absoluteFilePath.AddToFileName( "Material" ).WithExtension( "cs" ); diff --git a/Runtime/Shading/Tools/CSShaderClassGenerator/CSShaderClassTemplate.txt b/Runtime/Shading/Tools/CSShaderClassGenerator/CSShaderClassTemplate.txt index a26b927..a95388c 100644 --- a/Runtime/Shading/Tools/CSShaderClassGenerator/CSShaderClassTemplate.txt +++ b/Runtime/Shading/Tools/CSShaderClassGenerator/CSShaderClassTemplate.txt @@ -2,7 +2,9 @@ using Godot; namespace Rokojori { - public class ${ShaderName} + // Generated by ShaderClassGenerator + + public class ${ShaderName}Shader { public static readonly CachedResource shader = new CachedResource( "${ShaderResourcePath}" @@ -12,6 +14,8 @@ namespace Rokojori } + [Tool] + [GlobalClass] public partial class ${ShaderName}Material:CustomMaterial { ${MaterialPresets} @@ -20,7 +24,7 @@ namespace Rokojori public ${ShaderName}Material() { - Shader = ${ShaderName}.shader.Get(); + Shader = ${ShaderName}Shader.shader.Get(); ${ShaderInstancePropertiesInitializers} } diff --git a/Runtime/Text/Lexing/LexerEvent.cs b/Runtime/Text/Lexing/LexerEvent.cs index 28d4594..f5f3cf8 100644 --- a/Runtime/Text/Lexing/LexerEvent.cs +++ b/Runtime/Text/Lexing/LexerEvent.cs @@ -79,6 +79,11 @@ namespace Rokojori } public override string ToString() { + if ( match != null ) + { + return "Token{ '" + type + "':'" + match + "' (" + offset + "-" + end + ") }"; + } + return "Token{ '" + type + "' (" + offset + "-" + end + ") }"; } @@ -109,6 +114,40 @@ namespace Rokojori return Is( matcher == null ? null : matcher.type, match ); } + public bool MatchIs( string match ) + { + return match == this.match; + } + + public bool MatchIsAny( params string[] matches ) + { + for ( int i = 0; i < matches.Length; i++ ) + { + if ( MatchIs( matches[ i ] ) ) + { + return true; + } + } + + return false; + } + + public bool IsAny( LexerMatcher matcher, params string[] matches ) + { + if ( matches == null || matches.Length == 0 ) + { + return Is( matcher ); + } + + var correctType = matcher == null || matcher.type == type; + + if ( ! correctType ) + { + return false; + } + + return MatchIsAny( matches ); + } public enum FindResultType { @@ -122,10 +161,46 @@ namespace Rokojori { public FindResultType type = FindResultType.NotFound; public int index; + + + public FindResult() + { } + + public FindResult( FindResultType type, int index ) + { + this.type = type; + this.index = index; + } } - public static string GetMatchFromRange( List tokens, int offset, int length ) + public static FindResult Found( int index) { + return new FindResult( FindResultType.Found, index ); + } + + public static FindResult KeepSearch( int index ) + { + return new FindResult( FindResultType.KeepSearching, index ); + } + + public static FindResult NotFound( int index ) + { + return new FindResult( FindResultType.NotFound, index ); + } + + public static FindResult Error( int index ) + { + return new FindResult( FindResultType.NotFound, index ); + } + + + public static string GetMatchFromRange( List tokens, int offset, int length = -1 ) + { + if ( length == -1 ) + { + length = tokens.Count - offset; + } + var match = new StringBuilder(); for ( int i = 0; i < length; i++ ) @@ -136,6 +211,19 @@ namespace Rokojori return match.ToString(); } + public static int Find( List tokens, int offset, params string[] types ) + { + for ( int i = offset; i < tokens.Count; i++ ) + { + if ( Arrays.IndexOf( types, tokens[ i ].type ) != -1 ) + { + return i; + } + } + + return -1; + + } public static FindResult Find( List tokens, int offset, System.Func evaluator ) { @@ -160,6 +248,47 @@ namespace Rokojori return result; } + public static List GetSeparatorsInBrackets( List tokens, int offset, string seperator = "," ) + { + var openTypes = new List(){ "(","[","{" }; + var closingTypes = new List(){ ")","]","}" }; + + var stack = new List(); + var separators = new List(); + + for ( int i = offset; i < tokens.Count; i++ ) + { + if ( stack.Count == 1 && tokens[ i ].MatchIs( seperator ) ) + { + separators.Add( i ); + } + + var match = tokens[ i ].match; + + if ( openTypes.Contains( match ) ) + { + stack.Add( match ); + continue; + } + else if ( closingTypes.Contains( match ) ) + { + var closingTypeIndex = closingTypes.IndexOf( match ); + var expectedOpener = openTypes[ closingTypeIndex ]; + + if ( stack[ stack.Count - 1 ] != expectedOpener ) + { + return null; + } + + stack.RemoveAt( stack.Count - 1 ); + } + } + + return separators; + + } + + public static FindResult FindClosingBracket( List tokens, int offset ) { var openTypes = new List(){ "(","[","{" }; @@ -171,9 +300,7 @@ namespace Rokojori if ( bracketIndex == -1 ) { - var result = new FindResult(); - result.type = FindResultType.NotFound; - result.index = offset; + var result = new FindResult( FindResultType.NotFound, offset ); return result; } diff --git a/Runtime/Text/Lexing/LexerLibrary/XMLLexer.cs b/Runtime/Text/Lexing/LexerLibrary/XMLLexer.cs index df854dd..0233feb 100644 --- a/Runtime/Text/Lexing/LexerLibrary/XMLLexer.cs +++ b/Runtime/Text/Lexing/LexerLibrary/XMLLexer.cs @@ -44,8 +44,11 @@ namespace Rokojori XMLLexer.Inside_Start_Tag, XMLLexer.Inside_Start_Tag ); - public static readonly LexerMatcher XMLStartTagClosing = - new LexerMatcher( "XMLStartTagClosing", @"\/?>", XMLLexer.Inside_Start_Tag, Lexer.Default_Mode ); + public static readonly LexerMatcher XMLStartTagClosingTag = + new LexerMatcher( "XMLStartTagClosingTag", @">", XMLLexer.Inside_Start_Tag, Lexer.Default_Mode ); + + public static readonly LexerMatcher XMLStartTagClosingElement = + new LexerMatcher( "XMLStartTagClosingElement", @"\/>", XMLLexer.Inside_Start_Tag, Lexer.Default_Mode ); public static readonly LexerMatcher XMLAttributeAssignment = new LexerMatcher( "XMLAttributeAssignment", @"=", XMLLexer.Inside_Start_Tag, XMLLexer.Inside_Start_Tag ); @@ -114,7 +117,8 @@ namespace Rokojori LexerMatcherLibrary.BreakMatcher, XMLLexer.XMLText, - XMLLexer.XMLStartTagClosing, + XMLLexer.XMLStartTagClosingElement, + XMLLexer.XMLStartTagClosingTag, XMLLexer.InsideStartTag_SingleQuotedStringMatcher, XMLLexer.InsideStartTag_DoubleQuotedStringMatcher, diff --git a/Runtime/Text/Lexing/LexerMatcher.cs b/Runtime/Text/Lexing/LexerMatcher.cs index f201b3f..1c951dc 100644 --- a/Runtime/Text/Lexing/LexerMatcher.cs +++ b/Runtime/Text/Lexing/LexerMatcher.cs @@ -44,6 +44,11 @@ namespace Rokojori return fullType == le.type; } + public bool Matches( string type ) + { + return fullType == type; + } + public RegexMatches GetRegexMatches( string source ) { return new RegexMatches( matcher.Match( source, 0 ) ); diff --git a/Runtime/Text/RegexUtility.cs b/Runtime/Text/RegexUtility.cs index 253fb2a..4c12801 100644 --- a/Runtime/Text/RegexUtility.cs +++ b/Runtime/Text/RegexUtility.cs @@ -156,9 +156,19 @@ namespace Rokojori return -1; } - public static bool Matching( string source, string regex ) + public static bool Matching( string source, string regex, RegexOptions options = RegexOptions.None ) { - return new Regex( regex ).Match( source ).Success; + if ( source == null ) + { + return false; + } + + return new Regex( regex, options ).Match( source ).Success; + } + + public static bool MatchingIgnoreCase( string source, string regex ) + { + return Matching( source, regex, RegexOptions.IgnoreCase ); } public static string Substring( string source, string regex ) diff --git a/Runtime/Time/TimeLineManager.cs b/Runtime/Time/TimeLineManager.cs index 247c320..d59dcd5 100644 --- a/Runtime/Time/TimeLineManager.cs +++ b/Runtime/Time/TimeLineManager.cs @@ -13,7 +13,7 @@ namespace Rokojori public partial class TimeLineManager:NetworkNode { [Export] - public TimeLine[] timeLines; + public TimeLine[] timeLines = new TimeLine[ 0 ]; [Export] public TimeLine gameTimeTimeLine; diff --git a/Runtime/Tools/Arrays.cs b/Runtime/Tools/Arrays.cs index 2dc03d2..3be0f59 100644 --- a/Runtime/Tools/Arrays.cs +++ b/Runtime/Tools/Arrays.cs @@ -37,6 +37,11 @@ namespace Rokojori public static int FindIndex( T[] values, Func predicate ) { + if ( values == null ) + { + return -1; + } + for ( int i = 0; i < values.Length; i++ ) { if ( predicate( values[ i ] ) ) @@ -60,6 +65,19 @@ namespace Rokojori return Array.IndexOf( values, other ) != -1; } + public static bool ContainsEqual( T[] values, T other ) + { + for ( int i = 0; i < values.Length; i++ ) + { + if ( other.Equals( values[ i ] ) ) + { + return true; + } + } + + return false; + } + public static T[] Add( T[] values, T other ) { var newValues = new T[ values.Length + 1 ]; @@ -70,6 +88,35 @@ namespace Rokojori return newValues; } + public static T[] RemoveIndex( T[] values, int index ) + { + if ( index <= -1 || index >= values.Length ) + { + return values; + } + + if ( values.Length == 1 && index == 0 ) + { + return new T[ 0 ]; + } + + var newValues = new T[ values.Length - 1 ]; + + if ( index != 0 ) + { + Array.Copy( values, newValues, index ); + } + + if ( index != ( values.Length - 1 ) ) + { + Array.Copy( values, index + 1, newValues, index, ( values.Length - 1 ) - index ); + } + + + return newValues; + } + + public static void ForEach( T[] values, Action callback ) { foreach ( var it in values ) diff --git a/Runtime/Tools/Lists.cs b/Runtime/Tools/Lists.cs index 4f51289..ad120dd 100644 --- a/Runtime/Tools/Lists.cs +++ b/Runtime/Tools/Lists.cs @@ -10,7 +10,29 @@ namespace Rokojori public static class Lists { - + public static bool IsOneOf( T value, params T[] values ) + { + for ( int i = 0; i < values.Length; i++ ) + { + if ( EqualityComparer.Default.Equals( values[ i ], value ) ) + { + return true; + } + } + + return false; + } + + public static bool ContainsEqual( List values, T value ) + { + if ( value == null || values == null ) + { + return false; + } + + return values.Find( v => value.Equals( v ) ) != null; + } + public static void Sort( List data, Func getValue ) { ValueSorter.SortList( data, getValue ); diff --git a/Runtime/Tools/ReflectionHelper.cs b/Runtime/Tools/ReflectionHelper.cs index 24fa91e..f73c182 100644 --- a/Runtime/Tools/ReflectionHelper.cs +++ b/Runtime/Tools/ReflectionHelper.cs @@ -213,7 +213,26 @@ namespace Rokojori return list; } - + public static bool IsTypeOneOf( T instance, params Type[] types ) + { + if ( instance == null ) + { + return false; + } + + var type = instance.GetType(); + + for ( int i = 0; i < types.Length; i++ ) + { + if ( type.IsAssignableFrom( types[ i ] ) ) + { + return true; + } + } + + return false; + } + public static bool IsType( MemberInfo mi ) { if ( mi is FieldInfo fi ) diff --git a/Runtime/UI/Layouts/UILayouting.cs b/Runtime/UI/Layouts/UILayouting.cs index 572e38e..b27adbd 100644 --- a/Runtime/UI/Layouts/UILayouting.cs +++ b/Runtime/UI/Layouts/UILayouting.cs @@ -38,7 +38,7 @@ namespace Rokojori var childUIRegion = (UIRegion) control; childUIRegion.Layout(); } - else if ( control is UIImage || control is UIBorderImage ) + else if ( control is UIImage ) { var tw = 0; var th = 0; @@ -56,26 +56,13 @@ namespace Rokojori tw = uiImage.Texture.GetWidth(); th = uiImage.Texture.GetHeight(); } - else if ( control is UIBorderImage ) - { - var uiBorderImage = (UIBorderImage) control; - - if ( uiBorderImage.Texture == null ) - { - uiBorderImage.Size = new Vector2( 0, 0 ); - return; - } - - tw = uiBorderImage.Texture.GetWidth(); - th = uiBorderImage.Texture.GetHeight(); - } - var container = (UIStylePropertyContainer) control; var w = UINumber.Compute( control, UIStyleNumberProperty.Width, tw, tw / 100f ); var h = UINumber.Compute( control, UIStyleNumberProperty.Height, th, th / 100f ); + // RJLog.Log( "Set Image Size", w, h ); control.Size = new Vector2( w, h ); if ( control is UIImage ) @@ -144,10 +131,27 @@ namespace Rokojori text.uiTextLabelSettings.ShadowOffset = new Vector2( UINumber.Compute( control, UIStyleNumberProperty.FontShadowOffsetX, 0 ), UINumber.Compute( control, UIStyleNumberProperty.FontShadowOffsetY, 0 ) - ); - + ); + + control.UpdateMinimumSize(); - control.Size = control.GetMinimumSize(); + + if ( text.alwaysMinimumSize ) + { + + control.Size = control.GetMinimumSize(); + } + else + { + var minSize = control.GetMinimumSize(); + + var w = UINumber.Compute( control, UIStyleNumberProperty.Width, minSize.X, minSize.X / 100f ); + var h = UINumber.Compute( control, UIStyleNumberProperty.Height, minSize.Y, minSize.Y / 100f ); + + // RJLog.Log( "Set Image Size", w, h ); + control.Size = new Vector2( w, h ); + } + } else { @@ -215,16 +219,24 @@ namespace Rokojori var pivotX = UINumber.Compute( c, UIStyleNumberProperty.PivotX, 0.5f * c.Size.X, c.Size.X ); var pivotY = UINumber.Compute( c, UIStyleNumberProperty.PivotY, 0.5f * c.Size.Y, c.Size.Y ); - c.PivotOffset = new Vector2( pivotX, pivotY ); + if ( c is UIText text && ! text.alwaysMinimumSize ) + { + pivotX = 0; + pivotY = 0; + } - c.Rotation = UINumber.Compute( c, UIStyleNumberProperty.Rotation, 0 ); + c.PivotOffset = new Vector2( pivotX, pivotY ); + + + + c.Rotation = MathX.DegreesToRadians * UINumber.Compute( c, UIStyleNumberProperty.Rotation, 0 ); var scale = UINumber.Compute( c, UIStyleNumberProperty.Scale, 1, 1 ); c.Scale = new Vector2( UINumber.Compute( c, UIStyleNumberProperty.ScaleX, 1, 1 ) , UINumber.Compute( c, UIStyleNumberProperty.ScaleY, 1, 1 ) - ) * scale; + ) * scale; } diff --git a/Runtime/UI/Nodes/UIBorderImage.cs b/Runtime/UI/Nodes/UIBorderImage.cs deleted file mode 100644 index 47f48c9..0000000 --- a/Runtime/UI/Nodes/UIBorderImage.cs +++ /dev/null @@ -1,178 +0,0 @@ - -using Godot; -using Rokojori; -using System.Collections.Generic; - -namespace Rokojori -{ - [Tool] - [GlobalClass] - public partial class UIBorderImage:NinePatchRect, UIStylePropertyContainer - { - [Export] - public UIStyle parentStyle; - - [ExportGroup("Size & Margins")] - [Export] - public UINumber width; - - [Export] - public UINumber height; - - - [Export] - public UINumber margin; - - [Export] - public UINumber marginLeft; - [Export] - public UINumber marginTop; - [Export] - public UINumber marginRight; - [Export] - public UINumber marginBottom; - - - [ExportGroup( "Position" )] - [Export] - public UIPosition position; - [Export] - public UILineWrap lineWrap; - [Export] - public UINumber left; - [Export] - public UINumber top; - [Export] - public UINumber right; - [Export] - public UINumber bottom; - - - [ExportGroup("Rotation & Scale")] - [Export] - public UINumber pivotX; - [Export] - public UINumber pivotY; - - [Export] - public UINumber rotation; - - [Export] - public UINumber scale; - - [Export] - public UINumber scaleX; - [Export] - public UINumber scaleY; - - public List> GetActiveShaderUIColorTransitions() - { - return null; - } - - public List> GetActiveShaderUINumberTransitions() - { - return null; - } - - [ExportGroup("Transitions")] - [Export] - public TransitionSettingsAll transitionSettings; - public TransitionSettingsAll GetTransitionSettingsAll() - { - return transitionSettings; - } - - [Export] - public UINumberTransition[] numberTransitions; - public UINumberTransition[] GetNumberTransitions() - { - return numberTransitions; - } - public List> activeNumberTransitions = new List>(); - public List> GetActiveUINumberTransitions() - { - return activeNumberTransitions; - } - - [Export] - public UIColorTransition[] colorTransitions; - public UIColorTransition[] GetColorTransitions() - { - return colorTransitions; - } - - public List> activeColorTransitions = new List>(); - public List> GetActiveUIColorTransitions() - { - return activeColorTransitions; - } - - public UIStyle GetUIStyleParent() - { - return parentStyle; - } - - public UIPosition GetUIPosition() - { - return position; - } - - public UILineWrap GetUILineWrap() - { - return lineWrap; - } - - public UILayout GetUILayout() - { - return UILayout.___; - } - - public ShaderUIColor[] GetShaderUIColors() - { - return null; - } - - public ShaderUINumber[] GetShaderUINumbers() - { - return null; - } - - public UIColor GetUIStyleColorProperty( UIStyleColorProperty property ) - { - return null; - } - - public UINumber GetUIStyleNumberProperty( UIStyleNumberProperty property ) - { - switch ( property ) - { - case UIStyleNumberProperty.Width: return width; - case UIStyleNumberProperty.Height: return height; - - case UIStyleNumberProperty.Margin: return margin; - - case UIStyleNumberProperty.MarginLeft: return marginLeft; - case UIStyleNumberProperty.MarginRight: return marginRight; - case UIStyleNumberProperty.MarginTop: return marginTop; - case UIStyleNumberProperty.MarginBottom: return marginBottom; - - - case UIStyleNumberProperty.Left: return left; - case UIStyleNumberProperty.Right: return right; - case UIStyleNumberProperty.Top: return top; - case UIStyleNumberProperty.Bottom: return bottom; - - case UIStyleNumberProperty.PivotX: return pivotX; - case UIStyleNumberProperty.PivotY: return pivotY; - case UIStyleNumberProperty.Rotation: return rotation; - - case UIStyleNumberProperty.Scale: return scale; - case UIStyleNumberProperty.ScaleX: return scaleX; - case UIStyleNumberProperty.ScaleY: return scaleY; - } - - return null; - } - } -} \ No newline at end of file diff --git a/Runtime/UI/Nodes/UIImage.cs b/Runtime/UI/Nodes/UIImage.cs index e5f3e32..7cdafab 100644 --- a/Runtime/UI/Nodes/UIImage.cs +++ b/Runtime/UI/Nodes/UIImage.cs @@ -6,9 +6,144 @@ using System.Collections.Generic; namespace Rokojori { [Tool] - [GlobalClass] + [GlobalClass,Icon("res://addons/rokojori_action_library/Icons/UIImage.svg")] public partial class UIImage:TextureRect, UIStylePropertyContainer { + [Export] + public bool freezeImageType = false; + + UIImageType _imageType; + [Export] + public UIImageType imageType + { + get => _imageType; + set + { + if ( freezeImageType ) + { + return; + } + + if ( _imageType != value ) + { + if ( _imageType != null ) + { + _imageType.Clear( this ); + } + } + + _imageType = value; + + this.LogInfo( Material == null ? "null" : ( Material.GetType().Name ) ); + UpdateImageType(); + this.LogInfo( Material == null ? "null" : ( Material.GetType().Name ) ); + } + } + + void UpdateImageType() + { + ResetImageType(); + + if ( _imageType != null ) + { + _imageType.Assign( this ); + } + } + + void ResetImageType() + { + ExpandMode = TextureRect.ExpandModeEnum.IgnoreSize; + StretchMode = TextureRect.StretchModeEnum.Scale; + Material = null; + } + + public void CopyNumberShaderPropertyFrom( CustomMaterialProperty name, UINumber number, TransitionSettings transition ) + { + SetNumberShaderProperty( name.GetPropertyName(), number, transition ); + } + + public void SetNumberShaderProperty( FloatPropertyName name, UINumber number, TransitionSettings transition ) + { + if ( name == null || name.propertyName == null ) + { + this.LogInfo( "Name is null" ); + return; + } + + + for ( int i = 0; i < numberProperties.Length; i++ ) + { + if ( numberProperties[ i ] == null || numberProperties[ i ].floatPropertyName == null ) + { + return; + } + } + + if ( number == null ) + { + var index = Arrays.FindIndex( numberProperties, p => p.floatPropertyName.propertyName == name.propertyName ); + numberProperties = Arrays.RemoveIndex( numberProperties, index ); + return; + } + + var shaderUINumber = Arrays.Find( numberProperties, p => p.floatPropertyName.propertyName == name.propertyName ); + + if ( shaderUINumber == null ) + { + shaderUINumber = new ShaderUINumber(); + shaderUINumber.floatPropertyName = name; + numberProperties = Arrays.Add( numberProperties, shaderUINumber ); + } + + shaderUINumber.number = number; + shaderUINumber.transitionSettings = transition; + } + + public void CopyColorShaderPropertyFrom( CustomMaterialProperty name, UIColor color ) + { + SetColorShaderProperty( name.GetPropertyName(), color ); + } + + public void SetColorShaderProperty( ColorPropertyName name, UIColor color ) + { + if ( name == null || name.propertyName == null ) + { + this.LogInfo( "Name is null" ); + return; + } + + for ( int i = 0; i < colorProperties.Length; i++ ) + { + if ( colorProperties[ i ] == null || colorProperties[ i ].colorPropertyName == null ) + { + return; + } + } + + + if ( color == null ) + { + var index = Arrays.FindIndex( colorProperties, p => p != null && p.colorPropertyName.propertyName == name.propertyName ); + colorProperties = Arrays.RemoveIndex( colorProperties, index ); + return; + } + + + + + + var shaderUIColor = Arrays.Find( colorProperties, p => p != null && p.colorPropertyName.propertyName == name.propertyName ); + + if ( shaderUIColor == null ) + { + shaderUIColor = new ShaderUIColor(); + shaderUIColor.colorPropertyName = name; + colorProperties = Arrays.Add( colorProperties, shaderUIColor ); + } + + shaderUIColor.color = color; + } + [Export] public UIStyle parentStyle; @@ -67,7 +202,7 @@ namespace Rokojori [ExportGroup( "Shader Properties" )] [Export] - public ShaderUIColor[] colorProperties; + public ShaderUIColor[] colorProperties = new ShaderUIColor[ 0 ]; public List> activeShaderColorTransitions = new List>(); public List> GetActiveShaderUIColorTransitions() { @@ -75,7 +210,7 @@ namespace Rokojori } [Export] - public ShaderUINumber[] numberProperties; + public ShaderUINumber[] numberProperties = new ShaderUINumber[ 0 ]; public List> activeShaderNumberTransitions = new List>(); public List> GetActiveShaderUINumberTransitions() { @@ -91,7 +226,7 @@ namespace Rokojori } [Export] - public UINumberTransition[] numberTransitions; + public UINumberTransition[] numberTransitions = new UINumberTransition[0]; public UINumberTransition[] GetNumberTransitions() { return numberTransitions; @@ -104,7 +239,7 @@ namespace Rokojori } [Export] - public UIColorTransition[] colorTransitions; + public UIColorTransition[] colorTransitions = new UIColorTransition[ 0 ]; public UIColorTransition[] GetColorTransitions() { return colorTransitions; @@ -185,5 +320,15 @@ namespace Rokojori { return null; } + + public Font GetFont() + { + return null; + } + + public Vector2 GetUISize() + { + return GetSize(); + } } } \ No newline at end of file diff --git a/Runtime/UI/Nodes/UIImageTypes/NinePatchUIImageType.cs b/Runtime/UI/Nodes/UIImageTypes/NinePatchUIImageType.cs new file mode 100644 index 0000000..e418bae --- /dev/null +++ b/Runtime/UI/Nodes/UIImageTypes/NinePatchUIImageType.cs @@ -0,0 +1,104 @@ + +using Godot; +using Rokojori; +using System.Collections.Generic; + +namespace Rokojori +{ + [Tool] + [GlobalClass,Icon("res://addons/rokojori_action_library/Icons/UIImage.svg")] + public partial class NinePatchUIImageType:UIImageType + { + Dictionary _materials = new Dictionary(); + + [ExportGroup( "Nine Patch Pixel Offsets")] + float _horizontalPixelOffset = 0; + [Export] + public float horizontalPixelOffset + { + get => _horizontalPixelOffset; + set { _horizontalPixelOffset = value; onChange.DispatchEvent( null ); } + } + + float _leftPixelOffset = 0; + [Export] + public float leftPixelOffset + { + get => _leftPixelOffset; + set { _leftPixelOffset = value; onChange.DispatchEvent( null ); } + } + + float _rightPixelOffset = 0; + [Export] + public float rightPixelOffset + { + get => _rightPixelOffset; + set { _rightPixelOffset = value; onChange.DispatchEvent( null ); } + } + + float _verticalPixelOffset = 0; + [Export] + public float verticalPixelOffset + { + get => _verticalPixelOffset; + set { _verticalPixelOffset = value; onChange.DispatchEvent( null ); } + } + + + float _topPixelOffset = 0; + [Export] + public float topPixelOffset + { + get => _topPixelOffset; + set { _topPixelOffset = value; onChange.DispatchEvent( null ); } + } + + float _bottomPixelOffset = 0; + [Export] + public float bottomPixelOffset + { + get => _bottomPixelOffset; + set { _bottomPixelOffset = value; onChange.DispatchEvent( null ); } + } + + + protected override void _Assign( UIImage image ) + { + if ( _materials.ContainsKey( image ) ) + { + return; + } + + _materials[ image ] = new UINinePatchMaterial(); + + image.Material = _materials[ image ]; + + } + + protected override void _Clear( UIImage image ) + { + if ( image != null && _materials.ContainsKey( image ) && image.Material == _materials[ image ] ) + { + image.Material = null; + } + + _materials.Remove( image ); + + } + + protected override void _ApplyChange( UIImage image ) + { + var material = _materials[ image ]; + + var borders = new Vector4( + horizontalPixelOffset + leftPixelOffset, + horizontalPixelOffset + rightPixelOffset, + verticalPixelOffset + topPixelOffset, + verticalPixelOffset + bottomPixelOffset + ); + + material.borders.Set( borders ); + + } + } +} \ No newline at end of file diff --git a/Runtime/UI/Nodes/UIImageTypes/RoundedRectangleUIImageType.cs b/Runtime/UI/Nodes/UIImageTypes/RoundedRectangleUIImageType.cs new file mode 100644 index 0000000..efb3642 --- /dev/null +++ b/Runtime/UI/Nodes/UIImageTypes/RoundedRectangleUIImageType.cs @@ -0,0 +1,118 @@ + +using Godot; +using Rokojori; +using System.Collections.Generic; + +namespace Rokojori +{ + [Tool] + [GlobalClass,Icon("res://addons/rokojori_action_library/Icons/UIImage.svg")] + public partial class RoundedRectangleUIImageType:UIImageType + { + Dictionary _materials = new Dictionary(); + + UIColor _fillColor; + [Export] + public UIColor fillColor + { + get => _fillColor; + set { _fillColor = value; onChange.DispatchEvent( null ); } + } + + UIColor _strokeColor; + [Export] + public UIColor strokeColor + { + get => _strokeColor; + set { _strokeColor = value; onChange.DispatchEvent( null ); } + } + + UINumber _borderRadius; + [Export] + public UINumber borderRadius + { + get => _borderRadius; + set { _borderRadius = value; onChange.DispatchEvent( null ); } + } + + TransitionSettings _borderRadiusTransition; + [Export] + public TransitionSettings borderRadiusTransition + { + get => _borderRadiusTransition; + set { _borderRadiusTransition = value; onChange.DispatchEvent( null ); } + } + + UINumber _strokeSize; + [Export] + public UINumber strokeSize + { + get => _strokeSize; + set { _strokeSize = value; onChange.DispatchEvent( null ); } + } + + TransitionSettings _strokeSizeTransition; + [Export] + public TransitionSettings strokeSizeTransition + { + get => _strokeSizeTransition; + set { _strokeSizeTransition = value; onChange.DispatchEvent( null ); } + } + + UINumber _offset; + [Export] + public UINumber offset + { + get => _offset; + set { _offset = value; onChange.DispatchEvent( null ); } + } + + TransitionSettings _offsetTransition; + [Export] + public TransitionSettings offsetTransition + { + get => _offsetTransition; + set { _offsetTransition = value; onChange.DispatchEvent( null ); } + } + + protected override void _Assign( UIImage image ) + { + if ( _materials.ContainsKey( image ) ) + { + return; + } + + _materials[ image ] = new RoundedRectangleMaterial(); + + image.Material = _materials[ image ]; + + } + + protected override void _Clear( UIImage image ) + { + if ( image != null && _materials.ContainsKey( image ) && image.Material == _materials[ image ] ) + { + image.Material = null; + } + + _materials.Remove( image ); + + } + + protected override void _ApplyChange( UIImage image ) + { + + var material = _materials[ image ]; + + image.CopyColorShaderPropertyFrom( material.fillColor, _fillColor ); + image.CopyColorShaderPropertyFrom( material.strokeColor, _strokeColor ); + + + image.CopyNumberShaderPropertyFrom( material.borderRadius, _borderRadius, _borderRadiusTransition ); + image.CopyNumberShaderPropertyFrom( material.strokeSize, _strokeSize, _strokeSizeTransition ); + image.CopyNumberShaderPropertyFrom( material.offset, _offset, _offsetTransition ); + } + + + } +} \ No newline at end of file diff --git a/Runtime/UI/Nodes/UIImageTypes/UIImageType.cs b/Runtime/UI/Nodes/UIImageTypes/UIImageType.cs new file mode 100644 index 0000000..b564c39 --- /dev/null +++ b/Runtime/UI/Nodes/UIImageTypes/UIImageType.cs @@ -0,0 +1,54 @@ + +using Godot; +using Rokojori; +using System.Collections.Generic; + +namespace Rokojori +{ + [Tool] + [GlobalClass,Icon("res://addons/rokojori_action_library/Icons/UIImage.svg")] + public partial class UIImageType:Resource + { + public readonly EventSlot onChange = new EventSlot(); + List _images = new List(); + + public UIImageType() + { + onChange.AddAction( a => ApplyChanges() ); + } + + public void Assign( UIImage image ) + { + _images.Add( image ); + _Assign( image ); + _ApplyChange( image ); + } + + public void Clear( UIImage image ) + { + _images.Remove( image ); + _Clear( image ); + } + + public void ApplyChanges() + { + _images.ForEach( i => _ApplyChange( i ) ); + } + + protected virtual void _ApplyChange( UIImage image ) + { + + } + + protected virtual void _Assign( UIImage image ) + { + + } + + protected virtual void _Clear( UIImage image ) + { + + } + + } +} \ No newline at end of file diff --git a/Runtime/UI/Nodes/UIInputInfo.cs b/Runtime/UI/Nodes/UIInputInfo.cs new file mode 100644 index 0000000..766538f --- /dev/null +++ b/Runtime/UI/Nodes/UIInputInfo.cs @@ -0,0 +1,218 @@ + +using Godot; +using System.Collections.Generic; + + +namespace Rokojori +{ + + [Tool] + [GlobalClass, Icon("res://addons/rokojori_action_library/Icons/UIInputIcon.svg")] + public partial class UIInputInfo: UIRegion + { + InputIcon[] _inputIcons = new InputIcon[ 0 ]; + + [Export] + public InputIcon[] inputIcons + { + get => _inputIcons; + set + { + _inputIcons = value; + UpdateInfo(); + } + } + + [Export] + public LocalizedString locale; + + [Export] + public bool upperCase; + + [Export] + public bool updateInfo + { + get => false; + set { if ( value ){ UpdateInfo(); }} + } + + [Export] + public DeviceFilter deviceFilter; + + // public override void _Ready() + // { + // UpdateInfo(); + // } + + void UpdateInfo() + { + Nodes.RemoveAndDeleteChildren( this ); + + if ( inputIcons == null ) + { + return; + } + + var iiLib = GetInputIconsLibrary(); + + if ( iiLib == null ) + { + this.LogInfo( "No Input lib!" ); + return; + } + + var icons = iiLib.ResolveIcons( inputIcons ); + + this.LogInfo( "Resolved Icons:\n", inputIcons, "\n>>\n", icons ); + + if ( deviceFilter != null ) + { + var iconsBefore = Lists.From( icons ); + icons = Lists.Filter( icons, i => deviceFilter.BelongsToDevice( i ) ); + this.LogInfo( "Device Filtered Icons:\n", iconsBefore, "\n>>\n", icons ); + } + + icons = iiLib.ResolveIcons( icons.ToArray() ); + + icons.ForEach( i => AddIcon( i ) ); + + + + if ( locale != null ) + { + var localeText = this.CreateChild( "Locale" ); + localeText.locale = locale; + + localeText.font = iiLib.font; + localeText.fontSize = iiLib.fontSize; + + localeText.Uppercase = upperCase; + localeText.marginLeft = UINumber.EM( 0.25f ); + } + + } + + InputIconsLibrary GetInputIconsLibrary() + { + var ui = Unique.Get(); + + if ( ui == null ) + { + ui = this.FindParentThatIs(); + + if ( ui == null ) + { + this.LogInfo( "No UI in parents >", ui ); + + return null; + } + } + + var lib = ui.inputIconsLibrary; + + return lib; + } + + void AddIcon( InputIcon inputIcon ) + { + if ( inputIcon == null ) + { + return; + } + + var lib = GetInputIconsLibrary(); + + var id = lib.GetInputIconDefinition( inputIcon ); + + if ( id == null ) + { + this.LogInfo( "No definition found >> ", inputIcon ); + return; + } + + this.LogInfo( "Definition found >> ", inputIcon ); + + var iconRegion = this.CreateChild(); + var elements = id.GetIconElementsForIcon( inputIcon ); + + elements.ForEach( e => AddElement( iconRegion, e, e == elements[ 0 ] ) ); + + } + + void AddElement( UIRegion iconRegion, IconElement element, bool isBG ) + { + var lib = GetInputIconsLibrary(); + + if ( element is TextureIconElement textureIconElement ) + { + var uiImage = iconRegion.CreateChild(); + uiImage.Texture = textureIconElement.texture; + uiImage.ExpandMode = TextureRect.ExpandModeEnum.IgnoreSize; + uiImage.StretchMode = TextureRect.StretchModeEnum.Scale; + + uiImage.height = UINumber.EM( lib.iconHeightInEm ); + + if ( isBG ) + { + uiImage.width = UINumber.EM( lib.iconHeightInEm * textureIconElement.widthScale ); + + if ( textureIconElement.hasBorders ) + { + var ninePatchType = new NinePatchUIImageType(); + + ninePatchType.leftPixelOffset = textureIconElement.borderLeft; + ninePatchType.rightPixelOffset = textureIconElement.borderRight; + ninePatchType.topPixelOffset = textureIconElement.borderTop; + ninePatchType.bottomPixelOffset = textureIconElement.borderBottom; + + uiImage.imageType = ninePatchType; + } + } + else + { + var size = textureIconElement.texture.GetSize(); + var ratio = size.X / size.Y; + + uiImage.width = UINumber.EM( lib.iconHeightInEm ).GetMultiplied( ratio ); + uiImage.top = UINumber.EM( 0f ); + uiImage.position = UIPosition.Parent_Anchor; + + if ( TextureIconOverlayAlignment.Left == textureIconElement.alignment ) + { + uiImage.left = UINumber.EM( 0f ); + } + + if ( TextureIconOverlayAlignment.Right == textureIconElement.alignment ) + { + uiImage.right = UINumber.EM( 0f ); + } + } + + if ( textureIconElement.rotation != 0 ) + { + uiImage.rotation = UINumber.Create( textureIconElement.rotation ); + } + } + else if ( element is LabelIconElement labelIconElement ) + { + var uiText = iconRegion.CreateChild(); + + uiText.font = lib.font; + uiText.fontSize = labelIconElement.fontScale == 1 ? lib.fontSize : lib.fontSize.GetMultiplied( labelIconElement.fontScale ); + uiText.locale = labelIconElement.locale; + + uiText.width = UINumber.PW( 100 ); + uiText.height = UINumber.PH( 100 ); + uiText.left = UINumber.EM( 0f ); + uiText.top = UINumber.EM( 0f ); + + uiText.position = UIPosition.Parent_Anchor; + uiText.alwaysMinimumSize = false; + uiText.HorizontalAlignment = HorizontalAlignment.Center; + uiText.VerticalAlignment = VerticalAlignment.Center; + + uiText.Uppercase = labelIconElement.fontIsUpperCase; + } + } + } +} \ No newline at end of file diff --git a/Runtime/UI/Nodes/UIRegion.cs b/Runtime/UI/Nodes/UIRegion.cs index 47934d4..d83bcd3 100644 --- a/Runtime/UI/Nodes/UIRegion.cs +++ b/Runtime/UI/Nodes/UIRegion.cs @@ -5,7 +5,7 @@ using System.Collections.Generic; namespace Rokojori { [Tool] - [GlobalClass] + [GlobalClass,Icon("res://addons/rokojori_action_library/Icons/UIRegion.svg")] public partial class UIRegion : Control, UIStylePropertyContainer { [Export] @@ -95,7 +95,6 @@ namespace Rokojori return null; } - [ExportGroup("Transitions")] [Export] public TransitionSettingsAll transitionSettings; @@ -105,7 +104,7 @@ namespace Rokojori } [Export] - public UINumberTransition[] numberTransitions; + public UINumberTransition[] numberTransitions = new UINumberTransition[ 0 ]; public UINumberTransition[] GetNumberTransitions() { return numberTransitions; @@ -118,7 +117,7 @@ namespace Rokojori } [Export] - public UIColorTransition[] colorTransitions; + public UIColorTransition[] colorTransitions = new UIColorTransition[ 0 ]; public UIColorTransition[] GetColorTransitions() { return colorTransitions; @@ -160,6 +159,16 @@ namespace Rokojori return null; } + public Font GetFont() + { + return font; + } + + public Vector2 GetUISize() + { + return GetSize(); + } + public UINumber GetUIStyleNumberProperty( UIStyleNumberProperty property ) { switch ( property ) diff --git a/Runtime/UI/Nodes/UIText.cs b/Runtime/UI/Nodes/UIText.cs index 1c35f97..122a7cf 100644 --- a/Runtime/UI/Nodes/UIText.cs +++ b/Runtime/UI/Nodes/UIText.cs @@ -6,15 +6,62 @@ using System.Collections.Generic; namespace Rokojori { [Tool] - [GlobalClass] - public partial class UIText:Label,UIStylePropertyContainer + [GlobalClass,Icon("res://addons/rokojori_action_library/Icons/UIText.svg")] + public partial class UIText:Label,UIStylePropertyContainer, iLocalizable { - [Export] - public UIStyle parentStyle; + + LocalizedString _locale; + [Export] + public LocalizedString locale + { + get => _locale; + + set { _locale = value; UpdateLocalization(); } + } + + [Export] + public bool refreshText + { + get => false; + set { if ( value ) UpdateLocalization(); UpdateFont(); } + } + + [Export] + public bool disableLocalization = false; + + public void UpdateLocalization() + { + if ( disableLocalization ) + { + return; + } + + Text = LocalizedString.Get( _locale ); + + } + + + [Export] + public bool alwaysMinimumSize = true; + + UIStyle _parentStyle; + [Export] + public UIStyle parentStyle + { + get => _parentStyle; + set { _parentStyle = value; UpdateFont(); } + } + + Font _font; [ExportGroup( "Font" )] [Export] - public Font font; + public Font font + { + get => _font; + set { _font = value; UpdateFont(); } + } + [Export] public UINumber fontSize; [Export] @@ -88,6 +135,23 @@ namespace Rokojori [Export] public UINumber scaleY; + public Font GetFont() + { + return font; + } + + void UpdateFont() + { + var resolvedFont = UIStyle.Font( this ); + + if ( resolvedFont != null ) + { + RemoveThemeFontOverride( "font" ); + AddThemeFontOverride( "font", resolvedFont ); + } + + } + public List> GetActiveShaderUIColorTransitions() { return null; @@ -107,7 +171,7 @@ namespace Rokojori } [Export] - public UINumberTransition[] numberTransitions; + public UINumberTransition[] numberTransitions = new UINumberTransition[ 0 ]; public UINumberTransition[] GetNumberTransitions() { return numberTransitions; @@ -120,7 +184,7 @@ namespace Rokojori } [Export] - public UIColorTransition[] colorTransitions; + public UIColorTransition[] colorTransitions = new UIColorTransition[ 0 ]; public UIColorTransition[] GetColorTransitions() { return colorTransitions; @@ -134,6 +198,8 @@ namespace Rokojori LabelSettings _labelSettings; + + public LabelSettings uiTextLabelSettings { get @@ -224,6 +290,11 @@ namespace Rokojori return null; } + public Vector2 GetUISize() + { + return GetSize(); + } + public UIColor GetUIStyleColorProperty( UIStyleColorProperty property ) { switch ( property ) diff --git a/Runtime/UI/ShaderProperties/ShaderUIColor.cs b/Runtime/UI/ShaderProperties/ShaderUIColor.cs index 6e0c2ac..d398fd5 100644 --- a/Runtime/UI/ShaderProperties/ShaderUIColor.cs +++ b/Runtime/UI/ShaderProperties/ShaderUIColor.cs @@ -20,5 +20,10 @@ namespace Rokojori var colorValue = UIColor.Compute( container as Control, color, Colors.White ); colorPropertyName.Set( material, colorValue ); } + + public override string ToString() + { + return RJLog.GetInfo( colorPropertyName, color ); + } } } \ No newline at end of file diff --git a/Runtime/UI/Shaders/NinePatch/UINinePatch.gdshader b/Runtime/UI/Shaders/NinePatch/UINinePatch.gdshader new file mode 100644 index 0000000..82f6740 --- /dev/null +++ b/Runtime/UI/Shaders/NinePatch/UINinePatch.gdshader @@ -0,0 +1,30 @@ +// NOTE: Shader automatically converted from Godot Engine 4.3.stable.mono's CanvasItemMaterial. + +shader_type canvas_item; +render_mode blend_mix; + +#include "res://addons/rokojori_action_library/Runtime/Shading/Library/NinePatch.gdshaderinc" + +uniform vec2 size = vec2( 128, 128 ); +uniform vec4 borders = vec4( 40, 40, 40, 40 ); + +varying vec4 scaledBorders; +varying vec4 uvBorders; + +void vertex() +{ + vec4 outUVBorders = vec4( 0, 0, 0, 0 ); + vec4 outScaledBorders = vec4( 0, 0, 0, 0 ); + + computeNinePatchBorders( TEXTURE_PIXEL_SIZE, size, borders, outUVBorders, outScaledBorders ); + + uvBorders = outUVBorders; + scaledBorders = outScaledBorders; +} + +void fragment() +{ + vec2 nUV = computeNinePatchUV( UV, size, uvBorders, scaledBorders ); + + COLOR = texture( TEXTURE, nUV ) ; +} \ No newline at end of file diff --git a/Runtime/UI/Shaders/NinePatch/UINinePatchMaterial.cs b/Runtime/UI/Shaders/NinePatch/UINinePatchMaterial.cs new file mode 100644 index 0000000..d74804c --- /dev/null +++ b/Runtime/UI/Shaders/NinePatch/UINinePatchMaterial.cs @@ -0,0 +1,37 @@ +using Godot; + +namespace Rokojori +{ + // Generated by ShaderClassGenerator + + public class UINinePatchShader + { + public static readonly CachedResource shader = new CachedResource( + "res://addons/rokojori_action_library/Runtime/UI/Shaders/NinePatch/UINinePatch.gdshader" + ); + + public static readonly Vector2PropertyName size = Vector2PropertyName.Create( "size" ); + public static readonly Vector4PropertyName borders = Vector4PropertyName.Create( "borders" ); + + } + + [Tool] + [GlobalClass] + public partial class UINinePatchMaterial:CustomMaterial + { + + + public readonly CustomMaterialProperty size; + public readonly CustomMaterialProperty borders; + + public UINinePatchMaterial() + { + Shader = UINinePatchShader.shader.Get(); + + size = new CustomMaterialProperty( this, UINinePatchShader.size ); + borders = new CustomMaterialProperty( this, UINinePatchShader.borders ); + } + + } + +} \ No newline at end of file diff --git a/Runtime/UI/Shaders/RoundedRectangle/RoundedRectangle.gdshader b/Runtime/UI/Shaders/RoundedRectangle/RoundedRectangle.gdshader new file mode 100644 index 0000000..4c22bdc --- /dev/null +++ b/Runtime/UI/Shaders/RoundedRectangle/RoundedRectangle.gdshader @@ -0,0 +1,93 @@ +shader_type canvas_item; + +#include "res://addons/rokojori_action_library/Runtime/Shading/Library/Colors.gdshaderinc" +#include "res://addons/rokojori_action_library/Runtime/Shading/Library/Math.gdshaderinc" +#include "res://addons/rokojori_action_library/Runtime/Shading/Library/Transform.gdshaderinc" +#include "res://addons/rokojori_action_library/Runtime/Shading/Library/SDF.gdshaderinc" + +uniform vec2 size; +uniform float sharpness = 5; +uniform float borderRadius = 5; +uniform float strokeSize = 5; +uniform float offset; + +uniform vec4 fillColor:source_color; +uniform sampler2D fill; +uniform vec4 fillUVTransform; +uniform sampler2D screenFillMultiply; +uniform vec4 screenfillMultiplyUVTransform; +uniform vec2 screenfillMultiplyUVMovement; + + +uniform vec4 strokeColor:source_color; +uniform sampler2D stroke; +uniform vec4 strokeUVTransform; +uniform sampler2D screenStrokeMultiply; +uniform vec4 screenStrokeMultiplyUVTransform; +uniform vec2 screenStrokeMultiplyUVMovment; + +uniform float opacity:hint_range(0,1) = 1; + +void vertex() +{ + // Called for every vertex the material is visible on. +} + +void fragment() +{ + float maxRadius = min( size.x, size.y ) / 2.0 - offset; + + vec2 fillMinP; + vec2 fillMaxP; + float fillRadius; + + computeRectangleBounds( offset, borderRadius, maxRadius, size, fillMinP, fillMaxP, fillRadius ); + float fillMask = roundedRectangle( fillMinP, fillMaxP, UV * size, fillRadius, sharpness ); + vec2 fillUV = tilingOffsetRepeat( UV, fillUVTransform ); + vec2 fillMoved = screenfillMultiplyUVMovement * TIME; + vec4 screenFillMovement = vec4( 0,0, fillMoved.x, fillMoved.y ); + vec2 screenFillMultiplyUV = tilingOffsetRepeat( SCREEN_UV, screenfillMultiplyUVTransform + screenFillMovement ); + vec4 combinedfillColor = fillColor * texture( fill, fillUV ) * texture( screenFillMultiply, screenFillMultiplyUV ); + + + vec2 strokeMinP; + vec2 strokeMaxP; + float strokeRadius; + + computeRectangleBounds( offset - strokeSize, borderRadius + strokeSize, maxRadius, size,strokeMinP, strokeMaxP, strokeRadius ); + float outerStrokeMask = roundedRectangle( strokeMinP, strokeMaxP, UV * size, strokeRadius, sharpness ); + float strokeMask = outerStrokeMask - fillMask; + vec2 strokeUV = tilingOffsetRepeat( UV, strokeUVTransform ); + vec2 strokeMoved = screenStrokeMultiplyUVMovment * TIME; + vec4 screenstrokeMovement = vec4( 0,0, strokeMoved.x, strokeMoved.y ); + vec2 screenStrokeMultiplyUV = tilingOffsetRepeat( SCREEN_UV, screenStrokeMultiplyUVTransform + screenstrokeMovement ); + vec4 combinedStrokeColor = strokeColor * texture( stroke, strokeUV ) * texture( screenStrokeMultiply, screenStrokeMultiplyUV ); + + vec2 fillMaskMinP; + vec2 fillMaskMaxP; + float fillMaskStrokeRadius; + + computeRectangleBounds( offset - strokeSize * 0.5, borderRadius + strokeSize, maxRadius, size, fillMaskMinP, fillMaskMaxP, fillMaskStrokeRadius ); + float fillAlphaMask = roundedRectangle( fillMaskMinP, fillMaskMaxP, UV * size, fillMaskStrokeRadius, sharpness ); + + + vec4 strokeLayer = vec4( combinedStrokeColor.rgb, combinedStrokeColor.a ); + vec4 fillLayer = vec4( combinedfillColor.rgb, combinedfillColor.a * fillAlphaMask ); + + vec4 strokePM = straightToPremultipliedColor( strokeLayer ); + vec4 fillPM = straightToPremultipliedColor( fillLayer ); + + vec4 outputColor = premultipliedToStraightColor( mix( fillPM, strokePM, strokeMask ) ); + + float mask = max ( fillMask , strokeMask ); + mask = fillMask + strokeMask; + + COLOR = vec4( outputColor.rgb, outputColor.a * mask * opacity ); + + // Called for every pixel the material is visible on. +} + +//void light() { + // Called for every pixel for every light affecting the CanvasItem. + // Uncomment to replace the default light processing function with this one. +//} diff --git a/Runtime/UI/Shaders/RoundedRectangle/RoundedRectangleMaterial.cs b/Runtime/UI/Shaders/RoundedRectangle/RoundedRectangleMaterial.cs new file mode 100644 index 0000000..4800576 --- /dev/null +++ b/Runtime/UI/Shaders/RoundedRectangle/RoundedRectangleMaterial.cs @@ -0,0 +1,85 @@ +using Godot; + +namespace Rokojori +{ + // Generated by ShaderClassGenerator + + public class RoundedRectangleShader + { + public static readonly CachedResource shader = new CachedResource( + "res://addons/rokojori_action_library/Runtime/UI/Shaders/RoundedRectangle/RoundedRectangle.gdshader" + ); + + public static readonly Vector2PropertyName size = Vector2PropertyName.Create( "size" ); + public static readonly FloatPropertyName sharpness = FloatPropertyName.Create( "sharpness" ); + public static readonly FloatPropertyName borderRadius = FloatPropertyName.Create( "borderRadius" ); + public static readonly FloatPropertyName strokeSize = FloatPropertyName.Create( "strokeSize" ); + public static readonly FloatPropertyName offset = FloatPropertyName.Create( "offset" ); + public static readonly ColorPropertyName fillColor = ColorPropertyName.Create( "fillColor" ); + public static readonly Vector4PropertyName fillUvTransform = Vector4PropertyName.Create( "fillUVTransform" ); + public static readonly Vector4PropertyName screenfillMultiplyUvTransform = Vector4PropertyName.Create( "screenfillMultiplyUVTransform" ); + public static readonly Vector2PropertyName screenfillMultiplyUvMovement = Vector2PropertyName.Create( "screenfillMultiplyUVMovement" ); + public static readonly ColorPropertyName strokeColor = ColorPropertyName.Create( "strokeColor" ); + public static readonly Vector4PropertyName strokeUvTransform = Vector4PropertyName.Create( "strokeUVTransform" ); + public static readonly Vector4PropertyName screenStrokeMultiplyUvTransform = Vector4PropertyName.Create( "screenStrokeMultiplyUVTransform" ); + public static readonly Vector2PropertyName screenStrokeMultiplyUvMovment = Vector2PropertyName.Create( "screenStrokeMultiplyUVMovment" ); + public static readonly FloatPropertyName opacity = FloatPropertyName.Create( "opacity" ); + public static readonly Texture2DPropertyName fill = Texture2DPropertyName.Create( "fill" ); + public static readonly Texture2DPropertyName screenFillMultiply = Texture2DPropertyName.Create( "screenFillMultiply" ); + public static readonly Texture2DPropertyName stroke = Texture2DPropertyName.Create( "stroke" ); + public static readonly Texture2DPropertyName screenStrokeMultiply = Texture2DPropertyName.Create( "screenStrokeMultiply" ); + + } + + [Tool] + [GlobalClass] + public partial class RoundedRectangleMaterial:CustomMaterial + { + + + public readonly CustomMaterialProperty size; + public readonly CustomMaterialProperty sharpness; + public readonly CustomMaterialProperty borderRadius; + public readonly CustomMaterialProperty strokeSize; + public readonly CustomMaterialProperty offset; + public readonly CustomMaterialProperty fillColor; + public readonly CustomMaterialProperty fillUvTransform; + public readonly CustomMaterialProperty screenfillMultiplyUvTransform; + public readonly CustomMaterialProperty screenfillMultiplyUvMovement; + public readonly CustomMaterialProperty strokeColor; + public readonly CustomMaterialProperty strokeUvTransform; + public readonly CustomMaterialProperty screenStrokeMultiplyUvTransform; + public readonly CustomMaterialProperty screenStrokeMultiplyUvMovment; + public readonly CustomMaterialProperty opacity; + public readonly CustomMaterialProperty fill; + public readonly CustomMaterialProperty screenFillMultiply; + public readonly CustomMaterialProperty stroke; + public readonly CustomMaterialProperty screenStrokeMultiply; + + public RoundedRectangleMaterial() + { + Shader = RoundedRectangleShader.shader.Get(); + + size = new CustomMaterialProperty( this, RoundedRectangleShader.size ); + sharpness = new CustomMaterialProperty( this, RoundedRectangleShader.sharpness ); + borderRadius = new CustomMaterialProperty( this, RoundedRectangleShader.borderRadius ); + strokeSize = new CustomMaterialProperty( this, RoundedRectangleShader.strokeSize ); + offset = new CustomMaterialProperty( this, RoundedRectangleShader.offset ); + fillColor = new CustomMaterialProperty( this, RoundedRectangleShader.fillColor ); + fillUvTransform = new CustomMaterialProperty( this, RoundedRectangleShader.fillUvTransform ); + screenfillMultiplyUvTransform = new CustomMaterialProperty( this, RoundedRectangleShader.screenfillMultiplyUvTransform ); + screenfillMultiplyUvMovement = new CustomMaterialProperty( this, RoundedRectangleShader.screenfillMultiplyUvMovement ); + strokeColor = new CustomMaterialProperty( this, RoundedRectangleShader.strokeColor ); + strokeUvTransform = new CustomMaterialProperty( this, RoundedRectangleShader.strokeUvTransform ); + screenStrokeMultiplyUvTransform = new CustomMaterialProperty( this, RoundedRectangleShader.screenStrokeMultiplyUvTransform ); + screenStrokeMultiplyUvMovment = new CustomMaterialProperty( this, RoundedRectangleShader.screenStrokeMultiplyUvMovment ); + opacity = new CustomMaterialProperty( this, RoundedRectangleShader.opacity ); + fill = new CustomMaterialProperty( this, RoundedRectangleShader.fill ); + screenFillMultiply = new CustomMaterialProperty( this, RoundedRectangleShader.screenFillMultiply ); + stroke = new CustomMaterialProperty( this, RoundedRectangleShader.stroke ); + screenStrokeMultiply = new CustomMaterialProperty( this, RoundedRectangleShader.screenStrokeMultiply ); + } + + } + +} \ No newline at end of file diff --git a/Runtime/UI/Styling/UINumber.cs b/Runtime/UI/Styling/UINumber.cs index fa30b99..2d29e6f 100644 --- a/Runtime/UI/Styling/UINumber.cs +++ b/Runtime/UI/Styling/UINumber.cs @@ -14,6 +14,7 @@ namespace Rokojori [Export] public string unit = ""; + [ExportGroup("Animation")] @@ -34,6 +35,40 @@ namespace Rokojori public bool IsNone => unit == "none"; + + public UINumber GetMultiplied( float scale ) + { + var uiNumber = new UINumber(); + uiNumber.CopyFrom( this ); + uiNumber.value = value * scale; + + return uiNumber; + } + + public static UINumber Create( float value, string unit = "" ) + { + var uiNumber = new UINumber(); + uiNumber.unit = unit; + uiNumber.value = value; + return uiNumber; + + } + + public static UINumber EM( float em ) + { + return Create( em, "em" ); + } + + public static UINumber PW( float pw ) + { + return Create( pw, "pw" ); + } + + public static UINumber PH( float ph ) + { + return Create( ph, "ph" ); + } + public float ComputeRaw( Control control, float alternative ) { return UINumber.Compute( control, this, alternative ); @@ -116,7 +151,7 @@ namespace Rokojori } - public void CopyForm( UINumber other ) + public void CopyFrom( UINumber other ) { if ( other == this ) { @@ -241,6 +276,20 @@ namespace Rokojori } + static readonly string[] _variables = new string[] + { + "em", + + "vw", "vh", + "pw", "ph", + + "cw","ch", + "cx","cy", + + "relative", + "value" + }; + static float ComputeWithoutAnimation( Control control, UINumber number, float width, float height, float relative ) { if ( number == null ) @@ -320,21 +369,13 @@ namespace Rokojori var expression = new Expression(); var expressionText = number.unit == null ? "" : RegexUtility.Replace( number.unit, "%", " * relative " ); - var parseResult = expression.Parse( expressionText, - new string[] - { - "em", - "vw", "vh", - "pw", "ph", - - "cw","ch", - "cx","cy", + if ( ! IsValid( expressionText ) ) + { + return 0; + } - "relative", - "value" - } - ); + var parseResult = expression.Parse( expressionText, _variables ); if ( Error.Ok != parseResult ) { @@ -376,6 +417,43 @@ namespace Rokojori return (float) expression.Execute( inputs ).AsDouble() ; } + static bool IsValid( string expressionText ) + { + if ( expressionText == null || expressionText == "" ) + { + return false; + } + + var lexer = new CSharpLexer(); + + var list = lexer.LexToList( expressionText ); + + if ( lexer.hasError ) + { + return false; + } + + lexer.GrabMatches( list, expressionText ); + + for ( int i = 0; i < list.Count; i++ ) + { + var token = list[ i ]; + + if ( token.Is( LexerMatcherLibrary.CwordMatcher ) ) + { + var value = token.match; + + if ( ! Arrays.Contains( _variables, value ) ) + { + // RJLog.Log( "Unknown variable:", "'" + value + "'", " in: ", "'" + expressionText + "'" ); + return false; + } + } + } + + + return true; + } } } diff --git a/Runtime/UI/Styling/UIStyle.cs b/Runtime/UI/Styling/UIStyle.cs index 2a78fad..e038958 100644 --- a/Runtime/UI/Styling/UIStyle.cs +++ b/Runtime/UI/Styling/UIStyle.cs @@ -105,9 +105,14 @@ namespace Rokojori [ExportGroup( "Shader Properties" )] [Export] - public ShaderUIColor[] colorProperties; + public ShaderUIColor[] colorProperties = new ShaderUIColor[ 0 ]; [Export] - public ShaderUINumber[] numberProperties; + public ShaderUINumber[] numberProperties = new ShaderUINumber[ 0 ]; + + public Font GetFont() + { + return font; + } public List> GetActiveShaderUIColorTransitions() { @@ -128,7 +133,7 @@ namespace Rokojori } [Export] - public UINumberTransition[] numberTransitions; + public UINumberTransition[] numberTransitions = new UINumberTransition[ 0 ]; public UINumberTransition[] GetNumberTransitions() { return numberTransitions; @@ -141,7 +146,7 @@ namespace Rokojori [Export] - public UIColorTransition[] colorTransitions; + public UIColorTransition[] colorTransitions = new UIColorTransition[ 0 ]; public UIColorTransition[] GetColorTransitions() { return colorTransitions; @@ -229,6 +234,11 @@ namespace Rokojori return null; } + public Vector2 GetUISize() + { + return new Vector2( 1, 1 ); + } + public UIColor GetUIStyleColorProperty( UIStyleColorProperty property ) { switch ( property ) @@ -686,6 +696,78 @@ namespace Rokojori return parent.GetUILineWrap(); } + + static Font GetFontFromOwnOrStyleParent( UIStylePropertyContainer container ) + { + if ( container == null ) + { + return null; + } + + var ownFont = container.GetFont(); + + if ( ownFont != null ) + { + return ownFont; + } + + var parent = container.GetUIStyleParent(); + + if ( parent == null ) + { + return null; + } + + return parent.GetFont(); + + } + + public static Font Font( UIStylePropertyContainer container ) + { + var font = GetFontFromOwnOrStyleParent( container ); + + if ( font != null ) + { + return font; + } + + if ( ! ( container is Control ) ) + { + return null; + } + + var control = container as Control; + font = null; + + NodesWalker.Get().GetInParents( control, + it => + { + if ( ! ( it is UIStylePropertyContainer ) ) + { + return false; + } + + var container = (UIStylePropertyContainer) it; + font = GetFontFromOwnOrStyleParent( container ); + + return font != null; + } + ); + + if ( font == null ) + { + var ui = control.FindParentThatIs(); + + if ( ui != null ) + { + return ui.defaultFont; + } + + } + + return font; + } + public static UINumber GetUINumberProperty( UIStylePropertyContainer container, UIStyleNumberProperty property ) { switch ( property ) diff --git a/Runtime/UI/Styling/UIStylePropertyContainer.cs b/Runtime/UI/Styling/UIStylePropertyContainer.cs index e77f7fb..9798887 100644 --- a/Runtime/UI/Styling/UIStylePropertyContainer.cs +++ b/Runtime/UI/Styling/UIStylePropertyContainer.cs @@ -12,6 +12,10 @@ namespace Rokojori UIPosition GetUIPosition(); UILayout GetUILayout(); UILineWrap GetUILineWrap(); + + Vector2 GetUISize(); + + Font GetFont(); UINumber GetUIStyleNumberProperty( UIStyleNumberProperty property ); UIColor GetUIStyleColorProperty( UIStyleColorProperty property ); diff --git a/Runtime/UI/Styling/UIStyling.cs b/Runtime/UI/Styling/UIStyling.cs index 70c7c0e..f6d8e20 100644 --- a/Runtime/UI/Styling/UIStyling.cs +++ b/Runtime/UI/Styling/UIStyling.cs @@ -8,7 +8,7 @@ namespace Rokojori { public static bool CanPosition( Control control ) { - if ( control is UIRegion || control is UIImage || control is UIBorderImage || control is UIText ) + if ( control is UIRegion || control is UIImage || control is UIText ) { return true; } diff --git a/Runtime/UI/UI.cs b/Runtime/UI/UI.cs index 98e23aa..cb76256 100644 --- a/Runtime/UI/UI.cs +++ b/Runtime/UI/UI.cs @@ -5,33 +5,61 @@ namespace Rokojori { [Tool] - [GlobalClass] + [GlobalClass,Icon("res://addons/rokojori_action_library/Icons/UI.svg")] public partial class UI : Control { [Export] public UISettings settings; + [Export] + public InputIconsLibrary inputIconsLibrary; + + [ExportGroup("Font Settings")] + [Export] public UINumber fontSize; + [Export] + public Font defaultFont; + [Export] public float fontZoom = 1; - [Export] - public float X_computedFontSizePixels = 1; - + [ExportGroup("Update Mode")] [Export] public bool updateFlag = false; [Export] public bool updateAlways = true; + [ExportGroup("Read Only")] + + [Export] + public float X_computedFontSizePixels = 1; + public override void _Process( double delta ) { UpdateFontSize(); UpdateUIElements(); } + public override void _Ready() + { + var sm = Unique.Get(); + + if ( sm != null ) + { + sm._onActiveDeviceChange.AddAction( a => UpdateUIInputs() ); + } + + UpdateUIInputs(); + } + + void UpdateUIInputs() + { + Nodes.ForEach( this, uii => uii.updateInfo = true ); + } + void UpdateFontSize() diff --git a/Runtime/UI/UISettings.cs b/Runtime/UI/UISettings.cs index 523a258..2d0321b 100644 --- a/Runtime/UI/UISettings.cs +++ b/Runtime/UI/UISettings.cs @@ -4,10 +4,13 @@ using Godot; namespace Rokojori { [Tool] - [GlobalClass] + [GlobalClass,Icon("res://addons/rokojori_action_library/Icons/UI.svg")] public partial class UISettings : Resource { [Export] public Vector2PropertyName sizePropertyName; + + [Export] + public Vector2PropertyName textureSizePropertyName; } } \ No newline at end of file diff --git a/Runtime/VirtualCameras/Effects/CameraEffect.cs b/Runtime/VirtualCameras/Effects/CameraEffect.cs index 7476a36..93e14c7 100644 --- a/Runtime/VirtualCameras/Effects/CameraEffect.cs +++ b/Runtime/VirtualCameras/Effects/CameraEffect.cs @@ -13,7 +13,7 @@ namespace Rokojori public partial class CameraEffect:Resource { [Export] - public CameraEffectTargetAnimationCurve[] animations; + public CameraEffectTargetAnimationCurve[] animations = new CameraEffectTargetAnimationCurve[ 0 ]; [Export] public TimeLine timeline; diff --git a/Runtime/VirtualCameras/MouseEditorCamera.cs b/Runtime/VirtualCameras/MouseEditorCamera.cs index c53ed46..ceeb4f7 100644 --- a/Runtime/VirtualCameras/MouseEditorCamera.cs +++ b/Runtime/VirtualCameras/MouseEditorCamera.cs @@ -40,10 +40,33 @@ namespace Rokojori public float maxPitch = 89; [Export] - public Sensor orbitButton; + public Sensor mouseMovementOrbitButton; [Export] - public Sensor[] orbitModifierButtons; + public Sensor[] orbitModifierButtons = new Sensor[ 0 ]; + + [Export] + public float yawButtonsSpeed = 1; + + [Export] + public Sensor yawDecreaseButton; + + [Export] + public Sensor yawIncreaseButton; + + + + [Export] + public float pitchButtonsSpeed = 1; + + [Export] + public Sensor pitchDecreaseButton; + + [Export] + public Sensor pitchIncreaseButton; + + + [ExportGroup("Pan")] @@ -54,10 +77,10 @@ namespace Rokojori public float panSpeedY = 0.01f; [Export] - public Sensor panButton; + public Sensor mouseMovementPanButton; [Export] - public Sensor[] panModifierButtons; + public Sensor[] panModifierButtons = new Sensor[ 0 ]; [ExportGroup("Zoom")] @@ -75,13 +98,23 @@ namespace Rokojori public Sensor zoomInButton; [Export] - public Sensor[] zoomInModifierButtons; + public Sensor[] zoomInModifierButtons = new Sensor[ 0 ]; [Export] public Sensor zoomOutButton; [Export] - public Sensor[] zoomOutModifierButtons; + public Sensor[] zoomOutModifierButtons = new Sensor[ 0 ]; + + + [Export] + public Sensor continousZoomInButton; + + [Export] + public Sensor continousZoomOutButton; + + [Export] + public float continousZoomStepInPercentage = 1; [Export] public float zoomSmoothingCoefficient = 0.1f; @@ -141,23 +174,30 @@ namespace Rokojori } - void Orbit() + void OrbitByMouse() { - if ( ! Sensors.IsActive( orbitButton ) ) + if ( ! Sensors.IsActive( mouseMovementOrbitButton ) ) { return; } - yaw += motionDelta.X * yawSpeed; + yaw += motionDelta.X * yawSpeed; pitch += motionDelta.Y * pitchSpeed; pitch = Mathf.Clamp( pitch, minPitch, maxPitch ); } + void Orbit() + { + OrbitByMouse(); + yaw += Sensors.PolarAxis( yawDecreaseButton, yawIncreaseButton ) * yawButtonsSpeed; + pitch += Sensors.PolarAxis( pitchDecreaseButton, pitchIncreaseButton ) * pitchButtonsSpeed; + } + void Pan() { - if ( ! Sensors.IsActive( panButton ) ) + if ( ! Sensors.IsActive( mouseMovementPanButton ) ) { return; } @@ -181,6 +221,16 @@ namespace Rokojori distance *= Mathf.Pow( 1 + zoomStepInPercentage / 100f, -1 ); } + if ( Sensors.IsActive( continousZoomInButton ) ) + { + distance *= Mathf.Pow( 1 + continousZoomStepInPercentage / 100f, 1 ); + } + + if ( Sensors.IsActive( continousZoomOutButton ) ) + { + distance *= Mathf.Pow( 1 + continousZoomStepInPercentage / 100f, -1 ); + } + distance = Mathf.Clamp( distance, minDistance, maxDistance ); } @@ -202,7 +252,7 @@ namespace Rokojori if ( Sensors.IsActive( upButton ) || Sensors.IsActive( downButton ) ) { - moveDirection = ( Sensors.GetValue( upButton ) - Sensors.GetValue( downButton ) ) * this.GlobalUp(); + moveDirection = ( Sensors.GetValue( downButton ) - Sensors.GetValue( upButton ) ) * this.GlobalUp(); } moveDirection = moveDirection.Normalized() * moveSpeed; diff --git a/Runtime/VirtualCameras/StrategyTopDownCamera.cs b/Runtime/VirtualCameras/StrategyTopDownCamera.cs index ce98cf0..21474a7 100644 --- a/Runtime/VirtualCameras/StrategyTopDownCamera.cs +++ b/Runtime/VirtualCameras/StrategyTopDownCamera.cs @@ -112,13 +112,13 @@ namespace Rokojori public Sensor zoomInButton; [Export] - public Sensor[] zoomInModifierButtons; + public Sensor[] zoomInModifierButtons = new Sensor[ 0 ]; [Export] public Sensor zoomOutButton; [Export] - public Sensor[] zoomOutModifierButtons; + public Sensor[] zoomOutModifierButtons = new Sensor[ 0 ]; [Export] public float zoomSmoothingCoefficient = 0.1f; diff --git a/Runtime/WorldMap/WorldMap.cs b/Runtime/WorldMap/WorldMap.cs index 13ead5a..ed1ff6c 100644 --- a/Runtime/WorldMap/WorldMap.cs +++ b/Runtime/WorldMap/WorldMap.cs @@ -17,13 +17,13 @@ namespace Rokojori public Node regionsContainer; [Export] - public Node3D[] streamTargets; + public Node3D[] streamTargets = new Node3D[ 0 ]; [Export] public float streamTargetRadius = 500; [Export] - public WorldMapLayerSetting[] layerSettings; + public WorldMapLayerSetting[] layerSettings = new WorldMapLayerSetting[ 0 ]; [Export] public float hueScale = 0.01f; diff --git a/Runtime/WorldMap/WorldMapDefinition.cs b/Runtime/WorldMap/WorldMapDefinition.cs index c917940..aba852e 100644 --- a/Runtime/WorldMap/WorldMapDefinition.cs +++ b/Runtime/WorldMap/WorldMapDefinition.cs @@ -16,7 +16,7 @@ namespace Rokojori public float regionSize = 250; [Export] - public WorldMapLayerDefinition[] layers; + public WorldMapLayerDefinition[] layers = new WorldMapLayerDefinition[ 0 ]; } } \ No newline at end of file diff --git a/Runtime/XML/Nodes/XMLDocument.cs b/Runtime/XML/Nodes/XMLDocument.cs index bbd9665..ac51c66 100644 --- a/Runtime/XML/Nodes/XMLDocument.cs +++ b/Runtime/XML/Nodes/XMLDocument.cs @@ -10,6 +10,18 @@ namespace Rokojori List _roots = new List(); // public List roots => _roots; + public static XMLDocument From( string text ) + { + var reader = new XMLReader(); + return reader.Read( text ); + } + + public static XMLDocument HTML() + { + var text = ""; + return From( text ); + } + public void AppendChild( XMLNode node ) { _roots.Add( node ); @@ -29,7 +41,7 @@ namespace Rokojori return _roots[ index ]; } - public XMLDocument():base( null, XMLNode.NodeType.Comment ) + public XMLDocument():base( null, XMLNode.NodeType.Document ) { _document = this; } diff --git a/Runtime/XML/Nodes/XMLElementNode.cs b/Runtime/XML/Nodes/XMLElementNode.cs index da575b4..4074268 100644 --- a/Runtime/XML/Nodes/XMLElementNode.cs +++ b/Runtime/XML/Nodes/XMLElementNode.cs @@ -157,6 +157,23 @@ namespace Rokojori public int numAttributes => _attributes.Count; + public void RemoveAttributeAt( int index ) + { + _attributes.RemoveAt( index ); + } + + public void RemoveAttribute( XMLAttributeNode attributeNode ) + { + var index = _attributes.IndexOf( attributeNode ); + + if ( index == -1 ) + { + return; + } + + RemoveAttributeAt( index ); + } + public XMLAttributeNode GetAttributeAt( int index ) { return _attributes[ index ]; diff --git a/Runtime/XML/SVG/Inkscape.cs b/Runtime/XML/SVG/Inkscape.cs new file mode 100644 index 0000000..a09a5a5 --- /dev/null +++ b/Runtime/XML/SVG/Inkscape.cs @@ -0,0 +1,117 @@ +using System.Collections; +using System.Collections.Generic; +using System.Text.RegularExpressions; + +namespace Rokojori +{ + public class Inkscape + { + public static readonly XMLAttributeName label = XMLAttributeName.Create( "label", "inkscape" ); + + public static void StripEditorData( XMLDocument doc ) + { + var walker = new XMLWalker(); + + var it = doc.documentElement; + + var removals = new List(); + var inkspaceNamespaceRegex = "^(sodipodi|inkscape)$"; + + walker.Iterate( it, + ( n )=> + { + if ( XMLNode.NodeType.Element != n.nodeType ) + { + if ( XMLNode.NodeType.Text == n.nodeType && ! HasTextParent( n) ) + { + removals.Add( n ); + } + + return; + } + + var element = (XMLElementNode) n; + + if ( RegexUtility.MatchingIgnoreCase( element.nameSpace, inkspaceNamespaceRegex ) ) + { + removals.Add( element ); + return; + } + + var attRemovals = new List(); + + for ( int i = 0; i < element.numAttributes; i++ ) + { + var att = element.GetAttributeAt( i ); + + if ( ! RegexUtility.MatchingIgnoreCase( att.nameSpace, inkspaceNamespaceRegex ) ) + { + continue; + } + + attRemovals.Add( i ); + } + + + for ( int i = attRemovals.Count - 1; i >= 0; i -- ) + { + var index = attRemovals[ i ]; + element.RemoveAttributeAt( index ); + } + + + } + ); + + + removals.ForEach( n => n.parentElement.RemoveChild( n ) ); + } + + public static bool HasTextParent( XMLNode node ) + { + var parent = node.parentElement; + + if ( parent == null ) + { + return false; + } + + var parentName = parent.nodeName; + + var textElementRegex = "^(text|tspan)$"; + + return RegexUtility.MatchingIgnoreCase( parentName, textElementRegex ); + } + + public static List GetLayers( XMLDocument doc, bool onlyTopLayers = false ) + { + + if ( onlyTopLayers ) + { + var svg = doc.querySelector( SVGElementName.svg ); + + var list = new List(); + + for ( int i = 0; i < svg.numChildren; i++ ) + { + var child = svg.GetChildAt( i ); + var elementChild = child as XMLElementNode; + + if ( elementChild != null && label.Selects( elementChild ) ) + { + list.Add( elementChild ); + } + } + + return list; + } + + return doc.querySelectorAll( Inkscape.label ); + } + + public static string GetLayerName( XMLElementNode node ) + { + return label.Get( node ); + } + } +} \ No newline at end of file diff --git a/Runtime/XML/SVG/SVGAttributeName.cs b/Runtime/XML/SVG/SVGAttributeName.cs index 7257aa0..114f728 100644 --- a/Runtime/XML/SVG/SVGAttributeName.cs +++ b/Runtime/XML/SVG/SVGAttributeName.cs @@ -7,5 +7,6 @@ namespace Rokojori public class SVGAttributeName { public static readonly XMLAttributeName d = XMLAttributeName.Create( "d" ); + public static readonly XMLAttributeName style = XMLAttributeName.Create( "style" ); } } \ No newline at end of file diff --git a/Runtime/XML/SVG/SVGInkscapeLayerSeperator.cs b/Runtime/XML/SVG/SVGInkscapeLayerSeperator.cs new file mode 100644 index 0000000..6d15009 --- /dev/null +++ b/Runtime/XML/SVG/SVGInkscapeLayerSeperator.cs @@ -0,0 +1,110 @@ +using Godot; +using System; +using System.Collections.Generic; + +namespace Rokojori +{ + [Tool] + [GlobalClass] + public partial class SVGInkscapeLayerSeperator:Node + { + string _inputDirectory; + + [Export] + public string inputDirectory + { + get => _inputDirectory; + set + { + _inputDirectory = value; + + } + } + + [Export] + public string outputDirectory; + + [Export] + public bool processFlag + { + get => false; + set { if ( value ) ProcessDocuments(); } + } + + public override void _Process( double delta ) + { + + } + + void ProcessDocuments() + { + var files = FilesSync.GetFiles( inputDirectory, p => p.HasFileExtension( "svg" ), true ); + + for ( int i = 0; i < files.Count; i++ ) + { + var input = files[ i ].fullPath; + var output = outputDirectory + "/" + files[ i ].fileName + "-"; + ProcessDocument( input, output ); + } + } + + void ProcessDocument( string inputPath, string outputPath ) + { + var text = FilesSync.LoadUTF8( inputPath ); + var reader = new XMLReader(); + + var doc = reader.Read( text ); + + var layers = Inkscape.GetLayers( doc, true ); + var layerNames = Lists.Map( layers, l => Inkscape.GetLayerName( l ) ); + + Inkscape.StripEditorData( doc ); + + var svgElement = doc.querySelector( SVGElementName.svg ); + + layers.ForEach( l => svgElement.RemoveChild( l ) ); + + + for ( int i = 0; i < layers.Count; i++ ) + { + if ( layerNames[ i ].StartsWith( "__" ) ) + { + continue; + } + + svgElement.AppendChild( layers[ i ] ); + + + + var style = SVGAttributeName.style.Get( layers[ i ] ); + var hidden = "display:none"; + + if ( style == hidden ) + { + SVGAttributeName.style.RemoveFrom( layers[ i ] ); + + } + + var serializer = new XMLSerializer(); + var layerDocString = serializer.SerializeXMLNode( doc ); + + svgElement.RemoveChild( layers[ i ] ); + + FilesSync.SaveUTF8( outputPath + layerNames[ i ] + ".svg", layerDocString ); + + // var layerDoc = XMLDocument.From( docString ); + + // var name = Inkscape.GetLayerName( layers[ i ] ); + // var parent = layers[ i ].parentElement; + + // var parentName = parent == null ? "" : parent.nodeName; + // this.LogInfo( i, name, parentName ); + } + + + + // FilesSync.SaveUTF8( inputPath + "-copy.xml", docString ); + } + } + +} \ No newline at end of file diff --git a/Runtime/XML/XMLAttributeName.cs b/Runtime/XML/XMLAttributeName.cs index 1a8f1be..d681f5a 100644 --- a/Runtime/XML/XMLAttributeName.cs +++ b/Runtime/XML/XMLAttributeName.cs @@ -61,6 +61,17 @@ namespace Rokojori return atttribute == null ? null : atttribute.nodeValue; } + public void Set( XMLElementNode elementNode, string value ) + { + elementNode.SetAttribute( _attributeName, value, _nameSpace ); + } + + public void RemoveFrom( XMLElementNode elementNode ) + { + var att = GetAttribute( elementNode ); + elementNode.RemoveAttribute( att ); + } + public bool Selects( XMLElementNode elementNode ) { diff --git a/Runtime/XML/XMLElementNodeName.cs b/Runtime/XML/XMLElementNodeName.cs index 8b90f1b..65900ae 100644 --- a/Runtime/XML/XMLElementNodeName.cs +++ b/Runtime/XML/XMLElementNodeName.cs @@ -6,6 +6,7 @@ namespace Rokojori { public class XMLElementNodeName:XMLElementSelector { + string _nodeName; string _nameSpace; diff --git a/Runtime/XML/XMLReader.cs b/Runtime/XML/XMLReader.cs index ffff316..b403a1f 100644 --- a/Runtime/XML/XMLReader.cs +++ b/Runtime/XML/XMLReader.cs @@ -19,6 +19,8 @@ string text; + + public XMLDocument Read( string text ) { this.text = text; @@ -78,9 +80,19 @@ if ( XMLLexer.Inside_Start_Tag == e.mode ) { - if ( XMLLexer.XMLStartTagClosing.Matches( e ) ) + if ( + XMLLexer.XMLStartTagClosingElement.Matches( e ) || + XMLLexer.XMLStartTagClosingTag.Matches( e ) + ) { SetElementAttributes(); + + if ( XMLLexer.XMLStartTagClosingElement.Matches( e ) ) + { + + // RJLog.Log( "Closing", node, ">>\n", node.parentNode ); + node = node.parentNode; + } } else { @@ -127,7 +139,7 @@ node = element; } - else if ( XMLLexer.XMLEndTag.Matches( e ) ) + else if ( XMLLexer.XMLEndTag.Matches( e ) && node != document ) { var el = (XMLElementNode) node; node = el.parentNode; @@ -219,6 +231,8 @@ void Add( XMLNode childNode ) { + // RJLog.Log( "Adding to Doc", childNode.GetType().Name, childNode.GetInfo(), "is doc element:", document.documentElement == childNode ); + if ( node == document ) { document.AppendChild( childNode ); diff --git a/Runtime/XML/XMLSerializer.cs b/Runtime/XML/XMLSerializer.cs index 97c70f9..554425a 100644 --- a/Runtime/XML/XMLSerializer.cs +++ b/Runtime/XML/XMLSerializer.cs @@ -48,7 +48,7 @@ namespace Rokojori var element = n as XMLElementNode; - RJLog.Log( "Processing:", n ); + // RJLog.Log( "Processing:", n ); if ( element != null ) {