Skip to content

Commit

Permalink
Make desktop shortcuts optional
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchLeaders committed Feb 3, 2024
1 parent 71d85c6 commit 58905f0
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 77 deletions.
7 changes: 5 additions & 2 deletions src/NxEditor.Launcher/Helpers/AppUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,13 @@ public class AppUpdater

public static bool IsInstalled => File.Exists(_versionFile);

public static async Task Install(bool addToPath = true)
public static async Task Install(bool addToPath = true, bool createShortcuts = true)
{
CopyRunningLauncherToOutput();
CreateDesktopShortcuts();
if (createShortcuts) {
CreateDesktopShortcuts();
}

Directory.CreateDirectory(_outputPath);

(Stream stream, string tag) = await GithubHelper.GetRelease(GITHUB_ORG, GITHUB_REPO, _zipFileName);
Expand Down
16 changes: 12 additions & 4 deletions src/NxEditor.Launcher/ViewModels/ShellViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ public partial class ShellViewModel : ObservableObject
[ObservableProperty]
private bool _isLoading = false;

[ObservableProperty]
private bool _createShortcuts = true;

[ObservableProperty]
private ObservableCollection<PluginInfo> _plugins = new(PluginManager.GetPluginInfo());

Expand Down Expand Up @@ -81,7 +84,7 @@ public async Task InstallUpdates()
IsLoading = true;

if (_canUpdate) {
await AppUpdater.Install();
await AppUpdater.Install(createShortcuts: CreateShortcuts);
}

await PluginUpdater.InstallAll(Plugins);
Expand All @@ -95,7 +98,10 @@ public async Task PrimaryButton()
{
IsLoading = true;
if (IsEditorInstalled) {
await PluginUpdater.InstallAll(Plugins);
await Task.Run(async () => {
await PluginUpdater.InstallAll(Plugins);
});

Process.Start(
Path.Combine(GlobalConfig.StaticPath, "bin", PlatformHelper.GetExecutableName())
);
Expand All @@ -105,8 +111,10 @@ public async Task PrimaryButton()
}


await AppUpdater.Install();
await PluginUpdater.InstallAll(Plugins);
await Task.Run(async () => {
await AppUpdater.Install(createShortcuts: CreateShortcuts);
await PluginUpdater.InstallAll(Plugins);
});

IsEditorInstalled = true;
PrimaryButtonContent = "Open NX Editor";
Expand Down
159 changes: 88 additions & 71 deletions src/NxEditor.Launcher/Views/ShellView.axaml
Original file line number Diff line number Diff line change
@@ -1,101 +1,118 @@
<Window x:Class="NxEditor.Launcher.Views.ShellView"
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="using:NxEditor.Launcher.ViewModels"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:pi="clr-namespace:Projektanker.Icons.Avalonia;assembly=Projektanker.Icons.Avalonia"
Title="NX Editor Launcher"
Width="650"
Height="400"
d:DesignHeight="400"
d:DesignWidth="650"
x:CompileBindings="True"
x:DataType="local:ShellViewModel"
CanResize="False"
ExtendClientAreaChromeHints="NoChrome"
ExtendClientAreaToDecorationsHint="True"
Icon="/Assets/icon.ico"
SystemDecorations="BorderOnly"
WindowStartupLocation="CenterScreen"
mc:Ignorable="d">
<Window
x:Class="NxEditor.Launcher.Views.ShellView"
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="using:NxEditor.Launcher.ViewModels"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:pi="clr-namespace:Projektanker.Icons.Avalonia;assembly=Projektanker.Icons.Avalonia"
Title="NX Editor Launcher"
Width="650"
Height="400"
d:DesignHeight="400"
d:DesignWidth="650"
x:CompileBindings="True"
x:DataType="local:ShellViewModel"
CanResize="False"
ExtendClientAreaChromeHints="NoChrome"
ExtendClientAreaToDecorationsHint="True"
Icon="/Assets/icon.ico"
SystemDecorations="BorderOnly"
WindowStartupLocation="CenterScreen"
mc:Ignorable="d">
<Grid Name="Client" Background="Transparent">
<Image VerticalAlignment="Top"
Source="/Assets/background.jpg"
Stretch="Fill" />
<Image
VerticalAlignment="Top"
Source="/Assets/background.jpg"
Stretch="Fill" />

<Border Background="{DynamicResource SystemChromeLowColor}" Opacity="0.8" />

<Grid Margin="25" RowDefinitions="Auto,*,Auto,Auto">
<Grid Margin="0,0,0,25"
Background="Transparent"
ColumnDefinitions="Auto,*">
<Grid
Margin="0,0,0,25"
Background="Transparent"
ColumnDefinitions="Auto,*">
<Image Margin="0,5,15,0" Source="/Assets/icon.ico" />
<TextBlock Grid.Column="1"
FontSize="30"
FontWeight="Bold"
Text="Nintendo Extended Editor" />
<TextBlock
Grid.Column="1"
FontSize="30"
FontWeight="Bold"
Text="Nintendo Extended Editor" />
</Grid>
<StackPanel Grid.Row="1" Orientation="Horizontal">
<ScrollViewer>
<ItemsControl ItemsSource="{Binding Plugins}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid Background="Transparent" ToolTip.Tip="{Binding Description}">
<StackPanel Margin="0,0,200,0"
HorizontalAlignment="Left"
Orientation="Horizontal">
<TextBlock Margin="0,0,0,5"
VerticalAlignment="Center"
Text="{Binding Name}" />
<Ellipse Width="10"
Height="10"
Margin="5,0,0,0"
VerticalAlignment="Center"
IsVisible="{Binding IsOnline}"
Stroke="#00a4ef"
StrokeThickness="2" />
<Ellipse Width="10"
Height="10"
Margin="5,0,0,0"
VerticalAlignment="Center"
IsVisible="{Binding CanUpdate}"
Stroke="#ffa15a"
StrokeThickness="2" />
<StackPanel
Margin="0,0,200,0"
HorizontalAlignment="Left"
Orientation="Horizontal">
<TextBlock
Margin="0,0,0,5"
VerticalAlignment="Center"
Text="{Binding Name}" />
<Ellipse
Width="10"
Height="10"
Margin="5,0,0,0"
VerticalAlignment="Center"
IsVisible="{Binding IsOnline}"
Stroke="#00a4ef"
StrokeThickness="2" />
<Ellipse
Width="10"
Height="10"
Margin="5,0,0,0"
VerticalAlignment="Center"
IsVisible="{Binding CanUpdate}"
Stroke="#ffa15a"
StrokeThickness="2" />
</StackPanel>
<ToggleSwitch Grid.Column="1"
HorizontalAlignment="Right"
IsChecked="{Binding IsEnabled}"
OffContent=""
OnContent="" />
<ToggleSwitch
Grid.Column="1"
HorizontalAlignment="Right"
IsChecked="{Binding IsEnabled}"
OffContent=""
OnContent="" />
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</StackPanel>
<ProgressBar Grid.Row="2"
Margin="0,15"
IsIndeterminate="True"
IsVisible="{Binding IsLoading}" />
<StackPanel Grid.Row="3"
HorizontalAlignment="Right"
Orientation="Horizontal"
Spacing="10">
<ProgressBar
Grid.Row="2"
Margin="0,15"
IsIndeterminate="True"
IsVisible="{Binding IsLoading}" />
<StackPanel
Grid.Row="3"
HorizontalAlignment="Right"
Orientation="Horizontal"
Spacing="10">
<CheckBox
Content="Create Shortcuts"
IsChecked="{Binding CreateShortcuts}"
IsVisible="{Binding !IsEditorInstalled}" />
<Button Command="{Binding InstallUpdatesCommand}" Content="{Binding FoundUpdates, StringFormat='Install Updates ({0})'}" />
<Button Command="{Binding PrimaryButtonCommand}" Content="{Binding PrimaryButtonContent}" />
</StackPanel>
<StackPanel Grid.Row="3"
HorizontalAlignment="Left"
Orientation="Horizontal"
Spacing="10">
<StackPanel
Grid.Row="3"
HorizontalAlignment="Left"
Orientation="Horizontal"
Spacing="10">
<Button VerticalAlignment="Stretch" Command="{Binding ShowHelpCommand}">
<pi:Icon Value="fa-solid fa-info" />
</Button>
<Button Command="{Binding ExitCommand}" Content="Exit" />
<Button Command="{Binding UninstallCommand}"
Content="Uninstall"
IsVisible="{Binding IsEditorInstalled}" />
<Button
Command="{Binding UninstallCommand}"
Content="Uninstall"
IsVisible="{Binding IsEditorInstalled}" />
</StackPanel>
</Grid>
</Grid>
Expand Down
4 changes: 4 additions & 0 deletions src/NxEditor.Launcher/Views/ShellView.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,8 @@ public ShellView()
InitializeComponent();
Client.PointerPressed += (s, e) => BeginMoveDrag(e);
}

private void Binding(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
{
}
}

0 comments on commit 58905f0

Please sign in to comment.