Cleanup some more and fix todos

pull/32/head
Miepee 4 years ago
parent 8f6ef8212c
commit ea2fbebd8c

@ -3,6 +3,11 @@ using log4net;
using log4net.Config;
using System;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using GLib;
using Application = Eto.Forms.Application;
using FileInfo = System.IO.FileInfo;
namespace AM2RLauncher.Gtk;
@ -34,6 +39,20 @@ internal static class MainClass
// Configure logger
XmlConfigurator.Configure(new FileInfo(launcherDataPath + "/log4net.config"));
// Log distro and version (if it exists)
if (File.Exists("/etc/os-release"))
{
string osRelease = File.ReadAllText("/etc/os-release");
Regex lineRegex = new Regex(".*=.*");
var results = lineRegex.Matches(osRelease).Cast<Match>().ToList();
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("\"", "")));
}
else
log.Error("Couldn't determine the currently running distro!");
try
{
Application gtkLauncher = new Application(Eto.Platforms.Gtk);

@ -35,6 +35,10 @@ internal static class MainClass
// Configure logger
XmlConfigurator.Configure(new FileInfo(launcherDataPath + "/log4net.config"));
//Log Wine
if (Core.Core.IsThisRunningFromWine)
log.Info("Currently running from WINE!");
// Try catch in case it ever crashes before actually getting to the Eto application
try
{

@ -11,6 +11,7 @@ namespace AM2RLauncher
/// <summary>
/// Class that checks for Updates and then Updates the Launcher.
/// </summary>
//TODO: Mac support for autoupdater in general
public static class LauncherUpdater
{
// How often this was broken count: 6
@ -23,9 +24,8 @@ namespace AM2RLauncher
private static readonly string oldConfigPath = CrossPlatformOperations.CURRENTPATH + "/" + CrossPlatformOperations.LAUNCHERNAME + ".oldCfg";
/// <summary>The actual Path where the executable is stored, only used for updating.</summary>
//TODO: for mac, this reports the path of the mac runner, not the actual .app
private static readonly string updatePath = OS.IsWindows ? CrossPlatformOperations.CURRENTPATH : Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory);
//TODO: Mac support for this in general
private static readonly string updatePath = OS.IsWindows ? CrossPlatformOperations.CURRENTPATH
: (OS.IsLinux ? Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory) : Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory + "../../../"));
/// <summary>
/// Our log object, that handles logging the current execution to a file.

@ -88,7 +88,6 @@ namespace AM2RLauncher
// If profile supports Android and if we are NOT already creating an APK...
if (IsProfileIndexValid())
{
//TODO: clean this up later
var profile = profileList[profileIndex.Value];
if (profile.SupportsAndroid && profile.Installable && (apkButtonState == ApkButtonState.Create))
{
@ -103,18 +102,12 @@ namespace AM2RLauncher
case UpdateState.Play: apkButton.Enabled = true; apkButton.ToolTip = Language.Text.ApkButtonEnabledToolTip.Replace("$NAME", profileDropDown?.Items[profileDropDown.SelectedIndex]?.Text ?? ""); break;
case UpdateState.Playing: apkButton.Enabled = false; apkButton.ToolTip = Language.Text.ApkButtonDisabledToolTip; break;
}
}
else
{
apkButton.Enabled = false;
apkButton.ToolTip = Language.Text.ApkButtonDisabledToolTip;
return;
}
}
else // Otherwise, disable.
{
apkButton.Enabled = false;
apkButton.ToolTip = Language.Text.ApkButtonDisabledToolTip;
}
apkButton.Enabled = false;
apkButton.ToolTip = Language.Text.ApkButtonDisabledToolTip;
}
/// <summary>

@ -117,29 +117,6 @@ namespace AM2RLauncher
Log.Info("Current Platform-ID is: " + Platform.ID);
Log.Info("Current OS is: " + OS.Name);
//Log Wine
//TODO: move this to WPF project?
if (isThisRunningFromWine)
{
Log.Info("Currently running from WINE!");
}
// Log distro and version (if it exists)
//TODO: move this to GTK project?
else if (OS.IsLinux)
{
if (File.Exists("/etc/os-release"))
{
string osRelease = File.ReadAllText("/etc/os-release");
Regex lineRegex = new Regex(".*=.*");
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("\"", "")));
}
else
Log.Error("Couldn't determine the currently running distro!");
}
// Set the Current Directory to the path the Launcher is located. Fixes some relative path issues.
Environment.CurrentDirectory = CrossPlatformOperations.CURRENTPATH;
Log.Info("Set Launcher CWD to " + Environment.CurrentDirectory);
@ -428,8 +405,7 @@ namespace AM2RLauncher
changelogWebView = new WebView { Url = changelogUri };
//TODO: what happens if one would make this on unix instead of linux?
if (OS.IsLinux && !isInternetThere)
if (OS.IsUnix && !isInternetThere)
changelogWebView = new WebView();
changelogNoConnectionLabel = new Label
@ -456,8 +432,7 @@ namespace AM2RLauncher
newsUri = new Uri("https://am2r-community-developers.github.io/DistributionCenter/news.html");
newsWebView = new WebView { Url = newsUri };
//TODO: see todo above
if (OS.IsLinux && !isInternetThere)
if (OS.IsUnix && !isInternetThere)
newsWebView = new WebView();
newsNoConnectionLabel = new Label
@ -480,8 +455,7 @@ namespace AM2RLauncher
}
};
//TODO: see todo above
if (OS.IsLinux && !isInternetThere)
if (OS.IsUnix && !isInternetThere)
{
changelogPage.Content = new TableLayout
{
@ -828,7 +802,7 @@ namespace AM2RLauncher
if (OS.IsLinux)
customEnvVarTextBox.LostFocus += CustomEnvVarTextBoxLostFocus;
//TODO: These don't work properly on mac? Maybe on other platforms too?
//TODO: Retest if these now work on mac
newsWebView.DocumentLoaded += NewsWebViewDocumentLoaded;
changelogWebView.DocumentLoaded += ChangelogWebViewDocumentLoaded;

Loading…
Cancel
Save