Esempio n. 1
0
        public void Draw()
        {
            if (!Visible || !TreeView.Contains(m_currentOrigin, m_currentSize))
            {
                return;
            }

            bool    isHighlighted      = TreeView.HooveredItem == this;
            Vector2 expandIconPosition = GetExpandIconPosition();
            Vector2 iconPosition       = GetIconPosition();
            Vector2 textPosition       = GetTextPosition();

            Vector4 baseColor = Enabled ? Vector4.One : MyGuiConstants.TREEVIEW_DISABLED_ITEM_COLOR;

            if (TreeView.FocusedItem == this)
            {
                Color selectedColor = TreeView.GetColor(MyGuiConstants.TREEVIEW_SELECTED_ITEM_COLOR * baseColor);
                if (TreeView.WholeRowHighlight())
                {
                    MyGUIHelper.FillRectangle(new Vector2(TreeView.GetPosition().X, m_currentOrigin.Y), new Vector2(TreeView.GetBodySize().X, m_currentSize.Y), selectedColor);
                }
                else
                {
                    MyGUIHelper.FillRectangle(m_currentOrigin, m_currentSize, selectedColor);
                }
            }

            if (GetItemCount() > 0)
            {
                Vector4 expandColor = (isHighlighted) ? baseColor * MyGuiConstants.CONTROL_MOUSE_OVER_BACKGROUND_COLOR_MULTIPLIER : baseColor;
                MyGuiManager.DrawSpriteBatch(IsExpanded ? m_collapseIcon : m_expandIcon,
                                             m_currentOrigin + expandIconPosition, m_expandIconSize,
                                             TreeView.GetColor(expandColor), MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP);
            }

            if (m_icon != null && m_icon.LoadState != LoadState.Error)
            {
                if (m_icon == null)
                { // texture is still being loaded on other thread
                    DrawLoadingIcon(baseColor, iconPosition);
                }
                else
                {
                    MyGuiManager.DrawSpriteBatch(m_icon, m_currentOrigin + iconPosition, m_iconSize,
                                                 TreeView.GetColor(baseColor),
                                                 MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP);
                }
            }

            Vector4 textColor = (isHighlighted) ? MyGuiConstants.CONTROL_MOUSE_OVER_BACKGROUND_COLOR_MULTIPLIER * baseColor : MyGuiConstants.TREEVIEW_TEXT_COLOR * baseColor;

            MyGuiManager.DrawString(MyGuiManager.GetFontMinerWarsBlue(), Text,
                                    m_currentOrigin + textPosition,
                                    0.8f, TreeView.GetColor(textColor), MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP);

            if (IconTexts != null)
            {
                IconTexts.Draw(m_currentOrigin + iconPosition, m_iconSize, TreeView.GetTransitionAlpha(), isHighlighted);
            }
        }
        public MyGuiScreenLoading(MyGuiScreenGamePlay screenToLoad, MyGuiScreenGamePlay screenToUnload, MyTexture2D textureFromConstructor)
            : base(Vector2.Zero, null, null)
        {
            MyLoadingPerformance.Instance.StartTiming();

            System.Diagnostics.Debug.Assert(Static == null);
            Static = this;

            m_screenToLoad         = screenToLoad;
            m_screenToUnload       = screenToUnload;
            m_closeOnEsc           = false;
            DrawMouseCursor        = false;
            m_loadInDrawFinished   = false;
            m_drawEvenWithoutFocus = true;
            m_currentQuoteOfTheDay = MyQuoteOfTheDay.GetRandomQuote();

            Vector2 loadingTextSize = MyGuiManager.GetNormalizedSize(MyGuiManager.GetFontMinerWarsBlue(),
                                                                     MyTextsWrapper.Get(MyTextsWrapperEnum.LoadingPleaseWait), MyGuiConstants.LOADING_PLEASE_WAIT_SCALE);

            m_rotatingWheelTexture = MyGuiManager.GetLoadingTexture();
            Controls.Add(new MyGuiControlRotatingWheel(this, MyGuiConstants.LOADING_PLEASE_WAIT_POSITION - new Vector2(0, 0.075f + loadingTextSize.Y),
                                                       MyGuiConstants.ROTATING_WHEEL_COLOR, MyGuiConstants.ROTATING_WHEEL_DEFAULT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, m_rotatingWheelTexture));
            m_backgroundTextureFromConstructor = textureFromConstructor;

            m_loadFinished = false;

            if (m_screenToLoad != null)
            {
                MyMinerGame.IsGameReady = false;
            }
        }
        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();
            }
        }
Esempio n. 4
0
        protected void DrawGlobalVersionText()
        {
            //  Text "TEST BUILD"
            Color   colorBuildType          = new Color(230, 230, 230, 230) * m_transitionAlpha;
            Vector2 textRightBottomPosition = MyGuiManager.GetScreenTextRightBottomPosition();

            textRightBottomPosition.X -= 0.03f;
            textRightBottomPosition.Y -= 0.01f;
            Vector2 position = textRightBottomPosition;

            if (MyMwcFinalBuildConstants.IS_PUBLIC)
            {
                // There's no text for public
                //MyGuiManager.DrawString(MyGuiManager.GetFontMinerWarsBlue(), MyTextsWrapper.Get(MyTextsWrapperEnum.xxx),
                //      position, MyGuiConstants.APP_GLOBAL_TEXT_SCALE, new Color(MyGuiConstants.LABEL_TEXT_COLOR * m_transitionAlpha)/*colorBuildType*/, MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM);
            }
            else if (MyMwcFinalBuildConstants.IS_TEST)
            {
                MyGuiManager.DrawString(MyGuiManager.GetFontMinerWarsBlue(), MyTextsWrapper.Get(MyTextsWrapperEnum.TestBuild),
                                        position, MyGuiConstants.APP_GLOBAL_TEXT_SCALE, new Color(MyGuiConstants.LABEL_TEXT_COLOR * m_transitionAlpha), MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM);
            }
            else if (MyMwcFinalBuildConstants.IS_DEVELOP)
            {
                MyGuiManager.DrawString(MyGuiManager.GetFontMinerWarsBlue(), MyTextsWrapper.Get(MyTextsWrapperEnum.DevelopBuild),
                                        position, MyGuiConstants.APP_GLOBAL_TEXT_SCALE, new Color(MyGuiConstants.LABEL_TEXT_COLOR * m_transitionAlpha), MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM);
            }
            else
            {
                throw new SysUtils.Utils.MyMwcExceptionApplicationShouldNotGetHere();
            }
        }
        //  Converts carriage (or just char) position to normalized coordinates
        Vector2 GetCarriagePosition(int index)
        {
            string  leftFromCarriageText = GetTextByType().Substring(0, index);
            Vector2 leftFromCarriageSize = MyGuiManager.GetNormalizedSize(MyGuiManager.GetFontMinerWarsBlue(), new StringBuilder(leftFromCarriageText), m_textScale);

            return(GetTextAreaPosition() + new Vector2(leftFromCarriageSize.X, 0));
        }
