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

            RenderingProvider.Static.DrawElement(pOwner, pRenderTarget, Source._ReturnState, Element);
            //Draw Faded out overlay to darken things up.
            DrawFadeOverlay(g, Bounds);
            //draw a centered Countdown

            if (Source.LastSecond != Source.timeremaining.Seconds)
            {
                //emit a sound.
                TetrisGame.Soundman.PlaySound(pOwner.AudioThemeMan.GameOverShade.Key, pOwner.Settings.std.EffectVolume);
                Source.LastSecond = Source.timeremaining.Seconds;
                Source.lastMillis = 1000;
            }

            double SecondsLeft  = Math.Round(Source.timeremaining.TotalSeconds, 1);
            String sSecondsLeft = Source.timeremaining.ToString("%s");
            double Millis       = (double)Source.timeremaining.Milliseconds / 1000d; //millis in percent. We will use this to animate the unpause time left.

            Millis = Math.Min(Millis, Source.lastMillis);
            float useSize     = (float)(64f * (1 - (Millis)));
            var   SecondsFont = TetrisGame.GetRetroFont(useSize, pOwner.ScaleFactor);
            var   MeasureText = g.MeasureString(sSecondsLeft, SecondsFont);

            PointF DrawPosition = new PointF(Bounds.Width / 2 - MeasureText.Width / 2, Bounds.Height / 2 - MeasureText.Height / 2);

            g.DrawString(sSecondsLeft, SecondsFont, Brushes.White, DrawPosition);
            Source.lastMillis = Millis;
        }
        public void Render(IStateOwner pOwner, Graphics pRenderTarget, PauseGameState Source, BaseDrawParameters Element)
        {
            if (!Source.DrawDataInitialized)
            {
                InitDrawData(pOwner, Source, Element);
                Source.DrawDataInitialized = true;
            }
            Graphics g          = pRenderTarget;
            var      Bounds     = Element.Bounds;
            var      FallImages = Source.FallImages;
            //Render the paused state.
            Font   usePauseFont = TetrisGame.GetRetroFont(24, pOwner.ScaleFactor);
            String sPauseText   = "Pause";
            SizeF  Measured     = g.MeasureString(sPauseText, usePauseFont);

            g.FillRectangle(Brushes.Gray, Bounds);
            foreach (var iterate in FallImages)
            {
                iterate.Draw(g);
            }

            g.ResetTransform();
            PointF DrawPos = new PointF(Bounds.Width / 2 - Measured.Width / 2, Bounds.Height / 2 - Measured.Height / 2);

            TetrisGame.DrawText(g, usePauseFont, sPauseText, Brushes.White, Brushes.Black, DrawPos.X, DrawPos.Y);
            //retrieve the renderer for the MenuState object.
            base.Render(pOwner, pRenderTarget, Source, Element);
        }
        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 void PopulateOptions(IStateOwner pOwner)
        {
            int  DesiredFontPixelHeight = (int)(pOwner.GameArea.Height * (23d / 644d));
            Font standardFont           = TetrisGame.GetRetroFont(DesiredFontPixelHeight, 1.0f);
            Font ItemFont = TetrisGame.GetRetroFont(DesiredFontPixelHeight * .75f, 1.0);
            MenuStateTextMenuItem ReturnItem = new MenuStateTextMenuItem()
            {
                Text = "Return"
            };

            StateHeader    = "Choose Handler";
            HeaderTypeface = TetrisGame.GetRetroFont(14, 1.0f).FontFamily.Name;
            HeaderTypeSize = DesiredFontPixelHeight * .75f;



            var useDictionary = pOwner.Settings.AllSettings;
            Dictionary <MenuStateTextMenuItem, KeyValuePair <String, StandardSettings> > setlookup = new Dictionary <MenuStateTextMenuItem, KeyValuePair <String, StandardSettings> >();

            foreach (var iterateset in useDictionary)
            {
                MenuStateTextMenuItem submenuitem = new MenuStateTextMenuItem()
                {
                    Text = iterateset.Key
                };
                submenuitem.FontFace = ItemFont.FontFamily.Name;
                submenuitem.FontSize = ItemFont.Size;
                MenuElements.Add(submenuitem);
                setlookup.Add(submenuitem, iterateset);
            }

            MenuItemActivated += (obj, e) =>
            {
                if (e.MenuElement == ReturnItem)
                {
                    pOwner.Settings.Save();
                    pOwner.CurrentState = _OriginalState;
                }
                else
                {
                    MenuStateTextMenuItem selecteditem = e.MenuElement as MenuStateTextMenuItem;
                    var getkvp           = setlookup[selecteditem];
                    OptionsMenuState oms = new OptionsMenuState(this._BG, pOwner, this, getkvp.Key, getkvp.Value);
                    pOwner.CurrentState = oms;
                    this.ActivatedItem  = null;
                }
            };
            ReturnItem.FontFace = ItemFont.FontFamily.Name;
            ReturnItem.FontSize = ItemFont.Size;
            MenuElements.Add(ReturnItem);
        }
        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(' ', '_');
            }
        }
