Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix GUI layout issues with scaling #4316

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
27 changes: 23 additions & 4 deletions AutoUpdate/SingleAssemblyResourceManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,35 @@ namespace CKAN.AutoUpdateHelper
{
// Thanks and credit to this guy: https://stackoverflow.com/q/1952638/2422988

/// <summary>
/// Wrapper around ResourceManager that retrieves strings from the assembly
/// rather than external files
/// </summary>
public class SingleAssemblyResourceManager : ResourceManager
{
public SingleAssemblyResourceManager(string basename, Assembly assembly) : base(basename, assembly)
/// <summary>
/// Initialize the resource manager
/// </summary>
/// <param name="basename">To be passed to ResourceManager</param>
/// <param name="assembly">To be passed to ResourceManager</param>
public SingleAssemblyResourceManager(string basename, Assembly assembly)
: base(basename, assembly)
{
}

/// <summary>
/// Provides resources from the assembly to ResourceManager
/// </summary>
/// <param name="culture">The language to get</param>
/// <param name="createIfNotExists">Set to false to avoid loading if not already cached</param>
/// <param name="tryParents">Just gets passed to base class implementation</param>
/// <returns></returns>
protected override ResourceSet? InternalGetResourceSet(CultureInfo culture,
bool createIfNotExists, bool tryParents)
bool createIfNotExists,
bool tryParents)
{
if (!myResourceSets.TryGetValue(culture, out ResourceSet? rs) && createIfNotExists && MainAssembly != null)
if (!myResourceSets.TryGetValue(culture, out ResourceSet? rs)
&& createIfNotExists && MainAssembly != null)
{
// Lazy-load default language (without caring about duplicate assignment in race conditions, no harm done)
neutralResourcesCulture ??= GetNeutralResourcesLanguage(MainAssembly);
Expand Down Expand Up @@ -46,7 +65,7 @@ public SingleAssemblyResourceManager(string basename, Assembly assembly) : base(
return rs;
}

private CultureInfo? neutralResourcesCulture;
private CultureInfo? neutralResourcesCulture;
private readonly Dictionary<CultureInfo, ResourceSet> myResourceSets = new Dictionary<CultureInfo, ResourceSet>();
}
}
53 changes: 0 additions & 53 deletions Cmdline/SingleAssemblyResourceManager.cs

This file was deleted.

69 changes: 0 additions & 69 deletions ConsoleUI/SingleAssemblyResourceManager.cs

This file was deleted.

2 changes: 2 additions & 0 deletions Core/ModuleInstaller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1577,12 +1577,14 @@ public static bool FindRecommendations(GameInstance
out Dictionary<CkanModule, List<string>> suggestions,
out Dictionary<CkanModule, HashSet<string>> supporters)
{
log.DebugFormat("Finding recommendations for: {0}", string.Join(", ", sourceModules));
var crit = instance.VersionCriteria();
var resolver = new RelationshipResolver(sourceModules.Where(m => !m.IsDLC),
null,
RelationshipResolverOptions.KitchenSinkOpts(instance.StabilityToleranceConfig),
registry, instance.game, crit);
var recommenders = resolver.Dependencies().ToHashSet();
log.DebugFormat("Recommenders: {0}", string.Join(", ", recommenders));

var checkedRecs = resolver.Recommendations(recommenders)
.Where(m => resolver.ReasonsFor(m)
Expand Down
2 changes: 1 addition & 1 deletion Core/Relationships/RelationshipResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ private IEnumerable<CkanModule> allDependers(CkanModule module)
.Except(found));

public IEnumerable<CkanModule> Dependencies()
=> BreadthFirstSearch(user_requested_mods,
=> BreadthFirstSearch(user_requested_mods.Where(m => !suppressedRecommenders.Any(rel => rel.WithinBounds(m))),
(searching, found) =>
modlist.Values
.Except(found)
Expand Down
22 changes: 20 additions & 2 deletions Core/SingleAssemblyResourceManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,35 @@ namespace CKAN
{
// Thanks and credit to this guy: https://stackoverflow.com/q/1952638/2422988

/// <summary>
/// Wrapper around ResourceManager that retrieves strings from the assembly
/// rather than external files
/// </summary>
public class SingleAssemblyResourceManager : ResourceManager
{
public SingleAssemblyResourceManager(string basename, Assembly assembly) : base(basename, assembly)
/// <summary>
/// Initialize the resource manager
/// </summary>
/// <param name="basename">To be passed to ResourceManager</param>
/// <param name="assembly">To be passed to ResourceManager</param>
public SingleAssemblyResourceManager(string basename, Assembly assembly)
: base(basename, assembly)
{
}

/// <summary>
/// Provides resources from the assembly to ResourceManager
/// </summary>
/// <param name="culture">The language to get</param>
/// <param name="createIfNotExists">Set to false to avoid loading if not already cached</param>
/// <param name="tryParents">Just gets passed to base class implementation</param>
/// <returns></returns>
protected override ResourceSet? InternalGetResourceSet(CultureInfo culture,
bool createIfNotExists,
bool tryParents)
{
if (!myResourceSets.TryGetValue(culture, out ResourceSet? rs) && createIfNotExists && MainAssembly != null)
if (!myResourceSets.TryGetValue(culture, out ResourceSet? rs)
&& createIfNotExists && MainAssembly != null)
{
// Lazy-load default language (without caring about duplicate assignment in race conditions, no harm done)
neutralResourcesCulture ??= GetNeutralResourcesLanguage(MainAssembly);
Expand Down
3 changes: 2 additions & 1 deletion GUI/Controls/Changeset.Designer.cs

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

3 changes: 2 additions & 1 deletion GUI/Controls/ChooseProvidedMods.Designer.cs

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

3 changes: 2 additions & 1 deletion GUI/Controls/ChooseRecommendedMods.Designer.cs

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

3 changes: 2 additions & 1 deletion GUI/Controls/DeleteDirectories.Designer.cs

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

3 changes: 2 additions & 1 deletion GUI/Controls/EditModSearch.Designer.cs

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

3 changes: 2 additions & 1 deletion GUI/Controls/EditModSearchDetails.Designer.cs

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

4 changes: 2 additions & 2 deletions GUI/Controls/EditModSearches.Designer.cs

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

17 changes: 5 additions & 12 deletions GUI/Controls/EditModSearches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ public EditModSearches()
{
InitializeComponent();
ToolTip.SetToolTip(AddSearchButton, Properties.Resources.EditModSearchesTooltipAddSearchButton);
ActiveControl = AddSearch();
}

public event Action? SurrenderFocus;
Expand Down Expand Up @@ -69,6 +68,10 @@ public void SetSearches(List<ModSearch> searches)
{
RemoveSearch(editors[^1]);
}
if (editors.Count < 1)
{
ActiveControl = AddSearch();
}
if (searches.Count < 1)
{
if (//editors is [var editor]
Expand Down Expand Up @@ -116,8 +119,6 @@ private void AddSearchButton_Click(object? sender, EventArgs? e)

private EditModSearch AddSearch()
{
SuspendLayout();

var ctl = new EditModSearch()
{
// Dock handles the layout for us
Expand All @@ -136,9 +137,6 @@ private EditModSearch AddSearch()
// Still need to be able to see the add button, without this it's covered up
AddSearchButton.BringToFront();

ResumeLayout(false);
PerformLayout();

Height = editors.Sum(ems => ems.Height);

return ctl;
Expand All @@ -148,8 +146,6 @@ private void RemoveSearch(EditModSearch which)
{
if (editors.Count >= 2)
{
SuspendLayout();

if (which == ActiveControl)
{
// Move focus to next control, or previous if last in list
Expand All @@ -169,9 +165,6 @@ private void RemoveSearch(EditModSearch which)
editor.ShowLabel = true;
}

ResumeLayout(false);
PerformLayout();

Height = editors.Sum(ems => ems.Height);
}
}
Expand All @@ -190,7 +183,7 @@ private void Apply()
var searches = editors.Select(ems => ems.Search)
.ToList();
ApplySearches?.Invoke(searches.Count == 0 ? null : searches);
AddSearchButton.Enabled = editors.Count == searches.Count;
AddSearchButton.Enabled = editors.Count == searches.OfType<ModSearch>().Count();
}

private void EditModSearch_SurrenderFocus()
Expand Down
3 changes: 2 additions & 1 deletion GUI/Controls/EditModpack.Designer.cs

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

Loading