Skip to content

Commit

Permalink
imp - Adjusted to Terminaux's recent breaking chan...
Browse files Browse the repository at this point in the history
...ges

---

As Terminaux 6.0 has been released with breaking changes, we've decided to
adjust the codebase to align with the recent changes.

---

Type: imp
Breaking: False
Doc Required: False
Backport Required: False
Part: 1/1
  • Loading branch information
AptiviCEO committed Dec 22, 2024
1 parent f291253 commit 5fd06d9
Show file tree
Hide file tree
Showing 4 changed files with 198 additions and 20 deletions.
5 changes: 3 additions & 2 deletions private/BassBoom.Cli/CliBase/Common.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
using Terminaux.Base.Buffered;
using Terminaux.Inputs.Styles;
using Terminaux.Inputs.Styles.Infobox;
using Terminaux.Writer.CyclicWriters.Renderer.Tools;
using Terminaux.Writer.MiscWriters;

namespace BassBoom.Cli.CliBase
Expand Down Expand Up @@ -245,14 +246,14 @@ System specifications
internal static void ShowHelp()
{
InfoBoxModalColor.WriteInfoBoxModal("Available keystrokes",
KeybindingsWriter.RenderKeybindingHelpText(Player.allBindings)
KeybindingTools.RenderKeybindingHelpText(Player.allBindings)
);
}

internal static void ShowHelpRadio()
{
InfoBoxModalColor.WriteInfoBoxModal("Available keystrokes",
KeybindingsWriter.RenderKeybindingHelpText(Radio.allBindings)
KeybindingTools.RenderKeybindingHelpText(Radio.allBindings)
);
}

Expand Down
39 changes: 35 additions & 4 deletions private/BassBoom.Cli/CliBase/Equalizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
using Terminaux.Inputs.Styles;
using Terminaux.Writer.MiscWriters;
using Terminaux.Writer.CyclicWriters.Renderer.Tools;
using Terminaux.Writer.CyclicWriters;

namespace BassBoom.Cli.CliBase
{
Expand Down Expand Up @@ -134,14 +135,21 @@ private static string HandleDraw()
ConsoleWrapper.CursorVisible = false;

// First, print the keystrokes
drawn.Append(KeybindingsWriter.RenderKeybindings(showBindings, 0, ConsoleWrapper.WindowHeight - 1));
var keybindings = new Keybindings()
{
KeybindingList = showBindings,
Left = 0,
Top = ConsoleWrapper.WindowHeight - 1,
Width = ConsoleWrapper.WindowWidth - 1,
};
drawn.Append(keybindings.Render());

// Write current song
string name = "Not playing. Music player is idle.";
if (Common.cachedInfos.Count > 0)
name = Common.isRadioMode ? RadioControls.RenderStationName() : PlayerControls.RenderSongName(Common.CurrentCachedInfo?.MusicPath ?? "");

// Now, print the list of bands and their values.
// Now, populate the input choice information instances that represent bands
var choices = new List<InputChoiceInfo>();
int startPos = 4;
int endPos = ConsoleWrapper.WindowHeight - 1;
Expand All @@ -161,9 +169,32 @@ private static string HandleDraw()
string bandData = $"[{val:0.00}] Band #{i + 1} - {eqType}";
choices.Add(new($"{i + 1}", bandData));
}

// Print the list of bands and their values.
var bandBoxFrame = new BoxFrame()
{
Text = name,
Left = 2,
Top = 1,
InteriorWidth = ConsoleWrapper.WindowWidth - 6,
InteriorHeight = bandsPerPage
};
var bandSelections = new Selection([.. choices])
{
Left = 3,
Top = 2,
CurrentSelection = Common.currentPos - 1,
Height = bandsPerPage,
Width = ConsoleWrapper.WindowWidth - 6,
Settings = new()
{
SelectedOptionColor = ConsoleColors.Green,
OptionColor = ConsoleColors.Silver,
}
};
drawn.Append(
BoxFrameColor.RenderBoxFrame(name, 2, 1, ConsoleWrapper.WindowWidth - 6, bandsPerPage) +
SelectionInputTools.RenderSelections([.. choices], 3, 2, currentBandIdx, bandsPerPage, ConsoleWrapper.WindowWidth - 6, selectedForegroundColor: new Color(ConsoleColors.Green), foregroundColor: new Color(ConsoleColors.Silver))
bandBoxFrame.Render() +
bandSelections.Render()
);
return drawn.ToString();
}
Expand Down
101 changes: 93 additions & 8 deletions private/BassBoom.Cli/CliBase/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
using Terminaux.Writer.MiscWriters;
using Terminaux.Base.Extensions;
using Terminaux.Writer.CyclicWriters.Renderer.Tools;
using Terminaux.Writer.CyclicWriters;
using Terminaux.Colors.Transformation;
using Terminaux.Writer.CyclicWriters.Renderer;

