Example #1
0
        //! @cond NODOC
        /// Remove AudioSource not playing
        /// </summary>
        protected IEnumerator <float> ThreadDestroyAllVoice()
        {
            try
            {
                fluid_voice[] voicesList = GetComponentsInChildren <fluid_voice>();
                //Debug.LogFormat("DestroyAllVoice {0}", (voicesList != null ? voicesList.Length.ToString() : "no voice found"));

                if (voicesList != null)
                {
                    foreach (fluid_voice voice in voicesList)
                    {
                        try
                        {
                            // Debug.Log("Destroy " + voice.IdVoice + " " + (voice.Audiosource.clip != null ? voice.Audiosource.clip.name : "no clip"));
                            // Don't delete audio source template
                            if (voice.name.StartsWith("VoiceId_"))
                            {
                                Destroy(voice.gameObject);
                            }
                        }
                        catch (System.Exception ex)
                        {
                            MidiPlayerGlobal.ErrorDetail(ex);
                        }
                    }
                    Voices.Clear();
                }
                //audiosources = new List<AudioSource>();
            }
            catch (System.Exception ex)
            {
                MidiPlayerGlobal.ErrorDetail(ex);
            }
            yield return(0);
        }
Example #2
0
        private void LoadFile(string path)
        {
            try
            {
                x9aFile = ParseX9A(path);
            }
            catch (Exception ex)
            {
                TaskDialog taskDialog = new TaskDialog();

                taskDialog.MainIcon                = TaskDialogIcon.Error;
                taskDialog.Content                 = "X9A Editor cannot read this file, most likely because it was created using an unsupported CP88/CP73 firmware version.\r\n\r\nPlease report this issue on <a href=\"https://github.com/chausner/X9AEditor\">GitHub</a>.";
                taskDialog.ExpandedInformation     = ex.ToString();
                taskDialog.EnableHyperlinks        = true;
                taskDialog.AllowDialogCancellation = true;
                taskDialog.WindowTitle             = "Error opening file";
                taskDialog.Buttons.Add(new TaskDialogButton(ButtonType.Ok));
                taskDialog.HyperlinkClicked += (sender, e) => Process.Start(e.Href);

                taskDialog.ShowDialog();
                return;
            }

            LoadedFilePath = path;

            Voices.Clear();
            for (int i = 0; i < x9aFile.Voices.Length; i++)
            {
                Voices.Add(new VoiceViewModel((X9aFile.Voice)x9aFile.Voices[i].Clone(), (i / 8) + 1, (i % 8) + 1, this));
            }
        }
Example #3
0
 public void Clear()
 {
     IsUpdate  = false;
     VoiceType = PlayerInformation.Info.PType;
     BehType   = BehaviorType.None;
     Targets.Clear();
     Damages.Clear();
     Abnormals.Clear();
     IsHit.Clear();
     //IsDeath.Clear();
     KillList.Clear();
     Effects.Clear();
     Sounds.Clear();
     Voices.Clear();
     Messages.Clear();
 }
Example #4
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);
            }