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); } } }
private void DrawHeader(float transitionAlpha) { var topLeft = GetPositionAbsoluteTopLeft(); var position = topLeft + m_headerArea.Position; MyGuiManager.DrawSpriteBatch(m_styleDef.HeaderTextureHighlight, position, m_headerArea.Size, Color.White, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP); for (int i = 0; i < m_columnsMetaData.Count; ++i) { var meta = m_columnsMetaData[i]; var font = m_styleDef.HeaderFontNormal; if (m_mouseOverColumnIndex.HasValue && m_mouseOverColumnIndex.Value == i) { font = m_styleDef.HeaderFontHighlight; } var cellSize = new Vector2(meta.Width * m_rowsArea.Size.X, m_headerArea.Height); var textPos = MyUtils.GetCoordAlignedFromCenter(position + 0.5f * cellSize, cellSize, meta.HeaderTextAlign); MyGuiManager.DrawString(font, meta.Name, textPos, TextScaleWithLanguage, ApplyColorMaskModifiers(ColorMask, Enabled, transitionAlpha), meta.HeaderTextAlign, maxTextWidth: cellSize.X); position.X += meta.Width * m_headerArea.Width; } }
public virtual void DrawSpriteBatch(Vector2 normalizedCoord, Vector2 normalizedSize, Color color, MyGuiDrawAlignEnum drawAlign) { if (m_icon != null) { MyGuiManager.DrawSpriteBatch(m_icon, normalizedCoord, normalizedSize, color, drawAlign); } }
public override void Draw() { base.Draw(); //1.5 radian per second - not using MinerWars.GameTime, because its nort updated sometimes m_rotatingAngle = (System.Environment.TickCount / 1000f) * 1.5f; Vector2 rotatingSize = MyGuiManager.GetNormalizedSize(m_texture, m_wheelScale); Vector2 rotatingPosition = m_parent.GetPositionAbsolute() + m_position + new Vector2(rotatingSize.X / 2.0f, rotatingSize.Y / 2.0f); // Large wheel - shadow only MyGuiManager.DrawSpriteBatch(m_texture, rotatingPosition + MyGuiConstants.SHADOW_OFFSET, m_wheelScale, new Color(m_parent.GetTransitionAlpha() * (new Color(0, 0, 0, 80)).ToVector4()), MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, m_rotatingAngle, new Vector2(0.5f, 0.5f)); // Large wheel - wheel MyGuiManager.DrawSpriteBatch(m_texture, rotatingPosition, m_wheelScale, new Color(m_color * m_parent.GetTransitionAlpha()), MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, m_rotatingAngle, new Vector2(0.5f, 0.5f)); // Small wheel - without shadow const float SMALL_SCALE = 0.6f; Vector2 smallRotatingPosition = rotatingPosition - (rotatingSize * ((1 - SMALL_SCALE) / 2.0f)); MyGuiManager.DrawSpriteBatch(m_texture, smallRotatingPosition, SMALL_SCALE * m_wheelScale, new Color(m_color * m_parent.GetTransitionAlpha()), MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, -m_rotatingAngle * 1.1f, new Vector2(0.5f, 0.5f)); // Mini wheel - without shadow const float MINI_SCALE = SMALL_SCALE * 0.6f; MyGuiManager.DrawSpriteBatch(m_texture, rotatingPosition - (rotatingSize * ((1 - MINI_SCALE) / 2.0f)), MINI_SCALE * m_wheelScale, new Color(m_color * m_parent.GetTransitionAlpha()), MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, m_rotatingAngle * 1.2f, new Vector2(0.5f, 0.5f)); }
// WARNING: Lot of hard coded stuff. Logic was mostly copied from MyGuiScreenHudBase private void DrawShadow(Vector2 position) { Color color = new Color(0, 0, 0, (byte)(255 * 0.85f)); Vector2 shadowSize = m_size; if (m_size.X < SMALL_STRING_WIDTH) { ResizeXSmallText(ref shadowSize); shadowSize.Y *= 1.2f; position.Y += (shadowSize.Y - m_size.Y) * 1.5f; MyGuiManager.DrawSpriteBatch(MyGuiConstants.FOG_SMALL2, position, shadowSize, color, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, false); } else { ResizeXLargeText(ref shadowSize); shadowSize.Y = shadowSize.Y * 0.7f * 3.0f; float actualSizeDiff = shadowSize.X - m_size.X; if (actualSizeDiff > NO_OFFSET_THRESHOLD) { position.X -= actualSizeDiff - NO_OFFSET_THRESHOLD; } position.Y -= (shadowSize.Y - m_size.Y) / 7.5f; MyGuiManager.DrawSpriteBatch(MyGuiConstants.FOG_SMALL3, position, shadowSize, color, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, false); } }
public override bool Draw() { base.Draw(); if (m_selectedItem == -1) { return(true); } var selectedItem = m_items[m_selectedItem]; if (selectedItem is MyGuiControlItem) { m_itemsRect.Position = m_scrollPanel.GetPositionAbsoluteTopLeft(); using (MyGuiManager.UsingScissorRectangle(ref m_itemsRect)) { Vector2 position = selectedItem.GetPositionAbsoluteTopLeft(); string texture = MyGuiConstants.TEXTURE_HIGHLIGHT_DARK.Center.Texture; MyGuiManager.DrawSpriteBatch(texture, position, selectedItem.Size, Color.White, VRage.Utils.MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP); } // MyGuiManager.DrawBorders(selectedItem.GetPositionAbsoluteTopLeft(), selectedItem.Size, Color.Red, 2); } return(true); }
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); } }
// Returns true or false to let child implementation know if it has to run its own version of draw. public virtual bool Draw() { // This is just background of the screen rectangle if ((m_backgroundColor.HasValue) && (m_size.HasValue)) { // Background texture if (m_backgroundTexture == null) { if (m_size.HasValue) { // If this screen doesn't have custom texture, we will use one of the default - but with respect to screen's aspect ratio m_backgroundTexture = MyGuiManager.GetBackgroundTextureFilenameByAspectRatio(m_size.Value); } } MyGuiManager.DrawSpriteBatch(m_backgroundTexture, m_position, m_size.Value, ApplyTransitionAlpha(m_backgroundColor.Value), MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER); //if (MyFakes.DRAW_GUI_SCREEN_BORDERS && MyFinalBuildConstants.IS_DEBUG) //{ // MyGuiManager2.DrawBorders(GetPositionAbsoluteTopLeft(), m_size.Value, Color.White, 1); //} } DrawElements(m_transitionAlpha); DrawControls(m_transitionAlpha); return(true); }
private unsafe void DrawDisconnectedIndicator() { MyPlayer player; MyPlayer.PlayerId?savedPlayer = (base.Entity as MyCharacter).SavedPlayer; if (((savedPlayer != null) && (savedPlayer.Value.SerialId == 0)) && !MySession.Static.Players.TryGetPlayerById(savedPlayer.Value, out player)) { Vector3D vectord = (base.Entity.PositionComp.GetPosition() + (base.Entity.PositionComp.LocalAABB.Height * base.Entity.PositionComp.WorldMatrix.Up)) + (base.Entity.PositionComp.WorldMatrix.Up * 0.20000000298023224); double num = Vector3D.Distance(MySector.MainCamera.Position, vectord); if (num <= MAX_DISCONNECT_ICON_DISTANCE) { Color white = Color.White; Color *colorPtr1 = (Color *)ref white; colorPtr1.A = (byte)(white.A * ((float)Math.Min(1.0, Math.Max((double)0.0, (double)((MAX_DISCONNECT_ICON_DISTANCE - num) / 10.0))))); MyGuiDrawAlignEnum drawAlign = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_BOTTOM; MyGuiPaddedTexture texture = MyGuiConstants.TEXTURE_DISCONNECTED_PLAYER; Vector3D vectord2 = Vector3D.Transform(vectord, MySector.MainCamera.ViewMatrix * MySector.MainCamera.ProjectionMatrix); if (vectord2.Z < 1.0) { Vector2 hudPos = new Vector2((float)vectord2.X, (float)vectord2.Y); hudPos = (hudPos * 0.5f) + (0.5f * Vector2.One); Vector2 *vectorPtr1 = (Vector2 *)ref hudPos; vectorPtr1->Y = 1f - hudPos.Y; Vector2 normalizedCoord = MyGuiScreenHudBase.ConvertHudToNormalizedGuiPosition(ref hudPos); MyGuiManager.DrawSpriteBatch(texture.Texture, normalizedCoord, (texture.SizeGui * 0.5f) * (1f - (((float)num) / ((float)MAX_DISCONNECT_ICON_DISTANCE))), white, drawAlign, false, true); } } } }
private void DrawPerformanceWarning(int xPosition, int yPosition, MyGuiDrawAlignEnum alignment, string texturepath, float length, float width) { if (!Controls.Contains(m_warningLabel)) { Controls.Add(m_warningLabel); } if (m_warningNotifications.Count != 0) { Vector2 position = MyGuiManager.ComputeFullscreenGuiCoordinate(alignment, xPosition, yPosition); position -= new Vector2(length / 1.5f, 0f); MyGuiManager.DrawSpriteBatch(Path.GetFullPath(Path.Combine(MyFileSystem.UserDataPath, texturepath)), position, new Vector2(length / 1.5f, width / 1.5f), Color.White, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER); StringBuilder stringBuilder = new StringBuilder(); if (MyInput.Static.IsJoystickLastUsed) { stringBuilder.AppendFormat(MyCommonTexts.PerformanceWarningCombinationGamepad, MyControllerHelper.GetCodeForControl(MyControllerHelper.CX_BASE, MyControlsSpace.WARNING_SCREEN)); } else { stringBuilder.AppendFormat(MyCommonTexts.PerformanceWarningCombination, MyGuiSandbox.GetKeyName(MyControlsSpace.HELP_SCREEN)); } MyGuiManager.DrawString("White", MyTexts.GetString(m_warningNotifications[0]), position + new Vector2(0.09f, -0.011f), 0.7f, null, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER); MyGuiManager.DrawString("White", stringBuilder.ToString(), position + new Vector2(0.09f, 0.018f), 0.6f, null, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER); stringBuilder.Clear(); MyGuiManager.DrawString("White", stringBuilder.AppendFormat("({0})", m_warningNotifications.Count).ToString(), position + new Vector2(0.177f, -0.023f), 0.55f, null, MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER); m_warningNotifications.RemoveAt(0); } }
public override void Draw(float transitionAlpha) { var center = GetPositionAbsoluteCenter(); foreach (var separator in m_separators) { var color = ApplyColorMaskModifiers(ColorMask * separator.Color, Enabled, transitionAlpha); Vector2 leftTopInPixels = MyGuiManager.GetScreenCoordinateFromNormalizedCoordinate(GetPositionAbsoluteCenter() + separator.Start); Vector2 sizeInPixels = MyGuiManager.GetScreenSizeFromNormalizedSize(separator.Size); if (sizeInPixels.X == 0f) { sizeInPixels.X += 1; } else if (sizeInPixels.Y == 0f) { sizeInPixels.Y += 1; } MyGuiManager.DrawSpriteBatch(MyGuiConstants.BLANK_TEXTURE, (int)leftTopInPixels.X, (int)leftTopInPixels.Y, (int)sizeInPixels.X, (int)sizeInPixels.Y, color); } //base.Draw(); }
public override bool Draw(float backgroundFadeAlpha) { if (base.Draw(backgroundFadeAlpha) == false) { return(false); } if (m_videoPlayer != null) { m_videoPlayer.Update(); Texture texture = m_videoPlayer.OutputFrame; Vector4 color = m_colorMultiplier * m_transitionAlpha; Rectangle videoRect; MyGuiManager.GetSafeAspectRatioFullScreenPictureSize(new MyMwcVector2Int(texture.GetLevelDescription(0).Width, texture.GetLevelDescription(0).Height), out videoRect); MyGuiManager.DrawSpriteBatch(texture, videoRect, new Color(color)); if (m_subtitleToDraw != null) { MyGuiManager.DrawStringCentered(MyGuiManager.GetFontMinerWarsWhite(), m_subtitleToDraw, new Vector2(0.5f, 0.85f), 1.6f, Color.White, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_BOTTOM); } } return(true); }
/// <summary> /// Draws fog (eg. background for notifications) at specified position in normalized GUI coordinates. /// </summary> public static void DrawFog(ref Vector2 centerPosition, ref Vector2 textSize, float fogAlphaMultiplier = 1, MyGuiDrawAlignEnum alignment = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER) { Color color = new Color(0, 0, 0, (byte)(255 * 0.85f * fogAlphaMultiplier)); Vector2 fogFadeSize = textSize * new Vector2(1.4f, 3.0f); MyGuiManager.DrawSpriteBatch(MyGuiConstants.FOG_SMALL, centerPosition, fogFadeSize, color, alignment, MyVideoSettingsManager.IsTripleHead()); }
public virtual void Draw() { if (m_backgroundColor.HasValue) { MyTexture2D controlTexture = MyGuiManager.GetBlankTexture(); Vector4 backgroundColor = m_backgroundColor.Value; if (m_controlTexture != null) { controlTexture = m_controlTexture; if (m_mouseButtonPressed && m_pressedTexture != null) { controlTexture = m_pressedTexture; } else if (IsMouseOverOrKeyboardActive()) { if ((m_highlightType == MyGuiControlHighlightType.WHEN_ACTIVE) || (m_highlightType == MyGuiControlHighlightType.WHEN_CURSOR_OVER && IsMouseOver()) || (m_hasKeyboardActiveControl && m_canHandleKeyboardActiveControl)) { backgroundColor = m_backgroundColor.Value * MyGuiConstants.CONTROL_MOUSE_OVER_BACKGROUND_COLOR_MULTIPLIER; } } } if (!Enabled) { backgroundColor = m_backgroundColor.Value * MyGuiConstants.DISABLED_BUTTON_COLOR_VECTOR; } MyGuiManager.DrawSpriteBatch(controlTexture, m_parent.GetPositionAbsolute() + m_position, m_size.Value * m_scale, GetColorAfterTransitionAlpha(backgroundColor), MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER); } }
public override void Draw() { base.Draw(); MyGuiManager.EndSpriteBatch(); Vector2 normalizeSize = new Vector2(483 / 1600f, 112 / 1200f); //MyGuiManager.GetNormalizedCoordsAndPreserveOriginalSize(483, 112); 559? Vector2 stencilPos = GetParent().GetPositionAbsolute() - m_size.Value / 2f; Vector2 senctilSize = new Vector2(normalizeSize.X * m_value, normalizeSize.Y) + new Vector2(38 / 1600f, 0); //MyGuiManager.GetNormalizedCoordsAndPreserveOriginalSize(38, 0); Utils.MyRectangle2D stencilRect = new Utils.MyRectangle2D(stencilPos, senctilSize); MyGuiManager.DrawStencilMaskRectangle(stencilRect, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP); MyGuiManager.BeginSpriteBatch_StencilMask(); // draw progress bar MyGuiManager.DrawSpriteBatch(MyGuiManager.GetProgressBarTexture(), GetParent().GetPositionAbsolute(), m_size.Value, new Color(m_progressColor), MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER); MyGuiManager.EndSpriteBatch_StencilMask(); MyGuiManager.BeginSpriteBatch(); // draw progress value m_progressValueText.Clear(); float percentage = m_value * 100f; if (m_decimals > 0) { m_progressValueText.AppendDecimal(percentage, m_decimals); } else { m_progressValueText.AppendInt32((int)percentage); } m_progressValueText.Append(PERCENTAGE); MyGuiManager.DrawString(MyGuiManager.GetFontMinerWarsWhite(), m_progressValueText, GetParent().GetPositionAbsolute() - new Vector2(0f, m_size.Value.Y / 2f), m_textScale, new Color(m_textColor), MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER); }
public override void Draw(float transitionAlpha, float backgroundTransitionAlpha) { base.Draw(transitionAlpha, backgroundTransitionAlpha); Vector2 topLeft = Vector2.Zero; if (Icon.HasValue || (Text != null && Text.Length > 0)) { topLeft = GetPositionAbsoluteTopLeft(); } var internalTopLeft = topLeft + m_internalArea.Position; var internalSize = m_internalArea.Size; if (Icon.HasValue) { var iconPosition = MyUtils.GetCoordAlignedFromTopLeft(internalTopLeft, internalSize, IconOriginAlign); var icon = Icon.Value; var ratios = Vector2.Min(icon.SizeGui, internalSize) / icon.SizeGui; float scale = Math.Min(ratios.X, ratios.Y); MyGuiManager.DrawSpriteBatch( texture: (HasHighlight) ? icon.Highlight : icon.Normal, normalizedCoord: iconPosition, normalizedSize: icon.SizeGui * scale, color: ApplyColorMaskModifiers(ColorMask, Enabled, transitionAlpha), drawAlign: IconOriginAlign); } if (Text != null && Text.Length > 0) { Vector2 textPosition = MyUtils.GetCoordAlignedFromTopLeft(internalTopLeft, m_internalArea.Size, TextAlignment); var textFont = m_font; var textScale = MyGuiConstants.DEFAULT_TEXT_SCALE * MyGuiManager.LanguageTextScale; MyGuiManager.DrawString(textFont, Text, textPosition, textScale, ApplyColorMaskModifiers(Vector4.One, Enabled, transitionAlpha), TextAlignment); } }
public override bool Draw(float backgroundFadeAlpha) { if (base.Draw(backgroundFadeAlpha) == false) { return(false); } if (m_colorArea.Checked || m_particleEffect.Checked) { MyGuiManager.DrawSpriteBatch(MyGuiManager.GetBlankTexture(), GetPosition() + new Vector2(MyGuiConstants.SLIDER_WIDTH / 2 + 0.02f, 0) + m_redSlider.GetPosition(), MyGuiConstants.CHECKBOX_SIZE, new Color(m_redSlider.GetValue() / MyEditorConstants.COLOR_COMPONENT_MAX_VALUE, 0, 0), MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER); MyGuiManager.DrawSpriteBatch(MyGuiManager.GetBlankTexture(), GetPosition() + new Vector2(MyGuiConstants.SLIDER_WIDTH / 2 + 0.02f, 0) + m_greenSlider.GetPosition(), MyGuiConstants.CHECKBOX_SIZE, new Color(0, m_greenSlider.GetValue() / MyEditorConstants.COLOR_COMPONENT_MAX_VALUE, 0), MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER); MyGuiManager.DrawSpriteBatch(MyGuiManager.GetBlankTexture(), GetPosition() + new Vector2(MyGuiConstants.SLIDER_WIDTH / 2 + 0.02f, 0) + m_blueSlider.GetPosition(), MyGuiConstants.CHECKBOX_SIZE, new Color(0, 0, m_blueSlider.GetValue() / MyEditorConstants.COLOR_COMPONENT_MAX_VALUE), MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER); float height = MyGuiConstants.CHECKBOX_SIZE.Y + CONTROLS_DELTA.Y * 2; float width = MyGuiConstants.CHECKBOX_SIZE.X / MyGuiConstants.CHECKBOX_SIZE.Y * height; MyGuiManager.DrawSpriteBatch(MyGuiManager.GetBlankTexture(), GetPosition() + new Vector2(MyGuiConstants.SLIDER_WIDTH / 2 + 0.04f + width / 2, 0) + m_greenSlider.GetPosition(), new Vector2(width, height), new Color(m_redSlider.GetValue() / 255, m_greenSlider.GetValue() / 255, m_blueSlider.GetValue() / 255), MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER); } return(true); }
public void DrawDraged(Vector2 position, float transitionAlpha) { if ((m_icon != null) || Text != null) { if (m_icon != null) { string texture = m_icon; if (texture == null) { // texture is still being loaded on other thread DrawLoadingIcon(Vector4.One, GetIconPosition(), transitionAlpha); } else { MyGUIHelper.OutsideBorder(position + GetIconPosition(), m_iconSize, 2, MyGuiConstants.THEMED_GUI_LINE_COLOR); MyGuiManager.DrawSpriteBatch(m_icon, position + GetIconPosition(), m_iconSize, Color.White, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP); } } else if (Text != null) { var leftTop = position + GetTextPosition(); var size = MyGuiManager.MeasureString(MyFontEnum.Blue, Text, 0.8f); MyGUIHelper.OutsideBorder(leftTop, size, 2, MyGuiConstants.THEMED_GUI_LINE_COLOR); MyGUIHelper.FillRectangle(leftTop, size, TreeView.GetColor(MyGuiConstants.TREEVIEW_SELECTED_ITEM_COLOR, transitionAlpha)); Color textColor = TreeView.GetColor(MyGuiConstants.CONTROL_MOUSE_OVER_BACKGROUND_COLOR_MULTIPLIER, transitionAlpha); MyGuiManager.DrawString(MyFontEnum.Blue, Text, position + GetTextPosition(), 0.8f, textColor, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP); } } }
private static void OffsetInnerBorder(Vector2 normalizedPosition, Vector2 normalizedSize, int pixelWidth, int offset, Color color, bool top = true, bool bottom = true, bool left = true, bool right = true, Vector2?normalizedOffset = null) { Vector2 screenPosition = MyGuiManager.GetScreenCoordinateFromNormalizedCoordinate(normalizedPosition - (normalizedOffset.HasValue ? normalizedOffset.Value : Vector2.Zero)); var a = new Point((int)screenPosition.X - offset, (int)screenPosition.Y - offset); // for precission Vector2 screenPositionDownRight = MyGuiManager.GetScreenCoordinateFromNormalizedCoordinate(normalizedPosition + normalizedSize + (normalizedOffset.HasValue ? normalizedOffset.Value : Vector2.Zero)); var b = new Point((int)screenPositionDownRight.X + offset, (int)screenPositionDownRight.Y + offset); if (top) { MyGuiManager.DrawSpriteBatch(MyGuiManager.GetBlankTexture(), a.X, a.Y, b.X - a.X, pixelWidth, color); // Top } if (bottom) { MyGuiManager.DrawSpriteBatch(MyGuiManager.GetBlankTexture(), a.X, b.Y - pixelWidth, b.X - a.X, pixelWidth, color); // Bottom } if (left) { MyGuiManager.DrawSpriteBatch(MyGuiManager.GetBlankTexture(), a.X, a.Y + (top ? pixelWidth : 0), pixelWidth, b.Y - a.Y - (bottom ? pixelWidth : 0) - (top ? pixelWidth : 0), color); // Left } if (right) { MyGuiManager.DrawSpriteBatch(MyGuiManager.GetBlankTexture(), b.X - pixelWidth, a.Y + (top ? pixelWidth : 0), pixelWidth, b.Y - a.Y - (bottom ? pixelWidth : 0) - (top ? pixelWidth : 0), color); // Right } }
public override void Draw(float transitionAlpha, float backgroundTransitionAlpha) { //base.Draw(); if (IsActive()) { // draw item's background if (DrawBackgroundTexture) { MyGuiManager.DrawSpriteBatch(MyGuiConstants.BLANK_TEXTURE, MyGuiManager.MouseCursorPosition, Size, ApplyColorMaskModifiers(ColorMask * new Color(50, 66, 70, 255).ToVector4(), true, backgroundTransitionAlpha), MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER); } Vector2 itemPosition = MyGuiManager.MouseCursorPosition - Size / 2.0f; Vector2 textPosition = itemPosition + m_textOffset; textPosition.Y += (Size.Y / 2.0f); // draw item's icon if (m_supportIcon == true && m_draggingGridItem.Icon != null) { MyGuiManager.DrawSpriteBatch(m_draggingGridItem.Icon, itemPosition, Size, ApplyColorMaskModifiers(ColorMask, true, transitionAlpha), MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP); } ShowToolTip(); } }
public void Draw() { ClearTexts(); int visibleCount = Math.Min(m_notifications.Count, MyNotificationConstants.MAX_DISPLAYED_NOTIFICATIONS_COUNT); for (int i = 0; i < visibleCount; i++) { MyNotification actualNotification = m_notifications[i]; StringBuilder messageStringBuilder = m_textsPool.Allocate(); Debug.Assert(actualNotification != null); Debug.Assert(messageStringBuilder != null); bool hasConfirmation = actualNotification.HasDefaultDisappearMessage(); messageStringBuilder.Append(actualNotification.GetText()); if (hasConfirmation) { messageStringBuilder.AppendLine(); messageStringBuilder.ConcatFormat(m_defaultNotificationDisapearMessage, MyGuiManager.GetInput().GetGameControlTextEnum(MyGameControlEnums.NOTIFICATION_CONFIRMATION)); } // draw background: Vector2 textSize = MyGuiManager.GetNormalizedSize(m_usedFont, messageStringBuilder, actualNotification.GetScale()); m_textSizes.Add(textSize); m_texts.Add(messageStringBuilder); } MyGuiManager.BeginSpriteBatch(); var offset = new Vector2(VideoMode.MyVideoModeManager.IsTripleHead() ? -1 : 0, 0); // Draw fog Vector2 notificationPosition = Position; for (int i = 0; i < visibleCount; i++) { Vector2 fogFadeSize = m_textSizes[i] * new Vector2(1.6f, 8.0f); MyGuiManager.DrawSpriteBatch(MyGuiManager.GetFogSmallTexture(), notificationPosition + offset, fogFadeSize, m_fogColor, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, MyVideoModeManager.IsTripleHead()); notificationPosition.Y += m_textSizes[i].Y; } // Draw texts notificationPosition = Position; for (int i = 0; i < visibleCount; i++) { MyNotification actualNotification = m_notifications[i]; MyGuiManager.DrawString(actualNotification.GetFont(), m_texts[i], notificationPosition + offset, actualNotification.GetScale(), Color.White, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, MyVideoModeManager.IsTripleHead()); notificationPosition.Y += m_textSizes[i].Y; } MyGuiManager.EndSpriteBatch(); }
public override void Draw() { Vector4?oldBackgroundColor = m_backgroundColor; if (m_highlight == true) { if (m_backgroundColor != null) { m_backgroundColor = m_backgroundColor.Value * MyGuiConstants.CONTROL_MOUSE_OVER_BACKGROUND_COLOR_MULTIPLIER; } } base.Draw(); m_backgroundColor = oldBackgroundColor; if (m_checked == true) { Vector4 checkedColor = !Enabled ? MyGuiConstants.DISABLED_BUTTON_COLOR_VECTOR : (IsMouseOverOrKeyboardActive() || m_highlightWhenChecked) ? m_backgroundColor.Value * MyGuiConstants.CONTROL_MOUSE_OVER_BACKGROUND_COLOR_MULTIPLIER : m_backgroundColor.Value; // Checked sprite (fajka) MyGuiManager.DrawSpriteBatch(m_checkedTexture, m_parent.GetPositionAbsolute() + m_position, m_size.Value, GetColorAfterTransitionAlpha(checkedColor), MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER); } }
/// <summary> /// Draw's scrollbar /// </summary> public void Draw() { Vector4 vctColor = Color.White.ToVector4(); vctColor.W *= m_parent.GetTransitionAlpha(); MyGuiManager.DrawSpriteBatch(m_texture, m_parent.GetPositionAbsolute() + m_scrollSliderPosition, m_scrollSliderSize, new Color(vctColor), MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP); }
public static void DrawSpriteBatchBackground(Vector4?color) { var offset = new Vector2(VideoMode.MyVideoModeManager.IsTripleHead() ? -1 : 0, 0); MyGuiManager.DrawSpriteBatch(MyGuiManager.GetAmmoSelectLowBackground(), MyGuiManager.GetNormalizedCoordinateFromScreenCoordinate(MyGuiConstants.AMMO_SELECT_LEFT_TOP_POSITION) + offset, m_backSize, new Color(color.Value), MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP); }
public void DrawGameLogo(float transitionAlpha) { Color colorForeground = new Color(1, 1, 1, transitionAlpha); MyGuiManager.DrawSpriteBatch(GameLogoTexture, new Vector2(0.5f, 0.15f), new Vector2(702 / 1600f, 237 / 1200f), colorForeground, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER); }
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 override void Draw() { base.Draw(); if (m_texture != null) { var position = m_parent.GetPositionAbsolute() + m_position - new Vector2(m_size.Value.X / 2 - 0.01f, 0); MyGuiManager.DrawSpriteBatch(m_texture, position, MyGuiConstants.LISTBOX_SMALL_SIZE, m_textureColor, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER); } }
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(0.95f, 0.95f, 0.95f, m_transitionAlpha))); return(true); }
public override void Draw(float transitionAlpha) { base.Draw(transitionAlpha); // draw progress bar var progressFillSize = Size * (new Vector2(Value, 1.0f)); var color = ApplyColorMaskModifiers(ColorMask * ProgressColor.ToVector4(), Enabled, transitionAlpha); MyGuiManager.DrawSpriteBatch(MyGuiConstants.PROGRESS_BAR, GetPositionAbsoluteTopLeft(), progressFillSize, color, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP); }
private void DrawPauseIndicator() { var fullscreenRect = MyGuiManager.GetSafeFullscreenRectangle(); fullscreenRect.Height /= 18; var font = MyFontEnum.Red; var text = MyTexts.Get(MySpaceTexts.GamePaused); MyGuiManager.DrawSpriteBatch(MyGuiConstants.TEXTURE_HUD_BG_MEDIUM_RED2.Texture, fullscreenRect, Color.White); MyGuiManager.DrawString(font, text, new Vector2(0.5f, 0.024f), 1.0f, drawAlign: MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER); }