Make program output even more uniform

This commit is contained in:
Matt Nadareski
2016-04-18 20:04:38 -07:00
parent ccb8864ff2
commit 9663d22274
6 changed files with 55 additions and 31 deletions

View File

@@ -55,7 +55,6 @@ namespace SabreTools
public static void Main(string[] args) public static void Main(string[] args)
{ {
Console.Clear(); Console.Clear();
Console.Title = "DATFromDir " + Build.Version;
// Credits take precidence over all // Credits take precidence over all
if ((new List<string>(args)).Contains("--credits")) if ((new List<string>(args)).Contains("--credits"))
@@ -150,6 +149,9 @@ namespace SabreTools
return; return;
} }
// Output the title
Build.Start("DATFromDir");
// If any of the inputs are not valid, show the help // If any of the inputs are not valid, show the help
foreach (string input in inputs) foreach (string input in inputs)
{ {

View File

@@ -35,10 +35,7 @@ namespace SabreTools
logger.Start(); logger.Start();
DBTools.EnsureDatabase(_dbName, _connectionString); DBTools.EnsureDatabase(_dbName, _connectionString);
Remapping.CreateRemappings(); Remapping.CreateRemappings();
Console.Clear(); Console.Clear();
Console.SetBufferSize(Console.BufferWidth, 999);
Console.Title = "DATabase " + Build.Version;
// Credits take precidence over all // Credits take precidence over all
if ((new List<string>(args)).Contains("--credits")) if ((new List<string>(args)).Contains("--credits"))
@@ -199,20 +196,6 @@ namespace SabreTools
return; return;
} }
/// <summary>
/// Print the program header
/// </summary>
private static void PrintHeader()
{
ConsoleColor formertext = Console.ForegroundColor;
ConsoleColor formerback = Console.BackgroundColor;
Console.ForegroundColor = ConsoleColor.Yellow;
Console.BackgroundColor = ConsoleColor.Blue;
Console.WriteLine(_header);
Console.ForegroundColor = formertext;
Console.BackgroundColor = formerback;
}
/// <summary> /// <summary>
/// Show the text-based main menu /// Show the text-based main menu
/// </summary> /// </summary>
@@ -223,7 +206,7 @@ namespace SabreTools
while (selection.ToLowerInvariant() != "x") while (selection.ToLowerInvariant() != "x")
{ {
Console.Clear(); Console.Clear();
PrintHeader(); Build.Start("DATabase");
Console.WriteLine(@"MAIN MENU Console.WriteLine(@"MAIN MENU
=========================== ===========================
Make a selection: Make a selection:
@@ -266,14 +249,14 @@ Make a selection:
break; break;
case "7": case "7":
Console.Clear(); Console.Clear();
PrintHeader(); Build.Start("DATabase");
ListSources(); ListSources();
Console.Write("\nPress any key to continue..."); Console.Write("\nPress any key to continue...");
Console.ReadKey(); Console.ReadKey();
break; break;
case "8": case "8":
Console.Clear(); Console.Clear();
PrintHeader(); Build.Start("DATabase");
ListSystems(); ListSystems();
Console.Write("\nPress any key to continue..."); Console.Write("\nPress any key to continue...");
Console.ReadKey(); Console.ReadKey();
@@ -305,7 +288,7 @@ Make a selection:
while (selection.ToLowerInvariant() != "b") while (selection.ToLowerInvariant() != "b")
{ {
Console.Clear(); Console.Clear();
PrintHeader(); Build.Start("DATabase");
Console.WriteLine( @"IMPORT MENU Console.WriteLine( @"IMPORT MENU
=========================== ===========================
Enter the name of a DAT file or folder containing DAT files Enter the name of a DAT file or folder containing DAT files
@@ -366,7 +349,7 @@ or 'b' to go back to the previous menu:");
while (selection.ToLowerInvariant() != "b") while (selection.ToLowerInvariant() != "b")
{ {
Console.Clear(); Console.Clear();
PrintHeader(); Build.Start("DATabase");
Console.WriteLine(@"GENERATE MENU Console.WriteLine(@"GENERATE MENU
=========================== ===========================
Make a selection: Make a selection:
@@ -441,7 +424,7 @@ Make a selection:
while (selection.ToLowerInvariant() != "b") while (selection.ToLowerInvariant() != "b")
{ {
Console.Clear(); Console.Clear();
PrintHeader(); Build.Start("DATabase");
Console.WriteLine(@"GENERATE ALL MENU Console.WriteLine(@"GENERATE ALL MENU
=========================== ===========================
Make a selection: Make a selection:
@@ -603,7 +586,7 @@ Make a selection:
while (selection.ToLowerInvariant() != "b") while (selection.ToLowerInvariant() != "b")
{ {
Console.Clear(); Console.Clear();
PrintHeader(); Build.Start("DATabase");
Console.WriteLine(@"XML -> RV CONVERT MENU Console.WriteLine(@"XML -> RV CONVERT MENU
=========================== ===========================
Enter the name of a DAT file to convert from XML to RV Enter the name of a DAT file to convert from XML to RV
@@ -663,7 +646,7 @@ or 'b' to go back to the previous menu:
while (selection.ToLowerInvariant() != "b") while (selection.ToLowerInvariant() != "b")
{ {
Console.Clear(); Console.Clear();
PrintHeader(); Build.Start("DATabase");
Console.WriteLine(@"RV -> XML CONVERT MENU Console.WriteLine(@"RV -> XML CONVERT MENU
=========================== ===========================
Enter the name of a DAT file to convert from RV to XML Enter the name of a DAT file to convert from RV to XML
@@ -786,7 +769,7 @@ ORDER BY systems.manufacturer, systems.system";
while (selection.ToLowerInvariant() != "b") while (selection.ToLowerInvariant() != "b")
{ {
Console.Clear(); Console.Clear();
PrintHeader(); Build.Start("DATabase");
Console.WriteLine(@"ADD AND REMOVE MENU Console.WriteLine(@"ADD AND REMOVE MENU
=========================== ===========================
Make a selection: Make a selection:

View File

@@ -16,7 +16,7 @@ namespace DatSplit
public static void Main(string[] args) public static void Main(string[] args)
{ {
Console.Title = "DatSplit " + Build.Version; Console.Clear();
// Credits take precidence over all // Credits take precidence over all
if ((new List<string>(args)).Contains("--credits")) if ((new List<string>(args)).Contains("--credits"))
@@ -32,6 +32,9 @@ namespace DatSplit
return; return;
} }
// Output the title
Build.Start("DatSplit");
// Set needed strings // Set needed strings
_filename = args[0]; _filename = args[0];
_extA = (args[1].StartsWith(".") ? args[1] : "." + args[1]).ToUpperInvariant(); _extA = (args[1].StartsWith(".") ? args[1] : "." + args[1]).ToUpperInvariant();

View File

@@ -26,13 +26,12 @@ namespace SabreTools
static void Main(string[] args) static void Main(string[] args)
{ {
// Perform initial setup and verification // Perform initial setup and verification
Console.Clear();
logger = new Logger(false, "database.log"); logger = new Logger(false, "database.log");
logger.Start(); logger.Start();
DBTools.EnsureDatabase(_dbName, _connectionString); DBTools.EnsureDatabase(_dbName, _connectionString);
Remapping.CreateHeaderSkips(); Remapping.CreateHeaderSkips();
Console.Title = "Headerer " + Build.Version;
// Credits take precidence over all // Credits take precidence over all
if ((new List<string>(args)).Contains("--credits")) if ((new List<string>(args)).Contains("--credits"))
{ {
@@ -47,6 +46,9 @@ namespace SabreTools
return; return;
} }
// Output the title
Build.Start("Headerer");
// Get the filename (or foldername) // Get the filename (or foldername)
string file = ""; string file = "";
bool deheader = true; bool deheader = true;

View File

@@ -23,6 +23,37 @@ namespace SabreTools.Helper
get { return (Type.GetType("Mono.Runtime") != null); } get { return (Type.GetType("Mono.Runtime") != null); }
} }
/// <summary>
/// Readies the console and outputs the header
/// </summary>
/// <param name="name">The name to be displayed as the program</param>
/// <remarks>Adapted from http://stackoverflow.com/questions/8200661/how-to-align-string-in-fixed-length-string</remarks>
public static void Start(string name)
{
// Dynamically create the header string
string border = "+-----------------------------------------------------------------------------+";
string mid = name + " " + Build.Version;
mid = "|" + mid.PadLeft(((77 - mid.Length) / 2) + mid.Length).PadRight(77) + "|";
// Set the console to ready state
Console.SetBufferSize(Console.BufferWidth, 999);
Console.Title = name + " " + Build.Version;
ConsoleColor formertext = Console.ForegroundColor;
ConsoleColor formerback = Console.BackgroundColor;
Console.ForegroundColor = ConsoleColor.Yellow;
Console.BackgroundColor = ConsoleColor.Blue;
// Output the header
Console.WriteLine(border);
Console.WriteLine(mid);
Console.WriteLine(border);
Console.WriteLine();
// Return the console to the original text and background colors
Console.ForegroundColor = formertext;
Console.BackgroundColor = formerback;
}
/// <summary> /// <summary>
/// Show the help dialog for a given class /// Show the help dialog for a given class
/// </summary> /// </summary>

View File

@@ -15,7 +15,7 @@ namespace SabreTools
public static void Main(string[] args) public static void Main(string[] args)
{ {
Console.Title = "SingleGame " + Build.Version; Console.Clear();
// Credits take precidence over all // Credits take precidence over all
if ((new List<string>(args)).Contains("--credits")) if ((new List<string>(args)).Contains("--credits"))
@@ -30,6 +30,9 @@ namespace SabreTools
return; return;
} }
// Output the title
Build.Start("SingleGame");
_filename = args[0]; _filename = args[0];
if (args.Length > 1) if (args.Length > 1)