Skip to content

Commit

Permalink
Added reinstall loader button and updated for latest addon loader.
Browse files Browse the repository at this point in the history
  • Loading branch information
Friendly0Fire committed Apr 22, 2023
1 parent 78c6574 commit 26577ee
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 12 deletions.
21 changes: 13 additions & 8 deletions application/GW2 Addon Manager/Backend/LoaderSetup/LoaderSetup.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System.ComponentModel;
using System;
using System.ComponentModel;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Net;
using System.Threading.Tasks;
using GW2_Addon_Manager.App.Configuration;
Expand All @@ -17,7 +19,7 @@ class LoaderSetup
UpdatingViewModel viewModel;
string fileName;
string latestLoaderVersion;
string loader_dxgi_destination;
string[] loader_dxgi_destination;
string loader_d3d11_destination;
string loader_self_destination;

Expand All @@ -36,18 +38,20 @@ public LoaderSetup(IConfigurationManager configurationManager)
/// Checks for update to addon loader and downloads if a new release is available
/// </summary>
/// <returns></returns>
public async Task HandleLoaderUpdate()
public async Task HandleLoaderUpdate(bool force)
{
dynamic releaseInfo = UpdateHelpers.GitReleaseInfo(loader_git_url);

loader_d3d11_destination = Path.Combine(loader_game_path, "d3d11.dll");
loader_dxgi_destination = Path.Combine(loader_game_path, "bin64/cef/dxgi.dll");
loader_dxgi_destination = new string[] { Path.Combine(loader_game_path, "bin64/cef/dxgi.dll"),
Path.Combine(loader_game_path, "bin64/dxgi.dll"),
Path.Combine(loader_game_path, "dxgi.dll") };
loader_self_destination = Path.Combine(loader_game_path, "addonLoader.dll");

latestLoaderVersion = releaseInfo.tag_name;

if (File.Exists(loader_d3d11_destination) &&
File.Exists(loader_dxgi_destination) &&
if (!force && File.Exists(loader_d3d11_destination) &&
loader_dxgi_destination.All(File.Exists) &&
File.Exists(loader_self_destination) &&
_configurationManager.UserConfig.LoaderVersion == latestLoaderVersion)
return;
Expand Down Expand Up @@ -80,8 +84,9 @@ private void Install()
if (File.Exists(loader_d3d11_destination))
File.Delete(loader_d3d11_destination);

if (File.Exists(loader_dxgi_destination))
File.Delete(loader_dxgi_destination);
foreach (var x in loader_dxgi_destination)
if (File.Exists(x))
File.Delete(x);

if (File.Exists(loader_self_destination))
File.Delete(loader_self_destination);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public static async void UpdateAll()
UpdatingViewModel viewModel = UpdatingViewModel.GetInstance;

LoaderSetup settingUp = new LoaderSetup(new ConfigurationManager());
await settingUp.HandleLoaderUpdate();
await settingUp.HandleLoaderUpdate((bool)Application.Current.Properties["ForceLoader"]);

List<AddonInfoFromYaml> addons = (List<AddonInfoFromYaml>)Application.Current.Properties["Selected"];

Expand Down
2 changes: 1 addition & 1 deletion application/GW2 Addon Manager/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.4.4.0")]
[assembly: AssemblyVersion("1.4.5.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
15 changes: 14 additions & 1 deletion application/GW2 Addon Manager/UI/OpeningPage/OpeningView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@
/>
</Storyboard>
</BeginStoryboard>

</EventTrigger>
</TextBlock.Triggers>
<!-- -->
Expand Down Expand Up @@ -338,6 +338,19 @@
BorderBrush="#FFC9C9C9"
Style="{StaticResource BigContentButton}" FontWeight="Bold"
/>
<Button Grid.Row="3" x:Name="reinstallLoader" Content="{x:Static l:StaticText.ReinstallLoader}"
VerticalAlignment="Bottom"
HorizontalAlignment="Right"
Margin="0,0,263,25"
Foreground="White"
Background="#7FABEFF9"
FontFamily="Microsoft YaHei UI"
FontSize="17"
BorderThickness="1"
Padding="5"
BorderBrush="#FFC9C9C9"
Style="{StaticResource BigContentButton}" FontWeight="Bold" Click="reinstallLoader_Click"
/>

</Grid>
</Page>
17 changes: 17 additions & 0 deletions application/GW2 Addon Manager/UI/OpeningPage/OpeningView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,28 @@ private void update_button_clicked(object sender, RoutedEventArgs e)
selectedAddons.Add(addon);
}

Application.Current.Properties["ForceLoader"] = false;
Application.Current.Properties["Selected"] = selectedAddons;

this.NavigationService.Navigate(new Uri("UI/UpdatingPage/UpdatingView.xaml", UriKind.Relative));
}

private void reinstallLoader_Click(object sender, RoutedEventArgs e)
{
//If bin folder doesn't exist then LoaderSetup intialization will fail.
if (_configurationManager.UserConfig.BinFolder == null)
{
MessageBox.Show("Unable to locate Guild Wars 2 /bin/ or /bin64/ folder." + Environment.NewLine + "Please verify Game Path is correct.",
"Unable to Update", MessageBoxButton.OK, MessageBoxImage.Warning);
return;
}

Application.Current.Properties["ForceLoader"] = true;
Application.Current.Properties["Selected"] = new List<AddonInfoFromYaml>();

this.NavigationService.Navigate(new Uri("UI/UpdatingPage/UpdatingView.xaml", UriKind.Relative));
}

/***** Hyperlink Handler *****/
private void Hyperlink_RequestNavigate(object sender, System.Windows.Navigation.RequestNavigateEventArgs e)
{
Expand Down
11 changes: 10 additions & 1 deletion application/Localization/StaticText.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions application/Localization/StaticText.resx
Original file line number Diff line number Diff line change
Expand Up @@ -216,4 +216,7 @@
<data name="SelectAnAddonToSeeMoreInformationAboutIt" xml:space="preserve">
<value>Select an add-on to see more information about it.</value>
</data>
<data name="ReinstallLoader" xml:space="preserve">
<value>Reinstall Loader</value>
</data>
</root>

0 comments on commit 26577ee

Please sign in to comment.