Ejemplo n.º 1
0
        protected override void Paint(bool AForce)
        {
            // Draw the message
            switch (_TextAlignment)
            {
            case CrtAlignment.Center:
                if (Text.Length >= Width)
                {
                    // Text is greater than available space so chop it off with PadRight()
                    Crt.FastWrite(StringUtils.PadRight(Text, ' ', Width), ScreenLeft, ScreenTop, _ForeColour, _BackColour);
                }
                else
                {
                    // Text needs to be centered
                    int LeftSpaces  = (Width - Text.Length) / 2;
                    int RightSpaces = Width - Text.Length - LeftSpaces;
                    Crt.FastWrite(new string(' ', LeftSpaces) + Text + new string(' ', RightSpaces), ScreenLeft, ScreenTop, _ForeColour, _BackColour);
                }
                break;

            case CrtAlignment.Left:
                Crt.FastWrite(StringUtils.PadRight(Text, ' ', Width), ScreenLeft, ScreenTop, _ForeColour, _BackColour);
                break;

            case CrtAlignment.Right:
                Crt.FastWrite(StringUtils.PadLeft(Text, ' ', Width), ScreenLeft, ScreenTop, _ForeColour, _BackColour);
                break;
            }
        }
Ejemplo n.º 2
0
        // Event for when the status bar needs updating }
        static void Door_OnStatusBar(object sender, EventArgs e)
        {
            switch (Status.Current)
            {
            case 0:
                Crt.FastWrite("þ                       þ F1=HELP þ RMASTERMIND þ Idle:       þ Left:          þ", 1, 25, 30);
                Crt.FastWrite(StringUtils.PadRight(Door.DropInfo.RealName, ' ', 21), 3, 25, 31);
                Crt.FastWrite("F1=HELP", 27, 25, 31);
                Crt.FastWrite("RMASTERMIND", 37, 25, 31);
                Crt.FastWrite(StringUtils.PadRight("Idle: " + StringUtils.SecToMS(Door.SecondsIdle), ' ', 11), 51, 25, 31);
                Crt.FastWrite("Left: " + StringUtils.SecToHMS(Door.SecondsLeft), 65, 25, 31);
                break;

            case 1:
                Crt.FastWrite("þ F1: Toggle StatusBar þ Alt-C: SysOp Chat þ Alt-H: Hang-Up þ Alt-K: Kick User þ", 1, 25, 30);
                Crt.FastWrite("F1: Toggle StatusBar", 3, 25, 31);
                Crt.FastWrite("Alt-C: SysOp Chat", 26, 25, 31);
                Crt.FastWrite("Alt-H: Hang-Up", 46, 25, 31);
                Crt.FastWrite("Alt-K: Kick User", 63, 25, 31);
                break;

            case 2:
                Crt.FastWrite(StringUtils.PadRight(" " + PROG_VER + " is an R&M Door example program - http://www.randm.ca/", ' ', 80), 1, 25, 31);
                break;
            }
        }
Ejemplo n.º 3
0
        private void LogUnimplemented(string[] tokens)
        {
            string Output = "UNIMPLEMENTED (hit a key): " + string.Join(" ", tokens);

            Crt.FastWrite(StringUtils.PadRight(Output, ' ', 80), 1, 25, 31);
            Crt.ReadKey();
            Crt.FastWrite(new string(' ', 80), 1, 25, 0);
        }
Ejemplo n.º 4
0
        private void LogUnused(string[] tokens)
        {
            string Output = "UNUSED?!? (hit a key): " + string.Join(" ", tokens);

            Crt.FastWrite(StringUtils.PadRight(Output, ' ', 80), 1, 25, 31);
            Crt.ReadKey();
            Crt.FastWrite(new string(' ', 80), 1, 25, 0);
        }
Ejemplo n.º 5
0
        private void LogMissing(string[] tokens)
        {
            string Output = "MISSING!!! (hit a key): " + string.Join(" ", tokens);

            Crt.FastWrite(StringUtils.PadRight(Output, ' ', 80), 1, 25, 31);
            Crt.ReadKey();
            Crt.FastWrite(new string(' ', 80), 1, 25, 0);
        }
Ejemplo n.º 6
0
 private static void UpdateTime()
 {
     if (_FancyOutput)
     {
         // Update time
         Crt.FastWrite(StringUtils.PadRight(DateTime.Now.ToString(_TimeFormatFooter).ToLower(), ' ', 7), 9, 38, Crt.LightGreen);
         Crt.FastWrite(StringUtils.PadRight(DateTime.Now.ToString("dddd MMMM dd, yyyy"), ' ', 28), 23, 38, Crt.LightGreen);
     }
 }
