public void CreateSentence() { List <HO> temp = new List <HO>(); while (m_LeftBoxHO.Count > 0 && m_LeftBoxHO[0].m_Index <= m_LeftBoxCurrentItem.m_Index) { temp.Add(m_LeftBoxHO[0]); m_LeftBoxHO.RemoveAt(0); } if (temp.Count > 0) { CleanSentence cs = new CleanSentence(); cs.m_Index = m_Sentences.Count + 1; cs.m_StartTime = temp[0].m_StartTime; cs.m_EndTime = temp[temp.Count - 1].m_StartTime; cs.m_HOList = temp; List <CO> coList = new List <CO>(); for (int i = 0; i < cs.m_HOList.Count; i++) { CO co = new CO(); co.m_Index = i + 1; co.m_CliciTimes = 1; co.m_Position = cs.m_HOList[i].m_Position; coList.Add(co); } cs.m_COList = coList; m_Sentences.Add(cs); } CreateLeftBoxScrollViewContent(); CreateSentenceBoxContent(); }
void DestroyLastSentenceProcess() { if (m_Sentences.Count > 0) { CleanSentence cs = m_Sentences[m_Sentences.Count - 1]; for (int i = cs.m_HOList.Count - 1; i >= 0; i--) { m_LeftBoxHO.Insert(0, cs.m_HOList[i]); } m_Sentences.Remove(cs); if (cs.m_Index == m_CurrentSelectSentence.m_Index) { m_CurrentSelectSentence = null; ClearSentenceContentBox(); } } }
void LoadFile() { m_CurrentSongName = m_DropDown.options[m_DropDown.value].text; TextAsset sentences = null; string filePath = GetPathString(m_CurrentSongName + "_temp.txt"); if (File.Exists(filePath)) { AssetBundle bundle = AssetBundle.LoadFromFile(filePath); sentences = bundle.LoadAsset <TextAsset>(m_CurrentSongName + "OSU"); } else { LogManager.LogError(m_CurrentSongName, ".txt 文件没有找到!!"); return; } m_Sentences.Clear(); ClearAllContent(); string[] contents = sentences.text.Split('\n'); for (int i = 0; i < contents.Length; i++) { string parseContent = contents[i].Trim(); string[] firstSplit = parseContent.Split(','); CleanSentence cs = new CleanSentence(); cs.m_StartTime = int.Parse(firstSplit[0]); cs.m_EndTime = int.Parse(firstSplit[1]); cs.m_Index = i + 1; string[] readWords = firstSplit[2].Split('$'); string[] showWords = firstSplit[3].Split('$'); Dictionary <string, string> wordMap = new Dictionary <string, string>(); for (int j = 0; j < readWords.Length; j++) { string originWord = readWords[j]; string originShowWord = showWords[j]; string word = ""; string showWord = ""; if (originWord.Contains("|")) {//tic word string[] splits = originWord.Split('|'); word = splits[0]; showWord = originShowWord.Split('|')[0]; } else { word = originWord; showWord = originShowWord; } if (!wordMap.ContainsKey(word)) { wordMap.Add(word, showWord); } cs.m_WordMap = wordMap; } } CreateSentenceContent(); }