diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml
new file mode 100644
index 0000000..c23e985
--- /dev/null
+++ b/.github/workflows/docs.yml
@@ -0,0 +1,44 @@
+# Your GitHub workflow file under .github/workflows/
+# Trigger the action on push to master
+on:
+ push:
+ branches:
+ - master
+
+# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
+permissions:
+ actions: read
+ pages: write
+ id-token: write
+
+# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
+# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
+concurrency:
+ group: "pages"
+ cancel-in-progress: false
+
+jobs:
+ publish-docs:
+ environment:
+ name: github-pages
+ url: ${{ steps.deployment.outputs.page_url }}
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v3
+ - name: Dotnet Setup
+ uses: actions/setup-dotnet@v3
+ with:
+ dotnet-version: 8.x
+
+ - run: dotnet tool update -g docfx
+ - run: docfx docs/docfx.json
+
+ - name: Upload artifact
+ uses: actions/upload-pages-artifact@v3
+ with:
+ # Upload entire repository
+ path: 'docs/_site'
+ - name: Deploy to GitHub Pages
+ id: deployment
+ uses: actions/deploy-pages@v4
diff --git a/OpenPuppet.sln b/OpenPuppet.sln
index dc4f854..f6775d0 100644
--- a/OpenPuppet.sln
+++ b/OpenPuppet.sln
@@ -1,7 +1,7 @@
Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio Version 17
-VisualStudioVersion = 17.14.37111.16 d17.14
+# Visual Studio Version 18
+VisualStudioVersion = 18.11.12328.437 stable
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenPuppet", "src\OpenPuppet\OpenPuppet.csproj", "{04493B85-FA83-4B82-B1B2-B574DDAF93D3}"
EndProject
@@ -17,6 +17,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenPuppet.Core", "src\Plug
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenPuppet.Preferences", "src\Plugins\OpenPuppet.Preferences\OpenPuppet.Preferences.csproj", "{B4C01F7A-1E01-4DFA-96A2-8A3CE95F38B9}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenPuppet.Translations", "src\Plugins\OpenPuppet.Translations\OpenPuppet.Translations.csproj", "{AB19BF75-595B-431D-9091-1A0832DC08CA}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -47,6 +49,10 @@ Global
{B4C01F7A-1E01-4DFA-96A2-8A3CE95F38B9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B4C01F7A-1E01-4DFA-96A2-8A3CE95F38B9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B4C01F7A-1E01-4DFA-96A2-8A3CE95F38B9}.Release|Any CPU.Build.0 = Release|Any CPU
+ {AB19BF75-595B-431D-9091-1A0832DC08CA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {AB19BF75-595B-431D-9091-1A0832DC08CA}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {AB19BF75-595B-431D-9091-1A0832DC08CA}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {AB19BF75-595B-431D-9091-1A0832DC08CA}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -55,6 +61,7 @@ Global
{F8F83C68-494B-6C0F-59A9-2875CFAB98DA} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8}
{710B2E9D-DBCF-490D-B58E-FB2F19A0881A} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8}
{B4C01F7A-1E01-4DFA-96A2-8A3CE95F38B9} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8}
+ {AB19BF75-595B-431D-9091-1A0832DC08CA} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {8242C2F9-5D81-4332-8968-F5B543049B2E}
diff --git a/docs/.gitignore b/docs/.gitignore
new file mode 100644
index 0000000..f807665
--- /dev/null
+++ b/docs/.gitignore
@@ -0,0 +1,9 @@
+###############
+# folder #
+###############
+/**/DROP/
+/**/TEMP/
+/**/packages/
+/**/bin/
+/**/obj/
+_site
\ No newline at end of file
diff --git a/docs/api/.gitignore b/docs/api/.gitignore
new file mode 100644
index 0000000..7e7bb37
--- /dev/null
+++ b/docs/api/.gitignore
@@ -0,0 +1,5 @@
+###############
+# temp file #
+###############
+*.yml
+.manifest
\ No newline at end of file
diff --git a/docs/api/index.md b/docs/api/index.md
new file mode 100644
index 0000000..8d504f1
--- /dev/null
+++ b/docs/api/index.md
@@ -0,0 +1,8 @@
+---
+uid: api-docs
+title: API
+---
+
+# API
+
+API Reference documentation
\ No newline at end of file
diff --git a/docs/docfx.json b/docs/docfx.json
new file mode 100644
index 0000000..6e6c382
--- /dev/null
+++ b/docs/docfx.json
@@ -0,0 +1,46 @@
+{
+ "$schema": "https://raw.githubusercontent.com/dotnet/docfx/main/schemas/docfx.schema.json",
+ "metadata": [
+ {
+ "src": [
+ {
+ "src": "../src",
+ "files": [
+ "**/*.csproj"
+ ]
+ }
+ ],
+ "dest": "api"
+ }
+ ],
+ "build": {
+ "content": [
+ {
+ "files": [
+ "**/*.{md,yml}"
+ ],
+ "exclude": [
+ "_site/**"
+ ]
+ }
+ ],
+ "resource": [
+ {
+ "files": [
+ "images/**"
+ ]
+ }
+ ],
+ "output": "_site",
+ "template": [
+ "default",
+ "modern",
+ "templates/custom"
+ ],
+ "globalMetadata": {
+ "_appName": "OpenPuppet",
+ "_appTitle": "OpenPuppet",
+ "_enableSearch": true
+ }
+ }
+}
\ No newline at end of file
diff --git a/docs/docs/developer-guide.md b/docs/docs/developer-guide.md
new file mode 100644
index 0000000..6a88840
--- /dev/null
+++ b/docs/docs/developer-guide.md
@@ -0,0 +1,54 @@
+# Getting Started (Developer)
+
+
+ If you're looking for the plugin developer guide, try here instead .
+
+
+There are a number of prerequisites for developing OpenPuppet.
+
+If you are on Windows, you need the following software installed on your computer.
+
+- **Either** Visual Studio, Visual Studio Code (and build tools), or another editor of your choice.
+ - It must support **.NET 10**.
+ - Visual Studio 2026 is preferred, as there are things such as build scripts
+ that *may* not work correctly if you don't use it.
+- Git
+- Basic knowledge of C#
+
+---
+
+
+
+1. **Fork the repository on your GitHub account.**
+2. Locally clone **your fork** onto your computer
+ - Typically using `git clone https://github.com/username/repo/`
+3. Open the `OpenPuppet.sln` Visual Studio solution.
+4. Make your changes
+5. Commit your changes
+6. Push your changes
+7. Open a pull request
+8. Done!
+
+## Contributing
+
+We welcome all contributions, but please make sure you follow the contributing guidelines, and code of conduct.
+
+We accept all sorts of contributions:
+
+- Answering questions in discussions.
+- Helping to debug issues.
+- Finding vulnerabilities (**DO NOT OPEN AN ISSUE FOR THIS**, please refer to the security policy on how to submit vulnerabilities).
+- Contributing code.
+
+> [!WARNING]
+> If you open a pull request that is majority-made with an LLM (Large Language Model), you may
+> have your pull request closed.
+>
+> For things such as issues, discussions, or pull request reviews, LLMs should be avoided.
+> If a maintainer asks that you stop using an LLM, and you continue, you may be blocked
+> from the repository.
+
+If you are new to the codebase, it would be a good idea to find issues marked as either
+["help wanted"](https://github.com/Project-Axion/OpenPuppet/issues?q=is%3Aissue+state%3Aopen+label%3A%22help+wanted%22)
+or
+["good first issue"](https://github.com/Project-Axion/OpenPuppet/issues?q=is%3Aissue+state%3Aopen+label%3A%22good+first+issue%22).
\ No newline at end of file
diff --git a/docs/docs/getting-started.md b/docs/docs/getting-started.md
new file mode 100644
index 0000000..756ca9e
--- /dev/null
+++ b/docs/docs/getting-started.md
@@ -0,0 +1,22 @@
+# Getting Started
+
+
+ If you're looking for the plugin developer guide, try here instead .
+
+
+To get started with OpenPuppet, you must first download the latest stable build from the GitHub repository.
+
+
+
+
+Once you have it downloaded, run the installer to get it installed on your computer. Then launch it. Now you have the
+application installed, follow the [OpenPuppet basics guide](/guides/basics/index.md).
+
+---
+
+## Guides
+
+If you're looking for individual guides instead, try looking [here](/guides/) instead.
\ No newline at end of file
diff --git a/docs/docs/introduction.md b/docs/docs/introduction.md
new file mode 100644
index 0000000..f6ecaa6
--- /dev/null
+++ b/docs/docs/introduction.md
@@ -0,0 +1 @@
+# Introduction
\ No newline at end of file
diff --git a/docs/docs/systems/naming.md b/docs/docs/systems/naming.md
new file mode 100644
index 0000000..000b9d4
--- /dev/null
+++ b/docs/docs/systems/naming.md
@@ -0,0 +1,9 @@
+# Naming conventions
+
+## Command naming convention
+
+A command has 2 parts: The source (the ID of the plugin source, i.e. the one that registered it),
+and the command ID (typically a string of what look like random numbers and letters), separated
+by an exclamation mark (`!`).
+
+For example: `com.openpuppet.core!Jc7agK9dxLXbeNXUJM7BZFghJq0007pc`.
\ No newline at end of file
diff --git a/docs/docs/systems/plugins/create.md b/docs/docs/systems/plugins/create.md
new file mode 100644
index 0000000..59b18f5
--- /dev/null
+++ b/docs/docs/systems/plugins/create.md
@@ -0,0 +1 @@
+# Make your own plugin
\ No newline at end of file
diff --git a/docs/docs/systems/plugins/overview.md b/docs/docs/systems/plugins/overview.md
new file mode 100644
index 0000000..fc892dd
--- /dev/null
+++ b/docs/docs/systems/plugins/overview.md
@@ -0,0 +1,14 @@
+# Plugin system overview
+
+This section of the documentation outlines how the plugin system works,
+how plugin loading, unloading, and management is handled.
+
+## Everything is a service
+
+When a plugin is initialised, it gets passed a `IServicesCollection` which
+is from the `Microsoft.Extensions.DependencyInjection` NuGet package.
+
+**Every** service that the plugin registers must be registered through the
+provided `IServicesCollection`, otherwise unloading doesn't work correctly.
+When a plugin is unloaded/destroyed, all of the services it has registered
+must be loaded.
\ No newline at end of file
diff --git a/docs/docs/systems/tasks/background.md b/docs/docs/systems/tasks/background.md
new file mode 100644
index 0000000..bc239bf
--- /dev/null
+++ b/docs/docs/systems/tasks/background.md
@@ -0,0 +1,6 @@
+# Background tasks
+
+Background tasks are tasks that are queued, and run in the background when they get their turn.
+When a background worker is available, it will attempt to execute the background task.
+
+Depending on the user settings, these background tasks may run concurrently.
\ No newline at end of file
diff --git a/docs/docs/systems/tasks/overview.md b/docs/docs/systems/tasks/overview.md
new file mode 100644
index 0000000..228b455
--- /dev/null
+++ b/docs/docs/systems/tasks/overview.md
@@ -0,0 +1,9 @@
+# Tasks Overview
+
+There are a few fairly basic rules for the tasks system in OpenPuppet:
+
+- **All** tasks must be cancellable.
+- Background tasks shouldn't *massively*\* alter the UI.
+ - \* meaning things like loading a layout, or plugin that may shift the layout.
+ Things such as previews, icons, or other small details on the screen **do not**
+ count as *massively* altering the UI.
\ No newline at end of file
diff --git a/docs/docs/systems/tasks/priority.md b/docs/docs/systems/tasks/priority.md
new file mode 100644
index 0000000..0bf6c3a
--- /dev/null
+++ b/docs/docs/systems/tasks/priority.md
@@ -0,0 +1,7 @@
+# Priority (foreground) tasks
+
+A priority task is one that is required for the user to be able to continue. This involves
+blocking user input until the process has been completed.
+This typically involves an undismissable dialog with a progress bar and a cancel button.
+A priority task should be avoided unless **absolutely neccecary**. Updating certain data,
+or other minimal tasks should be done as [background tasks](background.md) instead.
\ No newline at end of file
diff --git a/docs/docs/toc.yml b/docs/docs/toc.yml
new file mode 100644
index 0000000..2e0265e
--- /dev/null
+++ b/docs/docs/toc.yml
@@ -0,0 +1,24 @@
+- name: Introduction
+ href: introduction.md
+- name: Getting Started
+ href: getting-started.md
+- name: Getting Started (Developer)
+ href: developer-guide.md
+- name: Systems
+ items:
+ - name: Naming
+ href: systems/naming.md
+ - name: Plugins
+ items:
+ - name: Overview
+ href: systems/plugins/overview.md
+ - name: Make your own
+ href: systems/plugins/create.md
+ - name: Task system
+ items:
+ - name: Overview
+ href: systems/tasks/overview.md
+ - name: Priority (foreground) tasks
+ href: systems/tasks/priority.md
+ - name: Background tasks
+ href: systems/tasks/background.md
\ No newline at end of file
diff --git a/docs/guides/index.md b/docs/guides/index.md
new file mode 100644
index 0000000..e69de29
diff --git a/docs/index.md b/docs/index.md
new file mode 100644
index 0000000..97a4288
--- /dev/null
+++ b/docs/index.md
@@ -0,0 +1,13 @@
+---
+_layout: landing
+---
+
+
+
+
2D Rigged Animation Software
+
Modern 2D Rigged Animation Software with... yeah no that's about it
+
+
\ No newline at end of file
diff --git a/docs/templates/custom/public/main.css b/docs/templates/custom/public/main.css
new file mode 100644
index 0000000..473a1c6
--- /dev/null
+++ b/docs/templates/custom/public/main.css
@@ -0,0 +1,214 @@
+:root {
+ --bs-link-color-rgb: 44, 119, 204;
+ --bs-link-hover-color-rgb: 59, 117, 187;
+ --brand-blue: #2c77cc;
+ --brand-blue-light: #e8f1fb;
+ --brand-blue-dark: #1a5a9e;
+}
+
+/* Navbar logo */
+.navbar .navbar-brand img {
+ height: 48px;
+ width: 48px;
+}
+
+/* Landing page */
+
+.landing-hero {
+ text-align: center;
+ padding: 4rem 1.5rem 3rem;
+ max-width: 720px;
+ margin: 0 auto;
+}
+
+.landing-hero img {
+ max-width: 400px;
+ width: 100%;
+ margin-bottom: 1.5rem;
+}
+
+.landing-hero h1 {
+ font-size: 2rem;
+ font-weight: 300;
+ line-height: 1.4;
+ margin-bottom: 1rem;
+ color: var(--bs-body-color);
+}
+
+.landing-hero p {
+ font-size: 1.125rem;
+ line-height: 1.7;
+ color: var(--bs-secondary-color);
+ margin-bottom: 2rem;
+}
+
+.landing-actions {
+ display: flex;
+ gap: 0.75rem;
+ justify-content: center;
+ flex-wrap: wrap;
+}
+
+.landing-actions a {
+ display: inline-block;
+ padding: 0.6rem 1.5rem;
+ border-radius: 6px;
+ font-weight: 500;
+ font-size: 0.95rem;
+ text-decoration: none;
+ transition:
+ background-color 0.15s,
+ color 0.15s;
+}
+
+.btn-primary-landing {
+ background-color: var(--brand-blue);
+ color: #fff !important;
+}
+
+.btn-primary-landing:hover {
+ background-color: var(--brand-blue-dark);
+ color: #fff !important;
+}
+
+.btn-outline-landing {
+ border: 1px solid var(--bs-border-color);
+ color: var(--bs-body-color) !important;
+ background: transparent;
+}
+
+.btn-outline-landing:hover {
+ border-color: var(--brand-blue);
+ color: var(--brand-blue) !important;
+}
+
+/* Quick install */
+
+.quick-install {
+ max-width: 520px;
+ margin: 0 auto 4rem;
+ text-align: center;
+}
+
+.quick-install code {
+ display: inline-block;
+ padding: 0.75rem 1.25rem;
+ border-radius: 6px;
+ font-size: 0.9rem;
+}
+
+.typewriter-cursor {
+ display: inline-block;
+ width: 0;
+ animation: blink 0.7s step-end infinite;
+ margin-left: 1px;
+ font-weight: 100;
+ color: var(--brand-blue);
+}
+
+/* Feature grid */
+
+.feature-grid {
+ display: grid;
+ grid-template-columns: 1fr;
+ gap: 2rem;
+ max-width: 900px;
+ margin: 0 auto 4rem;
+ padding: 0 1.5rem;
+}
+
+@media (min-width: 768px) {
+ .feature-grid {
+ grid-template-columns: 1fr 1fr;
+ }
+}
+
+.feature-card {
+ padding: 1.5rem;
+ border: 1px solid var(--bs-border-color);
+ border-radius: 8px;
+ transition: border-color 0.15s;
+}
+
+.feature-card:hover {
+ border-color: var(--brand-blue);
+}
+
+.feature-card h3 {
+ font-size: 1.1rem;
+ font-weight: 600;
+ margin-bottom: 0.5rem;
+}
+
+.feature-card p {
+ font-size: 0.95rem;
+ line-height: 1.6;
+ color: var(--bs-secondary-color);
+ margin-bottom: 0;
+}
+
+/* Bottom CTA */
+
+.landing-cta {
+ text-align: center;
+ padding: 3rem 1.5rem 4rem;
+ max-width: 600px;
+ margin: 0 auto;
+}
+
+.landing-cta h2 {
+ font-size: 1.5rem;
+ font-weight: 400;
+ margin-bottom: 1.5rem;
+}
+
+.landing-cta .landing-actions {
+ margin-top: 1rem;
+}
+
+@keyframes blink {
+ 50% {
+ opacity: 0;
+ }
+}
+
+
+/* Other actions */
+.other-actions {
+ display: flex;
+ gap: 0.75rem;
+ flex-wrap: wrap;
+}
+
+.other-actions a {
+ display: inline-block;
+ padding: 0.6rem 1.5rem;
+ border-radius: 6px;
+ font-weight: 500;
+ font-size: 0.95rem;
+ text-decoration: none;
+ transition:
+ background-color 0.15s,
+ color 0.15s;
+}
+
+.btn-primary-other {
+ background-color: var(--brand-blue);
+ color: #fff !important;
+}
+
+.btn-primary-other:hover {
+ background-color: var(--brand-blue-dark);
+ color: #fff !important;
+}
+
+.btn-outline-other {
+ border: 1px solid var(--bs-border-color);
+ color: var(--bs-body-color) !important;
+ background: transparent;
+}
+
+.btn-outline-other:hover {
+ border-color: var(--brand-blue);
+ color: var(--brand-blue) !important;
+}
\ No newline at end of file
diff --git a/docs/toc.yml b/docs/toc.yml
new file mode 100644
index 0000000..149a655
--- /dev/null
+++ b/docs/toc.yml
@@ -0,0 +1,6 @@
+- name: Docs
+ href: docs/
+- name: Guides
+ href: guides/
+- name: API
+ href: api/
\ No newline at end of file
diff --git a/src/OpenPuppet.SDK/ContextMenu.cs b/src/OpenPuppet.SDK/ContextMenu.cs
index 4876c91..07b9d95 100644
--- a/src/OpenPuppet.SDK/ContextMenu.cs
+++ b/src/OpenPuppet.SDK/ContextMenu.cs
@@ -9,7 +9,7 @@ namespace OpenPuppet.SDK
{
public static class ContextMenu
{
- public static ContextMenuList Root { get; } = new();
+ public static ContextMenuList Root { get; } = new() { Name = string.Empty, DisplayName = string.Empty };
static void ProcessItem(string path, Action onClick, ContextMenuList currentNode, string? name, bool enabled)
{
@@ -103,6 +103,9 @@ static void ProcessR(string path, ContextMenuList currentNode, string name)
}
else
{
+ //foreach (var node in currentNode.Nodes.Where(p => p.Name == parts[0] && p is ContextMenuList))
+ // ProcessR(string.Join('.', parts.Skip(1)), node as ContextMenuList, name);
+
foreach (var node in currentNode.Nodes)
if (node.Name == parts[0] && node is ContextMenuList li)
ProcessR(string.Join('.', parts.Skip(1)), li, name);
@@ -119,6 +122,9 @@ static void ProcessRm(string path, ContextMenuList currentNode)
}
else
{
+ //foreach (var node in currentNode.Nodes.Where(p => p.Name == parts[0] && p is ContextMenuList))
+ // ProcessRm(string.Join('.', parts.Skip(1)), node as ContextMenuList);
+
foreach (var node in currentNode.Nodes)
if (node.Name == parts[0] && node is ContextMenuList li)
ProcessRm(string.Join('.', parts.Skip(1)), li);
@@ -156,31 +162,31 @@ public interface IContextMenuNode
public class ContextMenuList : IContextMenuNode
{
- public string Name { get; set; }
- public string DisplayName { get; set; }
+ public required string Name { get; set; }
+ public required string DisplayName { get; set; }
public bool Enabled { get; set; } = true;
public List Nodes { get; set; } = new();
}
public class ContextMenuItem : IContextMenuNode
{
- public string Name { get; set; }
- public string DisplayName { get; set; }
+ public required string Name { get; set; }
+ public required string DisplayName { get; set; }
public bool Enabled { get; set; } = true;
- public Action OnClick { get; set; }
+ public required Action OnClick { get; set; }
}
public class ContextDummyItem : IContextMenuNode
{
- public string Name { get; set; }
- public string DisplayName { get; set; }
+ public required string Name { get; set; }
+ public required string DisplayName { get; set; }
public bool Enabled { get; set; } = true;
}
public class ContextMenuSeparatorItem : IContextMenuNode
{
- public string Name { get; set; }
- public string DisplayName { get; set; }
+ public required string Name { get; set; }
+ public required string DisplayName { get; set; }
public bool Enabled { get; set; } = true;
}
}
diff --git a/src/OpenPuppet.SDK/Events/IEvent.cs b/src/OpenPuppet.SDK/Events/IEvent.cs
index 3cb306e..3d0475a 100644
--- a/src/OpenPuppet.SDK/Events/IEvent.cs
+++ b/src/OpenPuppet.SDK/Events/IEvent.cs
@@ -22,10 +22,9 @@ public static void Invoke(string registry, object? sender, T e)
public static void Subscribe(string registry, Action callback)
{
- if (RegisteredEvents.TryGetValue(registry, out var existing))
- RegisteredEvents[registry] = existing + callback;
- else
- RegisteredEvents[registry] = callback;
+ RegisteredEvents[registry] = RegisteredEvents.TryGetValue(registry, out var existing)
+ ? existing + callback
+ : callback;
}
public static void Unsubscribe(string registry, Action callback)
diff --git a/src/OpenPuppet.SDK/Exceptions/IUIExceptions.cs b/src/OpenPuppet.SDK/Exceptions/IUIExceptions.cs
index a512405..5e13dca 100644
--- a/src/OpenPuppet.SDK/Exceptions/IUIExceptions.cs
+++ b/src/OpenPuppet.SDK/Exceptions/IUIExceptions.cs
@@ -6,21 +6,17 @@
namespace OpenPuppet.SDK.Exceptions
{
- public class NotImplementedInterfaceException : Exception
- {
- public override string Message { get; }
- public NotImplementedInterfaceException(string message)
- {
- Message = message;
- }
- }
-
- public class NotRegisteredException : Exception
- {
- public override string Message { get; }
- public NotRegisteredException(string message)
- {
- Message = message;
- }
- }
+ ///
+ /// Thrown when the plugin being loaded doesn't implement the interface required.
+ ///
+ /// Extra details
+ public class NotImplementedInterfaceException(string message) : Exception(message)
+ { }
+
+ ///
+ /// Thrown when something is trying to use something that isn't registered.
+ ///
+ /// Extra details
+ public class NotRegisteredException(string message) : Exception(message)
+ { }
}
diff --git a/src/OpenPuppet.SDK/GameObject/VectorGameObject.cs b/src/OpenPuppet.SDK/GameObject/VectorGameObject.cs
index 28ebf57..1fdea0e 100644
--- a/src/OpenPuppet.SDK/GameObject/VectorGameObject.cs
+++ b/src/OpenPuppet.SDK/GameObject/VectorGameObject.cs
@@ -15,7 +15,7 @@
namespace OpenPuppet.SDK.GameObject
{
- public class VectorGameObject : ISceneGameObject where vtx : IVertex
+ public class VectorGameObject : ISceneGameObject where vtxT : IVertex
{
public Guid ID => Guid.NewGuid();
@@ -26,24 +26,24 @@ public class VectorGameObject : ISceneGameObject where vtx : IVertex
public string VectorAssetPath { get; set; } = string.Empty;
[JsonIgnore] public UnifiedVector VectorASTCache { get; set; }
- [JsonIgnore] VertexMesh MeshCache { get; set; }
- [JsonIgnore] Model Model { get; set; } = null!;
+ [JsonIgnore] VertexMesh MeshCache { get; set; }
+ [JsonIgnore] Model Model { get; set; } = null!;
public VectorGameObject(string vectorAssetPath)
{
- this.VectorAssetPath = vectorAssetPath;
+ VectorAssetPath = vectorAssetPath;
if (ProjectManager.ActiveProject != null)
- vectorAssetPath = Path.Combine(ProjectManager.ActiveProject.Directory, vectorAssetPath);
+ vectorAssetPath = Path.Join(ProjectManager.ActiveProject.Directory, vectorAssetPath);
VectorASTCache = IVectorASTComponent.LoadFromDisk(vectorAssetPath);
- MeshCache = VectorMesher.GenerateUnifiedMesh(VectorASTCache);
+ MeshCache = VectorMesher.GenerateUnifiedMesh(VectorASTCache);
}
public unsafe void Draw(GL gl)
{
- if (Model is null) Model = new(gl, MeshCache);
+ Model ??= new(gl, MeshCache);
Model.Bind(gl);
diff --git a/src/OpenPuppet.SDK/IEasingMode.cs b/src/OpenPuppet.SDK/IEasingMode.cs
index bd6ab73..79e9d8f 100644
--- a/src/OpenPuppet.SDK/IEasingMode.cs
+++ b/src/OpenPuppet.SDK/IEasingMode.cs
@@ -17,9 +17,9 @@ public interface IEasingMode
public static void Register(string registry, IEasingMode mode) => EasingModes[registry] = mode;
public static double Ease(string registry, double input, EasingDirection direction)
{
- if (EasingModes.TryGetValue(registry, out var mode))
- return mode.Ease(input, direction);
- else return 0;
+ return EasingModes.TryGetValue(registry, out var mode)
+ ? mode.Ease(input, direction)
+ : 0;
}
public static double Ease(Easing easing, double input) => Ease(easing.Mode, input, easing.Direction);
diff --git a/src/OpenPuppet.SDK/IPlugin.cs b/src/OpenPuppet.SDK/IPlugin.cs
index f6277d9..8b8ddd5 100644
--- a/src/OpenPuppet.SDK/IPlugin.cs
+++ b/src/OpenPuppet.SDK/IPlugin.cs
@@ -1,4 +1,5 @@
-using Newtonsoft.Json;
+using Microsoft.Extensions.DependencyInjection;
+using Newtonsoft.Json;
using OpenPuppet.SDK.Events;
using OpenPuppet.SDK.Plugin;
using OpenPuppet.SDK.Plugins;
@@ -53,19 +54,18 @@ static string PluginPath
{
get
{
- return Path.Combine(InstallPath!, "Plugins");
+ return Path.Join(InstallPath!, "Plugins");
}
}
static string PluginListPath
{
get
{
- return Path.Combine(PluginPath!, "plugins.json");
+ return Path.Join(PluginPath!, "plugins.json");
}
}
public const string PluginID = "";
- public PluginLogger Logger { get; }
public static void RegisterPlugin(PluginMetadata metadata, string path, IPlugin? plugin = null, bool enabled = false)
{
@@ -112,8 +112,8 @@ public static void RemovePlugin(string registry)
public static void LoadPlugin(string id, string path)
{
- string anycpu = Path.Combine(path, "anycpu.dll"),
- specific = Path.Combine(path, $"{RuntimeInformation.ProcessArchitecture}.dll");
+ string anycpu = Path.Join(path, "anycpu.dll"),
+ specific = Path.Join(path, $"{RuntimeInformation.ProcessArchitecture}.dll");
if (File.Exists(specific))
LoadAssembly(specific, id);
@@ -149,8 +149,7 @@ public static void UnloadPlugin(string id, bool soft = false)
}
catch (Exception ex)
{
- SDK.logger.WriteLine(
- ILogger.Level.Error,
+ LogTrace(
$"Plugin \"{id}\" threw an exception during OnShutdown: {ex}"
);
}
@@ -181,10 +180,7 @@ public static void UnloadPlugin(string id, bool soft = false)
if (leaked)
{
- SDK.logger.WriteLine(
- ILogger.Level.Warn,
- $"Could not unload Plugin \"{id}\", possible reference leak"
- );
+ LogWarning($"Could not unload Plugin \"{id}\", possible reference leak");
if (soft)
IEvent.Invoke("openpuppet.restart", null, false);
@@ -196,10 +192,7 @@ public static void UnloadPlugin(string id, bool soft = false)
}
else
{
- SDK.logger.WriteLine(
- ILogger.Level.Log,
- $"Plugin with the ID of \"{id}\" cannot be unloaded, as it is not in an unloadable state"
- );
+ LogInfo($"Plugin with the ID of \"{id}\" cannot be unloaded, as it is not in an unloadable state");
}
}
}
@@ -218,7 +211,8 @@ static void LoadAssembly(string path, string id)
var t = asm.DefinedTypes.Single(t => typeof(IPlugin).IsAssignableFrom(t) && !t.IsAbstract && t.IsAnsiClass);
plugin.Plugin = (IPlugin)Activator.CreateInstance(t.AsType())!;
plugin.State = PluginState.Loaded;
- plugin.Plugin.OnInitialized();
+ plugin.Plugin.OnInitialized(SDK.Services);
+
/*asm.DefinedTypes.Where(t => typeof(IPlugin).IsAssignableFrom(t) && !t.IsAbstract && t.IsClass).ToList().ForEach(t =>
{
var p = (IPlugin)Activator.CreateInstance(t.AsType())!;
@@ -231,11 +225,13 @@ static void LoadAssembly(string path, string id)
}
catch (Exception ex)
{
- SDK.logger.WriteLine(
- ILogger.Level.Warn,
+ LogWarning(
$"Failed to load plugin with ID \"{id}\": {ex.Message}"
);
UnloadPlugin(id);
+
+ ServiceProvider provider = SDK.GetServices().BuildServiceProvider();
+ provider.GetRequiredService().ReportError(ex, []);
}
}
@@ -244,7 +240,7 @@ public static void LoadPluginDirectory(string path, bool enabled = true)
if (!Directory.Exists(path))
throw new ArgumentException($"\"{path}\" does not exist");
- string meta = Path.Combine(path, "meta.inf");
+ string meta = Path.Join(path, "meta.inf");
if (!File.Exists(meta))
throw new ArgumentException($"No metadata present in \"{path}\" (\"{meta}\" does not exist)");
@@ -288,8 +284,7 @@ public static void UninstallPlugin(string id)
}
catch (Exception ex)
{
- SDK.logger.WriteLine(
- ILogger.Level.Warn,
+ LogWarning(
$"Could not fully uninstall plugin with the ID \"{id}\": {ex.Message}"
);
}
@@ -313,7 +308,7 @@ static string SafePluginName(string name)
static string GetPluginPath(string name)
{
if (PluginPath == null) return null!;
- return Path.Combine(PluginPath, SafePluginName(name));
+ return Path.Join(PluginPath, SafePluginName(name));
}
static string GetPluginPath(PluginMetadata metadata)
@@ -329,7 +324,7 @@ static void GenerateDefault()
foreach (var item in Directory.GetDirectories(PluginPath))
{
- string meta = Path.Combine(item, "meta.inf");
+ string meta = Path.Join(item, "meta.inf");
if (!File.Exists(meta))
throw new ArgumentException($"No metadata present in \"{item}\" (\"{meta}\" does not exist)");
@@ -358,8 +353,7 @@ static void GenerateDefault()
var plugins = JsonConvert.DeserializeObject>(File.ReadAllText(PluginListPath));
if (plugins == null)
{
- SDK.logger.WriteLine(
- ILogger.Level.Warn,
+ LogWarning(
"Plugins list is null, rewriting with default values. " +
"The user will need to reinstall plugins."
);
@@ -368,8 +362,7 @@ static void GenerateDefault()
}
else
{
- SDK.logger.WriteLine(
- ILogger.Level.OK,
+ LogInfo(
$"Found {plugins.Count} plugins"
);
@@ -379,12 +372,10 @@ static void GenerateDefault()
}
catch (Exception ex)
{
- SDK.logger.WriteLine(
- ILogger.Level.Error,
+ LogTrace(
$"Failed to load plugins list: " + ex.Message
);
- SDK.logger.WriteLine(
- ILogger.Level.Warn,
+ LogWarning(
"Rewriting plugin list with default values. " +
"The user will need to reinstall plugins."
);
@@ -421,7 +412,7 @@ public static void SavePluginList(Dictionary? list = null)
Plugin method definitions
*/
- void IDisposable.Dispose() { }
+ //void IDisposable.Dispose() { }
///
/// OnInitialized is called when the plugin is loaded.
@@ -432,7 +423,11 @@ void IDisposable.Dispose() { }
/// - Registering dialogs
/// - Registering context menu items
///
- abstract void OnInitialized();
+ ///
+ /// The IServiceCollection, all services provided by this plugin
+ /// must be registered through this.
+ ///
+ abstract void OnInitialized(IServiceCollection services);
///
/// OnShutdown is called when the plugin is unloaded.
@@ -507,7 +502,7 @@ namespace Plugin
{
public class PluginItem
{
- public string Path { get; set; }
+ public required string Path { get; set; }
public bool Enabled { get; set; }
}
diff --git a/src/OpenPuppet.SDK/IUIDialog.cs b/src/OpenPuppet.SDK/IUIDialog.cs
index fd60e2c..a92bc05 100644
--- a/src/OpenPuppet.SDK/IUIDialog.cs
+++ b/src/OpenPuppet.SDK/IUIDialog.cs
@@ -65,8 +65,7 @@ public static void Register(string registry, Type t)
if (t.IsAssignableTo(typeof(IUIDialog)) && t.IsClass)
{
if (RegisteredWindows.ContainsKey(registry))
- SDK.logger.WriteLine(
- Logger.ILogger.Level.Warn,
+ Logger.LogWarning(
$"A dialog with registry: '{registry}' already exists, overriding"
);
diff --git a/src/OpenPuppet.SDK/IUIWindow.cs b/src/OpenPuppet.SDK/IUIWindow.cs
index 1b21f4b..8badcdb 100644
--- a/src/OpenPuppet.SDK/IUIWindow.cs
+++ b/src/OpenPuppet.SDK/IUIWindow.cs
@@ -105,7 +105,7 @@ public static string RegistryFromType(Type t)
string errstring = $"Could not retrieve Registry from {t.FullName}";
- SDK.logger.WriteLine(Logger.ILogger.Level.Error, errstring);
+ Logger.LogTrace(errstring);
throw new Exception(errstring);
}
diff --git a/src/OpenPuppet.SDK/Interfaces/IErrorReporter.cs b/src/OpenPuppet.SDK/Interfaces/IErrorReporter.cs
new file mode 100644
index 0000000..a845240
--- /dev/null
+++ b/src/OpenPuppet.SDK/Interfaces/IErrorReporter.cs
@@ -0,0 +1,31 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace OpenPuppet.SDK
+{
+ ///
+ /// Error reporting service, this should be as an unavoidable dialog popup.
+ ///
+ public interface IErrorReporter : IDisposable
+ {
+ public void ReportError(Exception exception, ErrorReporterAction[] actions);
+
+ public void ReportError(Exception exception, Type type, ErrorReporterAction[] actions);
+
+ public void ReportWarning(string warning, ErrorReporterAction[] actions);
+ }
+
+ public class ErrorReporterAction
+ {
+ public enum ActionType
+ {
+ Retry,
+ Continue,
+ Abort
+ };
+
+ public ActionType Type;
+ public string Command; // TODO: Replace with an actual command link
+ }
+}
diff --git a/src/OpenPuppet.SDK/Interfaces/IProjectManager.cs b/src/OpenPuppet.SDK/Interfaces/IProjectManager.cs
new file mode 100644
index 0000000..ecca175
--- /dev/null
+++ b/src/OpenPuppet.SDK/Interfaces/IProjectManager.cs
@@ -0,0 +1,130 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace OpenPuppet.SDK
+{
+ ///
+ /// The project manager service.
+ ///
+ /// This service provides the tools required for managing the creation, opening, saving
+ /// of projects, and handling the recent projects list.
+ ///
+ public interface IProjectManager : IDisposable
+ {
+ public List RecentProjects { get; }
+
+ /* Also just a note here:
+ * It would be nice if these returned maybe some kind of result,
+ * this could help reference to the project just opened, or provide
+ * some kind of user feedback later in the chain
+ * */
+
+ ///
+ /// Open a project based on project metadata
+ ///
+ /// The project metadata
+ public void OpenProject(Projects.ProjectMetadata meta);
+
+ ///
+ /// Open a project based on a path
+ ///
+ ///
+ /// The path provided should either be a path
+ /// to a directory containing a project file, or a direct
+ /// path to a project file
+ ///
+ /// The path
+ public void OpenProject(string path);
+
+ ///
+ /// Open a project based on an IProjectPath
+ ///
+ /// The IProjectPath
+ public void OpenProject(IProjectPath path);
+
+ ///
+ /// Save a project based on project metadata
+ ///
+ /// The project metadata
+ public void SaveProject(Projects.ProjectMetadata meta);
+
+ ///
+ /// Save a project based on project metadata and a path
+ ///
+ ///
+ /// The path provided should either be a path
+ /// to a directory containing a project file, or a direct
+ /// path to a project file
+ ///
+ /// The project metadata
+ /// The path
+ public void SaveProject(Projects.ProjectMetadata meta, string path);
+
+ ///
+ /// Save a project based on project metadata and an IProjectPath
+ ///
+ /// The project metadata
+ /// The path
+ public void SaveProject(Projects.ProjectMetadata meta, IProjectPath path);
+
+ ///
+ /// Create a project
+ ///
+ ///
+ /// The path provided should either be a path
+ /// to a directory containing a project file, or a direct
+ /// path to a project file
+ ///
+ /// The project name
+ /// The path
+ public void Create(string name, string path);
+
+ ///
+ /// Create a project
+ ///
+ /// The project path
+ /// The path
+ public void Create(string name, IProjectPath path);
+
+ ///
+ /// Asynchronous version of
+ ///
+ public Task OpenProjectAsync(Projects.ProjectMetadata meta, CancellationToken? ct);
+
+ ///
+ /// Asynchronous version of
+ ///
+ public Task OpenProjectAsync(string path, CancellationToken? ct);
+
+ ///
+ /// Asynchronous version of
+ ///
+ public Task OpenProjectAsync(IProjectPath path, CancellationToken? ct);
+
+ ///
+ /// Asynchronous version of
+ ///
+ public Task SaveProjectAsync(Projects.ProjectMetadata meta, CancellationToken? ct);
+
+ ///
+ /// Asynchronous version of
+ ///
+ public Task SaveProjectAsync(Projects.ProjectMetadata meta, string path, CancellationToken? ct);
+
+ ///
+ /// Asynchronous version of
+ ///
+ public Task SaveProjectAsync(Projects.ProjectMetadata meta, IProjectPath path, CancellationToken? ct);
+
+ ///
+ /// Asynchronous version of
+ ///
+ public Task CreateAsync(string name, string path, CancellationToken? ct);
+
+ ///
+ /// Asynchronous version of
+ ///
+ public Task CreateAsync(string name, IProjectPath path, CancellationToken? ct);
+ }
+}
diff --git a/src/OpenPuppet.SDK/Interfaces/IProjectPath.cs b/src/OpenPuppet.SDK/Interfaces/IProjectPath.cs
new file mode 100644
index 0000000..5723bb3
--- /dev/null
+++ b/src/OpenPuppet.SDK/Interfaces/IProjectPath.cs
@@ -0,0 +1,25 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace OpenPuppet.SDK
+{
+ ///
+ /// The IProjectPath is an interface for extendability reasons,
+ /// it provides very basic utilities.
+ ///
+ public interface IProjectPath : IDisposable
+ {
+ ///
+ /// Get the base directory of the project
+ ///
+ /// The very base directory path
+ public string GetDirectory();
+
+ ///
+ /// Get the project configuration file path
+ ///
+ /// The project file
+ public string GetProjctFilePath();
+ }
+}
diff --git a/src/OpenPuppet.SDK/Logger.cs b/src/OpenPuppet.SDK/Logger.cs
index ff89c07..5f96b5a 100644
--- a/src/OpenPuppet.SDK/Logger.cs
+++ b/src/OpenPuppet.SDK/Logger.cs
@@ -1,15 +1,17 @@
using System.Diagnostics;
+using System.Globalization;
using System.Reflection;
+using System.Runtime.CompilerServices;
namespace OpenPuppet.SDK
{
- public static class Logger
+ /*public static class Logger
{
internal static string? LocalPath
{
get
{
- return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "OpenPuppet");
+ return Path.Join(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "OpenPuppet");
}
}
@@ -17,7 +19,7 @@ public static string? LogPath
{
get
{
- return LocalPath != null ? Path.Combine(LocalPath, "Logs") : null;
+ return LocalPath != null ? Path.Join(LocalPath, "Logs") : null;
}
}
@@ -25,12 +27,12 @@ public static class LogManager
{
public static string RequestPluginLogFile(string pluginName)
{
- if (!Directory.Exists(Path.Combine(LogPath!, IPlugin.SafePluginName(pluginName))))
+ if (!Directory.Exists(Path.Join(LogPath!, IPlugin.SafePluginName(pluginName))))
{
- Directory.CreateDirectory(Path.Combine(LogPath!, IPlugin.SafePluginName(pluginName)));
+ Directory.CreateDirectory(Path.Join(LogPath!, IPlugin.SafePluginName(pluginName)));
}
- string path = Path.Combine(
+ string path = Path.Join(
LogPath!,
IPlugin.SafePluginName(pluginName),
DateTime.Now.ToString("dd'-'MM'-'yyyy'.txt'")
@@ -145,5 +147,96 @@ public void Dispose()
//FileStream.Dispose();
}
}
+ }*/
+
+ public static class Logger
+ {
+ private static readonly AsyncLocal Source = new();
+ private static readonly string Version = Assembly.GetExecutingAssembly().GetCustomAttribute()?.Version ?? "Unknown";
+
+ public static string CurrentVerLogDirPath { get; private set; }
+ public static string CurrentLogFile { get; private set; }
+ public static string AppLogDirPath { get; private set; }
+
+ public static void InitLogger(string appLogPath, bool console = false)
+ {
+ string versionedPath = Path.Join(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "OpenPuppet", appLogPath, Version);
+ string basePath = Path.GetDirectoryName(versionedPath);
+
+ if (!Directory.Exists(versionedPath))
+ {
+ Directory.CreateDirectory(versionedPath);
+ }
+
+ AppLogDirPath = basePath;
+ CurrentVerLogDirPath = versionedPath;
+
+ var logFile = $"Log_{DateTime.Now.ToString(@"yyyy-MM-dd", CultureInfo.InvariantCulture)}.log";
+ var logFilePath = Path.Join(versionedPath, logFile);
+ CurrentLogFile = logFilePath;
+
+ Source.Value = appLogPath;
+
+ Trace.Listeners.Add(new TextWriterTraceListener(logFilePath));
+ if (console)
+ {
+ Trace.Listeners.Add(new ConsoleTraceListener());
+ }
+ Trace.AutoFlush = true;
+ }
+
+ private static string GetCallerInfo(string memberName, string sourceFilePath, int sourceLineNumber)
+ {
+ string callerFileName = "Unknown";
+ try
+ {
+ string fileName = Path.GetFileName(sourceFilePath);
+ if (!string.IsNullOrEmpty(fileName))
+ {
+ callerFileName = fileName;
+ }
+ }
+ catch (Exception)
+ {
+ callerFileName = "Unknown";
+ throw;
+ }
+
+ return $"{callerFileName}::{memberName}::{sourceLineNumber}";
+ }
+
+ private static void Log(string msg, string type, string memberName, string sourceFilePath, int sourceLineNumber)
+ {
+ var source = Source.Value ?? "Unknown";
+ Trace.WriteLine($"{source} [{DateTime.Now.TimeOfDay} {DateTime.Now.ToString(@"yyyy-MM-dd", CultureInfo.InvariantCulture)}] [{type}] {GetCallerInfo(memberName, sourceFilePath, sourceLineNumber)}");
+ if (msg != string.Empty)
+ {
+ Trace.Indent();
+ Trace.WriteLine(msg);
+ Trace.Unindent();
+ }
+ }
+
+ public static void LogWarning(string msg, [CallerMemberName] string memberName = "", [CallerFilePath] string sourceFilePath = "", [CallerLineNumber] int sourceLineNumber = 0)
+ {
+ Log(msg, "Warning", memberName, sourceFilePath, sourceLineNumber);
+ }
+
+ public static void LogInfo(string msg, [CallerMemberName] string memberName = "", [CallerFilePath] string sourceFilePath = "", [CallerLineNumber] int sourceLineNumber = 0)
+ {
+ Log(msg, "Info", memberName, sourceFilePath, sourceLineNumber);
+ }
+
+ public static void LogTrace(string msg, [CallerMemberName] string memberName = "", [CallerFilePath] string sourceFilePath = "", [CallerLineNumber] int sourceLineNumber = 0)
+ {
+ Log(msg, "Trace", memberName, sourceFilePath, sourceLineNumber);
+ }
+
+ public static void LogDebug(string msg, [CallerMemberName] string memberName = "", [CallerFilePath] string sourceFilePath = "", [CallerLineNumber] int sourceLineNumber = 0)
+ {
+#if DEBUG
+ Log(msg, "Debug", memberName, sourceFilePath, sourceLineNumber);
+#endif
+ }
}
}
\ No newline at end of file
diff --git a/src/OpenPuppet.SDK/ObservableServiceCollection.cs b/src/OpenPuppet.SDK/ObservableServiceCollection.cs
new file mode 100644
index 0000000..935d8da
--- /dev/null
+++ b/src/OpenPuppet.SDK/ObservableServiceCollection.cs
@@ -0,0 +1,41 @@
+using Microsoft.Extensions.DependencyInjection;
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Text;
+
+namespace OpenPuppet.SDK
+{
+ // See: https://github.com/dotnet/runtime/discussions/128166#discussioncomment-16911648
+ public class ObservableServiceCollection : Collection, IServiceCollection
+ {
+ public event Action? OnAdded;
+ public event Action? OnReplaced;
+ public event Action? OnRemoved;
+ public event Action? OnCleared;
+
+ protected override void InsertItem(int index, ServiceDescriptor item)
+ {
+ OnAdded?.Invoke(item);
+ base.InsertItem(index, item);
+ }
+
+ protected override void SetItem(int index, ServiceDescriptor item)
+ {
+ OnReplaced?.Invoke(this[index], item);
+ base.SetItem(index, item);
+ }
+
+ protected override void RemoveItem(int index)
+ {
+ OnRemoved?.Invoke(this[index]);
+ base.RemoveItem(index);
+ }
+
+ protected override void ClearItems()
+ {
+ OnCleared?.Invoke();
+ base.ClearItems();
+ }
+ }
+}
diff --git a/src/OpenPuppet.SDK/OpenPuppet.SDK.csproj b/src/OpenPuppet.SDK/OpenPuppet.SDK.csproj
index 0f43c79..36431d1 100644
--- a/src/OpenPuppet.SDK/OpenPuppet.SDK.csproj
+++ b/src/OpenPuppet.SDK/OpenPuppet.SDK.csproj
@@ -8,6 +8,8 @@
+
+
diff --git a/src/OpenPuppet.SDK/Plugins/PluginLoadContext.cs b/src/OpenPuppet.SDK/Plugins/PluginLoadContext.cs
index 8854586..2bf5a4b 100644
--- a/src/OpenPuppet.SDK/Plugins/PluginLoadContext.cs
+++ b/src/OpenPuppet.SDK/Plugins/PluginLoadContext.cs
@@ -24,10 +24,9 @@ public PluginLoadContext(string path)
return null;
var path = _resolver.ResolveAssemblyToPath(assemblyName);
- if (path != null)
- return LoadFromAssemblyPath(path);
- else
- return null;
+ return path != null
+ ? LoadFromAssemblyPath(path)
+ : null;
//return path is null ? null : LoadFromAssemblyPath(path);
}
diff --git a/src/OpenPuppet.SDK/Projects/ProjectPath.cs b/src/OpenPuppet.SDK/Projects/ProjectPath.cs
new file mode 100644
index 0000000..5a1ef2e
--- /dev/null
+++ b/src/OpenPuppet.SDK/Projects/ProjectPath.cs
@@ -0,0 +1,54 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace OpenPuppet.SDK.Projects
+{
+ ///
+ /// The default implementation of IProjectPath
+ ///
+ public class ProjectPath : IProjectPath
+ {
+ private readonly string ProjectBase;
+ private readonly string ProjectFile;
+
+ public ProjectPath(string path)
+ {
+ if(File.Exists(path))
+ {
+ ProjectBase = Path.GetDirectoryName(path)!;
+ ProjectFile = path;
+ } else if(Directory.Exists(path))
+ {
+ ProjectBase = path;
+ string file = Path.Join(path, new DirectoryInfo(path).Name + ".opp");
+ if(File.Exists(file))
+ {
+ ProjectFile = file;
+ } else
+ {
+ throw new FileNotFoundException(
+ $"Couldn't find a part of the path \"{file}\""
+ );
+ }
+ } else
+ {
+ throw new DirectoryNotFoundException(
+ $"Couldn't find a part of the path \"{path}\""
+ );
+ }
+ }
+
+ public ProjectPath(FileInfo file) : this(file.FullName)
+ { }
+
+ public ProjectPath(DirectoryInfo dir) : this(dir.FullName)
+ { }
+
+ public string GetDirectory() => ProjectBase;
+
+ public string GetProjctFilePath() => ProjectFile;
+
+ public void Dispose() { }
+ }
+}
diff --git a/src/OpenPuppet.SDK/SDK.cs b/src/OpenPuppet.SDK/SDK.cs
index d5ba275..4d0f1f3 100644
--- a/src/OpenPuppet.SDK/SDK.cs
+++ b/src/OpenPuppet.SDK/SDK.cs
@@ -1,4 +1,5 @@
-using System;
+using Microsoft.Extensions.DependencyInjection;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -8,13 +9,65 @@ namespace OpenPuppet.SDK
{
public static class SDK
{
- internal static readonly Logger.PluginLogger logger = Logger.LogManager.RequestPluginLogger("com.openpuppet.sdk");
+ public static string LocalDataPath = Path.Join(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "OpenPuppet");
+ public static string DataPath = Path.Join(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "OpenPuppet");
- public static void DestroyLogger() => logger?.Dispose();
+ public static SafeTypeBinder JsonTypeBinder { get; } = new();
- public static string LocalDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "OpenPuppet");
- public static string DataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "OpenPuppet");
+ internal static ObservableServiceCollection Services { get; } = [];
+ internal static ServiceProvider Provider { get; private set; } = Services.BuildServiceProvider();
- public static SafeTypeBinder JsonTypeBinder { get; } = new();
+ public static ServiceProvider GetProvider()
+ {
+ return Provider;
+ }
+
+ public static ObservableServiceCollection GetServices()
+ {
+ return Services;
+ }
+
+ public static void Init()
+ {
+ Services.OnAdded += Services_OnAdded;
+ Services.OnCleared += Services_OnCleared;
+ Services.OnRemoved += Services_OnRemoved;
+ Services.OnReplaced += Services_OnReplaced;
+ }
+
+ private static void Services_OnReplaced(ServiceDescriptor arg1, ServiceDescriptor arg2)
+ {
+ Logger.LogDebug($"Service {arg1} replaced with {arg2}");
+
+ RebuildServiceProvider();
+ }
+
+ private static void Services_OnRemoved(ServiceDescriptor obj)
+ {
+ Logger.LogDebug($"Service {obj} removed");
+
+ RebuildServiceProvider();
+ }
+
+ private static void Services_OnCleared()
+ {
+ Logger.LogDebug($"Services cleared");
+
+ RebuildServiceProvider();
+ }
+
+ private static void Services_OnAdded(ServiceDescriptor obj)
+ {
+ Logger.LogDebug($"Service {obj} added");
+
+ RebuildServiceProvider();
+ }
+
+ public static void RebuildServiceProvider()
+ {
+ Logger.LogInfo("Rebuilding service provider");
+ Provider = Services.BuildServiceProvider();
+ Logger.LogDebug("Rebuilt service provider successfully");
+ }
}
}
diff --git a/src/OpenPuppet.SDK/TimelineTracks/PropertyTimeline.cs b/src/OpenPuppet.SDK/TimelineTracks/PropertyTimeline.cs
index 0ad7467..df7f47a 100644
--- a/src/OpenPuppet.SDK/TimelineTracks/PropertyTimeline.cs
+++ b/src/OpenPuppet.SDK/TimelineTracks/PropertyTimeline.cs
@@ -38,7 +38,7 @@ public SceneMetadata Scene
Action SetValue;
[JsonConstructor]
- public PropertyTimeline(Guid holder, SceneMetadata scene, string name, string property)
+ public PropertyTimeline(Guid holder, SceneMetadata scene, string name, string property) // TODO: Fix CS8618
{
Name = name;
HolderID = holder;
@@ -76,7 +76,7 @@ public void MoveKeyframe(TimeSpan timestamp, TimeSpan newFrame)
{
if (!Keyframes.TryGetValue(timestamp, out var keyframeValue)) return;
- if(KeyframeEasings.TryGetValue(timestamp, out var val))
+ if (KeyframeEasings.TryGetValue(timestamp, out var val))
{
KeyframeEasings[newFrame] = val;
KeyframeEasings.Remove(timestamp);
@@ -136,11 +136,12 @@ public void Mutate(TimeSpan timestamp)
public bool KeyframeInRange(TimeSpan range, out TimeSpan keyframe, float radius = 12)
{
var result = Keyframes.Where(k => Math.Abs((k.Key - range).TotalMilliseconds) <= radius);
- if(result.Any())
+ if (result.Any())
{
keyframe = result.Single().Key;
return true;
- } else
+ }
+ else
{
keyframe = default;
return false;
diff --git a/src/OpenPuppet.SDK/Translation/ITranslation.cs b/src/OpenPuppet.SDK/Translation/ITranslation.cs
new file mode 100644
index 0000000..4932df6
--- /dev/null
+++ b/src/OpenPuppet.SDK/Translation/ITranslation.cs
@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace OpenPuppet.SDK.Translation
+{
+ ///
+ /// The base class that all translation classes extend from.
+ ///
+ /// This sets out the base for all translation strings.
+ ///
+ public interface ITranslation
+ {
+ public string ToString();
+ }
+}
diff --git a/src/OpenPuppet.SDK/Translation/ITranslationUnit.cs b/src/OpenPuppet.SDK/Translation/ITranslationUnit.cs
new file mode 100644
index 0000000..a52e4e1
--- /dev/null
+++ b/src/OpenPuppet.SDK/Translation/ITranslationUnit.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace OpenPuppet.SDK.Translation
+{
+ ///
+ /// This interface is the base for translation units.
+ ///
+ /// A translation unit is typically a per-plugin thing, where a plugin
+ /// can register its own translations for the languages that it supports,
+ /// and the translator can relay this data to the settings.
+ ///
+ public interface ITranslationUnit
+ {
+ }
+}
diff --git a/src/OpenPuppet.SDK/Translation/ITranslator.cs b/src/OpenPuppet.SDK/Translation/ITranslator.cs
new file mode 100644
index 0000000..cc3c112
--- /dev/null
+++ b/src/OpenPuppet.SDK/Translation/ITranslator.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace OpenPuppet.SDK.Translation
+{
+ ///
+ /// The base of the translator
+ ///
+ public interface ITranslator
+ {
+
+ }
+}
diff --git a/src/OpenPuppet.SDK/rendering/IVertex.cs b/src/OpenPuppet.SDK/rendering/IVertex.cs
index 20abf81..c779eac 100644
--- a/src/OpenPuppet.SDK/rendering/IVertex.cs
+++ b/src/OpenPuppet.SDK/rendering/IVertex.cs
@@ -16,18 +16,11 @@ public interface IVertex where TSelf : IVertex
public static abstract List FromGeneralData(List vecs);
}
- public struct GeneralVertexData
+ public struct GeneralVertexData(Vector3 position, Vector3 normal, Vector2 uv, Vector4 color)
{
- public Vector3 Position;
- public Vector3 Normal;
- public Vector2 UV;
- public Vector4 Color;
- public GeneralVertexData(Vector3 position, Vector3 normal, Vector2 uv, Vector4 color)
- {
- Position = position;
- Normal = normal;
- UV = uv;
- Color = color;
- }
+ public Vector3 Position = position;
+ public Vector3 Normal = normal;
+ public Vector2 UV = uv;
+ public Vector4 Color = color;
}
}
diff --git a/src/OpenPuppet.SDK/rendering/RenderSurface.cs b/src/OpenPuppet.SDK/rendering/RenderSurface.cs
index e1b80dc..a6ac396 100644
--- a/src/OpenPuppet.SDK/rendering/RenderSurface.cs
+++ b/src/OpenPuppet.SDK/rendering/RenderSurface.cs
@@ -11,6 +11,7 @@ namespace OpenPuppet.rendering
{
public class RenderSurface
{
+ // TODO: Fix whatever CS8618 is complaining about
static GL _gl;
public static List Surfaces { get; } = new();
diff --git a/src/OpenPuppet.SDK/rendering/VertexMesh.cs b/src/OpenPuppet.SDK/rendering/VertexMesh.cs
index 2791f64..d5c5798 100644
--- a/src/OpenPuppet.SDK/rendering/VertexMesh.cs
+++ b/src/OpenPuppet.SDK/rendering/VertexMesh.cs
@@ -8,13 +8,13 @@ namespace OpenPuppet.rendering
{
public class VertexMesh(List verticies, List indicies) where T : IVertex
{
- public T[] Verticies { get; } = verticies.ToArray();
- public int[] Indices { get; } = indicies.ToArray();
+ public T[] Verticies { get; } = [.. verticies];
+ public int[] Indices { get; } = [.. indicies];
public static VertexMesh Unify(IEnumerable> meshes)
{
- List verticies = new();
- List indicies = new();
+ List verticies = [];
+ List indicies = [];
int offset = 0;
foreach (var mesh in meshes)
{
diff --git a/src/OpenPuppet.SDK/rendering/VertexPropLayer.cs b/src/OpenPuppet.SDK/rendering/VertexPropLayer.cs
index 450f24a..32169cb 100644
--- a/src/OpenPuppet.SDK/rendering/VertexPropLayer.cs
+++ b/src/OpenPuppet.SDK/rendering/VertexPropLayer.cs
@@ -14,7 +14,6 @@ public struct VertexPropLayer(int count, VertexAttribPointerType type, bool norm
public bool Normalize { get; set; } = normalized;
public int SizeInBytes { get; private set; } = GatherSize(type) * count;
-
static int GatherSize(VertexAttribPointerType type)
{
return type switch
diff --git a/src/OpenPuppet.SDK/rendering/VertexTypes/ColorVertex.cs b/src/OpenPuppet.SDK/rendering/VertexTypes/ColorVertex.cs
index 8ae668b..7306091 100644
--- a/src/OpenPuppet.SDK/rendering/VertexTypes/ColorVertex.cs
+++ b/src/OpenPuppet.SDK/rendering/VertexTypes/ColorVertex.cs
@@ -10,7 +10,7 @@
namespace OpenPuppet.rendering.VertexTypes
{
[StructLayout(LayoutKind.Sequential)]
- public unsafe record struct ColorVertex(Vector3 Position, Vector4 color) : IVertex
+ public unsafe record struct ColorVertex(Vector3 Position, Vector4 Color) : IVertex
{
public static uint Size { get; set; } = (uint)sizeof(Vector3) + (uint)sizeof(Vector4);
public static VertexPropLayer[] PropLayers { get; set; } =
diff --git a/src/OpenPuppet.SDK/vector/IVectorASTComponent.cs b/src/OpenPuppet.SDK/vector/IVectorASTComponent.cs
index 812d636..accb718 100644
--- a/src/OpenPuppet.SDK/vector/IVectorASTComponent.cs
+++ b/src/OpenPuppet.SDK/vector/IVectorASTComponent.cs
@@ -483,9 +483,8 @@ public List Flatten(double Y) =>
double[] candidates = { alpha + acos, alpha - acos };
- foreach (var t in candidates)
+ foreach (var t in candidates.Where(IsInArc))
{
- if (!IsInArc(t)) continue;
var (px, _) = EllipsePoint(t);
results.Add((new Vector3((float)px, (float)Y, 0f), EllipseNormal(t)));
}
@@ -537,9 +536,8 @@ public List Flatten(double Y) =>
var roots = SolveCubic(a, b, c, d);
var results = new List<(Vector3 point, Vector3 normal)>();
- foreach (var t in roots)
+ foreach (var t in roots.Where((p) => !(p < 0 || p > 1)))
{
- if (t < 0 || t > 1) continue;
double x = Math.Pow(1 - t, 3) * Origin.X
+ 3 * Math.Pow(1 - t, 2) * t * Control1.X
+ 3 * (1 - t) * t * t * Control2.X
@@ -664,9 +662,8 @@ public List Flatten(double Y) =>
var roots = SolveQuadratic(a, b, c);
var results = new List<(Vector3 point, Vector3 normal)>();
- foreach (var t in roots)
+ foreach (var t in roots.Where((p) => !(p < 0 || p > 1)))
{
- if (t < 0 || t > 1) continue;
double x = Math.Pow(1 - t, 2) * Origin.X
+ 2 * (1 - t) * t * Control.X
+ t * t * Destination.X;
diff --git a/src/OpenPuppet.SDK/vector/VectorMesher.cs b/src/OpenPuppet.SDK/vector/VectorMesher.cs
index bb3a53d..7ca1e83 100644
--- a/src/OpenPuppet.SDK/vector/VectorMesher.cs
+++ b/src/OpenPuppet.SDK/vector/VectorMesher.cs
@@ -24,7 +24,7 @@ public static VertexMesh GenerateUnifiedMesh(
}
public static VertexMesh GenerateMesh(
- IVectorASTComponent ASTComponent,
+ IVectorASTComponent ASTComponent,
IVectorColorSampler colorSampler,
uint density = 200
) where T : IVertex
@@ -157,12 +157,12 @@ public static VertexMesh GenerateMesh(
return new(
T.FromGeneralData(
- prototype.Positions.Select(
+ [.. prototype.Positions.Select(
x => new GeneralVertexData(
- x, Vector3.Zero, Vector2.Zero,
+ x, Vector3.Zero, Vector2.Zero,
colorSampler.SampleColor(x)
)
- ).ToList()
+ )]
), idx
);
}
diff --git a/src/OpenPuppet.SDK/vector/VectorScreen.cs b/src/OpenPuppet.SDK/vector/VectorScreen.cs
index 596fe07..205edd4 100644
--- a/src/OpenPuppet.SDK/vector/VectorScreen.cs
+++ b/src/OpenPuppet.SDK/vector/VectorScreen.cs
@@ -11,5 +11,14 @@ public struct VectorScreen
{
public Vector2 Viewbox { get; set; }
public Vector2 Scale { get; set; }
+
+ public VectorScreen()
+ { }
+
+ public VectorScreen(Vector2 viewbox, Vector2 scale)
+ {
+ Viewbox = viewbox;
+ Scale = scale;
+ }
}
}
diff --git a/src/OpenPuppet.Tests/Plugins/Path.cs b/src/OpenPuppet.Tests/Plugins/Path.cs
index 52df212..7b82b94 100644
--- a/src/OpenPuppet.Tests/Plugins/Path.cs
+++ b/src/OpenPuppet.Tests/Plugins/Path.cs
@@ -26,7 +26,7 @@ public void TestPluginName()
public void TestPluginPath()
{
Assert.Equal(
- System.IO.Path.Combine(IPlugin.PluginPath!, IPlugin.SafePluginName("a-b-c-d")),
+ System.IO.Path.Join(IPlugin.PluginPath!, IPlugin.SafePluginName("a-b-c-d")),
IPlugin.GetPluginPath(
@"a B
`¦¬!" + '"' + @"@£$%^&*()_+-=[]{};:'@#~,/<>?\| C d"
diff --git a/src/OpenPuppet/Program.cs b/src/OpenPuppet/Program.cs
index fdfcceb..10f599e 100644
--- a/src/OpenPuppet/Program.cs
+++ b/src/OpenPuppet/Program.cs
@@ -41,20 +41,21 @@ class Program
static ImGuiController cont = null;
- public static readonly Logger.PluginLogger logger = Logger.LogManager.RequestPluginLogger("openpuppet");
-
// Just so we can see how long it takes for it to start up
internal static Stopwatch startupSW;
static void Main(string[] args)
{
+ Logger.InitLogger("openpuppet.runner", true);
+
+ SDK.SDK.Init();
+
if (args.Length > 0)
{
if (args[0] == "clean")
{
- logger.Dispose();
- if (Directory.Exists(Logger.LogPath))
- Directory.Delete(Logger.LogPath, true);
+ if (Directory.Exists(Logger.AppLogDirPath))
+ Directory.Delete(Logger.AppLogDirPath, true);
Environment.Exit(0);
}
}
@@ -86,7 +87,7 @@ static void Main(string[] args)
if (soft) SoftRestart();
else
{
- logger.WriteLine($"Launching {Assembly.GetExecutingAssembly().Location.Replace(".dll", ".exe")}");
+ Logger.LogDebug($"Launching {Assembly.GetExecutingAssembly().Location.Replace(".dll", ".exe")}");
window.Close();
Process.Start(Assembly.GetExecutingAssembly().Location.Replace(".dll", ".exe"));
Environment.Exit(0);
@@ -102,22 +103,44 @@ static void Main(string[] args)
}
catch (Exception ex)
{
- logger.WriteLine(
- Logger.ILogger.Level.Error,
+ Logger.LogTrace(
$"Exception occurred while running main window: {ex.Message} ({ex.GetType()})"
);
+ Logger.LogInfo(
+ "An exception at this level is irrecoverable, the application will " +
+ "automatically attempt to restart"
+ );
+
if (ex.GetType() == typeof(Silk.NET.GLFW.GlfwException))
{
// Temporary message
- logger.WriteLine(
- Logger.ILogger.Level.Warn,
+ Logger.LogWarning(
"The above exception may occur if you are using an extremely low-end " +
"GPU, or integrated graphics. If you have multiple GPUs, please modify " +
"the operating system settings to ensure that OpenPuppet uses the " +
"correct GPU."
);
}
+
+ foreach (var plugin in IPlugin.RegisteredPlugins)
+ {
+ try
+ {
+ IPlugin.UnloadPlugin(plugin.Key);
+ } catch
+ {
+ IPlugin.DisablePlugin(plugin.Key);
+ }
+ }
+
+ string path = Environment.ProcessPath; //Assembly.GetEntryAssembly().Location;
+ Logger.LogDebug($"Starting {path}");
+ ProcessStartInfo start = new(path);
+ start.ArgumentList.Add("--recovered-from-crash");
+ Process.Start(start);
+
+ Environment.Exit(1);
}
}
@@ -138,7 +161,7 @@ static void Load()
LoadPlugins();
startupSW.Stop();
- logger.WriteLine(Logger.ILogger.Level.OK, $"Started up in {startupSW.Elapsed}");
+ Logger.LogDebug($"Started up in {startupSW.Elapsed}");
}
static void Update(double deltaSeconds)
{
@@ -294,15 +317,11 @@ static void Closing()
}
catch (Exception ex)
{
- logger.WriteLine(
- Logger.ILogger.Level.Warn,
+ Logger.LogWarning(
$"\"{plugin.Key}\" failed to shut down: {ex.Message}"
);
}
}
-
- SDK.SDK.DestroyLogger();
- logger.Dispose();
}
static void LoadPlugins()
@@ -347,7 +366,7 @@ static void LoadPlugins()
static void SoftRestart()
{
- logger.WriteLine("Starting soft restart");
+ Logger.LogDebug("Starting soft restart");
ContextMenu.Root.Nodes.Clear();
IUIWindow.CloseAll();
@@ -364,8 +383,7 @@ static void SoftRestart()
}
catch (Exception ex)
{
- logger.WriteLine(
- Logger.ILogger.Level.Warn,
+ Logger.LogTrace(
$"\"{plugin.Key}\" failed to shut down: {ex.Message}"
);
}
@@ -375,7 +393,7 @@ static void SoftRestart()
LoadPlugins();
- logger.WriteLine("Finished soft restart");
+ Logger.LogDebug("Finished soft restart");
}
}
}
\ No newline at end of file
diff --git a/src/OpenPuppet/postbuild.bat b/src/OpenPuppet/postbuild.bat
index b306265..4ab50e5 100644
--- a/src/OpenPuppet/postbuild.bat
+++ b/src/OpenPuppet/postbuild.bat
@@ -1,7 +1,7 @@
@echo off
:: This script will be run after every build
set "config=%1"
-set "base=..\..\bin\%config%\net9.0"
+set "base=..\..\bin\%config%\net10.0"
set "plugins=%base%\Plugins"
set "sources=..\Plugins"
@@ -28,11 +28,11 @@ FOR /D %%D IN ("%sources%\*") DO (
)
:: Copy all build output
- xcopy "%%D\bin\%config%\net9.0" "%plugins%\%%~nxD" /E /I /Y >nul
+ xcopy "%%D\bin\%config%\net10.0" "%plugins%\%%~nxD" /E /I /Y >nul
:: Copy the plugin's main DLL renamed to anycpu.dll
- if exist "%%D\bin\%config%\net9.0\%%~nxD.dll" (
- copy /Y "%%D\bin\%config%\net9.0\%%~nxD.dll" "%plugins%\%%~nxD\anycpu.dll" >nul
+ if exist "%%D\bin\%config%\net10.0\%%~nxD.dll" (
+ copy /Y "%%D\bin\%config%\net10.0\%%~nxD.dll" "%plugins%\%%~nxD\anycpu.dll" >nul
) else (
echo WARNING: could not find %%~nxD.dll to copy as anycpu.dll
)
diff --git a/src/Plugins/OpenPuppet.Core/Dialogs/ErrorDialog.cs b/src/Plugins/OpenPuppet.Core/Dialogs/ErrorDialog.cs
new file mode 100644
index 0000000..e9f16bc
--- /dev/null
+++ b/src/Plugins/OpenPuppet.Core/Dialogs/ErrorDialog.cs
@@ -0,0 +1,67 @@
+using ImGuiNET;
+using OpenPuppet.SDK;
+using System;
+using System.Collections.Generic;
+using System.Numerics;
+using System.Text;
+
+namespace OpenPuppet.Core.Dialogs
+{
+ public class ErrorDialog : IUIDialog
+ {
+ public string Title { get; set; } = "Error";
+ public ImGuiWindowFlags? Flags { get; set; } = null;
+ public Vector2? Size { get; set; } = null;
+
+ private bool error = false;
+
+ private Exception? ex;
+ private string? msg;
+
+ public void OnLoad()
+ {
+
+ }
+
+ public void OnPreRender()
+ {
+
+ }
+
+ public void OnRender()
+ {
+ if(ex == null && msg == null)
+ {
+ ImGui.Text("One sec...");
+ return;
+ }
+
+ if (error) ImGui.TextColored(new(255, 0, 0, 255), "Error");
+ else ImGui.TextColored(new(128, 128, 0, 255), "Warning");
+
+ ImGui.Text(ex?.ToString() ?? msg ?? "");
+ }
+
+ public void OnClose()
+ {
+
+ }
+
+ public void RelayError(Exception ex)
+ {
+ this.ex = ex;
+ error = true;
+ }
+
+ public void RelayError(string err)
+ {
+ msg = err;
+ error = true;
+ }
+
+ public void RelayWarning(string warning)
+ {
+ msg = warning;
+ }
+ }
+}
diff --git a/src/Plugins/OpenPuppet.Core/ErrorReporter.cs b/src/Plugins/OpenPuppet.Core/ErrorReporter.cs
new file mode 100644
index 0000000..29fc6ef
--- /dev/null
+++ b/src/Plugins/OpenPuppet.Core/ErrorReporter.cs
@@ -0,0 +1,39 @@
+using OpenPuppet.SDK;
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace OpenPuppet.Core
+{
+ public class ErrorReporter : IErrorReporter
+ {
+ public void ReportError(Exception exception, ErrorReporterAction[] actions)
+ {
+ IUIDialog.Open("openpuppet.core.error");
+ var dialog = IUIDialog.ActiveDialog;
+ var error = dialog as Dialogs.ErrorDialog;
+ error?.RelayError(exception);
+ }
+
+ public void ReportError(Exception exception, Type type, ErrorReporterAction[] actions)
+ {
+ IUIDialog.Open("openpuppet.core.error");
+ var dialog = IUIDialog.ActiveDialog;
+ var error = dialog as Dialogs.ErrorDialog;
+ error?.RelayError(exception);
+ }
+
+ public void ReportWarning(string warning, ErrorReporterAction[] actions)
+ {
+ IUIDialog.Open("openpuppet.core.error");
+ var dialog = IUIDialog.ActiveDialog;
+ var error = dialog as Dialogs.ErrorDialog;
+ error?.RelayWarning(warning);
+ }
+
+ public void Dispose()
+ {
+
+ }
+ }
+}
diff --git a/src/Plugins/OpenPuppet.Core/Plugin.cs b/src/Plugins/OpenPuppet.Core/Plugin.cs
index b4501e5..ba56322 100644
--- a/src/Plugins/OpenPuppet.Core/Plugin.cs
+++ b/src/Plugins/OpenPuppet.Core/Plugin.cs
@@ -1,4 +1,5 @@
using ImGuiNET;
+using Microsoft.Extensions.DependencyInjection;
using Newtonsoft.Json;
using OpenPuppet.Core.Dialogs;
using OpenPuppet.Core.Mutators;
@@ -19,14 +20,14 @@ public class Plugin : IPlugin
{
public const string PluginID = "com.openpuppet.core";
- public Logger.PluginLogger Logger { get; internal set; } = SDK.Logger.LogManager.RequestPluginLogger(PluginID);
-
private bool shutdown = false;
- public void OnInitialized()
+ public void OnInitialized(IServiceCollection services)
{
+ SDK.Logger.InitLogger(PluginID);
+
Global.MainPlugin = this;
- Logger.WriteLine(SDK.Logger.ILogger.Level.Log, "Hello Core");
+ Logger.LogInfo("Hello Core");
SDK.SDK.JsonTypeBinder.AllowedAssemblies.Add(Assembly.GetExecutingAssembly());
@@ -36,10 +37,10 @@ public void OnInitialized()
IMutator.RegisterMutator(typeof(Color3Mutator));
IMutator.RegisterMutator(typeof(Color4Mutator));
- if (!File.Exists(Path.Combine(SDK.SDK.DataPath, "projcache")))
- File.WriteAllText(Path.Combine(SDK.SDK.DataPath, "projcache"), "");
+ if (!File.Exists(Path.Join(SDK.SDK.DataPath, "projcache")))
+ File.WriteAllText(Path.Join(SDK.SDK.DataPath, "projcache"), "");
- Projects.RecentProjects = File.ReadAllLines(Path.Combine(SDK.SDK.DataPath, "projcache")).ToList();
+ Projects.RecentProjects = File.ReadAllLines(Path.Join(SDK.SDK.DataPath, "projcache")).ToList();
ContextMenu.AddMenuList("File");
ContextMenu.AddMenuList("File.Import");
@@ -52,11 +53,12 @@ public void OnInitialized()
IUIWindow.Register("openpuppet.core.viewport", typeof(Viewport));
IUIWindow.Register("openpuppet.core.properties", typeof(Properties));
IUIWindow.Register("openpuppet.settings", typeof(SettingsWindow));
- IUIWindow.Register("openpuppet.core.project", typeof(Project));
+ IUIWindow.Register("openpuppet.core.project", typeof(ProjectWindow));
IUIWindow.Register("openpuppet.core.hierarchy", typeof(Hierarchy));
IUIDialog.Register("openpuppet.core.createproject", typeof(CreateProject));
IUIDialog.Register("openpuppet.core.welcome", typeof(WelcomeDialog));
+ IUIDialog.Register("openpuppet.core.error", typeof(ErrorDialog));
IEasingMode.Register("openpuppet.core.linear", new LinearEasing());
@@ -94,17 +96,20 @@ public void OnInitialized()
if (ProjectManager.ActiveProject == null)
IUIDialog.Open("openpuppet.core.welcome");
+
+ Logger.LogInfo("Registering services");
+ services.AddSingleton();
+ services.AddSingleton();
+ Logger.LogDebug("Finished registering services");
}
public void OnShutdown()
{
if (shutdown) return;
Events.Unsubscribe();
- Logger.Dispose();
shutdown = true;
// See if this maybe works?
- Global.MainPlugin.Logger = null;
Global.MainPlugin = null;
}
diff --git a/src/Plugins/OpenPuppet.Core/Project.cs b/src/Plugins/OpenPuppet.Core/Project.cs
index db3f9e0..dbd116d 100644
--- a/src/Plugins/OpenPuppet.Core/Project.cs
+++ b/src/Plugins/OpenPuppet.Core/Project.cs
@@ -9,7 +9,7 @@
namespace OpenPuppet.Core
{
- public class Project : IUIWindow
+ public class ProjectWindow : IUIWindow
{
public uint InstanceIndex { get; set; }
public string Title { get; set; } = "Project";
diff --git a/src/Plugins/OpenPuppet.Core/Projects/Project.cs b/src/Plugins/OpenPuppet.Core/Projects/Project.cs
index 1260227..4e6cf8d 100644
--- a/src/Plugins/OpenPuppet.Core/Projects/Project.cs
+++ b/src/Plugins/OpenPuppet.Core/Projects/Project.cs
@@ -32,14 +32,14 @@ public static void OpenProject(ProjectMetadata meta)
ProjectManager.ActiveProject = meta;
- var projfile = Path.Combine(meta.Directory, meta.Name + ".opp");
+ var projfile = Path.Join(meta.Directory, meta.Name + ".opp");
RecentProjects.Remove(projfile);
RecentProjects.Insert(0, projfile);
RecentProjects = RecentProjects.Take(25).ToList();
- File.WriteAllLines(Path.Combine(SDK.SDK.DataPath, "projcache"), RecentProjects);
+ File.WriteAllLines(Path.Join(SDK.SDK.DataPath, "projcache"), RecentProjects);
IEvent.Invoke("openpuppet.window.modify.title", null, $"OpenPuppet - {meta.Name}");
@@ -47,12 +47,12 @@ public static void OpenProject(ProjectMetadata meta)
}
public static void SaveProject(ProjectMetadata meta) => SaveProject(meta, meta.Directory);
- public static void SaveProject(ProjectMetadata meta,string dir)
+ public static void SaveProject(ProjectMetadata meta, string dir)
{
meta.Directory = dir;
File.WriteAllText(
- Path.Combine(dir, meta.Name + ".opp"),
+ Path.Join(dir, meta.Name + ".opp"),
JsonConvert.SerializeObject(meta, new JsonSerializerSettings()
{
TypeNameHandling = TypeNameHandling.Auto,
@@ -83,13 +83,13 @@ public static void OpenProject(string path)
public static void Create(string name, string path)
{
- string dir = Path.Combine(path, name);
+ string dir = Path.Join(path, name);
int i = 0;
- for (; Directory.Exists(dir); i++) dir = Path.Combine(path, name + $"({i})");
+ for (; Directory.Exists(dir); i++) dir = Path.Join(path, name + $"({i})");
Directory.CreateDirectory(dir);
- Directory.CreateDirectory(Path.Combine(dir, "Vectors"));
+ Directory.CreateDirectory(Path.Join(dir, "Vectors"));
var proj = new ProjectMetadata()
{
@@ -170,7 +170,7 @@ public static void Create(string name, string path)
),
]);
- IVectorASTComponent.SaveToDisk(vector, Path.Combine(dir, "Vectors", "vecpath.ovec"));
+ IVectorASTComponent.SaveToDisk(vector, Path.Join(dir, "Vectors", "vecpath.ovec"));
proj.Scenes.Add(new());
@@ -199,10 +199,10 @@ public static void Create(string name, string path)
);
OpenProject(proj);
- proj.Scenes[0].SceneObjects.Add(new VectorGameObject(Path.Combine("Vectors", "vecpath.ovec")));
+ proj.Scenes[0].SceneObjects.Add(new VectorGameObject(Path.Join("Vectors", "vecpath.ovec")));
File.WriteAllText(
- Path.Combine(dir, proj.Name + ".opp"),
+ Path.Join(dir, proj.Name + ".opp"),
JsonConvert.SerializeObject(ProjectManager.ActiveProject, new JsonSerializerSettings()
{
TypeNameHandling = TypeNameHandling.Auto,
@@ -212,4 +212,94 @@ public static void Create(string name, string path)
);
}
}
+
+ public class Project : IProjectManager
+ {
+ public List RecentProjects { get; } = [];
+
+ public void Create(string name, string path)
+ {
+ CreateAsync(name, path, null).Wait();
+ }
+
+ public void Create(string name, IProjectPath path)
+ {
+ CreateAsync(name, path, null).Wait();
+ }
+
+ public Task CreateAsync(string name, string path, CancellationToken? ct)
+ {
+ return CreateAsync(name, new ProjectPath(path), ct);
+ }
+
+ public Task CreateAsync(string name, IProjectPath path, CancellationToken? ct)
+ {
+ ct?.ThrowIfCancellationRequested();
+ throw new NotImplementedException();
+ }
+
+ public void OpenProject(ProjectMetadata meta)
+ {
+ OpenProjectAsync(meta, null).Wait();
+ }
+
+ public void OpenProject(string path)
+ {
+ OpenProjectAsync(path, null).Wait();
+ }
+
+ public void OpenProject(IProjectPath path)
+ {
+ OpenProjectAsync(path, null).Wait();
+ }
+
+ public Task OpenProjectAsync(ProjectMetadata meta, CancellationToken? ct)
+ {
+ return OpenProjectAsync(new ProjectPath(meta.Directory), ct);
+ }
+
+ public Task OpenProjectAsync(string path, CancellationToken? ct)
+ {
+ return OpenProjectAsync(new ProjectPath(path), ct);
+ }
+
+ public Task OpenProjectAsync(IProjectPath path, CancellationToken? ct)
+ {
+ ct?.ThrowIfCancellationRequested();
+ throw new NotImplementedException();
+ }
+
+ public void SaveProject(ProjectMetadata meta)
+ {
+ SaveProjectAsync(meta, null).Wait();
+ }
+
+ public void SaveProject(ProjectMetadata meta, string path)
+ {
+ SaveProjectAsync(meta, path, null).Wait();
+ }
+
+ public void SaveProject(ProjectMetadata meta, IProjectPath path)
+ {
+ SaveProjectAsync(meta, path, null).Wait();
+ }
+
+ public Task SaveProjectAsync(ProjectMetadata meta, CancellationToken? ct)
+ {
+ return SaveProjectAsync(meta, new ProjectPath(meta.Directory), ct);
+ }
+
+ public Task SaveProjectAsync(ProjectMetadata meta, string path, CancellationToken? ct)
+ {
+ return SaveProjectAsync(meta, new ProjectPath(path), ct);
+ }
+
+ public Task SaveProjectAsync(ProjectMetadata meta, IProjectPath path, CancellationToken? ct)
+ {
+ ct?.ThrowIfCancellationRequested();
+ throw new NotImplementedException();
+ }
+
+ public void Dispose() { }
+ }
}
diff --git a/src/Plugins/OpenPuppet.Core/SettingsWindow.cs b/src/Plugins/OpenPuppet.Core/SettingsWindow.cs
index 9fd3912..34412a1 100644
--- a/src/Plugins/OpenPuppet.Core/SettingsWindow.cs
+++ b/src/Plugins/OpenPuppet.Core/SettingsWindow.cs
@@ -1,4 +1,5 @@
using ImGuiNET;
+using Microsoft.Extensions.DependencyInjection;
using OpenPuppet.SDK;
using System;
using System.Collections.Generic;
@@ -89,6 +90,9 @@ public void OnRender(double deltaTime)
public void OnPostRender(double deltaTime) { }
- public void OnClose() { }
+ public void OnClose()
+ {
+
+ }
}
}
diff --git a/src/Plugins/OpenPuppet.Preferences/Plugin.cs b/src/Plugins/OpenPuppet.Preferences/Plugin.cs
index 7b4f2f0..f03c024 100644
--- a/src/Plugins/OpenPuppet.Preferences/Plugin.cs
+++ b/src/Plugins/OpenPuppet.Preferences/Plugin.cs
@@ -1,4 +1,5 @@
-using OpenPuppet.Preferences.Layouts;
+using Microsoft.Extensions.DependencyInjection;
+using OpenPuppet.Preferences.Layouts;
using OpenPuppet.SDK;
namespace OpenPuppet.Preferences
@@ -7,14 +8,13 @@ public class Plugin : IPlugin
{
public const string PluginID = "com.openpuppet.preferences";
- public Logger.PluginLogger Logger { get; internal set; } = SDK.Logger.LogManager.RequestPluginLogger(PluginID);
-
private bool shutdown = false;
- public void OnInitialized()
+ public void OnInitialized(IServiceCollection services)
{
+ Logger.InitLogger(PluginID);
Global.MainPlugin = this;
- Logger.WriteLine(SDK.Logger.ILogger.Level.Log, "Hello Preferences Plugin");
+ Logger.LogInfo("Hello Preferences Plugin");
IUIDialog.Register("openpuppet.layouts.new_layout", typeof(NewLayout));
@@ -31,7 +31,7 @@ public void OnInitialized()
public void OnShutdown()
{
if (shutdown) return;
- Logger.WriteLine(SDK.Logger.ILogger.Level.Log, "Saving current window layout");
+ Logger.LogInfo("Saving current window layout");
Windows.SavePreviousWindows();
Windows.SaveLayout("default");
ContextMenu.Remove("view.layouts");
@@ -39,7 +39,6 @@ public void OnShutdown()
//ContextMenu.Remove("view.layouts.layouts");
//ContextMenu.Remove("view.layouts.layouts.default");
Windows.UnsubscribeToEvents();
- Logger.Dispose();
shutdown = true;
}
diff --git a/src/Plugins/OpenPuppet.Preferences/Windows.cs b/src/Plugins/OpenPuppet.Preferences/Windows.cs
index e40393f..8d9b79b 100644
--- a/src/Plugins/OpenPuppet.Preferences/Windows.cs
+++ b/src/Plugins/OpenPuppet.Preferences/Windows.cs
@@ -13,8 +13,8 @@ namespace OpenPuppet.Preferences
public static class Windows
{
private static readonly List OpenWindows = new();
- private static readonly string WindowsFile = Path.Combine(SDK.SDK.DataPath, "Preferences", "last_windows.json");
- private static readonly string LayoutDir = Path.Combine(SDK.SDK.DataPath, "Preferences", "layouts");
+ private static readonly string WindowsFile = Path.Join(SDK.SDK.DataPath, "Preferences", "last_windows.json");
+ private static readonly string LayoutDir = Path.Join(SDK.SDK.DataPath, "Preferences", "layouts");
private static bool IsLoaded = false; // This fixes the event handling running twice
public static void SubscribeToEvents()
@@ -46,7 +46,7 @@ public static void OnWindowClosed(object? sender, SDK.Events.WindowEvents.Window
public static void OnFinishedLoading(object? sender, EventArgs args)
{
if (IsLoaded) return;
- Global.MainPlugin.Logger.WriteLine(SDK.Logger.ILogger.Level.Log, "Attempting to load previous layout");
+ Logger.LogInfo("Attempting to load previous layout");
OpenPreviousWindows();
OpenLayout("default");
IsLoaded = true;
@@ -65,7 +65,7 @@ public static void OpenPreviousWindows()
string[]? data = JsonSerializer.Deserialize(File.ReadAllText(WindowsFile));
if (data == null)
{
- Global.MainPlugin.Logger.WriteLine(Logger.ILogger.Level.Error, "Failed to load last opened windows");
+ Logger.LogTrace("Failed to load last opened windows");
SavePreviousWindows();
}
else
@@ -78,7 +78,7 @@ public static void OpenPreviousWindows()
}
catch (Exception ex)
{
- Global.MainPlugin.Logger.WriteLine(Logger.ILogger.Level.Error, "Failed to load last opened windows: " + ex.Message);
+ Logger.LogTrace("Failed to load last opened windows: " + ex.Message);
SavePreviousWindows();
}
}
@@ -103,18 +103,18 @@ public static void SavePreviousWindows()
public static bool OpenLayout(string id)
{
- if (!File.Exists(Path.Combine(LayoutDir, $"{id}.ini"))) return false;
+ if (!File.Exists(Path.Join(LayoutDir, $"{id}.ini"))) return false;
try
{
- string file = File.ReadAllText(Path.Combine(LayoutDir, $"{id}.ini"));
+ string file = File.ReadAllText(Path.Join(LayoutDir, $"{id}.ini"));
ImGui.LoadIniSettingsFromMemory(file);
return true;
}
catch (Exception ex)
{
- Global.MainPlugin.Logger.WriteLine(SDK.Logger.ILogger.Level.Error, "Failed to load ImGui layout: " + ex.Message);
+ Logger.LogTrace("Failed to load ImGui layout: " + ex.Message);
return false;
}
}
@@ -124,7 +124,7 @@ public static void SaveLayout(string id)
if (!Directory.Exists(LayoutDir))
Directory.CreateDirectory(LayoutDir);
- File.WriteAllText(Path.Combine(LayoutDir, $"{id}.ini"), ImGui.SaveIniSettingsToMemory());
+ File.WriteAllText(Path.Join(LayoutDir, $"{id}.ini"), ImGui.SaveIniSettingsToMemory());
}
}
}
\ No newline at end of file
diff --git a/src/Plugins/OpenPuppet.SVG/ImportSVG.cs b/src/Plugins/OpenPuppet.SVG/ImportSVG.cs
index 5420f8c..b8ea629 100644
--- a/src/Plugins/OpenPuppet.SVG/ImportSVG.cs
+++ b/src/Plugins/OpenPuppet.SVG/ImportSVG.cs
@@ -53,11 +53,12 @@ public void OnRender()
if (openDisabled) ImGui.BeginDisabled();
if (ImGui.Button("Open") && !openDisabled)
{
+ // TODO: Convert this to an async operation
var vector = SVGImporter.ImportSVG(path);
var scene = ProjectManager.ActiveProject!.Scenes[ProjectManager.ActiveProject.ActiveScene];
- var vecpath = Path.Combine(
+ var vecpath = Path.Join(
ProjectManager.ActiveProject.Directory,
"Vectors", $"{Path.GetFileNameWithoutExtension(path)}.ovec"
);
diff --git a/src/Plugins/OpenPuppet.SVG/Plugin.cs b/src/Plugins/OpenPuppet.SVG/Plugin.cs
index 1596c83..7b4d29b 100644
--- a/src/Plugins/OpenPuppet.SVG/Plugin.cs
+++ b/src/Plugins/OpenPuppet.SVG/Plugin.cs
@@ -1,4 +1,5 @@
using ImGuiNET;
+using Microsoft.Extensions.DependencyInjection;
using OpenPuppet;
using OpenPuppet.SDK;
using System;
@@ -13,15 +14,14 @@ public class Plugin : IPlugin
{
public const string PluginID = "com.openpuppet.svg";
- public Logger.PluginLogger Logger { get; internal set; } = SDK.Logger.LogManager.RequestPluginLogger(PluginID);
-
private bool shutdown = false;
- public void OnInitialized()
+ public void OnInitialized(IServiceCollection services)
{
+ Logger.InitLogger(PluginID);
bool hasProject = SDK.Projects.ProjectManager.ActiveProject != null;
- Logger.WriteLine(SDK.Logger.ILogger.Level.Log, "Hello SVG Plugin");
+ Logger.LogInfo("Hello SVG Plugin");
IUIDialog.Register("openpuppet.svg.import", typeof(ImportSVG));
@@ -32,7 +32,6 @@ public void OnShutdown()
{
if (shutdown) return;
ContextMenu.Remove("File.Import.SVG");
- Logger.Dispose();
shutdown = true;
}
diff --git a/src/Plugins/OpenPuppet.SVG/SVGImporter.cs b/src/Plugins/OpenPuppet.SVG/SVGImporter.cs
index c70d350..ad0d20c 100644
--- a/src/Plugins/OpenPuppet.SVG/SVGImporter.cs
+++ b/src/Plugins/OpenPuppet.SVG/SVGImporter.cs
@@ -13,18 +13,20 @@ namespace OpenPuppet.SVG
{
public static class SVGImporter
{
- static Dictionary> Importers = new()
+ static readonly Dictionary> Importers = new()
{
{"rect",RectImporter},
{"circle",CircleImporter},
{"ellipse",EllipseImporter},
};
- public static UnifiedVector ImportSVG(string path)
+ public static UnifiedVector ImportSVG(string path, CancellationToken? ct = null)
{
if (!File.Exists(path))
throw new Exception($"SVG file {path} does not exist");
+ ct?.ThrowIfCancellationRequested();
+
var doc = XDocument.Parse(File.ReadAllText(path));
if (doc.Root == null || doc.Root.Name.LocalName.ToLowerInvariant() != "svg")
@@ -51,27 +53,36 @@ public static UnifiedVector ImportSVG(string path)
viewbox.Height = float.Parse(doc.Root.AttributeOrDefault("height", "200").Value);
}
+ ct?.ThrowIfCancellationRequested();
+
List Components = new();
foreach (var item in doc.Descendants())
{
var name = item.Name.LocalName.ToLowerInvariant();
- if (Importers.ContainsKey(name))
+ if (Importers.TryGetValue(name, out var val))
{
- var imported = Importers[name](item, viewbox);
+ var imported = val(item, viewbox);
Components.AddRange(imported);
}
+
+ ct?.ThrowIfCancellationRequested();
}
return new(Components);
}
- static ColoredVectorComponent[] RectImporter(XElement element,RectangleF Viewbox)
+ public static Task ImportSVGAsync(string path, CancellationToken ct)
+ {
+ return Task.Run(() => { return ImportSVG(path, ct); }, ct);
+ }
+
+ static ColoredVectorComponent[] RectImporter(XElement element, RectangleF Viewbox)
{
var biggest = Math.Max(Viewbox.Width, Viewbox.Height);
- var x = (float.Parse(element.AttributeOrDefault("x","0").Value) - Viewbox.X) / biggest;
+ var x = (float.Parse(element.AttributeOrDefault("x", "0").Value) - Viewbox.X) / biggest;
var y = (float.Parse(element.AttributeOrDefault("y", "0").Value) - Viewbox.Y) / biggest;
var w = float.Parse(element.AttributeOrDefault("width", "0").Value) / biggest;
var h = float.Parse(element.AttributeOrDefault("height", "0").Value) / biggest;
@@ -86,7 +97,7 @@ static ColoredVectorComponent[] RectImporter(XElement element,RectangleF Viewbox
{
var color4 = SixLabors.ImageSharp.Color.Parse(fill.Value).ToPixel().ToVector4();
- components.Add(new(component,new VectorSolidColorSampler(color4)));
+ components.Add(new(component, new VectorSolidColorSampler(color4)));
}
var stroke = element.Attribute("stroke");
@@ -98,7 +109,7 @@ static ColoredVectorComponent[] RectImporter(XElement element,RectangleF Viewbox
components.Add(
new(
- new SolidifyComponent(component, strokew / 2, strokew / 2),
+ new SolidifyComponent(component, strokew / 2, strokew / 2),
new VectorSolidColorSampler(color4)
)
);
@@ -157,7 +168,7 @@ static ColoredVectorComponent[] EllipseImporter(XElement element, RectangleF Vie
List components = new();
- IVectorASTComponent component = new EllipseComponent(new(x, y), new(rx,ry));
+ IVectorASTComponent component = new EllipseComponent(new(x, y), new(rx, ry));
var fill = element.Attribute("fill");
@@ -186,7 +197,7 @@ static ColoredVectorComponent[] EllipseImporter(XElement element, RectangleF Vie
return components.ToArray();
}
- static XAttribute AttributeOrDefault(this XElement element, string attr,string defaultValue = "") =>
+ static XAttribute AttributeOrDefault(this XElement element, string attr, string defaultValue = "") =>
element.Attribute(attr) ?? new XAttribute(attr, defaultValue);
}
}
diff --git a/src/Plugins/OpenPuppet.Translations/OpenPuppet.Translations.csproj b/src/Plugins/OpenPuppet.Translations/OpenPuppet.Translations.csproj
new file mode 100644
index 0000000..8221b14
--- /dev/null
+++ b/src/Plugins/OpenPuppet.Translations/OpenPuppet.Translations.csproj
@@ -0,0 +1,19 @@
+
+
+
+ net10.0
+ enable
+ enable
+
+
+
+
+
+
+
+
+ PreserveNewest
+
+
+
+
diff --git a/src/Plugins/OpenPuppet.Translations/Plugin.cs b/src/Plugins/OpenPuppet.Translations/Plugin.cs
new file mode 100644
index 0000000..2b93aef
--- /dev/null
+++ b/src/Plugins/OpenPuppet.Translations/Plugin.cs
@@ -0,0 +1,29 @@
+using Microsoft.Extensions.DependencyInjection;
+using OpenPuppet.SDK;
+
+namespace OpenPuppet.Translations
+{
+ public class Plugin : IPlugin
+ {
+ public const string PluginID = "com.openpuppet.translations";
+
+ public void OnInitialized(IServiceCollection services)
+ {
+ Logger.InitLogger(PluginID);
+
+ Logger.LogInfo("Hello Translations");
+
+ ISettingsSection.RegisterSection("Language", null);
+ }
+
+ public void OnShutdown()
+ {
+ throw new NotImplementedException();
+ }
+
+ public void Dispose()
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
diff --git a/src/Plugins/OpenPuppet.Translations/meta.inf b/src/Plugins/OpenPuppet.Translations/meta.inf
new file mode 100644
index 0000000..1ebcdf4
--- /dev/null
+++ b/src/Plugins/OpenPuppet.Translations/meta.inf
@@ -0,0 +1,8 @@
+{
+ "id": "com.openpuppet.translations",
+ "name": "OpenPuppet Translations Plugin",
+ "description": "Provides translations for OpenPuppet, enabling localisation, and multi-language support",
+ "author": "OpenPuppet (Project-Axion)",
+ "version": "1.0.0",
+ "icon": ""
+}
\ No newline at end of file