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.º 2
0
    /// <summary>
    /// Draws the buttons in the main menu or pause menu. Also draws the Keen Software House logo and controllor hints.
    /// </summary>
    /// <param name="constructor"></param>
    public override void RecreateControls(bool constructor)
    {
        base.RecreateControls(constructor);
        m_elementGroup = new MyGuiControlElementGroup();
        Vector2 minSizeGui = MyGuiControlButton.GetVisualStyle(MyGuiControlButtonStyleEnum.Default).NormalTexture.MinSizeGui;
        Vector2 leftButtonPositionOrigin = MyGuiManager.ComputeFullscreenGuiCoordinate(MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM) + new Vector2(minSizeGui.X / 2f, 0f) + new Vector2(15f, 0f) / MyGuiConstants.GUI_OPTIMAL_SIZE;

        leftButtonPositionOrigin.Y += 0.043f;
        _ = MyGuiManager.ComputeFullscreenGuiCoordinate(MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM) + new Vector2((0f - minSizeGui.X) / 2f, 0f);
        Vector2 lastButtonPosition = Vector2.Zero;

        if (MyGuiScreenGamePlay.Static == null)
        {
            CreateMainMenu(leftButtonPositionOrigin, out lastButtonPosition);
        }
        else
        {
            CreateInGameMenu(leftButtonPositionOrigin, out lastButtonPosition);
        }
        //Draws the controllor hints under the buttons.
        MyGuiControlLabel myGuiControlLabel = new MyGuiControlLabel(lastButtonPosition + new Vector2((0f - minSizeGui.X) / 2f, minSizeGui.Y / 2f));

        myGuiControlLabel.Name = MyGuiScreenBase.GAMEPAD_HELP_LABEL_NAME;
        Controls.Add(myGuiControlLabel);
        //Draws the Keen Software House Logo in the top righthand corner.
        MyGuiControlPanel myGuiControlPanel = new MyGuiControlPanel(MyGuiManager.ComputeFullscreenGuiCoordinate(MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP, 49, 82), MyGuiConstants.TEXTURE_KEEN_LOGO.MinSizeGui, null, null, null, MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP);

        myGuiControlPanel.BackgroundTexture = MyGuiConstants.TEXTURE_KEEN_LOGO;
        Controls.Add(myGuiControlPanel);
        //Refreshes the badges under the game logo.
        m_myBadgeHelper.RefreshGameLogo();
        //Creates the news and Dlc banners on the right of the screen.
        CreateRightSection(minSizeGui);
        CheckLowMemSwitchToLow();
        if (MyGuiScreenGamePlay.Static == null && !MyPlatformGameSettings.FEEDBACK_ON_EXIT && !string.IsNullOrEmpty(MyPlatformGameSettings.FEEDBACK_URL))
        {
            MyGuiSandbox.OpenUrl(MyPlatformGameSettings.FEEDBACK_URL, UrlOpenMode.ExternalWithConfirm, MyTexts.Get(MyCommonTexts.MessageBoxTextBetaFeedback), MyTexts.Get(MyCommonTexts.MessageBoxCaptionBetaFeedback));
        }
    }
Ejemplo n.º 3
0
        internal static void DrawDebugEnvironmentRenderTargets()
        {
            BlendState.Opaque.Apply();

            int cubeSize = GetRenderTargetCube(MyRenderTargets.EnvironmentCube).GetLevelDescription(0).Width;

            cubeSize = 128;

            MyMwcVector2Int delta = new MyMwcVector2Int((int)(MyCamera.Viewport.Height * 0.07f), (int)(MyCamera.Viewport.Height * 0.015f));
            MyMwcVector2Int size  = new MyMwcVector2Int(cubeSize, cubeSize);

            int heightOffset = size.Y + delta.Y;

            for (int i = 0; i < 6; i++)
            {
                //var back = MyTextureManager.GetTexture<MyTextureCube>("Textures\\BackgroundCube\\Final\\TestCube", null, MinerWars.AppCode.Game.Managers.LoadingMode.Immediate);
                MyGuiManager.DrawSpriteFast(GetRenderTargetCube(MyRenderTargets.EnvironmentCube), (CubeMapFace)i, delta.X + size.X * i, delta.Y, size.X, size.Y, Color.White);
                MyGuiManager.DrawSpriteFast(GetRenderTargetCube(MyRenderTargets.EnvironmentCubeAux), (CubeMapFace)i, delta.X + size.X * i, delta.Y + heightOffset, size.X, size.Y, Color.White);
                MyGuiManager.DrawSpriteFast(GetRenderTargetCube(MyRenderTargets.AmbientCube), (CubeMapFace)i, delta.X + size.X * i, delta.Y + heightOffset * 2, size.X, size.Y, Color.White);
                MyGuiManager.DrawSpriteFast(GetRenderTargetCube(MyRenderTargets.AmbientCubeAux), (CubeMapFace)i, delta.X + size.X * i, delta.Y + heightOffset * 3, size.X, size.Y, Color.White);
            }
        }
