Skip to content
This repository has been archived by the owner on Mar 31, 2021. It is now read-only.

Commit

Permalink
Merge pull request #79 from Foxlider/feature/Update-1.5
Browse files Browse the repository at this point in the history
Update 1.5d
  • Loading branch information
Foxlider authored Jan 28, 2020
2 parents f2a8e1e + ae5e53c commit 6fb7bad
Show file tree
Hide file tree
Showing 21 changed files with 332 additions and 250 deletions.
38 changes: 9 additions & 29 deletions FASTER/About.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Controls;
using FASTER.Models;
using Microsoft.AppCenter.Analytics;

namespace FASTER
Expand All @@ -23,54 +24,33 @@ public About()
private void IDiscordButton_Click(object sender, RoutedEventArgs e)
{
Analytics.TrackEvent("About - Clicked Discord", new Dictionary<string, string> {
{ "Name", MainWindow.Instance.ISteamUserBox.Text }
{ "Name", Properties.Settings.Default.steamUserName }
});
OpenBrowser("https://discord.gg/uPjgqHU");
Functions.OpenBrowser("https://discord.gg/uPjgqHU");
}

private void IGitHubButton_Click(object sender, RoutedEventArgs e)
{
Analytics.TrackEvent("About - Clicked Git", new Dictionary<string, string> {
{ "Name", MainWindow.Instance.ISteamUserBox.Text }
{ "Name", Properties.Settings.Default.steamUserName }
});
OpenBrowser("https://github.com/Foxlider/Fox-s-Arma-Server-Tool-Extended-Rewrite");
Functions.OpenBrowser("https://github.com/Foxlider/Fox-s-Arma-Server-Tool-Extended-Rewrite");
}

private void IForumsButton_Click(object sender, RoutedEventArgs e)
{
Analytics.TrackEvent("About - Clicked Forums", new Dictionary<string, string> {
{ "Name", MainWindow.Instance.ISteamUserBox.Text }
{ "Name", Properties.Settings.Default.steamUserName }
});
OpenBrowser("https://forums.bohemia.net/forums/topic/224359-foxs-arma-server-tool-extended-rewrite-faster/");
Functions.OpenBrowser("https://forums.bohemia.net/forums/topic/224359-foxs-arma-server-tool-extended-rewrite-faster/");
}

private void IDonateButton_Click(object sender, RoutedEventArgs e)
{
Analytics.TrackEvent("About - Clicked Donate", new Dictionary<string, string> {
{ "Name", MainWindow.Instance.ISteamUserBox.Text }
{ "Name", Properties.Settings.Default.steamUserName }
});
OpenBrowser("https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=49H6MZNFUJYWA&source=url");
}

private void OpenBrowser(string url)
{
try
{ Process.Start(url); }
catch
{
// hack because of this: https://github.com/dotnet/corefx/issues/10361
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
url = url.Replace("&", "^&");
Process.Start(new ProcessStartInfo("cmd", $"/c start {url}") { CreateNoWindow = true });
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{ Process.Start("xdg-open", url); }
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{ Process.Start("open", url); }
else
{ throw; }
}
Functions.OpenBrowser("https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=49H6MZNFUJYWA&source=url");
}

private void About_Loaded(object sender, RoutedEventArgs e)
Expand Down
3 changes: 3 additions & 0 deletions FASTER/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
<setting name="checkForModUpdates" serializeAs="String">
<value>True</value>
</setting>
<setting name="SteamAPIKey" serializeAs="String">
<value />
</setting>
</FASTER.Properties.Settings>
</userSettings>
</configuration>
8 changes: 5 additions & 3 deletions FASTER/FASTER.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<PublishSingleFile>true</PublishSingleFile>
<RuntimeIdentifier>win-x86</RuntimeIdentifier>
<UseWPF>true</UseWPF>
<Version>1.5.3</Version>
<Version>1.5.4</Version>
<Authors>Keelah Fox</Authors>
<Company>FoxliCorp.</Company>
<Description>Fox's Arma Server Tool Extended Rewrite</Description>
Expand All @@ -17,6 +17,9 @@
<StartupObject>FASTER.App</StartupObject>
<ApplicationManifest>Properties\FASTER.manifest</ApplicationManifest>
<LangVersion>8.0</LangVersion>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>FASTERKey.snk</AssemblyOriginatorKeyFile>
<DelaySign>false</DelaySign>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
Expand All @@ -41,13 +44,12 @@
<PackageReference Include="Autoupdater.NET.Official" Version="1.5.8" />
<PackageReference Include="LiveCharts.Wpf" Version="0.9.7" />
<PackageReference Include="MahApps.Metro" Version="2.0.0-alpha0660" />
<PackageReference Include="MahApps.Metro.IconPacks" Version="3.1.0" />
<PackageReference Include="MahApps.Metro.IconPacks" Version="3.2.0" />
<PackageReference Include="MahApps.Metro.SimpleChildWindow" Version="2.0.0-alpha0032" />
<PackageReference Include="Microsoft-WindowsAPICodePack-Shell" Version="1.1.3.3" />
<PackageReference Include="Microsoft.AppCenter.Analytics" Version="2.6.4" />
<PackageReference Include="Microsoft.AppCenter.Crashes" Version="2.6.4" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="SQLitePCLRaw.lib.e_sqlite3.v110_xp" Version="1.1.14" />
<PackageReference Include="System.Management" Version="4.7.0" />
</ItemGroup>

