-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b2bce28
commit 09f5f82
Showing
14 changed files
with
426 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
.idea | ||
ProtoExport/obj | ||
ProtoExport/bin | ||
ToolGUI/bin | ||
ToolGUI/obj | ||
*.user |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<Application xmlns="https://github.com/avaloniaui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
x:Class="ToolGUI.App" | ||
xmlns:local="using:ToolGUI" | ||
RequestedThemeVariant="Default"> | ||
<!-- "Default" ThemeVariant follows system theme variant. "Dark" or "Light" are other available options. --> | ||
|
||
<Application.DataTemplates> | ||
<local:ViewLocator/> | ||
</Application.DataTemplates> | ||
|
||
<Application.Styles> | ||
<FluentTheme /> | ||
</Application.Styles> | ||
</Application> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ToolGUI.ViewModels; | ||
using ToolGUI.Views; | ||
|
||
namespace ToolGUI; | ||
|
||
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<DataAnnotationsValidationPlugin>().ToArray(); | ||
|
||
// remove each entry found | ||
foreach (var plugin in dataValidationPluginsToRemove) | ||
{ | ||
BindingPlugins.DataValidators.Remove(plugin); | ||
} | ||
} | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using GameFrameX.ProtoExport; | ||
using Newtonsoft.Json; | ||
|
||
namespace ToolGUI.Models; | ||
|
||
public class SettingData | ||
{ | ||
Dictionary<string, LauncherOptions> Options { get; set; } | ||
|
||
public SettingData() | ||
{ | ||
Options = new Dictionary<string, LauncherOptions>(); | ||
Options.Add("Server", new LauncherOptions { Mode = ModeType.Server.ToString(), IsGenerateErrorCode = true, NamespaceName = "GameFrameX.Proto.Proto", OutputPath = "./../../../../../Server/GameFrameX.Proto/Proto", InputPath = "./../../../../../Protobuf" }); | ||
Options.Add("Unity", new LauncherOptions { Mode = ModeType.Unity.ToString(), IsGenerateErrorCode = true, NamespaceName = "Hotfix.Proto", OutputPath = "./../../../../../Unity/Assets/Hotfix/Proto", InputPath = "./../../../../../Protobuf" }); | ||
Options.Add("TypeScript", new LauncherOptions { Mode = ModeType.TypeScript.ToString(), IsGenerateErrorCode = true, NamespaceName = "", OutputPath = "./../../../../../Laya/src/gameframex/protobuf", InputPath = "./../../../../../Protobuf" }); | ||
} | ||
|
||
public static SettingData Instance { get; } = new SettingData(); | ||
|
||
public static LauncherOptions GetOptions(string mode) | ||
{ | ||
if (string.IsNullOrWhiteSpace(mode)) | ||
{ | ||
return default; | ||
} | ||
|
||
return Instance.Options.GetValueOrDefault(mode); | ||
} | ||
|
||
public const string SettingPath = "Setting.json"; | ||
|
||
public static void LoadSetting() | ||
{ | ||
if (File.Exists(SettingPath)) | ||
{ | ||
var json = File.ReadAllText(SettingPath); | ||
Instance.Options = JsonConvert.DeserializeObject<Dictionary<string, LauncherOptions>>(json); | ||
} | ||
} | ||
|
||
public static void SaveSetting() | ||
{ | ||
File.WriteAllText(SettingPath, JsonConvert.SerializeObject(Instance.Options, Formatting.Indented)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using Avalonia; | ||
using System; | ||
|
||
namespace ToolGUI; | ||
|
||
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<App>() | ||
.UsePlatformDetect() | ||
.WithInterFont() | ||
.LogToTrace(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<OutputType>WinExe</OutputType> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<Nullable>disable</Nullable> | ||
<BuiltInComInteropSupport>true</BuiltInComInteropSupport> | ||
<ApplicationManifest>app.manifest</ApplicationManifest> | ||
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault> | ||
<LangVersion>10</LangVersion> | ||
<PublishSingleFile>true</PublishSingleFile> | ||
<PublishTrimmed>true</PublishTrimmed> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<AvaloniaResource Include="Assets\**" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Avalonia" Version="11.2.1" /> | ||
<PackageReference Include="Avalonia.Desktop" Version="11.2.1" /> | ||
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.2.1" /> | ||
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.2.1" /> | ||
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.--> | ||
<PackageReference Include="Avalonia.Diagnostics" Version="11.2.1"> | ||
<IncludeAssets Condition="'$(Configuration)' != 'Debug'">None</IncludeAssets> | ||
<PrivateAssets Condition="'$(Configuration)' != 'Debug'">All</PrivateAssets> | ||
</PackageReference> | ||
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.1" /> | ||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\ProtoExport\ProtoExport.csproj" /> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using System; | ||
using Avalonia.Controls; | ||
using Avalonia.Controls.Templates; | ||
using ToolGUI.ViewModels; | ||
|
||
namespace ToolGUI; | ||
|
||
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace ToolGUI.ViewModels; | ||
|
||
public partial class MainWindowViewModel : ViewModelBase | ||
{ | ||
public string Greeting { get; } = "Welcome to Avalonia!"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
using CommunityToolkit.Mvvm.ComponentModel; | ||
|
||
namespace ToolGUI.ViewModels; | ||
|
||
public class ViewModelBase : ObservableObject | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<Window xmlns="https://github.com/avaloniaui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:vm="using:ToolGUI.ViewModels" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
mc:Ignorable="d" d:DesignWidth="450" d:DesignHeight="300" | ||
x:Class="ToolGUI.Views.MainWindow" | ||
x:DataType="vm:MainWindowViewModel" | ||
CanResize="False" | ||
WindowState="Normal" | ||
Icon="/Assets/logo.ico" | ||
Title="ToolGUI"> | ||
|
||
<Design.DataContext> | ||
<!-- This only sets the DataContext for the previewer in an IDE, | ||
to set the actual DataContext for runtime, set the DataContext property in code (look at App.axaml.cs) --> | ||
<vm:MainWindowViewModel /> | ||
</Design.DataContext> | ||
<StackPanel Margin="20" Orientation="Vertical"> | ||
<StackPanel Orientation="Horizontal" VerticalAlignment="Center"> | ||
<TextBlock Text="导出类型:" Width="100" VerticalAlignment="Center" /> | ||
<ComboBox Name="Mode" Width="300" VerticalAlignment="Center" SelectedIndex="1" SelectionChanged="Mode_OnSelectionChanged"> | ||
<ComboBoxItem>Server</ComboBoxItem> | ||
<ComboBoxItem>Unity</ComboBoxItem> | ||
<ComboBoxItem>TypeScript</ComboBoxItem> | ||
</ComboBox> | ||
</StackPanel> | ||
|
||
<!-- 第二行 --> | ||
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" Margin="0,10,0,0"> | ||
<TextBlock Text="命名空间:" Width="100" VerticalAlignment="Center" /> | ||
|
||
<TextBox Name="NameSpace" Width="300" VerticalAlignment="Center" /> | ||
</StackPanel> | ||
|
||
<!-- 第三行 --> | ||
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" Margin="0,10,0,0"> | ||
<TextBlock Text="协议文件路径:" Width="100" VerticalAlignment="Center" /> | ||
<TextBox Name="InputPath" Width="300" VerticalAlignment="Center" /> | ||
</StackPanel> | ||
|
||
<!-- 第四行 --> | ||
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" Margin="0,10,0,0"> | ||
<TextBlock Text="导出文件路径:" Width="100" VerticalAlignment="Center" /> | ||
<TextBox Name="OutputPath" Width="300" VerticalAlignment="Center" /> | ||
</StackPanel> | ||
|
||
<!-- 第五行 --> | ||
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" Margin="0,10,0,0"> | ||
<TextBlock Text="生成错误码?:" Width="100" VerticalAlignment="Center" /> | ||
<CheckBox Name="IsGenerateErrorCode" VerticalAlignment="Center" IsChecked="True" /> | ||
</StackPanel> | ||
<StackPanel> | ||
<Button | ||
Click="Button_OnClick" | ||
Content="导出" | ||
HorizontalAlignment="Center" | ||
VerticalAlignment="Center" | ||
HorizontalContentAlignment="Center" | ||
VerticalContentAlignment="Center" | ||
FontSize="30" | ||
Foreground="White" | ||
BorderThickness="2" | ||
CornerRadius="10" | ||
BorderBrush="Yellow" | ||
Width="200" | ||
Height="50" | ||
Background="DarkGreen" /> | ||
</StackPanel> | ||
<StackPanel> | ||
<Border Background="AliceBlue" Width="400" Height="120" Margin="0,10,0,0"> | ||
<ScrollViewer> | ||
<StackPanel> | ||
<TextBlock Name="ErrorLog" Foreground="Brown" VerticalAlignment="Center" /> | ||
</StackPanel> | ||
</ScrollViewer> | ||
</Border> | ||
</StackPanel> | ||
</StackPanel> | ||
</Window> |
Oops, something went wrong.