internal pDrawable Add(OsuTexture tabTexture, List <pDrawable> sprites) { pSprite tab = new pSprite(TextureManager.Load(tabTexture), FieldTypes.StandardSnapTopCentre, OriginTypes.TopCentre, ClockTypes.Mode, new Vector2(0, -100), 0.41f, true, Color4.Gray); tab.OnClick += onTabClick; tab.OnHover += delegate { tab.FadeColour(Color4.White, 100); }; tab.OnHoverLost += delegate { tab.FadeColour(Color4.Gray, 100); }; spriteManager.Add(tab); spriteManagers.Add(tab, sprites != null ? new SpriteManager(sprites) : new SpriteManager()); if (tabs.Count == 0) { tab.Click(); } tabs.Add(tab); float x = -(Math.Max(0, tabs.Count - 1) * 200f) / 2; for (int i = 0; i < tabs.Count; i++) { tabs[i].Offset = new Vector2(x, 0); x += 200; } return(tab); }
void expand(EasingTypes easing, int delay = animation_delay) { expanded = true; layerLeft.MoveTo(new Vector2(layer_left_active, layerLeft.Position.Y), delay, easing); icon.MoveTo(new Vector2(layer_left_active / centre_offset, icon.Position.Y), delay, easing); layerRight.MoveTo(new Vector2(layer_right_active + layerRightTextAllowance, layerRight.Position.Y), delay, easing); text.MoveTo(new Vector2((layer_right_active + layerRightTextAllowance - layer_left_active) / centre_offset + layer_left_active, text.Position.Y), delay, easing); layerLeft.FadeColour(colour_active, delay, false, easing); }
private void UpdateBackgroundColour(int duration) { if (backgroundSprite != null) { backgroundSprite.FadeColour(BackgroundColour, duration); } }
private void CheckUnhover() { if (!bg.drawRectangle.Contains(MouseManager.MousePoint)) { bg.FadeColour(ColourHelper.ChangeAlpha(bg.InitialColour, 25), 100); } }
private void UpdateColour() { if (spriteBackground != null) { if (Visible && spriteManager.Alpha > 0) { spriteBackground.FadeColour(backgroundColour, 300); } else { spriteBackground.StartColour = backgroundColour; } spriteBackground.HoverEffect = new Transformation(backgroundColour, new Color((byte)(backgroundColour.R + 40), (byte)(backgroundColour.G + 40), (byte)(backgroundColour.B + 40)), 0, 100); if (Rank > 10) { spriteRank.TextColour = new Color(255, 255, 255, 100); } else if (Rank == 1) { spriteRank.TextColour = new Color(88, 171, 248, 120); } else { spriteRank.TextColour = new Color(244, 218, 73, 120); } } }
private void UpdateColour() { if (spriteBackground != null) { if (Visible && spriteManager.Alpha > 0 && spriteBackground.IsVisible) { spriteBackground.FadeColour(CurrentBackgroundColour, 300, true); spriteForeground.FadeColour(CurrentForegroundColour, 300, true); } else { spriteBackground.Transformations.RemoveAll(t => t.Type == TransformationType.Colour); spriteBackground.InitialColour = spriteBackground.drawColour = CurrentBackgroundColour; spriteForeground.Transformations.RemoveAll(t => t.Type == TransformationType.Colour); spriteForeground.InitialColour = spriteForeground.drawColour = CurrentForegroundColour; } if (Rank > 200000) { spriteRank.TextColour = new Color(255, 255, 255, 20); } if (Rank > 100000) { spriteRank.TextColour = new Color(255, 255, 255, 40); } else if (Rank > 50000) { spriteRank.TextColour = new Color(255, 255, 255, 60); } else if (Rank > 1000) { spriteRank.TextColour = new Color(255, 255, 255, 80); } else if (Rank > 10) { spriteRank.TextColour = new Color(255, 255, 255, 100); } else if (Rank > 1) { spriteRank.TextColour = new Color(244, 218, 73, 120); } else { spriteRank.TextColour = new Color(88, 171, 248, 120); } } }
public void SetScore(bScoreFrame score) { Frame = score; this.score = score.totalScore; spriteInfo.Text = score.totalScore > 0 ? score.totalScore.ToString("0,0", GameBase.nfi) : "-"; spriteInfo.Text += " (" + score.currentCombo + "x)"; spriteBackground.FadeColour(new Color((byte)(200 - score.currentHp), 20, (byte)score.currentHp, spriteBackground.CurrentColour.A), 50); UpdatePending = false; }
private void UpdateMultiplier() { double mult = ModManager.ScoreMultiplier(); modMultiplier.Text = string.Format("Score Multiplier: {0:0.00}x", mult); if (mult > 1) { modMultiplier.FadeColour(Color.GreenYellow, 400); } else if (mult < 1) { modMultiplier.FadeColour(Color.OrangeRed, 400); } else { modMultiplier.FadeColour(Color.White, 400); } }
private void pointAt(Vector2 vector2) { pSprite sp = new pSprite(TextureManager.Load(OsuTexture.finger_inner), vector2) { Origin = OriginTypes.Centre, Colour = new Color4(50, 50, 50, 255), ScaleScalar = 0.5f }; sp.OnHover += delegate { sp.FadeColour(Color4.White, 100); }; sp.OnHoverLost += delegate { sp.FadeColour(new Color4(50, 50, 50, 255), 100); }; pText text = new pText(vector2.ToString(), 12, vector2, 1, true, Color4.White) { Origin = OriginTypes.Centre }; spriteManager.Add(text); spriteManager.Add(sp); }
internal virtual void SetScore(Score score, int?totalScore = null) { Score = score; this.score = totalScore ?? score.TotalScore; int combo = FixedScore ? score.MaxCombo : score.CurrentCombo; switch (scoreType) { default: SpriteScore.Text = this.score > 0 ? this.score.ToString(@"#,#", GameBase.nfi) : @"-"; SpriteCombo.Text = combo.ToString(@"#,#", GameBase.nfi) + (combo > 0 ? @"x" : @""); break; case MatchScoringTypes.Accuracy: SpriteScore.Text = this.score > 0 ? string.Format(@"{0:n}%", score.Accuracy * 100) : @"-"; SpriteCombo.Text = combo.ToString(@"#,#", GameBase.nfi) + (combo > 0 ? @"x" : @""); break; case MatchScoringTypes.Combo: SpriteCombo.Text = this.score > 0 ? this.score.ToString(@"#,#", GameBase.nfi) : @"-"; SpriteScore.Text = combo.ToString(@"#,#", GameBase.nfi) + (combo > 0 ? @"x" : @""); break; } if (!FixedScore) { Color col = SpriteBackground.InitialColour; if (score.Pass) { if (score.CurrentHp > 0) { col = new Color((byte)(200 - score.CurrentHp), 20, (byte)score.CurrentHp, SpriteBackground.InitialColour.A); } } else { col = new Color(80, 80, 80, SpriteBackground.InitialColour.A); } SpriteBackground.FadeColour(col, 50); } }
internal void Show(int time_offset) { if (m_visible) { return; } Color backcol = m_selected ? SelectedColour : BackgroundColour; foreach (pSprite p in Sprites) { p.Transformations.Clear(); p.FadeIn(200); } Background.Transformations.Clear(); Background.FadeColour(backcol, 0); Background.Transformations.Add(new Transformation(TransformationType.Fade, 0.0f, (float)backcol.A / 255.0f, GameBase.Time + time_offset, GameBase.Time + time_offset + 200)); Background.IsVisible = true; Background.HandleInput = true; m_visible = true; }
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); }
internal BeatmapPanel(Beatmap beatmap, EventHandler action, int index) { base_depth += 0.001f * index; s_BackingPlate = new pSprite(TextureManager.Load(OsuTexture.songselect_panel), Vector2.Zero) { DrawDepth = base_depth, Colour = new Color4(255, 255, 255, 170), Tag = this }; Sprites.Add(s_BackingPlate); Beatmap = beatmap; if (action != null) { s_BackingPlate.OnClick += action; } s_BackingPlate.HandleClickOnUp = true; s_BackingPlate.OnHover += delegate { s_BackingPlate.FadeOut(100, 0.01f); s_BackingPlate2.FadeColour(BACKGROUND_COLOUR, 80); }; s_BackingPlate.OnHoverLost += delegate { s_BackingPlate.FadeIn(60); s_BackingPlate2.FadeColour(Color4.Transparent, 100); }; s_Text = new pText(string.Empty, 26, Vector2.Zero, Vector2.Zero, 0.5f, true, Color4.White, false); s_Text.Bold = true; s_Text.Offset = new Vector2(130, 0); Sprites.Add(s_Text); s_TextArtist = new pText(string.Empty, 26, Vector2.Zero, Vector2.Zero, 0.51f, true, Color4.OrangeRed, false); s_TextArtist.Offset = new Vector2(130, 29); Sprites.Add(s_TextArtist); #if !DIST && !iOS pText s_TextCreator = new pText(string.Empty, 14, Vector2.Zero, Vector2.Zero, 0.52f, true, BACKGROUND_COLOUR, false); s_TextCreator.Origin = OriginTypes.TopRight; s_TextCreator.Field = FieldTypes.StandardSnapRight; //Sprites.Add(s_TextCreator); #endif pTexture thumb = null; float starCount = 0; if (beatmap != null) { try { s_Text.Text = beatmap.Title; s_TextArtist.Text = beatmap.Artist; #if !DIST && !iOS if (s_TextCreator != null) { s_TextCreator.Text = beatmap.Creator; } #endif starCount = beatmap.DifficultyStars / 2f; } catch { //could fail due to corrupt package. } } else { thumb = TextureManager.Load(OsuTexture.songselect_thumb_dl); } if (thumb != null) { s_Thumbnail = new pSprite(thumb, Vector2.Zero) { DrawDepth = base_depth + 0.02f } } ; else { s_Thumbnail = new pSpriteDynamic { LoadDelegate = GetThumbnail, DrawDepth = 0.49f } }; s_Thumbnail.AlphaBlend = false; s_Thumbnail.Offset = new Vector2(38.5f, 3.8f); Sprites.Add(s_Thumbnail); s_BackingPlate2 = new pSprite(TextureManager.Load(OsuTexture.songselect_panel_selected), Vector2.Zero) { DrawDepth = base_depth + 0.01f, Colour = new Color4(255, 255, 255, 0) }; Sprites.Add(s_BackingPlate2); if (beatmap != null) { #if oldstars for (int i = 0; i < 0; i++) { Color4 col; switch (i) { default: case 0: col = new Color4(180, 255, 0, 255); break; case 1: col = new Color4(230, 255, 0, 255); break; case 2: col = new Color4(255, 198, 0, 255); break; case 3: col = new Color4(255, 126, 0, 255); break; case 4: col = new Color4(255, 12, 0, 255); break; } s_Star = new pSprite(TextureManager.Load(OsuTexture.songselect_star), Vector2.Zero) { Origin = OriginTypes.BottomLeft, Field = FieldTypes.StandardSnapRight, ScaleScalar = 0.5f, DrawDepth = base_depth + 0.06f + i * 0.001f, Colour = col, Offset = new Vector2(124 - i * 18, PANEL_HEIGHT) }; Sprites.Add(s_Star); } if (starCount % 1 != 0) { s_Star.Texture = TextureManager.Load(OsuTexture.songselect_star_half); } #else s_StarBg = new pSprite(TextureManager.Load(OsuTexture.difficulty_bar_bg), Vector2.Zero) { Origin = OriginTypes.BottomLeft, Field = FieldTypes.StandardSnapRight, DrawDepth = base_depth + 0.06f, Offset = new Vector2(179 + GameBase.SuperWidePadding, PANEL_HEIGHT) }; Sprites.Add(s_StarBg); s_Star = new pSprite(TextureManager.Load(OsuTexture.difficulty_bar_colour), Vector2.Zero) { Origin = OriginTypes.BottomLeft, Field = FieldTypes.StandardSnapRight, DrawDepth = base_depth + 0.07f, Offset = new Vector2(179 + GameBase.SuperWidePadding, PANEL_HEIGHT) }; if (starCount == 0) { //always use zero-width for no stars (even though this should not ever happen) to avoid single-pixel glitching. s_Star.DrawWidth = 0; } else if (starCount < 5) { const int border = 2; s_Star.DrawWidth = (int)((s_Star.DrawWidth - border * 2) * starCount / 5f) + border; } Sprites.Add(s_Star); #endif foreach (DifficultyScoreInfo diffInfo in Beatmap.BeatmapInfo.DifficultyScores.Values) { if (diffInfo.HighScore != null) { int offset = 0; switch (diffInfo.difficulty) { case Difficulty.Easy: offset = 90; break; case Difficulty.Normal: offset = 50; break; case Difficulty.Expert: offset = 10; break; } pSprite rankingSprite = new pSprite(diffInfo.HighScore.RankingTextureTiny, Vector2.Zero) { Origin = OriginTypes.TopRight, Field = FieldTypes.StandardSnapRight, DrawDepth = base_depth + 0.08f, Offset = new Vector2(offset, 2) }; Sprites.Add(rankingSprite); rankSprites.Add(rankingSprite); } } } }
private void HandleButtonHoverLost(object sender, EventArgs e) { pSprite s = sender as pSprite; s.FadeColour(colourInactive, 100); }
private void HandleButtonHover(object sender, EventArgs e) { pSprite s = sender as pSprite; s.FadeColour(Color4.White, 100); }