示例#1
0
        private HashSet <string> GetMatchingCharacterIds(string textToFind)
        {
            HashSet <string> matchingCharacterIds;

            if (!m_findTextToMatchingCharacterIds.TryGetValue(textToFind, out matchingCharacterIds))
            {
                if (CharacterDetailData.Singleton.GetAll().Count() !=
                    CharacterVerseData.SingletonLocalizedCharacterIdToCharacterIdDictionary.Count)
                {
                    // First time getting UI versions of character IDs (typically when running tests), so we need to force
                    // population of CharacterVerseData.SingletonLocalizedCharacterIdToCharacterIdDictionary.
                    foreach (var characterId in CharacterGroups.SelectMany(characterGroup => characterGroup.CharacterIds))
                    {
                        CharacterVerseData.GetCharacterNameForUi(characterId);
                    }
                }
                matchingCharacterIds = new HashSet <string>();
                m_findTextToMatchingCharacterIds.Add(textToFind, matchingCharacterIds);
                foreach (var kvp in CharacterVerseData.SingletonLocalizedCharacterIdToCharacterIdDictionary)
                {
                    if (kvp.Value.IndexOf(textToFind, StringComparison.OrdinalIgnoreCase) >= 0)
                    {
                        matchingCharacterIds.Add(kvp.Key);
                    }
                }
            }
            return(matchingCharacterIds);
        }
        public bool MoveCharactersToGroup(IList <string> characterIds, CharacterGroup destGroup, bool warnUserAboutProximity = false)
        {
            CharacterGroup sourceGroup = GetSourceGroupForMove(characterIds, destGroup);

            if (sourceGroup == null)
            {
                return(false);
            }

            if (destGroup != null && warnUserAboutProximity && destGroup.CharacterIds.Count > 0)
            {
                var proximity = new Proximity(m_project.IncludedBooks, m_project.DramatizationPreferences);

                var testGroup       = new CharacterIdHashSet(destGroup.CharacterIds);
                var resultsBefore   = proximity.CalculateMinimumProximity(testGroup);
                int proximityBefore = resultsBefore.NumberOfBlocks;

                testGroup.AddRange(characterIds);
                var resultsAfter   = proximity.CalculateMinimumProximity(testGroup);
                int proximityAfter = resultsAfter.NumberOfBlocks;

                if (proximityBefore > proximityAfter && proximityAfter <= Proximity.kDefaultMinimumProximity)
                {
                    var firstReference  = resultsAfter.FirstReference;
                    var secondReference = resultsAfter.SecondReference;

                    var dlgMessageFormat1 = (firstReference == secondReference) ?
                                            LocalizationManager.GetString("DialogBoxes.VoiceActorAssignmentDlg.MoveCharacterDialog.Message.Part1",
                                                                          "This move will result in a group with a minimum proximity of {0} blocks between [{1}] and [{2}] in {3}.") :
                                            LocalizationManager.GetString("DialogBoxes.VoiceActorAssignmentDlg.MoveCharacterDialog.Message.Part1",
                                                                          "This move will result in a group with a minimum proximity of {0} blocks between [{1}] in {3} and [{2}] in {4}.");
                    dlgMessageFormat1 = string.Format(dlgMessageFormat1,
                                                      resultsAfter.NumberOfBlocks,
                                                      CharacterVerseData.GetCharacterNameForUi(resultsAfter.FirstCharacterId),
                                                      CharacterVerseData.GetCharacterNameForUi(resultsAfter.SecondCharacterId),
                                                      firstReference, secondReference);
                    var dlgMessageFormat2 =
                        LocalizationManager.GetString("DialogBoxes.VoiceActorAssignmentDlg.MoveCharacterDialog.Message.Part2",
                                                      "Do you want to continue with this move?");

                    var dlgMessage = string.Format(dlgMessageFormat1 + Environment.NewLine + Environment.NewLine + dlgMessageFormat2);
                    var dlgTitle   = LocalizationManager.GetString("DialogBoxes.VoiceActorAssignmentDlg.MoveCharacterDialog.Title",
                                                                   "Confirm");

                    if (MessageBox.Show(dlgMessage, dlgTitle, MessageBoxButtons.YesNo) != DialogResult.Yes)
                    {
                        return(false);
                    }
                }
            }

            m_undoStack.Push(new MoveCharactersToGroupUndoAction(m_project, sourceGroup, destGroup, characterIds));

            Save();

            return(true);
        }
 public void FilterCharacterIds(string match)
 {
     m_filteredCharacters = new List <CharacterDetail>();
     foreach (var character in m_availableCharacters)
     {
         var charName = CharacterVerseData.GetCharacterNameForUi(character.CharacterId);
         if (charName.IndexOf(match, StringComparison.OrdinalIgnoreCase) >= 0)
         {
             m_filteredCharacters.Add(character);
         }
     }
 }
