コード例 #1
0
ファイル: GameConsole.cs プロジェクト: ttou73/IronStar
        void RefreshConsoleLayer()
        {
            if (!dirty)
            {
                return;
            }

            var vp = Game.GraphicsDevice.DisplayBounds;

            int cols = vp.Width / charWidth;
            int rows = vp.Height / charHeight / 2;

            int count = 1;

            consoleLayer.Clear();

            //	add small gap below command line...
            consoleLayer.Draw(null, 0, 0, vp.Width, vp.Height / 2 + 1, BackColor);

            var lines = LogRecorder.GetLines();

            scroll = MathUtil.Clamp(scroll, 0, lines.Count());

            /*var info = Game.GetReleaseInfo();
             * consoleFont.DrawString( consoleLayer, info, vp.Width - consoleFont.MeasureString(info).Width, vp.Height/2 - 1 * charHeight, ErrorColor );*/


            foreach (var line in lines.Reverse().Skip(scroll))
            {
                Color color = Color.Gray;

                switch (line.MessageType)
                {
                case LogMessageType.Information: color = MessageColor; break;

                case LogMessageType.Error: color = ErrorColor;   break;

                case LogMessageType.Warning: color = WarningColor; break;

                case LogMessageType.Verbose: color = VerboseColor; break;

                case LogMessageType.Debug: color = DebugColor;   break;
                }


                DrawString(consoleLayer, charWidth / 2, vp.Height / 2 - (count + 2) * charHeight, line.MessageText, color);
                //consoleFont.DrawString( consoleLayer, line.Message, , color );

                if (count > rows)
                {
                    break;
                }

                count++;
            }

            dirty = false;
        }