diff --git a/Client/Context/SessionContext.cs b/Client/Context/SessionContext.cs index e9e4ac1..5150074 100644 --- a/Client/Context/SessionContext.cs +++ b/Client/Context/SessionContext.cs @@ -398,21 +398,25 @@ namespace Client { //var list = GetView("account_show"); var list = new ListView(new ViewData("ListView").SetAttribute("padding_left", 2).SetAttribute("padding_right", 2).SetAttribute("border", 8), LangManager.NO_LANG); - if (data.Length == 1 && data[0].Length == 0) return list; - bool b = data.Length == 1 && data[0].Length == 0; - Tuple[] listData = new Tuple[data.Length - (b ? 1 : 0)]; - if (!b) - for (int i = 0; i < listData.Length; ++i) + //if (data.Length == 1 && data[0].Length == 0) data = new string[0]; + Tuple[] listData = new Tuple[data.Length - ((data.Length == 1 && data[0].Length == 0) ? 1 : 0)]; + for (int i = 0; i < listData.Length; ++i) + { + ButtonView t = new ButtonView(new ViewData("ButtonView").AddNestedSimple("Text", data[i]), LangManager.NO_LANG); // Don't do translations + t.SetEvent(v => { - ButtonView t = new ButtonView(new ViewData("ButtonView").AddNestedSimple("Text", data[i]), LangManager.NO_LANG); // Don't do translations - t.SetEvent(v => - { - onclick?.Invoke(v); - if (exitOnSubmit) Hide(list); - }); - listData[i] = new Tuple(t.Text, t); - } - list.AddViews(0, listData); // Insert generated buttons before predefined "close" button + onclick?.Invoke(v); + if (exitOnSubmit) Hide(list); + }); + listData[i] = new Tuple(t.Text, t); + } + if (listData.Length > 0) list.AddViews(0, listData); + else + { + ButtonView close = new ButtonView(new ViewData("ButtonView").AddNestedSimple("Text", GetIntlString("GENERIC_dismiss")), LangManager.NO_LANG); + close.SetEvent(_ => Hide(list)); + list.AddView(close, "close"); + } if (hideOnBack) list.OnBackEvent = v => Hide(v); return list; } diff --git a/Server/Output.cs b/Server/Output.cs index 485aa39..9aff21c 100644 --- a/Server/Output.cs +++ b/Server/Output.cs @@ -67,6 +67,8 @@ namespace Server if (newline) { writer.WriteLine(); + Console.ForegroundColor = f1; + Console.BackgroundColor = b1; readStart_x = 0; ++readStart_y; OnNewLine?.Invoke(); @@ -74,9 +76,12 @@ namespace Server readStart_x = (short)Console.CursorLeft; if (reading) Console.Out.Write(read); } - else readStart_x = (short)Console.CursorLeft; - Console.ForegroundColor = f1; - Console.BackgroundColor = b1; + else + { + readStart_x = (short)Console.CursorLeft; + Console.ForegroundColor = f1; + Console.BackgroundColor = b1; + } } } diff --git a/Server/Program.cs b/Server/Program.cs index 8601a6d..975d596 100644 --- a/Server/Program.cs +++ b/Server/Program.cs @@ -25,15 +25,16 @@ Use command 'help' to get a list of available commands"; private const string VERBOSE_RESPONSE = "@string/REMOTE_"; public static int verbosity = 2; const decimal ratePerDay = 0.5M; // Savings account has a growth rate of 150% per day + + // Initialize the database + public static readonly Database db = new Database("BankDB", "Resources"); public static void Main(string[] args) { // Create a client session manager and allow sessions to remain valid for up to 5 minutes of inactivity (300 seconds) SessionManager manager = new SessionManager(300 * TimeSpan.TicksPerSecond, 20); - // Initialize the database - Database db = new Database("BankDB", "Resources"); SetConsoleCtrlHandler(i => { - if (i == 2) db.Flush(); // Ensures that the database is flushed before the program exits + db.Flush(); // Ensures that the database is flushed before the program exits return false; }, true); @@ -547,7 +548,7 @@ Use command 'help' to get a list of available commands"; // Handles unexpected console close events (kernel event hook for window close event) private delegate bool EventHandler(int eventType); - [DllImport("kernel32.dll")] + [DllImport("Kernel32.dll", SetLastError = true)] private static extern bool SetConsoleCtrlHandler(EventHandler callback, bool add); } }