add simple installer/uninstaller

This commit is contained in:
Mikhail Thompson
2024-07-03 16:37:42 -04:00
parent 03373e7069
commit 4b1c5473d1
21 changed files with 857 additions and 35 deletions

View File

@@ -0,0 +1,42 @@
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:vm="clr-namespace:ServerSelector.ViewModels"
mc:Ignorable="d" d:DesignWidth="370" d:DesignHeight="170"
x:Class="ServerSelector.Views.MainView"
x:DataType="vm:MainViewModel"
>
<Design.DataContext>
<!-- This only sets the DataContext for the previewer in an IDE,
to set the actual DataContext for runtime, set the DataContext property in code (look at App.axaml.cs) -->
<vm:MainViewModel />
</Design.DataContext>
<StackPanel>
<WrapPanel Margin="5">
<TextBlock VerticalAlignment="Center" Margin="5">Game path: </TextBlock>
<TextBox x:Name="txtGamePath">C:\NIKKE\NIKKE\game</TextBox>
</WrapPanel>
<WrapPanel Margin="5">
<TextBlock VerticalAlignment="Center" Margin="5">Launcher path: </TextBlock>
<TextBox x:Name="txtLauncherPath">C:\NIKKE\Launcher</TextBox>
</WrapPanel>
<WrapPanel Margin="5">
<TextBlock VerticalAlignment="Center" Margin="5">Server: </TextBlock>
<ComboBox SelectedIndex="0" x:Name="CmbServerSelection">
<ComboBox.Items>
<ComboBoxItem>Official</ComboBoxItem>
<ComboBoxItem>Local</ComboBoxItem>
</ComboBox.Items>
</ComboBox>
</WrapPanel>
<Button HorizontalAlignment="Right" Margin="5" Click="Save_Click">Save</Button>
</StackPanel>
</UserControl>

View File

@@ -0,0 +1,37 @@
using Avalonia.Controls;
using System;
using System.Runtime.InteropServices;
using System.Security.Principal;
namespace ServerSelector.Views;
public partial class MainView : UserControl
{
public MainView()
{
InitializeComponent();
CmbServerSelection.SelectedIndex = ServerSwitcher.IsUsingOfficalServer() ? 0 : 1;
}
private void Save_Click(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
{
try
{
ServerSwitcher.SaveCfg(CmbServerSelection.SelectedIndex == 0, txtGamePath.Text, txtLauncherPath.Text);
}
catch(Exception ex)
{
ShowWarningMsg("Failed to save configuration: " + ex.ToString(), "Error");
}
}
// for some stupid reason avalonia does not support message boxes.
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
public static extern int MessageBox(IntPtr hWnd, String text, String caption, uint type);
public static void ShowWarningMsg(string text, string title)
{
MessageBox(IntPtr.Zero, text, title, 0x00000030);
}
}

View File

@@ -0,0 +1,12 @@
<Window xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vm="using:ServerSelector.ViewModels"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:views="clr-namespace:ServerSelector.Views"
mc:Ignorable="d" d:DesignWidth="370" d:DesignHeight="170"
x:Class="ServerSelector.Views.MainWindow"
Icon="/Assets/avalonia-logo.ico"
Title="Server Switcher Utility" Width="370" Height="170" CanResize="False">
<views:MainView />
</Window>

View File

@@ -0,0 +1,11 @@
using Avalonia.Controls;
namespace ServerSelector.Views;
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
}