Ejemplo n.º 1
0
 static MyGuiScreenMessageBox()
 {
     m_typesConfiguration = new MyMessageBoxConfiguration[MyMwcUtils.GetMaxValueFromEnum <MyMessageBoxType>() + 1];
     m_typesConfiguration[(int)MyMessageBoxType.MESSAGE] = new MyMessageBoxConfiguration(
         MyTextureManager.GetTexture <MyTexture2D>("Textures\\GUI\\MessageBackground_blue", flags: TextureFlags.IgnoreQuality),
         MyGuiConstants.MESSAGE_BOX_MESSAGE_TEXT_COLOR,
         MyGuiConstants.MESSAGE_BOX_MESSAGE_BACKGROUND_COLOR,
         MyGuiConstants.MESSAGE_BOX_MESSAGE_BUTTON_BACKGROUND_COLOR,
         MyGuiConstants.MESSAGE_BOX_MESSAGE_ROTATING_WHEEL_COLOR,
         MyGuiConstants.MESSAGE_BOX_MESSAGE_BACKGROUND_INTERFERENCE_VIDEO_COLOR,
         MyGuiManager.GetFontMinerWarsBlue(),
         MyGuiManager.GetConfirmButton());
     m_typesConfiguration[(int)MyMessageBoxType.ERROR] = new MyMessageBoxConfiguration(
         MyTextureManager.GetTexture <MyTexture2D>("Textures\\GUI\\MessageBackground_red", flags: TextureFlags.IgnoreQuality),
         MyGuiConstants.MESSAGE_BOX_ERROR_TEXT_COLOR,
         MyGuiConstants.MESSAGE_BOX_ERROR_BACKGROUND_COLOR,
         MyGuiConstants.MESSAGE_BOX_ERROR_BUTTON_BACKGROUND_COLOR,
         MyGuiConstants.MESSAGE_BOX_ERROR_ROTATING_WHEEL_COLOR,
         MyGuiConstants.MESSAGE_BOX_ERROR_BACKGROUND_INTERFERENCE_VIDEO_COLOR,
         MyGuiManager.GetFontMinerWarsWhite(),
         MyGuiManager.GetMessageBoxButton());
     m_typesConfiguration[(int)MyMessageBoxType.NULL] = new MyMessageBoxConfiguration(
         MyTextureManager.GetTexture <MyTexture2D>("Textures\\GUI\\MessageBackground_blue", flags: TextureFlags.IgnoreQuality),
         MyGuiConstants.MESSAGE_BOX_NULL_TEXT_COLOR,
         MyGuiConstants.MESSAGE_BOX_NULL_BACKGROUND_COLOR,
         MyGuiConstants.MESSAGE_BOX_NULL_BUTTON_BACKGROUND_COLOR,
         MyGuiConstants.MESSAGE_BOX_NULL_ROTATING_WHEEL_COLOR,
         MyGuiConstants.MESSAGE_BOX_NULL_BACKGROUND_INTERFERENCE_VIDEO_COLOR,
         MyGuiManager.GetFontMinerWarsBlue(),
         MyGuiManager.GetConfirmButton());
 }
Ejemplo n.º 2
0
        private void DrawTexts()
        {
            m_oreName.Clear();
            m_oreCount.Clear();
            foreach (MyMwcObjectBuilder_Ore_TypesEnum key in Enum.GetValues(typeof(MyMwcObjectBuilder_Ore_TypesEnum)))
            {
                int val = (int)MySession.PlayerShip.Inventory.GetTotalAmountOfInventoryItems(MyMwcObjectBuilderTypeEnum.Ore, (int)key);
                if (val > 0)
                {
                    m_oreName.Append(MyGuiObjectBuilderHelpers.GetGuiHelper(MyMwcObjectBuilderTypeEnum.Ore, (int)key).Description);
                    m_oreName.Append(ORE_TEXT_SEPARATOR);
                    m_oreName.AppendLine();

                    m_oreCount.Append(val);
                    m_oreCount.AppendLine();
                }
            }

            MyGuiManager.DrawString(MyGuiManager.GetFontMinerWarsWhite(), m_oreName,
                                    MyGuiManager.GetScreenTextRightTopPosition() - ORE_INFORMATION_RIGHT_OFFSET, MyGuiConstants.LABEL_TEXT_SCALE,
                                    MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP);

            MyGuiManager.DrawString(MyGuiManager.GetFontMinerWarsWhite(), m_oreCount,
                                    MyGuiManager.GetScreenTextRightTopPosition(), MyGuiConstants.LABEL_TEXT_SCALE,
                                    MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP);
        }
