implement data folder for log.config, use code cleaner

pull/30/head
Miepee 5 years ago
parent 664e39f18b
commit 0446689e77

@ -1,7 +1,7 @@
using Eto.Forms; using Eto.Forms;
using log4net; using log4net;
using System;
using log4net.Config; using log4net.Config;
using System;
using System.IO; using System.IO;
using System.Reflection; using System.Reflection;
@ -22,19 +22,18 @@ namespace AM2RLauncher.Gtk
[STAThread] [STAThread]
public static void Main(string[] args) public static void Main(string[] args)
{ {
string launcherDataPath = GenerateCurrentPath();
string localAM2RPath = Environment.GetEnvironmentVariable("HOME") + "/.local/share/AM2RLauncher"; // Make sure first, ~/.local/share/AM2RLauncher exists
if (!Directory.Exists(launcherDataPath))
// Make sure first, ~/.local/share exists Directory.CreateDirectory(launcherDataPath);
if (!Directory.Exists(localAM2RPath))
Directory.CreateDirectory(localAM2RPath);
// Now, see if log4netConfig exists, if not write it again. // Now, see if log4netConfig exists, if not write it again.
if (!File.Exists(localAM2RPath + "/log4net.config")) if (!File.Exists(launcherDataPath + "/log4net.config"))
File.WriteAllText(localAM2RPath + "/log4net.config", Properties.Resources.log4netContents); File.WriteAllText(launcherDataPath + "/log4net.config", Properties.Resources.log4netContents.Replace("${DATADIR}", launcherDataPath));
// Configure logger // Configure logger
XmlConfigurator.Configure(new FileInfo(localAM2RPath + "/log4net.config")); XmlConfigurator.Configure(new FileInfo(launcherDataPath + "/log4net.config"));
try try
{ {
@ -43,7 +42,7 @@ namespace AM2RLauncher.Gtk
GTKLauncher.UnhandledException += GTKLauncher_UnhandledException; GTKLauncher.UnhandledException += GTKLauncher_UnhandledException;
GTKLauncher.Run(new MainForm()); GTKLauncher.Run(new MainForm());
} }
catch(Exception e) catch (Exception e)
{ {
log.Error("An unhandled exception has occurred: \n*****Stack Trace*****\n\n" + e.StackTrace.ToString()); log.Error("An unhandled exception has occurred: \n*****Stack Trace*****\n\n" + e.StackTrace.ToString());
Console.WriteLine(Language.Text.UnhandledException + "\n" + e.Message + "\n*****Stack Trace*****\n\n" + e.StackTrace.ToString()); Console.WriteLine(Language.Text.UnhandledException + "\n" + e.Message + "\n*****Stack Trace*****\n\n" + e.StackTrace.ToString());
@ -58,5 +57,45 @@ namespace AM2RLauncher.Gtk
log.Error("An unhandled exception has occurred: \n*****Stack Trace*****\n\n" + e.ExceptionObject.ToString()); log.Error("An unhandled exception has occurred: \n*****Stack Trace*****\n\n" + e.ExceptionObject.ToString());
MessageBox.Show(Language.Text.UnhandledException + "\n*****Stack Trace*****\n\n" + e.ExceptionObject.ToString(), "GTK", MessageBoxType.Error); MessageBox.Show(Language.Text.UnhandledException + "\n*****Stack Trace*****\n\n" + e.ExceptionObject.ToString(), "GTK", MessageBoxType.Error);
} }
// This is a duplicate of CrossPlatformOperations.GenerateCurrentPath, because trying to invoke that would cause a crash due to currentPlatform not being initialized.
private static string GenerateCurrentPath()
{
string NIXHOME = Environment.GetEnvironmentVariable("HOME");
// First, we check if the user has a custom AM2RLAUNCHERDATA env var
string am2rLauncherDataEnvVar = Environment.GetEnvironmentVariable("AM2RLAUNCHERDATA");
if (!String.IsNullOrWhiteSpace(am2rLauncherDataEnvVar))
{
try
{
// This will create the directories recursively if they don't exist
Directory.CreateDirectory(am2rLauncherDataEnvVar);
// Our env var is now set and directories exist
return am2rLauncherDataEnvVar;
}
catch { }
}
// First check if XDG_DATA_HOME is set, if not we'll use ~/.local/share
string xdgDataHome = Environment.GetEnvironmentVariable("XDG_DATA_HOME");
if (string.IsNullOrWhiteSpace(xdgDataHome))
xdgDataHome = NIXHOME + "/.local/share";
// Add AM2RLauncher to the end of the dataPath
xdgDataHome += "/AM2RLauncher";
try
{
// This will create the directories recursively if they don't exist
Directory.CreateDirectory(xdgDataHome);
// Our env var is now set and directories exist
return xdgDataHome;
}
catch { }
return Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
}
} }
} }

