Пример #1
0
        private void DrawBlood(float alpha)
        {
            RectangleF destination     = new RectangleF(0f, 0f, (float)MyGuiManager.GetFullscreenRectangle().Width, (float)MyGuiManager.GetFullscreenRectangle().Height);
            Rectangle? sourceRectangle = null;

            MyRenderProxy.DrawSprite(@"Textures\Gui\Blood.dds", ref destination, false, ref sourceRectangle, new Color(new Vector4(1f, 1f, 1f, alpha)), 0f, new Vector2(1f, 0f), ref Vector2.Zero, SpriteEffects.None, 0f, true, null);
        }
Пример #2
0
        private void DrawBlood(float alpha)
        {
            RectangleF dest   = new RectangleF(0, 0, MyGuiManager.GetFullscreenRectangle().Width, MyGuiManager.GetFullscreenRectangle().Height);
            Rectangle? source = null;

            VRageRender.MyRenderProxy.DrawSprite("Textures\\Gui\\Blood.dds", ref dest, false, ref source, new Color(new Vector4(1, 1, 1, alpha)), 0,
                                                 new Vector2(1, 0), ref Vector2.Zero, VRageRender.Graphics.SpriteEffects.None, 0);
        }
Пример #3
0
        private static void DrawFullScreenSprite()
        {
            var       fullScreenRect = MyGuiManager.GetFullscreenRectangle();
            var       rect           = new RectangleF(fullScreenRect.X, fullScreenRect.Y, fullScreenRect.Width, fullScreenRect.Height);
            Rectangle?source         = null;
            Vector2   origin         = Vector2.Zero;

            VRageRender.MyRenderProxy.DrawSprite(m_textureName, ref rect, false, ref source, Color.White, 0f, Vector2.UnitX, ref origin, VRageRender.Graphics.SpriteEffects.None, 0f);
        }
        public static void Reload()
        {
            Rectangle a = MyGuiManager.GetSafeFullscreenRectangle();
            Rectangle b = MyGuiManager.GetFullscreenRectangle();

            topLeftPosition  = MyGuiManager.GetNormalizedCoordinateFromScreenCoordinate(MyGuiConstants.AMMO_SELECT_LEFT_TOP_POSITION);
            topLeftPosition += new Vector2((a.X - b.X) / a.Width, 0);
            m_menuItemHeight = m_menuItemWidth * 4f / 3f;
            ItemHeight       = m_itemWidth * 4f / 3f;
        }
        public override void Draw(float transitionAlpha, float backgroundTransitionAlpha)
        {
            var pixelHorizontal  = 1.1f / MyGuiManager.GetFullscreenRectangle().Width;
            var pixelVertical    = 1.1f / MyGuiManager.GetFullscreenRectangle().Height;
            var paddedSize       = Size + new Vector2(-2.1f * pixelHorizontal, -2.0f * pixelVertical);
            var progressFillSize = paddedSize * new Vector2((IsHorizontal ? Value : 1.0f), (IsHorizontal ? 1.0f : Value));

            m_progressForeground.Size = progressFillSize;

            base.Draw(transitionAlpha, backgroundTransitionAlpha);
        }
            private void RecalculatePotentialBar()
            {
                if (!m_progressBar.PotentialBar.Visible)
                {
                    return;
                }
                RecalculateStatRegenLeft();
                var pixelHorizontal = 1.01f / MyGuiManager.GetFullscreenRectangle().Height;
                var pixelVertical   = 1.01f / MyGuiManager.GetFullscreenRectangle().Height;

                m_progressBar.PotentialBar.Size = new Vector2(m_progressBar.Size.X * (MathHelper.Clamp((m_stat.StatRegenLeft + m_stat.Value + m_potentialChange) / m_stat.MaxValue, 0f, 1f)) - pixelHorizontal, m_progressBar.Size.Y - 2.0f * pixelVertical);
            }
