Skip to content

Commit

Permalink
Treat metapackage depends as not auto installed
Browse files Browse the repository at this point in the history
  • Loading branch information
HebaruSan committed Feb 17, 2020
1 parent 523d7c6 commit e24a628
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Core/ModuleInstaller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ public void InstallList(ICollection<CkanModule> modules, RelationshipResolverOpt
User.RaiseProgress(String.Format("Installing mod \"{0}\"", modsToInstall[i]),
percent_complete);

Install(modsToInstall[i], resolver.ReasonFor(modsToInstall[i]) is SelectionReason.Depends, registry_manager.registry);
Install(modsToInstall[i], resolver.IsAutoInstalled(modsToInstall[i]), registry_manager.registry);
}

User.RaiseProgress("Updating registry", 70);
Expand Down
15 changes: 15 additions & 0 deletions Core/Relationships/RelationshipResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,21 @@ public SelectionReason ReasonFor(CkanModule mod)

return reasons[mod];
}

/// <summary>
/// Indicates whether a module should be considered auto-installed in this change set.
/// A mod is auto-installed if it is in the list because it's a dependency
/// and if its depending mod is not a metpaackage.
/// </summary>
/// <param name="mod">Module to check</param>
/// <returns>
/// true if auto-installed, false otherwise
/// </returns>
public bool IsAutoInstalled(CkanModule mod)
{
var reason = ReasonFor(mod);
return reason is SelectionReason.Depends && !reason.Parent.IsMetapackage;
}
}

/// <summary>
Expand Down
19 changes: 14 additions & 5 deletions GUI/Controls/ThemedTabControl.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.Drawing;
using System.Windows.Forms;

Expand All @@ -21,11 +22,19 @@ protected override void OnDrawItem(DrawItemEventArgs e)
bgRect.Inflate(-2, -1);
bgRect.Offset(0, 1);
e.Graphics.FillRectangle(new SolidBrush(BackColor), bgRect);
// Text
var tabPage = TabPages[e.Index];
Rectangle rect = e.Bounds;
TextRenderer.DrawText(e.Graphics, tabPage.Text, tabPage.Font,
rect, tabPage.ForeColor);
// e.Index can be invalid (!!), so we need try/catch
try
{
// Text
var tabPage = TabPages[e.Index];
Rectangle rect = e.Bounds;
TextRenderer.DrawText(e.Graphics, tabPage.Text, tabPage.Font,
rect, tabPage.ForeColor);
}
catch (ArgumentOutOfRangeException)
{
// No such tab page, oh well
}
// Alert event subscribers
base.OnDrawItem(e);
}
Expand Down

0 comments on commit e24a628

Please sign in to comment.