Icon Update

This commit is contained in:
Josef 2024-05-12 19:02:28 +02:00
parent dc8ca36829
commit 81a55f96b8
5 changed files with 112 additions and 17 deletions

View File

@ -10,6 +10,7 @@ class CppClassMember
isMethod = false;
isVirtual = false;
isStatic = false;
isSignal = false;
type = "void";
parameters = [];
@ -36,6 +37,11 @@ class CppClassMember
this.isStatic = true;
}
if ( "signal" === names[ i ] )
{
this.isSignal = true;
}
}
if ( this.isMethod )
@ -83,7 +89,24 @@ class CppClassMember
getMethodBinding( className )
{
if ( this.isVirtual )
if ( this.isSignal )
{
//ADD_SIGNAL(MethodInfo("session_supported", PropertyInfo(Variant::STRING, "session_mode"), PropertyInfo(Variant::BOOL, "supported")));
let parameterInfos = "";
for ( let i = 0; i < this.parameters.length; i++ )
{
let type = stringToVariantType( this.parameters[ i ].type );
let name = this.parameters[ i ].name;
let pi = `, PropertyInfo(Variant::${type}, "${name}")`;
parameterInfos += pi;
}
return `ADD_SIGNAL (MethodInfo( "${this.name}" ${parameterInfos}) );`;
}
else if ( this.isVirtual )
{
return `GDVIRTUAL_BIND( ${this.name} );`;
}
@ -95,7 +118,11 @@ class CppClassMember
getHeaderDefinition()
{
if ( this.isMethod )
if ( this.isSignal )
{
return `/* signal ${this.name} */`;
}
else if ( this.isMethod )
{
return this.getMethodHeaderDefinition();
}
@ -144,3 +171,56 @@ module.exports =
CppParameter,
CppClassMember
}
function stringToVariantType( stringType )
{
switch( stringType )
{
case "bool": return "BOOL";
case "int": return "INT";
case "float": return "FLOAT";
case "String": return "STRING";
// Math types.
case "Vector2": return "VECTOR2";
case "Vector2i": return "VECTOR2I";
case "Rect2": return "RECT2";
case "Rect2i": return "RECT2I";
case "Transform2D": return "TRANSFORM2D";
case "Vector3": return "VECTOR3";
case "Vector3i": return "VECTOR3I";
case "Vector4": return "VECTOR4";
case "Vector4i": return "VECTOR4I";
case "Plane": return "PLANE";
case "AABB": return "AABB";
case "Quaternion": return "QUATERNION";
case "Basis": return "BASIS";
case "Transform3D": return "TRANSFORM3D";
case "Projection": return "PROJECTION";
// Miscellaneous types.
case "Color": return "COLOR";
case "RID": return "RID";
case "Object": return "OBJECT";
case "Callable": return "CALLABLE";
case "Signal": return "SIGNAL";
case "StringName": return "STRING_NAME";
case "NodePath": return "NODE_PATH";
case "Dictionary": return "DICTIONARY";
case "Array": return "ARRAY";
// Arrays.
case "PackedByteArray": return "PACKED_BYTE_ARRAY";
case "PackedInt32Array": return "PACKED_INT32_ARRAY";
case "PackedInt64Array": return "PACKED_INT64_ARRAY";
case "PackedFloat32Array": return "PACKED_FLOAT32_ARRAY";
case "PackedFloat64Array": return "PACKED_FLOAT64_ARRAY";
case "PackedStringArray": return "PACKED_STRING_ARRAY";
case "PackedVector2Array": return "PACKED_VECTOR2_ARRAY";
case "PackedVector3Array": return "PACKED_VECTOR3_ARRAY";
case "PackedColorArray": return "PACKED_COLOR_ARRAY";
}
return null;
}

View File

@ -3,7 +3,7 @@ const path = require( "path" );
const { loadJSON, getFiles, saveUTF8, getMatches, loadUTF8, insertText } = require( "./library.js" );
const { CppClassMember } = require( "./cpp-class-member.js" );
function createCppHeader( className, extendingClassName, headerDefine, protectedMembers, publicMembers )
function createCppHeader( className, extendingClassName, headerDefine, protectedMembers, publicMembers, includes )
{
let cppHeader =
@ -14,6 +14,7 @@ let cppHeader =
#ifndef ${headerDefine}
#define ${headerDefine}
${includes}
#include "./${extendingClassName}.h"
@ -92,6 +93,8 @@ function createIncludes( className )
async function main()
{
let files = await getFiles( definitionsPath );
files = files.filter( f => ! f.startsWith( "_" ) );
let typesFile = await loadUTF8( registerTypesPath );
let types = getRegistratedTypes( typesFile );
@ -185,7 +188,7 @@ function getHeaderDefine( className )
className = output.join( "" );
return "ROKOJORI_CORE__" + className + "_H";
return "ROKOJORI__" + className + "_H";
}
function getRegistratedTypes( text )
@ -209,7 +212,11 @@ async function createCppFiles( definitionPath, types, missingTypes )
{
console.log( "Creating: ", definitionPath );
let data = await loadJSON( path.join( definitionsPath, definitionPath ) );
let jsonPath = path.join( definitionsPath, definitionPath );
let data = await loadJSON( jsonPath );
//console.log( "data:", jsonPath, data );
let classNameResult = /(\w+)(?:\:(\w+))?/.exec( data.class );
@ -229,7 +236,14 @@ async function createCppFiles( definitionPath, types, missingTypes )
let bindings = protectedBindings.concat( publicBindings ).join( "\n " );
let header = createCppHeader( className, extendingClass, headerDefine, protectedHeader, publicHeader );
let includes = "";
if ( data.includes )
{
includes = data.includes.map( inc => `#include "${inc}"` );
}
let header = createCppHeader( className, extendingClass, headerDefine, protectedHeader, publicHeader, includes );
let implementation = createCppImplementation( className, bindings );
//console.log( header );

@ -1 +1 @@
Subproject commit 26aea1a20d5bc2e35486517e2849b02f3b5d585b
Subproject commit d6b968703d75749c4f7ded3abe5ec9beba97ae8d

View File

@ -1,10 +0,0 @@
{
"class":"RJSequenceAction:RJAction",
"public":
{
"virtual dispatchStartEvent()":{},
"virtual dispatchCancelEvent()":{},
"virtual dispatchEndEvent()":{}
}
}

View File

@ -0,0 +1,11 @@
{
"class":"RJSequenceAction:RJActions",
"public":
{
"virtual dispatchStart()" : { "type":"int" },
"virtual dispatchCancel()" : { "parameters":[ { "id":"int" } ] },
"virtual dispatchEnd()" : { "parameters":[ { "id":"int" } ] },
"signal onSequenceDone()" : { "parameters":[ { "id":"int" } ] }
}
}