Ejemplo n.º 7
0
        static void GameSrv_LogOnEvent(object sender, NodeEventArgs e)
        {
            if (_FancyOutput)
            {
                _ConnectionCounts[e.NodeInfo.ConnectionType] += 1;

                Crt.FastWrite(StringUtils.PadRight(e.NodeInfo.User.Alias + " (" + e.NodeInfo.Connection.GetRemoteIP() + ":" + e.NodeInfo.Connection.GetRemotePort() + ")", ' ', 65), 8, 1, (Crt.Blue << 4) + Crt.White);
                Crt.FastWrite(StringUtils.PadRight(DateTime.Now.ToString("dddd MMMM dd, yyyy  " + _TimeFormatFooter), ' ', 65), 8, 2, (Crt.Blue << 4) + Crt.White);
                Crt.FastWrite(StringUtils.PadRight(e.NodeInfo.ConnectionType.ToString(), ' ', 65), 8, 3, (Crt.Blue << 4) + Crt.White);
                Crt.FastWrite(_ConnectionCounts[ConnectionType.RLogin].ToString(), 87, 1, (Crt.Blue << 4) + Crt.White);
                Crt.FastWrite(_ConnectionCounts[ConnectionType.Telnet].ToString(), 87, 2, (Crt.Blue << 4) + Crt.White);
                Crt.FastWrite(_ConnectionCounts[ConnectionType.WebSocket].ToString(), 87, 3, (Crt.Blue << 4) + Crt.White);
                UpdateTime();
            }
        }
Ejemplo n.º 8
0
        private static void InitConsole()
        {
            Crt.SetTitle("GameSrv WFC Screen v" + GameSrv.Version);
            Crt.SetWindowSize(90, 40);
            Crt.HideCursor();
            Crt.ClrScr();

            // WFC Screen
            Ansi.Write(" Last: No callers yet...                                                 ³    RLogin: 0      On: No callers yet...                                                 ³    Telnet: 0    Type: No callers yet...                                                 ³ WebSocket: 0   ÚððStatusððÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ³ Time: Date: ³ °±²ÛGameSrv WFC Screen v" + GameSrv.Version + " ²±° ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ  Press [F1] For Help or [Q] To Quit");
            Crt.FastWrite(DateTime.Now.ToString(_TimeFormatFooter).ToLower(), 9, 38, Crt.LightGreen);
            Crt.FastWrite(DateTime.Now.ToString("dddd MMMM dd, yyyy"), 23, 38, Crt.LightGreen);

            // Setup scrolling region with a window
            Crt.Window(3, 5, 88, 36);
            Crt.GotoXY(1, 32);
        }
Ejemplo n.º 9
0
        static void Main(string[] args)
        {
            try
            {
                if (!Debugger.IsAttached)
                {
                    Crt.HideCursor();
                }

                // Initialize door driver
                Door.Startup();
                Door.ClrScr();
                Door.SethWrite = true;

                Game.Start();

                if (Debugger.IsAttached)
                {
                    Crt.FastWrite(StringUtils.PadRight("Terminating...hit a key to quit", '\0', 80), 1, 25, 31);
                    Crt.ReadKey();
                }
            }
            catch (Exception ex)
            {
                if (Debugger.IsAttached)
                {
                    throw;
                }
                FileUtils.FileAppendAllText(Global.GetSafeAbsolutePath("ex.log"), ex.ToString() + Environment.NewLine);
                Door.WriteLn();
                Door.WriteLn($"`4`b**`% ERROR : `2{ex.Message} `4`b**`2");
                Door.Write("Hit a key to quit");
                Door.ReadKey();
            }
            finally
            {
                Door.Shutdown();
            }
        }
