internal ScoreboardEntryExtended(int rank, User user, MatchScoringTypes scoreType, PlayModes playMode, SlotTeams team, Mods mods = Mods.None) : base(rank, user.Name, playMode) { PositionOffset = new Vector2(32.4f, 0); Team = team; this.scoreType = scoreType; this.mods = mods; //SpriteCollection.AddRange(ModManager.ShowModSprites(mods, new Vector2(34, 6), 0.5f)); SpriteAvatar = new pSpriteDynamic(null, null, 0, new Vector2(-15.6f, 12.51f), 0.920001f) { Alpha = 0 }; user.LoadAvatarInto(SpriteAvatar, 51f); SpriteSkip = new pSprite(TextureManager.Load(@"multi-skipped"), Fields.TopLeft, Origins.BottomRight, Clocks.Game, new Vector2(86, 30), SpriteBackground.Depth + 0.000001f, true, Color.White) { Alpha = 0, Bypass = true }; SpriteCollection.Add(SpriteSkip); SpriteCollection.Add(SpriteAvatar); UpdateSpriteLayout(); }
private void InitializeAvatar() { Vector2 startPosition = currentPosition; Vector2 offset = new Vector2(23, 23); float depth = spriteBackground != null ? spriteBackground.Depth + 0.000001f : 0; if (spriteAvatar != null) { spriteAvatar.InitialPosition = startPosition + offset; if (spriteAvatar.Texture == null) { spriteAvatar.OnTextureLoaded += delegate { spriteAvatar.Scale = 74F / Math.Max(spriteAvatar.Width, spriteAvatar.Height); } } ; spriteAvatar.Scale = 74F / Math.Max(spriteAvatar.Width, spriteAvatar.Height); } else { spriteAvatar = GetFreshAvatarSprite(startPosition + offset, depth, 74f); if (Sprites != null) { Sprites.Add(spriteAvatar); } } spriteAvatar.Position = currentPosition + offset; spriteAvatar.Origin = Origins.Centre; }
public bool LoadAvatarInto(pSpriteDynamic p, float maxDimension) { p.Origin = Origins.Centre; p.Url = Id <= 0 ? null : string.Format(Id == GameBase.User.Id ? Urls.USER_GET_AVATAR_NOCACHE : Urls.USER_GET_AVATAR, Id); p.LocalCache = Path.Combine(User.AvatarFilePath, Id.ToString()); p.MaxDimension = maxDimension; return(p.State == LoadState.Unknown); }
internal pSpriteDynamic GetFreshAvatarSprite(Vector2 position, float depth, float maxDimension) { bool isLocal = Id == GameBase.User.Id; pSpriteDynamic psd = new pSpriteDynamic(Id < 0 ? null : string.Format(this.Id == GameBase.User.Id ? Urls.USER_GET_AVATAR_NOCACHE : Urls.USER_GET_AVATAR, Id), Path.Combine(AvatarFilePath, Id.ToString()), isLocal ? 0 : 500, position, depth); psd.OnTextureLoaded += delegate { psd.Scale = maxDimension / Math.Max(psd.Width, psd.Height); }; return(psd); }
internal BackgroundManager(Tournament tournament, SpriteManager spriteManager, float depth) { this.tournament = tournament; var remoteBackgroundSprite = new pSpriteDynamic(Tournament.Config.GetValue(@"background", @"https://osu.ppy.sh/images/tournament/default.png"), null, 0, Vector2.Zero, 0.1f) { AlwaysDraw = true, Alpha = 0 }; remoteBackgroundSprite.OnTextureLoaded += () => remoteBackgroundSprite.ScaleToScreen(false, true); spriteManager.Add(remoteBackgroundSprite); foreach (string bg in backgroundNames) { var tex = TextureManager.Load(Path.Combine(Tournament.SkinDirectory, bg)); if (tex != null) { var bgSprite = new pSprite(tex, Fields.TopLeft, Origins.TopLeft, Clocks.Game, Vector2.Zero, depth, true, Color.White) { Alpha = 0 }; bgSprite.ScaleToScreen(false, true); modeBackgroundSprites.Add(bg, bgSprite); spriteManager.Add(bgSprite); } var tempVideo = new pVideo(Path.Combine(Tournament.SkinDirectory, bg), SkinSource.Skin, Clocks.Game); if (tempVideo.Texture != null) { tempVideo.Field = Fields.TopLeft; tempVideo.Origin = Origins.TopLeft; // Make sure videos are above backgrounds in all cases tempVideo.Depth = depth + 0.0001f; tempVideo.Alpha = 0; tempVideo.Loop = true; tempVideo.ScaleToScreen(false, true); tempVideo.UpdateTextureAlignment(); modeBackgroundVideos.Add(bg, tempVideo); spriteManager.Add(tempVideo); } depth += 0.00001f; } if (!modeBackgroundSprites.ContainsKey(backgroundNames[0])) { modeBackgroundSprites.Add(backgroundNames[0], remoteBackgroundSprite); } loadBackground(@"background"); }
protected virtual void PopulateSprites() { Debug.Assert(SpriteCollection == null && !IsLoaded); SpriteCollection = new List <pDrawable>(); if (Beatmap != null) { PlayModes?mode = modeOverride; if (Beatmap != null && Beatmap.PlayMode != PlayModes.Osu) { mode = Beatmap.PlayMode; } OldLayout = SkinManager.Current.Version < 2.2 && TextureManager.Load(@"menu-button-background").Source != SkinSource.Osu; string text = Beatmap.SortTitleAuto; string text2 = Beatmap.Creator.Length > 0 ? Beatmap.Creator : "unknown creator"; backgroundSprite = new pSprite(s_menuButtonBackground, Fields.TopLeft, Origins.CentreLeft, Clocks.Game, new Vector2((float)Position.X, (float)Position.Y), StartDepth, true, BackgroundColour, this); backgroundSprite.HandleInput = true; SpriteCollection.Add(backgroundSprite); bool thumb = shouldShowThumbnail; float xPadding = OldLayout ? 15 : 5; float thumbPadding = thumb ? 75 : 5; float yPadding = OldLayout ? -3 : 0; float titleSize = GameBase.TournamentDrawings ? 22 : 16; textTitle = new pText(Name, titleSize, Vector2.Zero, Vector2.Zero, StartDepth + DEPTH_INCREASE_STEP, true, colourTextInactive, false); textTitle.Origin = Origins.CentreLeft; textTitle.Tag = new Vector2(thumbPadding, yPadding - (GameBase.Tournament ? 0 : 16)); blackSprites.Add(textTitle); SpriteCollection.Add(textTitle); textArtist = new pText(Beatmap.ArtistAuto + @" // " + Beatmap.Creator, 12, Vector2.Zero, Vector2.Zero, StartDepth + DEPTH_INCREASE_STEP, true, colourTextInactive, false); textArtist.Origin = Origins.CentreLeft; textArtist.Tag = new Vector2(thumbPadding + 1, yPadding - 4); blackSprites.Add(textArtist); if (!GameBase.TournamentDrawings) { SpriteCollection.Add(textArtist); } if (thumb) { bool highres = GameBase.WindowManager.Height >= 768; thumbnail = new pSpriteDynamic(General.STATIC_WEB_ROOT_BEATMAP + @"/thumb/" + Beatmap.BeatmapSetId + (highres ? @"l" : @"") + @".jpg", Path.Combine(OsuMain.UserPath, @"Data", @"bt", Beatmap.BeatmapSetId + (highres ? @"l" : @"") + @".jpg"), 500, Vector2.Zero, StartDepth + DEPTH_INCREASE_STEP); if (GameBase.TournamentDrawings) { thumbnail.Url = string.Empty; thumbnail.LocalCache = Path.Combine(Beatmap.ContainingFolderAbsolute, Beatmap.BackgroundImage); thumbnail.State = LoadState.Unloaded; thumbnail.OnUnload += delegate { if (thumbnail != null) { thumbnail.State = LoadState.Unloaded; } }; } ((pSpriteDynamic)thumbnail).OnTextureLoaded += delegate { thumbnail.FadeInFromZero(400); if (GameBase.TournamentDrawings) { thumbnail.VectorScale = Vector2.One; thumbnail.Scale = Math.Min(114f / thumbnail.Width, 85.5f / thumbnail.Height); } }; thumbnail.InitialColour = new Color(50, 50, 50, 255); thumbnail.Additive = true; thumbnail.VectorScale = new Vector2(1.425f, 1.425f) * (highres ? 0.5f : 1); thumbnail.Origin = Origins.CentreLeft; thumbnail.Tag = new Vector2(5.2f, 0.25f); SpriteCollection.Add(thumbnail); } AlwaysVisibleSprites = SpriteCollection.Count; float starScale; if (OldLayout) { starScale = 0.6f; } else { starScale = 0.8f; } textDifficulty = new pText(string.Empty, 12, Vector2.Zero, Vector2.Zero, StartDepth + DEPTH_INCREASE_STEP, true, colourTextInactive, false); textDifficulty.Origin = Origins.CentreLeft; textDifficulty.TextBold = true; textDifficulty.Tag = new Vector2(thumbPadding + 1, yPadding + 7); blackSprites.Add(textDifficulty); SpriteCollection.Add(textDifficulty); UpdateDifficultyText(); if (mode.HasValue) { hasMode = true; pTexture modeTexture = null; switch (mode) { case PlayModes.Osu: modeTexture = TextureManager.Load(@"mode-osu-small", SkinSource.Osu); break; case PlayModes.Taiko: modeTexture = TextureManager.Load(@"mode-taiko-small", SkinSource.Osu); break; case PlayModes.CatchTheBeat: modeTexture = TextureManager.Load(@"mode-fruits-small", SkinSource.Osu); break; case PlayModes.OsuMania: modeTexture = TextureManager.Load(@"mode-mania-small", SkinSource.Osu); break; } modeSprite = new pSprite(modeTexture, Fields.TopLeft, Origins.CentreLeft, Clocks.Game, Vector2.Zero, StartDepth + DEPTH_INCREASE_STEP, true, Color.White); modeSprite.VectorScale = new Vector2(0.8f, 0.8f); modeSprite.Tag = new Vector2(xPadding + thumbPadding + 1, yPadding - 13); blackSprites.Add(modeSprite); SpriteCollection.Add(modeSprite); } rankSprite = new pSprite(null, Origins.CentreLeft, Vector2.Zero, StartDepth + DEPTH_INCREASE_STEP, true, Color.White); rankSprite.Tag = new Vector2(xPadding + thumbPadding - 1, yPadding + (hasMode ? 14 : 0)); SpriteCollection.Add(rankSprite); UpdateRank(); } for (int i = 0; i < SpriteCollection.Count; i++) { SpriteCollection[i].Alpha = 0; } }
private void ClearSprites() { Sprites = null; spriteAvatar = null; }
public bool DrawAt(Vector2 pos) { bool firstPopulation = SpriteCollection == null; if (firstPopulation) { position = pos; SpriteCollection = new List <pSprite>(); bg = new pSprite(GameBase.WhitePixel, Fields.TopLeft, Origins.TopLeft, Clocks.Game, pos, 0.89F, true, new Color(255, 255, 255, 25)); bg.VectorScale = new Vector2(GameBase.WindowManager.WidthScaled - 15, 48); bg.Scale = 1.6f; bg.OnHover += delegate { bg.FadeColour(ColourHelper.ChangeAlpha(bg.InitialColour, 50), 100); AudioEngine.Click(null, @"click-short"); }; bg.OnHoverLost += delegate { CheckUnhover(); }; bg.ClickRequiresConfirmation = true; bg.OnClick += joinMatch; infoLeft1 = new pText(string.Empty, 12, pos + new Vector2(20, 0), 0.9f, true, Color.White); infoLeft1.TextBold = true; SpriteCollection.Add(infoLeft1); infoLeft2 = new pText(string.Empty, 11, pos + new Vector2(56, 13), 0.9f, true, Color.White); SpriteCollection.Add(infoLeft2); infoRight1 = new pText(string.Empty, 12, pos + new Vector2(240, 0), 0.9f, true, Color.White); infoRight1.TextBold = true; SpriteCollection.Add(infoRight1); infoRight2 = new pText(string.Empty, 11, pos + new Vector2(240, 11), 0.9f, true, Color.White); SpriteCollection.Add(infoRight2); password = new pSprite(TextureManager.Load(@"lobby-lock", SkinSource.Osu), pos + new Vector2(3, 5), 0.895f, true, Color.TransparentWhite); SpriteCollection.Add(password); gametype = new pSprite(null, pos + new Vector2(0, 3), 0.894f, true, Color.White); SpriteCollection.Add(gametype); Vector2 avPos = pos + new Vector2(210, 24); hostAvatar = new pSpriteDynamic(null, null, 200, avPos, 0.920001f); hostBackground = new pSprite(TextureManager.Load(@"lobby-avatar", SkinSource.Osu), Origins.Centre, avPos, 0.92f, true, playerColour); hostBackground.Alpha = 1; hostBackground.Scale = 1f; hostBackground.HandleInput = true; hostBackground.OnHoverLost += delegate { CheckUnhover(); }; hostBackground.ClickRequiresConfirmation = true; hostBackground.OnClick += joinMatch; SpriteCollection.Add(hostAvatar); SpriteCollection.Add(hostBackground); slot_size = !GameBase.WindowManager.IsWidescreen && matchInfo.slotUsedAboveEight ? 0.75f : 1; for (int i = 0; i < bMatch.MAX_PLAYERS - 1; i++) { avPos = pos + new Vector2(i * 33f * slot_size + 251.4f, 24f + 10.4f); avatars.Add(new pSpriteDynamic(null, null, 200, avPos, 0.920001f)); pSprite abg = new pSprite(TextureManager.Load(@"lobby-avatar", SkinSource.Osu), Origins.Centre, avPos, 0.92f, true, Color.TransparentWhite); abg.Alpha = 0; abg.Scale = 0.58f * slot_size; abg.HandleInput = true; abg.OnHoverLost += delegate { CheckUnhover(); }; //Because these also get hovered, if the mouse moves from the avatar to another point outside the LobbyMatch the bg will not return states unless this triggers. abg.OnClick += joinMatch; abg.ClickRequiresConfirmation = true; avatarBackgrounds.Add(abg); } SpriteCollection.AddRange(avatarBackgrounds); foreach (pSpriteDynamic p in avatars) { SpriteCollection.Add(p); } SpriteCollection.Add(bg); } else { foreach (pSprite p in SpriteCollection) { Vector2 destination = pos + (p.InitialPosition - position); p.MoveTo(destination, 500, EasingTypes.Out); } } password.Bypass = !matchInfo.passwordRequired; float avgLevel = 0; float avgRank = 0; float minLevel = 1000; float maxLevel = 0; float minRank = 1000000; float maxRank = 0; bool hasUnranked = false; int totalPlayers = 0; int k = -1; for (int j = 0; j < bMatch.MAX_PLAYERS; j++) { int s = matchInfo.slotId[j]; pSpriteDynamic thisAvatar; pSprite thisAvatarBackground; bool isHost = s == matchInfo.hostId; if (!isHost) { //Add non-host players to the player list. k++; if (k >= avatars.Count) { break; } thisAvatar = avatars[k]; thisAvatarBackground = avatarBackgrounds[k]; if (matchInfo.slotStatus[j] != SlotStatus.Locked) { thisAvatarBackground.Bypass = false; if (matchInfo.slotStatus[j] != SlotStatus.Open) { thisAvatarBackground.HandleInput = true; thisAvatarBackground.FadeColour(playerColour, 200); thisAvatarBackground.FadeTo(1, 200, EasingTypes.None); } else { thisAvatarBackground.HandleInput = false; thisAvatarBackground.FadeColour(openColour, 200); thisAvatarBackground.FadeTo(100 / 255f, 200, EasingTypes.None); } } else { thisAvatarBackground.HandleInput = false; thisAvatarBackground.FadeColour(closedColour, 200); thisAvatarBackground.FadeTo(100 / 255f, 200, EasingTypes.None); } } else { thisAvatar = hostAvatar; thisAvatarBackground = hostBackground; } if (s >= 0) { User u = BanchoClient.GetUserById(s); if (u == null) { continue; } avgLevel += u.Level; avgRank += u.Rank; if (u.Level < minLevel) { minLevel = u.Level; } if (u.Level > maxLevel) { maxLevel = u.Level; } if (u.Rank < minRank) { if (u.Rank == 0) { hasUnranked = true; } else { minRank = u.Rank; } } if (u.Rank > maxRank) { maxRank = u.Rank; } totalPlayers++; if (string.IsNullOrEmpty(thisAvatarBackground.ToolTip) || thisAvatarBackground.ToolTip.StartsWith(User.LOADING_STRING)) { thisAvatarBackground.ToolTip = string.Format(u.Name + " (#" + u.Rank + ")\n" + u.Location); } if (thisAvatar.Tag != u) { thisAvatar.Tag = u; if (u.LoadAvatarInto(thisAvatar, (thisAvatar == hostAvatar ? 63f : 36f) * slot_size)) { thisAvatar.OnTextureLoaded += delegate { thisAvatar.Transformations.Add(new Transformation(TransformationType.Scale, 0, thisAvatar.Scale, GameBase.Time, GameBase.Time + 200, EasingTypes.Out)); if (!Filtered) { thisAvatar.FadeIn(500); } }; } } } else { if (thisAvatar.Tag != null) { thisAvatarBackground.ToolTip = null; thisAvatar.Tag = null; thisAvatar.Texture = null; thisAvatar.FadeOut(500); } } } avgLevel /= totalPlayers; avgRank /= totalPlayers; switch (matchInfo.playMode) { case PlayModes.Osu: gametype.Texture = TextureManager.Load(@"mode-osu-small", SkinSource.Osu); break; case PlayModes.CatchTheBeat: gametype.Texture = TextureManager.Load(@"mode-fruits-small", SkinSource.Osu); break; case PlayModes.Taiko: gametype.Texture = TextureManager.Load(@"mode-taiko-small", SkinSource.Osu); break; case PlayModes.OsuMania: gametype.Texture = TextureManager.Load(@"mode-mania-small", SkinSource.Osu); break; } bool foundBeatmapBefore = foundBeatmap; if (foundChecksum != matchInfo.beatmapChecksum) { foundBeatmap = !string.IsNullOrEmpty(matchInfo.beatmapChecksum) && BeatmapManager.GetBeatmapByChecksum(matchInfo.beatmapChecksum) != null; foundChecksum = matchInfo.beatmapChecksum; } bg.HandleInput = true; if (foundBeatmapBefore != foundBeatmap) { bg.InitialColour = foundBeatmap ? new Color(185, 64, 255, 25) : new Color(202, 202, 202, 25); } infoLeft1.InitialColour = matchInfo.inProgress ? Color.Gray : Color.White; infoRight1.InitialColour = matchInfo.inProgress ? Color.Gray : Color.White; infoLeft1.Text = string.Format( @"{0} ({3}) {1} / {2} ", GeneralHelper.FormatEnum(matchInfo.playMode.ToString()), matchInfo.slotUsedCount, matchInfo.slotOpenCount, GeneralHelper.FormatEnum(matchInfo.matchTeamType.ToString())); /*infoLeft2.Text = * string.Format(minLevel != maxLevel ? @"lv{0:0}-{1:0}" : @"lv{0:0}", minLevel, maxLevel);*/ if (hasUnranked) { //maxRank > 0 ensures that at least one non-null rank has been processed. infoLeft2.Text = @"rank: " + string.Format(maxRank > 0 ? @"{0:#,#} - ?" : @" ?", minRank, maxRank); } else { infoLeft2.Text = @"rank: " + string.Format(minRank != maxRank ? @"{0:#,#} - {1:#,#}" : @"{0:#,#}", minRank, maxRank); } infoRight1.Text = matchInfo.gameName + @" " + (matchInfo.inProgress ? LocalisationManager.GetString(OsuString.LobbyMatch_InProgress) : string.Empty); infoRight2.Text = string.IsNullOrEmpty(matchInfo.beatmapChecksum) ? LocalisationManager.GetString(OsuString.LobbyMatch_ChangingBeatmap) : string.Format(@"{0}{1}", ModManager.FormatShort(matchInfo.activeMods, true, true), matchInfo.beatmapName);//bofore mapname is better infoRight2.InitialColour = new Color(255, 215, 109); return(firstPopulation); }
private void SongInfo_Show() { spriteManagerDifficultySelect.ScaleTo(0.5f, 300, EasingTypes.Out); spriteManagerDifficultySelect.FadeOut(300); background.FadeOut(300); SelectedPanel.Sprites.ForEach(s => s.MoveTo(new Vector2(0, -100), 400)); songInfoSpriteManager.Clear(); songInfoSpriteManager.Alpha = 0; songInfoSpriteManager.Position = Vector2.Zero; songInfoSpriteManager.Transformations.Clear(); songInfoSpriteManager.Transform(new TransformationBounce(Clock.ModeTime + 200, Clock.ModeTime + 700, 1, 0.5f, 2)); songInfoSpriteManager.Transform(new TransformationF(TransformationType.Fade, 0, 1, Clock.ModeTime + 200, Clock.ModeTime + 500)); Beatmap beatmap = SelectedPanel.Beatmap; //256x172 float aspectAdjust = GameBase.BaseSize.Y / (172 * GameBase.SpriteToBaseRatio); pSprite thumbSprite = new pSpriteDynamic { LoadDelegate = delegate { pTexture thumb = null; byte[] bytes = beatmap.GetFileBytes("thumb-256.jpg"); if (bytes != null) { thumb = pTexture.FromBytes(bytes); } return(thumb); }, DrawDepth = 0.49f, Field = FieldTypes.StandardSnapCentre, Origin = OriginTypes.Centre, ScaleScalar = aspectAdjust, Alpha = 0.3f }; songInfoSpriteManager.Add(thumbSprite); float vPos = 60; string unicodeTitle = beatmap.Package.GetMetadata(MapMetaType.TitleUnicode); string normalTitle = beatmap.Title; if (unicodeTitle != normalTitle) { pText titleUnicode = new pText(unicodeTitle, 30, new Vector2(0, vPos), 1, true, Color4.White) { Field = FieldTypes.StandardSnapTopCentre, Origin = OriginTypes.Centre }; songInfoSpriteManager.Add(titleUnicode); vPos += 40; } pText title = new pText(normalTitle, 30, new Vector2(0, vPos), 1, true, Color4.White) { Field = FieldTypes.StandardSnapTopCentre, Origin = OriginTypes.Centre, TextShadow = true }; songInfoSpriteManager.Add(title); vPos += 40; string unicodeArtist = beatmap.Package.GetMetadata(MapMetaType.ArtistUnicode); pText artist = new pText("by " + beatmap.Package.GetMetadata(MapMetaType.ArtistFullName), 24, new Vector2(0, vPos), 1, true, Color4.White) { Field = FieldTypes.StandardSnapTopCentre, Origin = OriginTypes.Centre, TextShadow = true }; songInfoSpriteManager.Add(artist); vPos += 40; string artistTwitter = beatmap.Package.GetMetadata(MapMetaType.ArtistTwitter); string artistWeb = beatmap.Package.GetMetadata(MapMetaType.ArtistUrl); if (artistWeb != null) { pText info = new pText(artistWeb, 20, new Vector2(0, vPos), 1, true, Color4.SkyBlue) { Field = FieldTypes.StandardSnapTopCentre, Origin = OriginTypes.Centre }; info.OnClick += delegate { GameBase.Instance.OpenUrl(artistWeb); }; songInfoSpriteManager.Add(info); vPos += 40; } if (artistTwitter != null) { pText info = new pText(artistTwitter, 20, new Vector2(0, vPos), 1, true, Color4.SkyBlue) { Field = FieldTypes.StandardSnapTopCentre, Origin = OriginTypes.Centre }; info.OnClick += delegate { GameBase.Instance.OpenUrl(artistTwitter.Replace(@"@", @"https://twitter.com/")); }; songInfoSpriteManager.Add(info); vPos += 40; } string unicodeSource = beatmap.Package.GetMetadata(MapMetaType.SourceUnicode); string normalSource = beatmap.Package.GetMetadata(MapMetaType.Source); if (normalSource != null) { vPos += 40; pText source = new pText(normalSource, 24, new Vector2(0, vPos), 1, true, Color4.White) { Field = FieldTypes.StandardSnapTopCentre, Origin = OriginTypes.Centre, TextShadow = true }; songInfoSpriteManager.Add(source); } if (normalSource != unicodeSource) { vPos += 40; pText source = new pText(unicodeSource, 24, new Vector2(0, vPos), 1, true, Color4.White) { Field = FieldTypes.StandardSnapTopCentre, Origin = OriginTypes.Centre, TextShadow = true }; songInfoSpriteManager.Add(source); } pText mapper = new pText("Level design by " + beatmap.Creator, 18, new Vector2(0, 40), 1, true, Color4.White) { Field = FieldTypes.StandardSnapBottomCentre, Origin = OriginTypes.BottomCentre }; songInfoSpriteManager.Add(mapper); State = SelectState.SongInfo; footerHide(); }
internal void Initialize(StreamingContext context) { string description = string.Format("{0} Chart, {1} Beatmaps", new CultureInfo("en-US", false).TextInfo.ToTitleCase(type), beatmaps.Count); string leader = "No leader yet!\nYou are not ranked on this chart!"; bool active = true; spriteManager.Add(new pText(name, 20, new Vector2(PADDING * 2 + HEIGHT, 0), 1, true, Color.White)); spriteManager.Add(new pText(description, 12, new Vector2(PADDING * 2 + HEIGHT, 20), 1, true, new Color(144, 238, 254))); spriteManager.Add(new pText(leader, 14, new Vector2(PADDING * 2 + HEIGHT, HEIGHT), 1, true, Color.White) { Origin = Origins.BottomLeft }); //chart image pSpriteDynamic background = new pSpriteDynamic(@"https://s.ppy.sh/a/3103765_1378920280.png", null, 0, new Vector2(PADDING, 0), 0.2f); background.MaxDimension = HEIGHT * 1.6f; spriteManager.Add(background); for (int i = 0; i < beatmaps.Count; i++) { const int thumb_size = 40; float xPos = PADDING * 2 + i * (thumb_size + 2); pSpriteDynamic b = new pSpriteDynamic(General.STATIC_WEB_ROOT_BEATMAP + @"/thumb/" + beatmaps[i].beatmapset_id + @".jpg", null, 0, new Vector2(xPos, PADDING), 0.2f); b.MaxDimension = thumb_size * 1.6f; b.Field = Fields.TopRight; b.Origin = Origins.TopRight; spriteManager.Add(b); if (!beatmaps[i].passed) { spriteManager.Add(new pTextAwesome(FontAwesome.circle_o, 14, new Vector2(xPos + thumb_size / 2, thumb_size + 5 + PADDING)) { InitialColour = new Color(253, 202, 55), Field = Fields.TopRight }); } else { spriteManager.Add(new pTextAwesome(FontAwesome.check_circle_o, 14, new Vector2(xPos + thumb_size / 2, thumb_size + 5)) { InitialColour = new Color(172, 219, 39), Field = Fields.TopRight }); } } //active light if (end_date >= DateTime.Now) { spriteManager.Add(new pBox(new Vector2(0, 0), new Vector2(10, HEIGHT), 0.1f, new Color(172, 219, 39))); } pBox colourBackground = new pBox(new Vector2(PADDING, 0), new Vector2(GameBase.WindowManager.WidthScaled - Charts.PADDING * 2, HEIGHT), 1, new Color(50, 50, 50)) { Alpha = 0.01f, Additive = true, HandleInput = true, ClickRequiresConfirmation = true }; colourBackground.OnClick += delegate { }; colourBackground.OnHover += delegate { colourBackground.Alpha = 1; colourBackground.FadeTo(0.6f, 500, EasingTypes.In); }; colourBackground.OnHoverLost += delegate { colourBackground.FadeTo(0.01f, 500, EasingTypes.In); }; spriteManager.Add(colourBackground); //separator (move out?) spriteManager.Add(new pBox(new Vector2(PADDING, HEIGHT + 5), new Vector2(GameBase.WindowManager.WidthScaled - Charts.PADDING * 2, 1), 0, new Color(110, 96, 103))); }
private void ShowMetadata() { //song info songInfoSpriteManager.Position = new Vector2(20, 0); Beatmap beatmap = Player.Beatmap; //256x172 float aspectAdjust = GameBase.BaseSize.X / (256 * GameBase.SpriteToBaseRatio); pSprite thumbSprite = new pSpriteDynamic { LoadDelegate = delegate { pTexture thumb = null; byte[] bytes = beatmap.GetFileBytes("thumb-256.jpg"); if (bytes != null) { thumb = pTexture.FromBytes(bytes); } return(thumb); }, DrawDepth = 0.49f, Field = FieldTypes.StandardSnapCentre, Origin = OriginTypes.Centre, ScaleScalar = aspectAdjust, Alpha = 0.3f }; spriteManager.Add(thumbSprite); float vPos = 5; string unicodeTitle = beatmap.Package.GetMetadata(MapMetaType.TitleUnicode); string normalTitle = beatmap.Title; pText title = new pText(normalTitle, 40, new Vector2(0, vPos), 1, true, Color4.White) { Field = FieldTypes.Standard, Origin = OriginTypes.TopLeft, TextShadow = true }; songInfoSpriteManager.Add(title); vPos += 40; string unicodeArtist = beatmap.Package.GetMetadata(MapMetaType.ArtistUnicode); pText artist = new pText("by " + beatmap.Package.GetMetadata(MapMetaType.ArtistFullName), 30, new Vector2(0, vPos), 1, true, Color4.LightYellow) { Field = FieldTypes.Standard, Origin = OriginTypes.TopLeft, TextShadow = true }; songInfoSpriteManager.Add(artist); vPos += 50; string artistTwitter = beatmap.Package.GetMetadata(MapMetaType.ArtistTwitter); string artistWeb = beatmap.Package.GetMetadata(MapMetaType.ArtistUrl); if (artistWeb != null) { pText info = new pText("web: " + artistWeb, 26, new Vector2(0, vPos), 1, true, Color4.SkyBlue) { Field = FieldTypes.Standard, Origin = OriginTypes.TopLeft }; info.OnClick += delegate { GameBase.Instance.OpenUrl(artistWeb); }; songInfoSpriteManager.Add(info); vPos += 30; } if (artistTwitter != null) { pText info = new pText("twitter: " + artistTwitter, 26, new Vector2(0, vPos), 1, true, Color4.SkyBlue) { Field = FieldTypes.Standard, Origin = OriginTypes.TopLeft }; info.OnClick += delegate { GameBase.Instance.OpenUrl(artistTwitter.Replace(@"@", @"https://twitter.com/")); }; songInfoSpriteManager.Add(info); vPos += 40; } string unicodeSource = beatmap.Package.GetMetadata(MapMetaType.SourceUnicode); string normalSource = beatmap.Package.GetMetadata(MapMetaType.Source); if (normalSource != null && normalSource != "Original") { pText source = new pText("As seen in " + normalSource, 26, new Vector2(0, vPos), 1, true, Color4.LightYellow) { Field = FieldTypes.Standard, Origin = OriginTypes.TopLeft, TextShadow = true }; songInfoSpriteManager.Add(source); } pText mapper = new pText("Level design by " + beatmap.Creator, 26, new Vector2(30, 0), 1, true, Color4.White) { Field = FieldTypes.StandardSnapBottomRight, Origin = OriginTypes.BottomRight }; songInfoSpriteManager.Add(mapper); }