Esempio n. 6
0
        public Vector2 LayoutItem(Vector2 origin)
        {
            m_currentOrigin = origin;

            if (!Visible)
            {
                m_currentSize = Vector2.Zero;
                return(Vector2.Zero);
            }

            m_currentTextSize = MyGuiManager.MeasureString(MyGuiManager.GetFontMinerWarsBlue(), Text, m_currentOrigin, 0.8f, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_TOP).Size;

            float iconOffset = m_icon != null ? m_iconSize.X + spacing : 0;
            float width      = padding + m_expandIconSize.X + spacing + iconOffset + m_currentTextSize.X + rightBorder + padding;
            float height     = padding + GetHeight() + padding;

            m_currentSize = new Vector2(width, height);

            if (IsExpanded)
            {
                Vector2 offset    = GetOffset();
                Vector2 itemsSize = LayoutItems(origin + GetOffset());

                width   = Math.Max(width, offset.X + itemsSize.X);
                height += itemsSize.Y;
            }

            return(new Vector2(width, height));
        }
Esempio n. 7
0
        public void DrawDraged(Vector2 position)
        {
            if ((m_icon != null && m_icon.LoadState == LoadState.Loaded) || Text != null)
            {
                if (m_icon != null)
                {
                    MyTexture2D texture = m_icon;
                    if (texture == null)
                    { // texture is still being loaded on other thread
                        DrawLoadingIcon(Vector4.One, GetIconPosition());
                    }
                    else
                    {
                        MyGUIHelper.OutsideBorder(position + GetIconPosition(), m_iconSize, 2, MyGuiConstants.TOOL_TIP_BORDER_COLOR);
                        MyGuiManager.DrawSpriteBatch(m_icon,
                                                     position + GetIconPosition(), m_iconSize,
                                                     Color.White, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP);
                    }
                }
                else if (Text != null)
                {
                    var textRect = MyGuiManager.MeasureString(MyGuiManager.GetFontMinerWarsBlue(), Text, position + GetTextPosition(), 0.8f, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP);
                    MyGUIHelper.OutsideBorder(textRect.LeftTop, textRect.Size, 2, MyGuiConstants.TOOL_TIP_BORDER_COLOR);
                    MyGUIHelper.FillRectangle(textRect.LeftTop, textRect.Size, TreeView.GetColor(MyGuiConstants.TREEVIEW_SELECTED_ITEM_COLOR));

                    Color textColor = TreeView.GetColor(MyGuiConstants.CONTROL_MOUSE_OVER_BACKGROUND_COLOR_MULTIPLIER);
                    MyGuiManager.DrawString(MyGuiManager.GetFontMinerWarsBlue(), Text,
                                            position + GetTextPosition(),
                                            0.8f, textColor, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP);
                }
            }
        }
Esempio n. 8
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());
 }
        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);
        }
Esempio n. 10
0
 /// <summary>
 /// Adds new tooltip with specific color and scale
 /// </summary>
 /// <param name="toolTip">Tooltip's text</param>
 /// <param name="color">Tooltip's color</param>
 /// <param name="textScale">Tooltip's scale</param>
 public void AddToolTip(StringBuilder toolTip, Color color, float textScale)
 {
     if (toolTip != null)
     {
         m_toolTips.Add(new MyColoredText(toolTip, color, MyGuiManager.GetFontMinerWarsBlue(), textScale));
         RecalculateSize();
     }
 }
        public override void Draw()
        {
            if (!Visible)
            {
                return;
            }

            base.Draw();

            Vector2 textAreaSize     = GetTextAreaSize();
            Vector2 textAreaPosition = GetTextAreaPosition();
            Vector4 tempTextColor    = (IsMouseOverOrKeyboardActive() == false) ? m_textColor : m_textColor * MyGuiConstants.CONTROL_MOUSE_OVER_BACKGROUND_COLOR_MULTIPLIER;
            Vector2 carriagePosition = GetCarriagePosition(m_carriagePositionIndex);

            //  End our standard sprite batch
            MyGuiManager.EndSpriteBatch();

            //  Draw the rectangle to stencil buffer, so later when we draw, only pixels with stencil=1 will be rendered
            //  Textbox interior must be increased by 1 pixel in all four directions (thus adding 2.0 to its height and width - because it's centered).
            //  Otherwise stencil would cut out something from textbox interior.
            MyGuiManager.DrawStencilMaskRectangle(new MyRectangle2D(textAreaPosition + new Vector2(textAreaSize.X / 2.0f, 0),
                                                                    textAreaSize + MyGuiManager.GetNormalizedSizeFromScreenSize(new Vector2(2.0f, 2.0f))), MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER);

            //  Set up the stencil operation and parameters
            MyGuiManager.BeginSpriteBatch_StencilMask();

            UpdateSlidingWindowPosition();
            float slidingWindowPositionDeltaX = m_slidingWindowPosition.X - textAreaPosition.X;

            //  Show "sliding window" rectangle - only for debugging
            //MyGuiManager.DrawSpriteBatch(MyGuiManager.GetBlankTexture(), m_slidingWindowPosition, textAreaSize,
            //    GetColorAfterTransitionAlpha(new Vector4(0, 1, 0, 0.3f)), MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER);

            //  Draw text in textbox
            MyGuiManager.DrawString(MyGuiManager.GetFontMinerWarsBlue(), new StringBuilder(GetTextByType()), new Vector2(textAreaPosition.X - slidingWindowPositionDeltaX, textAreaPosition.Y),
                                    m_textScale, GetColorAfterTransitionAlpha(tempTextColor), MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER);

            //  Draw carriage line
            //  Carriage blinker time is solved here in Draw because I want to be sure it will be drawn even in low FPS
            if (m_hasKeyboardActiveControl == true)
            {
                //  This condition controls "blinking", so most often is carrier visible and blinks very fast
                //  It also depends on FPS, but as we have max FPS set to 60, it won't go faster, nor will it omit a "blink".
                int carriageInterval = m_carriageBlinkerTimer % 20;
                if ((carriageInterval >= 0) && (carriageInterval <= 15))
                {
                    MyGuiManager.DrawSpriteBatch(MyGuiManager.GetBlankTexture(), new Vector2(carriagePosition.X - slidingWindowPositionDeltaX, carriagePosition.Y), 1, m_size.Value.Y * 0.5f,
                                                 GetColorAfterTransitionAlpha(tempTextColor), MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER);
                }
            }
            m_carriageBlinkerTimer++;

            //  End stencil-mask batch, and restart the standard sprite batch
            //MyGuiManager.EndSpriteBatch();
            MyGuiManager.EndSpriteBatch_StencilMask();
            //MyGuiManager.BeginSpriteBatch_StencilMask();
            MyGuiManager.BeginSpriteBatch();
        }
 public void HudDrawActualAmmoComment(Vector4?backgroundColor, StringBuilder text)
 {
     if (backgroundColor.HasValue)
     {
         m_color = new Color(backgroundColor.Value);
         MyGuiManager.BeginSpriteBatch();
         MyGuiManager.DrawString(MyGuiManager.GetFontMinerWarsBlue(), text, MyNotificationConstants.DEFAULT_NOTIFICATION_MESSAGE_NORMALIZED_POSITION - new Vector2(0, 0.03f), 1, new Color(MyGuiConstants.LABEL_TEXT_COLOR), MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_BOTTOM);
         MyGuiManager.EndSpriteBatch();
     }
 }
