From 0335086df8b1a845ac2139a2a675bfd55c5b378e Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Fri, 22 Nov 2024 17:07:10 -0600 Subject: [PATCH 1/2] Add more scripting templates. --- Content/Editor/Scripting/ActorTemplate.cpp | 19 +++++ Content/Editor/Scripting/ActorTemplate.cs | 39 ++++++++++ Content/Editor/Scripting/ActorTemplate.h | 13 ++++ .../Editor/Scripting/EmptyClassTemplate.cs | 13 ++++ .../Scripting/EmptyInterfaceTemplate.cs | 13 ++++ .../Editor/Scripting/EmptyStructTemplate.cs | 13 ++++ Source/Editor/Content/Proxy/CSharpProxy.cs | 74 ++++++++++++++++++- Source/Editor/Content/Proxy/CppProxy.cs | 18 +++++ .../Editor/Modules/ContentDatabaseModule.cs | 5 ++ 9 files changed, 204 insertions(+), 3 deletions(-) create mode 100644 Content/Editor/Scripting/ActorTemplate.cpp create mode 100644 Content/Editor/Scripting/ActorTemplate.cs create mode 100644 Content/Editor/Scripting/ActorTemplate.h create mode 100644 Content/Editor/Scripting/EmptyClassTemplate.cs create mode 100644 Content/Editor/Scripting/EmptyInterfaceTemplate.cs create mode 100644 Content/Editor/Scripting/EmptyStructTemplate.cs diff --git a/Content/Editor/Scripting/ActorTemplate.cpp b/Content/Editor/Scripting/ActorTemplate.cpp new file mode 100644 index 000000000..826c361cc --- /dev/null +++ b/Content/Editor/Scripting/ActorTemplate.cpp @@ -0,0 +1,19 @@ +%copyright%#include "%filename%.h" + +%class%::%class%(const SpawnParams& params) + : Actor(params) +{ + +} + +void %class%::OnEnable() +{ + Actor::OnEnable(); + // Here you can add code that needs to be called when script is enabled (eg. register for events) +} + +void %class%::OnDisable() +{ + Actor::OnDisable(); + // Here you can add code that needs to be called when script is disabled (eg. unregister from events) +} diff --git a/Content/Editor/Scripting/ActorTemplate.cs b/Content/Editor/Scripting/ActorTemplate.cs new file mode 100644 index 000000000..20714b22b --- /dev/null +++ b/Content/Editor/Scripting/ActorTemplate.cs @@ -0,0 +1,39 @@ +%copyright%using System; +using System.Collections.Generic; +using FlaxEngine; + +namespace %namespace%; + +/// +/// %class% Actor. +/// +public class %class% : Actor +{ + /// + public override void OnBeginPlay() + { + base.OnBeginPlay(); + // Here you can add code that needs to be called when Actor added to the game. This is called during edit time as well. + } + + /// + public override void OnEndPlay() + { + base.OnEndPlay(); + // Here you can add code that needs to be called when Actor removed to the game. This is called during edit time as well. + } + + /// + public override void OnEnable() + { + base.OnEnable(); + // Here you can add code that needs to be called when Actor is enabled (eg. register for events). This is called during edit time as well. + } + + /// + public override void OnDisable() + { + base.OnDisable(); + // Here you can add code that needs to be called when Actor is disabled (eg. unregister from events). This is called during edit time as well. + } +} diff --git a/Content/Editor/Scripting/ActorTemplate.h b/Content/Editor/Scripting/ActorTemplate.h new file mode 100644 index 000000000..e97651a51 --- /dev/null +++ b/Content/Editor/Scripting/ActorTemplate.h @@ -0,0 +1,13 @@ +%copyright%#pragma once + +#include "Engine/Level/Actor.h" + +API_CLASS() class %module%%class% : public Actor +{ +API_AUTO_SERIALIZATION(); +DECLARE_SCENE_OBJECT(%class%); + + // [Actor] + void OnEnable() override; + void OnDisable() override; +}; diff --git a/Content/Editor/Scripting/EmptyClassTemplate.cs b/Content/Editor/Scripting/EmptyClassTemplate.cs new file mode 100644 index 000000000..613f80cfa --- /dev/null +++ b/Content/Editor/Scripting/EmptyClassTemplate.cs @@ -0,0 +1,13 @@ +%copyright%using System; +using System.Collections.Generic; +using FlaxEngine; + +namespace %namespace%; + +/// +/// %class% class. +/// +public class %class% +{ + +} diff --git a/Content/Editor/Scripting/EmptyInterfaceTemplate.cs b/Content/Editor/Scripting/EmptyInterfaceTemplate.cs new file mode 100644 index 000000000..9738379bd --- /dev/null +++ b/Content/Editor/Scripting/EmptyInterfaceTemplate.cs @@ -0,0 +1,13 @@ +%copyright%using System; +using System.Collections.Generic; +using FlaxEngine; + +namespace %namespace%; + +/// +/// %class% interface. +/// +public interface %class% +{ + +} diff --git a/Content/Editor/Scripting/EmptyStructTemplate.cs b/Content/Editor/Scripting/EmptyStructTemplate.cs new file mode 100644 index 000000000..3cca5aed4 --- /dev/null +++ b/Content/Editor/Scripting/EmptyStructTemplate.cs @@ -0,0 +1,13 @@ +%copyright%using System; +using System.Collections.Generic; +using FlaxEngine; + +namespace %namespace%; + +/// +/// %class% struct. +/// +public struct %class% +{ + +} diff --git a/Source/Editor/Content/Proxy/CSharpProxy.cs b/Source/Editor/Content/Proxy/CSharpProxy.cs index 099ad6109..0476d6aa8 100644 --- a/Source/Editor/Content/Proxy/CSharpProxy.cs +++ b/Source/Editor/Content/Proxy/CSharpProxy.cs @@ -73,10 +73,10 @@ namespace FlaxEditor.Content } /// - /// Context proxy object for C# script files. + /// Context proxy object for C# Script files. /// /// - [ContentContextMenu("New/C#/C# Script")] + [ContentContextMenu("New/C#/Scripting/C# Script")] public class CSharpScriptProxy : CSharpProxy { /// @@ -89,11 +89,28 @@ namespace FlaxEditor.Content } } + /// + /// Context proxy object for C# Actor files. + /// + /// + [ContentContextMenu("New/C#/Scripting/C# Actor")] + public class CSharpActorProxy : CSharpProxy + { + /// + public override string Name => "C# Actor"; + + /// + protected override void GetTemplatePath(out string path) + { + path = StringUtils.CombinePaths(Globals.EngineContentFolder, "Editor/Scripting/ActorTemplate.cs"); + } + } + /// /// Context proxy object for empty C# files. /// /// - [ContentContextMenu("New/C#/C# Empty File")] + [ContentContextMenu("New/C#/Generic/C# Empty File")] public class CSharpEmptyProxy : CSharpProxy { /// @@ -105,4 +122,55 @@ namespace FlaxEditor.Content path = StringUtils.CombinePaths(Globals.EngineContentFolder, "Editor/Scripting/CSharpEmptyTemplate.cs"); } } + + /// + /// Context proxy object for empty C# class files. + /// + /// + [ContentContextMenu("New/C#/Generic/C# Class")] + public class CSharpEmptyClassProxy : CSharpProxy + { + /// + public override string Name => "C# Class"; + + /// + protected override void GetTemplatePath(out string path) + { + path = StringUtils.CombinePaths(Globals.EngineContentFolder, "Editor/Scripting/EmptyClassTemplate.cs"); + } + } + + /// + /// Context proxy object for empty C# struct files. + /// + /// + [ContentContextMenu("New/C#/Generic/C# Struct")] + public class CSharpEmptyStructProxy : CSharpProxy + { + /// + public override string Name => "C# Struct"; + + /// + protected override void GetTemplatePath(out string path) + { + path = StringUtils.CombinePaths(Globals.EngineContentFolder, "Editor/Scripting/EmptyStructTemplate.cs"); + } + } + + /// + /// Context proxy object for empty C# interface files. + /// + /// + [ContentContextMenu("New/C#/Generic/C# Interface")] + public class CSharpEmptyInterfaceProxy : CSharpProxy + { + /// + public override string Name => "C# Interface"; + + /// + protected override void GetTemplatePath(out string path) + { + path = StringUtils.CombinePaths(Globals.EngineContentFolder, "Editor/Scripting/EmptyInterfaceTemplate.cs"); + } + } } diff --git a/Source/Editor/Content/Proxy/CppProxy.cs b/Source/Editor/Content/Proxy/CppProxy.cs index af5f93421..3d3b6588f 100644 --- a/Source/Editor/Content/Proxy/CppProxy.cs +++ b/Source/Editor/Content/Proxy/CppProxy.cs @@ -100,6 +100,24 @@ namespace FlaxEditor.Content sourceTemplate = StringUtils.CombinePaths(Globals.EngineContentFolder, "Editor/Scripting/ScriptTemplate.cpp"); } } + + /// + /// Context proxy object for C++ Actor files. + /// + /// + [ContentContextMenu("New/C++/C++ Actor")] + public class CppActorProxy : CppProxy + { + /// + public override string Name => "C++ Actor"; + + /// + protected override void GetTemplatePaths(out string headerTemplate, out string sourceTemplate) + { + headerTemplate = StringUtils.CombinePaths(Globals.EngineContentFolder, "Editor/Scripting/ActorTemplate.h"); + sourceTemplate = StringUtils.CombinePaths(Globals.EngineContentFolder, "Editor/Scripting/ActorTemplate.cpp"); + } + } /// /// Context proxy object for C++ Json Asset files. diff --git a/Source/Editor/Modules/ContentDatabaseModule.cs b/Source/Editor/Modules/ContentDatabaseModule.cs index c42bd9d86..7a85107d9 100644 --- a/Source/Editor/Modules/ContentDatabaseModule.cs +++ b/Source/Editor/Modules/ContentDatabaseModule.cs @@ -1136,9 +1136,14 @@ namespace FlaxEditor.Modules Proxy.Add(new SceneAnimationProxy()); Proxy.Add(new CSharpScriptProxy()); Proxy.Add(new CSharpEmptyProxy()); + Proxy.Add(new CSharpEmptyClassProxy()); + Proxy.Add(new CSharpEmptyStructProxy()); + Proxy.Add(new CSharpEmptyInterfaceProxy()); + Proxy.Add(new CSharpActorProxy()); Proxy.Add(new CppAssetProxy()); Proxy.Add(new CppStaticClassProxy()); Proxy.Add(new CppScriptProxy()); + Proxy.Add(new CppActorProxy()); Proxy.Add(new SceneProxy()); Proxy.Add(new PrefabProxy()); Proxy.Add(new IESProfileProxy()); From c7fd1999dbc7e3513565f5bcb3a34a48941c1363 Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Tue, 26 Nov 2024 20:22:36 -0600 Subject: [PATCH 2/2] Remove c# template menus. --- Source/Editor/Content/Proxy/CSharpProxy.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Source/Editor/Content/Proxy/CSharpProxy.cs b/Source/Editor/Content/Proxy/CSharpProxy.cs index 0476d6aa8..8abdf8b30 100644 --- a/Source/Editor/Content/Proxy/CSharpProxy.cs +++ b/Source/Editor/Content/Proxy/CSharpProxy.cs @@ -76,7 +76,7 @@ namespace FlaxEditor.Content /// Context proxy object for C# Script files. /// /// - [ContentContextMenu("New/C#/Scripting/C# Script")] + [ContentContextMenu("New/C#/C# Script")] public class CSharpScriptProxy : CSharpProxy { /// @@ -93,7 +93,7 @@ namespace FlaxEditor.Content /// Context proxy object for C# Actor files. /// /// - [ContentContextMenu("New/C#/Scripting/C# Actor")] + [ContentContextMenu("New/C#/C# Actor")] public class CSharpActorProxy : CSharpProxy { /// @@ -110,7 +110,7 @@ namespace FlaxEditor.Content /// Context proxy object for empty C# files. /// /// - [ContentContextMenu("New/C#/Generic/C# Empty File")] + [ContentContextMenu("New/C#/C# Empty File")] public class CSharpEmptyProxy : CSharpProxy { /// @@ -127,7 +127,7 @@ namespace FlaxEditor.Content /// Context proxy object for empty C# class files. /// /// - [ContentContextMenu("New/C#/Generic/C# Class")] + [ContentContextMenu("New/C#/C# Class")] public class CSharpEmptyClassProxy : CSharpProxy { /// @@ -144,7 +144,7 @@ namespace FlaxEditor.Content /// Context proxy object for empty C# struct files. /// /// - [ContentContextMenu("New/C#/Generic/C# Struct")] + [ContentContextMenu("New/C#/C# Struct")] public class CSharpEmptyStructProxy : CSharpProxy { /// @@ -161,7 +161,7 @@ namespace FlaxEditor.Content /// Context proxy object for empty C# interface files. /// /// - [ContentContextMenu("New/C#/Generic/C# Interface")] + [ContentContextMenu("New/C#/C# Interface")] public class CSharpEmptyInterfaceProxy : CSharpProxy { ///