Skip to content
This repository has been archived by the owner on Aug 24, 2023. It is now read-only.

Commit

Permalink
MINOR v3.2.0 (Added optional updates + Fixed folder bug from v3.1.9)
Browse files Browse the repository at this point in the history
  • Loading branch information
weedeej committed Mar 17, 2022
1 parent 5ccac08 commit 258d917
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 20 deletions.
50 changes: 33 additions & 17 deletions ValorantCC/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -351,27 +351,43 @@ private async void spinner_Loaded(object sender, RoutedEventArgs e)
{
BackgroundAuth auth = new BackgroundAuth(DataProcessor);

if (Directory.Exists(Path.GetTempPath() + $"EZ_Updater0"))
{
Directory.CreateDirectory(Path.GetTempPath() + $"EZ_Updater0{Updater.OriginalFileName}");
Directory.Delete(Path.GetTempPath() + $"EZ_Updater0");
}

Updater.CustomLogger = Utilities.Utils.Log;
Updater.LogInterfix = " | ";
if (await Updater.CheckUpdateAsync("weedeej", "ValorantCC"))
try
{
if (Updater.CannotWriteOnDir)
if (Directory.Exists(Path.GetTempPath() + $"EZ_Updater0"))
Directory.Move(Path.GetTempPath() + $"EZ_Updater0", Path.GetTempPath() + $"EZ_Updater0{System.Reflection.Assembly.GetExecutingAssembly().GetName().Name}");
Updater.CustomLogger = Utilities.Utils.Log;
Updater.LogInterfix = " | ";
if (await Updater.CheckUpdateAsync("weedeej", "ValorantCC"))
{
Utilities.Utils.Log("User is not authorized to create a file on current valcc dir. Consider moving.");
MessageWindow.Show("There's an update available but you have no access to write on this folder.\nPlease consider moving the app to a folder created by you or running the app as administrator.");
this.Close();
if (Updater.CannotWriteOnDir)
{
Utilities.Utils.Log("User is not authorized to create a file on current valcc dir. Consider moving.");
MessageWindow.Show("There's an update available but you have no access to write on this folder.\nPlease consider moving the app to a folder created by you or running the app as administrator.");
this.Close();
}
bool UpdateMessage = MessageWindow.Show($"There is an update available. Would you like to update to {Updater.ReleaseVersion}?", Updater.ReleaseName, true);
if (!UpdateMessage)
{
if (Updater.ReleaseName.Contains("[!]"))
{
MessageWindow.Show("This update can't be skipped as it contains important patches.");
var update = new UpdateWindow();
update.Owner = this;
update.ShowDialog();
}
else Utilities.Utils.Log($"User skipped release: {Updater.ReleaseName}");
}
else
{
var update = new UpdateWindow();
update.Owner = this;
update.ShowDialog();
}
}
var update = new UpdateWindow();
update.Owner = this;
update.ShowDialog();
} catch (Exception ex)
{
Utilities.Utils.Log($"{ex.Message}: {ex.StackTrace}");
}

auth.LoopCheck();
}

Expand Down
7 changes: 6 additions & 1 deletion ValorantCC/SubWindow/MessageWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@
<Border BorderBrush="White" BorderThickness="0 0.5 0 0" Padding="0,10,0,10">
<StackPanel VerticalAlignment="Center">
<TextBlock x:Name="Messagetxtbox" TextWrapping="Wrap" Text="Here goes the text to be displayed" Width="Auto" Height="Auto" Foreground="White" FontSize="14" HorizontalAlignment="Left" Background="#FF232429" VerticalAlignment="Center" Padding="10,0,10,0"/>
<Button x:Name="OKbtn" Style="{DynamicResource RoundButton}" Content="OK" Cursor="Hand" Height="22" Width="84" Background="#FF295FFE" FontFamily="Quicksand" FontSize="14" FontWeight="DemiBold" TextBlock.FontFamily="Segoe UI Semibold" TextBlock.FontWeight="Bold" Margin="0,10,0,0" Click="OKbtn_Click"/>
<Border Padding="5,0,5,0">
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Name="ButtonGroup">
<Button x:Name="OKbtn" Style="{DynamicResource RoundButton}" Content="OK" Cursor="Hand" Height="22" Width="84" Background="#FF295FFE" FontFamily="Quicksand" FontSize="14" FontWeight="DemiBold" TextBlock.FontFamily="Segoe UI Semibold" TextBlock.FontWeight="Bold" Margin="0,10,0,0" Click="OKbtn_Click"/>

</StackPanel>
</Border>
</StackPanel>
</Border>
</StackPanel>
Expand Down
30 changes: 29 additions & 1 deletion ValorantCC/SubWindow/MessageWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;

namespace ValorantCC.SubWindow
{
Expand All @@ -8,11 +10,30 @@ namespace ValorantCC.SubWindow
/// </summary>
public partial class MessageWindow : Window
{
public static void Show(string Message, string Title = null)
public static bool Show(string Message, string Title = null, bool OkCancel = false)
{
MessageWindow MessageWin = new(Message, Title);
MessageWin.Owner = Application.Current.Windows.OfType<Window>().FirstOrDefault(x => x.IsActive);
if (OkCancel)
{
var CancelBtn = new Button()
{
Content = "CANCEL",
Height = MessageWin.OKbtn.Height,
Width = MessageWin.OKbtn.Width,
Background = MessageWin.OKbtn.Background,
FontFamily = MessageWin.OKbtn.FontFamily,
FontSize = MessageWin.OKbtn.FontSize,
Style = MessageWin.OKbtn.Style,
Cursor = MessageWin.OKbtn.Cursor,
FontWeight = MessageWin.OKbtn.FontWeight,
Margin = new Thickness(5, 10, 0, 0)
};
CancelBtn.Click += MessageWin.CancelBtn_Click;
MessageWin.ButtonGroup.Children.Add(CancelBtn);
}
MessageWin.ShowDialog();
return (bool)MessageWin.DialogResult;
}

public MessageWindow(string Message, string Title = null)
Expand All @@ -26,6 +47,13 @@ public MessageWindow(string Message, string Title = null)

private void OKbtn_Click(object sender, RoutedEventArgs e)
{
this.DialogResult = true;
Close();
}

public void CancelBtn_Click(object sender, RoutedEventArgs e)
{
this.DialogResult = false;
Close();
}
}
Expand Down
2 changes: 1 addition & 1 deletion ValorantCC/ValorantCC.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<AssemblyVersion></AssemblyVersion>
<FileVersion></FileVersion>
<Version>3.1.9</Version>
<Version>3.2.0</Version>
<SignAssembly>true</SignAssembly>
<AssemblyName>$(MSBuildProjectName)</AssemblyName>
</PropertyGroup>
Expand Down

0 comments on commit 258d917

Please sign in to comment.