Пример #7
0
        public void Draw(Vector2 mousePosition)
        {
            const bool centerHeight       = false;
            var        normalizedPosition = mousePosition + MyGuiConstants.TOOL_TIP_RELATIVE_DEFAULT_POSITION;

            if (Size.X > -1f)
            {
                Vector2 innerBorder = new Vector2(0.005f, 0.002f);
                Vector2 bgSize      = Size + 2 * innerBorder;
                Vector2 bgPosition  = normalizedPosition - new Vector2(innerBorder.X, centerHeight ? bgSize.Y / 2 : 0);

                var screenRectangle = MyGuiManager.FullscreenHudEnabled ? MyGuiManager.GetFullscreenRectangle() : MyGuiManager.GetSafeFullscreenRectangle();
                var topleft         = MyGuiManager.GetNormalizedCoordinateFromScreenCoordinate(new Vector2(screenRectangle.Left, screenRectangle.Top)) + new Vector2(MyGuiConstants.TOOLTIP_DISTANCE_FROM_BORDER);
                var rightbottom     = MyGuiManager.GetNormalizedCoordinateFromScreenCoordinate(new Vector2(screenRectangle.Right, screenRectangle.Bottom)) - new Vector2(MyGuiConstants.TOOLTIP_DISTANCE_FROM_BORDER);

                if (bgPosition.X + bgSize.X > rightbottom.X)
                {
                    bgPosition.X = rightbottom.X - bgSize.X;
                }
                if (bgPosition.Y + bgSize.Y > rightbottom.Y)
                {
                    bgPosition.Y = rightbottom.Y - bgSize.Y;
                }
                if (bgPosition.X < topleft.X)
                {
                    bgPosition.X = topleft.X;
                }
                if (bgPosition.Y < topleft.Y)
                {
                    bgPosition.Y = topleft.Y;
                }

                if (Highlight)
                {
                    Vector2 offset            = new Vector2(0.003f, 0.004f);
                    Vector2 highlightPosition = bgPosition - offset;
                    Vector2 highlightSize     = bgSize + 2 * offset;

                    MyGuiConstants.TEXTURE_RECTANGLE_NEUTRAL.Draw(highlightPosition, highlightSize, HighlightColor);
                }

                MyGuiManager.DrawSpriteBatch(MyGuiConstants.BLANK_TEXTURE, bgPosition, bgSize, MyGuiConstants.THEMED_GUI_BACKGROUND_COLOR, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP);
                MyGuiManager.DrawBorders(bgPosition, bgSize, MyGuiConstants.THEMED_GUI_LINE_COLOR, 1);

                Vector2 toolTipPosition = bgPosition + new Vector2(innerBorder.X, bgSize.Y / 2 - Size.Y / 2f);

                foreach (MyColoredText toolTip in ToolTips)
                {
                    toolTip.Draw(toolTipPosition, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, 1f, false);
                    toolTipPosition.Y += toolTip.Size.Y;
                }
            }
        }
