Skip to content

Commit

Permalink
fix to UI lag
Browse files Browse the repository at this point in the history
arcDPS update check is quite slow, may move to an alternate way of checking for updates
  • Loading branch information
fmmmlee committed Aug 14, 2019
1 parent fa966a0 commit d6318a4
Show file tree
Hide file tree
Showing 7 changed files with 123 additions and 14 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# GW2-UOAOU [![Current Version](https://img.shields.io/badge/version-0.2.1-blue)](https://github.com/fmmmlee/GW2-Addon-Updater/releases)
# GW2-UOAOU [![Current Version](https://img.shields.io/badge/version-0.2.3-blue)](https://github.com/fmmmlee/GW2-Addon-Updater/releases)
##### Guild Wars 2 Unofficial Add-On Updater

A tool to update some Guild Wars 2 add-ons without having to manually go to each website, check version numbers, download and rename dlls, etc.
Expand Down
76 changes: 74 additions & 2 deletions application/source/Add-On_Selector.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,43 @@
</Setter.Value>
</Setter>
</Style>
<Style x:Key="BigContentButtons" TargetType="{x:Type Button}">
<Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisual}"/>
<Setter Property="Background" Value="{StaticResource Button.Static.Background}"/>
<Setter Property="BorderBrush" Value="{StaticResource Button.Static.Border}"/>
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="Padding" Value="1"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Border x:Name="border" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" SnapsToDevicePixels="true">
<ContentPresenter x:Name="contentPresenter" Focusable="False" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsDefaulted" Value="true">
<Setter Property="BorderBrush" TargetName="border" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/>
</Trigger>
<Trigger Property="IsMouseOver" Value="true">
<Setter Property="Background" TargetName="border" Value="{StaticResource Button.MouseOver.Background}"/>
<Setter Property="BorderBrush" TargetName="border" Value="{StaticResource Button.MouseOver.Border}"/>
</Trigger>
<Trigger Property="IsPressed" Value="true">
<Setter Property="Background" TargetName="border" Value="{StaticResource Button.Pressed.Background}"/>
<Setter Property="BorderBrush" TargetName="border" Value="{StaticResource Button.Pressed.Border}"/>
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Background" TargetName="border" Value="{StaticResource Button.Disabled.Background}"/>
<Setter Property="BorderBrush" TargetName="border" Value="{StaticResource Button.Disabled.Border}"/>
<Setter Property="TextElement.Foreground" TargetName="contentPresenter" Value="{StaticResource Button.Disabled.Foreground}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Page.Resources>

<Grid Margin="0,0,0,0">
Expand All @@ -79,13 +116,47 @@
<Button x:Name="close" Content="x" Click="close_clicked" Width="20" Height = "25" DockPanel.Dock="Right" Background="Transparent" Foreground="Black" FontSize="16" Margin="0,0,60,0" BorderThickness="0" Style="{DynamicResource Xbutton}" FontFamily="Leelawadee UI"/>
<Button x:Name="minimize" Content="-" Click="minimize_clicked" Width="20" Height = "25" DockPanel.Dock="Right" HorizontalAlignment="Right" Background="Transparent" Foreground="Black" FontSize="16" BorderThickness="0" FontFamily="Leelawadee UI"/>
<Label PreviewMouseDown="TitleBar_MouseHeld"/>
<!--<Button x:Name="settings" Content="Settings" HorizontalAlignment="Left" Height="20" Background="Transparent" BorderThickness="0" Margin="35,0,0,0" FontFamily="Microsoft YaHei Light"/>-->
</DockPanel>

<Label Grid.Row = "1" FontWeight="Bold" FontSize="60" Foreground="DimGray" Margin="30,0,0,0" FontFamily="Microsoft JhengHei UI Light" Width="Auto" HorizontalAlignment="Left">
GW2-UOAOU
</Label>
<TextBlock Grid.Row="1" Margin="40,75,0,0" FontSize ="16" Foreground="DimGray" FontFamily="Microsoft YaHei UI Light"> Guild Wars 2 - Unofficial Add-On Updater</TextBlock>

<TextBlock Grid.Row="2" HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="300,0,0,37" FontFamily="Microsoft YaHei UI Light" FontSize="14">
Game Path
</TextBlock>
<Button x:Name="set_gamepath"
Click="Set_gamepath_Click"
Grid.Row="2"
Margin="705,0,0,9"
HorizontalAlignment="Left"
VerticalAlignment="Bottom"
Content="SET"
Background="Red"
Foreground="White"
FontSize="14"
FontFamily="Footlight MT Light"
Height="25"
Width="40"
BorderThickness="1"
BorderBrush="#ff8787"
Style="{DynamicResource BigContentButtons}"
/>
<TextBox x:Name="game_path"
Grid.Row="2"
Margin="300,0,0,10"
HorizontalAlignment="Left"
VerticalAlignment="Bottom"
Width="400"
Height="23"
Background="LightGray"
BorderThickness="0"
FontSize="16"
FontFamily="Microsoft JhengHei Light"
>

</TextBox>
<Border Grid.Row="2" Width="200" Height="300" HorizontalAlignment="Left" Margin="40,20,0,0" BorderThickness="1" BorderBrush="DimGray" Background="WhiteSmoke">
<StackPanel Width="200" Height="275" HorizontalAlignment="Left">

Expand All @@ -110,7 +181,8 @@
FontFamily="Footlight MT Light"
FontSize="16"
BorderThickness="1"
BorderBrush="#ff8787"
BorderBrush="#ff8787" Style="{DynamicResource BigContentButtons}"

