Esempio n. 1
0
		void PlayVideo(VqaPlayerWidget player, string video, PlayingVideo pv, Action onComplete)
		{
			StopVideo(player);

			playingVideo = pv;
			player.Load(video);

			// video playback runs asynchronously
			player.PlayThen(onComplete);

			// Mute other distracting sounds
			MuteSounds();
		}
Esempio n. 2
0
        void PlayVideo(VqaPlayerWidget player, string video, PlayingVideo pv, Action onComplete = null)
        {
            if (!modData.DefaultFileSystem.Exists(video))
            {
                ConfirmationDialogs.ButtonPrompt(
                    title: "Video not installed",
                    text: "The game videos can be installed from the\n\"Manage Content\" menu in the mod chooser.",
                    cancelText: "Back",
                    onCancel: () => { });
            }
            else
            {
                StopVideo(player);

                playingVideo = pv;
                player.Load(video);

                // video playback runs asynchronously
                player.PlayThen(() =>
                {
                    StopVideo(player);
                    if (onComplete != null)
                        onComplete();
                });

                // Mute other distracting sounds
                MuteSounds();
            }
        }
Esempio n. 3
0
        bool LoadAsset(string filename)
        {
            if (isVideoLoaded)
            {
                player.Stop();
                player = null;
                isVideoLoaded = false;
            }

            if (string.IsNullOrEmpty(filename))
                return false;

            if (!GlobalFileSystem.Exists(filename))
                return false;

            if (Path.GetExtension(filename) == ".vqa")
            {
                player = panel.Get<VqaPlayerWidget>("PLAYER");
                currentFilename = filename;
                player.Load(filename);
                isVideoLoaded = true;
                frameSlider.MaximumValue = (float)player.Video.Frames - 1;
                frameSlider.Ticks = 0;
            }
            else
            {
                currentFilename = filename;
                currentSprites = world.Map.SequenceProvider.SpriteCache[filename];
                currentFrame = 0;
                frameSlider.MaximumValue = (float)currentSprites.Length - 1;
                frameSlider.Ticks = currentSprites.Length;
            }

            return true;
        }
Esempio n. 4
0
        bool LoadAsset(string filename)
        {
            if (isVideoLoaded)
            {
                player.Stop();
                player = null;
                isVideoLoaded = false;
            }

            if (string.IsNullOrEmpty(filename))
                return false;

            if (!modData.DefaultFileSystem.Exists(filename))
                return false;

            errorLabelWidget.Visible = false;

            try
            {
                if (Path.GetExtension(filename.ToLowerInvariant()) == ".vqa")
                {
                    player = panel.Get<VqaPlayerWidget>("PLAYER");
                    currentFilename = filename;
                    player.Load(filename);
                    player.DrawOverlay = false;
                    isVideoLoaded = true;
                    frameSlider.MaximumValue = (float)player.Video.Frames - 1;
                    frameSlider.Ticks = 0;
                    return true;
                }

                currentFilename = filename;
                currentSprites = world.Map.Rules.Sequences.SpriteCache[filename];
                currentFrame = 0;
                frameSlider.MaximumValue = (float)currentSprites.Length - 1;
                frameSlider.Ticks = currentSprites.Length;
            }
            catch (Exception ex)
            {
                if (errorLabelWidget != null)
                {
                    errorLabelWidget.Text = WidgetUtils.TruncateText(errorLabelWidget.Text.Replace("{filename}", filename),
                        errorLabelWidget.Bounds.Width, errorFont);

                    currentSprites = new Sprite[0];
                    errorLabelWidget.Visible = true;
                }

                Log.AddChannel("assetbrowser", "assetbrowser.log");
                Log.Write("assetbrowser", "Error reading {0}:{3} {1}{3}{2}", filename, ex.Message, ex.StackTrace, Environment.NewLine);

                return false;
            }

            return true;
        }