示例#1
0
        private void SetXML(VoiceList vl, string file)
        {
            VoiceList t1;

            if (File.Exists(file))
            {
                using (FileStream fileStream = new FileStream(file, FileMode.Open))
                    t1 = Voices.Util.Deserialise <VoiceList>((Stream)fileStream);
            }
            else
            {
                t1 = new VoiceList()
                {
                    Entries = new List <VoiceEntry>()
                }
            };
            fTools.DummyEntries t2 = new fTools.DummyEntries()
            {
                Entries = new List <VoiceEntry>()
            };
            foreach (VoiceEntry entry in vl.Entries)
            {
                VoiceEntry e          = entry;
                VoiceEntry voiceEntry = t1.Entries.Find((Predicate <VoiceEntry>)(ve => ve.DID == e.DID && (ve.SID ?? string.Empty).Equals(e.SID ?? string.Empty)));
                if (voiceEntry != null)
                {
                    voiceEntry.Dialogue = e.Dialogue;
                }
                else if (e.Dialogue.Contains <char>('“'))
                {
                    t1.Entries.Add(e);
                }
                else
                {
                    t2.Entries.Add(e);
                }
            }
            using (FileStream fileStream = new FileStream(file, FileMode.Create))
                Voices.Util.Serialise <VoiceList>(t1, (Stream)fileStream);
            if (!t2.Entries.Any <VoiceEntry>())
            {
                return;
            }
            XmlDocument xmlDocument1 = new XmlDocument();

            xmlDocument1.Load(file);
            MemoryStream memoryStream = new MemoryStream();

            Voices.Util.Serialise <fTools.DummyEntries>(t2, (Stream)memoryStream);
            memoryStream.Position = 0L;
            XmlDocument xmlDocument2 = new XmlDocument();

            xmlDocument2.Load((Stream)memoryStream);
            string     data    = "The following entries don't look like dialogue. You can uncomment them if they are needed.\n\n\t" + xmlDocument2.SelectSingleNode("/DummyEntries").InnerXml.Replace("--", "~~").Replace("<Entry", "\n\t<Entry") + "\n";
            XmlComment comment = xmlDocument1.CreateComment(data);

            xmlDocument1.SelectSingleNode("/VoiceList").AppendChild((XmlNode)comment);
            xmlDocument1.Save(file);
        }
        public async Task <IVoice> DefaultVoice()
        {
            VoiceList = await SelectedProvider.GetVoicesAsync();

            var lastUsedVoice = VoiceList.FirstOrDefault(voice => Settings.Default.LastVoice == voice.Name);

            return(lastUsedVoice ?? VoiceList.First());
        }
示例#3
0
        private void DoExtract(string input, string output)
        {
            VoiceIndex t = new VoiceIndex()
            {
                Entries = new List <IndexEntry>()
            };

            if (!File.Exists(Path.Combine(input, "maplist")))
            {
                MessageBox.Show("This FLevel is missing the maplist file");
                return;
            }
            using (FileStream fileStream1 = new FileStream(Path.Combine(input, "maplist"), FileMode.Open))
            {
                ushort num1     = Voices.Util.ReadUShortFrom((Stream)fileStream1, 0);
                byte[] numArray = new byte[32];
                foreach (int num2 in Enumerable.Range(0, (int)num1))
                {
                    fileStream1.Position = (long)(2 + 32 * num2);
                    fileStream1.Read(numArray, 0, 32);
                    string str  = Encoding.ASCII.GetString(numArray).Trim().TrimEnd(new char[1]);
                    string path = Path.Combine(input, str);
                    if (File.Exists(path))
                    {
                        using (FileStream fileStream2 = new FileStream(path, FileMode.Open))
                        {
                            VoiceList vl = Dumper.Dump((Stream)fileStream2, str);
                            if (vl != null)
                            {
                                string file = Path.Combine(output, str + ".xml");
                                this.SetXML(vl, file);
                            }
                            else
                            {
                                continue;
                            }
                        }
                        t.Entries.Add(new IndexEntry()
                        {
                            File    = str + ".xml",
                            FieldID = num2
                        });
                    }
                    System.Diagnostics.Debug.WriteLine("Processed " + str);
                }
            }
            using (FileStream fileStream = new FileStream(Path.Combine(output, "index.xml"), FileMode.Create))
                Voices.Util.Serialise <VoiceIndex>(t, (Stream)fileStream);
        }
	public void LinkFrom(ScriptedObjectInfo info){
		// 	initialize members from deserialized info
		gameObject.name = info.unityObjectName;
		moveToParentOnDrop = info.moveToParentOnDrop; // set this in each prefab, but false so constructed ones dont
		dropTargetName = info.dropTargetName;

		// don't process the scripts in this method
		
		register = info.register; // instead, derive this from any contained scripts who listen to status messages
		prettyname = info.prettyname; // this was on the OI class, we shouldnt need it here
		XMLName = info.XMLName;
		XMLDirectory = info.XMLDirectory;
		assetBundleInfo = info.assetBundleInfo;
		voiceList = info.voiceList;
		voiceLists = info.voiceLists;
		vitalsBehaviors = info.vitalsBehaviors;
		scanRecords = info.scanRecords;
		
	}
	public void InitFrom(ScriptedObjectInfo info){
		// we should probably destroy any existing hierarchy here, calling OnDestroy() on our children;
		
		// 	initialize members from deserialized info
		gameObject.name = info.unityObjectName;
		
		moveToParentOnDrop = info.moveToParentOnDrop; // set this in each prefab, but false so constructed ones dont
		dropTargetName = info.dropTargetName;
		// make children from all the scriptInfos, and init each one from it's info, which will build the Actions
		scripts = new InteractionScript[info.scripts.Length];
		for (int i = 0; i<info.scripts.Length; i++){
			GameObject go = new GameObject(info.scripts[i].unityObjectName);
			go.transform.parent = this.transform;
			scripts[i] = go.AddComponent("InteractionScript") as InteractionScript;
			scripts[i].InitFrom(info.scripts[i]);	
		}
		if (info.startupScriptName != null && info.startupScriptName != ""){
			for (int i = 0; i<scripts.Length; i++){
				if (scripts[i].name == info.startupScriptName){
					startupScript = scripts[i];
					break;
				}
			}
		}
		
		register = info.register; // instead, derive this from any contained scripts who listen to status messages
		prettyname = info.prettyname; // this was on the OI class, we shouldnt need it here
		XMLName = info.XMLName;
		XMLDirectory = info.XMLDirectory;
		assetBundleInfo = info.assetBundleInfo;
		voiceList = info.voiceList;
		voiceLists = info.voiceLists;
		vitalsBehaviors = info.vitalsBehaviors;
		scanRecords = info.scanRecords;
	}
示例#6
0
	public void AddVoiceList(VoiceList list){
		if (list == null) return;
		
		VoiceList oldList = FindList(list.Name);
		if (oldList != null){
			foreach (VoiceMap map in list.VoiceMaps){
				// replace any existing map by the same Name
				VoiceMap oldMap = null;
                for(int i = 0; i< oldList.VoiceMaps.Count; i++) // need to go thru by index so we can replace
                {
                    if (map.Tag == oldList.VoiceMaps[i].Tag){
                        oldMap = oldList.VoiceMaps[i];
						oldList.VoiceMaps[i] = map;
						break;
					}
                }				
				if (oldMap == null){
					oldList.VoiceMaps.Add(map);
				}
			}
		}
		else
			VoiceLists.Add(list);
	}