Example #1
0
        public virtual void GetTranslationStats(ref List <TranslationStatEntry> stats)
        {
            Console.WriteLine("Calculating Translation Statistic for " + AssetName);
            SpreadsheetsResource.GetRequest request = GoogleSheetConnector.GetInstance().Service.Spreadsheets.Get(SheetId);
            request.Ranges          = SheetRange;
            request.IncludeGridData = true;
            Spreadsheet      sheet = request.Execute();
            IList <GridData> grid  = sheet.Sheets[0].Data;
            //Getting each range (should only be one)
            AssetEntry tmpEntry = new AssetEntry(VariableDefinitions);

            foreach (GridData gridData in grid)
            {
                //For each row
                foreach (var row in gridData.RowData)
                {
                    SheetCellWithColor[] rowRaw = new SheetCellWithColor[row.Values.Count];
                    for (int i = 0; i < row.Values.Count; i++)
                    {
                        rowRaw[i] = new SheetCellWithColor(row.Values[i]);
                    }

                    tmpEntry.CalculateTranslationStats(rowRaw, ref stats);
                }
            }
        }
Example #2
0
        public void AppendToFile(StreamWriter sw, AssetEntry thisEntry)
        {
            for (int i = 0; i < VariableDefinitions.Count; i++)
            {
                if (i > 0)
                {
                    sw.Write('\t');
                }
                Variables[i].AppendToFile(sw);
            }

            sw.Write('\r');
        }
        public override void BuildGameDataFromSheet(string outRootPath)
        {
            Console.WriteLine("Getting " + AssetName + " Spreadsheet content");

            SpreadsheetsResource.ValuesResource.GetRequest request = GoogleSheetConnector.GetInstance().Service.Spreadsheets.Values.Get(SheetId, SheetRange);
            ValueRange             response = request.Execute();
            List <IList <object> > values   = (List <IList <object> >)response.Values;
            List <AssetEntry>      patches  = new List <AssetEntry>();

            if (values != null && values.Count > 0)
            {
                foreach (var row in values)
                {
                    AssetEntry thisEntry = new AssetEntry(VariableDefinitions);
                    thisEntry.PopulateBySheetRow(row);
                    patches.Add(thisEntry);
                }
            }

            string cinameticFolder     = Environment.CurrentDirectory + Path.DirectorySeparatorChar + "Input" + Path.DirectorySeparatorChar + "cinematic";
            string outputFileDirectory = outRootPath + Path.DirectorySeparatorChar + "cinematic";

            if (!Directory.Exists(outputFileDirectory))
            {
                Directory.CreateDirectory(outputFileDirectory);
            }

            Console.WriteLine("Patching Cinematic files from " + cinameticFolder + " into " + outputFileDirectory);
            string[] files = Directory.GetFiles(cinameticFolder, "*.bytes");

            for (int i = 0; i < files.Length; i++)
            {
                Console.Title = "[" + AssetName + "] Processing " + i + "/" + files.Length;
                string filePath = files[i];
                string data     = File.ReadAllText(filePath);

                foreach (var patch in patches)
                {
                    data = data.Replace(patch.Variables[0].OriginalValue, patch.Variables[0].Translation);
                }

                string outFilePath = filePath.Replace(cinameticFolder, outputFileDirectory);
                outFilePath = outFilePath.Replace(".bytes", ".json");
                File.WriteAllText(outFilePath, data);
            }

            Console.WriteLine("Done!");
            Console.WriteLine("");
        }
Example #4
0
        public virtual void BuildGameDataFromSheet(string outRootPath)
        {
            string outFilePath = outRootPath + Path.DirectorySeparatorChar + FilePathWithoutExtension + OutputExtension;

            Console.WriteLine("Getting " + AssetName + " Spreadsheet content");

            SpreadsheetsResource.ValuesResource.GetRequest request = GoogleSheetConnector.GetInstance().Service.Spreadsheets.Values.Get(SheetId, SheetRange);
            ValueRange             response = request.Execute();
            List <IList <object> > values   = (List <IList <object> >)response.Values;

            //Clearing Asset File
            string outDirectory = Path.GetDirectoryName(outFilePath);

            if (!Directory.Exists(outDirectory))
            {
                Directory.CreateDirectory(outDirectory);
            }
            //Resetting file
            File.WriteAllText(outFilePath, "");

            //Getting all Sheet entries and dumping them into output text asset in right format
            Console.WriteLine("Extracting to " + FilePathWithoutExtension + OutputExtension);
            StreamWriter sw = File.AppendText(outFilePath);

            if (values != null && values.Count > 0)
            {
                foreach (var row in values)
                {
                    AssetEntry thisEntry = new AssetEntry(VariableDefinitions);
                    thisEntry.PopulateBySheetRow(row);
                    thisEntry.AppendToFile(sw, thisEntry);
                }
            }

            sw.Close();
        }
