internal EventVideo(pVideo video, string filename, int startTime) { Video = video; Type = EventTypes.Video; Filename = Path.GetFileName(filename); Sprite = video; StartTime = startTime; }
internal EventVideo(pVideo video, string filename, int startTime) { Video = video; StoryboardIgnore = true; Type = EventTypes.Video; Filename = Path.GetFileName(filename); Sprite = video; StartTime = startTime; Loaded = true; }
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"); }
internal void Update() { if (tournament.Team1.HasWon) { loadBackground(@"background-win1-full"); } else if (tournament.Team2.HasWon) { loadBackground(@"background-win2-full"); } else { switch (tournament.State) { case TourneyState.Ranking: { if (tournament.Team1.CurrentScore > tournament.Team2.CurrentScore) { loadBackground(@"background-win1"); } else if (tournament.Team2.CurrentScore > tournament.Team1.CurrentScore) { loadBackground(@"background-win2"); } } break; default: loadBackground(@"background"); break; } } if (pendingBackgroundVideo != null) { pendingBackgroundVideo.NextFrame(); if (pendingBackgroundVideo.video.PlaybackStable) { if (activeBackgroundVideo != null && activeBackgroundVideo != defaultBackgroundVideo) { activeBackgroundVideo.FadeOut(500); } if (activeBackgroundSprite != null && activeBackgroundSprite != defaultBackgroundSprite) { activeBackgroundSprite.FadeOut(500); } activeBackgroundSprite = null; activeBackgroundVideo = pendingBackgroundVideo; if (activeBackgroundVideo == defaultBackgroundVideo) { activeBackgroundVideo.Alpha = 1f; } activeBackgroundVideo.FadeIn(500); pendingBackgroundVideo = null; } } activeBackgroundVideo?.NextFrame(); }
private void loadBackground(string name) { pVideo newVideo; if (modeBackgroundVideos.TryGetValue(name, out newVideo)) { if (newVideo == activeBackgroundVideo || newVideo == pendingBackgroundVideo) { return; } if (activeBackgroundVideo != null) { newVideo.StartTime = activeBackgroundVideo.StartTime; newVideo.EndTime = newVideo.StartTime + newVideo.video.length; } if (name == backgroundNames[0] && defaultBackgroundVideo == null) { activeBackgroundVideo = newVideo; defaultBackgroundVideo = activeBackgroundVideo; defaultBackgroundVideo.Alpha = 1f; } else { pendingBackgroundVideo = newVideo; pendingBackgroundVideo.SeekToCurrent(true); } } else { pSprite newSprite; if (!modeBackgroundSprites.TryGetValue(name, out newSprite)) { newSprite = defaultBackgroundSprite; } if (name == backgroundNames[0] && defaultBackgroundSprite == null) { defaultBackgroundSprite = newSprite; } if (newSprite == activeBackgroundSprite) { return; } if (activeBackgroundVideo != null && activeBackgroundVideo != defaultBackgroundVideo) { activeBackgroundVideo.FadeOut(500); } activeBackgroundVideo = null; if (activeBackgroundSprite != null && activeBackgroundSprite != defaultBackgroundSprite) { activeBackgroundSprite.FadeOut(500); } activeBackgroundSprite = newSprite; if (activeBackgroundSprite == defaultBackgroundSprite) { activeBackgroundSprite.Alpha = 1f; } activeBackgroundSprite.FadeIn(500); } }
internal void Update() { bool breakMode = false; if (GameBase.Mode == Modes.Play && AudioEngine.Time < HitObjectManager.hitObjects[0].StartTime - HitObjectManager.PreEmpt) { breakMode = true; } for (int i = 0; i < eventBreaks.Count; i++) { EventBreak e = eventBreaks[i]; if (AudioEngine.Time >= e.StartTime && AudioEngine.Time <= e.EndTime) { breakMode = true; BreakCurrent = e; break; } } if (GameBase.Mode == Modes.Play && Player.Passing != passingCurrent) { passingCurrent = Player.Passing; for (int i = 0; i < storyLayerSets[(int)StoryLayer.Failing].Count; i++) { Event e = storyLayerSets[(int)StoryLayer.Failing][i]; switch (e.Type) { case EventTypes.Sprite: case EventTypes.Animation: if (Player.Passing) { spriteManagerFG.Remove(e.Sprite); } else { spriteManagerFG.Add(e.Sprite); } break; case EventTypes.Sample: if (Player.Passing) { AudioEngine.SampleEvents.Remove(((EventSample)e).SampleCache); } else { AudioEngine.SampleEvents.Add(((EventSample)e).SampleCache); } break; } } if (!firstRun) { for (int i = 0; i < storyLayerSets[(int)StoryLayer.Passing].Count; i++) { Event e = storyLayerSets[(int)StoryLayer.Passing][i]; switch (e.Type) { case EventTypes.Sprite: case EventTypes.Animation: if (Player.Passing) { spriteManagerFG.Add(e.Sprite); } else { spriteManagerFG.Remove(e.Sprite); } break; case EventTypes.Sample: if (Player.Passing) { AudioEngine.SampleEvents.Add(((EventSample)e).SampleCache); } else { AudioEngine.SampleEvents.Remove(((EventSample)e).SampleCache); } break; } } } firstRun = false; } BreakMode = breakMode; if (!breakMode) { BreakCurrent = null; } //foregroundTexture.CurrentScale = GameBase.s_fadeScreen.CurrentScale; if (GameBase.Mode == Modes.Play && SkinManager.Current.SpinnerFadePlayfield && Player.IsSpinning && spriteManagerBG.Blackness < 1) { spriteManagerBG.Blackness += 0.04F; spriteManagerFG.Blackness += 0.04F; } else if (spriteManagerBG.Blackness > 0.3F) { spriteManagerBG.Blackness -= 0.04F; spriteManagerFG.Blackness -= 0.04F; } else if (!breakMode && spriteManagerBG.Blackness < 0.25F) { spriteManagerBG.Blackness += 0.04F; spriteManagerFG.Blackness += 0.04F; if (GameBase.Mode == Modes.Play && breakTop.TagNumeric == 1) { breakTop.TagNumeric = 0; breakTop.Transformations.Add( new Transformation(TransformationType.Fade, 1, 0, GameBase.Time - 1, GameBase.Time + 200)); breakBottom.Transformations.Add( new Transformation(TransformationType.Fade, 1, 0, GameBase.Time - 1, GameBase.Time + 200)); } } else if (breakMode && (spriteManagerBG.Blackness > 0 || breakTop.TagNumeric == 0)) { spriteManagerBG.Blackness -= 0.04F; spriteManagerFG.Blackness -= 0.04F; if (GameBase.Mode == Modes.Play && breakTop.TagNumeric == 0) { breakTop.TagNumeric = 1; breakTop.Transformations.Add( new Transformation(TransformationType.Fade, 0, 1, GameBase.Time - 1, GameBase.Time + 200)); breakBottom.Transformations.Add( new Transformation(TransformationType.Fade, 0, 1, GameBase.Time - 1, GameBase.Time + 200)); } } VideoPlaying = false; //Handle video playback. for (int i = 0; i < videoSprites.Count; i++) { pVideo v = videoSprites[i]; if (AudioEngine.AudioState == AudioEngine.AudioStates.Playing || AudioEngine.Time < 0) { VideoPlaying = true; if (!v.Triggered && AudioEngine.Time >= v.StartTime) { v.Start(); v.SeekToCurrent(); } } else { if (v.Triggered) { v.Pause(); } } if (v.Triggered) { if ((Math.Abs(v.video.offset) > 1000) || (v.video.offset != -1 && Math.Abs(v.video.lastSample - (AudioEngine.Time - v.StartTimeOffset)) > 500)) { v.SeekToCurrent(); } } } }
internal Event Add(string filename, int time) { filename = BeatmapManager.Current.ContainingFolder + "\\" + filename; if (!File.Exists(filename)) { return(null); } BackgroundDrawDepth += 0.001F; try { string extension = Path.GetExtension(filename).ToLower(); Event e; pSprite videoSprite = null; switch (extension) { case ".png": case ".jpg": case ".jpeg": e = new EventSprite(new pSprite(Texture2D.FromFile(GameBase.graphics.GraphicsDevice, filename), FieldTypes.GamefieldRatio, OriginTypes.Centre, ClockTypes.Audio, new Vector2(GameBase.WindowDefaultWidth / 2, GameBase.WindowDefaultHeight / 2)), filename, -100000, (int)(1000 * AudioEngine.AudioLength)); e.Sprite.CurrentScale = (float)GameBase.WindowDefaultWidth / e.Sprite.Width; e.Sprite.Depth = BackgroundDrawDepth; e.WriteToOsu = true; break; case ".avi": case ".wmv": case ".mpg": case ".flv": if (ConfigManager.sVideo && !ModManager.ModNoVideo) { try { videoSprite = new pVideo(filename, time); videoSprite.CurrentScale = (float)GameBase.WindowDefaultWidth / videoSprite.DrawWidth; videoSprites.Add((pVideo)videoSprite); } catch (Exception) { GameBase.ShowMessage("Video playback failed - check your codecs."); } } e = new EventVideo((pVideo)videoSprite, filename, time); if (videoSprite != null) { videoSprite.Depth = BackgroundDrawDepth; videoSprite.Transformations.Add( new Transformation(TransformationType.Fade, 0, 1, time, time + 1000)); videoSprite.Transformations.Add( new Transformation(TransformationType.Fade, 1, 0, ((pVideo)videoSprite).EndTime - 1000, ((pVideo)videoSprite).EndTime)); spriteManagerBG.Add(videoSprite); e.Sprite.Depth = BackgroundDrawDepth; } e.WriteToOsu = true; events.Add(e); return(e); default: throw new Exception("moo"); } events.Add(e); if (e.Sprite != null) { spriteManagerBG.Add(e.Sprite); } return(e); } catch (Exception) { GameBase.ShowMessage("An error occurred while adding this file."); } return(null); }
internal Event Add(string filename, int time) { BackgroundDrawDepth += 0.001F; #if !DEBUGz try #endif { Event e; pSprite videoSprite = null; FileType ext = GeneralHelper.GetFileType(filename); switch (ext) { case FileType.Image: pTexture tex = TextureManager.Load(filename, SkinSource.Beatmap); pSprite spr = null; if (tex == null && GameBase.Mode == OsuModes.Play && !GameBase.TestMode) { BeatmapManager.Current.BackgroundVisible = false; } else { spr = new pSprite(tex, Fields.StoryboardCentre, Origins.Centre, Clocks.Audio, Vector2.Zero); } e = new EventSprite(spr, filename, -100000, 1000 * AudioEngine.AudioLength); if (e.Sprite == null) { NotificationManager.ShowMessageMassive(LocalisationManager.GetString(OsuString.OsuIsAngry), 5000); } else { e.Sprite.AlwaysDraw = true; //e.Sprite.Transformations.Add(new Transformation(TransformationType.Fade, 0, 1, -100000, -100000)); //e.Sprite.Transformations.Add(new Transformation(TransformationType.Fade, 1, 0, 1000 * AudioEngine.AudioLength, 1000 * AudioEngine.AudioLength)); e.Sprite.Depth = BackgroundDrawDepth; } e.Type = EventTypes.Background; e.WriteToOsu = true; backgroundEvent = e; break; case FileType.Video: if (!BeatmapManager.Current.CheckFileExists(filename)) { return(null); } if (ShowVideo && ((GameBase.Mode != OsuModes.Edit && !GameBase.TestMode) || ConfigManager.sEditorVideo)) { try { videoSprite = new pVideo(filename, time); videoSprite.Scale = (float)WindowManager.DEFAULT_WIDTH / videoSprite.DrawWidth; videoSprites.Add((pVideo)videoSprite); } catch (Exception) { NotificationManager.ShowMessage("Video playback failed. This could be due to missing dll files (try running the updater)."); } } e = new EventVideo(videoSprite as pVideo, filename, time); if (videoSprite != null) { videoSprite.Depth = BackgroundDrawDepth; videoSprite.Transformations.Add( new Transformation(TransformationType.Fade, 0, 1, time, time + 1000)); videoSprite.Transformations.Add( new Transformation(TransformationType.Fade, 1, 0, ((pVideo)videoSprite).EndTime - 1000, ((pVideo)videoSprite).EndTime)); spriteManagerBGWide.AddNonOptimised(videoSprite); e.Sprite.Depth = BackgroundDrawDepth; } e.WriteToOsu = true; events.Add(e); return(e); default: throw new Exception("moo"); } events.Add(e); e.StoryboardIgnore = true; if (e.Sprite != null) { spriteManagerBGWide.AddNonOptimised(e.Sprite); } return(e); } #if !DEBUGz catch (Exception) { NotificationManager.ShowMessage("An error occurred while adding this file."); } #endif return(null); }