Ejemplo n.º 4
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);
        }
        private bool SaveChangesToInventory()
        {
            float?priceCoeficient = MyValueFormatter.GetFloatFromString(m_priceCoeficientTextbox.Text, 2, string.Empty);

            if (priceCoeficient == null)
            {
                MyGuiManager.AddScreen(new MyGuiScreenMessageBox(MyMessageBoxType.ERROR, MyTextsWrapperEnum.MessageYouMustSetPriceCoeficient, MyTextsWrapperEnum.Error, MyTextsWrapperEnum.Ok, null));
                return(false);
            }
            if (priceCoeficient < 1f)
            {
                MyGuiManager.AddScreen(new MyGuiScreenMessageBox(MyMessageBoxType.ERROR, MyTextsWrapperEnum.MessagePriceCoeficientMustBeGreaterThanOrEqualToOne, MyTextsWrapperEnum.Error, MyTextsWrapperEnum.Ok, null));
                return(false);
            }

            MyMwcInventoryTemplateTypeEnum?templateType = SelectedTemplateType;

            int?refillTime = RefillTime;

            if (refillTime != null && templateType == null || refillTime == null && templateType != null)
            {
                MyGuiManager.AddScreen(new MyGuiScreenMessageBox(MyMessageBoxType.ERROR, MyTextsWrapperEnum.MessageYouMustSetTemplateIfYouWantRefillInventory, MyTextsWrapperEnum.Error, MyTextsWrapperEnum.Ok, null));
                return(false);
            }

            EntityWithInventory.Inventory.PriceCoeficient = priceCoeficient.Value;
            EntityWithInventory.Inventory.ClearInventoryItems(false);
            foreach (int itemKey in m_entityInventoryListbox.GetItemsKeys())
            {
                EntityWithInventory.Inventory.AddInventoryItem(m_inventoryItemsRepository.GetItem(itemKey));
                //m_inventoryItemsRepository.RemoveItem(itemKey, false);
            }
            EntityWithInventory.Inventory.TemplateType = templateType;
            if (PrefabContainer != null)
            {
                PrefabContainer.RefillTime = refillTime;
            }
            return(true);
        }
Ejemplo n.º 6
0
        private void DrawAppVersion()
        {
            Vector2 size;
            Vector2 textRightBottomPosition = MyGuiManager.ComputeFullscreenGuiCoordinate(MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM);
            textRightBottomPosition.Y -= 1 * TEXT_LINE_HEIGHT;

            if (MyFinalBuildConstants.IS_OFFICIAL)
            {
                if (MySteam.BranchName != null)
                {
                    BranchName.Clear();
                    BranchName.Append(" ");
                    BranchName.Append(MySteam.BranchName);

                    size = MyGuiManager.MeasureString(MyFontEnum.BuildInfoHighlight, BranchName, MyGuiConstants.APP_VERSION_TEXT_SCALE);
                    MyGuiManager.DrawString(MyFontEnum.BuildInfoHighlight, BranchName, textRightBottomPosition, MyGuiConstants.APP_VERSION_TEXT_SCALE,
                        new Color(MyGuiConstants.LABEL_TEXT_COLOR * m_transitionAlpha), MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM);

                    textRightBottomPosition.X -= size.X;
                }
            }
            else
            {
                size = MyGuiManager.MeasureString(MyFontEnum.BuildInfoHighlight, NON_OFFICIAL, MyGuiConstants.APP_VERSION_TEXT_SCALE);
                MyGuiManager.DrawString(MyFontEnum.BuildInfoHighlight, NON_OFFICIAL, textRightBottomPosition, MyGuiConstants.APP_VERSION_TEXT_SCALE,
                    new Color(MyGuiConstants.LABEL_TEXT_COLOR * m_transitionAlpha), MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM);

                textRightBottomPosition.X -= size.X;
            }

            size = MyGuiManager.MeasureString(MyFontEnum.BuildInfo, PLATFORM, MyGuiConstants.APP_VERSION_TEXT_SCALE);
            MyGuiManager.DrawString(MyFontEnum.BuildInfo, PLATFORM, textRightBottomPosition, MyGuiConstants.APP_VERSION_TEXT_SCALE,
                new Color(MyGuiConstants.LABEL_TEXT_COLOR * m_transitionAlpha), MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM);

            textRightBottomPosition.X -= size.X;
            
            MyGuiManager.DrawString(MyFontEnum.BuildInfo, APP_VERSION, textRightBottomPosition, MyGuiConstants.APP_VERSION_TEXT_SCALE,
                new Color(MyGuiConstants.LABEL_TEXT_COLOR * m_transitionAlpha), MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM);
        }
