[Logger, SimpleSort, Stats] Make everything prettier

This commit is contained in:
Matt Nadareski
2016-06-26 23:25:48 -07:00
parent 02b6cd7d75
commit 30a2b31f74
5 changed files with 93 additions and 13 deletions

View File

@@ -137,7 +137,8 @@ namespace SabreTools.Helper
// USER and ERROR writes to console
if (loglevel == LogLevel.USER || loglevel == LogLevel.ERROR)
{
int padlength = (int)(Math.Ceiling((double)output.Length / 80) * 80) - 1;
int padlength = (int)(Math.Ceiling((double)output.Length / 80) * 80);
padlength = (padlength > 0 ? padlength: 0);
string tempoutput = output.PadRight(padlength, ' ');
Console.WriteLine((loglevel == LogLevel.ERROR ? loglevel.ToString() + " " : "") + tempoutput);
}
@@ -178,6 +179,7 @@ namespace SabreTools.Helper
// Write out to the console
int padlength = (int)(Math.Ceiling((double)output.Length / 80) * 80) - 1;
padlength = (padlength > 0 ? padlength : 0);
string tempoutput = output.PadRight(padlength, ' ');
Console.Write(tempoutput);
@@ -228,5 +230,22 @@ namespace SabreTools.Helper
{
return Log(output, LogLevel.ERROR);
}
/// <summary>
/// Clear lines beneath the given line in the console
/// </summary>
/// <param name="line">Line number to clear beneath</param>
/// <returns>True</returns>
public bool ClearBeneath(int line)
{
if (!Console.IsOutputRedirected)
{
for (int i = line; i < Console.WindowHeight; i++)
{
Log(" ", i, 0);
}
}
return true;
}
}
}

View File

@@ -464,7 +464,7 @@ namespace SabreTools.Helper
// If we still have a success, then return this rule
if (success)
{
logger.User("Matching rule found!");
logger.User(" Matching rule found!");
skipperRule = rule;
break;
}

View File

@@ -1476,7 +1476,7 @@ namespace SabreTools.Helper
foreach (Rom rom in newroms)
{
count++;
string key = rom.Size + "-" + rom.CRC; ;
string key = rom.Size + "-" + rom.CRC;
if (sortable.ContainsKey(key))
{
sortable[key].Add(rom);

View File

@@ -133,21 +133,21 @@ Please check the log folder if the stats scrolled offscreen");
SortedDictionary<string, List<Rom>> newroms = DatTools.BucketByGame(datdata.Roms, false, true, logger, false);
string line = " Uncompressed size: " + Style.GetBytesReadable(datdata.TotalSize);
logger.User(line.PadRight(79, ' '));
logger.Log(line, Console.CursorTop, 0);
line = " Games found: " + (game == -1 ? newroms.Count : game);
logger.User(line.PadRight(79, ' '));
logger.Log(line, Console.CursorTop + 1, 0);
line = " Roms found: " + datdata.RomCount;
logger.User(line.PadRight(79, ' '));
logger.Log(line, Console.CursorTop + 1, 0);
line = " Disks found: " + datdata.DiskCount;
logger.User(line.PadRight(79, ' '));
logger.Log(line, Console.CursorTop + 1, 0);
line = " Roms with CRC: " + datdata.CRCCount;
logger.User(line.PadRight(79, ' '));
logger.Log(line, Console.CursorTop + 1, 0);
line = " Roms with MD5: " + datdata.MD5Count;
logger.User(line.PadRight(79, ' '));
logger.Log(line, Console.CursorTop + 1, 0);
line = " Roms with SHA-1: " + datdata.SHA1Count;
logger.User(line.PadRight(79, ' '));
logger.Log(line, Console.CursorTop + 1, 0);
line = " Roms with Nodump status: " + datdata.NodumpCount;
logger.User(line.PadRight(79, ' '));
logger.Log(line, Console.CursorTop + 1, 0);
logger.User("");
}
}