Beispiel #6
0
        public void PopulateMenu(GenericMenuState Target, IStateOwner pOwner)
        {
            Target.StateHeader = "BASeTris";

            //var NewGameItem = new MenuStateTextMenuItem() { Text = "New Game" };
            var NewGameItem = new MenuStateTextMenuItem()
            {
                Text = "New Game"
            };
            var OptionsItem = new MenuStateTextMenuItem()
            {
                Text = "Options"
            };
            var scaleitem      = new MenuStateScaleMenuItem(pOwner);
            var HighScoresItem = new MenuStateTextMenuItem()
            {
                Text = "High Scores"
            };
            var ExitItem = new ConfirmedTextMenuItem()
            {
                Text = "Quit"
            };

            ExitItem.OnOptionConfirmed += (a, b) =>
            {
                if (pOwner is BASeTrisTK)
                {
                    ((BASeTrisTK)pOwner).Exit();
                }
                else if (pOwner is BASeTris)
                {
                    ((BASeTris)pOwner).Close();
                }
            };

            /*NewGameItem.OnDeactivateOption += (o, eventarg) =>
             * {
             *   //start a new game.
             *
             *
             *   if (pOwner is IGamePresenter igp)
             *   {
             *       IGameCustomizationHandler Handler = (eventarg.Option.Handler);
             *       if (Handler != null)
             *       {
             *           //IGameCustomizationHandler Handler = DrMarioGame ? (IGameCustomizationHandler)new DrMarioHandler() : (IGameCustomizationHandler)new StandardTetrisHandler();
             *           pOwner.CurrentState = new GameplayGameState(Handler, null, TetrisGame.Soundman);
             *
             *           igp.StartGame();
             *       }
             *       else
             *       {
             *           NewGameItem.Reset();
             *       }
             *   }
             * };
             * NewGameItem.OnActivateOption += (o, eventarg) =>
             * {
             *
             * };
             * NewGameItem.OnChangeOption += (o2, eventarg2) =>
             * {
             *  //nothing for when we change the option.
             * };*/

            Target.MenuItemActivated += (o, e) =>
            {
                if (e.MenuElement == NewGameItem)
                {
                    GenericMenuState gms = new GenericMenuState(Target.BG, pOwner, new NewGameMenuPopulator(Target));
                    pOwner.CurrentState  = gms;
                    Target.ActivatedItem = null;
                }

                else if (e.MenuElement == OptionsItem)
                {
                    //Show the options menu
                    //var OptionsMenu = new OptionsMenuState(Target.BG, pOwner, pOwner.CurrentState); // GenericMenuState(Target.BG, pOwner, new OptionsMenuPopulator());
                    var OptionsMenu = new OptionsMenuSettingsSelectorState(Target.BG, pOwner, pOwner.CurrentState);
                    pOwner.CurrentState  = OptionsMenu;
                    Target.ActivatedItem = null;
                }
                else if (e.MenuElement == HighScoresItem)
                {
                    ShowHighScoresState scorestate = new ShowHighScoresState(TetrisGame.ScoreMan["Standard"], Target, null);
                    pOwner.CurrentState  = scorestate;
                    Target.ActivatedItem = null;
                }
                else if (e.MenuElement == ExitItem)
                {
                    //nothing, this needs confirmation so is handled separate.
                }
            };



            var FontSrc = TetrisGame.GetRetroFont(14, 1.0f);

            Target.HeaderTypeface = FontSrc.FontFamily.Name;
            Target.HeaderTypeSize = (float)(28f * pOwner.ScaleFactor);
            foreach (var iterate in new [] { NewGameItem, OptionsItem, scaleitem, HighScoresItem, ExitItem })
            {
                iterate.FontFace = FontSrc.FontFamily.Name;
                iterate.FontSize = FontSrc.Size;
                Target.MenuElements.Add(iterate);
            }
        }
