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);
        }
Exemple #2
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);
            }
        }
Exemple #3
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);
            }
        }
Exemple #4
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);
            }
        }
        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);
        }