Ejemplo n.º 7
0
        public static void DrawSelectedObjectHighlight(string atlasTexture, MyAtlasTextureCoordinate textureCoord, MyHudSelectedObject selection)
        {
            var rect = MyGuiManager.GetSafeFullscreenRectangle();

            Vector2 hudSize = new Vector2(rect.Width, rect.Height);

            var          worldViewProj   = selection.InteractiveObject.ActivationMatrix * MySector.MainCamera.ViewMatrix * (MatrixD)MySector.MainCamera.ProjectionMatrix;
            BoundingBoxD screenSpaceAabb = new BoundingBoxD(-Vector3D.One / 2, Vector3D.One / 2).Transform(worldViewProj);
            var          min             = new Vector2((float)screenSpaceAabb.Min.X, (float)screenSpaceAabb.Min.Y);
            var          max             = new Vector2((float)screenSpaceAabb.Max.X, (float)screenSpaceAabb.Max.Y);

            var minToMax = min - max;

            min = min * 0.5f + 0.5f * Vector2.One;
            max = max * 0.5f + 0.5f * Vector2.One;

            min.Y = 1 - min.Y;
            max.Y = 1 - max.Y;

            float textureScale = (float)Math.Pow(Math.Abs(minToMax.X), 0.35f) * 2.5f;

            if (selection.InteractiveObject.ShowOverlay)
            {
                BoundingBoxD one   = new BoundingBoxD(new Vector3(-0.5f, -0.5f, -0.5f), new Vector3(0.5f, 0.5f, 0.5f));
                Color        color = Color.Gold;
                color *= 0.2f;
                var m            = selection.InteractiveObject.ActivationMatrix;
                var localToWorld = MatrixD.Invert(selection.InteractiveObject.WorldMatrix);
                //MySimpleObjectDraw.DrawTransparentBox(ref m, ref one, ref color, MySimpleObjectRasterizer.Solid, 0, 0.05f, "Square", null, true);

                MySimpleObjectDraw.DrawAttachedTransparentBox(ref m, ref one, ref color, selection.InteractiveObject.RenderObjectID,
                                                              ref localToWorld, MySimpleObjectRasterizer.Solid, 0, 0.05f, "Square", null, true);
            }

            DrawSelectionCorner(atlasTexture, selection, textureCoord, hudSize, min, -Vector2.UnitY, textureScale);
            DrawSelectionCorner(atlasTexture, selection, textureCoord, hudSize, new Vector2(min.X, max.Y), Vector2.UnitX, textureScale);
            DrawSelectionCorner(atlasTexture, selection, textureCoord, hudSize, new Vector2(max.X, min.Y), -Vector2.UnitX, textureScale);
            DrawSelectionCorner(atlasTexture, selection, textureCoord, hudSize, max, Vector2.UnitY, textureScale);
        }
Ejemplo n.º 8
0
        protected override void OnError(Exception exception, MySectorServiceClient client)
        {
            MyMwcLog.WriteLine(exception); // log exception

            if (EnableRetry)
            {
                ShowRetryDialog(exception);
            }
            else
            {
                RaiseActionFailed(exception);
                if (ShowErrorMessage)
                {
                    MyGuiManager.AddScreen(new MyGuiScreenMessageBox(MyMessageBoxType.ERROR, ErrorMessageText, ErrorCaptionText, MyTextsWrapperEnum.Ok, null));
                }
                CloseScreen();
                if (OnErrorReturnToMainMenu)
                {
                    MyGuiManager.BackToMainMenu();
                }
            }
        }
        protected void DrawBuildingStepsCount(Vector3I?startBuild, Vector3I?startRemove, Vector3I?continueBuild, ref Matrix localMatrixAdd)
        {
            var startPosition = startBuild ?? startRemove;

            if (startPosition != null && continueBuild != null)
            {
                Vector3I rotatedSize;
                Vector3I.TransformNormal(ref CurrentBlockDefinition.Size, ref localMatrixAdd, out rotatedSize);
                rotatedSize = Vector3I.Abs(rotatedSize);

                int      stepCount;
                Vector3I stepDelta;
                Vector3I counter;

                ComputeSteps(startPosition.Value, continueBuild.Value, startBuild.HasValue ? rotatedSize : Vector3I.One, out stepDelta, out counter, out stepCount);
                m_cubeCountStringBuilder.Clear();
                m_cubeCountStringBuilder.Append("  ");
                m_cubeCountStringBuilder.AppendInt32(stepCount);

                MyGuiManager.DrawString(MyFontEnum.White, m_cubeCountStringBuilder, new Vector2(0.5f, 0.5f), 1.5f);
            }
        }
Ejemplo n.º 10
0
 private static void CheckErrors(StringBuilder errors, MyGuiScreenEditorSaveProgress screen)
 {
     if (errors != null)
     {
         var caption = new StringBuilder("Please check missing entities (full list in log). Really save?");
         MyGuiManager.AddScreen(new MyGuiScreenMessageBox(MyMessageBoxType.MESSAGE, errors, caption, MyTextsWrapperEnum.Yes, MyTextsWrapperEnum.No, (result) =>
         {
             if (result == MyGuiScreenMessageBoxCallbackEnum.YES)
             {
                 MyGuiManager.AddScreen(screen);
             }
             else
             {
                 screen.CloseScreenNow();
             }
         }));
     }
     else
     {
         MyGuiManager.AddScreen(screen);
     }
 }