Ejemplo n.º 3
0
        public override void Draw()
        {
            base.Draw();
            MyGuiManager.EndSpriteBatch();
            Vector2 normalizeSize = new Vector2(483 / 1600f, 112 / 1200f);                                                //MyGuiManager.GetNormalizedCoordsAndPreserveOriginalSize(483, 112); 559?
            Vector2 stencilPos    = GetParent().GetPositionAbsolute() - m_size.Value / 2f;
            Vector2 senctilSize   = new Vector2(normalizeSize.X * m_value, normalizeSize.Y) + new Vector2(38 / 1600f, 0); //MyGuiManager.GetNormalizedCoordsAndPreserveOriginalSize(38, 0);

            Utils.MyRectangle2D stencilRect = new Utils.MyRectangle2D(stencilPos, senctilSize);
            MyGuiManager.DrawStencilMaskRectangle(stencilRect, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP);
            MyGuiManager.BeginSpriteBatch_StencilMask();
            // draw progress bar
            MyGuiManager.DrawSpriteBatch(MyGuiManager.GetProgressBarTexture(), GetParent().GetPositionAbsolute(), m_size.Value, new Color(m_progressColor), MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER);
            MyGuiManager.EndSpriteBatch_StencilMask();
            MyGuiManager.BeginSpriteBatch();

            // draw progress value
            m_progressValueText.Clear();
            float percentage = m_value * 100f;

            if (m_decimals > 0)
            {
                m_progressValueText.AppendDecimal(percentage, m_decimals);
            }
            else
            {
                m_progressValueText.AppendInt32((int)percentage);
            }
            m_progressValueText.Append(PERCENTAGE);
            MyGuiManager.DrawString(MyGuiManager.GetFontMinerWarsWhite(), m_progressValueText, GetParent().GetPositionAbsolute() - new Vector2(0f, m_size.Value.Y / 2f), m_textScale, new Color(m_textColor), MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER);
        }
        public override bool Draw(float backgroundFadeAlpha)
        {
            if (base.Draw(backgroundFadeAlpha) == false)
            {
                return(false);
            }

            if (m_videoPlayer != null)
            {
                m_videoPlayer.Update();

                Texture texture = m_videoPlayer.OutputFrame;

                Vector4 color = m_colorMultiplier * m_transitionAlpha;

                Rectangle videoRect;
                MyGuiManager.GetSafeAspectRatioFullScreenPictureSize(new MyMwcVector2Int(texture.GetLevelDescription(0).Width, texture.GetLevelDescription(0).Height), out videoRect);

                MyGuiManager.DrawSpriteBatch(texture, videoRect, new Color(color));

                if (m_subtitleToDraw != null)
                {
                    MyGuiManager.DrawStringCentered(MyGuiManager.GetFontMinerWarsWhite(), m_subtitleToDraw,
                                                    new Vector2(0.5f, 0.85f), 1.6f, Color.White, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_BOTTOM);
                }
            }

            return(true);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Draw debug text
        /// </summary>
        /// <param name="screenCoord"></param>
        /// <param name="text"></param>
        /// <param name="color"></param>
        /// <param name="scale"></param>
        public static float DrawText(Vector2 screenCoord, StringBuilder text, Color color, float scale)
        {
            MyGuiManager.BeginSpriteBatch();
            float textLenght = MyGuiManager.GetFontMinerWarsWhite().DrawString(screenCoord, color, text, scale);

            MyGuiManager.EndSpriteBatch();

            return(textLenght);
        }
Ejemplo n.º 6
0
 public MySolarSystemMapNavigationMark(MyMwcVector3Int sector, string name, MyMissionID?missionID, Color color, MyTransparentMaterialEnum texture)
 {
     Sector           = sector;
     Name             = name;
     Color            = color;
     Texture          = texture;
     Importance       = 1;
     DrawVerticalLine = true;
     MissionID        = missionID;
     Font             = MyGuiManager.GetFontMinerWarsWhite();
 }
        public static void DrawSpriteBatchTooltip()
        {
            // draw description if any, under background layer:
            if (m_description != null)
            {
                /*
                 * var bodyBgSize =
                 *  MyGuiManager.GetNormalizedSizeFromScreenSize(
                 *      MyGuiManager.GetFontMinerWarsWhite().MeasureString(m_description,
                 *                                                            MyGuiConstants.AMMO_SELECTION_TOOL_TIP_TEXT_SCALE)) + new Vector2(-0.005f, -0f);
                 */


                var bodyBgSize = MyGuiManager.GetNormalizedSize(MyGuiManager.GetFontMinerWarsWhite(), m_description,
                                                                MyGuiConstants.AMMO_SELECTION_TOOL_TIP_TEXT_SCALE) * 1.05f;


                //bodyBgSize.Y = 72/1200f;
                m_tipTextPosition   += new Vector2(0.01f, 0f);
                m_tipTextPosition.Y -= m_menuItemHeight * 2f;
                var leftPos = m_tipTextPosition + new Vector2(0.005f, 0f);

                MyGUIHelper.FillRectangle(leftPos, bodyBgSize, MyGuiConstants.TOOL_TIP_BACKGROUND_COLOR);
                MyGUIHelper.OutsideBorder(leftPos, bodyBgSize, 1, MyGuiConstants.TOOL_TIP_BORDER_COLOR);

                //MyGuiManager.BeginSpriteBatch();
                //MyGuiManager.DrawSpriteBatchRoundUp(MyGuiManager.GetToolTipLeft(), leftPos, new Vector2(32 / 1600f, 72 / 1200f), new Color(255, 255, 255, 255), MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER);
                //MyGuiManager.EndSpriteBatch();

                //MyGuiManager.EndSpriteBatch();
                //MyGuiManager.EndSpriteBatch();

                //MyGuiManager.DrawStencilMaskRectangleRoundUp(new MyRectangle2D(leftPos, bodyBgSize), MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER);

                //MyGuiManager.BeginSpriteBatch_StencilMask();
                //MyGuiManager.DrawSpriteBatchRoundUp(MyGuiManager.GetToolTipBody(), leftPos, new Vector2(1024 / 1600f, 72 / 1200f), new Color(255, 255, 255, 255), MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER);
                //MyGuiManager.EndSpriteBatch_StencilMask();

                //MyGuiManager.BeginSpriteBatch();
                //MyGuiManager.DrawSpriteBatchRoundUp(MyGuiManager.GetToolTipRight(), leftPos + new Vector2(bodyBgSize.X, 0), new Vector2(32 / 1600f, 72 / 1200f), new Color(255, 255, 255, 255), MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER);
                //MyGuiManager.EndSpriteBatch();

                //MyGuiManager.BeginSpriteBatch();
                //MyGuiManager.BeginSpriteBatch();

                MyGuiManager.DrawString(MyGuiManager.GetFontMinerWarsBlue(), m_description, m_tipTextPosition + new Vector2(0.01f, 0f), MyGuiConstants.AMMO_SELECTION_TOOL_TIP_TEXT_SCALE,
                                        Color.White,
                                        MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP);
            }
        }
Ejemplo n.º 8
0
            static public void Draw()
            {
                MyGuiManager.BeginSpriteBatch();

                for (int i = 0; i < m_data.Count; i++)
                {
                    TextData data = m_data[i];
                    MyGuiManager.GetFontMinerWarsWhite().DrawString(data.screenCoord, data.color, data.text, data.scale);
                }

                MyGuiManager.EndSpriteBatch();

                m_data.Clear();
            }
Ejemplo n.º 9
0
        public override bool Draw(float backgroundFadeAlpha)
        {
            if (base.Draw(backgroundFadeAlpha) == false)
            {
                return(false);
            }

            SetTexts();
            float textScale = MyGuiConstants.DEBUG_STATISTICS_TEXT_SCALE;

            Vector2 origin = GetScreenLeftTopPosition();

            MyGuiManager.DrawString(MyGuiManager.GetFontMinerWarsWhite(), m_debugText, origin, textScale,
                                    Color.Yellow, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP);

            return(true);
        }
Ejemplo n.º 10
0
        // initialize:
        public static void LoadContent()
        {
            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("MyHudNotification::LoadContent");

            m_usedFont = MyGuiManager.GetFontMinerWarsWhite();
            if (m_screenNotifications == null)
            {
                int allScreensCount = (int)MyGuiScreenGamePlayType.ALL_SCREEN_COUNT;
                m_screenNotifications = new MyScreenNotifications[allScreensCount];
                for (int i = 0; i < allScreensCount; ++i)
                {
                    m_screenNotifications[i] = new MyScreenNotifications();
                }
            }
            m_fogColor   = MyGuiConstants.SELECT_AMMO_TIP_BACKGROUND_FADE_COLOR;
            m_fogColor.A = (byte)(m_fogColor.A * 0.85f);

            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();
        }
        public override bool Draw(float backgroundFadeAlpha)
        {
            if (base.Draw(backgroundFadeAlpha) == false)
            {
                return(false);
            }

            Vector2 opacityPosition = m_position + m_opacitySlider.GetPosition() +
                                      new Vector2(0.13f, 0);

            Vector2 finalColorPosition = m_position + m_redColorSlider.GetPosition() +
                                         new Vector2(0.18f, -MyGuiConstants.SLIDER_HEIGHT / 2);
            Vector2 finalColorScreenCoord = MyGuiManager.GetScreenCoordinateFromNormalizedCoordinate(finalColorPosition);

            Vector2 finalColorSize = MyGuiManager.GetScreenSizeFromNormalizedSize(new Vector2(3 * MyGuiConstants.SLIDER_HEIGHT, 3 * MyGuiConstants.SLIDER_HEIGHT) + new Vector2(0, 0.024f));

            // Draws one big final color rectangle to see result of each RGBA component in one
            MyGuiManager.DrawString(MyGuiManager.GetFontMinerWarsWhite(), m_opacityValueText, opacityPosition, MyGuiConstants.LABEL_TEXT_SCALE, new Color(MyGuiConstants.LABEL_TEXT_COLOR), MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER);
            MyGuiManager.DrawSpriteBatch(MyGuiManager.GetBlankTexture(), (int)finalColorScreenCoord.X, (int)finalColorScreenCoord.Y, (int)finalColorSize.X, (int)finalColorSize.Y, m_sphereDustColor);

            return(true);
        }
Ejemplo n.º 12
0
 public MyColoredText(StringBuilder text, Color color, float textScale)
     : this(text, color, MyGuiManager.GetFontMinerWarsWhite(), textScale)
 {
 }
Ejemplo n.º 13
0
        private void AddHeaders()
        {
            int   rowIndex  = m_statsListbox.AddRow();
            var   textColor = new Color(0.9f, 0.9f, 0.9f, 1f);
            float textScale = 0.9f;

            m_statsListbox.AddItem(new MyGuiControlListboxItem(rowIndex * 4 + 0,
                                                               new MyColoredText(MyTextsWrapper.Get(MyTextsWrapperEnum.ScoreName), textColor, MyGuiManager.GetFontMinerWarsWhite(), textScale),
                                                               null, new MyToolTips(MyTextsWrapper.Get(MyTextsWrapperEnum.ScoreName))), rowIndex, 0);
            m_statsListbox.AddItem(new MyGuiControlListboxItem(rowIndex * 4 + 1,
                                                               new MyColoredText(MyTextsWrapper.Get(MyTextsWrapperEnum.ScoreKills), textColor, MyGuiManager.GetFontMinerWarsWhite(), textScale),
                                                               null, new MyToolTips(MyTextsWrapper.Get(MyTextsWrapperEnum.ScoreKills)))
            {
                BackgroundColor = Color.Red.ToVector4()
            }, rowIndex, 1);
            m_statsListbox.AddItem(new MyGuiControlListboxItem(rowIndex * 4 + 2,
                                                               new MyColoredText(MyTextsWrapper.Get(MyTextsWrapperEnum.ScoreDeaths), textColor, MyGuiManager.GetFontMinerWarsWhite(), textScale),
                                                               null, new MyToolTips(MyTextsWrapper.Get(MyTextsWrapperEnum.ScoreDeaths)))
            {
                BackgroundColor = Color.Red.ToVector4()
            }, rowIndex, 2);
            m_statsListbox.AddItem(new MyGuiControlListboxItem(rowIndex * 4 + 3,
                                                               new MyColoredText(MyTextsWrapper.Get(MyTextsWrapperEnum.ScorePing), textColor, MyGuiManager.GetFontMinerWarsWhite(), textScale),
                                                               null, new MyToolTips(MyTextsWrapper.Get(MyTextsWrapperEnum.ScorePing)))
            {
                BackgroundColor = Color.Red.ToVector4()
            }, rowIndex, 3);
        }
        private MyGuiControlListboxItem CreateListboxItemAndAddToRepository(MyInventoryItem inventoryItem)
        {
            int inventoryItemKey = m_inventoryItemsRepository.AddItem(inventoryItem);

            StringBuilder description = null;

            if (inventoryItem.Icon == null)
            {
                description = inventoryItem.MultiLineDescription;
            }

            MyToolTips toolTips = new MyToolTips();

            toolTips.AddToolTip(inventoryItem.MultiLineDescription, Color.White, 0.7f);

            MyGuiControlListboxItem listboxItem = new MyGuiControlListboxItem(inventoryItemKey, description, inventoryItem.Icon, toolTips, MyGuiConstants.LABEL_TEXT_SCALE);

            listboxItem.IconTexts = new MyIconTexts();

            // add amount icon's text
            if (inventoryItem.Amount != 1f || inventoryItem.Amount != inventoryItem.MaxAmount)
            {
                StringBuilder amount = new StringBuilder();
                amount.Append(inventoryItem.Amount.ToString());
                MyGuiDrawAlignEnum align;
                Vector2            offset;
                if (inventoryItem.AmountTextAlign == MyInventoryAmountTextAlign.MiddleRight)
                {
                    align  = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER;
                    offset = new Vector2(-0.004f, 0.0038f);
                }
                else if (inventoryItem.AmountTextAlign == MyInventoryAmountTextAlign.BottomRight)
                {
                    align  = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM;
                    offset = new Vector2(-0.004f, -0.0025f);
                }
                else
                {
                    throw new MyMwcExceptionApplicationShouldNotGetHere();
                }
                listboxItem.IconTexts[align] = new MyColoredText(amount, Color.White, Color.White, MyGuiManager.GetFontMinerWarsWhite(), 0.5f, offset);
            }

            return(listboxItem);
        }
        public override void Draw()
        {
            /*
             * int count = m_allToolTips.Keys.Count;
             * for (int c = 0; c < count; c++)
             * {
             *  MyGuiManager.DrawSpriteBatch(m_selectedTexture, m_parentScreen.GetPosition() + m_position, m_size.Value,
             *      GetColorAfterTransitionAlpha(m_backgroundColor.Value), MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER);
             * }
             */
            //base.Draw();

            //draw buttons on head with texts
            int count = m_tabs.Keys.Count;
            int pos   = 0;

            foreach (int i in m_tabs.Keys)
            {
                MyTexture2D buttonTexture = MyGuiManager.GetButtonTexture();
                Vector2     parentPos     = m_parent.GetPositionAbsolute();
                Vector2?    parentSize    = m_parent.GetSize();
                parentPos -= parentSize.Value / 2;
                Vector2 offsetPos   = parentPos + pos * new Vector2(m_headSize.X * parentSize.Value.X / count, 0);
                Vector2 tabHeadSize = new Vector2((m_headSize.X / (count)) * parentSize.Value.X, (m_headSize.Y) * parentSize.Value.Y);

                bool isHighlight = GetMouseOverTab() == i || GetSelectedTab() == i;

                bool isNotImplementedForbidenOrDisabled = /*!m_implementedFeature || m_accessForbiddenReason != null ||*/ !Enabled;

                /*
                 * bool isHighlighted = IsMouseOverOrKeyboardActive() &&
                 *  (m_highlightType == MyGuiControlHighlightType.WHEN_ACTIVE || (m_highlightType == MyGuiControlHighlightType.WHEN_CURSOR_OVER && IsMouseOver()));
                 */
                Vector4 backgroundColor = isNotImplementedForbidenOrDisabled ? MyGuiConstants.DISABLED_BUTTON_COLOR_VECTOR :
                                          (isHighlight ? m_backgroundColor.Value * MyGuiConstants.CONTROL_MOUSE_OVER_BACKGROUND_COLOR_MULTIPLIER : m_backgroundColor.Value);
                backgroundColor.W = 1.0f;
                // Draw background texture
                MyGuiManager.DrawSpriteBatch(buttonTexture, offsetPos, tabHeadSize * m_scale,
                                             new Color(backgroundColor), MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP);



                Vector4 textColor = isNotImplementedForbidenOrDisabled ? textColor = MyGuiConstants.DISABLED_BUTTON_TEXT_COLOR :
                                                                                     ((isHighlight) ? m_color * MyGuiConstants.CONTROL_MOUSE_OVER_BACKGROUND_COLOR_MULTIPLIER : m_color);

                StringBuilder text = new StringBuilder(GetTabSubControl(i).GetCaption());
                if (text != null)
                {
                    Vector2            textPosition;
                    MyGuiDrawAlignEnum textDrawAlign;

                    textPosition  = offsetPos + tabHeadSize / 2;
                    textDrawAlign = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER;

                    /*
                     * if (m_textAlignment == MyGuiControlButtonTextAlignment.CENTERED)
                     * {
                     *  textPosition = m_parentScreen.GetPosition() + m_position;
                     *  textDrawAlign = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER;
                     * }
                     * else if (m_textAlignment == MyGuiControlButtonTextAlignment.LEFT)
                     * {
                     *  //  This will move text few pixels from button's left border
                     *  textPosition = m_parentScreen.GetPosition() + m_position - new Vector2(m_size.Value.X / 2.0f, 0) + new Vector2(MyGuiConstants.BUTTON_TEXT_OFFSET.X, 0);
                     *  textDrawAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER;
                     * }
                     * else
                     * {
                     *  throw new MyMwcExceptionApplicationShouldNotGetHere();
                     * }
                     */

                    MyGuiManager.DrawString(MyGuiManager.GetFontMinerWarsWhite(), text, textPosition, 1.2f /*m_textScale*/, GetColorAfterTransitionAlpha(textColor), textDrawAlign);
                }

                pos++;
            }

            //base.Draw();
            GetTabSubControl(m_selectedTab).Draw();
        }
        public override void LoadContent()
        {
            m_texture = MyTextureManager.GetTexture <MyTexture2D>("Textures\\GUI\\BackgroundScreen\\PerformanceBackground", flags: TextureFlags.IgnoreQuality);

            float scale = 1.2f;

            m_warningText1 = new MyGuiControlMultilineText(
                this,
                new Vector2(0.245f, -0.09f),
                new Vector2(1.0f, 0.5f),
                Vector4.Zero,
                MyGuiManager.GetFontMinerWarsWhite(), scale,
                MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                MyTextsWrapper.Get(MyTextsWrapperEnum.PerfWarning1_0), false, true);


            m_warningText2 = new MyGuiControlMultilineText(
                this,
                new Vector2(0.215f, -0.04f),
                new Vector2(1.0f, 0.5f),
                Vector4.Zero,
                MyGuiManager.GetFontMinerWarsWhite(), scale,
                MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                new StringBuilder(), false, true);
            m_warningText2.AppendText(MyTextsWrapper.Get(MyTextsWrapperEnum.PerfWarning2_0), MyGuiManager.GetFontMinerWarsBlue(), scale, Vector4.One);



            m_warningText3 = new MyGuiControlMultilineText(
                this,
                new Vector2(0.225f, 0.12f),
                new Vector2(1.0f, 0.5f),
                Vector4.Zero,
                MyGuiManager.GetFontMinerWarsWhite(), scale,
                MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                MyTextsWrapper.Get(MyTextsWrapperEnum.PerfWarning3_0), false, true);

            m_warningText4 = new MyGuiControlMultilineText(
                this,
                new Vector2(0.335f, 0.17f),
                new Vector2(1.0f, 0.5f),
                Vector4.Zero,
                MyGuiManager.GetFontMinerWarsWhite(), scale,
                MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                MyTextsWrapper.Get(MyTextsWrapperEnum.PerfWarning4_0).Append(" "), false, true);
            m_warningText4.AppendText(MyTextsWrapper.Get(MyTextsWrapperEnum.PerfWarning4_1).Append(" "), MyGuiManager.GetFontMinerWarsBlue(), scale, Vector4.One);
            m_warningText4.AppendText(MyTextsWrapper.Get(MyTextsWrapperEnum.PerfWarning4_2).Append(": "), MyGuiManager.GetFontMinerWarsWhite(), scale, Vector4.One);
            m_warningText4.AppendText(new StringBuilder("VRAGE"), MyGuiManager.GetFontMinerWarsBlue(), scale, Vector4.One);



            m_warningText5 = new MyGuiControlMultilineText(
                this,
                new Vector2(0.26f, 0.33f),
                new Vector2(1.0f, 0.5f),
                Vector4.Zero,
                MyGuiManager.GetFontMinerWarsWhite(), scale,
                MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                MyTextsWrapper.Get(MyTextsWrapperEnum.PerfWarning5_0), false, true);

            m_warningText6 = new MyGuiControlMultilineText(
                this,
                new Vector2(0.363f, 0.38f),
                new Vector2(1.0f, 0.5f),
                Vector4.Zero,
                MyGuiManager.GetFontMinerWarsWhite(), scale,
                MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                MyTextsWrapper.Get(MyTextsWrapperEnum.PerfWarning6_0), false, true);



            m_button = new MyGuiControlButton(this,
                                              new Vector2(0, 0.3f),
                                              new Vector2(0.25f, 0.09f),
                                              new Vector4(0.8f, 0.8f, 0.8f, 1),
                                              new StringBuilder("I UNDERSTAND"),
                                              null,
                                              Vector4.One,
                                              1,
                                              OnButtonClick,
                                              MyGuiControlButtonTextAlignment.CENTERED,
                                              true,
                                              MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_TOP,
                                              true);

            Controls.Add(m_button);

            OnEnterCallback += delegate
            {
                CloseScreen();
            };

            base.LoadContent();
        }
        public override bool Draw(float backgroundFadeAlpha)
        {
            if (base.Draw(backgroundFadeAlpha) == false)
            {
                return(false);
            }

            float rowDistance = MyGuiConstants.DEBUG_STATISTICS_ROW_DISTANCE;
            float textScale   = MyGuiConstants.DEBUG_STATISTICS_TEXT_SCALE;

            m_stringIndex = 0;
            m_texts.Clear();
            m_rightAlignedtexts.Clear();


            m_texts.Add(StringBuilderCache.GetFormatedFloat("FPS: ", MyFpsManager.GetFps()));

            m_texts.Add(MyGuiManager.GetGuiScreensForDebug());

            m_texts.Add(StringBuilderCache.GetFormatedBool("Paused: ", MyMinerGame.IsPaused()));
            m_texts.Add(StringBuilderCache.GetFormatedDateTimeOffset("System Time: ", TimeUtil.LocalTime));
            m_texts.Add(StringBuilderCache.GetFormatedTimeSpan("Total MISSION Time: ", MyMissions.ActiveMission == null ? TimeSpan.Zero : MyMissions.ActiveMission.MissionTimer.GetElapsedTime()));
            m_texts.Add(StringBuilderCache.GetFormatedTimeSpan("Total GAME-PLAY Time: ", TimeSpan.FromMilliseconds(MyMinerGame.TotalGamePlayTimeInMilliseconds)));
            m_texts.Add(StringBuilderCache.GetFormatedTimeSpan("Total Time: ", TimeSpan.FromMilliseconds(MyMinerGame.TotalTimeInMilliseconds)));

            m_texts.Add(StringBuilderCache.GetFormatedLong("GC.GetTotalMemory: ", GC.GetTotalMemory(false), " bytes"));

//#if MEMORY_PROFILING
            //TODO: I am unable to show this without allocations
            m_texts.Add(StringBuilderCache.GetFormatedLong("Environment.WorkingSet: ", MyWindowsAPIWrapper.WorkingSet, " bytes"));

            m_texts.Add(StringBuilderCache.GetFormatedFloat("Available videomemory: ", MyMinerGame.Static.GraphicsDevice.AvailableTextureMemory / (1024.0f * 1024.0f), " MB"));
            // TODO: Videomem
            //m_texts.Add(StringBuilderCache.GetFormatedFloat("Allocated videomemory: ", MyProgram.GetResourcesSizeInMB(), " MB"));
//#endif

#if PHYSICS_SENSORS_PROFILING
            if (MinerWars.AppCode.Physics.MyPhysics.physicsSystem != null)
            {
                m_texts.Add(StringBuilderCache.GetFormatedInt("Physics sensor - new allocated interactions: ", MinerWars.AppCode.Physics.MyPhysics.physicsSystem.GetSensorInteractionModule().GetNewAllocatedInteractionsCount()));
                m_texts.Add(StringBuilderCache.GetFormatedInt("Physics sensor - interactions in use: ", MinerWars.AppCode.Physics.MyPhysics.physicsSystem.GetSensorInteractionModule().GetInteractionsInUseCount()));
                m_texts.Add(StringBuilderCache.GetFormatedInt("Physics sensor - interactions in use MAX: ", MinerWars.AppCode.Physics.MyPhysics.physicsSystem.GetSensorInteractionModule().GetInteractionsInUseCountMax()));
                m_texts.Add(StringBuilderCache.GetFormatedInt("Physics sensor - all sensors: ", MinerWars.AppCode.Physics.MyPhysics.physicsSystem.GetSensorModule().SensorsCount()));
                m_texts.Add(StringBuilderCache.GetFormatedInt("Physics sensor - active sensors: ", MinerWars.AppCode.Physics.MyPhysics.physicsSystem.GetSensorModule().ActiveSensors.Count));
            }
#endif

            m_texts.Add(StringBuilderCache.GetFormatedInt("Sound Instances Total 2D: ", MyAudio.GetSoundInstancesTotal2D()));
            m_texts.Add(StringBuilderCache.GetFormatedInt("Sound Instances Total 3D: ", MyAudio.GetSoundInstancesTotal3D()));
            m_texts.Add(MyAudio.GetCurrentTransitionForDebug());
            if (MyAudio.GetMusicCue() != null)
            {
                //m_texts.Add(StringBuilderCache.GetStrings("Currently Playing Music Cue: ", MyAudio.GetMusicCue().Value.GetCue().Name));
            }

            m_texts.Add(StringBuilderCache.Clear());
            m_texts.Add(StringBuilderCache.GetFormatedInt("Textures 2D Count: ", MyPerformanceCounter.PerAppLifetime.Textures2DCount));
            m_texts.Add(StringBuilderCache.GetFormatedInt("Textures 2D Size In Pixels: ", MyPerformanceCounter.PerAppLifetime.Textures2DSizeInPixels));
            m_texts.Add(StringBuilderCache.GetFormatedDecimal("Textures 2D Size In Mb: ", MyPerformanceCounter.PerAppLifetime.Textures2DSizeInMb, 3));
            m_texts.Add(StringBuilderCache.GetFormatedInt("Dxt Compressed Textures Count: ", MyPerformanceCounter.PerAppLifetime.DxtCompressedTexturesCount));
            m_texts.Add(StringBuilderCache.GetFormatedInt("Non Dxt Compressed Textures Count: ", MyPerformanceCounter.PerAppLifetime.NonDxtCompressedTexturesCount));
            m_texts.Add(StringBuilderCache.GetFormatedInt("Non Mip Mapped Textures Count: ", MyPerformanceCounter.PerAppLifetime.NonMipMappedTexturesCount));
            m_texts.Add(StringBuilderCache.GetFormatedInt("Texture Cubes Count: ", MyPerformanceCounter.PerAppLifetime.TextureCubesCount));
            m_texts.Add(StringBuilderCache.GetFormatedInt("Texture Cubes Size In Pixels: ", MyPerformanceCounter.PerAppLifetime.TextureCubesSizeInPixels));
            m_texts.Add(StringBuilderCache.GetFormatedDecimal("Texture Cubes Size In Mb: ", MyPerformanceCounter.PerAppLifetime.TextureCubesSizeInMb, 3));
            m_texts.Add(StringBuilderCache.GetFormatedInt("Non MyModels Count: ", MyPerformanceCounter.PerAppLifetime.ModelsCount));
            m_texts.Add(StringBuilderCache.GetFormatedInt("MyModels Count: ", MyPerformanceCounter.PerAppLifetime.MyModelsCount));
            m_texts.Add(StringBuilderCache.GetFormatedInt("MyModels Meshes Count: ", MyPerformanceCounter.PerAppLifetime.MyModelsMeshesCount));
            m_texts.Add(StringBuilderCache.GetFormatedInt("MyModels Vertexes Count: ", MyPerformanceCounter.PerAppLifetime.MyModelsVertexesCount));
            m_texts.Add(StringBuilderCache.GetFormatedInt("MyModels Triangles Count: ", MyPerformanceCounter.PerAppLifetime.MyModelsTrianglesCount));
            m_texts.Add(StringBuilderCache.GetFormatedInt("Size of Model Vertex Buffers in Mb: ", MyPerformanceCounter.PerAppLifetime.ModelVertexBuffersSize / 1024 / 1024));
            m_texts.Add(StringBuilderCache.GetFormatedInt("Size of Model Index Buffers in Mb: ", MyPerformanceCounter.PerAppLifetime.ModelIndexBuffersSize / 1024 / 1024));
            m_texts.Add(StringBuilderCache.GetFormatedInt("Size of Voxel Vertex Buffers in Mb: ", MyPerformanceCounter.PerAppLifetime.VoxelVertexBuffersSize / 1024 / 1024));
            m_texts.Add(StringBuilderCache.GetFormatedInt("Size of Voxel Index Buffers in Mb: ", MyPerformanceCounter.PerAppLifetime.VoxelIndexBuffersSize / 1024 / 1024));
            m_texts.Add(StringBuilderCache.GetFormatedBool("Paused: ", MyMinerGame.IsPaused()));
            MyGuiManager.GetInput().GetPressedKeys(m_pressedKeys);
            AddPressedKeys("Current keys              : ", m_pressedKeys);

            m_texts.Add(StringBuilderCache.Clear());
            m_texts.Add(m_frameDebugText);


            //This ensures constant max length of right block to avoid flickering when correct max line is changing too often
            m_frameDebugTextRA.AppendLine();
            m_frameDebugTextRA.Append("                                                                  ");
            ////

            m_rightAlignedtexts.Add(m_frameDebugTextRA);

            Vector2 origin             = GetScreenLeftTopPosition();
            Vector2 rightAlignedOrigin = GetScreenRightTopPosition();

            for (int i = 0; i < m_texts.Count; i++)
            {
                MyGuiManager.DrawString(MyGuiManager.GetFontMinerWarsWhite(), m_texts[i], origin + new Vector2(0, i * rowDistance), textScale,
                                        Color.Yellow, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP);
            }
            for (int i = 0; i < m_rightAlignedtexts.Count; i++)
            {
                MyGuiManager.DrawString(MyGuiManager.GetFontMinerWarsWhite(), m_rightAlignedtexts[i], rightAlignedOrigin + new Vector2(0.0f, i * rowDistance), textScale,
                                        Color.Yellow, MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP);
            }

            ClearFrameDebugText();

            return(true);
        }
Ejemplo n.º 18
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="backgroundFadeAlpha"></param>
        public override bool Draw(float backgroundFadeAlpha)
        {
            if (base.Draw(backgroundFadeAlpha) == false) return false;

            const float TEXT_DISTANCE_Y = 0.025f;
            const float TEXT_SCALE = 0.5f;

            List<StringBuilder> texts = new List<StringBuilder>(20);
            texts.Add(new StringBuilder("BOT DEBUG SCREEN"));
            texts.Add(new StringBuilder(String.Empty));

            if (BotExists())
            {
                // Non-persistence disclaimer.
                texts.Add(new StringBuilder("Use this debug screen to test different bot settings in"));
                texts.Add(new StringBuilder("order to find those that 'feel' best. Note that these settings"));
                texts.Add(new StringBuilder("are just for experimentation and don't persist. Final changes"));
                texts.Add(new StringBuilder("must be made in the code itself."));
                texts.Add(new StringBuilder(String.Empty));

                // Camera.
                texts.Add(new StringBuilder("Camera.CameraAttachedTo = " + MyGuiScreenGamePlay.Static.CameraAttachedTo.ToString()));
                texts.Add(new StringBuilder("MySpectator.Position = " + MyUtils.GetFormatedVector3(MySpectator.Position,0)));
                texts.Add(new StringBuilder("Camera.ThirdPersonCamDelta = " + MyUtils.GetFormatedVector3( MyGuiScreenGamePlay.Static.ThirdPersonCameraDelta, 0 )));
                texts.Add(new StringBuilder(String.Empty));

                // Bot info.
                //double angle = this.m_bot.AngleBetweenForwardAndTarget( this.m_pl
                //texts.Add(new StringBuilder("Bot.AngleBetweenForwardAndPlayerPosition = " + angle.ToString("F0")));
                //texts.Add(new StringBuilder(String.Empty));


                // Bot debug key controls.
                texts.Add(new StringBuilder("Use UP/DOWN arrows keys to select a parameter."));
                texts.Add(new StringBuilder("Use RIGHT/LEFT arrows keys to adjust parameter value."));
                texts.Add(new StringBuilder("Press Shift-F12 to close this screen."));
                texts.Add(new StringBuilder(String.Empty));

                // List specific bot that we're modifying.
                StringBuilder botTitle = new StringBuilder();
                botTitle.Append("Selected bot:  ");
                //botTitle.Append(m_bot.Name);
                texts.Add(botTitle);
                texts.Add(new StringBuilder(String.Empty));

                // Walk through all settable parameters and list current names and values.
                // Add either spacing or tick mark prefix to each parameter listed.
                // The little tick marks indicates the currently editting parameter.
                for (int i = 0; i < this.m_botParams.Count; i++)
                {
                    StringBuilder sb = new StringBuilder();
                    BotParam param = this.m_botParams[i];
                    sb.Append((this.GetPrefix(i) + param.Name + " = "));
                    if (param.IsBoolean == false)
                    {
                        sb.Append((param.Value.ToString("F1")));
                    }
                    else
                    {
                        if (param.Value == 0.0f)
                        {
                            sb.Append("False");
                        }
                        else
                        {
                            sb.Append("True");
                        }
                    }
                    texts.Add(sb);
                }
                texts.Add(new StringBuilder(String.Empty));

                // Description what effect changing current parameter will have..
                texts.Add(new StringBuilder("Description:"));
                texts.Add(new StringBuilder(this.m_currentParam.Description));
                texts.Add(new StringBuilder(String.Empty));

            }

            // Where to start drawing text.
            Vector2 origin = this.GetScreenLeftTopPosition();

            // Draw our text on screen.
            for (int i = 0; i < texts.Count; i++)
            {
                MyGuiManager.DrawString(MyGuiManager.GetFontMinerWarsWhite(), texts[i], origin + new Vector2(0, i * TEXT_DISTANCE_Y), TEXT_SCALE,
                    Color.Yellow, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP);
            }

            ClearFrameDebugText();

            return true;
        }
Ejemplo n.º 19
0
 public MyColoredText(StringBuilder text, Color normalColor, Color highlightColor)
     : this(text, normalColor, highlightColor, MyGuiManager.GetFontMinerWarsWhite(), MyGuiConstants.COLORED_TEXT_DEFAULT_TEXT_SCALE, Vector2.Zero)
 {
 }