v0.5 Finish
This commit is contained in:
parent
ebc2d0dcae
commit
e27d2e9ef1
|
|
@ -5,6 +5,7 @@ using System.Collections.Generic;
|
|||
using System.Globalization;
|
||||
using System;
|
||||
using System.Data;
|
||||
using Rokojori.Tools;
|
||||
|
||||
namespace Rokojori
|
||||
{
|
||||
|
|
@ -17,9 +18,9 @@ namespace Rokojori
|
|||
#else
|
||||
[Tool]
|
||||
public partial class RokojoriPlugin: EditorPlugin
|
||||
|
||||
{
|
||||
GizmoDrawerPlugin gizmoDrawerPlugin = new GizmoDrawerPlugin();
|
||||
GodotEditorInspectorTools inspectorTools = new GodotEditorInspectorTools();
|
||||
|
||||
public static readonly string path = "res://addons/rokojori_action_library";
|
||||
|
||||
|
|
@ -123,6 +124,8 @@ namespace Rokojori
|
|||
|
||||
AddNode3DGizmoPlugin( gizmoDrawerPlugin );
|
||||
|
||||
inspectorTools.rokojoriPlugin = this;
|
||||
inspectorTools.AddPlugins();
|
||||
// var pePackedScene = GD.Load<PackedScene>( ProblemsExplorerPath );
|
||||
|
||||
// if ( pePackedScene != null )
|
||||
|
|
@ -157,6 +160,9 @@ namespace Rokojori
|
|||
}
|
||||
|
||||
RemoveNode3DGizmoPlugin( gizmoDrawerPlugin );
|
||||
|
||||
inspectorTools.rokojoriPlugin = this;
|
||||
inspectorTools.RemovePlugins();
|
||||
}
|
||||
|
||||
bool wasDisposed = true;
|
||||
|
|
|
|||
|
|
@ -263,3 +263,14 @@ bool ditherDiscard( float ditherFadeValue, vec4 _FRAGCOORD )
|
|||
vec3 magic = vec3( 0.06711056, 0.00583715, 52.9829189 );
|
||||
return ditherFadeValue < 0.001 || ditherFadeValue < fract( magic.z * fract( dot( _FRAGCOORD.xy, magic.xy ) ) );
|
||||
}
|
||||
|
||||
|
||||
bool perlinDiscard( float ditherFadeValue, vec2 _FRAGCOORD, float fadeBlend )
|
||||
{
|
||||
|
||||
float scale = mapClamped( ditherFadeValue, 1.0, 1.0 - fadeBlend, 0.0, 1.0 );
|
||||
|
||||
float offset = perlin( _FRAGCOORD ) * scale;
|
||||
|
||||
return ( ditherFadeValue + offset ) < 1.0;
|
||||
}
|
||||
|
|
@ -6,6 +6,7 @@
|
|||
#include "res://addons/rokojori_action_library/Runtime/Shading/Library/Noise.gdshaderinc"
|
||||
|
||||
uniform vec4 albedo : source_color;
|
||||
uniform float multiplyAlbedoByAlpha:hint_range(0,1) = 0;
|
||||
|
||||
uniform float driver:hint_range(0,1) = 0;
|
||||
|
||||
|
|
@ -78,6 +79,11 @@ void fragment()
|
|||
float noise2 = perlin3D( relativeWorldVertex * noiseScale2 + ( noiseScroll2 + noiseScrollFromScanDirection2 * normalizedScanDir )* TIME );
|
||||
|
||||
noise2 = mix( 1, noise2, noiseAmount2 );
|
||||
ALBEDO = albedo.rgb * scanColor.rgb;
|
||||
ALPHA = clamp01( albedo.a * scanColor.a * noise * noise2 );
|
||||
float alphaValue = clamp01( albedo.a * scanColor.a * noise * noise2 );
|
||||
|
||||
float alphaMultiply = mix( 1.0, alphaValue, multiplyAlbedoByAlpha );
|
||||
ALBEDO = albedo.rgb * scanColor.rgb * alphaMultiply;
|
||||
|
||||
ALPHA = alphaValue;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,24 @@
|
|||
[gd_resource type="VisualShader" load_steps=2 format=3 uid="uid://cfpq68lhdwdmq"]
|
||||
|
||||
[sub_resource type="VisualShaderNodeGlobalExpression" id="VisualShaderNodeGlobalExpression_gj0vb"]
|
||||
size = Vector2(360, 160)
|
||||
expression = "#include \"res://addons/rokojori_action_library/Runtime/Shading/Shaders/Effects/Scanner/ScannerBase.gdshaderinc\""
|
||||
|
||||
[resource]
|
||||
code = "shader_type spatial;
|
||||
render_mode blend_premul_alpha, depth_draw_never, depth_test_default, cull_back, diffuse_lambert, specular_schlick_ggx, unshaded;
|
||||
|
||||
|
||||
|
||||
// GlobalExpression:0
|
||||
#include \"res://addons/rokojori_action_library/Runtime/Shading/Shaders/Effects/Scanner/ScannerBase.gdshaderinc\"
|
||||
"
|
||||
modes/blend = 4
|
||||
modes/depth_draw = 2
|
||||
flags/unshaded = true
|
||||
nodes/vertex/2/node = SubResource("VisualShaderNodeGlobalExpression_gj0vb")
|
||||
nodes/vertex/2/position = Vector2(-140, 60)
|
||||
nodes/vertex/2/size = Vector2(360, 160)
|
||||
nodes/vertex/2/input_ports = ""
|
||||
nodes/vertex/2/output_ports = ""
|
||||
nodes/vertex/2/expression = "#include \"res://addons/rokojori_action_library/Runtime/Shading/Shaders/Effects/Scanner/ScannerBase.gdshaderinc\""
|
||||
|
|
@ -10,6 +10,12 @@ namespace Rokojori
|
|||
[Export]
|
||||
public FlashPreset preset;
|
||||
|
||||
[Export, ReadOnly]
|
||||
public string test = "3";
|
||||
|
||||
[Export, NamedArray ]
|
||||
public FlareLayer[] layers = [];
|
||||
|
||||
[Export]
|
||||
public Node[] targets;
|
||||
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ gradient = SubResource("Gradient_ad8tv")
|
|||
render_priority = 0
|
||||
shader = ExtResource("4_gli2s")
|
||||
shader_parameter/albedo = Color(4.2130003, 4.2130003, 4.2130003, 1)
|
||||
shader_parameter/multiplyAlbedoByAlpha = 0.0
|
||||
shader_parameter/driver = 0.0
|
||||
shader_parameter/position = Vector3(0, 0, 0)
|
||||
shader_parameter/direction = Vector3(0, 1, 0)
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ use_hdr = true
|
|||
render_priority = 0
|
||||
shader = ExtResource("4_uu110")
|
||||
shader_parameter/albedo = Color(4.2130003, 4.2130003, 4.2130003, 1)
|
||||
shader_parameter/multiplyAlbedoByAlpha = 0.0
|
||||
shader_parameter/driver = 0.0
|
||||
shader_parameter/position = Vector3(0, 0, 0)
|
||||
shader_parameter/direction = Vector3(0, 1, 0)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,7 @@
|
|||
using System;
|
||||
namespace Rokojori;
|
||||
|
||||
public class InfoAttribute : Attribute
|
||||
{
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://umduhx2b15in
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
using System;
|
||||
using Godot;
|
||||
|
||||
|
||||
namespace Rokojori.Tools;
|
||||
|
||||
|
||||
#if TOOLS
|
||||
public partial class InfoAttributeDrawer : GodotEditorAttributeDrawer<InfoAttribute>
|
||||
{
|
||||
protected override Control GetPropertyEditor(
|
||||
Variant.Type type, string name, PropertyHint hintType, string hintString,
|
||||
PropertyUsageFlags usageFlags, bool wide, object value
|
||||
)
|
||||
{
|
||||
return new Label() { Text = $"{ value.ToString() ?? "" }" };
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://cxgt07gnemhdw
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
using System;
|
||||
namespace Rokojori;
|
||||
|
||||
public class NamedArrayAttribute : Attribute
|
||||
{
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://co7psqyxy1up7
|
||||
|
|
@ -0,0 +1,117 @@
|
|||
using System;
|
||||
using Godot;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Rokojori.Tools;
|
||||
|
||||
|
||||
#if TOOLS
|
||||
|
||||
|
||||
[Tool]
|
||||
|
||||
public partial class NamedArrayEditor:EditorProperty
|
||||
{
|
||||
VBoxContainer _container;
|
||||
List<object> _values = [];
|
||||
bool _updating = false;
|
||||
Type _arrayItemType;
|
||||
|
||||
public NamedArrayEditor( Type arrayItemType )
|
||||
{
|
||||
_container = new VBoxContainer();
|
||||
_arrayItemType = arrayItemType;
|
||||
AddChild( _container );
|
||||
AddFocusable( _container );
|
||||
}
|
||||
|
||||
|
||||
public override void _UpdateProperty()
|
||||
{
|
||||
_container.DestroyChildren();
|
||||
|
||||
var value = GetEditedObject().Get( GetEditedProperty() ).AsGodotArray();
|
||||
|
||||
_updating = true;
|
||||
|
||||
for ( int i = 0; i < value.Count; i++ )
|
||||
{
|
||||
var hbox = new HBoxContainer();
|
||||
|
||||
var label = new Label();
|
||||
label.Text = ( i + 1 ) + ":";
|
||||
hbox.AddChild( label );
|
||||
|
||||
var item = value[ i ];
|
||||
var editor = EditorInspector.InstantiatePropertyEditor(
|
||||
(GodotObject) item, item.VariantType,
|
||||
"", PropertyHint.None, "",
|
||||
(uint) PropertyUsageFlags.Editor, false
|
||||
);
|
||||
|
||||
editor.UpdateProperty();
|
||||
hbox.AddChild( editor );
|
||||
|
||||
_container.AddChild( hbox );
|
||||
|
||||
}
|
||||
|
||||
var button = new Button();
|
||||
button.Text = "+";
|
||||
|
||||
button.Pressed += ()=>
|
||||
{
|
||||
var array = GetEditedObject().Get( GetEditedProperty() ).AsGodotArray();
|
||||
|
||||
// array.Add( Variant.From<( null ) );
|
||||
};
|
||||
|
||||
_container.AddChild( button );
|
||||
|
||||
|
||||
_updating = false;
|
||||
}
|
||||
|
||||
// Variant CreateDefaultValue( Type type )
|
||||
// {
|
||||
// if ( typeof( int ) == type )
|
||||
// {
|
||||
// return 0;
|
||||
// }
|
||||
|
||||
// if ( typeof( float ) == type )
|
||||
// {
|
||||
// return 0f;
|
||||
// }
|
||||
|
||||
// if ( typeof( bool ) == type )
|
||||
// {
|
||||
// return false;
|
||||
// }
|
||||
|
||||
// if ( typeof( string ) == type )
|
||||
// {
|
||||
// return "";
|
||||
// }
|
||||
|
||||
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
|
||||
public partial class NamedArrayAttributeDrawer : GodotEditorAttributeDrawer<NamedArrayAttribute>
|
||||
{
|
||||
protected override Control GetPropertyEditor(
|
||||
Variant.Type type, string name, PropertyHint hintType, string hintString,
|
||||
PropertyUsageFlags usageFlags, bool wide, object value
|
||||
)
|
||||
{
|
||||
var itemType = ReflectionHelper.GetDataMemberInfo( godotObject, name ).GetType().GetElementType();
|
||||
return new NamedArrayEditor( itemType );
|
||||
// var typeName = value == null ? "null" : value.GetType().Name;
|
||||
// return new Label() { Text = typeName };
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://b8buka2dlp53x
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
using System;
|
||||
namespace Rokojori;
|
||||
|
||||
public class ReadOnlyAttribute : Attribute
|
||||
{
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://e44nnts2vx27
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
using System;
|
||||
using Godot;
|
||||
|
||||
|
||||
namespace Rokojori.Tools;
|
||||
|
||||
|
||||
#if TOOLS
|
||||
public partial class ReadOnlyAttributeDrawer : GodotEditorAttributeDrawer<ReadOnlyAttribute>
|
||||
{
|
||||
protected override Control GetPropertyEditor(
|
||||
Variant.Type type, string name, PropertyHint hintType, string hintString,
|
||||
PropertyUsageFlags usageFlags, bool wide, object value
|
||||
)
|
||||
{
|
||||
return new Label() { Text = $"{name}: { value.ToString() ?? "null" }" };
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://cfpqhdrn3rcjb
|
||||
|
|
@ -18,8 +18,14 @@ public abstract partial class GodotEditorAttributeDrawer<A> : GodotEditorInspect
|
|||
|
||||
if ( GetValueOfMemberWithAttribute( obj, name, typeof(A), out object value ) )
|
||||
{
|
||||
var control = GetPropertyEditor( type, name, hintType, hintString, usageFlags, wide, value );
|
||||
AddPropertyEditor( name, control );
|
||||
var editor = GetPropertyEditor( type, name, hintType, hintString, usageFlags, wide, value );
|
||||
|
||||
if ( editor == null )
|
||||
{
|
||||
return base._ParseProperty( obj, type, name, hintType, hintString, usageFlags, wide );
|
||||
}
|
||||
|
||||
AddPropertyEditor( name, editor );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -27,6 +33,7 @@ public abstract partial class GodotEditorAttributeDrawer<A> : GodotEditorInspect
|
|||
return base._ParseProperty( obj, type, name, hintType, hintString, usageFlags, wide );
|
||||
}
|
||||
|
||||
|
||||
protected abstract Control GetPropertyEditor(
|
||||
Variant.Type type, string name, PropertyHint hintType,
|
||||
string hintString, PropertyUsageFlags usageFlags, bool wide, object value
|
||||
|
|
|
|||
|
|
@ -0,0 +1,106 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using Godot;
|
||||
using System.Linq;
|
||||
|
||||
namespace Rokojori.Tools;
|
||||
|
||||
public class GodotEditorInspectorTools
|
||||
{
|
||||
List<EditorInspectorPlugin> registeredPlugins = [];
|
||||
public RokojoriPlugin rokojoriPlugin;
|
||||
|
||||
public void AddPlugins()
|
||||
{
|
||||
registeredPlugins = new List<EditorInspectorPlugin>();
|
||||
|
||||
// var plugins = GetGodotEditorInspectorPluginsInAssembly();
|
||||
|
||||
List<EditorInspectorPlugin> plugins =
|
||||
[
|
||||
new InfoAttributeDrawer(),
|
||||
new ReadOnlyAttributeDrawer(),
|
||||
|
||||
new NamedArrayAttributeDrawer()
|
||||
];
|
||||
|
||||
plugins.ForEach(
|
||||
p =>
|
||||
{
|
||||
try
|
||||
{
|
||||
rokojoriPlugin.AddInspectorPlugin( p );
|
||||
RJLog.Log( $"Registered inspector for: {p.GetType().FullName}" );
|
||||
}
|
||||
catch ( Exception e )
|
||||
{
|
||||
RJLog.Error( $"Error adding inspector automatically: {p.GetType().Name}. Skipping. {e}");
|
||||
return;
|
||||
}
|
||||
|
||||
registeredPlugins.Add( p );
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void RemovePlugins()
|
||||
{
|
||||
registeredPlugins.ForEach( rokojoriPlugin.RemoveInspectorPlugin );
|
||||
}
|
||||
|
||||
static bool IsSubclassOfGeneric( Type type, Type genericBaseType )
|
||||
{
|
||||
var it = type.BaseType;
|
||||
|
||||
while ( it != null )
|
||||
{
|
||||
if ( it.IsGenericType && it.GetGenericTypeDefinition() == genericBaseType )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
it = it.BaseType;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
List<EditorInspectorPlugin> GetGodotEditorInspectorPluginsInAssembly()
|
||||
{
|
||||
var results = new List<EditorInspectorPlugin>();
|
||||
var baseType = typeof( GodotEditorInspector<> );
|
||||
|
||||
foreach ( var assembly in AppDomain.CurrentDomain.GetAssemblies() )
|
||||
{
|
||||
try
|
||||
{
|
||||
var types = assembly.GetTypes().Where( t => t.IsClass && ! t.IsAbstract && IsSubclassOfGeneric( t, baseType ) );
|
||||
|
||||
foreach ( var type in types )
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( Activator.CreateInstance( type ) is EditorInspectorPlugin pluginInstance )
|
||||
{
|
||||
results.Add(pluginInstance);
|
||||
}
|
||||
}
|
||||
catch ( Exception e )
|
||||
{
|
||||
RJLog.Error( $"Unable creating instance of type {type.Name}. {e.Message}" );
|
||||
}
|
||||
}
|
||||
}
|
||||
catch ( ReflectionTypeLoadException e )
|
||||
{
|
||||
RJLog.Error( $"Unable to load types from assembly: {assembly.FullName}. {e.Message} ");
|
||||
}
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://bfq4t4jyytoft
|
||||
Loading…
Reference in New Issue