Example #5
0
        public virtual void UpdateSheetFromGameFile(string inputFolder)
        {
            string gameFilePath = inputFolder + Path.DirectorySeparatorChar + FilePathWithoutExtension + ".bytes";
            //Getting all current entries
            Dictionary <string, AssetEntry> entries = new Dictionary <string, AssetEntry>();

            Console.WriteLine("Getting " + AssetName + " Spreadsheet content");

            SpreadsheetsResource.ValuesResource.GetRequest request = GoogleSheetConnector.GetInstance().Service.Spreadsheets.Values.Get(SheetId, SheetRange);
            ValueRange             response = request.Execute();
            List <IList <object> > values   = (List <IList <object> >)response.Values;

            int rowC = 1;

            if (values != null && values.Count > 0)
            {
                foreach (var row in values)
                {
                    AssetEntry ae = new AssetEntry(VariableDefinitions);
                    ae.PopulateBySheetRow(row);
                    ae.Row = rowC;
                    string index = (string)row[0];
                    if (entries.ContainsKey(index))
                    {
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine("Detected multiple entries with key " + index + "! Using last one...");
                        Console.ForegroundColor = ConsoleColor.White;
                    }
                    entries[index] = ae;
                    rowC++;
                }
            }

            var updateRequests = new List <Request>();

            Console.WriteLine("Comparing with games version and calculating updates...");
            //Parse every line in the game asset file
            System.IO.StreamReader reader = new System.IO.StreamReader(gameFilePath);
            string[] lines = File.ReadAllLines(gameFilePath);
            for (int i = 0; i < lines.Length; i++)
            {
                string line = lines[i];
                Console.Title = "[" + AssetName + "] Processing " + i + "/" + lines.Length;
                //Splitting
                string[]   data = line.Split('\t');
                AssetEntry entry;
                if (entries.ContainsKey(data[0]))
                {
                    //Compare and update
                    entry = entries[data[0]];
                }
                else
                {
                    //New entry
                    entry            = new AssetEntry(VariableDefinitions);
                    entries[data[0]] = entry;
                }

                entry.PopulateByGameAssetRow(data);
                List <Request> updateReqs = entry.GetUpdateRequests();
                foreach (Request req in updateReqs)
                {
                    updateRequests.Add(req);
                }

                if (updateRequests.Count >= 2500)
                {
                    HandleUpdateRequests(ref updateRequests);
                }
            }

            HandleUpdateRequests(ref updateRequests);

            foreach (var aeE in entries)
            {
                AssetEntry ae = aeE.Value;
                if (!ae.FoundInGameData)
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("Unreferenced Entry " + aeE.Key + " in Row " + (ae.Row + 1));
                    Console.ForegroundColor = ConsoleColor.White;
                }
            }

            Console.WriteLine("Done!");
            Console.WriteLine("");
        }
        public override void UpdateSheetFromGameFile(string outRootPath)
        {
            string cinameticFolder = Environment.CurrentDirectory + Path.DirectorySeparatorChar + "Input" + Path.DirectorySeparatorChar + "cinematic";

            Console.WriteLine("Getting Cinametic Patching Spreadsheet content");

            SpreadsheetsResource.ValuesResource.GetRequest request = GoogleSheetConnector.GetInstance().Service.Spreadsheets.Values.Get(SheetId, SheetRange);
            ValueRange             response = request.Execute();
            List <IList <object> > values   = (List <IList <object> >)response.Values;

            Dictionary <string, AssetEntry> entries = new Dictionary <string, AssetEntry>();

            int rowC = 1;

            if (values != null && values.Count > 0)
            {
                foreach (var row in values)
                {
                    AssetEntry ae = new AssetEntry(VariableDefinitions);
                    ae.PopulateBySheetRow(row);
                    ae.Row = rowC;
                    string index = (string)row[1];
                    if (entries.ContainsKey(index))
                    {
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine("Detected multiple entries with key " + index + " in row " + +(ae.Row + 1) + " ! Using last one...");
                        Console.ForegroundColor = ConsoleColor.White;
                    }
                    entries[index] = ae;

                    rowC++;
                }
            }

            var updateRequests = new List <Request>();

            Console.WriteLine("Searching for important entries in cinametic files...");
            string[]      files       = Directory.GetFiles(cinameticFolder, "*.bytes");
            List <string> ToTranslate = new List <string>();

            for (int i = 0; i < files.Length; i++)
            {
                Console.Title = "[" + AssetName + "] Processing " + i + "/" + files.Length;
                string filePath = files[i];
                string dataRaw  = File.ReadAllText(filePath);

                List <IPatchableNode> patchables = GetPatchableNodes(dataRaw);

                foreach (var patchable in patchables)
                {
                    List <string> translateables = patchable.GetToTranslateList();
                    foreach (string translateable in translateables)
                    {
                        ToTranslate.Add(translateable);
                    }
                }
            }

            foreach (string s in ToTranslate)
            {
                AssetEntry entry;
                if (entries.ContainsKey(s))
                {
                    //Compare and update
                    entry = entries[s];
                }
                else
                {
                    //New entry
                    entry      = new AssetEntry(VariableDefinitions);
                    entries[s] = entry;
                }

                entry.PopulateByGameAssetRow(new string[] { s });
                List <Request> updateReqs = entry.GetUpdateRequests();
                foreach (Request req in updateReqs)
                {
                    updateRequests.Add(req);
                }

                if (updateRequests.Count >= 2500)
                {
                    HandleUpdateRequests(ref updateRequests);
                }
            }
            HandleUpdateRequests(ref updateRequests);

            foreach (var aeE in entries)
            {
                AssetEntry ae = aeE.Value;
                if (!ae.FoundInGameData)
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("Unreferenced Entry " + aeE.Key + " in Row " + (ae.Row + 1));
                    Console.ForegroundColor = ConsoleColor.White;
                }
            }

            Console.WriteLine("Done!");
            Console.WriteLine("");
        }