public void RecreateControls()
            {
                Elements.Clear();

                var guiTextScale     = (float)Math.Pow(1.2f, m_stat.StatDefinition.GuiDef.HeightMultiplier - 1.0f);
                var guiArrowScale    = (float)Math.Pow(1.3f, m_stat.StatDefinition.GuiDef.HeightMultiplier - 1.0f) / m_stat.StatDefinition.GuiDef.HeightMultiplier;
                var textScale        = MyGuiConstants.HUD_TEXT_SCALE * 0.6f * guiTextScale;
                var barLength        = 0.0875f;
                var arrowIconSize    = new Vector2(Size.Y * 1.5f, Size.Y) * 0.5f * guiArrowScale;
                var leftTextWidth    = 0.16f;
                var textHeightOffset = -0.1f;

                var leftTextOffset  = -1.0f / 2.0f + leftTextWidth;
                var barOffset       = leftTextOffset + 0.025f;
                var arrowIconOffset = barOffset + barLength / Size.X + 0.05f;
                var rightTextOffset = arrowIconOffset + arrowIconSize.X + 0.035f;

                m_statNameLabel = new MyGuiControlLabel(position: Size * new Vector2(leftTextOffset, textHeightOffset),
                                                        text: m_stat.StatId.ToString(),
                                                        textScale: textScale,
                                                        size: new Vector2(leftTextWidth * Size.X, 1.0f),
                                                        originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER);
                Elements.Add(m_statNameLabel);

                var vecColor = m_stat.StatDefinition.GuiDef.Color;
                var barColor = new Color(vecColor.X, vecColor.Y, vecColor.Z);

                m_progressBar = new MyGuiControlProgressBar(position: Size * new Vector2(barOffset, 0.0f),
                                                            originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER,
                                                            size: new Vector2(barLength, Size.Y),
                                                            backgroundTexture: new MyGuiCompositeTexture(MyGuiConstants.TEXTURE_HUD_STAT_BAR_BG.Texture),
                                                            progressBarColor: barColor);
                if (m_stat != null)
                {
                    m_progressBar.Value = m_stat.CurrentRatio;
                }
                Elements.Add(m_progressBar);

                m_effectArrow = new MyGuiControlPanel(position: Size * new Vector2(arrowIconOffset, 0.0f),
                                                      originAlign: MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER,
                                                      size: arrowIconSize,
                                                      texture: MyGuiConstants.TEXTURE_HUD_STAT_EFFECT_ARROW_UP.Texture);
                Elements.Add(m_effectArrow);

                StringBuilder statText = new StringBuilder();

                statText.AppendDecimal((int)m_stat.Value, 0);
                statText.Append("/");
                statText.AppendDecimal(m_stat.MaxValue, 0);
                m_statValueLabel = new MyGuiControlLabel(position: Size * new Vector2(rightTextOffset, textHeightOffset),
                                                         text: statText.ToString(),
                                                         textScale: textScale,
                                                         originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER);
                Elements.Add(m_statValueLabel);
            }
Beispiel #2
0
        public MyGuiScreenSimpleProgressBar(MyTextsWrapperEnum caption, StringBuilder text, float value, MySoundCuesEnum?progressCueEnum, MySoundCuesEnum?cancelCueEnum, int decimals, MySoundCuesEnum?successCueEnum = null)
            : base(new Vector2(0.5f, 0.5f), MyGuiConstants.SCREEN_BACKGROUND_COLOR, new Vector2(0.4f, 0.4f))
        {
            m_decimals          = decimals;
            m_text              = text;
            m_closeOnEsc        = false;
            m_isTopMostScreen   = true;
            m_backgroundTexture = MyTextureManager.GetTexture <MyTexture2D>("Textures\\GUI\\BackgroundScreen\\ProgressBarBackground", flags: TextureFlags.IgnoreQuality);
            m_size              = new Vector2(673 / 1600f, 363 / 1200f);// MyGuiManager.GetNormalizedCoordsAndPreserveOriginalSize(673, 363);

            m_progressCueEnum = progressCueEnum;
            m_cancelCueEnum   = cancelCueEnum;
            m_successCueEnum  = successCueEnum;

            AddCaption(caption, new Vector2(0f, 0.015f));
            Vector2 progressBarSize = new Vector2(559 / 1600f, 112 / 1200f);// MyGuiManager.GetNormalizedCoordsAndPreserveOriginalSize(559, 112);

            m_progressBar = new MyGuiControlProgressBar(this, Vector2.Zero, progressBarSize, Vector4.Zero, new Vector4(1f, 1f, 1f, 1f), Color.White.ToVector4(), MyGuiConstants.LABEL_TEXT_SCALE, value, m_decimals);
            Controls.Add(m_progressBar);

            m_progressText = new MyGuiControlLabel(this, new Vector2(0f, 0.05f), null, m_text, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER);
            Controls.Add(m_progressText);
        }