Ejemplo n.º 11
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;
        }
        public override bool Draw(float backgroundFadeAlpha)
        {
            Rectangle backgroundRectangle;

            MyGuiManager.GetSafeAspectRatioFullScreenPictureSize(MyGuiConstants.LOADING_BACKGROUND_TEXTURE_REAL_SIZE, out backgroundRectangle);

            backgroundRectangle.Inflate(-(int)(backgroundRectangle.Width * (1 - m_scale) / 2), -((int)(backgroundRectangle.Height * (1 - m_scale) / 2)));
            MyGuiManager.DrawSpriteBatch(m_texture, backgroundRectangle, new Color(new Vector4(1, 1, 1, m_transitionAlpha)));



            m_warningText1.Draw();
            m_warningText2.Draw();
            m_warningText3.Draw();
            m_warningText4.Draw();
            m_warningText5.Draw();
            m_warningText6.Draw();

            m_button.Draw();

            return(true);
        }
        protected override void LoadControls()
        {
            base.LoadControls();

            var pos = GetNextControlPosition() - MyGuiConstants.CONTROLS_DELTA + new Vector2(0.07f, -0.02f);

            /*
             * Controls.Add(m_acquireControl = new MyGuiControlButton(this, pos , new Vector2(MyGuiConstants.MESSAGE_BOX_BUTTON_SIZE.X * 2f, MyGuiConstants.MESSAGE_BOX_BUTTON_SIZE.Y), MyGuiConstants.BUTTON_BACKGROUND_COLOR,
             *  MyTextsWrapperEnum.AcquireControl, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, OnAcquireControlClick, MyGuiControlButtonTextAlignment.CENTERED, true, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, true));
             */

            m_acquireControl = new MyGuiControlButton(this, pos, new Vector2(0.14f, 0.051f),
                                                      MyGuiConstants.BUTTON_BACKGROUND_COLOR,
                                                      MyGuiManager.GetConfirmButton(), null, null, MyTextsWrapperEnum.AcquireControl,
                                                      MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE_SMALLER, MyGuiControlButtonTextAlignment.CENTERED, OnAcquireControlClick,
                                                      true, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, true, true);
            m_acquireControl.Enabled = m_entity.Enabled;
            Controls.Add(m_acquireControl);
            m_acquireControl.DrawRedTextureWhenDisabled = false;

            UpdateAcquireState();
        }
Ejemplo n.º 14
0
        protected override void OnOkClick(MyGuiControlButton sender)
        {
            SaveTempEditProperties();

            m_errorMessages.Clear();
            m_errorMessage.Clear();
            if (!Validate(ref m_errorMessages))
            {
                foreach (StringBuilder errorMessage in m_errorMessages)
                {
                    MyMwcUtils.AppendStringBuilder(m_errorMessage, errorMessage);
                    m_errorMessage.AppendLine();
                }
                StringBuilder caption = MyTextsWrapper.Get(m_errorMessages.Count > 1 ? MyTextsWrapperEnum.CaptionPropertiesAreNotValid : MyTextsWrapperEnum.CaptionPropertyIsNotValid);
                MyGuiManager.AddScreen(new MyGuiScreenMessageBox(MyMessageBoxType.ERROR, m_errorMessage, caption, MyTextsWrapperEnum.Ok, null));
                return;
            }

            Save();

            base.OnOkClick(sender);
        }
Ejemplo n.º 15
0
        public override void Draw(float transitionAlpha, float backgroundTransitionAlpha)
        {
            var topLeft = GetPositionAbsoluteTopLeft();

            m_styleDef.Texture.Draw(topLeft, Size,
                                    ApplyColorMaskModifiers(ColorMask, Enabled, backgroundTransitionAlpha));

            var scissor = m_itemsRectangle;

            scissor.Position += topLeft;
            using (MyGuiManager.UsingScissorRectangle(ref scissor))
            {
                base.Draw(transitionAlpha, backgroundTransitionAlpha);
            }

            if (m_showScrollbar)
            {
                m_scrollBar.Draw(ApplyColorMaskModifiers(ColorMask, Enabled, transitionAlpha));
            }

            //DebugDraw();
        }
        private void DrawLabels(float transitionAlpha)
        {
            var padding    = m_styleDef.ItemPadding;
            var normalFont = m_styleDef.ItemFontNormal;

            for (int row = 0; row < RowsCount; ++row)
            {
                for (int col = 0; col < ColumnsCount; ++col)
                {
                    int idx  = ComputeIndex(row, col);
                    var item = TryGetItemAt(idx);
                    if (item != null && Labels.IsValidIndex(idx))
                    {
                        var label = Labels[idx];
                        textBuilder.Clear();
                        textBuilder.Append(label);

                        var drawPosition = m_itemsRectangle.Position + m_itemStep * new Vector2((float)col, (float)row);

                        drawPosition.X += m_itemStep.X + padding.MarginStep.X;
                        drawPosition.Y += m_itemStep.Y * 0.5f;

                        bool enabled = this.Enabled && item.Enabled;

                        var maxLabelWidth = Math.Abs(Size.X - drawPosition.X);

                        MyGuiManager.DrawString(
                            font: normalFont,
                            text: textBuilder,
                            normalizedCoord: drawPosition,
                            scale: TextScale,
                            colorMask: ApplyColorMaskModifiers(item.IconColorMask, Enabled, transitionAlpha),
                            drawAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER,
                            maxTextWidth: maxLabelWidth);
                    }
                }
            }
        }
        public override void Draw()
        {
            base.Draw();

            if (MyDebugDrawSettings.DEBUG_DRAW_VOICE_CHAT && MyFakes.ENABLE_VOICE_CHAT_DEBUGGING)
            {
                DebugDraw();
            }

            foreach (var pair in m_receivedVoiceData)
            {
                if (pair.Value.SpeakerTimestamp != MyTimeSpan.Zero)
                {
                    var player = Sync.Players.GetPlayerById(new MyPlayer.PlayerId(pair.Key, 0));
                    if (player.Character != null)
                    {
                        var position = player.Character.PositionComp.GetPosition() + player.Character.PositionComp.LocalAABB.Height * player.Character.PositionComp.WorldMatrix.Up + player.Character.PositionComp.WorldMatrix.Up * 0.2f;
                        var color    = Color.White;
//                        MyTransparentGeometry.AddPointBillboard(Sandbox.Graphics.GUI.MyGuiConstants.TEXTURE_VOICE_CHAT, color, position, 0.25f, 0, 0, true);

                        VRage.Utils.MyGuiDrawAlignEnum align = VRage.Utils.MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_BOTTOM;
                        var bg            = Sandbox.Graphics.GUI.MyGuiConstants.TEXTURE_VOICE_CHAT;
                        var worldViewProj = MySector.MainCamera.ViewMatrix * (MatrixD)MySector.MainCamera.ProjectionMatrix;
                        var v3t           = Vector3D.Transform(position, worldViewProj);
                        var basePos       = new Vector2((float)v3t.X, (float)v3t.Y);
                        basePos   = basePos * 0.5f + 0.5f * Vector2.One;
                        basePos.Y = 1 - basePos.Y;
                        var bgPos = Sandbox.Game.Gui.MyGuiScreenHudSpace.ConvertHudToNormalizedGuiPosition(ref basePos);
                        MyGuiManager.DrawSpriteBatch(
                            bg.Texture,
                            bgPos,
                            bg.SizeGui * 0.5f,
                            color,
                            align);
                    }
                }
            }
        }
