├── .gitignore ├── README.md ├── behavior-sdk ├── README.md ├── v1 │ ├── README.md │ ├── aces.schema.json │ ├── behavior.addon.schema.json │ ├── behavior.lang.schema.json │ └── sample-behavior │ │ ├── aces.json │ │ ├── addon.json │ │ ├── behavior.js │ │ ├── c3runtime │ │ ├── actions.js │ │ ├── behavior.js │ │ ├── conditions.js │ │ ├── expressions.js │ │ ├── instance.js │ │ └── type.js │ │ ├── icon.svg │ │ ├── instance.js │ │ ├── lang │ │ └── en-US.json │ │ └── type.js └── v2 │ ├── aces.schema.json │ ├── basic-bullet │ ├── aces.json │ ├── addon.json │ ├── behavior.js │ ├── behavior.ts │ ├── c3runtime │ │ ├── actions.js │ │ ├── actions.ts │ │ ├── behavior.js │ │ ├── behavior.ts │ │ ├── conditions.js │ │ ├── conditions.ts │ │ ├── expressions.js │ │ ├── expressions.ts │ │ ├── instance.js │ │ ├── instance.ts │ │ ├── main.js │ │ ├── main.ts │ │ ├── type.js │ │ └── type.ts │ ├── icon.svg │ ├── instance.js │ ├── instance.ts │ ├── lang │ │ └── en-US.json │ ├── tsconfig.json │ ├── type.js │ └── type.ts │ ├── behavior.addon.schema.json │ ├── behavior.lang.schema.json │ └── sample-behavior │ ├── aces.json │ ├── addon.json │ ├── behavior.js │ ├── behavior.ts │ ├── c3runtime │ ├── actions.js │ ├── actions.ts │ ├── behavior.js │ ├── behavior.ts │ ├── conditions.js │ ├── conditions.ts │ ├── expressions.js │ ├── expressions.ts │ ├── instance.js │ ├── instance.ts │ ├── main.js │ ├── main.ts │ ├── type.js │ └── type.ts │ ├── icon.svg │ ├── instance.js │ ├── instance.ts │ ├── lang │ └── en-US.json │ ├── tsconfig.json │ ├── type.js │ └── type.ts ├── effect-sdk ├── effect.addon.schema.json ├── effect.lang.schema.json ├── sample-tint │ ├── addon.json │ ├── effect.fx │ ├── effect.wgsl │ └── lang │ │ └── en-US.json └── sample-webgl2 │ ├── addon.json │ ├── effect.fx │ ├── effect.webgl2.fx │ ├── effect.wgsl │ └── lang │ └── en-US.json ├── plugin-sdk ├── README.md ├── v1 │ ├── README.md │ ├── aces.schema.json │ ├── customImporterPlugin │ │ ├── aces.json │ │ ├── addon.json │ │ ├── c3runtime │ │ │ ├── actions.js │ │ │ ├── conditions.js │ │ │ ├── expressions.js │ │ │ ├── instance.js │ │ │ ├── plugin.js │ │ │ └── type.js │ │ ├── icon.svg │ │ ├── instance.js │ │ ├── lang │ │ │ └── en-US.json │ │ ├── plugin.js │ │ └── type.js │ ├── customImporterSampleData.zip │ ├── domElementPlugin │ │ ├── aces.json │ │ ├── addon.json │ │ ├── c3runtime │ │ │ ├── actions.js │ │ │ ├── conditions.js │ │ │ ├── domSide.js │ │ │ ├── expressions.js │ │ │ ├── instance.js │ │ │ ├── plugin.js │ │ │ └── type.js │ │ ├── icon.svg │ │ ├── instance.js │ │ ├── lang │ │ │ └── en-US.json │ │ ├── plugin.js │ │ └── type.js │ ├── domMessagingPlugin │ │ ├── aces.json │ │ ├── addon.json │ │ ├── c3runtime │ │ │ ├── actions.js │ │ │ ├── conditions.js │ │ │ ├── domSide.js │ │ │ ├── expressions.js │ │ │ ├── instance.js │ │ │ ├── plugin.js │ │ │ └── type.js │ │ ├── icon.svg │ │ ├── instance.js │ │ ├── lang │ │ │ └── en-US.json │ │ ├── plugin.js │ │ └── type.js │ ├── drawingPlugin │ │ ├── aces.json │ │ ├── addon.json │ │ ├── c3runtime │ │ │ ├── actions.js │ │ │ ├── conditions.js │ │ │ ├── expressions.js │ │ │ ├── instance.js │ │ │ ├── plugin.js │ │ │ └── type.js │ │ ├── icon.svg │ │ ├── instance.js │ │ ├── lang │ │ │ └── en-US.json │ │ ├── plugin.js │ │ └── type.js │ ├── editorTextPlugin │ │ ├── aces.json │ │ ├── addon.json │ │ ├── c3runtime │ │ │ ├── actions.js │ │ │ ├── conditions.js │ │ │ ├── expressions.js │ │ │ ├── instance.js │ │ │ ├── plugin.js │ │ │ └── type.js │ │ ├── icon.svg │ │ ├── instance.js │ │ ├── lang │ │ │ └── en-US.json │ │ ├── plugin.js │ │ └── type.js │ ├── plugin.addon.schema.json │ ├── plugin.lang.schema.json │ ├── singleGlobalPlugin │ │ ├── aces.json │ │ ├── addon.json │ │ ├── c3runtime │ │ │ ├── actions.js │ │ │ ├── conditions.js │ │ │ ├── expressions.js │ │ │ ├── instance.js │ │ │ ├── plugin.js │ │ │ └── type.js │ │ ├── icon.svg │ │ ├── instance.js │ │ ├── lang │ │ │ └── en-US.json │ │ ├── plugin.js │ │ └── type.js │ └── wrapperExtensionPlugin │ │ ├── Wrapper extension sample project.c3p │ │ ├── construct-plugin │ │ ├── MyExtension_x64.ext.dll │ │ ├── MyExtension_x86.ext.dll │ │ ├── aces.json │ │ ├── addon.json │ │ ├── c3runtime │ │ │ ├── actions.js │ │ │ ├── conditions.js │ │ │ ├── expressions.js │ │ │ ├── instance.js │ │ │ ├── plugin.js │ │ │ └── type.js │ │ ├── icon.svg │ │ ├── instance.js │ │ ├── lang │ │ │ └── en-US.json │ │ ├── plugin.js │ │ └── type.js │ │ └── extension │ │ ├── IApplication.h │ │ ├── IExtension.h │ │ ├── Utils.cpp │ │ ├── Utils.h │ │ ├── WrapperExtension.cpp │ │ ├── WrapperExtension.h │ │ ├── WrapperExtension.sln │ │ ├── WrapperExtension.vcxproj │ │ ├── WrapperExtension.vcxproj.filters │ │ ├── cpp.hint │ │ ├── dllmain.cpp │ │ ├── framework.h │ │ ├── pch.cpp │ │ └── pch.h └── v2 │ ├── aces.schema.json │ ├── customImporterPlugin │ ├── aces.json │ ├── addon.json │ ├── c3runtime │ │ ├── actions.js │ │ ├── actions.ts │ │ ├── conditions.js │ │ ├── conditions.ts │ │ ├── expressions.js │ │ ├── expressions.ts │ │ ├── instance.js │ │ ├── instance.ts │ │ ├── main.js │ │ ├── main.ts │ │ ├── plugin.js │ │ ├── plugin.ts │ │ ├── type.js │ │ └── type.ts │ ├── icon.svg │ ├── instance.js │ ├── instance.ts │ ├── lang │ │ └── en-US.json │ ├── plugin.js │ ├── plugin.ts │ ├── tsconfig.json │ ├── type.js │ └── type.ts │ ├── customImporterSampleData.zip │ ├── domElementPlugin │ ├── aces.json │ ├── addon.json │ ├── c3runtime │ │ ├── actions.js │ │ ├── actions.ts │ │ ├── conditions.js │ │ ├── conditions.ts │ │ ├── domSide.js │ │ ├── domSide.ts │ │ ├── expressions.js │ │ ├── expressions.ts │ │ ├── instance.js │ │ ├── instance.ts │ │ ├── main.js │ │ ├── main.ts │ │ ├── plugin.js │ │ ├── plugin.ts │ │ ├── type.js │ │ └── type.ts │ ├── icon.svg │ ├── instance.js │ ├── instance.ts │ ├── lang │ │ └── en-US.json │ ├── plugin.js │ ├── plugin.ts │ ├── tsconfig.json │ ├── type.js │ └── type.ts │ ├── domMessagingPlugin │ ├── aces.json │ ├── addon.json │ ├── c3runtime │ │ ├── actions.js │ │ ├── actions.ts │ │ ├── conditions.js │ │ ├── conditions.ts │ │ ├── domSide.js │ │ ├── domSide.ts │ │ ├── expressions.js │ │ ├── expressions.ts │ │ ├── instance.js │ │ ├── instance.ts │ │ ├── main.js │ │ ├── main.ts │ │ ├── plugin.js │ │ ├── plugin.ts │ │ ├── type.js │ │ └── type.ts │ ├── icon.svg │ ├── instance.js │ ├── instance.ts │ ├── lang │ │ └── en-US.json │ ├── plugin.js │ ├── plugin.ts │ ├── tsconfig.json │ ├── type.js │ └── type.ts │ ├── drawingPlugin │ ├── aces.json │ ├── addon.json │ ├── c3runtime │ │ ├── actions.js │ │ ├── actions.ts │ │ ├── conditions.js │ │ ├── conditions.ts │ │ ├── expressions.js │ │ ├── expressions.ts │ │ ├── instance.js │ │ ├── instance.ts │ │ ├── main.js │ │ ├── main.ts │ │ ├── plugin.js │ │ ├── plugin.ts │ │ ├── type.js │ │ └── type.ts │ ├── icon.svg │ ├── instance.js │ ├── instance.ts │ ├── lang │ │ └── en-US.json │ ├── plugin.js │ ├── plugin.ts │ ├── tsconfig.json │ ├── type.js │ └── type.ts │ ├── editorTextPlugin │ ├── aces.json │ ├── addon.json │ ├── c3runtime │ │ ├── actions.js │ │ ├── actions.ts │ │ ├── conditions.js │ │ ├── conditions.ts │ │ ├── expressions.js │ │ ├── expressions.ts │ │ ├── instance.js │ │ ├── instance.ts │ │ ├── main.js │ │ ├── main.ts │ │ ├── plugin.js │ │ ├── plugin.ts │ │ ├── type.js │ │ └── type.ts │ ├── icon.svg │ ├── instance.js │ ├── instance.ts │ ├── lang │ │ └── en-US.json │ ├── plugin.js │ ├── plugin.ts │ ├── tsconfig.json │ ├── type.js │ └── type.ts │ ├── plugin.addon.schema.json │ ├── plugin.lang.schema.json │ ├── singleGlobalPlugin │ ├── aces.json │ ├── addon.json │ ├── c3runtime │ │ ├── actions.js │ │ ├── actions.ts │ │ ├── conditions.js │ │ ├── conditions.ts │ │ ├── expressions.js │ │ ├── expressions.ts │ │ ├── instance.js │ │ ├── instance.ts │ │ ├── main.js │ │ ├── main.ts │ │ ├── plugin.js │ │ ├── plugin.ts │ │ ├── type.js │ │ └── type.ts │ ├── icon.svg │ ├── instance.js │ ├── instance.ts │ ├── lang │ │ └── en-US.json │ ├── plugin.js │ ├── plugin.ts │ ├── tsconfig.json │ ├── type.js │ └── type.ts │ └── wrapperExtensionPlugin │ ├── Wrapper extension sample project.c3p │ ├── construct-plugin │ ├── MyExtension_arm64.ext.dll │ ├── MyExtension_x64.ext.dll │ ├── MyExtension_x86.ext.dll │ ├── aces.json │ ├── addon.json │ ├── c3runtime │ │ ├── actions.js │ │ ├── actions.ts │ │ ├── conditions.js │ │ ├── conditions.ts │ │ ├── expressions.js │ │ ├── expressions.ts │ │ ├── instance.js │ │ ├── instance.ts │ │ ├── main.js │ │ ├── main.ts │ │ ├── plugin.js │ │ ├── plugin.ts │ │ ├── type.js │ │ └── type.ts │ ├── icon.svg │ ├── instance.js │ ├── instance.ts │ ├── lang │ │ └── en-US.json │ ├── my_extension_x64.ext.so │ ├── myextension.ext.dylib │ ├── plugin.js │ ├── plugin.ts │ ├── tsconfig.json │ ├── type.js │ └── type.ts │ └── extension │ ├── CMakeLists.txt │ ├── IApplication.h │ ├── IExtension.h │ ├── Utils.cpp │ ├── Utils.h │ ├── WrapperExtension.cpp │ ├── WrapperExtension.h │ ├── WrapperExtension.sln │ ├── WrapperExtension.vcxproj │ ├── WrapperExtension.vcxproj.filters │ ├── WrapperExtension.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ └── contents.xcworkspacedata │ └── xcshareddata │ │ └── xcschemes │ │ └── WrapperExtension.xcscheme │ ├── cpp.hint │ ├── dllmain.cpp │ ├── pch.cpp │ └── pch.h └── theme-sdk ├── sample-theme ├── addon.json ├── icon.svg ├── lang │ └── en-US.json └── theme.css ├── theme.addon.schema.json └── theme.lang.schema.json /.gitignore: -------------------------------------------------------------------------------- 1 | .vs 2 | *.c3addon 3 | *.vcxproj.user 4 | ts-defs 5 | /plugin-sdk/v2/wrapperExtensionPlugin/extension/x64/ 6 | /plugin-sdk/v2/wrapperExtensionPlugin/extension/ARM64/ 7 | /plugin-sdk/v2/wrapperExtensionPlugin/extension/Win32/ 8 | /plugin-sdk/v2/wrapperExtensionPlugin/construct-plugin/*.exp 9 | /plugin-sdk/v2/wrapperExtensionPlugin/construct-plugin/*.lib 10 | /plugin-sdk/v2/wrapperExtensionPlugin/construct-plugin/*.pdb 11 | /plugin-sdk/v2/wrapperExtensionPlugin/extension/WrapperExtension/ 12 | plugin-sdk/v2/wrapperExtensionPlugin/extension/build/ 13 | .DS_Store 14 | xcuserdata/ 15 | -------------------------------------------------------------------------------- /behavior-sdk/README.md: -------------------------------------------------------------------------------- 1 | # Addon SDK v1 is being retired 2 | 3 | The legacy Addon SDK v1 will be retired in mid-2025. New addons should be developed using the Addon SDK v2. To port legacy SDK v1 addons to SDK v2, see [Porting to Addon SDK v2](https://www.construct.net/en/make-games/manuals/addon-sdk/guide/porting-addon-sdk-v2). -------------------------------------------------------------------------------- /behavior-sdk/v1/README.md: -------------------------------------------------------------------------------- 1 | # Addon SDK v1 is being retired 2 | 3 | The legacy Addon SDK v1 will be retired in mid-2025. New addons should be developed using the Addon SDK v2. To port legacy SDK v1 addons to SDK v2, see [Porting to Addon SDK v2](https://www.construct.net/en/make-games/manuals/addon-sdk/guide/porting-addon-sdk-v2). -------------------------------------------------------------------------------- /behavior-sdk/v1/sample-behavior/aces.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "../aces.schema.json", 3 | 4 | "": { 5 | "conditions": [ 6 | { 7 | "id": "is-moving", 8 | "scriptName": "IsMoving" 9 | } 10 | ], 11 | "actions": [ 12 | { 13 | "id": "stop", 14 | "scriptName": "Stop" 15 | } 16 | ], 17 | "expressions": [ 18 | { 19 | "id": "leet", 20 | "expressionName": "MyExpression", 21 | "returnType": "number" 22 | } 23 | ] 24 | } 25 | } -------------------------------------------------------------------------------- /behavior-sdk/v1/sample-behavior/addon.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "../behavior.addon.schema.json", 3 | 4 | "is-c3-addon": true, 5 | "sdk-version": 1, 6 | "type": "behavior", 7 | "name": "My custom behavior", 8 | "id": "MyCompany_MyBehavior", 9 | "version": "1.0.0.0", 10 | "author": "Scirra", 11 | "website": "https://www.construct.net", 12 | "documentation": "https://www.construct.net", 13 | "description": "Example custom Construct 3 behavior.", 14 | "editor-scripts": [ 15 | "behavior.js", 16 | "type.js", 17 | "instance.js" 18 | ], 19 | "file-list": [ 20 | "c3runtime/behavior.js", 21 | "c3runtime/type.js", 22 | "c3runtime/instance.js", 23 | "c3runtime/conditions.js", 24 | "c3runtime/actions.js", 25 | "c3runtime/expressions.js", 26 | "lang/en-US.json", 27 | "aces.json", 28 | "addon.json", 29 | "icon.svg", 30 | "instance.js", 31 | "behavior.js", 32 | "type.js" 33 | ] 34 | } -------------------------------------------------------------------------------- /behavior-sdk/v1/sample-behavior/behavior.js: -------------------------------------------------------------------------------- 1 | 2 | const SDK = self.SDK; 3 | 4 | //////////////////////////////////////////// 5 | // The behavior ID is how Construct identifies different kinds of behaviors. 6 | // *** NEVER CHANGE THE BEHAVIOR ID! *** 7 | // If you change the behavior ID after releasing the behavior, Construct will think it is an entirely different 8 | // behavior and assume it is incompatible with the old one, and YOU WILL BREAK ALL EXISTING PROJECTS USING THE BEHAVIOR. 9 | // Only the behavior name is displayed in the editor, so to rename your behavior change the name but NOT the ID. 10 | // If you want to completely replace a behavior, make it deprecated (it will be hidden but old projects keep working), 11 | // and create an entirely new behavior with a different behavior ID. 12 | const BEHAVIOR_ID = "MyCompany_MyBehavior"; 13 | //////////////////////////////////////////// 14 | 15 | const BEHAVIOR_VERSION = "1.0.0.0"; 16 | const BEHAVIOR_CATEGORY = "general"; 17 | 18 | const BEHAVIOR_CLASS = SDK.Behaviors.MyCompany_MyBehavior = class MyCustomBehavior extends SDK.IBehaviorBase 19 | { 20 | constructor() 21 | { 22 | super(BEHAVIOR_ID); 23 | 24 | SDK.Lang.PushContext("behaviors." + BEHAVIOR_ID.toLowerCase()); 25 | 26 | this._info.SetName(self.lang(".name")); 27 | this._info.SetDescription(self.lang(".description")); 28 | this._info.SetVersion(BEHAVIOR_VERSION); 29 | this._info.SetCategory(BEHAVIOR_CATEGORY); 30 | this._info.SetAuthor("Scirra"); 31 | this._info.SetHelpUrl(self.lang(".help-url")); 32 | this._info.SetIsOnlyOneAllowed(true); 33 | 34 | SDK.Lang.PushContext(".properties"); 35 | 36 | this._info.SetProperties([ 37 | new SDK.PluginProperty("integer", "test-property", 0) 38 | ]); 39 | 40 | SDK.Lang.PopContext(); // .properties 41 | 42 | SDK.Lang.PopContext(); 43 | } 44 | }; 45 | 46 | BEHAVIOR_CLASS.Register(BEHAVIOR_ID, BEHAVIOR_CLASS); 47 | -------------------------------------------------------------------------------- /behavior-sdk/v1/sample-behavior/c3runtime/actions.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = self.C3; 3 | 4 | C3.Behaviors.MyCompany_MyBehavior.Acts = 5 | { 6 | Stop() 7 | { 8 | // placeholder 9 | } 10 | }; 11 | -------------------------------------------------------------------------------- /behavior-sdk/v1/sample-behavior/c3runtime/behavior.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = self.C3; 3 | 4 | C3.Behaviors.MyCompany_MyBehavior = class MyBehavior extends C3.SDKBehaviorBase 5 | { 6 | constructor(opts) 7 | { 8 | super(opts); 9 | } 10 | 11 | Release() 12 | { 13 | super.Release(); 14 | } 15 | }; 16 | -------------------------------------------------------------------------------- /behavior-sdk/v1/sample-behavior/c3runtime/conditions.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = self.C3; 3 | 4 | C3.Behaviors.MyCompany_MyBehavior.Cnds = 5 | { 6 | IsMoving() 7 | { 8 | return false; // placeholder 9 | } 10 | }; 11 | -------------------------------------------------------------------------------- /behavior-sdk/v1/sample-behavior/c3runtime/expressions.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = self.C3; 3 | 4 | C3.Behaviors.MyCompany_MyBehavior.Exps = 5 | { 6 | MyExpression() 7 | { 8 | return 1337; 9 | } 10 | }; 11 | -------------------------------------------------------------------------------- /behavior-sdk/v1/sample-behavior/c3runtime/instance.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = self.C3; 3 | 4 | C3.Behaviors.MyCompany_MyBehavior.Instance = class MyBehaviorInstance extends C3.SDKBehaviorInstanceBase 5 | { 6 | constructor(behInst, properties) 7 | { 8 | super(behInst); 9 | 10 | this._myProperty = 0; 11 | 12 | if (properties) 13 | { 14 | this._myProperty = properties[0]; 15 | } 16 | 17 | // Opt-in to getting calls to Tick() 18 | //this._StartTicking(); 19 | } 20 | 21 | Release() 22 | { 23 | super.Release(); 24 | } 25 | 26 | _SetMyProperty(n) 27 | { 28 | this._myProperty = 0; 29 | } 30 | 31 | _GetMyProperty() 32 | { 33 | return this._myProperty; 34 | } 35 | 36 | SaveToJson() 37 | { 38 | return { 39 | // data to store for savegames 40 | }; 41 | } 42 | 43 | LoadFromJson(o) 44 | { 45 | // load state for savegames 46 | } 47 | 48 | /* 49 | Tick() 50 | { 51 | const dt = this._runtime.GetDt(this._inst); 52 | const wi = this._inst.GetWorldInfo(); 53 | 54 | // ... code to run every tick for this behavior ... 55 | } 56 | */ 57 | 58 | GetScriptInterfaceClass() 59 | { 60 | return self.IMyBehaviorInstance; 61 | } 62 | }; 63 | 64 | // Script interface for behavior instance 65 | const map = new WeakMap(); 66 | 67 | self.IMyBehaviorInstance = class IMyBehaviorInstance extends self.IBehaviorInstance { 68 | constructor() 69 | { 70 | super(); 71 | 72 | // Map by SDK instance 73 | map.set(this, self.IBehaviorInstance._GetInitInst().GetSdkInstance()); 74 | } 75 | 76 | // Example setter/getter property on script interface 77 | set myProperty(n) 78 | { 79 | map.get(this)._SetMyProperty(n); 80 | } 81 | 82 | get myProperty() 83 | { 84 | return map.get(this)._GetMyProperty(); 85 | } 86 | }; 87 | -------------------------------------------------------------------------------- /behavior-sdk/v1/sample-behavior/c3runtime/type.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = self.C3; 3 | 4 | C3.Behaviors.MyCompany_MyBehavior.Type = class MyBehaviorType extends C3.SDKBehaviorTypeBase 5 | { 6 | constructor(behaviorType) 7 | { 8 | super(behaviorType); 9 | } 10 | 11 | Release() 12 | { 13 | super.Release(); 14 | } 15 | 16 | OnCreate() 17 | { 18 | } 19 | }; 20 | -------------------------------------------------------------------------------- /behavior-sdk/v1/sample-behavior/instance.js: -------------------------------------------------------------------------------- 1 | 2 | const SDK = self.SDK; 3 | 4 | const BEHAVIOR_CLASS = SDK.Behaviors.MyCompany_MyBehavior; 5 | 6 | BEHAVIOR_CLASS.Instance = class MyCustomBehaviorInstance extends SDK.IBehaviorInstanceBase 7 | { 8 | constructor(sdkBehType, behInst) 9 | { 10 | super(sdkBehType, behInst); 11 | } 12 | 13 | Release() 14 | { 15 | } 16 | 17 | OnCreate() 18 | { 19 | } 20 | 21 | OnPropertyChanged(id, value) 22 | { 23 | } 24 | 25 | LoadC2Property(name, valueString) 26 | { 27 | return false; // not handled 28 | } 29 | }; 30 | -------------------------------------------------------------------------------- /behavior-sdk/v1/sample-behavior/lang/en-US.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "../../behavior.lang.schema.json", 3 | 4 | "languageTag": "en-US", 5 | "fileDescription": "Strings for MyCustomBehavior.", 6 | "text": { 7 | "behaviors": { 8 | "mycompany_mybehavior": { 9 | "name": "MyCustomBehavior", 10 | "description": "An example third-party behavior.", 11 | "help-url": "https://www.construct.net", 12 | "properties": { 13 | "test-property": { 14 | "name": "Test property", 15 | "desc": "A test number property." 16 | } 17 | }, 18 | "aceCategories": { 19 | }, 20 | "conditions": { 21 | "is-moving": { 22 | "list-name": "Is moving", 23 | "display-text": "{my} is moving", 24 | "description": "An example condition for the behavior." 25 | } 26 | }, 27 | "actions": { 28 | "stop": { 29 | "list-name": "Stop", 30 | "display-text": "Stop {my}", 31 | "description": "An example action for the behavior." 32 | } 33 | }, 34 | "expressions": { 35 | "leet": { 36 | "description": "Returns the number 1337.", 37 | "translated-name": "MyExpression" 38 | } 39 | } 40 | } 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /behavior-sdk/v1/sample-behavior/type.js: -------------------------------------------------------------------------------- 1 | 2 | const SDK = self.SDK; 3 | 4 | const BEHAVIOR_CLASS = SDK.Behaviors.MyCompany_MyBehavior; 5 | 6 | BEHAVIOR_CLASS.Type = class MyCustomBehaviorType extends SDK.IBehaviorTypeBase 7 | { 8 | constructor(sdkPlugin, iBehaviorType) 9 | { 10 | super(sdkPlugin, iBehaviorType); 11 | } 12 | }; 13 | -------------------------------------------------------------------------------- /behavior-sdk/v2/basic-bullet/aces.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "../aces.schema.json", 3 | 4 | "": { 5 | "conditions": [ 6 | { 7 | "id": "compare-speed", 8 | "scriptName": "CompareSpeed", 9 | "params": [ 10 | { "id": "comparison", "type": "cmp" }, 11 | { "id": "speed", "type": "number" } 12 | ] 13 | }, { 14 | "id": "on-hit-solid", 15 | "scriptName": "OnHitSolid", 16 | "isTrigger": true 17 | } 18 | ], 19 | "actions": [ 20 | { 21 | "id": "set-speed", 22 | "scriptName": "SetSpeed", 23 | "params": [{ "id": "speed", "type": "number" }] 24 | }, { 25 | "id": "set-enabled", 26 | "scriptName": "SetEnabled", 27 | "params": [{ "id": "enabled", "type": "boolean" }] 28 | } 29 | ], 30 | "expressions": [ 31 | { 32 | "id": "speed", 33 | "expressionName": "Speed", 34 | "returnType": "number" 35 | } 36 | ] 37 | } 38 | } -------------------------------------------------------------------------------- /behavior-sdk/v2/basic-bullet/addon.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "../behavior.addon.schema.json", 3 | 4 | "is-c3-addon": true, 5 | "sdk-version": 2, 6 | "min-construct-version": "r401", 7 | "type": "behavior", 8 | "name": "Basic bullet", 9 | "id": "SDKSample_BasicBullet", 10 | "version": "1.0.0.0", 11 | "author": "Scirra", 12 | "website": "https://www.construct.net", 13 | "documentation": "https://www.construct.net", 14 | "description": "SDK sample behavior for a basic bullet movement.", 15 | "editor-scripts": [ 16 | "behavior.js", 17 | "type.js", 18 | "instance.js" 19 | ], 20 | "file-list": [ 21 | "c3runtime/main.js", 22 | "c3runtime/behavior.js", 23 | "c3runtime/type.js", 24 | "c3runtime/instance.js", 25 | "c3runtime/conditions.js", 26 | "c3runtime/actions.js", 27 | "c3runtime/expressions.js", 28 | "lang/en-US.json", 29 | "aces.json", 30 | "addon.json", 31 | "icon.svg", 32 | "instance.js", 33 | "behavior.js", 34 | "type.js" 35 | ] 36 | } -------------------------------------------------------------------------------- /behavior-sdk/v2/basic-bullet/c3runtime/actions.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = globalThis.C3; 3 | 4 | // Note it's a good idea for ACE methods to call the public APIs, 5 | // so actions work equivalently to script APIs 6 | C3.Behaviors.SDKSample_BasicBullet.Acts = 7 | { 8 | SetSpeed(s) 9 | { 10 | this.speed = s; 11 | }, 12 | 13 | SetEnabled(e) 14 | { 15 | this.isEnabled = e; 16 | } 17 | }; 18 | -------------------------------------------------------------------------------- /behavior-sdk/v2/basic-bullet/c3runtime/actions.ts: -------------------------------------------------------------------------------- 1 | 2 | import type { SDKInstanceClass } from "./instance.ts"; 3 | 4 | const C3 = globalThis.C3; 5 | 6 | // Note it's a good idea for ACE methods to call the public APIs, 7 | // so actions work equivalently to script APIs 8 | C3.Behaviors.SDKSample_BasicBullet.Acts = 9 | { 10 | SetSpeed(this: SDKInstanceClass, s: number) 11 | { 12 | this.speed = s; 13 | }, 14 | 15 | SetEnabled(this: SDKInstanceClass, e: boolean) 16 | { 17 | this.isEnabled = e; 18 | } 19 | }; 20 | -------------------------------------------------------------------------------- /behavior-sdk/v2/basic-bullet/c3runtime/behavior.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = globalThis.C3; 3 | 4 | C3.Behaviors.SDKSample_BasicBullet = class BasicBulletBehavior extends globalThis.ISDKBehaviorBase 5 | { 6 | constructor() 7 | { 8 | super(); 9 | } 10 | }; 11 | -------------------------------------------------------------------------------- /behavior-sdk/v2/basic-bullet/c3runtime/behavior.ts: -------------------------------------------------------------------------------- 1 | 2 | const C3 = globalThis.C3; 3 | 4 | C3.Behaviors.SDKSample_BasicBullet = class BasicBulletBehavior extends globalThis.ISDKBehaviorBase 5 | { 6 | constructor() 7 | { 8 | super(); 9 | } 10 | }; 11 | 12 | // Necessary for TypeScript to treat this file as a module 13 | export {} -------------------------------------------------------------------------------- /behavior-sdk/v2/basic-bullet/c3runtime/conditions.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = globalThis.C3; 3 | 4 | C3.Behaviors.SDKSample_BasicBullet.Cnds = 5 | { 6 | CompareSpeed(cmp, speed) 7 | { 8 | return C3.compare(this.speed, cmp, speed); 9 | }, 10 | 11 | OnHitSolid() 12 | { 13 | return true; 14 | } 15 | }; 16 | -------------------------------------------------------------------------------- /behavior-sdk/v2/basic-bullet/c3runtime/conditions.ts: -------------------------------------------------------------------------------- 1 | 2 | import type { SDKInstanceClass } from "./instance.ts"; 3 | 4 | const C3 = globalThis.C3; 5 | 6 | C3.Behaviors.SDKSample_BasicBullet.Cnds = 7 | { 8 | CompareSpeed(this: SDKInstanceClass, cmp: number, speed: number) 9 | { 10 | return C3.compare(this.speed, cmp, speed); 11 | }, 12 | 13 | OnHitSolid(this: SDKInstanceClass) 14 | { 15 | return true; 16 | } 17 | }; 18 | -------------------------------------------------------------------------------- /behavior-sdk/v2/basic-bullet/c3runtime/expressions.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = globalThis.C3; 3 | 4 | C3.Behaviors.SDKSample_BasicBullet.Exps = 5 | { 6 | Speed() 7 | { 8 | return this.speed; 9 | } 10 | }; 11 | -------------------------------------------------------------------------------- /behavior-sdk/v2/basic-bullet/c3runtime/expressions.ts: -------------------------------------------------------------------------------- 1 | 2 | import type { SDKInstanceClass } from "./instance.ts"; 3 | 4 | const C3 = globalThis.C3; 5 | 6 | C3.Behaviors.SDKSample_BasicBullet.Exps = 7 | { 8 | Speed(this: SDKInstanceClass) 9 | { 10 | return this.speed; 11 | } 12 | }; 13 | -------------------------------------------------------------------------------- /behavior-sdk/v2/basic-bullet/c3runtime/main.js: -------------------------------------------------------------------------------- 1 | import "./behavior.js"; 2 | import "./type.js"; 3 | import "./instance.js"; 4 | import "./conditions.js"; 5 | import "./actions.js"; 6 | import "./expressions.js"; -------------------------------------------------------------------------------- /behavior-sdk/v2/basic-bullet/c3runtime/main.ts: -------------------------------------------------------------------------------- 1 | import "./behavior.js"; 2 | import "./type.js"; 3 | import "./instance.js"; 4 | import "./conditions.js"; 5 | import "./actions.js"; 6 | import "./expressions.js"; -------------------------------------------------------------------------------- /behavior-sdk/v2/basic-bullet/c3runtime/type.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = globalThis.C3; 3 | 4 | C3.Behaviors.SDKSample_BasicBullet.Type = class BasicBulletBehaviorType extends globalThis.ISDKBehaviorTypeBase 5 | { 6 | constructor() 7 | { 8 | super(); 9 | } 10 | 11 | _onCreate() 12 | { 13 | 14 | } 15 | }; 16 | -------------------------------------------------------------------------------- /behavior-sdk/v2/basic-bullet/c3runtime/type.ts: -------------------------------------------------------------------------------- 1 | 2 | const C3 = globalThis.C3; 3 | 4 | C3.Behaviors.SDKSample_BasicBullet.Type = class BasicBulletBehaviorType extends globalThis.ISDKBehaviorTypeBase 5 | { 6 | constructor() 7 | { 8 | super(); 9 | } 10 | 11 | _onCreate() 12 | { 13 | 14 | } 15 | }; 16 | 17 | // Necessary for TypeScript to treat this file as a module 18 | export {} -------------------------------------------------------------------------------- /behavior-sdk/v2/basic-bullet/instance.js: -------------------------------------------------------------------------------- 1 | 2 | const SDK = globalThis.SDK; 3 | 4 | const BEHAVIOR_CLASS = SDK.Behaviors.SDKSample_BasicBullet; 5 | 6 | BEHAVIOR_CLASS.Instance = class BasicBulletBehaviorInstance extends SDK.IBehaviorInstanceBase 7 | { 8 | constructor(sdkBehType, behInst) 9 | { 10 | super(sdkBehType, behInst); 11 | } 12 | 13 | Release() 14 | { 15 | } 16 | 17 | OnCreate() 18 | { 19 | } 20 | 21 | OnPropertyChanged(id, value) 22 | { 23 | } 24 | 25 | LoadC2Property(name, valueString) 26 | { 27 | return false; // not handled 28 | } 29 | }; 30 | -------------------------------------------------------------------------------- /behavior-sdk/v2/basic-bullet/instance.ts: -------------------------------------------------------------------------------- 1 | 2 | const SDK = globalThis.SDK; 3 | 4 | const BEHAVIOR_CLASS = SDK.Behaviors.SDKSample_BasicBullet; 5 | 6 | BEHAVIOR_CLASS.Instance = class BasicBulletBehaviorInstance extends SDK.IBehaviorInstanceBase 7 | { 8 | constructor(sdkBehType: SDK.IBehaviorTypeBase, behInst: SDK.IBehaviorInstance) 9 | { 10 | super(sdkBehType, behInst); 11 | } 12 | 13 | Release() 14 | { 15 | } 16 | 17 | OnCreate() 18 | { 19 | } 20 | 21 | OnPropertyChanged(id: string, value: EditorPropertyValueType) 22 | { 23 | } 24 | 25 | LoadC2Property(name: string, valueString: string) 26 | { 27 | return false; // not handled 28 | } 29 | }; 30 | 31 | export {} -------------------------------------------------------------------------------- /behavior-sdk/v2/basic-bullet/tsconfig.json: -------------------------------------------------------------------------------- 1 | 2 | { 3 | "compilerOptions": { 4 | /* Visit https://aka.ms/tsconfig to read more about this file */ 5 | 6 | /* Transpile away class fields, as Closure Compiler doesn't support them yet */ 7 | "target": "ES2021", 8 | 9 | /* Use modern standard JavaScript (ES) Modules */ 10 | "module": "ES2022", 11 | 12 | /* Disable polyfill code for CommonJS modules - Construct always uses ES Modules */ 13 | "esModuleInterop": false, 14 | 15 | /* Other standard settings specified by tsc --init */ 16 | "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */ 17 | "strict": true 18 | } 19 | } -------------------------------------------------------------------------------- /behavior-sdk/v2/basic-bullet/type.js: -------------------------------------------------------------------------------- 1 | 2 | const SDK = globalThis.SDK; 3 | 4 | const BEHAVIOR_CLASS = SDK.Behaviors.SDKSample_BasicBullet; 5 | 6 | BEHAVIOR_CLASS.Type = class BasicBulletBehaviorType extends SDK.IBehaviorTypeBase 7 | { 8 | constructor(sdkBehavior, iBehaviorType) 9 | { 10 | super(sdkBehavior, iBehaviorType); 11 | } 12 | }; 13 | -------------------------------------------------------------------------------- /behavior-sdk/v2/basic-bullet/type.ts: -------------------------------------------------------------------------------- 1 | 2 | const SDK = globalThis.SDK; 3 | 4 | const BEHAVIOR_CLASS = SDK.Behaviors.SDKSample_BasicBullet; 5 | 6 | BEHAVIOR_CLASS.Type = class BasicBulletBehaviorType extends SDK.IBehaviorTypeBase 7 | { 8 | constructor(sdkBehavior: SDK.IBehaviorBase, iBehaviorType: SDK.IBehaviorType) 9 | { 10 | super(sdkBehavior, iBehaviorType); 11 | } 12 | }; 13 | 14 | export {} -------------------------------------------------------------------------------- /behavior-sdk/v2/sample-behavior/aces.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "../aces.schema.json", 3 | 4 | "": { 5 | "conditions": [ 6 | { 7 | "id": "is-moving", 8 | "scriptName": "IsMoving" 9 | } 10 | ], 11 | "actions": [ 12 | { 13 | "id": "stop", 14 | "scriptName": "Stop" 15 | } 16 | ], 17 | "expressions": [ 18 | { 19 | "id": "leet", 20 | "expressionName": "MyExpression", 21 | "returnType": "number" 22 | } 23 | ] 24 | } 25 | } -------------------------------------------------------------------------------- /behavior-sdk/v2/sample-behavior/addon.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "../behavior.addon.schema.json", 3 | 4 | "is-c3-addon": true, 5 | "sdk-version": 2, 6 | "min-construct-version": "r401", 7 | "type": "behavior", 8 | "name": "My custom behavior", 9 | "id": "MyCompany_MyBehavior", 10 | "version": "1.0.0.0", 11 | "author": "Scirra", 12 | "website": "https://www.construct.net", 13 | "documentation": "https://www.construct.net", 14 | "description": "Example custom Construct 3 behavior.", 15 | "editor-scripts": [ 16 | "behavior.js", 17 | "type.js", 18 | "instance.js" 19 | ], 20 | "file-list": [ 21 | "c3runtime/main.js", 22 | "c3runtime/behavior.js", 23 | "c3runtime/type.js", 24 | "c3runtime/instance.js", 25 | "c3runtime/conditions.js", 26 | "c3runtime/actions.js", 27 | "c3runtime/expressions.js", 28 | "lang/en-US.json", 29 | "aces.json", 30 | "addon.json", 31 | "icon.svg", 32 | "instance.js", 33 | "behavior.js", 34 | "type.js" 35 | ] 36 | } -------------------------------------------------------------------------------- /behavior-sdk/v2/sample-behavior/behavior.js: -------------------------------------------------------------------------------- 1 | 2 | const SDK = globalThis.SDK; 3 | 4 | //////////////////////////////////////////// 5 | // The behavior ID is how Construct identifies different kinds of behaviors. 6 | // *** NEVER CHANGE THE BEHAVIOR ID! *** 7 | // If you change the behavior ID after releasing the behavior, Construct will think it is an entirely different 8 | // behavior and assume it is incompatible with the old one, and YOU WILL BREAK ALL EXISTING PROJECTS USING THE BEHAVIOR. 9 | // Only the behavior name is displayed in the editor, so to rename your behavior change the name but NOT the ID. 10 | // If you want to completely replace a behavior, make it deprecated (it will be hidden but old projects keep working), 11 | // and create an entirely new behavior with a different behavior ID. 12 | const BEHAVIOR_ID = "MyCompany_MyBehavior"; 13 | //////////////////////////////////////////// 14 | 15 | const BEHAVIOR_CATEGORY = "general"; 16 | 17 | const BEHAVIOR_CLASS = SDK.Behaviors.MyCompany_MyBehavior = class MyCustomBehavior extends SDK.IBehaviorBase 18 | { 19 | constructor() 20 | { 21 | super(BEHAVIOR_ID); 22 | 23 | SDK.Lang.PushContext("behaviors." + BEHAVIOR_ID.toLowerCase()); 24 | 25 | this._info.SetName(globalThis.lang(".name")); 26 | this._info.SetDescription(globalThis.lang(".description")); 27 | this._info.SetCategory(BEHAVIOR_CATEGORY); 28 | this._info.SetAuthor("Scirra"); 29 | this._info.SetHelpUrl(globalThis.lang(".help-url")); 30 | this._info.SetIsOnlyOneAllowed(true); 31 | this._info.SetRuntimeModuleMainScript("c3runtime/main.js"); 32 | 33 | SDK.Lang.PushContext(".properties"); 34 | 35 | this._info.SetProperties([ 36 | new SDK.PluginProperty("integer", "test-property", 0) 37 | ]); 38 | 39 | SDK.Lang.PopContext(); // .properties 40 | 41 | SDK.Lang.PopContext(); 42 | } 43 | }; 44 | 45 | BEHAVIOR_CLASS.Register(BEHAVIOR_ID, BEHAVIOR_CLASS); 46 | -------------------------------------------------------------------------------- /behavior-sdk/v2/sample-behavior/behavior.ts: -------------------------------------------------------------------------------- 1 | 2 | const SDK = globalThis.SDK; 3 | 4 | //////////////////////////////////////////// 5 | // The behavior ID is how Construct identifies different kinds of behaviors. 6 | // *** NEVER CHANGE THE BEHAVIOR ID! *** 7 | // If you change the behavior ID after releasing the behavior, Construct will think it is an entirely different 8 | // behavior and assume it is incompatible with the old one, and YOU WILL BREAK ALL EXISTING PROJECTS USING THE BEHAVIOR. 9 | // Only the behavior name is displayed in the editor, so to rename your behavior change the name but NOT the ID. 10 | // If you want to completely replace a behavior, make it deprecated (it will be hidden but old projects keep working), 11 | // and create an entirely new behavior with a different behavior ID. 12 | const BEHAVIOR_ID = "MyCompany_MyBehavior"; 13 | //////////////////////////////////////////// 14 | 15 | const BEHAVIOR_CATEGORY = "general"; 16 | 17 | const BEHAVIOR_CLASS = SDK.Behaviors.MyCompany_MyBehavior = class MyCustomBehavior extends SDK.IBehaviorBase 18 | { 19 | constructor() 20 | { 21 | super(BEHAVIOR_ID); 22 | 23 | SDK.Lang.PushContext("behaviors." + BEHAVIOR_ID.toLowerCase()); 24 | 25 | this._info.SetName(globalThis.lang(".name")); 26 | this._info.SetDescription(globalThis.lang(".description")); 27 | this._info.SetCategory(BEHAVIOR_CATEGORY); 28 | this._info.SetAuthor("Scirra"); 29 | this._info.SetHelpUrl(globalThis.lang(".help-url")); 30 | this._info.SetIsOnlyOneAllowed(true); 31 | this._info.SetRuntimeModuleMainScript("c3runtime/main.js"); 32 | 33 | SDK.Lang.PushContext(".properties"); 34 | 35 | this._info.SetProperties([ 36 | new SDK.PluginProperty("integer", "test-property", 0) 37 | ]); 38 | 39 | SDK.Lang.PopContext(); // .properties 40 | 41 | SDK.Lang.PopContext(); 42 | } 43 | }; 44 | 45 | BEHAVIOR_CLASS.Register(BEHAVIOR_ID, BEHAVIOR_CLASS); 46 | 47 | export {} -------------------------------------------------------------------------------- /behavior-sdk/v2/sample-behavior/c3runtime/actions.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = globalThis.C3; 3 | 4 | C3.Behaviors.MyCompany_MyBehavior.Acts = 5 | { 6 | Stop() 7 | { 8 | // placeholder 9 | } 10 | }; 11 | -------------------------------------------------------------------------------- /behavior-sdk/v2/sample-behavior/c3runtime/actions.ts: -------------------------------------------------------------------------------- 1 | 2 | import type { SDKInstanceClass } from "./instance.ts"; 3 | 4 | const C3 = globalThis.C3; 5 | 6 | C3.Behaviors.MyCompany_MyBehavior.Acts = 7 | { 8 | Stop(this: SDKInstanceClass) 9 | { 10 | // placeholder 11 | } 12 | }; 13 | -------------------------------------------------------------------------------- /behavior-sdk/v2/sample-behavior/c3runtime/behavior.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = globalThis.C3; 3 | 4 | C3.Behaviors.MyCompany_MyBehavior = class MyBehavior extends globalThis.ISDKBehaviorBase 5 | { 6 | constructor() 7 | { 8 | super(); 9 | } 10 | }; 11 | -------------------------------------------------------------------------------- /behavior-sdk/v2/sample-behavior/c3runtime/behavior.ts: -------------------------------------------------------------------------------- 1 | 2 | const C3 = globalThis.C3; 3 | 4 | C3.Behaviors.MyCompany_MyBehavior = class MyBehavior extends globalThis.ISDKBehaviorBase 5 | { 6 | constructor() 7 | { 8 | super(); 9 | } 10 | }; 11 | 12 | // Necessary for TypeScript to treat this file as a module 13 | export {} -------------------------------------------------------------------------------- /behavior-sdk/v2/sample-behavior/c3runtime/conditions.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = globalThis.C3; 3 | 4 | C3.Behaviors.MyCompany_MyBehavior.Cnds = 5 | { 6 | IsMoving() 7 | { 8 | return false; // placeholder 9 | } 10 | }; 11 | -------------------------------------------------------------------------------- /behavior-sdk/v2/sample-behavior/c3runtime/conditions.ts: -------------------------------------------------------------------------------- 1 | 2 | import type { SDKInstanceClass } from "./instance.ts"; 3 | 4 | const C3 = globalThis.C3; 5 | 6 | C3.Behaviors.MyCompany_MyBehavior.Cnds = 7 | { 8 | IsMoving(this: SDKInstanceClass) 9 | { 10 | return false; // placeholder 11 | } 12 | }; 13 | -------------------------------------------------------------------------------- /behavior-sdk/v2/sample-behavior/c3runtime/expressions.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = globalThis.C3; 3 | 4 | C3.Behaviors.MyCompany_MyBehavior.Exps = 5 | { 6 | MyExpression() 7 | { 8 | return 1337; 9 | } 10 | }; 11 | -------------------------------------------------------------------------------- /behavior-sdk/v2/sample-behavior/c3runtime/expressions.ts: -------------------------------------------------------------------------------- 1 | 2 | import type { SDKInstanceClass } from "./instance.ts"; 3 | 4 | const C3 = globalThis.C3; 5 | 6 | C3.Behaviors.MyCompany_MyBehavior.Exps = 7 | { 8 | MyExpression(this: SDKInstanceClass) 9 | { 10 | return 1337; 11 | } 12 | }; 13 | -------------------------------------------------------------------------------- /behavior-sdk/v2/sample-behavior/c3runtime/instance.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = globalThis.C3; 3 | 4 | C3.Behaviors.MyCompany_MyBehavior.Instance = class MyBehaviorInstance extends globalThis.ISDKBehaviorInstanceBase 5 | { 6 | constructor() 7 | { 8 | super(); 9 | 10 | this._myProperty = 0; 11 | 12 | const properties = this._getInitProperties(); 13 | if (properties) 14 | { 15 | this._myProperty = properties[0]; 16 | } 17 | 18 | // Opt-in to getting calls to _tick() 19 | //this._setTicking(true); 20 | } 21 | 22 | _release() 23 | { 24 | super._release(); 25 | } 26 | 27 | _setMyProperty(n) 28 | { 29 | this._myProperty = n; 30 | } 31 | 32 | _getMyProperty() 33 | { 34 | return this._myProperty; 35 | } 36 | 37 | _saveToJson() 38 | { 39 | return { 40 | // data to store for savegames 41 | }; 42 | } 43 | 44 | _loadFromJson(o) 45 | { 46 | // load state for savegames 47 | } 48 | 49 | /* 50 | _tick() 51 | { 52 | const dt = this.instance.dt; 53 | 54 | // ... code to run every tick for this behavior ... 55 | } 56 | */ 57 | }; 58 | -------------------------------------------------------------------------------- /behavior-sdk/v2/sample-behavior/c3runtime/instance.ts: -------------------------------------------------------------------------------- 1 | 2 | const C3 = globalThis.C3; 3 | 4 | class MyBehaviorInstance extends globalThis.ISDKBehaviorInstanceBase 5 | { 6 | _myProperty: number; 7 | 8 | constructor() 9 | { 10 | super(); 11 | 12 | this._myProperty = 0; 13 | 14 | const properties = this._getInitProperties(); 15 | if (properties) 16 | { 17 | this._myProperty = properties[0] as number; 18 | } 19 | 20 | // Opt-in to getting calls to _tick() 21 | //this._setTicking(true); 22 | } 23 | 24 | _release() 25 | { 26 | super._release(); 27 | } 28 | 29 | _setMyProperty(n: number) 30 | { 31 | this._myProperty = n; 32 | } 33 | 34 | _getMyProperty() 35 | { 36 | return this._myProperty; 37 | } 38 | 39 | _saveToJson() 40 | { 41 | return { 42 | // data to store for savegames 43 | }; 44 | } 45 | 46 | _loadFromJson(o: any) 47 | { 48 | // load state for savegames 49 | } 50 | 51 | /* 52 | _tick() 53 | { 54 | const dt = this.instance.dt; 55 | 56 | // ... code to run every tick for this behavior ... 57 | } 58 | */ 59 | }; 60 | 61 | C3.Behaviors.MyCompany_MyBehavior.Instance = MyBehaviorInstance; 62 | 63 | export type { MyBehaviorInstance as SDKInstanceClass }; -------------------------------------------------------------------------------- /behavior-sdk/v2/sample-behavior/c3runtime/main.js: -------------------------------------------------------------------------------- 1 | import "./behavior.js"; 2 | import "./type.js"; 3 | import "./instance.js"; 4 | import "./conditions.js"; 5 | import "./actions.js"; 6 | import "./expressions.js"; -------------------------------------------------------------------------------- /behavior-sdk/v2/sample-behavior/c3runtime/main.ts: -------------------------------------------------------------------------------- 1 | import "./behavior.js"; 2 | import "./type.js"; 3 | import "./instance.js"; 4 | import "./conditions.js"; 5 | import "./actions.js"; 6 | import "./expressions.js"; -------------------------------------------------------------------------------- /behavior-sdk/v2/sample-behavior/c3runtime/type.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = globalThis.C3; 3 | 4 | C3.Behaviors.MyCompany_MyBehavior.Type = class MyBehaviorType extends globalThis.ISDKBehaviorTypeBase 5 | { 6 | constructor() 7 | { 8 | super(); 9 | } 10 | 11 | _onCreate() 12 | { 13 | 14 | } 15 | }; 16 | -------------------------------------------------------------------------------- /behavior-sdk/v2/sample-behavior/c3runtime/type.ts: -------------------------------------------------------------------------------- 1 | 2 | const C3 = globalThis.C3; 3 | 4 | C3.Behaviors.MyCompany_MyBehavior.Type = class MyBehaviorType extends globalThis.ISDKBehaviorTypeBase 5 | { 6 | constructor() 7 | { 8 | super(); 9 | } 10 | 11 | _onCreate() 12 | { 13 | 14 | } 15 | }; 16 | 17 | // Necessary for TypeScript to treat this file as a module 18 | export {} -------------------------------------------------------------------------------- /behavior-sdk/v2/sample-behavior/instance.js: -------------------------------------------------------------------------------- 1 | 2 | const SDK = globalThis.SDK; 3 | 4 | const BEHAVIOR_CLASS = SDK.Behaviors.MyCompany_MyBehavior; 5 | 6 | BEHAVIOR_CLASS.Instance = class MyCustomBehaviorInstance extends SDK.IBehaviorInstanceBase 7 | { 8 | constructor(sdkBehType, behInst) 9 | { 10 | super(sdkBehType, behInst); 11 | } 12 | 13 | Release() 14 | { 15 | } 16 | 17 | OnCreate() 18 | { 19 | } 20 | 21 | OnPropertyChanged(id, value) 22 | { 23 | } 24 | 25 | LoadC2Property(name, valueString) 26 | { 27 | return false; // not handled 28 | } 29 | }; 30 | -------------------------------------------------------------------------------- /behavior-sdk/v2/sample-behavior/instance.ts: -------------------------------------------------------------------------------- 1 | 2 | const SDK = globalThis.SDK; 3 | 4 | const BEHAVIOR_CLASS = SDK.Behaviors.MyCompany_MyBehavior; 5 | 6 | BEHAVIOR_CLASS.Instance = class MyCustomBehaviorInstance extends SDK.IBehaviorInstanceBase 7 | { 8 | constructor(sdkBehType: SDK.IBehaviorTypeBase, behInst: SDK.IBehaviorInstance) 9 | { 10 | super(sdkBehType, behInst); 11 | } 12 | 13 | Release() 14 | { 15 | } 16 | 17 | OnCreate() 18 | { 19 | } 20 | 21 | OnPropertyChanged(id: string, value: EditorPropertyValueType) 22 | { 23 | } 24 | 25 | LoadC2Property(name: string, valueString: string) 26 | { 27 | return false; // not handled 28 | } 29 | }; 30 | 31 | export {} -------------------------------------------------------------------------------- /behavior-sdk/v2/sample-behavior/lang/en-US.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "../../behavior.lang.schema.json", 3 | 4 | "languageTag": "en-US", 5 | "fileDescription": "Strings for MyCustomBehavior.", 6 | "text": { 7 | "behaviors": { 8 | "mycompany_mybehavior": { 9 | "name": "MyCustomBehavior", 10 | "description": "An example third-party behavior.", 11 | "help-url": "https://www.construct.net", 12 | "properties": { 13 | "test-property": { 14 | "name": "Test property", 15 | "desc": "A test number property." 16 | } 17 | }, 18 | "aceCategories": { 19 | }, 20 | "conditions": { 21 | "is-moving": { 22 | "list-name": "Is moving", 23 | "display-text": "{my} is moving", 24 | "description": "An example condition for the behavior." 25 | } 26 | }, 27 | "actions": { 28 | "stop": { 29 | "list-name": "Stop", 30 | "display-text": "Stop {my}", 31 | "description": "An example action for the behavior." 32 | } 33 | }, 34 | "expressions": { 35 | "leet": { 36 | "description": "Returns the number 1337.", 37 | "translated-name": "MyExpression" 38 | } 39 | } 40 | } 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /behavior-sdk/v2/sample-behavior/tsconfig.json: -------------------------------------------------------------------------------- 1 | 2 | { 3 | "compilerOptions": { 4 | /* Visit https://aka.ms/tsconfig to read more about this file */ 5 | 6 | /* Transpile away class fields, as Closure Compiler doesn't support them yet */ 7 | "target": "ES2021", 8 | 9 | /* Use modern standard JavaScript (ES) Modules */ 10 | "module": "ES2022", 11 | 12 | /* Disable polyfill code for CommonJS modules - Construct always uses ES Modules */ 13 | "esModuleInterop": false, 14 | 15 | /* Other standard settings specified by tsc --init */ 16 | "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */ 17 | "strict": true 18 | } 19 | } -------------------------------------------------------------------------------- /behavior-sdk/v2/sample-behavior/type.js: -------------------------------------------------------------------------------- 1 | 2 | const SDK = globalThis.SDK; 3 | 4 | const BEHAVIOR_CLASS = SDK.Behaviors.MyCompany_MyBehavior; 5 | 6 | BEHAVIOR_CLASS.Type = class MyCustomBehaviorType extends SDK.IBehaviorTypeBase 7 | { 8 | constructor(sdkBehavior, iBehaviorType) 9 | { 10 | super(sdkBehavior, iBehaviorType); 11 | } 12 | }; 13 | -------------------------------------------------------------------------------- /behavior-sdk/v2/sample-behavior/type.ts: -------------------------------------------------------------------------------- 1 | 2 | const SDK = globalThis.SDK; 3 | 4 | const BEHAVIOR_CLASS = SDK.Behaviors.MyCompany_MyBehavior; 5 | 6 | BEHAVIOR_CLASS.Type = class MyCustomBehaviorType extends SDK.IBehaviorTypeBase 7 | { 8 | constructor(sdkBehavior: SDK.IBehaviorBase, iBehaviorType: SDK.IBehaviorType) 9 | { 10 | super(sdkBehavior, iBehaviorType); 11 | } 12 | }; 13 | 14 | export {} -------------------------------------------------------------------------------- /effect-sdk/sample-tint/addon.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "../effect.addon.schema.json", 3 | 4 | "is-c3-addon": true, 5 | "type": "effect", 6 | "name": "My custom effect", 7 | "id": "MyCompany_MyEffect", 8 | 9 | "supported-renderers": ["webgl", "webgpu"], 10 | 11 | "version": "1.0.0.0", 12 | "author": "Scirra", 13 | "website": "https://www.construct.net", 14 | "documentation": "https://www.construct.net", 15 | "description": "Example custom Construct 3 effect.", 16 | "file-list": [ 17 | "lang/en-US.json", 18 | "addon.json", 19 | "effect.fx", 20 | "effect.wgsl" 21 | ], 22 | 23 | "category": "color", 24 | "blends-background": false, 25 | "cross-sampling": false, 26 | "preserves-opaqueness": true, 27 | "animated": false, 28 | "extend-box": { 29 | "horizontal": 0, 30 | "vertical": 0 31 | }, 32 | 33 | "parameters": [ 34 | { 35 | "id": "color", 36 | "type": "color", 37 | "initial-value": [1, 0, 0], 38 | "uniform": "setColor" 39 | } 40 | ] 41 | } -------------------------------------------------------------------------------- /effect-sdk/sample-tint/effect.fx: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////// 2 | // Sample tint effect 3 | varying mediump vec2 vTex; 4 | uniform lowp sampler2D samplerFront; 5 | uniform lowp vec3 setColor; 6 | 7 | void main(void) 8 | { 9 | lowp float a = texture2D(samplerFront, vTex).a; 10 | 11 | gl_FragColor = vec4(setColor.r * a, setColor.g * a, setColor.b * a, a); 12 | } 13 | -------------------------------------------------------------------------------- /effect-sdk/sample-tint/effect.wgsl: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////// 2 | // Texture and sampler 3 | %%SAMPLERFRONT_BINDING%% var samplerFront : sampler; 4 | %%TEXTUREFRONT_BINDING%% var textureFront : texture_2d; 5 | 6 | ///////////////////////////////////////////////////////// 7 | // Shader custom parameters 8 | struct ShaderParams { 9 | setColor : vec3 10 | }; 11 | %%SHADERPARAMS_BINDING%% var shaderParams : ShaderParams; 12 | 13 | %%FRAGMENTINPUT_STRUCT%% 14 | %%FRAGMENTOUTPUT_STRUCT%% 15 | 16 | ///////////////////////////////////////////////////////// 17 | // Main method 18 | @fragment 19 | fn main(input : FragmentInput) -> FragmentOutput 20 | { 21 | var a : f32 = textureSample(textureFront, samplerFront, input.fragUV).a; 22 | 23 | var output : FragmentOutput; 24 | output.color = vec4(shaderParams.setColor * a, a); 25 | return output; 26 | } 27 | -------------------------------------------------------------------------------- /effect-sdk/sample-tint/lang/en-US.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "../../effect.lang.schema.json", 3 | 4 | "languageTag": "en-US", 5 | "fileDescription": "Strings for the 'MyCustomEffect' effect.", 6 | "text": { 7 | "effects": { 8 | "mycompany_myeffect": { 9 | "name": "My custom effect", 10 | "description": "An example effect for the SDK, which is a copy of the 'Set color' effect.", 11 | "parameters": { 12 | "color": { 13 | "name": "Color", 14 | "desc": "Color to set over the image." 15 | } 16 | } 17 | } 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /effect-sdk/sample-webgl2/addon.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "../effect.addon.schema.json", 3 | 4 | "is-c3-addon": true, 5 | "type": "effect", 6 | "name": "WebGL 2 effect", 7 | "id": "MyCompany_WebGL2Effect", 8 | 9 | "supported-renderers": ["webgl", "webgl2", "webgpu"], 10 | 11 | "version": "1.0.0.0", 12 | "author": "Scirra", 13 | "website": "https://www.construct.net", 14 | "documentation": "https://www.construct.net", 15 | "description": "Demonstrates WebGL 2 shader variants by displaying red with WebGL 1 and green with WebGL 2 (and blue with WebGPU).", 16 | "file-list": [ 17 | "lang/en-US.json", 18 | "addon.json", 19 | "effect.fx", 20 | "effect.webgl2.fx", 21 | "effect.wgsl" 22 | ], 23 | 24 | "category": "color", 25 | "blends-background": false, 26 | "cross-sampling": false, 27 | "preserves-opaqueness": true, 28 | "animated": false, 29 | "extend-box": { 30 | "horizontal": 0, 31 | "vertical": 0 32 | }, 33 | 34 | "parameters": [] 35 | } -------------------------------------------------------------------------------- /effect-sdk/sample-webgl2/effect.fx: -------------------------------------------------------------------------------- 1 |  2 | // Sample WebGL 1 shader. This just outputs a red color 3 | // to indicate WebGL 1 is in use. 4 | varying mediump vec2 vTex; 5 | uniform lowp sampler2D samplerFront; 6 | uniform lowp vec3 setColor; 7 | 8 | void main(void) 9 | { 10 | gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0); 11 | } 12 | -------------------------------------------------------------------------------- /effect-sdk/sample-webgl2/effect.webgl2.fx: -------------------------------------------------------------------------------- 1 | #version 300 es 2 | 3 | // Sample WebGL 2 shader. This just outputs a green color 4 | // to indicate WebGL 2 is in use. Notice that WebGL 2 shaders 5 | // must be written with '#version 300 es' as the very first line 6 | // (no linebreaks or comments before it!) and have updated syntax. 7 | 8 | in mediump vec2 vTex; 9 | out lowp vec4 outColor; 10 | 11 | uniform lowp sampler2D samplerFront; 12 | 13 | void main(void) 14 | { 15 | outColor = vec4(0.0, 1.0, 0.0, 1.0); 16 | } 17 | -------------------------------------------------------------------------------- /effect-sdk/sample-webgl2/effect.wgsl: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////// 2 | // Minimal sample WebGPU shader. This just outputs a blue 3 | // color to indicate WebGPU is in use (rather than one of 4 | // the WebGL shader variants). 5 | 6 | %%FRAGMENTINPUT_STRUCT%% 7 | %%FRAGMENTOUTPUT_STRUCT%% 8 | 9 | @fragment 10 | fn main(input : FragmentInput) -> FragmentOutput 11 | { 12 | var output : FragmentOutput; 13 | output.color = vec4(0.0f, 0.0f, 1.0f, 1.0f); 14 | return output; 15 | } 16 | -------------------------------------------------------------------------------- /effect-sdk/sample-webgl2/lang/en-US.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "../../effect.lang.schema.json", 3 | 4 | "languageTag": "en-US", 5 | "fileDescription": "Strings for the sample WebGL2 effect.", 6 | "text": { 7 | "effects": { 8 | "mycompany_webgl2effect": { 9 | "name": "WebGL 2 effect", 10 | "description": "Demonstrates WebGL 2 shader variants by displaying red with WebGL 1 and green with WebGL 2 (and blue with WebGPU)." 11 | } 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /plugin-sdk/README.md: -------------------------------------------------------------------------------- 1 | # Addon SDK v1 is being retired 2 | 3 | The legacy Addon SDK v1 will be retired in mid-2025. New addons should be developed using the Addon SDK v2. To port legacy SDK v1 addons to SDK v2, see [Porting to Addon SDK v2](https://www.construct.net/en/make-games/manuals/addon-sdk/guide/porting-addon-sdk-v2). -------------------------------------------------------------------------------- /plugin-sdk/v1/README.md: -------------------------------------------------------------------------------- 1 | # Addon SDK v1 is being retired 2 | 3 | The legacy Addon SDK v1 will be retired in mid-2025. New addons should be developed using the Addon SDK v2. To port legacy SDK v1 addons to SDK v2, see [Porting to Addon SDK v2](https://www.construct.net/en/make-games/manuals/addon-sdk/guide/porting-addon-sdk-v2). -------------------------------------------------------------------------------- /plugin-sdk/v1/customImporterPlugin/aces.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "../aces.schema.json", 3 | 4 | "custom": { 5 | "conditions": [ 6 | { 7 | "id": "is-large-number", 8 | "scriptName": "IsLargeNumber", 9 | "highlight": true, 10 | "params": [ 11 | { 12 | "id": "number", 13 | "type": "number" 14 | } 15 | ] 16 | } 17 | ], 18 | "actions": [ 19 | { 20 | "id": "do-alert", 21 | "scriptName": "Alert", 22 | "highlight": true 23 | } 24 | ], 25 | "expressions": [ 26 | { 27 | "id": "double", 28 | "expressionName": "Double", 29 | "highlight": true, 30 | "returnType": "number", 31 | "params": [ 32 | { 33 | "id": "number", 34 | "type": "number" 35 | } 36 | ] 37 | } 38 | ] 39 | } 40 | } -------------------------------------------------------------------------------- /plugin-sdk/v1/customImporterPlugin/addon.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "../plugin.addon.schema.json", 3 | 4 | "is-c3-addon": true, 5 | "sdk-version": 1, 6 | "type": "plugin", 7 | "name": "My custom importer plugin", 8 | "id": "MyCompany_CustomImporter", 9 | "version": "1.0.0.0", 10 | "author": "Scirra", 11 | "website": "https://www.construct.net", 12 | "documentation": "https://www.construct.net", 13 | "description": "Example custom Construct 3 plugin using Custom Importer API.", 14 | "editor-scripts": [ 15 | "plugin.js", 16 | "type.js", 17 | "instance.js" 18 | ], 19 | "file-list": [ 20 | "c3runtime/plugin.js", 21 | "c3runtime/type.js", 22 | "c3runtime/instance.js", 23 | "c3runtime/conditions.js", 24 | "c3runtime/actions.js", 25 | "c3runtime/expressions.js", 26 | "lang/en-US.json", 27 | "aces.json", 28 | "addon.json", 29 | "icon.svg", 30 | "instance.js", 31 | "plugin.js", 32 | "type.js" 33 | ] 34 | } -------------------------------------------------------------------------------- /plugin-sdk/v1/customImporterPlugin/c3runtime/actions.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = self.C3; 3 | 4 | C3.Plugins.MyCompany_CustomImporter.Acts = 5 | { 6 | Alert() 7 | { 8 | alert("Test property = " + this._GetTestProperty()); 9 | } 10 | }; 11 | -------------------------------------------------------------------------------- /plugin-sdk/v1/customImporterPlugin/c3runtime/conditions.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = self.C3; 3 | 4 | C3.Plugins.MyCompany_CustomImporter.Cnds = 5 | { 6 | IsLargeNumber(number) 7 | { 8 | return number > 100; 9 | } 10 | }; 11 | -------------------------------------------------------------------------------- /plugin-sdk/v1/customImporterPlugin/c3runtime/expressions.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = self.C3; 3 | 4 | C3.Plugins.MyCompany_CustomImporter.Exps = 5 | { 6 | Double(number) 7 | { 8 | return number * 2; 9 | } 10 | }; 11 | -------------------------------------------------------------------------------- /plugin-sdk/v1/customImporterPlugin/c3runtime/instance.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = self.C3; 3 | 4 | C3.Plugins.MyCompany_CustomImporter.Instance = class CustomImporterInstance extends C3.SDKInstanceBase 5 | { 6 | constructor(inst, properties) 7 | { 8 | super(inst); 9 | 10 | // Initialise object properties 11 | this._testProperty = 0; 12 | 13 | if (properties) // note properties may be null in some cases 14 | { 15 | this._testProperty = properties[0]; 16 | } 17 | } 18 | 19 | Release() 20 | { 21 | super.Release(); 22 | } 23 | 24 | _SetTestProperty(n) 25 | { 26 | this._testProperty = n; 27 | } 28 | 29 | _GetTestProperty() 30 | { 31 | return this._testProperty; 32 | } 33 | 34 | SaveToJson() 35 | { 36 | return { 37 | // data to be saved for savegames 38 | }; 39 | } 40 | 41 | LoadFromJson(o) 42 | { 43 | // load state for savegames 44 | } 45 | 46 | GetScriptInterfaceClass() 47 | { 48 | return self.IMyCustomImporterInstance; 49 | } 50 | }; 51 | 52 | // Script interface. Use a WeakMap to safely hide the internal implementation details from the 53 | // caller using the script interface. 54 | const map = new WeakMap(); 55 | 56 | self.IMyCustomImporterInstance = class IMyCustomImporterInstance extends self.IInstance { 57 | constructor() 58 | { 59 | super(); 60 | 61 | // Map by SDK instance 62 | map.set(this, self.IInstance._GetInitInst().GetSdkInstance()); 63 | } 64 | 65 | // Example setter/getter property on script interface 66 | set testProperty(n) 67 | { 68 | map.get(this)._SetTestProperty(n); 69 | } 70 | 71 | get testProperty() 72 | { 73 | return map.get(this)._GetTestProperty(); 74 | } 75 | }; 76 | -------------------------------------------------------------------------------- /plugin-sdk/v1/customImporterPlugin/c3runtime/plugin.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = self.C3; 3 | 4 | C3.Plugins.MyCompany_CustomImporter = class CustomImporterPlugin extends C3.SDKPluginBase 5 | { 6 | constructor(opts) 7 | { 8 | super(opts); 9 | } 10 | 11 | Release() 12 | { 13 | super.Release(); 14 | } 15 | }; 16 | -------------------------------------------------------------------------------- /plugin-sdk/v1/customImporterPlugin/c3runtime/type.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = self.C3; 3 | 4 | C3.Plugins.MyCompany_CustomImporter.Type = class CustomImporterType extends C3.SDKTypeBase 5 | { 6 | constructor(objectClass) 7 | { 8 | super(objectClass); 9 | } 10 | 11 | Release() 12 | { 13 | super.Release(); 14 | } 15 | 16 | OnCreate() 17 | { 18 | } 19 | }; 20 | -------------------------------------------------------------------------------- /plugin-sdk/v1/customImporterPlugin/instance.js: -------------------------------------------------------------------------------- 1 | 2 | const SDK = self.SDK; 3 | 4 | const PLUGIN_CLASS = SDK.Plugins.MyCompany_CustomImporter; 5 | 6 | PLUGIN_CLASS.Instance = class MyCustomImporterInstance extends SDK.IInstanceBase 7 | { 8 | constructor(sdkType, inst) 9 | { 10 | super(sdkType, inst); 11 | } 12 | 13 | Release() 14 | { 15 | } 16 | 17 | OnCreate() 18 | { 19 | } 20 | 21 | OnPropertyChanged(id, value) 22 | { 23 | } 24 | 25 | LoadC2Property(name, valueString) 26 | { 27 | return false; // not handled 28 | } 29 | }; 30 | -------------------------------------------------------------------------------- /plugin-sdk/v1/customImporterPlugin/lang/en-US.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "../../plugin.lang.schema.json", 3 | 4 | "languageTag": "en-US", 5 | "fileDescription": "Strings for MyCustomImporterPlugin.", 6 | "text": { 7 | "plugins": { 8 | "mycompany_customimporter": { 9 | "name": "CustomImportPlugin", 10 | "description": "An example third-party plugin demonstrating the Custom Importer API.", 11 | "help-url": "https://www.construct.net", 12 | "properties": { 13 | "test-property": { 14 | "name": "Test property", 15 | "desc": "A test number property. Displayed by 'Alert' action." 16 | } 17 | }, 18 | "aceCategories": { 19 | "custom": "Custom" 20 | }, 21 | "conditions": { 22 | "is-large-number": { 23 | "list-name": "Is large number", 24 | "display-text": "[i]{0}[/i] is a large number", 25 | "description": "Test if a number is greater than 100.", 26 | "params": { 27 | "number": { 28 | "name": "Number", 29 | "desc": "Number to test if greater than 100." 30 | } 31 | } 32 | } 33 | }, 34 | "actions": { 35 | "do-alert": { 36 | "list-name": "Do alert", 37 | "display-text": "Do alert", 38 | "description": "Do a dummy alert." 39 | } 40 | }, 41 | "expressions": { 42 | "double": { 43 | "description": "Double a number.", 44 | "translated-name": "Double", 45 | "params": { 46 | "number": { 47 | "name": "Number", 48 | "desc": "The number to double." 49 | } 50 | } 51 | } 52 | } 53 | } 54 | } 55 | } 56 | } -------------------------------------------------------------------------------- /plugin-sdk/v1/customImporterPlugin/type.js: -------------------------------------------------------------------------------- 1 | 2 | const SDK = self.SDK; 3 | 4 | const PLUGIN_CLASS = SDK.Plugins.MyCompany_CustomImporter; 5 | 6 | PLUGIN_CLASS.Type = class MyCustomImporterType extends SDK.ITypeBase 7 | { 8 | constructor(sdkPlugin, iObjectType) 9 | { 10 | super(sdkPlugin, iObjectType); 11 | } 12 | }; 13 | -------------------------------------------------------------------------------- /plugin-sdk/v1/customImporterSampleData.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Scirra/Construct-Addon-SDK/2fc509b759992d815d980a160db9f810abf9ca58/plugin-sdk/v1/customImporterSampleData.zip -------------------------------------------------------------------------------- /plugin-sdk/v1/domElementPlugin/aces.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "../aces.schema.json", 3 | 4 | "button": { 5 | "conditions": [ 6 | { 7 | "id": "on-click", 8 | "scriptName": "OnClick", 9 | "isTrigger": true 10 | } 11 | ], 12 | "actions": [ 13 | { 14 | "id": "set-text", 15 | "scriptName": "SetText", 16 | "params": [{ "id": "text", "type": "string" }] 17 | } 18 | ], 19 | "expressions": [ 20 | { 21 | "id": "text", 22 | "expressionName": "Text", 23 | "returnType": "string" 24 | } 25 | ] 26 | } 27 | } -------------------------------------------------------------------------------- /plugin-sdk/v1/domElementPlugin/addon.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "../plugin.addon.schema.json", 3 | 4 | "is-c3-addon": true, 5 | "sdk-version": 1, 6 | "type": "plugin", 7 | "name": "My DOM plugin", 8 | "id": "MyCompany_DOMPlugin", 9 | "version": "1.0.0.0", 10 | "author": "Scirra", 11 | "website": "https://www.construct.net", 12 | "documentation": "https://www.construct.net", 13 | "description": "Example custom DOM element Construct 3 plugin.", 14 | "editor-scripts": [ 15 | "plugin.js", 16 | "type.js", 17 | "instance.js" 18 | ], 19 | "file-list": [ 20 | "c3runtime/plugin.js", 21 | "c3runtime/type.js", 22 | "c3runtime/instance.js", 23 | "c3runtime/domSide.js", 24 | "c3runtime/conditions.js", 25 | "c3runtime/actions.js", 26 | "c3runtime/expressions.js", 27 | "lang/en-US.json", 28 | "aces.json", 29 | "addon.json", 30 | "icon.svg", 31 | "plugin.js", 32 | "type.js", 33 | "instance.js" 34 | ] 35 | } -------------------------------------------------------------------------------- /plugin-sdk/v1/domElementPlugin/c3runtime/actions.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = self.C3; 3 | 4 | C3.Plugins.MyCompany_DOMPlugin.Acts = 5 | { 6 | SetText(text) 7 | { 8 | this._SetText(text); 9 | } 10 | }; 11 | -------------------------------------------------------------------------------- /plugin-sdk/v1/domElementPlugin/c3runtime/conditions.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = self.C3; 3 | 4 | C3.Plugins.MyCompany_DOMPlugin.Cnds = 5 | { 6 | OnClick() 7 | { 8 | return true; 9 | } 10 | }; 11 | -------------------------------------------------------------------------------- /plugin-sdk/v1/domElementPlugin/c3runtime/expressions.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = self.C3; 3 | 4 | C3.Plugins.MyCompany_DOMPlugin.Exps = 5 | { 6 | Text() 7 | { 8 | // Return the button text. Note this returns a copy of the text stored in the instance, 9 | // since retrieving the real button text would require an asynchronous message posting 10 | // from the runtime to the DOM, and expressions must return synchronously. 11 | return this._GetText(); 12 | } 13 | }; 14 | 15 | -------------------------------------------------------------------------------- /plugin-sdk/v1/domElementPlugin/c3runtime/plugin.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = self.C3; 3 | 4 | // NOTE: use a unique DOM component ID to ensure it doesn't clash with anything else 5 | // This must also match the ID in instance.js and domSide.js. 6 | const DOM_COMPONENT_ID = "mycompany-mydomplugin"; 7 | 8 | // NOTE: DOM plugins derive from C3.SDKDOMPluginBase, not C3.SDKPluginBase. 9 | C3.Plugins.MyCompany_DOMPlugin = class MyDOMPlugin extends C3.SDKDOMPluginBase 10 | { 11 | constructor(opts) 12 | { 13 | super(opts, DOM_COMPONENT_ID); 14 | 15 | // Calls to PostToRuntimeElement() in domSide.js are forwarded to the plugin here. 16 | // The relevant instance is passed as an argument. Generally these messages need to be handled by the 17 | // instances themselves, so the handlers here just forward messages to instance calls. 18 | 19 | // Forward "click" messages to the _OnClick method of the relevant instance. 20 | // Note this also forwards the optional extra details object as the argument 'e', but in this 21 | // case it's not used for the click handler. 22 | this.AddElementMessageHandler("click", (sdkInst, e) => sdkInst._OnClick(e)); 23 | } 24 | 25 | Release() 26 | { 27 | super.Release(); 28 | } 29 | }; 30 | -------------------------------------------------------------------------------- /plugin-sdk/v1/domElementPlugin/c3runtime/type.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = self.C3; 3 | 4 | C3.Plugins.MyCompany_DOMPlugin.Type = class MyDOMType extends C3.SDKTypeBase 5 | { 6 | constructor(objectClass) 7 | { 8 | super(objectClass); 9 | } 10 | 11 | Release() 12 | { 13 | super.Release(); 14 | } 15 | 16 | OnCreate() 17 | { 18 | 19 | } 20 | }; 21 | -------------------------------------------------------------------------------- /plugin-sdk/v1/domElementPlugin/lang/en-US.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "../../plugin.lang.schema.json", 3 | 4 | "languageTag": "en-US", 5 | "fileDescription": "Strings for MyCompany_DOMPlugin.", 6 | "text": { 7 | "plugins": { 8 | "mycompany_domplugin": { 9 | "name": "MyDOM", 10 | "description": "Testing a custom DOM element third-party plugin.", 11 | "help-url": "https://www.construct.net", 12 | "properties": { 13 | "button-text": { 14 | "name": "Button text", 15 | "desc": "The text to display on the button." 16 | } 17 | }, 18 | "aceCategories": { 19 | "button": "Button" 20 | }, 21 | "conditions": { 22 | "on-click": { 23 | "list-name": "On click", 24 | "display-text": "On click", 25 | "description": "Triggered when the button is clicked." 26 | } 27 | }, 28 | "actions": { 29 | "set-text": { 30 | "list-name": "Set text", 31 | "display-text": "Set button text to [i]{0}[/i]", 32 | "description": "Set the button text.", 33 | "params": { 34 | "text": { 35 | "name": "Text", 36 | "desc": "The new button text." 37 | } 38 | } 39 | } 40 | }, 41 | "expressions": { 42 | "text": { 43 | "description": "The button text.", 44 | "translated-name": "Text" 45 | } 46 | } 47 | } 48 | } 49 | } 50 | } -------------------------------------------------------------------------------- /plugin-sdk/v1/domElementPlugin/type.js: -------------------------------------------------------------------------------- 1 | 2 | const SDK = self.SDK; 3 | 4 | const PLUGIN_CLASS = SDK.Plugins.MyCompany_DOMPlugin; 5 | 6 | PLUGIN_CLASS.Type = class MyDOMPluginType extends SDK.ITypeBase 7 | { 8 | constructor(sdkPlugin, iObjectType) 9 | { 10 | super(sdkPlugin, iObjectType); 11 | } 12 | }; 13 | -------------------------------------------------------------------------------- /plugin-sdk/v1/domMessagingPlugin/aces.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "../aces.schema.json", 3 | 4 | "custom": { 5 | "actions": [ 6 | { 7 | "id": "set-document-title", 8 | "scriptName": "SetDocumentTitle", 9 | "highlight": true, 10 | "params": [ 11 | { 12 | "id": "title", 13 | "type": "string" 14 | } 15 | ] 16 | } 17 | ], 18 | "expressions": [ 19 | { 20 | "id": "get-document-title", 21 | "expressionName": "DocumentTitle", 22 | "highlight": true, 23 | "returnType": "string" 24 | } 25 | ] 26 | } 27 | } -------------------------------------------------------------------------------- /plugin-sdk/v1/domMessagingPlugin/addon.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "../plugin.addon.schema.json", 3 | 4 | "is-c3-addon": true, 5 | "sdk-version": 1, 6 | "type": "plugin", 7 | "name": "DOM plugin", 8 | "id": "MyCompany_DOMMessaging", 9 | "version": "1.0.0.0", 10 | "author": "Scirra", 11 | "website": "https://www.construct.net", 12 | "documentation": "https://www.construct.net", 13 | "description": "Example custom Construct 3 plugin.", 14 | "editor-scripts": [ 15 | "plugin.js", 16 | "type.js", 17 | "instance.js" 18 | ], 19 | "file-list": [ 20 | "c3runtime/plugin.js", 21 | "c3runtime/type.js", 22 | "c3runtime/instance.js", 23 | "c3runtime/conditions.js", 24 | "c3runtime/actions.js", 25 | "c3runtime/expressions.js", 26 | "c3runtime/domSide.js", 27 | "lang/en-US.json", 28 | "aces.json", 29 | "addon.json", 30 | "icon.svg", 31 | "instance.js", 32 | "plugin.js", 33 | "type.js" 34 | ] 35 | } -------------------------------------------------------------------------------- /plugin-sdk/v1/domMessagingPlugin/c3runtime/actions.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = self.C3; 3 | 4 | C3.Plugins.MyCompany_DOMMessaging.Acts = 5 | { 6 | SetDocumentTitle(title) 7 | { 8 | // Update the copy of the document title held on the instance. 9 | this._documentTitle = title; 10 | 11 | // Post a message to the domSide.js script to update the document title. 12 | this.PostToDOM("set-document-title", { 13 | "title": title 14 | }); 15 | } 16 | }; 17 | -------------------------------------------------------------------------------- /plugin-sdk/v1/domMessagingPlugin/c3runtime/conditions.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = self.C3; 3 | 4 | C3.Plugins.MyCompany_DOMMessaging.Cnds = 5 | { 6 | // no conditions 7 | }; 8 | -------------------------------------------------------------------------------- /plugin-sdk/v1/domMessagingPlugin/c3runtime/domSide.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | { 4 | // Update the DOM_COMPONENT_ID to be unique to your plugin. 5 | // It must match the value set in instance.js as well. 6 | const DOM_COMPONENT_ID = "MyCompany_DOMMessaging"; 7 | 8 | // This class handles messages from the runtime, which may be in a Web Worker. 9 | const HANDLER_CLASS = class ExampleDOMHandler extends self.DOMHandler 10 | { 11 | constructor(iRuntime) 12 | { 13 | super(iRuntime, DOM_COMPONENT_ID); 14 | 15 | // This provides a table of message names to functions to call for those messages. 16 | // For example the "Set document title" action posts a "set-document-title" message, 17 | // which will then call _OnSetDocumentTitle(). 18 | this.AddRuntimeMessageHandlers([ 19 | ["get-initial-state", () => this._OnGetInitialState()], 20 | ["set-document-title", e => this._OnSetDocumentTitle(e)] 21 | ]); 22 | } 23 | 24 | _OnGetInitialState() 25 | { 26 | // Return the initial document title so the DocumentTitle expression has the right 27 | // value on startup. The return value of this method will be what the PostToDOMAsync() 28 | // promise resolves to. 29 | return { 30 | "document-title": document.title 31 | }; 32 | } 33 | 34 | // Called by the 'Set document title' action. Since this script is always in the DOM, 35 | // the document.title property can be accessed directly, and updated with the title 36 | // sent from the action. 37 | _OnSetDocumentTitle(e) 38 | { 39 | document.title = e["title"]; 40 | } 41 | }; 42 | 43 | self.RuntimeInterface.AddDOMHandlerClass(HANDLER_CLASS); 44 | } -------------------------------------------------------------------------------- /plugin-sdk/v1/domMessagingPlugin/c3runtime/expressions.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = self.C3; 3 | 4 | C3.Plugins.MyCompany_DOMMessaging.Exps = 5 | { 6 | DocumentTitle() 7 | { 8 | // This returns the copy of the document title held on the runtime side. 9 | return this._documentTitle; 10 | } 11 | }; 12 | -------------------------------------------------------------------------------- /plugin-sdk/v1/domMessagingPlugin/c3runtime/plugin.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = self.C3; 3 | 4 | C3.Plugins.MyCompany_DOMMessaging = class DOMMessagingPlugin extends C3.SDKPluginBase 5 | { 6 | constructor(opts) 7 | { 8 | super(opts); 9 | } 10 | 11 | Release() 12 | { 13 | super.Release(); 14 | } 15 | }; 16 | -------------------------------------------------------------------------------- /plugin-sdk/v1/domMessagingPlugin/c3runtime/type.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = self.C3; 3 | 4 | C3.Plugins.MyCompany_DOMMessaging.Type = class DOMMessagingType extends C3.SDKTypeBase 5 | { 6 | constructor(objectClass) 7 | { 8 | super(objectClass); 9 | } 10 | 11 | Release() 12 | { 13 | super.Release(); 14 | } 15 | 16 | OnCreate() 17 | { 18 | } 19 | }; 20 | -------------------------------------------------------------------------------- /plugin-sdk/v1/domMessagingPlugin/instance.js: -------------------------------------------------------------------------------- 1 | 2 | const SDK = self.SDK; 3 | 4 | const PLUGIN_CLASS = SDK.Plugins.MyCompany_DOMMessaging; 5 | 6 | PLUGIN_CLASS.Instance = class MyCustomInstance extends SDK.IInstanceBase 7 | { 8 | constructor(sdkType, inst) 9 | { 10 | super(sdkType, inst); 11 | } 12 | 13 | Release() 14 | { 15 | } 16 | 17 | OnCreate() 18 | { 19 | } 20 | 21 | OnPropertyChanged(id, value) 22 | { 23 | } 24 | }; 25 | -------------------------------------------------------------------------------- /plugin-sdk/v1/domMessagingPlugin/lang/en-US.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "../../plugin.lang.schema.json", 3 | 4 | "languageTag": "en-US", 5 | "fileDescription": "Strings for DOMMessaging.", 6 | "text": { 7 | "plugins": { 8 | "mycompany_dommessaging": { 9 | "name": "MyDOMPlugin", 10 | "description": "An example third-party plugin using DOM messaging.", 11 | "help-url": "https://www.construct.net", 12 | "properties": { 13 | "test-property": { 14 | "name": "Test property", 15 | "desc": "A test number property." 16 | } 17 | }, 18 | "aceCategories": { 19 | "custom": "Custom" 20 | }, 21 | "conditions": { 22 | }, 23 | "actions": { 24 | "set-document-title": { 25 | "list-name": "Set document title", 26 | "display-text": "Set document title to [b]{0}[/b]", 27 | "description": "Set the document title to a string.", 28 | "params": { 29 | "title": { 30 | "name": "Title", 31 | "desc": "The document title to set." 32 | } 33 | } 34 | } 35 | }, 36 | "expressions": { 37 | "get-document-title": { 38 | "description": "Get the current document title.", 39 | "translated-name": "DocumentTitle" 40 | } 41 | } 42 | } 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /plugin-sdk/v1/domMessagingPlugin/plugin.js: -------------------------------------------------------------------------------- 1 | 2 | const SDK = self.SDK; 3 | 4 | //////////////////////////////////////////// 5 | // The plugin ID is how Construct identifies different kinds of plugins. 6 | // *** NEVER CHANGE THE PLUGIN ID! *** 7 | // If you change the plugin ID after releasing the plugin, Construct will think it is an entirely different 8 | // plugin and assume it is incompatible with the old one, and YOU WILL BREAK ALL EXISTING PROJECTS USING THE PLUGIN. 9 | // Only the plugin name is displayed in the editor, so to rename your plugin change the name but NOT the ID. 10 | // If you want to completely replace a plugin, make it deprecated (it will be hidden but old projects keep working), 11 | // and create an entirely new plugin with a different plugin ID. 12 | const PLUGIN_ID = "MyCompany_DOMMessaging"; 13 | //////////////////////////////////////////// 14 | 15 | const PLUGIN_VERSION = "1.0.0.0"; 16 | const PLUGIN_CATEGORY = "general"; 17 | 18 | const PLUGIN_CLASS = SDK.Plugins.MyCompany_DOMMessaging = class MyCustomPlugin extends SDK.IPluginBase 19 | { 20 | constructor() 21 | { 22 | super(PLUGIN_ID); 23 | 24 | SDK.Lang.PushContext("plugins." + PLUGIN_ID.toLowerCase()); 25 | 26 | this._info.SetName(self.lang(".name")); 27 | this._info.SetDescription(self.lang(".description")); 28 | this._info.SetVersion(PLUGIN_VERSION); 29 | this._info.SetCategory(PLUGIN_CATEGORY); 30 | this._info.SetAuthor("Scirra"); 31 | this._info.SetHelpUrl(self.lang(".help-url")); 32 | this._info.SetIsSingleGlobal(true); 33 | 34 | // Set the domSide.js script to run in the context of the DOM 35 | this._info.SetDOMSideScripts(["c3runtime/domSide.js"]); 36 | 37 | SDK.Lang.PushContext(".properties"); 38 | 39 | this._info.SetProperties([ 40 | new SDK.PluginProperty("integer", "test-property", 0) 41 | ]); 42 | 43 | SDK.Lang.PopContext(); // .properties 44 | 45 | SDK.Lang.PopContext(); 46 | } 47 | }; 48 | 49 | PLUGIN_CLASS.Register(PLUGIN_ID, PLUGIN_CLASS); 50 | -------------------------------------------------------------------------------- /plugin-sdk/v1/domMessagingPlugin/type.js: -------------------------------------------------------------------------------- 1 | 2 | const SDK = self.SDK; 3 | 4 | const PLUGIN_CLASS = SDK.Plugins.MyCompany_DOMMessaging; 5 | 6 | PLUGIN_CLASS.Type = class MyCustomPluginType extends SDK.ITypeBase 7 | { 8 | constructor(sdkPlugin, iObjectType) 9 | { 10 | super(sdkPlugin, iObjectType); 11 | } 12 | }; 13 | -------------------------------------------------------------------------------- /plugin-sdk/v1/drawingPlugin/aces.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "../aces.schema.json", 3 | 4 | "custom": { 5 | "conditions": [ 6 | { 7 | "id": "is-large-number", 8 | "scriptName": "IsLargeNumber", 9 | "highlight": true, 10 | "params": [ 11 | { 12 | "id": "number", 13 | "type": "number" 14 | } 15 | ] 16 | } 17 | ], 18 | "actions": [ 19 | { 20 | "id": "do-alert", 21 | "scriptName": "Alert", 22 | "highlight": true 23 | } 24 | ], 25 | "expressions": [ 26 | { 27 | "id": "double", 28 | "expressionName": "Double", 29 | "highlight": true, 30 | "returnType": "number", 31 | "params": [ 32 | { 33 | "id": "number", 34 | "type": "number" 35 | } 36 | ] 37 | } 38 | ] 39 | } 40 | } -------------------------------------------------------------------------------- /plugin-sdk/v1/drawingPlugin/addon.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "../plugin.addon.schema.json", 3 | 4 | "is-c3-addon": true, 5 | "sdk-version": 1, 6 | "type": "plugin", 7 | "name": "My drawing plugin", 8 | "id": "MyCompany_DrawingPlugin", 9 | "version": "1.0.0.0", 10 | "author": "Scirra", 11 | "website": "https://www.construct.net", 12 | "documentation": "https://www.construct.net", 13 | "description": "Example custom drawing Construct 3 plugin.", 14 | "editor-scripts": [ 15 | "plugin.js", 16 | "type.js", 17 | "instance.js" 18 | ], 19 | "file-list": [ 20 | "c3runtime/plugin.js", 21 | "c3runtime/type.js", 22 | "c3runtime/instance.js", 23 | "c3runtime/conditions.js", 24 | "c3runtime/actions.js", 25 | "c3runtime/expressions.js", 26 | "lang/en-US.json", 27 | "aces.json", 28 | "addon.json", 29 | "icon.svg", 30 | "plugin.js", 31 | "type.js", 32 | "instance.js" 33 | ] 34 | } -------------------------------------------------------------------------------- /plugin-sdk/v1/drawingPlugin/c3runtime/actions.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = self.C3; 3 | 4 | C3.Plugins.MyCompany_DrawingPlugin.Acts = 5 | { 6 | Alert() 7 | { 8 | alert("Test property = " + this._GetTestProperty()); 9 | } 10 | }; 11 | -------------------------------------------------------------------------------- /plugin-sdk/v1/drawingPlugin/c3runtime/conditions.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = self.C3; 3 | 4 | C3.Plugins.MyCompany_DrawingPlugin.Cnds = 5 | { 6 | IsLargeNumber(number) 7 | { 8 | return number > 100; 9 | } 10 | }; 11 | -------------------------------------------------------------------------------- /plugin-sdk/v1/drawingPlugin/c3runtime/expressions.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = self.C3; 3 | 4 | C3.Plugins.MyCompany_DrawingPlugin.Exps = 5 | { 6 | Double(number) 7 | { 8 | return number * 2; 9 | } 10 | }; 11 | 12 | -------------------------------------------------------------------------------- /plugin-sdk/v1/drawingPlugin/c3runtime/plugin.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = self.C3; 3 | 4 | C3.Plugins.MyCompany_DrawingPlugin = class DrawingPlugin extends C3.SDKPluginBase 5 | { 6 | constructor(opts) 7 | { 8 | super(opts); 9 | } 10 | 11 | Release() 12 | { 13 | super.Release(); 14 | } 15 | }; 16 | -------------------------------------------------------------------------------- /plugin-sdk/v1/drawingPlugin/c3runtime/type.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = self.C3; 3 | 4 | C3.Plugins.MyCompany_DrawingPlugin.Type = class DrawingType extends C3.SDKTypeBase 5 | { 6 | constructor(objectClass) 7 | { 8 | super(objectClass); 9 | } 10 | 11 | Release() 12 | { 13 | super.Release(); 14 | } 15 | 16 | OnCreate() 17 | { 18 | this.GetImageInfo().LoadAsset(this._runtime); 19 | } 20 | 21 | LoadTextures(renderer) 22 | { 23 | return this.GetImageInfo().LoadStaticTexture(renderer, { 24 | sampling: this._runtime.GetSampling() 25 | }); 26 | } 27 | 28 | ReleaseTextures() 29 | { 30 | this.GetImageInfo().ReleaseTexture(); 31 | } 32 | }; 33 | -------------------------------------------------------------------------------- /plugin-sdk/v1/drawingPlugin/lang/en-US.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "../../plugin.lang.schema.json", 3 | 4 | "languageTag": "en-US", 5 | "fileDescription": "Strings for MyDrawingPlugin.", 6 | "text": { 7 | "plugins": { 8 | "mycompany_drawingplugin": { 9 | "name": "MyDrawing", 10 | "description": "Testing a custom drawing third-party plugin.", 11 | "help-url": "https://www.construct.net", 12 | "properties": { 13 | "edit-image": { 14 | "name": "Image", 15 | "desc": "Click to edit the object's image.", 16 | "link-text": "Edit" 17 | }, 18 | "make-original-size": { 19 | "name": "Size", 20 | "desc": "Click to set the object to the same size as its image.", 21 | "link-text": "Make 1:1" 22 | }, 23 | "test-property": { 24 | "name": "Test property", 25 | "desc": "A test number property. Displayed by 'Alert' action." 26 | } 27 | }, 28 | "aceCategories": { 29 | "custom": "Custom" 30 | }, 31 | "conditions": { 32 | "is-large-number": { 33 | "list-name": "Is large number", 34 | "display-text": "[i]{0}[/i] is a large number", 35 | "description": "Test if a number is greater than 100.", 36 | "params": { 37 | "number": { 38 | "name": "Number", 39 | "desc": "Number to test if greater than 100." 40 | } 41 | } 42 | } 43 | }, 44 | "actions": { 45 | "do-alert": { 46 | "list-name": "Do alert", 47 | "display-text": "Do alert", 48 | "description": "Do a dummy alert." 49 | } 50 | }, 51 | "expressions": { 52 | "double": { 53 | "description": "Double a number.", 54 | "translated-name": "Double", 55 | "params": { 56 | "number": { 57 | "name": "Number", 58 | "desc": "The number to double." 59 | } 60 | } 61 | } 62 | } 63 | } 64 | } 65 | } 66 | } -------------------------------------------------------------------------------- /plugin-sdk/v1/drawingPlugin/type.js: -------------------------------------------------------------------------------- 1 | 2 | const SDK = self.SDK; 3 | 4 | const PLUGIN_CLASS = SDK.Plugins.MyCompany_DrawingPlugin; 5 | 6 | PLUGIN_CLASS.Type = class MyDrawingPluginType extends SDK.ITypeBase 7 | { 8 | constructor(sdkPlugin, iObjectType) 9 | { 10 | super(sdkPlugin, iObjectType); 11 | } 12 | }; 13 | -------------------------------------------------------------------------------- /plugin-sdk/v1/editorTextPlugin/aces.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "../aces.schema.json", 3 | 4 | "custom": { 5 | "conditions": [ 6 | { 7 | "id": "is-large-number", 8 | "scriptName": "IsLargeNumber", 9 | "highlight": true, 10 | "params": [ 11 | { 12 | "id": "number", 13 | "type": "number" 14 | } 15 | ] 16 | } 17 | ], 18 | "actions": [ 19 | { 20 | "id": "do-alert", 21 | "scriptName": "Alert", 22 | "highlight": true 23 | } 24 | ], 25 | "expressions": [ 26 | { 27 | "id": "double", 28 | "expressionName": "Double", 29 | "scriptName": "Double", 30 | "highlight": true, 31 | "returnType": "number", 32 | "params": [ 33 | { 34 | "id": "number", 35 | "type": "number" 36 | } 37 | ] 38 | } 39 | ] 40 | } 41 | } -------------------------------------------------------------------------------- /plugin-sdk/v1/editorTextPlugin/addon.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "../plugin.addon.schema.json", 3 | 4 | "is-c3-addon": true, 5 | "sdk-version": 1, 6 | "type": "plugin", 7 | "name": "My text plugin", 8 | "id": "MyCompany_TextPlugin", 9 | "version": "1.0.0.0", 10 | "author": "Scirra", 11 | "website": "https://www.construct.net", 12 | "documentation": "https://www.construct.net", 13 | "description": "Example custom text drawing Construct 3 plugin.", 14 | "editor-scripts": [ 15 | "plugin.js", 16 | "type.js", 17 | "instance.js" 18 | ], 19 | "file-list": [ 20 | "c3runtime/plugin.js", 21 | "c3runtime/type.js", 22 | "c3runtime/instance.js", 23 | "c3runtime/conditions.js", 24 | "c3runtime/actions.js", 25 | "c3runtime/expressions.js", 26 | "lang/en-US.json", 27 | "aces.json", 28 | "addon.json", 29 | "icon.svg", 30 | "plugin.js", 31 | "type.js", 32 | "instance.js" 33 | ] 34 | } -------------------------------------------------------------------------------- /plugin-sdk/v1/editorTextPlugin/c3runtime/actions.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = self.C3; 3 | 4 | C3.Plugins.MyCompany_TextPlugin.Acts = 5 | { 6 | Alert() 7 | { 8 | alert("Hello world"); 9 | } 10 | }; 11 | -------------------------------------------------------------------------------- /plugin-sdk/v1/editorTextPlugin/c3runtime/conditions.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = self.C3; 3 | 4 | C3.Plugins.MyCompany_TextPlugin.Cnds = 5 | { 6 | IsLargeNumber(number) 7 | { 8 | return number > 100; 9 | } 10 | }; 11 | -------------------------------------------------------------------------------- /plugin-sdk/v1/editorTextPlugin/c3runtime/expressions.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = self.C3; 3 | 4 | C3.Plugins.MyCompany_TextPlugin.Exps = 5 | { 6 | Double(number) 7 | { 8 | return number * 2; 9 | } 10 | }; 11 | 12 | -------------------------------------------------------------------------------- /plugin-sdk/v1/editorTextPlugin/c3runtime/plugin.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = self.C3; 3 | 4 | C3.Plugins.MyCompany_TextPlugin = class MyTextPlugin extends C3.SDKPluginBase 5 | { 6 | constructor(opts) 7 | { 8 | super(opts); 9 | } 10 | 11 | Release() 12 | { 13 | super.Release(); 14 | } 15 | }; 16 | -------------------------------------------------------------------------------- /plugin-sdk/v1/editorTextPlugin/c3runtime/type.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = self.C3; 3 | 4 | C3.Plugins.MyCompany_TextPlugin.Type = class MyTextType extends C3.SDKTypeBase 5 | { 6 | constructor(objectClass) 7 | { 8 | super(objectClass); 9 | } 10 | 11 | Release() 12 | { 13 | super.Release(); 14 | } 15 | 16 | OnCreate() 17 | { 18 | } 19 | }; 20 | -------------------------------------------------------------------------------- /plugin-sdk/v1/editorTextPlugin/lang/en-US.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "../../plugin.lang.schema.json", 3 | 4 | "languageTag": "en-US", 5 | "fileDescription": "Strings for MyTextPlugin.", 6 | "text": { 7 | "plugins": { 8 | "mycompany_textplugin": { 9 | "name": "MyText", 10 | "description": "Testing a custom text drawing third-party plugin.", 11 | "help-url": "https://www.construct.net", 12 | "properties": { 13 | "font": { 14 | "name": "Font", 15 | "desc": "The font to use." 16 | }, 17 | "text": { 18 | "name": "Text", 19 | "desc": "The text to display." 20 | } 21 | }, 22 | "aceCategories": { 23 | "custom": "Custom" 24 | }, 25 | "conditions": { 26 | "is-large-number": { 27 | "list-name": "Is large number", 28 | "display-text": "[i]{0}[/i] is a large number", 29 | "description": "Test if a number is greater than 100.", 30 | "params": { 31 | "number": { 32 | "name": "Number", 33 | "desc": "Number to test if greater than 100." 34 | } 35 | } 36 | } 37 | }, 38 | "actions": { 39 | "do-alert": { 40 | "list-name": "Do alert", 41 | "display-text": "Do alert", 42 | "description": "Do a dummy alert." 43 | } 44 | }, 45 | "expressions": { 46 | "double": { 47 | "description": "Double a number.", 48 | "translated-name": "Double", 49 | "params": { 50 | "number": { 51 | "name": "Number", 52 | "desc": "The number to double." 53 | } 54 | } 55 | } 56 | } 57 | } 58 | } 59 | } 60 | } -------------------------------------------------------------------------------- /plugin-sdk/v1/editorTextPlugin/type.js: -------------------------------------------------------------------------------- 1 | 2 | const SDK = self.SDK; 3 | 4 | const PLUGIN_CLASS = SDK.Plugins.MyCompany_TextPlugin; 5 | 6 | PLUGIN_CLASS.Type = class MyTextPluginType extends SDK.ITypeBase 7 | { 8 | constructor(sdkPlugin, iObjectType) 9 | { 10 | super(sdkPlugin, iObjectType); 11 | } 12 | }; 13 | -------------------------------------------------------------------------------- /plugin-sdk/v1/singleGlobalPlugin/aces.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "../aces.schema.json", 3 | 4 | "custom": { 5 | "conditions": [ 6 | { 7 | "id": "is-large-number", 8 | "scriptName": "IsLargeNumber", 9 | "highlight": true, 10 | "params": [ 11 | { 12 | "id": "number", 13 | "type": "number" 14 | } 15 | ] 16 | } 17 | ], 18 | "actions": [ 19 | { 20 | "id": "log-to-console", 21 | "scriptName": "LogToConsole", 22 | "highlight": true 23 | } 24 | ], 25 | "expressions": [ 26 | { 27 | "id": "double", 28 | "expressionName": "Double", 29 | "highlight": true, 30 | "returnType": "number", 31 | "params": [ 32 | { 33 | "id": "number", 34 | "type": "number" 35 | } 36 | ] 37 | } 38 | ] 39 | } 40 | } -------------------------------------------------------------------------------- /plugin-sdk/v1/singleGlobalPlugin/addon.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "../plugin.addon.schema.json", 3 | 4 | "is-c3-addon": true, 5 | "sdk-version": 1, 6 | "type": "plugin", 7 | "name": "My custom plugin", 8 | "id": "MyCompany_SingleGlobal", 9 | "version": "1.0.0.0", 10 | "author": "Scirra", 11 | "website": "https://www.construct.net", 12 | "documentation": "https://www.construct.net", 13 | "description": "Example custom Construct 3 plugin.", 14 | "editor-scripts": [ 15 | "plugin.js", 16 | "type.js", 17 | "instance.js" 18 | ], 19 | "file-list": [ 20 | "c3runtime/plugin.js", 21 | "c3runtime/type.js", 22 | "c3runtime/instance.js", 23 | "c3runtime/conditions.js", 24 | "c3runtime/actions.js", 25 | "c3runtime/expressions.js", 26 | "lang/en-US.json", 27 | "aces.json", 28 | "addon.json", 29 | "icon.svg", 30 | "instance.js", 31 | "plugin.js", 32 | "type.js" 33 | ] 34 | } -------------------------------------------------------------------------------- /plugin-sdk/v1/singleGlobalPlugin/c3runtime/actions.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = self.C3; 3 | 4 | C3.Plugins.MyCompany_SingleGlobal.Acts = 5 | { 6 | LogToConsole() 7 | { 8 | console.log("This is the 'Log to console' action. Test property = " + this._GetTestProperty()); 9 | } 10 | }; 11 | -------------------------------------------------------------------------------- /plugin-sdk/v1/singleGlobalPlugin/c3runtime/conditions.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = self.C3; 3 | 4 | C3.Plugins.MyCompany_SingleGlobal.Cnds = 5 | { 6 | IsLargeNumber(number) 7 | { 8 | return number > 100; 9 | } 10 | }; 11 | -------------------------------------------------------------------------------- /plugin-sdk/v1/singleGlobalPlugin/c3runtime/expressions.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = self.C3; 3 | 4 | C3.Plugins.MyCompany_SingleGlobal.Exps = 5 | { 6 | Double(number) 7 | { 8 | return number * 2; 9 | } 10 | }; 11 | -------------------------------------------------------------------------------- /plugin-sdk/v1/singleGlobalPlugin/c3runtime/instance.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = self.C3; 3 | 4 | C3.Plugins.MyCompany_SingleGlobal.Instance = class SingleGlobalInstance extends C3.SDKInstanceBase 5 | { 6 | constructor(inst, properties) 7 | { 8 | super(inst); 9 | 10 | // Initialise object properties 11 | this._testProperty = 0; 12 | 13 | if (properties) // note properties may be null in some cases 14 | { 15 | this._testProperty = properties[0]; 16 | } 17 | } 18 | 19 | Release() 20 | { 21 | super.Release(); 22 | } 23 | 24 | _SetTestProperty(n) 25 | { 26 | this._testProperty = n; 27 | } 28 | 29 | _GetTestProperty() 30 | { 31 | return this._testProperty; 32 | } 33 | 34 | SaveToJson() 35 | { 36 | return { 37 | // data to be saved for savegames 38 | }; 39 | } 40 | 41 | LoadFromJson(o) 42 | { 43 | // load state for savegames 44 | } 45 | 46 | GetScriptInterfaceClass() 47 | { 48 | return self.IMySingleGlobalInstance; 49 | } 50 | }; 51 | 52 | // Script interface. Use a WeakMap to safely hide the internal implementation details from the 53 | // caller using the script interface. 54 | const map = new WeakMap(); 55 | 56 | self.IMySingleGlobalInstance = class IMySingleGlobalInstance extends self.IInstance { 57 | constructor() 58 | { 59 | super(); 60 | 61 | // Map by SDK instance 62 | map.set(this, self.IInstance._GetInitInst().GetSdkInstance()); 63 | } 64 | 65 | // Example setter/getter property on script interface 66 | set testProperty(n) 67 | { 68 | map.get(this)._SetTestProperty(n); 69 | } 70 | 71 | get testProperty() 72 | { 73 | return map.get(this)._GetTestProperty(); 74 | } 75 | }; 76 | -------------------------------------------------------------------------------- /plugin-sdk/v1/singleGlobalPlugin/c3runtime/plugin.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = self.C3; 3 | 4 | C3.Plugins.MyCompany_SingleGlobal = class SingleGlobalPlugin extends C3.SDKPluginBase 5 | { 6 | constructor(opts) 7 | { 8 | super(opts); 9 | } 10 | 11 | Release() 12 | { 13 | super.Release(); 14 | } 15 | }; 16 | -------------------------------------------------------------------------------- /plugin-sdk/v1/singleGlobalPlugin/c3runtime/type.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = self.C3; 3 | 4 | C3.Plugins.MyCompany_SingleGlobal.Type = class SingleGlobalType extends C3.SDKTypeBase 5 | { 6 | constructor(objectClass) 7 | { 8 | super(objectClass); 9 | } 10 | 11 | Release() 12 | { 13 | super.Release(); 14 | } 15 | 16 | OnCreate() 17 | { 18 | } 19 | }; 20 | -------------------------------------------------------------------------------- /plugin-sdk/v1/singleGlobalPlugin/instance.js: -------------------------------------------------------------------------------- 1 | 2 | const SDK = self.SDK; 3 | 4 | const PLUGIN_CLASS = SDK.Plugins.MyCompany_SingleGlobal; 5 | 6 | PLUGIN_CLASS.Instance = class MyCustomInstance extends SDK.IInstanceBase 7 | { 8 | constructor(sdkType, inst) 9 | { 10 | super(sdkType, inst); 11 | } 12 | 13 | Release() 14 | { 15 | } 16 | 17 | OnCreate() 18 | { 19 | } 20 | 21 | OnPropertyChanged(id, value) 22 | { 23 | } 24 | 25 | LoadC2Property(name, valueString) 26 | { 27 | return false; // not handled 28 | } 29 | }; 30 | -------------------------------------------------------------------------------- /plugin-sdk/v1/singleGlobalPlugin/lang/en-US.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "../../plugin.lang.schema.json", 3 | 4 | "languageTag": "en-US", 5 | "fileDescription": "Strings for MyCustomPlugin.", 6 | "text": { 7 | "plugins": { 8 | "mycompany_singleglobal": { 9 | "name": "MyCustomPlugin", 10 | "description": "An example third-party plugin.", 11 | "help-url": "https://www.construct.net", 12 | "properties": { 13 | "test-property": { 14 | "name": "Test property", 15 | "desc": "A test number property. Displayed by 'Alert' action." 16 | } 17 | }, 18 | "aceCategories": { 19 | "custom": "Custom" 20 | }, 21 | "conditions": { 22 | "is-large-number": { 23 | "list-name": "Is large number", 24 | "display-text": "[i]{0}[/i] is a large number", 25 | "description": "Test if a number is greater than 100.", 26 | "params": { 27 | "number": { 28 | "name": "Number", 29 | "desc": "Number to test if greater than 100." 30 | } 31 | } 32 | } 33 | }, 34 | "actions": { 35 | "log-to-console": { 36 | "list-name": "Log to console", 37 | "display-text": "Log to console", 38 | "description": "Log a test message to the console." 39 | } 40 | }, 41 | "expressions": { 42 | "double": { 43 | "description": "Double a number.", 44 | "translated-name": "Double", 45 | "params": { 46 | "number": { 47 | "name": "Number", 48 | "desc": "The number to double." 49 | } 50 | } 51 | } 52 | } 53 | } 54 | } 55 | } 56 | } -------------------------------------------------------------------------------- /plugin-sdk/v1/singleGlobalPlugin/plugin.js: -------------------------------------------------------------------------------- 1 | 2 | const SDK = self.SDK; 3 | 4 | //////////////////////////////////////////// 5 | // The plugin ID is how Construct identifies different kinds of plugins. 6 | // *** NEVER CHANGE THE PLUGIN ID! *** 7 | // If you change the plugin ID after releasing the plugin, Construct will think it is an entirely different 8 | // plugin and assume it is incompatible with the old one, and YOU WILL BREAK ALL EXISTING PROJECTS USING THE PLUGIN. 9 | // Only the plugin name is displayed in the editor, so to rename your plugin change the name but NOT the ID. 10 | // If you want to completely replace a plugin, make it deprecated (it will be hidden but old projects keep working), 11 | // and create an entirely new plugin with a different plugin ID. 12 | const PLUGIN_ID = "MyCompany_SingleGlobal"; 13 | //////////////////////////////////////////// 14 | 15 | const PLUGIN_VERSION = "1.0.0.0"; 16 | const PLUGIN_CATEGORY = "general"; 17 | 18 | const PLUGIN_CLASS = SDK.Plugins.MyCompany_SingleGlobal = class MyCustomPlugin extends SDK.IPluginBase 19 | { 20 | constructor() 21 | { 22 | super(PLUGIN_ID); 23 | 24 | SDK.Lang.PushContext("plugins." + PLUGIN_ID.toLowerCase()); 25 | 26 | this._info.SetName(self.lang(".name")); 27 | this._info.SetDescription(self.lang(".description")); 28 | this._info.SetVersion(PLUGIN_VERSION); 29 | this._info.SetCategory(PLUGIN_CATEGORY); 30 | this._info.SetAuthor("Scirra"); 31 | this._info.SetHelpUrl(self.lang(".help-url")); 32 | this._info.SetIsSingleGlobal(true); 33 | 34 | SDK.Lang.PushContext(".properties"); 35 | 36 | this._info.SetProperties([ 37 | new SDK.PluginProperty("integer", "test-property", 0) 38 | ]); 39 | 40 | SDK.Lang.PopContext(); // .properties 41 | 42 | SDK.Lang.PopContext(); 43 | } 44 | }; 45 | 46 | PLUGIN_CLASS.Register(PLUGIN_ID, PLUGIN_CLASS); 47 | -------------------------------------------------------------------------------- /plugin-sdk/v1/singleGlobalPlugin/type.js: -------------------------------------------------------------------------------- 1 | 2 | const SDK = self.SDK; 3 | 4 | const PLUGIN_CLASS = SDK.Plugins.MyCompany_SingleGlobal; 5 | 6 | PLUGIN_CLASS.Type = class MyCustomPluginType extends SDK.ITypeBase 7 | { 8 | constructor(sdkPlugin, iObjectType) 9 | { 10 | super(sdkPlugin, iObjectType); 11 | } 12 | }; 13 | -------------------------------------------------------------------------------- /plugin-sdk/v1/wrapperExtensionPlugin/Wrapper extension sample project.c3p: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Scirra/Construct-Addon-SDK/2fc509b759992d815d980a160db9f810abf9ca58/plugin-sdk/v1/wrapperExtensionPlugin/Wrapper extension sample project.c3p -------------------------------------------------------------------------------- /plugin-sdk/v1/wrapperExtensionPlugin/construct-plugin/MyExtension_x64.ext.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Scirra/Construct-Addon-SDK/2fc509b759992d815d980a160db9f810abf9ca58/plugin-sdk/v1/wrapperExtensionPlugin/construct-plugin/MyExtension_x64.ext.dll -------------------------------------------------------------------------------- /plugin-sdk/v1/wrapperExtensionPlugin/construct-plugin/MyExtension_x86.ext.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Scirra/Construct-Addon-SDK/2fc509b759992d815d980a160db9f810abf9ca58/plugin-sdk/v1/wrapperExtensionPlugin/construct-plugin/MyExtension_x86.ext.dll -------------------------------------------------------------------------------- /plugin-sdk/v1/wrapperExtensionPlugin/construct-plugin/aces.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "../../aces.schema.json", 3 | 4 | "wrapper-extension": { 5 | "conditions": [ 6 | { 7 | "id": "is-available", 8 | "scriptName": "IsAvailable" 9 | } 10 | ], 11 | "actions": [ 12 | { 13 | "id": "show-messagebox", 14 | "scriptName": "ShowMessageBox", 15 | "params": [{ "id": "message", "type": "string" }, 16 | { "id": "title", "type": "string" }] 17 | } 18 | ], 19 | "expressions": [ 20 | { 21 | "id": "sample-string-1", 22 | "expressionName": "SampleString1", 23 | "returnType": "string" 24 | }, { 25 | "id": "sample-string-2", 26 | "expressionName": "SampleString2", 27 | "returnType": "string" 28 | } 29 | ] 30 | } 31 | } -------------------------------------------------------------------------------- /plugin-sdk/v1/wrapperExtensionPlugin/construct-plugin/addon.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "../../plugin.addon.schema.json", 3 | 4 | "is-c3-addon": true, 5 | "sdk-version": 1, 6 | "type": "plugin", 7 | "name": "Wrapper extension", 8 | "id": "MyCompany_WrapperExt", 9 | "version": "1.0.0.0", 10 | "author": "Scirra", 11 | "website": "https://www.construct.net", 12 | "documentation": "https://www.construct.net", 13 | "description": "A sample wrapper extension plugin.", 14 | "editor-scripts": [ 15 | "plugin.js", 16 | "type.js", 17 | "instance.js" 18 | ], 19 | "file-list": [ 20 | "c3runtime/plugin.js", 21 | "c3runtime/type.js", 22 | "c3runtime/instance.js", 23 | "c3runtime/conditions.js", 24 | "c3runtime/actions.js", 25 | "c3runtime/expressions.js", 26 | "lang/en-US.json", 27 | "aces.json", 28 | "addon.json", 29 | "icon.svg", 30 | "instance.js", 31 | "plugin.js", 32 | "type.js", 33 | "MyExtension_x86.ext.dll", 34 | "MyExtension_x64.ext.dll" 35 | ] 36 | } -------------------------------------------------------------------------------- /plugin-sdk/v1/wrapperExtensionPlugin/construct-plugin/c3runtime/actions.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = self.C3; 3 | 4 | C3.Plugins.MyCompany_WrapperExt.Acts = 5 | { 6 | ShowMessageBox(message, title) 7 | { 8 | // Ignore action if extension unavailable 9 | if (!this._IsAvailable()) 10 | return; 11 | 12 | // Send a "show-messagebox" message to the extension, with the message and 13 | // title as two parameters. 14 | this.SendWrapperExtensionMessage("show-messagebox", [ 15 | message, 16 | title 17 | ]); 18 | } 19 | }; 20 | -------------------------------------------------------------------------------- /plugin-sdk/v1/wrapperExtensionPlugin/construct-plugin/c3runtime/conditions.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = self.C3; 3 | 4 | C3.Plugins.MyCompany_WrapperExt.Cnds = 5 | { 6 | IsAvailable() 7 | { 8 | return this._IsAvailable(); 9 | } 10 | }; 11 | -------------------------------------------------------------------------------- /plugin-sdk/v1/wrapperExtensionPlugin/construct-plugin/c3runtime/expressions.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = self.C3; 3 | 4 | C3.Plugins.MyCompany_WrapperExt.Exps = 5 | { 6 | SampleString1() 7 | { 8 | return this._sampleString1; 9 | }, 10 | 11 | SampleString2() 12 | { 13 | return this._sampleString2; 14 | } 15 | }; 16 | -------------------------------------------------------------------------------- /plugin-sdk/v1/wrapperExtensionPlugin/construct-plugin/c3runtime/plugin.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = self.C3; 3 | 4 | C3.Plugins.MyCompany_WrapperExt = class MyCompany_WrapperExtPlugin extends C3.SDKPluginBase 5 | { 6 | constructor(opts) 7 | { 8 | super(opts); 9 | } 10 | 11 | Release() 12 | { 13 | super.Release(); 14 | } 15 | }; 16 | -------------------------------------------------------------------------------- /plugin-sdk/v1/wrapperExtensionPlugin/construct-plugin/c3runtime/type.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = self.C3; 3 | 4 | C3.Plugins.MyCompany_WrapperExt.Type = class MyCompany_WrapperExtType extends C3.SDKTypeBase 5 | { 6 | constructor(objectClass) 7 | { 8 | super(objectClass); 9 | } 10 | 11 | Release() 12 | { 13 | super.Release(); 14 | } 15 | 16 | OnCreate() 17 | { 18 | } 19 | }; 20 | -------------------------------------------------------------------------------- /plugin-sdk/v1/wrapperExtensionPlugin/construct-plugin/instance.js: -------------------------------------------------------------------------------- 1 | 2 | const SDK = self.SDK; 3 | 4 | const PLUGIN_CLASS = SDK.Plugins.MyCompany_WrapperExt; 5 | 6 | PLUGIN_CLASS.Instance = class MyCompany_WrapperExtInstance extends SDK.IInstanceBase 7 | { 8 | constructor(sdkType, inst) 9 | { 10 | super(sdkType, inst); 11 | } 12 | 13 | Release() 14 | { 15 | } 16 | 17 | OnCreate() 18 | { 19 | } 20 | 21 | OnPropertyChanged(id, value) 22 | { 23 | } 24 | 25 | LoadC2Property(name, valueString) 26 | { 27 | return false; // not handled 28 | } 29 | }; 30 | -------------------------------------------------------------------------------- /plugin-sdk/v1/wrapperExtensionPlugin/construct-plugin/lang/en-US.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "../../../plugin.lang.schema.json", 3 | 4 | "languageTag": "en-US", 5 | "fileDescription": "Strings for the sample wrapper extension.", 6 | "text": { 7 | "plugins": { 8 | "mycompany_wrapperext": { 9 | "name": "Wrapper extension", 10 | "description": "A sample wrapper extension plugin.", 11 | "help-url": "https://www.construct.net", 12 | "properties": { 13 | }, 14 | "aceCategories": { 15 | "wrapper-extension": "Wrapper extension" 16 | }, 17 | "conditions": { 18 | "is-available": { 19 | "list-name": "Is available", 20 | "display-text": "Is available", 21 | "description": "True if running in a supported exporter and the extension initialized OK." 22 | } 23 | }, 24 | "actions": { 25 | "show-messagebox": { 26 | "list-name": "Show messagebox", 27 | "display-text": "Show messagebox with message [i]{0}[/i], title [i]{1}[/i]", 28 | "description": "Sample action to show a messagebox via a Windows API call in the extension.", 29 | "params": { 30 | "message": { 31 | "name": "Message", 32 | "desc": "The message to show in the messagebox." 33 | }, 34 | "title": { 35 | "name": "Title", 36 | "desc": "The title of the messagebox." 37 | } 38 | } 39 | } 40 | }, 41 | "expressions": { 42 | "sample-string-1": { 43 | "description": "Sample string 1 returned from extension.", 44 | "translated-name": "SampleString1" 45 | }, 46 | "sample-string-2": { 47 | "description": "Sample string 2 returned from extension.", 48 | "translated-name": "SampleString2" 49 | } 50 | } 51 | } 52 | } 53 | } 54 | } -------------------------------------------------------------------------------- /plugin-sdk/v1/wrapperExtensionPlugin/construct-plugin/type.js: -------------------------------------------------------------------------------- 1 | 2 | const SDK = self.SDK; 3 | 4 | const PLUGIN_CLASS = SDK.Plugins.MyCompany_WrapperExt; 5 | 6 | PLUGIN_CLASS.Type = class MyCompany_WrapperExtType extends SDK.ITypeBase 7 | { 8 | constructor(sdkPlugin, iObjectType) 9 | { 10 | super(sdkPlugin, iObjectType); 11 | } 12 | }; 13 | -------------------------------------------------------------------------------- /plugin-sdk/v1/wrapperExtensionPlugin/extension/Utils.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "IExtension.h" 4 | 5 | // Convert std::string with UTF-8 encoding to std::wstring. 6 | // Use this to convert UTF-8 strings to a format that can be passed to Windows APIs. 7 | std::wstring Utf8ToWide(const std::string& utf8string); 8 | 9 | // Convert std::wstring to std::string with UTF-8 encoding. 10 | // Use this to convert strings returned by Windows APIs back to UTF-8. 11 | std::string WideToUtf8(const std::wstring& widestring); 12 | 13 | // Helper methods for sending data over DLL boundary 14 | std::vector UnpackExtensionParameterArray(size_t paramCount, const ExtensionParameterPOD* paramArr); 15 | std::vector PackNamedExtensionParameters(const std::map& params); 16 | -------------------------------------------------------------------------------- /plugin-sdk/v1/wrapperExtensionPlugin/extension/WrapperExtension.h: -------------------------------------------------------------------------------- 1 | 2 | #include "IApplication.h" 3 | #include "IExtension.h" 4 | 5 | // Main class for your wrapper extension DLL. 6 | class WrapperExtension : public IExtension { 7 | public: 8 | WrapperExtension(IApplication* iApplication_); 9 | 10 | // IExtension overrides 11 | void Init(); 12 | void Release(); 13 | void OnWebMessage(LPCSTR messageId, size_t paramCount, const ExtensionParameterPOD* paramArr, double asyncId); 14 | void OnMainWindowCreated(HWND hWnd_); 15 | 16 | // Web messaging methods 17 | void HandleWebMessage(const std::string& messageId, const std::vector& params, double asyncId); 18 | void SendWebMessage(const std::string& messageId, const std::map& params, double asyncId = -1.0); 19 | void SendAsyncResponse(const std::map& params, double asyncId); 20 | 21 | // Handler methods for specific kinds of message 22 | void OnInitMessage(double asyncId); 23 | void OnShowMessageBox(const std::string& message, const std::string& title); 24 | 25 | protected: 26 | IApplication* iApplication; 27 | HWND hWndMain; 28 | }; -------------------------------------------------------------------------------- /plugin-sdk/v1/wrapperExtensionPlugin/extension/WrapperExtension.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.7.34003.232 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WrapperExtension", "WrapperExtension.vcxproj", "{4A1E51B7-1E34-4E93-ACAD-547C50E53040}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|ARM64 = Debug|ARM64 11 | Debug|x64 = Debug|x64 12 | Debug|x86 = Debug|x86 13 | Release|ARM64 = Release|ARM64 14 | Release|x64 = Release|x64 15 | Release|x86 = Release|x86 16 | EndGlobalSection 17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 18 | {4A1E51B7-1E34-4E93-ACAD-547C50E53040}.Debug|ARM64.ActiveCfg = Debug|ARM64 19 | {4A1E51B7-1E34-4E93-ACAD-547C50E53040}.Debug|ARM64.Build.0 = Debug|ARM64 20 | {4A1E51B7-1E34-4E93-ACAD-547C50E53040}.Debug|x64.ActiveCfg = Debug|x64 21 | {4A1E51B7-1E34-4E93-ACAD-547C50E53040}.Debug|x64.Build.0 = Debug|x64 22 | {4A1E51B7-1E34-4E93-ACAD-547C50E53040}.Debug|x86.ActiveCfg = Debug|Win32 23 | {4A1E51B7-1E34-4E93-ACAD-547C50E53040}.Debug|x86.Build.0 = Debug|Win32 24 | {4A1E51B7-1E34-4E93-ACAD-547C50E53040}.Release|ARM64.ActiveCfg = Release|ARM64 25 | {4A1E51B7-1E34-4E93-ACAD-547C50E53040}.Release|ARM64.Build.0 = Release|ARM64 26 | {4A1E51B7-1E34-4E93-ACAD-547C50E53040}.Release|x64.ActiveCfg = Release|x64 27 | {4A1E51B7-1E34-4E93-ACAD-547C50E53040}.Release|x64.Build.0 = Release|x64 28 | {4A1E51B7-1E34-4E93-ACAD-547C50E53040}.Release|x86.ActiveCfg = Release|Win32 29 | {4A1E51B7-1E34-4E93-ACAD-547C50E53040}.Release|x86.Build.0 = Release|Win32 30 | EndGlobalSection 31 | GlobalSection(SolutionProperties) = preSolution 32 | HideSolutionNode = FALSE 33 | EndGlobalSection 34 | GlobalSection(ExtensibilityGlobals) = postSolution 35 | SolutionGuid = {9C29B02E-C919-4999-B543-D8348B274A30} 36 | EndGlobalSection 37 | EndGlobal 38 | -------------------------------------------------------------------------------- /plugin-sdk/v1/wrapperExtensionPlugin/extension/cpp.hint: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Scirra/Construct-Addon-SDK/2fc509b759992d815d980a160db9f810abf9ca58/plugin-sdk/v1/wrapperExtensionPlugin/extension/cpp.hint -------------------------------------------------------------------------------- /plugin-sdk/v1/wrapperExtensionPlugin/extension/dllmain.cpp: -------------------------------------------------------------------------------- 1 | // dllmain.cpp : Defines the entry point for the DLL application. 2 | #include "pch.h" 3 | 4 | BOOL APIENTRY DllMain( HMODULE hModule, 5 | DWORD ul_reason_for_call, 6 | LPVOID lpReserved 7 | ) 8 | { 9 | switch (ul_reason_for_call) 10 | { 11 | case DLL_PROCESS_ATTACH: 12 | case DLL_THREAD_ATTACH: 13 | case DLL_THREAD_DETACH: 14 | case DLL_PROCESS_DETACH: 15 | break; 16 | } 17 | return TRUE; 18 | } 19 | 20 | -------------------------------------------------------------------------------- /plugin-sdk/v1/wrapperExtensionPlugin/extension/framework.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Windows Header Files 4 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers 5 | #include 6 | 7 | // STL includes 8 | #include // std::vector 9 | #include // std::map 10 | #include // std::string, std::wstring 11 | 12 | // SDK utilities 13 | #include "Utils.h" 14 | -------------------------------------------------------------------------------- /plugin-sdk/v1/wrapperExtensionPlugin/extension/pch.cpp: -------------------------------------------------------------------------------- 1 | // pch.cpp: source file corresponding to the pre-compiled header 2 | 3 | #include "pch.h" 4 | 5 | // When you are using pre-compiled headers, this source file is necessary for compilation to succeed. 6 | -------------------------------------------------------------------------------- /plugin-sdk/v1/wrapperExtensionPlugin/extension/pch.h: -------------------------------------------------------------------------------- 1 | // pch.h: This is a precompiled header file. 2 | // Files listed below are compiled only once, improving build performance for future builds. 3 | // This also affects IntelliSense performance, including code completion and many code browsing features. 4 | // However, files listed here are ALL re-compiled if any one of them is updated between builds. 5 | // Do not add files here that you will be updating frequently as this negates the performance advantage. 6 | 7 | #ifndef PCH_H 8 | #define PCH_H 9 | 10 | // add headers that you want to pre-compile here 11 | #include "framework.h" 12 | 13 | #endif //PCH_H 14 | -------------------------------------------------------------------------------- /plugin-sdk/v2/customImporterPlugin/aces.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "../aces.schema.json", 3 | 4 | "custom": { 5 | "conditions": [ 6 | { 7 | "id": "is-large-number", 8 | "scriptName": "IsLargeNumber", 9 | "highlight": true, 10 | "params": [ 11 | { 12 | "id": "number", 13 | "type": "number" 14 | } 15 | ] 16 | } 17 | ], 18 | "actions": [ 19 | { 20 | "id": "do-alert", 21 | "scriptName": "Alert", 22 | "highlight": true 23 | } 24 | ], 25 | "expressions": [ 26 | { 27 | "id": "double", 28 | "expressionName": "Double", 29 | "highlight": true, 30 | "returnType": "number", 31 | "params": [ 32 | { 33 | "id": "number", 34 | "type": "number" 35 | } 36 | ] 37 | } 38 | ] 39 | } 40 | } -------------------------------------------------------------------------------- /plugin-sdk/v2/customImporterPlugin/addon.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "../plugin.addon.schema.json", 3 | 4 | "is-c3-addon": true, 5 | "sdk-version": 2, 6 | "min-construct-version": "r401", 7 | "type": "plugin", 8 | "name": "My custom importer plugin", 9 | "id": "MyCompany_CustomImporter", 10 | "version": "1.0.0.0", 11 | "author": "Scirra", 12 | "website": "https://www.construct.net", 13 | "documentation": "https://www.construct.net", 14 | "description": "Example custom Construct 3 plugin using Custom Importer API.", 15 | "editor-scripts": [ 16 | "plugin.js", 17 | "type.js", 18 | "instance.js" 19 | ], 20 | "file-list": [ 21 | "c3runtime/main.js", 22 | "c3runtime/plugin.js", 23 | "c3runtime/type.js", 24 | "c3runtime/instance.js", 25 | "c3runtime/conditions.js", 26 | "c3runtime/actions.js", 27 | "c3runtime/expressions.js", 28 | "lang/en-US.json", 29 | "aces.json", 30 | "addon.json", 31 | "icon.svg", 32 | "instance.js", 33 | "plugin.js", 34 | "type.js" 35 | ] 36 | } -------------------------------------------------------------------------------- /plugin-sdk/v2/customImporterPlugin/c3runtime/actions.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = globalThis.C3; 3 | 4 | C3.Plugins.MyCompany_CustomImporter.Acts = 5 | { 6 | Alert() 7 | { 8 | alert("Test property = " + this._getTestProperty()); 9 | } 10 | }; 11 | -------------------------------------------------------------------------------- /plugin-sdk/v2/customImporterPlugin/c3runtime/actions.ts: -------------------------------------------------------------------------------- 1 | 2 | import type { SDKInstanceClass } from "./instance.ts"; 3 | 4 | const C3 = globalThis.C3; 5 | 6 | C3.Plugins.MyCompany_CustomImporter.Acts = 7 | { 8 | Alert(this: SDKInstanceClass) 9 | { 10 | alert("Test property = " + this._getTestProperty()); 11 | } 12 | }; 13 | -------------------------------------------------------------------------------- /plugin-sdk/v2/customImporterPlugin/c3runtime/conditions.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = globalThis.C3; 3 | 4 | C3.Plugins.MyCompany_CustomImporter.Cnds = 5 | { 6 | IsLargeNumber(number) 7 | { 8 | return number > 100; 9 | } 10 | }; 11 | -------------------------------------------------------------------------------- /plugin-sdk/v2/customImporterPlugin/c3runtime/conditions.ts: -------------------------------------------------------------------------------- 1 | 2 | import type { SDKInstanceClass } from "./instance.ts"; 3 | 4 | const C3 = globalThis.C3; 5 | 6 | C3.Plugins.MyCompany_CustomImporter.Cnds = 7 | { 8 | IsLargeNumber(this: SDKInstanceClass, num: number) 9 | { 10 | return num > 100; 11 | } 12 | }; 13 | -------------------------------------------------------------------------------- /plugin-sdk/v2/customImporterPlugin/c3runtime/expressions.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = globalThis.C3; 3 | 4 | C3.Plugins.MyCompany_CustomImporter.Exps = 5 | { 6 | Double(number) 7 | { 8 | return number * 2; 9 | } 10 | }; 11 | -------------------------------------------------------------------------------- /plugin-sdk/v2/customImporterPlugin/c3runtime/expressions.ts: -------------------------------------------------------------------------------- 1 | 2 | import type { SDKInstanceClass } from "./instance.ts"; 3 | 4 | const C3 = globalThis.C3; 5 | 6 | C3.Plugins.MyCompany_CustomImporter.Exps = 7 | { 8 | Double(this: SDKInstanceClass, num: number) 9 | { 10 | return num * 2; 11 | } 12 | }; 13 | -------------------------------------------------------------------------------- /plugin-sdk/v2/customImporterPlugin/c3runtime/instance.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = globalThis.C3; 3 | 4 | C3.Plugins.MyCompany_CustomImporter.Instance = class CustomImporterInstance extends globalThis.ISDKInstanceBase 5 | { 6 | constructor() 7 | { 8 | super(); 9 | 10 | // Initialise object properties 11 | this._testProperty = 0; 12 | 13 | const properties = this._getInitProperties(); 14 | if (properties) // note properties may be null in some cases 15 | { 16 | this._testProperty = properties[0]; 17 | } 18 | } 19 | 20 | _release() 21 | { 22 | super._release(); 23 | } 24 | 25 | _setTestProperty(n) 26 | { 27 | this._testProperty = n; 28 | } 29 | 30 | _getTestProperty() 31 | { 32 | return this._testProperty; 33 | } 34 | 35 | _saveToJson() 36 | { 37 | return { 38 | // data to be saved for savegames 39 | }; 40 | } 41 | 42 | _loadFromJson(o) 43 | { 44 | // load state for savegames 45 | } 46 | }; 47 | -------------------------------------------------------------------------------- /plugin-sdk/v2/customImporterPlugin/c3runtime/instance.ts: -------------------------------------------------------------------------------- 1 | 2 | const C3 = globalThis.C3; 3 | 4 | class CustomImporterInstance extends globalThis.ISDKInstanceBase 5 | { 6 | _testProperty: number; 7 | 8 | constructor() 9 | { 10 | super(); 11 | 12 | // Initialise object properties 13 | this._testProperty = 0; 14 | 15 | const properties = this._getInitProperties(); 16 | if (properties) // note properties may be null in some cases 17 | { 18 | this._testProperty = properties[0] as number; 19 | } 20 | } 21 | 22 | _release() 23 | { 24 | super._release(); 25 | } 26 | 27 | _setTestProperty(n: number) 28 | { 29 | this._testProperty = n; 30 | } 31 | 32 | _getTestProperty() 33 | { 34 | return this._testProperty; 35 | } 36 | 37 | _saveToJson() 38 | { 39 | return { 40 | // data to be saved for savegames 41 | }; 42 | } 43 | 44 | _loadFromJson(o: any) 45 | { 46 | // load state for savegames 47 | } 48 | }; 49 | 50 | C3.Plugins.MyCompany_CustomImporter.Instance = CustomImporterInstance; 51 | 52 | export type { CustomImporterInstance as SDKInstanceClass }; -------------------------------------------------------------------------------- /plugin-sdk/v2/customImporterPlugin/c3runtime/main.js: -------------------------------------------------------------------------------- 1 | import "./plugin.js"; 2 | import "./type.js"; 3 | import "./instance.js"; 4 | import "./conditions.js"; 5 | import "./actions.js"; 6 | import "./expressions.js"; -------------------------------------------------------------------------------- /plugin-sdk/v2/customImporterPlugin/c3runtime/main.ts: -------------------------------------------------------------------------------- 1 | import "./plugin.js"; 2 | import "./type.js"; 3 | import "./instance.js"; 4 | import "./conditions.js"; 5 | import "./actions.js"; 6 | import "./expressions.js"; -------------------------------------------------------------------------------- /plugin-sdk/v2/customImporterPlugin/c3runtime/plugin.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = globalThis.C3; 3 | 4 | C3.Plugins.MyCompany_CustomImporter = class CustomImporterPlugin extends globalThis.ISDKPluginBase 5 | { 6 | constructor() 7 | { 8 | super(); 9 | } 10 | }; 11 | -------------------------------------------------------------------------------- /plugin-sdk/v2/customImporterPlugin/c3runtime/plugin.ts: -------------------------------------------------------------------------------- 1 | 2 | const C3 = globalThis.C3; 3 | 4 | C3.Plugins.MyCompany_CustomImporter = class CustomImporterPlugin extends globalThis.ISDKPluginBase 5 | { 6 | constructor() 7 | { 8 | super(); 9 | } 10 | }; 11 | 12 | // Necessary for TypeScript to treat this file as a module 13 | export {} -------------------------------------------------------------------------------- /plugin-sdk/v2/customImporterPlugin/c3runtime/type.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = globalThis.C3; 3 | 4 | C3.Plugins.MyCompany_CustomImporter.Type = class CustomImporterType extends globalThis.ISDKObjectTypeBase 5 | { 6 | constructor() 7 | { 8 | super(); 9 | } 10 | 11 | _onCreate() 12 | { 13 | } 14 | }; 15 | -------------------------------------------------------------------------------- /plugin-sdk/v2/customImporterPlugin/c3runtime/type.ts: -------------------------------------------------------------------------------- 1 | 2 | import type { SDKInstanceClass } from "./instance.ts"; 3 | 4 | const C3 = globalThis.C3; 5 | 6 | C3.Plugins.MyCompany_CustomImporter.Type = class CustomImporterType extends globalThis.ISDKObjectTypeBase 7 | { 8 | constructor() 9 | { 10 | super(); 11 | } 12 | 13 | _onCreate() 14 | { 15 | } 16 | }; 17 | -------------------------------------------------------------------------------- /plugin-sdk/v2/customImporterPlugin/instance.js: -------------------------------------------------------------------------------- 1 | 2 | const SDK = globalThis.SDK; 3 | 4 | const PLUGIN_CLASS = SDK.Plugins.MyCompany_CustomImporter; 5 | 6 | PLUGIN_CLASS.Instance = class MyCustomImporterInstance extends SDK.IInstanceBase 7 | { 8 | constructor(sdkType, inst) 9 | { 10 | super(sdkType, inst); 11 | } 12 | 13 | Release() 14 | { 15 | } 16 | 17 | OnCreate() 18 | { 19 | } 20 | 21 | OnPropertyChanged(id, value) 22 | { 23 | } 24 | 25 | LoadC2Property(name, valueString) 26 | { 27 | return false; // not handled 28 | } 29 | }; 30 | -------------------------------------------------------------------------------- /plugin-sdk/v2/customImporterPlugin/instance.ts: -------------------------------------------------------------------------------- 1 | 2 | const SDK = globalThis.SDK; 3 | 4 | const PLUGIN_CLASS = SDK.Plugins.MyCompany_CustomImporter; 5 | 6 | PLUGIN_CLASS.Instance = class MyCustomImporterInstance extends SDK.IInstanceBase 7 | { 8 | constructor(sdkType: SDK.ITypeBase, inst: SDK.IObjectInstance) 9 | { 10 | super(sdkType, inst); 11 | } 12 | 13 | Release() 14 | { 15 | } 16 | 17 | OnCreate() 18 | { 19 | } 20 | 21 | OnPropertyChanged(id: string, value: EditorPropertyValueType) 22 | { 23 | } 24 | 25 | LoadC2Property(name: string, valueString: string) 26 | { 27 | return false; // not handled 28 | } 29 | }; 30 | 31 | export {} -------------------------------------------------------------------------------- /plugin-sdk/v2/customImporterPlugin/lang/en-US.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "../../plugin.lang.schema.json", 3 | 4 | "languageTag": "en-US", 5 | "fileDescription": "Strings for MyCustomImporterPlugin.", 6 | "text": { 7 | "plugins": { 8 | "mycompany_customimporter": { 9 | "name": "CustomImportPlugin", 10 | "description": "An example third-party plugin demonstrating the Custom Importer API.", 11 | "help-url": "https://www.construct.net", 12 | "properties": { 13 | "test-property": { 14 | "name": "Test property", 15 | "desc": "A test number property. Displayed by 'Alert' action." 16 | } 17 | }, 18 | "aceCategories": { 19 | "custom": "Custom" 20 | }, 21 | "conditions": { 22 | "is-large-number": { 23 | "list-name": "Is large number", 24 | "display-text": "[i]{0}[/i] is a large number", 25 | "description": "Test if a number is greater than 100.", 26 | "params": { 27 | "number": { 28 | "name": "Number", 29 | "desc": "Number to test if greater than 100." 30 | } 31 | } 32 | } 33 | }, 34 | "actions": { 35 | "do-alert": { 36 | "list-name": "Do alert", 37 | "display-text": "Do alert", 38 | "description": "Do a dummy alert." 39 | } 40 | }, 41 | "expressions": { 42 | "double": { 43 | "description": "Double a number.", 44 | "translated-name": "Double", 45 | "params": { 46 | "number": { 47 | "name": "Number", 48 | "desc": "The number to double." 49 | } 50 | } 51 | } 52 | } 53 | } 54 | } 55 | } 56 | } -------------------------------------------------------------------------------- /plugin-sdk/v2/customImporterPlugin/tsconfig.json: -------------------------------------------------------------------------------- 1 | 2 | { 3 | "compilerOptions": { 4 | /* Visit https://aka.ms/tsconfig to read more about this file */ 5 | 6 | /* Transpile away class fields, as Closure Compiler doesn't support them yet */ 7 | "target": "ES2021", 8 | 9 | /* Use modern standard JavaScript (ES) Modules */ 10 | "module": "ES2022", 11 | 12 | /* Disable polyfill code for CommonJS modules - Construct always uses ES Modules */ 13 | "esModuleInterop": false, 14 | 15 | /* Other standard settings specified by tsc --init */ 16 | "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */ 17 | "strict": true 18 | } 19 | } -------------------------------------------------------------------------------- /plugin-sdk/v2/customImporterPlugin/type.js: -------------------------------------------------------------------------------- 1 | 2 | const SDK = globalThis.SDK; 3 | 4 | const PLUGIN_CLASS = SDK.Plugins.MyCompany_CustomImporter; 5 | 6 | PLUGIN_CLASS.Type = class MyCustomImporterType extends SDK.ITypeBase 7 | { 8 | constructor(sdkPlugin, iObjectType) 9 | { 10 | super(sdkPlugin, iObjectType); 11 | } 12 | }; 13 | -------------------------------------------------------------------------------- /plugin-sdk/v2/customImporterPlugin/type.ts: -------------------------------------------------------------------------------- 1 | 2 | const SDK = globalThis.SDK; 3 | 4 | const PLUGIN_CLASS = SDK.Plugins.MyCompany_CustomImporter; 5 | 6 | PLUGIN_CLASS.Type = class MyCustomImporterType extends SDK.ITypeBase 7 | { 8 | constructor(sdkPlugin: SDK.IPluginBase, iObjectType: SDK.IObjectType) 9 | { 10 | super(sdkPlugin, iObjectType); 11 | } 12 | }; 13 | 14 | export {} -------------------------------------------------------------------------------- /plugin-sdk/v2/customImporterSampleData.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Scirra/Construct-Addon-SDK/2fc509b759992d815d980a160db9f810abf9ca58/plugin-sdk/v2/customImporterSampleData.zip -------------------------------------------------------------------------------- /plugin-sdk/v2/domElementPlugin/aces.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "../aces.schema.json", 3 | 4 | "button": { 5 | "conditions": [ 6 | { 7 | "id": "on-click", 8 | "scriptName": "OnClick", 9 | "isTrigger": true 10 | } 11 | ], 12 | "actions": [ 13 | { 14 | "id": "set-text", 15 | "scriptName": "SetText", 16 | "params": [{ "id": "text", "type": "string" }] 17 | } 18 | ], 19 | "expressions": [ 20 | { 21 | "id": "text", 22 | "expressionName": "Text", 23 | "returnType": "string" 24 | } 25 | ] 26 | } 27 | } -------------------------------------------------------------------------------- /plugin-sdk/v2/domElementPlugin/addon.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "../plugin.addon.schema.json", 3 | 4 | "is-c3-addon": true, 5 | "sdk-version": 2, 6 | "min-construct-version": "r401", 7 | "type": "plugin", 8 | "name": "My DOM plugin", 9 | "id": "MyCompany_DOMPlugin", 10 | "version": "1.0.0.0", 11 | "author": "Scirra", 12 | "website": "https://www.construct.net", 13 | "documentation": "https://www.construct.net", 14 | "description": "Example custom DOM element Construct 3 plugin.", 15 | "editor-scripts": [ 16 | "plugin.js", 17 | "type.js", 18 | "instance.js" 19 | ], 20 | "file-list": [ 21 | "c3runtime/main.js", 22 | "c3runtime/plugin.js", 23 | "c3runtime/type.js", 24 | "c3runtime/instance.js", 25 | "c3runtime/domSide.js", 26 | "c3runtime/conditions.js", 27 | "c3runtime/actions.js", 28 | "c3runtime/expressions.js", 29 | "lang/en-US.json", 30 | "aces.json", 31 | "addon.json", 32 | "icon.svg", 33 | "plugin.js", 34 | "type.js", 35 | "instance.js" 36 | ] 37 | } -------------------------------------------------------------------------------- /plugin-sdk/v2/domElementPlugin/c3runtime/actions.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = globalThis.C3; 3 | 4 | C3.Plugins.MyCompany_DOMPlugin.Acts = 5 | { 6 | SetText(text) 7 | { 8 | this._setText(text); 9 | } 10 | }; 11 | -------------------------------------------------------------------------------- /plugin-sdk/v2/domElementPlugin/c3runtime/actions.ts: -------------------------------------------------------------------------------- 1 | 2 | import type { SDKInstanceClass } from "./instance.ts"; 3 | 4 | const C3 = globalThis.C3; 5 | 6 | C3.Plugins.MyCompany_DOMPlugin.Acts = 7 | { 8 | SetText(this: SDKInstanceClass, text: string) 9 | { 10 | this._setText(text); 11 | } 12 | }; 13 | -------------------------------------------------------------------------------- /plugin-sdk/v2/domElementPlugin/c3runtime/conditions.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = globalThis.C3; 3 | 4 | C3.Plugins.MyCompany_DOMPlugin.Cnds = 5 | { 6 | OnClick() 7 | { 8 | return true; 9 | } 10 | }; 11 | -------------------------------------------------------------------------------- /plugin-sdk/v2/domElementPlugin/c3runtime/conditions.ts: -------------------------------------------------------------------------------- 1 | 2 | import type { SDKInstanceClass } from "./instance.ts"; 3 | 4 | const C3 = globalThis.C3; 5 | 6 | C3.Plugins.MyCompany_DOMPlugin.Cnds = 7 | { 8 | OnClick(this: SDKInstanceClass) 9 | { 10 | return true; 11 | } 12 | }; 13 | -------------------------------------------------------------------------------- /plugin-sdk/v2/domElementPlugin/c3runtime/expressions.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = globalThis.C3; 3 | 4 | C3.Plugins.MyCompany_DOMPlugin.Exps = 5 | { 6 | Text() 7 | { 8 | // Return the button text. Note this returns a copy of the text stored in the instance, 9 | // since retrieving the real button text would require an asynchronous message posting 10 | // from the runtime to the DOM, and expressions must return synchronously. 11 | return this._getText(); 12 | } 13 | }; 14 | 15 | -------------------------------------------------------------------------------- /plugin-sdk/v2/domElementPlugin/c3runtime/expressions.ts: -------------------------------------------------------------------------------- 1 | 2 | import type { SDKInstanceClass } from "./instance.ts"; 3 | 4 | const C3 = globalThis.C3; 5 | 6 | C3.Plugins.MyCompany_DOMPlugin.Exps = 7 | { 8 | Text(this: SDKInstanceClass) 9 | { 10 | // Return the button text. Note this returns a copy of the text stored in the instance, 11 | // since retrieving the real button text would require an asynchronous message posting 12 | // from the runtime to the DOM, and expressions must return synchronously. 13 | return this._getText(); 14 | } 15 | }; 16 | 17 | -------------------------------------------------------------------------------- /plugin-sdk/v2/domElementPlugin/c3runtime/main.js: -------------------------------------------------------------------------------- 1 | import "./plugin.js"; 2 | import "./type.js"; 3 | import "./instance.js"; 4 | import "./conditions.js"; 5 | import "./actions.js"; 6 | import "./expressions.js"; -------------------------------------------------------------------------------- /plugin-sdk/v2/domElementPlugin/c3runtime/main.ts: -------------------------------------------------------------------------------- 1 | import "./plugin.js"; 2 | import "./type.js"; 3 | import "./instance.js"; 4 | import "./conditions.js"; 5 | import "./actions.js"; 6 | import "./expressions.js"; -------------------------------------------------------------------------------- /plugin-sdk/v2/domElementPlugin/c3runtime/plugin.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = globalThis.C3; 3 | 4 | // NOTE: use a unique DOM component ID to ensure it doesn't clash with anything else 5 | // This must also match the ID in instance.js and domSide.js. 6 | const DOM_COMPONENT_ID = "mycompany-mydomplugin"; 7 | 8 | // NOTE: DOM plugins derive from ISDKDOMPluginBase, not ISDKPluginBase 9 | C3.Plugins.MyCompany_DOMPlugin = class MyDOMPlugin extends globalThis.ISDKDOMPluginBase 10 | { 11 | constructor() 12 | { 13 | super({ domComponentId: DOM_COMPONENT_ID }); 14 | 15 | // Calls to PostToRuntimeElement() in domSide.js are forwarded to the plugin here. 16 | // The relevant instance is passed as an argument. Generally these messages need to be handled by the 17 | // instances themselves, so the handlers here just forward messages to instance calls. 18 | 19 | // Forward "click" messages to the _onClick() method of the relevant instance. 20 | // Note this also forwards the optional extra details object as the argument 'e', but in this 21 | // case it's not used for the click handler. 22 | this._addElementMessageHandler("click", (inst, e) => inst._onClick(e)); 23 | } 24 | }; 25 | -------------------------------------------------------------------------------- /plugin-sdk/v2/domElementPlugin/c3runtime/plugin.ts: -------------------------------------------------------------------------------- 1 | 2 | import type { SDKInstanceClass } from "./instance.ts"; 3 | 4 | const C3 = globalThis.C3; 5 | 6 | // NOTE: use a unique DOM component ID to ensure it doesn't clash with anything else 7 | // This must also match the ID in instance.js and domSide.js. 8 | const DOM_COMPONENT_ID = "mycompany-mydomplugin"; 9 | 10 | // NOTE: DOM plugins derive from ISDKDOMPluginBase, not ISDKPluginBase 11 | C3.Plugins.MyCompany_DOMPlugin = class MyDOMPlugin extends globalThis.ISDKDOMPluginBase 12 | { 13 | constructor() 14 | { 15 | super({ domComponentId: DOM_COMPONENT_ID }); 16 | 17 | // Calls to PostToRuntimeElement() in domSide.js are forwarded to the plugin here. 18 | // The relevant instance is passed as an argument. Generally these messages need to be handled by the 19 | // instances themselves, so the handlers here just forward messages to instance calls. 20 | 21 | // Forward "click" messages to the _onClick() method of the relevant instance. 22 | // Note this also forwards the optional extra details object as the argument 'e', but in this 23 | // case it's not used for the click handler. 24 | this._addElementMessageHandler("click", (inst, e) => inst._onClick(e)); 25 | } 26 | }; 27 | 28 | // Necessary for TypeScript to treat this file as a module 29 | export {} -------------------------------------------------------------------------------- /plugin-sdk/v2/domElementPlugin/c3runtime/type.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = globalThis.C3; 3 | 4 | C3.Plugins.MyCompany_DOMPlugin.Type = class MyDOMType extends globalThis.ISDKObjectTypeBase 5 | { 6 | constructor() 7 | { 8 | super(); 9 | } 10 | 11 | _onCreate() 12 | { 13 | } 14 | }; 15 | -------------------------------------------------------------------------------- /plugin-sdk/v2/domElementPlugin/c3runtime/type.ts: -------------------------------------------------------------------------------- 1 | 2 | import type { SDKInstanceClass } from "./instance.ts"; 3 | 4 | const C3 = globalThis.C3; 5 | 6 | C3.Plugins.MyCompany_DOMPlugin.Type = class MyDOMType extends globalThis.ISDKObjectTypeBase 7 | { 8 | constructor() 9 | { 10 | super(); 11 | } 12 | 13 | _onCreate() 14 | { 15 | } 16 | }; 17 | -------------------------------------------------------------------------------- /plugin-sdk/v2/domElementPlugin/lang/en-US.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "../../plugin.lang.schema.json", 3 | 4 | "languageTag": "en-US", 5 | "fileDescription": "Strings for MyCompany_DOMPlugin.", 6 | "text": { 7 | "plugins": { 8 | "mycompany_domplugin": { 9 | "name": "MyDOM", 10 | "description": "Testing a custom DOM element third-party plugin.", 11 | "help-url": "https://www.construct.net", 12 | "properties": { 13 | "button-text": { 14 | "name": "Button text", 15 | "desc": "The text to display on the button." 16 | } 17 | }, 18 | "aceCategories": { 19 | "button": "Button" 20 | }, 21 | "conditions": { 22 | "on-click": { 23 | "list-name": "On click", 24 | "display-text": "On click", 25 | "description": "Triggered when the button is clicked." 26 | } 27 | }, 28 | "actions": { 29 | "set-text": { 30 | "list-name": "Set text", 31 | "display-text": "Set button text to [i]{0}[/i]", 32 | "description": "Set the button text.", 33 | "params": { 34 | "text": { 35 | "name": "Text", 36 | "desc": "The new button text." 37 | } 38 | } 39 | } 40 | }, 41 | "expressions": { 42 | "text": { 43 | "description": "The button text.", 44 | "translated-name": "Text" 45 | } 46 | } 47 | } 48 | } 49 | } 50 | } -------------------------------------------------------------------------------- /plugin-sdk/v2/domElementPlugin/tsconfig.json: -------------------------------------------------------------------------------- 1 | 2 | { 3 | "compilerOptions": { 4 | /* Visit https://aka.ms/tsconfig to read more about this file */ 5 | 6 | /* Transpile away class fields, as Closure Compiler doesn't support them yet */ 7 | "target": "ES2021", 8 | 9 | /* Use modern standard JavaScript (ES) Modules */ 10 | "module": "ES2022", 11 | 12 | /* Disable polyfill code for CommonJS modules - Construct always uses ES Modules */ 13 | "esModuleInterop": false, 14 | 15 | /* Other standard settings specified by tsc --init */ 16 | "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */ 17 | "strict": true 18 | } 19 | } -------------------------------------------------------------------------------- /plugin-sdk/v2/domElementPlugin/type.js: -------------------------------------------------------------------------------- 1 | 2 | const SDK = globalThis.SDK; 3 | 4 | const PLUGIN_CLASS = SDK.Plugins.MyCompany_DOMPlugin; 5 | 6 | PLUGIN_CLASS.Type = class MyDOMPluginType extends SDK.ITypeBase 7 | { 8 | constructor(sdkPlugin, iObjectType) 9 | { 10 | super(sdkPlugin, iObjectType); 11 | } 12 | }; 13 | -------------------------------------------------------------------------------- /plugin-sdk/v2/domElementPlugin/type.ts: -------------------------------------------------------------------------------- 1 | 2 | const SDK = globalThis.SDK; 3 | 4 | const PLUGIN_CLASS = SDK.Plugins.MyCompany_DOMPlugin; 5 | 6 | PLUGIN_CLASS.Type = class MyDOMPluginType extends SDK.ITypeBase 7 | { 8 | constructor(sdkPlugin: SDK.IPluginBase, iObjectType: SDK.IObjectType) 9 | { 10 | super(sdkPlugin, iObjectType); 11 | } 12 | }; 13 | 14 | export {} -------------------------------------------------------------------------------- /plugin-sdk/v2/domMessagingPlugin/aces.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "../aces.schema.json", 3 | 4 | "custom": { 5 | "actions": [ 6 | { 7 | "id": "set-document-title", 8 | "scriptName": "SetDocumentTitle", 9 | "highlight": true, 10 | "params": [ 11 | { 12 | "id": "title", 13 | "type": "string" 14 | } 15 | ] 16 | } 17 | ], 18 | "expressions": [ 19 | { 20 | "id": "get-document-title", 21 | "expressionName": "DocumentTitle", 22 | "highlight": true, 23 | "returnType": "string" 24 | } 25 | ] 26 | } 27 | } -------------------------------------------------------------------------------- /plugin-sdk/v2/domMessagingPlugin/addon.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "../plugin.addon.schema.json", 3 | 4 | "is-c3-addon": true, 5 | "sdk-version": 2, 6 | "min-construct-version": "r401", 7 | "type": "plugin", 8 | "name": "DOM plugin", 9 | "id": "MyCompany_DOMMessaging", 10 | "version": "1.0.0.0", 11 | "author": "Scirra", 12 | "website": "https://www.construct.net", 13 | "documentation": "https://www.construct.net", 14 | "description": "Example custom Construct 3 plugin.", 15 | "editor-scripts": [ 16 | "plugin.js", 17 | "type.js", 18 | "instance.js" 19 | ], 20 | "file-list": [ 21 | "c3runtime/main.js", 22 | "c3runtime/plugin.js", 23 | "c3runtime/type.js", 24 | "c3runtime/instance.js", 25 | "c3runtime/conditions.js", 26 | "c3runtime/actions.js", 27 | "c3runtime/expressions.js", 28 | "c3runtime/domSide.js", 29 | "lang/en-US.json", 30 | "aces.json", 31 | "addon.json", 32 | "icon.svg", 33 | "instance.js", 34 | "plugin.js", 35 | "type.js" 36 | ] 37 | } -------------------------------------------------------------------------------- /plugin-sdk/v2/domMessagingPlugin/c3runtime/actions.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = globalThis.C3; 3 | 4 | C3.Plugins.MyCompany_DOMMessaging.Acts = 5 | { 6 | SetDocumentTitle(title) 7 | { 8 | // Update the copy of the document title held on the instance. 9 | this._documentTitle = title; 10 | 11 | // Post a message to the domSide.js script to update the document title. 12 | this._postToDOM("set-document-title", { 13 | "title": title 14 | }); 15 | } 16 | }; 17 | -------------------------------------------------------------------------------- /plugin-sdk/v2/domMessagingPlugin/c3runtime/actions.ts: -------------------------------------------------------------------------------- 1 | 2 | import type { SDKInstanceClass } from "./instance.ts"; 3 | 4 | const C3 = globalThis.C3; 5 | 6 | C3.Plugins.MyCompany_DOMMessaging.Acts = 7 | { 8 | SetDocumentTitle(this: SDKInstanceClass, title: string) 9 | { 10 | // Update the copy of the document title held on the instance. 11 | this._documentTitle = title; 12 | 13 | // Post a message to the domSide.js script to update the document title. 14 | this._postToDOM("set-document-title", { 15 | "title": title 16 | }); 17 | } 18 | }; 19 | -------------------------------------------------------------------------------- /plugin-sdk/v2/domMessagingPlugin/c3runtime/conditions.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = globalThis.C3; 3 | 4 | C3.Plugins.MyCompany_DOMMessaging.Cnds = 5 | { 6 | // no conditions 7 | }; 8 | -------------------------------------------------------------------------------- /plugin-sdk/v2/domMessagingPlugin/c3runtime/conditions.ts: -------------------------------------------------------------------------------- 1 | 2 | import type { SDKInstanceClass } from "./instance.ts"; 3 | 4 | const C3 = globalThis.C3; 5 | 6 | C3.Plugins.MyCompany_DOMMessaging.Cnds = 7 | { 8 | // no conditions 9 | }; 10 | -------------------------------------------------------------------------------- /plugin-sdk/v2/domMessagingPlugin/c3runtime/domSide.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | { 4 | // Update the DOM_COMPONENT_ID to be unique to your plugin. 5 | // It must match the value set in instance.js as well. 6 | const DOM_COMPONENT_ID = "MyCompany_DOMMessaging"; 7 | 8 | // This class handles messages from the runtime, which may be in a Web Worker. 9 | const HANDLER_CLASS = class ExampleDOMHandler extends globalThis.DOMHandler 10 | { 11 | constructor(iRuntime) 12 | { 13 | super(iRuntime, DOM_COMPONENT_ID); 14 | 15 | // This provides a table of message names to functions to call for those messages. 16 | // For example the "Set document title" action posts a "set-document-title" message, 17 | // which will then call _OnSetDocumentTitle(). 18 | this.AddRuntimeMessageHandlers([ 19 | ["get-initial-state", () => this._OnGetInitialState()], 20 | ["set-document-title", e => this._OnSetDocumentTitle(e)] 21 | ]); 22 | } 23 | 24 | _OnGetInitialState() 25 | { 26 | // Return the initial document title so the DocumentTitle expression has the right 27 | // value on startup. The return value of this method will be what the PostToDOMAsync() 28 | // promise resolves to. 29 | return { 30 | "document-title": document.title 31 | }; 32 | } 33 | 34 | // Called by the 'Set document title' action. Since this script is always in the DOM, 35 | // the document.title property can be accessed directly, and updated with the title 36 | // sent from the action. 37 | _OnSetDocumentTitle(e) 38 | { 39 | document.title = e["title"]; 40 | } 41 | }; 42 | 43 | globalThis.RuntimeInterface.AddDOMHandlerClass(HANDLER_CLASS); 44 | } -------------------------------------------------------------------------------- /plugin-sdk/v2/domMessagingPlugin/c3runtime/domSide.ts: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | { 4 | // Update the DOM_COMPONENT_ID to be unique to your plugin. 5 | // It must match the value set in instance.js as well. 6 | const DOM_COMPONENT_ID = "MyCompany_DOMMessaging"; 7 | 8 | // This class handles messages from the runtime, which may be in a Web Worker. 9 | const HANDLER_CLASS = class ExampleDOMHandler extends globalThis.DOMHandler 10 | { 11 | constructor(iRuntime: IRuntimeInterface) 12 | { 13 | super(iRuntime, DOM_COMPONENT_ID); 14 | 15 | // This provides a table of message names to functions to call for those messages. 16 | // For example the "Set document title" action posts a "set-document-title" message, 17 | // which will then call _OnSetDocumentTitle(). 18 | this.AddRuntimeMessageHandlers([ 19 | ["get-initial-state", () => this._OnGetInitialState()], 20 | ["set-document-title", e => this._OnSetDocumentTitle(e)] 21 | ]); 22 | } 23 | 24 | _OnGetInitialState() 25 | { 26 | // Return the initial document title so the DocumentTitle expression has the right 27 | // value on startup. The return value of this method will be what the PostToDOMAsync() 28 | // promise resolves to. 29 | return { 30 | "document-title": document.title 31 | }; 32 | } 33 | 34 | // Called by the 'Set document title' action. Since this script is always in the DOM, 35 | // the document.title property can be accessed directly, and updated with the title 36 | // sent from the action. 37 | _OnSetDocumentTitle(e: JSONValue) 38 | { 39 | const data = e as JSONObject; 40 | document.title = data["title"] as string; 41 | } 42 | }; 43 | 44 | globalThis.RuntimeInterface.AddDOMHandlerClass(HANDLER_CLASS); 45 | } -------------------------------------------------------------------------------- /plugin-sdk/v2/domMessagingPlugin/c3runtime/expressions.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = globalThis.C3; 3 | 4 | C3.Plugins.MyCompany_DOMMessaging.Exps = 5 | { 6 | DocumentTitle() 7 | { 8 | // This returns the copy of the document title held on the runtime side. 9 | return this._documentTitle; 10 | } 11 | }; 12 | -------------------------------------------------------------------------------- /plugin-sdk/v2/domMessagingPlugin/c3runtime/expressions.ts: -------------------------------------------------------------------------------- 1 | 2 | import type { SDKInstanceClass } from "./instance.ts"; 3 | 4 | const C3 = globalThis.C3; 5 | 6 | C3.Plugins.MyCompany_DOMMessaging.Exps = 7 | { 8 | DocumentTitle(this: SDKInstanceClass) 9 | { 10 | // This returns the copy of the document title held on the runtime side. 11 | return this._documentTitle; 12 | } 13 | }; 14 | -------------------------------------------------------------------------------- /plugin-sdk/v2/domMessagingPlugin/c3runtime/instance.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = globalThis.C3; 3 | 4 | // Update the DOM_COMPONENT_ID to be unique to your plugin. 5 | // It must match the value set in domSide.js as well. 6 | const DOM_COMPONENT_ID = "MyCompany_DOMMessaging"; 7 | 8 | C3.Plugins.MyCompany_DOMMessaging.Instance = class DOMMessagingInstance extends globalThis.ISDKInstanceBase 9 | { 10 | constructor() 11 | { 12 | // Note that DOM_COMPONENT_ID must be passed to the base class as an additional parameter. 13 | super({ domComponentId: DOM_COMPONENT_ID }); 14 | 15 | // The document title is not directly accessible in a worker. Therefore keep a copy of the 16 | // current document title on the runtime side so it can be returned from an expression. 17 | this._documentTitle = ""; 18 | 19 | // Initialise object properties 20 | this._testProperty = 0; 21 | 22 | const properties = this._getInitProperties(); 23 | if (properties) // note properties may be null in some cases 24 | { 25 | this._testProperty = properties[0]; 26 | } 27 | 28 | // Post to the DOM to retrieve the initial state, which makes sure that the initial document 29 | // title held on the runtime side is correct on startup. Make runtime loading wait for the response. 30 | this.runtime.sdk.addLoadPromise( 31 | this._postToDOMAsync("get-initial-state") 32 | .then(data => 33 | { 34 | this._documentTitle = data["document-title"]; 35 | }) 36 | ); 37 | } 38 | 39 | _release() 40 | { 41 | super._release(); 42 | } 43 | 44 | _setTestProperty(n) 45 | { 46 | this._testProperty = n; 47 | } 48 | 49 | _getTestProperty() 50 | { 51 | return this._testProperty; 52 | } 53 | 54 | _saveToJson() 55 | { 56 | return { 57 | // data to be saved for savegames 58 | }; 59 | } 60 | 61 | _loadFromJson(o) 62 | { 63 | // load state for savegames 64 | } 65 | }; 66 | -------------------------------------------------------------------------------- /plugin-sdk/v2/domMessagingPlugin/c3runtime/main.js: -------------------------------------------------------------------------------- 1 | import "./plugin.js"; 2 | import "./type.js"; 3 | import "./instance.js"; 4 | import "./conditions.js"; 5 | import "./actions.js"; 6 | import "./expressions.js"; -------------------------------------------------------------------------------- /plugin-sdk/v2/domMessagingPlugin/c3runtime/main.ts: -------------------------------------------------------------------------------- 1 | import "./plugin.js"; 2 | import "./type.js"; 3 | import "./instance.js"; 4 | import "./conditions.js"; 5 | import "./actions.js"; 6 | import "./expressions.js"; -------------------------------------------------------------------------------- /plugin-sdk/v2/domMessagingPlugin/c3runtime/plugin.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = globalThis.C3; 3 | 4 | C3.Plugins.MyCompany_DOMMessaging = class DOMMessagingPlugin extends globalThis.ISDKPluginBase 5 | { 6 | constructor() 7 | { 8 | super(); 9 | } 10 | }; 11 | -------------------------------------------------------------------------------- /plugin-sdk/v2/domMessagingPlugin/c3runtime/plugin.ts: -------------------------------------------------------------------------------- 1 | 2 | const C3 = globalThis.C3; 3 | 4 | C3.Plugins.MyCompany_DOMMessaging = class DOMMessagingPlugin extends globalThis.ISDKPluginBase 5 | { 6 | constructor() 7 | { 8 | super(); 9 | } 10 | }; 11 | 12 | // Necessary for TypeScript to treat this file as a module 13 | export {} -------------------------------------------------------------------------------- /plugin-sdk/v2/domMessagingPlugin/c3runtime/type.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = globalThis.C3; 3 | 4 | C3.Plugins.MyCompany_DOMMessaging.Type = class DOMMessagingType extends globalThis.ISDKObjectTypeBase 5 | { 6 | constructor() 7 | { 8 | super(); 9 | } 10 | 11 | _onCreate() 12 | { 13 | } 14 | }; 15 | -------------------------------------------------------------------------------- /plugin-sdk/v2/domMessagingPlugin/c3runtime/type.ts: -------------------------------------------------------------------------------- 1 | 2 | import type { SDKInstanceClass } from "./instance.ts"; 3 | 4 | const C3 = globalThis.C3; 5 | 6 | C3.Plugins.MyCompany_DOMMessaging.Type = class DOMMessagingType extends globalThis.ISDKObjectTypeBase 7 | { 8 | constructor() 9 | { 10 | super(); 11 | } 12 | 13 | _onCreate() 14 | { 15 | } 16 | }; 17 | -------------------------------------------------------------------------------- /plugin-sdk/v2/domMessagingPlugin/instance.js: -------------------------------------------------------------------------------- 1 | 2 | const SDK = globalThis.SDK; 3 | 4 | const PLUGIN_CLASS = SDK.Plugins.MyCompany_DOMMessaging; 5 | 6 | PLUGIN_CLASS.Instance = class MyCustomInstance extends SDK.IInstanceBase 7 | { 8 | constructor(sdkType, inst) 9 | { 10 | super(sdkType, inst); 11 | } 12 | 13 | Release() 14 | { 15 | } 16 | 17 | OnCreate() 18 | { 19 | } 20 | 21 | OnPropertyChanged(id, value) 22 | { 23 | } 24 | }; 25 | -------------------------------------------------------------------------------- /plugin-sdk/v2/domMessagingPlugin/instance.ts: -------------------------------------------------------------------------------- 1 | 2 | const SDK = globalThis.SDK; 3 | 4 | const PLUGIN_CLASS = SDK.Plugins.MyCompany_DOMMessaging; 5 | 6 | PLUGIN_CLASS.Instance = class MyCustomInstance extends SDK.IInstanceBase 7 | { 8 | constructor(sdkType: SDK.ITypeBase, inst: SDK.IObjectInstance) 9 | { 10 | super(sdkType, inst); 11 | } 12 | 13 | Release() 14 | { 15 | } 16 | 17 | OnCreate() 18 | { 19 | } 20 | 21 | OnPropertyChanged(id: string, value: EditorPropertyValueType) 22 | { 23 | } 24 | }; 25 | 26 | export {} -------------------------------------------------------------------------------- /plugin-sdk/v2/domMessagingPlugin/lang/en-US.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "../../plugin.lang.schema.json", 3 | 4 | "languageTag": "en-US", 5 | "fileDescription": "Strings for DOMMessaging.", 6 | "text": { 7 | "plugins": { 8 | "mycompany_dommessaging": { 9 | "name": "MyDOMPlugin", 10 | "description": "An example third-party plugin using DOM messaging.", 11 | "help-url": "https://www.construct.net", 12 | "properties": { 13 | "test-property": { 14 | "name": "Test property", 15 | "desc": "A test number property." 16 | } 17 | }, 18 | "aceCategories": { 19 | "custom": "Custom" 20 | }, 21 | "conditions": { 22 | }, 23 | "actions": { 24 | "set-document-title": { 25 | "list-name": "Set document title", 26 | "display-text": "Set document title to [b]{0}[/b]", 27 | "description": "Set the document title to a string.", 28 | "params": { 29 | "title": { 30 | "name": "Title", 31 | "desc": "The document title to set." 32 | } 33 | } 34 | } 35 | }, 36 | "expressions": { 37 | "get-document-title": { 38 | "description": "Get the current document title.", 39 | "translated-name": "DocumentTitle" 40 | } 41 | } 42 | } 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /plugin-sdk/v2/domMessagingPlugin/plugin.js: -------------------------------------------------------------------------------- 1 | 2 | const SDK = globalThis.SDK; 3 | 4 | //////////////////////////////////////////// 5 | // The plugin ID is how Construct identifies different kinds of plugins. 6 | // *** NEVER CHANGE THE PLUGIN ID! *** 7 | // If you change the plugin ID after releasing the plugin, Construct will think it is an entirely different 8 | // plugin and assume it is incompatible with the old one, and YOU WILL BREAK ALL EXISTING PROJECTS USING THE PLUGIN. 9 | // Only the plugin name is displayed in the editor, so to rename your plugin change the name but NOT the ID. 10 | // If you want to completely replace a plugin, make it deprecated (it will be hidden but old projects keep working), 11 | // and create an entirely new plugin with a different plugin ID. 12 | const PLUGIN_ID = "MyCompany_DOMMessaging"; 13 | //////////////////////////////////////////// 14 | 15 | const PLUGIN_CATEGORY = "general"; 16 | 17 | const PLUGIN_CLASS = SDK.Plugins.MyCompany_DOMMessaging = class MyCustomPlugin extends SDK.IPluginBase 18 | { 19 | constructor() 20 | { 21 | super(PLUGIN_ID); 22 | 23 | SDK.Lang.PushContext("plugins." + PLUGIN_ID.toLowerCase()); 24 | 25 | this._info.SetName(globalThis.lang(".name")); 26 | this._info.SetDescription(globalThis.lang(".description")); 27 | this._info.SetCategory(PLUGIN_CATEGORY); 28 | this._info.SetAuthor("Scirra"); 29 | this._info.SetHelpUrl(globalThis.lang(".help-url")); 30 | this._info.SetIsSingleGlobal(true); 31 | this._info.SetRuntimeModuleMainScript("c3runtime/main.js"); 32 | 33 | // Set the domSide.js script to run in the context of the DOM 34 | this._info.SetDOMSideScripts(["c3runtime/domSide.js"]); 35 | 36 | SDK.Lang.PushContext(".properties"); 37 | 38 | this._info.SetProperties([ 39 | new SDK.PluginProperty("integer", "test-property", 0) 40 | ]); 41 | 42 | SDK.Lang.PopContext(); // .properties 43 | 44 | SDK.Lang.PopContext(); 45 | } 46 | }; 47 | 48 | PLUGIN_CLASS.Register(PLUGIN_ID, PLUGIN_CLASS); 49 | -------------------------------------------------------------------------------- /plugin-sdk/v2/domMessagingPlugin/tsconfig.json: -------------------------------------------------------------------------------- 1 | 2 | { 3 | "compilerOptions": { 4 | /* Visit https://aka.ms/tsconfig to read more about this file */ 5 | 6 | /* Transpile away class fields, as Closure Compiler doesn't support them yet */ 7 | "target": "ES2021", 8 | 9 | /* Use modern standard JavaScript (ES) Modules */ 10 | "module": "ES2022", 11 | 12 | /* Disable polyfill code for CommonJS modules - Construct always uses ES Modules */ 13 | "esModuleInterop": false, 14 | 15 | /* Other standard settings specified by tsc --init */ 16 | "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */ 17 | "strict": true 18 | } 19 | } -------------------------------------------------------------------------------- /plugin-sdk/v2/domMessagingPlugin/type.js: -------------------------------------------------------------------------------- 1 | 2 | const SDK = globalThis.SDK; 3 | 4 | const PLUGIN_CLASS = SDK.Plugins.MyCompany_DOMMessaging; 5 | 6 | PLUGIN_CLASS.Type = class MyCustomPluginType extends SDK.ITypeBase 7 | { 8 | constructor(sdkPlugin, iObjectType) 9 | { 10 | super(sdkPlugin, iObjectType); 11 | } 12 | }; 13 | -------------------------------------------------------------------------------- /plugin-sdk/v2/domMessagingPlugin/type.ts: -------------------------------------------------------------------------------- 1 | 2 | const SDK = globalThis.SDK; 3 | 4 | const PLUGIN_CLASS = SDK.Plugins.MyCompany_DOMMessaging; 5 | 6 | PLUGIN_CLASS.Type = class MyCustomPluginType extends SDK.ITypeBase 7 | { 8 | constructor(sdkPlugin: SDK.IPluginBase, iObjectType: SDK.IObjectType) 9 | { 10 | super(sdkPlugin, iObjectType); 11 | } 12 | }; 13 | 14 | export {} -------------------------------------------------------------------------------- /plugin-sdk/v2/drawingPlugin/aces.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "../aces.schema.json", 3 | 4 | "custom": { 5 | "conditions": [ 6 | { 7 | "id": "is-large-number", 8 | "scriptName": "IsLargeNumber", 9 | "highlight": true, 10 | "params": [ 11 | { 12 | "id": "number", 13 | "type": "number" 14 | } 15 | ] 16 | } 17 | ], 18 | "actions": [ 19 | { 20 | "id": "do-alert", 21 | "scriptName": "Alert", 22 | "highlight": true 23 | } 24 | ], 25 | "expressions": [ 26 | { 27 | "id": "double", 28 | "expressionName": "Double", 29 | "highlight": true, 30 | "returnType": "number", 31 | "params": [ 32 | { 33 | "id": "number", 34 | "type": "number" 35 | } 36 | ] 37 | } 38 | ] 39 | } 40 | } -------------------------------------------------------------------------------- /plugin-sdk/v2/drawingPlugin/addon.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "../plugin.addon.schema.json", 3 | 4 | "is-c3-addon": true, 5 | "sdk-version": 2, 6 | "min-construct-version": "r401", 7 | "type": "plugin", 8 | "name": "My drawing plugin", 9 | "id": "MyCompany_DrawingPlugin", 10 | "version": "1.0.0.0", 11 | "author": "Scirra", 12 | "website": "https://www.construct.net", 13 | "documentation": "https://www.construct.net", 14 | "description": "Example custom drawing Construct 3 plugin.", 15 | "editor-scripts": [ 16 | "plugin.js", 17 | "type.js", 18 | "instance.js" 19 | ], 20 | "file-list": [ 21 | "c3runtime/main.js", 22 | "c3runtime/plugin.js", 23 | "c3runtime/type.js", 24 | "c3runtime/instance.js", 25 | "c3runtime/conditions.js", 26 | "c3runtime/actions.js", 27 | "c3runtime/expressions.js", 28 | "lang/en-US.json", 29 | "aces.json", 30 | "addon.json", 31 | "icon.svg", 32 | "plugin.js", 33 | "type.js", 34 | "instance.js" 35 | ] 36 | } -------------------------------------------------------------------------------- /plugin-sdk/v2/drawingPlugin/c3runtime/actions.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = globalThis.C3; 3 | 4 | C3.Plugins.MyCompany_DrawingPlugin.Acts = 5 | { 6 | Alert() 7 | { 8 | alert("Test property = " + this._getTestProperty()); 9 | } 10 | }; 11 | -------------------------------------------------------------------------------- /plugin-sdk/v2/drawingPlugin/c3runtime/actions.ts: -------------------------------------------------------------------------------- 1 | 2 | import type { SDKInstanceClass } from "./instance.ts"; 3 | 4 | const C3 = globalThis.C3; 5 | 6 | C3.Plugins.MyCompany_DrawingPlugin.Acts = 7 | { 8 | Alert(this: SDKInstanceClass) 9 | { 10 | alert("Test property = " + this._getTestProperty()); 11 | } 12 | }; 13 | -------------------------------------------------------------------------------- /plugin-sdk/v2/drawingPlugin/c3runtime/conditions.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = globalThis.C3; 3 | 4 | C3.Plugins.MyCompany_DrawingPlugin.Cnds = 5 | { 6 | IsLargeNumber(number) 7 | { 8 | return number > 100; 9 | } 10 | }; 11 | -------------------------------------------------------------------------------- /plugin-sdk/v2/drawingPlugin/c3runtime/conditions.ts: -------------------------------------------------------------------------------- 1 | 2 | import type { SDKInstanceClass } from "./instance.ts"; 3 | 4 | const C3 = globalThis.C3; 5 | 6 | C3.Plugins.MyCompany_DrawingPlugin.Cnds = 7 | { 8 | IsLargeNumber(this: SDKInstanceClass, num: number) 9 | { 10 | return num > 100; 11 | } 12 | }; 13 | -------------------------------------------------------------------------------- /plugin-sdk/v2/drawingPlugin/c3runtime/expressions.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = globalThis.C3; 3 | 4 | C3.Plugins.MyCompany_DrawingPlugin.Exps = 5 | { 6 | Double(number) 7 | { 8 | return number * 2; 9 | } 10 | }; 11 | 12 | -------------------------------------------------------------------------------- /plugin-sdk/v2/drawingPlugin/c3runtime/expressions.ts: -------------------------------------------------------------------------------- 1 | 2 | import type { SDKInstanceClass } from "./instance.ts"; 3 | 4 | const C3 = globalThis.C3; 5 | 6 | C3.Plugins.MyCompany_DrawingPlugin.Exps = 7 | { 8 | Double(this: SDKInstanceClass, num: number) 9 | { 10 | return num * 2; 11 | } 12 | }; 13 | 14 | -------------------------------------------------------------------------------- /plugin-sdk/v2/drawingPlugin/c3runtime/instance.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = globalThis.C3; 3 | 4 | const tempQuad = new C3.Quad(); 5 | 6 | C3.Plugins.MyCompany_DrawingPlugin.Instance = class DrawingInstance extends globalThis.ISDKWorldInstanceBase 7 | { 8 | constructor() 9 | { 10 | super(); 11 | 12 | this._testProperty = 0; 13 | 14 | const properties = this._getInitProperties(); 15 | if (properties) 16 | { 17 | this._testProperty = properties[0]; 18 | } 19 | } 20 | 21 | _release() 22 | { 23 | super._release(); 24 | } 25 | 26 | _draw(renderer) 27 | { 28 | const imageInfo = this.objectType.getImageInfo(); 29 | const texture = imageInfo.getTexture(renderer); 30 | 31 | if (!texture) 32 | return; // dynamic texture load which hasn't completed yet; can't draw anything 33 | 34 | let quad = this.getBoundingQuad(); 35 | const rcTex = imageInfo.getTexRect(); 36 | 37 | renderer.setTexture(texture); 38 | 39 | if (this.runtime.isPixelRoundingEnabled) 40 | { 41 | const ox = Math.round(this.x) - this.x; 42 | const oy = Math.round(this.y) - this.y; 43 | 44 | if (ox !== 0 && oy !== 0) 45 | { 46 | quad = new DOMQuad(new DOMPoint(quad.p1.x + ox, quad.p1.y + oy), 47 | new DOMPoint(quad.p2.x + ox, quad.p2.y + oy), 48 | new DOMPoint(quad.p3.x + ox, quad.p3.y + oy), 49 | new DOMPoint(quad.p4.x + ox, quad.p4.y + oy)); 50 | } 51 | } 52 | 53 | renderer.quad3(quad, rcTex); 54 | } 55 | 56 | _saveToJson() 57 | { 58 | return { 59 | // data to be saved for savegames 60 | }; 61 | } 62 | 63 | _loadFromJson(o) 64 | { 65 | // load state for savegames 66 | } 67 | 68 | _setTestProperty(n) 69 | { 70 | this._testProperty = n; 71 | } 72 | 73 | _getTestProperty() 74 | { 75 | return this._testProperty; 76 | } 77 | }; 78 | -------------------------------------------------------------------------------- /plugin-sdk/v2/drawingPlugin/c3runtime/instance.ts: -------------------------------------------------------------------------------- 1 | 2 | const C3 = globalThis.C3; 3 | 4 | class DrawingInstance extends globalThis.ISDKWorldInstanceBase 5 | { 6 | _testProperty: number; 7 | 8 | constructor() 9 | { 10 | super(); 11 | 12 | this._testProperty = 0; 13 | 14 | const properties = this._getInitProperties(); 15 | if (properties) 16 | { 17 | this._testProperty = properties[0] as number; 18 | } 19 | } 20 | 21 | _release() 22 | { 23 | super._release(); 24 | } 25 | 26 | _draw(renderer: IRenderer) 27 | { 28 | const imageInfo = this.objectType.getImageInfo(); 29 | const texture = imageInfo.getTexture(renderer); 30 | 31 | if (!texture) 32 | return; // dynamic texture load which hasn't completed yet; can't draw anything 33 | 34 | let quad = this.getBoundingQuad(); 35 | const rcTex = imageInfo.getTexRect(); 36 | 37 | renderer.setTexture(texture); 38 | 39 | if (this.runtime.isPixelRoundingEnabled) 40 | { 41 | const ox = Math.round(this.x) - this.x; 42 | const oy = Math.round(this.y) - this.y; 43 | 44 | if (ox !== 0 && oy !== 0) 45 | { 46 | quad = new DOMQuad(new DOMPoint(quad.p1.x + ox, quad.p1.y + oy), 47 | new DOMPoint(quad.p2.x + ox, quad.p2.y + oy), 48 | new DOMPoint(quad.p3.x + ox, quad.p3.y + oy), 49 | new DOMPoint(quad.p4.x + ox, quad.p4.y + oy)); 50 | } 51 | } 52 | 53 | renderer.quad3(quad, rcTex); 54 | } 55 | 56 | _saveToJson() 57 | { 58 | return { 59 | // data to be saved for savegames 60 | }; 61 | } 62 | 63 | _loadFromJson(o: JSONValue) 64 | { 65 | // load state for savegames 66 | } 67 | 68 | _setTestProperty(n: number) 69 | { 70 | this._testProperty = n; 71 | } 72 | 73 | _getTestProperty() 74 | { 75 | return this._testProperty; 76 | } 77 | }; 78 | 79 | C3.Plugins.MyCompany_DrawingPlugin.Instance = DrawingInstance; 80 | 81 | export type { DrawingInstance as SDKInstanceClass }; -------------------------------------------------------------------------------- /plugin-sdk/v2/drawingPlugin/c3runtime/main.js: -------------------------------------------------------------------------------- 1 | import "./plugin.js"; 2 | import "./type.js"; 3 | import "./instance.js"; 4 | import "./conditions.js"; 5 | import "./actions.js"; 6 | import "./expressions.js"; -------------------------------------------------------------------------------- /plugin-sdk/v2/drawingPlugin/c3runtime/main.ts: -------------------------------------------------------------------------------- 1 | import "./plugin.js"; 2 | import "./type.js"; 3 | import "./instance.js"; 4 | import "./conditions.js"; 5 | import "./actions.js"; 6 | import "./expressions.js"; -------------------------------------------------------------------------------- /plugin-sdk/v2/drawingPlugin/c3runtime/plugin.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = globalThis.C3; 3 | 4 | C3.Plugins.MyCompany_DrawingPlugin = class DrawingPlugin extends globalThis.ISDKPluginBase 5 | { 6 | constructor() 7 | { 8 | super(); 9 | } 10 | }; 11 | -------------------------------------------------------------------------------- /plugin-sdk/v2/drawingPlugin/c3runtime/plugin.ts: -------------------------------------------------------------------------------- 1 | 2 | const C3 = globalThis.C3; 3 | 4 | C3.Plugins.MyCompany_DrawingPlugin = class DrawingPlugin extends globalThis.ISDKPluginBase 5 | { 6 | constructor() 7 | { 8 | super(); 9 | } 10 | }; 11 | 12 | // Necessary for TypeScript to treat this file as a module 13 | export {} -------------------------------------------------------------------------------- /plugin-sdk/v2/drawingPlugin/c3runtime/type.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = globalThis.C3; 3 | 4 | C3.Plugins.MyCompany_DrawingPlugin.Type = class DrawingType extends globalThis.ISDKObjectTypeBase 5 | { 6 | constructor() 7 | { 8 | super(); 9 | } 10 | 11 | _onCreate() 12 | { 13 | this.runtime.assets.loadImageAsset(this.getImageInfo()); 14 | } 15 | 16 | _loadTextures(renderer) 17 | { 18 | return renderer.loadTextureForImageInfo(this.getImageInfo(), { 19 | sampling: this.runtime.sampling 20 | }); 21 | } 22 | 23 | _releaseTextures(renderer) 24 | { 25 | renderer.releaseTextureForImageInfo(this.getImageInfo()); 26 | } 27 | }; 28 | -------------------------------------------------------------------------------- /plugin-sdk/v2/drawingPlugin/c3runtime/type.ts: -------------------------------------------------------------------------------- 1 | 2 | import type { SDKInstanceClass } from "./instance.ts"; 3 | 4 | const C3 = globalThis.C3; 5 | 6 | C3.Plugins.MyCompany_DrawingPlugin.Type = class DrawingType extends globalThis.ISDKObjectTypeBase 7 | { 8 | constructor() 9 | { 10 | super(); 11 | } 12 | 13 | _onCreate() 14 | { 15 | this.runtime.assets.loadImageAsset(this.getImageInfo()); 16 | } 17 | 18 | _loadTextures(renderer: IRenderer) 19 | { 20 | return renderer.loadTextureForImageInfo(this.getImageInfo(), { 21 | sampling: this.runtime.sampling 22 | }); 23 | } 24 | 25 | _releaseTextures(renderer: IRenderer) 26 | { 27 | renderer.releaseTextureForImageInfo(this.getImageInfo()); 28 | } 29 | }; 30 | -------------------------------------------------------------------------------- /plugin-sdk/v2/drawingPlugin/lang/en-US.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "../../plugin.lang.schema.json", 3 | 4 | "languageTag": "en-US", 5 | "fileDescription": "Strings for MyDrawingPlugin.", 6 | "text": { 7 | "plugins": { 8 | "mycompany_drawingplugin": { 9 | "name": "MyDrawing", 10 | "description": "Testing a custom drawing third-party plugin.", 11 | "help-url": "https://www.construct.net", 12 | "properties": { 13 | "edit-image": { 14 | "name": "Image", 15 | "desc": "Click to edit the object's image.", 16 | "link-text": "Edit" 17 | }, 18 | "make-original-size": { 19 | "name": "Size", 20 | "desc": "Click to set the object to the same size as its image.", 21 | "link-text": "Make 1:1" 22 | }, 23 | "test-property": { 24 | "name": "Test property", 25 | "desc": "A test number property. Displayed by 'Alert' action." 26 | } 27 | }, 28 | "aceCategories": { 29 | "custom": "Custom" 30 | }, 31 | "conditions": { 32 | "is-large-number": { 33 | "list-name": "Is large number", 34 | "display-text": "[i]{0}[/i] is a large number", 35 | "description": "Test if a number is greater than 100.", 36 | "params": { 37 | "number": { 38 | "name": "Number", 39 | "desc": "Number to test if greater than 100." 40 | } 41 | } 42 | } 43 | }, 44 | "actions": { 45 | "do-alert": { 46 | "list-name": "Do alert", 47 | "display-text": "Do alert", 48 | "description": "Do a dummy alert." 49 | } 50 | }, 51 | "expressions": { 52 | "double": { 53 | "description": "Double a number.", 54 | "translated-name": "Double", 55 | "params": { 56 | "number": { 57 | "name": "Number", 58 | "desc": "The number to double." 59 | } 60 | } 61 | } 62 | } 63 | } 64 | } 65 | } 66 | } -------------------------------------------------------------------------------- /plugin-sdk/v2/drawingPlugin/tsconfig.json: -------------------------------------------------------------------------------- 1 | 2 | { 3 | "compilerOptions": { 4 | /* Visit https://aka.ms/tsconfig to read more about this file */ 5 | 6 | /* Transpile away class fields, as Closure Compiler doesn't support them yet */ 7 | "target": "ES2021", 8 | 9 | /* Use modern standard JavaScript (ES) Modules */ 10 | "module": "ES2022", 11 | 12 | /* Disable polyfill code for CommonJS modules - Construct always uses ES Modules */ 13 | "esModuleInterop": false, 14 | 15 | /* Other standard settings specified by tsc --init */ 16 | "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */ 17 | "strict": true 18 | } 19 | } -------------------------------------------------------------------------------- /plugin-sdk/v2/drawingPlugin/type.js: -------------------------------------------------------------------------------- 1 | 2 | const SDK = globalThis.SDK; 3 | 4 | const PLUGIN_CLASS = SDK.Plugins.MyCompany_DrawingPlugin; 5 | 6 | PLUGIN_CLASS.Type = class MyDrawingPluginType extends SDK.ITypeBase 7 | { 8 | constructor(sdkPlugin, iObjectType) 9 | { 10 | super(sdkPlugin, iObjectType); 11 | } 12 | }; 13 | -------------------------------------------------------------------------------- /plugin-sdk/v2/drawingPlugin/type.ts: -------------------------------------------------------------------------------- 1 | 2 | const SDK = globalThis.SDK; 3 | 4 | const PLUGIN_CLASS = SDK.Plugins.MyCompany_DrawingPlugin; 5 | 6 | PLUGIN_CLASS.Type = class MyDrawingPluginType extends SDK.ITypeBase 7 | { 8 | constructor(sdkPlugin: SDK.IPluginBase, iObjectType: SDK.IObjectType) 9 | { 10 | super(sdkPlugin, iObjectType); 11 | } 12 | }; 13 | 14 | export {} -------------------------------------------------------------------------------- /plugin-sdk/v2/editorTextPlugin/aces.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "../aces.schema.json", 3 | 4 | "custom": { 5 | "conditions": [ 6 | { 7 | "id": "is-large-number", 8 | "scriptName": "IsLargeNumber", 9 | "highlight": true, 10 | "params": [ 11 | { 12 | "id": "number", 13 | "type": "number" 14 | } 15 | ] 16 | } 17 | ], 18 | "actions": [ 19 | { 20 | "id": "do-alert", 21 | "scriptName": "Alert", 22 | "highlight": true 23 | } 24 | ], 25 | "expressions": [ 26 | { 27 | "id": "double", 28 | "expressionName": "Double", 29 | "scriptName": "Double", 30 | "highlight": true, 31 | "returnType": "number", 32 | "params": [ 33 | { 34 | "id": "number", 35 | "type": "number" 36 | } 37 | ] 38 | } 39 | ] 40 | } 41 | } -------------------------------------------------------------------------------- /plugin-sdk/v2/editorTextPlugin/addon.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "../plugin.addon.schema.json", 3 | 4 | "is-c3-addon": true, 5 | "sdk-version": 2, 6 | "min-construct-version": "r401", 7 | "type": "plugin", 8 | "name": "My text plugin", 9 | "id": "MyCompany_TextPlugin", 10 | "version": "1.0.0.0", 11 | "author": "Scirra", 12 | "website": "https://www.construct.net", 13 | "documentation": "https://www.construct.net", 14 | "description": "Example custom text drawing Construct 3 plugin.", 15 | "editor-scripts": [ 16 | "plugin.js", 17 | "type.js", 18 | "instance.js" 19 | ], 20 | "file-list": [ 21 | "c3runtime/main.js", 22 | "c3runtime/plugin.js", 23 | "c3runtime/type.js", 24 | "c3runtime/instance.js", 25 | "c3runtime/conditions.js", 26 | "c3runtime/actions.js", 27 | "c3runtime/expressions.js", 28 | "lang/en-US.json", 29 | "aces.json", 30 | "addon.json", 31 | "icon.svg", 32 | "plugin.js", 33 | "type.js", 34 | "instance.js" 35 | ] 36 | } -------------------------------------------------------------------------------- /plugin-sdk/v2/editorTextPlugin/c3runtime/actions.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = globalThis.C3; 3 | 4 | C3.Plugins.MyCompany_TextPlugin.Acts = 5 | { 6 | Alert() 7 | { 8 | alert("Hello world"); 9 | } 10 | }; 11 | -------------------------------------------------------------------------------- /plugin-sdk/v2/editorTextPlugin/c3runtime/actions.ts: -------------------------------------------------------------------------------- 1 | 2 | import type { SDKInstanceClass } from "./instance.ts"; 3 | 4 | const C3 = globalThis.C3; 5 | 6 | C3.Plugins.MyCompany_TextPlugin.Acts = 7 | { 8 | Alert(this: SDKInstanceClass) 9 | { 10 | alert("Hello world"); 11 | } 12 | }; 13 | -------------------------------------------------------------------------------- /plugin-sdk/v2/editorTextPlugin/c3runtime/conditions.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = globalThis.C3; 3 | 4 | C3.Plugins.MyCompany_TextPlugin.Cnds = 5 | { 6 | IsLargeNumber(number) 7 | { 8 | return number > 100; 9 | } 10 | }; 11 | -------------------------------------------------------------------------------- /plugin-sdk/v2/editorTextPlugin/c3runtime/conditions.ts: -------------------------------------------------------------------------------- 1 | 2 | import type { SDKInstanceClass } from "./instance.ts"; 3 | 4 | const C3 = globalThis.C3; 5 | 6 | C3.Plugins.MyCompany_TextPlugin.Cnds = 7 | { 8 | IsLargeNumber(this: SDKInstanceClass, num: number) 9 | { 10 | return num > 100; 11 | } 12 | }; 13 | -------------------------------------------------------------------------------- /plugin-sdk/v2/editorTextPlugin/c3runtime/expressions.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = globalThis.C3; 3 | 4 | C3.Plugins.MyCompany_TextPlugin.Exps = 5 | { 6 | Double(number) 7 | { 8 | return number * 2; 9 | } 10 | }; 11 | 12 | -------------------------------------------------------------------------------- /plugin-sdk/v2/editorTextPlugin/c3runtime/expressions.ts: -------------------------------------------------------------------------------- 1 | 2 | import type { SDKInstanceClass } from "./instance.ts"; 3 | 4 | const C3 = globalThis.C3; 5 | 6 | C3.Plugins.MyCompany_TextPlugin.Exps = 7 | { 8 | Double(this: SDKInstanceClass, num: number) 9 | { 10 | return num * 2; 11 | } 12 | }; 13 | 14 | -------------------------------------------------------------------------------- /plugin-sdk/v2/editorTextPlugin/c3runtime/main.js: -------------------------------------------------------------------------------- 1 | import "./plugin.js"; 2 | import "./type.js"; 3 | import "./instance.js"; 4 | import "./conditions.js"; 5 | import "./actions.js"; 6 | import "./expressions.js"; -------------------------------------------------------------------------------- /plugin-sdk/v2/editorTextPlugin/c3runtime/main.ts: -------------------------------------------------------------------------------- 1 | import "./plugin.js"; 2 | import "./type.js"; 3 | import "./instance.js"; 4 | import "./conditions.js"; 5 | import "./actions.js"; 6 | import "./expressions.js"; -------------------------------------------------------------------------------- /plugin-sdk/v2/editorTextPlugin/c3runtime/plugin.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = globalThis.C3; 3 | 4 | C3.Plugins.MyCompany_TextPlugin = class MyTextPlugin extends globalThis.ISDKPluginBase 5 | { 6 | constructor() 7 | { 8 | super(); 9 | } 10 | }; 11 | -------------------------------------------------------------------------------- /plugin-sdk/v2/editorTextPlugin/c3runtime/plugin.ts: -------------------------------------------------------------------------------- 1 | 2 | const C3 = globalThis.C3; 3 | 4 | C3.Plugins.MyCompany_TextPlugin = class MyTextPlugin extends globalThis.ISDKPluginBase 5 | { 6 | constructor() 7 | { 8 | super(); 9 | } 10 | }; 11 | 12 | // Necessary for TypeScript to treat this file as a module 13 | export {} -------------------------------------------------------------------------------- /plugin-sdk/v2/editorTextPlugin/c3runtime/type.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = globalThis.C3; 3 | 4 | C3.Plugins.MyCompany_TextPlugin.Type = class MyTextType extends globalThis.ISDKObjectTypeBase 5 | { 6 | constructor() 7 | { 8 | super(); 9 | } 10 | 11 | _onCreate() 12 | { 13 | } 14 | }; 15 | -------------------------------------------------------------------------------- /plugin-sdk/v2/editorTextPlugin/c3runtime/type.ts: -------------------------------------------------------------------------------- 1 | 2 | import type { SDKInstanceClass } from "./instance.ts"; 3 | 4 | const C3 = globalThis.C3; 5 | 6 | C3.Plugins.MyCompany_TextPlugin.Type = class MyTextType extends globalThis.ISDKObjectTypeBase 7 | { 8 | constructor() 9 | { 10 | super(); 11 | } 12 | 13 | _onCreate() 14 | { 15 | } 16 | }; 17 | -------------------------------------------------------------------------------- /plugin-sdk/v2/editorTextPlugin/lang/en-US.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "../../plugin.lang.schema.json", 3 | 4 | "languageTag": "en-US", 5 | "fileDescription": "Strings for MyTextPlugin.", 6 | "text": { 7 | "plugins": { 8 | "mycompany_textplugin": { 9 | "name": "MyText", 10 | "description": "Testing a custom text drawing third-party plugin.", 11 | "help-url": "https://www.construct.net", 12 | "properties": { 13 | "font": { 14 | "name": "Font", 15 | "desc": "The font to use." 16 | }, 17 | "text": { 18 | "name": "Text", 19 | "desc": "The text to display." 20 | } 21 | }, 22 | "aceCategories": { 23 | "custom": "Custom" 24 | }, 25 | "conditions": { 26 | "is-large-number": { 27 | "list-name": "Is large number", 28 | "display-text": "[i]{0}[/i] is a large number", 29 | "description": "Test if a number is greater than 100.", 30 | "params": { 31 | "number": { 32 | "name": "Number", 33 | "desc": "Number to test if greater than 100." 34 | } 35 | } 36 | } 37 | }, 38 | "actions": { 39 | "do-alert": { 40 | "list-name": "Do alert", 41 | "display-text": "Do alert", 42 | "description": "Do a dummy alert." 43 | } 44 | }, 45 | "expressions": { 46 | "double": { 47 | "description": "Double a number.", 48 | "translated-name": "Double", 49 | "params": { 50 | "number": { 51 | "name": "Number", 52 | "desc": "The number to double." 53 | } 54 | } 55 | } 56 | } 57 | } 58 | } 59 | } 60 | } -------------------------------------------------------------------------------- /plugin-sdk/v2/editorTextPlugin/tsconfig.json: -------------------------------------------------------------------------------- 1 | 2 | { 3 | "compilerOptions": { 4 | /* Visit https://aka.ms/tsconfig to read more about this file */ 5 | 6 | /* Transpile away class fields, as Closure Compiler doesn't support them yet */ 7 | "target": "ES2021", 8 | 9 | /* Use modern standard JavaScript (ES) Modules */ 10 | "module": "ES2022", 11 | 12 | /* Disable polyfill code for CommonJS modules - Construct always uses ES Modules */ 13 | "esModuleInterop": false, 14 | 15 | /* Other standard settings specified by tsc --init */ 16 | "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */ 17 | "strict": true 18 | } 19 | } -------------------------------------------------------------------------------- /plugin-sdk/v2/editorTextPlugin/type.js: -------------------------------------------------------------------------------- 1 | 2 | const SDK = globalThis.SDK; 3 | 4 | const PLUGIN_CLASS = SDK.Plugins.MyCompany_TextPlugin; 5 | 6 | PLUGIN_CLASS.Type = class MyTextPluginType extends SDK.ITypeBase 7 | { 8 | constructor(sdkPlugin, iObjectType) 9 | { 10 | super(sdkPlugin, iObjectType); 11 | } 12 | }; 13 | -------------------------------------------------------------------------------- /plugin-sdk/v2/editorTextPlugin/type.ts: -------------------------------------------------------------------------------- 1 | 2 | const SDK = globalThis.SDK; 3 | 4 | const PLUGIN_CLASS = SDK.Plugins.MyCompany_TextPlugin; 5 | 6 | PLUGIN_CLASS.Type = class MyTextPluginType extends SDK.ITypeBase 7 | { 8 | constructor(sdkPlugin: SDK.IPluginBase, iObjectType: SDK.IObjectType) 9 | { 10 | super(sdkPlugin, iObjectType); 11 | } 12 | }; 13 | 14 | export {} -------------------------------------------------------------------------------- /plugin-sdk/v2/singleGlobalPlugin/aces.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "../aces.schema.json", 3 | 4 | "custom": { 5 | "conditions": [ 6 | { 7 | "id": "is-large-number", 8 | "scriptName": "IsLargeNumber", 9 | "highlight": true, 10 | "params": [ 11 | { 12 | "id": "number", 13 | "type": "number" 14 | } 15 | ] 16 | } 17 | ], 18 | "actions": [ 19 | { 20 | "id": "log-to-console", 21 | "scriptName": "LogToConsole", 22 | "highlight": true 23 | } 24 | ], 25 | "expressions": [ 26 | { 27 | "id": "double", 28 | "expressionName": "Double", 29 | "highlight": true, 30 | "returnType": "number", 31 | "params": [ 32 | { 33 | "id": "number", 34 | "type": "number" 35 | } 36 | ] 37 | } 38 | ] 39 | } 40 | } -------------------------------------------------------------------------------- /plugin-sdk/v2/singleGlobalPlugin/addon.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "../plugin.addon.schema.json", 3 | 4 | "is-c3-addon": true, 5 | "sdk-version": 2, 6 | "min-construct-version": "r401", 7 | "type": "plugin", 8 | "name": "My custom plugin", 9 | "id": "MyCompany_SingleGlobal", 10 | "version": "1.0.0.0", 11 | "author": "Scirra", 12 | "website": "https://www.construct.net", 13 | "documentation": "https://www.construct.net", 14 | "description": "Example custom Construct 3 plugin.", 15 | "editor-scripts": [ 16 | "plugin.js", 17 | "type.js", 18 | "instance.js" 19 | ], 20 | "file-list": [ 21 | "c3runtime/main.js", 22 | "c3runtime/plugin.js", 23 | "c3runtime/type.js", 24 | "c3runtime/instance.js", 25 | "c3runtime/conditions.js", 26 | "c3runtime/actions.js", 27 | "c3runtime/expressions.js", 28 | "lang/en-US.json", 29 | "aces.json", 30 | "addon.json", 31 | "icon.svg", 32 | "instance.js", 33 | "plugin.js", 34 | "type.js" 35 | ] 36 | } -------------------------------------------------------------------------------- /plugin-sdk/v2/singleGlobalPlugin/c3runtime/actions.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = globalThis.C3; 3 | 4 | C3.Plugins.MyCompany_SingleGlobal.Acts = 5 | { 6 | LogToConsole() 7 | { 8 | console.log("This is the 'Log to console' action. Test property = " + this._getTestProperty()); 9 | } 10 | }; 11 | -------------------------------------------------------------------------------- /plugin-sdk/v2/singleGlobalPlugin/c3runtime/actions.ts: -------------------------------------------------------------------------------- 1 | 2 | import type { SDKInstanceClass } from "./instance.ts"; 3 | 4 | const C3 = globalThis.C3; 5 | 6 | C3.Plugins.MyCompany_SingleGlobal.Acts = 7 | { 8 | LogToConsole(this: SDKInstanceClass) 9 | { 10 | console.log("This is the 'Log to console' action. Test property = " + this._getTestProperty()); 11 | } 12 | }; 13 | -------------------------------------------------------------------------------- /plugin-sdk/v2/singleGlobalPlugin/c3runtime/conditions.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = globalThis.C3; 3 | 4 | C3.Plugins.MyCompany_SingleGlobal.Cnds = 5 | { 6 | IsLargeNumber(number) 7 | { 8 | return number > 100; 9 | } 10 | }; 11 | -------------------------------------------------------------------------------- /plugin-sdk/v2/singleGlobalPlugin/c3runtime/conditions.ts: -------------------------------------------------------------------------------- 1 | 2 | import type { SDKInstanceClass } from "./instance.ts"; 3 | 4 | const C3 = globalThis.C3; 5 | 6 | C3.Plugins.MyCompany_SingleGlobal.Cnds = 7 | { 8 | IsLargeNumber(this: SDKInstanceClass, num: number) 9 | { 10 | return num > 100; 11 | } 12 | }; 13 | -------------------------------------------------------------------------------- /plugin-sdk/v2/singleGlobalPlugin/c3runtime/expressions.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = globalThis.C3; 3 | 4 | C3.Plugins.MyCompany_SingleGlobal.Exps = 5 | { 6 | Double(number) 7 | { 8 | return number * 2; 9 | } 10 | }; 11 | -------------------------------------------------------------------------------- /plugin-sdk/v2/singleGlobalPlugin/c3runtime/expressions.ts: -------------------------------------------------------------------------------- 1 | 2 | import type { SDKInstanceClass } from "./instance.ts"; 3 | 4 | const C3 = globalThis.C3; 5 | 6 | C3.Plugins.MyCompany_SingleGlobal.Exps = 7 | { 8 | Double(this: SDKInstanceClass, num: number) 9 | { 10 | return num * 2; 11 | } 12 | }; 13 | -------------------------------------------------------------------------------- /plugin-sdk/v2/singleGlobalPlugin/c3runtime/instance.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = globalThis.C3; 3 | 4 | C3.Plugins.MyCompany_SingleGlobal.Instance = class SingleGlobalInstance extends globalThis.ISDKInstanceBase 5 | { 6 | constructor() 7 | { 8 | super(); 9 | 10 | // Initialise object properties 11 | this._testProperty = 0; 12 | 13 | const properties = this._getInitProperties(); 14 | if (properties) // note properties may be null in some cases 15 | { 16 | this._testProperty = properties[0]; 17 | } 18 | } 19 | 20 | _release() 21 | { 22 | super._release(); 23 | } 24 | 25 | _setTestProperty(n) 26 | { 27 | this._testProperty = n; 28 | } 29 | 30 | _getTestProperty() 31 | { 32 | return this._testProperty; 33 | } 34 | 35 | _saveToJson() 36 | { 37 | return { 38 | // data to be saved for savegames 39 | }; 40 | } 41 | 42 | _loadFromJson(o) 43 | { 44 | // load state for savegames 45 | } 46 | }; 47 | -------------------------------------------------------------------------------- /plugin-sdk/v2/singleGlobalPlugin/c3runtime/instance.ts: -------------------------------------------------------------------------------- 1 | 2 | const C3 = globalThis.C3; 3 | 4 | class SingleGlobalInstance extends globalThis.ISDKInstanceBase 5 | { 6 | _testProperty: number; 7 | 8 | constructor() 9 | { 10 | super(); 11 | 12 | // Initialise object properties 13 | this._testProperty = 0; 14 | 15 | const properties = this._getInitProperties(); 16 | if (properties) // note properties may be null in some cases 17 | { 18 | this._testProperty = properties[0] as number; 19 | } 20 | } 21 | 22 | _release() 23 | { 24 | super._release(); 25 | } 26 | 27 | _setTestProperty(n: number) 28 | { 29 | this._testProperty = n; 30 | } 31 | 32 | _getTestProperty() 33 | { 34 | return this._testProperty; 35 | } 36 | 37 | _saveToJson() 38 | { 39 | return { 40 | // data to be saved for savegames 41 | }; 42 | } 43 | 44 | _loadFromJson(o: any) 45 | { 46 | // load state for savegames 47 | } 48 | }; 49 | 50 | C3.Plugins.MyCompany_SingleGlobal.Instance = SingleGlobalInstance; 51 | 52 | export type { SingleGlobalInstance as SDKInstanceClass }; -------------------------------------------------------------------------------- /plugin-sdk/v2/singleGlobalPlugin/c3runtime/main.js: -------------------------------------------------------------------------------- 1 | import "./plugin.js"; 2 | import "./type.js"; 3 | import "./instance.js"; 4 | import "./conditions.js"; 5 | import "./actions.js"; 6 | import "./expressions.js"; -------------------------------------------------------------------------------- /plugin-sdk/v2/singleGlobalPlugin/c3runtime/main.ts: -------------------------------------------------------------------------------- 1 | import "./plugin.js"; 2 | import "./type.js"; 3 | import "./instance.js"; 4 | import "./conditions.js"; 5 | import "./actions.js"; 6 | import "./expressions.js"; -------------------------------------------------------------------------------- /plugin-sdk/v2/singleGlobalPlugin/c3runtime/plugin.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = globalThis.C3; 3 | 4 | C3.Plugins.MyCompany_SingleGlobal = class SingleGlobalPlugin extends globalThis.ISDKPluginBase 5 | { 6 | constructor() 7 | { 8 | super(); 9 | } 10 | }; 11 | -------------------------------------------------------------------------------- /plugin-sdk/v2/singleGlobalPlugin/c3runtime/plugin.ts: -------------------------------------------------------------------------------- 1 | 2 | const C3 = globalThis.C3; 3 | 4 | C3.Plugins.MyCompany_SingleGlobal = class SingleGlobalPlugin extends globalThis.ISDKPluginBase 5 | { 6 | constructor() 7 | { 8 | super(); 9 | } 10 | }; 11 | 12 | // Necessary for TypeScript to treat this file as a module 13 | export {} -------------------------------------------------------------------------------- /plugin-sdk/v2/singleGlobalPlugin/c3runtime/type.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = globalThis.C3; 3 | 4 | C3.Plugins.MyCompany_SingleGlobal.Type = class SingleGlobalType extends globalThis.ISDKObjectTypeBase 5 | { 6 | constructor() 7 | { 8 | super(); 9 | } 10 | 11 | _onCreate() 12 | { 13 | } 14 | }; 15 | -------------------------------------------------------------------------------- /plugin-sdk/v2/singleGlobalPlugin/c3runtime/type.ts: -------------------------------------------------------------------------------- 1 | 2 | import type { SDKInstanceClass } from "./instance.ts"; 3 | 4 | const C3 = globalThis.C3; 5 | 6 | C3.Plugins.MyCompany_SingleGlobal.Type = class SingleGlobalType extends globalThis.ISDKObjectTypeBase 7 | { 8 | constructor() 9 | { 10 | super(); 11 | } 12 | 13 | _onCreate() 14 | { 15 | } 16 | }; 17 | -------------------------------------------------------------------------------- /plugin-sdk/v2/singleGlobalPlugin/instance.js: -------------------------------------------------------------------------------- 1 | 2 | const SDK = globalThis.SDK; 3 | 4 | const PLUGIN_CLASS = SDK.Plugins.MyCompany_SingleGlobal; 5 | 6 | PLUGIN_CLASS.Instance = class MyCustomInstance extends SDK.IInstanceBase 7 | { 8 | constructor(sdkType, inst) 9 | { 10 | super(sdkType, inst); 11 | } 12 | 13 | Release() 14 | { 15 | } 16 | 17 | OnCreate() 18 | { 19 | } 20 | 21 | OnPropertyChanged(id, value) 22 | { 23 | } 24 | 25 | LoadC2Property(name, valueString) 26 | { 27 | return false; // not handled 28 | } 29 | }; 30 | -------------------------------------------------------------------------------- /plugin-sdk/v2/singleGlobalPlugin/instance.ts: -------------------------------------------------------------------------------- 1 | 2 | const SDK = globalThis.SDK; 3 | 4 | const PLUGIN_CLASS = SDK.Plugins.MyCompany_SingleGlobal; 5 | 6 | PLUGIN_CLASS.Instance = class MyCustomInstance extends SDK.IInstanceBase 7 | { 8 | constructor(sdkType: SDK.ITypeBase, inst: SDK.IObjectInstance) 9 | { 10 | super(sdkType, inst); 11 | } 12 | 13 | Release() 14 | { 15 | } 16 | 17 | OnCreate() 18 | { 19 | } 20 | 21 | OnPropertyChanged(id: string, value: EditorPropertyValueType) 22 | { 23 | } 24 | 25 | LoadC2Property(name: string, valueString: string) 26 | { 27 | return false; // not handled 28 | } 29 | }; 30 | 31 | export {} -------------------------------------------------------------------------------- /plugin-sdk/v2/singleGlobalPlugin/lang/en-US.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "../../plugin.lang.schema.json", 3 | 4 | "languageTag": "en-US", 5 | "fileDescription": "Strings for MyCustomPlugin.", 6 | "text": { 7 | "plugins": { 8 | "mycompany_singleglobal": { 9 | "name": "MyCustomPlugin", 10 | "description": "An example third-party plugin.", 11 | "help-url": "https://www.construct.net", 12 | "properties": { 13 | "test-property": { 14 | "name": "Test property", 15 | "desc": "A test number property. Displayed by 'Alert' action." 16 | } 17 | }, 18 | "aceCategories": { 19 | "custom": "Custom" 20 | }, 21 | "conditions": { 22 | "is-large-number": { 23 | "list-name": "Is large number", 24 | "display-text": "[i]{0}[/i] is a large number", 25 | "description": "Test if a number is greater than 100.", 26 | "params": { 27 | "number": { 28 | "name": "Number", 29 | "desc": "Number to test if greater than 100." 30 | } 31 | } 32 | } 33 | }, 34 | "actions": { 35 | "log-to-console": { 36 | "list-name": "Log to console", 37 | "display-text": "Log to console", 38 | "description": "Log a test message to the console." 39 | } 40 | }, 41 | "expressions": { 42 | "double": { 43 | "description": "Double a number.", 44 | "translated-name": "Double", 45 | "params": { 46 | "number": { 47 | "name": "Number", 48 | "desc": "The number to double." 49 | } 50 | } 51 | } 52 | } 53 | } 54 | } 55 | } 56 | } -------------------------------------------------------------------------------- /plugin-sdk/v2/singleGlobalPlugin/plugin.js: -------------------------------------------------------------------------------- 1 | 2 | const SDK = globalThis.SDK; 3 | 4 | //////////////////////////////////////////// 5 | // The plugin ID is how Construct identifies different kinds of plugins. 6 | // *** NEVER CHANGE THE PLUGIN ID! *** 7 | // If you change the plugin ID after releasing the plugin, Construct will think it is an entirely different 8 | // plugin and assume it is incompatible with the old one, and YOU WILL BREAK ALL EXISTING PROJECTS USING THE PLUGIN. 9 | // Only the plugin name is displayed in the editor, so to rename your plugin change the name but NOT the ID. 10 | // If you want to completely replace a plugin, make it deprecated (it will be hidden but old projects keep working), 11 | // and create an entirely new plugin with a different plugin ID. 12 | const PLUGIN_ID = "MyCompany_SingleGlobal"; 13 | //////////////////////////////////////////// 14 | 15 | const PLUGIN_CATEGORY = "general"; 16 | 17 | const PLUGIN_CLASS = SDK.Plugins.MyCompany_SingleGlobal = class MyCustomPlugin extends SDK.IPluginBase 18 | { 19 | constructor() 20 | { 21 | super(PLUGIN_ID); 22 | 23 | SDK.Lang.PushContext("plugins." + PLUGIN_ID.toLowerCase()); 24 | 25 | this._info.SetName(globalThis.lang(".name")); 26 | this._info.SetDescription(globalThis.lang(".description")); 27 | this._info.SetCategory(PLUGIN_CATEGORY); 28 | this._info.SetAuthor("Scirra"); 29 | this._info.SetHelpUrl(globalThis.lang(".help-url")); 30 | this._info.SetIsSingleGlobal(true); 31 | this._info.SetRuntimeModuleMainScript("c3runtime/main.js"); 32 | 33 | SDK.Lang.PushContext(".properties"); 34 | 35 | this._info.SetProperties([ 36 | new SDK.PluginProperty("integer", "test-property", 0) 37 | ]); 38 | 39 | SDK.Lang.PopContext(); // .properties 40 | 41 | SDK.Lang.PopContext(); 42 | } 43 | }; 44 | 45 | PLUGIN_CLASS.Register(PLUGIN_ID, PLUGIN_CLASS); 46 | -------------------------------------------------------------------------------- /plugin-sdk/v2/singleGlobalPlugin/plugin.ts: -------------------------------------------------------------------------------- 1 | 2 | const SDK = globalThis.SDK; 3 | 4 | //////////////////////////////////////////// 5 | // The plugin ID is how Construct identifies different kinds of plugins. 6 | // *** NEVER CHANGE THE PLUGIN ID! *** 7 | // If you change the plugin ID after releasing the plugin, Construct will think it is an entirely different 8 | // plugin and assume it is incompatible with the old one, and YOU WILL BREAK ALL EXISTING PROJECTS USING THE PLUGIN. 9 | // Only the plugin name is displayed in the editor, so to rename your plugin change the name but NOT the ID. 10 | // If you want to completely replace a plugin, make it deprecated (it will be hidden but old projects keep working), 11 | // and create an entirely new plugin with a different plugin ID. 12 | const PLUGIN_ID = "MyCompany_SingleGlobal"; 13 | //////////////////////////////////////////// 14 | 15 | const PLUGIN_CATEGORY = "general"; 16 | 17 | const PLUGIN_CLASS = SDK.Plugins.MyCompany_SingleGlobal = class MyCustomPlugin extends SDK.IPluginBase 18 | { 19 | constructor() 20 | { 21 | super(PLUGIN_ID); 22 | 23 | SDK.Lang.PushContext("plugins." + PLUGIN_ID.toLowerCase()); 24 | 25 | this._info.SetName(globalThis.lang(".name")); 26 | this._info.SetDescription(globalThis.lang(".description")); 27 | this._info.SetCategory(PLUGIN_CATEGORY); 28 | this._info.SetAuthor("Scirra"); 29 | this._info.SetHelpUrl(globalThis.lang(".help-url")); 30 | this._info.SetIsSingleGlobal(true); 31 | this._info.SetRuntimeModuleMainScript("c3runtime/main.js"); 32 | 33 | SDK.Lang.PushContext(".properties"); 34 | 35 | this._info.SetProperties([ 36 | new SDK.PluginProperty("integer", "test-property", 0) 37 | ]); 38 | 39 | SDK.Lang.PopContext(); // .properties 40 | 41 | SDK.Lang.PopContext(); 42 | } 43 | }; 44 | 45 | PLUGIN_CLASS.Register(PLUGIN_ID, PLUGIN_CLASS); 46 | 47 | export type { PLUGIN_CLASS as SDKPluginClass }; 48 | -------------------------------------------------------------------------------- /plugin-sdk/v2/singleGlobalPlugin/tsconfig.json: -------------------------------------------------------------------------------- 1 | 2 | { 3 | "compilerOptions": { 4 | /* Visit https://aka.ms/tsconfig to read more about this file */ 5 | 6 | /* Transpile away class fields, as Closure Compiler doesn't support them yet */ 7 | "target": "ES2021", 8 | 9 | /* Use modern standard JavaScript (ES) Modules */ 10 | "module": "ES2022", 11 | 12 | /* Disable polyfill code for CommonJS modules - Construct always uses ES Modules */ 13 | "esModuleInterop": false, 14 | 15 | /* Other standard settings specified by tsc --init */ 16 | "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */ 17 | "strict": true 18 | } 19 | } -------------------------------------------------------------------------------- /plugin-sdk/v2/singleGlobalPlugin/type.js: -------------------------------------------------------------------------------- 1 | 2 | const SDK = globalThis.SDK; 3 | 4 | const PLUGIN_CLASS = SDK.Plugins.MyCompany_SingleGlobal; 5 | 6 | PLUGIN_CLASS.Type = class MyCustomPluginType extends SDK.ITypeBase 7 | { 8 | constructor(sdkPlugin, iObjectType) 9 | { 10 | super(sdkPlugin, iObjectType); 11 | } 12 | }; 13 | -------------------------------------------------------------------------------- /plugin-sdk/v2/singleGlobalPlugin/type.ts: -------------------------------------------------------------------------------- 1 | 2 | const SDK = globalThis.SDK; 3 | 4 | const PLUGIN_CLASS = SDK.Plugins.MyCompany_SingleGlobal; 5 | 6 | PLUGIN_CLASS.Type = class MyCustomPluginType extends SDK.ITypeBase 7 | { 8 | constructor(sdkPlugin: SDK.IPluginBase, iObjectType: SDK.IObjectType) 9 | { 10 | super(sdkPlugin, iObjectType); 11 | } 12 | }; 13 | 14 | export {} -------------------------------------------------------------------------------- /plugin-sdk/v2/wrapperExtensionPlugin/Wrapper extension sample project.c3p: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Scirra/Construct-Addon-SDK/2fc509b759992d815d980a160db9f810abf9ca58/plugin-sdk/v2/wrapperExtensionPlugin/Wrapper extension sample project.c3p -------------------------------------------------------------------------------- /plugin-sdk/v2/wrapperExtensionPlugin/construct-plugin/MyExtension_arm64.ext.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Scirra/Construct-Addon-SDK/2fc509b759992d815d980a160db9f810abf9ca58/plugin-sdk/v2/wrapperExtensionPlugin/construct-plugin/MyExtension_arm64.ext.dll -------------------------------------------------------------------------------- /plugin-sdk/v2/wrapperExtensionPlugin/construct-plugin/MyExtension_x64.ext.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Scirra/Construct-Addon-SDK/2fc509b759992d815d980a160db9f810abf9ca58/plugin-sdk/v2/wrapperExtensionPlugin/construct-plugin/MyExtension_x64.ext.dll -------------------------------------------------------------------------------- /plugin-sdk/v2/wrapperExtensionPlugin/construct-plugin/MyExtension_x86.ext.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Scirra/Construct-Addon-SDK/2fc509b759992d815d980a160db9f810abf9ca58/plugin-sdk/v2/wrapperExtensionPlugin/construct-plugin/MyExtension_x86.ext.dll -------------------------------------------------------------------------------- /plugin-sdk/v2/wrapperExtensionPlugin/construct-plugin/aces.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "../../aces.schema.json", 3 | 4 | "wrapper-extension": { 5 | "conditions": [ 6 | { 7 | "id": "is-available", 8 | "scriptName": "IsAvailable" 9 | } 10 | ], 11 | "actions": [ 12 | { 13 | "id": "show-messagebox", 14 | "scriptName": "ShowMessageBox", 15 | "params": [{ "id": "message", "type": "string" }, 16 | { "id": "title", "type": "string" }] 17 | } 18 | ], 19 | "expressions": [ 20 | { 21 | "id": "sample-string-1", 22 | "expressionName": "SampleString1", 23 | "returnType": "string" 24 | }, { 25 | "id": "sample-string-2", 26 | "expressionName": "SampleString2", 27 | "returnType": "string" 28 | } 29 | ] 30 | } 31 | } -------------------------------------------------------------------------------- /plugin-sdk/v2/wrapperExtensionPlugin/construct-plugin/addon.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "../../plugin.addon.schema.json", 3 | 4 | "is-c3-addon": true, 5 | "sdk-version": 2, 6 | "min-construct-version": "r401", 7 | "type": "plugin", 8 | "name": "Wrapper extension", 9 | "id": "MyCompany_WrapperExt", 10 | "version": "1.0.0.0", 11 | "author": "Scirra", 12 | "website": "https://www.construct.net", 13 | "documentation": "https://www.construct.net", 14 | "description": "A sample wrapper extension plugin.", 15 | "editor-scripts": [ 16 | "plugin.js", 17 | "type.js", 18 | "instance.js" 19 | ], 20 | "file-list": [ 21 | "c3runtime/main.js", 22 | "c3runtime/plugin.js", 23 | "c3runtime/type.js", 24 | "c3runtime/instance.js", 25 | "c3runtime/conditions.js", 26 | "c3runtime/actions.js", 27 | "c3runtime/expressions.js", 28 | "lang/en-US.json", 29 | "aces.json", 30 | "addon.json", 31 | "icon.svg", 32 | "instance.js", 33 | "plugin.js", 34 | "type.js", 35 | "MyExtension_x86.ext.dll", 36 | "MyExtension_x64.ext.dll", 37 | "my_extension_x64.ext.so" 38 | ] 39 | } -------------------------------------------------------------------------------- /plugin-sdk/v2/wrapperExtensionPlugin/construct-plugin/c3runtime/actions.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = globalThis.C3; 3 | 4 | C3.Plugins.MyCompany_WrapperExt.Acts = 5 | { 6 | ShowMessageBox(message, title) 7 | { 8 | // Ignore action if extension unavailable 9 | if (!this._isAvailable()) 10 | return; 11 | 12 | // Send a "show-messagebox" message to the extension, with the message and 13 | // title as two parameters. 14 | this._sendWrapperExtensionMessage("show-messagebox", [ 15 | message, 16 | title 17 | ]); 18 | } 19 | }; 20 | -------------------------------------------------------------------------------- /plugin-sdk/v2/wrapperExtensionPlugin/construct-plugin/c3runtime/actions.ts: -------------------------------------------------------------------------------- 1 | 2 | import type { SDKInstanceClass } from "./instance.ts"; 3 | 4 | const C3 = globalThis.C3; 5 | 6 | C3.Plugins.MyCompany_WrapperExt.Acts = 7 | { 8 | ShowMessageBox(this: SDKInstanceClass, message: string, title: string) 9 | { 10 | // Ignore action if extension unavailable 11 | if (!this._isAvailable()) 12 | return; 13 | 14 | // Send a "show-messagebox" message to the extension, with the message and 15 | // title as two parameters. 16 | this._sendWrapperExtensionMessage("show-messagebox", [ 17 | message, 18 | title 19 | ]); 20 | } 21 | }; 22 | -------------------------------------------------------------------------------- /plugin-sdk/v2/wrapperExtensionPlugin/construct-plugin/c3runtime/conditions.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = globalThis.C3; 3 | 4 | C3.Plugins.MyCompany_WrapperExt.Cnds = 5 | { 6 | IsAvailable() 7 | { 8 | return this._isAvailable(); 9 | } 10 | }; 11 | -------------------------------------------------------------------------------- /plugin-sdk/v2/wrapperExtensionPlugin/construct-plugin/c3runtime/conditions.ts: -------------------------------------------------------------------------------- 1 | 2 | import type { SDKInstanceClass } from "./instance.ts"; 3 | 4 | const C3 = globalThis.C3; 5 | 6 | C3.Plugins.MyCompany_WrapperExt.Cnds = 7 | { 8 | IsAvailable(this: SDKInstanceClass) 9 | { 10 | return this._isAvailable(); 11 | } 12 | }; 13 | -------------------------------------------------------------------------------- /plugin-sdk/v2/wrapperExtensionPlugin/construct-plugin/c3runtime/expressions.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = globalThis.C3; 3 | 4 | C3.Plugins.MyCompany_WrapperExt.Exps = 5 | { 6 | SampleString1() 7 | { 8 | return this._sampleString1; 9 | }, 10 | 11 | SampleString2() 12 | { 13 | return this._sampleString2; 14 | } 15 | }; 16 | -------------------------------------------------------------------------------- /plugin-sdk/v2/wrapperExtensionPlugin/construct-plugin/c3runtime/expressions.ts: -------------------------------------------------------------------------------- 1 | 2 | import type { SDKInstanceClass } from "./instance.ts"; 3 | 4 | const C3 = globalThis.C3; 5 | 6 | C3.Plugins.MyCompany_WrapperExt.Exps = 7 | { 8 | SampleString1(this: SDKInstanceClass) 9 | { 10 | return this._sampleString1; 11 | }, 12 | 13 | SampleString2(this: SDKInstanceClass) 14 | { 15 | return this._sampleString2; 16 | } 17 | }; 18 | -------------------------------------------------------------------------------- /plugin-sdk/v2/wrapperExtensionPlugin/construct-plugin/c3runtime/main.js: -------------------------------------------------------------------------------- 1 | import "./plugin.js"; 2 | import "./type.js"; 3 | import "./instance.js"; 4 | import "./conditions.js"; 5 | import "./actions.js"; 6 | import "./expressions.js"; -------------------------------------------------------------------------------- /plugin-sdk/v2/wrapperExtensionPlugin/construct-plugin/c3runtime/main.ts: -------------------------------------------------------------------------------- 1 | import "./plugin.js"; 2 | import "./type.js"; 3 | import "./instance.js"; 4 | import "./conditions.js"; 5 | import "./actions.js"; 6 | import "./expressions.js"; -------------------------------------------------------------------------------- /plugin-sdk/v2/wrapperExtensionPlugin/construct-plugin/c3runtime/plugin.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = globalThis.C3; 3 | 4 | C3.Plugins.MyCompany_WrapperExt = class MyCompany_WrapperExtPlugin extends globalThis.ISDKPluginBase 5 | { 6 | constructor() 7 | { 8 | super(); 9 | } 10 | }; 11 | -------------------------------------------------------------------------------- /plugin-sdk/v2/wrapperExtensionPlugin/construct-plugin/c3runtime/plugin.ts: -------------------------------------------------------------------------------- 1 | 2 | const C3 = globalThis.C3; 3 | 4 | C3.Plugins.MyCompany_WrapperExt = class MyCompany_WrapperExtPlugin extends globalThis.ISDKPluginBase 5 | { 6 | constructor() 7 | { 8 | super(); 9 | } 10 | }; 11 | 12 | // Necessary for TypeScript to treat this file as a module 13 | export {} -------------------------------------------------------------------------------- /plugin-sdk/v2/wrapperExtensionPlugin/construct-plugin/c3runtime/type.js: -------------------------------------------------------------------------------- 1 | 2 | const C3 = globalThis.C3; 3 | 4 | C3.Plugins.MyCompany_WrapperExt.Type = class MyCompany_WrapperExtType extends globalThis.ISDKObjectTypeBase 5 | { 6 | constructor() 7 | { 8 | super(); 9 | } 10 | 11 | _onCreate() 12 | { 13 | } 14 | }; 15 | -------------------------------------------------------------------------------- /plugin-sdk/v2/wrapperExtensionPlugin/construct-plugin/c3runtime/type.ts: -------------------------------------------------------------------------------- 1 | 2 | import type { SDKInstanceClass } from "./instance.ts"; 3 | 4 | const C3 = globalThis.C3; 5 | 6 | C3.Plugins.MyCompany_WrapperExt.Type = class MyCompany_WrapperExtType extends globalThis.ISDKObjectTypeBase 7 | { 8 | constructor() 9 | { 10 | super(); 11 | } 12 | 13 | _onCreate() 14 | { 15 | } 16 | }; 17 | -------------------------------------------------------------------------------- /plugin-sdk/v2/wrapperExtensionPlugin/construct-plugin/instance.js: -------------------------------------------------------------------------------- 1 | 2 | const SDK = globalThis.SDK; 3 | 4 | const PLUGIN_CLASS = SDK.Plugins.MyCompany_WrapperExt; 5 | 6 | PLUGIN_CLASS.Instance = class MyCompany_WrapperExtInstance extends SDK.IInstanceBase 7 | { 8 | constructor(sdkType, inst) 9 | { 10 | super(sdkType, inst); 11 | } 12 | 13 | Release() 14 | { 15 | } 16 | 17 | OnCreate() 18 | { 19 | } 20 | 21 | OnPropertyChanged(id, value) 22 | { 23 | } 24 | 25 | LoadC2Property(name, valueString) 26 | { 27 | return false; // not handled 28 | } 29 | }; 30 | -------------------------------------------------------------------------------- /plugin-sdk/v2/wrapperExtensionPlugin/construct-plugin/instance.ts: -------------------------------------------------------------------------------- 1 | 2 | const SDK = globalThis.SDK; 3 | 4 | const PLUGIN_CLASS = SDK.Plugins.MyCompany_WrapperExt; 5 | 6 | PLUGIN_CLASS.Instance = class MyCompany_WrapperExtInstance extends SDK.IInstanceBase 7 | { 8 | constructor(sdkType: SDK.ITypeBase, inst: SDK.IObjectInstance) 9 | { 10 | super(sdkType, inst); 11 | } 12 | 13 | Release() 14 | { 15 | } 16 | 17 | OnCreate() 18 | { 19 | } 20 | 21 | OnPropertyChanged(id: string, value: EditorPropertyValueType) 22 | { 23 | } 24 | 25 | LoadC2Property(name: string, valueString: string) 26 | { 27 | return false; // not handled 28 | } 29 | }; 30 | 31 | export {} -------------------------------------------------------------------------------- /plugin-sdk/v2/wrapperExtensionPlugin/construct-plugin/lang/en-US.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "../../../plugin.lang.schema.json", 3 | 4 | "languageTag": "en-US", 5 | "fileDescription": "Strings for the sample wrapper extension.", 6 | "text": { 7 | "plugins": { 8 | "mycompany_wrapperext": { 9 | "name": "Wrapper extension", 10 | "description": "A sample wrapper extension plugin.", 11 | "help-url": "https://www.construct.net", 12 | "properties": { 13 | }, 14 | "aceCategories": { 15 | "wrapper-extension": "Wrapper extension" 16 | }, 17 | "conditions": { 18 | "is-available": { 19 | "list-name": "Is available", 20 | "display-text": "Is available", 21 | "description": "True if running in a supported exporter and the extension initialized OK." 22 | } 23 | }, 24 | "actions": { 25 | "show-messagebox": { 26 | "list-name": "Show messagebox", 27 | "display-text": "Show messagebox with message [i]{0}[/i], title [i]{1}[/i]", 28 | "description": "Sample action to show a messagebox via a Windows API call in the extension.", 29 | "params": { 30 | "message": { 31 | "name": "Message", 32 | "desc": "The message to show in the messagebox." 33 | }, 34 | "title": { 35 | "name": "Title", 36 | "desc": "The title of the messagebox." 37 | } 38 | } 39 | } 40 | }, 41 | "expressions": { 42 | "sample-string-1": { 43 | "description": "Sample string 1 returned from extension.", 44 | "translated-name": "SampleString1" 45 | }, 46 | "sample-string-2": { 47 | "description": "Sample string 2 returned from extension.", 48 | "translated-name": "SampleString2" 49 | } 50 | } 51 | } 52 | } 53 | } 54 | } -------------------------------------------------------------------------------- /plugin-sdk/v2/wrapperExtensionPlugin/construct-plugin/my_extension_x64.ext.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Scirra/Construct-Addon-SDK/2fc509b759992d815d980a160db9f810abf9ca58/plugin-sdk/v2/wrapperExtensionPlugin/construct-plugin/my_extension_x64.ext.so -------------------------------------------------------------------------------- /plugin-sdk/v2/wrapperExtensionPlugin/construct-plugin/myextension.ext.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Scirra/Construct-Addon-SDK/2fc509b759992d815d980a160db9f810abf9ca58/plugin-sdk/v2/wrapperExtensionPlugin/construct-plugin/myextension.ext.dylib -------------------------------------------------------------------------------- /plugin-sdk/v2/wrapperExtensionPlugin/construct-plugin/tsconfig.json: -------------------------------------------------------------------------------- 1 | 2 | { 3 | "compilerOptions": { 4 | /* Visit https://aka.ms/tsconfig to read more about this file */ 5 | 6 | /* Transpile away class fields, as Closure Compiler doesn't support them yet */ 7 | "target": "ES2021", 8 | 9 | /* Use modern standard JavaScript (ES) Modules */ 10 | "module": "ES2022", 11 | 12 | /* Disable polyfill code for CommonJS modules - Construct always uses ES Modules */ 13 | "esModuleInterop": false, 14 | 15 | /* Other standard settings specified by tsc --init */ 16 | "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */ 17 | "strict": true 18 | } 19 | } -------------------------------------------------------------------------------- /plugin-sdk/v2/wrapperExtensionPlugin/construct-plugin/type.js: -------------------------------------------------------------------------------- 1 | 2 | const SDK = globalThis.SDK; 3 | 4 | const PLUGIN_CLASS = SDK.Plugins.MyCompany_WrapperExt; 5 | 6 | PLUGIN_CLASS.Type = class MyCompany_WrapperExtType extends SDK.ITypeBase 7 | { 8 | constructor(sdkPlugin, iObjectType) 9 | { 10 | super(sdkPlugin, iObjectType); 11 | } 12 | }; 13 | -------------------------------------------------------------------------------- /plugin-sdk/v2/wrapperExtensionPlugin/construct-plugin/type.ts: -------------------------------------------------------------------------------- 1 | 2 | const SDK = globalThis.SDK; 3 | 4 | const PLUGIN_CLASS = SDK.Plugins.MyCompany_WrapperExt; 5 | 6 | PLUGIN_CLASS.Type = class MyCompany_WrapperExtType extends SDK.ITypeBase 7 | { 8 | constructor(sdkPlugin: SDK.IPluginBase, iObjectType: SDK.IObjectType) 9 | { 10 | super(sdkPlugin, iObjectType); 11 | } 12 | }; 13 | 14 | export {} -------------------------------------------------------------------------------- /plugin-sdk/v2/wrapperExtensionPlugin/extension/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.10) 2 | project(WrapperExtension) 3 | 4 | # Find pkg-config 5 | find_package(PkgConfig REQUIRED) 6 | 7 | # Find GTK 3.0 8 | pkg_check_modules(GTK3 REQUIRED gtk+-3.0) 9 | 10 | # Add include directories for GTK 11 | include_directories(${GTK3_INCLUDE_DIRS}) 12 | 13 | # Add the compiler flags for GTK 14 | link_directories(${GTK3_LIBRARY_DIRS}) 15 | add_definitions(${GTK3_CFLAGS_OTHER}) 16 | 17 | add_library(wrapper_extension SHARED WrapperExtension.cpp Utils.cpp) 18 | 19 | # Link the GTK libraries to your project 20 | target_link_libraries(wrapper_extension ${GTK3_LIBRARIES}) 21 | 22 | set_target_properties(wrapper_extension PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 23 | -------------------------------------------------------------------------------- /plugin-sdk/v2/wrapperExtensionPlugin/extension/Utils.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "IExtension.h" 4 | 5 | #ifdef _WIN32 6 | 7 | // Convert std::string with UTF-8 encoding to std::wstring. 8 | // Use this to convert UTF-8 strings to a format that can be passed to Windows APIs. 9 | std::wstring Utf8ToWide(const std::string& utf8string); 10 | 11 | // Convert std::wstring to std::string with UTF-8 encoding. 12 | // Use this to convert strings returned by Windows APIs back to UTF-8. 13 | std::string WideToUtf8(const std::wstring& widestring); 14 | 15 | #endif 16 | 17 | // Helper methods for sending data over DLL boundary 18 | std::vector UnpackExtensionParameterArray(size_t paramCount, const ExtensionParameterPOD* paramArr); 19 | std::vector PackNamedExtensionParameters(const std::map& params); 20 | -------------------------------------------------------------------------------- /plugin-sdk/v2/wrapperExtensionPlugin/extension/WrapperExtension.h: -------------------------------------------------------------------------------- 1 | 2 | #include "IApplication.h" 3 | #include "IExtension.h" 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | // Main class for your wrapper extension DLL. 10 | class WrapperExtension : public IExtension { 11 | public: 12 | WrapperExtension(IApplication* iApplication_); 13 | 14 | // IExtension overrides 15 | void Init(); 16 | void Release(); 17 | void OnWebMessage(const char* messageId, size_t paramCount, const ExtensionParameterPOD* paramArr, double asyncId); 18 | #ifdef _WIN32 19 | void OnMainWindowCreated(HWND hWnd_); 20 | #else 21 | void OnMainWindowCreated(); 22 | #endif 23 | 24 | // Web messaging methods 25 | void HandleWebMessage(const std::string& messageId, const std::vector& params, double asyncId); 26 | void SendWebMessage(const std::string& messageId, const std::map& params, double asyncId = -1.0); 27 | void SendAsyncResponse(const std::map& params, double asyncId); 28 | 29 | // Handler methods for specific kinds of message 30 | void OnInitMessage(double asyncId); 31 | void OnShowMessageBox(const std::string& message, const std::string& title); 32 | 33 | protected: 34 | IApplication* iApplication; 35 | 36 | #ifdef _WIN32 37 | HWND hWndMain; 38 | #endif 39 | }; 40 | -------------------------------------------------------------------------------- /plugin-sdk/v2/wrapperExtensionPlugin/extension/WrapperExtension.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.7.34003.232 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WrapperExtension", "WrapperExtension.vcxproj", "{4A1E51B7-1E34-4E93-ACAD-547C50E53040}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|ARM64 = Debug|ARM64 11 | Debug|x64 = Debug|x64 12 | Debug|x86 = Debug|x86 13 | Release|ARM64 = Release|ARM64 14 | Release|x64 = Release|x64 15 | Release|x86 = Release|x86 16 | EndGlobalSection 17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 18 | {4A1E51B7-1E34-4E93-ACAD-547C50E53040}.Debug|ARM64.ActiveCfg = Debug|ARM64 19 | {4A1E51B7-1E34-4E93-ACAD-547C50E53040}.Debug|ARM64.Build.0 = Debug|ARM64 20 | {4A1E51B7-1E34-4E93-ACAD-547C50E53040}.Debug|x64.ActiveCfg = Debug|x64 21 | {4A1E51B7-1E34-4E93-ACAD-547C50E53040}.Debug|x64.Build.0 = Debug|x64 22 | {4A1E51B7-1E34-4E93-ACAD-547C50E53040}.Debug|x86.ActiveCfg = Debug|Win32 23 | {4A1E51B7-1E34-4E93-ACAD-547C50E53040}.Debug|x86.Build.0 = Debug|Win32 24 | {4A1E51B7-1E34-4E93-ACAD-547C50E53040}.Release|ARM64.ActiveCfg = Release|ARM64 25 | {4A1E51B7-1E34-4E93-ACAD-547C50E53040}.Release|ARM64.Build.0 = Release|ARM64 26 | {4A1E51B7-1E34-4E93-ACAD-547C50E53040}.Release|x64.ActiveCfg = Release|x64 27 | {4A1E51B7-1E34-4E93-ACAD-547C50E53040}.Release|x64.Build.0 = Release|x64 28 | {4A1E51B7-1E34-4E93-ACAD-547C50E53040}.Release|x86.ActiveCfg = Release|Win32 29 | {4A1E51B7-1E34-4E93-ACAD-547C50E53040}.Release|x86.Build.0 = Release|Win32 30 | EndGlobalSection 31 | GlobalSection(SolutionProperties) = preSolution 32 | HideSolutionNode = FALSE 33 | EndGlobalSection 34 | GlobalSection(ExtensibilityGlobals) = postSolution 35 | SolutionGuid = {9C29B02E-C919-4999-B543-D8348B274A30} 36 | EndGlobalSection 37 | EndGlobal 38 | -------------------------------------------------------------------------------- /plugin-sdk/v2/wrapperExtensionPlugin/extension/WrapperExtension.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /plugin-sdk/v2/wrapperExtensionPlugin/extension/cpp.hint: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Scirra/Construct-Addon-SDK/2fc509b759992d815d980a160db9f810abf9ca58/plugin-sdk/v2/wrapperExtensionPlugin/extension/cpp.hint -------------------------------------------------------------------------------- /plugin-sdk/v2/wrapperExtensionPlugin/extension/dllmain.cpp: -------------------------------------------------------------------------------- 1 | // dllmain.cpp : Defines the entry point for the DLL application. 2 | #include "pch.h" 3 | 4 | BOOL APIENTRY DllMain( HMODULE hModule, 5 | DWORD ul_reason_for_call, 6 | LPVOID lpReserved 7 | ) 8 | { 9 | switch (ul_reason_for_call) 10 | { 11 | case DLL_PROCESS_ATTACH: 12 | case DLL_THREAD_ATTACH: 13 | case DLL_THREAD_DETACH: 14 | case DLL_PROCESS_DETACH: 15 | break; 16 | } 17 | return TRUE; 18 | } 19 | 20 | -------------------------------------------------------------------------------- /plugin-sdk/v2/wrapperExtensionPlugin/extension/pch.cpp: -------------------------------------------------------------------------------- 1 | // pch.cpp: source file corresponding to the pre-compiled header 2 | 3 | #include "pch.h" 4 | 5 | // When you are using pre-compiled headers, this source file is necessary for compilation to succeed. 6 | -------------------------------------------------------------------------------- /plugin-sdk/v2/wrapperExtensionPlugin/extension/pch.h: -------------------------------------------------------------------------------- 1 | // pch.h: This is a precompiled header file. 2 | // Files listed below are compiled only once, improving build performance for future builds. 3 | // This also affects IntelliSense performance, including code completion and many code browsing features. 4 | // However, files listed here are ALL re-compiled if any one of them is updated between builds. 5 | // Do not add files here that you will be updating frequently as this negates the performance advantage. 6 | 7 | #ifndef PCH_H 8 | #define PCH_H 9 | 10 | // add headers that you want to pre-compile here 11 | 12 | #ifdef _WIN32 13 | 14 | // Windows Header Files 15 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers 16 | #include 17 | 18 | #define DLLEXPORT __declspec(dllexport) 19 | 20 | #else 21 | 22 | // Empty defines for non-Microsoft platforms 23 | #define DECLSPEC_NOVTABLE 24 | #define DLLEXPORT 25 | 26 | #endif 27 | 28 | // STL includes 29 | #include // std::vector 30 | #include // std::map 31 | #include // std::string, std::wstring 32 | 33 | // SDK utilities 34 | #include "Utils.h" 35 | 36 | #endif //PCH_H 37 | -------------------------------------------------------------------------------- /theme-sdk/sample-theme/addon.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "../theme.addon.schema.json", 3 | 4 | "is-c3-addon": true, 5 | "type": "theme", 6 | "name": "Green bars theme", 7 | "id": "GreenBars", 8 | "version": "1.0.0.0", 9 | "author": "Scirra", 10 | "icon-type": "image/svg+xml", 11 | "website": "https://www.construct.net", 12 | "documentation": "https://www.construct.net", 13 | "description": "Makes the captions green.", 14 | "stylesheets": [ 15 | "theme.css" 16 | ], 17 | "file-list": [ 18 | "lang/en-US.json", 19 | "addon.json", 20 | "icon.svg", 21 | "theme.css" 22 | ] 23 | } -------------------------------------------------------------------------------- /theme-sdk/sample-theme/lang/en-US.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "../../theme.lang.schema.json", 3 | 4 | "languageTag": "en-US", 5 | "fileDescription": "Strings for GreenBars theme.", 6 | "text": { 7 | "themes": { 8 | "greenbars": { 9 | "name": "Green bars theme", 10 | "description": "Makes the bars go green.", 11 | "help-url": "https://www.scirra.com" 12 | } 13 | } 14 | } 15 | } --------------------------------------------------------------------------------