mirror of
https://github.com/RoyalnetworkTR/simple-launcher.git
synced 2026-09-25 05:10:13 +03:00
- Add Services/ServersDat.cs (self-contained big-endian NBT codec) to write/ merge .AthenaStudios/servers.dat so the Athena server auto-appears in the in-game Multiplayer list. Existing entries preserved, deduped by IP. - Write servers.dat on every launch (independent of auto-connect). - Add an auto-connect-on-launch user setting (LocalSettings.AutoConnectOnLaunch + Settings checkbox); effective server-join = backend AutoConnect AND the user setting, so players can opt out of auto-join. - Remove the account delete button from AccountsView: users keep their name slots; only admins delete via the web panel (backend now 403s the self-delete endpoint).
69 lines
2.3 KiB
C#
69 lines
2.3 KiB
C#
using System;
|
||
using Avalonia.Controls;
|
||
using Avalonia.Interactivity;
|
||
using Avalonia.Platform.Storage;
|
||
using OfflineMinecraftLauncher.Services;
|
||
|
||
namespace OfflineMinecraftLauncher.Views;
|
||
|
||
public partial class SettingsView : UserControl
|
||
{
|
||
private readonly LocalSettings _settings;
|
||
private const string Preset =
|
||
"-XX:+UseG1GC -XX:+UnlockExperimentalVMOptions -XX:G1NewSizePercent=20 -XX:MaxGCPauseMillis=50 -XX:+DisableExplicitGC";
|
||
|
||
public SettingsView(LocalSettings settings)
|
||
{
|
||
_settings = settings;
|
||
InitializeComponent();
|
||
|
||
MaxSlider.Value = _settings.MaxRamMb;
|
||
MinSlider.Value = _settings.MinRamMb;
|
||
JavaBox.Text = _settings.JavaPath;
|
||
JvmBox.Text = _settings.JvmArguments;
|
||
AutoConnectBox.IsChecked = _settings.AutoConnectOnLaunch;
|
||
UpdateLabels();
|
||
|
||
MaxSlider.PropertyChanged += (_, e) => { if (e.Property == Slider.ValueProperty) UpdateLabels(); };
|
||
MinSlider.PropertyChanged += (_, e) => { if (e.Property == Slider.ValueProperty) UpdateLabels(); };
|
||
}
|
||
|
||
private void UpdateLabels()
|
||
{
|
||
MaxLabel.Text = $"Maksimum: {(int)MaxSlider.Value} MB";
|
||
MinLabel.Text = $"Minimum: {(int)MinSlider.Value} MB";
|
||
}
|
||
|
||
private async void OnBrowseJava(object? sender, RoutedEventArgs e)
|
||
{
|
||
var top = TopLevel.GetTopLevel(this);
|
||
if (top is null) return;
|
||
var files = await top.StorageProvider.OpenFilePickerAsync(new FilePickerOpenOptions
|
||
{
|
||
Title = "Java çalıştırılabilir dosyasını seç",
|
||
AllowMultiple = false
|
||
});
|
||
if (files.Count > 0)
|
||
{
|
||
var p = files[0].TryGetLocalPath();
|
||
if (!string.IsNullOrEmpty(p)) JavaBox.Text = p;
|
||
}
|
||
}
|
||
|
||
private void OnPreset(object? sender, RoutedEventArgs e) => JvmBox.Text = Preset;
|
||
|
||
private void OnSave(object? sender, RoutedEventArgs e)
|
||
{
|
||
int max = (int)MaxSlider.Value;
|
||
int min = (int)MinSlider.Value;
|
||
if (min > max) min = max;
|
||
_settings.MaxRamMb = max;
|
||
_settings.MinRamMb = min;
|
||
_settings.JavaPath = JavaBox.Text ?? "";
|
||
_settings.JvmArguments = JvmBox.Text ?? "";
|
||
_settings.AutoConnectOnLaunch = AutoConnectBox.IsChecked ?? true;
|
||
_settings.Save();
|
||
SaveStatus.Text = "Kaydedildi ✓";
|
||
}
|
||
}
|