Ejemplo n.º 18
0
        public MyGuiIngameScriptsPage(Action <string> onScriptOpened, Func <string> getCodeFromEditor, Action close) :
            base(new Vector2(MyGuiManager.GetMaxMouseCoord().X - SCREEN_SIZE.X * 0.5f + HIDDEN_PART_RIGHT, 0.5f), SCREEN_SIZE, MyGuiConstants.SCREEN_BACKGROUND_COLOR, false)
        {
            EnabledBackgroundFade = true;
            OnClose = close;
            this.GetCodeFromEditor = getCodeFromEditor;
            this.OnScriptOpened    = onScriptOpened;
            m_localScriptFolder    = Path.Combine(MyFileSystem.UserDataPath, SCRIPTS_DIRECTORY, "local");
            m_workshopFolder       = Path.Combine(MyFileSystem.UserDataPath, SCRIPTS_DIRECTORY, "workshop");

            if (!Directory.Exists(m_localScriptFolder))
            {
                Directory.CreateDirectory(m_localScriptFolder);
            }

            if (!Directory.Exists(m_workshopFolder))
            {
                Directory.CreateDirectory(m_workshopFolder);
            }

            m_scriptList.Items.Clear();

            GetLocalScriptNames(m_subscribedItemsList.Count == 0);
            RecreateControls(true);

            m_scriptList.ItemsSelected     += OnSelectItem;
            m_scriptList.ItemDoubleClicked += OnItemDoubleClick;
            OnEnterCallback += Ok;

            m_canShareInput = false;
            CanBeHidden     = true;
            CanHideOthers   = false;
            m_canCloseInCloseAllScreenCalls = true;
            m_isTopScreen     = false;
            m_isTopMostScreen = false;

            m_searchBox.TextChanged += OnSearchTextChange;
        }
Ejemplo n.º 19
0
        protected void DrawGuiIndicators()
        {
            if (MyHud.MinimalHud)
            {
                return;
            }

            if (MyGuiScreenGamePlay.ActiveGameplayScreen != null)
            {
                return;
            }

            if (IsCubeSizeModesAvailable)
            {
                StringBuilder sb = new StringBuilder();
                sb.AppendFormat(MyTexts.GetString(MySpaceTexts.CubeBuilder_CubeSizeModeChange), MyGuiSandbox.GetKeyName(MyControlsSpace.CUBE_BUILDER_CUBESIZE_MODE));
                Vector2 coords2D = new Vector2(0.5f, 0.13f);
                MyGuiManager.DrawString(MyFontEnum.White, sb, coords2D, 1.0f, null, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER);

                coords2D = new Vector2(0.52f, 0.2f);
                float alphaValue         = CubeBuilderState.CubeSizeMode != MyCubeSize.Small ? 0.8f : 1.0f;
                Color premultipliedColor = new Color(alphaValue, alphaValue, alphaValue, alphaValue);
                MyRenderProxy.DrawSprite(MyGuiConstants.CB_SMALL_GRID_MODE, coords2D, Vector2.One, premultipliedColor, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, 0, Vector2.UnitX, 1.0f, null);

                coords2D           = new Vector2(0.48f, 0.2f);
                alphaValue         = CubeBuilderState.CubeSizeMode != MyCubeSize.Large ? 0.8f : 1.0f;
                premultipliedColor = new Color(alphaValue, alphaValue, alphaValue, alphaValue);
                MyRenderProxy.DrawSprite(MyGuiConstants.CB_LARGE_GRID_MODE, coords2D, Vector2.One, premultipliedColor, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, 0, Vector2.UnitX, 1.0f, null);
            }

            if (BuildInputValid)
            {
                Vector2 screenPos = new Vector2(0.5f, 0.1f);
                string  texture   = DynamicMode ? MyGuiConstants.CB_FREE_MODE_ICON : MyGuiConstants.CB_LCS_GRID_ICON;

                MyRenderProxy.DrawSprite(texture, screenPos, Vector2.One, Color.White, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, 0, Vector2.UnitX, 1.0f, null);
            }
        }
        override protected int GetCarriagePositionFromMouseCursor()
        {
            Vector2 mouseRelative = MyGuiManager.MouseCursorPosition - GetPositionAbsoluteTopLeft();

            mouseRelative.Y += this.ScrollbarValue;
            int closestIndex = 0;
            int currentLine  = 0;

            for (currentLine = 0; currentLine < m_lineInformation.Count; ++currentLine)
            {
                float lineMin = m_fontHeight * currentLine;
                if (mouseRelative.Y > lineMin && mouseRelative.Y < lineMin + m_fontHeight)
                {
                    int lenght = currentLine + 1 >= m_lineInformation.Count ? m_text.Length : m_lineInformation[currentLine + 1];
                    lenght -= m_lineInformation[currentLine];
                    int   startPos        = m_lineInformation[currentLine];
                    float closestDistance = float.MaxValue;
                    for (int j = 0; j < lenght; ++j)
                    {
                        m_tmpOffsetMeasure.Clear();
                        m_tmpOffsetMeasure.AppendSubstring(m_text, startPos, j + 1);
                        float   currentCharPos = MyGuiManager.MeasureString(Font, m_tmpOffsetMeasure, TextScaleWithLanguage).X;
                        Vector2 charPosition   = new Vector2(currentCharPos, mouseRelative.Y);
                        float   charDistance   = Vector2.Distance(charPosition, mouseRelative);
                        if (charDistance < closestDistance)
                        {
                            closestDistance = charDistance;
                            closestIndex    = startPos + j + 1;
                        }
                    }
                    break;
                }
            }

            m_currentCarriageColumn = GetCarriageColumn(closestIndex);
            m_currentCarriageLine   = currentLine + 1;
            return(closestIndex);
        }