Esempio n. 13
0
 public MyRectangle2D GetTextSize()
 {
     if (m_textDraw != null)
     {
         //  This means that text was changed through UpdateParams
         return(MyGuiManager.MeasureString(MyGuiManager.GetFontMinerWarsBlue(), m_textDraw, m_parent.GetPositionAbsolute() + m_position, m_textScale, m_textAlign));
     }
     else
     {
         return(MyGuiManager.MeasureString(MyGuiManager.GetFontMinerWarsBlue(), MyTextsWrapper.Get(m_textEnum), m_parent.GetPositionAbsolute() + m_position, m_textScale, m_textAlign));
     }
 }
Esempio n. 14
0
        /*protected void DrawActorsPhotos()
         * {
         *  if (m_minerWarsActorsTexture != null)
         *  {
         *      //  Miner Wars actors
         *      Color colorForeground = new Color(new Vector4(1, 1, 1, 1f * m_transitionAlpha));
         *
         *      MyGuiManager.DrawSpriteBatch(m_minerWarsActorsTexture, new Vector2(1.1f, -0.01f),
         *                                   new Vector2(323.3f / 1600f, 394.4f / 1200f), colorForeground,
         *                                   MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP);
         *  }
         * }*/

        protected void DrawAppVersion()
        {
            Vector2 textRightBottomPosition = MyGuiManager.GetScreenTextRightBottomPosition();

            textRightBottomPosition.X -= 0.03f;
            textRightBottomPosition.Y -= 0.06f;
            MyGuiManager.DrawString(MyGuiManager.GetFontMinerWarsBlue(), APP_VERSION, textRightBottomPosition, MyGuiConstants.APP_VERSION_TEXT_SCALE,
                                    new Color(MyGuiConstants.LABEL_TEXT_COLOR * m_transitionAlpha), MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM);

            textRightBottomPosition.Y += 0.03f;
            MyGuiManager.DrawString(MyGuiManager.GetFontMinerWarsBlue(), UNOFFICIAL_MOD, textRightBottomPosition, MyGuiConstants.APP_VERSION_TEXT_SCALE,
                                    new Color(MyGuiConstants.LABEL_TEXT_COLOR * m_transitionAlpha), MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM);
        }
Esempio n. 15
0
        public override bool Draw(float backgroundFadeAlpha)
        {
            if (base.Draw(backgroundFadeAlpha) == false)
            {
                return(false);
            }

            ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            //  Credits
            ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

            float movingY = m_scrollingPositionY;

            for (int i = 0; i < m_departments.Count; i++)
            {
                MyGuiManager.DrawString(MyGuiManager.GetFontMinerWarsBlue(), m_departments[i].Name,
                                        new Vector2(0.5f, movingY), 0.78f,
                                        ChangeTextAlpha(color, movingY),
                                        MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER);
                movingY += 0.05f;

                for (int j = 0; j < m_departments[i].Persons.Count; j++)
                {
                    MyGuiManager.DrawString(MyGuiManager.GetFontMinerWarsBlue(), m_departments[i].Persons[j].Name,
                                            new Vector2(0.5f, movingY), 1.04f,
                                            ChangeTextAlpha(color, movingY),
                                            MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER);
                    movingY += 0.05f;
                }

                movingY += 0.04f;
            }

            //  This will start scrolling again after last word was scrolled through the top
            if (movingY <= 0)
            {
                ResetScrollingPositionY();
            }


            MyGuiManager.DrawSpriteBatch(m_menuOverlay, new Rectangle(0, 0, MyMinerGame.ScreenSize.X, MyMinerGame.ScreenSize.Y), Color.White);

            ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            //  Company Logo - with shadow (thus drawing two times)
            ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

            DrawMinerWarsLogo();

            return(true);
        }
        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);
            }
        }
Esempio n. 17
0
        public bool DrawLoading(float backgroundFadeAlpha)
        {
            m_transitionAlpha = 1.0f;

            MyMinerGame.Static.GraphicsDevice.Clear(ClearFlags.Target, new SharpDX.ColorBGRA(0), 0, 0);

            Color colorQuote = new Color(255, 255, 255, 250);     //  White

            colorQuote.A = (byte)(colorQuote.A * m_transitionAlpha);
            //if (m_backgroundTextureFromConstructor == null)
            {
                //////////////////////////////////////////////////////////////////////
                //  Normal loading screen
                //////////////////////////////////////////////////////////////////////

                //  Random background texture
                Rectangle backgroundRectangle;
                MyGuiManager.GetSafeHeightFullScreenPictureSize(MyGuiConstants.LOADING_BACKGROUND_TEXTURE_REAL_SIZE, out backgroundRectangle);
                MyGuiManager.DrawSpriteBatch(m_backgroundScreenTexture, backgroundRectangle, new Color(new Vector4(0.95f, 0.95f, 0.95f, m_transitionAlpha)));

                //  Miner Wars logo
                DrawMinerWarsLogo();

                //  Current version:
                //DrawAppVersion();
                //DrawGlobalVersionText();

                //  Quote of the day or something
                MyGuiManager.DrawStringCentered(MyGuiManager.GetFontMinerWarsBlue(), (new System.Text.StringBuilder()).Append(MyTextsWrapper.Get(MyTextsWrapperEnum.Tip)).Append(" ").Append(MyTextsWrapper.Get(m_currentQuoteOfTheDay)),
                                                new Vector2(0.5f, 0.55f), 1.15f, colorQuote, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER);
            }

            LastBackgroundTexture = m_backgroundScreenTexture;

            //  Loading Please Wait
            MyGuiManager.DrawString(MyGuiManager.GetFontMinerWarsBlue(), MyTextsWrapper.Get(MyTextsWrapperEnum.LoadingPleaseWait),
                                    MyGuiConstants.LOADING_PLEASE_WAIT_POSITION, MyGuiConstants.LOADING_PLEASE_WAIT_SCALE, new Color(MyGuiConstants.LOADING_PLEASE_WAIT_COLOR * GetTransitionAlpha()),
                                    MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_BOTTOM);

            if (base.Draw(backgroundFadeAlpha) == false)
            {
                return(false);
            }


            return(true);
        }