@ -19,7 +19,7 @@ namespace AM2RLauncher.Gtk.Properties {
// -Klasse über ein Tool wie ResGen oder Visual Studio automatisch generiert. // -Klasse über ein Tool wie ResGen oder Visual Studio automatisch generiert.
// Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen // Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen
// mit der /str-Option erneut aus, oder Sie erstellen Ihr VS-Projekt neu. // mit der /str-Option erneut aus, oder Sie erstellen Ihr VS-Projekt neu.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources { internal class Resources {
@ -67,14 +67,14 @@ namespace AM2RLauncher.Gtk.Properties {
/// <appender-ref ref="file" /> /// <appender-ref ref="file" />
/// </root> /// </root>
/// <appender name="file" type="log4net.Appender.RollingFileAppender"> /// <appender name="file" type="log4net.Appender.RollingFileAppender">
/// <file value="${HOME}/.local/share/AM2RLauncher/Logs/AM2RLauncher.log" /> /// <file value="${DATADIR}/Logs/AM2RLauncher.log" />
/// <appendToFile value="true" /> /// <appendToFile value="true" />
/// <rollingStyle value="Once" /> /// <rollingStyle value="Once" />
/// <maxSizeRollBackups value="7" /> /// <maxSizeRollBackups value="7" />
/// <maximumFileSize value="3MB" /> /// <maximumFileSize value="3MB" />
/// <staticLogFileName value="true" /> /// <staticLogFileName value="true" />
/// <layout type="log4net.Layout.PatternLayout"> /// <layout type="log4net.Layout.PatternLayout">
/// <conversionPattern value="%date [Rest der Zeichenfolge wurde abgeschnitten]"; ähnelt. /// <conversionPattern value="%date [%thread] %level %logg [Rest der Zeichenfolge wurde abgeschnitten]"; ähnelt.
/// </summary> /// </summary>
internal static string log4netContents { internal static string log4netContents {
get { get {

@ -124,7 +124,7 @@
&lt;appender-ref ref="file" /&gt; &lt;appender-ref ref="file" /&gt;
&lt;/root&gt; &lt;/root&gt;
&lt;appender name="file" type="log4net.Appender.RollingFileAppender"&gt; &lt;appender name="file" type="log4net.Appender.RollingFileAppender"&gt;
&lt;file value="${HOME}/.local/share/AM2RLauncher/Logs/AM2RLauncher.log" /&gt; &lt;file value="${DATADIR}/Logs/AM2RLauncher.log" /&gt;
&lt;appendToFile value="true" /&gt; &lt;appendToFile value="true" /&gt;
&lt;rollingStyle value="Once" /&gt; &lt;rollingStyle value="Once" /&gt;
&lt;maxSizeRollBackups value="7" /&gt; &lt;maxSizeRollBackups value="7" /&gt;

@ -1,14 +1,14 @@
using Eto.Forms; using Eto.Forms;
using System;
using log4net; using log4net;
using log4net.Config; using log4net.Config;
using System;
using System.IO; using System.IO;
using System.Reflection; using System.Reflection;
namespace AM2RLauncher.Wpf namespace AM2RLauncher.Wpf
{ {
/// <summary> /// <summary>
/// The main class for the GTK project. /// The main class for the WinForms project.
/// </summary> /// </summary>
class MainClass class MainClass
{ {
@ -17,13 +17,13 @@ namespace AM2RLauncher.Wpf
/// </summary> /// </summary>
private static readonly ILog log = LogManager.GetLogger(typeof(MainForm)); private static readonly ILog log = LogManager.GetLogger(typeof(MainForm));
/// <summary> /// <summary>
/// The main method for the GTK project. /// The main method for the WinForms project.
/// </summary> /// </summary>
[STAThread] [STAThread]
public static void Main(string[] args) public static void Main(string[] args)
{ {
// Configure logger // Configure logger
XmlConfigurator.Configure(new FileInfo(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + "/log4net.config")); XmlConfigurator.Configure(new FileInfo(GenerateCurrentPath() + "/log4net.config"));
// Try catch in case it ever crashes before actually getting to the Eto application // Try catch in case it ever crashes before actually getting to the Eto application
try try
@ -33,7 +33,7 @@ namespace AM2RLauncher.Wpf
WinLauncher.UnhandledException += WinLauncher_UnhandledException; WinLauncher.UnhandledException += WinLauncher_UnhandledException;
WinLauncher.Run(new MainForm()); WinLauncher.Run(new MainForm());
} }
catch(Exception e) catch (Exception e)
{ {
log.Error("An unhandled exception has occurred: \n*****Stack Trace*****\n\n" + e.StackTrace.ToString()); log.Error("An unhandled exception has occurred: \n*****Stack Trace*****\n\n" + e.StackTrace.ToString());
System.Windows.Forms.MessageBox.Show(Language.Text.UnhandledException + "\n" + e.Message + "\n*****Stack Trace*****\n\n" + e.StackTrace.ToString(), "Microsoft .NET Framework", System.Windows.Forms.MessageBox.Show(Language.Text.UnhandledException + "\n" + e.Message + "\n*****Stack Trace*****\n\n" + e.StackTrace.ToString(), "Microsoft .NET Framework",
@ -47,7 +47,28 @@ namespace AM2RLauncher.Wpf
private static void WinLauncher_UnhandledException(object sender, Eto.UnhandledExceptionEventArgs e) private static void WinLauncher_UnhandledException(object sender, Eto.UnhandledExceptionEventArgs e)
{ {
log.Error("An unhandled exception has occurred: \n*****Stack Trace*****\n\n" + e.ExceptionObject.ToString()); log.Error("An unhandled exception has occurred: \n*****Stack Trace*****\n\n" + e.ExceptionObject.ToString());
MessageBox.Show(Language.Text.UnhandledException + "\n*****Stack Trace*****\n\n" +e.ExceptionObject.ToString(), "Microsoft .NET Framework", MessageBoxType.Error); MessageBox.Show(Language.Text.UnhandledException + "\n*****Stack Trace*****\n\n" + e.ExceptionObject.ToString(), "Microsoft .NET Framework", MessageBoxType.Error);
}
// This is a duplicate of CrossPlatformOperations.GenerateCurrentPath, because trying to invoke that would cause a crash due to currentPlatform not being initialized.
private static string GenerateCurrentPath()
{
// First, we check if the user has a custom AM2RLAUNCHERDATA env var
string am2rLauncherDataEnvVar = Environment.GetEnvironmentVariable("AM2RLAUNCHERDATA");
if (!String.IsNullOrWhiteSpace(am2rLauncherDataEnvVar))
{
try
{
// This will create the directories recursively if they don't exist
Directory.CreateDirectory(am2rLauncherDataEnvVar);
// Our env var is now set and directories exist
return am2rLauncherDataEnvVar;
}
catch { }
}
// Windows has the path where the exe is located as default
return Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
} }
} }
} }

@ -1,7 +1,7 @@
 
Microsoft Visual Studio Solution File, Format Version 12.00 Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16 # Visual Studio Version 17
VisualStudioVersion = 16.0.31005.135 VisualStudioVersion = 17.0.31912.275
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AM2RLauncher", "AM2RLauncher\AM2RLauncher.csproj", "{9B67055C-5AEF-4F83-AFE0-38E600183C9F}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AM2RLauncher", "AM2RLauncher\AM2RLauncher.csproj", "{9B67055C-5AEF-4F83-AFE0-38E600183C9F}"
EndProject EndProject

@ -2,7 +2,7 @@
<PropertyGroup> <PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework> <TargetFramework>netstandard2.0</TargetFramework>
<ApplicationIcon>icon64.ico</ApplicationIcon> <ApplicationIcon>Resources\LauncherIcon.ico</ApplicationIcon>
<Authors>Lojemiru, Miepee</Authors> <Authors>Lojemiru, Miepee</Authors>
<Company>AM2R-Community-Developers</Company> <Company>AM2R-Community-Developers</Company>
<Description>This is a Launcher for AM2R and its Community Updates.</Description> <Description>This is a Launcher for AM2R and its Community Updates.</Description>
@ -19,6 +19,10 @@
<DebugSymbols>false</DebugSymbols> <DebugSymbols>false</DebugSymbols>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<Content Include="Resources\LauncherIcon.ico" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Eto.Forms" Version="2.5.11" /> <PackageReference Include="Eto.Forms" Version="2.5.11" />
<PackageReference Include="LibGit2Sharp" Version="0.26.2" /> <PackageReference Include="LibGit2Sharp" Version="0.26.2" />
@ -75,4 +79,10 @@
</EmbeddedResource> </EmbeddedResource>
</ItemGroup> </ItemGroup>
<ItemGroup>
<None Update="../../LICENSE">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project> </Project>

@ -1,21 +1,19 @@
using Eto; using Eto;
using Eto.Forms; using log4net;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Configuration; using System.Configuration;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Text;
using System.Reflection; using System.Reflection;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using log4net;
namespace AM2RLauncher namespace AM2RLauncher
{ {
/// <summary> /// <summary>
/// Class that does Operations that work cross-platform. /// Class that does Operations that work cross-platform.
/// </summary> /// </summary>
class CrossPlatformOperations public class CrossPlatformOperations
{ {
/// <summary> /// <summary>
/// The logger for <see cref="MainForm"/>, used to write any caught exceptions. /// The logger for <see cref="MainForm"/>, used to write any caught exceptions.
@ -25,17 +23,27 @@ namespace AM2RLauncher
/// <summary> /// <summary>
/// Gets the current platform. /// Gets the current platform.
/// </summary> /// </summary>
readonly private static Platform currentPlatform = Platform.Instance; private static readonly Platform currentPlatform = Platform.Instance;
/// <summary> /// <summary>
/// Current Path where the Launcher is located. For more info, check <see cref="GenerateCurrentPath"/>. /// Current Path where the Launcher is located. For more info, check <see cref="GenerateCurrentPath"/>.
/// </summary> /// </summary>
static readonly public string CURRENTPATH = GenerateCurrentPath(); public static readonly string CURRENTPATH = GenerateCurrentPath();
/// <summary> /// <summary>
/// Name of the Launcher executable. /// Name of the Launcher executable.
/// </summary> /// </summary>
static readonly public string LAUNCHERNAME = AppDomain.CurrentDomain.FriendlyName; public static readonly string LAUNCHERNAME = AppDomain.CurrentDomain.FriendlyName;
/// <summary>
/// Path to the Home Folder on *Nix-based systems.
/// </summary>
public static readonly string NIXHOME = Environment.GetEnvironmentVariable("HOME");
/// <summary>
/// Path to the Config folder on *Nix-based systems.
/// </summary>
public static readonly string NIXXDGCONFIG = Environment.GetEnvironmentVariable("XDG_CONFIG_HOME");
/// <summary> /// <summary>
/// Generates the mirror list, depending on the current Platform. /// Generates the mirror list, depending on the current Platform.
@ -82,9 +90,8 @@ namespace AM2RLauncher
if (currentPlatform.IsGtk) if (currentPlatform.IsGtk)
{ {
// Config for nix systems will be saved in XDG_CONFIG_HOME/AM2RLauncher (or if empty, ~/.config) // Config for nix systems will be saved in XDG_CONFIG_HOME/AM2RLauncher (or if empty, ~/.config)
string homePath = Environment.GetEnvironmentVariable("HOME"); string homePath = NIXHOME;
string xdgConfigHome = Environment.GetEnvironmentVariable("XDG_CONFIG_HOME"); string launcherConfigPath = (String.IsNullOrWhiteSpace(NIXXDGCONFIG) ? (homePath + "/.config") : NIXXDGCONFIG) + "/AM2RLauncher";
string launcherConfigPath = (String.IsNullOrWhiteSpace(xdgConfigHome) ? (homePath + "/.config") : xdgConfigHome) + "/AM2RLauncher";
string launcherConfigFilePath = launcherConfigPath + "/config.xml"; string launcherConfigFilePath = launcherConfigPath + "/config.xml";
XML.LauncherConfigXML launcherConfig = new XML.LauncherConfigXML(); XML.LauncherConfigXML launcherConfig = new XML.LauncherConfigXML();
@ -121,7 +128,7 @@ namespace AM2RLauncher
if (appConfig == null) if (appConfig == null)
throw new NullReferenceException("Could not find the Config file! Please make sure it exists!"); throw new NullReferenceException("Could not find the Config file! Please make sure it exists!");
ConnectionStringsSection connectionStringsSection = (ConnectionStringsSection)appConfig.GetSection("connectionStrings"); ConnectionStringsSection connectionStringsSection = (ConnectionStringsSection)appConfig.GetSection("connectionStrings");
if (connectionStringsSection == null || connectionStringsSection.ConnectionStrings[property]?.ConnectionString == null) if (connectionStringsSection == null || connectionStringsSection.ConnectionStrings[property]?.ConnectionString == null)
throw new ArgumentException("The property " + property + " could not be found."); throw new ArgumentException("The property " + property + " could not be found.");
connectionStringsSection.ConnectionStrings[property].ConnectionString = value.ToString(); connectionStringsSection.ConnectionStrings[property].ConnectionString = value.ToString();
appConfig.Save(); appConfig.Save();
@ -130,9 +137,8 @@ namespace AM2RLauncher
else if (currentPlatform.IsGtk) else if (currentPlatform.IsGtk)
{ {
// Config for nix systems will be saved in XDG_CONFIG_HOME/AM2RLauncher (or if empty, ~/.config) // Config for nix systems will be saved in XDG_CONFIG_HOME/AM2RLauncher (or if empty, ~/.config)
string homePath = Environment.GetEnvironmentVariable("HOME"); string homePath = NIXHOME;
string xdgConfigHome = Environment.GetEnvironmentVariable("XDG_CONFIG_HOME"); string launcherConfigPath = (String.IsNullOrWhiteSpace(NIXXDGCONFIG) ? (homePath + "/.config") : NIXXDGCONFIG) + "/AM2RLauncher";
string launcherConfigPath = (String.IsNullOrWhiteSpace(xdgConfigHome) ? (homePath + "/.config") : xdgConfigHome) + "/AM2RLauncher";
string launcherConfigFilePath = launcherConfigPath + "/config.xml"; string launcherConfigFilePath = launcherConfigPath + "/config.xml";
XML.LauncherConfigXML launcherConfig = new XML.LauncherConfigXML(); XML.LauncherConfigXML launcherConfig = new XML.LauncherConfigXML();
@ -152,7 +158,7 @@ namespace AM2RLauncher
File.WriteAllText(launcherConfigFilePath, XML.Serializer.Serialize<XML.LauncherConfigXML>(launcherConfig)); File.WriteAllText(launcherConfigFilePath, XML.Serializer.Serialize<XML.LauncherConfigXML>(launcherConfig));
} }
} }
/// <summary> /// <summary>
/// When a Launcher update occurs that introduces new config properties, this method ensures that the old user config is copied over as much as possible. /// When a Launcher update occurs that introduces new config properties, this method ensures that the old user config is copied over as much as possible.
/// </summary> /// </summary>
@ -170,7 +176,7 @@ namespace AM2RLauncher
MatchCollection oldMatch = settingRegex.Matches(oldConfigText); MatchCollection oldMatch = settingRegex.Matches(oldConfigText);
MatchCollection newMatch = settingRegex.Matches(newConfigText); MatchCollection newMatch = settingRegex.Matches(newConfigText);
for(int i = 0; i < oldMatch.Count; i++) for (int i = 0; i < oldMatch.Count; i++)
newConfigText = newConfigText.Replace(newMatch[i].Value, oldMatch[i].Value); newConfigText = newConfigText.Replace(newMatch[i].Value, oldMatch[i].Value);
File.WriteAllText(newConfigPath, newConfigText); File.WriteAllText(newConfigPath, newConfigText);
@ -179,9 +185,8 @@ namespace AM2RLauncher
else if (currentPlatform.IsGtk) else if (currentPlatform.IsGtk)
{ {
// Config for nix systems will be saved in XDG_CONFIG_HOME/AM2RLauncher (or if empty, ~/.config) // Config for nix systems will be saved in XDG_CONFIG_HOME/AM2RLauncher (or if empty, ~/.config)
string homePath = Environment.GetEnvironmentVariable("HOME"); string homePath = NIXHOME;
string xdgConfigHome = Environment.GetEnvironmentVariable("XDG_CONFIG_HOME"); string launcherConfigPath = (String.IsNullOrWhiteSpace(NIXXDGCONFIG) ? (homePath + "/.config") : NIXXDGCONFIG) + "/AM2RLauncher";
string launcherConfigPath = (String.IsNullOrWhiteSpace(xdgConfigHome) ? (homePath + "/.config") : xdgConfigHome) + "/AM2RLauncher";
string launcherConfigFilePath = launcherConfigPath + "/config.xml"; string launcherConfigFilePath = launcherConfigPath + "/config.xml";
XML.LauncherConfigXML launcherConfig = new XML.LauncherConfigXML(); XML.LauncherConfigXML launcherConfig = new XML.LauncherConfigXML();
@ -212,7 +217,7 @@ namespace AM2RLauncher
// We have to replace forward slashes with backslashes here on windows because explorer.exe is picky... // We have to replace forward slashes with backslashes here on windows because explorer.exe is picky...
// And on Nix systems, we want to replace ~ with its corresponding env var // And on Nix systems, we want to replace ~ with its corresponding env var
string realPath = currentPlatform.IsWinForms ? Environment.ExpandEnvironmentVariables(path).Replace("/", "\\") string realPath = currentPlatform.IsWinForms ? Environment.ExpandEnvironmentVariables(path).Replace("/", "\\")
: path.Replace("~", Environment.GetEnvironmentVariable("HOME")); : path.Replace("~", NIXHOME);
if (!Directory.Exists(realPath)) if (!Directory.Exists(realPath))
{ {
log.Info(realPath + " did not exist and was created"); log.Info(realPath + " did not exist and was created");
@ -238,7 +243,7 @@ namespace AM2RLauncher
// We have to replace forward slashes with backslashes here on windows because explorer.exe is picky... // We have to replace forward slashes with backslashes here on windows because explorer.exe is picky...
// And on nix systems, we want to replace ~ with its corresponding env var // And on nix systems, we want to replace ~ with its corresponding env var
string realPath = currentPlatform.IsWinForms ? Environment.ExpandEnvironmentVariables(path).Replace("/", "\\") string realPath = currentPlatform.IsWinForms ? Environment.ExpandEnvironmentVariables(path).Replace("/", "\\")
: path.Replace("~", Environment.GetEnvironmentVariable("HOME")); : path.Replace("~", NIXHOME);
if (!File.Exists(realPath)) if (!File.Exists(realPath))
{ {
log.Error(realPath + "did not exist, operation to open its folder was cancelled!"); log.Error(realPath + "did not exist, operation to open its folder was cancelled!");
@ -273,16 +278,16 @@ namespace AM2RLauncher
arguments = "-version"; arguments = "-version";
} }
ProcessStartInfo javaStart = new ProcessStartInfo(); ProcessStartInfo javaStart = new ProcessStartInfo
javaStart.FileName = process; {
javaStart.Arguments = arguments; FileName = process,
javaStart.UseShellExecute = false; Arguments = arguments,
javaStart.CreateNoWindow = true; UseShellExecute = false,
CreateNoWindow = true
};
Process java = new Process();
java.StartInfo = javaStart; Process java = new Process { StartInfo = javaStart };
// This is primarily for linux, but could be happening on windows as well // This is primarily for linux, but could be happening on windows as well
try try
@ -297,7 +302,6 @@ namespace AM2RLauncher
} }
return java.ExitCode == 0; return java.ExitCode == 0;
} }
/// <summary> /// <summary>
@ -307,18 +311,18 @@ namespace AM2RLauncher
public static bool CheckIfXdeltaIsInstalled() public static bool CheckIfXdeltaIsInstalled()
{ {
string process = "xdelta3"; string process = "xdelta3";
string arguments = "-V"; string arguments = "-V";
ProcessStartInfo xdeltaStart = new ProcessStartInfo();
xdeltaStart.FileName = process;
xdeltaStart.Arguments = arguments;
xdeltaStart.UseShellExecute = false;
xdeltaStart.CreateNoWindow = true;
ProcessStartInfo xdeltaStart = new ProcessStartInfo
{
FileName = process,
Arguments = arguments,
UseShellExecute = false,
CreateNoWindow = true
};
Process xdelta = new Process();
xdelta.StartInfo = xdeltaStart; Process xdelta = new Process { StartInfo = xdeltaStart };
try try
{ {
@ -347,7 +351,7 @@ namespace AM2RLauncher
if (original == output) if (original == output)
output = output += "_"; output = output += "_";
string arguments = "-f -d -s \"" + original.Replace(CURRENTPATH + "/","") + "\" \"" + patch.Replace(CURRENTPATH + "/", "") string arguments = "-f -d -s \"" + original.Replace(CURRENTPATH + "/", "") + "\" \"" + patch.Replace(CURRENTPATH + "/", "")
+ "\" \"" + output.Replace(CURRENTPATH + "/", "") + "\""; + "\" \"" + output.Replace(CURRENTPATH + "/", "") + "\"";
if (currentPlatform.IsWinForms) if (currentPlatform.IsWinForms)
@ -438,7 +442,7 @@ namespace AM2RLauncher
if (string.IsNullOrWhiteSpace(xdgDataHome)) if (string.IsNullOrWhiteSpace(xdgDataHome))
{ {
log.Info("Using default Linux CurrentPath."); log.Info("Using default Linux CurrentPath.");
xdgDataHome = Environment.GetEnvironmentVariable("HOME") + "/.local/share"; xdgDataHome = NIXHOME + "/.local/share";
} }
// Add AM2RLauncher to the end of the dataPath // Add AM2RLauncher to the end of the dataPath

@ -1,16 +1,11 @@
using Eto; using AM2RLauncher.Helpers;
using Eto;
using Eto.Forms; using Eto.Forms;
using log4net;
using System; using System;
using System.Collections.Generic;
using System.Configuration;
using System.IO; using System.IO;
using System.IO.Compression; using System.IO.Compression;
using System.Linq;
using System.Net; using System.Net;
using System.Reflection;
using System.Text;
using log4net;
using AM2RLauncher.Helpers;
namespace AM2RLauncher namespace AM2RLauncher
{ {
@ -45,8 +40,6 @@ namespace AM2RLauncher
{ {
log.Info("Running update check..."); log.Info("Running update check...");
string version = VERSION.Replace(".", "");
// Update section // Update section
// Clean old files that have been left // Clean old files that have been left
@ -104,7 +97,7 @@ namespace AM2RLauncher
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://github.com/AM2R-Community-Developers/AM2RLauncher/releases/latest"); HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://github.com/AM2R-Community-Developers/AM2RLauncher/releases/latest");
HttpWebResponse response = null; HttpWebResponse response = null;
try try
{ {
response = (HttpWebResponse)request.GetResponse(); response = (HttpWebResponse)request.GetResponse();
} }
catch (WebException) catch (WebException)
@ -144,7 +137,7 @@ namespace AM2RLauncher
Directory.CreateDirectory(tmpUpdatePath); Directory.CreateDirectory(tmpUpdatePath);
try try
{ {
using (var client = new WebClient()) using (var client = new WebClient())
{ {
string platformSuffix = ""; string platformSuffix = "";
@ -152,13 +145,13 @@ namespace AM2RLauncher
else if (currentPlatform.IsGtk) platformSuffix = "_lin"; else if (currentPlatform.IsGtk) platformSuffix = "_lin";
log.Info("Downloading https://github.com/AM2R-Community-Developers/AM2RLauncher/releases/latest/download/AM2RLauncher_" + onlineVersion + platformSuffix + ".zip to " + zipPath + "."); log.Info("Downloading https://github.com/AM2R-Community-Developers/AM2RLauncher/releases/latest/download/AM2RLauncher_" + onlineVersion + platformSuffix + ".zip to " + zipPath + ".");
client.DownloadFile("https://github.com/AM2R-Community-Developers/AM2RLauncher/releases/latest/download/AM2RLauncher_" + onlineVersion + platformSuffix + ".zip", zipPath); client.DownloadFile("https://github.com/AM2R-Community-Developers/AM2RLauncher/releases/latest/download/AM2RLauncher_" + onlineVersion + platformSuffix + ".zip", zipPath);
log.Info("File successfully downloaded."); log.Info("File successfully downloaded.");
} }
} }
catch(UnauthorizedAccessException) catch (UnauthorizedAccessException)
{ {
log.Error("UnauthorizedAccessException caught! Displaying MessageBox."); log.Error("UnauthorizedAccessException caught! Displaying MessageBox.");
MessageBox.Show(Language.Text.UnauthorizedAccessMessage); MessageBox.Show(Language.Text.UnauthorizedAccessMessage);
@ -174,7 +167,7 @@ namespace AM2RLauncher
foreach (var file in new DirectoryInfo(tmpUpdatePath).GetFiles()) foreach (var file in new DirectoryInfo(tmpUpdatePath).GetFiles())
{ {
log.Info("Moving " + file.FullName + " to " + CrossPlatformOperations.CURRENTPATH + "/" + file.Name); log.Info("Moving " + file.FullName + " to " + CrossPlatformOperations.CURRENTPATH + "/" + file.Name);
File.Copy(file.FullName, updatePath + "/" + file.Name, true); File.Copy(file.FullName, updatePath + "/" + file.Name, true);
} }
// For windows, the actual application is in "AM2RLauncher.dll". Which means, we need to update the lib folder as well. // For windows, the actual application is in "AM2RLauncher.dll". Which means, we need to update the lib folder as well.
@ -189,7 +182,7 @@ namespace AM2RLauncher
} }
// Do the same for each subdir // Do the same for each subdir
foreach(DirectoryInfo dir in new DirectoryInfo(CrossPlatformOperations.CURRENTPATH + "/lib").GetDirectories()) foreach (DirectoryInfo dir in new DirectoryInfo(CrossPlatformOperations.CURRENTPATH + "/lib").GetDirectories())
{ {
foreach (FileInfo file in dir.GetFiles()) foreach (FileInfo file in dir.GetFiles())
{ {
@ -201,7 +194,7 @@ namespace AM2RLauncher
if (Directory.Exists(tmpUpdatePath + "lib")) if (Directory.Exists(tmpUpdatePath + "lib"))
HelperMethods.DirectoryCopy(tmpUpdatePath + "lib", CrossPlatformOperations.CURRENTPATH + "/lib", true); HelperMethods.DirectoryCopy(tmpUpdatePath + "lib", CrossPlatformOperations.CURRENTPATH + "/lib", true);
} }
Directory.Delete(tmpUpdatePath, true); Directory.Delete(tmpUpdatePath, true);
CrossPlatformOperations.CopyOldConfigToNewConfig(); CrossPlatformOperations.CopyOldConfigToNewConfig();

@ -1,74 +1,74 @@
using Eto.Forms; using Eto.Drawing;
using Eto.Drawing; using Eto.Forms;
using Pablo.Controls; using Pablo.Controls;
namespace AM2RLauncher namespace AM2RLauncher
{ {
/// <summary> /// <summary>
/// Extension of <see cref="CustomButton"/> that allows for advanced color settings. /// Extension of <see cref="CustomButton"/> that allows for advanced color settings.
/// </summary> /// </summary>
class ColorButton : CustomButton class ColorButton : CustomButton
{ {
/// <summary>The <see cref="Color"/> to draw the background with when <see cref="CustomButton.Hover"/> is true.</summary> /// <summary>The <see cref="Color"/> to draw the background with when <see cref="CustomButton.Hover"/> is true.</summary>
public Color BackgroundColorHover { get; set; } public Color BackgroundColorHover { get; set; }
/// <summary>The <see cref="Font"/> to use for text drawing.</summary> /// <summary>The <see cref="Font"/> to use for text drawing.</summary>
public Font Font { get; set; } public Font Font { get; set; }
/// <summary>The <see cref="Color"/> with which to draw the frame.</summary> /// <summary>The <see cref="Color"/> with which to draw the frame.</summary>
public Color FrameColor { get; set; } public Color FrameColor { get; set; }
/// <summary>The <see cref="Color"/> with which to draw the frame when it is disabled.</summary> /// <summary>The <see cref="Color"/> with which to draw the frame when it is disabled.</summary>
public Color FrameColorDisabled { get; set; } public Color FrameColorDisabled { get; set; }
/// <summary>The text to be drawn.</summary> /// <summary>The text to be drawn.</summary>
public string Text { get; set; } public string Text { get; set; }
/// <summary>The <see cref="Color"/> with which to draw the <see cref="Text"/>.</summary> /// <summary>The <see cref="Color"/> with which to draw the <see cref="Text"/>.</summary>
public Color TextColor { get; set; } public Color TextColor { get; set; }
/// <summary>The <see cref="Color"/> with which to draw the <see cref="Text"/> when it is disabled.</summary> /// <summary>The <see cref="Color"/> with which to draw the <see cref="Text"/> when it is disabled.</summary>
public Color TextColorDisabled { get; set; } public Color TextColorDisabled { get; set; }
/// <summary> /// <summary>
/// Creates a <see cref="ColorButton"/> with a default set of attributes. /// Creates a <see cref="ColorButton"/> with a default set of attributes.
/// </summary> /// </summary>
public ColorButton() public ColorButton()
{ {
BackgroundColorHover = Colors.White; BackgroundColorHover = Colors.White;
Font = new Font(SystemFont.Default, 12); Font = new Font(SystemFont.Default, 12);
FrameColor = Colors.White; FrameColor = Colors.White;
FrameColorDisabled = Colors.Gray; FrameColorDisabled = Colors.Gray;
Text = ""; Text = "";
TextColor = Colors.Black; TextColor = Colors.Black;
TextColorDisabled = Colors.Gray; TextColorDisabled = Colors.Gray;
} }
/// <summary> /// <summary>
/// Event raised to draw this control. /// Event raised to draw this control.
/// </summary> /// </summary>
/// <param name="pe"></param> /// <param name="pe"></param>
protected override void OnPaint(PaintEventArgs pe) protected override void OnPaint(PaintEventArgs pe)
{ {
// Define draw bounds // Define draw bounds
Rectangle drawBounds = new Rectangle(2, 2, Width - 5, Height - 5); Rectangle drawBounds = new Rectangle(2, 2, Width - 5, Height - 5);
// Draw background // Draw background
pe.Graphics.FillRectangle(Hover ? BackgroundColorHover : BackgroundColor, drawBounds); pe.Graphics.FillRectangle(Hover ? BackgroundColorHover : BackgroundColor, drawBounds);
// Draw frame // Draw frame
Pen framePen = new Pen(Enabled ? FrameColor : FrameColorDisabled, 1); Pen framePen = new Pen(Enabled ? FrameColor : FrameColorDisabled, 1);
pe.Graphics.DrawRectangle(framePen, drawBounds); pe.Graphics.DrawRectangle(framePen, drawBounds);
SolidBrush brush = new SolidBrush(Enabled ? TextColor : TextColorDisabled); SolidBrush brush = new SolidBrush(Enabled ? TextColor : TextColorDisabled);
// Get text measurements // Get text measurements
SizeF stringSize = pe.Graphics.MeasureString(Font, Text); SizeF stringSize = pe.Graphics.MeasureString(Font, Text);
int textWidth = (int)stringSize.Width; int textWidth = (int)stringSize.Width;
int textHeight = (int)stringSize.Height; int textHeight = (int)stringSize.Height;
// Draw text // Draw text
pe.Graphics.DrawText(Font, brush, new PointF(Width / 2 - textWidth / 2, Height / 2 - textHeight / 2), Text); pe.Graphics.DrawText(Font, brush, new PointF(Width / 2 - textWidth / 2, Height / 2 - textHeight / 2), Text);
} }
} }
} }

@ -1,191 +1,191 @@
using System; using Eto.Drawing;
using Eto.Forms; using Eto.Forms;
using Eto.Drawing; using System;
namespace Pablo.Controls namespace Pablo.Controls
{ {
/// <summary> /// <summary>
/// A custom button implementation for advanced drawing and events. /// A custom button implementation for advanced drawing and events.
/// Originally written by cwensley (https://gist.github.com/cwensley/95000998e37acd93e830), /// Originally written by cwensley (https://gist.github.com/cwensley/95000998e37acd93e830),
/// modified by Lojemiru and Miepee for use in the AM2RLauncher. /// modified by Lojemiru and Miepee for use in the AM2RLauncher.
/// </summary> /// </summary>
public class CustomButton : Drawable public class CustomButton : Drawable
{ {
/// <summary>Whether or not this <see cref="CustomButton"/> is being pressed.</summary> /// <summary>Whether or not this <see cref="CustomButton"/> is being pressed.</summary>
bool pressed; bool pressed;
/// <summary>Whether or not the mouse is hovering over this <see cref="CustomButton"/>.</summary> /// <summary>Whether or not the mouse is hovering over this <see cref="CustomButton"/>.</summary>
bool hover; bool hover;
/// <summary></summary> /// <summary></summary>
bool mouseDown; bool mouseDown;
/// <summary>Gets or sets the disabled color of this control.</summary> /// <summary>Gets or sets the disabled color of this control.</summary>
public static Color DisabledColor = Color.FromGrayscale(0.4f, 0.3f); public static Color DisabledColor = Color.FromGrayscale(0.4f, 0.3f);
/// <summary>Gets or sets the color of this control.</summary> /// <summary>Gets or sets the color of this control.</summary>
public static Color EnabledColor = Colors.Black; public static Color EnabledColor = Colors.Black;
/// <summary>Gets or sets whether or not this control is enabled.</summary> /// <summary>Gets or sets whether or not this control is enabled.</summary>
public override bool Enabled public override bool Enabled
{
get { return base.Enabled; }
set
{
if (base.Enabled != value)
{
base.Enabled = value;
if (Loaded)
Invalidate();
}
}
}
/// <summary>Gets or sets <see cref="pressed"/>.</summary>
public bool Pressed
{
get { return pressed; }
set
{
if (pressed != value)
{
pressed = value;
mouseDown = false;
if (Loaded)
Invalidate();
}
}
}
/// <summary>Gets <see cref="hover"/>.</summary>
public bool Hover
{ {
get { return hover; } get { return base.Enabled; }
set
{
if (base.Enabled != value)
{
base.Enabled = value;
if (Loaded)
Invalidate();
}
}
} }
/// <summary>Gets either the <see cref="EnabledColor"/> or <see cref="DisabledColor"/> dependent on <see cref="Enabled"/>.</summary> /// <summary>Gets or sets <see cref="pressed"/>.</summary>
public Color DrawColor public bool Pressed
{ {
get { return Enabled ? EnabledColor : DisabledColor; } get { return pressed; }
} set
{
/// <summary>Gets or sets whether or not this control should act as a toggle.</summary> if (pressed != value)
public bool Toggle { get; set; } {
pressed = value;
/// <summary>Gets or sets whether or not this control is persistent.</summary> mouseDown = false;
public bool Persistent { get; set; } if (Loaded)
Invalidate();
public event EventHandler<EventArgs> Click; }
}
/// <summary> }
/// Event raised when this control is clicked.
/// </summary> /// <summary>Gets <see cref="hover"/>.</summary>
/// <param name="e"></param> public bool Hover
protected virtual void OnClick(EventArgs e) {
{ get { return hover; }
if (Click != null) }
Click(this, e);
} /// <summary>Gets either the <see cref="EnabledColor"/> or <see cref="DisabledColor"/> dependent on <see cref="Enabled"/>.</summary>
public Color DrawColor
/// <summary>Default constructor. Sets <see cref="Enabled"/> to true.</summary> {
public CustomButton() { Enabled = true; } get { return Enabled ? EnabledColor : DisabledColor; }
}
/// <summary>Event raised when this control is resized.</summary>
/// <param name="e"></param> /// <summary>Gets or sets whether or not this control should act as a toggle.</summary>
protected override void OnSizeChanged(EventArgs e) public bool Toggle { get; set; }
{
base.OnSizeChanged(e); /// <summary>Gets or sets whether or not this control is persistent.</summary>
if (Loaded) public bool Persistent { get; set; }
Invalidate();
} public event EventHandler<EventArgs> Click;
/// <summary> /// <summary>
/// Event raised when the mouse is pressed down over this control's bounding box. /// Event raised when this control is clicked.
/// </summary> /// </summary>
/// <param name="e"></param> /// <param name="e"></param>
protected override void OnMouseDown(MouseEventArgs e) protected virtual void OnClick(EventArgs e)
{ {
base.OnMouseDown(e); if (Click != null)
if (Enabled) Click(this, e);
{ }
mouseDown = true;
Invalidate(); /// <summary>Default constructor. Sets <see cref="Enabled"/> to true.</summary>
} public CustomButton() { Enabled = true; }
}
/// <summary>Event raised when this control is resized.</summary>
/// <summary> /// <param name="e"></param>
/// Event raised when the mouse enters this control's bounding box. protected override void OnSizeChanged(EventArgs e)
/// </summary> {
/// <param name="e"></param> base.OnSizeChanged(e);
protected override void OnMouseEnter(MouseEventArgs e) if (Loaded)
{ Invalidate();
Cursor = new Cursor(CursorType.Pointer); }
base.OnMouseEnter(e);
hover = true; /// <summary>
Invalidate(); /// Event raised when the mouse is pressed down over this control's bounding box.
} /// </summary>
/// <param name="e"></param>
/// <summary> protected override void OnMouseDown(MouseEventArgs e)
/// Event raised when the mouse leaves this control's bounding box. {
/// </summary> base.OnMouseDown(e);
/// <param name="e"></param> if (Enabled)
protected override void OnMouseLeave(MouseEventArgs e) {
{ mouseDown = true;
Cursor = new Cursor(CursorType.Default); Invalidate();
base.OnMouseLeave(e); }
hover = false; }
Invalidate();
} /// <summary>
/// Event raised when the mouse enters this control's bounding box.
/// <summary> /// </summary>
/// Event raised when the mouse is released over this control's bounding box. /// <param name="e"></param>
/// </summary> protected override void OnMouseEnter(MouseEventArgs e)
/// <param name="e"></param> {
protected override void OnMouseUp(MouseEventArgs e) Cursor = new Cursor(CursorType.Pointer);
{ base.OnMouseEnter(e);
base.OnMouseUp(e); hover = true;
var rect = new Rectangle(this.Size); Invalidate();
if (mouseDown && rect.Contains((Point)e.Location)) }
{
if (Toggle) /// <summary>
pressed = !pressed; /// Event raised when the mouse leaves this control's bounding box.
else if (Persistent) /// </summary>
pressed = true; /// <param name="e"></param>
else protected override void OnMouseLeave(MouseEventArgs e)
pressed = false; {
mouseDown = false; Cursor = new Cursor(CursorType.Default);
base.OnMouseLeave(e);
this.Invalidate(); hover = false;
if (Enabled) Invalidate();
OnClick(EventArgs.Empty); }
}
else /// <summary>
{ /// Event raised when the mouse is released over this control's bounding box.
mouseDown = false; /// </summary>
this.Invalidate(); /// <param name="e"></param>
} protected override void OnMouseUp(MouseEventArgs e)
} {
base.OnMouseUp(e);
/// <summary> var rect = new Rectangle(this.Size);
/// Event raised to draw this control. if (mouseDown && rect.Contains((Point)e.Location))
/// </summary> {
/// <param name="pe"></param> if (Toggle)
protected override void OnPaint(PaintEventArgs pe) pressed = !pressed;
{ else if (Persistent)
var rect = new Rectangle(this.Size); pressed = true;
var col = Color.FromGrayscale(hover && Enabled ? 0.95f : 0.8f); else
if (Enabled && (pressed || mouseDown)) pressed = false;
{ mouseDown = false;
pe.Graphics.FillRectangle(col, rect);
pe.Graphics.DrawInsetRectangle(Colors.Gray, Colors.White, rect); this.Invalidate();
} if (Enabled)
else if (hover && Enabled) OnClick(EventArgs.Empty);
{ }
pe.Graphics.FillRectangle(col, rect); else
pe.Graphics.DrawInsetRectangle(Colors.White, Colors.Gray, rect); {
} mouseDown = false;
this.Invalidate();
base.OnPaint(pe); }
} }
}
/// <summary>
/// Event raised to draw this control.
/// </summary>
/// <param name="pe"></param>
protected override void OnPaint(PaintEventArgs pe)
{
var rect = new Rectangle(this.Size);
var col = Color.FromGrayscale(hover && Enabled ? 0.95f : 0.8f);
if (Enabled && (pressed || mouseDown))
{
pe.Graphics.FillRectangle(col, rect);
pe.Graphics.DrawInsetRectangle(Colors.Gray, Colors.White, rect);
}
else if (hover && Enabled)
{
pe.Graphics.FillRectangle(col, rect);
pe.Graphics.DrawInsetRectangle(Colors.White, Colors.Gray, rect);
}
base.OnPaint(pe);
}
}
} }

@ -1,10 +1,8 @@
using log4net; using log4net;
using System; using System;
using System.Collections.Generic;
using System.IO; using System.IO;
using System.Net; using System.Net;
using System.Security.Cryptography; using System.Security.Cryptography;
using System.Text;
namespace AM2RLauncher.Helpers namespace AM2RLauncher.Helpers
{ {

@ -1,107 +1,105 @@
using System; using Eto.Drawing;
using System.Collections.Generic; using System;
using System.Text;
using Eto.Drawing;
namespace Pablo.Controls namespace Pablo.Controls
{ {
/// <summary> /// <summary>
/// Extension of <see cref="CustomButton"/> that allows image assignment and drawing. /// Extension of <see cref="CustomButton"/> that allows image assignment and drawing.
/// Originally written by cwensley (https://gist.github.com/cwensley/95000998e37acd93e830), /// Originally written by cwensley (https://gist.github.com/cwensley/95000998e37acd93e830),
/// modified by Lojemiru and Miepee for use in the AM2RLauncher. /// modified by Lojemiru and Miepee for use in the AM2RLauncher.
/// </summary> /// </summary>
public class ImageButton : CustomButton public class ImageButton : CustomButton
{ {
/// <summary> /// <summary>
/// Whether or not this control's size has been set. /// Whether or not this control's size has been set.
/// </summary> /// </summary>
bool sizeSet; bool sizeSet;
/// <summary> /// <summary>
/// Gets or sets the <see cref="Eto.Drawing.Image"/> to draw during <see cref="OnPaint"/>. /// Gets or sets the <see cref="Eto.Drawing.Image"/> to draw during <see cref="OnPaint"/>.
/// </summary> /// </summary>
public Image Image { get; set; } public Image Image { get; set; }
/// <summary> /// <summary>
/// Gets or sets the <see cref="Eto.Drawing.Image"/> to draw during <see cref="OnPaint"/> if this control is disabled. /// Gets or sets the <see cref="Eto.Drawing.Image"/> to draw during <see cref="OnPaint"/> if this control is disabled.
/// </summary> /// </summary>
public Image DisabledImage { get; set; } public Image DisabledImage { get; set; }
/// <summary> /// <summary>
/// Gets or sets the <see cref="Eto.Drawing.Size"/> of this control. /// Gets or sets the <see cref="Eto.Drawing.Size"/> of this control.
/// </summary> /// </summary>
public override Size Size public override Size Size
{ {
get { return base.Size; } get { return base.Size; }
set { base.Size = value; sizeSet = true; } set { base.Size = value; sizeSet = true; }
} }
/// <summary> /// <summary>
/// Default contructor, assigns no special attributes. /// Default contructor, assigns no special attributes.
/// </summary> /// </summary>
public ImageButton() { } public ImageButton() { }
/// <summary> /// <summary>
/// Event raised when this control is loading. /// Event raised when this control is loading.
/// </summary> /// </summary>
/// <param name="e"></param> /// <param name="e"></param>
protected override void OnLoad(EventArgs e) protected override void OnLoad(EventArgs e)
{ {
base.OnLoad(e); base.OnLoad(e);
if (Image != null) if (Image != null)
{ {
if (!sizeSet) if (!sizeSet)
this.Size = Image.Size + 4; this.Size = Image.Size + 4;
} }
} }
/// <summary> /// <summary>
/// Event raised when this control has finished loading. /// Event raised when this control has finished loading.
/// </summary> /// </summary>
/// <param name="e"></param> /// <param name="e"></param>
protected override void OnLoadComplete(EventArgs e) protected override void OnLoadComplete(EventArgs e)
{ {
base.OnLoadComplete(e); base.OnLoadComplete(e);
if (DisabledImage == null) if (DisabledImage == null)
{ {
var image = Image; var image = Image;
if (image != null) if (image != null)
{ {
var disabledImage = new Bitmap(image.Size.Width, image.Size.Height, PixelFormat.Format32bppRgba); var disabledImage = new Bitmap(image.Size.Width, image.Size.Height, PixelFormat.Format32bppRgba);
using (var graphics = new Graphics(disabledImage)) using (var graphics = new Graphics(disabledImage))
{ {
graphics.DrawImage(image, 0, 0); graphics.DrawImage(image, 0, 0);
} }
using (var bd = disabledImage.Lock()) using (var bd = disabledImage.Lock())
{ {
unsafe unsafe
{ {
var data = (int*)bd.Data; var data = (int*)bd.Data;
for (int i = 0; i < bd.ScanWidth * disabledImage.Size.Height; i++) for (int i = 0; i < bd.ScanWidth * disabledImage.Size.Height; i++)
{ {
var col = Color.FromArgb(bd.TranslateDataToArgb(*data)); var col = Color.FromArgb(bd.TranslateDataToArgb(*data));
var gray = (col.R + col.G + col.B) / 3; var gray = (col.R + col.G + col.B) / 3;
*data = bd.TranslateArgbToData(Color.FromGrayscale(gray, 0.8f).ToArgb()); *data = bd.TranslateArgbToData(Color.FromGrayscale(gray, 0.8f).ToArgb());
} }
} }
} }
} }
} }
} }
/// <summary> /// <summary>
/// Event raised to draw this control. /// Event raised to draw this control.
/// </summary> /// </summary>
/// <param name="pe"></param> /// <param name="pe"></param>
protected override void OnPaint(Eto.Forms.PaintEventArgs pe) protected override void OnPaint(Eto.Forms.PaintEventArgs pe)
{ {
var image = this.Enabled ? Image : DisabledImage; var image = this.Enabled ? Image : DisabledImage;
var size = image.Size.FitTo(this.Size - 2); var size = image.Size.FitTo(this.Size - 2);
var xoffset = (this.Size.Width - size.Width) / 2; var xoffset = (this.Size.Width - size.Width) / 2;
var yoffset = (this.Size.Height - size.Height) / 2; var yoffset = (this.Size.Height - size.Height) / 2;
pe.Graphics.DrawImage(image, xoffset, yoffset, size.Width, size.Height); pe.Graphics.DrawImage(image, xoffset, yoffset, size.Width, size.Height);
} }
} }
} }

@ -1,26 +1,18 @@
using Eto; using AM2RLauncher.Helpers;
using Eto.Drawing; using AM2RLauncher.XML;
using Eto;
using Eto.Forms; using Eto.Forms;
using System;
using System.Collections.Generic;
using System.Text;
using Pablo.Controls;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Threading.Tasks;
using LibGit2Sharp; using LibGit2Sharp;
using LibGit2Sharp.Handlers;
using System;
using System.ComponentModel;
using System.IO; using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using LibGit2Sharp.Handlers;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Threading; using System.Threading;
using System.ComponentModel; using System.Threading.Tasks;
using System.Net;
using System.IO.Compression;
using AM2RLauncher.XML;
using AM2RLauncher.Helpers;
namespace AM2RLauncher namespace AM2RLauncher
{ {
@ -140,7 +132,7 @@ namespace AM2RLauncher
log.Info("Cancelling archival! User-defined archive in Mods already exists."); log.Info("Cancelling archival! User-defined archive in Mods already exists.");
} }
} }
else // If our desired rename already exists, it's probably a user archive... so we just delete the folder and move on with installation of the new version. else // If our desired rename already exists, it's probably a user archive... so we just delete the folder and move on with installation of the new version.
{ {
@ -152,7 +144,7 @@ namespace AM2RLauncher
LoadProfiles(); LoadProfiles();
} }
} }
@ -225,7 +217,7 @@ namespace AM2RLauncher
} }
successful = false; successful = false;
} }
catch(Exception ex) // This is if somehow any other exception might get thrown as well. catch (Exception ex) // This is if somehow any other exception might get thrown as well.
{ {
log.Error(ex.Message + "\n*****Stack Trace*****\n\n" + ex.StackTrace); log.Error(ex.Message + "\n*****Stack Trace*****\n\n" + ex.StackTrace);
MessageBox.Show(ex.Message + "\n*****Stack Trace*****\n\n" + ex.StackTrace, Language.Text.ErrorWindowTitle, MessageBoxType.Error); MessageBox.Show(ex.Message + "\n*****Stack Trace*****\n\n" + ex.StackTrace, Language.Text.ErrorWindowTitle, MessageBoxType.Error);
@ -352,7 +344,7 @@ namespace AM2RLauncher
{ {
InstallProfile(profileList[profileIndex.Value]); InstallProfile(profileList[profileIndex.Value]);
} }
catch(Exception ex) catch (Exception ex)
{ {
log.Error(ex.Message + "\n*****Stack Trace*****\n\n" + ex.StackTrace); log.Error(ex.Message + "\n*****Stack Trace*****\n\n" + ex.StackTrace);
MessageBox.Show(ex.Message + "\n*****Stack Trace*****\n\n" + ex.StackTrace, Language.Text.ErrorWindowTitle, MessageBoxType.Error); MessageBox.Show(ex.Message + "\n*****Stack Trace*****\n\n" + ex.StackTrace, Language.Text.ErrorWindowTitle, MessageBoxType.Error);
@ -430,7 +422,7 @@ namespace AM2RLauncher
progressLabel.Text = Language.Text.ProgressbarProgress + " " + transferProgress.ReceivedObjects + " (" + (int)transferProgress.ReceivedBytes / 1000000 + "MB) / " + transferProgress.TotalObjects + " objects"; progressLabel.Text = Language.Text.ProgressbarProgress + " " + transferProgress.ReceivedObjects + " (" + (int)transferProgress.ReceivedBytes / 1000000 + "MB) / " + transferProgress.TotalObjects + " objects";
currentGitObject = transferProgress.ReceivedObjects; currentGitObject = transferProgress.ReceivedObjects;
progressBar.Value = transferProgress.ReceivedObjects; progressBar.Value = transferProgress.ReceivedObjects;
} }
})); }));
@ -578,7 +570,7 @@ namespace AM2RLauncher
log.Error("Mod is for " + profile.OperatingSystem + " while current OS is " + Platform + ". Cancelling mod import."); log.Error("Mod is for " + profile.OperatingSystem + " while current OS is " + Platform + ". Cancelling mod import.");
MessageBox.Show(Language.Text.ModIsForWrongOS.Replace("$NAME",profile.Name).Replace("$OS",profile.OperatingSystem).Replace("$CURRENTOS",currentOS), MessageBox.Show(Language.Text.ModIsForWrongOS.Replace("$NAME", profile.Name).Replace("$OS", profile.OperatingSystem).Replace("$CURRENTOS", currentOS),
Language.Text.ErrorWindowTitle, MessageBoxType.Error); Language.Text.ErrorWindowTitle, MessageBoxType.Error);
HelperMethods.DeleteDirectory(modsDir + "/" + extractedName); HelperMethods.DeleteDirectory(modsDir + "/" + extractedName);
return; return;
@ -596,7 +588,7 @@ namespace AM2RLauncher
addedProfile = profile; addedProfile = profile;
log.Info(profile.Name + " successfully installed."); log.Info(profile.Name + " successfully installed.");
MessageBox.Show(Language.Text.ModSuccessfullyInstalledMessage.Replace("$NAME", profile.Name), Language.Text.SuccessWindowTitle); MessageBox.Show(Language.Text.ModSuccessfullyInstalledMessage.Replace("$NAME", profile.Name), Language.Text.SuccessWindowTitle);
} }
else else
{ {
@ -747,7 +739,7 @@ namespace AM2RLauncher
} }
/// <summary>Gets called when user selects a different item from <see cref="profileDropDown"/> and changes <see cref="profileAuthorLabel"/> accordingly.</summary> /// <summary>Gets called when user selects a different item from <see cref="profileDropDown"/> and changes <see cref="profileAuthorLabel"/> accordingly.</summary>
private void ProfileDropDownSelectedIndexChanged(object sender, EventArgs e) private void ProfileDropDownSelectedIndexChanged(object sender, EventArgs e)
{ {
profileIndex = profileDropDown.SelectedIndex; profileIndex = profileDropDown.SelectedIndex;
log.Info("profileDropDown.SelectedIndex has been changed to " + profileIndex + "."); log.Info("profileDropDown.SelectedIndex has been changed to " + profileIndex + ".");
@ -799,12 +791,12 @@ namespace AM2RLauncher
mirrorDropDown.Enabled = !enabled; mirrorDropDown.Enabled = !enabled;
// Not sure why the dropdown menu needs this hack, but the textBox does not. // Not sure why the dropdown menu needs this hack, but the textBox does not.
if (Platform.IsWinForms) if (Platform.IsWinForms)
mirrorDropDown.TextColor = mirrorDropDown.Enabled ? colGreen : colInactive; mirrorDropDown.TextColor = mirrorDropDown.Enabled ? colGreen : colInactive;
mirrorLabel.TextColor = !enabled ? colGreen : colInactive; mirrorLabel.TextColor = !enabled ? colGreen : colInactive;
// Create warning dialog when enabling // Create warning dialog when enabling
if (enabled) if (enabled)
{ {
MessageBox.Show(Language.Text.WarningWindowText, Language.Text.WarningWindowTitle, MessageBoxType.Warning); MessageBox.Show(Language.Text.WarningWindowText, Language.Text.WarningWindowTitle, MessageBoxType.Warning);
currentMirror = customMirrorTextBox.Text; currentMirror = customMirrorTextBox.Text;
} }
@ -824,7 +816,7 @@ namespace AM2RLauncher
log.Info("Current mirror has been set to " + currentMirror + "."); log.Info("Current mirror has been set to " + currentMirror + ".");
CrossPlatformOperations.WriteToConfig("MirrorIndex",mirrorDropDown.SelectedIndex); CrossPlatformOperations.WriteToConfig("MirrorIndex", mirrorDropDown.SelectedIndex);
// Don't overwrite the git config while we download!!! // Don't overwrite the git config while we download!!!
if (updateState == UpdateState.Downloading) return; if (updateState == UpdateState.Downloading) return;
@ -901,7 +893,7 @@ namespace AM2RLauncher
ProfileXML profile = profileList[settingsProfileDropDown.SelectedIndex]; ProfileXML profile = profileList[settingsProfileDropDown.SelectedIndex];
log.Info("User is attempting to delete profile " + profile.Name + "."); log.Info("User is attempting to delete profile " + profile.Name + ".");
DialogResult result = MessageBox.Show(Language.Text.DeleteModWarning.Replace("$NAME", profile.Name), Language.Text.WarningWindowTitle, DialogResult result = MessageBox.Show(Language.Text.DeleteModWarning.Replace("$NAME", profile.Name), Language.Text.WarningWindowTitle,
MessageBoxButtons.OKCancel, MessageBoxType.Warning, MessageBoxDefaultButton.Cancel); MessageBoxButtons.OKCancel, MessageBoxType.Warning, MessageBoxDefaultButton.Cancel);
if (result == DialogResult.Ok) if (result == DialogResult.Ok)
@ -992,7 +984,7 @@ namespace AM2RLauncher
// Rename directory to take the old one's place // Rename directory to take the old one's place
string originalFolder = modsDir + "/" + extractedName.Replace("_new", ""); string originalFolder = modsDir + "/" + extractedName.Replace("_new", "");
Directory.Move(modsDir + "/" + extractedName, originalFolder); Directory.Move(modsDir + "/" + extractedName, originalFolder);
} }
else // Cancel the operation! else // Cancel the operation!
{ {
@ -1051,9 +1043,9 @@ namespace AM2RLauncher
{ {
e.Cancel = true; e.Cancel = true;
} }
else else
isGitProcessGettingCancelled = true; isGitProcessGettingCancelled = true;
// We don't need to delete any folders here, the cancelled gitClone will do that automatically for us :) // We don't need to delete any folders here, the cancelled gitClone will do that automatically for us :)
} }
else if (updateState == UpdateState.Installing) else if (updateState == UpdateState.Installing)

@ -1,21 +1,16 @@
using System; using AM2RLauncher.Helpers;
using System.Collections.Generic; using AM2RLauncher.XML;
using System.Text; using Eto;
using Eto.Drawing;
using Eto.Forms; using Eto.Forms;
using System.Threading;
using LibGit2Sharp; using LibGit2Sharp;
using System;
using System.Diagnostics;
using System.IO; using System.IO;
using System.IO.Compression; using System.IO.Compression;
using Eto;
using System.Diagnostics;
using System.Linq; using System.Linq;
using Eto.Drawing;
using System.Xml.Serialization;
using AM2RLauncher.XML;
using System.Net.NetworkInformation;
using System.Net;
using AM2RLauncher.Helpers;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Threading;
namespace AM2RLauncher namespace AM2RLauncher
{ {
@ -269,12 +264,12 @@ namespace AM2RLauncher
// Failsafe for Profiles directory // Failsafe for Profiles directory
if (!Directory.Exists(profilesHomePath)) if (!Directory.Exists(profilesHomePath))
Directory.CreateDirectory(profilesHomePath); Directory.CreateDirectory(profilesHomePath);
// This failsafe should NEVER get triggered, but Miepee's broken this too much for me to trust it otherwise. // This failsafe should NEVER get triggered, but Miepee's broken this too much for me to trust it otherwise.
if (Directory.Exists(profilePath)) if (Directory.Exists(profilePath))
Directory.Delete(profilePath, true); Directory.Delete(profilePath, true);
// Create profile directory // Create profile directory
Directory.CreateDirectory(profilePath); Directory.CreateDirectory(profilePath);
@ -326,7 +321,7 @@ namespace AM2RLauncher
if (profile.UsesYYC) if (profile.UsesYYC)
{ {
CrossPlatformOperations.ApplyXdeltaPatch(profilePath + "/data.win", dataPath + "/AM2R.xdelta", profilePath + "/" + exe); CrossPlatformOperations.ApplyXdeltaPatch(profilePath + "/data.win", dataPath + "/AM2R.xdelta", profilePath + "/" + exe);
// Delete 1.1's data.win, we don't need it anymore! // Delete 1.1's data.win, we don't need it anymore!
File.Delete(profilePath + "/data.win"); File.Delete(profilePath + "/data.win");
} }
@ -341,7 +336,7 @@ namespace AM2RLauncher
CrossPlatformOperations.ApplyXdeltaPatch(profilePath + "/data.win", dataPath + "/game.xdelta", profilePath + "/" + datawin); CrossPlatformOperations.ApplyXdeltaPatch(profilePath + "/data.win", dataPath + "/game.xdelta", profilePath + "/" + datawin);
CrossPlatformOperations.ApplyXdeltaPatch(profilePath + "/AM2R.exe", dataPath + "/AM2R.xdelta", profilePath + "/" + exe); CrossPlatformOperations.ApplyXdeltaPatch(profilePath + "/AM2R.exe", dataPath + "/AM2R.xdelta", profilePath + "/" + exe);
// Just in case the resulting file isn't chmoddded... // Just in case the resulting file isn't chmoddded...
Process.Start("chmod", "+x \"" + profilePath + "/" + exe + "\"").WaitForExit(); Process.Start("chmod", "+x \"" + profilePath + "/" + exe + "\"").WaitForExit();
// These are not needed by linux at all, so we delete them // These are not needed by linux at all, so we delete them
File.Delete(profilePath + "/data.win"); File.Delete(profilePath + "/data.win");
@ -363,7 +358,7 @@ namespace AM2RLauncher
// HQ music // HQ music
if (!profile.UsesCustomMusic && (bool)hqMusicPCCheck.Checked) if (!profile.UsesCustomMusic && (bool)hqMusicPCCheck.Checked)
HelperMethods.DirectoryCopy(CrossPlatformOperations.CURRENTPATH + "/PatchData/data/HDR_HQ_in-game_music", profilePath); HelperMethods.DirectoryCopy(CrossPlatformOperations.CURRENTPATH + "/PatchData/data/HDR_HQ_in-game_music", profilePath);
// Linux post-process // Linux post-process
if (Platform.IsGtk) if (Platform.IsGtk)
@ -403,7 +398,7 @@ namespace AM2RLauncher
// Clean files // Clean files
Directory.Delete(profilePath + "/AM2R.AppDir", true); Directory.Delete(profilePath + "/AM2R.AppDir", true);
Directory.Delete(assetsPath, true); Directory.Delete(assetsPath, true);
File.Delete(profilePath + "/" +exe); File.Delete(profilePath + "/" + exe);
if (File.Exists(profilePath + "/AM2R.AppImage")) File.Delete(profilePath + "/AM2R.AppImage"); if (File.Exists(profilePath + "/AM2R.AppImage")) File.Delete(profilePath + "/AM2R.AppImage");
File.Move(profilePath + "/" + "AM2R-x86_64.AppImage", profilePath + "/AM2R.AppImage"); File.Move(profilePath + "/" + "AM2R-x86_64.AppImage", profilePath + "/AM2R.AppImage");
} }
@ -450,7 +445,7 @@ namespace AM2RLauncher
// Check if xdelta is installed on linux, by searching all folders in PATH // Check if xdelta is installed on linux, by searching all folders in PATH
if (Platform.IsGtk && !CrossPlatformOperations.CheckIfXdeltaIsInstalled()) if (Platform.IsGtk && !CrossPlatformOperations.CheckIfXdeltaIsInstalled())
{ {
// Message box show needs to be done on main thread // Message box show needs to be done on main thread
Application.Instance.Invoke(new Action(() => Application.Instance.Invoke(new Action(() =>
{ {
@ -500,7 +495,7 @@ namespace AM2RLauncher
{ {
FileName = proc, FileName = proc,
// For an explanation on the .replace look in CreateXdeltaPatch method // For an explanation on the .replace look in CreateXdeltaPatch method
Arguments = args + "\"" + apktoolPath.Replace(CrossPlatformOperations.CURRENTPATH + "/","../") + "\" d \"" + dataPath.Replace(CrossPlatformOperations.CURRENTPATH + "/", "../") + "/android/AM2RWrapper.apk\"", Arguments = args + "\"" + apktoolPath.Replace(CrossPlatformOperations.CURRENTPATH + "/", "../") + "\" d \"" + dataPath.Replace(CrossPlatformOperations.CURRENTPATH + "/", "../") + "/android/AM2RWrapper.apk\"",
WorkingDirectory = tempDir, WorkingDirectory = tempDir,
UseShellExecute = false, UseShellExecute = false,
CreateNoWindow = true CreateNoWindow = true
@ -646,7 +641,7 @@ namespace AM2RLauncher
// These are used on both windows and linux for game logging // These are used on both windows and linux for game logging
string savePath = Platform.IsWinForms ? profile.SaveLocation.Replace("%localappdata%", Environment.GetEnvironmentVariable("LOCALAPPDATA")) string savePath = Platform.IsWinForms ? profile.SaveLocation.Replace("%localappdata%", Environment.GetEnvironmentVariable("LOCALAPPDATA"))
: profile.SaveLocation.Replace("~", Environment.GetEnvironmentVariable("HOME")); : profile.SaveLocation.Replace("~", CrossPlatformOperations.NIXHOME);
DirectoryInfo logDir = new DirectoryInfo(savePath + "/logs"); DirectoryInfo logDir = new DirectoryInfo(savePath + "/logs");
string date = string.Join("-", DateTime.Now.ToString().Split(Path.GetInvalidFileNameChars(), StringSplitOptions.RemoveEmptyEntries)); string date = string.Join("-", DateTime.Now.ToString().Split(Path.GetInvalidFileNameChars(), StringSplitOptions.RemoveEmptyEntries));
@ -704,7 +699,7 @@ namespace AM2RLauncher
{ {
string envVars = customEnvVarTextBox.Text; string envVars = customEnvVarTextBox.Text;
for(int i = 0; i < customEnvVarTextBox.Text.Count(f => f == '='); i++) for (int i = 0; i < customEnvVarTextBox.Text.Count(f => f == '='); i++)
{ {
// Env var variable // Env var variable
string variable = envVars.Substring(0, envVars.IndexOf('=')); string variable = envVars.Substring(0, envVars.IndexOf('='));
@ -715,15 +710,15 @@ namespace AM2RLauncher
if (envVars[0] != '"') // If value is not embedded in "", check if there are spaces left. If yes, get the index of the space, if not that was the last if (envVars[0] != '"') // If value is not embedded in "", check if there are spaces left. If yes, get the index of the space, if not that was the last
{ {
if (envVars.IndexOf(' ') >= 0) if (envVars.IndexOf(' ') >= 0)
valueSubstringLength = envVars.IndexOf(' ')+1; valueSubstringLength = envVars.IndexOf(' ') + 1;
else else
valueSubstringLength = envVars.Length; valueSubstringLength = envVars.Length;
} }
else // If value is embedded in "", check if there are spaces after the "". if yes, get index of that, if not that was the last else // If value is embedded in "", check if there are spaces after the "". if yes, get index of that, if not that was the last
{ {
int secondQuoteIndex = envVars.IndexOf('"', envVars.IndexOf('"')+1); int secondQuoteIndex = envVars.IndexOf('"', envVars.IndexOf('"') + 1);
if (envVars.IndexOf(' ', secondQuoteIndex) >= 0) if (envVars.IndexOf(' ', secondQuoteIndex) >= 0)
valueSubstringLength = envVars.IndexOf(' ', secondQuoteIndex)+1; valueSubstringLength = envVars.IndexOf(' ', secondQuoteIndex) + 1;
else else
valueSubstringLength = envVars.Length; valueSubstringLength = envVars.Length;
} }
@ -746,7 +741,7 @@ namespace AM2RLauncher
log.Info("CWD of Profile is " + startInfo.WorkingDirectory); log.Info("CWD of Profile is " + startInfo.WorkingDirectory);
log.Info("Launching game with following variables: "); log.Info("Launching game with following variables: ");
foreach(System.Collections.DictionaryEntry item in startInfo.EnvironmentVariables) foreach (System.Collections.DictionaryEntry item in startInfo.EnvironmentVariables)
{ {
log.Info("Key: \"" + item.Key + "\" Value: \"" + item.Value + "\""); log.Info("Key: \"" + item.Key + "\" Value: \"" + item.Value + "\"");
} }
@ -907,7 +902,7 @@ namespace AM2RLauncher
} }
else // Otherwise, disable. else // Otherwise, disable.
{ {
apkButton.Enabled = false; apkButton.Enabled = false;
apkButton.ToolTip = Language.Text.ApkButtonDisabledToolTip; apkButton.ToolTip = Language.Text.ApkButtonDisabledToolTip;
} }
} }
@ -1048,9 +1043,9 @@ namespace AM2RLauncher
case UpdateState.Download: playButton.Enabled = true; playButton.ToolTip = Language.Text.PlayButtonDownloadToolTip; break; case UpdateState.Download: playButton.Enabled = true; playButton.ToolTip = Language.Text.PlayButtonDownloadToolTip; break;
case UpdateState.Downloading: playButton.Enabled = true; playButton.ToolTip = ""; break; // ; playButton.ToolTip = Language.Text.PlayButtonDownladingToolTip; break; case UpdateState.Downloading: playButton.Enabled = true; playButton.ToolTip = ""; break; // ; playButton.ToolTip = Language.Text.PlayButtonDownladingToolTip; break;
case UpdateState.Select11: playButton.Enabled = true; playButton.ToolTip = Language.Text.PlayButtonSelect11ToolTip; break; case UpdateState.Select11: playButton.Enabled = true; playButton.ToolTip = Language.Text.PlayButtonSelect11ToolTip; break;
case UpdateState.Install: playButton.Enabled = true; playButton.ToolTip = Language.Text.PlayButtonInstallToolTip.Replace("$NAME", profileName) ; break; case UpdateState.Install: playButton.Enabled = true; playButton.ToolTip = Language.Text.PlayButtonInstallToolTip.Replace("$NAME", profileName); break;
case UpdateState.Installing: playButton.Enabled = false; playButton.ToolTip = Language.Text.PlayButtonInstallingToolTip; break; case UpdateState.Installing: playButton.Enabled = false; playButton.ToolTip = Language.Text.PlayButtonInstallingToolTip; break;
case UpdateState.Play: playButton.Enabled = true; playButton.ToolTip = Language.Text.PlayButtonPlayToolTip.Replace("$NAME", profileName) ; break; case UpdateState.Play: playButton.Enabled = true; playButton.ToolTip = Language.Text.PlayButtonPlayToolTip.Replace("$NAME", profileName); break;
case UpdateState.Playing: playButton.Enabled = false; playButton.ToolTip = Language.Text.PlayButtonPlayingToolTip; break; case UpdateState.Playing: playButton.Enabled = false; playButton.ToolTip = Language.Text.PlayButtonPlayingToolTip; break;
} }
playButton.Text = GetPlayButtonText(); playButton.Text = GetPlayButtonText();

@ -1,17 +1,16 @@
using Eto.Drawing; using AM2RLauncher.XML;
using Eto.Drawing;
using Eto.Forms; using Eto.Forms;
using log4net;
using Pablo.Controls;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using Pablo.Controls; using System.Globalization;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Threading;
using System.Globalization;
using AM2RLauncher.XML;
using log4net;
using log4net.Config;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Threading;
namespace AM2RLauncher namespace AM2RLauncher
{ {
@ -143,7 +142,7 @@ namespace AM2RLauncher
var results = lineRegex.Matches(osRelease).Cast<Match>(); var results = lineRegex.Matches(osRelease).Cast<Match>();
var version = results.FirstOrDefault(x => x.Value.Contains("VERSION")); var version = results.FirstOrDefault(x => x.Value.Contains("VERSION"));
log.Info("Current Distro: " + results.FirstOrDefault(x => x.Value.Contains("NAME")).Value.Substring(5).Replace("\"", "") + log.Info("Current Distro: " + results.FirstOrDefault(x => x.Value.Contains("NAME")).Value.Substring(5).Replace("\"", "") +
(version == null ? "" : " " + version.Value.Substring(8).Replace("\"",""))); (version == null ? "" : " " + version.Value.Substring(8).Replace("\"", "")));
} }
// Set the Current Directory to the path the Launcher is located. Fixes some relative path issues. // Set the Current Directory to the path the Launcher is located. Fixes some relative path issues.
@ -626,7 +625,7 @@ namespace AM2RLauncher
mirrorDropDown.Items.AddRange(mirrorDescriptionList); // As above, find a way to get this inside the dropDown definition mirrorDropDown.Items.AddRange(mirrorDescriptionList); // As above, find a way to get this inside the dropDown definition
mirrorIndex = (int.Parse(CrossPlatformOperations.ReadFromConfig("MirrorIndex")) < mirrorDropDown.Items.Count) ? int.Parse(CrossPlatformOperations.ReadFromConfig("MirrorIndex")) : 0; mirrorIndex = (int.Parse(CrossPlatformOperations.ReadFromConfig("MirrorIndex")) < mirrorDropDown.Items.Count) ? int.Parse(CrossPlatformOperations.ReadFromConfig("MirrorIndex")) : 0;
mirrorDropDown.SelectedIndex = mirrorIndex; mirrorDropDown.SelectedIndex = mirrorIndex;
currentMirror = mirrorList[mirrorDropDown.SelectedIndex]; currentMirror = mirrorList[mirrorDropDown.SelectedIndex];

@ -1,6 +1,5 @@
using Eto; using Eto;
using System; using System;
using System.Collections.Generic;
using System.Linq; using System.Linq;
namespace AM2RLauncher namespace AM2RLauncher
@ -81,9 +80,9 @@ namespace AM2RLauncher
string[] combinedSplash; string[] combinedSplash;
Random rng = new Random(); Random rng = new Random();
if (Platform.Instance.IsGtk) if (Platform.Instance.IsGtk)
combinedSplash = generalSplash.Concat(linuxSplash).ToArray(); combinedSplash = generalSplash.Concat(linuxSplash).ToArray();
else else
combinedSplash = generalSplash; combinedSplash = generalSplash;
string splashString = combinedSplash[rng.Next(0, combinedSplash.Length)]; string splashString = combinedSplash[rng.Next(0, combinedSplash.Length)];

Before

Width:  |  Height:  |  Size: 101 KiB

After

Width:  |  Height:  |  Size: 101 KiB

@ -1,10 +1,6 @@
using System; using System;
using System.Reflection;
using System.Collections.Generic;
using System.Text;
using System.Xml.Serialization;
using System.Linq; using System.Linq;
using System.ComponentModel; using System.Xml.Serialization;
namespace AM2RLauncher.XML namespace AM2RLauncher.XML
{ {
@ -87,7 +83,7 @@ namespace AM2RLauncher.XML
public object this[string property] public object this[string property]
{ {
get get
{ {
// This is gonna throw an exception, if the property can't be found. because of null.GetValue(this) // This is gonna throw an exception, if the property can't be found. because of null.GetValue(this)
return typeof(LauncherConfigXML).GetProperties().Where(p => p.CanRead && p.Name == property).First().GetValue(this).ToString(); return typeof(LauncherConfigXML).GetProperties().Where(p => p.CanRead && p.Name == property).First().GetValue(this).ToString();
} }

@ -1,12 +1,8 @@
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization; using System.Xml.Serialization;
namespace AM2RLauncher.XML namespace AM2RLauncher.XML
{ {
/// <summary> /// <summary>
/// Class that handles how the mod settings are saved as XML. /// Class that handles how the mod settings are saved as XML.
/// </summary> /// </summary>

@ -1,9 +1,5 @@
using System; using System;
using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq;
using System.Runtime.Serialization;
using System.Web;
using System.Text; using System.Text;
namespace AM2RLauncher.XML namespace AM2RLauncher.XML

Loading…
Cancel
Save