private void SetCharacterAndDelivery(Block block, Character selectedCharacter, Delivery selectedDelivery)
        {
            if (CharacterVerseData.IsCharacterUnclear(selectedCharacter.CharacterId))
            {
                throw new ArgumentException("Character cannot be confirmed as ambigous or unknown.", "selectedCharacter");
            }
            // If the user sets a non-narrator to a block we marked as narrator, we want to track it
            if (!selectedCharacter.IsNarrator && !block.IsQuote)
            {
                Analytics.Track("NarratorToQuote", new Dictionary <string, string>
                {
                    { "book", CurrentBookId },
                    { "chapter", block.ChapterNumber.ToString(CultureInfo.InvariantCulture) },
                    { "initialStartVerse", block.InitialStartVerseNumber.ToString(CultureInfo.InvariantCulture) },
                    { "lastVerse", block.LastVerseNum.ToString(CultureInfo.InvariantCulture) },
                    { "character", selectedCharacter.CharacterId }
                });
            }

            if (selectedCharacter.ProjectSpecific || selectedDelivery.ProjectSpecific)
            {
                AddRecordToProjectCharacterVerseData(block, selectedCharacter, selectedDelivery);
            }

            SetCharacter(block, selectedCharacter);

            block.Delivery = selectedDelivery.IsNormal ? null : selectedDelivery.Text;
        }
        private void InsertHeSaidText(IReferenceLanguageInfo referenceLanguageInfo, int i, Action <int, int, string> handleHeSaidInserted, int level = 0)
        {
            var block = CorrelatedBlocks[i];

            if (block.CharacterIs(BookId, CharacterVerseData.StandardCharacter.Narrator) ||
                block.CharacterIsUnclear)
            {
                var existingEmptyVerseRefText = block.GetEmptyVerseReferenceTextAtDepth(level);
                if (existingEmptyVerseRefText != null)
                {
                    var narrator = CharacterVerseData.GetStandardCharacterId(BookId, CharacterVerseData.StandardCharacter.Narrator);
                    if (block.CharacterIsUnclear)
                    {
                        block.SetNonDramaticCharacterId(narrator);
                    }
                    // Deal with following blocks in quote block chain (and mark this one None).
                    if (block.MultiBlockQuote == MultiBlockQuote.Start)
                    {
                        for (int iCont = i + 1; iCont < CorrelatedBlocks.Count; iCont++)
                        {
                            var contBlock = CorrelatedBlocks[iCont];
                            if (contBlock.MultiBlockQuote != MultiBlockQuote.Continuation)
                            {
                                break;
                            }
                            contBlock.MultiBlockQuote = MultiBlockQuote.None;
                            // It's probably impossible in practice, but if this block has a character other than narrator already set,
                            // let's leave it as is. And, of course, if it's already explicitly set to narrator, then there's nothing to
                            // do.
                            if (contBlock.CharacterIsUnclear)
                            {
                                // By far the common case will be that this block will be associated with a reference
                                // block that has a real character ID. If so, we'll use that ID, even if it's not
                                // narrator because it's better not to have weird UI changes (that might be scrolled off
                                // the screen) that the user won't be able to account for. But in the unusual case where
                                // the vernacular block was unknown/ambiguous and it didn't align to a real ref block (so
                                // we just made up an empty one on the fly), it's probably best to go ahead and assume
                                // that any such continuation blocks are to be assigned to the narrator. In that case,
                                // we need to fire the handler to alert the client.
                                var dataChange     = false;
                                var newCharacterId = contBlock.ReferenceBlocks.SingleOrDefault()?.CharacterId;
                                if (CharacterVerseData.IsCharacterUnclear(newCharacterId))
                                {
                                    newCharacterId = narrator;
                                    dataChange     = true;
                                }
                                contBlock.SetNonDramaticCharacterId(newCharacterId);
                                if (dataChange)
                                {
                                    handleHeSaidInserted(iCont, level, null);
                                }
                            }
                        }
                        block.MultiBlockQuote = MultiBlockQuote.None;
                    }
                    var text = existingEmptyVerseRefText + referenceLanguageInfo.HeSaidText;
                    if (i < CorrelatedBlocks.Count - 1 && !CorrelatedBlocks[i + 1].IsParagraphStart)
                    {
                        text += referenceLanguageInfo.WordSeparator;
                    }
                    SetReferenceText(i, text, level);
                    handleHeSaidInserted(i, level, text);
                }
                if (referenceLanguageInfo.HasSecondaryReferenceText)
                {
                    InsertHeSaidText(referenceLanguageInfo.BackingReferenceLanguage, i, handleHeSaidInserted, level + 1);
                }
            }
        }
Example #3
0
 public bool CharacterIsUnclear()
 {
     return(CharacterVerseData.IsCharacterUnclear(CharacterId));
 }