Esempio n. 18
0
        void DrawText(StringBuilder sb)
        {
            Vector4 textColor = m_textColor;

            if (!Enabled)
            {
                textColor = m_textColor * MyGuiConstants.DISABLED_BUTTON_COLOR_VECTOR;
            }
            if (Font == null)
            {
                MyGuiManager.DrawString(MyGuiManager.GetFontMinerWarsBlue(), sb, m_parent.GetPositionAbsolute() + m_position, m_textScale, GetColorAfterTransitionAlpha(textColor), m_textAlign);
            }
            else
            {
                MyGuiManager.DrawString(Font, sb, m_parent.GetPositionAbsolute() + m_position, m_textScale, GetColorAfterTransitionAlpha(textColor), m_textAlign);
            }
        }
Esempio n. 19
0
        public override bool Draw(float backgroundFadeAlpha)
        {
            if (base.Draw(backgroundFadeAlpha) == false)
            {
                return(false);
            }

            Color textColor = new Color(MyGuiConstants.LABEL_TEXT_COLOR);

            MyGuiManager.DrawString(MyGuiManager.GetFontMinerWarsBlue(), MyTextsWrapper.Get(MyTextsWrapperEnum.RegistrationInfo), new Vector2(0.50f, 0.25f), 0.75f * 0.8f,
                                    textColor, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_BOTTOM);
            MyGuiManager.DrawString(MyGuiManager.GetFontMinerWarsBlue(), MyTextsWrapper.Get(MyTextsWrapperEnum.FormAgreement1), new Vector2(0.50f, 0.67f), 0.75f * 0.8f,
                                    textColor, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_BOTTOM);
            MyGuiManager.DrawString(MyGuiManager.GetFontMinerWarsBlue(), MyTextsWrapper.Get(MyTextsWrapperEnum.FormAgreement2), new Vector2(0.50f, 0.69f), 0.75f * 0.8f,
                                    textColor, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_BOTTOM);

            return(true);
        }
Esempio n. 20
0
        /// <summary>
        /// Recalculates size of tooltips
        /// </summary>
        public void RecalculateSize()
        {
            m_size = new Vector2(0f, 0f);
            bool isEmptyToolTip = true;

            for (int i = 0; i < m_toolTips.Count; i++)
            {
                if (m_toolTips[i].Text.Length > 0)
                {
                    isEmptyToolTip = false;
                }
                Vector2 actualToolTipSize = MyGuiManager.GetNormalizedSize(MyGuiManager.GetFontMinerWarsBlue(), m_toolTips[i].Text, m_toolTips[i].Scale);
                m_size.X  = Math.Max(m_size.X, actualToolTipSize.X);
                m_size.Y += actualToolTipSize.Y;
            }

            if (isEmptyToolTip)
            {
                m_size = new Vector2(-1f, -1f);
            }
        }
Esempio n. 21
0
        public MyGuiControlListboxItem(int key, StringBuilder value, MyTexture2D icon, MyToolTips tooltip, float scale)
        {
            Key     = key;
            Icon    = icon;
            ToolTip = tooltip;

            if (value != null)
            {
                ColoredText = new MyColoredText(value, new Color(MyGuiConstants.LISTBOX_TEXT_COLOR),
                                                new Color(MyGuiConstants.LISTBOX_TEXT_COLOR * MyGuiConstants.CONTROL_MOUSE_OVER_BACKGROUND_COLOR_MULTIPLIER),
                                                MyGuiManager.GetFontMinerWarsBlue(),
                                                scale, Vector2.Zero);

                if (ToolTip == null)
                {
                    ToolTip = new MyToolTips(value);
                }
            }
            BackgroundColor = Vector4.One;
            Enabled         = true;
        }
Esempio n. 22
0
        //StringBuilder m_drawPositionSb = new StringBuilder();
        private void DrawControlDebugPosition(MyGuiControlBase control)
        {
            m_drawPositionSb.Clear();
            m_drawPositionSb.Append("[");
            m_drawPositionSb.Append(control.GetPosition().X.ToString("0.0000"));
            m_drawPositionSb.Append(",");
            m_drawPositionSb.Append(control.GetPosition().Y.ToString("0.0000"));
            m_drawPositionSb.Append("]");
            float   scale = 0.7f;
            Vector2 size  = MyGuiManager.GetNormalizedSizeFromScreenSize(MyGuiManager.GetFontMinerWarsBlue().MeasureString(m_drawPositionSb, scale));
            Vector4 color = new Vector4(0f, 0f, 0f, 0.5f);

            MyGuiManager.DrawSpriteBatch(MyGuiManager.GetBlankTexture(), control.GetPosition() + control.GetParent().GetPositionAbsolute(),
                                         size, new Color(color),
                                         MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER);

            MyGuiManager.DrawString(MyGuiManager.GetFontMinerWarsBlue(),
                                    m_drawPositionSb,
                                    control.GetPosition() + control.GetParent().GetPositionAbsolute(), scale,
                                    Color.Green,
                                    MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER);
        }
Esempio n. 23
0
        public MyGuiScreenUnloading(MyGuiScreenGamePlay screenToUnload, MyGuiScreenBase screenToShowAfter)
            : base(Vector2.Zero, null, null)
        {
            m_screenToUnload       = screenToUnload;
            m_closeOnEsc           = false;
            DrawMouseCursor        = false;
            m_loadInDrawFinished   = false;
            m_drawEvenWithoutFocus = true;
            m_currentQuoteOfTheDay = MyQuoteOfTheDay.GetRandomQuote();

            Vector2 loadingTextSize = MyGuiManager.GetNormalizedSize(MyGuiManager.GetFontMinerWarsBlue(),
                                                                     MyTextsWrapper.Get(MyTextsWrapperEnum.LoadingPleaseWait), MyGuiConstants.LOADING_PLEASE_WAIT_SCALE);

            m_rotatingWheelTexture = MyGuiManager.GetLoadingTexture();
            Controls.Add(new MyGuiControlRotatingWheel(this, MyGuiConstants.LOADING_PLEASE_WAIT_POSITION - new Vector2(0, 0.075f + loadingTextSize.Y),
                                                       MyGuiConstants.ROTATING_WHEEL_COLOR, MyGuiConstants.ROTATING_WHEEL_DEFAULT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, m_rotatingWheelTexture));

            m_loadFinished = false;

            MyMinerGame.IsGameReady = false;
            m_screenToShowAfter     = screenToShowAfter;
        }
