public override void LoadContent() { if (content == null) { content = new ContentManager(ScreenManager.Game.Services, "Content"); } uncheckedCheckbox = content.Load <Texture2D>("Sprites\\checkbox"); checkedCheckbox = content.Load <Texture2D>("Sprites\\checkbox-checked"); foreach (MenuEntry menuEntry in MenuEntries) { //set checkbox image based on completion status try { ChallengeModeMenuEntry cMenuEntry = (ChallengeModeMenuEntry)menuEntry; if (cMenuEntry.IsChallengeCompleted()) { cMenuEntry.SetImage(checkedCheckbox); } else { cMenuEntry.SetImage(uncheckedCheckbox); } } catch (InvalidCastException ice) { //swallow this, it happens when the backMenuEntry is iterated over continue; } } }
public ChallengeModeSelectionScreen(Switch.GameObjects.Challenges.ChallengeManager.ChallengeLevel level) : base("Select A Challenge!") { this.SetSubMenuTitleText("Challenges " + ChallengeManager.Instance.GetPercentOfChallengesCompleted() + "% Completed"); List <IChallenge> challenges = ChallengeManager.Instance.GetChallenges(level); foreach (IChallenge challenge in challenges) { ChallengeModeMenuEntry menuEntry = new ChallengeModeMenuEntry(challenge.GetName(), challenge.GetDescription(), ChallengeManager.Instance.GetChallengeStatus(challenge.GetName())); menuEntry.Selected += ChallengeEntrySelected; MenuEntries.Add(menuEntry); } backMenuEntry = new ExitOrBackMenuEntry("Go Back..."); backMenuEntry.Selected += OnCancel; MenuEntries.Add(backMenuEntry); }