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); } }
//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); } }