Skip to content

Commit

Permalink
imp - brk|doc - Used Terminaux 6.0 (pt. 2)
Browse files Browse the repository at this point in the history
---

We've managed to use the modern cyclic writers instead of the old-school
ones for readability. However, the whole commit series introduced a set of
graphical glitches across some of the TUIs, such as The Nitrocid Homepage,
and another set of bugs, such as switch not working in the settings TUI.
We'll find solutions.

---

Type: imp
Breaking: True
Doc Required: True
Backport Required: False
Part: 2/2
  • Loading branch information
AptiviCEO committed Dec 24, 2024
1 parent bfca298 commit aac2c27
Show file tree
Hide file tree
Showing 81 changed files with 1,556 additions and 900 deletions.
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
changes!
-->
<NitrocidModAPIVersionMajor>3.0.27</NitrocidModAPIVersionMajor>
<NitrocidModAPIVersionChangeset>12</NitrocidModAPIVersionChangeset>
<NitrocidModAPIVersionChangeset>13</NitrocidModAPIVersionChangeset>

<!-- The above two properties are to be installed to the file version -->
<NitrocidModAPIVersion>$(NitrocidModAPIVersionMajor).$(NitrocidModAPIVersionChangeset)</NitrocidModAPIVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
using Terminaux.Inputs;
using Terminaux.Writer.CyclicWriters;
using Terminaux.Writer.CyclicWriters.Renderer.Tools;
using Terminaux.Colors.Transformation;
using Terminaux.Writer.CyclicWriters.Renderer;