Ejemplo n.º 10
0
        private static void InitConsole()
        {
            if (_FancyOutput)
            {
                //TODO Can do this without System.Windows.Forms reference? Crt.SetIcon(new Icon(Assembly.GetExecutingAssembly().GetManifestResourceStream("GameSrv.GameSrv16+32.ico")).Handle);
                Crt.SetTitle("GameSrv WFC Screen v" + GameSrv.Version);
                Crt.SetWindowSize(90, 40);
                Crt.HideCursor();
                Crt.ClrScr();

                // WFC Screen
                Ansi.Write(" Last: No callers yet...                                                 ³    RLogin: 0      On: No callers yet...                                                 ³    Telnet: 0    Type: No callers yet...                                                 ³ WebSocket: 0   ÚððStatusððÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³³ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ³ Time: Date: ³ °±²ÛGameSrv WFC Screen v" + GameSrv.Version + " ²±° ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ  Press [F1] For Help or [Q] To Quit");
                Crt.FastWrite(DateTime.Now.ToString(_TimeFormatFooter).ToLower(), 9, 38, Crt.LightGreen);
                Crt.FastWrite(DateTime.Now.ToString("dddd MMMM dd, yyyy"), 23, 38, Crt.LightGreen);

                // Setup scrolling region with a window
                Crt.Window(3, 5, 88, 36);
                Crt.GotoXY(1, 32);
            }
            else
            {
                Crt.ClrScr();
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Re-Draw the bar and percent text.
        /// </summary>
        /// <param name="AForce">When true, the bar and percent will always be Paintn.  When false, the bar and percent will only be Paintn as necessary, which reduces the number of unnecessary Paints (especially when a large maximum is used)</param>
        protected override void Paint(bool AForce)
        {
            if (Style == ProgressBarStyle.Marquee)
            {
                if (AForce)
                {
                    // Erase the old bar
                    Crt.FastWrite(new string((char)176, _Width), ScreenLeft, ScreenTop, _BlankForeColour, _BackColour);
                }

                // Draw the new bar
                if (_Value > 0)
                {
                    if (_Value > _Width)
                    {
                        Crt.FastWrite(((char)176).ToString(), ScreenLeft + _Width - (15 - (int)(_Value - _Width)), ScreenTop, _BlankForeColour, _BackColour);
                    }
                    else if (_Value >= 15)
                    {
                        string Bar = new string((char)219, (int)Math.Min(_Value, 15));
                        Crt.FastWrite(Bar, ScreenLeft + (int)_Value - 15, ScreenTop, _BarForeColour, _BackColour);
                        Crt.FastWrite(((char)176).ToString(), ScreenLeft + (int)_Value - 15, ScreenTop, _BlankForeColour, _BackColour);
                    }
                    else
                    {
                        string Bar = new string((char)219, (int)Math.Min(_Value, 15));
                        Crt.FastWrite(Bar, ScreenLeft, ScreenTop, _BarForeColour, _BackColour);
                    }
                }
            }
            else
            {
                // Check if we're forcing an update (probably due to a change in Left, Top, Width, etc)
                if (AForce)
                {
                    // Yep, so reset the "Last" variables
                    _LastBarWidth    = 9999;
                    _LastPercentText = "";
                }

                bool   PaintPercentText = false;
                double Percent          = ((double)Value / (double)Maximum);
                int    NewBarWidth      = (int)(Percent * _Width);
                if (NewBarWidth != _LastBarWidth)
                {
                    // Check if the bar shrank (if so, we need to delete the old bar)
                    if (NewBarWidth < _LastBarWidth)
                    {
                        // Erase the old bar
                        Crt.FastWrite(new string((char)176, _Width), ScreenLeft, ScreenTop, _BlankForeColour, _BackColour);
                    }

                    // Draw the new bar
                    Crt.FastWrite(new string((char)_Style, NewBarWidth), ScreenLeft, ScreenTop, _BarForeColour, _BackColour);

                    _LastBarWidth    = NewBarWidth;
                    PaintPercentText = true;
                }

                // Draw the percentage
                if (_PercentVisible)
                {
                    string NewPercentText = Percent.ToString("P" + _PercentPrecision.ToString());
                    if ((NewPercentText != _LastPercentText) || (PaintPercentText))
                    {
                        _LastPercentText = NewPercentText;

                        int ProgressStart = (Width - NewPercentText.Length) / 2;
                        if (ProgressStart >= NewBarWidth)
                        {
                            // Bar hasn't reached the percent text, so draw in the bar's empty color
                            Crt.FastWrite(NewPercentText, ScreenLeft + ProgressStart, ScreenTop, _BlankForeColour, _BackColour);
                        }
                        else if (ProgressStart + NewPercentText.Length <= NewBarWidth)
                        {
                            // Bar has passed the percent text, so draw in the bar's foreground colour (or still use background for Blocks)
                            Crt.FastWrite(NewPercentText, ScreenLeft + ProgressStart, ScreenTop, _BackColour, _BarForeColour);
                        }
                        else
                        {
                            // Bar is in the middle of the percent text, so draw the colour as necessary for each letter in the text
                            for (int i = 0; i < NewPercentText.Length; i++)
                            {
                                int LetterPosition = ProgressStart + i;
                                int FG             = (LetterPosition >= NewBarWidth) ? _BlankForeColour : _BackColour;
                                int BG             = (LetterPosition >= NewBarWidth) ? _BackColour : _BarForeColour;
                                Crt.FastWrite(NewPercentText[i].ToString(), ScreenLeft + LetterPosition, ScreenTop, FG, BG);
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 12
0
        protected override void Paint(bool AForce)
        {
            // Characters for the box
            char TopLeft     = '\0';
            char TopRight    = '\0';
            char BottomLeft  = '\0';
            char BottomRight = '\0';
            char TopBottom   = '\0';
            char LeftRight   = '\0';

            // Determine which character set to use
            switch (_Border)
            {
            case BorderStyle.Single:
                TopLeft     = (char)218;
                TopRight    = (char)191;
                BottomLeft  = (char)192;
                BottomRight = (char)217;
                TopBottom   = (char)196;
                LeftRight   = (char)179;
                break;

            case BorderStyle.Double:
                TopLeft     = (char)201;
                TopRight    = (char)187;
                BottomLeft  = (char)200;
                BottomRight = (char)188;
                TopBottom   = (char)205;
                LeftRight   = (char)186;
                break;

            case BorderStyle.DoubleH:
            case BorderStyle.SingleV:
                TopLeft     = (char)213;
                TopRight    = (char)184;
                BottomLeft  = (char)212;
                BottomRight = (char)190;
                TopBottom   = (char)205;
                LeftRight   = (char)179;
                break;

            case BorderStyle.DoubleV:
            case BorderStyle.SingleH:
                TopLeft     = (char)214;
                TopRight    = (char)183;
                BottomLeft  = (char)211;
                BottomRight = (char)189;
                TopBottom   = (char)196;
                LeftRight   = (char)186;
                break;
            }

            // Draw top row
            Crt.FastWrite(TopLeft.ToString() + new string(TopBottom, _Width - 2) + TopRight.ToString(), ScreenLeft, ScreenTop, _ForeColour, _BackColour);

            // Draw middle rows
            for (int Line = ScreenTop + 1; Line < ScreenTop + _Height - 1; Line++)
            {
                Crt.FastWrite(LeftRight.ToString() + new string(' ', _Width - 2) + LeftRight.ToString(), ScreenLeft, Line, _ForeColour, _BackColour);
            }

            // Draw bottom row
            Crt.FastWrite(BottomLeft.ToString() + new string(TopBottom, _Width - 2) + BottomRight.ToString(), ScreenLeft, ScreenTop + _Height - 1, _ForeColour, _BackColour);

            // Draw window title
            if (_Text.Trim().Length > 0)
            {
                int    TitleX      = 0;
                int    TitleY      = 0;
                string WindowTitle = " " + _Text.Trim() + " ";

                // Get X component
                switch (_TextAlignment)
                {
                case CrtAlignment.BottomLeft:
                case CrtAlignment.MiddleLeft:
                case CrtAlignment.TopLeft:
                    TitleX = ScreenLeft + 2;
                    break;

                case CrtAlignment.BottomCenter:
                case CrtAlignment.MiddleCenter:
                case CrtAlignment.TopCenter:
                    TitleX = ScreenLeft + ((_Width - WindowTitle.Length) / 2);
                    break;

                case CrtAlignment.BottomRight:
                case CrtAlignment.MiddleRight:
                case CrtAlignment.TopRight:
                    TitleX = ScreenLeft + Width - WindowTitle.Length - 2;
                    break;
                }

                // Get the Y component
                switch (_TextAlignment)
                {
                case CrtAlignment.BottomCenter:
                case CrtAlignment.BottomLeft:
                case CrtAlignment.BottomRight:
                    TitleY = ScreenTop + _Height - 1;
                    break;

                case CrtAlignment.MiddleCenter:
                case CrtAlignment.MiddleLeft:
                case CrtAlignment.MiddleRight:
                case CrtAlignment.TopCenter:
                case CrtAlignment.TopLeft:
                case CrtAlignment.TopRight:
                    TitleY = ScreenTop;
                    break;
                }

                // Draw title
                Crt.FastWrite(WindowTitle, TitleX, TitleY, _ForeColour, _BackColour);
            }
        }