예제 #1
0
파일: KKLabelGroup.cs 프로젝트: RedXVII/kkt
 public void Append(KKLine line)
 {
     Lines.Add(line);
 }
예제 #2
0
파일: KKFile.cs 프로젝트: RedXVII/kkt
        public bool LoadFromKK(string filePath)
        {
            if (KKLabelGroups == null)
            {
                KKLabelGroups = new List<KKLabelGroup>();
            }

            KKOutputFile outputFile = new KKOutputFile() { FileName = System.IO.Path.GetFileName(filePath) };
            outputFile.Labels = new List<KKLabelGroup>();

            var lines = File.ReadLines(filePath, System.Text.Encoding.GetEncoding(932)); //SHIFT-JIS
            int lineNumber = 1;

            KKLabelGroup currentGroup = null;

            foreach (var rawLine in lines)
            {
                string line = rawLine;

                KKLine newLine = new KKLine(lineNumber, line);

                if (!string.IsNullOrEmpty(newLine.Label))
                {
                    if (currentGroup != null)
                    {
                        currentGroup.Compute();
                        outputFile.Labels.Add(currentGroup);
                    }
                    currentGroup = new KKLabelGroup(newLine.Label);
                }

                if (currentGroup != null)
                {
                    currentGroup.Append(newLine);
                }

                lineNumber++;
            }
            if (currentGroup != null)
            {
                currentGroup.Compute();
                outputFile.Labels.Add(currentGroup);
            }

            var newChoices = LoadChoicesFromLabels(outputFile.Labels);

            KKOutputFiles.Add(outputFile);
            KKLabelGroups.AddRange(outputFile.Labels);
            KKChoices.AddRange(newChoices);
            RefreshNameTags();

            _KKLabelGroupsToTranslateCache = null;
            RefreshChapterNames();

            return true;
        }