namespace BassBoom.Cli.CliBase
{
Expand Down Expand Up @@ -110,32 +113,75 @@ public static void PlayerLoop()
{
if (Common.CurrentCachedInfo is null)
return "";

// Get the song name
var buffer = new StringBuilder();
string name = PlayerControls.RenderSongName(Common.CurrentCachedInfo.MusicPath);

// Get the positions and the amount of songs per page
int startPos = 4;
int endPos = ConsoleWrapper.WindowHeight - 5;
int songsPerPage = endPos - startPos;

// Get the position
position = FileTools.IsOpened(BassBoomCli.basolia) ? PlaybackPositioningTools.GetCurrentDuration(BassBoomCli.basolia) : 0;
var posSpan = FileTools.IsOpened(BassBoomCli.basolia) ? PlaybackPositioningTools.GetCurrentDurationSpan(BassBoomCli.basolia) : new();

// Disco effect!
var disco = PlaybackTools.IsPlaying(BassBoomCli.basolia) && Common.enableDisco ? new Color($"hsl:{hue};50;50") : BassBoomCli.white;
if (PlaybackTools.IsPlaying(BassBoomCli.basolia))
{
hue++;
if (hue >= 360)
hue = 0;
}

// Render the song list box frame and the duration bar
var listBoxFrame = new BoxFrame()
{
Text = name,
Left = 2,
Top = 1,
InteriorWidth = ConsoleWrapper.WindowWidth - 6,
InteriorHeight = songsPerPage,
FrameColor = disco,
TitleColor = disco,
BackgroundColor = disco,
};
var durationBar = new SimpleProgress((int)(100 * (position / (double)Common.CurrentCachedInfo.Duration)), 100)
{
LeftMargin = 1,
RightMargin = 1,
ShowPercentage = false,
ProgressForegroundColor = TransformationTools.GetDarkBackground(disco),
ProgressActiveForegroundColor = disco,
};
buffer.Append(
listBoxFrame.Render() +
ContainerTools.RenderRenderable(listBoxFrame, new(2, ConsoleWrapper.WindowHeight - 5))
);

// Render the indicator
string boostIndicator = Common.volBoost ? new Color(ConsoleColors.Red).VTSequenceForeground : "";
string indicator =
$"┤ Seek: {PlayerControls.seekRate:0.00} | " +
$"{boostIndicator}Volume: {Common.volume * 100:0}%{disco.VTSequenceForeground} ├";

// Render the lyric
string lyric = Common.CurrentCachedInfo.LyricInstance is not null ? Common.CurrentCachedInfo.LyricInstance.GetLastLineCurrent(BassBoomCli.basolia) : "";
string finalLyric = string.IsNullOrWhiteSpace(lyric) ? "..." : lyric;

// Render the results
var lyricText = new AlignedText()
{
Top = ConsoleWrapper.WindowHeight - 3,
ForegroundColor = disco,
Text = Common.CurrentCachedInfo.LyricInstance is not null && PlaybackTools.IsPlaying(BassBoomCli.basolia) ? $"┤ {finalLyric} ├" : ""
};
buffer.Append(
BoxFrameColor.RenderBoxFrame(name, 2, 1, ConsoleWrapper.WindowWidth - 6, songsPerPage, disco, ColorTools.CurrentBackgroundColor, disco) +
ProgressBarColor.RenderProgress(100 * (position / (double)Common.CurrentCachedInfo.Duration), 2, ConsoleWrapper.WindowHeight - 5, ConsoleWrapper.WindowWidth - 6, disco, disco) +
TextWriterWhereColor.RenderWhereColor($"┤ {posSpan} / {Common.CurrentCachedInfo.DurationSpan} ├", 4, ConsoleWrapper.WindowHeight - 5, disco) +
TextWriterWhereColor.RenderWhereColor(indicator, ConsoleWrapper.WindowWidth - ConsoleChar.EstimateCellWidth(indicator) - 4, ConsoleWrapper.WindowHeight - 5, disco) +
CenteredTextColor.RenderCentered(ConsoleWrapper.WindowHeight - 3, Common.CurrentCachedInfo.LyricInstance is not null && PlaybackTools.IsPlaying(BassBoomCli.basolia) ? $"┤ {finalLyric} ├" : "", disco)
lyricText.Render()
);
return buffer.ToString();
});
Expand Down Expand Up @@ -395,7 +441,14 @@ private static string HandleDraw()
ConsoleWrapper.CursorVisible = false;

// First, print the keystrokes
drawn.Append(KeybindingsWriter.RenderKeybindings(showBindings, 0, ConsoleWrapper.WindowHeight - 1));
var keybindings = new Keybindings()
{
KeybindingList = showBindings,
Left = 0,
Top = ConsoleWrapper.WindowHeight - 1,
Width = ConsoleWrapper.WindowWidth - 1,
};
drawn.Append(keybindings.Render());

// In case we have no songs in the playlist...
if (Common.cachedInfos.Count == 0)
Expand All @@ -412,7 +465,16 @@ private static string HandleDraw()
else
{
int height = (ConsoleWrapper.WindowHeight - 2) / 2;
drawn.Append(CenteredTextColor.RenderCentered(height, "Press 'A' to insert a single song to the playlist, or 'S' to insert the whole music library."));
var message = new AlignedText()
{
Top = height,
Text = "Press 'A' to insert a single song to the playlist, or 'S' to insert the whole music library.",
Settings = new()
{
Alignment = TextAlignment.Middle
}
};
drawn.Append(message.Render());
return drawn.ToString();
}
}
Expand All @@ -426,7 +488,7 @@ private static string HandleDraw()
name = PlayerControls.RenderSongName(Common.CurrentCachedInfo.MusicPath);
}

// Now, print the list of songs.
// Now, populate the input choice information instances that represent songs
var choices = new List<InputChoiceInfo>();
int startPos = 4;
int endPos = ConsoleWrapper.WindowHeight - 5;
Expand All @@ -440,9 +502,32 @@ private static string HandleDraw()
string songPreview = $"[{duration}] {musicArtist} - {musicName}";
choices.Add(new($"{i + 1}", songPreview));
}

// Render the selections inside the box
var playlistBoxFrame = new BoxFrame()
{
Text = name,
Left = 2,
Top = 1,
InteriorWidth = ConsoleWrapper.WindowWidth - 6,
InteriorHeight = songsPerPage,
};
var playlistSelections = new Selection([.. choices])
{
Left = 3,
Top = 2,
CurrentSelection = Common.currentPos - 1,
Height = songsPerPage,
Width = ConsoleWrapper.WindowWidth - 6,
Settings = new()
{
SelectedOptionColor = ConsoleColors.Green,
OptionColor = ConsoleColors.Silver,
}
};
drawn.Append(
BoxFrameColor.RenderBoxFrame(name, 2, 1, ConsoleWrapper.WindowWidth - 6, songsPerPage) +
SelectionInputTools.RenderSelections([.. choices], 3, 2, Common.currentPos - 1, songsPerPage, ConsoleWrapper.WindowWidth - 6, selectedForegroundColor: new Color(ConsoleColors.Green), foregroundColor: new Color(ConsoleColors.Silver))
playlistBoxFrame.Render() +
playlistSelections.Render()
);
return drawn.ToString();
}
Expand Down
73 changes: 67 additions & 6 deletions private/BassBoom.Cli/CliBase/Radio.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
using Terminaux.Writer.MiscWriters;
using Terminaux.Base.Extensions;
using Terminaux.Writer.CyclicWriters.Renderer.Tools;
using Terminaux.Writer.CyclicWriters;

