示例#1
0
        private IEnumerator UpdateSelectionsCoroutine()
        {
            var selectedIds   = GetSelectedMatchIds().ToList();
            var selectedCount = selectedIds.Count;

            if (selectedCount == 0)
            {
                Logger.LogWarningMessage("No characters selected");
                GeBoAPI.Instance.PlayNotificationSound(NotificationSound.Error);
            }
            else if (selectedCount != 1)
            {
                Logger.LogWarningMessage(
                    "Select only instances of a single character.");
                GeBoAPI.Instance.PlayNotificationSound(NotificationSound.Error);
            }
            else
            {
                yield return
                    (StartCoroutine(CoroutineUtils.CreateCoroutine(() => SelectCharasById(selectedIds.First()))));
            }
        }
示例#2
0
        private Dictionary <string, string> LoadTrackingFile()
        {
            var lastLoadedScenes = new Dictionary <string, string>(StringComparer.InvariantCultureIgnoreCase);
            var count            = 0;

            using (var fileStream = new FileStream(TrackLastLoadedSceneFile, FileMode.OpenOrCreate))
            {
                int     expectedCount;
                Version version;
                using (var streamReader = new StreamReader(fileStream, Encoding.UTF8, true))
                {
                    if (!TryReadTrackingHeader(streamReader, out version, out expectedCount))
                    {
                        fileStream.Position = 0;
                    }

                    string line;

                    while ((line = streamReader.ReadLine()) != null)
                    {
                        if (line.IsNullOrEmpty())
                        {
                            continue;
                        }

                        try
                        {
                            count++;
                            var entry = line.Split(TrackingFileEntrySplit, 2);
                            // Normalize on load to take care of any changes between versions
                            if (!Path.IsPathRooted(entry[0]))
                            {
                                if (entry[0] == ".")
                                {
                                    entry[0] = PathUtils.NormalizePath(SceneUtils.StudioSceneRootFolder);
                                }
                                else
                                {
                                    entry[0] = PathUtils.NormalizePath(Path.Combine(SceneUtils.StudioSceneRootFolder,
                                                                                    entry[0]));
                                }
                            }

                            if (lastLoadedScenes.ContainsKey(entry[0]))
                            {
                                Logger.LogWarning(
                                    $"{nameof(LoadTrackingFile)}: line {count}: duplicate key {entry[0]}");
                            }

                            lastLoadedScenes[entry[0]] = Path.GetFileName(entry[1]);
                        }
                        catch (Exception err)
                        {
                            Logger.LogException(err,
                                                $"{nameof(LoadTrackingFile)}: line {count}: {line.TrimEnd()}");
                        }
                    }
                }

                if (expectedCount >= 0 && version >= new Version(0, 8, 7) && expectedCount != count)
                {
                    Logger.LogWarningMessage(
                        $"{nameof(LoadTrackingFile)}: {TrackLastLoadedSceneFile} may be corrupted. It contains {count} entries, expected {expectedCount}.");
                }
            }

            return(lastLoadedScenes);
        }
示例#3
0
        private void ExecuteDump()
        {
            if (StudioInitObject == null)
            {
                return;
            }
            var scenes = GetListPath();

            if (scenes.Count < 1)
            {
                return;
            }

            var dirName = Path.GetDirectoryName(scenes[0]);

            if (string.IsNullOrEmpty(dirName))
            {
                return;
            }
            Logger.LogInfo("Start dump.");

            var outputFile = Path.GetFullPath(Path.Combine(dirName, "SceneCharaInfo.csv"));

            var append = false;

            _processedScenes.Clear();
            if (File.Exists(outputFile))
            {
                append = true;
                using (var reader = new StreamReader(outputFile, Encoding.UTF8))
                {
                    string line;
                    while ((line = reader.ReadLine()) != null)
                    {
                        var fPath = line.Split(',').FirstOrDefault()?.Trim();
                        if (string.IsNullOrEmpty(fPath))
                        {
                            continue;
                        }
                        if (fPath.StartsWith($"{DQ}", StringComparison.InvariantCulture) &&
                            fPath.EndsWith($"{DQ}", StringComparison.InvariantCulture))
                        {
                            fPath = fPath.Substring(1, fPath.Length - 2);
                        }

                        _processedScenes.Add(fPath);
                    }
                }
            }

            Logger.LogDebug($"ProcessedScenes: \n\t{string.Join("\n\t", _processedScenes.ToArray())}");

            Logger.LogInfoMessage($"Dumping {scenes.Count} scenes to {outputFile}");

            using (var writer = new StreamWriter(outputFile, append, Encoding.UTF8))
            {
                var line = new List <string>();
                var i    = 0;
                foreach (var pth in scenes)
                {
                    ResetHspe();
                    i++;
                    var displayPath = PrepPath(pth);
                    //writer.Write($"{q}{displayPath}{q}");
                    if (_processedScenes.Contains(displayPath))
                    {
                        continue;
                    }

                    line.Clear();
                    line.Add(displayPath);
                    try
                    {
                        var names = ProcessScene(pth);
                        line.AddRange(names);

                        /*
                         *  foreach (string name in names.Distinct().OrderBy(a => a))
                         *  {
                         *      writer.Write($",{q}{name}{q}");
                         *  }
                         */
                        Logger.LogDebug($"finished {displayPath} ({i}/{scenes.Count})");
                    }
                    catch (Exception err)
                    {
                        //writer.Write($",{q}ERROR PROCESSING FILE{q}");
                        line.Add("ERROR PROCESSING FILE");
                        line.Add($"{err}".Replace(DQ, '\''));
                        Logger.LogException(err, $"${nameof(ExecuteDump)}: error processing {displayPath}");
                    }

                    writer.Write(DQ);
                    try
                    {
                        writer.Write(string.Join($"{DQ},{DQ}", line.ToArray()));
                    }
                    finally
                    {
                        writer.WriteLine(DQ);
                    }

                    _processedScenes.Add(displayPath);
                }
            }

            Logger.LogInfo($"Completed dumping {scenes.Count} scenes to {outputFile}");
            if (_resetHspeWrapper != null)
            {
                Logger.LogWarningMessage("Dump complete. Reset or load new scene before proceeding");
            }

            GeBoAPI.Instance.PlayNotificationSound(NotificationSound.Success);
        }