Beispiel #7
0
        //right now a copy of the title menu...

        public void PopulateMenu(GenericMenuState Target, IStateOwner pOwner)
        {
            var NewGameItem = new MenuStateTextMenuItem()
            {
                Text = "New Game"
            };
            var OptionsItem = new MenuStateTextMenuItem()
            {
                Text = "Options"
            };
            var HighScoresItem = new MenuStateTextMenuItem()
            {
                Text = "High Scores"
            };
            var ExitItem = new ConfirmedTextMenuItem()
            {
                Text = "Quit"
            };

            ExitItem.OnOptionConfirmed += (a, b) =>
            {
                if (pOwner is BASeTrisTK)
                {
                    ((BASeTrisTK)pOwner).Exit();
                }
                else if (pOwner is BASeTris)
                {
                    ((BASeTris)pOwner).Close();
                }
            };
            Target.MenuItemActivated += (o, e) =>
            {
                if (e.MenuElement == NewGameItem)
                {
                    //start a new game.
                    if (pOwner is IGamePresenter igp)
                    {
                        igp.StartGame();
                    }
                }
                if (e.MenuElement == OptionsItem)
                {
                    //Show the options menu
                }
                if (e.MenuElement == HighScoresItem)
                {
                    ShowHighScoresState scorestate = new ShowHighScoresState(TetrisGame.ScoreMan["Standard"], Target, null);
                    pOwner.CurrentState  = scorestate;
                    Target.ActivatedItem = null;
                }
                if (e.MenuElement == ExitItem)
                {
                    //nothing, this needs confirmation so is handled separate.
                }
            };



            var FontSrc = TetrisGame.GetRetroFont(20, 1.0f);

            foreach (var iterate in new[] { NewGameItem, OptionsItem, HighScoresItem, ExitItem })
            {
                iterate.FontFace = FontSrc.FontFamily.Name;
                iterate.FontSize = FontSrc.Size;
                Target.MenuElements.Add(iterate);
            }
        }