namespace Nitrocid.Extras.Amusements.Amusements.Games
{
Expand Down Expand Up @@ -89,11 +91,26 @@ static void ResetAll()
int height = consoleSixthsHeight * i + 3;
var horse = horses[i];
var finalColor = i + 1 == selected ? ConsoleColors.White : horse.HorseColor;
var border = new Border()
{
Left = boxLeft,
Top = height,
InteriorWidth = boxWidth,
InteriorHeight = 1,
Color = finalColor
};
var progress = new SimpleProgress(horse.HorseProgress, 100)
{
LeftMargin = 5,
RightMargin = 5,
ProgressActiveForegroundColor = finalColor,
ProgressForegroundColor = TransformationTools.GetDarkBackground(finalColor),
};
builder.Append(
TextWriterWhereColor.RenderWhereColor(Translate.DoTranslation("Horse") + $" {horse.HorseNumber}", 1, height - 1, finalColor) +
BorderColor.RenderBorder(boxLeft, height, boxWidth, 1, finalColor) +
border.Render() +
TextWriterWhereColor.RenderWhereColor($"{horse.HorseProgress:000}%", 2, height + 1, finalColor) +
ProgressBarColor.RenderProgress(horse.HorseProgress, progressLeft, height, ConsoleWrapper.WindowWidth - 10, finalColor, finalColor)
ContainerTools.RenderRenderable(progress, new(progressLeft, height))
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,9 @@ public static void InitializeSnaker(bool Simulation)
ScreenPart part = new();

// Draw the floor
part.BackgroundColor(FloorColor);
part.AddDynamicText(() =>
{
StringBuilder floor = new();
StringBuilder floor = new(ColorTools.RenderSetConsoleColor(FloorColor, true));

int FloorTopLeftEdge = 2;
int FloorBottomLeftEdge = 2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
using Terminaux.Base;
using Terminaux.Colors.Data;
using Terminaux.Inputs;
using Terminaux.Writer.CyclicWriters;

namespace Nitrocid.Extras.Amusements.Amusements.Games
{
Expand Down Expand Up @@ -131,7 +132,15 @@ private static void RenderBoxes(string RandomWord, int maxGuesses, char[,] curre
int boxExteriorLength = 3;
int currentX = marginX + (boxExteriorLength + 2) * (l - 1);
int currentY = marginY + boxExteriorLength * (g - 1);
BorderColor.WriteBorder(currentX, currentY, 3, 1, finalColor);
var border = new Border()
{
Left = currentX,
Top = currentY,
InteriorWidth = 3,
InteriorHeight = 1,
Color = finalColor,
};
TextWriterRaw.WriteRaw(border.Render());

// Render a character inside it
TextWriterWhereColor.WriteWhere(currChar.ToString(), currentX + 2, currentY + 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
using Terminaux.Colors;
using Terminaux.Base;
using Terminaux.Base.Extensions;
using Terminaux.Writer.CyclicWriters;
using Listing = Nitrocid.Files.Folders.Listing;

namespace Nitrocid.Extras.BassBoom.Animations.Lyrics
{
Expand Down Expand Up @@ -116,7 +118,15 @@ public static void VisualizeLyric(string path)
var lyricLines = lyric.Lines;
var shownLines = new List<LyricLine>();
DebugWriter.WriteDebug(DebugLevel.I, "{0} lyric lines", lyricLines.Count);
BoxFrameColor.WriteBoxFrame(fileName, 2, ConsoleWrapper.WindowHeight - 4, ConsoleWrapper.WindowWidth - 6, 1);
var boxFrame = new BoxFrame()
{
Text = fileName,
Left = 2,
Top = ConsoleWrapper.WindowHeight - 4,
InteriorWidth = ConsoleWrapper.WindowWidth - 6,
InteriorHeight = 1,
};
TextWriterRaw.WriteRaw(boxFrame.Render());
DebugWriter.WriteDebug(DebugLevel.I, "Visualizing lyric file {0} [file name: {1}]", path, fileName);

// Start the elapsed time in 3...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
using Terminaux.Base;
using Terminaux.Inputs;
using BassBoom.Basolia;
using Terminaux.Writer.CyclicWriters;

namespace Nitrocid.Extras.BassBoom.Commands
{
Expand Down Expand Up @@ -96,10 +97,32 @@ public override int Execute(CommandParameters parameters, ref string variableVal
Translate.DoTranslation("Unknown Genre");
var totalSpan = AudioInfoTools.GetDurationSpanFromSamples(media, total);
string duration = totalSpan.ToString();
ListEntryWriterColor.WriteListEntry(Translate.DoTranslation("Name"), musicName);
ListEntryWriterColor.WriteListEntry(Translate.DoTranslation("Artist"), musicArtist);
ListEntryWriterColor.WriteListEntry(Translate.DoTranslation("Genre"), musicGenre);
ListEntryWriterColor.WriteListEntry(Translate.DoTranslation("Duration"), duration);
var musicNameEntry = new ListEntry()
{
Entry = Translate.DoTranslation("Name"),
Value = musicName,
};
var musicArtistEntry = new ListEntry()
{
Entry = Translate.DoTranslation("Artist"),
Value = musicArtist,
};
var musicGenreEntry = new ListEntry()
{
Entry = Translate.DoTranslation("Genre"),
Value = musicGenre,
};
var musicDurationEntry = new ListEntry()
{
Entry = Translate.DoTranslation("Duration"),
Value = duration,
};
TextWriterRaw.WriteRaw(
musicNameEntry.Render() +
musicArtistEntry.Render() +
musicGenreEntry.Render() +
musicDurationEntry.Render()
);

// Wait until the song stops or the user bails
TextWriters.Write(Translate.DoTranslation("Press 'q' to stop playing."), KernelColorType.Tip);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
using Nitrocid.Shell.ShellBase.Switches;
using System.Collections.Generic;
using System.Linq;
using Terminaux.Writer.CyclicWriters;

namespace Nitrocid.Extras.Caffeine.Commands
{
Expand Down Expand Up @@ -66,7 +67,11 @@ public override int Execute(CommandParameters parameters, ref string variableVal
{
TextWriters.Write(Translate.DoTranslation("The seconds in which your cup will be ready is invalid."), KernelColorType.Error);
TextWriters.Write(Translate.DoTranslation("If you're trying to supply a name of the drink, check out the list below:"), KernelColorType.Tip);
ListWriterColor.WriteList(caffeines);
var listing = new Listing()
{
Objects = caffeines,
};
TextWriterRaw.WriteRaw(listing.Render());
return 26;
}
AlarmTools.StartAlarm("Caffeine", Translate.DoTranslation("Your cup is now ready!"), alarmSeconds, nameSpecified ? Translate.DoTranslation(secsOrName) : "");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
using Terminaux.Writer.FancyWriters;
using Terminaux.Base;
using Terminaux.Colors;
using Terminaux.Writer.CyclicWriters;
using Terminaux.Writer.ConsoleWriters;

namespace Nitrocid.Extras.Calendar.Calendar
{
Expand Down Expand Up @@ -162,7 +164,18 @@ public static void PrintCalendar(int Year, int Month, CalendarTypes calendar = C
CurrentDayMark = $"{markStart}{CurrentDay}{markEnd}";
CalendarData[CurrentWeekIndex + 1, currentDay - 1] = CurrentDayMark;
}
TableColor.WriteTable(CalendarData, 2, 3, ConsoleWrapper.WindowWidth - 4, ConsoleWrapper.WindowHeight - 4, true, CalendarCellOptions);

var calendarTable = new Table()
{
Rows = CalendarData,
Left = 2,
Top = 3,
InteriorWidth = ConsoleWrapper.WindowWidth - 4,
InteriorHeight = ConsoleWrapper.WindowHeight - 4,
Header = true,
Settings = CalendarCellOptions,
};
TextWriterRaw.WriteRaw(calendarTable.Render());
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
using Terminaux.Inputs;
using Terminaux.Writer.CyclicWriters.Renderer.Tools;
using Terminaux.Writer.MiscWriters;
using Terminaux.Writer.CyclicWriters;

namespace Nitrocid.Extras.Calendar.Calendar
{
Expand Down Expand Up @@ -128,14 +129,23 @@ private static void RenderKeybindings(ref Screen screen)
{
// Make a screen part
var part = new ScreenPart();
part.AddDynamicText(() => KeybindingsWriter.RenderKeybindings(bindings,
KernelColorTools.GetColor(KernelColorType.TuiKeyBindingBuiltin),
KernelColorTools.GetColor(KernelColorType.TuiKeyBindingBuiltinForeground),
KernelColorTools.GetColor(KernelColorType.TuiKeyBindingBuiltinBackground),
KernelColorTools.GetColor(KernelColorType.TuiKeyBindingOption),
KernelColorTools.GetColor(KernelColorType.TuiOptionForeground),
KernelColorTools.GetColor(KernelColorType.TuiOptionBackground),
0, ConsoleWrapper.WindowHeight - 1));
part.AddDynamicText(() =>
{
var keybindings = new Keybindings()
{
KeybindingList = bindings,
Left = 0,
Top = ConsoleWrapper.WindowHeight - 1,
Width = ConsoleWrapper.WindowWidth - 1,
BuiltinColor = KernelColorTools.GetColor(KernelColorType.TuiKeyBindingBuiltin),
BuiltinForegroundColor = KernelColorTools.GetColor(KernelColorType.TuiKeyBindingBuiltinForeground),
BuiltinBackgroundColor = KernelColorTools.GetColor(KernelColorType.TuiKeyBindingBuiltinBackground),
OptionColor = KernelColorTools.GetColor(KernelColorType.TuiKeyBindingOption),
OptionForegroundColor = KernelColorTools.GetColor(KernelColorType.TuiOptionForeground),
OptionBackgroundColor = KernelColorTools.GetColor(KernelColorType.TuiOptionBackground),
};
return keybindings.Render();
});
screen.AddBufferedPart("Interactive calendar - Keybindings", part);
}

Expand Down Expand Up @@ -170,11 +180,16 @@ private static void RenderViewBox(ref Screen screen)
int SeparatorMaximumHeightInterior = ConsoleWrapper.WindowHeight - 4;

// Render the box
builder.Append(
$"{ColorTools.RenderSetConsoleColor(KernelColorTools.GetColor(KernelColorType.TuiPaneSeparator))}" +
$"{ColorTools.RenderSetConsoleColor(KernelColorTools.GetColor(KernelColorType.Background), true)}" +
$"{BorderColor.RenderBorderPlain(0, SeparatorMinimumHeight, SeparatorConsoleWidthInterior, SeparatorMaximumHeightInterior)}"
);
var border = new Border()
{
Left = 0,
Top = SeparatorMinimumHeight,
InteriorWidth = SeparatorConsoleWidthInterior,
InteriorHeight = SeparatorMaximumHeightInterior,
Color = KernelColorTools.GetColor(KernelColorType.TuiPaneSeparator),
BackgroundColor = KernelColorTools.GetColor(KernelColorType.Background),
};
builder.Append(border.Render());
return builder.ToString();
});
screen.AddBufferedPart("Interactive calendar - View box", part);
Expand Down Expand Up @@ -221,9 +236,17 @@ private static void RenderCalendar((int Year, int Month, int Day, CalendarTypes
int boxTop = 3;
int boxWidth = 4 + (6 * 6);
int boxHeight = 13;
builder.Append(
BorderColor.RenderBorder(CalendarTitle, boxLeft, boxTop, boxWidth, boxHeight, boxForeground, background)
);
var border = new Border()
{
Text = CalendarTitle,
Left = boxLeft,
Top = boxTop,
InteriorWidth = boxWidth,
InteriorHeight = boxHeight,
Color = boxForeground,
BackgroundColor = background,
};
builder.Append(border.Render());

// Make a calendar
int dayPosX = boxLeft + 1;
Expand Down Expand Up @@ -311,9 +334,17 @@ private static void RenderCalendar((int Year, int Month, int Day, CalendarTypes
int eventBoxTop = 3;
int eventBoxWidth = ConsoleWrapper.WindowWidth - eventBoxLeft - 6;
int eventBoxHeight = ConsoleWrapper.WindowHeight - 8;
builder.Append(
BorderColor.RenderBorder(Translate.DoTranslation("Events and reminders for") + $" {CalendarTitle}", eventBoxLeft, eventBoxTop, eventBoxWidth, eventBoxHeight, boxForeground, background)
);
var eventBorder = new Border()
{
Text = Translate.DoTranslation("Events and reminders for") + $" {CalendarTitle}",
Left = eventBoxLeft,
Top = eventBoxTop,
InteriorWidth = eventBoxWidth,
InteriorHeight = eventBoxHeight,
Color = boxForeground,
BackgroundColor = background,
};
builder.Append(eventBorder.Render());

// List all events and reminders in a separate builder to wrap
var eventsBuilder = new StringBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
using Terminaux.Writer.ConsoleWriters;
using Terminaux.Base.Extensions;
using Textify.Data.Figlet;
using Terminaux.Writer.CyclicWriters;
using Terminaux.Writer.CyclicWriters.Renderer;

namespace Nitrocid.Extras.Chemistry.Screensavers
{
Expand Down Expand Up @@ -66,9 +68,16 @@ public override void ScreensaverLogic()
int height = ConsoleWrapper.WindowHeight - 4;
int posX = ConsoleWrapper.WindowWidth / 2 - width / 2;
int posY = 1;
periodicItem.Append(
BorderColor.RenderBorder(posX, posY, width, height, ConsoleColors.Black, color)
);
var border = new Border()
{
Left = posX,
Top = posY,
InteriorWidth = width,
InteriorHeight = height,
Color = ConsoleColors.Black,
BackgroundColor = color,
};
periodicItem.Append(border.Render());

// Render the element properties in small fonts first
int elementAtomicNumberPosX = posX + 3;
Expand All @@ -88,9 +97,13 @@ public override void ScreensaverLogic()
int elementSymbolFigletHeight = FigletTools.GetFigletHeight(substance.Symbol, font);
int elementSymbolFigletPosX = ConsoleWrapper.WindowWidth / 2 - elementSymbolFigletWidth / 2 + 1;
int elementSymbolFigletPosY = ConsoleWrapper.WindowHeight / 2 - elementSymbolFigletHeight / 2 - 1;
periodicItem.Append(
FigletWhereColor.RenderFigletWhere(substance.Symbol, elementSymbolFigletPosX, elementSymbolFigletPosY, true, font, ConsoleColors.Black, color)
);
var figletSubstance = new FigletText(font)
{
Text = substance.Symbol,
ForegroundColor = ConsoleColors.Black,
BackgroundColor = color,
};
periodicItem.Append(ContainerTools.RenderRenderable(figletSubstance, new(elementSymbolFigletPosX, elementSymbolFigletPosY)));

// Render the chemical element preview
TextWriterRaw.WriteRaw(periodicItem.ToString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
using Nitrocid.Shell.ShellBase.Commands;
using System;
using System.Collections.Generic;
using Terminaux.Writer.CyclicWriters;

namespace Nitrocid.Extras.Diagnostics.Commands
{
Expand Down Expand Up @@ -55,8 +56,11 @@ public override int Execute(CommandParameters parameters, ref string variableVal
string threadAddress = trace.Key;
string[] threadTrace = trace.Value;
TextWriters.Write(Translate.DoTranslation("Thread stack trace information for {0}") + "\n", true, KernelColorType.ListTitle, threadAddress);
ListWriterColor.WriteList(threadTrace);
TextWriterRaw.Write();
var listing = new Listing()
{
Objects = threadTrace,
};
TextWriterRaw.WriteRaw(listing.Render());
}
return 0;
}
Expand Down
Loading

0 comments on commit aac2c27

Please sign in to comment.