public override void DrawButton(UIButton b) { VTex2D bi; bi = StateImg(b.State); int fw = SmallFont.Width(b.Name); int fh = SmallFont.Height(); Vector4 col = new Vector4(1, 1, 1, 1 * UISys.AlphaMod); switch (b.State) { case ButState.Norm: col = new Vector4(0.6f, 0.6f, 0.6f, 0.6f * UISys.AlphaMod); break; case ButState.Hover: col = new Vector4(0.8f, 0.8f, 0.8f, 0.8f * UISys.AlphaMod); break; case ButState.Press: col = Vector4.One; col.W = col.W * UISys.AlphaMod; break; } VPen.Rect((int)b.WidX, (int)b.WidY, (int)b.WidW, (int)b.WidH, bi, col); VFontRenderer.Draw(SmallFont, b.Name, (int)(b.WidX + b.WidW / 2 - (fw / 2)), (int)(b.WidY + (b.WidH) / 2 - (fh / 2)), new Vector4(1, 1, 1, UISys.AlphaMod)); if (b == UISys.Active) { VPen.Line(b.WidX, b.WidY + 4, b.WidX + b.WidW, b.WidY + 4, new Vector4(1, 1, 1, 1)); } }
void IDisposable.Dispose() { VeryLargeFont.Dispose(); VeryLargeFont.Dispose(); LargeFont.Dispose(); MediumFont.Dispose(); SmallFont.Dispose(); VerySmallFont.Dispose(); FillBrush.Dispose(); AccentBrush.Dispose(); DefaultBrush.Dispose(); }
public static void ReleaseResources() { VBO?.Dispose(); VAO?.Dispose(); NormalFont?.Dispose(); SmallFont?.Dispose(); TextRenderer?.Dispose(); UIShader?.Dispose(); NormalFont?.Dispose(); SmallFont?.Dispose(); MonoFont?.Dispose(); }
public override void Draw(GameTime gameTime) { FinalBomber.Instance.SpriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null, null, _gameManager.Camera.GetTransformation()); _gameManager.Draw(gameTime, _gameManager.Camera); FinalBomber.Instance.SpriteBatch.End(); FinalBomber.Instance.SpriteBatch.Begin(); const string str = "Single Player Tests"; FinalBomber.Instance.SpriteBatch.DrawString(BigFont, str, new Vector2( Config.Resolutions[Config.IndexResolution, 0] / 2f - this.BigFont.MeasureString(str).X / 2 - 75, 0), Color.Black); string cameraPosition = "Camera position: " + _gameManager.Camera.Position; FinalBomber.Instance.SpriteBatch.DrawString(ControlManager.SpriteFont, cameraPosition, new Vector2(1, 41), Color.Black); FinalBomber.Instance.SpriteBatch.DrawString(ControlManager.SpriteFont, cameraPosition, new Vector2(0, 40), Color.White); #region HUD // Window boxes ScoresWindowBox.Draw(FinalBomber.Instance.SpriteBatch); TimerWindowBox.Draw(FinalBomber.Instance.SpriteBatch); // Draw player HUD foreach (var p in _gameManager.Players) { // HUD => Item Info FinalBomber.Instance.SpriteBatch.DrawString(ControlManager.SpriteFont, p.Name + ": " + p.Stats.Score + " pt(s)", new Vector2(HudOrigin.X + HudMarginLeft, HudOrigin.Y + HudTopSpace + (p.Id) * Config.HUDPlayerInfoSpace), Color.Black); #if DEBUG FinalBomber.Instance.SpriteBatch.DrawString(ControlManager.SpriteFont, "Player " + p.Id + ": " + (p.CellPosition).ToString(), new Vector2(HudOrigin.X + HudMarginLeft, HudOrigin.Y + HudTopSpace + Config.HUDPlayerInfoSpace * _gameManager.Players.Count + 60 + 20 * (p.Id)), Color.Black); #endif // To space the red icons and the "normal color" icons int iconLag = 0; // Player's power int counterRedFlames = 0; if (p.BombPower >= 10) { iconLag = 10; counterRedFlames = p.BombPower / 10; for (int i = 0; i < counterRedFlames; i++) { FinalBomber.Instance.SpriteBatch.Draw(ItemInfoIcon, new Vector2(HudOrigin.X + HudMarginLeft + 7 * i, HudOrigin.Y + HudTopSpace + (p.Id) * Config.HUDPlayerInfoSpace + 30), new Rectangle(14, 0, 14, 14), Color.White); } } else { iconLag = 0; } int counterYellowFlames = p.BombPower % 10; for (int i = 0; i < counterYellowFlames; i++) { FinalBomber.Instance.SpriteBatch.Draw(ItemInfoIcon, new Vector2(HudOrigin.X + HudMarginLeft + 14 * counterRedFlames + 7 * i + iconLag, HudOrigin.Y + HudTopSpace + (p.Id) * Config.HUDPlayerInfoSpace + 30), new Rectangle(0, 0, 14, 14), Color.White); } // Player's bomb number int counterRedBombs = 0; if (p.CurrentBombAmount >= 10) { iconLag = 10; counterRedBombs = p.CurrentBombAmount / 10; for (int i = 0; i < counterRedBombs; i++) { FinalBomber.Instance.SpriteBatch.Draw(ItemInfoIcon, new Vector2(HudOrigin.X + HudMarginLeft + 7 * i, HudOrigin.Y + HudTopSpace + (p.Id) * Config.HUDPlayerInfoSpace + 50), new Rectangle(42, 0, 14, 14), Color.White); } } else { iconLag = 0; } int counterBlackBombs = p.CurrentBombAmount % 10; int finalCounter = 0; for (int i = 0; i < counterBlackBombs; i++) { FinalBomber.Instance.SpriteBatch.Draw(ItemInfoIcon, new Vector2(HudOrigin.X + 7 * counterRedBombs + HudMarginLeft + 7 * i + iconLag, HudOrigin.Y + HudTopSpace + (p.Id) * Config.HUDPlayerInfoSpace + 50), new Rectangle(28, 0, 14, 14), Color.White); finalCounter = i; } if (p.HasBadEffect && p.BadEffect == BadEffect.NoBomb) { FinalBomber.Instance.SpriteBatch.Draw(Cross, new Rectangle(HudOrigin.X + HudMarginLeft, HudOrigin.Y + HudTopSpace + (p.Id) * Config.HUDPlayerInfoSpace + 50, 7 * counterRedBombs + 7 * finalCounter + iconLag + 15, 15), Color.White); } // Player's speed int counterRedShoes = 0; var counterIncrementeur = (int)((p.Speed - GameConfiguration.BasePlayerSpeed) / (GameConfiguration.BasePlayerSpeed * (GameConfiguration.PlayerSpeedIncrementeurPercentage / 100))) + 1; if (counterIncrementeur >= 10) { iconLag = 10; counterRedShoes = (int)(counterIncrementeur) / 10; for (int i = 0; i < counterRedShoes; i++) { FinalBomber.Instance.SpriteBatch.Draw(ItemInfoIcon, new Vector2(HudOrigin.X + HudMarginLeft + 7 * i, HudOrigin.Y + HudTopSpace + (p.Id) * Config.HUDPlayerInfoSpace + 70), new Rectangle(70, 0, 14, 14), Color.White); } } else { iconLag = 0; } int counterBlueShoes = (int)(counterIncrementeur) % 10; for (int i = 0; i < counterBlueShoes; i++) { FinalBomber.Instance.SpriteBatch.Draw(ItemInfoIcon, new Vector2(HudOrigin.X + HudMarginLeft + counterRedShoes * 7 + 7 * i + iconLag, HudOrigin.Y + HudTopSpace + (p.Id) * Config.HUDPlayerInfoSpace + 70), new Rectangle(56, 0, 14, 14), Color.White); } // Player's bad item GameTimer if (p.HasBadEffect) { FinalBomber.Instance.SpriteBatch.Draw(ItemInfoIcon, new Vector2(HudOrigin.X + HudMarginLeft, HudOrigin.Y + HudTopSpace + (p.Id) * Config.HUDPlayerInfoSpace + 90), new Rectangle(98, 0, 14, 14), Color.White); int lenght = 200 - (int)((200 / p.BadEffectTimerLenght.TotalSeconds) * p.BadEffectTimer.TotalSeconds); string badItemTimer = ((int)Math.Round(p.BadEffectTimerLenght.TotalSeconds - p.BadEffectTimer.TotalSeconds) + 1).ToString(); if (p.BadEffect == BadEffect.BombTimerChanged) { badItemTimer += " (" + p.BombTimer.TotalSeconds.ToString() + ")"; } for (int i = 0; i < lenght; i++) { FinalBomber.Instance.SpriteBatch.Draw(BadItemTimerBar, new Vector2(HudOrigin.X + HudMarginLeft + 20 + 1 * i, HudOrigin.Y + HudTopSpace + (p.Id) * Config.HUDPlayerInfoSpace + 90), Color.White); } FinalBomber.Instance.SpriteBatch.DrawString(SmallFont, badItemTimer, new Vector2(HudOrigin.X + HudMarginLeft + 20 + 1 * (lenght / 2) - SmallFont.MeasureString(badItemTimer).X / 2, HudOrigin.Y + HudTopSpace + (p.Id) * Config.HUDPlayerInfoSpace + 90), Color.White); } else { FinalBomber.Instance.SpriteBatch.Draw(ItemInfoIcon, new Vector2(HudOrigin.X + HudMarginLeft, HudOrigin.Y + HudTopSpace + (p.Id) * Config.HUDPlayerInfoSpace + 90), new Rectangle(84, 0, 14, 14), Color.White); } } var pos = new Vector2( HudOrigin.X + HudMarginLeft + (ControlManager.SpriteFont.MeasureString(_gameManager.GameTimer.ToString("mm") + ":" + _gameManager.GameTimer.ToString("ss")).X) + 25, HudOrigin.Y + HudTopSpace + Config.HUDPlayerInfoSpace * _gameManager.Players.Count + 22); FinalBomber.Instance.SpriteBatch.DrawString(ControlManager.SpriteFont, _gameManager.GameTimer.ToString("mm") + ":" + _gameManager.GameTimer.ToString("ss"), pos, Color.Black); #endregion #if DEBUG #region Debug if (InputHandler.KeyDown(Keys.O)) { for (int x = 0; x < _gameManager.CurrentMap.Size.X; x++) { for (int y = 0; y < _gameManager.CurrentMap.Size.Y; y++) { string itemMapType = ""; Color colorMapItem = Color.White; if (_gameManager.CurrentMap.Board[x, y] != null) { switch (_gameManager.CurrentMap.Board[x, y].GetType().Name) { case "Wall": itemMapType = "W"; colorMapItem = Color.Pink; break; case "Bomb": itemMapType = "B"; colorMapItem = Color.Red; break; case "Player": itemMapType = "P"; colorMapItem = Color.Green; break; case "Item": itemMapType = "I"; colorMapItem = Color.Yellow; break; case "EdgeWall": itemMapType = "E"; colorMapItem = Color.Black; break; case "UnbreakableWall": itemMapType = "U"; colorMapItem = Color.Black; break; case "Teleporter": itemMapType = "T"; colorMapItem = Color.Blue; break; case "Arrow": itemMapType = "A"; colorMapItem = Color.DarkViolet; break; } } else { itemMapType = "."; } FinalBomber.Instance.SpriteBatch.DrawString(ControlManager.SpriteFont, itemMapType, new Vector2(x * 20, 80 + 20 * y), colorMapItem); } } } else if (InputHandler.KeyDown(Keys.C)) { for (int x = 0; x < _gameManager.CurrentMap.Size.X; x++) { for (int y = 0; y < _gameManager.CurrentMap.Size.Y; y++) { if (!_gameManager.CurrentMap.CollisionLayer[x, y]) { FinalBomber.Instance.SpriteBatch.DrawString(ControlManager.SpriteFont, "0", new Vector2(x * 20, 80 + 20 * y), Color.ForestGreen); } else { FinalBomber.Instance.SpriteBatch.DrawString(ControlManager.SpriteFont, "1", new Vector2(x * 20, 80 + 20 * y), Color.Purple); } } } } else if (InputHandler.KeyDown(Keys.H)) { for (int x = 0; x < _gameManager.CurrentMap.Size.X; x++) { for (int y = 0; y < _gameManager.CurrentMap.Size.Y; y++) { FinalBomber.Instance.SpriteBatch.DrawString(ControlManager.SpriteFont, _gameManager.HazardMap[x, y].ToString(), new Vector2(x * 30, 80 + 20 * y), Color.Black); } } } #endregion #endif FinalBomber.Instance.SpriteBatch.End(); base.Draw(gameTime); }
protected override void RenderOverlay() { uint colorCursor = (uint)ColorCursor.ToArgb(); if (UpdateOverlays) { UpdateOverlays = false; UpdateDrawablePositions(); OverlayTextLabels.Clear(); OverlayVertexesUsed = 0; foreach (LabelledLine line in LabelledHorLines) { if (OverlayVertexesUsed < OverlayVertexes.Length - 2) { OverlayVertexes[OverlayVertexesUsed].PositionRhw.X = 0; OverlayVertexes[OverlayVertexesUsed].PositionRhw.Y = (float)SampleToYPos(line.Position); OverlayVertexes[OverlayVertexesUsed].PositionRhw.Z = 0.5f; OverlayVertexes[OverlayVertexesUsed].PositionRhw.W = 1; OverlayVertexes[OverlayVertexesUsed].Color = line.Color; OverlayVertexesUsed++; OverlayVertexes[OverlayVertexesUsed].PositionRhw.X = DirectXWidth; OverlayVertexes[OverlayVertexesUsed].PositionRhw.Y = (float)SampleToYPos(line.Position); OverlayVertexes[OverlayVertexesUsed].PositionRhw.Z = 0.5f; OverlayVertexes[OverlayVertexesUsed].PositionRhw.W = 1; OverlayVertexes[OverlayVertexesUsed].Color = line.Color; OverlayVertexesUsed++; /* add the labels to the label list to draw */ OverlayTextLabels.AddLast(new StringLabel(line.Label, 60, (int)SampleToYPos(line.Position) + 5, line.Color)); } } foreach (LabelledLine line in LabelledVertLines) { if (OverlayVertexesUsed < OverlayVertexes.Length - 4) { double freq = XPosFromSampleNum(line.Position); if (freq >= 0 && freq < DirectXWidth) { OverlayVertexes[OverlayVertexesUsed].PositionRhw.X = 10 + (float)XPosFromSampleNum(line.Position); OverlayVertexes[OverlayVertexesUsed].PositionRhw.Y = 0; OverlayVertexes[OverlayVertexesUsed].PositionRhw.Z = 0.5f; OverlayVertexes[OverlayVertexesUsed].PositionRhw.W = 1; OverlayVertexes[OverlayVertexesUsed].Color = line.Color; OverlayVertexesUsed++; OverlayVertexes[OverlayVertexesUsed].PositionRhw.X = (float)XPosFromSampleNum(line.Position); OverlayVertexes[OverlayVertexesUsed].PositionRhw.Y = 10; OverlayVertexes[OverlayVertexesUsed].PositionRhw.Z = 0.5f; OverlayVertexes[OverlayVertexesUsed].PositionRhw.W = 1; OverlayVertexes[OverlayVertexesUsed].Color = line.Color; OverlayVertexesUsed++; OverlayVertexes[OverlayVertexesUsed].PositionRhw.X = (float)XPosFromSampleNum(line.Position); OverlayVertexes[OverlayVertexesUsed].PositionRhw.Y = 10; OverlayVertexes[OverlayVertexesUsed].PositionRhw.Z = 0.5f; OverlayVertexes[OverlayVertexesUsed].PositionRhw.W = 1; OverlayVertexes[OverlayVertexesUsed].Color = line.Color; OverlayVertexesUsed++; OverlayVertexes[OverlayVertexesUsed].PositionRhw.X = (float)XPosFromSampleNum(line.Position); OverlayVertexes[OverlayVertexesUsed].PositionRhw.Y = DirectXHeight; OverlayVertexes[OverlayVertexesUsed].PositionRhw.Z = 0.5f; OverlayVertexes[OverlayVertexesUsed].PositionRhw.W = 1; OverlayVertexes[OverlayVertexesUsed].Color = line.Color; OverlayVertexesUsed++; /* add the labels to the label list to draw */ OverlayTextLabels.AddLast(new StringLabel(line.Label, (int)XPosFromSampleNum(line.Position) + 5, 15, line.Color)); } } } } /* draw overlay */ if (OverlayVertexesUsed > 0) { Device.DrawUserPrimitives(PrimitiveType.LineList, OverlayVertexesUsed / 2, OverlayVertexes); } foreach (StringLabel label in OverlayTextLabels) { SmallFont.DrawString(null, label.Label, label.X, label.Y, (int)label.Color); } /* draw scale lines and text */ if (ScaleVertexesUsed > 0) { Device.DrawUserPrimitives(PrimitiveType.LineList, ScaleVertexesUsed / 2, ScaleVertexes); } for (double scalePos = ScalePosMin; scalePos <= ScalePosMax; scalePos += ScaleTextDistance) { SmallFont.DrawString(null, " " + (int)(scalePos * ScaleUnitFactor) + " " + ScaleUnit, 10, (int)SampleToYPos(scalePos), (int)(colorCursor & 0x80FFFFFF)); } }
protected override void RenderAxis() { uint colorCursor = (uint)ColorCursor.ToArgb(); uint colorLimiter = (uint)LimiterColor.ToArgb(); int xPos = (int)LastMousePos.X; int yPos = (int)LastMousePos.Y; float limiterLower = (float)XPosFromSampleNum(LimiterLowerLimit); float limiterUpper = (float)XPosFromSampleNum(LimiterUpperLimit); bool mouseInLowerLimit = (xPos <= limiterLower); bool mouseInUpperLimit = (xPos >= limiterUpper); /* only recalc scale lines when axis need to get updated */ if (UpdateAxis) { UpdateAxis = false; ScaleVertexesUsed = 0; /* update bandwith limiters */ LimiterLines[0].PositionRhw.X = limiterLower; LimiterLines[0].PositionRhw.Y = 0; LimiterLines[0].PositionRhw.Z = 0.5f; LimiterLines[0].PositionRhw.W = 1; LimiterLines[0].Color = colorLimiter; LimiterLines[1].PositionRhw.X = limiterLower; LimiterLines[1].PositionRhw.Y = DirectXHeight; LimiterLines[1].PositionRhw.Z = 0.5f; LimiterLines[1].PositionRhw.W = 1; LimiterLines[1].Color = colorLimiter; LimiterLines[2].PositionRhw.X = limiterUpper; LimiterLines[2].PositionRhw.Y = 0; LimiterLines[2].PositionRhw.Z = 0.5f; LimiterLines[2].PositionRhw.W = 1; LimiterLines[2].Color = colorLimiter; LimiterLines[3].PositionRhw.X = limiterUpper; LimiterLines[3].PositionRhw.Y = DirectXHeight; LimiterLines[3].PositionRhw.Z = 0.5f; LimiterLines[3].PositionRhw.W = 1; LimiterLines[3].Color = colorLimiter; BuildStripRectangle(LimiterVertexesLeft, colorLimiter & 0x2FFFFFFF, 0, limiterLower); BuildStripRectangle(LimiterVertexesRight, colorLimiter & 0x2FFFFFFF, limiterUpper, DirectXWidth); int scaleCount = (int)Math.Round((ScalePosMax - ScalePosMin) / ScaleBarDistance); /* draw scale lines */ for (int scaleNum = 0; scaleNum <= scaleCount; scaleNum++) { float scalePos = (float)(ScalePosMin + scaleNum * ScaleBarDistance); ScaleVertexes[ScaleVertexesUsed].PositionRhw.X = 0; ScaleVertexes[ScaleVertexesUsed].PositionRhw.Y = (float)SampleToYPos(scalePos); ScaleVertexes[ScaleVertexesUsed].PositionRhw.Z = 0.5f; ScaleVertexes[ScaleVertexesUsed].PositionRhw.W = 1; ScaleVertexes[ScaleVertexesUsed].Color = colorCursor; ScaleVertexesUsed++; if (scaleNum == 0 || scaleNum == scaleCount || Math.Round(scalePos / ScaleBarDistance) == 0) { ScaleVertexes[ScaleVertexesUsed].PositionRhw.X = 50; } else if (scaleNum % 2 == 0) { ScaleVertexes[ScaleVertexesUsed].PositionRhw.X = 20; } else { ScaleVertexes[ScaleVertexesUsed].PositionRhw.X = 10; } ScaleVertexes[ScaleVertexesUsed].PositionRhw.Y = (float)SampleToYPos(scalePos); ScaleVertexes[ScaleVertexesUsed].PositionRhw.Z = 0.5f; ScaleVertexes[ScaleVertexesUsed].PositionRhw.W = 1; ScaleVertexes[ScaleVertexesUsed].Color = colorCursor & 0x00FFFFFF; ScaleVertexesUsed++; ScaleVertexes[ScaleVertexesUsed].PositionRhw.X = DirectXWidth; ScaleVertexes[ScaleVertexesUsed].PositionRhw.Y = (float)SampleToYPos(scalePos); ScaleVertexes[ScaleVertexesUsed].PositionRhw.Z = 0.5f; ScaleVertexes[ScaleVertexesUsed].PositionRhw.W = 1; ScaleVertexes[ScaleVertexesUsed].Color = colorCursor; ScaleVertexesUsed++; if (scalePos % 100 == 0) { ScaleVertexes[ScaleVertexesUsed].PositionRhw.X = DirectXWidth - 50; } else if (scalePos % 50 == 0) { ScaleVertexes[ScaleVertexesUsed].PositionRhw.X = DirectXWidth - 20; } else { ScaleVertexes[ScaleVertexesUsed].PositionRhw.X = DirectXWidth - 10; } ScaleVertexes[ScaleVertexesUsed].PositionRhw.Y = (float)SampleToYPos(scalePos); ScaleVertexes[ScaleVertexesUsed].PositionRhw.Z = 0.5f; ScaleVertexes[ScaleVertexesUsed].PositionRhw.W = 1; ScaleVertexes[ScaleVertexesUsed].Color = colorCursor & 0x00FFFFFF; ScaleVertexesUsed++; } if (XAxisVerts == null || XAxisVerts.Length < XAxisLines * 4) { XAxisVerts = new Vertex[XAxisLines * 4]; } uint color1 = 0xFF101010; uint color2 = 0xFF404040; uint color3 = 0xFFFFFFFF; for (int pos = 0; pos < XAxisLines; pos++) { float x = (float)(XAxisGridOffset * XZoomFactor - DisplayXOffset + (pos * ((XAxisUnit / PlotVertsEntries) * DirectXWidth) * XZoomFactor)); XAxisVerts[pos * 4 + 0].PositionRhw.X = x; XAxisVerts[pos * 4 + 0].PositionRhw.Y = 0; XAxisVerts[pos * 4 + 0].PositionRhw.Z = 0.5f; XAxisVerts[pos * 4 + 0].PositionRhw.W = 1; XAxisVerts[pos * 4 + 0].Color = color1; XAxisVerts[pos * 4 + 1].PositionRhw.X = x; XAxisVerts[pos * 4 + 1].PositionRhw.Y = DirectXHeight / 2; XAxisVerts[pos * 4 + 1].PositionRhw.Z = 0.5f; XAxisVerts[pos * 4 + 1].PositionRhw.W = 1; XAxisVerts[pos * 4 + 1].Color = color2; XAxisVerts[pos * 4 + 2].PositionRhw.X = x; XAxisVerts[pos * 4 + 2].PositionRhw.Y = DirectXHeight / 2; XAxisVerts[pos * 4 + 2].PositionRhw.Z = 0.5f; XAxisVerts[pos * 4 + 2].PositionRhw.W = 1; XAxisVerts[pos * 4 + 2].Color = color2; XAxisVerts[pos * 4 + 3].PositionRhw.X = x; XAxisVerts[pos * 4 + 3].PositionRhw.Y = DirectXHeight; XAxisVerts[pos * 4 + 3].PositionRhw.Z = 0.5f; XAxisVerts[pos * 4 + 3].PositionRhw.W = 1; XAxisVerts[pos * 4 + 3].Color = color1; } } if (LimiterDisplayEnabled) { Device.DrawUserPrimitives(PrimitiveType.TriangleStrip, 2, LimiterVertexesLeft); Device.DrawUserPrimitives(PrimitiveType.TriangleStrip, 2, LimiterVertexesRight); Device.DrawUserPrimitives(PrimitiveType.LineList, 2, LimiterLines); if (mouseInLowerLimit) { if (xPos > DirectXWidth / 2) { int stringWidth = SmallFont.MeasureString(null, LimiterLowerDescription, DrawTextFormat.Center).Width; SmallFont.DrawString(null, LimiterLowerDescription, xPos - 30 - stringWidth, yPos + 20, (int)(colorLimiter)); } else { SmallFont.DrawString(null, LimiterLowerDescription, xPos + 20, yPos + 20, (int)(colorLimiter)); } } if (mouseInUpperLimit) { if (xPos > DirectXWidth / 2) { int stringWidth = SmallFont.MeasureString(null, LimiterUpperDescription, DrawTextFormat.Center).Width; SmallFont.DrawString(null, LimiterUpperDescription, xPos - 30 - stringWidth, yPos + 20, (int)(colorLimiter)); } else { SmallFont.DrawString(null, LimiterUpperDescription, xPos + 20, yPos + 20, (int)(colorLimiter)); } } } if (XAxisVerts.Length > 0) { Device.DrawUserPrimitives(PrimitiveType.LineList, XAxisVerts.Length / 2, XAxisVerts); } if (YAxisVerts.Length > 0) { Device.DrawUserPrimitives(PrimitiveType.LineList, YAxisVerts.Length / 2, YAxisVerts); } }
protected override void RenderCursor() { uint colorCursor = (uint)ColorCursor.ToArgb(); uint colorCursorBox = (uint)CursorBoxColor.ToArgb(); float stubLength = (float)DirectXHeight / 10.0f; float xPos = (float)LastMousePos.X; float yPos = (float)LastMousePos.Y; float unit = (float)(SampleFromYPos(yPos) * ScaleUnitFactor); if (UpdateCursor) { UpdateCursor = false; /* draw vertical cursor line */ if (xPos > DirectXWidth / 2) { CursorVertexesVert[0].PositionRhw.X = xPos - 30; } else { CursorVertexesVert[0].PositionRhw.X = xPos + 30; } CursorVertexesVert[1].PositionRhw.X = xPos; CursorVertexesVert[2].PositionRhw.X = xPos; CursorVertexesVert[3].PositionRhw.X = xPos; /* horizontal line */ CursorVertexesHor[0].PositionRhw.X = xPos - 30; CursorVertexesHor[0].PositionRhw.Y = yPos; CursorVertexesHor[1].PositionRhw.X = xPos; CursorVertexesHor[1].PositionRhw.Y = yPos; CursorVertexesHor[2].PositionRhw.X = xPos + 30; CursorVertexesHor[2].PositionRhw.Y = yPos; /* recalc lines (this is needed just once btw.) */ CursorVertexesVert[0].PositionRhw.Y = 20; CursorVertexesVert[0].PositionRhw.Z = 0.5f; CursorVertexesVert[0].PositionRhw.W = 1; CursorVertexesVert[0].Color = colorCursor & 0x00FFFFFF; CursorVertexesVert[1].PositionRhw.Y = 20 + stubLength; CursorVertexesVert[1].PositionRhw.Z = 0.5f; CursorVertexesVert[1].PositionRhw.W = 1; CursorVertexesVert[1].Color = colorCursor; CursorVertexesVert[2].PositionRhw.Y = DirectXHeight - stubLength; CursorVertexesVert[2].PositionRhw.Z = 0.5f; CursorVertexesVert[2].PositionRhw.W = 1; CursorVertexesVert[2].Color = colorCursor; CursorVertexesVert[3].PositionRhw.Y = DirectXHeight; CursorVertexesVert[3].PositionRhw.Z = 0.5f; CursorVertexesVert[3].PositionRhw.W = 1; CursorVertexesVert[3].Color = colorCursor; CursorVertexesHor[0].PositionRhw.Z = 0.5f; CursorVertexesHor[0].PositionRhw.W = 1; CursorVertexesHor[0].Color = colorCursor & 0x00FFFFFF; CursorVertexesHor[1].PositionRhw.Z = 0.5f; CursorVertexesHor[1].PositionRhw.W = 1; CursorVertexesHor[1].Color = colorCursor; CursorVertexesHor[2].PositionRhw.Z = 0.5f; CursorVertexesHor[2].PositionRhw.W = 1; CursorVertexesHor[2].Color = colorCursor & 0x00FFFFFF; } if (MouseHovering || ShowVerticalCursor) { string signalPower = unit + " " + ScaleUnit; string positionLabel; if (OverviewMode) { positionLabel = XLabelFromSampleNum(xPos); } else { positionLabel = XLabelFromCursorPos(xPos); } int signalPowerWidth = SmallFont.MeasureString(null, signalPower, DrawTextFormat.Center).Width; int positionLabelWidth = SmallFont.MeasureString(null, positionLabel, DrawTextFormat.Center).Width; int signalPowerHeight = SmallFont.MeasureString(null, signalPower, DrawTextFormat.Center).Height; int positionLabelHeight = SmallFont.MeasureString(null, positionLabel, DrawTextFormat.Center).Height; int boxWidth = 10 + Math.Max(signalPowerWidth, positionLabelWidth); int boxHeight = 10 + signalPowerHeight + positionLabelHeight; int boxY = 20; int boxX = (int)xPos; if (xPos > DirectXWidth / 2) { boxX -= boxWidth + 25; } else { boxX += 25; } BuildStripRectangle(CursorRectVertexes, colorCursorBox & 0x3FFFFFFF, boxX, boxX + boxWidth, boxY + boxHeight, boxY); Device.DrawUserPrimitives(PrimitiveType.TriangleStrip, 2, CursorRectVertexes); Device.DrawUserPrimitives(PrimitiveType.LineStrip, 3, CursorVertexesVert); if (MouseHovering) { /* draw the strength into box */ SmallFont.DrawString(null, signalPower, boxX + 5, boxY + 5, ColorFG.ToArgb()); Device.DrawUserPrimitives(PrimitiveType.LineStrip, 2, CursorVertexesHor); } /* draw the horizontal into box */ SmallFont.DrawString(null, positionLabel, boxX + 5, boxY + 5 + signalPowerHeight, ColorFG.ToArgb()); } }
protected override void RenderAxis() { uint colorCursor = (uint)ColorCursor.ToArgb(); uint colorLimiter = (uint)LimiterColor.ToArgb(); int xPos = (int)LastMousePos.X; int yPos = (int)LastMousePos.Y; float limiterLower = (float)(LimiterLowerLimit); float limiterUpper = (float)(LimiterUpperLimit); bool mouseInLowerLimit = (xPos <= limiterLower); bool mouseInUpperLimit = (xPos >= limiterUpper); /* only recalc scale lines when axis need to get updated */ if (UpdateAxis) { UpdateAxis = false; ScaleVertexesUsed = 0; BuildStripRectangle(LimiterVertexesLeft, colorLimiter & 0x2FFFFFFF, 0, limiterLower); BuildStripRectangle(LimiterVertexesRight, colorLimiter & 0x2FFFFFFF, limiterUpper, DirectXWidth); int scaleCount = (int)Math.Round((ScalePosMax - ScalePosMin) / ScaleBarDistance); /* draw scale lines */ for (int scaleNum = 0; scaleNum <= scaleCount; scaleNum++) { float scalePos = (float)(ScalePosMin + scaleNum * ScaleBarDistance); ScaleVertexes[ScaleVertexesUsed].PositionRhw.X = 0; ScaleVertexes[ScaleVertexesUsed].PositionRhw.Y = scalePos; ScaleVertexes[ScaleVertexesUsed].PositionRhw.Z = 0.5f; ScaleVertexes[ScaleVertexesUsed].PositionRhw.W = 1; ScaleVertexes[ScaleVertexesUsed].Color = colorCursor; ScaleVertexesUsed++; if (scaleNum == 0 || scaleNum == scaleCount || Math.Round(scalePos / ScaleBarDistance) == 0) { ScaleVertexes[ScaleVertexesUsed].PositionRhw.X = 50; } else if (scaleNum % 2 == 0) { ScaleVertexes[ScaleVertexesUsed].PositionRhw.X = 20; } else { ScaleVertexes[ScaleVertexesUsed].PositionRhw.X = 10; } ScaleVertexes[ScaleVertexesUsed].PositionRhw.Y = scalePos; ScaleVertexes[ScaleVertexesUsed].PositionRhw.Z = 0.5f; ScaleVertexes[ScaleVertexesUsed].PositionRhw.W = 1; ScaleVertexes[ScaleVertexesUsed].Color = colorCursor & 0x00FFFFFF; ScaleVertexesUsed++; ScaleVertexes[ScaleVertexesUsed].PositionRhw.X = DirectXWidth; ScaleVertexes[ScaleVertexesUsed].PositionRhw.Y = scalePos; ScaleVertexes[ScaleVertexesUsed].PositionRhw.Z = 0.5f; ScaleVertexes[ScaleVertexesUsed].PositionRhw.W = 1; ScaleVertexes[ScaleVertexesUsed].Color = colorCursor; ScaleVertexesUsed++; if (scalePos % 100 == 0) { ScaleVertexes[ScaleVertexesUsed].PositionRhw.X = DirectXWidth - 50; } else if (scalePos % 50 == 0) { ScaleVertexes[ScaleVertexesUsed].PositionRhw.X = DirectXWidth - 20; } else { ScaleVertexes[ScaleVertexesUsed].PositionRhw.X = DirectXWidth - 10; } ScaleVertexes[ScaleVertexesUsed].PositionRhw.Y = scalePos; ScaleVertexes[ScaleVertexesUsed].PositionRhw.Z = 0.5f; ScaleVertexes[ScaleVertexesUsed].PositionRhw.W = 1; ScaleVertexes[ScaleVertexesUsed].Color = colorCursor & 0x00FFFFFF; ScaleVertexesUsed++; } } if (LimiterDisplayEnabled) { Device.DrawUserPrimitives(PrimitiveType.TriangleStrip, 2, LimiterVertexesLeft); Device.DrawUserPrimitives(PrimitiveType.TriangleStrip, 2, LimiterVertexesRight); Device.DrawUserPrimitives(PrimitiveType.LineList, 2, LimiterLines); if (mouseInLowerLimit) { if (xPos > DirectXWidth / 2) { int stringWidth = SmallFont.MeasureString(null, LimiterLowerDescription, DrawTextFormat.Center).Width; SmallFont.DrawString(null, LimiterLowerDescription, xPos - 30 - stringWidth, yPos + 20, (int)(colorLimiter)); } else { SmallFont.DrawString(null, LimiterLowerDescription, xPos + 20, yPos + 20, (int)(colorLimiter)); } } if (mouseInUpperLimit) { if (xPos > DirectXWidth / 2) { int stringWidth = SmallFont.MeasureString(null, LimiterUpperDescription, DrawTextFormat.Center).Width; SmallFont.DrawString(null, LimiterUpperDescription, xPos - 30 - stringWidth, yPos + 20, (int)(colorLimiter)); } else { SmallFont.DrawString(null, LimiterUpperDescription, xPos + 20, yPos + 20, (int)(colorLimiter)); } } } if (XAxisVerts.Length > 0) { Device.DrawUserPrimitives(PrimitiveType.LineList, XAxisVerts.Length / 2, XAxisVerts); } if (YAxisVerts.Length > 0) { Device.DrawUserPrimitives(PrimitiveType.LineList, YAxisVerts.Length / 2, YAxisVerts); } }
protected void DrawBit(int bitNum, uint color1, uint color2, uint colorText) { float stubLength = (float)DirectXHeight / 3; float bitStartPos = (float)(XAxisGridOffset * XZoomFactor - DisplayXOffset + ((bitNum - 0.5f) * ((XAxisUnit / PlotVertsEntries) * DirectXWidth) * XZoomFactor)); float bitEndPos = (float)(XAxisGridOffset * XZoomFactor - DisplayXOffset + ((bitNum + 0.5f) * ((XAxisUnit / PlotVertsEntries) * DirectXWidth) * XZoomFactor)); //float bitStartPos = (float)(XAxisGridOffset * XZoomFactor - DisplayXOffset + ((bitNum - 0.5f) * XAxisUnit * XZoomFactor * (DirectXWidth / PlotVertsEntries))); //float bitEndPos = (float)(XAxisGridOffset * XZoomFactor - DisplayXOffset + ((bitNum + 0.5f) * XAxisUnit * XZoomFactor * (DirectXWidth / PlotVertsEntries))); float yPos = DirectXHeight / 2; if (bitNum >= 0 && bitNum < BurstBits.Length) { yPos = BurstBits[bitNum] ? stubLength : (DirectXHeight - stubLength); } else { return; } /* draw bit margins */ CursorVertexes[0].PositionRhw.X = bitStartPos; CursorVertexes[0].PositionRhw.Y = DirectXHeight / 2; CursorVertexes[0].PositionRhw.Z = 0.5f; CursorVertexes[0].PositionRhw.W = 1; CursorVertexes[0].Color = color2; CursorVertexes[1].PositionRhw.X = bitStartPos; CursorVertexes[1].PositionRhw.Y = yPos; CursorVertexes[1].PositionRhw.Z = 0.5f; CursorVertexes[1].PositionRhw.W = 1; CursorVertexes[1].Color = color1; CursorVertexes[2].PositionRhw.X = bitEndPos; CursorVertexes[2].PositionRhw.Y = DirectXHeight / 2; CursorVertexes[2].PositionRhw.Z = 0.5f; CursorVertexes[2].PositionRhw.W = 1; CursorVertexes[2].Color = color2; CursorVertexes[3].PositionRhw.X = bitEndPos; CursorVertexes[3].PositionRhw.Y = yPos; CursorVertexes[3].PositionRhw.Z = 0.5f; CursorVertexes[3].PositionRhw.W = 1; CursorVertexes[3].Color = color1; Device.DrawUserPrimitives(PrimitiveType.LineList, 2, CursorVertexes); /* horizontal top line */ CursorVertexes[0].PositionRhw.X = (float)bitStartPos; CursorVertexes[0].PositionRhw.Y = yPos; CursorVertexes[0].PositionRhw.Z = 0.5f; CursorVertexes[0].PositionRhw.W = 1; CursorVertexes[0].Color = color1; CursorVertexes[1].PositionRhw.X = (float)bitEndPos; CursorVertexes[1].PositionRhw.Y = yPos; CursorVertexes[1].PositionRhw.Z = 0.5f; CursorVertexes[1].PositionRhw.W = 1; CursorVertexes[1].Color = color1; Device.DrawUserPrimitives(PrimitiveType.LineList, 1, CursorVertexes); SmallFont.DrawString(null, (bitNum + 1).ToString(), (int)(bitStartPos + bitEndPos) / 2, (int)DirectXHeight / 2, (int)colorText); }