public void HudDrawActualAmmo(Vector2 position, Vector2 scaleToAmmoSelection, int amount, Vector4?backgroundColor, StringBuilder ammoSpecialText)
        {
            if (backgroundColor.HasValue)
            {
                m_color = new Color(backgroundColor.Value);
                MyGuiManager.BeginSpriteBatch();
                base.DrawSpriteBatch(position, new Vector2(m_itemWidth * scaleToAmmoSelection.X, ItemHeight * scaleToAmmoSelection.Y), m_color, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP);

                Vector2 textPosition = position;
                textPosition.X += m_itemWidth / 2.6f * 2.0f;
                textPosition.Y += ItemHeight * scaleToAmmoSelection.Y - ItemHeight / 6.0f;
                m_diff.X       += m_itemWidth * scaleToAmmoSelection.X * MyGuiConstants.AMMO_SELECT_ITEM_TEXT_RELATIVE_POSITION.X;
                m_diff.Y       += ItemHeight * scaleToAmmoSelection.Y * MyGuiConstants.AMMO_SELECT_ITEM_TEXT_RELATIVE_POSITION.Y;

                MyMwcUtils.ClearStringBuilder(m_amount);
                m_amount.AppendInt32(amount);

                var color = new Color(MyGuiConstants.LABEL_TEXT_COLOR);
                MyGuiManager.DrawString(MyGuiManager.GetFontMinerWarsBlue(), m_amount,
                                        textPosition, 0.7f, color,
                                        MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM);

                if (ammoSpecialText != null && ammoSpecialText.Length > 0)
                {
                    textPosition.Y -= ItemHeight / 4.0f;
                    MyGuiManager.DrawString(MyGuiManager.GetFontMinerWarsBlue(), ammoSpecialText, textPosition, .7f,
                                            color, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM);
                }

                MyGuiManager.EndSpriteBatch();
            }
        }
        public void SetTexts()
        {
            MyMwcUtils.ClearStringBuilder(m_debugText);

            m_debugText.AppendLine("Player friends debug info");

            if (MySession.Static == null || MySession.PlayerFriends == null)
            {
                m_debugText.AppendLine("Player friends does not exists");
                return;
            }

            foreach (var friend in MySession.PlayerFriends.GetDebug())
            {
                m_debugText.Append(friend.DisplayName);
                m_debugText.Append(": ");
                if (friend.EntityId.HasValue)
                {
                    m_debugText.AppendInt32((int)friend.EntityId.Value.NumericValue);
                    m_debugText.Append(" (");
                    m_debugText.AppendInt32(friend.EntityId.Value.PlayerId);
                    m_debugText.Append(")");
                    m_debugText.AppendLine();
                    m_debugText.Append("    Position: ");
                    m_debugText.AppendDecimal(friend.GetPosition().X, 1);
                    m_debugText.Append("; ");
                    m_debugText.AppendDecimal(friend.GetPosition().Y, 1);
                    m_debugText.Append("; ");
                    m_debugText.AppendDecimal(friend.GetPosition().Z, 1);
                    m_debugText.AppendLine();
                }
            }
        }
        void DrawLabel(Vector4 color)
        {
            MyMwcUtils.ClearStringBuilder(m_tempForDraw);
            m_tempForDraw.AppendFormat(m_labelText, MyValueFormatter.GetFormatedFloat(m_value.Value, LabelDecimalPlaces));

            MyGuiManager.DrawString(MyGuiManager.GetFontMinerWarsBlue(), m_tempForDraw, m_parent.GetPositionAbsolute() + m_position + new Vector2(m_size.Value.X / 2.0f + m_labelWidth, 0), m_labelScale,
                                    GetColorAfterTransitionAlpha(color), MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER);
        }
Example #4
0
        //  IMPORTANT: This class isn't initialized by constructor, but by Start() because it's supposed to be used in memory pool
        public void Start(MyGuiFont font, Vector2 position, Color color, float scale, MyGuiDrawAlignEnum alignement)
        {
            Font       = font;
            Position   = position;
            Color      = color;
            Scale      = scale;
            Alignement = alignement;

            //  Clear current text
            MyMwcUtils.ClearStringBuilder(m_text);
        }
