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 void Draw() { // End our standard sprite batch MyGuiManager.EndSpriteBatch(); // Draw the rectangle(basically the opened area) to stencil buffer to be used for clipping partial item MyGuiManager.DrawStencilMaskRectangle(new MyRectangle2D(m_body.GetPosition(), m_body.GetSize()), MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP); // Set up the stencil operation and parameters MyGuiManager.BeginSpriteBatch_StencilMask(); m_body.Draw(); // End stencil-mask batch, and restart the standard sprite batch //MyGuiManager.EndSpriteBatch(); MyGuiManager.EndSpriteBatch_StencilMask(); MyGuiManager.BeginSpriteBatch(); Color borderColor = m_control.GetColorAfterTransitionAlpha(MyGuiConstants.TREEVIEW_VERTICAL_LINE_COLOR); MyGUIHelper.OutsideBorder(m_position, m_size, 2, borderColor); m_vScrollbar.Draw(); m_hScrollbar.Draw(); }
public override void Draw() { // End our standard sprite batch MyGuiManager.EndSpriteBatch(); // Draw the rectangle(basically the opened area) to stencil buffer to be used for clipping partial item if (m_controlsPadding.Y > 0) { MyGuiManager.DrawStencilMaskRectangle(new MyRectangle2D(GetPositionAbsolute(), m_size.Value), MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER); } else { MyGuiManager.DrawStencilMaskRectangle(new MyRectangle2D(GetPositionAbsolute(), m_size.Value - 2 * m_controlsPadding), MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER); } // Set up the stencil operation and parameters MyGuiManager.BeginSpriteBatch_StencilMask(); base.Draw(); // End stencil-mask batch, and restart the standard sprite batch MyGuiManager.EndSpriteBatch_StencilMask(); //MyGuiManager.EndSpriteBatch(); MyGuiManager.BeginSpriteBatch(); m_verticalScrollbar.Draw(); }
public void HudDrawActualAmmo(Vector2 position, Vector2 scaleToAmmoSelection, int amount, Vector4?backgroundColor, StringBuilder ammoSpecialText) { if (backgroundColor.HasValue) { m_color = new Color(backgroundColor.Value); MyGuiManager.BeginSpriteBatch(); base.DrawSpriteBatch(position, new Vector2(m_itemWidth * scaleToAmmoSelection.X, ItemHeight * scaleToAmmoSelection.Y), m_color, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP); Vector2 textPosition = position; textPosition.X += m_itemWidth / 2.6f * 2.0f; textPosition.Y += ItemHeight * scaleToAmmoSelection.Y - ItemHeight / 6.0f; m_diff.X += m_itemWidth * scaleToAmmoSelection.X * MyGuiConstants.AMMO_SELECT_ITEM_TEXT_RELATIVE_POSITION.X; m_diff.Y += ItemHeight * scaleToAmmoSelection.Y * MyGuiConstants.AMMO_SELECT_ITEM_TEXT_RELATIVE_POSITION.Y; MyMwcUtils.ClearStringBuilder(m_amount); m_amount.AppendInt32(amount); var color = new Color(MyGuiConstants.LABEL_TEXT_COLOR); MyGuiManager.DrawString(MyGuiManager.GetFontMinerWarsBlue(), m_amount, textPosition, 0.7f, color, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM); if (ammoSpecialText != null && ammoSpecialText.Length > 0) { textPosition.Y -= ItemHeight / 4.0f; MyGuiManager.DrawString(MyGuiManager.GetFontMinerWarsBlue(), ammoSpecialText, textPosition, .7f, color, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM); } MyGuiManager.EndSpriteBatch(); } }
public void 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(); }
private void DrawChetArea() { List <MyChatMessage> messages = MyGuiScreenGamePlay.Static.GetChatMessages(8); if (messages == null) { return; } if (m_stringBuilderForText == null) { m_stringBuilderForText = new StringBuilder(MyGuiConstants.CHAT_WINDOW_MAX_MESSAGE_LENGTH); } else { m_stringBuilderForText.Clear(); } int visibleCount = messages.Count; if (visibleCount == 0) { return; } // row size float rowSize = 0; m_stringBuilderForText.Append(messages[0].SenderName.ToString()); m_stringBuilderForText.Append(": "); m_stringBuilderForText.Append(messages[0].Message); Vector2 textSize = MyGuiManager.GetNormalizedSize(GetSenderFont(messages[0].SenderRelation), m_stringBuilderForText, MyGuiConstants.CHAT_WINDOW_MESSAGE_SCALE); rowSize = textSize.Y; m_stringBuilderForText.Clear(); MyGuiManager.BeginSpriteBatch(); var offset = new Vector2(VideoMode.MyVideoModeManager.IsTripleHead() ? -1 : 0, 0); { // Draw texts Vector2 notificationPosition = new Vector2(0.305f, 0.756f) + m_positionOffset; for (int i = 0; i < visibleCount; i++) { m_stringBuilderForText.Append(messages[i].SenderName.ToString()); m_stringBuilderForText.Append(": "); MyRectangle2D size = MyGuiManager.DrawString(GetSenderFont(messages[i].SenderRelation), m_stringBuilderForText, notificationPosition + offset, MyGuiConstants.CHAT_WINDOW_MESSAGE_SCALE, MyGuiConstants.CHAT_WINDOW_TEXT_COLOR, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER); notificationPosition.X += size.Size.X; MyGuiManager.DrawString(GetSenderFont(messages[i].SenderRelation), messages[i].Message, notificationPosition + offset, MyGuiConstants.CHAT_WINDOW_MESSAGE_SCALE, MyGuiConstants.CHAT_WINDOW_TEXT_COLOR, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER); notificationPosition.Y += rowSize; notificationPosition.X -= size.Size.X; m_stringBuilderForText.Clear(); } } MyGuiManager.EndSpriteBatch(); }
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(); }
/// <summary> /// Draw debug text /// </summary> /// <param name="screenCoord"></param> /// <param name="text"></param> /// <param name="color"></param> /// <param name="scale"></param> public static float DrawText(Vector2 screenCoord, StringBuilder text, Color color, float scale) { MyGuiManager.BeginSpriteBatch(); float textLenght = MyGuiManager.GetFontMinerWarsWhite().DrawString(screenCoord, color, text, scale); MyGuiManager.EndSpriteBatch(); return(textLenght); }
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(); } }
static public void Draw() { MyGuiManager.BeginSpriteBatch(); for (int i = 0; i < m_data.Count; i++) { TextData data = m_data[i]; MyGuiManager.GetFontMinerWarsWhite().DrawString(data.screenCoord, data.color, data.text, data.scale); } MyGuiManager.EndSpriteBatch(); m_data.Clear(); }
void DrawLoadAnimation(/*GameTime gameTime*/) { if ((MyMinerGame.Static.GraphicsDevice == null) || MyMinerGame.Static.GraphicsDevice.IsDisposed) { return; } try { try { MyMinerGame.Static.GraphicsDevice.BeginScene(); MyGuiManager.BeginSpriteBatch(); DrawLoading(0.0f); MyGuiScreenGamePlay.DrawLoadsCount(); } catch (Exception) { // PetrM told to comment out //Debug.Fail("Loading screen draw crashed: "); // If anything went wrong (for instance the graphics device was lost // or reset) we don't have any good way to recover while running on a // background thread. Setting the device to null will stop us from // rendering, so the main game can deal with the problem later on. //MyMinerGameDX.Static.GraphicsDevice = null; } finally { MyGuiManager.EndSpriteBatch(); MyMinerGame.Static.GraphicsDevice.EndScene(); } // Slow down drawing of "loading..." screens, so background thread who is actualy loading content will have more time (CPU resources) to do his job. // Plus these two threads won't fight for graphic device. It's not big difference, just 10% or so. Thread.Sleep(MyGuiConstants.LOADING_THREAD_DRAW_SLEEP_IN_MILISECONDS); var res = MyMinerGame.Static.GraphicsDevice.TestCooperativeLevel(); if (res.Code == ResultCode.Success.Result.Code) { MyMinerGame.Static.GraphicsDevice.Present(); } } catch (Exception) { Debug.Fail("Loading screen draw crashed: "); } }
public override void Draw() { base.Draw(); if (!IsEnabled) { return; } MyGuiManager.BeginSpriteBatch(); if (m_text.Length > 0) { MyGuiManager.DrawString(MyGuiManager.GetFontGuiImpactLarge(), m_text, MyGuiManager.GetScreenTextLeftBottomPosition(), MyGuiConstants.LABEL_TEXT_SCALE * 0.93f, Color.Red, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP); } MyGuiManager.EndSpriteBatch(); }
public override void Draw() { //base.Draw(); if (IsActive()) { // draw item's background if (m_backgroundColor != null && DrawBackgroundTexture) { MyGuiManager.DrawSpriteBatch(MyGuiManager.GetBlankTexture(), MyGuiManager.MouseCursorPosition, m_size.Value, /*new Color(m_backgroundColor.Value)*/ GetColorAfterTransitionAlpha(m_backgroundColor.Value * (new Color(50, 66, 70, 255).ToVector4())), MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER); } Vector2 itemPosition = MyGuiManager.MouseCursorPosition - m_size.Value / 2.0f; Vector2 textPosition = itemPosition + m_textOffset; textPosition.Y += (m_size.Value.Y / 2.0f); // draw item's icon if (m_supportIcon == true && m_draggingListboxItem.Icon != null) { MyGuiManager.DrawSpriteBatch(m_draggingListboxItem.Icon, itemPosition, m_size.Value, GetColorAfterTransitionAlpha(m_backgroundColor.Value), MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP); } // draw item's text else if (m_draggingListboxItem.Value != null) { // End our standard sprite batch MyGuiManager.EndSpriteBatch(); // Draw the rectangle(basically the opened area) to stencil buffer to be used for clipping partial item MyGuiManager.DrawStencilMaskRectangle(new MyRectangle2D(itemPosition, m_size.Value), MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP); // Set up the stencil operation and parameters MyGuiManager.BeginSpriteBatch_StencilMask(); m_draggingListboxItem.ColoredText.Draw(textPosition, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, m_parent.GetTransitionAlpha(), true); // End stencil-mask batch, and restart the standard sprite batch //MyGuiManager.EndSpriteBatch(); MyGuiManager.EndSpriteBatch_StencilMask(); MyGuiManager.BeginSpriteBatch(); } ShowToolTip(); } }
public void DrawSpriteBatchMenuHeader(int orderX, bool selected, int selectedIndex, Vector4?backgroundColor) { MyGuiManager.BeginSpriteBatch(); if (backgroundColor.HasValue) { // selection color: m_backgroundActualColor = backgroundColor.Value; m_color = new Color(m_backgroundActualColor); Vector2 deltaVector = new Vector2(orderX * (m_menuItemWidth + m_menuItemDistance), 0); Vector2 startPosition = MyGuiManager.GetNormalizedCoordinateFromScreenCoordinate( MyGuiConstants.AMMO_SELECT_LEFT_TOP_POSITION) + deltaVector + m_offset; // render textures: if (selected) { m_color = new Color(m_backgroundActualColor * MyGuiConstants.SELECT_AMMO_ACTIVE_COLOR_MULTIPLIER); if (selectedIndex == 0) { m_backgroundActualColor *= MyGuiConstants.SELECT_AMMO_ACTIVE_COLOR_MULTIPLIER; } /* * MyGuiManager.DrawSpriteBatch(MyGuiManager.GetAmmoSelectTexture(), startPosition, * new Vector2(m_menuItemWidth, m_menuItemHeight), * new Color(m_backgroundActualColor), MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP); * */ } else { m_color = new Color(MyGuiConstants.SELECT_AMMO_BACKGROUND_COLOR /*DEFAULT_CONTROL_BACKGROUND_COLOR*/); } base.DrawSpriteBatch(startPosition, new Vector2(m_menuItemWidth, m_menuItemHeight), m_color, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP); } MyGuiManager.EndSpriteBatch(); }
Draw() { if (!Visible || MySession.PlayerShip == null) { return; } MySession.PlayerShip.Config.Items(ref m_displayedItems); MyGuiManager.BeginSpriteBatch(); var offset = new Vector2(VideoMode.MyVideoModeManager.IsTripleHead() ? -1 : 0, 0); //Draw background MyGuiManager.DrawSpriteBatch(m_backgroundtexture, new Vector2(0.5f, 0.5f) + offset, m_size.Value, Color.White, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER); //Draw items for (int i = 0, j = 0; i < m_displayedItems.Length; i++) { if (m_displayedItems[i] == null) { continue; } if (m_selected == i) { var pos = new Vector2(0.5f, m_position.Y - (ITEM_HEIGHT * m_displayedItems.Length / 2) + (ITEM_HEIGHT * j) - 0.003f); MyGuiManager.DrawSpriteBatch(m_smallBgHover, pos + offset, itemSize, Color.White, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_TOP); } //Draw item name var nameWithKey = new StringBuilder().Append(m_displayedItems[i].Name); MyGameControlEnums?control = m_displayedItems[i].AssociatedControl; if (control != null) { string key = MyGuiManager.GetInput().GetGameControlTextEnum(control.Value); if (key != MyTextsWrapper.Get(MyTextsWrapperEnum.UnknownControl).ToString()) { nameWithKey.Append(" (").Append(key).Append(")"); } } MyGuiManager.DrawString(MyGuiManager.GetFontMinerWarsBlue(), nameWithKey, new Vector2(m_position.X - (TOTAL_WIDTH / 2) - 0.02f, m_position.Y - (ITEM_HEIGHT * m_displayedItems.Length / 2) + (ITEM_HEIGHT * j)) + offset, TEXT_SCALE, Color.White, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP); //Draw item value bg var smallBgSize = MyGuiManager.GetNormalizedSizeFromScreenSize(MyGuiManager.GetFontMinerWarsGreen().MeasureString(m_displayedItems[i].CurrentValueText, TEXT_SCALE)); if (smallBgSize.LengthSquared() > 0.00f) { var bgPos = new Vector2(m_position.X + (TOTAL_WIDTH / 2) - SLIDER_WIDTH + 0.01f - smallBgSize.X / 2, m_position.Y - (ITEM_HEIGHT * m_displayedItems.Length / 2) + (ITEM_HEIGHT * j) - 0.003f); smallBgSize.Y = itemSize.Y; smallBgSize.X *= 1.6f; MyGuiManager.DrawSpriteBatch(m_smallBgHover, bgPos + offset, smallBgSize, new Color(255, 255, 255, 200), MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_TOP); } //draw item MyGuiManager.DrawString(MyGuiManager.GetFontMinerWarsGreen(), m_displayedItems[i].CurrentValueText, new Vector2(m_position.X + (TOTAL_WIDTH / 2) - SLIDER_WIDTH + 0.01f, m_position.Y - (ITEM_HEIGHT * m_displayedItems.Length / 2) + (ITEM_HEIGHT * j)) + offset, TEXT_SCALE, Color.White, MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP); j++; } /* * //Draw top button * if (IsUpButtonVisible) * { * MyGuiManager.DrawSpriteBatch(MyGuiManager.GetConfigWheelArrowTextureUp(), * new Vector2(m_position.X - (TOTAL_WIDTH / 2), m_position.Y - (ITEM_HEIGHT * ITEM_COUNT / 2) - BUTTON_HEIGHT - BUTTON_VERTICAL_DIFF) + offset, * new Vector2(TOTAL_WIDTH, BUTTON_HEIGHT), Color.White, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP); * } * * */ //Draw bottom button //if (IsDownButtonVisible) //{ // MyGuiManager.DrawSpriteBatch(MyGuiManager.GetConfigWheelArrowTextureDown(), // new Vector2(m_position.X - (TOTAL_WIDTH / 2), m_position.Y + (ITEM_HEIGHT * m_displayedItems.Length / 2) + BUTTON_VERTICAL_DIFF) + offset, // new Vector2(TOTAL_WIDTH, BUTTON_HEIGHT), Color.White, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP); //} //Draw scrollbar //if (IsScrollBarVisible) //{ // MyGuiManager.DrawSpriteBatch(MyGuiManager.GetBlankTexture(), // new Vector2(m_position.X + (TOTAL_WIDTH / 2) - SLIDER_WIDTH, m_position.Y - (ITEM_HEIGHT * m_displayedItems.Length / 2)) + offset, // new Vector2(SLIDER_WIDTH, m_displayedItems.Length * ITEM_HEIGHT), new Color(Color.RoyalBlue.R, Color.RoyalBlue.G, Color.RoyalBlue.B, (byte)(255 * 0.3f)), // MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP); // MyGuiManager.DrawSpriteBatch(MyGuiManager.GetScrollbarSlider(), // SliderNormalizedCoord, SliderNormalizedSize, Color.White, // MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP); //} MyGuiManager.EndSpriteBatch(); }
public override void Draw() { /* if (MyFakes.MW25D) * { * Visible = true; * //m_mouseCursorHoverTexture = null; * // return; * } */ if (!Visible) { return; } MyGuiManager.BeginSpriteBatch(); var offset = new Vector2(VideoMode.MyVideoModeManager.IsTripleHead() ? -1 : 0, 0); /* * // Draw information: * Vector2 screenSizeNormalize = MyGuiManager.GetNormalizedSize(MyGuiManager.GetAmmoSelectKeyConfirmBorderTexture(), MyGuiConstants.AMMO_SELECTION_CONFIRM_BORDER_INFO_SCALE); * screenSizeNormalize.X *= MyGuiConstants.AMMO_SELECTION_CONFIRM_BORDER_SCALE.X; * screenSizeNormalize.Y *= MyGuiConstants.AMMO_SELECTION_CONFIRM_BORDER_SCALE.Y; */ var screenSizeNormalize = new Vector2(918f / 1600f, 314f / 1200f); //if (!MyFakes.MW25D) if (Visible) { MyGuiManager.DrawSpriteBatch(MyGuiManager.GetAmmoSelectKeyConfirmBorderTexture(), MyGuiConstants.AMMO_SELECTION_CONFIRM_BORDER_POSITION + offset, screenSizeNormalize, MyGuiConstants.AMMO_SELECTION_CONFIRM_BORDER_COLOR, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER); MyGuiManager.DrawStringCentered(MyGuiManager.GetFontMinerWarsBlue(), m_text, MyGuiConstants.AMMO_SELECTION_CONFIRM_BORDER_TEXT_INFO_POSITION + offset, MyGuiConstants.AMMO_SELECTION_CONFIRMATION_TEXT_SCALE, MyGuiConstants.AMMO_SELECTION_CONFIRM_INFO_TEXT_COLOR, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER); MyGuiManager.DrawString(MyGuiManager.GetFontMinerWarsBlue(), m_textValues, MyGuiConstants.AMMO_SELECTION_CONFIRM_BORDER_TEXT_POSITION + offset, MyGuiConstants.AMMO_SELECTION_CONFIRMATION_TEXT_INFO_SCALE, MyGuiConstants.AMMO_SELECTION_CONFIRM_INFO_TEXT_COLOR, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER); } MyGuiSmallShipHelperAmmo.DrawSpriteBatchBackground(MyGuiConstants.SELECT_AMMO_BACKGROUND_COLOR); foreach (MyMwcObjectBuilder_AmmoGroupEnum item in MyGuiSmallShipHelpers.MyMwcObjectBuilder_SmallShip_AssignmentOfAmmo_GroupEnumValues) { MyGuiSmallShipHelpers.GetMyGuiSmallShipHelperAmmo(item).DrawSpriteBatchMenuHeader((int)item - 1, (m_selectedGroup == item), m_selectedIndex, m_backgroundColor.Value); } if (!Visible) { MyGuiManager.EndSpriteBatch(); return; } for (int i = m_ammoTypesAmounts.Count - 1; i >= 0; i--) { int itemsPerColumn = 7; int orderX = i / itemsPerColumn; int orderY = i % itemsPerColumn; MyGuiSmallShipHelperAmmo ammoHelper = MyGuiObjectBuilderHelpers.GetGuiHelper( MyMwcObjectBuilderTypeEnum.SmallShip_Ammo, (int)m_ammoTypesAmounts[i].Type) as MyGuiSmallShipHelperAmmo; //MyGuiSmallShipHelpers.GetMyGuiSmallShipHelperAmmo(m_ammoTypesAmounts[i].Type).DrawSpriteBatchMenuItem( // orderX - 1, orderY - 1, (i == m_selectedIndex), m_ammoTypesAmounts[i].Amount, m_backgroundColor.Value, i, (int)m_selectedGroup); ammoHelper.DrawSpriteBatchMenuItem(orderX - 1, orderY - 1, (i == m_selectedIndex), m_ammoTypesAmounts[i].Amount, m_backgroundColor.Value, i, (int)m_selectedGroup); } MyGuiSmallShipHelperAmmo.DrawSpriteBatchTooltip(); MyGuiManager.EndSpriteBatch(); }
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(); }