Skip to content

Commit

Permalink
Enable install only on valid HCE & clean up XAML
Browse files Browse the repository at this point in the history
  • Loading branch information
MirisWisdom committed Nov 21, 2018
1 parent c07a340 commit 799afc9
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 23 deletions.
18 changes: 12 additions & 6 deletions AmaiSosu/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Windows;
using AmaiSosu.IO;
using AmaiSosu.Properties;
using Atarashii.API;
Expand All @@ -14,24 +15,27 @@ namespace AmaiSosu
/// <summary>
/// Main AmaiSosu model.
/// </summary>
public class Main : INotifyPropertyChanged
public sealed class Main : INotifyPropertyChanged
{
/// <summary>
/// Installation is possible given the current state.
/// </summary>
private bool _canInstall = true;
private bool _canInstall;

/// <summary>
/// Current state of the OpenSauce installation.
/// </summary>
private string _installState = "Currently awaiting the end-user to invoke OpenSauce installation.";
private string _installState = "Click Browse and select the HCE installation path.";

/// <summary>
/// Installation path.
/// Path is expected to contain the HCE executable.
/// </summary>
private string _path;

/// <summary>
/// Git version.
/// </summary>
public string Version
{
get
Expand Down Expand Up @@ -176,12 +180,14 @@ private void FinishInstall(string backupDir)
/// </summary>
private void OnPathChanged()
{
if (Directory.Exists(Path))
InstallText = "Ready to install OpenSauce to the HCE folder!";
CanInstall = Directory.Exists(Path) && File.Exists(System.IO.Path.Combine(Path, "haloce.exe"));
InstallText = CanInstall
? "Ready to install OpenSauce to the HCE folder!"
: "Click Browse and select the HCE installation path.";
}

[NotifyPropertyChangedInvocator]
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
private void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
Expand Down
30 changes: 14 additions & 16 deletions AmaiSosu/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,22 +68,19 @@
<!-- Header -->
<StackPanel Orientation="Horizontal"
HorizontalAlignment="Center">
<Label Content="HCE."
FontFamily="Segoe UI Light"
FontSize="48"
Padding="0"
HorizontalContentAlignment="Center" />
<StackPanel.Resources>
<Style TargetType="Label">
<Setter Property="FontFamily" Value="Segoe UI Light" />
<Setter Property="FontSize" Value="48" />
<Setter Property="Padding" Value="0" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
</Style>
</StackPanel.Resources>

<Label Content="HCE." />
<Label Content="Amai"
FontFamily="Segoe UI Light"
FontSize="48"
Foreground="Crimson"
Padding="0"
HorizontalContentAlignment="Center" />
<Label Content="Sosu"
FontFamily="Segoe UI Light"
FontSize="48"
Padding="0"
HorizontalContentAlignment="Center" />
Foreground="Crimson" />
<Label Content="Sosu" />
</StackPanel>

<Label Content="⸻ An OpenSauce Installer ⸻"
Expand All @@ -101,7 +98,8 @@
Padding="2.5,0,0,0" />
</DockPanel>

<Border Margin="0,10,0,0">
<Border Margin="0,10,0,0"
IsEnabled="{Binding CanInstall}">
<Button Content="⬛ Install OpenSauce"
FontSize="16"
IsEnabled="{Binding CanInstall}"
Expand Down
2 changes: 1 addition & 1 deletion AmaiSosu/Resources/Version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@

v0.3.1-7-gd4cfe3a

0 comments on commit 799afc9

Please sign in to comment.