public ViewScoreDetailsState(ShowHighScoresState pOwner, IHighScoreEntry pShowEntry, IBackground useBG, int DetailPosition) { _Position = DetailPosition; _BG = useBG; //so it is the same as the "main" show score state and looks "seamless". _Owner = pOwner; ShowEntry = pShowEntry; }
public IHighScoreEntry Submit(IHighScoreEntry newEntry) { IHighScoreEntry <T> casted = newEntry as IHighScoreEntry <T>; if (casted != null) { return(Submit(casted.Name, casted.Score, casted.CustomData)); } return(Submit(newEntry.Name, newEntry.Score)); }
public override void Render(IStateOwner pOwner, SKCanvas pRenderTarget, ShowHighScoresState Source, GameStateSkiaDrawParameters Element) { if (Source.BG == null) { StandardImageBackgroundSkia sk = StandardImageBackgroundSkia.GetMenuBackgroundDrawer(); sk.Data.Movement = new SKPoint(3, 3); Source.BG = sk; } var Bounds = Element.Bounds; var g = pRenderTarget; float StartY = (Bounds.Height * 0.175f); var CurrentY = StartY; float MiddleX = Bounds.Width / 2; DrawBackground(Source, pOwner, g, Bounds); float TextSize = Bounds.Height / 30f; var ScoreFont = TetrisGame.RetroFontSK; //point size 24. SKPaint MainScoreFont = new SKPaint() { Typeface = ScoreFont, TextSize = (float)(24 * pOwner.ScaleFactor), Color = SKColors.Black }; SKPaint ShadowScoreFont = new SKPaint() { Typeface = ScoreFont, TextSize = (float)(24 * pOwner.ScaleFactor), Color = SKColors.White }; SKPaint ListingFont = new SKPaint() { Typeface = ScoreFont, TextSize = (float)(18 * pOwner.ScaleFactor), Color = SKColors.Black }; float PercentThroughSecond = (float)DateTime.Now.Millisecond / 1000f; SKPaint ListingFontRainbow = new SKPaint() { Typeface = ScoreFont, TextSize = (float)(18 * pOwner.ScaleFactor), Color = SKColor.FromHsl(PercentThroughSecond * 240, 240, 120) }; SKPaint ListingFontShadow = new SKPaint() { Typeface = ScoreFont, TextSize = (float)(18 * pOwner.ScaleFactor), Color = SKColors.White }; SKPaint ListingFontArrow = new SKPaint() { Typeface = TetrisGame.ArialFontSK, TextSize = (float)(18 * pOwner.ScaleFactor), Color = SKColor.FromHsl(PercentThroughSecond * 240, 240, 120) }; SKPaint ListingFontArrowShadow = new SKPaint() { Typeface = TetrisGame.ArialFontSK, TextSize = (float)(18 * pOwner.ScaleFactor), Color = SKColors.White }; SKRect resultitem = new SKRect(); float LineHeight = MainScoreFont.MeasureText("#", ref resultitem); var useShader = SKShader.CreateLinearGradient(new SKPoint(0, 0), new SKPoint(0, Bounds.Height), new SKColor[] { SKColors.Red, SKColors.Orange, SKColors.Yellow, SKColors.Green, SKColors.Blue, SKColors.Indigo, SKColors.Violet }, null, SKShaderTileMode.Mirror); SKPaint LinePaint = new SKPaint() { BlendMode = SKBlendMode.ColorBurn, StrokeWidth = 24, Shader = useShader }; g.DrawRect(new SKRect(0, 0, Bounds.Width, Bounds.Height), LinePaint); //g.DrawRect(new SKRect((int)(Bounds.Width * (1 / 7)), CurrentY, (float)(Bounds.Width - (Bounds.Width * (1 / 7))), (float)(CurrentY + (LineHeight * 2.5) + (LineHeight * 3) * 12)),LinePaint); if (Source.IncrementedDrawState >= 0) { //draw "HIGH SCORES" header text. SKRect MeasuredRect = new SKRect(); MainScoreFont.MeasureText(Source.HeaderText, ref MeasuredRect); SKPoint DrawPosition = new SKPoint(MiddleX - (MeasuredRect.Width / 2), StartY); g.DrawText(Source.HeaderText, new SKPoint(DrawPosition.X + 2, DrawPosition.Y + 2), ShadowScoreFont); g.DrawText(Source.HeaderText, DrawPosition, MainScoreFont); CurrentY = StartY + MeasuredRect.Height + 10; } if (Source.IncrementedDrawState >= 1) { //maybe a line under the header. } if (Source.IncrementedDrawState >= 2) { //draw the high score listing entries. //iterate from 2 to drawstate and draw the high score at position drawstate-2. for (int scoreiterate = 2; scoreiterate < Source.IncrementedDrawState; scoreiterate++) { int CurrentScoreIndex = scoreiterate - 2; int CurrentScorePosition = CurrentScoreIndex + 1; double useYPosition = StartY + (LineHeight * 2.5) + (LineHeight * 3) * CurrentScoreIndex; double useXPosition = Bounds.Width * 0.19d; String sUseName = "N/A"; int sUseScore = 0; IHighScoreEntry currentScore = Source.hs.Count > CurrentScoreIndex ? Source.hs[CurrentScoreIndex] : null; if (currentScore != null) { sUseName = currentScore.Name; sUseScore = currentScore.Score; } SKRect MeasureName = new SKRect(), MeasureScore = new SKRect(); ListingFont.MeasureText(sUseName, ref MeasureName); ListingFont.MeasureText(sUseScore.ToString(), ref MeasureScore); float PosXPosition = Bounds.Width * 0.1f; float NameXPosition = Bounds.Width * 0.20f; float ScoreXPositionRight = Bounds.Width * (1 - 0.10f); var useForegroundPaint = Source.HighlightedScorePositions.Contains(CurrentScorePosition) ? ListingFontRainbow : ListingFont; //draw position g.DrawText(CurrentScorePosition.ToString() + ".", new SKPoint(PosXPosition + 2, (float)useYPosition + 2), ListingFontShadow); g.DrawText(CurrentScorePosition.ToString() + ".", new SKPoint(PosXPosition, (float)useYPosition), useForegroundPaint); //draw high score name g.DrawText(sUseName, new SKPoint(PosXPosition + 2 + Math.Abs(resultitem.Height) * 2.25f, (float)useYPosition + 2), ListingFontShadow); g.DrawText(sUseName, new SKPoint(PosXPosition + Math.Abs(resultitem.Height) * 2.25f, (float)useYPosition), useForegroundPaint); //draw the high score float ScoreXPosition = ScoreXPositionRight - MeasureScore.Width; g.DrawText(sUseScore.ToString(), new SKPoint(ScoreXPosition + 2, (float)useYPosition + 2), ListingFontShadow); g.DrawText(sUseScore.ToString(), new SKPoint(ScoreXPosition, (float)useYPosition), useForegroundPaint); useForegroundPaint.StrokeWidth = 6; g.DrawLine(new SKPoint(NameXPosition + MeasureName.Width + 15, (float)useYPosition + LineHeight / 2), new SKPoint(ScoreXPosition - 15, (float)useYPosition + LineHeight / 2), useForegroundPaint); if (Source.SelectedScorePosition == CurrentScoreIndex) { //draw selection indicator if needed SKRect MeasureArrow = new SKRect(); useForegroundPaint.MeasureText(PointerText, ref MeasureArrow); float ArrowX = PosXPosition - MeasureArrow.Width - 5; float ArrowY = (float)useYPosition; g.DrawText(PointerText, new SKPoint(ArrowX + 2, ArrowY + 2), ListingFontArrowShadow); g.DrawText(PointerText, new SKPoint(ArrowX, ArrowY), ListingFontArrow); } } } }
public override void Render(IStateOwner pOwner, Graphics pRenderTarget, ShowHighScoresState Source, BaseDrawParameters Element) { var Bounds = Element.Bounds; var g = pRenderTarget; float StartY = Bounds.Height * 0.175f; float MiddleX = Bounds.Width / 2; DrawBackground(Source, pOwner, g, Bounds); float TextSize = Bounds.Height / 30f; using (ScoreFont = TetrisGame.GetRetroFont(24, pOwner.ScaleFactor, FontStyle.Bold, GraphicsUnit.Pixel)) { float LineHeight = g.MeasureString("#", ScoreFont).Height + 5; //This needs to change based on the actual gameplay area size.) if (Source.IncrementedDrawState >= 0) { //Draw HIGH SCORES var Measured = g.MeasureString(Source.HeaderText, ScoreFont); PointF DrawPosition = new PointF(MiddleX - (Measured.Width / 2), StartY); g.DrawString(Source.HeaderText, ScoreFont, Brushes.White, new PointF(DrawPosition.X + 2, DrawPosition.Y + 2)); g.DrawString(Source.HeaderText, ScoreFont, Brushes.Black, DrawPosition); } if (Source.IncrementedDrawState >= 1) { float LineYPosition = StartY + LineHeight; //draw a line underneath the High scores text g.DrawLine(LinePen, 20, LineYPosition, Bounds.Width - 20, LineYPosition); } if (Source.IncrementedDrawState >= 2) { //draw the high score listing entries. //iterate from 2 to drawstate and draw the high score at position drawstate-2. for (int scoreiterate = 2; scoreiterate < Source.IncrementedDrawState; scoreiterate++) { int CurrentScoreIndex = scoreiterate - 2; int CurrentScorePosition = CurrentScoreIndex + 1; float useYPosition = StartY + (LineHeight * 2.5f) + LineHeight * CurrentScoreIndex; float UseXPosition = Bounds.Width * 0.19f; String sUseName = "N/A"; int sUseScore = 0; IHighScoreEntry currentScore = Source.hs.Count > CurrentScoreIndex ? Source.hs[CurrentScoreIndex] : null; if (currentScore != null) { sUseName = currentScore.Name; sUseScore = currentScore.Score; } var MeasureScore = g.MeasureString(sUseScore.ToString(), ScoreFont); var MeasureName = g.MeasureString(sUseName, ScoreFont); float PosXPosition = Bounds.Width * 0.1f; float NameXPosition = Bounds.Width * 0.20f; float ScoreXPositionRight = Bounds.Width * (1 - 0.10f); Brush DrawScoreBrush = Source.HighlightedScorePositions.Contains(CurrentScorePosition) ? GetHighlightBrush() : Brushes.Gray; g.DrawString(CurrentScorePosition.ToString(), ScoreFont, Brushes.Black, PosXPosition + 2, useYPosition + 2); g.DrawString(CurrentScorePosition.ToString(), ScoreFont, DrawScoreBrush, PosXPosition, useYPosition); g.DrawString(sUseName, ScoreFont, Brushes.Black, NameXPosition + 2, useYPosition + 2); g.DrawString(sUseName, ScoreFont, DrawScoreBrush, NameXPosition, useYPosition); float ScoreXPosition = ScoreXPositionRight - MeasureScore.Width; g.DrawString(sUseScore.ToString(), ScoreFont, Brushes.Black, ScoreXPosition + 2, useYPosition + 2); g.DrawString(sUseScore.ToString(), ScoreFont, DrawScoreBrush, ScoreXPosition, useYPosition); g.DrawLine(new Pen(DrawScoreBrush, 3), NameXPosition + MeasureName.Width + 15, useYPosition + LineHeight / 2, ScoreXPosition - 15, useYPosition + LineHeight / 2); if (Source.SelectedScorePosition == CurrentScoreIndex) { //draw the selection arrow to the left of the NamePosition and useYPosition. var MeasureArrow = g.MeasureString(PointerText, ScoreFont); float ArrowX = PosXPosition - MeasureArrow.Width - 5; float ArrowY = useYPosition; g.DrawString(PointerText, ScoreFont, Brushes.Black, ArrowX + 2, ArrowY + 2); g.DrawString(PointerText, ScoreFont, DrawScoreBrush, ArrowX, ArrowY); } } } } }
public virtual int CompareTo(IHighScoreEntry <T> other) { return(Score.CompareTo(other.Score)); }