Beispiel #1
0
        private static void ProcessTextBlock(List <string> data)
        {
            var split   = data[0].Split(' ');
            var length1 = int.Parse(split[1]);
            var length2 = int.Parse(split[2]);

            var line = 1;
            var pos  = 0;

            var sb1 = new StringBuilder();

            for (var i = 0; i < length1; i++)
            {
                if (pos == data[line].Length)
                {
                    sb1.Append('\n');
                    line++;
                    pos = 0;
                }
                else
                {
                    sb1.Append(data[line][pos]);
                    pos++;
                }
            }

            var sb2 = new StringBuilder();

            for (var i = 0; i < length2; i++)
            {
                if (pos == data[line].Length)
                {
                    sb2.Append('\n');
                    line++;
                    pos = 0;
                }
                else
                {
                    sb2.Append(data[line][pos]);
                    pos++;
                }
            }

            DoomString.Replace(sb1.ToString(), sb2.ToString());
        }
Beispiel #2
0
        private static void ProcessBexStringsBlock(List <string> data)
        {
            string        name = null;
            StringBuilder sb   = null;

            foreach (var line in data.Skip(1))
            {
                if (name == null)
                {
                    var eqPos = line.IndexOf('=');
                    if (eqPos != -1)
                    {
                        var left  = line.Substring(0, eqPos).Trim();
                        var right = line.Substring(eqPos + 1).Trim().Replace("\\n", "\n");
                        if (right.Last() != '\\')
                        {
                            DoomString.ReplaceByName(left, right);
                        }
                        else
                        {
                            name = left;
                            sb   = new StringBuilder();
                            sb.Append(right, 0, right.Length - 1);
                        }
                    }
                }
                else
                {
                    var value = line.Trim().Replace("\\n", "\n");;
                    if (value.Last() != '\\')
                    {
                        sb.Append(value);
                        DoomString.ReplaceByName(name, sb.ToString());
                        name = null;
                        sb   = null;
                    }
                    else
                    {
                        sb.Append(value, 0, value.Length - 1);
                    }
                }
            }
        }