Skip to content

Commit

Permalink
imp - Two numbers in the section can be confusing
Browse files Browse the repository at this point in the history
---

We have made improvements to how we detect unsupported configuration for a settings key. Terminaux will implement unavailable selections so that these are greyed out and can't be selected.

---

Type: imp
Breaking: False
Doc Required: False
Part: 1/1
  • Loading branch information
AptiviCEO committed Feb 12, 2024
1 parent c80a452 commit 9569d36
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 18 deletions.
34 changes: 17 additions & 17 deletions public/Nitrocid/Kernel/Configuration/Settings/SettingsApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,30 +170,31 @@ public static void OpenSection(string Section, SettingsEntry SettingsSection, Ba
{
// Populate sections
var sections = new List<InputChoiceInfo>();
var displayUnsupportedConfigs = new List<string>();

// Check for platform compatibility
string Notes = "";
int offset = 0;
var unsupportedConfigs = SectionToken.Where((sk) => sk.Unsupported).ToArray();
var unsupportedConfigNames = unsupportedConfigs.Select((sk) => Translate.DoTranslation(sk.Name)).ToArray();
bool hasUnsupportedConfigs = unsupportedConfigs.Length > 0;
if (hasUnsupportedConfigs)
Notes = Translate.DoTranslation("One or more of the following settings found in this section are unsupported in your platform:") + $" {string.Join(", ", unsupportedConfigNames)}";

// Populate sections
for (int SectionIndex = 0; SectionIndex <= MaxOptions - 1; SectionIndex++)
{
var Setting = SectionToken[SectionIndex];

// Check to see if the host platform is supported
bool platformUnsupported = SettingsAppTools.ValidatePlatformCompatibility(Setting);
if (platformUnsupported)
{
displayUnsupportedConfigs.Add(Translate.DoTranslation(Setting.Name));
Notes = Translate.DoTranslation("One or more of the following settings found in this section are unsupported in your platform:") + $" {string.Join(", ", displayUnsupportedConfigs)}";
offset++;
if (Setting.Unsupported)
continue;
}

// Now, populate the input choice info
object CurrentValue = ConfigTools.GetValueFromEntry(Setting, settingsType);
string choiceName = $"{SectionIndex + 1}";
string choiceTitle = $"{Translate.DoTranslation(Setting.Name)} [{CurrentValue}]";
string choiceDesc = Translate.DoTranslation(Setting.Description);
var ici = new InputChoiceInfo(
$"{SectionIndex + 1 - offset}/{SectionIndex + 1}",
$"{Translate.DoTranslation(Setting.Name)} [{CurrentValue}]",
Translate.DoTranslation(Setting.Description)
choiceName,
choiceTitle,
choiceDesc
);
sections.Add(ici);
}
Expand All @@ -202,7 +203,7 @@ public static void OpenSection(string Section, SettingsEntry SettingsSection, Ba
// Populate the alt sections correctly
var altSections = new List<InputChoiceInfo>()
{
new($"{MaxOptions + 1 - offset}/{MaxOptions + 1}", Translate.DoTranslation("Go Back..."))
new($"{MaxOptions + 1}", Translate.DoTranslation("Go Back..."))
};

// Prompt user and check for input
Expand All @@ -221,8 +222,7 @@ public static void OpenSection(string Section, SettingsEntry SettingsSection, Ba
// Check the answer
var allSections = sections.Union(altSections).ToArray();
string answerChoice = allSections[Answer - 1].ChoiceName;
string answerNumberReal = answerChoice[(answerChoice.IndexOf('/') + 1)..];
int finalAnswer = Answer < 0 ? 0 : Convert.ToInt32(answerNumberReal);
int finalAnswer = Answer < 0 ? 0 : Convert.ToInt32(answerChoice);
DebugWriter.WriteDebug(DebugLevel.I, "Succeeded. Checking the answer if it points to the right direction...");
if (finalAnswer >= 1 & finalAnswer <= MaxOptions)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ internal static void SystemInformation()
);
}

internal static bool ValidatePlatformCompatibility(SettingsKey settings)
internal static bool IsUnsupported(SettingsKey settings)
{
string[] keyUnsupportedPlatforms = settings.UnsupportedPlatforms.ToArray() ?? [];
bool platformUnsupported = false;
Expand Down
4 changes: 4 additions & 0 deletions public/Nitrocid/Kernel/Configuration/Settings/SettingsKey.cs
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,10 @@ public KernelPathType ValuePathType
public string Tip =>
tip;

[JsonIgnore]
internal bool Unsupported =>
SettingsAppTools.IsUnsupported(this);

internal ISettingsKeyInput KeyInput
{
get
Expand Down

0 comments on commit 9569d36

Please sign in to comment.