public override void Render(IStateOwner pOwner, Graphics pRenderTarget, ViewScoreDetailsState Source, BaseDrawParameters Element)
        {
            var g      = pRenderTarget;
            var Bounds = Element.Bounds;

            RenderingProvider.Static.DrawElement(pOwner, pRenderTarget, Source.BG, new GDIBackgroundDrawData(Bounds));


            Font HeaderFont    = TetrisGame.GetRetroFont(24, pOwner.ScaleFactor);
            Font PlacementFont = TetrisGame.GetRetroFont(10, pOwner.ScaleFactor);
            Font DetailFont    = TetrisGame.GetRetroFont(8, pOwner.ScaleFactor);


            //One thing we draw in every case is the "--SCORE DETAILS--" header text. this is positioned at 5% from the top, centered in the middle of our bounds.
            float Millipercent = (float)DateTime.Now.Ticks / 5000f; //(float)DateTime.Now.Millisecond / 1000;

            var    MeasuredHeader = g.MeasureString(Source._DetailHeader, HeaderFont);
            int    RotateAmount   = (int)(Millipercent * 240);
            Color  UseColor1      = HSLColor.RotateHue(Color.Red, RotateAmount);
            Color  UseColor2      = HSLColor.RotateHue(Color.LightPink, RotateAmount);
            PointF ScorePosition  = new PointF((Bounds.Width / 2) - (MeasuredHeader.Width / 2), Bounds.Height * 0.05f);

            using (LinearGradientBrush lgb = new LinearGradientBrush(new Rectangle(0, 0, (int)MeasuredHeader.Width, (int)MeasuredHeader.Height), UseColor1, UseColor2, LinearGradientMode.Vertical))
            {
                using (GraphicsPath gp = new GraphicsPath())
                {
                    gp.AddString(Source._DetailHeader, HeaderFont, new Point((int)ScorePosition.X, (int)ScorePosition.Y), StringFormat.GenericDefault);
                    g.FillPath(lgb, gp);
                    g.DrawPath(Pens.White, gp);
                }
            }

            //we also show Xth Place - <NAME> centered below the header using the placementfont.
            String sPlacement = TetrisGame.FancyNumber(Source._Position) + " - " + Source.ShowEntry.Name + " - " + Source.ShowEntry.Score.ToString();

            var measureit = g.MeasureString(sPlacement, PlacementFont);

            PointF DrawPlacement = new PointF(Bounds.Width / 2 - measureit.Width / 2, (float)(ScorePosition.Y + MeasuredHeader.Height * 1.1f));

            g.DrawString(sPlacement, PlacementFont, Brushes.Black, DrawPlacement.X + 3, DrawPlacement.Y + 3);
            g.DrawString(sPlacement, PlacementFont, Brushes.White, DrawPlacement.X, DrawPlacement.Y);

            g.DrawLine(Separator, (float)(Bounds.Width * 0.05f), (float)(DrawPlacement.Y + measureit.Height + 5), (float)(Bounds.Width * 0.95), (float)(DrawPlacement.Y + measureit.Height + 5));


            switch (Source.CurrentView)
            {
            case ViewScoreDetailsState.ViewScoreDetailsType.Details_Tetrominoes:
                DrawTetronimoDetails(Source, g, Bounds);
                break;

            case ViewScoreDetailsState.ViewScoreDetailsType.Details_LevelTimes:
                DrawLevelTimesDetails(Source, g, Bounds);
                break;
            }
        }
 private Color GetLevelColor(int Level)
 {
     if (ColorArray == null)
     {
         var          BaseColor   = Color.Red;
         int          ColorCount  = 10;
         double       Partitions  = 240d / (double)ColorCount;
         List <Color> BuildColors = new List <Color>();
         for (int i = 0; i < ColorCount - 1; i++)
         {
             BuildColors.Add(HSLColor.RotateHue(BaseColor, (int)(i * Partitions)));
         }
         ColorArray = BuildColors.ToArray();
     }
     return(ColorArray[Level % (ColorArray.Length - 1)]);
 }
        public override void Render(IStateOwner pOwner, Graphics pRenderTarget, EnterTextState Source, BaseDrawParameters Element)
        {
            var Bounds = Element.Bounds;
            var g      = pRenderTarget;

            if (Source.useFont == null)
            {
                Source.useFont = TetrisGame.GetRetroFont(15, pOwner.ScaleFactor);
            }
            if (Source.EntryFont == null)
            {
                Source.EntryFont = TetrisGame.GetRetroFont(15, pOwner.ScaleFactor);
            }

            float Millipercent = (float)DateTime.Now.Ticks / 5000f; //(float)DateTime.Now.Millisecond / 1000;

            int RotateAmount = (int)(Millipercent * 240);

            Color UseBackgroundColor   = HSLColor.RotateHue(Color.DarkBlue, RotateAmount);
            Color UseHighLightingColor = HSLColor.RotateHue(Color.Red, RotateAmount);
            Color useLightRain         = HSLColor.RotateHue(Color.LightPink, RotateAmount);

            //throw new NotImplementedException();
            if (Source.BG != null)
            {
                RenderingProvider.Static.DrawElement(pOwner, pRenderTarget, Source.BG, new GDIBackgroundDrawData(Bounds));
            }
            int StartYPosition = (int)(Bounds.Height * 0.15f);
            var MeasureBounds  = g.MeasureString(Source.EntryPrompt[0], Source.useFont);

            for (int i = 0; i < Source.EntryPrompt.Length; i++)
            {
                //draw this line centered at StartYPosition+Height*i...

                int useYPosition = (int)(StartYPosition + (MeasureBounds.Height + 5) * i);
                int useXPosition = Math.Max((int)(Bounds.Width / 2 - MeasureBounds.Width / 2), (int)(Bounds.Left + 15));
                g.DrawString(Source.EntryPrompt[i], Source.useFont, Brushes.Black, new PointF(useXPosition + 5, useYPosition + 5));
                g.DrawString(Source.EntryPrompt[i], Source.useFont, new SolidBrush(useLightRain), new PointF(useXPosition, useYPosition));
            }

            float nameEntryY = StartYPosition + (MeasureBounds.Height + 5) * (Source.EntryPrompt.Length + 1);


            var   AllCharacterBounds = (from c in Source.NameEntered.ToString().ToCharArray() select g.MeasureString(c.ToString(), Source.useFont)).ToArray();
            var   charMeasure        = g.MeasureString("#", Source.EntryFont);
            float useCharWidth       = charMeasure.Width;
            float useCharHeight      = charMeasure.Height;
            float TotalWidth;

            if (Source.EntryStyle == EnterTextState.EntryDrawStyle.EntryDrawStyle_Centered)
            {
                TotalWidth = (useCharWidth + 5) * Source.NameEntered.ToString().Trim('_', ' ').Length;
            }
            TotalWidth = (useCharWidth + 5) * Source.NameEntered.Length;
            float NameEntryX = (Bounds.Width / 2) - (TotalWidth / 2);

            NameEntryX = Math.Max(NameEntryX, Bounds.Left + 10);
            float LineStart = NameEntryX;

            if (Source.EntryStyle == EnterTextState.EntryDrawStyle.EntryDrawStyle_Preblank)
            {
                for (int charpos = 0; charpos < Source.NameEntered.Length; charpos++)
                {
                    char  thischar = Source.NameEntered[charpos];
                    float useX     = NameEntryX + ((useCharWidth + 3) * (charpos));
                    if (useX + useCharWidth > Bounds.Width)
                    {
                        useX        = LineStart;
                        nameEntryY += useCharHeight + 3;
                    }
                    Brush DisplayBrush = (Source.CurrentPosition == charpos) ? new SolidBrush(UseHighLightingColor) : Brushes.NavajoWhite;
                    Brush ShadowBrush  = (Source.CurrentPosition == charpos) ? new SolidBrush(useLightRain) : Brushes.Black;
                    g.DrawString(thischar.ToString(), Source.EntryFont, ShadowBrush, new PointF(useX + 2, nameEntryY + 2));
                    g.DrawString(thischar.ToString(), Source.EntryFont, DisplayBrush, new PointF(useX, nameEntryY));
                }
            }
            else if (Source.EntryStyle == EnterTextState.EntryDrawStyle.EntryDrawStyle_Centered)
            {
                //"simpler"- we just draw the trimmed text.
                String TrimEntered = Source.NameEntered.ToString().Trim(' ', '_');
            }
        }
Exemplo n.º 4
0
        public static Color GetRainbowColor(Color Source, float PercentOffset)
        {
            int useRotation = (int)(PercentOffset * 240) % 240;

            return(HSLColor.RotateHue(Source, useRotation));
        }