维护一下功能,累了,喝一杯咖啡
This commit is contained in:
parent
e182fa3649
commit
ddf886b20a
|
@ -4,7 +4,6 @@ using RustTools.Contracts.Services;
|
||||||
using RustTools.ViewModels;
|
using RustTools.ViewModels;
|
||||||
|
|
||||||
namespace RustTools.Activation;
|
namespace RustTools.Activation;
|
||||||
|
|
||||||
public class DefaultActivationHandler : ActivationHandler<LaunchActivatedEventArgs>
|
public class DefaultActivationHandler : ActivationHandler<LaunchActivatedEventArgs>
|
||||||
{
|
{
|
||||||
private readonly INavigationService _navigationService;
|
private readonly INavigationService _navigationService;
|
||||||
|
|
|
@ -3,20 +3,24 @@ using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
using Microsoft.UI.Xaml;
|
using Microsoft.UI.Xaml;
|
||||||
|
|
||||||
using RustTools.Activation;
|
|
||||||
using RustTools.Contracts.Services;
|
using RustTools.Contracts.Services;
|
||||||
using RustTools.Helpers;
|
|
||||||
using RustTools.Models;
|
using RustTools.Models;
|
||||||
using RustTools.Services;
|
using RustTools.Services;
|
||||||
using RustTools.ViewModels;
|
using RustTools.ViewModels;
|
||||||
using RustTools.Views;
|
using RustTools.Views;
|
||||||
using System.Threading;
|
|
||||||
using RustTools.muqing;
|
using RustTools.muqing;
|
||||||
|
using RustTools.Activation;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using RustTools.WindowUI;
|
||||||
|
using Windows.ApplicationModel.Activation;
|
||||||
|
using Windows.Storage;
|
||||||
|
using Microsoft.UI.Xaml.Controls;
|
||||||
|
using Microsoft.Windows.AppLifecycle;
|
||||||
|
|
||||||
namespace RustTools;
|
namespace RustTools;
|
||||||
|
|
||||||
// To learn more about WinUI 3, see https://docs.microsoft.com/windows/apps/winui/winui3/.
|
// To learn more about WinUI 3, see https://docs.microsoft.com/windows/apps/winui/winui3/.
|
||||||
public partial class App : Application
|
public partial class App : Microsoft.UI.Xaml.Application
|
||||||
{
|
{
|
||||||
// The .NET Generic Host provides dependency injection, configuration, logging, and other services.
|
// The .NET Generic Host provides dependency injection, configuration, logging, and other services.
|
||||||
// https://docs.microsoft.com/dotnet/core/extensions/generic-host
|
// https://docs.microsoft.com/dotnet/core/extensions/generic-host
|
||||||
|
@ -46,18 +50,15 @@ public partial class App : Application
|
||||||
public App()
|
public App()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
System.Diagnostics.Process[] myProcesses = System.Diagnostics.Process.GetProcessesByName("RustTools");//获取指定的进程名
|
// 注册激活事件处理程序
|
||||||
if (myProcesses.Length > 1) //如果可以获取到知道的进程名则说明已经启动
|
|
||||||
{
|
|
||||||
Exit(); //关闭系统
|
|
||||||
}
|
|
||||||
Host = Microsoft.Extensions.Hosting.Host.
|
Host = Microsoft.Extensions.Hosting.Host.
|
||||||
CreateDefaultBuilder().
|
CreateDefaultBuilder().
|
||||||
UseContentRoot(AppContext.BaseDirectory).
|
UseContentRoot(AppContext.BaseDirectory).
|
||||||
ConfigureServices((context, services) =>
|
ConfigureServices((context, services) =>
|
||||||
{
|
{
|
||||||
// Default Activation Handler
|
// Default Activation Handler
|
||||||
services.AddTransient<ActivationHandler<LaunchActivatedEventArgs>, DefaultActivationHandler>();
|
services.AddTransient<ActivationHandler<Microsoft.UI.Xaml.LaunchActivatedEventArgs>, DefaultActivationHandler>();
|
||||||
|
|
||||||
// Other Activation Handlers
|
// Other Activation Handlers
|
||||||
|
|
||||||
|
@ -103,10 +104,53 @@ public partial class App : Application
|
||||||
// https://docs.microsoft.com/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.application.unhandledexception.
|
// https://docs.microsoft.com/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.application.unhandledexception.
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async override void OnLaunched(LaunchActivatedEventArgs args)
|
|
||||||
{
|
|
||||||
base.OnLaunched(args);
|
|
||||||
|
|
||||||
await App.GetService<IActivationService>().ActivateAsync(args);
|
protected async override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs args)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
var activatedEventArgs = Microsoft.Windows.AppLifecycle.AppInstance.GetCurrent().GetActivatedEventArgs();
|
||||||
|
if (activatedEventArgs.Kind == Microsoft.Windows.AppLifecycle.ExtendedActivationKind.File)
|
||||||
|
{
|
||||||
|
gj.sc("打开文件");
|
||||||
|
if (activatedEventArgs.Kind == ExtendedActivationKind.File)
|
||||||
|
{
|
||||||
|
if (activatedEventArgs.Data is IFileActivatedEventArgs fileArgs)
|
||||||
|
{
|
||||||
|
var files = fileArgs.Files;
|
||||||
|
// 处理打开的文件
|
||||||
|
foreach (var file in files)
|
||||||
|
{
|
||||||
|
var storageFile = file as Windows.Storage.StorageFile;
|
||||||
|
if (storageFile != null)
|
||||||
|
{
|
||||||
|
gj.sc(storageFile.Path);
|
||||||
|
var importModule=new ImportModule(storageFile.Path);
|
||||||
|
importModule.Activate();
|
||||||
|
// 读取或处理文件内容
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// If this is the first instance launched, then register it as the "main" instance.
|
||||||
|
// If this isn't the first instance launched, then "main" will already be registered,
|
||||||
|
// so retrieve it.
|
||||||
|
var mainInstance = Microsoft.Windows.AppLifecycle.AppInstance.FindOrRegisterForKey("main");
|
||||||
|
// If the instance that's executing the OnLaunched handler right now
|
||||||
|
// isn't the "main" instance.
|
||||||
|
if (!mainInstance.IsCurrent)
|
||||||
|
{
|
||||||
|
// Redirect the activation (and args) to the "main" instance, and exit.
|
||||||
|
await mainInstance.RedirectActivationToAsync(activatedEventArgs);
|
||||||
|
System.Diagnostics.Process.GetCurrentProcess().Kill();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
base.OnLaunched(args);
|
||||||
|
await App.GetService<IActivationService>().ActivateAsync(args);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,13 +7,11 @@ namespace RustTools;
|
||||||
public sealed partial class MainWindow : WindowEx
|
public sealed partial class MainWindow : WindowEx
|
||||||
{
|
{
|
||||||
private readonly Microsoft.UI.Dispatching.DispatcherQueue dispatcherQueue;
|
private readonly Microsoft.UI.Dispatching.DispatcherQueue dispatcherQueue;
|
||||||
public static MainWindow Main;
|
|
||||||
|
|
||||||
private readonly UISettings settings;
|
private readonly UISettings settings;
|
||||||
|
|
||||||
public MainWindow()
|
public MainWindow()
|
||||||
{
|
{
|
||||||
Main = this;
|
|
||||||
gj.SetBackTheme(this);
|
gj.SetBackTheme(this);
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
//AppWindow.SetIcon("Assets/tool.png");
|
//AppWindow.SetIcon("Assets/tool.png");
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
Version="{Version}"
|
Version="{Version}"
|
||||||
Publisher="{Publisher}"
|
Publisher="{Publisher}"
|
||||||
Uri="{MainPackageUri}"/>
|
Uri="{MainPackageUri}"/>
|
||||||
|
|
||||||
<UpdateSettings>
|
<UpdateSettings>
|
||||||
<OnLaunch HoursBetweenUpdateChecks="0" />
|
<OnLaunch HoursBetweenUpdateChecks="0" />
|
||||||
</UpdateSettings>
|
</UpdateSettings>
|
||||||
|
|
|
@ -58,6 +58,16 @@
|
||||||
</com:ExeServer>
|
</com:ExeServer>
|
||||||
</com:ComServer>
|
</com:ComServer>
|
||||||
</com:Extension>
|
</com:Extension>
|
||||||
|
<uap:Extension Category="windows.fileTypeAssociation">
|
||||||
|
<uap:FileTypeAssociation Name=".rwmod">
|
||||||
|
<uap:SupportedFileTypes>
|
||||||
|
<uap:FileType>.rwmod</uap:FileType>
|
||||||
|
</uap:SupportedFileTypes>
|
||||||
|
<uap:DisplayName>添加模组</uap:DisplayName>
|
||||||
|
<uap:Logo>Assets\tool.png</uap:Logo>
|
||||||
|
<uap:InfoTip>需要绑定铁锈路径</uap:InfoTip>
|
||||||
|
</uap:FileTypeAssociation>
|
||||||
|
</uap:Extension>
|
||||||
</Extensions>
|
</Extensions>
|
||||||
</Application>
|
</Application>
|
||||||
</Applications>
|
</Applications>
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
<None Remove="Views\ModulePage.xaml" />
|
<None Remove="Views\ModulePage.xaml" />
|
||||||
<None Remove="Views\RankingPage.xaml" />
|
<None Remove="Views\RankingPage.xaml" />
|
||||||
<None Remove="Views\UserPage.xaml" />
|
<None Remove="Views\UserPage.xaml" />
|
||||||
|
<None Remove="WindowUI\ImportModule.xaml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -56,6 +57,9 @@
|
||||||
<Pack>True</Pack>
|
<Pack>True</Pack>
|
||||||
<PackagePath>\</PackagePath>
|
<PackagePath>\</PackagePath>
|
||||||
</None>
|
</None>
|
||||||
|
<Page Update="WindowUI\ImportModule.xaml">
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
</Page>
|
||||||
<Page Update="Views\ModulePage.xaml">
|
<Page Update="Views\ModulePage.xaml">
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
</Page>
|
</Page>
|
||||||
|
|
|
@ -70,12 +70,21 @@
|
||||||
<TextBlock Text="模组路径" />
|
<TextBlock Text="模组路径" />
|
||||||
|
|
||||||
<AutoSuggestBox
|
<AutoSuggestBox
|
||||||
x:Name="ModFileUrlText"
|
Name="ModFileUrlText"
|
||||||
Margin="{StaticResource XSmallTopMargin}"
|
Margin="{StaticResource XSmallTopMargin}"
|
||||||
LostFocus="ModFileUrlText_LostFocus"
|
LostFocus="ModFileUrlText_LostFocus"
|
||||||
PlaceholderText="输入或者搜索路径(Enter/回车保存)"
|
PlaceholderText="输入或者搜索路径(取消焦点保存)"
|
||||||
QueryIcon="Find"
|
QueryIcon="Find"
|
||||||
QuerySubmitted="AutoSuggestBox_ModFileUrl" />
|
QuerySubmitted="AutoSuggestBox_Url" />
|
||||||
|
<TextBlock Margin="0,9,0,0" Text="地图路径" />
|
||||||
|
|
||||||
|
<AutoSuggestBox
|
||||||
|
Name="MapsFileUrlText"
|
||||||
|
Margin="{StaticResource XSmallTopMargin}"
|
||||||
|
LostFocus="ModFileUrlText_LostFocus"
|
||||||
|
PlaceholderText="输入或者搜索路径(取消焦点保存)"
|
||||||
|
QueryIcon="Find"
|
||||||
|
QuerySubmitted="AutoSuggestBox_Url" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
<TextBlock x:Uid="Settings_About" Style="{ThemeResource SubtitleTextBlockStyle}" />
|
<TextBlock x:Uid="Settings_About" Style="{ThemeResource SubtitleTextBlockStyle}" />
|
||||||
|
|
|
@ -1,15 +1,9 @@
|
||||||
using Microsoft.UI;
|
|
||||||
using Microsoft.UI.Composition.SystemBackdrops;
|
|
||||||
using Microsoft.UI.Xaml;
|
using Microsoft.UI.Xaml;
|
||||||
using Microsoft.UI.Xaml.Controls;
|
using Microsoft.UI.Xaml.Controls;
|
||||||
using Microsoft.UI.Xaml.Data;
|
|
||||||
using Microsoft.UI.Xaml.Media;
|
|
||||||
using RustTools.muqing;
|
using RustTools.muqing;
|
||||||
using RustTools.ViewModels;
|
using RustTools.ViewModels;
|
||||||
using Windows.Storage.AccessCache;
|
|
||||||
using Windows.Storage.Pickers;
|
using Windows.Storage.Pickers;
|
||||||
using Windows.Storage;
|
|
||||||
using WinUIEx;
|
|
||||||
|
|
||||||
namespace RustTools.Views;
|
namespace RustTools.Views;
|
||||||
|
|
||||||
|
@ -52,13 +46,14 @@ public sealed partial class SettingsPage : Page
|
||||||
}
|
}
|
||||||
BackgroundRadioButtons.SelectionChanged += BackgroundColor_SelectionChanged;
|
BackgroundRadioButtons.SelectionChanged += BackgroundColor_SelectionChanged;
|
||||||
ModFileUrlText.Text = iniHelper.GetValue(IniHelper.CODE.Rust, IniHelper.KEY.ModFileUrl);
|
ModFileUrlText.Text = iniHelper.GetValue(IniHelper.CODE.Rust, IniHelper.KEY.ModFileUrl);
|
||||||
|
MapsFileUrlText.Text = iniHelper.GetValue(IniHelper.CODE.Rust,IniHelper.KEY.MapsFileUrl);
|
||||||
}
|
}
|
||||||
private bool Backone = false;
|
private bool Backone = false;
|
||||||
private void BackgroundColor_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
private void BackgroundColor_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||||
{
|
{
|
||||||
if (Backone)
|
if (Backone)
|
||||||
{
|
{
|
||||||
if (MainWindow.Main != null && sender is RadioButtons rb)
|
if (App.MainWindow != null && sender is RadioButtons rb)
|
||||||
{
|
{
|
||||||
var colorName = rb.SelectedItem as string;
|
var colorName = rb.SelectedItem as string;
|
||||||
var iniHelper = new IniHelper();
|
var iniHelper = new IniHelper();
|
||||||
|
@ -66,7 +61,7 @@ public sealed partial class SettingsPage : Page
|
||||||
#pragma warning disable CS8604 // 引用类型参数可能为 null。
|
#pragma warning disable CS8604 // 引用类型参数可能为 null。
|
||||||
iniHelper.SetValue(IniHelper.CODE.Settings, IniHelper.KEY.SystemBackdrop, colorName);
|
iniHelper.SetValue(IniHelper.CODE.Settings, IniHelper.KEY.SystemBackdrop, colorName);
|
||||||
iniHelper.Save();
|
iniHelper.Save();
|
||||||
gj.SetBackTheme(MainWindow.Main);
|
gj.SetBackTheme(App.MainWindow);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -75,30 +70,32 @@ public sealed partial class SettingsPage : Page
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void AutoSuggestBox_ModFileUrl(AutoSuggestBox sender, AutoSuggestBoxQuerySubmittedEventArgs args)
|
private async void AutoSuggestBox_Url(AutoSuggestBox sender, AutoSuggestBoxQuerySubmittedEventArgs args)
|
||||||
{
|
{
|
||||||
var dialog = new ContentDialog();
|
var dialog = new ContentDialog
|
||||||
dialog.XamlRoot = this.XamlRoot;
|
{
|
||||||
|
XamlRoot = XamlRoot,
|
||||||
//dialog.Style = Application.Current.Resources["DefaultContentDialogStyle"] as Style;
|
//dialog.Style = Application.Current.Resources["DefaultContentDialogStyle"] as Style;
|
||||||
dialog.Title = "选择搜索模式";
|
Title = "选择搜索模式",
|
||||||
dialog.SecondaryButtonText = "手动选择";
|
SecondaryButtonText = "手动选择",
|
||||||
dialog.CloseButtonText = "自动搜索";
|
PrimaryButtonText = "自动搜索",
|
||||||
dialog.Content = "自动搜索利用助手专属搜索引擎进行全盘搜索游戏文件夹,直到找到 Rusted Warfare 文件夹为止 途中可选择中断。";
|
Content = "手动选择请找到Rusted Warfare文件目录软件会自动给你填写mod和maps路径," +
|
||||||
|
"自动搜索直到找到 Rusted Warfare 文件夹为止 途中可选择中断。"
|
||||||
|
};
|
||||||
//dialog.DefaultButton = ContentDialogButton.Primary;
|
//dialog.DefaultButton = ContentDialogButton.Primary;
|
||||||
dialog.SecondaryButtonClick += Dialog_SecondaryButtonClick;
|
dialog.SecondaryButtonClick += Dialog_SecondaryButtonClick;
|
||||||
dialog.CloseButtonClick += Dialog_CloseButtonClick;
|
dialog.PrimaryButtonClick += Dialog_PrimaryButtonClick;
|
||||||
await dialog.ShowAsync();
|
await dialog.ShowAsync();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
private void Dialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args){
|
||||||
private void Dialog_CloseButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args){
|
var mod = new Mod();
|
||||||
var mod = new mod();
|
ModFileUrlText.Text =mod.getUnitsDir();
|
||||||
ModFileUrlText.Text = mod.FileDir;
|
MapsFileUrlText.Text =mod.getMaps();
|
||||||
|
SaveModAndMaps();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void Dialog_SecondaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args){
|
private async void Dialog_SecondaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args){
|
||||||
|
|
||||||
var openPicker = new FolderPicker();
|
var openPicker = new FolderPicker();
|
||||||
var window = App.MainWindow;
|
var window = App.MainWindow;
|
||||||
var hWnd = WinRT.Interop.WindowNative.GetWindowHandle(window);
|
var hWnd = WinRT.Interop.WindowNative.GetWindowHandle(window);
|
||||||
|
@ -109,18 +106,37 @@ public sealed partial class SettingsPage : Page
|
||||||
if (folder != null)
|
if (folder != null)
|
||||||
{
|
{
|
||||||
//StorageApplicationPermissions.FutureAccessList.AddOrReplace("PickedFolderToken", folder);
|
//StorageApplicationPermissions.FutureAccessList.AddOrReplace("PickedFolderToken", folder);
|
||||||
ModFileUrlText.Text = folder.Path;
|
var a = Path.Combine(folder.Path, "mods\\units");
|
||||||
|
ModFileUrlText.Text = a;
|
||||||
|
var b = Path.Combine(folder.Path, "mods\\maps");
|
||||||
|
MapsFileUrlText.Text = b;
|
||||||
|
SaveModAndMaps();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void SaveModAndMaps()
|
||||||
|
{
|
||||||
|
var iniHelper = new IniHelper();
|
||||||
|
iniHelper.Load(IniHelper.FILE.Config);
|
||||||
|
iniHelper.SetValue(IniHelper.CODE.Rust, IniHelper.KEY.MapsFileUrl, MapsFileUrlText.Text);
|
||||||
|
iniHelper.SetValue(IniHelper.CODE.Rust, IniHelper.KEY.ModFileUrl, ModFileUrlText.Text);
|
||||||
|
iniHelper.Save();
|
||||||
|
}
|
||||||
|
|
||||||
private void ModFileUrlText_LostFocus(object sender, RoutedEventArgs e)
|
private void ModFileUrlText_LostFocus(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
|
var a=(AutoSuggestBox) sender;
|
||||||
// 获取 AutoSuggestBox 的当前文本
|
|
||||||
var text = ModFileUrlText.Text;
|
|
||||||
var iniHelper = new IniHelper();
|
var iniHelper = new IniHelper();
|
||||||
iniHelper.Load(IniHelper.FILE.Config);
|
iniHelper.Load(IniHelper.FILE.Config);
|
||||||
iniHelper.SetValue(IniHelper.CODE.Rust, IniHelper.KEY.ModFileUrl, text);
|
if (a.Name.Equals("MapsFileUrlText"))
|
||||||
|
{
|
||||||
|
iniHelper.SetValue(IniHelper.CODE.Rust, IniHelper.KEY.MapsFileUrl, MapsFileUrlText.Text);
|
||||||
|
}
|
||||||
|
else if(a.Name.Equals("ModFileUrlText"))
|
||||||
|
{
|
||||||
|
iniHelper.SetValue(IniHelper.CODE.Rust, IniHelper.KEY.ModFileUrl, ModFileUrlText.Text);
|
||||||
|
}
|
||||||
|
// 获取 AutoSuggestBox 的当前文本
|
||||||
iniHelper.Save();
|
iniHelper.Save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
47
RustTools/WindowUI/ImportModule.xaml
Normal file
47
RustTools/WindowUI/ImportModule.xaml
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<windowex:WindowEx
|
||||||
|
x:Class="RustTools.WindowUI.ImportModule"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:local="using:RustTools.WindowUI"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:windowex="using:WinUIEx"
|
||||||
|
Title="导入界面"
|
||||||
|
Width="500"
|
||||||
|
MinWidth="500"
|
||||||
|
MinHeight="500"
|
||||||
|
mc:Ignorable="d">
|
||||||
|
|
||||||
|
<Grid Name="Grid" Margin="16,16,16,16">
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
<RowDefinition Height="*" />
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<Grid.ColumnDefinitions />
|
||||||
|
<StackPanel Grid.Row="0">
|
||||||
|
<TextBlock Style="{StaticResource TitleTextBlockStyle}" Text="导入界面" />
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
|
<StackPanel Grid.Row="1" Margin="16,26,16,0">
|
||||||
|
<TextBlock
|
||||||
|
Name="NameText"
|
||||||
|
Style="{StaticResource SubtitleTextBlockStyle}"
|
||||||
|
Text="名称" />
|
||||||
|
<TextBlock
|
||||||
|
Name="MessageText"
|
||||||
|
Style="{StaticResource BodyStrongTextBlockStyle}"
|
||||||
|
Text="文件详情" />
|
||||||
|
<TextBlock
|
||||||
|
Name="InfoText"
|
||||||
|
Style="{StaticResource BodyStrongTextBlockStyle}"
|
||||||
|
Text="处理信息" />
|
||||||
|
</StackPanel>
|
||||||
|
<Button
|
||||||
|
Grid.Row="3"
|
||||||
|
HorizontalAlignment="Stretch"
|
||||||
|
Click="Button_Click"
|
||||||
|
Content="导入" />
|
||||||
|
</Grid>
|
||||||
|
</windowex:WindowEx>
|
72
RustTools/WindowUI/ImportModule.xaml.cs
Normal file
72
RustTools/WindowUI/ImportModule.xaml.cs
Normal file
|
@ -0,0 +1,72 @@
|
||||||
|
|
||||||
|
|
||||||
|
using Microsoft.UI.Xaml;
|
||||||
|
using Microsoft.UI.Xaml.Controls;
|
||||||
|
|
||||||
|
namespace RustTools.WindowUI;
|
||||||
|
public sealed partial class ImportModule : WindowEx
|
||||||
|
{
|
||||||
|
public ImportModule(string file)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
ExtendsContentIntoTitleBar = true;
|
||||||
|
if (file == string.Empty) {
|
||||||
|
Close();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var fileInfo = new FileInfo(file);
|
||||||
|
var iniHelper = new IniHelper();
|
||||||
|
iniHelper.Load(IniHelper.FILE.Config);
|
||||||
|
|
||||||
|
if (file.EndsWith(".rwmod"))
|
||||||
|
{
|
||||||
|
var l = " | ";
|
||||||
|
var formattedSize = FormatFileSize(fileInfo.Length);
|
||||||
|
MessageText.Text="类型:模组"+ l+ "大小"+ formattedSize;
|
||||||
|
var v = iniHelper.GetValue(IniHelper.CODE.Rust, IniHelper.KEY.ModFileUrl);
|
||||||
|
if (v == string.Empty) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
InfoText.Text = string.Format("原位置 {0} --> {1} \n在处理的时候请不要关闭此窗口 导成功后会自动关闭 失败则会提示权限等错误问题",
|
||||||
|
file,v);
|
||||||
|
}
|
||||||
|
NameText.Text =
|
||||||
|
fileInfo.Name;
|
||||||
|
}
|
||||||
|
private async void Dialog()
|
||||||
|
{
|
||||||
|
ContentDialog dialog = new ContentDialog
|
||||||
|
{
|
||||||
|
Title = "警告",
|
||||||
|
Content = "这是一个示例内容",
|
||||||
|
PrimaryButtonText = "确定",
|
||||||
|
SecondaryButtonText = "取消",
|
||||||
|
CloseButtonText = "关闭"
|
||||||
|
};
|
||||||
|
|
||||||
|
// 设置 XamlRoot,确保对话框显示在正确的窗口中
|
||||||
|
dialog.XamlRoot = Grid.XamlRoot;
|
||||||
|
|
||||||
|
// 显示对话框
|
||||||
|
await dialog.ShowAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static string FormatFileSize(long bytes)
|
||||||
|
{
|
||||||
|
return bytes switch
|
||||||
|
{
|
||||||
|
< 1024 => $"{bytes} B",
|
||||||
|
< 1024 * 1024 => $"{bytes / 1024.0:F2} KB",
|
||||||
|
< 1024 * 1024 * 1024 => $"{bytes / (1024.0 * 1024.0):F2} MB",
|
||||||
|
_ => $"{bytes / (1024.0 * 1024.0 * 1024.0):F2} GB"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Button_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
Dialog();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,7 +6,7 @@
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:windowex="using:WinUIEx"
|
xmlns:windowex="using:WinUIEx"
|
||||||
Title="模组信息"
|
Title="信息"
|
||||||
MinWidth="650"
|
MinWidth="650"
|
||||||
MinHeight="500"
|
MinHeight="500"
|
||||||
Closed="WindowEx_Closed"
|
Closed="WindowEx_Closed"
|
||||||
|
@ -18,7 +18,8 @@
|
||||||
<RowDefinition Height="*" />
|
<RowDefinition Height="*" />
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<Grid.ColumnDefinitions />
|
<Grid.ColumnDefinitions>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
<StackPanel Grid.Row="0" Orientation="Horizontal">
|
<StackPanel Grid.Row="0" Orientation="Horizontal">
|
||||||
<Border
|
<Border
|
||||||
Width="106"
|
Width="106"
|
||||||
|
|
|
@ -26,6 +26,7 @@ public class IniHelper
|
||||||
{
|
{
|
||||||
public const string SystemBackdrop = "SystemBackdrop";
|
public const string SystemBackdrop = "SystemBackdrop";
|
||||||
public const string ModFileUrl = "ModFileUrl";//模组路径
|
public const string ModFileUrl = "ModFileUrl";//模组路径
|
||||||
|
public const string MapsFileUrl = "MapsFileUrl";
|
||||||
}
|
}
|
||||||
|
|
||||||
private string filePath;
|
private string filePath;
|
||||||
|
@ -62,7 +63,9 @@ public class IniHelper
|
||||||
this.filePath = filePath;
|
this.filePath = filePath;
|
||||||
if (!File.Exists(filePath))
|
if (!File.Exists(filePath))
|
||||||
{
|
{
|
||||||
throw new FileNotFoundException("The specified file does not exist.", filePath);
|
File.Create(filePath);
|
||||||
|
return;
|
||||||
|
//throw new FileNotFoundException("The specified file does not exist.", filePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
var lines = File.ReadAllLines(filePath);
|
var lines = File.ReadAllLines(filePath);
|
||||||
|
|
|
@ -68,6 +68,14 @@ class gj
|
||||||
Kind = MicaKind.Base
|
Kind = MicaKind.Base
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
iniHelper.SetValue(IniHelper.CODE.Settings, IniHelper.KEY.SystemBackdrop, "Mica");
|
||||||
|
iniHelper.Save();
|
||||||
|
windowEx.SystemBackdrop = new MicaBackdrop()
|
||||||
|
{
|
||||||
|
Kind = MicaKind.Base
|
||||||
|
};
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
using Microsoft.Win32;
|
using Microsoft.Win32;
|
||||||
|
|
||||||
public class mod
|
public class Mod
|
||||||
{
|
{
|
||||||
|
|
||||||
//开始计时
|
//开始计时
|
||||||
|
@ -27,7 +27,7 @@ public class mod
|
||||||
};
|
};
|
||||||
//游戏位置
|
//游戏位置
|
||||||
public string FileDir = "";
|
public string FileDir = "";
|
||||||
public mod()
|
public Mod()
|
||||||
{
|
{
|
||||||
StartTime = DateTime.Now;
|
StartTime = DateTime.Now;
|
||||||
Console.WriteLine("开始执行文件搜索引擎");
|
Console.WriteLine("开始执行文件搜索引擎");
|
||||||
|
@ -57,6 +57,37 @@ public class mod
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
public string getUnitsDir()
|
||||||
|
{
|
||||||
|
if (FileDir==string.Empty) {
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var v = Path.Combine(FileDir, "mods\\units");
|
||||||
|
if (Directory.Exists(v))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(v);
|
||||||
|
}
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public string getMaps()
|
||||||
|
{
|
||||||
|
if (FileDir == string.Empty)
|
||||||
|
{
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var v = Path.Combine(FileDir, "mods\\maps");
|
||||||
|
if (!Directory.Exists(v))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(v);
|
||||||
|
}
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void init()
|
private void init()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user