public void SetTexts() { MyMwcUtils.ClearStringBuilder(m_debugText); m_debugText.AppendLine("Player friends debug info"); if (MySession.Static == null || MySession.PlayerFriends == null) { m_debugText.AppendLine("Player friends does not exists"); return; } foreach (var friend in MySession.PlayerFriends.GetDebug()) { m_debugText.Append(friend.DisplayName); m_debugText.Append(": "); if (friend.EntityId.HasValue) { m_debugText.AppendInt32((int)friend.EntityId.Value.NumericValue); m_debugText.Append(" ("); m_debugText.AppendInt32(friend.EntityId.Value.PlayerId); m_debugText.Append(")"); m_debugText.AppendLine(); m_debugText.Append(" Position: "); m_debugText.AppendDecimal(friend.GetPosition().X, 1); m_debugText.Append("; "); m_debugText.AppendDecimal(friend.GetPosition().Y, 1); m_debugText.Append("; "); m_debugText.AppendDecimal(friend.GetPosition().Z, 1); m_debugText.AppendLine(); } } }
public void RecreateControls() { Elements.Clear(); var guiTextScale = (float)Math.Pow(1.2f, m_stat.StatDefinition.GuiDef.HeightMultiplier - 1.0f); var guiArrowScale = (float)Math.Pow(1.3f, m_stat.StatDefinition.GuiDef.HeightMultiplier - 1.0f) / m_stat.StatDefinition.GuiDef.HeightMultiplier; var textScale = MyGuiConstants.HUD_TEXT_SCALE * 0.6f * guiTextScale; var barLength = 0.0875f; var arrowIconSize = new Vector2(Size.Y * 1.5f, Size.Y) * 0.5f * guiArrowScale; var leftTextWidth = 0.16f; var textHeightOffset = -0.1f; var leftTextOffset = -1.0f / 2.0f + leftTextWidth; var barOffset = leftTextOffset + 0.025f; var arrowIconOffset = barOffset + barLength / Size.X + 0.05f; var rightTextOffset = arrowIconOffset + arrowIconSize.X + 0.035f; m_statNameLabel = new MyGuiControlLabel(position: Size * new Vector2(leftTextOffset, textHeightOffset), text: m_stat.StatId.ToString(), textScale: textScale, size: new Vector2(leftTextWidth * Size.X, 1.0f), originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER); Elements.Add(m_statNameLabel); var vecColor = m_stat.StatDefinition.GuiDef.Color; var barColor = new Color(vecColor.X, vecColor.Y, vecColor.Z); m_progressBar = new MyGuiControlProgressBar(position: Size * new Vector2(barOffset, 0.0f), originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, size: new Vector2(barLength, Size.Y), backgroundTexture: new MyGuiCompositeTexture(MyGuiConstants.TEXTURE_HUD_STAT_BAR_BG.Texture), progressBarColor: barColor); if (m_stat != null) { m_progressBar.Value = m_stat.CurrentRatio; } Elements.Add(m_progressBar); m_effectArrow = new MyGuiControlPanel(position: Size * new Vector2(arrowIconOffset, 0.0f), originAlign: MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, size: arrowIconSize, texture: MyGuiConstants.TEXTURE_HUD_STAT_EFFECT_ARROW_UP.Texture); Elements.Add(m_effectArrow); StringBuilder statText = new StringBuilder(); statText.AppendDecimal((int)m_stat.Value, 0); statText.Append("/"); statText.AppendDecimal(m_stat.MaxValue, 0); m_statValueLabel = new MyGuiControlLabel(position: Size * new Vector2(rightTextOffset, textHeightOffset), text: statText.ToString(), textScale: textScale, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER); Elements.Add(m_statValueLabel); }
private void UpdateStatText(float newValue, float oldValue, object statChangeData) { m_progressBar.Value = m_stat.CurrentRatio; if (m_statValueLabel != null) { StringBuilder statText = new StringBuilder(); statText.AppendDecimal((int)m_stat.Value, 0); statText.Append("/"); statText.AppendDecimal(m_stat.MaxValue, 0); m_statValueLabel.Text = statText.ToString(); } }
private void UpdateStatControl(float newValue, float oldValue, object statChangeData) { m_progressBar.Value = m_stat.CurrentRatio; if (m_statValueLabel != null) // Update the text { StringBuilder statText = new StringBuilder(); statText.AppendDecimal((int)m_stat.Value, 0); statText.Append("/"); statText.AppendDecimal(m_stat.MaxValue, 0); m_statValueLabel.Text = statText.ToString(); } m_recalculatePotential = true; }
public static void AppendFormattedValueInBestUnit(float value, string[] unitNames, float[] unitMultipliers, int[] unitDecimalDigits, StringBuilder output) { Debug.Assert(unitNames.Length == unitDecimalDigits.Length); if (float.IsInfinity(value)) { output.Append('-'); return; } var absValue = Math.Abs(value); int i = 1; for (; i < unitMultipliers.Length; ++i) { if (absValue < unitMultipliers[i]) { break; } } --i; // move back to the best unit value /= unitMultipliers[i]; output.AppendDecimal(Math.Round(value, unitDecimalDigits[i]), unitDecimalDigits[i]); output.Append(' ').Append(unitNames[i]); }
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 SetTexts() { MyMwcUtils.ClearStringBuilder(m_debugText); m_debugText.Append("FPS: "); m_debugText.AppendInt32(MyFpsManager.GetFps()); m_debugText.AppendLine(); m_debugText.Append("Frame time: "); m_debugText.AppendDecimal(MyFpsManager.FrameTime, 1); m_debugText.Append(" ms"); m_debugText.AppendLine(); m_debugText.Append("Frame avg time: "); m_debugText.AppendDecimal(MyFpsManager.FrameTimeAvg, 1); m_debugText.Append(" ms"); m_debugText.AppendLine(); m_debugText.Append("Frame min time: "); m_debugText.AppendDecimal(MyFpsManager.FrameTimeMin, 1); m_debugText.Append(" ms"); m_debugText.AppendLine(); m_debugText.Append("Frame max time: "); m_debugText.AppendDecimal(MyFpsManager.FrameTimeMax, 1); m_debugText.Append(" ms"); m_debugText.AppendLine(); m_debugText.Append("Environment map update time: "); m_debugText.AppendDecimal(MinerWars.AppCode.Game.Render.EnvironmentMap.MyEnvironmentMap.LastUpdateTime, 1); m_debugText.Append(" ms"); m_debugText.AppendLine(); if (MyMwcFinalBuildConstants.IS_DEVELOP) { m_debugText.AppendLine(); MyPerformanceCounter.PerCameraDraw.AppendCustomCounters(m_debugText); m_debugText.AppendLine(); MyPerformanceCounter.PerCameraDraw.AppendCustomTimers(m_debugText); } }
public void AppendCustomTimers(StringBuilder builder, bool reset = true) { foreach (var custom in m_customTimers) { builder.Append(custom.Key); builder.Append(": "); builder.AppendDecimal((float)TicksToMs(custom.Value.Runtime), 3); builder.Append(" ms"); builder.AppendLine(); } if (reset) { m_keys.Clear(); foreach (var custom in m_customTimers) { m_keys.Add(custom.Key); } foreach (var key in m_keys) { m_customTimers[key] = Timer.Empty; } } }
private void FillListBoxFromID(MyGuiControlListbox listbox, int id, bool canBeMoved = true) { MyInventoryItem inventoryItem = m_itemsRepository.GetItem(id); StringBuilder description = null; if (inventoryItem.Icon == null) { description = inventoryItem.MultiLineDescription; } MyGuiControlListboxItem listboxItem = new MyGuiControlListboxItem(id, description, inventoryItem.Icon, GetListboxItemTooltip(listbox, id), MyGuiConstants.LABEL_TEXT_SCALE); listboxItem.IconTexts = new MyIconTexts(); // add amount icon's text if (inventoryItem.Amount != 0f || inventoryItem.Amount != inventoryItem.MaxAmount) { StringBuilder amount = new StringBuilder(); if (inventoryItem.Amount > (int)inventoryItem.Amount) { float fixedAmount = Math.Max(0.01f, inventoryItem.Amount); // prevent items with zero amount, for visualization 0.01 is the minimum value amount.AppendDecimal(fixedAmount, 2); } else { amount.AppendInt32((int)inventoryItem.Amount); } //amount.Append(inventoryItem.Amount.ToString()); MyGuiDrawAlignEnum align; Vector2 offset; //All amounts alignet to right bottom position from now /* if (inventoryItem.AmountTextAlign == MyInventoryAmountTextAlign.MiddleRight) { align = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER; offset = new Vector2(-0.004f, 0.0038f); } else if (inventoryItem.AmountTextAlign == MyInventoryAmountTextAlign.BottomRight) { * */ align = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM; offset = new Vector2(-0.013f, -0.01f); /*} else { throw new MyMwcExceptionApplicationShouldNotGetHere(); } * */ listboxItem.IconTexts[align] = new MyColoredText(amount, Color.White, Color.White, MyGuiManager.GetFontMinerWarsBlue(), 0.6f, offset); } bool enabled = inventoryItem.CanBeMoved && canBeMoved; if (m_tradeForMoney) { enabled &= inventoryItem.CanBeTraded; } listboxItem.Enabled = enabled; //if (!inventoryItem.CanBeMoved) //{ // listboxItem.Enabled = false; //} listbox.AddItem(listboxItem); }
public void RecreateControls() { Elements.Clear(); var guiTextScale = (float)Math.Pow(1.2f, m_stat.StatDefinition.GuiDef.HeightMultiplier - 1.0f); var guiArrowScale = (float)Math.Pow(1.3f, m_stat.StatDefinition.GuiDef.HeightMultiplier - 1.0f) / m_stat.StatDefinition.GuiDef.HeightMultiplier; var textScale = MyGuiConstants.HUD_TEXT_SCALE*0.6f*guiTextScale; var barLength = 0.0875f; var arrowIconSize = new Vector2(Size.Y * 1.5f, Size.Y) * 0.5f * guiArrowScale; var leftTextWidth = 0.16f; var textHeightOffset = -0.1f; var leftTextOffset = -1.0f / 2.0f + leftTextWidth; var barOffset = leftTextOffset + 0.025f; var arrowIconOffset = barOffset + barLength/Size.X + 0.05f; var rightTextOffset = arrowIconOffset + arrowIconSize.X + 0.035f; m_statNameLabel = new MyGuiControlLabel(position: Size * new Vector2(leftTextOffset, textHeightOffset), text: m_stat.StatId.ToString(), textScale: textScale, size: new Vector2(leftTextWidth*Size.X, 1.0f), originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER); Elements.Add(m_statNameLabel); var vecColor = m_stat.StatDefinition.GuiDef.Color; var barColor = new Color(vecColor.X, vecColor.Y, vecColor.Z); m_progressBar = new MyGuiControlProgressBar(position: Size * new Vector2(barOffset, 0.0f), originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, size: new Vector2(barLength, Size.Y), backgroundTexture: new MyGuiCompositeTexture(MyGuiConstants.TEXTURE_HUD_STAT_BAR_BG.Texture), progressBarColor: barColor); if (m_stat != null) m_progressBar.Value = m_stat.CurrentRatio; Elements.Add(m_progressBar); m_effectArrow = new MyGuiControlPanel( position: Size * new Vector2(arrowIconOffset, 0.0f), originAlign: MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, size: arrowIconSize, texture: MyGuiConstants.TEXTURE_HUD_STAT_EFFECT_ARROW_UP.Texture); Elements.Add(m_effectArrow); StringBuilder statText = new StringBuilder(); statText.AppendDecimal((int)m_stat.Value, 0); statText.Append("/"); statText.AppendDecimal(m_stat.MaxValue, 0); m_statValueLabel = new MyGuiControlLabel(position: Size * new Vector2(rightTextOffset, textHeightOffset), text: statText.ToString(), textScale: textScale, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER); Elements.Add(m_statValueLabel); }
public void GetActualJoystickState(StringBuilder text) { if (m_joystick.IsConnected == false) { text.Append("No joystick detected."); return; } XB1Interface.XB1Interface.GamepadState gamepad = m_actualJoystickState; text.Append("Supported axes: "); if (IsJoystickAxisSupported(MyJoystickAxesEnum.Xpos)) text.Append("X "); if (IsJoystickAxisSupported(MyJoystickAxesEnum.Ypos)) text.Append("Y "); if (IsJoystickAxisSupported(MyJoystickAxesEnum.Zpos)) text.Append("Z "); if (IsJoystickAxisSupported(MyJoystickAxesEnum.RotationXpos)) text.Append("Rx "); if (IsJoystickAxisSupported(MyJoystickAxesEnum.RotationYpos)) text.Append("Ry "); if (IsJoystickAxisSupported(MyJoystickAxesEnum.RotationZpos)) text.Append("Rz "); if (IsJoystickAxisSupported(MyJoystickAxesEnum.Slider1pos)) text.Append("S1 "); if (IsJoystickAxisSupported(MyJoystickAxesEnum.Slider2pos)) text.Append("S2 "); text.AppendLine(); text.Append("rotX: "); text.AppendDecimal(gamepad.rx, 4); text.AppendLine(); text.Append("rotY: "); text.AppendDecimal(gamepad.ry, 4); text.AppendLine(); text.Append("X: "); text.AppendDecimal(gamepad.lx, 4); text.AppendLine(); text.Append("Y: "); text.AppendDecimal(gamepad.ly, 4); text.AppendLine(); text.AppendLine(); text.Append("Buttons: "); foreach (JoystickHelper.XInputGamepadButtonFlags i in Enum.GetValues(typeof(JoystickHelper.XInputGamepadButtonFlags))) { text.Append( (( (uint)(i) & gamepad.Buttons) != 0) ? "#" : "_"); text.Append(" "); } text.AppendLine(); }