Fix game exit handling popup, color Play button when a mod is broken/outdated
This commit is contained in:
parent
009f905379
commit
63d57ccd12
6 changed files with 45 additions and 13 deletions
|
@ -80,10 +80,24 @@ If you encounter an issue while any mods are installed, report it to us. If you
|
||||||
private async void playbtn_Click(object sender, EventArgs e)
|
private async void playbtn_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (playbtn.ForeColor == Color.Green) return; //Disabled
|
if (playbtn.ForeColor == Color.Green) return; //Disabled
|
||||||
|
if (mods.Any(mod => mod.Value.Installed && mod.Value.Broken is true))
|
||||||
|
if (MessageBox.Show("Some installed mods are known to be broken on the current version of the game. The game might crash.",
|
||||||
|
"Warning", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.Cancel)
|
||||||
|
return;
|
||||||
await UpdateAPI();
|
await UpdateAPI();
|
||||||
await PatchStartGame(); //It will call EndWork();
|
await PatchStartGame(); //It will call EndWork();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void UpdatePlayButtonColor()
|
||||||
|
{
|
||||||
|
if (mods.Any(mod => mod.Value.Installed && mod.Value.Broken is true))
|
||||||
|
playbtn.ForeColor = Color.Red;
|
||||||
|
else if (mods.Any(mod => mod.Value.Installed && mod.Value.Outdated(lastGameUpdateTime)))
|
||||||
|
playbtn.ForeColor = Color.DarkOrange;
|
||||||
|
else
|
||||||
|
playbtn.ForeColor = Color.Lime;
|
||||||
|
}
|
||||||
|
|
||||||
private void settingsbtn_Click(object sender, EventArgs e)
|
private void settingsbtn_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (settingsbtn.ForeColor == Color.Green) return; //Disabled
|
if (settingsbtn.ForeColor == Color.Green) return; //Disabled
|
||||||
|
@ -124,9 +138,9 @@ If you encounter an issue while any mods are installed, report it to us. If you
|
||||||
{
|
{
|
||||||
if (mod.Updatable)
|
if (mod.Updatable)
|
||||||
addText("New version available! " + mod.UpdateDetails, Color.Aqua);
|
addText("New version available! " + mod.UpdateDetails, Color.Aqua);
|
||||||
if (mod.Broken)
|
if (mod.Broken is true)
|
||||||
addText("Outdated mod! It has been confirmed that the mod is broken on the current version of the game.", Color.Red);
|
addText("Outdated mod! It has been confirmed that the mod is broken on the current version of the game.", Color.Red);
|
||||||
else if (mod.LastUpdated != default && mod.LastUpdated < lastGameUpdateTime)
|
else if (mod.Outdated(lastGameUpdateTime))
|
||||||
addText("Outdated mod! It may not work properly on the current version of the game.", Color.DarkOrange);
|
addText("Outdated mod! It may not work properly on the current version of the game.", Color.DarkOrange);
|
||||||
if (mod.Description != null)
|
if (mod.Description != null)
|
||||||
modinfobox.AppendText(mod.Description.Replace("\n", Environment.NewLine));
|
modinfobox.AppendText(mod.Description.Replace("\n", Environment.NewLine));
|
||||||
|
|
|
@ -66,6 +66,7 @@ namespace TBMM
|
||||||
}
|
}
|
||||||
GetInstalledMods(); //Update list
|
GetInstalledMods(); //Update list
|
||||||
}
|
}
|
||||||
|
UpdatePlayButtonColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ExtractMod(ZipArchive archive, string destinationDirectoryName, ModInfo mod)
|
public void ExtractMod(ZipArchive archive, string destinationDirectoryName, ModInfo mod)
|
||||||
|
@ -170,6 +171,7 @@ namespace TBMM
|
||||||
{
|
{
|
||||||
MessageBox.Show("Could not remove mod files! Make sure the game isn't running.\n" + e.Message);
|
MessageBox.Show("Could not remove mod files! Make sure the game isn't running.\n" + e.Message);
|
||||||
}
|
}
|
||||||
|
UpdatePlayButtonColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task UpdateAPI()
|
public async Task UpdateAPI()
|
||||||
|
|
|
@ -59,6 +59,7 @@ namespace TBMM
|
||||||
public async Task GetAvailableMods()
|
public async Task GetAvailableMods()
|
||||||
{
|
{
|
||||||
bool preview = GetExe()?.Contains("Preview") ?? false;
|
bool preview = GetExe()?.Contains("Preview") ?? false;
|
||||||
|
//byte anyModOutdated = 0;
|
||||||
using (var client = GetClient())
|
using (var client = GetClient())
|
||||||
{
|
{
|
||||||
string str = await client.DownloadStringTaskAsync("https://exmods.org/mods/modlist.tsv");
|
string str = await client.DownloadStringTaskAsync("https://exmods.org/mods/modlist.tsv");
|
||||||
|
@ -96,6 +97,7 @@ namespace TBMM
|
||||||
== DialogResult.Yes)
|
== DialogResult.Yes)
|
||||||
Process.Start(tbmm.DownloadURL);
|
Process.Start(tbmm.DownloadURL);
|
||||||
}
|
}
|
||||||
|
UpdatePlayButtonColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<bool> FetchModInfo(ModInfo mod, bool preview, bool desc)
|
public async Task<bool> FetchModInfo(ModInfo mod, bool preview, bool desc)
|
||||||
|
@ -186,6 +188,7 @@ namespace TBMM
|
||||||
omod.Description = mod.Description ?? omod.Description;
|
omod.Description = mod.Description ?? omod.Description;
|
||||||
omod.DownloadURL = mod.DownloadURL ?? omod.DownloadURL;
|
omod.DownloadURL = mod.DownloadURL ?? omod.DownloadURL;
|
||||||
omod.UpdateDetails = mod.UpdateDetails ?? omod.UpdateDetails;
|
omod.UpdateDetails = mod.UpdateDetails ?? omod.UpdateDetails;
|
||||||
|
omod.Broken = mod.Broken ?? omod.Broken;
|
||||||
items[1].Text = omod.Author ?? "";
|
items[1].Text = omod.Author ?? "";
|
||||||
items[2].Text = (omod.Version ?? omod.LatestVersion)?.ToString();
|
items[2].Text = (omod.Version ?? omod.LatestVersion)?.ToString();
|
||||||
items[3].Text = omod.LatestVersion != null ? omod.LastUpdated.ToString() : "";
|
items[3].Text = omod.LatestVersion != null ? omod.LastUpdated.ToString() : "";
|
||||||
|
@ -202,10 +205,10 @@ namespace TBMM
|
||||||
}
|
}
|
||||||
if (mod.LatestVersion != null && mod.Version != null && mod.Version < mod.LatestVersion)
|
if (mod.LatestVersion != null && mod.Version != null && mod.Version < mod.LatestVersion)
|
||||||
item.ForeColor = Color.Blue;
|
item.ForeColor = Color.Blue;
|
||||||
else if(mod.Broken)
|
else if(mod.Broken is true)
|
||||||
item.ForeColor = Color.Red;
|
item.ForeColor = Color.Red;
|
||||||
else if (mod.LastUpdated != default && mod.LastUpdated < lastGameUpdateTime)
|
else if (mod.Outdated(lastGameUpdateTime))
|
||||||
item.ForeColor = Color.OrangeRed;
|
item.ForeColor = Color.DarkOrange;
|
||||||
else
|
else
|
||||||
item.ForeColor = modlist.ForeColor;
|
item.ForeColor = modlist.ForeColor;
|
||||||
}
|
}
|
||||||
|
@ -223,6 +226,7 @@ namespace TBMM
|
||||||
delete.Add(name);
|
delete.Add(name);
|
||||||
}
|
}
|
||||||
delete.ForEach(name => { mods.Remove(name); modlist.Items[name].Remove(); });
|
delete.ForEach(name => { mods.Remove(name); modlist.Items[name].Remove(); });
|
||||||
|
UpdatePlayButtonColor();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@ namespace TBMM
|
||||||
{ GameState.Unpatched, ("Unpatched", "", "") },
|
{ GameState.Unpatched, ("Unpatched", "", "") },
|
||||||
{ GameState.Patched, ("Patched", "", "") }
|
{ GameState.Patched, ("Patched", "", "") }
|
||||||
};
|
};
|
||||||
|
|
||||||
void SetStatusText(GameState state, bool patched)
|
void SetStatusText(GameState state, bool patched)
|
||||||
{
|
{
|
||||||
var (statusText, extra, play) = statusTexts[state];
|
var (statusText, extra, play) = statusTexts[state];
|
||||||
|
@ -35,6 +36,7 @@ namespace TBMM
|
||||||
status.Text += "\nUnpatch on exit disabled";
|
status.Text += "\nUnpatch on exit disabled";
|
||||||
playbtn.Text = play;
|
playbtn.Text = play;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GetExe() == null)
|
if (GetExe() == null)
|
||||||
{
|
{
|
||||||
patched = false;
|
patched = false;
|
||||||
|
|
|
@ -16,13 +16,23 @@ namespace TBMM
|
||||||
{
|
{
|
||||||
if (enabled)
|
if (enabled)
|
||||||
{
|
{
|
||||||
|
if (button.ForeColor == Color.Green)
|
||||||
button.ForeColor = Color.Lime;
|
button.ForeColor = Color.Lime;
|
||||||
|
else if(button.ForeColor == Color.DarkRed)
|
||||||
|
button.ForeColor = Color.Red;
|
||||||
|
else if (button.ForeColor == Color.FromArgb(127, 65, 0))
|
||||||
|
button.ForeColor = Color.DarkOrange;
|
||||||
button.FlatAppearance.MouseOverBackColor = Color.FromArgb(0, 40, 0);
|
button.FlatAppearance.MouseOverBackColor = Color.FromArgb(0, 40, 0);
|
||||||
button.FlatAppearance.MouseDownBackColor = Color.Green;
|
button.FlatAppearance.MouseDownBackColor = Color.Green;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if (button.ForeColor == Color.Lime)
|
||||||
button.ForeColor = Color.Green;
|
button.ForeColor = Color.Green;
|
||||||
|
else if (button.ForeColor == Color.Red)
|
||||||
|
button.ForeColor = Color.DarkRed;
|
||||||
|
else if (button.ForeColor == Color.DarkOrange)
|
||||||
|
button.ForeColor = Color.FromArgb(127, 65, 0);
|
||||||
button.FlatAppearance.MouseOverBackColor = Color.Black;
|
button.FlatAppearance.MouseOverBackColor = Color.Black;
|
||||||
button.FlatAppearance.MouseDownBackColor = Color.Black;
|
button.FlatAppearance.MouseDownBackColor = Color.Black;
|
||||||
}
|
}
|
||||||
|
@ -136,9 +146,7 @@ namespace TBMM
|
||||||
Debug.WriteLine("Game has not exited");
|
Debug.WriteLine("Game has not exited");
|
||||||
return true;
|
return true;
|
||||||
case { HasExited: true }:
|
case { HasExited: true }:
|
||||||
Debug.WriteLine("Game has exited, dialog shown");
|
Debug.WriteLine("Game has seemingly exited without handling, probably as part of the exit handler");
|
||||||
MessageBox.Show("Game has exited without handling... Please report.");
|
|
||||||
HandleGameExit(null, EventArgs.Empty);
|
|
||||||
return false;
|
return false;
|
||||||
default:
|
default:
|
||||||
Debug.WriteLine($"Process seems to be null: {_gameProcess}");
|
Debug.WriteLine($"Process seems to be null: {_gameProcess}");
|
||||||
|
|
|
@ -31,6 +31,8 @@ namespace TBMM
|
||||||
public HashSet<string> ModFiles { get; set; }
|
public HashSet<string> ModFiles { get; set; }
|
||||||
public string UpdateDetails { get; set; }
|
public string UpdateDetails { get; set; }
|
||||||
public bool Updatable => Version != null && LatestVersion != null && Version < LatestVersion;
|
public bool Updatable => Version != null && LatestVersion != null && Version < LatestVersion;
|
||||||
public bool Broken { get; set; }
|
public bool? Broken { get; set; }
|
||||||
|
|
||||||
|
public bool Outdated(DateTime lastGameUpdateTime) => LastUpdated != default && LastUpdated < lastGameUpdateTime;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue