Skip to content

Commit

Permalink
imp - Made the user interface more compact
Browse files Browse the repository at this point in the history
---

We've made the user interface more compact by moving the title so that the box frame generator takes care of it.

---

Type: imp
Breaking: False
Doc Required: False
Backport Required: False
Part: 1/1
  • Loading branch information
AptiviCEO committed Sep 18, 2024
1 parent 8c8a37e commit 900d278
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 35 deletions.
19 changes: 5 additions & 14 deletions BassBoom.Cli/CliBase/Equalizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,23 +139,14 @@ private static string HandleDraw()
drawn.Append(KeybindingsWriter.RenderKeybindings(showBindings, 0, ConsoleWrapper.WindowHeight - 1));

// Write current song
string name = "Not playing. Music player is idle.";
if (Common.cachedInfos.Count > 0)
{
if (Common.isRadioMode)
drawn.Append(RadioControls.RenderStationName());
else
drawn.Append(PlayerControls.RenderSongName(Common.CurrentCachedInfo?.MusicPath ?? ""));
}
else
drawn.Append(
TextWriterWhereColor.RenderWhere(ConsoleClearing.GetClearLineToRightSequence(), 0, 1) +
CenteredTextColor.RenderCentered(1, "Not playing. Music player is idle.", ConsoleColors.White)
);
name = Common.isRadioMode ? RadioControls.RenderStationName() : PlayerControls.RenderSongName(Common.CurrentCachedInfo?.MusicPath ?? "");

// Now, print the list of bands and their values.
var choices = new List<InputChoiceInfo>();
int startPos = 4;
int endPos = ConsoleWrapper.WindowHeight - 6;
int endPos = ConsoleWrapper.WindowHeight - 1;
int bandsPerPage = endPos - startPos;
for (int i = 0; i < 32; i++)
{
Expand All @@ -173,8 +164,8 @@ private static string HandleDraw()
choices.Add(new($"{i + 1}", bandData));
}
drawn.Append(
BoxFrameColor.RenderBoxFrame(2, 3, ConsoleWrapper.WindowWidth - 6, bandsPerPage) +
SelectionInputTools.RenderSelections([.. choices], 3, 4, currentBandIdx, bandsPerPage, ConsoleWrapper.WindowWidth - 6, selectedForegroundColor: new Color(ConsoleColors.Green), foregroundColor: new Color(ConsoleColors.Silver))
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))
);
return drawn.ToString();
}
Expand Down
18 changes: 9 additions & 9 deletions BassBoom.Cli/CliBase/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,10 @@ public static void PlayerLoop()
string lyric = Common.CurrentCachedInfo.LyricInstance is not null ? Common.CurrentCachedInfo.LyricInstance.GetLastLineCurrent(BassBoomCli.basolia) : "";
string finalLyric = string.IsNullOrWhiteSpace(lyric) ? "..." : lyric;
buffer.Append(
ProgressBarColor.RenderProgress(100 * (position / (double)Common.CurrentCachedInfo.Duration), 2, ConsoleWrapper.WindowHeight - 8, ConsoleWrapper.WindowWidth - 6, disco, disco) +
TextWriterWhereColor.RenderWhereColor($"┤ {posSpan} / {Common.CurrentCachedInfo.DurationSpan} ├", 4, ConsoleWrapper.WindowHeight - 8, disco) +
TextWriterWhereColor.RenderWhereColor(indicator, ConsoleWrapper.WindowWidth - indicator.Length - 4, ConsoleWrapper.WindowHeight - 8, disco) +
CenteredTextColor.RenderCentered(ConsoleWrapper.WindowHeight - 6, Common.CurrentCachedInfo.LyricInstance is not null && PlaybackTools.IsPlaying(BassBoomCli.basolia) ? $"┤ {finalLyric} ├" : "", 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 - indicator.Length - 4, ConsoleWrapper.WindowHeight - 5, disco) +
CenteredTextColor.RenderCentered(ConsoleWrapper.WindowHeight - 3, Common.CurrentCachedInfo.LyricInstance is not null && PlaybackTools.IsPlaying(BassBoomCli.basolia) ? $"┤ {finalLyric} ├" : "", disco)
);
return buffer.ToString();
});
Expand Down Expand Up @@ -335,7 +335,6 @@ private static void HandlePlay()
Common.populate = true;
Common.currentPos = Common.cachedInfos.IndexOf(musicFile) + 1;
PlayerControls.PopulateMusicFileInfo(musicFile.MusicPath);
TextWriterRaw.WritePlain(PlayerControls.RenderSongName(musicFile.MusicPath), false);
if (Common.paused)
{
Common.paused = false;
Expand Down Expand Up @@ -381,17 +380,18 @@ private static string HandleDraw()
}

// Populate music file info, as necessary
string name = "";
if (Common.CurrentCachedInfo is not null)
{
if (Common.populate)
PlayerControls.PopulateMusicFileInfo(Common.CurrentCachedInfo.MusicPath);
drawn.Append(PlayerControls.RenderSongName(Common.CurrentCachedInfo.MusicPath));
name = PlayerControls.RenderSongName(Common.CurrentCachedInfo.MusicPath);
}

// Now, print the list of songs.
var choices = new List<InputChoiceInfo>();
int startPos = 4;
int endPos = ConsoleWrapper.WindowHeight - 10;
int endPos = ConsoleWrapper.WindowHeight - 5;
int songsPerPage = endPos - startPos;
int max = Common.cachedInfos.Select((_, idx) => idx).Max((idx) => $" {idx + 1}) ".Length);
for (int i = 0; i < Common.cachedInfos.Count; i++)
Expand All @@ -403,8 +403,8 @@ private static string HandleDraw()
choices.Add(new($"{i + 1}", songPreview));
}
drawn.Append(
BoxFrameColor.RenderBoxFrame(2, 3, ConsoleWrapper.WindowWidth - 6, songsPerPage) +
SelectionInputTools.RenderSelections([.. choices], 3, 4, Common.currentPos - 1, songsPerPage, ConsoleWrapper.WindowWidth - 6, selectedForegroundColor: new Color(ConsoleColors.Green), foregroundColor: new Color(ConsoleColors.Silver))
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))
);
return drawn.ToString();
}
Expand Down
4 changes: 1 addition & 3 deletions BassBoom.Cli/CliBase/PlayerControls.cs
Original file line number Diff line number Diff line change
Expand Up @@ -292,9 +292,7 @@ internal static string RenderSongName(string musicPath)
var (musicName, musicArtist, _) = GetMusicNameArtistGenre(musicPath);

// Print the music name
return
TextWriterWhereColor.RenderWhere(ConsoleClearing.GetClearLineToRightSequence(), 0, 1) +
CenteredTextColor.RenderCentered(1, "Now playing: {0} - {1}", ConsoleColors.White, ConsoleColors.Black, 0, 0, musicArtist, musicName);
return $"Now playing: {musicArtist} - {musicName}";
}

internal static (string musicName, string musicArtist, string musicGenre) GetMusicNameArtistGenre(string musicPath)
Expand Down
13 changes: 7 additions & 6 deletions BassBoom.Cli/CliBase/Radio.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ public static void RadioLoop()
hue = 0;
}
buffer.Append(
BoxFrameColor.RenderBoxFrame(2, ConsoleWrapper.WindowHeight - 8, ConsoleWrapper.WindowWidth - 6, 1, disco) +
TextWriterWhereColor.RenderWhereColor(indicator, ConsoleWrapper.WindowWidth - indicator.Length - 4, ConsoleWrapper.WindowHeight - 8, disco)
BoxFrameColor.RenderBoxFrame(2, ConsoleWrapper.WindowHeight - 5, ConsoleWrapper.WindowWidth - 6, 1, disco) +
TextWriterWhereColor.RenderWhereColor(indicator, ConsoleWrapper.WindowWidth - indicator.Length - 4, ConsoleWrapper.WindowHeight - 5, disco)
);
return buffer.ToString();
});
Expand Down Expand Up @@ -291,17 +291,18 @@ private static string HandleDraw()
}

// Populate music file info, as necessary
string name = "";
if (Common.CurrentCachedInfo is not null)
{
if (Common.populate)
RadioControls.PopulateRadioStationInfo(Common.CurrentCachedInfo.MusicPath);
drawn.Append(RadioControls.RenderStationName());
name = RadioControls.RenderStationName();
}

// Now, print the list of stations.
var choices = new List<InputChoiceInfo>();
int startPos = 4;
int endPos = ConsoleWrapper.WindowHeight - 10;
int endPos = ConsoleWrapper.WindowHeight - 5;
int stationsPerPage = endPos - startPos;
int max = Common.cachedInfos.Select((_, idx) => idx).Max((idx) => $" {idx + 1}) ".Length);
for (int i = 0; i < Common.cachedInfos.Count; i++)
Expand All @@ -313,8 +314,8 @@ private static string HandleDraw()
choices.Add(new($"{i + 1}", stationPreview));
}
drawn.Append(
BoxFrameColor.RenderBoxFrame(2, 3, ConsoleWrapper.WindowWidth - 6, stationsPerPage) +
SelectionInputTools.RenderSelections([.. choices], 3, 4, Common.currentPos - 1, stationsPerPage, ConsoleWrapper.WindowWidth - 6, selectedForegroundColor: new Color(ConsoleColors.Green), foregroundColor: new Color(ConsoleColors.Silver))
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))
);
return drawn.ToString();
}
Expand Down
4 changes: 1 addition & 3 deletions BassBoom.Cli/CliBase/RadioControls.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,7 @@ internal static string RenderStationName()
string icy = PlaybackTools.GetRadioNowPlaying(BassBoomCli.basolia);

// Print the music name
return
TextWriterWhereColor.RenderWhere(ConsoleClearing.GetClearLineToRightSequence(), 0, 1) +
CenteredTextColor.RenderCentered(1, "Now playing: {0}", ConsoleColors.White, ConsoleColors.Black, 0, 0, icy);
return $"Now playing: {icy}";
}

internal static void RemoveCurrentStation()
Expand Down

0 comments on commit 900d278

Please sign in to comment.