@@ -262,7 +262,7 @@ module.exports = {
262262 } ;
263263 dummyObject . setRawJSONContent (
264264 JSON . stringify ( {
265- property1 : "Initial value " ,
265+ property1 : "Hello world " ,
266266 property2 : true ,
267267 property3 : 123
268268 } )
@@ -311,24 +311,29 @@ module.exports = {
311311 return instanceProperties ;
312312 } ;
313313
314- extension . addObject (
315- "DummyObject" ,
316- t ( "Dummy object for testing" ) ,
317- t ( "This dummy object does nothing" ) ,
318- "CppPlatform/Extensions/topdownmovementicon.png" ,
319- dummyObject
320- ) ;
314+ extension
315+ . addObject (
316+ "DummyObject" ,
317+ t ( "Dummy object for testing" ) ,
318+ t ( "This dummy object does nothing" ) ,
319+ "CppPlatform/Extensions/topdownmovementicon.png" ,
320+ dummyObject
321+ )
322+ . setIncludeFile ( "Extensions/ExampleJsExtension/dummyruntimeobject.js" )
323+ . addIncludeFile (
324+ "Extensions/ExampleJsExtension/dummyruntimeobject-pixi-renderer.js"
325+ ) ;
321326
322327 return extension ;
323328 } ,
324329 /**
325330 * You can optionally add sanity tests that will check the basic working
326331 * of your extension behaviors/objects by instanciating behaviors/objects
327332 * and setting the property to a given value.
328- *
333+ *
329334 * If you don't have any tests, you can simply return an empty array like this:
330335 * `runExtensionSanityTests: function(gd, extension) { return []; }`
331- *
336+ *
332337 * But it is recommended to create tests for the behaviors/objects properties you created
333338 * to avoid mistakes.
334339 */
@@ -351,5 +356,116 @@ module.exports = {
351356 "Testing value"
352357 )
353358 ] ;
359+ } ,
360+ /**
361+ * Register editors for objects.
362+ *
363+ * ℹ️ Run `node import-GDJS-Runtime.js` (in newIDE/app/scripts) if you make any change.
364+ */
365+ registerEditorConfigurations : function ( objectsEditorService ) {
366+ objectsEditorService . registerEditorConfiguration (
367+ "MyDummyExtension::DummyObject" ,
368+ objectsEditorService . getDefaultObjectJsImplementationPropertiesEditor ( )
369+ ) ;
370+ } ,
371+ /**
372+ * Register renderers for instance of objects on the scene editor.
373+ *
374+ * ℹ️ Run `node import-GDJS-Runtime.js` (in newIDE/app/scripts) if you make any change.
375+ */
376+ registerInstanceRenderers : function ( objectsRenderingService ) {
377+ const RenderedInstance = objectsRenderingService . RenderedInstance ;
378+ const PIXI = objectsRenderingService . PIXI ;
379+
380+ /**
381+ * Renderer for instances of DummyObject inside the IDE.
382+ *
383+ * @extends RenderedInstance
384+ * @class RenderedDummyObjectInstance
385+ * @constructor
386+ */
387+ function RenderedDummyObjectInstance (
388+ project ,
389+ layout ,
390+ instance ,
391+ associatedObject ,
392+ pixiContainer ,
393+ pixiResourcesLoader
394+ ) {
395+ RenderedInstance . call (
396+ this ,
397+ project ,
398+ layout ,
399+ instance ,
400+ associatedObject ,
401+ pixiContainer ,
402+ pixiResourcesLoader
403+ ) ;
404+
405+ //Setup the PIXI object:
406+ this . _pixiObject = new PIXI . Text ( "This is a dummy object" , {
407+ align : "left"
408+ } ) ;
409+ this . _pixiObject . anchor . x = 0.5 ;
410+ this . _pixiObject . anchor . y = 0.5 ;
411+ this . _pixiContainer . addChild ( this . _pixiObject ) ;
412+ this . update ( ) ;
413+ }
414+ RenderedDummyObjectInstance . prototype = Object . create (
415+ RenderedInstance . prototype
416+ ) ;
417+
418+ /**
419+ * Return the path to the thumbnail of the specified object.
420+ */
421+ RenderedDummyObjectInstance . getThumbnail = function (
422+ project ,
423+ resourcesLoader ,
424+ object
425+ ) {
426+ return "CppPlatform/Extensions/texticon24.png" ;
427+ } ;
428+
429+ /**
430+ * This is called to update the PIXI object on the scene editor
431+ */
432+ RenderedDummyObjectInstance . prototype . update = function ( ) {
433+ // Read a property from the object
434+ const property1Value = this . _associatedObject
435+ . getProperties ( this . project )
436+ . get ( "My first property" )
437+ . getValue ( ) ;
438+ this . _pixiObject . text = property1Value ;
439+
440+ // Read position and angle from the instance
441+ this . _pixiObject . position . x =
442+ this . _instance . getX ( ) + this . _pixiObject . width / 2 ;
443+ this . _pixiObject . position . y =
444+ this . _instance . getY ( ) + this . _pixiObject . height / 2 ;
445+ this . _pixiObject . rotation = RenderedInstance . toRad (
446+ this . _instance . getAngle ( )
447+ ) ;
448+ // Custom size can be read in instance.getCustomWidth() and
449+ // instance.getCustomHeight()
450+ } ;
451+
452+ /**
453+ * Return the width of the instance, when it's not resized.
454+ */
455+ RenderedDummyObjectInstance . prototype . getDefaultWidth = function ( ) {
456+ return this . _pixiObject . width ;
457+ } ;
458+
459+ /**
460+ * Return the height of the instance, when it's not resized.
461+ */
462+ RenderedDummyObjectInstance . prototype . getDefaultHeight = function ( ) {
463+ return this . _pixiObject . height ;
464+ } ;
465+
466+ objectsRenderingService . registerInstanceRenderer (
467+ "MyDummyExtension::DummyObject" ,
468+ RenderedDummyObjectInstance
469+ ) ;
354470 }
355471} ;
0 commit comments