Exemple #1
0
        /// <summary>
        /// Updates OSD/message timers and deletes old messages. Returns true if 3D view needs to be redrawn.
        /// </summary>
        public bool UpdateTimer()
        {
            bool removeditems = false;

            foreach (var key in MessageList.Keys.ToList())
            {
                if (!timer_freeze)
                {
                    MessageList[key]--;
                }
                if (MessageList[key] <= 0)
                {
                    MessageList.Remove(key);
                    removeditems = true;
                }
            }
            foreach (OSDItem osd in OSDItems.ToList())
            {
                if (osd.timer != -1)
                {
                    osd.timer--;
                    if (osd.timer <= 0)
                    {
                        OSDItems.Remove(osd);
                        removeditems = true;
                    }
                }
            }
            return(removeditems);
        }
Exemple #2
0
        /// <summary>
        /// Draw pending log and OSD items. Call this before D3DDevice.Present().
        /// </summary>
        public void ProcessMessages()
        {
            StringBuilder MessageString = new StringBuilder();

            //Update timers on render because the form's timer freezes when stuff is rendered
            UpdateTimer();
            //Create the full log string
            foreach (var key in MessageList.Keys.ToList())
            {
                MessageString.AppendFormat(key + "\n");
            }
            textSprite.Begin(SpriteFlags.AlphaBlend);
            //Process OSD items
            if (show_osd)
            {
                foreach (OSDItem osd in OSDItems.ToList())
                {
                    SharpDX.Rectangle rec = EditorOptions.OnscreenFont.MeasureText(null, osd.text, FontDrawFlags.Right);
                    EditorOptions.OnscreenFont.DrawText(textSprite, osd.text, osd.pos_x + 1 + rec.X, osd.pos_y + 1, Color.Black.ToRawColorBGRA());
                    EditorOptions.OnscreenFont.DrawText(textSprite, osd.text, osd.pos_x + rec.X, osd.pos_y + 1, Color.Black.ToRawColorBGRA());
                    EditorOptions.OnscreenFont.DrawText(textSprite, osd.text, osd.pos_x - 1 + rec.X, osd.pos_y - 1, Color.Black.ToRawColorBGRA());
                    EditorOptions.OnscreenFont.DrawText(textSprite, osd.text, osd.pos_x + rec.X, osd.pos_y - 1, Color.Black.ToRawColorBGRA());
                    EditorOptions.OnscreenFont.DrawText(textSprite, osd.text, osd.pos_x + rec.X, osd.pos_y, osd.color);
                }
            }
            //Process messages
            if (MessageList.Count > 0 && d3ddevice != null)
            {
                EditorOptions.OnscreenFont.DrawText(textSprite, MessageString.ToString(), 9, 9, Color.Black.ToRawColorBGRA());
                EditorOptions.OnscreenFont.DrawText(textSprite, MessageString.ToString(), 7, 7, Color.Black.ToRawColorBGRA());
                EditorOptions.OnscreenFont.DrawText(textSprite, MessageString.ToString(), 7, 9, Color.Black.ToRawColorBGRA());
                EditorOptions.OnscreenFont.DrawText(textSprite, MessageString.ToString(), 9, 7, Color.Black.ToRawColorBGRA());
                EditorOptions.OnscreenFont.DrawText(textSprite, MessageString.ToString(), 8, 8, logcolor);
            }
            textSprite.End();
            //Refresh messages after drawing
            MessageString.Clear();
        }