Esempio n. 24
0
        public override void UpdateBeforeSimulation()
        {
            base.UpdateBeforeSimulation();

            if (IsDust || IsSound)
            {
                float influence = CalculateInfluenceStrength(MyCamera.Position);
                if (m_influenceStrengthCamera != influence)
                {
                    if (IsDust)
                    {
                        ChangeDustColor(influence);
                    }
                    if (IsSound)
                    {
                        ChangeSound(influence);
                    }
                    m_influenceStrengthCamera = influence;
                }

                #region DEBUGING
                if (MyFakes.ENABLE_DEBUG_INFLUENCE_SPHERES_SOUNDS && IsSound)
                {
                    if (influence > 0f)
                    {
                        if (influence > m_nearestInfluenceSphereStrength)
                        {
                            m_nearestInfluenceSphere = this;
                            if (m_notification == null)
                            {
                                m_notification = new MyHudNotification.MyNotification(m_nearestInfluenceSphere.m_cueEnum.ToString() + ":" + (int)m_maxVolume, MyGuiManager.GetFontMinerWarsBlue());
                                MyHudNotification.AddNotification(m_notification);
                            }
                        }
                    }
                    else
                    {
                        if (m_nearestInfluenceSphere == this)
                        {
                            m_nearestInfluenceSphere         = null;
                            m_nearestInfluenceSphereStrength = 0f;
                            if (m_notification != null)
                            {
                                m_notification.Disappear();
                                m_notification = null;
                            }
                        }
                    }
                }
                #endregion
            }

            if (IsRadioactivity)
            {
                float influence = CalculateInfluenceStrength(MySession.PlayerShip.GetPosition());
                if (m_influenceStrengthShip != influence)
                {
                    ChangeRadioactivity(influence);
                    m_influenceStrengthShip = influence;
                }
            }
        }
Esempio n. 25
0
        private void GetOreSubmissionSuccess(MyMissionBase sender)
        {
            MyScriptWrapper.EntityInventoryItemAmountChanged -= OreAmountChanged;

            // remove the mined plutonium to prevend stupid players from breaking the game
            MyScriptWrapper.AddNotification(MyScriptWrapper.CreateNotification(MyTextsWrapperEnum.PlutoniumStored, MyGuiManager.GetFontMinerWarsBlue(), 5000, new object[] { URANITE_TO_OBTAIN }));
            MyScriptWrapper.RemoveInventoryItemAmount(MyScriptWrapper.GetPlayerInventory(), MyMwcObjectBuilderTypeEnum.Ore, (int)MyMwcObjectBuilder_Ore_TypesEnum.URANITE, URANITE_TO_OBTAIN);
        }
        public bool DrawLoading(float backgroundFadeAlpha)
        {
            //MyAudio.Update(true);
            m_transitionAlpha = 1.0f;

            MyMinerGame.Static.GraphicsDevice.Clear(ClearFlags.Target, new SharpDX.ColorBGRA(0), 0, 0);

            Color colorQuote = new Color(255, 255, 255, 250);     //  White

            colorQuote.A = (byte)(colorQuote.A * m_transitionAlpha);
            //if (m_backgroundTextureFromConstructor == null)
            {
                //////////////////////////////////////////////////////////////////////
                //  Normal loading screen
                //////////////////////////////////////////////////////////////////////

                MyTextsWrapperEnum sectorName        = MyTextsWrapperEnum.Null;
                MyTextsWrapperEnum sectorDescription = MyTextsWrapperEnum.Null;
                MyTexture2D        sectorTexture     = null;

                bool descriptionAvailable = false;
                if (m_screenToLoad != null)
                {
                    var position = m_screenToLoad.GetSectorIdentifier().Position;
                    descriptionAvailable = GetSectorDescription(position, out sectorName, out sectorDescription, out sectorTexture);
                }
                else if (MyGuiScreenGamePlay.Static != null)
                {
                    var position = MyGuiScreenGamePlay.Static.GetSectorIdentifier().Position;
                    descriptionAvailable = GetSectorDescription(position, out sectorName, out sectorDescription, out sectorTexture);
                }
                else
                {
                    descriptionAvailable = false;
                }



                //  Random background texture
                Rectangle backgroundRectangle;
                MyGuiManager.GetSafeHeightFullScreenPictureSize(MyGuiConstants.LOADING_BACKGROUND_TEXTURE_REAL_SIZE, out backgroundRectangle);
                MyGuiManager.DrawSpriteBatch(descriptionAvailable ? sectorTexture : m_backgroundScreenTexture, backgroundRectangle, new Color(new Vector4(0.95f, 0.95f, 0.95f, m_transitionAlpha)));

                //  Miner Wars logo
                DrawMinerWarsLogo();

                //  Current version:
                //DrawAppVersion();
                //DrawGlobalVersionText();

                if (descriptionAvailable)
                {
                    MyGuiManager.DrawStringCentered(MyGuiManager.GetFontMinerWarsBlue(), MyTextsWrapper.Get(sectorName),
                                                    new Vector2(0.5f, 0.4f), 1.6f, colorQuote, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER);
                    MyGuiManager.DrawStringCentered(MyGuiManager.GetFontMinerWarsBlue(), MyTextsWrapper.Get(sectorDescription),
                                                    new Vector2(0.5f, 0.5f), 1, colorQuote, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER);
                }
                else
                {
                    //  Quote of the day
                    MyGuiManager.DrawStringCentered(MyGuiManager.GetFontMinerWarsBlue(), (new StringBuilder()).Append(MyTextsWrapper.Get(MyTextsWrapperEnum.Tip)).Append(" ").Append(MyTextsWrapper.Get(m_currentQuoteOfTheDay)),
                                                    new Vector2(0.5f, 0.5f), 1.15f, colorQuote, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER);
                }
            }

            /* else
             * {
             *   //////////////////////////////////////////////////////////////////////
             *   //  Loading screen when there is specified background texture is little customized
             *   //////////////////////////////////////////////////////////////////////
             *
             *   MyGuiManager.DrawSpriteBatch(m_backgroundScreenTexture, Vector2.Zero, new Color(new Vector4(0.95f, 0.95f, 0.95f, m_transitionAlpha)));
             * }*/

            LastBackgroundTexture = m_backgroundScreenTexture;

            //  Loading Please Wait
            MyGuiManager.DrawString(MyGuiManager.GetFontMinerWarsBlue(), MyTextsWrapper.Get(MyTextsWrapperEnum.LoadingPleaseWait),
                                    MyGuiConstants.LOADING_PLEASE_WAIT_POSITION, MyGuiConstants.LOADING_PLEASE_WAIT_SCALE, new Color(MyGuiConstants.LOADING_PLEASE_WAIT_COLOR * GetTransitionAlpha()),
                                    MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_BOTTOM);

            MyGuiManager.DrawString(MyGuiManager.GetFontMinerWarsBlue(), MyTextsWrapper.Get(MyTextsWrapperEnum.LongerLoadingTimes),
                                    MyGuiConstants.LOADING_PLEASE_WAIT_POSITION + new Vector2(0, 0.025f), MyGuiConstants.LOADING_PLEASE_WAIT_SCALE * 0.8f, new Color(MyGuiConstants.LOADING_PLEASE_WAIT_COLOR * GetTransitionAlpha()),
                                    MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_BOTTOM);


            if (base.Draw(backgroundFadeAlpha) == false)
            {
                return(false);
            }


            return(true);
        }
        public MyGuiScreenMission(MyMission missionBase, bool canDecline = true)
            : base(new Vector2(0.5f, 0.5f), MyGuiConstants.SCREEN_BACKGROUND_COLOR, new Vector2(0.75f, 0.75f))
        {
            Debug.Assert(missionBase != null);
            m_mission           = missionBase;
            m_backgroundTexture = MyTextureManager.GetTexture <MyTexture2D>("Textures\\GUI\\BackgroundScreen\\MissionAcceptBackground", flags: TextureFlags.IgnoreQuality);
            m_size = new Vector2(1010 / 1600f, 855 / 1200f);

            // Title
            var titleLabel = new MyGuiControlLabel(
                this,
                new Vector2(0, -0.3052f),
                null,
                MyTextsWrapperEnum.Mission,
                MyGuiConstants.LABEL_TEXT_COLOR,
                MyGuiConstants.SCREEN_CAPTION_TEXT_SCALE,
                MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER);

            // append mission name to the title of the screen
            titleLabel.UpdateParams(new[] { missionBase.Name });
            Controls.Add(titleLabel);

            // mission description on the left
            Controls.Add(new MyGuiControlLabel(
                             this,
                             new Vector2(-m_size.Value.X / 4.5f, -0.2501f),
                             null, MyTextsWrapperEnum.Description,
                             MyGuiConstants.LABEL_TEXT_COLOR, .8f,
                             MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER));



            var multiLineText = new MyGuiControlMultilineText(
                this,
                new Vector2(-m_size.Value.X / 4.5f - 28 / 1600f, -0.0167f),
                new Vector2(370 / 1600f, 489 / 1200f),
                null,
                MyGuiManager.GetFontMinerWarsBlue(), .66f,
                MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                m_mission.DescriptionTemp, false, true);


            Controls.Add(multiLineText);
            multiLineText.ScrollbarOffset = 71 / 1600f;


            // mission objectives (submissions) on the right
            Controls.Add(new MyGuiControlLabel(
                             this,
                             new Vector2(m_size.Value.X / 4.5f, -0.2501f),
                             null, MyTextsWrapperEnum.Objectives,
                             MyGuiConstants.LABEL_TEXT_COLOR, .8f,
                             MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER));

            var objectives = new StringBuilder();

            foreach (MyObjective t in m_mission.Objectives)
            {
                objectives.Append("- ");
                objectives.Append(t.DescriptionTemp.ToString());
                objectives.AppendLine("\n");
                //objectives.AppendLine();
            }

            var textControl = new MyGuiControlMultilineText(
                this,
                new Vector2(m_size.Value.X / 4.5f - 28 / 1600f, -0.0167f),
                new Vector2(370 / 1600f, 489 / 1200f),
                null,
                MyGuiManager.GetFontMinerWarsBlue(), .66f,
                MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                objectives, false, true)
            {
                ScrollbarOffset = 64 / 1600f
            };


            Controls.Add(textControl);

            textControl.Clear();
            textControl.AppendText(objectives);


            var okButton = new MyGuiControlButton(this, new Vector2(-0.1379f, 0.2489f), MyGuiConstants.OK_BUTTON_SIZE,
                                                  MyGuiConstants.BUTTON_BACKGROUND_COLOR,
                                                  MyGuiManager.GetInventoryScreenButtonTexture(), null, null, MyTextsWrapperEnum.Accept,
                                                  MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, MyGuiControlButtonTextAlignment.CENTERED, OnAccept_Click,
                                                  true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true, true);

            Controls.Add(okButton);



            // decline button
            if (canDecline)
            {
                var declineButton = new MyGuiControlButton(this, new Vector2(0.1379f, 0.2489f), MyGuiConstants.OK_BUTTON_SIZE,
                                                           MyGuiConstants.BUTTON_BACKGROUND_COLOR,
                                                           MyGuiManager.GetInventoryScreenButtonTexture(), null, null, MyTextsWrapperEnum.Decline,
                                                           MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, MyGuiControlButtonTextAlignment.CENTERED, OnDecline_Click,
                                                           true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true, true);
                Controls.Add(declineButton);
            }
            else
            {
                m_closeOnEsc = canDecline;
            }
        }