示例#4
0
        internal static List <object> GetExportDataForBlock(Block block, int blockNumber, string bookId,
                                                            VoiceActor.VoiceActor voiceActor, string singleVoiceNarratorOverride, bool useCharacterIdInScript, bool includeSecondaryDirectorsGuide)
        {
            // NOTE: if the order here changes, there may be changes needed in GenerateExcelFile
            List <object> list = new List <object>();

            list.Add(blockNumber);
            if (voiceActor != null)
            {
                list.Add(voiceActor.Name);
            }
            list.Add(block.StyleTag);
            list.Add(bookId);
            list.Add(block.ChapterNumber);
            list.Add(block.InitialVerseNumberOrBridge);
            string characterId;

            if (singleVoiceNarratorOverride != null)
            {
                characterId = singleVoiceNarratorOverride;
            }
            else
            {
                characterId = useCharacterIdInScript ? block.CharacterIdInScript : block.CharacterId;
            }
            list.Add(CharacterVerseData.IsCharacterStandard(characterId) ? CharacterVerseData.GetStandardCharacterIdAsEnglish(characterId) : characterId);

            // add a column for the localized character id
            if (LocalizationManager.UILanguageId != "en")
            {
                list.Add(CharacterVerseData.GetCharacterNameForUi(characterId));
            }

            list.Add(block.Delivery);
            list.Add(block.GetText(true));
            list.Add(block.PrimaryReferenceText);
            if (includeSecondaryDirectorsGuide)
            {
                var primaryRefBlock = (block.MatchesReferenceText) ? block.ReferenceBlocks.Single() : null;
                if (primaryRefBlock != null && primaryRefBlock.MatchesReferenceText)
                {
                    list.Add(primaryRefBlock.PrimaryReferenceText);
                }
                else
                {
                    list.Add(null);
                }
            }
            list.Add(block.GetText(false).Length);
            return(list);
        }
 public string GetLocalizedCharacterId(int filteredCharacterIndex)
 {
     return(CharacterVerseData.GetCharacterNameForUi(GetCharacterId(filteredCharacterIndex)));
 }
示例#6
0
 public CharacterIds(string characterId)
 {
     CharacterId          = characterId;
     LocalizedCharacterId = CharacterVerseData.GetCharacterNameForUi(characterId);
 }
        public bool MoveCharactersToGroup(IList <string> characterIds, CharacterGroup destGroup, bool warnUserAboutProximity = false)
        {
            CharacterGroup sourceGroup = GetSourceGroupForMove(characterIds, destGroup);

            if (sourceGroup == null)
            {
                return(false);
            }

            if (destGroup != null && warnUserAboutProximity && destGroup.CharacterIds.Count > 0)
            {
                var testGroup     = new CharacterIdHashSet(destGroup.CharacterIds);
                var resultsBefore = ProjectProximity.CalculateMinimumProximity(testGroup);

                testGroup.AddRange(characterIds);
                var resultsAfter = ProjectProximity.CalculateMinimumProximity(testGroup);

                if (resultsBefore.IsBetterThan(resultsAfter) && !resultsAfter.IsAcceptable())
                {
                    var firstReference  = resultsAfter.FirstReference;
                    var secondReference = resultsAfter.SecondReference;

                    var dlgMessageFormat1 = (firstReference == secondReference) ?
                                            LocalizationManager.GetString("DialogBoxes.VoiceActorAssignmentDlg.MoveCharacterDialog.Message.Part1",
                                                                          "This move will result in the same voice actor speaking the parts of both [{1}] and [{2}] in {3}. This is not ideal. (Proximity: {0})") :
                                            LocalizationManager.GetString("DialogBoxes.VoiceActorAssignmentDlg.MoveCharacterDialog.Message.Part1",
                                                                          "This move will result in the same voice actor speaking the parts of both [{1}] in {3} and [{2}] in {4}. This is not ideal. (Proximity: {0})");
                    var dlgMessagePart1 = string.Format(dlgMessageFormat1,
                                                        resultsAfter.NumberOfBlocks,
                                                        CharacterVerseData.GetCharacterNameForUi(resultsAfter.FirstCharacterId),
                                                        CharacterVerseData.GetCharacterNameForUi(resultsAfter.SecondCharacterId),
                                                        firstReference, secondReference);

                    Logger.WriteEvent($"{dlgMessagePart1}\r\n>>>Moving {characterIds.Count} characters to group {destGroup.GroupId}:\r\n   {String.Join("\r\n   ", characterIds)}");

                    var dlgMessagePart2 =
                        LocalizationManager.GetString("DialogBoxes.VoiceActorAssignmentDlg.MoveCharacterDialog.Message.Part2",
                                                      "Do you want to continue with this move?");

                    var dlgMessage = dlgMessagePart1 + Environment.NewLine + Environment.NewLine + dlgMessagePart2;
                    var dlgTitle   = LocalizationManager.GetString("DialogBoxes.VoiceActorAssignmentDlg.MoveCharacterDialog.Title",
                                                                   "Confirm");

                    if (MessageBox.Show(dlgMessage, dlgTitle, MessageBoxButtons.YesNo) != DialogResult.Yes)
                    {
                        Logger.WriteEvent("User cancelled move of characters.");
                        return(false);
                    }
                }
                else
                {
                    LogAndOutputToDebugConsole($"Moving {characterIds.Count} character(s) to group {destGroup.GroupId} changed the " +
                                               $"proximity from {resultsBefore.NumberOfBlocks} to {resultsAfter.NumberOfBlocks}.");
                }
            }

            m_undoStack.Push(new MoveCharactersToGroupUndoAction(m_project, sourceGroup, destGroup, characterIds));

            Save();

            return(true);
        }