@@ -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) | |||
{ | |||
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 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) | |||
{ | |||
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) | |||
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); | |||
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); | |||
if (mod.Description != null) | |||
modinfobox.AppendText(mod.Description.Replace("\n", Environment.NewLine)); | |||
@@ -66,6 +66,7 @@ namespace TBMM | |||
} | |||
GetInstalledMods(); //Update list | |||
} | |||
UpdatePlayButtonColor(); | |||
} | |||
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); | |||
} | |||
UpdatePlayButtonColor(); | |||
} | |||
public async Task UpdateAPI() | |||
@@ -59,6 +59,7 @@ namespace TBMM | |||
public async Task GetAvailableMods() | |||
{ | |||
bool preview = GetExe()?.Contains("Preview") ?? false; | |||
//byte anyModOutdated = 0; | |||
using (var client = GetClient()) | |||
{ | |||
string str = await client.DownloadStringTaskAsync("https://exmods.org/mods/modlist.tsv"); | |||
@@ -96,6 +97,7 @@ namespace TBMM | |||
== DialogResult.Yes) | |||
Process.Start(tbmm.DownloadURL); | |||
} | |||
UpdatePlayButtonColor(); | |||
} | |||
public async Task<bool> FetchModInfo(ModInfo mod, bool preview, bool desc) | |||
@@ -186,6 +188,7 @@ namespace TBMM | |||
omod.Description = mod.Description ?? omod.Description; | |||
omod.DownloadURL = mod.DownloadURL ?? omod.DownloadURL; | |||
omod.UpdateDetails = mod.UpdateDetails ?? omod.UpdateDetails; | |||
omod.Broken = mod.Broken ?? omod.Broken; | |||
items[1].Text = omod.Author ?? ""; | |||
items[2].Text = (omod.Version ?? omod.LatestVersion)?.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) | |||
item.ForeColor = Color.Blue; | |||
else if(mod.Broken) | |||
else if(mod.Broken is true) | |||
item.ForeColor = Color.Red; | |||
else if (mod.LastUpdated != default && mod.LastUpdated < lastGameUpdateTime) | |||
item.ForeColor = Color.OrangeRed; | |||
else if (mod.Outdated(lastGameUpdateTime)) | |||
item.ForeColor = Color.DarkOrange; | |||
else | |||
item.ForeColor = modlist.ForeColor; | |||
} | |||
@@ -223,6 +226,7 @@ namespace TBMM | |||
delete.Add(name); | |||
} | |||
delete.ForEach(name => { mods.Remove(name); modlist.Items[name].Remove(); }); | |||
UpdatePlayButtonColor(); | |||
} | |||
} | |||
} |
@@ -13,7 +13,7 @@ namespace TBMM | |||
partial class MainForm | |||
{ | |||
public GameState CheckIfPatched() => CheckIfPatched(out _); | |||
public GameState CheckIfPatched(out bool patched) | |||
{ | |||
Dictionary<GameState, (string Status, string Extra, string Play)> statusTexts = new() | |||
@@ -23,8 +23,9 @@ namespace TBMM | |||
{ GameState.NoPatcher, ("Patcher missing", "Clicking Play will install it", "") }, | |||
{ GameState.OldPatcher, ("Patcher outdated", "nClicking play will update it", "") }, | |||
{ GameState.Unpatched, ("Unpatched", "", "") }, | |||
{ GameState.Patched, ("Patched", "", "")} | |||
{ GameState.Patched, ("Patched", "", "") } | |||
}; | |||
void SetStatusText(GameState state, bool patched) | |||
{ | |||
var (statusText, extra, play) = statusTexts[state]; | |||
@@ -35,6 +36,7 @@ namespace TBMM | |||
status.Text += "\nUnpatch on exit disabled"; | |||
playbtn.Text = play; | |||
} | |||
if (GetExe() == null) | |||
{ | |||
patched = false; | |||
@@ -16,13 +16,23 @@ namespace TBMM | |||
{ | |||
if (enabled) | |||
{ | |||
button.ForeColor = Color.Lime; | |||
if (button.ForeColor == Color.Green) | |||
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.MouseDownBackColor = Color.Green; | |||
} | |||
else | |||
{ | |||
button.ForeColor = Color.Green; | |||
if (button.ForeColor == Color.Lime) | |||
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.MouseDownBackColor = Color.Black; | |||
} | |||
@@ -136,9 +146,7 @@ namespace TBMM | |||
Debug.WriteLine("Game has not exited"); | |||
return true; | |||
case { HasExited: true }: | |||
Debug.WriteLine("Game has exited, dialog shown"); | |||
MessageBox.Show("Game has exited without handling... Please report."); | |||
HandleGameExit(null, EventArgs.Empty); | |||
Debug.WriteLine("Game has seemingly exited without handling, probably as part of the exit handler"); | |||
return false; | |||
default: | |||
Debug.WriteLine($"Process seems to be null: {_gameProcess}"); | |||
@@ -31,6 +31,8 @@ namespace TBMM | |||
public HashSet<string> ModFiles { get; set; } | |||
public string UpdateDetails { get; set; } | |||
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; | |||
} | |||
} |