Browse Source

added game window size startup settings

Veloe 1 year ago
parent
commit
6895b67bb3

+ 49 - 0
VeloeMinecraftLauncher/App.axaml

@@ -9,4 +9,53 @@
 	<Application.Styles>
 		<FluentTheme />
 	</Application.Styles>
+	<Application.Resources>
+		<ControlTheme x:Key="FixDataValidation" TargetType="NumericUpDown">
+			<Setter Property="Foreground" Value="{DynamicResource TextControlForeground}" />
+			<Setter Property="Background" Value="{DynamicResource TextControlBackground}" />
+			<Setter Property="BorderThickness" Value="{DynamicResource TextControlBorderThemeThickness}" />
+			<Setter Property="BorderBrush" Value="{DynamicResource TextControlBorderBrush}" />
+			<Setter Property="MinHeight" Value="{DynamicResource TextControlThemeMinHeight}" />
+			<Setter Property="MinWidth" Value="{DynamicResource TextControlThemeMinWidth}" />
+			<Setter Property="Padding" Value="{DynamicResource TextControlThemePadding}" />
+			<Setter Property="CornerRadius" Value="{DynamicResource ControlCornerRadius}" />
+			<Setter Property="Template">
+				<ControlTemplate>
+					<DataValidationErrors>
+						<ButtonSpinner Name="PART_Spinner"
+									   Background="{TemplateBinding Background}"
+									   BorderThickness="{TemplateBinding BorderThickness}"
+									   BorderBrush="{TemplateBinding BorderBrush}"
+									   CornerRadius="{TemplateBinding CornerRadius}"
+									   IsTabStop="False"
+									   Padding="0"
+									   MinWidth="0"
+									   HorizontalContentAlignment="Stretch"
+									   VerticalContentAlignment="Stretch"
+									   AllowSpin="{TemplateBinding AllowSpin}"
+									   ShowButtonSpinner="{TemplateBinding ShowButtonSpinner}"
+									   ButtonSpinnerLocation="{TemplateBinding ButtonSpinnerLocation}">
+							<TextBox Name="PART_TextBox"
+									 Background="Transparent"
+									 BorderBrush="Transparent"
+									 Margin="-1"
+									 Padding="{TemplateBinding Padding}"
+									 MinWidth="0"
+									 Foreground="{TemplateBinding Foreground}"
+									 Watermark="{TemplateBinding Watermark}"
+									 IsReadOnly="{TemplateBinding IsReadOnly}"
+									 VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
+									 HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
+									 Text="{TemplateBinding Text}"
+									 TextAlignment="{TemplateBinding TextAlignment}"
+									 AcceptsReturn="False"
+									 TextWrapping="NoWrap"
+									 InnerLeftContent="{Binding InnerLeftContent, RelativeSource={RelativeSource TemplatedParent}}"
+									 InnerRightContent="{Binding InnerRightContent, RelativeSource={RelativeSource TemplatedParent}}"/>
+						</ButtonSpinner>
+					</DataValidationErrors>
+				</ControlTemplate>
+			</Setter>
+		</ControlTheme>
+	</Application.Resources>
 </Application>

+ 14 - 0
VeloeMinecraftLauncher/Utils/Converters.cs

@@ -0,0 +1,14 @@
+using Avalonia.Data.Converters;
+using System.Linq;
+
+namespace VeloeMinecraftLauncher.Utils
+{
+    public static class Converters
+    {
+        /// <summary>
+        /// Gets list of bool values and conjuct them
+        /// </summary>
+        public static FuncMultiValueConverter<bool?, bool> BoolConjuctionConventer { get; } =
+            new FuncMultiValueConverter<bool?, bool>(bools => !bools.Any(x => x is null or false));
+    }
+}

+ 18 - 1
VeloeMinecraftLauncher/Utils/Settings.cs

@@ -27,6 +27,10 @@ internal static class Settings
     public static UInt32 maxLog = 1024;
     public static LogEventLevel consoleLogEventLevel = LogEventLevel.Debug;
     public static LogEventLevel fileLogEventLevel = LogEventLevel.Debug;
+    public static bool fullscreen = false;
+    public static bool customsize = false;
+    public static UInt32 clientwidth = 0;
+    public static UInt32 clientheight = 0;
 
     public static void UpdateSettings(SettingsSerializable settings)
     {
@@ -46,7 +50,10 @@ internal static class Settings
         maxLog = settings.MaxLog;
         consoleLogEventLevel = settings.ConsoleLogEventLevel;
         fileLogEventLevel = settings.FileLogEventLevel;
-
+        fullscreen = settings.FullScreen;
+        customsize = settings.CustomSize;
+        clientheight = settings.ClientHeight;
+        clientwidth = settings.ClientWidth;
     }
 
     public static void LoadSettings()
@@ -110,6 +117,12 @@ public class SettingsSerializable
 
     public bool SetMaxLog { get; set; }
     public UInt32 MaxLog { get; set; }
+
+    public bool FullScreen { get; set; }
+    public bool CustomSize { set; get; }
+    public UInt32 ClientWidth { get; set; }
+    public UInt32 ClientHeight { get; set; }
+
     public LogEventLevel ConsoleLogEventLevel { get; set; }
     public LogEventLevel FileLogEventLevel { get; set; }
 
@@ -129,5 +142,9 @@ public class SettingsSerializable
         MaxLog = Settings.maxLog;
         ConsoleLogEventLevel= Settings.consoleLogEventLevel;
         FileLogEventLevel= Settings.fileLogEventLevel;
+        FullScreen = Settings.fullscreen;
+        CustomSize = Settings.customsize;
+        ClientHeight = Settings.clientheight;
+        ClientWidth = Settings.clientwidth;
     }
 }

+ 7 - 0
VeloeMinecraftLauncher/Utils/Starter/StartCommandBuilder.cs

@@ -355,6 +355,13 @@ internal static class StartCommandBuilder
                     break;
             }
         }
+
+        if (Settings.fullscreen)
+            returnString.Append(" --fullscreen");
+
+        if (Settings.customsize && !Settings.fullscreen)
+            returnString.Append($" --width {Settings.clientwidth} --height {Settings.clientheight}");
+
         return returnString.ToString();
     }
 

+ 3 - 4
VeloeMinecraftLauncher/VeloeMinecraftLauncher.csproj

@@ -1,7 +1,7 @@
 <Project Sdk="Microsoft.NET.Sdk">
 	<PropertyGroup>
 		<OutputType>WinExe</OutputType>
-		<TargetFramework>net8.0</TargetFramework>
+		<TargetFrameworks>net8.0;net7.0</TargetFrameworks>
 		<TieredCompilationQuickJit>false</TieredCompilationQuickJit>
 		<JsonSerializerIsReflectionEnabledByDefault>true</JsonSerializerIsReflectionEnabledByDefault>
 		<Nullable>enable</Nullable>
@@ -10,8 +10,8 @@
 		<DebugType>embedded</DebugType>
 		<StartupObject>VeloeMinecraftLauncher.Program</StartupObject>
 		<PlatformTarget>x64</PlatformTarget>
-		<AssemblyVersion>1.5.0.56</AssemblyVersion>
-		<FileVersion>1.5.0.56</FileVersion>
+		<AssemblyVersion>1.5.1.73</AssemblyVersion>
+		<FileVersion>1.5.1.73</FileVersion>
 		<Configurations>Debug;Release</Configurations>
 	</PropertyGroup>
 	<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
@@ -42,7 +42,6 @@
 		<PackageReference Include="Avalonia.Themes.Fluent" Version="11.0.10" />
 		<PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="6.0.0" />
 		<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="8.0.4" />
-		<PackageReference Include="ReactiveUI.Blazor" Version="19.6.12" />
 		<PackageReference Include="ReactiveUI.Validation" Version="3.1.7" />
 		<PackageReference Include="Serilog" Version="3.1.1" />
 		<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />

+ 43 - 10
VeloeMinecraftLauncher/ViewModels/SettingsWindowViewModel.cs

@@ -16,27 +16,20 @@ namespace VeloeMinecraftLauncher.ViewModels;
 
 public class SettingsWindowViewModel : ViewModelBase
 {
+    public SettingsWindowViewModel() : this(new Serilog.LoggerConfiguration().CreateLogger())
+    { }
     public SettingsWindowViewModel(Serilog.ILogger logger)
     {
         LauncherVersion = Assembly.GetExecutingAssembly().GetName().Version?.ToString() ?? "unknown";
 
         _logger = logger;
 
-        this.ValidationRule(
-            viewModel => viewModel.MaxRam,
-            value => { UInt32 result; bool resultb = UInt32.TryParse(value, out result); return resultb; },
-            "Not a number.");
-
         var helper = this.ValidationRule(
             viewModel => viewModel.JavaPath,
             value => { if (value is null) return false; string path = Path.Combine(value , "bin/java"); if (OperatingSystem.IsWindows()) path += ".exe"; bool resultb = File.Exists(path); return resultb; },
             "Can't find java executable.");
 
-        this.ValidationRule(
-            viewModel => viewModel.MaxLog,
-            value => { UInt32 result; bool resultb = UInt32.TryParse(value, out result); return resultb; },
-            "Not a number.");   
-}
+    }
 
     private string _launcherVersion = string.Empty;
     private string _minecraftFolderPath = Settings.minecraftForlderPath;