>
<Button.Background>
<LinearGradientBrush StartPoint="0,0" EndPoint="1,1">
Expand Down
26 changes: 23 additions & 3 deletions application/source/Add-On_Selector.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
Expand All @@ -21,6 +23,8 @@ namespace GW2_Addon_Updater
/// </summary>
public partial class Add_On_Selector : Page
{
static string working_directory = Directory.GetCurrentDirectory();
static string config_file_path = working_directory + "\\config.ini";

string no_d912pxy_and_gw2hook_msg = "d912pxy and Gw2 Hook are currently not compatible. " +
"Using this configuration will most likely result in the game crashing on launch. Are you sure you want to continue?";
Expand All @@ -30,10 +34,9 @@ public partial class Add_On_Selector : Page
public Add_On_Selector()
{
InitializeComponent();
game_path.Text = get_default_gamepath();
}



private void Box_Checked(object sender, RoutedEventArgs e)
{

Expand Down Expand Up @@ -118,5 +121,22 @@ private void update_button_clicked(object sender, RoutedEventArgs e)

this.NavigationService.Navigate(new Uri("Updating.xaml", UriKind.Relative));
}

private void Set_gamepath_Click(object sender, RoutedEventArgs e)
{
Application.Current.Properties["game_path"] = game_path.Text.Replace("\\", "\\\\");
string config_file = File.ReadAllText(config_file_path);
dynamic config_obj = JsonConvert.DeserializeObject(config_file);
config_obj.game_path = Application.Current.Properties["game_path"].ToString().Replace("\\\\","\\");
string edited_config_file = JsonConvert.SerializeObject(config_obj);
File.WriteAllText(config_file_path, edited_config_file);
}

private string get_default_gamepath()
{
string config_file = File.ReadAllText(config_file_path);
dynamic config_obj = JsonConvert.DeserializeObject(config_file);
return config_obj.game_path;
}
}
}
4 changes: 3 additions & 1 deletion application/source/Updating.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
<SolidColorBrush x:Key="Button.Disabled.Background" Color="#FFF4F4F4"/>
<SolidColorBrush x:Key="Button.Disabled.Border" Color="#FFADB2B5"/>
<SolidColorBrush x:Key="Button.Disabled.Foreground" Color="#FF838383"/>
<SolidColorBrush x:Key="Button.MouseOver.Background2" Color="LightGray"/>
<Style x:Key="Xbutton" TargetType="{x:Type Button}">
<Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisual}"/>
<Setter Property="Background" Value="{StaticResource Button.Static.Background}"/>
Expand Down Expand Up @@ -122,7 +123,8 @@
BorderThickness="1"
BorderBrush="#ff8787"
Click="finish_button_clicked"
IsEnabled="false">
IsEnabled="{Binding closeButtonEnabled}"
>
<Button.Background>
<LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">

Expand Down
15 changes: 10 additions & 5 deletions application/source/Updating.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using System.Windows.Input;
using System.Diagnostics;
using System.Threading.Tasks;
using System.Windows.Threading;

namespace GW2_Addon_Updater
{
Expand All @@ -19,10 +20,10 @@ namespace GW2_Addon_Updater
/// </summary>
public partial class Updating : Page
{


static string working_directory = Directory.GetCurrentDirectory();
static string config_file_path = working_directory + "\\config.ini";

static string working_directory;
static string config_file_path;

string game_path;

Expand All @@ -36,10 +37,13 @@ public partial class Updating : Page
public Updating()
{
InitializeComponent();
working_directory = Directory.GetCurrentDirectory();
config_file_path = working_directory + "\\config.ini";
view = new UpdatingView { label = "Updating Add-Ons" };
DataContext = view;
view.closeButtonEnabled = false;
getPreferences();
Update();
Task.Run(() => Update()); //running the update method in the background so UI updates immediately
}

public void getPreferences()
Expand Down Expand Up @@ -93,6 +97,7 @@ public async void Update()
if ((bool)Application.Current.Properties["ArcDPS"])
{
arcdps arc = new arcdps(arc_name, arc_templates_name, view);

await arc.update();
await arc.update_templates();
Update();
Expand Down Expand Up @@ -121,7 +126,7 @@ public async void Update()
view.label = "Complete";
view.showProgress = 100;
//enable "finish" button
closeProgram.IsEnabled = true;
view.closeButtonEnabled = true;
}
}

Expand Down
4 changes: 2 additions & 2 deletions application/source/arcdps.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Threading;

namespace GW2_Addon_Updater
{
Expand Down Expand Up @@ -39,9 +40,8 @@ public arcdps(string arc_name, string arc_templates_name, UpdatingView view)
/***************************** ArcDPS *****************************/
public async Task update()
{

/* display message over progress bar */
theView.label = "Updating ArcDPS";
theView.label = "Updating ArcDPS";

/* download md5 file from arc website */
var client = new WebClient();
Expand Down
10 changes: 10 additions & 0 deletions application/source/updatingView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@ protected void propertyChanged(string propertyName)

string message;
int progress;
bool _closeButtonEnabled;

public bool closeButtonEnabled
{
get {return _closeButtonEnabled;}
set {
_closeButtonEnabled = value;
propertyChanged("closeButtonEnabled");
}
}

public string label
{
Expand Down

0 comments on commit d6318a4

Please sign in to comment.