refactor: redesign project structure
This commit is contained in:
6
Package/build/Polonium.props
Normal file
6
Package/build/Polonium.props
Normal file
@@ -0,0 +1,6 @@
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<PoloniumTemplateTargetPath>$(ProjectDir)script_templates/</PoloniumTemplateTargetPath>
|
||||
<PoloniumTemplateManifest>$(ProjectDir)embedded/templates.polonium.manifest</PoloniumTemplateManifest>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -1,12 +1,20 @@
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<PoloniumTemplateTargetPath>$(ProjectDir)script_templates/</PoloniumTemplateTargetPath>
|
||||
<PoloniumTemplateManifest>$(PoloniumTemplateTargetPath).polonium.manifest</PoloniumTemplateManifest>
|
||||
</PropertyGroup>
|
||||
<ItemGroup Label="Scene">
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Polonium.Generators" Version="0.1.1-x" />
|
||||
<PackageReference Include="Polonium.Tasks" Version="0.1.1-x"/>
|
||||
<Folder Include="Concepts"/>
|
||||
<Folder Include="Assets"/>
|
||||
<Folder Include="Registries"/>
|
||||
<Folder Include="Data"/>
|
||||
<Folder Include="Resources"/>
|
||||
<None Include="script_templates/**/*.*"/>
|
||||
<Compile Remove="script_templates/**/*.*"/>
|
||||
<Compile Remove="embedded/polonium_templates/**/*.cs"/>
|
||||
<AdditionalFiles Include="Assets/**/*.tscn"/>
|
||||
</ItemGroup>
|
||||
<Target Name="EnsureFolders" BeforeTargets="BeforeBuild">
|
||||
|
||||
<Target Name="PoloniumPrepare" BeforeTargets="PoloniumClean">
|
||||
<Message Text="Executing EnsureFolders target" Importance="High"/>
|
||||
<Message Text="$(ProjectDir)" Importance="High"/>
|
||||
<MakeDir Directories="$(ProjectDir)Assets" Condition="!Exists('$(ProjectDir)Assets')"/>
|
||||
@@ -16,27 +24,9 @@
|
||||
<MakeDir Directories="$(ProjectDir)Resources" Condition="!Exists('$(ProjectDir)Resources')"/>
|
||||
<MakeDir Directories="$(ProjectDir)Resources/ButtonTextureSet" Condition="!Exists('$(ProjectDir)Resources/ButtonTextureSet')"/>
|
||||
<MakeDir Directories="$(ProjectDir)script_templates" Condition="!Exists('$(ProjectDir)script_templates')"/>
|
||||
<MakeDir Directories="$(ProjectDir).polonium" Condition="!Exists('$(ProjectDir).polonium')"/>
|
||||
<MakeDir Directories="$(ProjectDir).polonium/Patches" Condition="!Exists('$(ProjectDir).polonium/Patches')" />
|
||||
<Exec
|
||||
Command='rmdir "$(ProjectDir)GlobalClasses"'
|
||||
Condition="'$(OS)'=='Windows_NT' and Exists('$(ProjectDir)GlobalClasses')"
|
||||
/>
|
||||
<Exec
|
||||
Command='mklink /D "$(ProjectDir)GlobalClasses" "$(MSBuildThisFileDirectory)GlobalClasses"'
|
||||
Condition="'$(OS)'=='Windows_NT' and !Exists('$(ProjectDir)GlobalClasses')"
|
||||
/>
|
||||
<Exec
|
||||
Command='rm -rf "$(ProjectDir)GlobalClasses"'
|
||||
Condition="'$(OS)'!='Windows_NT' and Exists('$(ProjectDir)GlobalClasses')"
|
||||
/>
|
||||
<Exec
|
||||
Command='ln -s "$(MSBuildThisFileDirectory)GlobalClasses" "$(ProjectDir)GlobalClasses"'
|
||||
Condition="'$(OS)'!='Windows_NT' and !Exists('$(ProjectDir)GlobalClasses')"
|
||||
/>
|
||||
</Target>
|
||||
|
||||
<Target Name="CleanPoloniumTemplates" BeforeTargets="CopyPoloniumTemplates">
|
||||
|
||||
<Target Name="PoloniumClean" DependsOnTargets="PoloniumPrepare" BeforeTargets="PoloniumRegenerate">
|
||||
<ReadLinesFromFile
|
||||
File="$(PoloniumTemplateManifest)"
|
||||
Condition="Exists('$(PoloniumTemplateManifest)')"
|
||||
@@ -44,16 +34,22 @@
|
||||
<Output TaskParameter="Lines" ItemName="PreviousTemplateFiles"/>
|
||||
</ReadLinesFromFile>
|
||||
<Delete Files="@(PreviousTemplateFiles)" Condition="@(PreviousTemplateFiles) != ''" />
|
||||
<Delete
|
||||
Files="$(PoloniumTemplateManifest)"
|
||||
Condition="Exists('$(PoloniumTemplateManifest)')"
|
||||
/>
|
||||
<RemoveDir Directories="$(ProjectDir)embedded" Condition="Exists('$(ProjectDir)embedded')"/>
|
||||
</Target>
|
||||
<Target Name="CopyPoloniumTemplates" DependsOnTargets="CleanPoloniumTemplates" AfterTargets="Build">
|
||||
|
||||
|
||||
<Target Name="PoloniumRegenerate" DependsOnTargets="PoloniumClean" BeforeTargets="CoreCompile">
|
||||
<MakeDir Directories="$(ProjectDir)" Condition="!Exists('$(ProjectDir)embedded')"/>
|
||||
<ItemGroup>
|
||||
<PoloniumTemplateFiles Include="$(MSBuildThisFileDirectory)polonium_templates/**/*.*"/>
|
||||
<EmbeddedFiles Include="$(MSBuildThisFileDirectory)embedded/**/*.*"/>
|
||||
</ItemGroup>
|
||||
<Copy
|
||||
SourceFiles="@(EmbeddedFiles)"
|
||||
DestinationFolder="$(ProjectDir)embedded/%(RecursiveDir)"
|
||||
/>
|
||||
<ItemGroup>
|
||||
<PoloniumTemplateFiles Include="$(MSBuildThisFileDirectory)embedded/polonium_templates/**/*.*"/>
|
||||
</ItemGroup>
|
||||
<Message Text="Executing Copy Task" Importance="high"/>
|
||||
<Copy
|
||||
SourceFiles="@(PoloniumTemplateFiles)"
|
||||
DestinationFiles="@(PoloniumTemplateFiles->'$(PoloniumTemplateTargetPath)%(RecursiveDir)%(FileName)%(Extension)')"
|
||||
@@ -66,29 +62,11 @@
|
||||
Overwrite="true"
|
||||
Encoding="UTF-8"
|
||||
/>
|
||||
</Target>
|
||||
<Target Name="CleanPoloniumFiles" BeforeTargets="GenerateTextureSetManifest">
|
||||
<ItemGroup>
|
||||
<PoloniumFiles Include="$(ProjectDir).polonium/**/*.*"/>
|
||||
</ItemGroup>
|
||||
<Delete Files="@(PoloniumFiles)"/>
|
||||
</Target>
|
||||
<Target Name="GenerateTextureSetManifest" DependsOnTargets="CleanPoloniumFiles" BeforeTargets="BeforeBuild">
|
||||
<ScanTextureSetFolderTask
|
||||
<GenerateTextureSetTask
|
||||
RootPath="$(ProjectDir)Resources/ButtonTextureSet/"
|
||||
OutputPath="$(ProjectDir).polonium/"
|
||||
OutputPath="$(ProjectDir)embedded/"
|
||||
/>
|
||||
</Target>
|
||||
<ItemGroup>
|
||||
<Folder Include="Concepts"/>
|
||||
<Folder Include="Assets"/>
|
||||
<Folder Include="Registries"/>
|
||||
<Folder Include="Data"/>
|
||||
<Folder Include="Resources"/>
|
||||
<None Include="script_templates/**/*.*"/>
|
||||
<Compile Remove="script_templates/**/*.*"/>
|
||||
<PackageReference Include="Polonium.Generators" Version="0.1.1-x" />
|
||||
<PackageReference Include="Polonium.Tasks" Version="0.1.1-x"/>
|
||||
<AdditionalFiles Include=".polonium/**/*.*"/>
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#pragma warning disable IDE0130
|
||||
using Godot;
|
||||
using Polonium.Attributes;
|
||||
using Polonium.DataStructures;
|
||||
using System.Collections.Generic;
|
||||
|
||||
|
||||
// ReSharper disable once CheckNamespace
|
||||
namespace GlobalClasses;
|
||||
[GlobalClass]
|
||||
[Tool]
|
||||
@@ -37,4 +37,5 @@ public partial class PoloniumTextureButton : TextureButton
|
||||
public virtual void __Ready()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
#pragma warning restore IDE0130
|
||||
@@ -1,6 +1,6 @@
|
||||
using Godot;
|
||||
using Polonium.Attributes;
|
||||
|
||||
// ReSharper disable once CheckNamespace
|
||||
namespace GlobalClasses;
|
||||
[ProxyNode]
|
||||
[GlobalClass]
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma warning disable IDE0130
|
||||
using Godot;
|
||||
using Polonium.Attributes;
|
||||
|
||||
// ReSharper disable once CheckNamespace
|
||||
namespace GlobalClasses;
|
||||
[ProxyNode]
|
||||
[GlobalClass]
|
||||
@@ -41,3 +42,4 @@ public partial class DissolveScene : Scene
|
||||
base._EnterTree();
|
||||
}
|
||||
}
|
||||
#pragma warning restore IDE0130
|
||||
@@ -1,7 +1,8 @@
|
||||
#pragma warning disable IDE0130
|
||||
using Godot;
|
||||
using Polonium.Attributes;
|
||||
using Polonium.Interfaces;
|
||||
|
||||
// ReSharper disable once CheckNamespace
|
||||
namespace GlobalClasses;
|
||||
[ProxyNode]
|
||||
[GlobalClass]
|
||||
@@ -59,3 +60,4 @@ public partial class RootScene : Scene
|
||||
}
|
||||
|
||||
}
|
||||
#pragma warning restore IDE0130
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma warning disable IDE0130
|
||||
using Godot;
|
||||
using Polonium.Attributes;
|
||||
|
||||
// ReSharper disable once CheckNamespace
|
||||
namespace GlobalClasses;
|
||||
[ProxyNode]
|
||||
[GlobalClass]
|
||||
@@ -9,3 +10,4 @@ public partial class Scene : Node2D
|
||||
{
|
||||
|
||||
}
|
||||
#pragma warning restore IDE0130
|
||||
57
Package/embedded/Patches/GlobalRegistry.p.cs
Normal file
57
Package/embedded/Patches/GlobalRegistry.p.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
#pragma warning disable IDE0130
|
||||
#pragma warning disable CA1000
|
||||
using Godot;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Polonium.Attributes;
|
||||
using Polonium;
|
||||
using Polonium.Interfaces;
|
||||
using System.Collections.Generic;
|
||||
|
||||
// ReSharper disable once CheckNamespace
|
||||
public static partial class GlobalRegistry
|
||||
{
|
||||
public static void Start()
|
||||
{
|
||||
PoloniumRegistry.Prepare();
|
||||
Assembly assembly = Assembly.GetExecutingAssembly();
|
||||
IEnumerable<Type> registerTypes = Utils.GetLoadableTypes(assembly);
|
||||
registerTypes = registerTypes.Where(t => t.IsClass && t.GetCustomAttributes(typeof(AutoRegister), false).Any());
|
||||
foreach (Type t in registerTypes)
|
||||
{
|
||||
MethodInfo registerMethod = t.GetMethod("Register", BindingFlags.Static | BindingFlags.Public);
|
||||
if (registerMethod != null)
|
||||
registerMethod.Invoke(null, null);
|
||||
}
|
||||
}
|
||||
|
||||
public static class Asset<T> where T : Node
|
||||
{
|
||||
private static readonly Queue<T> Pool = new();
|
||||
// ReSharper disable once StaticMemberInGenericType
|
||||
// ReSharper disable once UnusedAutoPropertyAccessor.Global
|
||||
public static PackedScene Scene { get; set; }
|
||||
private static T Instance => Scene.Instantiate<T>();
|
||||
public static T Get() => Pool.Count > 0 ? Pool.Dequeue() : Instance;
|
||||
|
||||
public static void Return(T obj)
|
||||
{
|
||||
if(Pool.Count < 10)
|
||||
Pool.Enqueue(obj);
|
||||
else
|
||||
obj.QueueFree();
|
||||
}
|
||||
}
|
||||
public static PoloniumRegistry PoloniumRegistry => PoloniumRegistry.Instance;
|
||||
public static bool Paused { get; set; }
|
||||
public static HashSet<ITimeConsumer> TimeConsumers { get; } = [];
|
||||
public static void Prepare() => PoloniumRegistry.Prepare();
|
||||
|
||||
// ReSharper disable once PartialTypeWithSinglePart
|
||||
public static partial class TextureSets
|
||||
{
|
||||
}
|
||||
}
|
||||
#pragma warning restore IDE0130
|
||||
#pragma warning restore CA1000
|
||||
@@ -13,47 +13,27 @@
|
||||
<DisableImplicitRestore>true</DisableImplicitRestore>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="GodotSharp" Version="4.4.0-beta.3" />
|
||||
<PackageReference Include="Polonium.Tasks" Version="0.1.1-x" />
|
||||
</ItemGroup>
|
||||
<Target Name="Prepare" BeforeTargets="BeforeBuild">
|
||||
<RemoveDir Directories="$(ProjectDir)Package/embedded/polonium_templates" Condition="Exists('$(ProjectDir)Package/polonium_templates')"/>
|
||||
<MakeDir Directories="$(ProjectDir)Package/embedded/polonium_templates"/>
|
||||
<GenerateProxyNodesTask
|
||||
SourceDirectory="$(ProjectDir)GlobalClasses"
|
||||
TemplateDirectory="$(ProjectDir)polonium_templates"
|
||||
SourceDirectory="$(ProjectDir)Package/embedded/GlobalClasses"
|
||||
TemplateDirectory="$(ProjectDir)Package/embedded/polonium_templates"
|
||||
AttributeName="ProxyNode"
|
||||
/>
|
||||
</Target>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="NuGet.config" />
|
||||
<None
|
||||
Include="Package/build/$(AssemblyName).targets"
|
||||
Pack="true"
|
||||
PackagePath="build"
|
||||
/>
|
||||
<None
|
||||
Include="GlobalClasses/**/*.cs"
|
||||
Pack="true"
|
||||
PackagePath="build/GlobalClasses"
|
||||
/>
|
||||
<None
|
||||
Include="polonium_templates/**/*.cs"
|
||||
Pack="true"
|
||||
PackagePath="build/polonium_templates"
|
||||
/>
|
||||
<None
|
||||
Include=".polonium/**/*.*"
|
||||
Pack="true"
|
||||
PackagePath="build/.polonium"
|
||||
/>
|
||||
<None Include="Package/build/$(AssemblyName).targets" Pack="true" PackagePath="build" />
|
||||
<None Include="Package/build/$(AssemblyName).props" Pack="true" PackagePath="build" />
|
||||
<None Include="Package/embedded/**/*.*" Pack="true" PackagePath="build/embedded" />
|
||||
<None Include="publish" />
|
||||
<Compile Remove="polonium_templates/**/*.*" />
|
||||
<Compile Remove="GlobalClasses/**/*.cs" />
|
||||
<Folder Include="polonium_templates" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="build" />
|
||||
<None Include="build" />
|
||||
<Compile Remove="Package/**/*.*"/>
|
||||
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="CleanPreviousPackages" BeforeTargets="Build">
|
||||
|
||||
16
Polonium.sln
16
Polonium.sln
@@ -16,28 +16,12 @@ Global
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{5BA39DF8-7098-4348-A670-B3F34269F48F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{5BA39DF8-7098-4348-A670-B3F34269F48F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{5BA39DF8-7098-4348-A670-B3F34269F48F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{5BA39DF8-7098-4348-A670-B3F34269F48F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{41B784D2-841C-44D6-90F3-9219BC264B19}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{41B784D2-841C-44D6-90F3-9219BC264B19}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{41B784D2-841C-44D6-90F3-9219BC264B19}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{41B784D2-841C-44D6-90F3-9219BC264B19}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{3BADB215-214B-41C1-B94E-89AF4A972F30}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{3BADB215-214B-41C1-B94E-89AF4A972F30}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{3BADB215-214B-41C1-B94E-89AF4A972F30}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{3BADB215-214B-41C1-B94E-89AF4A972F30}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{1B24F8AC-B185-48D0-835B-59857AF907E5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{1B24F8AC-B185-48D0-835B-59857AF907E5}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{1B24F8AC-B185-48D0-835B-59857AF907E5}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{1B24F8AC-B185-48D0-835B-59857AF907E5}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{D2BA966D-140F-4C04-8EE1-88FFE5FEB67C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{D2BA966D-140F-4C04-8EE1-88FFE5FEB67C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{D2BA966D-140F-4C04-8EE1-88FFE5FEB67C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{D2BA966D-140F-4C04-8EE1-88FFE5FEB67C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{25595747-BE10-4F36-BDE0-9400576EA921}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{25595747-BE10-4F36-BDE0-9400576EA921}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{25595747-BE10-4F36-BDE0-9400576EA921}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{25595747-BE10-4F36-BDE0-9400576EA921}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{5F0664A8-563F-408A-9EB6-05B2F25F5DC5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{5F0664A8-563F-408A-9EB6-05B2F25F5DC5}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{5F0664A8-563F-408A-9EB6-05B2F25F5DC5}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
|
||||
8
src/Interfaces/IGlobalRegistry.cs
Normal file
8
src/Interfaces/IGlobalRegistry.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace Polonium.Interfaces;
|
||||
|
||||
public interface IGlobalRegistry
|
||||
{
|
||||
public bool Paused { get; set; }
|
||||
public void Start();
|
||||
public void Prepare();
|
||||
}
|
||||
13
src/Utils.cs
13
src/Utils.cs
@@ -1,3 +1,5 @@
|
||||
#pragma warning disable CS0618
|
||||
#pragma warning disable CS0168
|
||||
using System.Reflection;
|
||||
using Godot;
|
||||
|
||||
@@ -16,8 +18,9 @@ public static class Utils
|
||||
return e.Types.Where(t => t != null);
|
||||
}
|
||||
}
|
||||
|
||||
private static Dictionary<StringName, AnimatedTexture> AnimatedTextureCache = new ();
|
||||
|
||||
private static Dictionary<StringName, AnimatedTexture> AnimatedTextureCache { get; } = new();
|
||||
|
||||
public static AnimatedTexture LoadAnimatedTextureFromDirectory(StringName path)
|
||||
{
|
||||
try
|
||||
@@ -41,6 +44,6 @@ public static class Utils
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
#pragma warning restore CS0618
|
||||
#pragma warning restore CS0168
|
||||
Reference in New Issue
Block a user