Beispiel #1
0
 public void Append(KKLine line)
 {
     Lines.Add(line);
 }
Beispiel #2
0
        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;
        }