Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
00139993b7 | |||
89916dd828 |
|
@ -2,12 +2,10 @@
|
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
x:Class="toast_mcl.App"
|
||||
xmlns:sty="using:FluentAvalonia.Styling"
|
||||
RequestedThemeVariant="Dark"
|
||||
>
|
||||
RequestedThemeVariant="Dark">
|
||||
<!-- "Default" ThemeVariant follows system theme variant. "Dark" or "Light" are other available options. -->
|
||||
|
||||
<Application.Styles>
|
||||
<!--<FluentTheme />-->
|
||||
<sty:FluentAvaloniaTheme />
|
||||
</Application.Styles>
|
||||
<Application.Resources>
|
||||
|
|
|
@ -8,11 +8,6 @@
|
|||
Title="toast_mcl">
|
||||
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<TabControl>
|
||||
<TabItem Header="主页">
|
||||
<ContentControl>
|
||||
|
@ -40,7 +35,6 @@
|
|||
<local:About/>
|
||||
</ContentControl>
|
||||
</TabItem>
|
||||
|
||||
</TabControl>
|
||||
</Grid>
|
||||
</Window>
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<UserControl xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
x:Class="toast_mcl.About">
|
||||
This is About
|
||||
<UniformGrid Columns="1" Rows="1" HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||
</UniformGrid>
|
||||
</UserControl>
|
||||
|
|
24
Program.cs
24
Program.cs
|
@ -1,23 +1,31 @@
|
|||
using Avalonia;
|
||||
using Avalonia;
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using toast_mcl;
|
||||
|
||||
namespace toast_mcl
|
||||
{
|
||||
internal 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.
|
||||
// 初始化代码。
|
||||
// 在调用AppMain之前,请不要使用任何Avalonia、第三方API或任何依赖于SynchronizationContext的代码:
|
||||
// 因为这些东西尚未初始化,可能会导致错误。
|
||||
[STAThread]
|
||||
public static void Main(string[] args) => BuildAvaloniaApp()
|
||||
.StartWithClassicDesktopLifetime(args);
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
Base.Init();
|
||||
|
||||
// Avalonia configuration, don't remove; also used by visual designer.
|
||||
BuildAvaloniaApp()
|
||||
.StartWithClassicDesktopLifetime(args);
|
||||
}
|
||||
|
||||
// Avalonia配置,请勿删除;也被可视化设计器使用。
|
||||
public static AppBuilder BuildAvaloniaApp()
|
||||
=> AppBuilder.Configure<App>()
|
||||
{
|
||||
return AppBuilder.Configure<App>()
|
||||
.UsePlatformDetect()
|
||||
.WithFont_LXGWWenKai()
|
||||
.LogToTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
26
Programs/Base.cs
Normal file
26
Programs/Base.cs
Normal file
|
@ -0,0 +1,26 @@
|
|||
using System;
|
||||
using toast_mcl.Programs;
|
||||
|
||||
namespace toast_mcl;
|
||||
|
||||
public static class Base
|
||||
{
|
||||
// 版本号处理
|
||||
public enum VersionTypes
|
||||
{
|
||||
Alpha,
|
||||
Beta,
|
||||
Release
|
||||
}
|
||||
public static VersionTypes VersionType = VersionTypes.Alpha;
|
||||
public static Version Version = new Version(0, 0, 1);
|
||||
|
||||
// 获取程序目录
|
||||
public static string AppDirectory = AppDomain.CurrentDomain.BaseDirectory;
|
||||
|
||||
// 初始化
|
||||
public static void Init()
|
||||
{
|
||||
ConfigUtils.Init();
|
||||
}
|
||||
}
|
15
Programs/Config/ConfigSettings.cs
Normal file
15
Programs/Config/ConfigSettings.cs
Normal file
|
@ -0,0 +1,15 @@
|
|||
using System;
|
||||
using toast_mcl;
|
||||
|
||||
namespace toast_mcl.Config;
|
||||
|
||||
public class ConfigSettings
|
||||
{
|
||||
public AppSettings ?AppSettings { get; set; }
|
||||
}
|
||||
|
||||
public class AppSettings
|
||||
{
|
||||
public Version Version { get; set; } = Base.Version;
|
||||
public string VersionType { get; set; } = Base.VersionType.ToString();
|
||||
}
|
66
Programs/Config/ConfigUtils.cs
Normal file
66
Programs/Config/ConfigUtils.cs
Normal file
|
@ -0,0 +1,66 @@
|
|||
using System.Linq;
|
||||
using System.IO;
|
||||
using Newtonsoft.Json;
|
||||
using toast_mcl.Config;
|
||||
using System;
|
||||
|
||||
namespace toast_mcl.Programs;
|
||||
public static class ConfigUtils
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public static ConfigSettings ?Settings { get; private set;}
|
||||
private static readonly string ConfigFolderPath = Path.Combine(Base.AppDirectory, "toast_mc");
|
||||
private static readonly string ConfigFilePath = Path.Combine(ConfigFolderPath, "config.json");
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
if (!Directory.Exists(ConfigFolderPath))
|
||||
{
|
||||
Directory.CreateDirectory(ConfigFolderPath);
|
||||
}
|
||||
if (!File.Exists(ConfigFilePath))
|
||||
{
|
||||
CreateDefaultConfig();
|
||||
}
|
||||
LoadConfig();
|
||||
}
|
||||
|
||||
private static void CreateDefaultConfig()
|
||||
{
|
||||
Settings = DefaultConfig.GetDefaultConfig();
|
||||
SaveConfig();
|
||||
}
|
||||
|
||||
public static void LoadConfig()
|
||||
{
|
||||
if (File.Exists(ConfigFilePath))
|
||||
{
|
||||
string configJson = File.ReadAllText(ConfigFilePath);
|
||||
Settings = JsonConvert.DeserializeObject<ConfigSettings>(configJson);
|
||||
}
|
||||
else
|
||||
{
|
||||
CreateDefaultConfig();
|
||||
}
|
||||
|
||||
var ConfigVersion = Settings?.AppSettings?.Version;
|
||||
if (ConfigVersion != Base.Version)
|
||||
{
|
||||
var oldSettings = Settings;
|
||||
UpdateConfig();
|
||||
}
|
||||
}
|
||||
|
||||
private static void UpdateConfig()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public static void SaveConfig()
|
||||
{
|
||||
string configJson = JsonConvert.SerializeObject(Settings, Formatting.Indented);
|
||||
File.WriteAllText(ConfigFilePath, configJson);
|
||||
}
|
||||
}
|
20
Programs/Config/DefaultConfig.cs
Normal file
20
Programs/Config/DefaultConfig.cs
Normal file
|
@ -0,0 +1,20 @@
|
|||
using System;
|
||||
using toast_mcl;
|
||||
|
||||
namespace toast_mcl.Config;
|
||||
|
||||
public static class DefaultConfig
|
||||
{
|
||||
public static ConfigSettings GetDefaultConfig()
|
||||
{
|
||||
|
||||
return new ConfigSettings
|
||||
{
|
||||
AppSettings = new AppSettings
|
||||
{
|
||||
Version = Base.Version,
|
||||
VersionType = Base.VersionType.ToString()
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
|
@ -1 +1,4 @@
|
|||
# toast_mcl
|
||||
# Toast Minecraft Launcher
|
||||
|
||||
[![Gitea](https://img.shields.io/badge/Gitea-609926)](https://git.hope-now.top:8443/HopeNowStudio/toast_mcl)
|
||||
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.0.6" />
|
||||
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
|
||||
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.6" />
|
||||
<PackageReference Include="Avalonia.Xaml.Behaviors" Version="0.5.0" />
|
||||
<PackageReference Include="FluentAvaloniaUI" Version="2.0.5" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
Loading…
Reference in New Issue
Block a user