Exemplo n.º 1
0
        private DefaultChoiceElement CreateDefaultChoiceGUI(DialogueElement root, ConversationRow conversation,
                                                            ChoiceRow choice, IList <ContentElement> contents, string language)
        {
            var choiceElem = new DefaultChoiceElement();

            CreateChoiceContent(root.Header, choiceElem, conversation, choice, contents, language);

            root.Add(choiceElem);
            return(choiceElem);
        }
Exemplo n.º 2
0
        private ChoiceElement CreateChoiceGUI(VisualElement root, ConversationRow conversation,
                                              ChoiceRow choice, IList <ContentElement> contents, string language)
        {
            var choiceElem = new ChoiceElement();

            var idElem = new IdElement {
                value = choice.Id.ToString()
            };

            choiceElem.Header.Add(idElem);

            CreateChoiceContent(choiceElem.Header, choiceElem.Content, conversation, choice, contents, language);

            root.Add(choiceElem);
            return(choiceElem);
        }
Exemplo n.º 3
0
        private NovelAsset Parse(Parser <VsnRow> parser, string csvData, NovelAsset asset, List <string> languages)
        {
            var enumerator = parser.Parse(csvData).GetEnumerator();
            var row        = 0;
            var error      = string.Empty;
            var logger     = new StringBuilder();
            var goToList   = new List <string>();

            ConversationRow conversation = null;
            DialogueRow     dialogue     = null;

            while (enumerator.MoveNext())
            {
                if (!enumerator.Current.IsValid)
                {
                    error = enumerator.Current.Error.ToString();
                    break;
                }

                var vsnRow = enumerator.Current.Result;
                row = enumerator.Current.RowIndex + 1;

                (conversation, dialogue) = vsnRow.Parse(asset, conversation, dialogue, languages, row,
                                                        goToList, this.commandParser, this.intArrayParser, logger);

                if (vsnRow.IsError)
                {
                    error = vsnRow.Error;
                    break;
                }
            }

            if (!string.IsNullOrEmpty(error))
            {
                Debug.LogError($"Vsn row {row}: {error}");
                return(null);
            }

            if (logger.Length > 0)
            {
                Debug.LogError(logger);
            }

            return(asset);
        }
Exemplo n.º 4
0
        private ContentElement CreateContentGUI(VisualElement root, ConversationRow conversation,
                                                ChoiceRow choice, IList <ContentElement> contentElems, string language)
        {
            root.userData = conversation;
            var contentText = conversation.GetContent(choice.ContentId)?.GetLocalization(language);

            if (string.IsNullOrEmpty(contentText))
            {
                return(null);
            }

            var contentElem = new ContentElement {
                userData = choice.ContentId,
                value    = contentText
            };

            contentElems.Add(contentElem);
            root.Add(contentElem);
            return(contentElem);
        }
Exemplo n.º 5
0
        private void OnChangeLanguage(ChangeEvent <string> evt)
        {
            var contentsContainer = (evt.currentTarget as VisualElement).parent;

            if (!(contentsContainer.userData is List <ContentElement> contents))
            {
                return;
            }

            ConversationRow conversation = null;

            foreach (var content in contents)
            {
                if (!ReferenceEquals(conversation, content.parent.userData))
                {
                    conversation = content.parent.userData as ConversationRow;
                }

                var id = (int)content.userData;
                content.value = conversation?.GetContent(id)?.GetLocalization(evt.newValue) ?? string.Empty;
            }
        }
Exemplo n.º 6
0
        private ConversationElement CreateConversationGUI(VisualElement root, NovelAsset asset,
                                                          ConversationRow conversation)
        {
            var contentElems     = new List <ContentElement>();
            var conversationElem = new ConversationElement {
                userData = contentElems,
                text     = conversation.Id
            };

            var languages      = new List <string>(asset.Languages);
            var languagesPopup = new LanguagePopup("Language Id", languages, 0);

            languagesPopup.RegisterValueChangedCallback(OnChangeLanguage);
            conversationElem.Add(languagesPopup);

            foreach (var kv in conversation.Dialogues)
            {
                CreateDialogueGUI(conversationElem.Content, conversation, kv.Value, contentElems, languages[0]);
            }

            root.Add(conversationElem);
            return(conversationElem);
        }
Exemplo n.º 7
0
 public (ConversationRow, DialogueRow) Parse(INovelData data, ConversationRow conversation,
                                             DialogueRow dialogue, in Segment <string> languages, int row,
Exemplo n.º 8
0
        private DialogueElement CreateDialogueGUI(VisualElement root, ConversationRow conversation,
                                                  DialogueRow dialogue, IList <ContentElement> contents, string language)
        {
            var dialogueElem = new DialogueElement();

            var idElem = new IdElement {
                value = dialogue.Id
            };

            dialogueElem.Header.Add(idElem);

            var defaultChoiceData = dialogue.GetChoice(0);

            if (defaultChoiceData != null)
            {
                CreateDefaultChoiceGUI(dialogueElem, conversation, defaultChoiceData, contents, language);
            }

            if (dialogue.Choices.Count > 1)
            {
                var choiceContainer = new ChoiceContainer();
                choiceContainer.Add(new Label("Choices"));

                var first = true;

                foreach (var kv in dialogue.Choices)
                {
                    if (kv.Value.Id == 0)
                    {
                        continue;
                    }

                    var choiceElem = CreateChoiceGUI(choiceContainer, conversation, kv.Value, contents, language);

                    if (first)
                    {
                        first = false;
                        choiceElem.style.marginTop = 0;
                    }
                }

                dialogueElem.Add(choiceContainer);
            }

            if (!dialogue.IsEnd())
            {
                var sb        = new StringBuilder();
                var delayElem = new DelayElement("Delay")
                {
                    value = dialogue.Delay.ToString()
                };
                dialogueElem.Add(delayElem);

                var speakerElem = new SpeakerElement("Speaker")
                {
                    value = dialogue.Speaker
                };
                dialogueElem.Add(speakerElem);

                if (HasActors(dialogue))
                {
                    CreateCharacterTableGUI(dialogueElem, out var columnContainerElem);

                    CreateCharacterList <ActorColumnElement>(columnContainerElem, "Actor",
                                                             dialogue.Actor1, dialogue.Actor2, dialogue.Actor3, dialogue.Actor4);

                    CreateCharacterList <ActionColumnElement>(columnContainerElem, "Actions",
                                                              dialogue.Actions1.BuildString(sb), dialogue.Actions2.BuildString(sb),
                                                              dialogue.Actions3.BuildString(sb), dialogue.Actions4.BuildString(sb));
                }

                var highlightElem = new HighlightElement("Highlight")
                {
                    value = dialogue.Highlight.BuildString(sb)
                };
                dialogueElem.Add(highlightElem);
            }

            if (dialogue.CommandsOnStart.Count > 0 ||
                dialogue.CommandsOnEnd.Count > 0)
            {
                CreateCommandTableGUI(dialogueElem, dialogue.CommandsOnStart, dialogue.CommandsOnEnd);
            }

            root.Add(dialogueElem);
            return(dialogueElem);
        }
Exemplo n.º 9
0
 private void CreateChoiceContent(VisualElement header, VisualElement content, ConversationRow conversation,
                                  ChoiceRow choice, IList <ContentElement> contents, string language)
 {
     CreateContentGUI(header, conversation, choice, contents, language);
     CreateGoToGUI(content, choice);
 }