Expand Down
Binary file added FASTER/FASTERKey.snk
Binary file not shown.
60 changes: 30 additions & 30 deletions FASTER/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ public partial class MainWindow

public MainWindow()
{
Properties.Options.Default.Reload();
Properties.Settings.Default.Reload();
InitializeComponent();
WindowStartupLocation = WindowStartupLocation.CenterScreen;

Properties.Options.Default.PropertyChanged += Default_PropertyChanged;
Properties.Settings.Default.PropertyChanged += Default_PropertyChanged;

IMessageDialogClose.Click += IMessageDialogClose_Click;
ISteamUserBox.LostFocus += ISteamSettings_Changed;
Expand All @@ -62,7 +62,7 @@ public MainWindow()

try
{
if (Properties.Options.Default.checkForAppUpdates)
if (Properties.Settings.Default.checkForAppUpdates)
{
AutoUpdater.ReportErrors = true;
AutoUpdater.LetUserSelectRemindLater = false;
Expand All @@ -82,7 +82,7 @@ public MainWindow()

private void Default_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
Properties.Options.Default.Save();
Properties.Settings.Default.Save();
}

/// <summary>
Expand Down Expand Up @@ -123,7 +123,7 @@ private void MetroWindow_Loaded(object sender, EventArgs e)

private void MetroWindow_Closing(object sender, EventArgs e)
{
Properties.Options.Default.Save();
Properties.Settings.Default.Save();
Application.Current.Shutdown();
}
#endregion
Expand All @@ -133,7 +133,7 @@ private void DirButton_Click(object sender, RoutedEventArgs e)
{
if (Equals(sender, ISteamDirButton))
{
string path = SelectFolder(Properties.Options.Default.steamCMDPath);
string path = SelectFolder(Properties.Settings.Default.steamCMDPath);
if (path != null)
{
ISteamDirBox.Text = path;
Expand All @@ -142,7 +142,7 @@ private void DirButton_Click(object sender, RoutedEventArgs e)
}
else if (Equals(sender, IServerDirButton))
{
string path = SelectFolder(Properties.Options.Default.serverPath);
string path = SelectFolder(Properties.Settings.Default.serverPath);
if (path != null)
{
IServerDirBox.Text = path;
Expand Down Expand Up @@ -290,7 +290,7 @@ private void MenuItemClone_Click(object sender, RoutedEventArgs e)
{
if (IServerProfilesMenu.SelectedIndex == -1)
{ return; }
var temp = Properties.Options.Default.Servers.ServerProfiles.FirstOrDefault(s => s.SafeName == ((ListBoxItem) IServerProfilesMenu.SelectedItem).Name);
var temp = Properties.Settings.Default.Servers.ServerProfiles.FirstOrDefault(s => s.SafeName == ((ListBoxItem) IServerProfilesMenu.SelectedItem).Name);
if (temp == null)
{
Instance.IMessageDialog.IsOpen = true;
Expand Down Expand Up @@ -374,7 +374,7 @@ private void IToolsDialog_MouseLeftButtonUp(object sender, RoutedEventArgs e)
}

private void IServerDirBox_TextChanged(object sender, RoutedEventArgs e)
{ Properties.Options.Default.serverPath = IServerDirBox.Text; }
{ Properties.Settings.Default.serverPath = IServerDirBox.Text; }

private void ISubmitCode_Click(object sender, RoutedEventArgs e)
{
Expand Down Expand Up @@ -418,9 +418,9 @@ private bool CheckAdmin()

public void LoadServerProfiles()
{
if (Properties.Options.Default.Servers != null)
if (Properties.Settings.Default.Servers != null)
{
var currentProfiles = Properties.Options.Default.Servers;
var currentProfiles = Properties.Settings.Default.Servers;
Dispatcher?.Invoke(() =>
{
IServerProfilesMenu.Items.Clear();
Expand Down Expand Up @@ -476,7 +476,7 @@ public bool ReadyToUpdate()
&& !string.IsNullOrEmpty(ISteamUserBox.Text)
&& !string.IsNullOrEmpty(ISteamPassBox.Password)
&& !string.IsNullOrEmpty(IServerDirBox.Text)
&& File.Exists(Properties.Options.Default.steamCMDPath + "\\steamcmd.exe");
&& File.Exists(Properties.Settings.Default.steamCMDPath + "\\steamcmd.exe");
}

// Opens Folder select dialog and returns selected path
Expand Down Expand Up @@ -505,20 +505,20 @@ public string SelectFolder(string default_folder = "")

private void UpdateSteamUpdaterSettings()
{
Properties.Options.Default.steamCMDPath = ISteamDirBox.Text;
Properties.Options.Default.steamUserName = ISteamUserBox.Text;
Properties.Options.Default.steamPassword = Encryption.Instance.EncryptData(ISteamPassBox.Password);
Properties.Options.Default.serverPath = IServerDirBox.Text;
Properties.Options.Default.serverBranch = IServerBranch.Text;
Properties.Settings.Default.steamCMDPath = ISteamDirBox.Text;
Properties.Settings.Default.steamUserName = ISteamUserBox.Text;
Properties.Settings.Default.steamPassword = Encryption.Instance.EncryptData(ISteamPassBox.Password);
Properties.Settings.Default.serverPath = IServerDirBox.Text;
Properties.Settings.Default.serverBranch = IServerBranch.Text;
}

private void LoadSteamUpdaterSettings()
{
ISteamDirBox.Text = Properties.Options.Default.steamCMDPath;
ISteamUserBox.Text = Properties.Options.Default.steamUserName;
ISteamPassBox.Password = Encryption.Instance.DecryptData(Properties.Options.Default.steamPassword);
IServerDirBox.Text = Properties.Options.Default.serverPath;
IServerBranch.Text = Properties.Options.Default.serverBranch;
ISteamDirBox.Text = Properties.Settings.Default.steamCMDPath;
ISteamUserBox.Text = Properties.Settings.Default.steamUserName;
ISteamPassBox.Password = Encryption.Instance.DecryptData(Properties.Settings.Default.steamPassword);
IServerDirBox.Text = Properties.Settings.Default.serverPath;
IServerBranch.Text = Properties.Settings.Default.serverBranch;
}

private void InstallSteam()
Expand All @@ -528,7 +528,7 @@ private void InstallSteam()
Instance.IMessageDialog.IsOpen = true;
Instance.IMessageDialogText.Text = "Please make sure you have set a valid path for SteamCMD.";
}
else if (!File.Exists(Properties.Options.Default.steamCMDPath + "\\steamcmd.exe"))
else if (!File.Exists(Properties.Settings.Default.steamCMDPath + "\\steamcmd.exe"))
{
IMessageDialog.IsOpen = true;
IMessageDialogText.Text = "Steam CMD will now download and start the install process. If prompted please enter your Steam Guard " +
Expand All @@ -537,8 +537,8 @@ private void InstallSteam()
ISteamOutputBox.AppendText("Installing SteamCMD");
ISteamOutputBox.AppendText("\nFile Downloading...");
const string url = "https://steamcdn-a.akamaihd.net/client/installer/steamcmd.zip";
string fileName = Properties.Options.Default.steamCMDPath + "\\steamcmd.zip";
if (!Directory.Exists(Properties.Options.Default.steamCMDPath)) Directory.CreateDirectory(Properties.Options.Default.steamCMDPath);
string fileName = Properties.Settings.Default.steamCMDPath + "\\steamcmd.zip";
if (!Directory.Exists(Properties.Settings.Default.steamCMDPath)) Directory.CreateDirectory(Properties.Settings.Default.steamCMDPath);
using WebClient client = new WebClient();
client.DownloadFileCompleted += SteamDownloadCompleted;
client.DownloadFileAsync(new Uri(url), fileName);
Expand All @@ -554,7 +554,7 @@ private void SteamDownloadCompleted(object sender, AsyncCompletedEventArgs e)
{
ISteamOutputBox.AppendText(Environment.NewLine + "Download Finished");

var steamPath = Properties.Options.Default.steamCMDPath;
var steamPath = Properties.Settings.Default.steamCMDPath;
string zip = steamPath + "\\steamcmd.zip";

ISteamOutputBox.AppendText("\nUnzipping...");
Expand Down Expand Up @@ -783,15 +783,15 @@ private static void CheckModUpdatesComplete(IReadOnlyCollection<string> modIds)
{
foreach (var modID in modIds)
{
var modToUpdate = Properties.Options.Default.steamMods.SteamMods.Find(m => m.WorkshopId.ToString() == modID);
var modToUpdate = Properties.Settings.Default.steamMods.SteamMods.Find(m => m.WorkshopId.ToString() == modID);
var steamCmdOutputText = Functions.StringFromRichTextBox(Instance.ISteamOutputBox);

if (steamCmdOutputText.Contains("ERROR! Timeout downloading"))
{ modToUpdate.Status = "Download Not Complete"; }
else
{
string modTempPath = Properties.Options.Default.steamCMDPath + @"\steamapps\workshop\downloads\107410\" + modID;
string modPath = Properties.Options.Default.steamCMDPath + @"\steamapps\workshop\content\107410\" + modID;
string modTempPath = Properties.Settings.Default.steamCMDPath + @"\steamapps\workshop\downloads\107410\" + modID;
string modPath = Properties.Settings.Default.steamCMDPath + @"\steamapps\workshop\content\107410\" + modID;

if (Directory.Exists(modTempPath))
modToUpdate.Status = "Download Not Complete";
Expand All @@ -805,7 +805,7 @@ private static void CheckModUpdatesComplete(IReadOnlyCollection<string> modIds)
}
}
}
Properties.Options.Default.Save();
Properties.Settings.Default.Save();
}
}

Expand Down
32 changes: 28 additions & 4 deletions FASTER/Models/Functions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Diagnostics;
using System.IO;
using System.Runtime.InteropServices;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using System.Text.RegularExpressions;
Expand All @@ -16,11 +18,11 @@ internal static class Functions
{
public static void CheckSettings()
{
if (!Directory.Exists(Properties.Options.Default.serverPath))
Properties.Options.Default.serverPath = string.Empty;
if (!Directory.Exists(Properties.Settings.Default.serverPath))
Properties.Settings.Default.serverPath = string.Empty;

if (!Directory.Exists(Properties.Options.Default.steamCMDPath))
Properties.Options.Default.steamCMDPath = string.Empty;
if (!Directory.Exists(Properties.Settings.Default.steamCMDPath))
Properties.Settings.Default.steamCMDPath = string.Empty;
}

public static T CloneObjectSerializable < T > (this T obj) where T: class {
Expand Down Expand Up @@ -119,5 +121,27 @@ public static string SafeName(string input, bool ignoreWhiteSpace = false, strin
input = input.Replace(replacement + replacement, replacement);
return input;
}

//Opens a browser url
public static void OpenBrowser(string url)
{
try
{ Process.Start(url); }
catch
{
// hack because of this: https://github.com/dotnet/corefx/issues/10361
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
url = url.Replace("&", "^&");
Process.Start(new ProcessStartInfo("cmd", $"/c start {url}") { CreateNoWindow = true });
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{ Process.Start("xdg-open", url); }
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{ Process.Start("open", url); }
else
{ throw; }
}
}
}
}
12 changes: 7 additions & 5 deletions FASTER/Models/LocalMod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Microsoft.AppCenter.Crashes;

// ReSharper disable UnusedAutoPropertyAccessor.Global

namespace FASTER.Models
Expand Down Expand Up @@ -34,13 +36,13 @@ public static List<LocalMod> GetLocalMods(bool serverPathOnly = false)

List<string> foldersToSearch = new List<string>();

if (serverPathOnly && !string.IsNullOrEmpty(Properties.Options.Default.serverPath))
if (serverPathOnly && !string.IsNullOrEmpty(Properties.Settings.Default.serverPath))
{
foldersToSearch.Add(Properties.Options.Default.serverPath);
foldersToSearch.Add(Properties.Settings.Default.serverPath);
}

if (!serverPathOnly && Properties.Options.Default.localModFolders != null)
{ foldersToSearch.AddRange(Properties.Options.Default.localModFolders.Where(folder => folder != null && folder != Properties.Options.Default.serverPath)); }
if (!serverPathOnly && Properties.Settings.Default.localModFolders != null)
{ foldersToSearch.AddRange(Properties.Settings.Default.localModFolders.Where(folder => folder != null && folder != Properties.Settings.Default.serverPath)); }

if (foldersToSearch.Count <= 0) return localMods;
foreach (var localModFolder in foldersToSearch)
Expand All @@ -55,7 +57,7 @@ public static List<LocalMod> GetLocalMods(bool serverPathOnly = false)
let website = "Unknown"
select new LocalMod(name, modFolder, author, website));
}
catch (Exception) { /* ignored */ }
catch (Exception e) { Crashes.TrackError(e, new Dictionary<string, string> { { "Name", Properties.Settings.Default.steamUserName } }); }
}

return localMods;
Expand Down
Loading

0 comments on commit 6fb7bad

Please sign in to comment.