Beispiel #8
0
        public void PopulateMenu(GenericMenuState Target, IStateOwner pOwner)
        {
            Target.StateHeader = "Select Game Type";

            //var NewGameItem = new MenuStateTextMenuItem() { Text = "New Game" };
            List <MenuStateMenuItem> AllItems = new List <MenuStateMenuItem>();
            Dictionary <MenuStateMenuItem, IGameCustomizationHandler> HandlerLookup = new Dictionary <MenuStateMenuItem, IGameCustomizationHandler>();
            var BackItem = new MenuStateTextMenuItem()
            {
                Text = "Back to Main"
            };

            foreach (var iterate in Program.GetGameHandlers())
            {
                ConstructorInfo ci = iterate.GetConstructor(new Type[] { });
                if (ci != null)
                {
                    IGameCustomizationHandler handler   = (IGameCustomizationHandler)ci.Invoke(new object[] { });
                    MenuStateTextMenuItem     builditem = new MenuStateTextMenuItem()
                    {
                        Text = handler.Name
                    };
                    HandlerLookup.Add(builditem, handler);
                    AllItems.Add(builditem);
                }
            }
            AllItems.Add(BackItem);



            Target.MenuItemActivated += (o, e) =>
            {
                if (HandlerLookup.ContainsKey(e.MenuElement))
                {
                    IGameCustomizationHandler usehandler = HandlerLookup[e.MenuElement];
                    if (pOwner is IGamePresenter igp)
                    {
                        pOwner.CurrentState = new GameplayGameState(usehandler, null, TetrisGame.Soundman, Target.PrimaryMenu);

                        igp.StartGame();
                    }
                }
                else if (e.MenuElement == BackItem)
                {
                    pOwner.CurrentState = RevertState;
                }
            };



            var FontSrc = TetrisGame.GetRetroFont(14, 1.0f);

            Target.HeaderTypeface = FontSrc.FontFamily.Name;
            Target.HeaderTypeSize = (float)(28f * pOwner.ScaleFactor);
            foreach (var iterate in AllItems)
            {
                if (iterate is MenuStateTextMenuItem titem)
                {
                    titem.FontFace = FontSrc.FontFamily.Name;
                    titem.FontSize = FontSrc.Size;
                }
                Target.MenuElements.Add(iterate);
            }
        }
