Browse Source

Show outdated mods in orange

tags/v1.4.0
NorbiPeti 3 years ago
parent
commit
854e02dd0d
4 changed files with 31 additions and 5 deletions
  1. +2
    -0
      GCMM/MainForm.cs
  2. +5
    -5
      GCMM/MainModList.cs
  3. +21
    -0
      GCMM/MainUtils.cs
  4. +3
    -0
      GCMM/ModInfo.cs

+ 2
- 0
GCMM/MainForm.cs View File

@@ -25,6 +25,7 @@ namespace GCMM
private readonly Dictionary<string, ModInfo> mods = new Dictionary<string, ModInfo>();
private readonly ModInfo gcipa = new ModInfo { Author = "modtainers", Name = "GCIPA" };
private readonly ModInfo gcmm = new ModInfo { Author = "NorbiPeti", Name = "GCMM" };
private DateTime lastGameUpdateTime;
private const string defaultInfo = @"
Gamecraft Mod Manager

@@ -239,6 +240,7 @@ You may also want to verify the game's files by right clicking the game in Steam
private async void refreshbtn_Click(object sender, EventArgs e)
{
CheckIfPatched(); //Set from placeholder
lastGameUpdateTime = GetLastGameUpdateTime();
var mods = GetInstalledMods();
await GetAvailableMods();
CheckUninstalledMods(mods);


+ 5
- 5
GCMM/MainModList.cs View File

@@ -33,7 +33,7 @@ namespace GCMM
var an = AssemblyName.GetAssemblyName(modPath);
if (an.Name == "0Harmony") continue;
//Use filename to avoid differences between repository & assembly name casing
var mod = new ModInfo { Name = Path.GetFileNameWithoutExtension(modPath), Version = an.Version, LastUpdated = File.GetLastWriteTime(modPath) };
var mod = new ModInfo { Name = Path.GetFileNameWithoutExtension(modPath), Version = an.Version };
AddUpdateModInList(mod);
installed.Add(mod.Name);
}
@@ -48,7 +48,6 @@ namespace GCMM
{
var an = AssemblyName.GetAssemblyName(ipath);
gcipa.Version = an.Version;
gcipa.LastUpdated = File.GetLastWriteTime(ipath);
}
}
catch (BadImageFormatException)
@@ -61,7 +60,6 @@ namespace GCMM
{
var an = AssemblyName.GetAssemblyName(mmpath);
gcmm.Version = an.Version;
gcmm.LastUpdated = File.GetLastWriteTime(mmpath);
}
}
catch (BadImageFormatException)
@@ -178,7 +176,7 @@ namespace GCMM
omod.UpdateDetails = mod.UpdateDetails ?? omod.UpdateDetails;
items[1].Text = omod.Author ?? "";
items[2].Text = (omod.Version ?? omod.LatestVersion)?.ToString();
items[3].Text = omod.LastUpdated.ToString();
items[3].Text = omod.LatestVersion != null ? omod.LastUpdated.ToString() : "";
item.Group = omod.Installed ? modlist.Groups["installed"] : modlist.Groups["available"];
modlist.Sort();
mod = omod;
@@ -186,12 +184,14 @@ namespace GCMM
else
{
mods.Add(mod.Name, mod);
item = new ListViewItem(new[] { mod.Name, mod.Author ?? "", (mod.Version ?? mod.LatestVersion)?.ToString() ?? "", mod.LastUpdated.ToString() }, modlist.Groups[mod.Installed ? "installed" : "available"]);
item = new ListViewItem(new[] { mod.Name, mod.Author ?? "", (mod.Version ?? mod.LatestVersion)?.ToString() ?? "", mod.LatestVersion != null ? mod.LastUpdated.ToString() : "" }, modlist.Groups[mod.Installed ? "installed" : "available"]);
item.Name = mod.Name;
modlist.Items.Add(item);
}
if (mod.LatestVersion != null && mod.Version != null && mod.Version < mod.LatestVersion)
item.ForeColor = Color.Blue;
else if (mod.LastUpdated < lastGameUpdateTime)
item.ForeColor = Color.DarkOrange;
else
item.ForeColor = modlist.ForeColor;
}


+ 21
- 0
GCMM/MainUtils.cs View File

@@ -160,5 +160,26 @@ namespace GCMM
}
return false;
}

public DateTime GetLastGameUpdateTime()
{
if (GetExe() == null)
return default;
foreach (var line in File.ReadAllLines(GamePath(@"\..\..\appmanifest_1078000.acf")))
{
var regex = new Regex("\\t\"LastUpdated\"\\t\\t\"(\\d+)\"");
var match = regex.Match(line);
if (!match.Success)
continue;
string updated = match.Groups[1].Value;
if (string.IsNullOrWhiteSpace(updated))
return default;
var updatedTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
updatedTime = updatedTime.AddSeconds(double.Parse(updated)).ToLocalTime();
return updatedTime;

}
return default;
}
}
}

+ 3
- 0
GCMM/ModInfo.cs View File

@@ -22,6 +22,9 @@ namespace GCMM
/// Can be null.
/// </summary>
public string Author { get; set; }
/// <summary>
/// The time when the mod was last updated by its author.
/// </summary>
public DateTime LastUpdated { get; set; }
public bool Installed => Version != null;
public string DownloadURL { get; set; }


Loading…
Cancel
Save