Nuke environment variable feature, put more matrix text

pull/32/head
Miepee 4 years ago
parent aa56bca48a
commit 9b8fb17733

@ -141,12 +141,6 @@ namespace AM2RLauncher.Language {
}
}
public static string CustomEnvVarLabel {
get {
return ResourceManager.GetString("CustomEnvVarLabel", resourceCulture);
}
}
public static string CustomMirrorCheck {
get {
return ResourceManager.GetString("CustomMirrorCheck", resourceCulture);

@ -165,9 +165,6 @@
<data name="CurrentProfile" xml:space="preserve">
<value>Aktuelles Profil:</value>
</data>
<data name="CustomEnvVarLabel" xml:space="preserve">
<value>Benutzerdefinierte Spielumgebungsvariablen eingeben:</value>
</data>
<data name="CustomMirrorCheck" xml:space="preserve">
<value>Nutze benutzerdefinierten Spiegelserver</value>
</data>

@ -165,9 +165,6 @@
<data name="CurrentProfile" xml:space="preserve">
<value>Perfil actual:</value>
</data>
<data name="CustomEnvVarLabel" xml:space="preserve">
<value>Introducir variables personalizadas del entorno de juego:</value>
</data>
<data name="CustomMirrorCheck" xml:space="preserve">
<value>Utilizar enlace de descarga personalizado</value>
</data>
@ -386,4 +383,7 @@ Procede con cautela.</value>
<data name="ArchiveNotesMods" xml:space="preserve">
<value>Esta es una versión archivada de un Mod instalado anteriormente. No puede ser reinstalada y se eliminará automáticamente si se borran sus archivos de juego.</value>
</data>
<data name="MatrixToolTip" xml:space="preserve">
<value>El Espacio Oficial de Matrix para AM2R</value>
</data>
</root>

@ -167,9 +167,6 @@ ce profil !</value>
<data name="CurrentProfile" xml:space="preserve">
<value>Profil actuel :</value>
</data>
<data name="CustomEnvVarLabel" xml:space="preserve">
<value>Entrez des variables d'environnement de jeu personnalisées :</value>
</data>
<data name="CustomMirrorCheck" xml:space="preserve">
<value>Utiliser un mirroir personnalisé</value>
</data>
@ -388,4 +385,7 @@ Soyez prudent.</value>
<data name="ArchiveNotesMods" xml:space="preserve">
<value>Il s'agit d'une archive d'un mod précédemment installé. Il ne peut pas être réinstallé et se supprimera de lui-même si ses fichiers de jeu sont supprimés.</value>
</data>
<data name="MatrixToolTip" xml:space="preserve">
<value>Le Matrix Space AM2R officiel</value>
</data>
</root>

@ -165,9 +165,6 @@
<data name="CurrentProfile" xml:space="preserve">
<value>Profilo corrente:</value>
</data>
<data name="CustomEnvVarLabel" xml:space="preserve">
<value>Inserisci variabili personalizzate dell'ambiente di gioco:</value>
</data>
<data name="CustomMirrorCheck" xml:space="preserve">
<value>Usa un mirror di download personalizzato.</value>
</data>
@ -386,4 +383,7 @@ Procedi con cautela.</value>
<data name="ArchiveNotesMods" xml:space="preserve">
<value>Questo è un archivio di una Mod precedentemente installata. Non può essere re-installata e si rimuoverà da sola se i suoi file di gioco vengono rimossi.</value>
</data>
<data name="MatrixToolTip" xml:space="preserve">
<value>La Matrix Space ufficiale di AM2R</value>
</data>
</root>

@ -165,9 +165,6 @@
<data name="CurrentProfile" xml:space="preserve">
<value>現在のプロファイル:</value>
</data>
<data name="CustomEnvVarLabel" xml:space="preserve">
<value>ゲームのカスタム環境変数の入力:</value>
</data>
<data name="CustomMirrorCheck" xml:space="preserve">
<value>ダウンロードするサイトを指定</value>
</data>

@ -165,9 +165,6 @@
<data name="CurrentProfile" xml:space="preserve">
<value>Perfil atual:</value>
</data>
<data name="CustomEnvVarLabel" xml:space="preserve">
<value>Insira variáveis de ambiente customizadas para o jogo:</value>
</data>
<data name="CustomMirrorCheck" xml:space="preserve">
<value>Usar link de download customizado</value>
</data>

@ -165,9 +165,6 @@
<data name="CurrentProfile" xml:space="preserve">
<value>Current profile:</value>
</data>
<data name="CustomEnvVarLabel" xml:space="preserve">
<value>Enter custom game environment variables:</value>
</data>
<data name="CustomMirrorCheck" xml:space="preserve">
<value>Use custom download mirror</value>
</data>

@ -165,9 +165,6 @@
<data name="CurrentProfile" xml:space="preserve">
<value>Текущий профиль:</value>
</data>
<data name="CustomEnvVarLabel" xml:space="preserve">
<value>Введите пользовательские переменные игры:</value>
</data>
<data name="CustomMirrorCheck" xml:space="preserve">
<value>Использовать пользовательское зеркало для загрузки</value>
</data>

@ -165,9 +165,6 @@
<data name="CurrentProfile" xml:space="preserve">
<value>当前游戏实例:</value>
</data>
<data name="CustomEnvVarLabel" xml:space="preserve">
<value>输入自定义的游戏环境变量:</value>
</data>
<data name="CustomMirrorCheck" xml:space="preserve">
<value>使用自定义的下载镜像</value>
</data>
@ -388,4 +385,7 @@
<data name="ArchiveNotesMods" xml:space="preserve">
<value>此为以前安装过的 Mod 的归档,无法重新安装,若对应的游戏文件被删除,该归档也会自行删除。</value>
</data>
<data name="MatrixToolTip" xml:space="preserve">
<value>AM2R 官方 Matrix 空间</value>
</data>
</root>

@ -136,7 +136,7 @@ public partial class MainForm : Form
{
//Only pull if Patchdata is cloned and user wants it updated
LoadProfilesAndAdjustLists();
if (!Profile.IsPatchDataCloned() || !(bool)autoUpdateAM2RCheck.Checked)
if (!Profile.IsPatchDataCloned() || !autoUpdateAM2RCheck.Checked.Value)
return;
SetPlayButtonState(PlayButtonState.Downloading);
@ -427,13 +427,12 @@ public partial class MainForm : Form
trayIndicator.Visible = true;
WindowState windowStateBeforeLaunching = WindowState;
Minimize();
string envVarText = customEnvVarTextBox?.Text;
bool createDebugLogs = profileDebugLogCheck.Checked.Value;
try
{
await Task.Run(() => Profile.RunGame(profile, createDebugLogs, envVarText));
await Task.Run(() => Profile.RunGame(profile, createDebugLogs));
}
catch
{
@ -559,14 +558,14 @@ public partial class MainForm : Form
private void AutoUpdateAM2RCheckChanged(object sender, EventArgs e)
{
log.Info("Auto Update AM2R has been set to " + autoUpdateAM2RCheck.Checked + ".");
WriteToConfig("AutoUpdateAM2R", (bool)autoUpdateAM2RCheck.Checked);
WriteToConfig("AutoUpdateAM2R", autoUpdateAM2RCheck.Checked.Value);
}
/// <summary>Gets called when <see cref="autoUpdateLauncherCheck"/> gets clicked and writes its new value to the config.</summary>
private void AutoUpdateLauncherCheckChanged(object sender, EventArgs e)
{
log.Info("Auto Update Launcher has been set to " + autoUpdateAM2RCheck.Checked + ".");
WriteToConfig("AutoUpdateLauncher", (bool)autoUpdateAM2RCheck.Checked);
WriteToConfig("AutoUpdateLauncher", autoUpdateAM2RCheck.Checked.Value);
}
/// <summary>Gets called when <see cref="hqMusicPCCheck"/> gets clicked and writes its new value to the config.</summary>
@ -624,12 +623,12 @@ public partial class MainForm : Form
private void CustomMirrorCheckChanged(object sender, EventArgs e)
{
log.Info("Use Custom Mirror option has been set to " + customMirrorCheck.Checked + ".");
WriteToConfig("CustomMirrorEnabled", (bool)customMirrorCheck.Checked);
WriteToConfig("CustomMirrorEnabled", customMirrorCheck.Checked.Value);
EnableMirrorControlsAccordingly();
// Create warning dialog when enabling
if ((bool)customMirrorCheck.Checked)
if (customMirrorCheck.Checked.Value)
{
MessageBox.Show(this, Text.WarningWindowText, Text.WarningWindowTitle, MessageBoxType.Warning);
currentMirror = customMirrorTextBox.Text;
@ -671,16 +670,7 @@ public partial class MainForm : Form
log.Info("Custom Mirror has been set to " + currentMirror + ".");
}
/// <summary>
/// If <see cref="customEnvVarTextBox"/> has lost focus, we write its text to the config.
/// </summary>
private void CustomEnvVarTextBoxLostFocus(object sender, EventArgs e)
{
log.Info("Custom Environment variables have been set to \"" + customEnvVarTextBox.Text + "\".");
WriteToConfig("CustomEnvVar", customEnvVarTextBox.Text);
}
#endregion
#region MOD SETTINGS

@ -542,31 +542,7 @@ public partial class MainForm : Form
Text = Text.ProfileDebugCheckBox,
TextColor = colorGreen
};
//TODO: potentially make this on all platforms?
// Custom environment variables label
Label customEnvVarLabel = new Label();
if (OS.IsLinux)
{
customEnvVarLabel = new Label
{
Text = Text.CustomEnvVarLabel,
TextColor = colorGreen
};
}
// Custom environment variables textbox
customEnvVarTextBox = null;
if (OS.IsLinux)
{
customEnvVarTextBox = new TextBox
{
Text = ReadFromConfig("CustomEnvVar"),
BackgroundColor = colorBGNoAlpha,
TextColor = colorGreen
};
}
// Mirror list
mirrorLabel = new Label
{
@ -617,9 +593,7 @@ public partial class MainForm : Form
autoUpdateLauncherCheck,
hqMusicPCCheck,
hqMusicAndroidCheck,
profileDebugLogCheck,
customEnvVarLabel,
(Control)customEnvVarTextBox ?? new Label(),
profileDebugLogCheck,
mirrorLabel,
mirrorDropDown,
customMirrorCheck,
@ -800,8 +774,6 @@ public partial class MainForm : Form
deleteModButton.Click += DeleteModButtonClicked;
updateModButton.Click += UpdateModButtonClicked;
profileDebugLogCheck.CheckedChanged += ProfileDebugLogCheckedChanged;
if (OS.IsLinux)
customEnvVarTextBox.LostFocus += CustomEnvVarTextBoxLostFocus;
//TODO: Retest if these now work on mac
newsWebView.DocumentLoaded += (_, _) => ChangeToEmptyPageOnNoInternet(newsPage, newsNoConnectionLabel);
@ -901,8 +873,6 @@ public partial class MainForm : Form
/// <summary>A <see cref="TextBox"/>, where the user can input their custom mirror.</summary>
private readonly TextBox customMirrorTextBox;
/// <summary>A <see cref="TextBox"/>, where the user can input their custom environment variables.</summary>
private readonly TextBox customEnvVarTextBox;
/// <summary>A <see cref="TextArea"/>, where the notes from the current selected profile in <see cref="modSettingsProfileDropDown"/> are displayed.</summary>
private readonly TextArea profileNotesTextArea;

@ -51,10 +51,6 @@ public class LauncherConfigXML
[XmlAttribute("ProfileDebugLog")]
public bool ProfileDebugLog
{ get; set; }
/// <summary>Indicates the custom environment variable(s) as text. Used for <see cref="MainForm.customEnvVarTextBox"/></summary>
[XmlAttribute("CustomEnvVar")]
public string CustomEnvVar
{ get; set; }
/// <summary>Indicates the Width of the Launcher.</summary>
[XmlAttribute("Width")]
public int Width
@ -108,7 +104,6 @@ public class LauncherConfigXML
CustomMirrorEnabled = false;
CustomMirrorText = "";
ProfileDebugLog = true;
CustomEnvVar = "";
Width = 600;
Height = 600;
IsMaximized = false;
@ -124,7 +119,6 @@ public class LauncherConfigXML
/// <param name="musicHQAndroid">Parameter that indicates if <see cref="MainForm.hqMusicAndroidCheck"/> is enabled or not.</param>
/// <param name="profileIndex">Parameter that saves the index of the selected profile of <see cref="MainForm.profileDropDown"/>.</param>
/// <param name="mirrorIndex">Parameter that saves the index of the selected mirror in <see cref="MainForm.mirrorDropDown"/>.</param>
/// <param name="customEnvVar">Parameter that saves custom Environment variables that will be used on Linux for launching a game.</param>
/// <param name="customMirrorEnabled">Parameter that indicates if <see cref="MainForm.customMirrorCheck"/> is enabled or not.</param>
/// <param name="profileDebugLog">Parameter that indicates if <see cref="MainForm.profileDebugLogCheck"/> is enabled or not.</param>
/// <param name="customMirrorText">Parameter that's used for <see cref="MainForm.customMirrorTextBox"/>.</param>
@ -132,7 +126,7 @@ public class LauncherConfigXML
/// <param name="height">Parameter that indicates the height of <see cref="MainForm"/>.</param>
/// <param name="isMaximized">Parameter that indicates if <see cref="MainForm"/> has been set to fullscreen or not.</param>
public LauncherConfigXML(bool autoUpdateAM2R, bool autoUpdateLauncher, string language, bool musicHQPC, bool musicHQAndroid,
string profileIndex, int mirrorIndex, bool profileDebugLog, string customEnvVar, bool customMirrorEnabled,
string profileIndex, int mirrorIndex, bool profileDebugLog, bool customMirrorEnabled,
string customMirrorText, int width, int height, bool isMaximized)
{
AutoUpdateAM2R = autoUpdateAM2R;
@ -145,7 +139,6 @@ public class LauncherConfigXML
CustomMirrorEnabled = customMirrorEnabled;
CustomMirrorText = customMirrorText;
ProfileDebugLog = profileDebugLog;
CustomEnvVar = customEnvVar;
Width = width;
Height = height;
IsMaximized = isMaximized;

@ -651,8 +651,7 @@ public static class Profile
/// </summary>
/// <param name="profile">The <see cref="ProfileXML"/> that should be run.</param>
/// <param name="useLogging">Whether game logging should take place.</param>
/// <param name="envVars">Environment variables with which the game should be launched. Linux only.</param>
public static void RunGame(ProfileXML profile, bool useLogging, string envVars = "")
public static void RunGame(ProfileXML profile, bool useLogging)
{
// These are used on all OS for game logging
string savePath = OS.IsWindows ? Environment.ExpandEnvironmentVariables(profile.SaveLocation)
@ -707,25 +706,6 @@ public static class Profile
else if (OS.IsLinux)
{
ProcessStartInfo startInfo = new ProcessStartInfo();
log.Info($"User does {(String.IsNullOrWhiteSpace(envVars) ? "not" : "")} have custom environment variables set.");
// Set environment variables to startInfo
if (!String.IsNullOrWhiteSpace(envVars))
{
// All env vars are of format "myVar=myValue foo=bar" etc., so split them by space
string[] providedVariables = envVars.Split(' ');
foreach (string providedVariable in providedVariables)
{
// After that, we split by '=' where the left is the variable and right is the value
// If there is a malformed env var, this will throw.
string[] variableAsArray = providedVariable.Split('=');
string variable = variableAsArray[0];
string value = variableAsArray[1];
log.Info($"Adding user variable \"{variable}\" with value \"{value}\"");
startInfo.EnvironmentVariables[variable] = value;
}
}
startInfo.UseShellExecute = false;
startInfo.WorkingDirectory = gameDirectory;

Loading…
Cancel
Save