Пример #8
0
        /// <summary>
        /// Draw drag indicators in the top left corner of the screen.
        /// Modified from MyGuiScreenHudSpace.DrawGravityIndicator.
        /// </summary>
        public static void DrawDrag(IMyCubeBlock cockpit, ref Vector3 worldDrag, float airDensity)
        {
            Rectangle fullscreen = MyGuiManager.GetFullscreenRectangle();

            if (screenSize.X != fullscreen.Width || screenSize.Y != fullscreen.Width)
            {
                screenSize.X = fullscreen.Width;
                screenSize.Y = fullscreen.Width;

                DrawAirAndDrag_CalcultatePositions();
            }

            DrawAirDensity.Clear();
            DrawAirDensity.Append("Air: ");
            DrawAirDensity.Append(airDensity.ToString("F3"));

            MyGuiManager.DrawSpriteBatch(MyGuiConstants.TEXTURE_HUD_BG_MEDIUM_DEFAULT.Texture, backgroundPosition, backgroundSize, Color.White, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM);
            MyGuiManager.DrawString(MyFontEnum.White, DrawTitle, titleTextPos, MyGuiConstants.HUD_TEXT_SCALE, drawAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM);
            MyGuiManager.DrawSpriteBatch(MyGuiConstants.TEXTURE_HUD_GRAVITY_LINE.Texture, dividerLinePosition, dividerLineSize, Color.White, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER);
            MyGuiManager.DrawString(MyFontEnum.White, DrawAirDensity, airDensityTextPos, MyGuiConstants.HUD_TEXT_SCALE, drawAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM);

            object obj = MyGuiScreenHudSpace_Static.GetValue(null);

            Vector3 backward = cockpit.WorldMatrix.Backward;
            float   parasiticDragMag; Vector3.Dot(ref worldDrag, ref backward, out parasiticDragMag);
            Vector3 parasiticDrag; Vector3.Multiply(ref backward, parasiticDragMag, out parasiticDrag);
            Vector3 liftDrag; Vector3.Subtract(ref worldDrag, ref parasiticDrag, out liftDrag);
            Vector3 airSpeed = -cockpit.CubeGrid.Physics.LinearVelocity;

            float length   = airSpeed.Normalize();
            int   lowValue = 255 - (int)(length * 2.55f);           // full colour at 100 m/s
            Color colour   = new Color(255, lowValue, lowValue);

            DrawGravityVectorIndicator_Params[1] = airSpeed;
            DrawGravityVectorIndicator_Params[3] = colour;
            MyGuiScreenHudSpace_DrawGravityVectorIndicator.Invoke(obj, DrawGravityVectorIndicator_Params);

            length   = liftDrag.Normalize();
            lowValue = 255 - (int)(length * 25.5f / cockpit.CubeGrid.Physics.Mass);             // full colour at 10 m/s/s
            colour   = new Color(lowValue, 255, lowValue);

            DrawGravityVectorIndicator_Params[1] = liftDrag;
            DrawGravityVectorIndicator_Params[3] = colour;
            MyGuiScreenHudSpace_DrawGravityVectorIndicator.Invoke(obj, DrawGravityVectorIndicator_Params);
        }
        public MyGuiControlProgressBar(Vector2?position = null, Vector2?size = null, Color?progressBarColor = null,
                                       MyGuiDrawAlignEnum originAlign = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, MyGuiCompositeTexture backgroundTexture = null, bool isHorizontal = true)
            : base(position: position,
                   size: size,
                   backgroundTexture: backgroundTexture,
                   originAlign: originAlign,
                   colorMask: null,
                   toolTip: null)
        {
            ProgressColor = (progressBarColor.HasValue ? progressBarColor.Value : DEFAULT_PROGRESS_COLOR);
            IsHorizontal  = isHorizontal;
            var pixelHorizontal = 1.1f / MyGuiManager.GetFullscreenRectangle().Width;
            var pixelVertical   = 1.1f / MyGuiManager.GetFullscreenRectangle().Height;

            m_progressForeground = new MyGuiControlPanel(position: new Vector2(-Size.X / 2.0f + pixelHorizontal, 0.0f),
                                                         originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER,
                                                         backgroundColor: ProgressColor);
            m_progressForeground.BackgroundTexture = MyGuiConstants.TEXTURE_GUI_BLANK;
            Elements.Add(m_progressForeground);
        }
