Unique/Nodes Update
This commit is contained in:
parent
273f1caa35
commit
1e0ffa9761
|
@ -0,0 +1,90 @@
|
|||
using Godot;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
|
||||
namespace Rokojori
|
||||
{
|
||||
/*
|
||||
|
||||
Match: [ (\w+)]
|
||||
Replace: [ "$1",]
|
||||
|
||||
*/
|
||||
|
||||
public class ExtendingControlGodotClassList
|
||||
{
|
||||
public static List<string> list = new List<string>
|
||||
{
|
||||
"AspectRatioContainer",
|
||||
"BaseButton",
|
||||
"BoxContainer",
|
||||
"Button",
|
||||
"CenterContainer",
|
||||
"CheckBox",
|
||||
"CheckButton",
|
||||
"CodeEdit",
|
||||
"ColorPicker",
|
||||
"ColorPickerButton",
|
||||
"ColorRect",
|
||||
"Container",
|
||||
"EditorInspector",
|
||||
"EditorProperty",
|
||||
"EditorResourcePicker",
|
||||
"EditorScriptPicker",
|
||||
"EditorSpinSlider",
|
||||
"FileSystemDock",
|
||||
"FlowContainer",
|
||||
"GraphEdit",
|
||||
"GraphElement",
|
||||
"GraphNode",
|
||||
"GridContainer",
|
||||
"HBoxContainer",
|
||||
"HFlowContainer",
|
||||
"HScrollBar",
|
||||
"HSeparator",
|
||||
"HSlider",
|
||||
"HSplitContainer",
|
||||
"ItemList",
|
||||
"Label",
|
||||
"LineEdit",
|
||||
"LinkButton",
|
||||
"MarginContainer",
|
||||
"MenuBar",
|
||||
"MenuButton",
|
||||
"NinePatchRect",
|
||||
"OptionButton",
|
||||
"Panel",
|
||||
"PanelContainer",
|
||||
"ProgressBar",
|
||||
"Range",
|
||||
"ReferenceRect",
|
||||
"RichTextLabel",
|
||||
"ScriptEditor",
|
||||
"ScriptEditorBase",
|
||||
"ScrollBar",
|
||||
"ScrollContainer",
|
||||
"Separator",
|
||||
"Slider",
|
||||
"SpinBox",
|
||||
"SplitContainer",
|
||||
"SubViewportContainer",
|
||||
"TabBar",
|
||||
"TabContainer",
|
||||
"TextEdit",
|
||||
"TextureButton",
|
||||
"TextureProgressBar",
|
||||
"TextureRect",
|
||||
"Tree",
|
||||
"VBoxContainer",
|
||||
"VFlowContainer",
|
||||
"VScrollBar",
|
||||
"VSeparator",
|
||||
"VSlider",
|
||||
"VSplitContainer",
|
||||
"VideoStreamPlayer",
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
using Godot;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
|
||||
namespace Rokojori
|
||||
{
|
||||
|
||||
/*
|
||||
|
||||
Match: [ (\w+)]
|
||||
Replace: [ "$1",]
|
||||
|
||||
*/
|
||||
public class ExtendingNode2DGodotClassList
|
||||
{
|
||||
public static List<string> list = new List<string>
|
||||
{
|
||||
"AnimatableBody2D",
|
||||
"AnimatedSprite2D",
|
||||
"Area2D",
|
||||
"AudioListener2D",
|
||||
"AudioStreamPlayer2D",
|
||||
"BackBufferCopy",
|
||||
"Bone2D",
|
||||
"CPUParticles2D",
|
||||
"Camera2D",
|
||||
"CanvasGroup",
|
||||
"CanvasModulate",
|
||||
"CharacterBody2D",
|
||||
"CollisionObject2D",
|
||||
"CollisionPolygon2D",
|
||||
"CollisionShape2D",
|
||||
"DampedSpringJoint2D",
|
||||
"DirectionalLight2D",
|
||||
"GPUParticles2D",
|
||||
"GrooveJoint2D",
|
||||
"Joint2D",
|
||||
"Light2D",
|
||||
"LightOccluder2D",
|
||||
"Line2D",
|
||||
"Marker2D",
|
||||
"MeshInstance2D",
|
||||
"MultiMeshInstance2D",
|
||||
"NavigationLink2D",
|
||||
"NavigationObstacle2D",
|
||||
"NavigationRegion2D",
|
||||
"ParallaxLayer",
|
||||
"Path2D",
|
||||
"PathFollow2D",
|
||||
"PhysicalBone2D",
|
||||
"PhysicsBody2D",
|
||||
"PinJoint2D",
|
||||
"PointLight2D",
|
||||
"Polygon2D",
|
||||
"RayCast2D",
|
||||
"RemoteTransform2D",
|
||||
"RigidBody2D",
|
||||
"ShapeCast2D",
|
||||
"Skeleton2D",
|
||||
"Sprite2D",
|
||||
"StaticBody2D",
|
||||
"TileMap",
|
||||
"TouchScreenButton",
|
||||
"VisibleOnScreenEnabler2D",
|
||||
"VisibleOnScreenNotifier2D"
|
||||
};
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,104 @@
|
|||
using Godot;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
|
||||
namespace Rokojori
|
||||
{
|
||||
/*
|
||||
|
||||
Match: [ (\w+)]
|
||||
Replace: [ "$1",]
|
||||
|
||||
*/
|
||||
|
||||
public class ExtendingNode3DGodotClassList
|
||||
{
|
||||
public static List<string> list = new List<string>
|
||||
{
|
||||
"AnimatableBody3D",
|
||||
"AnimatedSprite3D",
|
||||
"Area3D",
|
||||
"AudioListener3D",
|
||||
"AudioStreamPlayer3D",
|
||||
"BoneAttachment3D",
|
||||
"CPUParticles3D",
|
||||
"CSGBox3D",
|
||||
"CSGCombiner3D",
|
||||
"CSGCylinder3D",
|
||||
"CSGMesh3D",
|
||||
"CSGPolygon3D",
|
||||
"CSGPrimitive3D",
|
||||
"CSGShape3D",
|
||||
"CSGSphere3D",
|
||||
"CSGTorus3D",
|
||||
"Camera3D",
|
||||
"CharacterBody3D",
|
||||
"CollisionObject3D",
|
||||
"CollisionPolygon3D",
|
||||
"CollisionShape3D",
|
||||
"ConeTwistJoint3D",
|
||||
"Decal",
|
||||
"DirectionalLight3D",
|
||||
"FogVolume",
|
||||
"GPUParticles3D",
|
||||
"GPUParticlesAttractor3D",
|
||||
"GPUParticlesAttractorBox3D",
|
||||
"GPUParticlesAttractorSphere3D",
|
||||
"GPUParticlesAttractorVectorField3D",
|
||||
"GPUParticlesCollision3D",
|
||||
"GPUParticlesCollisionBox3D",
|
||||
"GPUParticlesCollisionHeightField3D",
|
||||
"GPUParticlesCollisionSDF3D",
|
||||
"GPUParticlesCollisionSphere3D",
|
||||
"Generic6DOFJoint3D",
|
||||
"GeometryInstance3D",
|
||||
"GridMap",
|
||||
"HingeJoint3D",
|
||||
"Joint3D",
|
||||
"Label3D",
|
||||
"Light3D",
|
||||
"LightmapGI",
|
||||
"LightmapProbe",
|
||||
"Marker3D",
|
||||
"MeshInstance3D",
|
||||
"MultiMeshInstance3D",
|
||||
"NavigationLink3D",
|
||||
"NavigationObstacle3D",
|
||||
"NavigationRegion3D",
|
||||
"OccluderInstance3D",
|
||||
"OmniLight3D",
|
||||
"OpenXRHand",
|
||||
"Path3D",
|
||||
"PathFollow3D",
|
||||
"PhysicalBone3D",
|
||||
"PhysicsBody3D",
|
||||
"PinJoint3D",
|
||||
"RayCast3D",
|
||||
"ReflectionProbe",
|
||||
"RemoteTransform3D",
|
||||
"RigidBody3D",
|
||||
"RootMotionView",
|
||||
"ShapeCast3D",
|
||||
"Skeleton3D",
|
||||
"SliderJoint3D",
|
||||
"SoftBody3D",
|
||||
"SpotLight3D",
|
||||
"SpringArm3D",
|
||||
"Sprite3D",
|
||||
"SpriteBase3D",
|
||||
"StaticBody3D",
|
||||
"VehicleBody3D",
|
||||
"VehicleWheel3D",
|
||||
"VisibleOnScreenEnabler3D",
|
||||
"VisibleOnScreenNotifier3D",
|
||||
"VisualInstance3D",
|
||||
"VoxelGI",
|
||||
"XRAnchor3D",
|
||||
"XRCamera3D",
|
||||
"XRController3D",
|
||||
"XRNode3D",
|
||||
"XROrigin3D"
|
||||
};
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
using Godot;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
|
||||
namespace Rokojori
|
||||
{
|
||||
public class ExtendingGodotClassList
|
||||
{
|
||||
public static List<string> list = Lists.CombineAll(
|
||||
ExtendingControlGodotClassList.list,
|
||||
ExtendingNode2DGodotClassList.list,
|
||||
ExtendingNode3DGodotClassList.list
|
||||
);
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,96 @@
|
|||
using Godot;
|
||||
using System.Text;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Rokojori
|
||||
{
|
||||
[Tool]
|
||||
[GlobalClass]
|
||||
public partial class GodotClassGenerator:Node
|
||||
{
|
||||
[Export]
|
||||
public string outputPath;
|
||||
|
||||
[Export]
|
||||
public bool exportFlag;
|
||||
|
||||
[Export]
|
||||
public string testClass;
|
||||
|
||||
public override void _Process( double delta )
|
||||
{
|
||||
if ( exportFlag )
|
||||
{
|
||||
exportFlag = false;
|
||||
var result = CreateClass( testClass );
|
||||
FilesSync.SaveUTF8( outputPath + testClass + ".cs", result );
|
||||
}
|
||||
}
|
||||
|
||||
public string CreateClass( string name )
|
||||
{
|
||||
var output = new StringBuilder();
|
||||
|
||||
output.Append( "using Godot;\n" );
|
||||
output.Append( "\n" );
|
||||
output.Append( "namespace Rokojori\n" );
|
||||
output.Append( "{\n" );
|
||||
output.Append( "\n" );
|
||||
|
||||
output.Append( " [GlobalClass]\n");
|
||||
output.Append( " public partial class RJ" + name + ":" + name + "\n");
|
||||
output.Append( " {\n" );
|
||||
|
||||
var classType = ReflectionHelper.GetTypeByName( name );
|
||||
|
||||
if ( classType == null )
|
||||
{
|
||||
RJLog.Log( "Type is null" );
|
||||
return "";
|
||||
}
|
||||
|
||||
output.Append( " \n" );
|
||||
var bindingFlags = BindingFlags.Instance | BindingFlags.Public;
|
||||
EventInfo[] events = classType.GetEvents( bindingFlags );
|
||||
|
||||
for ( int i = 0; i < events.Length; i++ )
|
||||
{
|
||||
var ev = events[ i ];
|
||||
var eventName = ev.Name;
|
||||
|
||||
output.Append( " [Export]\n" );
|
||||
output.Append( " public RJAction On" + eventName + ";\n" );
|
||||
}
|
||||
|
||||
output.Append( " \n" );
|
||||
|
||||
output.Append( " public override void _Ready()\n" );
|
||||
output.Append( " {\n" );
|
||||
|
||||
for ( int i = 0; i < events.Length; i++ )
|
||||
{
|
||||
var ev = events[ i ];
|
||||
var eventName = ev.Name;
|
||||
var parameters = ev.GetRaiseMethod().GetParameters();
|
||||
var p = "(";
|
||||
for ( int pn = 0; pn < parameters.Length; pn ++ )
|
||||
{
|
||||
p += "p" + pn;
|
||||
}
|
||||
p += ")";
|
||||
|
||||
|
||||
output.Append( " " + eventName + " += " + p + " { Actions.Trigger( On" + eventName +" ); }; \n" );
|
||||
}
|
||||
|
||||
output.Append( " }\n" );
|
||||
|
||||
output.Append( " }\n" );
|
||||
|
||||
output.Append( "}\n" );
|
||||
|
||||
|
||||
return output.ToString();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,11 +1,32 @@
|
|||
using Godot;
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
|
||||
namespace Rokojori
|
||||
{
|
||||
public class Nodes
|
||||
{
|
||||
public static void ForEach<T>( Node root, Action<T> callback ) where T:class
|
||||
{
|
||||
var walker = nodesWalker;
|
||||
|
||||
walker.Iterate( root,
|
||||
( n )=>
|
||||
{
|
||||
var t = n as T;
|
||||
|
||||
if ( t == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
callback( t );
|
||||
|
||||
}
|
||||
,false );
|
||||
}
|
||||
|
||||
public static T GetSibling<T>( Node node ) where T:Node
|
||||
{
|
||||
if ( node == null )
|
||||
|
@ -102,7 +123,23 @@ namespace Rokojori
|
|||
|
||||
public static T GetAnyChild<T>( Node parent ) where T:Node
|
||||
{
|
||||
return (T) nodesWalker.Find( parent, ( n )=> n is T, true );
|
||||
var result = nodesWalker.Find( parent,
|
||||
( n )=>
|
||||
{
|
||||
|
||||
|
||||
var castedNode = n as T;
|
||||
|
||||
RJLog.Log( "Testing", n.UniqueNameInOwner, castedNode != null, n.GetType() );
|
||||
|
||||
return castedNode != null;
|
||||
|
||||
},
|
||||
|
||||
|
||||
true );
|
||||
|
||||
return (T) result;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -3,6 +3,7 @@ using Godot;
|
|||
|
||||
namespace Rokojori
|
||||
{
|
||||
[Tool]
|
||||
public partial class Root:Node
|
||||
{
|
||||
private static Root _singleton;
|
||||
|
@ -14,12 +15,24 @@ namespace Rokojori
|
|||
|
||||
public static SceneTree Tree()
|
||||
{
|
||||
if ( _singleton == null )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return _singleton.GetTree();
|
||||
}
|
||||
|
||||
public static Window Window()
|
||||
{
|
||||
return Tree().Root;
|
||||
var tree = Tree();
|
||||
|
||||
if ( tree == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return tree.Root;
|
||||
}
|
||||
|
||||
public static Root Get()
|
||||
|
|
|
@ -9,16 +9,29 @@ namespace Rokojori
|
|||
{
|
||||
private static N _singleton;
|
||||
|
||||
public static N Get()
|
||||
public static N Get( Node n = null )
|
||||
{
|
||||
if ( _singleton != null )
|
||||
{
|
||||
return _singleton;
|
||||
}
|
||||
|
||||
_singleton = Nodes.GetAnyChild<N>( Root.Window() );
|
||||
var rootWindow = n == null ? Root.Window() : n.Owner;
|
||||
|
||||
RJLog.Log( "ROOT", rootWindow );
|
||||
|
||||
if ( rootWindow == null )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
_singleton = Nodes.GetAnyChild<N>( rootWindow );
|
||||
|
||||
RJLog.Log( "_singleton", _singleton );
|
||||
|
||||
return _singleton;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -3,7 +3,7 @@
|
|||
const float HCV_EPSILON = 1e-10;
|
||||
const float HSL_EPSILON = 1e-10;
|
||||
|
||||
vec3 RGBtoHCV( vec3 rgb )
|
||||
vec3 RGBtoHCV( vec3 rgb )
|
||||
{
|
||||
vec4 P = ( rgb.g < rgb.b ) ? vec4( rgb.bg, -1.0, 2.0/3.0 ) : vec4( rgb.gb, 0.0, -1.0/3.0 );
|
||||
vec4 Q = ( rgb.r < P.x ) ? vec4( P.xyw, rgb.r ) : vec4( rgb.r, P.yzx );
|
||||
|
@ -108,7 +108,7 @@ vec3 HSVtoRGB( vec3 c )
|
|||
{
|
||||
vec4 K = vec4( 1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0 );
|
||||
vec3 p = abs( fract( c.xxx + K.xyz ) * 6.0 - K.www );
|
||||
|
||||
|
||||
return c.z * mix( K.xxx, clamp( p - K.xxx, 0.0, 1.0 ), c.y );
|
||||
}
|
||||
|
||||
|
@ -126,17 +126,16 @@ vec4 mix3_v4( vec4 a, vec4 b, vec4 c, float t )
|
|||
float weightA = mapClamped( t, 0, 0.5, 1, 0 );
|
||||
float weightB = triangle( t );
|
||||
float weightC = mapClamped( t, 0.5, 1, 0, 1 );
|
||||
|
||||
return a * weightA + b * weightB + c * weightC;
|
||||
|
||||
return a * weightA + b * weightB + c * weightC;
|
||||
}
|
||||
|
||||
vec4 scaleRGB( vec4 rgba, float scale )
|
||||
{
|
||||
return vec4( rgba.rgb * scale, rgba.a );
|
||||
return vec4( rgba.rgb * scale, rgba.a );
|
||||
}
|
||||
|
||||
vec4 fade( vec4 rgba, float fade )
|
||||
{
|
||||
return vec4( rgba.rgb, rgba.a * fade );
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,18 @@ namespace Rokojori
|
|||
{
|
||||
public class Lists
|
||||
{
|
||||
public static List<T> CombineAll<T>( params List<T>[] lists )
|
||||
{
|
||||
var list = new List<T>();
|
||||
|
||||
foreach ( var l in lists )
|
||||
{
|
||||
list.AddRange( l );
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public static List<T> ToList<T>( T[] array )
|
||||
{
|
||||
var list = new List<T>();
|
||||
|
|
Loading…
Reference in New Issue