static Byte[] UpdateScenarioFile(FileReader reader, String jsonpath, List <TextItem> stringtableitems)
        {
            Assert.IsNotNull(reader, nameof(reader));
            Assert.IsValidString(jsonpath, nameof(jsonpath));
            Assert.IsNotNull(stringtableitems, nameof(stringtableitems));

            var scenariofile = new ScenarioFile(reader);
            var textitems    = JsonTextItemFileIO.ReadFromFile(jsonpath);

            var scenariotext_index = 0;

            scenariofile.VisitOperands(x => x.Type == Bytecode.OperandType.String, x => new Bytecode.Operand(Bytecode.OperandType.String, textitems[scenariotext_index++].GetBestText()));

            var stringtable = scenariofile.GetStringTable();

            for (var i = 0; i != stringtable.Count; ++i)
            {
                var textitem = stringtableitems.FirstOrDefault(x => x.Text == stringtable[i]);
                if (textitem != null && textitem.Translation != "")
                {
                    stringtable[i] = textitem.Translation;
                }
            }

            scenariofile.UpdateStringTable(stringtable);

            scenariofile.Fix();

            return(scenariofile.Write(reader.Encoding));
        }
Esempio n. 2
0
        static Tuple <List <String>, List <String> > ReadScenarioFile(FileReader reader)
        {
            Assert.IsNotNull(reader, nameof(reader));

            var scenariofile = new ScenarioFile(reader);

            var stringlist = new List <String>();

            scenariofile.VisitOperands(x => x.Type == Bytecode.OperandType.String, x => stringlist.Add(x.GetValue <String>()));

            var stringtable = scenariofile.GetStringTable();

            return(Tuple.Create(stringlist, stringtable));
        }