Пример #10
0
        public void Draw(Vector2 normalizedPosition)
        {
            if (GetSize().X > -1f)
            {
                Vector2 innerBorder = new Vector2(0.005f, 0.002f);
                Vector2 bgSize      = GetSize() + 2 * innerBorder;
                Vector2 bgPosition  = normalizedPosition - new Vector2(innerBorder.X, bgSize.Y / 2);

                var screenRectangle = MyGuiManager.FullscreenHudEnabled ? MyGuiManager.GetFullscreenRectangle() : MyGuiManager.GetSafeFullscreenRectangle();
                var topleft         = MyGuiManager.GetNormalizedCoordinateFromScreenCoordinate(new Vector2(screenRectangle.Left, screenRectangle.Top)) + new Vector2(MyGuiConstants.TOOLTIP_DISTANCE_FROM_BORDER);
                var rightbottom     = MyGuiManager.GetNormalizedCoordinateFromScreenCoordinate(new Vector2(screenRectangle.Right, screenRectangle.Bottom)) - new Vector2(MyGuiConstants.TOOLTIP_DISTANCE_FROM_BORDER);

                if (bgPosition.X + bgSize.X > rightbottom.X)
                {
                    bgPosition.X = rightbottom.X - bgSize.X;
                }
                if (bgPosition.Y + bgSize.Y > rightbottom.Y)
                {
                    bgPosition.Y = rightbottom.Y - bgSize.Y;
                }
                if (bgPosition.X < topleft.X)
                {
                    bgPosition.X = topleft.X;
                }
                if (bgPosition.Y < topleft.Y)
                {
                    bgPosition.Y = topleft.Y;
                }

                MyGUIHelper.FillRectangle(bgPosition, bgSize, MyGuiConstants.TOOL_TIP_BACKGROUND_COLOR);
                MyGUIHelper.OutsideBorder(bgPosition, bgSize, 1, MyGuiConstants.TOOL_TIP_BORDER_COLOR);

                Vector2 toolTipPosition = bgPosition + new Vector2(innerBorder.X, bgSize.Y / 2 - GetSize().Y / 2f);

                foreach (MyColoredText toolTip in GetToolTips())
                {
                    toolTipPosition.Y += toolTip.Draw(toolTipPosition, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, 1f, false).Size.Y;
                }
            }
        }
Пример #11
0
        //  Draw all screens
        public static void Draw()
        {
            VRageRender.MyRenderProxy.GetRenderProfiler().StartProfilingBlock("MyScreenManager::Draw");

            //  Find screen with focus
            MyGuiScreenBase screenWithFocus = GetScreenWithFocus();

            //  Find top screen that has background fade
            MyGuiScreenBase screenFade            = null;
            bool            previousCanHideOthers = false;

            for (int i = (m_screens.Count - 1); i >= 0; i--)
            {
                MyGuiScreenBase screen = m_screens[i];
                bool            screenGetEnableBackgroundFade = screen.EnabledBackgroundFade;
                bool            isScreenFade = false;
                if (screenWithFocus == screen || screen.GetDrawScreenEvenWithoutFocus() || !previousCanHideOthers)
                {
                    if ((screen.State != MyGuiScreenState.CLOSED) && (screenGetEnableBackgroundFade))
                    {
                        isScreenFade = true;
                    }
                }
                else if (IsScreenTransitioning(screen) && screenGetEnableBackgroundFade)
                {
                    isScreenFade = true;
                }

                if (isScreenFade)
                {
                    screenFade = screen;
                    break;
                }
                previousCanHideOthers = screen.CanHideOthers;
            }

            //  Draw all screen, from bottom to top
            for (int i = 0; i < m_screens.Count; i++)
            {
                MyGuiScreenBase screen = m_screens[i];

                bool drawScreen = false;
                if (screenWithFocus == screen || screen.GetDrawScreenEvenWithoutFocus() || !previousCanHideOthers)
                {
                    if (screen.State != MyGuiScreenState.CLOSED && screen.State != MyGuiScreenState.HIDDEN)
                    {
                        drawScreen = true;
                    }
                }
                else if (!screen.CanBeHidden)
                {
                    drawScreen = true;
                }
                else if (IsScreenTransitioning(screen))
                {
                    drawScreen = true;
                }

                if (drawScreen)
                {
                    // Draw background fade before drawing first screen that has it enabled.
                    if (screen == screenFade)
                    {
                        MyGuiManager.DrawSpriteBatch(MyGuiConstants.TEXTURE_BACKGROUND_FADE, MyGuiManager.GetFullscreenRectangle(), screen.BackgroundFadeColor);
                    }

                    screen.Draw();
                }
            }

            //VRageRender.MyRenderProxy.GetRenderProfiler().ProfileCustomValue("Drawcalls", MyPerformanceCounter.PerCameraDrawWrite.TotalDrawCalls);

            VRageRender.MyRenderProxy.GetRenderProfiler().EndProfilingBlock();
        }