Ejemplo n.º 21
0
        public void UpdateFace(Vector3 position, int faceIndex)
        {
            // SetRenderSetup();

            CubeMapFace face = (CubeMapFace)faceIndex;

            // New setup
            m_setup.CameraPosition   = position;
            m_setup.AspectRatio      = 1.0f;
            m_setup.Viewport         = new Viewport(0, 0, (int)m_environmentRT.GetLevelDescription(0).Width, (int)m_environmentRT.GetLevelDescription(0).Width);
            m_setup.ViewMatrix       = CreateViewMatrix(face, position);
            m_setup.Fov              = MathHelper.PiOver2;
            m_setup.ProjectionMatrix = Matrix.CreatePerspectiveFieldOfView(m_setup.Fov.Value, m_setup.AspectRatio.Value, NearClip, m_setup.LodTransitionBackgroundEnd.Value);
            m_setup.DepthToAlpha     = true;

            MyRender.GetRenderProfiler().StartProfilingBlock("Draw environmental maps");

            MyRender.PushRenderSetupAndApply(m_setup, ref m_backup);
            MyRender.Draw(false);

            MyRender.GetRenderProfiler().EndProfilingBlock();

            Surface cubeSurface = m_environmentRT.GetCubeMapSurface(face, 0);

            MyMinerGame.Static.GraphicsDevice.SetRenderTarget(0, cubeSurface);

            var screenEffect = MyRender.GetEffect(MyEffects.Screenshot) as MyEffectScreenshot;

            screenEffect.SetTechnique(MyEffectScreenshot.ScreenshotTechniqueEnum.Default);
            screenEffect.SetSourceTexture(m_fullSizeRT);
            screenEffect.SetScale(new Vector2(m_environmentRT.GetLevelDescription(0).Width / (float)m_fullSizeRT.GetLevelDescription(0).Width * 0.968f, 0.982f * m_environmentRT.GetLevelDescription(0).Width / (float)m_fullSizeRT.GetLevelDescription(0).Height));
            MyGuiManager.GetFullscreenQuad().Draw(screenEffect);
            screenEffect.SetScale(new Vector2(1, 1));

            cubeSurface.Dispose();

            MyRender.PopRenderSetupAndRevert(m_backup);
        }
        private void DrawInternal()
        {
            Color colorQuote = new Color(255, 255, 255, 250);     //  White

            colorQuote.A = (byte)(colorQuote.A * m_transitionAlpha);
            {
                //////////////////////////////////////////////////////////////////////
                //  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)));
                MyGuiManager.DrawSpriteBatch(MyGuiConstants.TEXTURE_BACKGROUND_FADE, backgroundRectangle, new Color(new Vector4(1f, 1f, 1f, m_transitionAlpha)));

                //  Game logo
                MyGuiSandbox.DrawGameLogo(m_transitionAlpha);
            }

            LastBackgroundTexture = m_backgroundScreenTexture;

            //  Loading Please Wait
            MyGuiManager.DrawString(m_fontId, MyTexts.Get(MyCommonTexts.LoadingPleaseWaitUppercase),
                                    MyGuiConstants.LOADING_PLEASE_WAIT_POSITION, MyGuiSandbox.GetDefaultTextScaleWithLanguage() * MyGuiConstants.LOADING_PLEASE_WAIT_SCALE, new Color(MyGuiConstants.LOADING_PLEASE_WAIT_COLOR * m_transitionAlpha),
                                    MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_BOTTOM);

            // Draw quote
            {
                var font = m_fontId;
                var controlBottomLeft = m_quoteTextControl.GetPositionAbsoluteBottomLeft();
                var textSize          = m_quoteTextControl.TextSize;
                var controlSize       = m_quoteTextControl.Size;
                var authorTopLeft     = controlBottomLeft + new Vector2((controlSize.X - textSize.X) * 0.5f + 0.025f, 0.025f);
                MyGuiManager.DrawString(font, m_authorWithDash, authorTopLeft, MyGuiSandbox.GetDefaultTextScaleWithLanguage());
                m_quoteTextControl.Draw(1, 1);
            }
        }
