Example #1
0
        internal override Event Clone()
        {
            pSprite     spriteClone = Sprite.Clone();
            EventSprite clone       = new EventSprite(spriteClone, Filename, StartTime, EndTime);

            clone.WriteToOsu        = WriteToOsu;
            clone.Type              = Type;
            clone.Layer             = Layer;
            clone.StoryboardIgnore  = StoryboardIgnore;
            clone.EventLoopTriggers = EventLoopTriggers;
            return(clone);
        }
Example #2
0
        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);
        }
Example #3
0
        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);
        }