@@ -101,6 +94,46 @@ public class SettingsWindowViewModel : ViewModelBase
         }
     }
 
+    public bool FullScreen
+    {
+        get => Settings.fullscreen;
+        set
+        {
+            this.RaiseAndSetIfChanged(ref Settings.customsize, !value, nameof(CustomSize));
+            this.RaiseAndSetIfChanged(ref Settings.fullscreen, value);
+        }
+    }
+
+    public bool CustomSize
+    {
+        get => Settings.customsize;
+        set
+        {
+            this.RaiseAndSetIfChanged(ref Settings.fullscreen, !value, nameof(FullScreen));
+            this.RaiseAndSetIfChanged(ref Settings.customsize, value);
+        }
+    }
+
+    public uint ClientWidth
+    {
+        get => Settings.clientwidth;
+        set => this.RaiseAndSetIfChanged(ref Settings.clientwidth, value);
+        /*{
+            if (uint.TryParse(value, out var result) && result != Settings.clientwidth)
+            {
+                Settings.clientwidth = result;
+                if (!string.IsNullOrEmpty(value))
+                    this.RaisePropertyChanged();
+            }
+        }*/
+    }
+
+    public uint ClientHeight
+    {
+        get => Settings.clientheight;
+        set => this.RaiseAndSetIfChanged(ref Settings.clientheight, value);
+    }
+
     public bool IsValid
     {
         get

+ 193 - 24
VeloeMinecraftLauncher/Views/SettingsWindow.axaml

@@ -4,6 +4,8 @@
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
 		xmlns:titlebars="using:VeloeMinecraftLauncher.Views.TitleBar"
+		xmlns:utils="using:VeloeMinecraftLauncher.Utils"
+		xmlns:controls="using:VeloeMinecraftLauncher.Controls"
         mc:Ignorable="d" d:DesignWidth="600" d:DesignHeight="450"
 		Width="600" Height="450"
 		MaxWidth="600" MaxHeight="450"
@@ -44,36 +46,150 @@
 			  DockPanel.Dock="Top">
 			</titlebars:TitleBarWindow>
 			<TabControl
-				HorizontalAlignment="Stretch" DockPanel.Dock="Top">
+				HorizontalAlignment="Stretch" 
+				DockPanel.Dock="Top">
 				<TabItem
 					Header="Game"
 					VerticalContentAlignment="Center">
-					<Grid Margin="10 0 10 5" ShowGridLines="false" RowDefinitions="Auto, Auto, Auto, Auto, Auto, Auto, Auto">
-						
+					<Grid 
+						Margin="10 0 10 5" 
+						ShowGridLines="false" 
+						RowDefinitions="Auto, Auto, Auto, Auto, Auto, Auto, Auto">
 						<Grid.ColumnDefinitions>
 							<ColumnDefinition Width="250"></ColumnDefinition>
 							<ColumnDefinition Width="*"></ColumnDefinition>
 							<ColumnDefinition Width="70"></ColumnDefinition>
 						</Grid.ColumnDefinitions>
 
-						<CheckBox Grid.Row="1" Grid.Column="0" IsChecked="true" IsEnabled="False">Set path to minecraft folder</CheckBox>
-						<TextBox Grid.Row="1" Grid.Column="1" Margin="5" Text="{Binding MinecraftFolderPath}" IsEnabled="{Binding SetMinecraftFolder}"></TextBox>
-						<Button Grid.Row="1" Grid.Column="2" Content="Open" Command="{Binding OpenMinecraftPathDialog}" CommandParameter="{Binding $parent[Window]}" HorizontalAlignment="Stretch" HorizontalContentAlignment="Center"></Button>
+						<CheckBox 
+							Grid.Row="1" Grid.Column="0" 
+							IsChecked="true" 
+							IsEnabled="False">
+							Set path to minecraft folder
+						</CheckBox>
+						<TextBox 
+							Grid.Row="1" Grid.Column="1" 
+							Margin="5" 
+							Text="{Binding MinecraftFolderPath}" 
+							IsEnabled="{Binding SetMinecraftFolder}"/>
+						<Button 
+							Grid.Row="1" Grid.Column="2" 
+							Content="Open" 
+							Command="{Binding OpenMinecraftPathDialog}"
+							CommandParameter="{Binding $parent[Window]}" 
+							HorizontalAlignment="Stretch" 
+							HorizontalContentAlignment="Center"/>
 
-						<CheckBox Grid.Row="2" Grid.Column="0" IsChecked="{Binding UseCustomJava}">Use custom java</CheckBox>
-						<TextBox Grid.Row="2" Grid.Column="1" Margin="5" Text="{Binding JavaPath}" IsEnabled="{Binding UseCustomJava}"></TextBox>
-						<Button Grid.Row="2" Grid.Column="2" Content="Open" Command="{Binding OpenJavaPathDialog}" CommandParameter="{Binding $parent[Window]}" IsEnabled="{Binding UseCustomJava}" HorizontalAlignment="Stretch" HorizontalContentAlignment="Center"></Button>
+						<CheckBox 
+							Grid.Row="2" 
+							Grid.Column="0" 
+							IsChecked="{Binding UseCustomJava}">
+							Use custom java
+						</CheckBox>
+						<TextBox 
+							Grid.Row="2" Grid.Column="1" 
+							Margin="5" 
+							Text="{Binding JavaPath}" 
+							IsEnabled="{Binding UseCustomJava}"/>
+						<Button 
+							Grid.Row="2" Grid.Column="2" 
+							Content="Open" 
+							Command="{Binding OpenJavaPathDialog}" 
+							CommandParameter="{Binding $parent[Window]}" 
+							IsEnabled="{Binding UseCustomJava}" 
+							HorizontalAlignment="Stretch" 
+							HorizontalContentAlignment="Center"/>
 
-						<CheckBox Grid.Row="3" Grid.Column="0" IsChecked="{Binding SetMaxRam}">Set max RAM</CheckBox>
-						<TextBox Grid.Row="3" Grid.Column="1" Margin="5" Name="MaxRam" Text="{Binding MaxRam}" IsEnabled="{Binding SetMaxRam}" HorizontalAlignment="Left" VerticalAlignment="Top"></TextBox>
+						<CheckBox Grid.Row="3" Grid.Column="0" 
+								  IsChecked="{Binding FullScreen}">Fullscreen mode</CheckBox>
+						
+						<CheckBox 
+							Grid.Row="4" Grid.Column="0" 
+							IsChecked="{Binding CustomSize}">Set game resolution</CheckBox>
+						
+						<StackPanel 
+							Grid.Row="4" Grid.Column="1" 
+							Orientation="Horizontal">
+							<NumericUpDown
+								Margin="5"
+								Name="GameWidthEdit"
+								Value="{Binding ClientWidth}"
+								MaxWidth="200"
+								ParsingNumberStyle="Integer"
+								Minimum="1280"
+								Maximum="{Binding $parent[Window].MaxGameWidth}"
+								Theme="{StaticResource FixDataValidation}"
+								ClipValueToMinMax ="True"
+								ShowButtonSpinner="False"
+								HorizontalAlignment="Left"
+								VerticalAlignment="Top">
+								<NumericUpDown.IsEnabled>
+									<MultiBinding Converter="{x:Static utils:Converters.BoolConjuctionConventer}">
+										<Binding Path="!FullScreen"/>
+										<Binding Path="CustomSize"/>
+									</MultiBinding>
+								</NumericUpDown.IsEnabled>
+							</NumericUpDown>
+							<TextBlock VerticalAlignment="Center">x</TextBlock>
+							<NumericUpDown
+								Margin="5"
+								Name="GameHeightEdit"
+								Value="{Binding ClientHeight}"
+								MaxWidth="200"
+								ParsingNumberStyle="Integer"
+								Minimum="720"
+								Maximum="{Binding $parent[Window].MaxGameHeight}"
+								Theme="{StaticResource FixDataValidation}"
+								ClipValueToMinMax ="True"
+								ShowButtonSpinner="False"
+								HorizontalAlignment="Left"
+								VerticalAlignment="Top">
+								<NumericUpDown.IsEnabled>
+									<MultiBinding Converter="{x:Static utils:Converters.BoolConjuctionConventer}">
+										<Binding Path="!FullScreen"/>
+										<Binding Path="CustomSize"/>
+									</MultiBinding>
+								</NumericUpDown.IsEnabled>
+							</NumericUpDown>
+						</StackPanel>		
 
-						<CheckBox Grid.Row="4" Grid.ColumnSpan="2" IsChecked="{Binding CheckAssets}" IsEnabled="True">Check vanilla game files before start</CheckBox>
+						<CheckBox 
+							Grid.Row="5" Grid.Column="0" IsChecked="{Binding SetMaxRam}">Set max RAM</CheckBox>
+						<StackPanel 
+							Grid.Row="5" Grid.Column="1" 
+							Orientation="Horizontal">
+							<NumericUpDown 
+								Grid.Row="5" Grid.Column="1" 
+								Margin="5" 
+								Name="MaxRamEdit" 
+								Value="{Binding MaxRam}" 
+								ParsingNumberStyle="Integer"
+								MaxWidth="200"
+								Minimum="256"
+								Maximum="{Binding $parent[Window].MaxRam}"
+								Theme="{StaticResource FixDataValidation}"
+								ClipValueToMinMax ="True"
+								ShowButtonSpinner="False" 
+								IsEnabled="{Binding SetMaxRam}" 
+								HorizontalAlignment="Left"
+								VerticalAlignment="Top"/>
+							<TextBlock VerticalAlignment="Center">MB</TextBlock>
+						</StackPanel>
+						<CheckBox 
+							Grid.Row="6" Grid.ColumnSpan="2" 
+							IsChecked="{Binding CheckAssets}" 
+							IsEnabled="True">
+							Check vanilla game files before start
+						</CheckBox>
 					</Grid>
 				</TabItem>
 				<TabItem
 					Header="Log"
 					VerticalContentAlignment="Center">
-					<Grid Margin="10 0 10 5" ShowGridLines="false" RowDefinitions="Auto, Auto, Auto, Auto, Auto, Auto, Auto">
+					<Grid 
+						Margin="10 0 10 5" 
+						ShowGridLines="false" 
+						RowDefinitions="Auto, Auto, Auto, Auto, Auto, Auto, Auto">
 						
 						<Grid.ColumnDefinitions>
 							<ColumnDefinition Width="250"></ColumnDefinition>
@@ -81,23 +197,76 @@
 							<ColumnDefinition Width="70"></ColumnDefinition>
 						</Grid.ColumnDefinitions>
 						
-						<TextBlock Grid.Row="1" Grid.Column="0" VerticalAlignment="Center">Console log event level</TextBlock>
-						<ComboBox Grid.Row="1" Grid.Column="1" Margin="5" ItemsSource="{Binding LogEventLevels}" PlaceholderText="Select level" SelectedItem="{Binding ConsoleLogEventLevel}" HorizontalAlignment="Stretch"></ComboBox>
+						<TextBlock 
+							Grid.Row="1" Grid.Column="0"
+							VerticalAlignment="Center" Text="Console log event level"/>
+						<ComboBox 
+							Grid.Row="1" Grid.Column="1" 
+							Margin="5" 
+							ItemsSource="{Binding LogEventLevels}" 
+							PlaceholderText="Select level" 
+							SelectedItem="{Binding ConsoleLogEventLevel}" 
+							HorizontalAlignment="Stretch"/>
 						
-						<TextBlock Grid.Row="2" Grid.Column="0" VerticalAlignment="Center">File log event level</TextBlock>
-						<ComboBox Grid.Row="2" Grid.Column="1" Margin="5" ItemsSource="{Binding LogEventLevels}" PlaceholderText="Select level" SelectedItem="{Binding FileLogEventLevel}" HorizontalAlignment="Stretch"></ComboBox>
+						<TextBlock 
+							Grid.Row="2" Grid.Column="0"
+							VerticalAlignment="Center">File log event level</TextBlock>
+						<ComboBox 
+							Grid.Row="2" Grid.Column="1" 
+							Margin="5" 
+							ItemsSource="{Binding LogEventLevels}" 
+							PlaceholderText="Select level" 
+							SelectedItem="{Binding FileLogEventLevel}" 
+							HorizontalAlignment="Stretch"/>
 						
-						<CheckBox Grid.Row="3" Grid.Column="0" IsChecked="{Binding SetMaxLog}">Set max log size</CheckBox>
-						<TextBox Grid.Row="3" Grid.Column="1" Margin="5" Name="MaxLog" Text="{Binding MaxLog}" IsEnabled="{Binding SetMaxLog}" HorizontalAlignment="Left" VerticalAlignment="Top"></TextBox>
-
-						<CheckBox Grid.Row="4" Grid.ColumnSpan="2" IsChecked="{Binding GameLogToLauncher}">Show game log in launcher (performace issues)</CheckBox>
-						<Button Grid.Row="5" Grid.ColumnSpan="2" Content="Open log" Command="{Binding OpenLogFile}"></Button>
+						<CheckBox 
+							Grid.Row="3" Grid.Column="0" 
+							IsChecked="{Binding SetMaxLog}">Set max log size</CheckBox>
+						<StackPanel
+							Grid.Row="3" Grid.Column="1"
+							Orientation="Horizontal">
+							<NumericUpDown
+								Margin="5" 
+								Name="MaxLogEdit" 
+								Value="{Binding MaxLog}" 
+								MaxWidth="200"
+								ParsingNumberStyle="Integer" 
+								IsEnabled="{Binding SetMaxLog}" 
+								Minimum="1" 
+								Maximum="1048576"
+								Theme="{StaticResource FixDataValidation}"
+								ClipValueToMinMax ="True" 
+								ShowButtonSpinner="False" 
+								HorizontalAlignment="Left" 
+								VerticalAlignment="Top"/>
+							<TextBlock VerticalAlignment="Center">KB</TextBlock>
+						</StackPanel>
+						<DockPanel 
+							Grid.Row="4" Grid.ColumnSpan="3">
+							<Button
+								DockPanel.Dock="Right"
+								Content="Open log"
+								Command="{Binding OpenLogFile}"/>
+							<CheckBox 
+								DockPanel.Dock="Left"
+								IsChecked="{Binding GameLogToLauncher}">Show game log in launcher (performace issues)</CheckBox>
+						</DockPanel>
 					</Grid>
 				</TabItem>
 				
 			</TabControl>
-			<Button Command="{Binding SaveSettings}" IsEnabled="{Binding IsValid}" Content="Save" VerticalAlignment="Bottom" Margin="10 0 0 10"></Button>
-			<TextBlock Text="{Binding LauncherVersion}" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="0 0 10 10"></TextBlock>			
+			<TextBlock
+				Text="{Binding LauncherVersion}"
+				HorizontalAlignment="Left"
+				VerticalAlignment="Bottom"
+				Margin="10 0 0 10"/>
+			<Button 
+				Command="{Binding SaveSettings}" 
+				IsEnabled="{Binding IsValid}" 
+				Content="Save" 
+				HorizontalAlignment="Right"
+				VerticalAlignment="Bottom" 
+				Margin="0 0 10 10"/>	
 		</DockPanel>
 	</Panel>
 </Window>

+ 18 - 0
VeloeMinecraftLauncher/Views/SettingsWindow.axaml.cs

@@ -1,4 +1,7 @@
 using Avalonia.Controls;
+using Avalonia.Input;
+using System;
+using System.Linq;
 
 namespace VeloeMinecraftLauncher.Views
 {
@@ -7,6 +10,21 @@ namespace VeloeMinecraftLauncher.Views
         public SettingsWindow()
         {
             InitializeComponent();
+            this.FindControl<NumericUpDown>("GameWidthEdit").AddHandler(TextInputEvent, NumericUpDown_TextInput, Avalonia.Interactivity.RoutingStrategies.Tunnel);
+            this.FindControl<NumericUpDown>("GameHeightEdit").AddHandler(TextInputEvent, NumericUpDown_TextInput, Avalonia.Interactivity.RoutingStrategies.Tunnel);
+            this.FindControl<NumericUpDown>("MaxRamEdit").AddHandler(TextInputEvent, NumericUpDown_TextInput, Avalonia.Interactivity.RoutingStrategies.Tunnel);
+            this.FindControl<NumericUpDown>("MaxLogEdit").AddHandler(TextInputEvent, NumericUpDown_TextInput, Avalonia.Interactivity.RoutingStrategies.Tunnel);
+        }
+
+        private int MaxGameWidth => Screens.All.Select(x => x.Bounds.Width).Max();
+
+        private int MaxGameHeight => Screens.All.Select(x => x.Bounds.Height).Max();
+
+        private long MaxRam => GC.GetGCMemoryInfo().TotalAvailableMemoryBytes / 1024 / 1024;
+
+        private void NumericUpDown_TextInput(object? sender, TextInputEventArgs e)
+        {
+            e.Handled = !e.Text?.All(x => char.IsDigit(x)) ?? false;
         }
     }
 }