/// <summary>
    /// Create the differents option for the resolution dropdown.
    /// </summary>
    private static Dropdown.OptionData[] CreateResolutionDropdown()
    {
        Dropdown.OptionData[] options = new Dropdown.OptionData[Screen.resolutions.Length + 1];
        options[0] = new ResolutionOption
        {
            text = string.Format(
                "{0} x {1} @ {2}",
                Screen.currentResolution.width,
                Screen.currentResolution.height,
                Screen.currentResolution.refreshRate),
            Resolution = Screen.currentResolution
        };

        for (int i = 0; i < Screen.resolutions.Length; i++)
        {
            options[i + 1] = new ResolutionOption
            {
                text = string.Format(
                    "{0} x {1} @ {2}",
                    Screen.resolutions[i].width,
                    Screen.resolutions[i].height,
                    Screen.resolutions[i].refreshRate),
                Resolution = Screen.resolutions[i]
            };
        }

        return(options);
    }
Пример #2
0
    public void OnApply()
    {
        LocalizationTable.SetLocalization(languageDropdown.value);

        if (WorldController.Instance != null)
        {
            WorldController.Instance.spawnInventoryController.SetUIVisibility(developerModeToggle.isOn);
        }

        // MasterTextureLimit should get 0 for High quality and higher values for lower qualities.
        // For example count is 3 (0:Low, 1:Med, 2:High).
        // For High: count - 1 - value  =  3 - 1 - 2  =  0  (therefore no limit = high quality).
        // For Med:  count - 1 - value  =  3 - 1 - 1  =  1  (therefore a slight limit = medium quality).
        // For Low:  count - 1 - value  =  3 - 1 - 0  =  1  (therefore more limit = low quality).
        QualitySettings.masterTextureLimit = qualityDropdown.options.Count - 1 - qualityDropdown.value;

        Screen.fullScreen = fullScreenToggle.isOn;

        ResolutionOption selectedOption = (ResolutionOption)resolutionDropdown.options[resolutionDropdown.value];
        Resolution       resolution     = selectedOption.Resolution;

        Screen.SetResolution(resolution.width, resolution.height, fullScreenToggle.isOn, resolution.refreshRate);

        if (WorldController.Instance != null)
        {
            WorldController.Instance.autosaveManager.SetAutosaveInterval(int.Parse(autosaveInterval.text));
        }

        // One to many but we want an applying feature;
        PerformanceHUDManager.DirtyUI();
    }
Пример #3
0
        public MediaFile Clone(ResolutionOption resolution)
        {
            var clone = new MediaFile();

            clone.Resolution       = resolution;
            clone.OutputRGBImage   = OutputRGBImage;
            clone.OutputYData      = OutputYData;
            clone.OutputYImage     = OutputYImage;
            clone._lastFieldNumber = _lastFieldNumber;
            clone.Open(_filename);
            return(clone);
        }
Пример #4
0
    public override GameObject InitializeElement()
    {
        selectedValue = getValue();
        GameObject go = DropdownHelperFromOptionData(CreateResolutionDropdown(), selectedValue);

        dropdownElement.onValueChanged.AddListener(
            (int v) =>
        {
            if (v != selectedValue)
            {
                valueChanged   = true;
                selectedOption = (ResolutionOption)dropdownElement.options[v];
                selectedValue  = v;
            }
        });

        return(go);
    }
Пример #5
0
    public void OnApply()
    {
        LocalizationTable.SetLocalization(languageDropdown.value);

        fpsObject.SetActive(fpsToggle.isOn);
        WorldController.Instance.spawnInventoryController.SetUIVisibility(developerModeToggle.isOn);

        // MasterTextureLimit should get 0 for High quality and higher values for lower qualities.
        // For example count is 3 (0:Low, 1:Med, 2:High).
        // For High: count - 1 - value  =  3 - 1 - 2  =  0  (therefore no limit = high quality).
        // For Med:  count - 1 - value  =  3 - 1 - 1  =  1  (therefore a slight limit = medium quality).
        // For Low:  count - 1 - value  =  3 - 1 - 0  =  1  (therefore more limit = low quality).
        QualitySettings.masterTextureLimit = qualityDropdown.options.Count - 1 - qualityDropdown.value;

        Screen.fullScreen = fullScreenToggle.isOn;

        ResolutionOption selectedOption = (ResolutionOption)resolutionDropdown.options[resolutionDropdown.value];
        Resolution       resolution     = selectedOption.Resolution;

        Screen.SetResolution(resolution.width, resolution.height, fullScreenToggle.isOn, resolution.refreshRate);
    }
    public override GameObject InitializeElement()
    {
        if (data == null || data.Length != Screen.resolutions.Length + 1)
        {
            data = CreateResolutionDropdown();
        }

        selectedValue = getValue();
        GameObject go = DropdownHelperFromOptionData(data, selectedValue);
        dropdownElement.onValueChanged.AddListener(
            (int v) =>
            {
                if (v != selectedValue)
                {
                    valueChanged = true;
                    selectedOption = (ResolutionOption)dropdownElement.options[v];
                    selectedValue = v;
                }
            });

        return go;
    }