Example #5
0
        public void SetTexts()
        {
            MyMwcUtils.ClearStringBuilder(m_debugText);

            m_debugText.Append("FPS: ");
            m_debugText.AppendInt32(MyFpsManager.GetFps());
            m_debugText.AppendLine();

            m_debugText.Append("Frame time: ");
            m_debugText.AppendDecimal(MyFpsManager.FrameTime, 1);
            m_debugText.Append(" ms");
            m_debugText.AppendLine();

            m_debugText.Append("Frame avg time: ");
            m_debugText.AppendDecimal(MyFpsManager.FrameTimeAvg, 1);
            m_debugText.Append(" ms");
            m_debugText.AppendLine();

            m_debugText.Append("Frame min time: ");
            m_debugText.AppendDecimal(MyFpsManager.FrameTimeMin, 1);
            m_debugText.Append(" ms");
            m_debugText.AppendLine();

            m_debugText.Append("Frame max time: ");
            m_debugText.AppendDecimal(MyFpsManager.FrameTimeMax, 1);
            m_debugText.Append(" ms");
            m_debugText.AppendLine();

            m_debugText.Append("Environment map update time: ");
            m_debugText.AppendDecimal(MinerWars.AppCode.Game.Render.EnvironmentMap.MyEnvironmentMap.LastUpdateTime, 1);
            m_debugText.Append(" ms");
            m_debugText.AppendLine();

            if (MyMwcFinalBuildConstants.IS_DEVELOP)
            {
                m_debugText.AppendLine();
                MyPerformanceCounter.PerCameraDraw.AppendCustomCounters(m_debugText);
                m_debugText.AppendLine();
                MyPerformanceCounter.PerCameraDraw.AppendCustomTimers(m_debugText);
            }
        }
Example #6
0
 //  If label's text contains params, we can update them here. Also don't forget that text is defined two time: one as a definition and one that we draw
 public void UpdateParams(params object[] args)
 {
     if (m_type == MyGuiControlLabelType.DEFINED_BY_TEXT_WRAPPER_ENUM)
     {
         if (m_textDraw == null)
         {
             m_textDraw = new StringBuilder();
         }
         MyMwcUtils.ClearStringBuilder(m_textDraw);
         m_textDraw.AppendFormat(MyTextsWrapper.Get(m_textEnum).ToString(), args);
         RecalculateSize();
     }
     else if (m_type == MyGuiControlLabelType.DEFINED_BY_STRING_BUILDER)
     {
         MyMwcUtils.ClearStringBuilder(m_textDraw);
         m_textDraw.AppendFormat(m_textDefinition.ToString(), args);
         RecalculateSize();
     }
     else
     {
         throw new MyMwcExceptionApplicationShouldNotGetHere();
     }
 }
        public void DrawSpriteBatchMenuItem(int orderX, int orderY, bool selected, int amount, Vector4?backgroundColor, int index, int selectedGroup)
        {
            MyMwcUtils.ClearStringBuilder(m_amount);
            m_amount.AppendInt32(amount);

            orderX += 1;

            MyGuiManager.BeginSpriteBatch();

            if (backgroundColor.HasValue)
            {
                // selection color:
                m_backgroundActualColor = backgroundColor.Value;
                if (selected)
                {
                    m_backgroundActualColor *= MyGuiConstants.SELECT_AMMO_ACTIVE_COLOR_MULTIPLIER;
                }
                else
                {
                    m_backgroundActualColor.W *= 1.0f; // move this to constants
                }
                m_color = new Color(m_backgroundActualColor);



                //calculate for save of pos
                m_diff.X = topLeftPosition.X + m_offset.X;
                m_diff.Y = topLeftPosition.Y + m_menuItemHeight + m_offset.Y;
                m_diffMovedPosition.X = m_diff.X + (orderX * (m_itemWidth + ItemDistance)) + (selectedGroup - 1) * (m_menuItemWidth + m_menuItemDistance);
                m_diffMovedPosition.Y = m_diff.Y + ((orderY + 1) * (ItemHeight + ItemDistance)) + 0.005f;

                m_lastSpritePosition = m_diffMovedPosition;//buffer last weapon sprite pos for cursor testing
                m_diff    = MyGuiManager.GetNormalizedCoordinateFromScreenCoordinate(MyGuiConstants.AMMO_SELECT_LEFT_TOP_POSITION) + m_offset;
                m_diff.Y += m_menuItemHeight;
                m_diffMovedPosition.X = m_diff.X + (orderX * (m_itemWidth + ItemDistance)) + (selectedGroup - 1) * (m_menuItemWidth + m_menuItemDistance);
                m_diffMovedPosition.Y = m_diff.Y + ((orderY + 1) * (ItemHeight + ItemDistance)) + 0.005f;

                /*
                 * // Select texture based on position:
                 * MyGuiManager.DrawSpriteBatch((orderY == -1 && index == 0) ? MyGuiManager.GetAmmoSelectBorderFirst() : MyGuiManager.GetAmmoSelectBorderPiece(),
                 *  m_diffMovedPosition, new Vector2(m_itemWidth, ItemHeight),
                 *  m_color, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP);
                 *
                 */
                base.DrawSpriteBatch(m_diffMovedPosition, new Vector2(m_itemWidth, ItemHeight),
                                     m_color, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP);

                //m_lastSpritePosition = m_diffMovedPosition;//buffer last weapon sprite pos for cursor testing

                m_diff.X += m_itemWidth * MyGuiConstants.AMMO_SELECT_ITEM_TEXT_RELATIVE_POSITION.X;
                m_diff.Y += ItemHeight * MyGuiConstants.AMMO_SELECT_ITEM_TEXT_RELATIVE_POSITION.Y;
                m_diffMovedPosition.X = m_diff.X + (orderX * (m_itemWidth + ItemDistance)) + (selectedGroup - 1) * (m_menuItemWidth + m_menuItemDistance);
                m_diffMovedPosition.Y = m_diff.Y + ((orderY + 1) * (ItemHeight + ItemDistance));


                MyGuiManager.DrawString(MyGuiManager.GetFontMinerWarsBlue(), m_amount,
                                        m_diffMovedPosition, 0.6f, new Color(MyGuiConstants.LABEL_TEXT_COLOR),
                                        MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM);

                // draw hint:
                if (selected)
                {
                    m_description     = MultiLineDescription;
                    m_tipTextPosition = m_diffMovedPosition;
                }
            }

            MyGuiManager.EndSpriteBatch();
        }
 //  Frame Debug Text - is cleared at the begining of Update and rendered at the end of Draw
 public void ClearFrameDebugText()
 {
     MyMwcUtils.ClearStringBuilder(m_frameDebugText);
     MyMwcUtils.ClearStringBuilder(m_frameDebugTextRA);
     //MyAudio.WriteDebugInfo(m_frameDebugTextRA);
 }
