Skip to content

Commit

Permalink
add - doc - Added mod manager TUI
Browse files Browse the repository at this point in the history
---

We've added an initial implementation of the mod manager interactive TUI.
Currently, it's informational, but it will have an ability to start/stop
mods, as well as some more options.

---

Type: add
Breaking: False
Doc Required: True
Backport Required: False
Part: 1/1
  • Loading branch information
AptiviCEO committed Jan 21, 2025
1 parent 7a0b8ed commit 43ede7d
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
using Nitrocid.ConsoleBase.Colors;
using Terminaux.Writer.ConsoleWriters;
using Nitrocid.Extras.Mods.Modifications;
using Nitrocid.Extras.Mods.Modifications.Interactive;
using Terminaux.Inputs.Interactive;

namespace Nitrocid.Extras.Mods.Commands
{
Expand Down Expand Up @@ -173,6 +175,12 @@ public override int Execute(CommandParameters parameters, ref string variableVal
ModManager.StartMods();
break;
}
case "tui":
{
var tui = new ModManagerTui();
InteractiveTuiTools.OpenInteractiveTui(tui);
break;
}

default:
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
using System;
using Nitrocid.Extras.Mods.Modifications;
using Nitrocid.Extras.Mods.Modifications.ManPages;
using Nitrocid.Extras.Mods.Modifications.Interactive;

namespace Nitrocid.Extras.Mods.Commands
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@
using System.Collections.Generic;
using System.Text;
using Textify.General;
using Nitrocid.Extras.Mods.Modifications.ManPages;

namespace Nitrocid.Extras.Mods.Modifications.ManPages
namespace Nitrocid.Extras.Mods.Modifications.Interactive
{
/// <summary>
/// Manual viewer class
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
//
// Nitrocid KS Copyright (C) 2018-2025 Aptivi
//
// This file is part of Nitrocid KS
//
// Nitrocid KS is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Nitrocid KS is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY, without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
//

using Terminaux.Inputs.Styles.Infobox;
using Terminaux.Inputs.Interactive;
using Nitrocid.Languages;
using System.Collections.Generic;
using System.Text;
using Textify.General;
using Nitrocid.Extras.Mods.Modifications.ManPages;
using Terminaux.Writer.ConsoleWriters;

namespace Nitrocid.Extras.Mods.Modifications.Interactive
{
/// <summary>
/// Mod manager TUI class
/// </summary>
public class ModManagerTui : BaseInteractiveTui<string>, IInteractiveTui<string>
{
/// <inheritdoc/>
public override IEnumerable<string> PrimaryDataSource =>
ModManager.ListMods().Keys;

/// <inheritdoc/>
public override string GetInfoFromItem(string item)
{
// Get some info from the mod
var selectedMod = ModManager.GetMod(item);
if (selectedMod is null)
return "";

// Render them to the second pane
return
ListEntryWriterColor.RenderListEntry(Translate.DoTranslation("Name"), selectedMod.ModName) + CharManager.NewLine +
ListEntryWriterColor.RenderListEntry(Translate.DoTranslation("File name"), selectedMod.ModFileName) + CharManager.NewLine +
ListEntryWriterColor.RenderListEntry(Translate.DoTranslation("File path"), selectedMod.ModFilePath) + CharManager.NewLine +
ListEntryWriterColor.RenderListEntry(Translate.DoTranslation("Version"), selectedMod.ModVersion) + CharManager.NewLine + CharManager.NewLine +
ListEntryWriterColor.RenderListEntry(Translate.DoTranslation("Languages"), $"{selectedMod.ModStrings.Count}") + CharManager.NewLine +
ListEntryWriterColor.RenderListEntry(Translate.DoTranslation("Entry point"), selectedMod.ModScript.GetType().ToString());
;
}

/// <inheritdoc/>
public override string GetStatusFromItem(string item)
{
var selectedMod = ModManager.GetMod(item);
if (selectedMod is null)
return "";
return selectedMod.ModName;
}

/// <inheritdoc/>
public override string GetEntryFromItem(string item)
{
var selectedMod = ModManager.GetMod(item);
if (selectedMod is null)
return "";
return selectedMod.ModName;
}
}
}
4 changes: 2 additions & 2 deletions public/Nitrocid.Addons/Nitrocid.Extras.Mods/ModsInit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ internal class ModsInit : IAddon
}),
new CommandArgumentInfo(new[]
{
new CommandArgumentPart(true, "list/reloadall/stopall/startall", new()
new CommandArgumentPart(true, "list/reloadall/stopall/startall/tui", new()
{
ExactWording = ["list", "reloadall", "stopall", "startall"]
ExactWording = ["list", "reloadall", "stopall", "startall", "tui"]
}),
}),
], new ModManCommand(), CommandFlags.Strict),
Expand Down

0 comments on commit 43ede7d

Please sign in to comment.