Ejemplo n.º 1
0
        public void TickLateUpdate()
        {
            if (m_ConsoleOpen)
            {
                m_DebugOverlay.visibleLinesOfText = m_Height;

                var lastY = m_Height - 2;
                for (var y = lastY; y > 4; --y)
                {
                    int line = m_LastVisibleLine - (lastY - y);
                    var idx  = (line % m_NumLines) * m_Width;
                    for (var x = 0; x < m_Width; x++)
                    {
                        var c = m_ConsoleBuffer[idx + x];
                        m_DebugOverlay.m_Unmanaged.m_Text.PutChar(x, y, c);
                    }
                }

                var blank = new Overlay.Text.Cell {
                };
                m_DebugOverlay.m_Unmanaged.m_Text.PutChars(0, m_Height - 1, blank, m_Width);

                var horizontalScroll = m_CursorPos - m_Width + 1;
                horizontalScroll = Mathf.Max(0, horizontalScroll);
                for (var i = horizontalScroll; i < m_InputFieldLength; i++)
                {
                    var c = m_InputFieldBuffer[i];
                    c.fg = m_TextColor;
                    c.bg = m_BackgroundColor;
                    if (c.unicode != '\0')
                    {
                        m_DebugOverlay.m_Unmanaged.m_Text.PutChar(i - horizontalScroll, m_Height - 1, c);
                    }
                }

                ++blinking;
                if (((blinking >> 3) & 1) == 1)
                {
                    var cursor = new Overlay.Text.Cell {
                        unicode = '▒', fg = m_CursorCol, bg = m_BackgroundColor
                    };
                    m_DebugOverlay.m_Unmanaged.m_Text.PutChar(m_CursorPos - horizontalScroll, m_Height - 1, cursor);
                }
            }
            else
            {
                m_DebugOverlay.visibleLinesOfText = 4;
            }
        }
Ejemplo n.º 2
0
 void InputFieldBufferFromString(string s)
 {
     m_InputFieldLength = 0;
     for (int i = 0; i < s.Length; ++i)
     {
         Overlay.Text.Cell t = new Overlay.Text.Cell {
             unicode = s[i]
         };
         m_InputFieldBuffer[m_InputFieldLength++] = t;
         if (Overlay.Managed.instance.m_Unmanaged.m_Text.isWide(s[i]))
         {
             t.side = true;
             m_InputFieldBuffer[m_InputFieldLength++] = t;
         }
     }
 }
Ejemplo n.º 3
0
        void Type(char c)
        {
            if (m_InputFieldLength >= m_InputFieldBuffer.Length)
            {
                return;
            }

            for (int i = 0; i < m_InputFieldLength - m_CursorPos; ++i)
            {
                m_InputFieldBuffer[m_InputFieldLength - i] = m_InputFieldBuffer[m_InputFieldLength - 1 - i];
            }
            m_InputFieldBuffer[m_CursorPos] = new Overlay.Text.Cell {
                unicode = c
            };
            m_CursorPos++;
            m_InputFieldLength++;
        }
Ejemplo n.º 4
0
        public void _Write(char[] buf, int length)
        {
            const string hexes = "0123456789ABCDEF";

            Overlay.Color col = Overlay.Color.Gray;
            for (int i = 0; i < length; i++)
            {
                if (buf[i] == '\n')
                {
                    NewLine();
                    continue;
                }

                // Parse color markup of the form ^AF7 -> color(0xAA, 0xFF, 0x77)
                if (buf[i] == '^' && i < length - 3)
                {
                    var r    = (uint)hexes.IndexOf(buf[i + 1]);
                    var g    = (uint)hexes.IndexOf(buf[i + 2]);
                    var b    = (uint)hexes.IndexOf(buf[i + 3]);
                    var rgba = new Vector4(r, g, b, 15) / 15.0f;
                    col = Overlay.Managed.instance.m_Unmanaged.Quantize(rgba);
                    i  += 3;
                    continue;
                }

                var idx = (m_LastLine % m_NumLines) * m_Width + m_LastColumn;
                var t   = new Overlay.Text.Cell {
                    unicode = buf[i], fg = col
                };
                m_ConsoleBuffer[idx] = t;
                m_LastColumn++;
                if (m_LastColumn >= m_Width)
                {
                    NewLine();
                }
            }
        }