Esempio n. 28
0
 protected void AddCaption(MyTextsWrapperEnum textEnum, Vector4 captionTextColor, Vector2?captionOffset = null, float captionScale = MyGuiConstants.SCREEN_CAPTION_TEXT_SCALE)
 {
     Controls.Add(new MyGuiControlLabel(this,
                                        new Vector2(0, -m_size.Value.Y / 2.0f + MyGuiConstants.SCREEN_CAPTION_DELTA_Y) + (captionOffset != null ? captionOffset.Value : Vector2.Zero),
                                        null, textEnum, captionTextColor, captionScale,
                                        MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, MyGuiManager.GetFontMinerWarsBlue()));
 }
        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();
        }
        public MyGuiScreenOptionsVideo()
            : base(new Vector2(0.5f, 0.5f), MyGuiConstants.SCREEN_BACKGROUND_COLOR, null)
        {
            MyMwcLog.WriteLine("MyGuiScreenOptionsVideo.ctor START");

            m_enableBackgroundFade = true;
            m_size  = new Vector2(0.59f, 0.68544f);
            m_size *= 1.1f;

            m_backgroundTexture = MyTextureManager.GetTexture <MyTexture2D>("Textures\\GUI\\BackgroundScreen\\VideoBackground", flags: TextureFlags.IgnoreQuality);

            AddCaption(MyTextsWrapperEnum.VideoOptions, new Vector2(0, 0.005f));
            //Controls.Add(new MyGuiControlLabel(this, -m_size.Value / 2.0f + MyGuiConstants.SCREEN_CAPTION_DELTA_Y, null, MyTextsWrapperEnum.VideoOptions, MyGuiConstants.SCREEN_CAPTION_TEXT_COLOR, MyGuiConstants.SCREEN_CAPTION_TEXT_SCALE));

            Vector2 controlsOriginLeft  = new Vector2(-m_size.Value.X / 2.0f + 0.05f, -m_size.Value.Y / 2.0f + 0.145f) + new Vector2(0.02f, 0f);
            Vector2 controlsOriginRight = new Vector2(-m_size.Value.X / 2.0f + 0.185f, -m_size.Value.Y / 2.0f + 0.145f) + new Vector2(0.043f, 0f);

            controlsOriginRight.X += 0.04f;


            int controlIndex = 0;

            // Adapter

            Controls.Add(new MyGuiControlLabel(this, controlsOriginLeft + controlIndex * MyGuiConstants.CONTROLS_DELTA, null, MyTextsWrapperEnum.VideoAdapter, MyGuiConstants.LABEL_TEXT_COLOR,
                                               MyGuiConstants.LABEL_TEXT_SCALE_OPTIONS, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, MyGuiManager.GetFontMinerWarsBlue()));

            m_videoAdapterCombobox = new MyGuiControlCombobox(this, controlsOriginRight + controlIndex++ *MyGuiConstants.CONTROLS_DELTA + new Vector2(MyGuiConstants.COMBOBOX_MEDIUM_SIZE.X / 2.0f, 0),
                                                              MyGuiControlPreDefinedSize.MEDIUM, MyGuiConstants.COMBOBOX_BACKGROUND_COLOR, MyGuiConstants.COMBOBOX_TEXT_SCALE);
            m_videoAdapterCombobox.OnSelect += OnVideoAdapterSelected;
            AddAdaptersToComboBox();
            Controls.Add(m_videoAdapterCombobox);

            //  Video Mode
            Controls.Add(new MyGuiControlLabel(this, controlsOriginLeft + controlIndex * MyGuiConstants.CONTROLS_DELTA, null, MyTextsWrapperEnum.VideoMode, MyGuiConstants.LABEL_TEXT_COLOR,
                                               MyGuiConstants.LABEL_TEXT_SCALE_OPTIONS, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, MyGuiManager.GetFontMinerWarsBlue()));

            m_videoModeCombobox = new MyGuiControlCombobox(this, controlsOriginRight + controlIndex++ *MyGuiConstants.CONTROLS_DELTA + new Vector2(MyGuiConstants.COMBOBOX_MEDIUM_SIZE.X / 2.0f, 0),
                                                           MyGuiControlPreDefinedSize.MEDIUM, MyGuiConstants.COMBOBOX_BACKGROUND_COLOR, MyGuiConstants.COMBOBOX_TEXT_SCALE);
            //  Populating Video Mode with supported DisplayMode reported by XNA framework
            m_videoModeCombobox.OnSelect += OnVideoModeSelected;
            //Added on UpdateSettings
            //AddDisplayModesToComboBox(MyMinerGame.GraphicsDeviceManager.GraphicsAdapter.AdapterOrdinal);
            Controls.Add(m_videoModeCombobox);

            //  Recommended aspect ratio
            m_recommendAspectRatioLabel = new MyGuiControlLabel(this, new Vector2(controlsOriginRight.X + MyGuiConstants.COMBOBOX_TEXT_OFFSET.X, controlsOriginRight.Y + controlIndex++ *MyGuiConstants.CONTROLS_DELTA.Y - 0.015f), null,
                                                                new StringBuilder(), MyGuiConstants.LABEL_TEXT_COLOR * 0.9f, MyGuiConstants.LABEL_TEXT_SCALE_OPTIONS * 0.85f, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, MyGuiManager.GetFontMinerWarsBlue());
            //Added on UpdateSettings
            //UpdateRecommendecAspectRatioLabel(MyMinerGame.GraphicsDeviceManager.GraphicsAdapter.AdapterOrdinal);
            Controls.Add(m_recommendAspectRatioLabel);

            //  reduce the spacing between "Recommended aspect ratio" and items below it
            Vector2 offSet = new Vector2(0, MyGuiConstants.CONTROLS_DELTA.Y / 2);

            controlsOriginLeft  -= offSet;
            controlsOriginRight -= offSet;

            //  Fullscreen
            Controls.Add(new MyGuiControlLabel(this, controlsOriginLeft + controlIndex * MyGuiConstants.CONTROLS_DELTA, null, MyTextsWrapperEnum.Fullscreen, MyGuiConstants.LABEL_TEXT_COLOR,
                                               MyGuiConstants.LABEL_TEXT_SCALE_OPTIONS, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, MyGuiManager.GetFontMinerWarsBlue()));

            m_fullscreenCheckbox = new MyGuiControlCheckbox(this,
                                                            controlsOriginRight + controlIndex++ *MyGuiConstants.CONTROLS_DELTA +
                                                            new Vector2(MyGuiConstants.CHECKBOX_WITH_GLOW_SIZE.X / 2.0f, 0), MyGuiConstants.CHECKBOX_WITH_GLOW_SIZE,
                                                            MyGuiManager.GetCheckboxOffTexture(), MyGuiManager.GetCheckboxOnTexture(), null,
                                                            true, MyGuiConstants.CHECKBOX_BACKGROUND_COLOR, true, null);
            //m_fullscreenCheckbox.OnCheck = OnFullScreenCheck;
            Controls.Add(m_fullscreenCheckbox);

            //  Vertical Sync
            Controls.Add(new MyGuiControlLabel(this, controlsOriginLeft + controlIndex * MyGuiConstants.CONTROLS_DELTA, null, MyTextsWrapperEnum.VerticalSync, MyGuiConstants.LABEL_TEXT_COLOR,
                                               MyGuiConstants.LABEL_TEXT_SCALE_OPTIONS, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, MyGuiManager.GetFontMinerWarsBlue()));
            //m_verticalSyncCheckbox = new MyGuiControlCheckbox(this, controlsOriginRight + 3 * MyGuiConstants.CONTROLS_DELTA + new Vector2(MyGuiConstants.CHECKBOX_SIZE.X / 2.0f, 0), true, MyGuiConstants.CHECKBOX_BACKGROUND_COLOR);


            m_verticalSyncCheckbox = new MyGuiControlCheckbox(this,
                                                              controlsOriginRight + controlIndex++ *MyGuiConstants.CONTROLS_DELTA +
                                                              new Vector2(MyGuiConstants.CHECKBOX_WITH_GLOW_SIZE.X / 2.0f, 0), MyGuiConstants.CHECKBOX_WITH_GLOW_SIZE,
                                                              MyGuiManager.GetCheckboxOffTexture(), MyGuiManager.GetCheckboxOnTexture(), null,
                                                              false, MyGuiConstants.CHECKBOX_BACKGROUND_COLOR, true, null);
            Controls.Add(m_verticalSyncCheckbox);


            //  Hardware Cursor
            Controls.Add(new MyGuiControlLabel(this, controlsOriginLeft + controlIndex * MyGuiConstants.CONTROLS_DELTA, null, MyTextsWrapperEnum.HardwareCursor, MyGuiConstants.LABEL_TEXT_COLOR,
                                               MyGuiConstants.LABEL_TEXT_SCALE_OPTIONS, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, MyGuiManager.GetFontMinerWarsBlue()));

            m_hardwareCursorCheckbox = new MyGuiControlCheckbox(this,
                                                                controlsOriginRight + controlIndex++ *MyGuiConstants.CONTROLS_DELTA +
                                                                new Vector2(MyGuiConstants.CHECKBOX_WITH_GLOW_SIZE.X / 2.0f, 0), MyGuiConstants.CHECKBOX_WITH_GLOW_SIZE,
                                                                MyGuiManager.GetCheckboxOffTexture(), MyGuiManager.GetCheckboxOnTexture(), null,
                                                                false, MyGuiConstants.CHECKBOX_BACKGROUND_COLOR, true, null);
            Controls.Add(m_hardwareCursorCheckbox);

            //  Render Quality
            Controls.Add(new MyGuiControlLabel(this, controlsOriginLeft + controlIndex * MyGuiConstants.CONTROLS_DELTA, null, MyTextsWrapperEnum.RenderQuality, MyGuiConstants.LABEL_TEXT_COLOR,
                                               MyGuiConstants.LABEL_TEXT_SCALE_OPTIONS, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, MyGuiManager.GetFontMinerWarsBlue()));
            m_renderQualityCombobox = new MyGuiControlCombobox(this, controlsOriginRight + controlIndex++ *MyGuiConstants.CONTROLS_DELTA + new Vector2(MyGuiConstants.COMBOBOX_MEDIUM_SIZE.X / 2.0f, 0),
                                                               MyGuiControlPreDefinedSize.MEDIUM, MyGuiConstants.COMBOBOX_BACKGROUND_COLOR, MyGuiConstants.COMBOBOX_TEXT_SCALE);
            m_renderQualityCombobox.AddItem((int)MyRenderQualityEnum.LOW, MyTextsWrapperEnum.RenderQualityLow);
            m_renderQualityCombobox.AddItem((int)MyRenderQualityEnum.NORMAL, MyTextsWrapperEnum.RenderQualityNormal);
            m_renderQualityCombobox.AddItem((int)MyRenderQualityEnum.HIGH, MyTextsWrapperEnum.RenderQualityHigh);
            m_renderQualityCombobox.AddItem((int)MyRenderQualityEnum.EXTREME, MyTextsWrapperEnum.RenderQualityExtreme);
            Controls.Add(m_renderQualityCombobox);

            // Field of View
            Controls.Add(new MyGuiControlLabel(this, controlsOriginLeft + controlIndex * MyGuiConstants.CONTROLS_DELTA, null, MyTextsWrapperEnum.FieldOfView, MyGuiConstants.LABEL_TEXT_COLOR,
                                               MyGuiConstants.LABEL_TEXT_SCALE_OPTIONS, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, MyGuiManager.GetFontMinerWarsBlue()));

            const float fovSliderSize = MyGuiConstants.SLIDER_WIDTH * 1.1f;

            m_fieldOfViewSlider = new MyGuiControlSlider(this, controlsOriginRight + controlIndex * MyGuiConstants.CONTROLS_DELTA + new Vector2(fovSliderSize / 2.0f, 0),
                                                         fovSliderSize, MyConstants.FIELD_OF_VIEW_CONFIG_MIN, MyConstants.FIELD_OF_VIEW_CONFIG_MAX, MyGuiConstants.SLIDER_BACKGROUND_COLOR,
                                                         new StringBuilder(), MyGuiConstants.SLIDER_WIDTH_LABEL, 0, MyGuiConstants.LABEL_TEXT_SCALE_OPTIONS * 0.85f);
            m_fieldOfViewSlider.OnChange = OnFovChanged;
            Controls.Add(m_fieldOfViewSlider);

            m_fieldOfViewLabel = new MyGuiControlLabel(this, controlsOriginRight + controlIndex++ *MyGuiConstants.CONTROLS_DELTA + new Vector2(fovSliderSize * 1.1f, 0),
                                                       null, new StringBuilder("{0:F1}"), MyGuiConstants.LABEL_TEXT_COLOR,
                                                       MyGuiConstants.LABEL_TEXT_SCALE_OPTIONS, MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER, MyGuiManager.GetFontMinerWarsBlue());
            Controls.Add(m_fieldOfViewLabel);

            m_fieldOfViewDefaultLabel = new MyGuiControlLabel(this, controlsOriginRight + controlIndex++ *MyGuiConstants.CONTROLS_DELTA + new Vector2(0.009f, 0),
                                                              null, MyTextsWrapper.Get(MyTextsWrapperEnum.DefaultFOV), MyGuiConstants.LABEL_TEXT_COLOR,
                                                              MyGuiConstants.LABEL_TEXT_SCALE_OPTIONS, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM, MyGuiManager.GetFontMinerWarsBlue());
            m_fieldOfViewDefaultLabel.UpdateParams(MathHelper.ToDegrees(MyConstants.FIELD_OF_VIEW_CONFIG_DEFAULT));
            Controls.Add(m_fieldOfViewDefaultLabel);

            //MyGuiManager.GetFontMinerWarsBlue()
            //  Brightness
            //Controls.Add(new MyGuiControlLabel(this, controlsOriginLeft + 8 * MyGuiConstants.CONTROLS_DELTA, null, MyTextsWrapperEnum.Brightness, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE_OPTIONS, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER));

            //  Contrast
            //Controls.Add(new MyGuiControlLabel(this, controlsOriginLeft + 9 * MyGuiConstants.CONTROLS_DELTA, null, MyTextsWrapperEnum.Contrast, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE_OPTIONS, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER));
            //m_contrastTextbox = new MyGuiControlTextbox(this, controlsOriginRight + 9 * MyGuiConstants.CONTROLS_DELTA + new Vector2(MyGuiConstants.TEXTBOX_WIDTH / 2.0f, 0), MyGuiConstants.TEXTBOX_WIDTH, "Opicka©123456", 20, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE_OPTIONS, MyGuiControlTextboxType.NORMAL);
            //Controls.Add(m_contrastTextbox);

            //  Buttons APPLY and BACK


            var m_okButton = new MyGuiControlButton(this, new Vector2(-0.1379f, 0.2269f), MyGuiConstants.OK_BUTTON_SIZE,
                                                    MyGuiConstants.BUTTON_BACKGROUND_COLOR,
                                                    MyGuiManager.GetInventoryScreenButtonTexture(), null, null, MyTextsWrapperEnum.Ok,
                                                    MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, MyGuiControlButtonTextAlignment.CENTERED, OnApplyClick,
                                                    true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true, true);

            Controls.Add(m_okButton);
            //Controls.Add(new MyGuiControlButton(this, new Vector2(-buttonDelta.X, buttonDelta.Y), MyGuiConstants.MESSAGE_BOX_BUTTON_SIZE, MyGuiConstants.BUTTON_BACKGROUND_COLOR,
            //   MyTextsWrapperEnum.Apply, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, OnApplyClick, MyGuiControlButtonTextAlignment.CENTERED, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true));
            //Controls.Add(new MyGuiControlButton(this, new Vector2(+buttonDelta.X, buttonDelta.Y), MyGuiConstants.MESSAGE_BOX_BUTTON_SIZE, MyGuiConstants.BUTTON_BACKGROUND_COLOR,
            //   MyTextsWrapperEnum.Back, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, OnBackClick, MyGuiControlButtonTextAlignment.CENTERED, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true));

            var m_cancelButton = new MyGuiControlButton(this, new Vector2(0.1428f, 0.2269f), MyGuiConstants.OK_BUTTON_SIZE,
                                                        MyGuiConstants.BUTTON_BACKGROUND_COLOR,
                                                        MyGuiManager.GetInventoryScreenButtonTexture(), null, null, MyTextsWrapperEnum.Back,
                                                        MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, MyGuiControlButtonTextAlignment.CENTERED, OnBackClick,
                                                        true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true, true);

            Controls.Add(m_cancelButton);

            //  Update controls with values from config file
            UpdateFromConfig();
            UpdateControls(m_settingsOld);

            //  Update OLD settings
            UpdateSettings(m_settingsOld);
            UpdateSettings(m_settingsNew);

            MyMwcLog.WriteLine("MyGuiScreenOptionsVideo.ctor END");
        }