Пример #1
0
        public bool PlayMovieInRadar(string movie, LuaFunction playComplete = null)
        {
            Action onCompleteRadar;

            if (playComplete != null)
            {
                var f = (LuaFunction)playComplete.CopyReference();
                onCompleteRadar = () =>
                {
                    try
                    {
                        using (f)
                            f.Call().Dispose();
                    }
                    catch (LuaException e)
                    {
                        Context.FatalError(e.Message);
                    }
                };
            }
            else
            {
                onCompleteRadar = () => { }
            };

            Stream s;

            try
            {
                s = Game.ModData.ModFiles.Open(movie);
            }
            catch (FileNotFoundException e)
            {
                Log.Write("lua", "Couldn't play movie {0}! File doesn't exist.", e.FileName);
                onCompleteRadar();
                return(false);
            }

            AsyncLoader  l              = new AsyncLoader(Media.LoadVqa);
            IAsyncResult ar             = l.BeginInvoke(s, null, null);
            Action       onLoadComplete = () =>
            {
                Media.StopFMVInRadar();
                world.AddFrameEndTask(_ => Media.PlayFMVInRadar(world, l.EndInvoke(ar), onCompleteRadar));
            };

            world.AddFrameEndTask(w => w.Add(new AsyncAction(ar, onLoadComplete)));
            return(true);
        }
Пример #2
0
        public bool PlayMovieInRadar(string movie, LuaFunction playComplete = null)
        {
            if (playComplete != null)
            {
                var f = playComplete.CopyReference() as LuaFunction;
                onCompleteRadar = () =>
                {
                    try
                    {
                        using (f)
                            f.Call().Dispose();
                    }
                    catch (LuaException e)
                    {
                        Context.FatalError(e.Message);
                    }
                };
            }
            else
                onCompleteRadar = () => { };

            Stream s = null;
            try
            {
                s = GlobalFileSystem.Open(movie);
            }
            catch (FileNotFoundException e)
            {
                Log.Write("lua", "Couldn't play movie {0}! File doesn't exist.", e.FileName);
                onCompleteRadar();
                return false;
            }

            AsyncLoader l = new AsyncLoader(Media.LoadVqa);
            IAsyncResult ar = l.BeginInvoke(s, null, null);
            onLoadComplete = () =>
            {
                Media.StopFMVInRadar();
                world.AddFrameEndTask(_ => Media.PlayFMVInRadar(world, l.EndInvoke(ar), onCompleteRadar));
            };

            world.AddFrameEndTask(w => w.Add(new AsyncAction(ar, onLoadComplete)));
            return true;
        }