diff --git a/.gitignore b/.gitignore index 72c6686..8a30d25 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,3 @@ -# Created by https://www.toptal.com/developers/gitignore/api/visualstudio -# Edit at https://www.toptal.com/developers/gitignore?templates=visualstudio - -### VisualStudio ### ## Ignore Visual Studio temporary files, build results, and ## files generated by popular Visual Studio add-ons. ## @@ -306,6 +302,8 @@ node_modules/ *.dsp # Visual Studio 6 technical files +*.ncb +*.aps # Visual Studio LightSwitch build output **/*.HTMLClient/GeneratedArtifacts @@ -398,92 +396,3 @@ FodyWeavers.xsd # JetBrains Rider *.sln.iml - -### VisualStudio Patch ### -# Additional files built by Visual Studio - -# End of https://www.toptal.com/developers/gitignore/api/visualstudio - -### Rider ### -# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider -# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 - -# User-specific stuff -.idea/**/workspace.xml -.idea/**/tasks.xml -.idea/**/usage.statistics.xml -.idea/**/dictionaries -.idea/**/shelf - -# AWS User-specific -.idea/**/aws.xml - -# Generated files -.idea/**/contentModel.xml - -# Sensitive or high-churn files -.idea/**/dataSources/ -.idea/**/dataSources.ids -.idea/**/dataSources.local.xml -.idea/**/sqlDataSources.xml -.idea/**/dynamic.xml -.idea/**/uiDesigner.xml -.idea/**/dbnavigator.xml - -# Gradle -.idea/**/gradle.xml -.idea/**/libraries - -# Gradle and Maven with auto-import -# When using Gradle or Maven with auto-import, you should exclude module files, -# since they will be recreated, and may cause churn. Uncomment if using -# auto-import. -# .idea/artifacts -# .idea/compiler.xml -# .idea/jarRepositories.xml -# .idea/modules.xml -# .idea/*.iml -# .idea/modules -# *.iml -# *.ipr - -# CMake -cmake-build-*/ - -# Mongo Explorer plugin -.idea/**/mongoSettings.xml - -# File-based project format -*.iws - -# IntelliJ -out/ - -# mpeltonen/sbt-idea plugin -.idea_modules/ - -# JIRA plugin -atlassian-ide-plugin.xml - -# Cursive Clojure plugin -.idea/replstate.xml - -# SonarLint plugin -.idea/sonarlint/ - -# Crashlytics plugin (for Android Studio and IntelliJ) -com_crashlytics_export_strings.xml -crashlytics.properties -crashlytics-build.properties -fabric.properties - -# Editor-based Rest Client -.idea/httpRequests - -# Android studio 3.1+ serialized cache file -.idea/caches/build_file_checksums.ser - -# All rider -.idea/ - -# End of https://www.toptal.com/developers/gitignore/api/rider diff --git a/.idea/.idea.Chief/.idea/.gitignore b/.idea/.idea.Chief/.idea/.gitignore new file mode 100644 index 0000000..5a5a2eb --- /dev/null +++ b/.idea/.idea.Chief/.idea/.gitignore @@ -0,0 +1,13 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Rider ignored files +/projectSettingsUpdater.xml +/modules.xml +/.idea.Chief.iml +/contentModel.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/.idea.Chief/.idea/avalonia.xml b/.idea/.idea.Chief/.idea/avalonia.xml new file mode 100644 index 0000000..3327c55 --- /dev/null +++ b/.idea/.idea.Chief/.idea/avalonia.xml @@ -0,0 +1,18 @@ + + + + + + \ No newline at end of file diff --git a/.idea/.idea.Chief/.idea/indexLayout.xml b/.idea/.idea.Chief/.idea/indexLayout.xml new file mode 100644 index 0000000..7b08163 --- /dev/null +++ b/.idea/.idea.Chief/.idea/indexLayout.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/.idea.Chief/.idea/vcs.xml b/.idea/.idea.Chief/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/.idea.Chief/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Chief.sln b/Chief.sln index 88e6c09..ead7ed8 100644 --- a/Chief.sln +++ b/Chief.sln @@ -1,8 +1,8 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Chief", "Chief\Chief.csproj", "{5A85FCAF-DAAC-4CAE-BC5C-4D6D6A8294D9}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Chief.App", "src\Chief.App\Chief.App.csproj", "{C36842CA-4C5F-4419-A7BF-2E148BC0D04F}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ChiefCore", "ChiefCore\ChiefCore.csproj", "{4D078273-78B7-4A5D-BD31-39FDD618968F}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Chief.Core", "src\Chief.Core\Chief.Core.csproj", "{1F067301-1F46-44F1-AA91-F7D42DAF1588}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -10,13 +10,13 @@ Global Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {5A85FCAF-DAAC-4CAE-BC5C-4D6D6A8294D9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {5A85FCAF-DAAC-4CAE-BC5C-4D6D6A8294D9}.Debug|Any CPU.Build.0 = Debug|Any CPU - {5A85FCAF-DAAC-4CAE-BC5C-4D6D6A8294D9}.Release|Any CPU.ActiveCfg = Release|Any CPU - {5A85FCAF-DAAC-4CAE-BC5C-4D6D6A8294D9}.Release|Any CPU.Build.0 = Release|Any CPU - {4D078273-78B7-4A5D-BD31-39FDD618968F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {4D078273-78B7-4A5D-BD31-39FDD618968F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {4D078273-78B7-4A5D-BD31-39FDD618968F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {4D078273-78B7-4A5D-BD31-39FDD618968F}.Release|Any CPU.Build.0 = Release|Any CPU + {C36842CA-4C5F-4419-A7BF-2E148BC0D04F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C36842CA-4C5F-4419-A7BF-2E148BC0D04F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C36842CA-4C5F-4419-A7BF-2E148BC0D04F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C36842CA-4C5F-4419-A7BF-2E148BC0D04F}.Release|Any CPU.Build.0 = Release|Any CPU + {1F067301-1F46-44F1-AA91-F7D42DAF1588}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1F067301-1F46-44F1-AA91-F7D42DAF1588}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1F067301-1F46-44F1-AA91-F7D42DAF1588}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1F067301-1F46-44F1-AA91-F7D42DAF1588}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection EndGlobal diff --git a/Chief.sln.DotSettings b/Chief.sln.DotSettings index 7954445..c3ce823 100644 --- a/Chief.sln.DotSettings +++ b/Chief.sln.DotSettings @@ -1,7 +1,2 @@  - True - True - True - True - True - True \ No newline at end of file + True \ No newline at end of file diff --git a/Chief/App.axaml b/Chief/App.axaml deleted file mode 100644 index 6ed9183..0000000 --- a/Chief/App.axaml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Chief/App.axaml.cs b/Chief/App.axaml.cs deleted file mode 100644 index dcc5086..0000000 --- a/Chief/App.axaml.cs +++ /dev/null @@ -1,40 +0,0 @@ -using Avalonia; -using Avalonia.Controls.ApplicationLifetimes; -using Avalonia.Markup.Xaml; -using Chief.Utils; -using Chief.ViewModels; -using Chief.Views; -using I18N.Avalonia; -using I18N.Avalonia.Interface; -using Splat; - -namespace Chief; - -public class App : Application -{ - public override void Initialize() - { - Cache.Config.LoadConfig(); - AvaloniaXamlLoader.Load(this); - } - - public override void RegisterServices() - { - base.RegisterServices(); - Locator.CurrentMutable.RegisterLazySingleton(() => new Localizer(I18N.Resource.ResourceManager), - typeof(ILocalizer)); - } - - public override void OnFrameworkInitializationCompleted() - { - if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) - { - desktop.MainWindow = new MainWindow - { - DataContext = new MainWindowViewModel(), - }; - } - - base.OnFrameworkInitializationCompleted(); - } -} \ No newline at end of file diff --git a/Chief/Chief.csproj b/Chief/Chief.csproj deleted file mode 100644 index eb335a1..0000000 --- a/Chief/Chief.csproj +++ /dev/null @@ -1,56 +0,0 @@ - - - WinExe - net8.0 - enable - true - app.manifest - true - 12 - - - - - - - - - - - - - - - - - - - - - - - - - ResXFileCodeGenerator - Resource.Designer.cs - - - - - - - True - True - Resource.resx - - - WoolangIndex.axaml - Code - - - - - - - - diff --git a/Chief/I18N/Resource.Designer.cs b/Chief/I18N/Resource.Designer.cs deleted file mode 100644 index 4c54ad2..0000000 --- a/Chief/I18N/Resource.Designer.cs +++ /dev/null @@ -1,188 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace Chief.I18N { - using System; - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Resource { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Resource() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Chief.I18N.Resource", typeof(Resource).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - - /// - /// Looks up a localized string similar to Baozi 包管理器. - /// - internal static string Baozi { - get { - return ResourceManager.GetString("Baozi", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Chief 本体设置. - /// - internal static string ChiefConfig { - get { - return ResourceManager.GetString("ChiefConfig", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to 主题样式. - /// - internal static string ConfigA1 { - get { - return ResourceManager.GetString("ConfigA1", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to 语言设置 (Language). - /// - internal static string ConfigA2 { - get { - return ResourceManager.GetString("ConfigA2", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to 设置. - /// - internal static string ConfigTitle { - get { - return ResourceManager.GetString("ConfigTitle", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to 全新安装. - /// - internal static string InstallButton { - get { - return ResourceManager.GetString("InstallButton", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to JoyEngine 引擎. - /// - internal static string JoyECS { - get { - return ResourceManager.GetString("JoyECS", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to 模块设置. - /// - internal static string ModifyButton { - get { - return ResourceManager.GetString("ModifyButton", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to 安装,编辑或卸载此设备上的. - /// - internal static string ModuleManageSubtitle { - get { - return ResourceManager.GetString("ModuleManageSubtitle", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to 管理. - /// - internal static string ModuleManageTitle { - get { - return ResourceManager.GetString("ModuleManageTitle", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to 重置所有设置. - /// - internal static string ResetConfig { - get { - return ResourceManager.GetString("ResetConfig", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to 当前多语言支持不完善,请使用“简体中文”语言。. - /// - internal static string TranslateNotice { - get { - return ResourceManager.GetString("TranslateNotice", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to 欢迎使用 Chief. - /// - internal static string WelcomeTitle { - get { - return ResourceManager.GetString("WelcomeTitle", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Woolang 编译器. - /// - internal static string Woolang { - get { - return ResourceManager.GetString("Woolang", resourceCulture); - } - } - } -} diff --git a/Chief/I18N/Resource.en-US.resx b/Chief/I18N/Resource.en-US.resx deleted file mode 100644 index f6b8147..0000000 --- a/Chief/I18N/Resource.en-US.resx +++ /dev/null @@ -1,175 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, - PublicKeyToken=b77a5c561934e089 - - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, - PublicKeyToken=b77a5c561934e089 - - - - Baozi Package Manager - - - Chief Configurations - - - Theme - - - Languages - - - Configurations - - - Install - - - NULL - - - NULL - - - NULL - - - JoyEngine ECS - - - Modify - - - Install, modify or remove - - - Manage - - - Reset All - - - English localization is currently in beta. Use Simplified Chinese for full experience. - - - Welcome to Chief - - - Woolang Compiler - - \ No newline at end of file diff --git a/Chief/I18N/Resource.ja-JP.resx b/Chief/I18N/Resource.ja-JP.resx deleted file mode 100644 index 64377a9..0000000 --- a/Chief/I18N/Resource.ja-JP.resx +++ /dev/null @@ -1,176 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, - PublicKeyToken=b77a5c561934e089 - - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, - PublicKeyToken=b77a5c561934e089 - - - - Baozi パッケージマネージャー - - - Chief オントロジー設定 - - - NULL - - - NULL - - - NULL - - - NULL - - - NULL - - - NULL - - - NULL - - - JoyEngine ゲームエンジン - - - NULL - - - NULL - - - NULL - - - NULL - - - 当前多语言支持不完善,请使用“简体中文”语言。 - - - Chief へ、ようこそ - - - Woolang コンパイラ - - \ No newline at end of file diff --git a/Chief/I18N/Resource.resx b/Chief/I18N/Resource.resx deleted file mode 100644 index b8df8fa..0000000 --- a/Chief/I18N/Resource.resx +++ /dev/null @@ -1,74 +0,0 @@ - - - - - - - text/microsoft-resx - - - 1.3 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, - PublicKeyToken=b77a5c561934e089 - - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, - PublicKeyToken=b77a5c561934e089 - - - - Baozi 包管理器 - - - Chief 本体设置 - - - 主题样式 - - - 语言设置 (Language) - - - 设置 - - - 全新安装 - - - 选择安装方式 - - - 获取程序资源 - - - 编译 - - - JoyEngine 引擎 - - - 模块设置 - - - 安装,修改或卸载此设备上的 - - - 管理 - - - 重置所有设置 - - - 当前多语言支持不完善,请使用“简体中文”语言。 - - - 欢迎使用 Chief - - - Woolang 编译器 - - \ No newline at end of file diff --git a/Chief/I18N/Resource.zh-CN.resx b/Chief/I18N/Resource.zh-CN.resx deleted file mode 100644 index b608e32..0000000 --- a/Chief/I18N/Resource.zh-CN.resx +++ /dev/null @@ -1,176 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, - PublicKeyToken=b77a5c561934e089 - - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, - PublicKeyToken=b77a5c561934e089 - - - - Baozi 包管理器 - - - Chief 程序设置 - - - 主题样式 - - - 语言设置 (Language) - - - 设置 - - - 全新安装 - - - 选择安装方式 - - - 获取程序资源 - - - 编译 - - - JoyEngine 引擎 - - - 模块设置 - - - 安装,编辑或卸载此设备上的 - - - 管理 - - - 重置所有设置 - - - 当前多语言支持不完善,请使用“简体中文”语言。 - - - 欢迎使用 Chief - - - Woolang 编译器 - - \ No newline at end of file diff --git a/Chief/Models/Enum.cs b/Chief/Models/Enum.cs deleted file mode 100644 index 439360e..0000000 --- a/Chief/Models/Enum.cs +++ /dev/null @@ -1,22 +0,0 @@ -namespace Chief.Models; - -public enum ModuleSource -{ - Woolang, - Baozi, - JoyEngine -} - -public enum ThemeMode -{ - Light, - Dark, - SyncWithSystem -} - -public enum SupportedLanguage -{ - English, - Chinese, - Japanese -} \ No newline at end of file diff --git a/Chief/PageTransitions/DrillTransition.cs b/Chief/PageTransitions/DrillTransition.cs deleted file mode 100644 index 41bd075..0000000 --- a/Chief/PageTransitions/DrillTransition.cs +++ /dev/null @@ -1,131 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using Avalonia; -using Avalonia.Animation; -using Avalonia.Animation.Easings; -using Avalonia.Controls; -using Avalonia.Media; -using Avalonia.Styling; -using Avalonia.VisualTree; -using Chief.Utils; - -namespace Chief.PageTransitions; - -public class DrillTransition : IPageTransition -{ - public bool Backward { get; init; } - - public async Task Start(Visual? from, Visual? to, bool forward, CancellationToken cancellationToken) - { - if (cancellationToken.IsCancellationRequested) - { - return; - } - - var animations = new List(); - - if (from != null) - { - foreach (var child in from.GetVisualDescendants().OfType()) - { - child.IsEnabled = false; - } - - animations.Add(Fade(false).RunAsync(from, cancellationToken)); - if (Backward) - { - animations.Add(Drill(ScaleTransform.ScaleXProperty, false).RunAsync(from, cancellationToken)); - animations.Add(Drill(ScaleTransform.ScaleYProperty, false).RunAsync(from, cancellationToken)); - } - } - - if (to != null) - { - to.IsVisible = true; - animations.Add(Fade(true).RunAsync(to, cancellationToken)); - if (!Backward) - { - animations.Add(Drill(ScaleTransform.ScaleXProperty, true).RunAsync(to, cancellationToken)); - animations.Add(Drill(ScaleTransform.ScaleYProperty, true).RunAsync(to, cancellationToken)); - } - } - - await Task.WhenAll(animations); - - if (from != null && !cancellationToken.IsCancellationRequested) - { - from.IsVisible = false; - } - } - - private Animation Fade(bool isOut) => new() - { - FillMode = FillMode.Forward, - Duration = TimeSpan.FromMilliseconds(Cache.Config.Instance!.AnimationSpeed), - Easing = new SineEaseIn(), - Children = - { - new KeyFrame() - { - Setters = - { - new Setter() - { - Property = Visual.OpacityProperty, - Value = isOut ? 0.0d : 1.0d - } - }, - Cue = new Cue(0d) - }, - new KeyFrame() - { - Setters = - { - new Setter() - { - Property = Visual.OpacityProperty, - Value = isOut ? 1.0d : 0.0d - } - }, - Cue = new Cue(1.0d) - } - } - }; - - private Animation Drill(AvaloniaProperty prop, bool isOut) => new() - { - FillMode = FillMode.Forward, - Easing = isOut ? new SineEaseOut() : new SineEaseIn(), - Duration = TimeSpan.FromMilliseconds(Cache.Config.Instance!.AnimationSpeed), - Children = - { - new KeyFrame - { - Setters = - { - new Setter - { - Property = prop, - Value = isOut ? 0.75d : 1.0d - } - }, - Cue = new Cue(0.0d) - }, - new KeyFrame - { - Setters = - { - new Setter - { - Property = prop, - Value = isOut ? 1.0d : 0.75d - } - }, - Cue = new Cue(1.0d) - } - } - }; -} \ No newline at end of file diff --git a/Chief/Utils/Cache.cs b/Chief/Utils/Cache.cs deleted file mode 100644 index 8e10ed0..0000000 --- a/Chief/Utils/Cache.cs +++ /dev/null @@ -1,105 +0,0 @@ -using System; -using System.Diagnostics; -using System.Globalization; -using System.IO; -using System.Threading; -using System.Threading.Tasks; -using Chief.Models; -using I18N.Avalonia.Interface; -using Newtonsoft.Json; -using Splat; - -namespace Chief.Utils; - -public class Cache -{ - public static readonly string CacheDir = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); - private static readonly string ChiefDir = Path.Combine(CacheDir, "Chief"); - - public static async Task ChangeCacheDir(string destDir, bool moveExistData = true) - { - if (destDir == ChiefDir) return true; - try - { - Directory.CreateDirectory(destDir); - if (moveExistData) - foreach (var file in Directory.EnumerateFiles(ChiefDir, "*", SearchOption.AllDirectories)) - { - var relativePath = Path.GetDirectoryName( - Path.GetRelativePath(ChiefDir, file)) ?? string.Empty; - Directory.CreateDirectory(Path.Combine(destDir, relativePath)); - await using var sourceStream = File.Open(file, FileMode.Open); - await using var destStream = - File.Create(Path.Combine(destDir, relativePath, Path.GetFileName(file))); - await sourceStream.CopyToAsync(destStream); - } - } - catch (Exception e) - { - //TODO: Exception handling - Debug.WriteLine(e); - return false; - } - - - return true; - } - - public class Config - { - [JsonIgnore] public static readonly string ConfigDir = Path.Combine(ChiefDir, "Config.json"); - [JsonIgnore] public static Config? Instance; - - private Config() - { - if (!File.Exists(ConfigDir)) - { - AppLanguage = Thread.CurrentThread.CurrentCulture.Name; - } - else - try - { - var json = File.ReadAllText(ConfigDir); - JsonConvert.PopulateObject(json, this); - } - catch - { - //TODO: Exception handling - } - } - - [JsonProperty("CacheDir")] private static string AppCacheDir => ChiefDir; - - [JsonProperty("Theme")] public ThemeMode AppTheme { get; set; } = ThemeMode.SyncWithSystem; - - [JsonProperty("Language")] - public string AppLanguage - { - get => Locator.Current.GetService()!.Language.Name; - set => Locator.Current.GetService()!.Language = new CultureInfo(value); - } - - [JsonProperty("Animation")] public double AnimationSpeed { get; set; } = 500; - - public CultureInfo GetAppCultureInfo() => new(AppLanguage); - public static void LoadConfig() => Instance = new Config(); - - public bool Save() - { - if (!Directory.Exists(ChiefDir)) - Directory.CreateDirectory(ChiefDir); - try - { - var json = JsonConvert.SerializeObject(this); - File.WriteAllText(ConfigDir, json); - } - catch (Exception e) - { - Debug.WriteLine(e); - return false; - } - - return true; - } - } -} \ No newline at end of file diff --git a/Chief/Utils/Converter.cs b/Chief/Utils/Converter.cs deleted file mode 100644 index f65cfe0..0000000 --- a/Chief/Utils/Converter.cs +++ /dev/null @@ -1,57 +0,0 @@ -using System; -using Avalonia; -using Avalonia.Platform; -using Avalonia.Styling; -using Chief.Models; - -namespace Chief.Utils; - -public static class ThemeConverter -{ - public static ThemeVariant PlatformThemeVar2AppThemeVar(PlatformThemeVariant systemTheme) - { - return systemTheme switch - { - PlatformThemeVariant.Light => ThemeVariant.Light, - PlatformThemeVariant.Dark => ThemeVariant.Dark, - _ => throw new ArgumentOutOfRangeException(nameof(systemTheme), systemTheme, null) - }; - } - - public static ThemeVariant ThemeMode2AppThemeVar(ThemeMode themeMode) - { - return themeMode switch - { - ThemeMode.Light => ThemeVariant.Light, - ThemeMode.Dark => ThemeVariant.Dark, - ThemeMode.SyncWithSystem => PlatformThemeVar2AppThemeVar(Application.Current!.PlatformSettings! - .GetColorValues().ThemeVariant), - _ => throw new ArgumentOutOfRangeException(nameof(themeMode), themeMode, null) - }; - } -} - -public static class LanguageConverter -{ - public static string SupportedLanguage2LanguageCode(SupportedLanguage language) - { - return language switch - { - SupportedLanguage.English => "en-US", - SupportedLanguage.Chinese => "zh-CN", - SupportedLanguage.Japanese => "ja-JP", - _ => throw new ArgumentOutOfRangeException(nameof(language), language, null) - }; - } - - public static SupportedLanguage LanguageCode2SupportedLanguage(string languageCode) - { - return languageCode switch - { - "en-US" => SupportedLanguage.English, - "zh-CN" => SupportedLanguage.Chinese, - "ja-JP" => SupportedLanguage.Japanese, - _ => throw new ArgumentOutOfRangeException(nameof(languageCode), languageCode, null) - }; - } -} \ No newline at end of file diff --git a/Chief/ViewLocator.cs b/Chief/ViewLocator.cs deleted file mode 100644 index e09fed9..0000000 --- a/Chief/ViewLocator.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System; -using Avalonia.Controls; -using Avalonia.Controls.Templates; -using Chief.ViewModels; - -namespace Chief; - -public class ViewLocator : IDataTemplate -{ - public Control Build(object? data) - { - var name = data!.GetType().FullName!.Replace("ViewModel", "View"); - 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/Chief/ViewModels/ConfigViewModel.cs b/Chief/ViewModels/ConfigViewModel.cs deleted file mode 100644 index 7937547..0000000 --- a/Chief/ViewModels/ConfigViewModel.cs +++ /dev/null @@ -1,61 +0,0 @@ -using System.Collections.Generic; -using Avalonia; -using Chief.Models; -using Chief.Utils; -using ReactiveUI; - -namespace Chief.ViewModels; - -public class ConfigViewModel : PageViewModel -{ - private bool _isChinese = Cache.Config.Instance!.AppLanguage == "zh-CN"; - - public static List Themes => new() - { - ThemeMode.Light, - ThemeMode.Dark, - ThemeMode.SyncWithSystem - }; - - public static List Languages => new() - { - SupportedLanguage.English, - SupportedLanguage.Chinese, - SupportedLanguage.Japanese - }; - - public ThemeMode CurrentTheme - { - get => Cache.Config.Instance!.AppTheme; - set - { - if (value == ThemeMode.SyncWithSystem) - Application.Current!.PlatformSettings!.ColorValuesChanged += - MainWindowViewModel.Instance!.SystemThemeChangedEvent; - else - Application.Current!.PlatformSettings!.ColorValuesChanged -= - MainWindowViewModel.Instance!.SystemThemeChangedEvent; - - Cache.Config.Instance!.AppTheme = value; - MainWindowViewModel.Instance.CurrentTheme = ThemeConverter.ThemeMode2AppThemeVar(value); - Cache.Config.Instance.Save(); - } - } - - public bool IsChinese - { - get => _isChinese; - set => this.RaiseAndSetIfChanged(ref _isChinese, value); - } - - public SupportedLanguage CurrentLanguage - { - get => LanguageConverter.LanguageCode2SupportedLanguage(Cache.Config.Instance!.AppLanguage); - set - { - IsChinese = value == SupportedLanguage.Chinese; - Cache.Config.Instance!.AppLanguage = LanguageConverter.SupportedLanguage2LanguageCode(value); - Cache.Config.Instance.Save(); - } - } -} \ No newline at end of file diff --git a/Chief/ViewModels/IndexViewModel.cs b/Chief/ViewModels/IndexViewModel.cs deleted file mode 100644 index 6cd0302..0000000 --- a/Chief/ViewModels/IndexViewModel.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System.Windows.Input; -using Chief.Models; -using Chief.PageTransitions; -using Chief.Views.Pages; -using ReactiveUI; - -namespace Chief.ViewModels; - -public class IndexViewModel : ViewModelBase -{ - public static ICommand GotoWoolangCommand => ReactiveCommand.Create(() => - { - MainWindowViewModel.Instance!.Navigate( - new ModuleManageViewModel(ModuleSource.Woolang), - transition: new DrillTransition()); - }); - - public static ICommand GotoBaoziCommand => ReactiveCommand.Create(() => - { - MainWindowViewModel.Instance!.Navigate( - new ModuleManageViewModel(ModuleSource.Baozi), - transition: new DrillTransition()); - }); - - public static ICommand GotoJoyEngineCommand => ReactiveCommand.Create(() => - { - MainWindowViewModel.Instance!.Navigate( - new ModuleManageViewModel(ModuleSource.JoyEngine), - transition: new DrillTransition()); - }); - - public static ICommand GotoConfigCommand => ReactiveCommand.Create(() => - { - MainWindowViewModel.Instance!.Navigate( - new ConfigViewModel(), transition: new DrillTransition()); - }); -} \ No newline at end of file diff --git a/Chief/ViewModels/MainWindowViewModel.cs b/Chief/ViewModels/MainWindowViewModel.cs deleted file mode 100644 index 7af5f98..0000000 --- a/Chief/ViewModels/MainWindowViewModel.cs +++ /dev/null @@ -1,89 +0,0 @@ -using System.Collections.Generic; -using Avalonia; -using Avalonia.Animation; -using Avalonia.Controls; -using Avalonia.Media; -using Avalonia.Platform; -using Avalonia.Styling; -using Chief.Models; -using Chief.Utils; -using ReactiveUI; - -namespace Chief.ViewModels; - -public class MainWindowViewModel : ViewModelBase -{ - private static readonly Dictionary ThemeColors = new() - { - { ThemeVariant.Light, Colors.SeaShell }, - { ThemeVariant.Dark, Color.FromArgb(51, 46, 46, 20) } - }; - - private UserControl _currentContent = new Views.Pages.Index(); - - private ThemeVariant _currentTheme = ThemeConverter.ThemeMode2AppThemeVar(Cache.Config.Instance!.AppTheme); - - private Color _themeColor = ThemeColors[ThemeConverter.ThemeMode2AppThemeVar(Cache.Config.Instance.AppTheme)]; - - private IPageTransition _transition = new CrossFade(); - - public MainWindowViewModel() - { - if (Cache.Config.Instance!.AppTheme == ThemeMode.SyncWithSystem) - Application.Current!.PlatformSettings!.ColorValuesChanged += SystemThemeChangedEvent; - Instance = this; - } - - public ThemeVariant CurrentTheme - { - get => _currentTheme; - set - { - BaseColor = ThemeColors[value]; - this.RaiseAndSetIfChanged(ref _currentTheme, value); - } - } - - public Color BaseColor - { - get => _themeColor; - set => this.RaiseAndSetIfChanged(ref _themeColor, value); - } - - public static MainWindowViewModel? Instance { get; set; } - - public UserControl CurrentContent - { - get => _currentContent; - set => this.RaiseAndSetIfChanged(ref _currentContent, value); - } - - public IPageTransition Transition - { - get => _transition; - set => this.RaiseAndSetIfChanged(ref _transition, value); - } - - public void Navigate(IPageTransition? transition = null) - where TV : UserControl, new() - where TM : new() - { - Navigate(new TM(), transition); - } - - public void Navigate(TM viewModel, IPageTransition? transition = null) - where TV : UserControl, new() - { - Transition = transition ?? new CrossFade(); - CurrentContent = new TV - { - DataContext = viewModel - }; - } - - public void SystemThemeChangedEvent(object? o, PlatformColorValues values) - { - CurrentTheme = ThemeConverter.PlatformThemeVar2AppThemeVar(values.ThemeVariant); - BaseColor = ThemeColors[ThemeConverter.PlatformThemeVar2AppThemeVar(values.ThemeVariant)]; - } -} \ No newline at end of file diff --git a/Chief/ViewModels/ModuleInstallViewModel.cs b/Chief/ViewModels/ModuleInstallViewModel.cs deleted file mode 100644 index 829ec4e..0000000 --- a/Chief/ViewModels/ModuleInstallViewModel.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System; -using Chief.I18N; -using Chief.Models; -using Chief.Utils; - -namespace Chief.ViewModels; - -public class ModuleInstallViewModel(ModuleSource source) : ViewModelBase -{ - public ModuleInstallViewModel() : this(ModuleSource.Woolang) - { - } - - public string SourceName => - source switch - { - ModuleSource.Woolang => - Resource.ResourceManager.GetString("Woolang", Cache.Config.Instance!.GetAppCultureInfo())!, - ModuleSource.Baozi => Resource.ResourceManager.GetString("Baozi", - Cache.Config.Instance!.GetAppCultureInfo())!, - ModuleSource.JoyEngine => Resource.ResourceManager.GetString("JoyECS", - Cache.Config.Instance!.GetAppCultureInfo())!, - _ => throw new ArgumentOutOfRangeException() - }; -} \ No newline at end of file diff --git a/Chief/ViewModels/ModuleManageViewModel.cs b/Chief/ViewModels/ModuleManageViewModel.cs deleted file mode 100644 index 5daae1a..0000000 --- a/Chief/ViewModels/ModuleManageViewModel.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System; -using Chief.I18N; -using Chief.Models; -using Chief.Utils; - -namespace Chief.ViewModels; - -public class ModuleManageViewModel(ModuleSource source) : PageViewModel -{ - public ModuleManageViewModel() : this(ModuleSource.Woolang) - { - } - - public string SourceName => - source switch - { - ModuleSource.Woolang => - Resource.ResourceManager.GetString("Woolang", Cache.Config.Instance!.GetAppCultureInfo())!, - ModuleSource.Baozi => Resource.ResourceManager.GetString("Baozi", - Cache.Config.Instance!.GetAppCultureInfo())!, - ModuleSource.JoyEngine => Resource.ResourceManager.GetString("JoyECS", - Cache.Config.Instance!.GetAppCultureInfo())!, - _ => throw new ArgumentOutOfRangeException() - }; -} \ No newline at end of file diff --git a/Chief/ViewModels/PageViewModel.cs b/Chief/ViewModels/PageViewModel.cs deleted file mode 100644 index b81c82b..0000000 --- a/Chief/ViewModels/PageViewModel.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System.Windows.Input; -using Chief.PageTransitions; -using Chief.Views.Pages; - -namespace Chief.ViewModels; - -public class PageViewModel : ViewModelBase -{ - public ICommand GotoIndexCommand { get; } = ReactiveUI.ReactiveCommand.Create(() => - { - MainWindowViewModel.Instance!.Navigate(new DrillTransition - { Backward = true }); - }); -} \ No newline at end of file diff --git a/Chief/ViewModels/ViewModelBase.cs b/Chief/ViewModels/ViewModelBase.cs deleted file mode 100644 index 2e18aa0..0000000 --- a/Chief/ViewModels/ViewModelBase.cs +++ /dev/null @@ -1,7 +0,0 @@ -using ReactiveUI; - -namespace Chief.ViewModels; - -public class ViewModelBase : ReactiveObject -{ -} \ No newline at end of file diff --git a/Chief/Views/MainWindow.axaml b/Chief/Views/MainWindow.axaml deleted file mode 100644 index ecec525..0000000 --- a/Chief/Views/MainWindow.axaml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Chief/Views/MainWindow.axaml.cs b/Chief/Views/MainWindow.axaml.cs deleted file mode 100644 index f70f09d..0000000 --- a/Chief/Views/MainWindow.axaml.cs +++ /dev/null @@ -1,11 +0,0 @@ -using Avalonia.Controls; - -namespace Chief.Views; - -public partial class MainWindow : Window -{ - public MainWindow() - { - InitializeComponent(); - } -} \ No newline at end of file diff --git a/Chief/Views/Pages/Config.axaml b/Chief/Views/Pages/Config.axaml deleted file mode 100644 index 892f1d7..0000000 --- a/Chief/Views/Pages/Config.axaml +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Chief/Views/Pages/Index.axaml.cs b/Chief/Views/Pages/Index.axaml.cs deleted file mode 100644 index e990a9f..0000000 --- a/Chief/Views/Pages/Index.axaml.cs +++ /dev/null @@ -1,11 +0,0 @@ -using Avalonia.Controls; - -namespace Chief.Views.Pages; - -public partial class Index : UserControl -{ - public Index() - { - InitializeComponent(); - } -} \ No newline at end of file diff --git a/Chief/Views/Pages/ModuleInstall.axaml b/Chief/Views/Pages/ModuleInstall.axaml deleted file mode 100644 index 2f8409f..0000000 --- a/Chief/Views/Pages/ModuleInstall.axaml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Chief/Views/Pages/ModuleInstall.axaml.cs b/Chief/Views/Pages/ModuleInstall.axaml.cs deleted file mode 100644 index 852675b..0000000 --- a/Chief/Views/Pages/ModuleInstall.axaml.cs +++ /dev/null @@ -1,11 +0,0 @@ -using Avalonia.Controls; - -namespace Chief.Views.Pages; - -public partial class ModuleInstall : UserControl -{ - public ModuleInstall() - { - InitializeComponent(); - } -} \ No newline at end of file diff --git a/Chief/Views/Pages/ModuleManage.axaml b/Chief/Views/Pages/ModuleManage.axaml deleted file mode 100644 index c5c07d7..0000000 --- a/Chief/Views/Pages/ModuleManage.axaml +++ /dev/null @@ -1,58 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Chief/Views/Pages/ModuleManage.axaml.cs b/Chief/Views/Pages/ModuleManage.axaml.cs deleted file mode 100644 index 4653ec5..0000000 --- a/Chief/Views/Pages/ModuleManage.axaml.cs +++ /dev/null @@ -1,11 +0,0 @@ -using Avalonia.Controls; - -namespace Chief.Views.Pages; - -public partial class ModuleManage : UserControl -{ - public ModuleManage() - { - InitializeComponent(); - } -} \ No newline at end of file diff --git a/Chief/app.manifest b/Chief/app.manifest deleted file mode 100644 index 80ced46..0000000 --- a/Chief/app.manifest +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - diff --git a/ChiefCore/BaoziInstaller.cs b/ChiefCore/BaoziInstaller.cs deleted file mode 100644 index 950d099..0000000 --- a/ChiefCore/BaoziInstaller.cs +++ /dev/null @@ -1,5 +0,0 @@ -namespace ChiefCore; - -public class BaoziInstaller -{ -} \ No newline at end of file diff --git a/ChiefCore/ChiefCore.csproj b/ChiefCore/ChiefCore.csproj deleted file mode 100644 index 95019e2..0000000 --- a/ChiefCore/ChiefCore.csproj +++ /dev/null @@ -1,17 +0,0 @@ - - - - net8.0 - enable - enable - 12 - - - - - - - - - - diff --git a/ChiefCore/WoolangInstaller.cs b/ChiefCore/WoolangInstaller.cs deleted file mode 100644 index dedde1b..0000000 --- a/ChiefCore/WoolangInstaller.cs +++ /dev/null @@ -1,223 +0,0 @@ -using System.Diagnostics; -using System.Globalization; -using System.Runtime.InteropServices; -using System.Text; -using System.Text.RegularExpressions; -using LibGit2Sharp; -using LibGit2Sharp.Handlers; -using Medallion.Shell; -using Microsoft.VisualStudio.Setup.Configuration; - -namespace ChiefCore; - -public record VisualStudioInfo -{ - public required string Path; - public InstanceState State = InstanceState.None; - public required string Version; -} - -public record WoolangCompilerInfo -{ - public DateTime? BuildTime; - public string? Commit; - public required string Path; - public required string Version; -} - -public static partial class WoolangInstallerExtensions -{ - [GeneratedRegex(@"\x1B\[[0-9;]*[mK]")] - private static partial Regex RemoveColorCharsRegex(); - - public static List? GetAllVisualStudioInfos() - { - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - return null; - - var result = new List(); - try - { - var query = new SetupConfiguration(); - var query2 = (ISetupConfiguration2)query; - var e = query2.EnumAllInstances(); - int fetched; - var instances = new ISetupInstance[1]; - do - { - e.Next(1, instances, out fetched); - if (fetched <= 0) continue; - var instance = (ISetupInstance2)instances[0]; - var state = instance.GetState(); - result.Add(new VisualStudioInfo - { - State = state, - Version = instance.GetInstallationVersion(), - Path = instance.GetInstallationPath() - }); - } while (fetched > 0); - } - catch (COMException ex) when (ex.HResult == unchecked((int)0x80040154)) - { - Debug.WriteLine("The query API is not registered. Assuming no instances are installed."); - } - catch (Exception ex) - { - Debug.WriteLine($"Error 0x{ex.HResult:x8}: {ex.Message}"); - } - - return result; - } - - public static async Task?> GetAllWoolangCompilerInfos() - { - var result = new List(); - string finder, woolang; - - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - finder = "where"; - woolang = "woodriver.exe"; - } - else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) || RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) - { - finder = "which"; - woolang = "woodriver"; - } - else return null; - - - var process = Process.Start(new ProcessStartInfo - { - FileName = finder, - Arguments = woolang, - RedirectStandardOutput = true, - UseShellExecute = false, - CreateNoWindow = true - }); - var woolangDirs = (await process!.StandardOutput.ReadToEndAsync()).Split("\r\n").ToList(); - woolangDirs.RemoveAll(x => !x.EndsWith(woolang)); - foreach (var copDir in woolangDirs) - { - try - { - process = Process.Start(new ProcessStartInfo - { - FileName = copDir, - RedirectStandardOutput = true, - UseShellExecute = false, - CreateNoWindow = true - }); - var woolangInfo = RemoveColorCharsRegex().Replace(await process!.StandardOutput.ReadToEndAsync(), "") - .Split("\r\n").ToList(); - result.Add(new WoolangCompilerInfo - { - BuildTime = Convert.ToDateTime(woolangInfo[3].Remove(0, 6), CultureInfo.InvariantCulture), - Commit = woolangInfo[2].Remove(0, 8) != "untracked" ? woolangInfo[2].Remove(0, 8) : null, - Path = copDir, - Version = woolangInfo[1].Remove(0, 9) - }); - } - catch (Exception e) - { - Debug.WriteLine(e); - } - } - - return result; - } -} - -public class WoolangInstaller(string cachePath, ICollection outputPipe, - VisualStudioInfo? visualStudioInfo = null) -{ - public ProgressHandler? ProgressEvent { get; set; } - - public async Task BuildWoolangCompiler() - { - if (Directory.Exists(cachePath) && Directory.EnumerateFileSystemEntries(cachePath).Any()) - return false; - - var repoGitPath = Repository.Clone("https://git.cinogama.net/cinogamaproject/woolang.git", cachePath, - new CloneOptions - { - BranchName = "release", - Checkout = true, - RecurseSubmodules = true, - OnProgress = ProgressEvent - }); - var repo = new Repository(repoGitPath); - await File.WriteAllTextAsync(Path.Combine(cachePath, "src", "wo_info.hpp"), $"\"{repo.Commits.First().Sha}\""); - - Directory.CreateDirectory(Path.Combine(cachePath, "build")); - - var cmd = new Shell(opts => opts - .WorkingDirectory(Path.Combine(cachePath, "build"))); - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - if (visualStudioInfo is null) return false; - if (RuntimeInformation.OSArchitecture is Architecture.X64 or Architecture.X86 or Architecture.Arm64) - await cmd.Run(Path.Combine(visualStudioInfo.Path, - "Common7", "IDE", "CommonExtensions", "Microsoft", "CMake", "CMake", "bin", "cmake.exe"), - cachePath, "-DWO_MAKE_OUTPUT_IN_SAME_PATH=ON", "-DCMAKE_BUILD_TYPE=RELWITHDEBINFO") - .RedirectTo(outputPipe) - .RedirectStandardErrorTo(outputPipe).Task; - else - await cmd.Run(Path.Combine(visualStudioInfo.Path, - "Common7", "IDE", "CommonExtensions", "Microsoft", "CMake", "CMake", "bin", "cmake.exe"), - cachePath, "-DWO_MAKE_OUTPUT_IN_SAME_PATH=ON", "-DCMAKE_BUILD_TYPE=RELWITHDEBINFO", - "-DWO_SUPPORT_ASMJIT=OFF") // disable asmjit - .RedirectTo(outputPipe) - .RedirectStandardErrorTo(outputPipe).Task; - - await cmd.Run(Path.Combine(visualStudioInfo.Path, "MSBuild", "Current", "Bin", "MSBuild.exe"), - Path.Combine(cachePath, "build", "driver", "woodriver.vcxproj"), "/p:Configuration=Release", - "-maxCpuCount", "-m") - .RedirectTo(outputPipe) - .RedirectStandardErrorTo(outputPipe).Task; - } - else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) || RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) - { - if (RuntimeInformation.OSArchitecture is Architecture.X64 or Architecture.X86 or Architecture.Arm64) - await cmd.Run("cmake", cachePath, "-DWO_MAKE_OUTPUT_IN_SAME_PATH=ON", - "-DCMAKE_BUILD_TYPE=RELWITHDEBINFO") - .RedirectTo(outputPipe) - .RedirectStandardErrorTo(outputPipe).Task; - else - await cmd.Run("cmake", cachePath, "-DWO_MAKE_OUTPUT_IN_SAME_PATH=ON", - "-DCMAKE_BUILD_TYPE=RELWITHDEBINFO", - "-DWO_SUPPORT_ASMJIT=OFF") // disable asmjit - .RedirectTo(outputPipe) - .RedirectStandardErrorTo(outputPipe).Task; - - await cmd.Run("make", "-C", Path.Combine(cachePath, "build"), "-j") - .RedirectTo(outputPipe) - .RedirectStandardErrorTo(outputPipe).Task; - } - - return true; - } - - public int InstallWoolangCompiler(string installPath, bool writeEnv = true) - { - var woodriver = Path.Combine(cachePath, "build", "Release", "woodriver.exe"); - var libwooExt = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "dll" : "so"; - var libwoo = Path.Combine(cachePath, "build", "Release", $"libwoo.{libwooExt}"); - if (!File.Exists(woodriver) || !File.Exists(libwoo)) return 4; - Directory.CreateDirectory(installPath); - File.Copy(woodriver, Path.Combine(installPath, "woodriver.exe"), true); - File.Copy(libwoo, Path.Combine(installPath, $"libwoo.{libwooExt}"), true); - if (writeEnv) - { - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - return 1; - var envPath = Environment.GetEnvironmentVariable("PATH", EnvironmentVariableTarget.User); - var sb = new StringBuilder(envPath); - sb.Append(';'); - sb.Append(installPath); - Environment.SetEnvironmentVariable("PATH", sb.ToString(), EnvironmentVariableTarget.User); - } - - return 0; - } -} \ No newline at end of file diff --git a/src/Chief.App/App.axaml b/src/Chief.App/App.axaml new file mode 100644 index 0000000..c7173b6 --- /dev/null +++ b/src/Chief.App/App.axaml @@ -0,0 +1,14 @@ + + + + + + + + + \ No newline at end of file diff --git a/src/Chief.App/App.axaml.cs b/src/Chief.App/App.axaml.cs new file mode 100644 index 0000000..c372b4a --- /dev/null +++ b/src/Chief.App/App.axaml.cs @@ -0,0 +1,23 @@ +using Avalonia; +using Avalonia.Controls.ApplicationLifetimes; +using Avalonia.Markup.Xaml; + +namespace Chief.App; + +public partial class App : Application +{ + public override void Initialize() + { + AvaloniaXamlLoader.Load(this); + } + + public override void OnFrameworkInitializationCompleted() + { + if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) + { + desktop.MainWindow = new MainWindow(); + } + + base.OnFrameworkInitializationCompleted(); + } +} \ No newline at end of file diff --git a/Chief/Assets/Fonts/HarmonyOS_Sans_SC_Black.ttf b/src/Chief.App/Assets/Fonts/HarmonyOS_Sans_SC/HarmonyOS_Sans_SC_Black.ttf old mode 100644 new mode 100755 similarity index 100% rename from Chief/Assets/Fonts/HarmonyOS_Sans_SC_Black.ttf rename to src/Chief.App/Assets/Fonts/HarmonyOS_Sans_SC/HarmonyOS_Sans_SC_Black.ttf diff --git a/Chief/Assets/Fonts/HarmonyOS_Sans_SC_Bold.ttf b/src/Chief.App/Assets/Fonts/HarmonyOS_Sans_SC/HarmonyOS_Sans_SC_Bold.ttf old mode 100644 new mode 100755 similarity index 100% rename from Chief/Assets/Fonts/HarmonyOS_Sans_SC_Bold.ttf rename to src/Chief.App/Assets/Fonts/HarmonyOS_Sans_SC/HarmonyOS_Sans_SC_Bold.ttf diff --git a/Chief/Assets/Fonts/HarmonyOS_Sans_SC_Light.ttf b/src/Chief.App/Assets/Fonts/HarmonyOS_Sans_SC/HarmonyOS_Sans_SC_Light.ttf old mode 100644 new mode 100755 similarity index 100% rename from Chief/Assets/Fonts/HarmonyOS_Sans_SC_Light.ttf rename to src/Chief.App/Assets/Fonts/HarmonyOS_Sans_SC/HarmonyOS_Sans_SC_Light.ttf diff --git a/Chief/Assets/Fonts/HarmonyOS_Sans_SC_Medium.ttf b/src/Chief.App/Assets/Fonts/HarmonyOS_Sans_SC/HarmonyOS_Sans_SC_Medium.ttf old mode 100644 new mode 100755 similarity index 100% rename from Chief/Assets/Fonts/HarmonyOS_Sans_SC_Medium.ttf rename to src/Chief.App/Assets/Fonts/HarmonyOS_Sans_SC/HarmonyOS_Sans_SC_Medium.ttf diff --git a/Chief/Assets/Fonts/HarmonyOS_Sans_SC_Regular.ttf b/src/Chief.App/Assets/Fonts/HarmonyOS_Sans_SC/HarmonyOS_Sans_SC_Regular.ttf old mode 100644 new mode 100755 similarity index 100% rename from Chief/Assets/Fonts/HarmonyOS_Sans_SC_Regular.ttf rename to src/Chief.App/Assets/Fonts/HarmonyOS_Sans_SC/HarmonyOS_Sans_SC_Regular.ttf diff --git a/Chief/Assets/Fonts/HarmonyOS_Sans_SC_Thin.ttf b/src/Chief.App/Assets/Fonts/HarmonyOS_Sans_SC/HarmonyOS_Sans_SC_Thin.ttf old mode 100644 new mode 100755 similarity index 100% rename from Chief/Assets/Fonts/HarmonyOS_Sans_SC_Thin.ttf rename to src/Chief.App/Assets/Fonts/HarmonyOS_Sans_SC/HarmonyOS_Sans_SC_Thin.ttf diff --git a/Chief/Assets/Fonts/LICENSE.txt b/src/Chief.App/Assets/Fonts/HarmonyOS_Sans_SC/LICENSE.txt similarity index 100% rename from Chief/Assets/Fonts/LICENSE.txt rename to src/Chief.App/Assets/Fonts/HarmonyOS_Sans_SC/LICENSE.txt diff --git a/Chief/Assets/avalonia-logo.ico b/src/Chief.App/Assets/avalonia-logo.ico similarity index 100% rename from Chief/Assets/avalonia-logo.ico rename to src/Chief.App/Assets/avalonia-logo.ico diff --git a/src/Chief.App/Chief.App.csproj b/src/Chief.App/Chief.App.csproj new file mode 100644 index 0000000..92b5d0f --- /dev/null +++ b/src/Chief.App/Chief.App.csproj @@ -0,0 +1,29 @@ + + + WinExe + net7.0 + enable + true + app.manifest + + false + + + + + + + + + + + + + + + + + + + + diff --git a/src/Chief.App/Controls/Card.cs b/src/Chief.App/Controls/Card.cs new file mode 100644 index 0000000..d4d0b71 --- /dev/null +++ b/src/Chief.App/Controls/Card.cs @@ -0,0 +1,10 @@ +using Avalonia.Controls; + +namespace Chief.App.Controls; + +public class Card: ContentControl +{ + public Card() + { + } +} \ No newline at end of file diff --git a/src/Chief.App/MainWindow.axaml b/src/Chief.App/MainWindow.axaml new file mode 100644 index 0000000..56ca2bf --- /dev/null +++ b/src/Chief.App/MainWindow.axaml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Chief.App/MainWindow.axaml.cs b/src/Chief.App/MainWindow.axaml.cs new file mode 100644 index 0000000..88284c7 --- /dev/null +++ b/src/Chief.App/MainWindow.axaml.cs @@ -0,0 +1,63 @@ +using System; +using Avalonia.Interactivity; +using Chief.App.Models; +using Chief.App.Services; +using Chief.App.Views; +using FluentAvalonia.Core; +using FluentAvalonia.UI.Controls; +using FluentAvalonia.UI.Media.Animation; +using FluentAvalonia.UI.Windowing; +using Microsoft.Extensions.DependencyInjection; + +namespace Chief.App; + +public partial class MainWindow : AppWindow +{ + public MainWindow() + { + InitializeComponent(); + + // not working in Linux + // TitleBar.ExtendsContentIntoTitleBar = true; + + ViewModelLocator.Instance.Provider.GetRequiredService().RegisterHandler(Navigate); + + var menu = new PageLink[] + { + new("Home", "Home", typeof(HomeView)), + new("Toolchain", "Toolbox", typeof(ToolchainView)), + new("Packages", "Apps", typeof(PackageView)) + }; + var footer = new PageLink[] + { + new("Settings","Settings",typeof(SettingsView)), + }; + Navigation.MenuItemsSource = menu; + Navigation.FooterMenuItemsSource = footer; + Navigation.SelectedItem = Navigation.MenuItemsSource.ElementAt(0); + Navigate(menu[0].Page); + } + + private void Navigate(Type pageType, object? parameter = null, NavigationTransitionInfo? transition = null) + { + if (transition != null) + { + Root.Navigate(pageType, parameter); + } + else if (parameter != null) + { + Root.Navigate(pageType, parameter); + } + else + { + Root.Navigate(pageType); + } + } + + private void Navigation_OnItemInvoked(object? sender, NavigationViewItemInvokedEventArgs e) + { + if (e.InvokedItemContainer.Tag is PageLink link) + ViewModelLocator.Instance.Provider.GetRequiredService() + .Navigate(link.Page, e.RecommendedNavigationTransitionInfo); + } +} \ No newline at end of file diff --git a/src/Chief.App/Models/PageLink.cs b/src/Chief.App/Models/PageLink.cs new file mode 100644 index 0000000..521c350 --- /dev/null +++ b/src/Chief.App/Models/PageLink.cs @@ -0,0 +1,6 @@ +using System; + +namespace Chief.App.Models; + +// TODO: title 未来替换成 key 用于本地化 +public record PageLink(string Title, string Icon, Type Page); \ No newline at end of file diff --git a/Chief/Program.cs b/src/Chief.App/Program.cs similarity index 79% rename from Chief/Program.cs rename to src/Chief.App/Program.cs index 9775211..5d751ef 100644 --- a/Chief/Program.cs +++ b/src/Chief.App/Program.cs @@ -1,12 +1,12 @@ -using System; -using Avalonia; +using Avalonia; +using Avalonia.ReactiveUI; +using System; using Avalonia.Media; using Avalonia.Media.Fonts; -using Avalonia.ReactiveUI; -namespace Chief; +namespace Chief.App; -internal static class Program +static 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 @@ -17,22 +17,21 @@ public static void Main(string[] args) => BuildAvaloniaApp() // Avalonia configuration, don't remove; also used by visual designer. private static AppBuilder BuildAvaloniaApp() - { - return AppBuilder.Configure() + => AppBuilder.Configure() .UsePlatformDetect() .ConfigureFonts(fm => fm.AddFontCollection( new EmbeddedFontCollection( new Uri("fonts:HarmonyOS_Sans_SC", UriKind.Absolute), - new Uri("avares://Chief/Assets/Fonts", UriKind.Absolute)))) + new Uri("avares://Chief.App/Assets/Fonts/HarmonyOS_Sans_SC", UriKind.Absolute)))) .With(new FontManagerOptions { DefaultFamilyName = "fonts:HarmonyOS_Sans_SC#HarmonyOS Sans SC", FontFallbacks = new FontFallback[] { - new() { FontFamily = new FontFamily("fonts:HarmonyOS_Sans_SC#HarmonyOS Sans SC") }, + new() { FontFamily = new FontFamily("fonts:HarmonyOS_Sans_SC#HarmonyOS Sans") }, } }) + .WithInterFont() .LogToTrace() .UseReactiveUI(); - } } \ No newline at end of file diff --git a/src/Chief.App/Services/NavigationService.cs b/src/Chief.App/Services/NavigationService.cs new file mode 100644 index 0000000..9944ede --- /dev/null +++ b/src/Chief.App/Services/NavigationService.cs @@ -0,0 +1,24 @@ +using System; +using Avalonia.Controls; +using FluentAvalonia.UI.Media.Animation; + +namespace Chief.App.Services; + +public class NavigationService +{ + private Action? navigationHandler; + + public void RegisterHandler(Action handler) + => navigationHandler = handler; + + public void Navigate(NavigationTransitionInfo? transition, object? parameter = null) + where TV : UserControl + =>Navigate(typeof(TV), transition, parameter); + + public void Navigate(object? parameter = null) + where TV : UserControl + => Navigate(null, parameter); + + public void Navigate(Type page, NavigationTransitionInfo? transition, object? parameter = null) + => navigationHandler?.Invoke(page, parameter, transition); +} \ No newline at end of file diff --git a/src/Chief.App/Styles/ControlThemes/CardStyles.axaml b/src/Chief.App/Styles/ControlThemes/CardStyles.axaml new file mode 100644 index 0000000..3815a1d --- /dev/null +++ b/src/Chief.App/Styles/ControlThemes/CardStyles.axaml @@ -0,0 +1,13 @@ + + + + + + + + + + + diff --git a/src/Chief.App/Styles/Controls.axaml b/src/Chief.App/Styles/Controls.axaml new file mode 100644 index 0000000..65fb3f3 --- /dev/null +++ b/src/Chief.App/Styles/Controls.axaml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/src/Chief.App/ViewModelLocator.cs b/src/Chief.App/ViewModelLocator.cs new file mode 100644 index 0000000..fe71d5b --- /dev/null +++ b/src/Chief.App/ViewModelLocator.cs @@ -0,0 +1,32 @@ +using System; +using Chief.App.Services; +using Chief.App.ViewModels; +using Microsoft.Extensions.DependencyInjection; + +namespace Chief.App; + +public class ViewModelLocator +{ + public static ViewModelLocator Instance { get; private set; } = null!; + public IServiceProvider Provider { get; } + + public ViewModelLocator() + { + Provider = ConfigureServices(); + + Instance = this; + } + + private IServiceProvider ConfigureServices() + { + var container = new ServiceCollection(); + + container.AddSingleton(); + + container.AddScoped(); + + return container.BuildServiceProvider(); + } + + public HomeViewModel Home => Provider.GetRequiredService(); +} \ No newline at end of file diff --git a/src/Chief.App/ViewModels/HomeViewModel.cs b/src/Chief.App/ViewModels/HomeViewModel.cs new file mode 100644 index 0000000..75f0f80 --- /dev/null +++ b/src/Chief.App/ViewModels/HomeViewModel.cs @@ -0,0 +1,6 @@ +namespace Chief.App.ViewModels; + +public class HomeViewModel: ViewModelBase +{ + +} \ No newline at end of file diff --git a/src/Chief.App/ViewModels/ViewModelBase.cs b/src/Chief.App/ViewModels/ViewModelBase.cs new file mode 100644 index 0000000..81f4b6b --- /dev/null +++ b/src/Chief.App/ViewModels/ViewModelBase.cs @@ -0,0 +1,8 @@ +using ReactiveUI; + +namespace Chief.App.ViewModels; + +public abstract class ViewModelBase: ReactiveObject +{ + +} \ No newline at end of file diff --git a/src/Chief.App/Views/HomeView.axaml b/src/Chief.App/Views/HomeView.axaml new file mode 100644 index 0000000..3626b11 --- /dev/null +++ b/src/Chief.App/Views/HomeView.axaml @@ -0,0 +1,9 @@ + + Welcome to Avalonia! + \ No newline at end of file diff --git a/src/Chief.App/Views/HomeView.axaml.cs b/src/Chief.App/Views/HomeView.axaml.cs new file mode 100644 index 0000000..bd9a772 --- /dev/null +++ b/src/Chief.App/Views/HomeView.axaml.cs @@ -0,0 +1,13 @@ +using Avalonia; +using Avalonia.Controls; +using Avalonia.Markup.Xaml; + +namespace Chief.App.Views; + +public partial class HomeView : UserControl +{ + public HomeView() + { + InitializeComponent(); + } +} \ No newline at end of file diff --git a/src/Chief.App/Views/PackageView.axaml b/src/Chief.App/Views/PackageView.axaml new file mode 100644 index 0000000..50e6438 --- /dev/null +++ b/src/Chief.App/Views/PackageView.axaml @@ -0,0 +1,10 @@ + + + + diff --git a/src/Chief.App/Views/PackageView.axaml.cs b/src/Chief.App/Views/PackageView.axaml.cs new file mode 100644 index 0000000..8aa0e33 --- /dev/null +++ b/src/Chief.App/Views/PackageView.axaml.cs @@ -0,0 +1,13 @@ +using Avalonia; +using Avalonia.Controls; +using Avalonia.Markup.Xaml; + +namespace Chief.App.Views; + +public partial class PackageView : UserControl +{ + public PackageView() + { + InitializeComponent(); + } +} \ No newline at end of file diff --git a/src/Chief.App/Views/SettingsView.axaml b/src/Chief.App/Views/SettingsView.axaml new file mode 100644 index 0000000..2374c32 --- /dev/null +++ b/src/Chief.App/Views/SettingsView.axaml @@ -0,0 +1,12 @@ + + + + + + diff --git a/src/Chief.App/Views/SettingsView.axaml.cs b/src/Chief.App/Views/SettingsView.axaml.cs new file mode 100644 index 0000000..9763f62 --- /dev/null +++ b/src/Chief.App/Views/SettingsView.axaml.cs @@ -0,0 +1,13 @@ +using Avalonia; +using Avalonia.Controls; +using Avalonia.Markup.Xaml; + +namespace Chief.App.Views; + +public partial class SettingsView : UserControl +{ + public SettingsView() + { + InitializeComponent(); + } +} \ No newline at end of file diff --git a/src/Chief.App/Views/ToolchainView.axaml b/src/Chief.App/Views/ToolchainView.axaml new file mode 100644 index 0000000..a10445e --- /dev/null +++ b/src/Chief.App/Views/ToolchainView.axaml @@ -0,0 +1,11 @@ + + + + + + diff --git a/src/Chief.App/Views/ToolchainView.axaml.cs b/src/Chief.App/Views/ToolchainView.axaml.cs new file mode 100644 index 0000000..59c4139 --- /dev/null +++ b/src/Chief.App/Views/ToolchainView.axaml.cs @@ -0,0 +1,13 @@ +using Avalonia; +using Avalonia.Controls; +using Avalonia.Markup.Xaml; + +namespace Chief.App.Views; + +public partial class ToolchainView : UserControl +{ + public ToolchainView() + { + InitializeComponent(); + } +} \ No newline at end of file diff --git a/src/Chief.App/app.manifest b/src/Chief.App/app.manifest new file mode 100644 index 0000000..cbe9fa9 --- /dev/null +++ b/src/Chief.App/app.manifest @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + diff --git a/src/Chief.Core/Chief.Core.csproj b/src/Chief.Core/Chief.Core.csproj new file mode 100644 index 0000000..6836c68 --- /dev/null +++ b/src/Chief.Core/Chief.Core.csproj @@ -0,0 +1,9 @@ + + + + net7.0 + enable + enable + + +