Example #1
0
 /// <summary>
 /// Generates a horizontal line on screen
 /// </summary>
 /// <param name="pChar">Character to use</param>
 /// <param name="pPosX">Left position</param>
 /// <param name="pPosY">Top position</param>
 /// <param name="pLenght">Length</param>
 internal static void GenerateHorizontalLine(Core.Layer pLayer, char pChar, int pPosX, int pPosY, int pLenght)
 {
     Console.SetCursorPosition(pPosX, pPosY);
     for (int i = 0; i < pLenght; i++)
     {
         Core.Write(pLayer, pChar);
     }
 }
Example #2
0
 /// <summary>
 /// Generates a vertical line on screen
 /// </summary>
 /// <param name="pChar">Character to use</param>
 /// <param name="pPosX">Left position</param>
 /// <param name="pPosY">Top position</param>
 /// <param name="pLenght">Length</param>
 internal static void GenerateVerticalLine(Core.Layer pLayer, char pChar, int pPosX, int pPosY, int pLenght)
 {
     Console.SetCursorPosition(pPosX, pPosY);
     for (int i = 0; i < pLenght; i++)
     {
         Core.Write(pLayer, pChar);
         Console.SetCursorPosition(pPosX, pPosY++);
         /* -- REASONS WHY I DO IT THIS WAY --
          * NEWLINE F***S UP SHIT
          * ADDING SPACE (for padding) OVERWRITES [anything in between] BUFFER
          * "hurr durr ur cpu cycles!!!11"
          */
     }
 }
Example #3
0
File: Game.cs Project: Nuke928/fwod
        /// <summary>
        /// Generates a box.
        /// </summary>
        /// <param name="pType">Type of line.</param>
        /// <param name="pPosX">Top position.</param>
        /// <param name="pPosY">Left position.</param>
        /// <param name="pWidth">Width.</param>
        /// <param name="pHeight">Height.</param>
        internal static void GenerateBox(Core.Layer pLayer, TypeOfLine pType, int pPosX, int pPosY, int pWidth, int pHeight)
        {
            // Minimum value must be at least 2
            pWidth = pWidth < 2 ? 1 : pWidth - 2;
            pHeight = pHeight < 2 ? 1 : pHeight - 1;

            // Verify that values are within bounds
            if (pPosX < 0)
            {
                pPosX = 0;
            }

            if (pPosX + pWidth > ConsoleTools.BufferWidth)
            {
                pPosX = ConsoleTools.BufferWidth - pWidth;
            }

            if (pPosY < 0)
            {
                pPosY = 0;
            }

            if (pPosY + pHeight > ConsoleTools.BufferWidth)
            {
                pPosY = ConsoleTools.BufferWidth - pHeight;
            }

            // Default is single lines
            char CornerTLChar = Graphics.Lines.SingleCorner[0]; // Top Left
            char CornerTRChar = Graphics.Lines.SingleCorner[1]; // Top Right
            char CornerBLChar = Graphics.Lines.SingleCorner[3]; // Bottom Left
            char CornerBRChar = Graphics.Lines.SingleCorner[2]; // Bottom Right
            char HorizontalChar = Graphics.Lines.Single[1];     // Horizontal
            char VerticalChar = Graphics.Lines.Single[0];       // Vertical

            switch (pType)
            {
                case TypeOfLine.Double:
                    CornerTLChar = Graphics.Lines.DoubleCorner[0];
                    CornerTRChar = Graphics.Lines.DoubleCorner[1];
                    CornerBLChar = Graphics.Lines.DoubleCorner[3];
                    CornerBRChar = Graphics.Lines.DoubleCorner[2];
                    HorizontalChar = Graphics.Lines.Double[1];
                    VerticalChar = Graphics.Lines.Double[0];
                    break;
            }

            // Top wall
            Core.Write(pLayer, CornerTLChar, pPosX, pPosY);
            ConsoleTools.GenerateHorizontalLine(pLayer, HorizontalChar, pWidth);
            Core.Write(pLayer, CornerTRChar);

            // Side walls
            Console.SetCursorPosition(pPosX, pPosY + 1);
            ConsoleTools.GenerateVerticalLine(pLayer, VerticalChar, pHeight);

            Console.SetCursorPosition(pPosX + pWidth + 1, pPosY + 1);
            ConsoleTools.GenerateVerticalLine(pLayer, VerticalChar, pHeight);

            // Bottom wall
            Console.SetCursorPosition(pPosX, pPosY + pHeight);
            Core.Write(pLayer, CornerBLChar);
            ConsoleTools.GenerateHorizontalLine(pLayer, HorizontalChar, pWidth);
            Core.Write(pLayer, CornerBRChar);
        }
Example #4
0
 /// <summary>
 /// Generates a vertical line on screen
 /// </summary>
 /// <param name="pChar">Character to use</param>
 /// <param name="pLenght">Length</param>
 internal static void GenerateVerticalLine(Core.Layer pLayer, char pChar, int pLenght)
 {
     GenerateVerticalLine(pLayer, pChar, Console.CursorLeft, Console.CursorTop, pLenght);
 }
Example #5
0
 /// <summary>
 /// Center text to middle and write, then moves a line foward
 /// </summary>
 /// <param name="pText">Input text</param>
 /// <param name="pTopPosition">Top position</param>
 internal static void WriteLineAndCenter(Core.Layer pLayer, string pText, int pTopPosition)
 {
     WriteAndCenter(pLayer, pText, pTopPosition);
     Console.SetCursorPosition(0, pTopPosition + 1);
 }
Example #6
0
 /// <summary>
 /// Center text to middle and write, then moves a line foward
 /// </summary>
 /// <param name="pText">Input text</param>
 internal static void WriteLineAndCenter(Core.Layer pLayer, string pText)
 {
     WriteLineAndCenter(pLayer, pText, Console.CursorTop);
 }
Example #7
0
 /// <summary>
 /// Center text to middle and write to a specific top position
 /// </summary>
 /// <param name="pText">Input text</param>
 /// <param name="pTopPosition">Top position</param>
 internal static void WriteAndCenter(Core.Layer pLayer, string pText, int pTopPosition)
 {
     // Calculate the starting position
     int start = (BufferWidth / 2) - (pText.Length / 2);
     // If the text is longer than the buffer, set it to 0
     start = start + pText.Length > BufferWidth ? 0 : start;
     // Print away at the current cursor height (top)
     Console.SetCursorPosition(start, pTopPosition);
     Core.Write(pLayer, pText);
 }