Ejemplo n.º 23
0
        private void ProcessBeforeDraw(out int visibleCount)
        {
            ClearTexts();

            visibleCount = 0;
            for (int i = MAX_PRIORITY; i >= 0; --i)
            {
                List <MyHudNotificationBase> notifications;
                m_notificationsByPriority.TryGetValue(i, out notifications);
                if (notifications == null)
                {
                    continue;
                }

                foreach (var notification in notifications)
                {
                    if (!IsDrawn(notification))
                    {
                        continue;
                    }

                    StringBuilder messageStringBuilder = m_textsPool.Allocate();
                    Debug.Assert(messageStringBuilder != null);

                    messageStringBuilder.Append(notification.GetText());

                    Vector2 textSize = MyGuiManager.MeasureString(notification.Font, messageStringBuilder, MyGuiSandbox.GetDefaultTextScaleWithLanguage());

                    m_textSizes.Add(textSize);
                    m_texts.Add(messageStringBuilder);
                    ++visibleCount;
                    if (visibleCount == MyNotificationConstants.MAX_DISPLAYED_NOTIFICATIONS_COUNT)
                    {
                        return;
                    }
                }
            }
        }
Ejemplo n.º 24
0
        public MyGuiBlueprintScreen(MyGridClipboard clipboard) :
            base(new Vector2(MyGuiManager.GetMaxMouseCoord().X - SCREEN_SIZE.X * 0.5f + HIDDEN_PART_RIGHT, 0.5f), SCREEN_SIZE, MyGuiConstants.SCREEN_BACKGROUND_COLOR, false)
        {
            if (!Directory.Exists(m_localBlueprintFolder))
            {
                Directory.CreateDirectory(m_localBlueprintFolder);
            }

            if (!Directory.Exists(m_workshopBlueprintFolder))
            {
                Directory.CreateDirectory(m_workshopBlueprintFolder);
            }
            m_blueprintList.Items.Clear();
            GetLocalBlueprintNames(m_downloadFromSteam);

            if (m_downloadFromSteam)
            {
                m_downloadFromSteam = false;
            }

            RecreateControls(true);

            m_blueprintList.ItemsSelected     += OnSelectItem;
            m_blueprintList.ItemDoubleClicked += OnItemDoubleClick;
            m_blueprintList.ItemMouseOver     += OnMouseOverItem;
            OnEnterCallback         += Ok;
            m_searchBox.TextChanged += OnSearchTextChange;

            if (clipboard != null)
            {
                m_clipboard = clipboard;
            }
            else
            {
                System.Diagnostics.Debug.Fail("Clipboard shouldn't be null!");
                m_clipboard = Sandbox.Game.Entities.MyCubeBuilder.Static.Clipboard;
            }
        }
Ejemplo n.º 25
0
        //  Update all screens
        public void Update(int totalTimeInMS)
        {
            VRageRender.MyRenderProxy.GetRenderProfiler().StartProfilingBlock("MyGuiSandbox::Update1");

            HandleRenderProfilerInput();
            VRageRender.MyRenderProxy.GetRenderProfiler().StartNextBlock("MyGuiSandbox::Update2");

            TotalGamePlayTimeInMilliseconds = totalTimeInMS;

            MyScreenManager.Update(totalTimeInMS);

            MyGuiScreenBase screenWithFocus = MyScreenManager.GetScreenWithFocus();

            bool gameFocused = (MySandboxGame.Static.IsActive == true
                                &&
                                ((Sandbox.AppCode.MyExternalAppBase.Static == null && MySandboxGame.Static.WindowHandle == GetForegroundWindow())
                                 ||
                                 (Sandbox.AppCode.MyExternalAppBase.Static != null && !Sandbox.AppCode.MyExternalAppBase.IsEditorActive))
                                );

            VRageRender.MyRenderProxy.GetRenderProfiler().StartNextBlock("MyGuiSandbox::Update3");
            //We have to know current focus screen because of centerize mouse
            MyInput.Static.Update(gameFocused);

            VRageRender.MyRenderProxy.GetRenderProfiler().StartNextBlock("MyGuiSandbox::Update4");
            MyGuiManager.Update(totalTimeInMS);
            MyGuiManager.MouseCursorPosition = MouseCursorPosition;


            MyGuiManager.Camera     = MySector.MainCamera != null ? MySector.MainCamera.WorldMatrix : VRageMath.MatrixD.Identity;
            MyGuiManager.CameraView = MySector.MainCamera != null ? MySector.MainCamera.ViewMatrix : VRageMath.MatrixD.Identity;
            MyGuiManager.TotalTimeInMilliseconds = MySandboxGame.TotalTimeInMilliseconds;

            //We should not need this call
            //EnableSoundsBasedOnWindowFocus();

            VRageRender.MyRenderProxy.GetRenderProfiler().EndProfilingBlock();
        }
