Exemple #1
0
            public Message Build()
            {
                //if (!HasMessage)
                //	throw new Exception();
                var voices = Voices.ToList();

                voices.Sort(CompareVoiceIds);
                string  novelId = (IsNovel ? "novel   " : string.Empty);
                string  nameId  = string.Join("", Names.Select(n => n.Content));
                string  voiceId = string.Join(" ", voices.Select(ToVoiceId));
                string  groupId = $"{novelId}{nameId}  {voiceId}";
                Message m       = new Message {
                    GroupId  = groupId,
                    Script   = Script,
                    Names    = Names.ToImmutableArrayLW(),
                    Messages = Messages.ToImmutableArrayLW(),
                    Voices   = Voices.ToImmutableArrayLW(),
                };

                Names.Clear();
                Messages.Clear();
                Voices.Clear();
                string msg = m.CreateMessage().Message;

                if (msg.Length == 0 || msg == "\n")
                {
                    return(null);
                }
                if (msg == new string('.', msg.Length))
                {
                    return(null);
                }
                if (JpUtils.Check(msg))
                {
                    return(null);
                }
                return(m);
            }
Exemple #2
0
        /*private void ReadNovelRanges(List<NovelRange> novelRanges) {
         *      NovelCommand on = null;
         *      for (int i = 0; i < Script.Count; i++) {
         *              if (Script.Lines[i] is NovelCommand novel) {
         *                      if (on == null && novel.State) {
         *                              on = novel;
         *                      }
         *                      else if (on != null && !novel.State) {
         *                              novelRanges.Add(new NovelRange(on, novel));
         *                              on = null;
         *                      }
         *              }
         *      }
         *      if (on != null)
         *              novelRanges.Add(new NovelRange(on));
         * }*/

        private void ReadScene(List <Message> messages, List <Choice> choices)
        {
            bool mesdraw = true;
            bool novel   = false;

            Message.Builder msgBuilder = new Message.Builder(this);
            for (int i = 0; i < Script.Count; i++)
            {
                ISceneLine line = Script.Lines[i];
                switch (line)
                {
                case ScenePage _:
                case SceneInput _:
                    if (msgBuilder.HasMessage)
                    {
                        Message msg = msgBuilder.Build();
                        if (mesdraw && msg != null)
                        {
                            messages.Add(msg);
                        }
                    }
                    break;

                case NovelCommand novelCmd:
                    novel = novelCmd.State;
                    msgBuilder.IsNovel = novelCmd.State;
                    break;

                case MesdrawCommand mesdrawCmd:
                    mesdraw = mesdrawCmd.State;
                    break;

                case SceneName name:
                    msgBuilder.Names.Add(name);
                    break;

                case SceneMessage message:
                    msgBuilder.Messages.Add(message);
                    break;

                case SoundPlayCommand play:
                    if (play.SoundType == SoundType.Pcm)
                    {
                        msgBuilder.Voices.Add(play);
                    }
                    break;

                case ConditionCommand condition:
                    if (condition.Command is SoundPlayCommand conPlay && conPlay.SoundType == SoundType.Pcm)
                    {
                        Console.WriteLine(condition.Content);
                    }
                    break;

                case ChoiceCommand choice:
                    if (!JpUtils.Check(choice.ChoiceContent))
                    {
                        choices.Add(new Choice(this, choice));
                    }
                    else
                    {
                        Console.WriteLine("");
                    }
                    break;
                }
            }
        }