private void UpdateValue(float value) { Value = value; FrontPlate.DrawWidth = (int)(BackingPlate.TextureWidth * value); FrontPlate.FlashColour(new Color4(131, 240, 0, 255), 150); action(value); }
internal void FlashBackgroundColour(Color colour, int duration) { if (backgroundSprite != null) { backgroundSprite.FlashColour(colour, duration); } }
internal bool PullStats(bool force) { if (StatsLoaded && !force) { return(true); } if (StatsLoading) { return(false); } if (Name.Length > 0) { StatsLoading = true; if (Sprites != null) { spriteBackground.FlashColour(Color.Crimson, 3000); spriteName.Text = Name; if (firstReceived) { spriteInfo.Text = string.Empty; } } if (Name == ConfigManager.sUsername) { BanchoClient.SendRequest(RequestType.Osu_RequestStatusUpdate, null); } } else { Name = @"Guest"; Level = 0; Id = -1; Permission = Permissions.Normal; InfoText = LocalisationManager.GetString(OsuString.Options_Online_ClickToLogin); spriteName.Text = Name; spriteInfo.Text = InfoText; spriteRank.Text = string.Empty; modeStatus.Texture = null; LoadAvatarInto(spriteAvatar, spriteAvatar.MaxDimension); updateLevelBar(); } return(true); }
internal bool PullStats(bool force) { if (StatsLoaded && !force) { return(true); } if (StatsLoading) { return(false); } if (Name.Length > 0) { StatsLoading = true; if (Sprites != null) { spriteBackground.FlashColour(Color.Crimson, 3000); spriteName.Text = Name; AvatarLoaded = false; if (firstReceived) { spriteInfo.Text = "Loading stats..."; } } if (Name == ConfigManager.sUsername) { BanchoClient.SendRequest(RequestType.Osu_RequestStatusUpdate, null); } } else { spriteName.Text = "Guest"; spriteInfo.Text = "Please click here to login."; } return(true); }
public override void Update() { base.Update(); spriteManagerDifficultySelect.Update(); if (songInfoSpriteManager != null) { songInfoSpriteManager.Update(); } if (rankingSpriteManager != null) { rankingSpriteManager.Update(); } topmostSpriteManager.Update(); inputStolen = InputManager.PrimaryTrackingPoint != null && InputManager.PrimaryTrackingPoint.HoveringObject == s_ButtonBack; //handle touch scrolling switch (State) { case SelectState.DifficultySelect: if (!AudioEngine.Music.IsElapsing) { playFromPreview(); } if (InputManager.IsPressed && !inputStolen) { pendingModeChange = true; } else if (pendingModeChange) { difficultySelectOffset += velocity; if (difficultySelectOffset > mode_button_width / 2) { SetDifficulty(Difficulty.Easy); } else if (difficultySelectOffset < -mode_button_width / 2) { SetDifficulty(Difficulty.Expert); } else { SetDifficulty(Difficulty.Normal); } pendingModeChange = false; } if (Director.PendingOsuMode == OsuMode.Unknown) { Vector2 pos = new Vector2(difficultySelectOffset, 0); if (Math.Abs(pos.X - s_ModeButtonEasy.Position.X) > 10) { s_ModeButtonEasy.MoveTo(pos, 200, EasingTypes.In); s_ModeButtonStream.MoveTo(pos, 200, EasingTypes.In); s_ModeButtonExpert.MoveTo(pos, 200, EasingTypes.In); } s_ModeButtonEasy.ScaleScalar = (float)Math.Sqrt(1 - 0.002f * Math.Abs(s_ModeButtonEasy.Offset.X + s_ModeButtonEasy.Position.X)); s_ModeButtonStream.ScaleScalar = (float)Math.Sqrt(1 - 0.002f * Math.Abs(s_ModeButtonStream.Offset.X + s_ModeButtonStream.Position.X)); s_ModeButtonExpert.ScaleScalar = (float)Math.Sqrt(1 - 0.002f * Math.Abs(s_ModeButtonExpert.Offset.X + s_ModeButtonExpert.Position.X)); s_ModeButtonEasy.Update(); s_ModeButtonStream.Update(); s_ModeButtonExpert.Update(); } break; case SelectState.SongSelect: float bound = offsetBound; bool wasBound = isBound; isBound = songSelectOffset == bound; if (!InputManager.IsPressed) { float lastOffset = songSelectOffset; songSelectOffset = songSelectOffset * (1 - 0.2f * Clock.ElapsedRatioToSixty) + bound * 0.2f * Clock.ElapsedRatioToSixty + velocity * Clock.ElapsedRatioToSixty; if (songSelectOffset != bound) { velocity *= (1 - 0.3f * Clock.ElapsedRatioToSixty); } else { velocity *= (1 - 0.06f * Clock.ElapsedRatioToSixty); } } float panelHeightPadded = BeatmapPanel.PANEL_HEIGHT + 10; float newIntOffset = isBound ? (int)Math.Round(songSelectOffset / panelHeightPadded) : songSelectOffset / panelHeightPadded; if (Director.PendingOsuMode == OsuMode.Unknown) { if (InputManager.PrimaryTrackingPoint != null && InputManager.IsPressed) { if (InputManager.PrimaryTrackingPoint.HoveringObject is pSprite sprite) { //check for beatmap present; the store link doesn't have one. if (sprite.Tag is BeatmapPanel panel && panel.Beatmap != null) { if (SelectedPanel != panel && PreviewingPanel != panel) { cancelHoverPreview(); SelectedPanel = panel; Player.Beatmap = panel.Beatmap; SelectedPanelHoverGlow = panel.s_BackingPlate2.AdditiveFlash(0, 1, true); SelectedPanelHoverGlow.FadeIn(time_to_hover); //cancel any previously scheduled preview that was not activated yet. GameBase.Scheduler.Cancel(previewDelegate); previewDelegate = GameBase.Scheduler.Add(delegate { if (panel != SelectedPanel || panel == PreviewingPanel || State != SelectState.SongSelect) { return; } cancelLockedHoverPreview(); if (AudioEngine.Music != null && (AudioEngine.Music.lastLoaded != panel.Beatmap.PackageIdentifier)) { AudioEngine.Music.Load(panel.Beatmap.GetFileBytes(panel.Beatmap.AudioFilename), false, panel.Beatmap.PackageIdentifier); if (!AudioEngine.Music.IsElapsing) { playFromPreview(); } SelectedPanelHoverGlow.Alpha = 1; SelectedPanelHoverGlow.Colour = Color4.White; SelectedPanelHoverGlow.FadeOut(500, 0.8f); SelectedPanelHoverGlow.Transformations[0].Looping = true; SelectedPanelHoverGlowLockedIn = SelectedPanelHoverGlow; SelectedPanelHoverGlow = null; PreviewingPanel = panel; PreviewingPanel.Add(SelectedPanelHoverGlowLockedIn); } }, time_to_hover); } else { if (SelectedPanelHoverGlow != null && Math.Abs(SelectedPanelHoverGlow.Position.Y - panel.s_BackingPlate2.Position.Y) > 3) { cancelHoverPreview(); } } } else { cancelHoverPreview(); } } } else { cancelHoverPreview(); if (!AudioEngine.Music.IsElapsing) { InitializeBgm(); } } if (newIntOffset != lastIntOffset) { if (isBound && wasBound) { AudioEngine.PlaySample(OsuSamples.MenuClick); background.FlashColour(new Color4(140, 140, 140, 255), 400); } lastIntOffset = newIntOffset; } if (SelectedPanelHoverGlow != null) { AudioEngine.Music.DimmableVolume = 1 - SelectedPanelHoverGlow.Alpha; } Vector2 pos = new Vector2(0, 60 + (newIntOffset * panelHeightPadded) * 0.5f + songSelectOffset * 0.5f); foreach (BeatmapPanel p in panels) { if (p.NewSection) { pos.Y += 20; } if (Math.Abs(p.s_BackingPlate.Position.Y - pos.Y) > 1 || Math.Abs(p.s_BackingPlate.Position.X - pos.X) > 1) { //todo: change this to use a draggable spritemanager instead. better performance and will move smoother on lower fps. p.MoveTo(pos, touchingBegun ? 50 : 300); } pos.Y += 63; } } break; }
private void ShowResponseDialog(OnlineBeatmap beatmap) { if (RespondingBeatmap != null) { HideResponseDialog(); } if ((GameBase.TournamentManager || (ConfigManager.sAutomaticDownload && (MatchSetup.Match != null || StreamingManager.CurrentlySpectating != null))) && !beatmap.exists && !beatmap.HasAttachedDownload) { beatmap.Download(ConfigManager.sAutomaticDownloadNoVideo); return; } if (GameBase.Tournament) { return; } background.FlashColour(Color.Gray, 500); if (ResponseSprites != null) { ResponseSprites.ForEach(s => { s.FadeOut(100); s.AlwaysDraw = false; }); } if (thumbRequest != null) { thumbRequest.Abort(); } if (previewRequest != null) { previewRequest.Abort(); } RespondingBeatmap = beatmap; ResponseSprites = new List <pSprite>(); float y = 24; pText pt = new pText(beatmap.artist, 12, new Vector2(background.Position.X, YPOS + y), 1, true, Color.Orchid); pt.Field = Fields.TopRight; pt.TextBold = true; ResponseSprites.Add(pt); y += 12; pt = new pText(beatmap.title, 12, new Vector2(background.Position.X, YPOS + y), 1, true, Color.White); pt.Field = Fields.TopRight; pt.TextBold = true; ResponseSprites.Add(pt); y += 12; pt = new pText("by " + beatmap.creator, 12, new Vector2(background.Position.X, YPOS + y), 1, true, Color.White); pt.Field = Fields.TopRight; ResponseSprites.Add(pt); y += 14; previewThumbnail = new pSprite(null, Fields.TopRight, Origins.Centre, Clocks.Game, new Vector2(background.Position.X - (WIDTH / 2), YPOS + y + (WIDTH * 0.8f / 2)), 1, true, Color.TransparentWhite); previewThumbnail.IsDisposable = true; previewThumbnail.Scale = 0.7f; y += 100; thumbRequest = new pWebRequest(General.STATIC_WEB_ROOT_BEATMAP + @"/thumb/" + beatmap.setId + @"l.jpg"); thumbRequest.Finished += delegate(pWebRequest r, Exception e) { byte[] data = r.ResponseData; if (e != null || data.Length == 0) { return; } GameBase.Scheduler.Add(delegate { previewThumbnail.Texture = pTexture.FromBytes(data); SkinManager.RegisterUnrecoverableTexture(previewThumbnail.Texture); fadeInThumbnail(); }); }; thumbRequest.Perform(); if (!disallowAudioPreview) { previewRequest = new pWebRequest(string.Format(@"{0}/preview/{1}.mp3", General.STATIC_WEB_ROOT_BEATMAP, beatmap.setId)); previewRequest.Finished += delegate(pWebRequest r, Exception e) { byte[] data = r.ResponseData; if (e != null || data.Length == 0) { return; } GameBase.Scheduler.Add(delegate { if (RespondingBeatmap != beatmap) { return; } WasPlayingAudio = AudioEngine.AudioState == AudioStates.Playing; if (WasPlayingAudio && GameBase.Mode != OsuModes.OnlineSelection && GameBase.Mode != OsuModes.Play) { AudioEngine.AllowRandomSong = false; AudioEngine.TogglePause(); } sampleTrack = AudioEngine.PlaySampleAsTrack(data); sampleTrack.Play(); fadeInThumbnail(); }); }; previewRequest.Perform(); } bool hasMap = BeatmapManager.GetBeatmapBySetId(beatmap.setId) != null; pButton pbut = null; float buttonHeight; if (hasMap && !beatmap.HasAttachedDownload && beatmap.hasVideo) { buttonHeight = 16.25f; } else if (hasMap || (!beatmap.HasAttachedDownload && beatmap.hasVideo)) { buttonHeight = 20f; } else { buttonHeight = 25f; } if (hasMap) { pbut = new pButton("Go to map", new Vector2(background.Position.X, YPOS + y), new Vector2(WIDTH, buttonHeight), 0.92f, Color.SkyBlue, delegate { if (MatchSetup.Match != null || Player.Instance != null) { return; } Beatmap b = BeatmapManager.GetBeatmapBySetId(beatmap.setId); BeatmapManager.Current = b; GameBase.ChangeMode(OsuModes.SelectPlay, true); HideResponseDialog(); }, false, true); ResponseSprites.AddRange(pbut.SpriteCollection); y += buttonHeight + 2; } pbut = new pButton(beatmap.HasAttachedDownload ? "Cancel DL" : "Download", new Vector2(background.Position.X, YPOS + y), new Vector2(WIDTH, buttonHeight), 0.92f, Color.Bisque, delegate { beatmap.Download(); HideResponseDialog(); }, false, true); ResponseSprites.AddRange(pbut.SpriteCollection); y += buttonHeight + 2; if (!beatmap.HasAttachedDownload && beatmap.hasVideo) { pbut = new pButton("DL NoVideo", new Vector2(background.Position.X, YPOS + y), new Vector2(WIDTH, buttonHeight), 0.92f, Color.BlueViolet, delegate { beatmap.Download(true); HideResponseDialog(); }, false, true); ResponseSprites.AddRange(pbut.SpriteCollection); y += buttonHeight + 2; } pbut = new pButton("Cancel", new Vector2(background.Position.X, YPOS + y), new Vector2(WIDTH, buttonHeight), 0.92f, Color.Gray, delegate { HideResponseDialog(); }, false, true); ResponseSprites.AddRange(pbut.SpriteCollection); y += buttonHeight + 2; if (beatmap.postid > 0) { pbut = new pButton("View Post", new Vector2(background.Position.X, YPOS + y), new Vector2(WIDTH, buttonHeight), 0.92f, Color.YellowGreen, delegate { GameBase.ProcessStart(String.Format(Urls.FORUM_POST, beatmap.postid)); }, false, true); ResponseSprites.AddRange(pbut.SpriteCollection); } else { pbut = new pButton("View Thread", new Vector2(background.Position.X, YPOS + y), new Vector2(WIDTH, buttonHeight), 0.92f, Color.YellowGreen, delegate { GameBase.ProcessStart(String.Format(Urls.FORUM_TOPIC, beatmap.threadid)); }, false, true); ResponseSprites.AddRange(pbut.SpriteCollection); } y += buttonHeight + 2; pbut = new pButton("View Listing", new Vector2(background.Position.X, YPOS + y), new Vector2(WIDTH, buttonHeight), 0.92f, Color.OrangeRed, delegate { GameBase.ProcessStart(String.Format(Urls.BEATMAP_SET_LISTING, beatmap.setId)); }, false, true); ResponseSprites.AddRange(pbut.SpriteCollection); //The panel isn't yet visible so we are fine to animate as per-usual. ResponseSprites.ForEach(s => s.FadeInFromZero(100)); ResponseSprites.Add(previewThumbnail); spriteManager.Add(ResponseSprites); }
internal override IncreaseScoreType GetScorePoints(Vector2 currentMousePos) { if (!InputManager.ScorableFrame) { return(0); } //First update the spinner velocity... Vector2 mouseVector = currentMousePos - SpriteCircleTop.drawPosition; double mouseAngle = Math.Atan2(mouseVector.Y, mouseVector.X); double mouseAngleDiff = mouseAngle - lastMouseAngle; if (mouseAngle - lastMouseAngle < -Math.PI) { mouseAngleDiff = (2 * Math.PI) + mouseAngle - lastMouseAngle; } else if (lastMouseAngle - mouseAngle < -Math.PI) { mouseAngleDiff = (-2 * Math.PI) - lastMouseAngle + mouseAngle; } double timeDiff = InputManager.LastScorableFrameTime > 0 ? AudioEngine.Time - InputManager.LastScorableFrameTime : GameBase.SIXTY_FRAME_TIME; double decay = Math.Pow(0.999, timeDiff); totalScoreFrameVariance = decay * totalScoreFrameVariance + (1 - decay) * timeDiff; if (mouseAngleDiff == 0) { velocityTheoretical = zeroCount++ < 1 ? velocityTheoretical / 3 : 0; } else { zeroCount = 0; if (!Player.Relaxing && ((InputManager.leftButton == ButtonState.Released && InputManager.rightButton == ButtonState.Released) || AudioEngine.Time < StartTime || AudioEngine.Time > EndTime)) { mouseAngleDiff = 0; } if (Math.Abs(mouseAngleDiff) < Math.PI) { if (HitObjectManager.ApplyModsToTime(totalScoreFrameVariance, hitObjectManager.ActiveMods) > GameBase.SIXTY_FRAME_TIME * 1.04f) { //after a certain lenience we need to stop allowing for SIXTY_FRAMEs and take frames for their actual elapsed time. //this is to handle the case where users are running at sub-60fps. //in a simple world, we could always use this timeDiff calculation, but due to historical reasons, //we were always slightly in the user's favour when calculating velocity here. velocityTheoretical = mouseAngleDiff / HitObjectManager.ApplyModsToTime(timeDiff, hitObjectManager.ActiveMods); } else { velocityTheoretical = mouseAngleDiff / GameBase.SIXTY_FRAME_TIME; } } else { velocityTheoretical = 0; } } lastMouseAngle = mouseAngle; //If we have actually progressed, let's return some score... if (rotationCount == lastRotationCount) { return(IncreaseScoreType.Ignore); } scoringRotationCount++; IncreaseScoreType score = IncreaseScoreType.Ignore; if (SkinManager.Current.SpinnerFrequencyModulate) { AudioEngine.UpdateSpinSample((float)scoringRotationCount / rotationRequirement); } if (scoringRotationCount > rotationRequirement + 3 && (scoringRotationCount - (rotationRequirement + 3)) % 2 == 0) { if (spriteGlow != null) { spriteGlow.FlashColour(Color.White, 200); } score = IncreaseScoreType.SpinnerBonus; if (!ModManager.CheckActive(Mods.Cinema)) { AudioEngine.PlaySample(@"spinnerbonus", AudioEngine.VolumeSample, SkinSource.All); } SpriteBonusCounter.Text = (1000 * (scoringRotationCount - (rotationRequirement + 3)) / 2).ToString(); SpriteBonusCounter.Transformations.Clear(); SpriteBonusCounter.Transformations.Add(new Transformation(TransformationType.Fade, 1, 0, AudioEngine.Time, AudioEngine.Time + 800)); SpriteBonusCounter.Transformations.Add(new Transformation(TransformationType.Scale, 2f, 1.28f, AudioEngine.Time, AudioEngine.Time + 800)); SpriteBonusCounter.Transformations[0].Easing = EasingTypes.Out; SpriteBonusCounter.Transformations[1].Easing = EasingTypes.Out; //Ensure we don't recycle this too early. SpriteBonusCounter.Transformations.Add(new Transformation(TransformationType.Fade, 0, 0, EndTime + 800, EndTime + 800)); } else if (scoringRotationCount > 1 && scoringRotationCount % 2 == 0) { score = IncreaseScoreType.SpinnerSpinPoints; } else if (scoringRotationCount > 1) { score = IncreaseScoreType.SpinnerSpin; } lastRotationCount = rotationCount; return(score); }