Esempio n. 1
0
        private static void SelectCharasById(CharaId matchId)
        {
            var selected      = 0;
            var origCharCount = StudioAPI.GetSelectedCharacters().Count();
            var origObjCount  = StudioAPI.GetSelectedObjects().Count() - origCharCount;

            foreach (var objectCtrlInfo in StudioUtils.EnumerateObjects())
            {
                Logger.DebugLogDebug($"SelectCharasById: {objectCtrlInfo}");
                if (objectCtrlInfo is OCIChar ociChar)
                {
                    if (DoesCharaMatch(matchId, ociChar))
                    {
                        ociChar.MultiSelectInWorkarea();
                        selected++;
                    }
                    else
                    {
                        if (ociChar.IsSelectedInWorkarea())
                        {
                            ociChar.UnselectInWorkarea();
                        }
                    }
                }
                else
                {
                    objectCtrlInfo.UnselectInWorkarea();
                }
            }

            Logger.LogInfoMessage(
                $"characters selected: {selected} ({selected - origCharCount} new selections, {origObjCount} non-characters unselected)");
            GeBoAPI.Instance.PlayNotificationSound(NotificationSound.Success);
        }
Esempio n. 2
0
        private void NavigateScene(int offset)
        {
            var navigated = false;

            if (_navigationInProgress)
            {
                return;
            }

            _navigationInProgress = true;
            Logger.LogDebug($"Attempting navigate to scene: {offset:+#;-#;0}");
            try
            {
                var paths = NormalizedScenePaths;
                var index = -1;
                if (!_currentScenePath.IsNullOrEmpty() && !paths.IsNullOrEmpty())
                {
                    index = paths.IndexOf(_currentScenePath);
                }

                if (index == -1)
                {
                    if (!paths.IsNullOrEmpty())
                    {
                        Logger.LogDebug(
                            $"Folder changed, resuming navigation for: {PathUtils.GetRelativePath(SceneUtils.StudioSceneRootFolder, _currentSceneFolder)}");
                        if (LoadLastLoadedScene())
                        {
                            navigated = true;
                        }
                    }
                }
                else
                {
                    string nextImage = null;
                    while (nextImage is null)
                    {
                        index -= offset;
                        if (index < 0 || index >= paths.Count)
                        {
                            Logger.LogInfoMessage("No further scenes to navigate to.");
                            return;
                        }

                        nextImage = paths[index];
                        if (IsSceneValid(nextImage))
                        {
                            continue;
                        }

                        Logger.LogWarningMessage($"Skipping invalid scene file: {nextImage}");
                        nextImage = null;
                    }

                    var coroutines = GeBoCommon.Utilities.ListPool <IEnumerator> .Get();

                    try
                    {
                        coroutines.Add(CoroutineUtils.CreateCoroutine(
                                           () => Logger.LogInfoMessage(
                                               $"Loading scene {paths.Count - index}/{paths.Count} ('{PathUtils.GetRelativePath(SceneUtils.StudioSceneRootFolder, nextImage)}')")));
                        coroutines.Add(LoadScene(nextImage));

                        StartCoroutine(CoroutineUtils.ComposeCoroutine(coroutines.ToArray()));
                    }
                    finally
                    {
                        GeBoCommon.Utilities.ListPool <IEnumerator> .Release(coroutines);
                    }

                    navigated = true;
                }
            }
            catch (Exception err)
            {
                Logger.LogException(err, this, nameof(NavigateScene));
            }
            finally
            {
                // error encountered during navigation
                if (!navigated)
                {
                    _navigationInProgress = false;
                    PlayNotificationSound(NotificationSound.Error);
                }
            }

            if (navigated)
            {
                _setPage = true;
            }
        }
Esempio n. 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);
        }