namespace BassBoom.Cli.CliBase
{
Expand Down Expand Up @@ -90,12 +91,20 @@ public static void RadioLoop()
{
if (Common.CurrentCachedInfo is null)
return "";

// Get the name
string name = RadioControls.RenderStationName();

// Get the positions and the amount of stations per page
int startPos = 4;
int endPos = ConsoleWrapper.WindowHeight - 1;
int stationsPerPage = endPos - startPos;

// Get the boost indicator
var buffer = new StringBuilder();
string boostIndicator = Common.volBoost ? new Color(ConsoleColors.Red).VTSequenceForeground : "";

// Disco effect!
var disco = PlaybackTools.IsPlaying(BassBoomCli.basolia) && Common.enableDisco ? new Color($"hsl:{hue};50;50") : BassBoomCli.white;
string indicator = $"┤ {boostIndicator}Volume: {Common.volume * 100:0}%{disco.VTSequenceForeground} ├";
if (PlaybackTools.IsPlaying(BassBoomCli.basolia))
Expand All @@ -104,8 +113,21 @@ public static void RadioLoop()
if (hue >= 360)
hue = 0;
}

// Render the station list box frame and the indicator
var listBoxFrame = new BoxFrame()
{
Text = name,
Left = 2,
Top = 1,
InteriorWidth = ConsoleWrapper.WindowWidth - 6,
InteriorHeight = stationsPerPage,
FrameColor = disco,
TitleColor = disco,
BackgroundColor = disco,
};
buffer.Append(
BoxFrameColor.RenderBoxFrame(name, 2, 1, ConsoleWrapper.WindowWidth - 6, stationsPerPage, disco, ColorTools.CurrentBackgroundColor, disco) +
listBoxFrame.Render() +
TextWriterWhereColor.RenderWhereColor(indicator, ConsoleWrapper.WindowWidth - ConsoleChar.EstimateCellWidth(indicator) - 4, ConsoleWrapper.WindowHeight - 3, disco)
);
return buffer.ToString();
Expand Down Expand Up @@ -305,13 +327,29 @@ private static string HandleDraw()
ConsoleWrapper.CursorVisible = false;

// First, print the keystrokes
drawn.Append(KeybindingsWriter.RenderKeybindings(Player.showBindings, 0, ConsoleWrapper.WindowHeight - 1));
var keybindings = new Keybindings()
{
KeybindingList = Player.showBindings,
Left = 0,
Top = ConsoleWrapper.WindowHeight - 1,
Width = ConsoleWrapper.WindowWidth - 1,
};
drawn.Append(keybindings.Render());

// In case we have no stations in the playlist...
if (Common.cachedInfos.Count == 0)
{
int height = (ConsoleWrapper.WindowHeight - 2) / 2;
drawn.Append(CenteredTextColor.RenderCentered(height, "Press 'A' to insert a radio station to the playlist."));
var message = new AlignedText()
{
Top = height,
Text = "Press 'A' to insert a radio station to the playlist.",
Settings = new()
{
Alignment = TextAlignment.Middle
}
};
drawn.Append(message.Render());
return drawn.ToString();
}

Expand All @@ -324,7 +362,7 @@ private static string HandleDraw()
name = RadioControls.RenderStationName();
}

// Now, print the list of stations.
// Now, populate the input choice information instances that represent stations
var choices = new List<InputChoiceInfo>();
int startPos = 4;
int endPos = ConsoleWrapper.WindowHeight - 1;
Expand All @@ -337,9 +375,32 @@ private static string HandleDraw()
string stationPreview = $"{stationName}";
choices.Add(new($"{i + 1}", stationPreview));
}

// Print the list of stations.
var playlistBoxFrame = new BoxFrame()
{
Text = name,
Left = 2,
Top = 1,
InteriorWidth = ConsoleWrapper.WindowWidth - 6,
InteriorHeight = stationsPerPage
};
var playlistSelections = new Selection([.. choices])
{
Left = 3,
Top = 2,
CurrentSelection = Common.currentPos - 1,
Height = stationsPerPage,
Width = ConsoleWrapper.WindowWidth - 6,
Settings = new()
{
SelectedOptionColor = ConsoleColors.Green,
OptionColor = ConsoleColors.Silver,
}
};
drawn.Append(
BoxFrameColor.RenderBoxFrame(name, 2, 1, ConsoleWrapper.WindowWidth - 6, stationsPerPage) +
SelectionInputTools.RenderSelections([.. choices], 3, 2, Common.currentPos - 1, stationsPerPage, ConsoleWrapper.WindowWidth - 6, selectedForegroundColor: new Color(ConsoleColors.Green), foregroundColor: new Color(ConsoleColors.Silver))
playlistBoxFrame.Render() +
playlistSelections.Render()
);
return drawn.ToString();
}
Expand Down

0 comments on commit 5fd06d9

Please sign in to comment.