Ejemplo n.º 26
0
        public static void DrawCrosshair(string atlas, MyAtlasTextureCoordinate textureCoord, MyHudCrosshair crosshair)
        {
            Vector2 rightVector = new Vector2(crosshair.UpVector.Y, crosshair.UpVector.X);

            float hudSizeX = MyGuiManager.GetSafeFullscreenRectangle().Width / MyGuiManager.GetHudSize().X;
            float hudSizeY = MyGuiManager.GetSafeFullscreenRectangle().Height / MyGuiManager.GetHudSize().Y;
            var   pos      = crosshair.Position;

            if (MyVideoSettingsManager.IsTripleHead())
            {
                pos.X += 1.0f;
            }

            VRageRender.MyRenderProxy.DrawSpriteAtlas(
                atlas,
                pos,
                textureCoord.Offset,
                textureCoord.Size,
                rightVector,
                new Vector2(hudSizeX, hudSizeY),
                crosshair.Color,
                crosshair.HalfSize);
        }
        public override void RecreateControls(bool contructor)
        {
            base.RecreateControls(contructor);
            Controls.Clear();

            if (!contructor)
            {
                m_entityUseControl.ClearAfterRemove();
            }
            m_entityUseControl = m_entity.GetGuiControl(this);
            m_entityUseControl.SetPosition(new Vector2(-0.013f, -0.27f));
            m_entityUseControl.ParentScreen = this;

            Controls.Add(m_entityUseControl);

            var exitButton = new MyGuiControlButton(this, new Vector2(0f, 0.3490f), new Vector2(0.161f, 0.0637f),
                                                    Vector4.One,
                                                    MyGuiManager.GetConfirmButton(), null, null, MyTextsWrapperEnum.Exit,
                                                    MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, MyGuiControlButtonTextAlignment.CENTERED, OnExitClick,
                                                    true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true, true);

            Controls.Add(exitButton);
        }
        private void OnVideoModeChangedAndComfirm(MinerWars.AppCode.Game.VideoMode.MyVideoModeManager.MyVideoModeChangeOperation result)
        {
            bool changed = MyVideoModeManager.EndChangeVideoMode(result);

            if (changed)
            {
                if (MyVideoModeManager.HasAnythingChanged(result))
                {
                    //udpate screen here
                    m_waitingForConfirmation = true;
                    MyGuiManager.AddScreen(new MyGuiScreenMessageBox(MyMessageBoxType.MESSAGE, MyTextsWrapperEnum.DoYouWantToKeepTheseSettingsXSecondsRemaining,
                                                                     MyTextsWrapperEnum.MessageBoxCaptionPleaseConfirm, MyTextsWrapperEnum.Yes, MyTextsWrapperEnum.No,
                                                                     OnMessageBoxCallback, MyGuiConstants.VIDEO_OPTIONS_CONFIRMATION_TIMEOUT_IN_MILISECONDS));
                }
            }
            else
            {
                MyGuiManager.AddScreen(new MyGuiScreenMessageBox(MyMessageBoxType.ERROR, MyTextsWrapperEnum.SorryButSelectedSettingsAreNotSupportedByYourHardware,
                                                                 MyTextsWrapperEnum.MessageBoxCaptionError, MyTextsWrapperEnum.Ok, null));

                m_doRevert = true;
            }
        }
        public override bool Draw(float backgroundFadeAlpha)
        {
            int deltaTime = MyMinerGame.TotalTimeInMilliseconds - m_drawingBlinkingTextLastTime;

            if (((m_drawingBlinkingTextStatus == true) && (deltaTime > m_blinkingIntervalVisible)) ||
                ((m_drawingBlinkingTextStatus == false) && (deltaTime > m_blinkingIntervalInvisible)))
            {
                m_drawingBlinkingTextStatus   = !m_drawingBlinkingTextStatus;
                m_drawingBlinkingTextLastTime = MyMinerGame.TotalTimeInMilliseconds;
            }

            if (m_drawingBlinkingTextStatus)
            {
                MyRectangle2D rec = MyGuiManager.DrawString(MyGuiManager.GetFontMinerWarsRed(), m_sbInfo,
                                                            m_normalizedCoord,
                                                            1f, Color.White,
                                                            MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER);
                MyGuiManager.DrawString(MyGuiManager.GetFontMinerWarsRed(), m_sbPressToHide,
                                        new Vector2(m_normalizedCoord.X, m_normalizedCoord.Y + rec.Size.Y),
                                        0.75f, Color.White, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER);
            }
            return(true);
        }
        public void OnSearchClick(MyGuiControlButton sender)
        {
            if (m_findPlayerName.Text.Length == 1)
            {
                MyGuiManager.AddScreen(new MyGuiScreenMessageBox(MyMessageBoxType.ERROR, MyTextsWrapperEnum.EnterAtLeastTwoCharacters, MyTextsWrapperEnum.MessageBoxCaptionError, MyTextsWrapperEnum.Ok, MsgBoxCallback));
                return;
            }

            MyConfig.LastFriendName = m_findPlayerName.Text ?? String.Empty;
            MyConfig.Save();

            var criterium = MyMwcSelectSectorRequestTypeEnum.FIND_BY_PLAYER_NAME_FULLTEXT;

            if (String.IsNullOrEmpty(m_findPlayerName.Text))
            {
                criterium = MyMwcSelectSectorRequestTypeEnum.RANDOM_FRIENDS;
            }

            MyGuiManager.AddScreen(new MyGuiScreenSelectSandboxProgress(criterium, MyTextsWrapperEnum.SelectSandboxInProgressPleaseWait,
                                                                        this, m_findPlayerName.Text, AddFriendSectorsResponse));

            //CloseScreen();
        }