Example #9
0
 /// <summary>
 /// Frame Debug Text - is cleared at the begining of Update and rendered at the end of Draw
 /// </summary>
 public void ClearFrameDebugText()
 {
     MyMwcUtils.ClearStringBuilder(m_frameDebugText);
 }
Example #10
0
        public void SetTexts()
        {
            MyMwcUtils.ClearStringBuilder(m_debugText);

            var joy = MyGuiManager.GetInput().GetActualJoystickState();

            if (joy == null)
            {
                m_debugText.Append("No joystick detected.");
                return;
            }

            m_debugText.Append("Supported axes: ");
            if (MyGuiManager.GetInput().IsJoystickAxisSupported(MyJoystickAxesEnum.Xpos))
            {
                m_debugText.Append("X ");
            }
            if (MyGuiManager.GetInput().IsJoystickAxisSupported(MyJoystickAxesEnum.Ypos))
            {
                m_debugText.Append("Y ");
            }
            if (MyGuiManager.GetInput().IsJoystickAxisSupported(MyJoystickAxesEnum.Zpos))
            {
                m_debugText.Append("Z ");
            }
            if (MyGuiManager.GetInput().IsJoystickAxisSupported(MyJoystickAxesEnum.RotationXpos))
            {
                m_debugText.Append("Rx ");
            }
            if (MyGuiManager.GetInput().IsJoystickAxisSupported(MyJoystickAxesEnum.RotationYpos))
            {
                m_debugText.Append("Ry ");
            }
            if (MyGuiManager.GetInput().IsJoystickAxisSupported(MyJoystickAxesEnum.RotationZpos))
            {
                m_debugText.Append("Rz ");
            }
            if (MyGuiManager.GetInput().IsJoystickAxisSupported(MyJoystickAxesEnum.Slider1pos))
            {
                m_debugText.Append("S1 ");
            }
            if (MyGuiManager.GetInput().IsJoystickAxisSupported(MyJoystickAxesEnum.Slider2pos))
            {
                m_debugText.Append("S2 ");
            }
            m_debugText.AppendLine();

            m_debugText.Append("accX: "); m_debugText.AppendInt32(joy.AccelerationX); m_debugText.AppendLine();
            m_debugText.Append("accY: "); m_debugText.AppendInt32(joy.AccelerationY); m_debugText.AppendLine();
            m_debugText.Append("accZ: "); m_debugText.AppendInt32(joy.AccelerationZ); m_debugText.AppendLine();
            m_debugText.Append("angAccX: "); m_debugText.AppendInt32(joy.AngularAccelerationX); m_debugText.AppendLine();
            m_debugText.Append("angAccY: "); m_debugText.AppendInt32(joy.AngularAccelerationY); m_debugText.AppendLine();
            m_debugText.Append("angAccZ: "); m_debugText.AppendInt32(joy.AngularAccelerationZ); m_debugText.AppendLine();
            m_debugText.Append("angVelX: "); m_debugText.AppendInt32(joy.AngularVelocityX); m_debugText.AppendLine();
            m_debugText.Append("angVelY: "); m_debugText.AppendInt32(joy.AngularVelocityY); m_debugText.AppendLine();
            m_debugText.Append("angVelZ: "); m_debugText.AppendInt32(joy.AngularVelocityZ); m_debugText.AppendLine();
            m_debugText.Append("forX: "); m_debugText.AppendInt32(joy.ForceX); m_debugText.AppendLine();
            m_debugText.Append("forY: "); m_debugText.AppendInt32(joy.ForceY); m_debugText.AppendLine();
            m_debugText.Append("forZ: "); m_debugText.AppendInt32(joy.ForceZ); m_debugText.AppendLine();
            m_debugText.Append("rotX: "); m_debugText.AppendInt32(joy.RotationX); m_debugText.AppendLine();
            m_debugText.Append("rotY: "); m_debugText.AppendInt32(joy.RotationY); m_debugText.AppendLine();
            m_debugText.Append("rotZ: "); m_debugText.AppendInt32(joy.RotationZ); m_debugText.AppendLine();
            m_debugText.Append("torqX: "); m_debugText.AppendInt32(joy.TorqueX); m_debugText.AppendLine();
            m_debugText.Append("torqY: "); m_debugText.AppendInt32(joy.TorqueY); m_debugText.AppendLine();
            m_debugText.Append("torqZ: "); m_debugText.AppendInt32(joy.TorqueZ); m_debugText.AppendLine();
            m_debugText.Append("velX: "); m_debugText.AppendInt32(joy.VelocityX); m_debugText.AppendLine();
            m_debugText.Append("velY: "); m_debugText.AppendInt32(joy.VelocityY); m_debugText.AppendLine();
            m_debugText.Append("velZ: "); m_debugText.AppendInt32(joy.VelocityZ); m_debugText.AppendLine();
            m_debugText.Append("X: "); m_debugText.AppendInt32(joy.X); m_debugText.AppendLine();
            m_debugText.Append("Y: "); m_debugText.AppendInt32(joy.Y); m_debugText.AppendLine();
            m_debugText.Append("Z: "); m_debugText.AppendInt32(joy.Z); m_debugText.AppendLine();
            m_debugText.AppendLine();
            m_debugText.Append("AccSliders: "); foreach (var i in joy.AccelerationSliders)
            {
                m_debugText.AppendInt32(i); m_debugText.Append(" ");
            }
            m_debugText.AppendLine();
            m_debugText.Append("Buttons: "); foreach (var i in joy.Buttons)
            {
                m_debugText.Append(i ? "#" : "_"); m_debugText.Append(" ");
            }
            m_debugText.AppendLine();
            m_debugText.Append("ForSliders: "); foreach (var i in joy.ForceSliders)
            {
                m_debugText.AppendInt32(i); m_debugText.Append(" ");
            }
            m_debugText.AppendLine();
            m_debugText.Append("POVControllers: "); foreach (var i in joy.PointOfViewControllers)
            {
                m_debugText.AppendInt32(i); m_debugText.Append(" ");
            }
            m_debugText.AppendLine();
            m_debugText.Append("Sliders: "); foreach (var i in joy.Sliders)
            {
                m_debugText.AppendInt32(i); m_debugText.Append(" ");
            }
            m_debugText.AppendLine();
            m_debugText.Append("VelocitySliders: "); foreach (var i in joy.VelocitySliders)
            {
                m_debugText.AppendInt32(i); m_debugText.Append(" ");
            }
            m_debugText.AppendLine();
        }