Skip to content

Commit

Permalink
Ignore missing files option for labels
Browse files Browse the repository at this point in the history
  • Loading branch information
HebaruSan committed Sep 29, 2024
1 parent 71f3b32 commit f1f06d3
Show file tree
Hide file tree
Showing 11 changed files with 96 additions and 36 deletions.
14 changes: 10 additions & 4 deletions Core/Registry/IRegistryQuerier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ public static bool HasUpdate(this IRegistryQuerier querier,
string identifier,
GameInstance? instance,
HashSet<string> filters,
bool checkMissingFiles,
out CkanModule? latestMod,
ICollection<CkanModule>? installed = null)
{
Expand Down Expand Up @@ -205,7 +206,8 @@ public static bool HasUpdate(this IRegistryQuerier querier,
if (comp == -1
|| (comp == 0 && !querier.MetadataChanged(identifier)
// Check if any of the files or directories are missing
&& (instance == null
&& (!checkMissingFiles
|| instance == null
|| (querier.InstalledModule(identifier)
?.Files
// Don't make them reinstall files they've filtered out since installing
Expand All @@ -227,7 +229,8 @@ public static bool HasUpdate(this IRegistryQuerier querier,

public static Dictionary<bool, List<CkanModule>> CheckUpgradeable(this IRegistryQuerier querier,
GameInstance? instance,
HashSet<string> heldIdents)
HashSet<string> heldIdents,
HashSet<string>? ignoreMissingIdents = null)
{
var filters = ServiceLocator.Container.Resolve<IConfiguration>()
.GlobalInstallFilters
Expand All @@ -240,21 +243,23 @@ public static Dictionary<bool, List<CkanModule>> CheckUpgradeable(this IRegistry
.Keys
.Select(ident => !heldIdents.Contains(ident)
&& querier.HasUpdate(ident, instance, filters,
!ignoreMissingIdents?.Contains(ident) ?? true,
out CkanModule? latest)
&& latest is not null
&& !latest.IsDLC
? latest
: querier.GetInstalledVersion(ident))
.OfType<CkanModule>()
.ToList();
return querier.CheckUpgradeable(instance, heldIdents, unlimited, filters);
return querier.CheckUpgradeable(instance, heldIdents, unlimited, filters, ignoreMissingIdents);
}

public static Dictionary<bool, List<CkanModule>> CheckUpgradeable(this IRegistryQuerier querier,
GameInstance? instance,
HashSet<string> heldIdents,
List<CkanModule> initial,
HashSet<string>? filters = null)
HashSet<string>? filters = null,
HashSet<string>? ignoreMissingIdents = null)
{
filters ??= ServiceLocator.Container.Resolve<IConfiguration>()
.GlobalInstallFilters
Expand All @@ -268,6 +273,7 @@ public static Dictionary<bool, List<CkanModule>> CheckUpgradeable(this IRegistry
{
if (!heldIdents.Contains(ident)
&& querier.HasUpdate(ident, instance, filters,
!ignoreMissingIdents?.Contains(ident) ?? true,
out CkanModule? latest, initial)
&& latest is not null
&& !latest.IsDLC)
Expand Down
17 changes: 10 additions & 7 deletions GUI/Controls/ManageMods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -335,24 +335,27 @@ private void LabelsContextMenuStrip_Opening(object? sender, CancelEventArgs? e)

private void labelMenuItem_Click(object? sender, EventArgs? e)
{
if (user != null && manager != null && currentInstance != null && SelectedModule != null)
if (user != null
&& manager != null
&& currentInstance != null
&& SelectedModule != null
&& sender is ToolStripMenuItem item
&& item.Tag is ModuleLabel mlbl)
{
var item = sender as ToolStripMenuItem;
var mlbl = item?.Tag as ModuleLabel;
if (item?.Checked ?? false)
if (item.Checked)
{
mlbl?.Add(currentInstance.game, SelectedModule.Identifier);
mlbl.Add(currentInstance.game, SelectedModule.Identifier);
}
else
{
mlbl?.Remove(currentInstance.game, SelectedModule.Identifier);
mlbl.Remove(currentInstance.game, SelectedModule.Identifier);
}
var registry = RegistryManager.Instance(currentInstance, repoData).registry;
mainModList.ReapplyLabels(SelectedModule, Conflicts?.ContainsKey(SelectedModule) ?? false,
currentInstance.Name, currentInstance.game, registry);
ModuleLabelList.ModuleLabels.Save(ModuleLabelList.DefaultPath);
UpdateHiddenTagsAndLabels();
if (mlbl?.HoldVersion ?? false)
if (mlbl.HoldVersion || mlbl.IgnoreMissingFiles)
{
UpdateCol.Visible = UpdateAllToolButton.Enabled =
mainModList.ResetHasUpdate(currentInstance, registry, ChangeSet, ModGrid.Rows);
Expand Down
34 changes: 29 additions & 5 deletions GUI/Dialogs/EditLabelsDialog.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit f1f06d3

Please sign in to comment.