diff --git a/SessionZero.sln b/SessionZero.sln new file mode 100644 index 0000000..a8146a5 --- /dev/null +++ b/SessionZero.sln @@ -0,0 +1,28 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SessionZero.Shared", "src\SessionZero.Shared\SessionZero.Shared.csproj", "{86CD0D66-D47D-41DA-B857-F8371AC6E6A9}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SessionZero.Client", "src\SessionZero.Client\SessionZero.Client.csproj", "{A6455219-BBF2-4A67-B13C-449249083703}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SessionZero.Server", "src\SessionZero.Server\SessionZero.Server.csproj", "{54824F5A-0499-4BC9-AC8E-88E943C66256}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {86CD0D66-D47D-41DA-B857-F8371AC6E6A9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {86CD0D66-D47D-41DA-B857-F8371AC6E6A9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {86CD0D66-D47D-41DA-B857-F8371AC6E6A9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {86CD0D66-D47D-41DA-B857-F8371AC6E6A9}.Release|Any CPU.Build.0 = Release|Any CPU + {A6455219-BBF2-4A67-B13C-449249083703}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A6455219-BBF2-4A67-B13C-449249083703}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A6455219-BBF2-4A67-B13C-449249083703}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A6455219-BBF2-4A67-B13C-449249083703}.Release|Any CPU.Build.0 = Release|Any CPU + {54824F5A-0499-4BC9-AC8E-88E943C66256}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {54824F5A-0499-4BC9-AC8E-88E943C66256}.Debug|Any CPU.Build.0 = Debug|Any CPU + {54824F5A-0499-4BC9-AC8E-88E943C66256}.Release|Any CPU.ActiveCfg = Release|Any CPU + {54824F5A-0499-4BC9-AC8E-88E943C66256}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/rambling.md b/docs/rambling.md similarity index 100% rename from rambling.md rename to docs/rambling.md diff --git a/samples/samples.txt b/samples/samples.txt new file mode 100644 index 0000000..bf4847c --- /dev/null +++ b/samples/samples.txt @@ -0,0 +1,2 @@ +Samples: +- This folder will include sample datapacks diff --git a/src/SessionZero.Client/App.axaml b/src/SessionZero.Client/App.axaml new file mode 100644 index 0000000..99d86a9 --- /dev/null +++ b/src/SessionZero.Client/App.axaml @@ -0,0 +1,15 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/src/SessionZero.Client/App.axaml.cs b/src/SessionZero.Client/App.axaml.cs new file mode 100644 index 0000000..415fbb3 --- /dev/null +++ b/src/SessionZero.Client/App.axaml.cs @@ -0,0 +1,47 @@ +using Avalonia; +using Avalonia.Controls.ApplicationLifetimes; +using Avalonia.Data.Core; +using Avalonia.Data.Core.Plugins; +using System.Linq; +using Avalonia.Markup.Xaml; +using SessionZero.Client.ViewModels; +using SessionZero.Client.Views; + +namespace SessionZero.Client; + +public partial class App : Application +{ + public override void Initialize() + { + AvaloniaXamlLoader.Load(this); + } + + public override void OnFrameworkInitializationCompleted() + { + if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) + { + // Avoid duplicate validations from both Avalonia and the CommunityToolkit. + // More info: https://docs.avaloniaui.net/docs/guides/development-guides/data-validation#manage-validationplugins + DisableAvaloniaDataAnnotationValidation(); + desktop.MainWindow = new MainWindow + { + DataContext = new MainWindowViewModel(), + }; + } + + base.OnFrameworkInitializationCompleted(); + } + + private void DisableAvaloniaDataAnnotationValidation() + { + // Get an array of plugins to remove + var dataValidationPluginsToRemove = + BindingPlugins.DataValidators.OfType().ToArray(); + + // remove each entry found + foreach (var plugin in dataValidationPluginsToRemove) + { + BindingPlugins.DataValidators.Remove(plugin); + } + } +} \ No newline at end of file diff --git a/src/SessionZero.Client/Assets/avalonia-logo.ico b/src/SessionZero.Client/Assets/avalonia-logo.ico new file mode 100644 index 0000000..f7da8bb Binary files /dev/null and b/src/SessionZero.Client/Assets/avalonia-logo.ico differ diff --git a/src/SessionZero.Client/Program.cs b/src/SessionZero.Client/Program.cs new file mode 100644 index 0000000..0addfe3 --- /dev/null +++ b/src/SessionZero.Client/Program.cs @@ -0,0 +1,21 @@ +using Avalonia; +using System; + +namespace SessionZero.Client; + +sealed class Program +{ + // Initialization code. Don't use any Avalonia, third-party APIs or any + // SynchronizationContext-reliant code before AppMain is called: things aren't initialized + // yet and stuff might break. + [STAThread] + public static void Main(string[] args) => BuildAvaloniaApp() + .StartWithClassicDesktopLifetime(args); + + // Avalonia configuration, don't remove; also used by visual designer. + public static AppBuilder BuildAvaloniaApp() + => AppBuilder.Configure() + .UsePlatformDetect() + .WithInterFont() + .LogToTrace(); +} \ No newline at end of file diff --git a/src/SessionZero.Client/SessionZero.Client.csproj b/src/SessionZero.Client/SessionZero.Client.csproj new file mode 100644 index 0000000..967aace --- /dev/null +++ b/src/SessionZero.Client/SessionZero.Client.csproj @@ -0,0 +1,28 @@ + + + WinExe + net9.0 + enable + true + app.manifest + true + + + + + + + + + + + + + + + None + All + + + + diff --git a/src/SessionZero.Client/ViewLocator.cs b/src/SessionZero.Client/ViewLocator.cs new file mode 100644 index 0000000..d59f1cb --- /dev/null +++ b/src/SessionZero.Client/ViewLocator.cs @@ -0,0 +1,30 @@ +using System; +using Avalonia.Controls; +using Avalonia.Controls.Templates; +using SessionZero.Client.ViewModels; + +namespace SessionZero.Client; + +public class ViewLocator : IDataTemplate +{ + public Control? Build(object? param) + { + if (param is null) + return null; + + var name = param.GetType().FullName!.Replace("ViewModel", "View", StringComparison.Ordinal); + var type = Type.GetType(name); + + if (type != null) + { + return (Control)Activator.CreateInstance(type)!; + } + + return new TextBlock { Text = "Not Found: " + name }; + } + + public bool Match(object? data) + { + return data is ViewModelBase; + } +} \ No newline at end of file diff --git a/src/SessionZero.Client/ViewModels/MainWindowViewModel.cs b/src/SessionZero.Client/ViewModels/MainWindowViewModel.cs new file mode 100644 index 0000000..799c449 --- /dev/null +++ b/src/SessionZero.Client/ViewModels/MainWindowViewModel.cs @@ -0,0 +1,6 @@ +namespace SessionZero.Client.ViewModels; + +public partial class MainWindowViewModel : ViewModelBase +{ + public string Greeting { get; } = "Welcome to Avalonia!"; +} \ No newline at end of file diff --git a/src/SessionZero.Client/ViewModels/ViewModelBase.cs b/src/SessionZero.Client/ViewModels/ViewModelBase.cs new file mode 100644 index 0000000..3873adc --- /dev/null +++ b/src/SessionZero.Client/ViewModels/ViewModelBase.cs @@ -0,0 +1,7 @@ +using CommunityToolkit.Mvvm.ComponentModel; + +namespace SessionZero.Client.ViewModels; + +public class ViewModelBase : ObservableObject +{ +} \ No newline at end of file diff --git a/src/SessionZero.Client/Views/MainWindow.axaml b/src/SessionZero.Client/Views/MainWindow.axaml new file mode 100644 index 0000000..81ce6f2 --- /dev/null +++ b/src/SessionZero.Client/Views/MainWindow.axaml @@ -0,0 +1,20 @@ + + + + + + + + + + diff --git a/src/SessionZero.Client/Views/MainWindow.axaml.cs b/src/SessionZero.Client/Views/MainWindow.axaml.cs new file mode 100644 index 0000000..44ac4e8 --- /dev/null +++ b/src/SessionZero.Client/Views/MainWindow.axaml.cs @@ -0,0 +1,11 @@ +using Avalonia.Controls; + +namespace SessionZero.Client.Views; + +public partial class MainWindow : Window +{ + public MainWindow() + { + InitializeComponent(); + } +} \ No newline at end of file diff --git a/src/SessionZero.Client/app.manifest b/src/SessionZero.Client/app.manifest new file mode 100644 index 0000000..eb09286 --- /dev/null +++ b/src/SessionZero.Client/app.manifest @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + diff --git a/src/SessionZero.Server/Program.cs b/src/SessionZero.Server/Program.cs new file mode 100644 index 0000000..d5e0ef3 --- /dev/null +++ b/src/SessionZero.Server/Program.cs @@ -0,0 +1,41 @@ +var builder = WebApplication.CreateBuilder(args); + +// Add services to the container. +// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi +builder.Services.AddOpenApi(); + +var app = builder.Build(); + +// Configure the HTTP request pipeline. +if (app.Environment.IsDevelopment()) +{ + app.MapOpenApi(); +} + +app.UseHttpsRedirection(); + +var summaries = new[] +{ + "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" +}; + +app.MapGet("/weatherforecast", () => + { + var forecast = Enumerable.Range(1, 5).Select(index => + new WeatherForecast + ( + DateOnly.FromDateTime(DateTime.Now.AddDays(index)), + Random.Shared.Next(-20, 55), + summaries[Random.Shared.Next(summaries.Length)] + )) + .ToArray(); + return forecast; + }) + .WithName("GetWeatherForecast"); + +app.Run(); + +record WeatherForecast(DateOnly Date, int TemperatureC, string? Summary) +{ + public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); +} \ No newline at end of file diff --git a/src/SessionZero.Server/Properties/launchSettings.json b/src/SessionZero.Server/Properties/launchSettings.json new file mode 100644 index 0000000..def5fae --- /dev/null +++ b/src/SessionZero.Server/Properties/launchSettings.json @@ -0,0 +1,23 @@ +{ + "$schema": "https://json.schemastore.org/launchsettings.json", + "profiles": { + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": false, + "applicationUrl": "http://localhost:5227", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "https": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": false, + "applicationUrl": "https://localhost:7090;http://localhost:5227", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/src/SessionZero.Server/SessionZero.Server.csproj b/src/SessionZero.Server/SessionZero.Server.csproj new file mode 100644 index 0000000..63257cb --- /dev/null +++ b/src/SessionZero.Server/SessionZero.Server.csproj @@ -0,0 +1,13 @@ + + + + net9.0 + enable + enable + + + + + + + diff --git a/src/SessionZero.Server/SessionZero.Server.http b/src/SessionZero.Server/SessionZero.Server.http new file mode 100644 index 0000000..57ddf6a --- /dev/null +++ b/src/SessionZero.Server/SessionZero.Server.http @@ -0,0 +1,6 @@ +@SessionZero.Server_HostAddress = http://localhost:5227 + +GET {{SessionZero.Server_HostAddress}}/weatherforecast/ +Accept: application/json + +### diff --git a/src/SessionZero.Server/appsettings.Development.json b/src/SessionZero.Server/appsettings.Development.json new file mode 100644 index 0000000..0c208ae --- /dev/null +++ b/src/SessionZero.Server/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/src/SessionZero.Server/appsettings.json b/src/SessionZero.Server/appsettings.json new file mode 100644 index 0000000..10f68b8 --- /dev/null +++ b/src/SessionZero.Server/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +} diff --git a/src/SessionZero.Shared/Models/CharaterTemplate.cs b/src/SessionZero.Shared/Models/CharaterTemplate.cs new file mode 100644 index 0000000..5072d78 --- /dev/null +++ b/src/SessionZero.Shared/Models/CharaterTemplate.cs @@ -0,0 +1,6 @@ +namespace SessionZero.Shared.Models; + +public class CharaterTemplate +{ + +} \ No newline at end of file diff --git a/src/SessionZero.Shared/Models/Datapack.cs b/src/SessionZero.Shared/Models/Datapack.cs new file mode 100644 index 0000000..a1b386f --- /dev/null +++ b/src/SessionZero.Shared/Models/Datapack.cs @@ -0,0 +1,22 @@ +namespace SessionZero.Shared.Models; + +public class Datapack +{ + public required Guid Id { get; set; } + public required string Name { get; set; } + public required string Version { get; set; } + public required string Author { get; set; } + public required string License { get; set; } + public string Description { get; set; } = string.Empty; + public required DateTime CreatedAt { get; set; } + public required string SessionZeroVersion { get; set; } + + public List Dependencies { get; set; } = new(); +} + +public class Dependency +{ + public required Guid Id { get; set; } + public required string Name { get; set; } + public required string Version { get; set; } +} \ No newline at end of file diff --git a/src/SessionZero.Shared/Models/Dataset.cs b/src/SessionZero.Shared/Models/Dataset.cs new file mode 100644 index 0000000..f73ba35 --- /dev/null +++ b/src/SessionZero.Shared/Models/Dataset.cs @@ -0,0 +1,17 @@ +namespace SessionZero.Shared.Models; + +public class Dataset : SzObject +{ + public required string DatasetType { get; set; } + +} + +public class DatasetEntry +{ + public required string Id { get; set; } + public required string Name { get; set; } + public string Description { get; set; } = string.Empty; + public string Icon { get; set; } = string.Empty; + + +} \ No newline at end of file diff --git a/src/SessionZero.Shared/Models/SessionTemplate.cs b/src/SessionZero.Shared/Models/SessionTemplate.cs new file mode 100644 index 0000000..0334327 --- /dev/null +++ b/src/SessionZero.Shared/Models/SessionTemplate.cs @@ -0,0 +1,6 @@ +namespace SessionZero.Shared.Models; + +public class SessionTemplate +{ + +} \ No newline at end of file diff --git a/src/SessionZero.Shared/Models/SzObject.cs b/src/SessionZero.Shared/Models/SzObject.cs new file mode 100644 index 0000000..d016bb6 --- /dev/null +++ b/src/SessionZero.Shared/Models/SzObject.cs @@ -0,0 +1,60 @@ +namespace SessionZero.Shared.Models; + +public class SzObject +{ + public required string Id { get; set; } + public required string Name { get; set; } + public required string SzType { get; set; } + public string Description { get; set; } = string.Empty; + public string Icon { get; set; } = string.Empty; + public required string Version { get; set; } + public required string SchemaVersion { get; set; } +} + +public class Section +{ + public required string Id { get; set; } + public required string Name { get; set; } + public required List Groups { get; set; } = new(); +} + +public class Group +{ + public required string Id { get; set; } + public required string Name { get; set; } + public required List Fields { get; set; } = new(); +} + +public class FieldDefinition +{ + public required string Id { get; set; } + public required string Name { get; set; } + public required FieldType Type { get; set; } + public object? DefaultValue { get; set; } + public DatasetLink? DatasetLink { get; set; } +} + +public class FieldValue +{ + public required FieldType Type { get; set; } + public required object Value { get; set; } +} + +public class DatasetLink +{ + /* TODO: + * This needs to be able to either link a list of specific dataset ids OR + * a list of allowed dataset types that could be any dataset that the pack has listed as a dependency + * (This is used on fields that are of type 'List') + */ +} + +public enum FieldType +{ + Text, + MultiText, + Number, + Boolean, + Formula, + List +} \ No newline at end of file diff --git a/src/SessionZero.Shared/SessionZero.Shared.csproj b/src/SessionZero.Shared/SessionZero.Shared.csproj new file mode 100644 index 0000000..17b910f --- /dev/null +++ b/src/SessionZero.Shared/SessionZero.Shared.csproj @@ -0,0 +1,9 @@ + + + + net9.0 + enable + enable + + + diff --git a/tools/tools.txt b/tools/tools.txt new file mode 100644 index 0000000..94beeaa --- /dev/null +++ b/tools/tools.txt @@ -0,0 +1,2 @@ +Planned tools: +- szpack: a cli tool for validating and packing szpack archives