Beispiel #9
0
        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);
                        }
                    }
                }
            }
        }
        private void PopulateOptions(IStateOwner pOwner)
        {
            int  DesiredFontPixelHeight = (int)(pOwner.GameArea.Height * (23d / 644d));
            Font standardFont           = TetrisGame.GetRetroFont(DesiredFontPixelHeight, 1.0f);
            Font ItemFont = TetrisGame.GetRetroFont(DesiredFontPixelHeight * .75f, 1.0);
            MenuStateTextMenuItem ReturnItem = new MenuStateTextMenuItem()
            {
                Text = "Return"
            };

            StateHeader    = "Options (" + _SettingsTitle + ")";
            HeaderTypeface = TetrisGame.GetRetroFont(14, 1.0f).FontFamily.Name;
            HeaderTypeSize = DesiredFontPixelHeight * .75f;


            MenuItemActivated += (obj, e) =>
            {
                if (e.MenuElement == ReturnItem)
                {
                    _AlterSet.Save();
                    pOwner.CurrentState = _OriginalState;
                }
            };
            //add the sound options label.
            MenuStateLabelMenuItem SoundLabel = new MenuStateLabelMenuItem()
            {
                Text = "--Sound--"
            };

            var useMusicOptions = new SoundOption[]
            {
                new SoundOption("TDM_A_THEME", "Classic"),
                new SoundOption("tetris_a_theme_techno", "Korotechno"),
                new SoundOption("tetris_a_theme_techno_A", "Korotechno - Alt"),
                new SoundOption("tetris_theme_A", "NES A Theme"),
                new SoundOption("tetris_theme_B", "NES B Theme"),
                new SoundOption("tetris_theme_C", "NES C Theme"),
                new SoundOption("tetris_2", "Tetris 2"),
                new SoundOption("smb3_tetris", "Tetris DS-SMB3"),
                new SoundOption("tetrisds", "Tetris DS"),
                new SoundOption("kirbysand", "Kirby Sand"),
                new SoundOption("silius1", "Silius"),
                new SoundOption("journey3", "Journey 3"),
                new SoundOption("tetris_nes_theme", "NES"),
                new SoundOption("tetris_gb_theme", "GB"),
                new SoundOption("DrMarioFever", "Fever"),
                new SoundOption("DrMarioFever_Rock", "Fever Rock"),
                new SoundOption("DrMarioChill", "Chill"),
                new SoundOption("DrMarioChill_Rock", "Chill Rock"),
                new SoundOption("<RANDOM>", "Random")
            };


            var ThemeArray = (from s in AudioTheme.AvailableSoundThemes select new SoundOption(s.Item1, s.Item2)).ToArray();
            int startIndex = 0;

            String CurrentTheme = _AlterSet.SoundScheme;

            for (int i = 0; i < ThemeArray.Length; i++)
            {
                if (ThemeArray[i].Equals(CurrentTheme))
                {
                    startIndex = i;
                    break;
                }
            }


            int    startMusicIndex = 0;
            String CurrentMusic    = pOwner.Settings.std.MusicOption;

            for (int i = 0; i < useMusicOptions.Length; i++)
            {
                if (useMusicOptions[i].SoundKey.Equals(CurrentMusic, StringComparison.OrdinalIgnoreCase))
                {
                    startMusicIndex = i;
                }
            }


            MultiOptionManagerList <SoundOption> SoundOptions      = new MultiOptionManagerList <SoundOption>(useMusicOptions, startMusicIndex);
            MultiOptionManagerList <SoundOption> SoundThemeOptions = new MultiOptionManagerList <SoundOption>(
                ThemeArray, startIndex);
            MenuStateMultiOption <SoundOption> MusicOptionItem      = new MenuStateMultiOption <SoundOption>(SoundOptions);
            MenuStateMultiOption <SoundOption> SoundThemeOptionItem = new MenuStateMultiOption <SoundOption>(SoundThemeOptions);

            MusicOptionItem.Text                 = "Music";
            SoundThemeOptionItem.Text            = "Sound Theme";
            MusicOptionItem.OnChangeOption      += MusicOptionItem_OnActivateOption;
            SoundThemeOptionItem.OnChangeOption += SoundThemeOptionItem_OnChangeOption;
            ReturnItem.FontFace = SoundLabel.FontFace = MusicOptionItem.FontFace = SoundThemeOptionItem.FontFace = ItemFont.FontFamily.Name;
            ReturnItem.FontSize = SoundLabel.FontSize = MusicOptionItem.FontSize = SoundThemeOptionItem.FontSize = ItemFont.Size;
            MenuElements.Add(ReturnItem);
            MenuElements.Add(SoundLabel);
            MenuElements.Add(MusicOptionItem);

            MenuElements.Add(SoundThemeOptionItem);
        }
 public EnterCheatState(GameState pOriginalState, IStateOwner pOwner, int EntryLength, string PossibleChars = " _ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890") : base(pOwner, EntryLength, PossibleChars)
 {
     _PreviousState = pOriginalState;
     EntryFont      = TetrisGame.GetRetroFont(8, pOwner.ScaleFactor);
     EntryPrompt    = new string[] { "Enter Cheat Code" };
 }
        public override void Render(IStateOwner pOwner, Graphics pRenderTarget, GameOverGameState Source, BaseDrawParameters Element)
        {
            var Bounds = Element.Bounds;
            var g      = pRenderTarget;

            if (Source.GameOveredState is GameplayGameState)
            {
                GameplayGameState standardgame = Source.GameOveredState as GameplayGameState;
                SizeF             BlockSize    = new SizeF(Bounds.Width / (float)standardgame.PlayField.ColCount, Bounds.Height / (float)standardgame.PlayField.RowCount);
                useCoverBrush = new LinearGradientBrush(new Rectangle(0, 0, (int)Bounds.Width, (int)BlockSize.Height), Color.DarkSlateGray, Color.MintCream, LinearGradientMode.Vertical);
                RenderingProvider.Static.DrawElement(pOwner, g, Source.GameOveredState, Element);
                g.FillRectangle(useCoverBrush, 0f, 0f, (float)Bounds.Width, (float)BlockSize.Height * Source.CoverBlocks);
            }

            if (Source.CompleteScroll)
            {
                Font EntryFont    = TetrisGame.GetRetroFont(14, pOwner.ScaleFactor);
                Font GameOverFont = TetrisGame.GetRetroFont(24, pOwner.ScaleFactor);

                var    measured    = g.MeasureString(Source.GameOverText, GameOverFont);
                var    measuremini = g.MeasureString(Source.GameOverText, EntryFont);
                PointF GameOverPos = new PointF(Bounds.Width / 2 - measured.Width / 2, measured.Height / 4);
                g.DrawString(Source.GameOverText, GameOverFont, Brushes.White, 5 + GameOverPos.X, 5 + GameOverPos.Y);
                g.DrawString(Source.GameOverText, GameOverFont, Brushes.Black, GameOverPos.X, GameOverPos.Y);

                //draw each "line" of summary statistical information based on ShowExtraLines.

                for (int i = 0; i < Source.CurrentLinesDisplay; i++)
                {
                    float XPosition = Bounds.Width * 0.25f;
                    float YPosition = GameOverPos.Y + ((1 + i) * measuremini.Height) + measuremini.Height;

                    if (i == 0)
                    {
                        var measuredmini = g.MeasureString("---Line Clears---", EntryFont);
                        TetrisGame.DrawText(g, EntryFont, "---Line Clears---", Brushes.Black, Brushes.White, Bounds.Width / 2 - measuredmini.Width / 2, GameOverPos.Y + measured.Height);
                    }

                    if (i == 1)
                    {
                        DrawTetrominoStat(Source, typeof(Tetrominoes.Tetromino_I), new PointF(XPosition, YPosition), g, Bounds, EntryFont);
                    }
                    if (i == 2)
                    {
                        DrawTetrominoStat(Source, typeof(Tetrominoes.Tetromino_O), new PointF(XPosition, YPosition), g, Bounds, EntryFont);
                    }
                    if (i == 3)
                    {
                        DrawTetrominoStat(Source, typeof(Tetrominoes.Tetromino_T), new PointF(XPosition, YPosition), g, Bounds, EntryFont);
                    }
                    if (i == 4)
                    {
                        DrawTetrominoStat(Source, typeof(Tetrominoes.Tetromino_J), new PointF(XPosition, YPosition), g, Bounds, EntryFont);
                    }
                    if (i == 5)
                    {
                        DrawTetrominoStat(Source, typeof(Tetrominoes.Tetromino_L), new PointF(XPosition, YPosition), g, Bounds, EntryFont);
                    }
                    if (i == 6)
                    {
                        DrawTetrominoStat(Source, typeof(Tetrominoes.Tetromino_S), new PointF(XPosition, YPosition), g, Bounds, EntryFont);
                    }
                    if (i == 7)
                    {
                        DrawTetrominoStat(Source, typeof(Tetrominoes.Tetromino_Z), new PointF(XPosition, YPosition), g, Bounds, EntryFont);
                    }
                }

                if (Source.NewScorePosition > -1)
                {
                    Font HighScoreEntryFont = new Font(GameOverFont.FontFamily, (float)(8 * pOwner.ScaleFactor), FontStyle.Regular);
                    //draw the awarded score position as well.
                    float  XPosition         = Bounds.Width * .25f;
                    float  YPosition         = Bounds.Height - measured.Height - 10;
                    String ScoreText         = "New High Score!";
                    var    MeasuredScoreText = g.MeasureString(ScoreText, HighScoreEntryFont);
                    using (Brush RainbowBrush = new SolidBrush(TetrisGame.GetRainbowColor(Color.Lime, 0.1d)))
                    {
                        TetrisGame.DrawText(g, GameOverFont, ScoreText, Brushes.Black, RainbowBrush, Bounds.Width / 2 - MeasuredScoreText.Width / 2, YPosition + measuremini.Height);
                    }
                }
            }
        }