Skip to content

Commit

Permalink
Added Version logic, fixed bug not downloading DB
Browse files Browse the repository at this point in the history
  • Loading branch information
netquick committed Jul 21, 2024
1 parent e28da19 commit b798cb2
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 19 deletions.
38 changes: 26 additions & 12 deletions DeFRaG_Helper/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,30 @@ protected override void OnStartup(StartupEventArgs e)
base.OnStartup(e);
// Initialize logging
MessageHelper.Log("Application starting");
LoadConfigurationAndStartAsync().ContinueWith(_ =>
LoadConfigurationAndStartAsync().ContinueWith(task =>
{
// This ensures the continuation runs on the UI thread
Dispatcher.Invoke(() =>
if (task.IsFaulted)
{
// Now that configuration and resources are loaded, show the main window
MessageHelper.Log("Main window created");
MainWindow mainWindow = new MainWindow();
mainWindow.Show();
});
});
// Log the error or show an error message to the user
MessageHelper.Log($"Error during startup: {task.Exception}");
// Optionally, close the application if critical startup tasks fail
Dispatcher.Invoke(() => Current.Shutdown());
}
else
{
// This ensures the continuation runs on the UI thread
Dispatcher.Invoke(() =>
{
// Now that configuration and resources are loaded, show the main window
MessageHelper.Log("Main window created");
MainWindow mainWindow = new MainWindow();
mainWindow.Show();
});
}
});
StartDelayedTasks();

}

private async void StartDelayedTasks()
{
// Wait for 1 minute after the application starts
Expand All @@ -51,12 +61,16 @@ private async Task LoadConfigurationAndStartAsync()

ApplyThemeColor();
// Create an instance of MapHistoryManager


await AppConfig.EnsureDatabaseExistsAsync();
MessageHelper.Log("Database exists");

MessageHelper.Log("Creating MapHistoryManager");
var mapHistoryManager = MapHistoryManager.GetInstance("DeFRaG_Helper");
MessageHelper.Log("MapHistoryManager created");

await AppConfig.EnsureDatabaseExistsAsync();
MessageHelper.Log("Database exists");

// The main window creation and showing is moved to the continuation of this method in OnStartup
}
private void ApplyThemeColor()
Expand Down
1 change: 1 addition & 0 deletions DeFRaG_Helper/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Reflection;
using System.Windows;

[assembly: ThemeInfo(
Expand Down
2 changes: 2 additions & 0 deletions DeFRaG_Helper/DeFRaG_Helper.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
<ImplicitUsings>enable</ImplicitUsings>
<UseWPF>true</UseWPF>
<ApplicationIcon>Quake3.ico</ApplicationIcon>
<AssemblyVersion>1.0.0</AssemblyVersion>
<FileVersion>1.0.0</FileVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
1 change: 0 additions & 1 deletion DeFRaG_Helper/Helpers/Downloader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ namespace DeFRaG_Helper
{
public static class Downloader
{

private static readonly HttpClient httpClient = CreateHttpClient();

private static HttpClient CreateHttpClient()
Expand Down
2 changes: 1 addition & 1 deletion DeFRaG_Helper/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<!-- Application Title Label -->
<Label Grid.Column="0" Content="DeFRaG_Helper" VerticalAlignment="Center" Foreground="{DynamicResource ThemeColor}" FontSize="20" Margin="10,0,0,0"/>
<Label Grid.Column="0" Content="{Binding AppTitleAndVersion}" VerticalAlignment="Center" Foreground="{DynamicResource ThemeColor}" FontSize="20" Margin="10,0,0,0"/>
<TextBox x:Name="searchBar" Grid.Column="1" VerticalAlignment="Center" FontSize="20" Margin="306,0,306,0" Height="34" Text="Search..." GotFocus="SearchBox_GotFocus" IsEnabled="False"/>
<!-- Spacer to push buttons to the right -->
<StackPanel Grid.Column="2" Orientation="Horizontal" HorizontalAlignment="Right">
Expand Down
13 changes: 12 additions & 1 deletion DeFRaG_Helper/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using DeFRaG_Helper.ViewModels;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Controls;
Expand Down Expand Up @@ -69,6 +70,9 @@ public MainWindow()
hideProgressBarTimer = new System.Timers.Timer(2000);
hideProgressBarTimer.Elapsed += HideProgressBarTimer_Elapsed;
hideProgressBarTimer.AutoReset = false; // Ensure the timer runs only once per start

this.DataContext = this;

}

//Method to apply filters based on the page navigated to in the MainFrame
Expand All @@ -77,7 +81,14 @@ private void MainFrame_Navigated(object sender, NavigationEventArgs e)
ApplyFilterBasedOnPageAsync(e.Content); //AppConfig.OnRequestGameDirectory += RequestGameDirectoryAsync;

}

public string AppTitleAndVersion
{
get
{
var version = Assembly.GetExecutingAssembly().GetName().Version;
return $"DeFRaG_Helper v{version.Major}.{version.Minor}.{version.Build}";
}
}
//Method to request game directory
private async Task<string> RequestGameDirectoryAsync()
{
Expand Down
5 changes: 1 addition & 4 deletions DeFRaG_Helper/ToDo.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
- Edit maps
- Config editor
- Records
- Versioning

- Own File Browser remove old..
- Refactor appConfig logic to ask gamepath
- Versioning and AutoUpdate



Expand Down

0 comments on commit b798cb2

Please sign in to comment.