Skip to content

Commit a80cfb0

Browse files
committed
Assign to sections and update text
Resolves #1571 Resolves #1606
1 parent d91db3b commit a80cfb0

File tree

15 files changed

+107
-82
lines changed

15 files changed

+107
-82
lines changed

src/Abstractions/NexusMods.Abstractions.Games.Diagnostics/DiagnosticSettings.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ public class DiagnosticSettings : ISettings
1717
/// <inheritdoc/>
1818
public static ISettingsBuilder Configure(ISettingsBuilder settingsBuilder)
1919
{
20-
// TODO: put in some section
21-
var sectionId = SectionId.DefaultValue;
20+
var sectionId = Sections.General;
2221

2322
return settingsBuilder.AddToUI<DiagnosticSettings>(builder => builder
2423
.AddPropertyToUI(x => x.MinimumSeverity, propertyBuilder => propertyBuilder
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using JetBrains.Annotations;
2+
3+
namespace NexusMods.Abstractions.Settings;
4+
5+
/// <summary>
6+
/// A collection of sections to use.
7+
/// </summary>
8+
[PublicAPI]
9+
public static class Sections
10+
{
11+
public static readonly SectionId General = SectionId.From(Guid.Parse("3106487b-db84-4caa-acdd-9428506fbf6d"));
12+
13+
public static readonly SectionId Privacy = SectionId.From(Guid.Parse("4ef7b142-8f0e-4cae-867f-a58d985241c0"));
14+
15+
public static readonly SectionId Advanced = SectionId.From(Guid.Parse("1531efa7-cb0a-4463-8a04-a865d848ca06"));
16+
17+
public static readonly SectionId DeveloperTools = SectionId.From(Guid.Parse("c33fb41c-7dc5-4911-b48c-3a8c822083d9"));
18+
19+
public static readonly SectionId Experimental = SectionId.From(Guid.Parse("864495d4-aa30-48a7-b292-d23adce391f1"));
20+
}

src/Abstractions/NexusMods.Abstractions.Telemetry/TelemetrySettings.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,13 @@ public record TelemetrySettings : ISettings
1212

1313
public static ISettingsBuilder Configure(ISettingsBuilder settingsBuilder)
1414
{
15-
// TODO: put in some section
16-
var sectionId = SectionId.DefaultValue;
17-
1815
return settingsBuilder
1916
.ConfigureStorageBackend<TelemetrySettings>(backend => backend.UseJson())
2017
.AddToUI<TelemetrySettings>(builder => builder
2118
.AddPropertyToUI(x => x.IsEnabled, propertyBuilder => propertyBuilder
22-
.AddToSection(sectionId)
23-
.WithDisplayName("Enable Telemetry")
24-
.WithDescription("Send anonymous analytics information and usage data to Nexus Mods.")
19+
.AddToSection(Sections.Privacy)
20+
.WithDisplayName("Send usage data")
21+
.WithDescription("Help us improve the App by sending usage data to Nexus Mods.")
2522
.UseBooleanContainer()
2623
.RequiresRestart()
2724
)

src/NexusMods.App.UI/ExperimentalSettings.cs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,20 @@ public record ExperimentalSettings : ISettings
2121

2222
public static ISettingsBuilder Configure(ISettingsBuilder settingsBuilder)
2323
{
24-
// TODO: put in some section
25-
var sectionId = SectionId.DefaultValue;
26-
2724
return settingsBuilder
2825
.ConfigureStorageBackend<ExperimentalSettings>(builder => builder.UseJson())
2926
.AddToUI<ExperimentalSettings>(builder => builder
3027
.AddPropertyToUI(x => x.EnableAllGames, propertyBuilder => propertyBuilder
31-
.AddToSection(sectionId)
32-
.WithDisplayName("[Unsupported] Enable Unsupported Games")
33-
.WithDescription("When set, 'work-in-progress' games that are not yet fully supported will be enabled in the UI.")
28+
.AddToSection(Sections.Experimental)
29+
.WithDisplayName("Enable unsupported games")
30+
.WithDescription("Allows you to manage unsupported games.")
3431
.UseBooleanContainer()
3532
.RequiresRestart()
3633
)
3734
.AddPropertyToUI(x => x.EnableMultipleLoadouts, propertyBuilder => propertyBuilder
38-
.AddToSection(sectionId)
39-
.WithDisplayName("(Experimental) Enable Multiple Loadouts")
40-
.WithDescription("When set, you will be able to create multiple loadouts for a game.")
35+
.AddToSection(Sections.Experimental)
36+
.WithDisplayName("Enable multiple loadouts")
37+
.WithDescription("Allows you to create multiple Loadouts.")
4138
.UseBooleanContainer()
4239
)
4340
);

src/NexusMods.App.UI/Overlays/MetricsOptIn/MetricsOptInViewModel.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,11 @@ public MetricsOptInViewModel(ISettingsManager settingsManager, IMarkdownRenderer
2929
MarkdownRendererViewModel = markdownRendererViewModel;
3030

3131
MarkdownRendererViewModel.Contents = """
32-
## Telemetry and usage data
32+
## Help us improve
3333
3434
Help us provide you with the best modding experience.
3535
36-
With your permission, we will collect analytics information and send it to our team to help us improve quality and performance.
37-
38-
This information is sent anonymously and will never be shared with a 3rd party.
36+
With your permission, we will collect anonymous analytics information and send it to our team to help us improve quality and performance.
3937
4038
[More information about the data we track](https://help.nexusmods.com/article/132-diagnostics-and-usage-nexus-mods-app)
4139
""";

src/NexusMods.App.UI/Pages/Settings/SettingsView.axaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public SettingsView()
3737
foreach (var group in grouped)
3838
{
3939
res.Add(dict[group.Key]);
40-
res.AddRange(group);
40+
res.AddRange(group.OrderBy(x => x.PropertyUIDescriptor.DisplayName, StringComparer.OrdinalIgnoreCase));
4141
}
4242

4343
return res;

src/NexusMods.App.UI/Settings/LanguageSettings.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,9 @@ static LanguageSettings()
3030

3131
public static ISettingsBuilder Configure(ISettingsBuilder settingsBuilder)
3232
{
33-
// TODO: put in some section
34-
var sectionId = SectionId.DefaultValue;
35-
3633
return settingsBuilder.AddToUI<LanguageSettings>(builder => builder
3734
.AddPropertyToUI(x => x.UICulture, propertyBuilder => propertyBuilder
38-
.AddToSection(sectionId)
35+
.AddToSection(Sections.General)
3936
.WithDisplayName("Language")
4037
.WithDescription("Set the language for the application.")
4138
.UseSingleValueMultipleChoiceContainer(

src/NexusMods.App.UI/Settings/LoadoutGridSettings.cs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,17 @@ public record LoadoutGridSettings : ISettings
1111

1212
public static ISettingsBuilder Configure(ISettingsBuilder settingsBuilder)
1313
{
14-
// TODO: put in some section
15-
var sectionId = SectionId.DefaultValue;
16-
1714
return settingsBuilder.AddToUI<LoadoutGridSettings>(builder => builder
1815
.AddPropertyToUI(x => x.ShowGameFiles, propertyBuilder => propertyBuilder
19-
.AddToSection(sectionId)
20-
.WithDisplayName("Show Game Files")
21-
.WithDescription("Shows the Game Files in the Mods page.")
16+
.AddToSection(Sections.Advanced)
17+
.WithDisplayName("Show game files")
18+
.WithDescription("Show game files as a mod alongside your added mods.")
2219
.UseBooleanContainer()
2320
)
2421
.AddPropertyToUI(x => x.ShowOverride, propertyBuilder => propertyBuilder
25-
.AddToSection(sectionId)
26-
.WithDisplayName("Show Override")
27-
.WithDescription("Shows Override in the Mods page.")
22+
.AddToSection(Sections.Advanced)
23+
.WithDisplayName("Show Override mod")
24+
.WithDescription("Shows the Override mod, which contains files generated or modified during gameplay that aren't part of any specific mod.")
2825
.UseBooleanContainer()
2926
)
3027
);

src/NexusMods.App.UI/Settings/TextEditorSettings.cs

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,6 @@ public record TextEditorSettings : ISettings
1212

1313
public static ISettingsBuilder Configure(ISettingsBuilder settingsBuilder)
1414
{
15-
// TODO: put in some section
16-
var sectionId = SectionId.DefaultValue;
17-
18-
// TODO: add font size to UI (requires new component)
19-
20-
return settingsBuilder.AddToUI<TextEditorSettings>(builder => builder
21-
.AddPropertyToUI(x => x.ThemeName, propertyBuilder => propertyBuilder
22-
.AddToSection(sectionId)
23-
.WithDisplayName("Text Editor Theme")
24-
.WithDescription("Set the desired theme in the text editor.")
25-
.UseSingleValueMultipleChoiceContainer(
26-
valueComparer: EqualityComparer<ThemeName>.Default,
27-
allowedValues: Enum.GetValues<ThemeName>(),
28-
valueToDisplayString: x => x.ToString()
29-
)
30-
)
31-
);
15+
return settingsBuilder;
3216
}
3317
}

src/NexusMods.CrossPlatform/LoggingSettings.cs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,17 +58,14 @@ public record LoggingSettings : ISettings
5858
/// <inheritdoc/>
5959
public static ISettingsBuilder Configure(ISettingsBuilder settingsBuilder)
6060
{
61-
// TODO: put in some section
62-
var sectionId = SectionId.DefaultValue;
63-
6461
return settingsBuilder
6562
.ConfigureDefault(serviceProvider => CreateDefault(serviceProvider.GetRequiredService<IFileSystem>().OS))
6663
.ConfigureStorageBackend<LoggingSettings>(builder => builder.UseJson())
6764
.AddToUI<LoggingSettings>(builder => builder
6865
.AddPropertyToUI(x => x.MinimumLevel, propertyBuilder => propertyBuilder
69-
.AddToSection(sectionId)
70-
.WithDisplayName("Minimum Logging Level")
71-
.WithDescription("Set the minimum logging level. Recommended: Debug")
66+
.AddToSection(Sections.General)
67+
.WithDisplayName("Minimum logging level")
68+
.WithDescription("Sets the minimum logging level. Recommended: Debug")
7269
.UseSingleValueMultipleChoiceContainer(
7370
valueComparer: EqualityComparer<LogLevel>.Default,
7471
allowedValues: [
@@ -81,9 +78,9 @@ public static ISettingsBuilder Configure(ISettingsBuilder settingsBuilder)
8178
.RequiresRestart()
8279
)
8380
.AddPropertyToUI(x => x.LogToConsole, propertyBuilder => propertyBuilder
84-
.AddToSection(sectionId)
85-
.WithDisplayName("Log to Console")
86-
.WithDescription("When enabled, logs will be written to the console as well as the log file.")
81+
.AddToSection(Sections.DeveloperTools)
82+
.WithDisplayName("Log to stdout")
83+
.WithDescription("Enables the ConsoleTarget for all loggers.")
8784
.UseBooleanContainer()
8885
.RequiresRestart()
8986
)

src/NexusMods.Icons/IconValues.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,9 @@ public static class IconValues
136136

137137
#region Editor
138138

139+
// https://pictogrammers.com/library/mdi/icon/poll
140+
public static readonly IconValue BarChart = new ProjektankerIcon("mdi-poll");
141+
139142
// https://pictogrammers.com/library/mdi/icon/drag-horizontal-variant/
140143
public static readonly IconValue DragHandleHorizontal = new ProjektankerIcon("mdi-drag-horizontal-variant");
141144

@@ -177,6 +180,9 @@ public static class IconValues
177180

178181
#region Hardware
179182

183+
// https://pictogrammers.com/library/mdi/icon/monitor/
184+
public static readonly IconValue Desktop = new ProjektankerIcon("mdi-monitor");
185+
180186
// https://pictogrammers.com/library/mdi/icon/gamepad-square-outline/
181187
public static readonly IconValue Game = new ProjektankerIcon("mdi-gamepad-square-outline");
182188

@@ -227,6 +233,13 @@ public static class IconValues
227233

228234
#endregion
229235

236+
#region Social
237+
238+
// https://pictogrammers.com/library/mdi/icon/school
239+
public static readonly IconValue School = new ProjektankerIcon("mdi-school");
240+
241+
#endregion
242+
230243
#region Toggle
231244

232245
// https://pictogrammers.com/library/mdi/icon/star/

src/NexusMods.Settings/Services.cs

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,33 @@ public static IServiceCollection AddSettingsManager(this IServiceCollection serv
1212
.AddSingleton<ISettingsManager, SettingsManager>()
1313
.AddSettingsSection(new SettingsSectionSetup
1414
{
15-
Id = SectionId.DefaultValue,
16-
IconFunc = static () => IconValues.Error,
17-
Name = "No Section",
15+
Id = Sections.General,
16+
IconFunc = static () => IconValues.Desktop,
17+
Name = "General",
18+
})
19+
.AddSettingsSection(new SettingsSectionSetup
20+
{
21+
Id = Sections.Privacy,
22+
IconFunc = static () => IconValues.BarChart,
23+
Name = "Privacy",
24+
})
25+
.AddSettingsSection(new SettingsSectionSetup
26+
{
27+
Id = Sections.Advanced,
28+
IconFunc = static () => IconValues.School,
29+
Name = "Advanced",
30+
})
31+
.AddSettingsSection(new SettingsSectionSetup
32+
{
33+
Id = Sections.DeveloperTools,
34+
IconFunc = static () => IconValues.Code,
35+
Name = "Developer tools",
36+
})
37+
.AddSettingsSection(new SettingsSectionSetup
38+
{
39+
Id = Sections.Experimental,
40+
IconFunc = static () => IconValues.WarningAmber,
41+
Name = "Experimental - Not currently supported",
1842
});
1943
}
2044
}

src/NexusMods.Settings/SettingsManager.cs

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public SettingsManager(IServiceProvider serviceProvider)
4141

4242
var settingsSectionSetups = serviceProvider.GetServices<SettingsSectionSetup>().ToArray();
4343

44-
// NOTE(erri120): This has to be Lazy because the Icon isn't available until Avalonia starts up.
44+
// NOTE(erri120): This has to be Lazy because icons aren't available until Avalonia starts up.
4545
_sectionDescriptors = new Lazy<ISettingsSectionDescriptor[]>(() => settingsSectionSetups
4646
.Select(descriptor => (ISettingsSectionDescriptor)new SettingsSectionDescriptor
4747
{
@@ -53,16 +53,6 @@ public SettingsManager(IServiceProvider serviceProvider)
5353
mode: LazyThreadSafetyMode.ExecutionAndPublication
5454
);
5555

56-
if (CompileConstants.IsDebug)
57-
{
58-
var ids = new HashSet<SectionId>();
59-
foreach (var sectionDescriptor in settingsSectionSetups)
60-
{
61-
var id = sectionDescriptor.Id;
62-
Debug.Assert(ids.Add(id), $"duplicate section ID: {id}");
63-
}
64-
}
65-
6656
var baseStorageBackendArray = serviceProvider.GetServices<IBaseSettingsStorageBackend>().ToArray();
6757
var settingsTypeInformationArray = serviceProvider.GetServices<SettingsTypeInformation>().ToArray();
6858
var defaultBaseStorageBackend = serviceProvider.GetService<DefaultSettingsStorageBackend>()?.Backend;
@@ -72,6 +62,21 @@ public SettingsManager(IServiceProvider serviceProvider)
7262
_storageBackendMappings = builderOutput.StorageBackendMappings;
7363
_asyncStorageBackendMappings = builderOutput.AsyncStorageBackendMappings;
7464
_propertyBuilderOutputs = builderOutput.PropertyBuilderOutputs;
65+
66+
if (CompileConstants.IsDebug)
67+
{
68+
var ids = new HashSet<SectionId>();
69+
foreach (var sectionDescriptor in settingsSectionSetups)
70+
{
71+
var id = sectionDescriptor.Id;
72+
Debug.Assert(ids.Add(id), $"duplicate section ID: {id}");
73+
}
74+
75+
foreach (var propertyBuilderOutput in _propertyBuilderOutputs)
76+
{
77+
Debug.Assert(settingsSectionSetups.Any(x => x.Id == propertyBuilderOutput.SectionId), $"section not registered: {propertyBuilderOutput.SectionId} (for setting {propertyBuilderOutput.DisplayName})");
78+
}
79+
}
7580
}
7681

7782
private void CoreSet<T>(T value, bool notify) where T : class, ISettings, new()

src/NexusMods.SingleProcess/CliSettings.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public class CliSettings() : ISettings
1212
/// <inheritdoc />
1313
public static ISettingsBuilder Configure(ISettingsBuilder settingsBuilder)
1414
{
15-
var sectionId = SectionId.DefaultValue;
15+
var sectionId = Sections.DeveloperTools;
1616
return settingsBuilder
1717
.ConfigureDefault(CreateDefault)
1818
.ConfigureStorageBackend<CliSettings>(builder => builder.UseJson())

src/NexusMods.StandardGameLocators/GameLocatorSettings.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,13 @@ public record GameLocatorSettings : ISettings
1010

1111
public static ISettingsBuilder Configure(ISettingsBuilder settingsBuilder)
1212
{
13-
// TODO: put in some section
14-
var sectionId = SectionId.DefaultValue;
15-
1613
return settingsBuilder
1714
.ConfigureStorageBackend<GameLocatorSettings>(builder => builder.UseJson())
1815
.AddToUI<GameLocatorSettings>(builder => builder
1916
.AddPropertyToUI(x => x.EnableXboxGamePass, propertyBuilder => propertyBuilder
20-
.AddToSection(sectionId)
21-
.WithDisplayName("(Experimental) Enable Xbox Game Pass support")
22-
.WithDescription("For testing the Xbox Game Pass detection")
17+
.AddToSection(Sections.Experimental)
18+
.WithDisplayName("Enable Xbox Game Pass support")
19+
.WithDescription("Allows you to manage games installed with Xbox Game Pass.")
2320
.UseBooleanContainer()
2421
)
2522
);

0 commit comments

Comments
 (0)