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 log4net;
using System;
using log4net.Config;
using System;
using System.IO;
using System.Reflection;
@ -22,19 +22,18 @@ namespace AM2RLauncher.Gtk
[STAThread]
public static void Main(string[] args)
{
string launcherDataPath = GenerateCurrentPath();
string localAM2RPath = Environment.GetEnvironmentVariable("HOME") + "/.local/share/AM2RLauncher";
// Make sure first, ~/.local/share exists
if (!Directory.Exists(localAM2RPath))
Directory.CreateDirectory(localAM2RPath);
// Make sure first, ~/.local/share/AM2RLauncher exists
if (!Directory.Exists(launcherDataPath))
Directory.CreateDirectory(launcherDataPath);
// Now, see if log4netConfig exists, if not write it again.
if (!File.Exists(localAM2RPath + "/log4net.config"))
File.WriteAllText(localAM2RPath + "/log4net.config", Properties.Resources.log4netContents);
if (!File.Exists(launcherDataPath + "/log4net.config"))
File.WriteAllText(launcherDataPath + "/log4net.config", Properties.Resources.log4netContents.Replace("${DATADIR}", launcherDataPath));
// Configure logger
XmlConfigurator.Configure(new FileInfo(localAM2RPath + "/log4net.config"));
XmlConfigurator.Configure(new FileInfo(launcherDataPath + "/log4net.config"));
try
{
@ -43,7 +42,7 @@ namespace AM2RLauncher.Gtk
GTKLauncher.UnhandledException += GTKLauncher_UnhandledException;
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());
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());
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.
// 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.
[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.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
@ -67,14 +67,14 @@ namespace AM2RLauncher.Gtk.Properties {
/// <appender-ref ref="file" />
/// </root>
/// <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" />
/// <rollingStyle value="Once" />
/// <maxSizeRollBackups value="7" />
/// <maximumFileSize value="3MB" />
/// <staticLogFileName value="true" />
/// <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>
internal static string log4netContents {
get {

@ -124,7 +124,7 @@
&lt;appender-ref ref="file" /&gt;
&lt;/root&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;rollingStyle value="Once" /&gt;
&lt;maxSizeRollBackups value="7" /&gt;

@ -1,14 +1,14 @@
using Eto.Forms;
using System;
using log4net;
using log4net.Config;
using System;
using System.IO;
using System.Reflection;
namespace AM2RLauncher.Wpf
{
/// <summary>
/// The main class for the GTK project.
/// The main class for the WinForms project.
/// </summary>
class MainClass
{
@ -17,13 +17,13 @@ namespace AM2RLauncher.Wpf
/// </summary>
private static readonly ILog log = LogManager.GetLogger(typeof(MainForm));
/// <summary>
/// The main method for the GTK project.
/// The main method for the WinForms project.
/// </summary>
[STAThread]
public static void Main(string[] args)
{
// 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
@ -33,7 +33,7 @@ namespace AM2RLauncher.Wpf
WinLauncher.UnhandledException += WinLauncher_UnhandledException;
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());
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)
{
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
# Visual Studio Version 16
VisualStudioVersion = 16.0.31005.135
# Visual Studio Version 17
VisualStudioVersion = 17.0.31912.275
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AM2RLauncher", "AM2RLauncher\AM2RLauncher.csproj", "{9B67055C-5AEF-4F83-AFE0-38E600183C9F}"
EndProject

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

@ -1,21 +1,19 @@
using Eto;
using Eto.Forms;
using log4net;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Reflection;
using System.Text.RegularExpressions;
using log4net;
namespace AM2RLauncher
{
/// <summary>
/// Class that does Operations that work cross-platform.
/// </summary>
class CrossPlatformOperations
public class CrossPlatformOperations
{
/// <summary>
/// The logger for <see cref="MainForm"/>, used to write any caught exceptions.
@ -25,17 +23,27 @@ namespace AM2RLauncher
/// <summary>
/// Gets the current platform.
/// </summary>
readonly private static Platform currentPlatform = Platform.Instance;
private static readonly Platform currentPlatform = Platform.Instance;
/// <summary>
/// Current Path where the Launcher is located. For more info, check <see cref="GenerateCurrentPath"/>.
/// </summary>
static readonly public string CURRENTPATH = GenerateCurrentPath();
public static readonly string CURRENTPATH = GenerateCurrentPath();
/// <summary>
/// Name of the Launcher executable.
/// </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>
/// Generates the mirror list, depending on the current Platform.
@ -82,9 +90,8 @@ namespace AM2RLauncher
if (currentPlatform.IsGtk)
{
// Config for nix systems will be saved in XDG_CONFIG_HOME/AM2RLauncher (or if empty, ~/.config)
string homePath = Environment.GetEnvironmentVariable("HOME");
string xdgConfigHome = Environment.GetEnvironmentVariable("XDG_CONFIG_HOME");
string launcherConfigPath = (String.IsNullOrWhiteSpace(xdgConfigHome) ? (homePath + "/.config") : xdgConfigHome) + "/AM2RLauncher";
string homePath = NIXHOME;
string launcherConfigPath = (String.IsNullOrWhiteSpace(NIXXDGCONFIG) ? (homePath + "/.config") : NIXXDGCONFIG) + "/AM2RLauncher";
string launcherConfigFilePath = launcherConfigPath + "/config.xml";
XML.LauncherConfigXML launcherConfig = new XML.LauncherConfigXML();
@ -130,9 +137,8 @@ namespace AM2RLauncher
else if (currentPlatform.IsGtk)
{
// Config for nix systems will be saved in XDG_CONFIG_HOME/AM2RLauncher (or if empty, ~/.config)
string homePath = Environment.GetEnvironmentVariable("HOME");
string xdgConfigHome = Environment.GetEnvironmentVariable("XDG_CONFIG_HOME");
string launcherConfigPath = (String.IsNullOrWhiteSpace(xdgConfigHome) ? (homePath + "/.config") : xdgConfigHome) + "/AM2RLauncher";
string homePath = NIXHOME;
string launcherConfigPath = (String.IsNullOrWhiteSpace(NIXXDGCONFIG) ? (homePath + "/.config") : NIXXDGCONFIG) + "/AM2RLauncher";
string launcherConfigFilePath = launcherConfigPath + "/config.xml";
XML.LauncherConfigXML launcherConfig = new XML.LauncherConfigXML();
@ -170,7 +176,7 @@ namespace AM2RLauncher
MatchCollection oldMatch = settingRegex.Matches(oldConfigText);
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);
File.WriteAllText(newConfigPath, newConfigText);
@ -179,9 +185,8 @@ namespace AM2RLauncher
else if (currentPlatform.IsGtk)
{
// Config for nix systems will be saved in XDG_CONFIG_HOME/AM2RLauncher (or if empty, ~/.config)
string homePath = Environment.GetEnvironmentVariable("HOME");
string xdgConfigHome = Environment.GetEnvironmentVariable("XDG_CONFIG_HOME");
string launcherConfigPath = (String.IsNullOrWhiteSpace(xdgConfigHome) ? (homePath + "/.config") : xdgConfigHome) + "/AM2RLauncher";
string homePath = NIXHOME;
string launcherConfigPath = (String.IsNullOrWhiteSpace(NIXXDGCONFIG) ? (homePath + "/.config") : NIXXDGCONFIG) + "/AM2RLauncher";
string launcherConfigFilePath = launcherConfigPath + "/config.xml";
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...
// And on Nix systems, we want to replace ~ with its corresponding env var
string realPath = currentPlatform.IsWinForms ? Environment.ExpandEnvironmentVariables(path).Replace("/", "\\")
: path.Replace("~", Environment.GetEnvironmentVariable("HOME"));
: path.Replace("~", NIXHOME);
if (!Directory.Exists(realPath))
{
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...
// And on nix systems, we want to replace ~ with its corresponding env var
string realPath = currentPlatform.IsWinForms ? Environment.ExpandEnvironmentVariables(path).Replace("/", "\\")
: path.Replace("~", Environment.GetEnvironmentVariable("HOME"));
: path.Replace("~", NIXHOME);
if (!File.Exists(realPath))
{
log.Error(realPath + "did not exist, operation to open its folder was cancelled!");
@ -273,16 +278,16 @@ namespace AM2RLauncher
arguments = "-version";
}
ProcessStartInfo javaStart = new ProcessStartInfo();
javaStart.FileName = process;
javaStart.Arguments = arguments;
javaStart.UseShellExecute = false;
javaStart.CreateNoWindow = true;
ProcessStartInfo javaStart = new ProcessStartInfo
{
FileName = process,
Arguments = arguments,
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
try
@ -297,7 +302,6 @@ namespace AM2RLauncher
}
return java.ExitCode == 0;
}
/// <summary>
@ -309,16 +313,16 @@ namespace AM2RLauncher
string process = "xdelta3";
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
{
@ -347,7 +351,7 @@ namespace AM2RLauncher
if (original == 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 + "/", "") + "\"";
if (currentPlatform.IsWinForms)
@ -438,7 +442,7 @@ namespace AM2RLauncher
if (string.IsNullOrWhiteSpace(xdgDataHome))
{
log.Info("Using default Linux CurrentPath.");
xdgDataHome = Environment.GetEnvironmentVariable("HOME") + "/.local/share";
xdgDataHome = NIXHOME + "/.local/share";
}
// Add AM2RLauncher to the end of the dataPath

@ -1,16 +1,11 @@
using Eto;
using AM2RLauncher.Helpers;
using Eto;
using Eto.Forms;
using log4net;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Net;
using System.Reflection;
using System.Text;
using log4net;
using AM2RLauncher.Helpers;
namespace AM2RLauncher
{
@ -45,8 +40,6 @@ namespace AM2RLauncher
{
log.Info("Running update check...");
string version = VERSION.Replace(".", "");
// Update section
// Clean old files that have been left
@ -158,7 +151,7 @@ namespace AM2RLauncher
log.Info("File successfully downloaded.");
}
}
catch(UnauthorizedAccessException)
catch (UnauthorizedAccessException)
{
log.Error("UnauthorizedAccessException caught! Displaying MessageBox.");
MessageBox.Show(Language.Text.UnauthorizedAccessMessage);
@ -174,7 +167,7 @@ namespace AM2RLauncher
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);
}
// 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
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())
{

@ -1,74 +1,74 @@
using Eto.Forms;
using Eto.Drawing;
using Eto.Drawing;
using Eto.Forms;
using Pablo.Controls;
namespace AM2RLauncher
{
/// <summary>
/// Extension of <see cref="CustomButton"/> that allows for advanced color settings.
/// </summary>
class ColorButton : CustomButton
{
/// <summary>The <see cref="Color"/> to draw the background with when <see cref="CustomButton.Hover"/> is true.</summary>
public Color BackgroundColorHover { get; set; }
/// <summary>
/// Extension of <see cref="CustomButton"/> that allows for advanced color settings.
/// </summary>
class ColorButton : CustomButton
{
/// <summary>The <see cref="Color"/> to draw the background with when <see cref="CustomButton.Hover"/> is true.</summary>
public Color BackgroundColorHover { get; set; }
/// <summary>The <see cref="Font"/> to use for text drawing.</summary>
public Font Font { get; set; }
/// <summary>The <see cref="Font"/> to use for text drawing.</summary>
public Font Font { get; set; }
/// <summary>The <see cref="Color"/> with which to draw the frame.</summary>
public Color FrameColor { get; set; }
/// <summary>The <see cref="Color"/> with which to draw the frame.</summary>
public Color FrameColor { get; set; }
/// <summary>The <see cref="Color"/> with which to draw the frame when it is disabled.</summary>
public Color FrameColorDisabled { get; set; }
/// <summary>The <see cref="Color"/> with which to draw the frame when it is disabled.</summary>
public Color FrameColorDisabled { get; set; }
/// <summary>The text to be drawn.</summary>
public string Text { get; set; }
/// <summary>The text to be drawn.</summary>
public string Text { get; set; }
/// <summary>The <see cref="Color"/> with which to draw the <see cref="Text"/>.</summary>
public Color TextColor { get; set; }
/// <summary>The <see cref="Color"/> with which to draw the <see cref="Text"/>.</summary>
public Color TextColor { get; set; }
/// <summary>The <see cref="Color"/> with which to draw the <see cref="Text"/> when it is disabled.</summary>
public Color TextColorDisabled { get; set; }
/// <summary>The <see cref="Color"/> with which to draw the <see cref="Text"/> when it is disabled.</summary>
public Color TextColorDisabled { get; set; }
/// <summary>
/// Creates a <see cref="ColorButton"/> with a default set of attributes.
/// </summary>
public ColorButton()
/// <summary>
/// Creates a <see cref="ColorButton"/> with a default set of attributes.
/// </summary>
public ColorButton()
{
BackgroundColorHover = Colors.White;
Font = new Font(SystemFont.Default, 12);
FrameColor = Colors.White;
FrameColorDisabled = Colors.Gray;
Text = "";
TextColor = Colors.Black;
TextColorDisabled = Colors.Gray;
}
BackgroundColorHover = Colors.White;
Font = new Font(SystemFont.Default, 12);
FrameColor = Colors.White;
FrameColorDisabled = Colors.Gray;
Text = "";
TextColor = Colors.Black;
TextColorDisabled = Colors.Gray;
}
/// <summary>
/// Event raised to draw this control.
/// </summary>
/// <param name="pe"></param>
protected override void OnPaint(PaintEventArgs pe)
/// <summary>
/// Event raised to draw this control.
/// </summary>
/// <param name="pe"></param>
protected override void OnPaint(PaintEventArgs pe)
{
// Define draw bounds
Rectangle drawBounds = new Rectangle(2, 2, Width - 5, Height - 5);
// Define draw bounds
Rectangle drawBounds = new Rectangle(2, 2, Width - 5, Height - 5);
// Draw background
pe.Graphics.FillRectangle(Hover ? BackgroundColorHover : BackgroundColor, drawBounds);
// Draw background
pe.Graphics.FillRectangle(Hover ? BackgroundColorHover : BackgroundColor, drawBounds);
// Draw frame
Pen framePen = new Pen(Enabled ? FrameColor : FrameColorDisabled, 1);
pe.Graphics.DrawRectangle(framePen, drawBounds);
// Draw frame
Pen framePen = new Pen(Enabled ? FrameColor : FrameColorDisabled, 1);
pe.Graphics.DrawRectangle(framePen, drawBounds);
SolidBrush brush = new SolidBrush(Enabled ? TextColor : TextColorDisabled);
SolidBrush brush = new SolidBrush(Enabled ? TextColor : TextColorDisabled);
// Get text measurements
SizeF stringSize = pe.Graphics.MeasureString(Font, Text);
int textWidth = (int)stringSize.Width;
int textHeight = (int)stringSize.Height;
// Get text measurements
SizeF stringSize = pe.Graphics.MeasureString(Font, Text);
int textWidth = (int)stringSize.Width;
int textHeight = (int)stringSize.Height;
// Draw text
pe.Graphics.DrawText(Font, brush, new PointF(Width / 2 - textWidth / 2, Height / 2 - textHeight / 2), Text);
}
// Draw 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.Drawing;
using System;
namespace Pablo.Controls
{
/// <summary>
/// A custom button implementation for advanced drawing and events.
/// Originally written by cwensley (https://gist.github.com/cwensley/95000998e37acd93e830),
/// modified by Lojemiru and Miepee for use in the AM2RLauncher.
/// </summary>
public class CustomButton : Drawable
{
/// <summary>Whether or not this <see cref="CustomButton"/> is being pressed.</summary>
bool pressed;
/// <summary>Whether or not the mouse is hovering over this <see cref="CustomButton"/>.</summary>
bool hover;
/// <summary></summary>
bool mouseDown;
/// <summary>Gets or sets the disabled color of this control.</summary>
public static Color DisabledColor = Color.FromGrayscale(0.4f, 0.3f);
/// <summary>Gets or sets the color of this control.</summary>
public static Color EnabledColor = Colors.Black;
/// <summary>Gets or sets whether or not this control is enabled.</summary>
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
/// <summary>
/// A custom button implementation for advanced drawing and events.
/// Originally written by cwensley (https://gist.github.com/cwensley/95000998e37acd93e830),
/// modified by Lojemiru and Miepee for use in the AM2RLauncher.
/// </summary>
public class CustomButton : Drawable
{
/// <summary>Whether or not this <see cref="CustomButton"/> is being pressed.</summary>
bool pressed;
/// <summary>Whether or not the mouse is hovering over this <see cref="CustomButton"/>.</summary>
bool hover;
/// <summary></summary>
bool mouseDown;
/// <summary>Gets or sets the disabled color of this control.</summary>
public static Color DisabledColor = Color.FromGrayscale(0.4f, 0.3f);
/// <summary>Gets or sets the color of this control.</summary>
public static Color EnabledColor = Colors.Black;
/// <summary>Gets or sets whether or not this control is enabled.</summary>
public override bool Enabled
{
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>
public Color DrawColor
{
get { return Enabled ? EnabledColor : DisabledColor; }
}
/// <summary>Gets or sets whether or not this control should act as a toggle.</summary>
public bool Toggle { get; set; }
/// <summary>Gets or sets whether or not this control is persistent.</summary>
public bool Persistent { get; set; }
public event EventHandler<EventArgs> Click;
/// <summary>
/// Event raised when this control is clicked.
/// </summary>
/// <param name="e"></param>
protected virtual void OnClick(EventArgs e)
{
if (Click != null)
Click(this, e);
}
/// <summary>Default constructor. Sets <see cref="Enabled"/> to true.</summary>
public CustomButton() { Enabled = true; }
/// <summary>Event raised when this control is resized.</summary>
/// <param name="e"></param>
protected override void OnSizeChanged(EventArgs e)
{
base.OnSizeChanged(e);
if (Loaded)
Invalidate();
}
/// <summary>
/// Event raised when the mouse is pressed down over this control's bounding box.
/// </summary>
/// <param name="e"></param>
protected override void OnMouseDown(MouseEventArgs e)
{
base.OnMouseDown(e);
if (Enabled)
{
mouseDown = true;
Invalidate();
}
}
/// <summary>
/// Event raised when the mouse enters this control's bounding box.
/// </summary>
/// <param name="e"></param>
protected override void OnMouseEnter(MouseEventArgs e)
{
Cursor = new Cursor(CursorType.Pointer);
base.OnMouseEnter(e);
hover = true;
Invalidate();
}
/// <summary>
/// Event raised when the mouse leaves this control's bounding box.
/// </summary>
/// <param name="e"></param>
protected override void OnMouseLeave(MouseEventArgs e)
{
Cursor = new Cursor(CursorType.Default);
base.OnMouseLeave(e);
hover = false;
Invalidate();
}
/// <summary>
/// Event raised when the mouse is released over this control's bounding box.
/// </summary>
/// <param name="e"></param>
protected override void OnMouseUp(MouseEventArgs e)
{
base.OnMouseUp(e);
var rect = new Rectangle(this.Size);
if (mouseDown && rect.Contains((Point)e.Location))
{
if (Toggle)
pressed = !pressed;
else if (Persistent)
pressed = true;
else
pressed = false;
mouseDown = false;
this.Invalidate();
if (Enabled)
OnClick(EventArgs.Empty);
}
else
{
mouseDown = false;
this.Invalidate();
}
}
/// <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);
}
}
/// <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; }
}
/// <summary>Gets either the <see cref="EnabledColor"/> or <see cref="DisabledColor"/> dependent on <see cref="Enabled"/>.</summary>
public Color DrawColor
{
get { return Enabled ? EnabledColor : DisabledColor; }
}
/// <summary>Gets or sets whether or not this control should act as a toggle.</summary>
public bool Toggle { get; set; }
/// <summary>Gets or sets whether or not this control is persistent.</summary>
public bool Persistent { get; set; }
public event EventHandler<EventArgs> Click;
/// <summary>
/// Event raised when this control is clicked.
/// </summary>
/// <param name="e"></param>
protected virtual void OnClick(EventArgs e)
{
if (Click != null)
Click(this, e);
}
/// <summary>Default constructor. Sets <see cref="Enabled"/> to true.</summary>
public CustomButton() { Enabled = true; }
/// <summary>Event raised when this control is resized.</summary>
/// <param name="e"></param>
protected override void OnSizeChanged(EventArgs e)
{
base.OnSizeChanged(e);
if (Loaded)
Invalidate();
}
/// <summary>
/// Event raised when the mouse is pressed down over this control's bounding box.
/// </summary>
/// <param name="e"></param>
protected override void OnMouseDown(MouseEventArgs e)
{
base.OnMouseDown(e);
if (Enabled)
{
mouseDown = true;
Invalidate();
}
}
/// <summary>
/// Event raised when the mouse enters this control's bounding box.
/// </summary>
/// <param name="e"></param>
protected override void OnMouseEnter(MouseEventArgs e)
{
Cursor = new Cursor(CursorType.Pointer);
base.OnMouseEnter(e);
hover = true;
Invalidate();
}
/// <summary>
/// Event raised when the mouse leaves this control's bounding box.
/// </summary>
/// <param name="e"></param>
protected override void OnMouseLeave(MouseEventArgs e)
{
Cursor = new Cursor(CursorType.Default);
base.OnMouseLeave(e);
hover = false;
Invalidate();
}
/// <summary>
/// Event raised when the mouse is released over this control's bounding box.
/// </summary>
/// <param name="e"></param>
protected override void OnMouseUp(MouseEventArgs e)
{
base.OnMouseUp(e);
var rect = new Rectangle(this.Size);
if (mouseDown && rect.Contains((Point)e.Location))
{
if (Toggle)
pressed = !pressed;
else if (Persistent)
pressed = true;
else
pressed = false;
mouseDown = false;
this.Invalidate();
if (Enabled)
OnClick(EventArgs.Empty);
}
else
{
mouseDown = false;
this.Invalidate();
}
}
/// <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 System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Security.Cryptography;
using System.Text;
namespace AM2RLauncher.Helpers
{

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

@ -1,26 +1,18 @@
using Eto;
using Eto.Drawing;
using AM2RLauncher.Helpers;
using AM2RLauncher.XML;
using Eto;
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.Handlers;
using System;
using System.ComponentModel;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Runtime.InteropServices;
using LibGit2Sharp.Handlers;
using System.Text.RegularExpressions;
using System.Threading;
using System.ComponentModel;
using System.Net;
using System.IO.Compression;
using AM2RLauncher.XML;
using AM2RLauncher.Helpers;
using System.Threading.Tasks;
namespace AM2RLauncher
{
@ -225,7 +217,7 @@ namespace AM2RLauncher
}
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);
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]);
}
catch(Exception ex)
catch (Exception ex)
{
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);
@ -578,7 +570,7 @@ namespace AM2RLauncher
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);
HelperMethods.DeleteDirectory(modsDir + "/" + extractedName);
return;
@ -800,7 +792,7 @@ namespace AM2RLauncher
// Not sure why the dropdown menu needs this hack, but the textBox does not.
if (Platform.IsWinForms)
mirrorDropDown.TextColor = mirrorDropDown.Enabled ? colGreen : colInactive;
mirrorLabel.TextColor = !enabled ? colGreen : colInactive;
mirrorLabel.TextColor = !enabled ? colGreen : colInactive;
// Create warning dialog when enabling
if (enabled)
@ -824,7 +816,7 @@ namespace AM2RLauncher
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!!!
if (updateState == UpdateState.Downloading) return;
@ -1053,7 +1045,7 @@ namespace AM2RLauncher
}
else
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)

@ -1,21 +1,16 @@
using System;
using System.Collections.Generic;
using System.Text;
using AM2RLauncher.Helpers;
using AM2RLauncher.XML;
using Eto;
using Eto.Drawing;
using Eto.Forms;
using System.Threading;
using LibGit2Sharp;
using System;
using System.Diagnostics;
using System.IO;
using System.IO.Compression;
using Eto;
using System.Diagnostics;
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.Threading;
namespace AM2RLauncher
{
@ -403,7 +398,7 @@ namespace AM2RLauncher
// Clean files
Directory.Delete(profilePath + "/AM2R.AppDir", true);
Directory.Delete(assetsPath, true);
File.Delete(profilePath + "/" +exe);
File.Delete(profilePath + "/" + exe);
if (File.Exists(profilePath + "/AM2R.AppImage")) File.Delete(profilePath + "/AM2R.AppImage");
File.Move(profilePath + "/" + "AM2R-x86_64.AppImage", profilePath + "/AM2R.AppImage");
}
@ -500,7 +495,7 @@ namespace AM2RLauncher
{
FileName = proc,
// 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,
UseShellExecute = false,
CreateNoWindow = true
@ -646,7 +641,7 @@ namespace AM2RLauncher
// These are used on both windows and linux for game logging
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");
string date = string.Join("-", DateTime.Now.ToString().Split(Path.GetInvalidFileNameChars(), StringSplitOptions.RemoveEmptyEntries));
@ -704,7 +699,7 @@ namespace AM2RLauncher
{
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
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.IndexOf(' ') >= 0)
valueSubstringLength = envVars.IndexOf(' ')+1;
valueSubstringLength = envVars.IndexOf(' ') + 1;
else
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
{
int secondQuoteIndex = envVars.IndexOf('"', envVars.IndexOf('"')+1);
int secondQuoteIndex = envVars.IndexOf('"', envVars.IndexOf('"') + 1);
if (envVars.IndexOf(' ', secondQuoteIndex) >= 0)
valueSubstringLength = envVars.IndexOf(' ', secondQuoteIndex)+1;
valueSubstringLength = envVars.IndexOf(' ', secondQuoteIndex) + 1;
else
valueSubstringLength = envVars.Length;
}
@ -746,7 +741,7 @@ namespace AM2RLauncher
log.Info("CWD of Profile is " + startInfo.WorkingDirectory);
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 + "\"");
}
@ -1048,9 +1043,9 @@ namespace AM2RLauncher
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.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.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;
}
playButton.Text = GetPlayButtonText();

@ -1,17 +1,16 @@
using Eto.Drawing;
using AM2RLauncher.XML;
using Eto.Drawing;
using Eto.Forms;
using log4net;
using Pablo.Controls;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using Pablo.Controls;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Threading;
using System.Globalization;
using AM2RLauncher.XML;
using log4net;
using log4net.Config;
using System.Text.RegularExpressions;
using System.Threading;
namespace AM2RLauncher
{
@ -143,7 +142,7 @@ namespace AM2RLauncher
var results = lineRegex.Matches(osRelease).Cast<Match>();
var version = results.FirstOrDefault(x => x.Value.Contains("VERSION"));
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.
@ -626,7 +625,7 @@ namespace AM2RLauncher
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;
mirrorDropDown.SelectedIndex = mirrorIndex;
mirrorDropDown.SelectedIndex = mirrorIndex;
currentMirror = mirrorList[mirrorDropDown.SelectedIndex];

@ -1,6 +1,5 @@
using Eto;
using System;
using System.Collections.Generic;
using System.Linq;
namespace AM2RLauncher

Before

Width:  |  Height:  |  Size: 101 KiB

After

Width:  |  Height:  |  Size: 101 KiB

@ -1,10 +1,6 @@
using System;
using System.Reflection;
using System.Collections.Generic;
using System.Text;
using System.Xml.Serialization;
using System.Linq;
using System.ComponentModel;
using System.Xml.Serialization;
namespace AM2RLauncher.XML
{

@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;
namespace AM2RLauncher.XML

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

Loading…
Cancel
Save