private void LoadStars(LevelSelector screen, Stars stars) { switch (stars) { case Stars.NONE: this.starsTexture = screen.Content.Load <Texture2D>("LevelSelectionIcons_SD\\NoMedal_SD"); break; case Stars.BRONZE: this.starsTexture = screen.Content.Load <Texture2D>("LevelSelectionIcons_SD\\Bronze_SD"); break; case Stars.SILVER: this.starsTexture = screen.Content.Load <Texture2D>("LevelSelectionIcons_SD\\Silver_SD"); break; case Stars.GOLD: this.starsTexture = screen.Content.Load <Texture2D>("LevelSelectionIcons_SD\\Gold_SD"); break; case Stars.LOCKED: this.LockedTexture = screen.Content.Load <Texture2D>("LevelSelectionIcons_SD\\LockedLevel_SD"); this.starsTexture = screen.Content.Load <Texture2D>("LevelSelectionIcons_SD\\NoMedal_SD"); break; } }
/// <summary> /// Constructs a new menu entry with the specified text. /// </summary> public LevelEntry(string levelName, string lvlIconToLoad, Stars stars, LevelSelector screen) { this.starsDisplayed = stars; this.levelName = levelName; this.levelIcon = screen.Content.Load<Texture2D>(lvlIconToLoad); LoadStars(screen, stars); screen.LevelEntries.Add(this); }
/// <summary> /// Queries how much space this menu entry requires. /// </summary> public virtual int GetHeight(LevelSelector screen) { int height = (int)screen.ScreenManager.Font.MeasureString(levelName).Y; height += entryContentPadding * 2; height += levelIcon.Height; height += starsTexture.Height; return(height); }
/// <summary> /// Constructs a new menu entry with the specified text. /// </summary> public LevelEntry(string levelName, string lvlIconToLoad, Stars stars, LevelSelector screen) { this.starsDisplayed = stars; this.levelName = levelName; this.levelIcon = screen.Content.Load <Texture2D>(lvlIconToLoad); LoadStars(screen, stars); screen.LevelEntries.Add(this); }
/// <summary> /// Queries how wide the entry is, used for centering on the screen. /// </summary> public virtual int GetWidth(LevelSelector screen) { int width = (int)screen.ScreenManager.Font.MeasureString(levelName).Y; if (width < levelIcon.Width) { width = levelIcon.Width; } if (width < starsTexture.Width) { width = starsTexture.Width; } return(width); }
/// <summary> /// Updates the menu entry. /// </summary> public virtual void Update(LevelSelector screen, bool isSelected, GameTime gameTime) { // there is no such thing as a selected item on Windows Phone, so we always // force isSelected to be false #if WINDOWS_PHONE isSelected = false; #endif // When the menu selection changes, entries gradually fade between // their selected and deselected appearance, rather than instantly // popping to the new state. float fadeSpeed = (float)gameTime.ElapsedGameTime.TotalSeconds * 4; if (isSelected) { selectionFade = Math.Min(selectionFade + fadeSpeed, 1); } else { selectionFade = Math.Max(selectionFade - fadeSpeed, 0); } }
/// <summary> /// Draws the menu entry. This can be overridden to customize the appearance. /// </summary> public virtual void Draw(LevelSelector screen, bool isSelected, GameTime gameTime) { // there is no such thing as a selected item on Windows Phone, so we always // force isSelected to be false #if WINDOWS_PHONE isSelected = false; #endif // Draw the selected entry in yellow, otherwise white. Color color = isSelected ? Color.Yellow : Color.White; screen.ScreenManager.SpriteBatch.DrawString(screen.ScreenManager.Font, levelName, position, color); screen.ScreenManager.SpriteBatch.Draw(levelIcon, new Rectangle((int)position.X, (int)position.Y + (int)screen.ScreenManager.Font.MeasureString(levelName).Y, levelIcon.Width, levelIcon.Height), Color.White); screen.ScreenManager.SpriteBatch.Draw(starsTexture, new Rectangle((int)position.X, (int)position.Y + ((int)screen.ScreenManager.Font.MeasureString(levelName).Y + levelIcon.Height), starsTexture.Width, starsTexture.Height), Color.White); if (starsDisplayed == Stars.LOCKED) { screen.ScreenManager.SpriteBatch.Draw(LockedTexture, new Rectangle((int)position.X - 15, (int)position.Y + 15, LockedTexture.Width, LockedTexture.Height), Color.White); } }
private void LoadStars(LevelSelector screen, Stars stars) { switch (stars) { case Stars.NONE: this.starsTexture = screen.Content.Load<Texture2D>("LevelSelectionIcons_SD\\NoMedal_SD"); break; case Stars.BRONZE: this.starsTexture = screen.Content.Load<Texture2D>("LevelSelectionIcons_SD\\Bronze_SD"); break; case Stars.SILVER: this.starsTexture = screen.Content.Load<Texture2D>("LevelSelectionIcons_SD\\Silver_SD"); break; case Stars.GOLD: this.starsTexture = screen.Content.Load<Texture2D>("LevelSelectionIcons_SD\\Gold_SD"); break; case Stars.LOCKED: this.LockedTexture = screen.Content.Load<Texture2D>("LevelSelectionIcons_SD\\LockedLevel_SD"); this.starsTexture = screen.Content.Load<Texture2D>("LevelSelectionIcons_SD\\NoMedal_SD"); break; } }
/// <summary> /// Updates the menu entry. /// </summary> public virtual void Update(LevelSelector screen, bool isSelected, GameTime gameTime) { // there is no such thing as a selected item on Windows Phone, so we always // force isSelected to be false #if WINDOWS_PHONE isSelected = false; #endif // When the menu selection changes, entries gradually fade between // their selected and deselected appearance, rather than instantly // popping to the new state. float fadeSpeed = (float)gameTime.ElapsedGameTime.TotalSeconds * 4; if (isSelected) selectionFade = Math.Min(selectionFade + fadeSpeed, 1); else selectionFade = Math.Max(selectionFade - fadeSpeed, 0); }
/// <summary> /// Queries how wide the entry is, used for centering on the screen. /// </summary> public virtual int GetWidth(LevelSelector screen) { int width = (int)screen.ScreenManager.Font.MeasureString(levelName).Y; if (width < levelIcon.Width) width = levelIcon.Width; if (width < starsTexture.Width) width = starsTexture.Width; return width; }
/// <summary> /// Queries how much space this menu entry requires. /// </summary> public virtual int GetHeight(LevelSelector screen) { int height = (int)screen.ScreenManager.Font.MeasureString(levelName).Y; height += entryContentPadding * 2; height += levelIcon.Height; height += starsTexture.Height; return height; }