Skip to content

Commit

Permalink
feat: add option to hide default variant names
Browse files Browse the repository at this point in the history
  • Loading branch information
anna-is-cute committed Dec 18, 2023
1 parent 8d82e3a commit f4f042f
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ internal class Configuration : IPluginConfiguration {
public bool OpenPenumbraAfterInstall = true;
public bool WarnAboutBreakingChanges = true;
public bool ReplaceSortName = true;
public bool HideDefaultVariant = true;
public string TitlePrefix = "[HS] ";
public string PenumbraFolder = "Heliosphere";
public string? DefaultCollection;
Expand All @@ -43,6 +44,7 @@ internal Configuration(Configuration other) {
this.OpenPenumbraAfterInstall = other.OpenPenumbraAfterInstall;
this.WarnAboutBreakingChanges = other.WarnAboutBreakingChanges;
this.ReplaceSortName = other.ReplaceSortName;
this.HideDefaultVariant = other.HideDefaultVariant;
this.TitlePrefix = other.TitlePrefix;
this.PenumbraFolder = other.PenumbraFolder;
this.DefaultCollection = other.DefaultCollection;
Expand Down
10 changes: 8 additions & 2 deletions DownloadTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -721,8 +721,14 @@ private async Task ConstructModPack(IDownloadTask_GetVersion info) {

private string GenerateModName(IDownloadTask_GetVersion info) {
var pkgName = info.Variant.Package.Name.Replace('/', '-');
var varName = info.Variant.Name.Replace('/', '-');
return $"{this.Plugin.Config.TitlePrefix}{pkgName} ({varName})";
var name = $"{this.Plugin.Config.TitlePrefix}{pkgName}";

if (!this.Plugin.Config.HideDefaultVariant || info.Variant.Name != Consts.DefaultVariant) {
var varName = info.Variant.Name.Replace('/', '-');
name += $" ({varName})";
}

return name;
}

private async Task ConstructMeta(IDownloadTask_GetVersion info, HeliosphereMeta hsMeta) {
Expand Down
4 changes: 4 additions & 0 deletions Ui/Tabs/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ internal void Draw() {
ImGui.SameLine();
ImGuiHelper.Help("Uncheck this if you change the name in the mod path to re-order your mods. Most users should keep this checked.");

anyChanged |= ImGui.Checkbox("Hide variant names in Penumbra when they are \"Default\"", ref this.Plugin.Config.HideDefaultVariant);
ImGui.SameLine();
ImGuiHelper.Help("This only affects mods installed after changing the setting.");

anyChanged |= ImGuiHelper.InputTextVertical(
"Penumbra mod title prefix",
"##title-prefix",
Expand Down
5 changes: 5 additions & 0 deletions Util/Consts.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
namespace Heliosphere.Util;

internal static class Consts {
internal const string DefaultVariant = "Default";
}

0 comments on commit f4f042f

Please sign in to comment.