Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
e89493c
feat: 项目开始迁移到 avaloniaui
textGamex Dec 5, 2024
209295f
fix: 无法使用xaml预览器
textGamex Dec 5, 2024
9b06c75
perf: MessageBox 带有对应等级的图标
textGamex Dec 5, 2024
d1f830e
feat: 完成数据文件夹选择菜单
textGamex Dec 5, 2024
2d81980
feat: 初步实现文件树显示和工作区 & 调整项目结构
textGamex Dec 6, 2024
a59229e
feat: 调整项目结构 & 添加文件监听功能
textGamex Dec 6, 2024
3329d51
feat: 添加菜单
textGamex Dec 6, 2024
f2db00f
feat: 实现 Xaml 热重载 (#33)
textGamex Dec 7, 2024
22b17f4
Feat: 实现不同平台下的侧边栏文件树排序 (#35)
textGamex Dec 7, 2024
8f9cc82
Feat: 设置UI添加主题选择器 (#36)
Supheria Dec 8, 2024
bcf8f4d
Fix: 修复文件树过长时的显示问题 (#37)
textGamex Dec 8, 2024
0128d11
feat: App 主题选择持久化 (#39)
Supheria Dec 9, 2024
2573a1f
feat: 实现 Windows 和 Linux 下的移动文件或文件夹到回收站操作
textGamex Dec 9, 2024
4114c41
Merge branch 'main' into avalonia
textGamex Dec 10, 2024
9de126d
Merge branch 'avalonia' into contextmenu
textGamex Dec 10, 2024
bbcd97c
Merge branch 'main' into avalonia
textGamex Dec 10, 2024
c06b473
Merge branch 'avalonia' into contextmenu
textGamex Dec 10, 2024
1c60323
Merge branch 'main' into avalonia
textGamex Dec 10, 2024
ae0852f
Merge branch 'avalonia' into contextmenu
textGamex Dec 10, 2024
7ef3871
Merge branch 'main' into avalonia
textGamex Dec 10, 2024
84bcfdb
Merge branch 'avalonia' into contextmenu
textGamex Dec 10, 2024
1f37b79
feat: 实现重命名功能
textGamex Dec 10, 2024
054aab7
perf: 将无BomUtf-8编码改为全局静态变量
textGamex Dec 10, 2024
5b0b97b
feat: 实现在资源管理器中显示
textGamex Dec 10, 2024
f888b14
perf: 右键菜单改为在鼠标指针的位置显示 & 添加注释
textGamex Dec 10, 2024
2d3a677
feat: 右键选中的文件树项高亮显示
textGamex Dec 10, 2024
5cf35d8
fix: 未释放 ShellItem 的非托管资源
textGamex Dec 10, 2024
9490fdc
docs: 添加 TODO
textGamex Dec 10, 2024
bff8f17
Merge pull request #40 from ModerCore/contextmenu
Supheria Dec 10, 2024
b24add1
Refactor: 使用模板控件重用路径选择器 (#42)
Supheria Dec 10, 2024
e19b11d
refactor: 调整项目结构
textGamex Dec 10, 2024
1eacc5b
perf: 将部分类改为密封类
textGamex Dec 10, 2024
fe4f1a4
添加本地化文本
textGamex Dec 10, 2024
4e9573d
fix: 工作区宽度设置错误导致的显示不完整
textGamex Dec 11, 2024
9581bed
feat: 实现 TabView 导航功能
textGamex Dec 11, 2024
5d37e0d
fix: 人物编辑器错误的 ToolTip
textGamex Dec 11, 2024
b25578c
refactor: 使用 Brushes 类中的静态属性替代自定义画刷
textGamex Dec 12, 2024
fef20f9
i18: 添加本地化文本 (#44)
Supheria Dec 12, 2024
62e5f1f
Merge branch 'main' into avalonia
textGamex Dec 13, 2024
12fab6e
Merge branch 'avalonia' into character-editor
textGamex Dec 13, 2024
b76b852
feat: 初步实现人物编辑器
textGamex Dec 13, 2024
425e1c6
refactor: 使用绑定简化对 InlineCollection 的操作
textGamex Dec 13, 2024
dcde832
ui: 描述符文字设置为底部对齐
textGamex Dec 14, 2024
9330a40
feat: 实现特质选择器
textGamex Dec 15, 2024
63f0ca9
feat: 支持特质显示修饰符
textGamex Dec 15, 2024
ce3d9ef
feat: 正常释放 CharacterEditorControlView
textGamex Dec 15, 2024
37f0be7
fix: TextBlock有时无法正确显示Inlines
textGamex Dec 16, 2024
59e02f5
feat: 支持地块修饰符显示 & 重构修饰符显示服务
textGamex Dec 16, 2024
c3e008c
refactor: 调整项目结构
textGamex Dec 17, 2024
b7ae296
feat: 支持前端数据校验 & 写入到文件更改为 AutoCompleteBox
textGamex Dec 17, 2024
e05dccb
feat: 支持本地化占位符格式
textGamex Dec 17, 2024
b26a63e
perf: 直接返回Brushes中的颜色来减少对象分配
textGamex Dec 17, 2024
6a4e36e
style: 清理代码
textGamex Dec 17, 2024
d24859c
Feat: 实现人物编辑器 (#43)
textGamex Dec 17, 2024
e9aa4fb
deps: HotAvalonia 从2.0.1升级为2.0.2
textGamex Dec 18, 2024
3ec0fd2
Feat: 使用 AvalonEdit 显示生成的人物代码
textGamex Dec 19, 2024
ec02e34
style: 删除无用文件
textGamex Dec 19, 2024
c68f814
feat: 右键菜单添加复制路径功能 (#48)
textGamex Dec 20, 2024
4f1a9b7
deps: 更新 Avalonia 和 AotAvalonia 依赖
textGamex Dec 20, 2024
90ab0e1
Revert "deps: 更新 Avalonia 和 AotAvalonia 依赖"
textGamex Dec 20, 2024
8100ddf
Feat: 启动时在后台加载本地化资源 (#49)
textGamex Dec 21, 2024
41e8c14
Feat: 特质搜索支持搜索修饰符名称 (#50)
textGamex Dec 21, 2024
4d85842
refactor: 优化 TraitVo 中的 Comparer 实现
textGamex Dec 22, 2024
26d6fc5
perf: AllTraits 改为惰性加载
textGamex Dec 22, 2024
059281f
feat: 使用 DynamicData 库替换DataGridCollectionView 类
textGamex Dec 22, 2024
2f0d96a
Feat: 添加设置页面 (#47)
Supheria Dec 24, 2024
e2d0dd8
deps: 升级 HotAvalonia 包
textGamex Dec 25, 2024
f545891
deps: 更新 ParadoxPower 依赖版本
textGamex Dec 26, 2024
830bb4f
feat: 使用自定义标题栏
textGamex Dec 26, 2024
9301862
fix: 主页面错误的Grid布局
textGamex Dec 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions Moder.Core/App.axaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<Application
x:Class="Moder.Core.App"
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:styling="clr-namespace:FluentAvalonia.Styling;assembly=FluentAvalonia"
RequestedThemeVariant="Default">
<!-- "Default" ThemeVariant follows system theme variant. "Dark" or "Light" are other available options. -->

<Application.Styles>
<FluentTheme />
<styling:FluentAvaloniaTheme />
<StyleInclude Source="avares://AvaloniaEdit/Themes/Fluent/AvaloniaEdit.xaml" />
<StyleInclude Source="avares://Moder.Core/Resources/AppThemeStyleSetter.axaml" />
<StyleInclude Source="avares://Moder.Core/Controls/Controls.axaml" />
</Application.Styles>

<Application.Resources>
<ResourceDictionary>
<FontFamily x:Key="FluentIconFontFamily">Segoe Fluent Icons</FontFamily>
<ResourceDictionary.MergedDictionaries>
<MergeResourceInclude Source="avares://Moder.Core/Resources/AppThemeResource.axaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
205 changes: 205 additions & 0 deletions Moder.Core/App.axaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,205 @@
using System.Diagnostics;
using System.Runtime.Versioning;
using Avalonia;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Data.Core.Plugins;
using Avalonia.Markup.Xaml;
using HotAvalonia;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Moder.Core.Extensions;
using Moder.Core.Infrastructure.FileSort;
using Moder.Core.Services;
using Moder.Core.Services.Config;
using Moder.Core.Services.FileNativeService;
using Moder.Core.Services.GameResources;
using Moder.Core.Services.GameResources.Base;
using Moder.Core.Services.GameResources.Localization;
using Moder.Core.Services.GameResources.Modifiers;
using Moder.Core.Views;
using Moder.Core.Views.Game;
using Moder.Core.Views.Menus;
using Moder.Core.ViewsModel;
using Moder.Core.ViewsModel.Game;
using Moder.Core.ViewsModel.Menus;
using Moder.Hosting;
using NLog;
using NLog.Extensions.Logging;

namespace Moder.Core;

public class App : Application
{
public const string AppVersion = "0.1.0-alpha";
public const string CodeRepositoryUrl = "https://github.com/ModerCore/Moder";
public static new App Current => (App)Application.Current!;
public static IServiceProvider Services => Current._serviceProvider;
public static string AppConfigFolder { get; } =
Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
"Moder",
"Configs"
);

public static string AssetsFolder { get; } = Path.Combine(Environment.CurrentDirectory, "Assets");
public static string ParserRulesFolder { get; } = Path.Combine(AssetsFolder, "ParserRules");

private IHost? _host;

public App()
{
InitializeApp();
}

private static void InitializeApp()
{
if (!Directory.Exists(AppConfigFolder))
{
Directory.CreateDirectory(AppConfigFolder);
}

if (!Directory.Exists(ParserRulesFolder))
{
Directory.CreateDirectory(ParserRulesFolder);
}
}

public override void Initialize()
{
this.EnableHotReload();
AvaloniaXamlLoader.Load(this);
}

private IServiceProvider _serviceProvider = null!;

public override async void OnFrameworkInitializationCompleted()
{
var builder = CreateHostBuilder();
var host = builder.Build();
_host = host;
_serviceProvider = host.Services;
var settingService = Services.GetRequiredService<AppSettingService>();
RequestedThemeVariant = settingService.AppTheme.ToThemeVariant();

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 = _serviceProvider.GetRequiredService<MainWindow>();
desktop.Exit += (_, _) =>
{
_serviceProvider.GetRequiredService<AppSettingService>().SaveChanged();
_host.StopAsync(TimeSpan.FromSeconds(5)).GetAwaiter().GetResult();
_host.Dispose();
_host = null;

// 在退出时刷新日志
LogManager.Flush();
};
}

base.OnFrameworkInitializationCompleted();

await _host.RunAsync();
}

private static HostApplicationBuilder CreateHostBuilder()
{
var settings = new HostApplicationBuilderSettings
{
Args = Environment.GetCommandLineArgs(),
ApplicationName = "Moder"
};

#if DEBUG
settings.EnvironmentName = "Development";
#else
settings.EnvironmentName = "Production";
#endif
var builder = Host.CreateApplicationBuilder(settings);

builder.Services.AttachLoggerToAvaloniaLogger();
builder.Logging.ClearProviders();
builder.Logging.AddNLog(builder.Configuration);
LogManager.Configuration = new NLogLoggingConfiguration(builder.Configuration.GetSection("NLog"));

// View, ViewModel
builder.Services.AddViewSingleton<MainWindow, MainWindowViewModel>();
builder.Services.AddViewTransient<AppInitializeControlView, AppInitializeControlViewModel>();
builder.Services.AddViewSingleton<MainControlView, MainControlViewModel>();
builder.Services.AddViewSingleton<SideBarControlView, SideBarControlViewModel>();
builder.Services.AddViewSingleton<WorkSpaceControlView, WorkSpaceControlViewModel>();
builder.Services.AddViewTransient<CharacterEditorControlView, CharacterEditorControlViewModel>();
builder.Services.AddViewTransient<AppSettingsView, AppSettingsViewModel>();
builder.Services.AddViewSingleton<StatusBarControlView, StatusBarControlViewModel>();
builder.Services.AddTransient<TraitSelectionWindowViewModel>();

builder.Services.AddSingleton(_ => AppSettingService.Load());
builder.Services.AddSingleton<MessageBoxService>();
builder.Services.AddSingleton<TabViewNavigationService>();
builder.Services.AddSingleton<AppResourcesService>();
builder.Services.AddSingleton<GameModDescriptorService>();
builder.Services.AddSingleton<GameResourcesPathService>();
builder.Services.AddSingleton<GameResourcesWatcherService>();

// 本地化文本相关服务
builder.Services.AddSingleton<LocalizationService>();
builder.Services.AddSingleton<LocalizationFormatService>();
builder.Services.AddSingleton<LocalizationTextColorsService>();
builder.Services.AddSingleton<LocalizationKeyMappingService>();

// 修饰符相关服务
builder.Services.AddSingleton<ModifierService>();
builder.Services.AddSingleton<ModifierDisplayService>();

builder.Services.AddSingleton<CharacterSkillService>();
builder.Services.AddSingleton<CharacterTraitsService>();
builder.Services.AddSingleton<TerrainService>();

AddPlatformNativeServices(builder.Services);

return builder;
}

private static void AddPlatformNativeServices(IServiceCollection builder)
{
#if WINDOWS
Debug.Assert(OperatingSystem.IsWindows());
AddWindowsServices(builder);
#elif LINUX
AddLinuxServices(builder);
#endif
}

#if WINDOWS
[SupportedOSPlatform("windows")]
private static void AddWindowsServices(IServiceCollection builder)
{
builder.AddSingleton<IFileSortComparer, WindowsFileSortComparer>();
builder.AddSingleton<IFileNativeService, WindowsFileNativeService>();
}
#elif LINUX
[SupportedOSPlatform("linux")]
private static void AddLinuxServices(IServiceCollection builder)
{
builder.AddSingleton<IFileSortComparer, LinuxFileSortComparer>();
builder.AddSingleton<IFileNativeService, LinuxFileNativeService>();
}
#endif

private static void DisableAvaloniaDataAnnotationValidation()
{
// Get an array of plugins to remove
var dataValidationPluginsToRemove = BindingPlugins
.DataValidators.OfType<DataAnnotationsValidationPlugin>()
.ToArray();

// remove each entry found
foreach (var plugin in dataValidationPluginsToRemove)
{
BindingPlugins.DataValidators.Remove(plugin);
}
}
}
16 changes: 0 additions & 16 deletions Moder.Core/App.xaml

This file was deleted.

78 changes: 0 additions & 78 deletions Moder.Core/App.xaml.cs

This file was deleted.

Loading
Loading