2024-08-01 14:28:39 +00:00
|
|
|
|
|
2024-07-28 13:33:21 +00:00
|
|
|
|
using Microsoft.UI.Xaml;
|
|
|
|
|
using Microsoft.UI.Xaml.Controls;
|
|
|
|
|
using RustTools.muqing;
|
2024-07-14 11:24:10 +00:00
|
|
|
|
using RustTools.ViewModels;
|
2024-07-28 13:33:21 +00:00
|
|
|
|
using Windows.Storage.Pickers;
|
2024-07-14 11:24:10 +00:00
|
|
|
|
|
|
|
|
|
namespace RustTools.Views;
|
|
|
|
|
|
|
|
|
|
// TODO: Set the URL for your privacy policy by updating SettingsPage_PrivacyTermsLink.NavigateUri in Resources.resw.
|
|
|
|
|
public sealed partial class SettingsPage : Page
|
|
|
|
|
{
|
|
|
|
|
public SettingsViewModel ViewModel
|
|
|
|
|
{
|
|
|
|
|
get;
|
|
|
|
|
}
|
2024-07-28 13:33:21 +00:00
|
|
|
|
public enum SystemBackdropEmnu
|
|
|
|
|
{
|
|
|
|
|
None,
|
|
|
|
|
}
|
2024-07-14 11:24:10 +00:00
|
|
|
|
public SettingsPage()
|
|
|
|
|
{
|
|
|
|
|
ViewModel = App.GetService<SettingsViewModel>();
|
|
|
|
|
InitializeComponent();
|
2024-08-08 04:29:27 +00:00
|
|
|
|
Init();
|
2024-07-28 13:33:21 +00:00
|
|
|
|
|
2024-08-08 04:29:27 +00:00
|
|
|
|
}
|
|
|
|
|
private async void Init()
|
|
|
|
|
{
|
2024-07-28 13:33:21 +00:00
|
|
|
|
var iniHelper = new IniHelper();
|
|
|
|
|
iniHelper.Load(IniHelper.FILE.Config);
|
|
|
|
|
var v = iniHelper.GetValue(IniHelper.CODE.Settings, IniHelper.KEY.SystemBackdrop);
|
|
|
|
|
switch (v)
|
|
|
|
|
{
|
|
|
|
|
case "None":
|
|
|
|
|
BackgroundRadioButtons.SelectedIndex = 0;
|
|
|
|
|
break;
|
|
|
|
|
case "Blur":
|
|
|
|
|
BackgroundRadioButtons.SelectedIndex = 1;
|
|
|
|
|
break;
|
|
|
|
|
case "AcrylicBlur":
|
|
|
|
|
BackgroundRadioButtons.SelectedIndex = 2;
|
|
|
|
|
break;
|
|
|
|
|
case "Mica":
|
|
|
|
|
BackgroundRadioButtons.SelectedIndex = 3;
|
|
|
|
|
break;
|
2024-08-03 11:49:28 +00:00
|
|
|
|
default: BackgroundRadioButtons.SelectedIndex = 0; break;
|
2024-07-28 13:33:21 +00:00
|
|
|
|
}
|
|
|
|
|
BackgroundRadioButtons.SelectionChanged += BackgroundColor_SelectionChanged;
|
|
|
|
|
ModFileUrlText.Text = iniHelper.GetValue(IniHelper.CODE.Rust, IniHelper.KEY.ModFileUrl);
|
2024-08-08 04:29:27 +00:00
|
|
|
|
MapsFileUrlText.Text = iniHelper.GetValue(IniHelper.CODE.Rust, IniHelper.KEY.MapsFileUrl);
|
2024-07-28 13:33:21 +00:00
|
|
|
|
}
|
|
|
|
|
private bool Backone = false;
|
2024-08-08 04:29:27 +00:00
|
|
|
|
private async void BackgroundColor_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
2024-07-28 13:33:21 +00:00
|
|
|
|
{
|
|
|
|
|
if (Backone)
|
2024-08-15 01:40:33 +00:00
|
|
|
|
{
|
2024-08-01 14:28:39 +00:00
|
|
|
|
if (App.MainWindow != null && sender is RadioButtons rb)
|
2024-07-28 13:33:21 +00:00
|
|
|
|
{
|
|
|
|
|
var colorName = rb.SelectedItem as string;
|
|
|
|
|
var iniHelper = new IniHelper();
|
|
|
|
|
iniHelper.Load(IniHelper.FILE.Config);
|
|
|
|
|
#pragma warning disable CS8604 // 引用类型参数可能为 null。
|
|
|
|
|
iniHelper.SetValue(IniHelper.CODE.Settings, IniHelper.KEY.SystemBackdrop, colorName);
|
|
|
|
|
iniHelper.Save();
|
2024-08-01 14:28:39 +00:00
|
|
|
|
gj.SetBackTheme(App.MainWindow);
|
2024-07-28 13:33:21 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Backone = true;
|
|
|
|
|
}
|
2024-08-15 01:40:33 +00:00
|
|
|
|
}
|
2024-07-28 13:33:21 +00:00
|
|
|
|
|
2024-08-01 14:28:39 +00:00
|
|
|
|
private async void AutoSuggestBox_Url(AutoSuggestBox sender, AutoSuggestBoxQuerySubmittedEventArgs args)
|
2024-07-28 13:33:21 +00:00
|
|
|
|
{
|
2024-08-01 14:28:39 +00:00
|
|
|
|
var dialog = new ContentDialog
|
|
|
|
|
{
|
|
|
|
|
XamlRoot = XamlRoot,
|
|
|
|
|
//dialog.Style = Application.Current.Resources["DefaultContentDialogStyle"] as Style;
|
|
|
|
|
Title = "选择搜索模式",
|
|
|
|
|
SecondaryButtonText = "手动选择",
|
|
|
|
|
PrimaryButtonText = "自动搜索",
|
|
|
|
|
Content = "手动选择请找到Rusted Warfare文件目录软件会自动给你填写mod和maps路径," +
|
|
|
|
|
"自动搜索直到找到 Rusted Warfare 文件夹为止 途中可选择中断。"
|
|
|
|
|
};
|
2024-07-28 13:33:21 +00:00
|
|
|
|
//dialog.DefaultButton = ContentDialogButton.Primary;
|
|
|
|
|
dialog.SecondaryButtonClick += Dialog_SecondaryButtonClick;
|
2024-08-01 14:28:39 +00:00
|
|
|
|
dialog.PrimaryButtonClick += Dialog_PrimaryButtonClick;
|
2024-07-28 13:33:21 +00:00
|
|
|
|
await dialog.ShowAsync();
|
|
|
|
|
|
|
|
|
|
}
|
2024-08-15 01:40:33 +00:00
|
|
|
|
private void Dialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
|
|
|
|
|
{
|
2024-08-06 06:34:25 +00:00
|
|
|
|
sender.Hide();
|
|
|
|
|
var mod = new Mod(XamlRoot, (FileDri) =>
|
|
|
|
|
{
|
2024-08-15 01:40:33 +00:00
|
|
|
|
gj.sc("找到了QWQ:::" + FileDri);
|
2024-08-06 06:34:25 +00:00
|
|
|
|
var a = Path.Combine(FileDri, "mods\\units");
|
|
|
|
|
ModFileUrlText.Text = a;
|
|
|
|
|
var b = Path.Combine(FileDri, "mods\\maps");
|
|
|
|
|
MapsFileUrlText.Text = b;
|
|
|
|
|
SaveModAndMaps();
|
|
|
|
|
});
|
2024-07-28 13:33:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-08-15 01:40:33 +00:00
|
|
|
|
private async void Dialog_SecondaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
|
|
|
|
|
{
|
2024-07-28 13:33:21 +00:00
|
|
|
|
var openPicker = new FolderPicker();
|
|
|
|
|
var window = App.MainWindow;
|
|
|
|
|
var hWnd = WinRT.Interop.WindowNative.GetWindowHandle(window);
|
|
|
|
|
WinRT.Interop.InitializeWithWindow.Initialize(openPicker, hWnd);
|
|
|
|
|
openPicker.SuggestedStartLocation = PickerLocationId.Desktop;
|
|
|
|
|
openPicker.FileTypeFilter.Add("*");
|
|
|
|
|
var folder = await openPicker.PickSingleFolderAsync();
|
|
|
|
|
if (folder != null)
|
|
|
|
|
{
|
|
|
|
|
//StorageApplicationPermissions.FutureAccessList.AddOrReplace("PickedFolderToken", folder);
|
2024-08-01 14:28:39 +00:00
|
|
|
|
var a = Path.Combine(folder.Path, "mods\\units");
|
|
|
|
|
ModFileUrlText.Text = a;
|
|
|
|
|
var b = Path.Combine(folder.Path, "mods\\maps");
|
|
|
|
|
MapsFileUrlText.Text = b;
|
|
|
|
|
SaveModAndMaps();
|
2024-07-28 13:33:21 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-08 04:29:27 +00:00
|
|
|
|
private async void SaveModAndMaps()
|
2024-07-28 13:33:21 +00:00
|
|
|
|
{
|
2024-08-01 14:28:39 +00:00
|
|
|
|
var iniHelper = new IniHelper();
|
2024-08-15 01:40:33 +00:00
|
|
|
|
iniHelper.Load(IniHelper.FILE.Config);
|
2024-08-01 14:28:39 +00:00
|
|
|
|
iniHelper.SetValue(IniHelper.CODE.Rust, IniHelper.KEY.MapsFileUrl, MapsFileUrlText.Text);
|
|
|
|
|
iniHelper.SetValue(IniHelper.CODE.Rust, IniHelper.KEY.ModFileUrl, ModFileUrlText.Text);
|
|
|
|
|
iniHelper.Save();
|
|
|
|
|
}
|
2024-07-28 13:33:21 +00:00
|
|
|
|
|
2024-08-08 04:29:27 +00:00
|
|
|
|
private async void ModFileUrlText_LostFocus(object sender, RoutedEventArgs e)
|
2024-08-01 14:28:39 +00:00
|
|
|
|
{
|
2024-08-15 01:40:33 +00:00
|
|
|
|
var a = (AutoSuggestBox)sender;
|
2024-07-28 13:33:21 +00:00
|
|
|
|
var iniHelper = new IniHelper();
|
2024-08-15 01:40:33 +00:00
|
|
|
|
iniHelper.Load(IniHelper.FILE.Config);
|
2024-08-01 14:28:39 +00:00
|
|
|
|
if (a.Name.Equals("MapsFileUrlText"))
|
|
|
|
|
{
|
2024-08-06 06:34:25 +00:00
|
|
|
|
var Url = MapsFileUrlText.Text;
|
2024-08-15 01:40:33 +00:00
|
|
|
|
if (!Directory.Exists(Url) && Url != string.Empty)
|
|
|
|
|
{
|
2024-08-06 06:34:25 +00:00
|
|
|
|
Url = iniHelper.GetValue(IniHelper.CODE.Rust, IniHelper.KEY.MapsFileUrl);
|
2024-08-15 01:40:33 +00:00
|
|
|
|
MapsFileUrlText.Text = Url;
|
2024-08-06 06:34:25 +00:00
|
|
|
|
}
|
|
|
|
|
if (Url != string.Empty)
|
|
|
|
|
{
|
|
|
|
|
Url = Path.GetFullPath(Url);
|
|
|
|
|
}
|
2024-08-15 01:40:33 +00:00
|
|
|
|
iniHelper.SetValue(IniHelper.CODE.Rust, IniHelper.KEY.MapsFileUrl, Url);
|
|
|
|
|
MapsFileUrlText.Text = Url;
|
2024-08-01 14:28:39 +00:00
|
|
|
|
}
|
2024-08-15 01:40:33 +00:00
|
|
|
|
else if (a.Name.Equals("ModFileUrlText"))
|
2024-08-01 14:28:39 +00:00
|
|
|
|
{
|
2024-08-06 06:34:25 +00:00
|
|
|
|
var Url = ModFileUrlText.Text;
|
2024-08-15 01:40:33 +00:00
|
|
|
|
if (!Directory.Exists(Url) && Url != string.Empty)
|
2024-08-06 06:34:25 +00:00
|
|
|
|
{
|
2024-08-15 01:40:33 +00:00
|
|
|
|
Url = iniHelper.GetValue(IniHelper.CODE.Rust, IniHelper.KEY.ModFileUrl);
|
2024-08-06 06:34:25 +00:00
|
|
|
|
ModFileUrlText.Text = Url;
|
|
|
|
|
}
|
|
|
|
|
if (Url != string.Empty)
|
|
|
|
|
{
|
|
|
|
|
Url = Path.GetFullPath(Url);
|
|
|
|
|
}
|
2024-08-15 01:40:33 +00:00
|
|
|
|
iniHelper.SetValue(IniHelper.CODE.Rust, IniHelper.KEY.ModFileUrl, Url);
|
|
|
|
|
ModFileUrlText.Text = Url;
|
2024-08-01 14:28:39 +00:00
|
|
|
|
}
|
|
|
|
|
// 获取 AutoSuggestBox 的当前文本
|
2024-07-28 13:33:21 +00:00
|
|
|
|
iniHelper.Save();
|
2024-07-14 11:24:10 +00:00
|
|
|
|
}
|
2024-08-06 06:34:25 +00:00
|
|
|
|
private async Task ModMapDialog()
|
|
|
|
|
{
|
|
|
|
|
var dialog = new ContentDialog()
|
|
|
|
|
{
|
|
|
|
|
XamlRoot = XamlRoot,
|
|
|
|
|
Title = "警告",
|
|
|
|
|
Content = "不正确的路径无法保存",
|
|
|
|
|
SecondaryButtonText = "取消"
|
|
|
|
|
};
|
|
|
|
|
await dialog.ShowAsync();
|
|
|
|
|
}
|
2024-07-14 11:24:10 +00:00
|
|
|
|
}
|