private void DrawNetgraphStringValue(Vector2 position, StringBuilder sb, float scale = 0.6f) { MyGuiManager.DrawString(MyFontEnum.White, sb, position, scale, null, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP); }
public override void Draw(float transitionAlpha, float backgroundTransitionAlpha) { if (!Visible) { return; } m_compositeBackground.Draw(GetPositionAbsoluteTopLeft(), Size, ApplyColorMaskModifiers(ColorMask, Enabled, backgroundTransitionAlpha)); base.Draw(transitionAlpha, backgroundTransitionAlpha); var textAreaRelative = m_textAreaRelative; var textArea = textAreaRelative; textArea.LeftTop += GetPositionAbsoluteTopLeft(); float carriageOffset = GetCarriageOffset(CarriagePositionIndex); var scissor = new RectangleF(textArea.LeftTop, textArea.Size); using (MyGuiManager.UsingScissorRectangle(ref scissor)) { RefreshSlidingWindow(); //Draws selection background, if any if (m_selection.Length > 0) { float normalizedWidth = GetCarriageOffset(m_selection.End) - GetCarriageOffset(m_selection.Start); MyGuiManager.DrawSpriteBatch(MyGuiConstants.BLANK_TEXTURE, new Vector2(textArea.LeftTop.X + GetCarriageOffset(m_selection.Start), textArea.LeftTop.Y), new Vector2(normalizedWidth, textArea.Size.Y), ApplyColorMaskModifiers(new Vector4(1, 1, 1, 0.5f), Enabled, transitionAlpha), MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP ); } // Draw text in textbox MyGuiManager.DrawString(TextFont, new StringBuilder(GetModifiedText()), new Vector2(textArea.LeftTop.X + m_slidingWindowOffset, textArea.LeftTop.Y), TextScaleWithLanguage, ApplyColorMaskModifiers(m_textColor, Enabled, transitionAlpha), MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP); // 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 (HasFocus) { // 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(MyGuiConstants.BLANK_TEXTURE, new Vector2(textArea.LeftTop.X + carriageOffset, textArea.LeftTop.Y), 1, textArea.Size.Y, ApplyColorMaskModifiers(Vector4.One, Enabled, transitionAlpha), MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP); } } m_carriageBlinkerTimer++; } //DebugDraw(); }
public override bool Draw() { if (!base.Draw()) { return(false); } float rowDistance = MyGuiConstants.DEBUG_STATISTICS_ROW_DISTANCE; float textScale = MyGuiConstants.DEBUG_STATISTICS_TEXT_SCALE; m_stringIndex = 0; m_texts.Clear(); m_rightAlignedtexts.Clear(); m_texts.Add(StringBuilderCache.GetFormatedFloat("FPS: ", MyFpsManager.GetFps())); m_texts.Add(new StringBuilder("Renderer: ").Append(MyRenderProxy.RendererInterfaceName())); if (MySector.MainCamera != null) { m_texts.Add(GetFormatedVector3(StringBuilderCache, "Camera pos: ", MySector.MainCamera.Position)); } m_texts.Add(MyScreenManager.GetGuiScreensForDebug()); m_texts.Add(StringBuilderCache.GetFormatedBool("Paused: ", MySandboxGame.IsPaused)); m_texts.Add(StringBuilderCache.GetFormatedDateTimeOffset("System Time: ", TimeUtil.LocalTime)); m_texts.Add(StringBuilderCache.GetFormatedTimeSpan("Total GAME-PLAY Time: ", TimeSpan.FromMilliseconds(MySandboxGame.TotalGamePlayTimeInMilliseconds))); m_texts.Add(StringBuilderCache.GetFormatedTimeSpan("Total Session Time: ", MySession.Static == null ? new TimeSpan(0) : MySession.Static.ElapsedPlayTime)); m_texts.Add(StringBuilderCache.GetFormatedTimeSpan("Total Foot Time: ", MySession.Static == null ? new TimeSpan(0) : MySession.Static.TimeOnFoot)); m_texts.Add(StringBuilderCache.GetFormatedTimeSpan("Total Jetpack Time: ", MySession.Static == null ? new TimeSpan(0) : MySession.Static.TimeOnJetpack)); m_texts.Add(StringBuilderCache.GetFormatedTimeSpan("Total Small Ship Time: ", MySession.Static == null ? new TimeSpan(0) : MySession.Static.TimeOnSmallShip)); m_texts.Add(StringBuilderCache.GetFormatedTimeSpan("Total Big Ship Time: ", MySession.Static == null ? new TimeSpan(0) : MySession.Static.TimeOnBigShip)); m_texts.Add(StringBuilderCache.GetFormatedTimeSpan("Total Time: ", TimeSpan.FromMilliseconds(MySandboxGame.TotalTimeInMilliseconds))); if (MySession.Static != null && MySession.Static.LocalCharacter != null) { var physGroup = MyExternalReplicable.FindByObject(MySession.Static.LocalCharacter).FindStateGroup <MyCharacterPhysicsStateGroup>(); m_texts.Add(StringBuilderCache.GetFormatedBool("Character has support: ", physGroup != null && physGroup.DebugSupport != null)); } m_texts.Add(StringBuilderCache.GetFormatedLong("GC.GetTotalMemory: ", GC.GetTotalMemory(false), " bytes")); if (MyFakes.DETECT_LEAKS) { var o = SharpDX.Diagnostics.ObjectTracker.FindActiveObjects(); m_texts.Add(StringBuilderCache.GetFormatedInt("SharpDX Active object count: ", o.Count)); } //TODO: I am unable to show this without allocations m_texts.Add(StringBuilderCache.GetFormatedLong("Environment.WorkingSet: ", WinApi.WorkingSet, " bytes")); // TODO: OP! Get available texture memory //m_texts.Add(StringBuilderCache.GetFormatedFloat("Available videomemory: ", MySandboxGame.Static.GraphicsDevice.AvailableTextureMemory / (1024.0f * 1024.0f), " MB")); m_texts.Add(StringBuilderCache.GetFormatedFloat("Allocated videomemory: ", 0, " MB")); #if PHYSICS_SENSORS_PROFILING if (MyPhysics.physicsSystem != null) { m_texts.Add(StringBuilderCache.GetFormatedInt("Physics sensor - new allocated interactions: ", MyPhysics.physicsSystem.GetSensorInteractionModule().GetNewAllocatedInteractionsCount())); m_texts.Add(StringBuilderCache.GetFormatedInt("Physics sensor - interactions in use: ", MyPhysics.physicsSystem.GetSensorInteractionModule().GetInteractionsInUseCount())); m_texts.Add(StringBuilderCache.GetFormatedInt("Physics sensor - interactions in use MAX: ", MyPhysics.physicsSystem.GetSensorInteractionModule().GetInteractionsInUseCountMax())); m_texts.Add(StringBuilderCache.GetFormatedInt("Physics sensor - all sensors: ", MyPhysics.physicsSystem.GetSensorModule().SensorsCount())); m_texts.Add(StringBuilderCache.GetFormatedInt("Physics sensor - active sensors: ", MyPhysics.physicsSystem.GetSensorModule().ActiveSensors.Count)); } #endif m_texts.Add(StringBuilderCache.GetFormatedInt("Sound Instances Total 2D: ", MyAudio.Static.GetSoundInstancesTotal2D())); m_texts.Add(StringBuilderCache.GetFormatedInt("Sound Instances Total 3D: ", MyAudio.Static.GetSoundInstancesTotal3D())); var tmp = StringBuilderCache; MyAudio.Static.WriteDebugInfo(tmp); m_texts.Add(tmp); for (int i = 0; i < 8; i++) { m_texts.Add(StringBuilderCache.Clear()); } MyInput.Static.GetPressedKeys(m_pressedKeys); AddPressedKeys("Current keys : ", m_pressedKeys); m_texts.Add(StringBuilderCache.Clear()); m_texts.Add(m_frameDebugText); m_rightAlignedtexts.Add(m_frameDebugTextRA); Vector2 origin = GetScreenLeftTopPosition(); Vector2 rightAlignedOrigin = GetScreenRightTopPosition(); for (int i = 0; i < m_texts.Count; i++) { MyGuiManager.DrawString(MyFontEnum.White, m_texts[i], origin + new Vector2(0, i * rowDistance), textScale, Color.Yellow, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP); } for (int i = 0; i < m_rightAlignedtexts.Count; i++) { MyGuiManager.DrawString(MyFontEnum.White, m_rightAlignedtexts[i], rightAlignedOrigin + new Vector2(-0.3f, i * rowDistance), textScale, Color.Yellow, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP); } ClearFrameDebugText(); AddPerformanceCountersToFrameDebugText(); #if DEBUG //list of last played sounds MyGuiManager.DrawString(MyFontEnum.White, new StringBuilder("Last played sounds:"), rightAlignedOrigin + new Vector2(-0.3f, 0.8f), textScale, Color.Yellow, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP); int colorIndex = (MyCueBank.lastSoundIndex > 0) ? (MyCueBank.lastSoundIndex - 1) : (MyCueBank.lastSounds.Count - 1);//index of last sound for (int i = 0; i < MyCueBank.lastSounds.Count; i++) { MyGuiManager.DrawString(MyFontEnum.White, MyCueBank.lastSounds[i], rightAlignedOrigin + new Vector2(-0.275f, 0.8f + (1 + i) * rowDistance), textScale, (i == colorIndex ? Color.LightBlue : Color.Yellow), MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP); } #endif return(true); }
public override bool Draw() { if (!base.Draw()) { return(false); } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Credits //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// float movingY = m_scrollingPositionY; var font = MyFontEnum.GameCredits; for (int i = 0; i < MyPerGameSettings.Credits.Departments.Count; i++) { MyGuiManager.DrawString(font, MyPerGameSettings.Credits.Departments[i].Name, new Vector2(0.5f, movingY), 0.78f, ChangeTextAlpha(color, movingY), MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER); movingY += 0.05f; for (int j = 0; j < MyPerGameSettings.Credits.Departments[i].Persons.Count; j++) { MyGuiManager.DrawString(font, MyPerGameSettings.Credits.Departments[i].Persons[j].Name, new Vector2(0.5f, movingY), 1.04f, ChangeTextAlpha(color, movingY), MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER); movingY += 0.05f; } movingY += 0.04f; } movingY += 0.05f; for (int i = 0; i < MyPerGameSettings.Credits.CreditNotices.Count; i++) { var notice = MyPerGameSettings.Credits.CreditNotices[i]; if (notice.LogoTexture != null) { if (notice.LogoNormalizedSize.HasValue) { MyGuiManager.DrawSpriteBatch( notice.LogoTexture, new Vector2(0.5f, movingY), notice.LogoNormalizedSize.Value, ChangeTextAlpha(color, movingY), MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER); } else if (notice.LogoScale.HasValue) { MyGuiManager.DrawSpriteBatch( notice.LogoTexture, new Vector2(0.5f, movingY), notice.LogoScale.Value, ChangeTextAlpha(color, movingY), MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, 0.0f, Vector2.Zero); } else { throw new InvalidBranchException(); } movingY += notice.LogoOffset; } for (int j = 0; j < notice.CreditNoticeLines.Count; j++) { MyGuiManager.DrawString(font, notice.CreditNoticeLines[j], new Vector2(0.5f, movingY), 0.78f, ChangeTextAlpha(color, movingY), MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER); movingY += 0.025f; } movingY += 0.15f; } // This will start scrolling again after last word was scrolled through the top if (movingY <= 0) { ResetScrollingPositionY(); } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Company Logo - with shadow (thus drawing two times) //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// MyGuiSandbox.DrawGameLogo(m_transitionAlpha); return(true); }
public override void Draw() { base.Draw(); m_frameDebugText.Clear(); m_frameDebugText.AppendFormat("RenderableObjects: {0: #,0}", MyPerformanceCounter.PerCameraDraw11Read.RenderableObjectsNum); m_frameDebugText.AppendLine(); m_frameDebugText.AppendFormat("ViewFrustumObjects: {0: #,0}", MyPerformanceCounter.PerCameraDraw11Read.ViewFrustumObjectsNum); m_frameDebugText.AppendLine(); m_frameDebugText.AppendFormat("Cascade0 Objects: {0: #,0}", MyPerformanceCounter.PerCameraDraw11Read.Cascade0ObjectsNum); m_frameDebugText.AppendLine(); m_frameDebugText.AppendFormat("Cascade1 Objects: {0: #,0}", MyPerformanceCounter.PerCameraDraw11Read.Cascade1ObjectsNum); m_frameDebugText.AppendLine(); m_frameDebugText.AppendFormat("Cascade2 Objects: {0: #,0}", MyPerformanceCounter.PerCameraDraw11Read.Cascade2ObjectsNum); m_frameDebugText.AppendLine(); m_frameDebugText.AppendFormat("Cascade3 Objects: {0: #,0}", MyPerformanceCounter.PerCameraDraw11Read.Cascade3ObjectsNum); m_frameDebugText.AppendLine(); m_frameDebugText.AppendFormat("MeshesDrawn: {0: #,0}", MyPerformanceCounter.PerCameraDraw11Read.MeshesDrawn); m_frameDebugText.AppendLine(); m_frameDebugText.AppendFormat("SubmeshesDrawn: {0: #,0}", MyPerformanceCounter.PerCameraDraw11Read.SubmeshesDrawn); m_frameDebugText.AppendLine(); m_frameDebugText.AppendFormat("ObjectConstantsChanges: {0: #,0}", MyPerformanceCounter.PerCameraDraw11Read.ObjectConstantsChanges); m_frameDebugText.AppendLine(); m_frameDebugText.AppendFormat("MaterialConstantsChanges: {0: #,0}", MyPerformanceCounter.PerCameraDraw11Read.MaterialConstantsChanges); m_frameDebugText.AppendLine(); m_frameDebugText.AppendFormat("Triangles: {0: #,0}", MyPerformanceCounter.PerCameraDraw11Read.TrianglesDrawn); m_frameDebugText.AppendLine(); m_frameDebugText.AppendFormat("Instances: {0: #,0}", MyPerformanceCounter.PerCameraDraw11Read.InstancesDrawn); m_frameDebugText.AppendLine(); m_frameDebugText.AppendLine(); m_frameDebugText.AppendFormat("DrawIndexed: {0}", MyPerformanceCounter.PerCameraDraw11Read.DrawIndexed); m_frameDebugText.AppendLine(); m_frameDebugText.AppendFormat("DrawIndexedInstanced: {0: #,0}", MyPerformanceCounter.PerCameraDraw11Read.DrawIndexedInstanced); m_frameDebugText.AppendLine(); m_frameDebugText.AppendFormat("DrawAuto: {0: #,0}", MyPerformanceCounter.PerCameraDraw11Read.DrawAuto); m_frameDebugText.AppendLine(); m_frameDebugText.AppendFormat("SetVB: {0: #,0}", MyPerformanceCounter.PerCameraDraw11Read.SetVB); m_frameDebugText.AppendLine(); m_frameDebugText.AppendFormat("SetIB: {0: #,0}", MyPerformanceCounter.PerCameraDraw11Read.SetIB); m_frameDebugText.AppendLine(); m_frameDebugText.AppendFormat("BindShaderResources: {0: #,0}", MyPerformanceCounter.PerCameraDraw11Read.BindShaderResources); m_frameDebugText.AppendLine(); m_frameDebugText.AppendFormat("SetIL: {0: #,0}", MyPerformanceCounter.PerCameraDraw11Read.SetIL); m_frameDebugText.AppendLine(); m_frameDebugText.AppendFormat("SetVS: {0: #,0}", MyPerformanceCounter.PerCameraDraw11Read.SetVS); m_frameDebugText.AppendLine(); m_frameDebugText.AppendFormat("SetPS: {0: #,0}", MyPerformanceCounter.PerCameraDraw11Read.SetPS); m_frameDebugText.AppendLine(); m_frameDebugText.AppendFormat("SetCB: {0: #,0}", MyPerformanceCounter.PerCameraDraw11Read.SetCB); m_frameDebugText.AppendLine(); m_frameDebugText.AppendFormat("SetPS: {0: #,0}", MyPerformanceCounter.PerCameraDraw11Read.SetPS); m_frameDebugText.AppendLine(); m_frameDebugText.AppendFormat("SetRasterizerState: {0: #,0}", MyPerformanceCounter.PerCameraDraw11Read.SetRasterizerState); m_frameDebugText.AppendLine(); m_frameDebugText.AppendFormat("SetBlendState: {0: #,0}", MyPerformanceCounter.PerCameraDraw11Read.SetBlendState); m_frameDebugText.AppendLine(); Vector2 origin = GetScreenLeftTopPosition(); MyGuiManager.DrawString(MyFontEnum.White, m_frameDebugText, origin, 1); }
public override void Draw() { base.Draw(); //VRageRender.MyRenderProxy.DebugDrawAABB(m_cubeBuilderAABB, Vector3.One, 1, 1, false); if (BlockCreationIsActivated) { MyHud.Crosshair.Position = MyHudCrosshair.ScreenCenter; } if (IsActivated) { if (DynamicMode) { CurrentGrid = null; CurrentVoxelMap = null; } else { ChoosePlacementObject(); } } if (ShipCreationIsActivated) { m_shipCreationClipboard.Update(); ShipCreationClipboard.CalculateRotationHints(m_rotationHints, m_rotationHintRotating); } else if (CopyPasteIsActivated) { Clipboard.CalculateRotationHints(m_rotationHints, m_rotationHintRotating); } else if (CopyPasteFloatingObjectIsActivated) { FloatingObjectClipboard.CalculateRotationHints(m_rotationHints, m_rotationHintRotating); } else if (MultiBlockCreationIsActivated) { m_multiBlockCreationClipboard.Update(); m_multiBlockCreationClipboard.CalculateRotationHints(m_rotationHints, false); } if (!BuildInputValid || MultiBlockCreationIsActivated || ShipCreationIsActivated || CopyPasteIsActivated || CopyPasteFloatingObjectIsActivated) { m_renderData.ClearInstanceData(); m_renderData.UpdateRenderInstanceData(); m_renderData.UpdateRenderEntitiesData(CurrentGrid != null ? CurrentGrid.WorldMatrix : MatrixD.Identity, UseTransparency); if (!ShipCreationIsActivated && !CopyPasteIsActivated && !MultiBlockCreationIsActivated) { m_rotationHints.Clear(); VRageRender.MyRenderProxy.RemoveBillboardViewProjection(0); } if (MyFakes.ENABLE_DEBUG_DRAW_TEXTURE_NAMES) { DebugDrawModelTextures(); } if (MyFakes.ENABLE_DEBUG_DRAW_GENERATING_BLOCK) { DebugDrawGeneratingBlock(); } if (MultiBlockCreationIsActivated) { UpdateBlockInfoHud(); } return; } var startPosition = m_gizmo.SpaceDefault.m_startBuild ?? m_gizmo.SpaceDefault.m_startRemove; if (startPosition != null && m_gizmo.SpaceDefault.m_continueBuild != null) { Vector3I rotatedSize; Vector3I.TransformNormal(ref CurrentBlockDefinition.Size, ref m_gizmo.SpaceDefault.m_localMatrixAdd, out rotatedSize); rotatedSize = Vector3I.Abs(rotatedSize); int stepCount; Vector3I stepDelta; Vector3I counter; ComputeSteps(startPosition.Value, m_gizmo.SpaceDefault.m_continueBuild.Value, m_gizmo.SpaceDefault.m_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); } bool addPos = m_gizmo.SpaceDefault.m_startBuild.HasValue; bool removePos = false; if (DynamicMode) { Vector3D freePlacementIntersectionPoint = GetFreeSpacePlacementPosition(out m_gizmo.SpaceDefault.m_dynamicBuildAllowed); m_gizmo.SpaceDefault.m_worldMatrixAdd.Translation = freePlacementIntersectionPoint; addPos = true; } else { if (m_gizmo.SpaceDefault.m_startBuild == null && m_gizmo.SpaceDefault.m_startRemove == null) { if (!FreezeGizmo) { float gridSize = MyDefinitionManager.Static.GetCubeSize(CurrentBlockDefinition.CubeSize); addPos = GetAddAndRemovePositions(gridSize, PlacingSmallGridOnLargeStatic, out m_gizmo.SpaceDefault.m_addPos, out m_gizmo.SpaceDefault.m_addPosSmallOnLarge, out m_gizmo.SpaceDefault.m_addDir, out m_gizmo.SpaceDefault.m_removePos, out m_gizmo.SpaceDefault.m_removeBlock, out m_gizmo.SpaceDefault.m_blockIdInCompound); } if (addPos) { if (PlacingSmallGridOnLargeStatic) { m_gizmo.SpaceDefault.m_localMatrixAdd.Translation = m_gizmo.SpaceDefault.m_addPosSmallOnLarge.Value; } else { m_gizmo.SpaceDefault.m_localMatrixAdd.Translation = m_gizmo.SpaceDefault.m_addPos; } if (CurrentGrid != null) { m_gizmo.SpaceDefault.m_worldMatrixAdd = m_gizmo.SpaceDefault.m_localMatrixAdd * CurrentGrid.WorldMatrix; } else { m_gizmo.SpaceDefault.m_worldMatrixAdd = m_gizmo.SpaceDefault.m_localMatrixAdd; } Debug.Assert(!m_gizmo.SpaceDefault.m_worldMatrixAdd.IsNan(), "Invalid gizmo matrix"); if (m_gizmo.SpaceDefault.m_removeBlock != null) { removePos = true; } } } } bool buildingDisabledByCockpit = MySession.ControlledEntity != null && MySession.ControlledEntity is MyCockpit && !SpectatorIsBuilding; //bool buildingDisabledByCockpit = true; if (!buildingDisabledByCockpit) { if (IsInSymmetrySettingMode) { m_gizmo.SpaceDefault.m_continueBuild = null; addPos = false; removePos = false; if (m_gizmo.SpaceDefault.m_removeBlock != null) { var min = (m_gizmo.SpaceDefault.m_removeBlock.Min * CurrentGrid.GridSize); var max = (m_gizmo.SpaceDefault.m_removeBlock.Max * CurrentGrid.GridSize); Vector3 center = (min + max) * 0.5f; Color color = DrawSymmetryPlane(m_symmetrySettingMode, CurrentGrid, center); DrawSemiTransparentBox(CurrentGrid, m_gizmo.SpaceDefault.m_removeBlock, color.ToVector4()); } } if (CurrentGrid != null && (UseSymmetry || IsInSymmetrySettingMode)) { if (CurrentGrid.XSymmetryPlane != null) { Vector3 center = CurrentGrid.XSymmetryPlane.Value * CurrentGrid.GridSize; DrawSymmetryPlane(CurrentGrid.XSymmetryOdd ? MySymmetrySettingModeEnum.XPlaneOdd : MySymmetrySettingModeEnum.XPlane, CurrentGrid, center); } if (CurrentGrid.YSymmetryPlane != null) { Vector3 center = CurrentGrid.YSymmetryPlane.Value * CurrentGrid.GridSize; DrawSymmetryPlane(CurrentGrid.YSymmetryOdd ? MySymmetrySettingModeEnum.YPlaneOdd : MySymmetrySettingModeEnum.YPlane, CurrentGrid, center); } if (CurrentGrid.ZSymmetryPlane != null) { Vector3 center = CurrentGrid.ZSymmetryPlane.Value * CurrentGrid.GridSize; DrawSymmetryPlane(CurrentGrid.ZSymmetryOdd ? MySymmetrySettingModeEnum.ZPlaneOdd : MySymmetrySettingModeEnum.ZPlane, CurrentGrid, center); } } } UpdateGizmos(addPos, removePos, true); m_renderData.UpdateRenderInstanceData(); if (DynamicMode || CurrentVoxelMap != null) { MatrixD drawMatrix = m_gizmo.SpaceDefault.m_worldMatrixAdd; Vector3D rotatedModelOffset; Vector3D.TransformNormal(ref CurrentBlockDefinition.ModelOffset, ref drawMatrix, out rotatedModelOffset); drawMatrix.Translation = drawMatrix.Translation + rotatedModelOffset; m_renderData.UpdateRenderEntitiesData(drawMatrix, UseTransparency); } else { m_renderData.UpdateRenderEntitiesData(CurrentGrid != null ? CurrentGrid.WorldMatrix : MatrixD.Identity, UseTransparency); } UpdateBlockInfoHud(); DebugDraw(); }
private void DrawRows(float transitionAlpha) { var positionTopLeft = GetPositionAbsoluteTopLeft() + m_rowsArea.Position; for (int i = 0; i < VisibleRowsCount; ++i) { Debug.Assert(m_visibleRowIndexOffset >= 0); var idx = i + m_visibleRowIndexOffset; if (idx >= m_rows.Count) { break; } Debug.Assert(idx >= 0); if (idx < 0) { continue; } bool highlightRow = (m_mouseOverRowIndex.HasValue && m_mouseOverRowIndex.Value == idx) || (SelectedRowIndex.HasValue && SelectedRowIndex.Value == idx); var rowFont = m_styleDef.RowFontNormal; if (highlightRow) { MyGuiManager.DrawSpriteBatch(m_styleDef.RowTextureHighlight, positionTopLeft, new Vector2(m_rowsArea.Size.X, RowHeight), ApplyColorMaskModifiers(ColorMask, Enabled, transitionAlpha), MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP); rowFont = m_styleDef.RowFontHighlight; } var row = m_rows[idx]; Debug.Assert(row != null); if (row != null) { var cellPos = positionTopLeft; for (int j = 0; j < ColumnsCount; ++j) { if (j >= row.Cells.Count) { break; } var cell = row.Cells[j]; var meta = m_columnsMetaData[j]; var cellSize = new Vector2(meta.Width * m_rowsArea.Size.X, RowHeight); if (cell != null && cell.Text != null) { if (cell.Icon.HasValue) { var iconPosition = MyUtils.GetCoordAlignedFromTopLeft(cellPos, cellSize, cell.IconOriginAlign); var icon = cell.Icon.Value; var ratios = Vector2.Min(icon.SizeGui, cellSize) / 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: cell.IconOriginAlign); } var textPos = MyUtils.GetCoordAlignedFromCenter(cellPos + 0.5f * cellSize, cellSize, meta.TextAlign); MyGuiManager.DrawString(rowFont, cell.Text, textPos, TextScaleWithLanguage, (cell.TextColor != null) ? cell.TextColor : ApplyColorMaskModifiers(ColorMask, Enabled, transitionAlpha), meta.TextAlign, maxTextWidth: cellSize.X); } cellPos.X += cellSize.X; } } positionTopLeft.Y += RowHeight; } }
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 override void Draw(float transitionAlpha, float backgroundTransitionAlpha) { Debug.Assert(m_visibleRowIndexOffset >= 0); base.Draw(transitionAlpha, backgroundTransitionAlpha); var positionTopLeft = GetPositionAbsoluteTopLeft(); m_styleDef.Texture.Draw(positionTopLeft, Size, ApplyColorMaskModifiers(ColorMask, Enabled, backgroundTransitionAlpha)); var position = positionTopLeft + new Vector2(m_itemsRectangle.X, m_itemsRectangle.Y); int index = m_visibleRowIndexOffset; //if at least one item has an icon, draw it with spacing to all of them (alighment) Vector2 iconSize = Vector2.Zero; Vector2 iconOffset = Vector2.Zero; if (ShouldDrawIconSpacing()) { iconSize = MyGuiConstants.LISTBOX_ICON_SIZE; iconOffset = MyGuiConstants.LISTBOX_ICON_OFFSET; } for (int i = 0; i < VisibleRowsCount; ++i) { var idx = i + m_visibleRowIndexOffset; if (idx >= Items.Count) { break; } Debug.Assert(idx >= 0); if (idx < 0) { continue; } while (index < Items.Count && !Items[index].Visible) { index++; } if (index >= Items.Count) { break; } var item = Items[index]; index++; if (item != null) { Color color = ApplyColorMaskModifiers(item.ColorMask * ColorMask, Enabled, transitionAlpha); bool isHighlit = SelectedItems.Contains(item) || item == m_mouseOverItem; MyFontEnum font = item.FontOverride ?? (isHighlit ? m_styleDef.ItemFontHighlight : m_styleDef.ItemFontNormal); if (isHighlit) { MyGuiManager.DrawSpriteBatch(m_styleDef.ItemTextureHighlight, position, ItemSize, color, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP); } if (!String.IsNullOrEmpty(item.Icon)) { MyGuiManager.DrawSpriteBatch( texture: item.Icon, normalizedCoord: position + iconOffset, normalizedSize: iconSize, color: color, drawAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP ); } MyGuiManager.DrawString(font, item.Text, position + new Vector2(iconSize.X + 2 * iconOffset.X, 0) + new Vector2(m_styleDef.TextOffset, 0f), TextScale, color, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, maxTextWidth: ItemSize.X - iconSize.X - 2 * iconOffset.X); } position.Y += ItemSize.Y; } //DebugDraw(); if (m_styleDef.DrawScroll) { m_scrollBar.Draw(ApplyColorMaskModifiers(ColorMask, Enabled, transitionAlpha)); } }
public override void Draw() { /* * int count = m_allToolTips.Keys.Count; * for (int c = 0; c < count; c++) * { * MyGuiManager.DrawSpriteBatch(m_selectedTexture, m_parentScreen.GetPosition() + m_position, m_size.Value, * GetColorAfterTransitionAlpha(m_backgroundColor.Value), MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER); * } */ //base.Draw(); //draw buttons on head with texts int count = m_tabs.Keys.Count; int pos = 0; foreach (int i in m_tabs.Keys) { MyTexture2D buttonTexture = MyGuiManager.GetButtonTexture(); Vector2 parentPos = m_parent.GetPositionAbsolute(); Vector2? parentSize = m_parent.GetSize(); parentPos -= parentSize.Value / 2; Vector2 offsetPos = parentPos + pos * new Vector2(m_headSize.X * parentSize.Value.X / count, 0); Vector2 tabHeadSize = new Vector2((m_headSize.X / (count)) * parentSize.Value.X, (m_headSize.Y) * parentSize.Value.Y); bool isHighlight = GetMouseOverTab() == i || GetSelectedTab() == i; bool isNotImplementedForbidenOrDisabled = /*!m_implementedFeature || m_accessForbiddenReason != null ||*/ !Enabled; /* * bool isHighlighted = IsMouseOverOrKeyboardActive() && * (m_highlightType == MyGuiControlHighlightType.WHEN_ACTIVE || (m_highlightType == MyGuiControlHighlightType.WHEN_CURSOR_OVER && IsMouseOver())); */ Vector4 backgroundColor = isNotImplementedForbidenOrDisabled ? MyGuiConstants.DISABLED_BUTTON_COLOR_VECTOR : (isHighlight ? m_backgroundColor.Value * MyGuiConstants.CONTROL_MOUSE_OVER_BACKGROUND_COLOR_MULTIPLIER : m_backgroundColor.Value); backgroundColor.W = 1.0f; // Draw background texture MyGuiManager.DrawSpriteBatch(buttonTexture, offsetPos, tabHeadSize * m_scale, new Color(backgroundColor), MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP); Vector4 textColor = isNotImplementedForbidenOrDisabled ? textColor = MyGuiConstants.DISABLED_BUTTON_TEXT_COLOR : ((isHighlight) ? m_color * MyGuiConstants.CONTROL_MOUSE_OVER_BACKGROUND_COLOR_MULTIPLIER : m_color); StringBuilder text = new StringBuilder(GetTabSubControl(i).GetCaption()); if (text != null) { Vector2 textPosition; MyGuiDrawAlignEnum textDrawAlign; textPosition = offsetPos + tabHeadSize / 2; textDrawAlign = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER; /* * if (m_textAlignment == MyGuiControlButtonTextAlignment.CENTERED) * { * textPosition = m_parentScreen.GetPosition() + m_position; * textDrawAlign = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER; * } * else if (m_textAlignment == MyGuiControlButtonTextAlignment.LEFT) * { * // This will move text few pixels from button's left border * textPosition = m_parentScreen.GetPosition() + m_position - new Vector2(m_size.Value.X / 2.0f, 0) + new Vector2(MyGuiConstants.BUTTON_TEXT_OFFSET.X, 0); * textDrawAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER; * } * else * { * throw new MyMwcExceptionApplicationShouldNotGetHere(); * } */ MyGuiManager.DrawString(MyGuiManager.GetFontMinerWarsWhite(), text, textPosition, 1.2f /*m_textScale*/, GetColorAfterTransitionAlpha(textColor), textDrawAlign); } pos++; } //base.Draw(); GetTabSubControl(m_selectedTab).Draw(); }
// Draw all screens public void Draw() { VRageRender.MyRenderProxy.GetRenderProfiler().StartProfilingBlock("MyGuiSandbox::Draw"); MyGuiManager.Camera = MySector.MainCamera != null ? MySector.MainCamera.WorldMatrix : VRageMath.MatrixD.Identity; MyGuiManager.CameraView = MySector.MainCamera != null ? MySector.MainCamera.ViewMatrix : VRageMath.MatrixD.Identity; MyTransparentGeometry.Camera = MyGuiManager.Camera; MyTransparentGeometry.CameraView = MyGuiManager.CameraView; ProfilerShort.Begin("ScreenManager.Draw"); MyScreenManager.Draw(); ProfilerShort.End(); m_debugText.Clear(); if (MyInput.Static.ENABLE_DEVELOPER_KEYS && MySandboxGame.Config.DebugComponentsInfo != MyDebugComponent.MyDebugComponentInfoState.NoInfo) { var h = 0f; var i = 0; bool drawBackground = false; MyDebugComponent.ResetFrame(); foreach (var userInputComponent in UserDebugInputComponents) { if (userInputComponent.Enabled) { if (h == 0) { m_debugText.AppendLine("Debug input:"); m_debugText.AppendLine(); h += 0.0630f; } m_debugText.ConcatFormat("{0} (Ctrl + numPad{1})", UserDebugInputComponents[i].GetName(), i); m_debugText.AppendLine(); h += 0.0265f; if (MySession.Static != null) { userInputComponent.DispatchUpdate(); } userInputComponent.Draw(); drawBackground = true; } ++i; } if (drawBackground) { MyGuiManager.DrawSpriteBatch(@"Textures\GUI\Controls\rectangle_dark_center.dds", new Vector2(MyGuiManager.GetMaxMouseCoord().X, 0f), new Vector2(MyGuiManager.MeasureString(MyFontEnum.White, m_debugText, 1f).X + 0.012f, h), new Color(0, 0, 0, 130), MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP); MyGuiManager.DrawString(MyFontEnum.White, m_debugText, new Vector2(MyGuiManager.GetMaxMouseCoord().X - 0.01f, 0f), 1f, Color.White, MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP); } } bool hwCursor = MyVideoSettingsManager.IsHardwareCursorUsed(); var screenWithFocus = MyScreenManager.GetScreenWithFocus(); if (((screenWithFocus != null) && (screenWithFocus.GetDrawMouseCursor() == true)) || (MyScreenManager.InputToNonFocusedScreens && MyScreenManager.GetScreensCount() > 1)) { #if XB1 SetMouseCursorVisibility(false, false); DrawMouseCursor(GetMouseOverTexture(screenWithFocus)); #else SetMouseCursorVisibility(hwCursor, false); if (!hwCursor || MyFakes.FORCE_SOFTWARE_MOUSE_DRAW) { DrawMouseCursor(GetMouseOverTexture(screenWithFocus)); } #endif } else { if (hwCursor) { if (screenWithFocus != null) { SetMouseCursorVisibility(screenWithFocus.GetDrawMouseCursor()); } } } VRageRender.MyRenderProxy.GetRenderProfiler().EndProfilingBlock(); }
/// <summary> /// Draws text /// </summary> /// <param name="position">Top-left position</param> /// <returns></returns> public override bool Draw(Vector2 position) { MyGuiManager.DrawString(m_font, m_text, position, m_scale, new Color(m_color), MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP); return(true); }
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() { base.Draw(); m_frameDebugText.Clear(); m_frameDebugText2.Clear(); m_frameDebugText.AppendFormat("RenderableObjects: {0: #,0}", MyPerformanceCounter.PerCameraDraw11Read.RenderableObjectsNum); m_frameDebugText.AppendLine(); m_frameDebugText.AppendFormat("ViewFrustumObjects: {0: #,0}", MyPerformanceCounter.PerCameraDraw11Read.ViewFrustumObjectsNum); m_frameDebugText.AppendLine(); for (int cascadeIndex = 0; cascadeIndex < MyRenderProxy.Settings.ShadowCascadeCount; ++cascadeIndex) { m_frameDebugText.AppendFormat("Cascade" + cascadeIndex.ToString() + " Objects: {0: #,0}", MyPerformanceCounter.PerCameraDraw11Read.ShadowCascadeObjectsNum[cascadeIndex]); m_frameDebugText.AppendLine(); } m_frameDebugText.AppendFormat("MeshesDrawn: {0: #,0}", MyPerformanceCounter.PerCameraDraw11Read.MeshesDrawn); m_frameDebugText.AppendLine(); m_frameDebugText.AppendFormat("SubmeshesDrawn: {0: #,0}", MyPerformanceCounter.PerCameraDraw11Read.SubmeshesDrawn); m_frameDebugText.AppendLine(); m_frameDebugText.AppendFormat("BillboardsDrawn: {0: #,0}", MyPerformanceCounter.PerCameraDraw11Read.BillboardsDrawn); m_frameDebugText.AppendLine(); m_frameDebugText.AppendFormat("ObjectConstantsChanges: {0: #,0}", MyPerformanceCounter.PerCameraDraw11Read.ObjectConstantsChanges); m_frameDebugText.AppendLine(); m_frameDebugText.AppendFormat("MaterialConstantsChanges: {0: #,0}", MyPerformanceCounter.PerCameraDraw11Read.MaterialConstantsChanges); m_frameDebugText.AppendLine(); m_frameDebugText.AppendFormat("Triangles: {0: #,0}", MyPerformanceCounter.PerCameraDraw11Read.TrianglesDrawn); m_frameDebugText.AppendLine(); for (int cascadeIndex = 0; cascadeIndex < MyRenderProxy.Settings.ShadowCascadeCount; ++cascadeIndex) { m_frameDebugText.AppendFormat("Cascade" + cascadeIndex.ToString() + " Triangles: {0: #,0}", MyPerformanceCounter.PerCameraDraw11Read.ShadowCascadeTriangles[cascadeIndex]); m_frameDebugText.AppendLine(); } m_frameDebugText.AppendFormat("Other shadow Triangles: {0: #,0}", MyPerformanceCounter.PerCameraDraw11Read.OtherShadowTriangles); m_frameDebugText.AppendLine(); m_frameDebugText.AppendFormat("Instances: {0: #,0}", MyPerformanceCounter.PerCameraDraw11Read.InstancesDrawn); m_frameDebugText2.AppendFormat("DrawIndexed: {0}", MyPerformanceCounter.PerCameraDraw11Read.DrawIndexed); m_frameDebugText2.AppendLine(); m_frameDebugText2.AppendFormat("DrawIndexedInstanced: {0: #,0}", MyPerformanceCounter.PerCameraDraw11Read.DrawIndexedInstanced); m_frameDebugText2.AppendLine(); m_frameDebugText2.AppendFormat("DrawAuto: {0: #,0}", MyPerformanceCounter.PerCameraDraw11Read.DrawAuto); m_frameDebugText2.AppendLine(); m_frameDebugText2.AppendFormat("Shadow DrawIndexed: {0: #,0}", MyPerformanceCounter.PerCameraDraw11Read.ShadowDrawIndexed); m_frameDebugText2.AppendLine(); m_frameDebugText2.AppendFormat("Shadow DrawIndexedInstanced: {0: #,0}", MyPerformanceCounter.PerCameraDraw11Read.ShadowDrawIndexedInstanced); m_frameDebugText2.AppendLine(); m_frameDebugText2.AppendFormat("Billboard DrawCalls: {0: #,0}", MyPerformanceCounter.PerCameraDraw11Read.BillboardDrawCalls); m_frameDebugText2.AppendLine(); m_frameDebugText2.AppendFormat("SetVB: {0: #,0}", MyPerformanceCounter.PerCameraDraw11Read.SetVB); m_frameDebugText2.AppendLine(); m_frameDebugText2.AppendFormat("SetIB: {0: #,0}", MyPerformanceCounter.PerCameraDraw11Read.SetIB); m_frameDebugText2.AppendLine(); m_frameDebugText2.AppendFormat("BindShaderResources: {0: #,0}", MyPerformanceCounter.PerCameraDraw11Read.BindShaderResources); m_frameDebugText2.AppendLine(); m_frameDebugText2.AppendFormat("SetIL: {0: #,0}", MyPerformanceCounter.PerCameraDraw11Read.SetIL); m_frameDebugText2.AppendLine(); m_frameDebugText2.AppendFormat("SetVS: {0: #,0}", MyPerformanceCounter.PerCameraDraw11Read.SetVS); m_frameDebugText2.AppendLine(); m_frameDebugText2.AppendFormat("SetPS: {0: #,0}", MyPerformanceCounter.PerCameraDraw11Read.SetPS); m_frameDebugText2.AppendLine(); m_frameDebugText2.AppendFormat("SetCB: {0: #,0}", MyPerformanceCounter.PerCameraDraw11Read.SetCB); m_frameDebugText2.AppendLine(); m_frameDebugText2.AppendFormat("SetPS: {0: #,0}", MyPerformanceCounter.PerCameraDraw11Read.SetPS); m_frameDebugText2.AppendLine(); m_frameDebugText2.AppendFormat("SetRasterizerState: {0: #,0}", MyPerformanceCounter.PerCameraDraw11Read.SetRasterizerState); m_frameDebugText2.AppendLine(); m_frameDebugText2.AppendFormat("SetBlendState: {0: #,0}", MyPerformanceCounter.PerCameraDraw11Read.SetBlendState); m_frameDebugText2.AppendLine(); Vector2 origin = GetScreenLeftTopPosition(); Vector2 horizontalOffset = origin + new Vector2(0.5f, 0.0f); MyGuiManager.DrawString(MyFontEnum.White, m_frameDebugText, origin, 1); MyGuiManager.DrawString(MyFontEnum.White, m_frameDebugText2, origin + horizontalOffset, 1); }
public override bool Draw() { if (!base.Draw()) { return(false); } float rowDistance = MyGuiConstants.DEBUG_STATISTICS_ROW_DISTANCE; float textScale = MyGuiConstants.DEBUG_STATISTICS_TEXT_SCALE; m_stringIndex = 0; m_texts.Clear(); m_rightAlignedtexts.Clear(); m_texts.Add(StringBuilderCache.GetFormatedFloat("FPS: ", MyFpsManager.GetFps())); m_texts.Add(new StringBuilder("Renderer: ").Append(MyRenderProxy.RendererInterfaceName())); m_texts.Add(MyScreenManager.GetGuiScreensForDebug()); m_texts.Add(StringBuilderCache.GetFormatedBool("Paused: ", MySandboxGame.IsPaused)); m_texts.Add(StringBuilderCache.GetFormatedDateTimeOffset("System Time: ", TimeUtil.LocalTime)); m_texts.Add(StringBuilderCache.GetFormatedTimeSpan("Total GAME-PLAY Time: ", TimeSpan.FromMilliseconds(MySandboxGame.TotalGamePlayTimeInMilliseconds))); m_texts.Add(StringBuilderCache.GetFormatedTimeSpan("Total Session Time: ", MySession.Static == null ? new TimeSpan(0) : MySession.Static.ElapsedPlayTime)); m_texts.Add(StringBuilderCache.GetFormatedTimeSpan("Total Foot Time: ", MySession.Static == null ? new TimeSpan(0) : MySession.Static.TimeOnFoot)); m_texts.Add(StringBuilderCache.GetFormatedTimeSpan("Total Jetpack Time: ", MySession.Static == null ? new TimeSpan(0) : MySession.Static.TimeOnJetpack)); m_texts.Add(StringBuilderCache.GetFormatedTimeSpan("Total Small Ship Time: ", MySession.Static == null ? new TimeSpan(0) : MySession.Static.TimeOnSmallShip)); m_texts.Add(StringBuilderCache.GetFormatedTimeSpan("Total Big Ship Time: ", MySession.Static == null ? new TimeSpan(0) : MySession.Static.TimeOnBigShip)); m_texts.Add(StringBuilderCache.GetFormatedTimeSpan("Total Time: ", TimeSpan.FromMilliseconds(MySandboxGame.TotalTimeInMilliseconds))); m_texts.Add(StringBuilderCache.GetFormatedLong("GC.GetTotalMemory: ", GC.GetTotalMemory(false), " bytes")); if (MyFakes.DETECT_LEAKS) { var o = SharpDX.Diagnostics.ObjectTracker.FindActiveObjects(); m_texts.Add(StringBuilderCache.GetFormatedInt("SharpDX Active object count: ", o.Count)); } //TODO: I am unable to show this without allocations m_texts.Add(StringBuilderCache.GetFormatedLong("Environment.WorkingSet: ", WinApi.WorkingSet, " bytes")); // TODO: OP! Get available texture memory //m_texts.Add(StringBuilderCache.GetFormatedFloat("Available videomemory: ", MySandboxGame.Static.GraphicsDevice.AvailableTextureMemory / (1024.0f * 1024.0f), " MB")); m_texts.Add(StringBuilderCache.GetFormatedFloat("Allocated videomemory: ", 0, " MB")); #if PHYSICS_SENSORS_PROFILING if (MyPhysics.physicsSystem != null) { m_texts.Add(StringBuilderCache.GetFormatedInt("Physics sensor - new allocated interactions: ", MyPhysics.physicsSystem.GetSensorInteractionModule().GetNewAllocatedInteractionsCount())); m_texts.Add(StringBuilderCache.GetFormatedInt("Physics sensor - interactions in use: ", MyPhysics.physicsSystem.GetSensorInteractionModule().GetInteractionsInUseCount())); m_texts.Add(StringBuilderCache.GetFormatedInt("Physics sensor - interactions in use MAX: ", MyPhysics.physicsSystem.GetSensorInteractionModule().GetInteractionsInUseCountMax())); m_texts.Add(StringBuilderCache.GetFormatedInt("Physics sensor - all sensors: ", MyPhysics.physicsSystem.GetSensorModule().SensorsCount())); m_texts.Add(StringBuilderCache.GetFormatedInt("Physics sensor - active sensors: ", MyPhysics.physicsSystem.GetSensorModule().ActiveSensors.Count)); } #endif m_texts.Add(StringBuilderCache.GetFormatedInt("Sound Instances Total 2D: ", MyAudio.Static.GetSoundInstancesTotal2D())); m_texts.Add(StringBuilderCache.GetFormatedInt("Sound Instances Total 3D: ", MyAudio.Static.GetSoundInstancesTotal3D())); var tmp = StringBuilderCache; MyAudio.Static.WriteDebugInfo(tmp); m_texts.Add(tmp); for (int i = 0; i < 8; i++) { m_texts.Add(StringBuilderCache.Clear()); } m_texts.Add(StringBuilderCache.GetFormatedInt("Updating 3D sounds count: ", MyAudio.Static.GetUpdating3DSoundsCount())); m_texts.Add(StringBuilderCache.Clear()); m_texts.Add(StringBuilderCache.GetFormatedInt("Textures 2D Count: ", VRageRender.MyPerformanceCounter.PerAppLifetime.Textures2DCount)); m_texts.Add(StringBuilderCache.GetFormatedInt("Textures 2D Size In Pixels: ", VRageRender.MyPerformanceCounter.PerAppLifetime.Textures2DSizeInPixels)); m_texts.Add(StringBuilderCache.AppendFormatedDecimal("Textures 2D Size In Mb: ", (float)VRageRender.MyPerformanceCounter.PerAppLifetime.Textures2DSizeInMb, 3)); m_texts.Add(StringBuilderCache.GetFormatedInt("Dxt Compressed Textures Count: ", VRageRender.MyPerformanceCounter.PerAppLifetime.DxtCompressedTexturesCount)); m_texts.Add(StringBuilderCache.GetFormatedInt("Non Dxt Compressed Textures Count: ", VRageRender.MyPerformanceCounter.PerAppLifetime.NonDxtCompressedTexturesCount)); m_texts.Add(StringBuilderCache.GetFormatedInt("Non Mip Mapped Textures Count: ", VRageRender.MyPerformanceCounter.PerAppLifetime.NonMipMappedTexturesCount)); m_texts.Add(StringBuilderCache.GetFormatedInt("Texture Cubes Count: ", VRageRender.MyPerformanceCounter.PerAppLifetime.TextureCubesCount)); m_texts.Add(StringBuilderCache.GetFormatedInt("Texture Cubes Size In Pixels: ", VRageRender.MyPerformanceCounter.PerAppLifetime.TextureCubesSizeInPixels)); m_texts.Add(StringBuilderCache.AppendFormatedDecimal("Texture Cubes Size In Mb: ", (float)VRageRender.MyPerformanceCounter.PerAppLifetime.TextureCubesSizeInMb, 3)); m_texts.Add(StringBuilderCache.GetFormatedInt("Non MyModels Count: ", VRageRender.MyPerformanceCounter.PerAppLifetime.ModelsCount)); m_texts.Add(StringBuilderCache.GetFormatedInt("MyModels Count: ", VRageRender.MyPerformanceCounter.PerAppLifetime.MyModelsCount)); m_texts.Add(StringBuilderCache.GetFormatedInt("MyModels Meshes Count: ", VRageRender.MyPerformanceCounter.PerAppLifetime.MyModelsMeshesCount)); m_texts.Add(StringBuilderCache.GetFormatedInt("MyModels Vertexes Count: ", VRageRender.MyPerformanceCounter.PerAppLifetime.MyModelsVertexesCount)); m_texts.Add(StringBuilderCache.GetFormatedInt("MyModels Triangles Count: ", VRageRender.MyPerformanceCounter.PerAppLifetime.MyModelsTrianglesCount)); m_texts.Add(StringBuilderCache.GetFormatedFloat("Size of Model Vertex Buffers in Mb: ", (float)VRageRender.MyPerformanceCounter.PerAppLifetime.ModelVertexBuffersSize / (1024 * 1024))); m_texts.Add(StringBuilderCache.GetFormatedFloat("Size of Model Index Buffers in Mb: ", (float)VRageRender.MyPerformanceCounter.PerAppLifetime.ModelIndexBuffersSize / (1024 * 1024))); m_texts.Add(StringBuilderCache.GetFormatedInt("Size of Voxel Vertex Buffers in Mb: ", VRageRender.MyPerformanceCounter.PerAppLifetime.VoxelVertexBuffersSize / 1024 / 1024)); m_texts.Add(StringBuilderCache.GetFormatedInt("Size of Voxel Index Buffers in Mb: ", VRageRender.MyPerformanceCounter.PerAppLifetime.VoxelIndexBuffersSize / 1024 / 1024)); m_texts.Add(StringBuilderCache.GetFormatedFloat("Size of loaded Model files in Mb: ", (float)VRageRender.MyPerformanceCounter.PerAppLifetime.MyModelsFilesSize / (1024 * 1024))); m_texts.Add(StringBuilderCache.GetFormatedBool("Paused: ", MySandboxGame.IsPaused)); if (MySector.MainCamera != null) { m_texts.Add(GetFormatedVector3(StringBuilderCache, "Camera pos: ", MySector.MainCamera.Position)); } MyInput.Static.GetPressedKeys(m_pressedKeys); AddPressedKeys("Current keys : ", m_pressedKeys); m_texts.Add(StringBuilderCache.Clear()); m_texts.Add(m_frameDebugText); m_rightAlignedtexts.Add(m_frameDebugTextRA); Vector2 origin = GetScreenLeftTopPosition(); Vector2 rightAlignedOrigin = GetScreenRightTopPosition(); for (int i = 0; i < m_texts.Count; i++) { MyGuiManager.DrawString(MyFontEnum.White, m_texts[i], origin + new Vector2(0, i * rowDistance), textScale, Color.Yellow, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP); } for (int i = 0; i < m_rightAlignedtexts.Count; i++) { MyGuiManager.DrawString(MyFontEnum.White, m_rightAlignedtexts[i], rightAlignedOrigin + new Vector2(-0.3f, i * rowDistance), textScale, Color.Yellow, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP); } ClearFrameDebugText(); AddPerformanceCountersToFrameDebugText(); return(true); }
public override void Draw() { MyTexture2D buttonTexture = null; MyTexture2D backgroundTexture = null; if (m_controlTexture == null) { if (m_size.HasValue && m_size.Value.Y < MyGuiConstants.MAIN_MENU_BUTTON_SIZE.Y) { buttonTexture = MyGuiManager.GetConfirmButton(); } else { buttonTexture = MyGuiManager.GetButtonTexture(); } } else { if (IsMouseOver() && m_mouseButtonPressed && m_pressedTexture != null) { buttonTexture = m_pressedTexture; } else if (IsMouseOver() && m_hoverTexture != null) { buttonTexture = m_hoverTexture; } else { buttonTexture = m_controlTexture; } } backgroundTexture = MyGuiManager.GetButtonTextureBg(buttonTexture); bool isNotImplementedForbidenOrDisabled = !m_implementedFeature || m_accessForbiddenReason != null || !Enabled; Vector4 backgroundColor, textColor; if (!UseSwitchMode) { bool isHighlighted = IsMouseOverOrKeyboardActive() && (m_highlightType == MyGuiControlHighlightType.WHEN_ACTIVE || (m_highlightType == MyGuiControlHighlightType.WHEN_CURSOR_OVER && IsMouseOver())); backgroundColor = isNotImplementedForbidenOrDisabled ? (DrawRedTextureWhenDisabled ? MyGuiConstants.DISABLED_BUTTON_COLOR_VECTOR : m_backgroundColor.Value * MyGuiConstants.DISABLED_BUTTON_NON_RED_MULTIPLIER) : (isHighlighted ? m_backgroundColor.Value * MyGuiConstants.CONTROL_MOUSE_OVER_BACKGROUND_COLOR_MULTIPLIER : m_backgroundColor.Value); textColor = isNotImplementedForbidenOrDisabled ? (DrawRedTextureWhenDisabled ? MyGuiConstants.DISABLED_BUTTON_TEXT_COLOR : m_textColor * MyGuiConstants.DISABLED_BUTTON_NON_RED_MULTIPLIER) : (isHighlighted ? m_textColor * MyGuiConstants.CONTROL_MOUSE_OVER_BACKGROUND_COLOR_MULTIPLIER : m_textColor); } else { backgroundColor = isNotImplementedForbidenOrDisabled ? (DrawRedTextureWhenDisabled ? MyGuiConstants.DISABLED_BUTTON_COLOR_VECTOR : m_backgroundColor.Value * MyGuiConstants.DISABLED_BUTTON_NON_RED_MULTIPLIER * 2) : (m_backgroundColor.Value * 0.75f); textColor = isNotImplementedForbidenOrDisabled ? (DrawRedTextureWhenDisabled ? MyGuiConstants.DISABLED_BUTTON_TEXT_COLOR : m_textColor * MyGuiConstants.DISABLED_BUTTON_NON_RED_MULTIPLIER * 2) : (m_textColor * 0.75f); } if (backgroundTexture != null && m_useBackground) { // Draw background texture MyGuiManager.DrawSpriteBatch(backgroundTexture, m_parent.GetPositionAbsolute() + m_position, m_size.Value * m_scale, Color.White, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER); } // Draw background texture if (buttonTexture != null) { MyGuiManager.DrawSpriteBatch(buttonTexture, m_parent.GetPositionAbsolute() + m_position, m_size.Value * m_scale, GetColorAfterTransitionAlpha(backgroundColor), MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER); } // Draw cross texture if (isNotImplementedForbidenOrDisabled && DrawCrossTextureWhenDisabled) { MyGuiManager.DrawSpriteBatch(MyGuiManager.GetLockedButtonTexture(), m_parent.GetPositionAbsolute() + m_position, m_size.Value * MyGuiConstants.LOCKBUTTON_SIZE_MODIFICATION, MyGuiConstants.DISABLED_BUTTON_COLOR, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER); } if (Text != null) { Vector2 textPosition; MyGuiDrawAlignEnum textDrawAlign; if (m_textAlignment == MyGuiControlButtonTextAlignment.CENTERED) { textPosition = m_parent.GetPositionAbsolute() + m_position; textDrawAlign = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER; } else if (m_textAlignment == MyGuiControlButtonTextAlignment.LEFT) { // This will move text few pixels from button's left border textPosition = m_parent.GetPositionAbsolute() + m_position - new Vector2(m_size.Value.X / 2.0f, 0) + new Vector2(MyGuiConstants.BUTTON_TEXT_OFFSET.X, 0); textDrawAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER; } else { throw new MyMwcExceptionApplicationShouldNotGetHere(); } textPosition += TextOffset; MyGuiManager.DrawString(MyGuiManager.GetFontMinerWarsBlue(), Text, textPosition, m_textScale, GetColorAfterTransitionAlpha(textColor), textDrawAlign); } //ShowToolTip(); }