Пример #7
0
 /// <summary>
 /// Configure the container to inject the given field name.
 /// </summary>
 /// <param name="name">Name of property to inject.</param>
 /// <param name="option">Tells Unity if this field is optional.</param>
 public InjectionField(string name, ResolutionOption option = ResolutionOption.Required)
     : base(name, ResolutionOption.Optional == option ? OptionalDependencyAttribute.Instance
                                                      : (object)DependencyAttribute.Instance)
 {
 }
Пример #8
0
            public void run(bool to1dir, bool allFiles, List <OutputFileObj> videos, List <OutputFileObj> others, MainWindow window,
                            CodecOption codec, AudioOption audioOp, ResolutionOption res, QualityOption quality, VideoTypeOption typeOp)
            {
                Console.WriteLine(
                    "Running Configurartion:" +
                    "\n  Codec: " + Enum.GetName(typeof(CodecOption), codec) +
                    "\n  Audio Codec: " + Enum.GetName(typeof(AudioOption), audioOp) +
                    "\n  Video Resolution: " + Enum.GetName(typeof(ResolutionOption), res) +
                    "\n Video Type: " + Enum.GetName(typeof(VideoTypeOption), typeOp));

                int totalVideos = videos.Count * 100;

                window.Dispatcher.Invoke(() => window.allVideoFilesProgressBar.Maximum = 100);

                Converter = new FFMpegConverter();
                int        index   = 0;
                MainWindow _window = window;
                Thread     _t      = Thread.CurrentThread;

                Converter.ConvertProgress += (sender, e) =>
                {
                    try
                    {
                        _window.Dispatcher.Invoke(() =>
                        {
                            Console.WriteLine("Processed: " + e.Processed);
                            _window.currFileProgressBar.Value = (float)e.Processed.TotalSeconds / (float)e.TotalDuration.TotalSeconds * 100;
                            Console.WriteLine((float)e.Processed.TotalSeconds / (float)e.TotalDuration.TotalSeconds * 100);
                            Console.WriteLine(_window.currFileProgressBar.Value);
                            _window.allVideoFilesProgressBar.Value = 100 / (float)videos.Count * index +
                                                                     (float)e.Processed.TotalSeconds / (float)e.TotalDuration.TotalSeconds * 100 / (float)videos.Count;
                        });
                    }
                    catch (TaskCanceledException tce)
                    {
                        _t.Abort();
                    }
                };
                foreach (OutputFileObj video in videos)
                {
                    var videoMedia = new NReco.VideoInfo.FFProbe().GetMediaInfo(video.Path);
                    window.Dispatcher.Invoke(() =>
                    {
                        window.currFileProgressBar.Maximum = 100;
                    });

                    if (typeOp != VideoTypeOption.copy)
                    {
                        video.OutPath = System.IO.Path.ChangeExtension(video.OutPath, "." + Enum.GetName(typeof(VideoTypeOption), typeOp));
                    }

                    if (audioOp == AudioOption.flac &&
                        System.IO.Path.GetExtension(video.Path).ToLower() ==
                        "." + Enum.GetName(typeof(VideoTypeOption), VideoTypeOption.mp4).ToLower())
                    {
                        audioOp = AudioOption.copy;
                    }

                    string scaleString =
                        res == ResolutionOption.copy ? "" :
                        res == ResolutionOption._1080 ? "-vf scale=-2:1080" :
                        res == ResolutionOption._720 ? "-vf scale=-2:720" :
                        res == ResolutionOption._480 ? "-vf scale=-2:480" :
                        res == ResolutionOption._240 ? "-vf scale=-2:240" : "";

                    Func <string> getCopyCodec = () =>
                    {
                        string videoCodec = videoMedia.Streams.ToList().Find(
                            (item) => item.CodecType.ToLower() == "video").CodecName;
                        if (videoCodec.Contains("h264"))
                        {
                            return("libx264");
                        }
                        if (videoCodec.Contains("hevc"))
                        {
                            return("libx265");
                        }
                        return("libx264");
                    };

                    string codecString =
                        codec == CodecOption.copy ? getCopyCodec() :
                        codec == CodecOption.h264 ? "libx264" :
                        codec == CodecOption.HEVC ? "libx265" : getCopyCodec();

                    string Command = string.Format(
                        "-c:v {3} {0} -crf {1} -c:a {2} -stats -y",
                        scaleString, (int)quality,
                        Enum.GetName(typeof(AudioOption), (int)audioOp), codecString);

                    Console.WriteLine("Input Path: '" + video.Path + "'");
                    Console.WriteLine("Output Path: '" + video.OutPath + "'");

                    System.IO.Directory.CreateDirectory(System.IO.Path.GetDirectoryName(video.OutPath));
                    Console.WriteLine("Created direcotory: '" + System.IO.Path.GetDirectoryName(video.OutPath) + "'");
                    Console.WriteLine("Running Command: '" + Command + "'");
                    Converter.ConvertMedia(video.Path, null, video.OutPath, null, new ConvertSettings()
                    {
                        CustomOutputArgs = Command
                    });
                    Console.WriteLine("Video converted");

                    index++;
                }
            }
Пример #9
0
        private void RunRenderButton_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrWhiteSpace(inputDirTextBox.Text))
            {
                inputDirTextBox.Background = new SolidColorBrush(Colors.Red);
                return;
            }
            else
            {
                inputDirTextBox.Background = new SolidColorBrush(Colors.White);
            }

            if (string.IsNullOrWhiteSpace(outputDirTextBox.Text))
            {
                outputDirTextBox.Background = new SolidColorBrush(Colors.Red);
                return;
            }
            else
            {
                outputDirTextBox.Background = new SolidColorBrush(Colors.White);
            }

            DirObj dir = new DirObj
            {
                Path = inputDirTextBox.Text
            };

            bool dirError = !dir.renderFolder();

            if (dirError)
            {
                Console.WriteLine("We wasn't able to render folder");
                return;
            }

            dir.allFiles.ForEach(file => Console.WriteLine("Path: \"" + file.Path + "\""));
            List <OutputFileObj> videoFiles = new List <OutputFileObj>();
            List <OutputFileObj> otherFiles = new List <OutputFileObj>();

            Func <FileObj, ObservableCollection <CheckableItem>, CheckableItem> findCorrespondingItem = null;

            findCorrespondingItem = (file, items) => {
                foreach (CheckableItem item in items)
                {
                    if (item.Path == file.Path)
                    {
                        return(item);
                    }
                    var foundItem = findCorrespondingItem(file, item.Children);
                    if (foundItem != null)
                    {
                        return(foundItem);
                    }
                }
                return(null);
            };

            foreach (FileObj file in dir.allFiles)
            {
                if (findCorrespondingItem(file, items).IsChecked)
                {
                    string relPath = new Uri(inputDirTextBox.Text).MakeRelativeUri(new Uri(file.Path)).ToString();
                    string outPath = System.IO.Path.Combine(outputDirTextBox.Text, relPath);
                    outPath = Uri.UnescapeDataString(outPath);

                    if (videoExtensions.Contains(System.IO.Path.GetExtension(file.Name)))
                    {
                        videoFiles.Add(new OutputFileObj(file)
                        {
                            OutPath = outPath
                        });
                    }
                    else
                    {
                        otherFiles.Add(new OutputFileObj(file)
                        {
                            OutPath = outPath
                        });
                    }
                }
            }

            bool to1Dir       = videoTo1Dir.IsChecked == true;
            bool CopyAllFiles = copyAllFiles.IsChecked == true;

            CodecOption      codec      = (CodecOption)videoCodecCombo.SelectedItem;
            AudioOption      audioCodec = (AudioOption)audioCodecCombo.SelectedItem;
            ResolutionOption res        = Enum.GetValues(typeof(ResolutionOption)).Cast <ResolutionOption>().ToArray()[videoResolutionCombo.SelectedIndex];
            QualityOption    quality    = (QualityOption)videoQualityCombo.SelectedItem;
            VideoTypeOption  type       = (VideoTypeOption)videoTypeCombo.SelectedItem;

            runner = new runnerThread();

            Thread t = new Thread(() => { runner.run(
                                              to1Dir,
                                              CopyAllFiles,
                                              videoFiles,
                                              otherFiles,
                                              this,
                                              codec,
                                              audioCodec,
                                              res,
                                              quality,
                                              type); });

            t.Start();
        }