예제 #1
0
        private StandardizedTermManager()
        {
            Console.WriteLine("Getting standardized terms from google sheets..");
            StandardizedTerms = new Dictionary <string, string>();

            GoogleSheetConnector gsc = GoogleSheetConnector.GetInstance();
            string termSpreadsheetId = gsc.SpreadsheetIDs["StandardizedTerms"];

            foreach (var range in SheetRanges)
            {
                SpreadsheetsResource.ValuesResource.GetRequest request = gsc.Service.Spreadsheets.Values.Get(termSpreadsheetId, range);
                ValueRange             response = request.Execute();
                List <IList <object> > values   = (List <IList <object> >)response.Values;

                if (values != null && values.Count > 0)
                {
                    foreach (var row in values)
                    {
                        if (row.Count == 2)
                        {
                            string chineseT = (string)row[0];
                            string engT     = (string)row[1];
                            if (!StandardizedTerms.ContainsKey(chineseT))
                            {
                                StandardizedTerms.Add(chineseT, engT);
                            }
                        }
                    }
                }
            }
        }
예제 #2
0
        public OperationSheet()
        {
            GoogleSheet = new GoogleSheetConnector();
            IList <IList <object> > rows = GoogleSheet.GetValues(SpreadsheetId, SheetRange);

            processor = new OperationSheetProcessor(rows);
        }
예제 #3
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);
                }
            }
        }
예제 #4
0
        public override void BuildGameDataFromSheet(string outRootPath)
        {
            string mergeFilePath = 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(mergeFilePath);

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

            string scheduleRelativeFolderPath = Path.DirectorySeparatorChar + "chs" + Path.DirectorySeparatorChar + "battle" + Path.DirectorySeparatorChar + "buffer";
            string bufferFolderPath           = outRootPath + Path.DirectorySeparatorChar + scheduleRelativeFolderPath;

            //Getting all Sheet entries and dumping them into Talk.txt in right format
            Console.WriteLine("Extracting to " + FilePathWithoutExtension + OutputExtension + " and the schedules folder");
            StreamWriter mergeFileWriter = File.AppendText(mergeFilePath);

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

                    //Writing to merge file
                    thisEntry.AppendToFile(mergeFileWriter, thisEntry);

                    //Writting to .json file
                    string fileName = thisEntry.Variables[0].OriginalValue;
                    string filePath = bufferFolderPath + Path.DirectorySeparatorChar + fileName;
                    outDirectory = Path.GetDirectoryName(filePath);
                    if (!Directory.Exists(outDirectory))
                    {
                        Directory.CreateDirectory(outDirectory);
                    }

                    File.WriteAllText(filePath, "");
                    StreamWriter scheduleFileWriter = File.AppendText(filePath);
                    thisEntry.AppendToFile(scheduleFileWriter, thisEntry);
                    scheduleFileWriter.Close();
                }
            }

            mergeFileWriter.Close();
        }
예제 #5
0
        public void HandleUpdateRequests(ref List <Request> updateRequests)
        {
            if (updateRequests.Count > 0)
            {
                Console.WriteLine("Sending " + updateRequests.Count + " Requests to Google API...");
                BatchUpdateSpreadsheetRequest batchUpdate = new BatchUpdateSpreadsheetRequest();
                batchUpdate.Requests = updateRequests;
                var updateRequest = GoogleSheetConnector.GetInstance().Service.Spreadsheets.BatchUpdate(batchUpdate, SheetId);
                updateRequest.Execute();

                updateRequests.Clear();
            }
        }
예제 #6
0
        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("");
        }
예제 #7
0
        public void BuildGameDataFromSheet(string outRootPath)
        {
            string outPath           = outRootPath + Path.DirectorySeparatorChar + "Talk.txt";
            GoogleSheetConnector gsc = GoogleSheetConnector.GetInstance();
            string talkSpreadsheetId = gsc.SpreadsheetIDs["Talk"];

            Console.WriteLine("Getting Talk Spreadsheet content");

            //Getting all current entries
            SpreadsheetsResource.ValuesResource.GetRequest request = gsc.Service.Spreadsheets.Values.Get(talkSpreadsheetId, SheetRange);
            ValueRange             response = request.Execute();
            List <IList <object> > values   = (List <IList <object> >)response.Values;

            //Clearing talk File
            string rootPath = Path.GetDirectoryName(outPath);

            if (!Directory.Exists(rootPath))
            {
                Directory.CreateDirectory(rootPath);
            }
            File.WriteAllText(outPath, "");

            //Getting all Sheet entries and dumping them into Talk.txt in right format
            Console.WriteLine("Constructing Talk.txt...");
            using (StreamWriter sw = File.AppendText(outPath))
            {
                if (values != null && values.Count > 0)
                {
                    foreach (var row in values)
                    {
                        sw.Write((string)row[0] + '\t');  //DialogID
                        sw.Write((string)row[1] + '\t');  //TalkerID
                        sw.Write((string)row[2] + '\t');  //C
                        sw.Write((string)row[3] + '\t');  //D
                        sw.Write((string)row[4] + '\t');  //The translated Text as Text
                        sw.Write((string)row[7] + '\t');  //NextDialogId
                        sw.Write((string)row[8] + '\t');  //I
                        sw.Write((string)row[9] + '\t');  //AlternativeNextDialogId
                        sw.Write((string)row[10] + '\t'); //K
                        sw.Write((string)row[11] + '\t'); //Script
                        sw.Write((string)row[12] + '\t'); //SecondScript
                        sw.Write('\r');
                    }
                }
            }
            Console.WriteLine("Done!");
        }
예제 #8
0
        public void BuildGameDataFromSheet(string outRootPath)
        {
            string outPath           = outRootPath + Path.DirectorySeparatorChar + "Adjustment.txt";
            GoogleSheetConnector gsc = GoogleSheetConnector.GetInstance();
            string talkSpreadsheetId = gsc.SpreadsheetIDs["Adjustment"];

            Console.WriteLine("Getting Adjustment Spreadsheet content");

            //Getting all current entries
            SpreadsheetsResource.ValuesResource.GetRequest request = gsc.Service.Spreadsheets.Values.Get(talkSpreadsheetId, SheetRange);
            ValueRange             response = request.Execute();
            List <IList <object> > values   = (List <IList <object> >)response.Values;

            //Clearing talk File
            string rootPath = Path.GetDirectoryName(outPath);

            if (!Directory.Exists(rootPath))
            {
                Directory.CreateDirectory(rootPath);
            }
            File.WriteAllText(outPath, "");

            Console.WriteLine("Constructing Adjustment.txt...");
            using (StreamWriter sw = File.AppendText(outPath))
            {
                if (values != null && values.Count > 0)
                {
                    foreach (var row in values)
                    {
                        sw.Write((string)row[0] + '\t');  //ID
                        sw.Write((string)row[1] + '\t');  //Title
                        sw.Write((string)row[3] + '\t');  //SecondTitle
                        sw.Write((string)row[5] + '\t');  //Description
                        sw.Write((string)row[7] + '\t');  //Element1
                        sw.Write((string)row[8] + '\t');  //Element2
                        sw.Write((string)row[9] + '\t');  //J
                        sw.Write((string)row[10] + '\t'); //H
                        sw.Write((string)row[11] + '\t'); //NPC ID 1
                        sw.Write((string)row[12] + '\t'); //NPC ID 2
                        sw.Write('\r');
                    }
                }
            }
            Console.WriteLine("Done!");
        }
예제 #9
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();
        }
예제 #10
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("");
        }
예제 #11
0
            public Request ToGoogleSheetUpdateRequest()
            {
                GoogleSheetConnector gsc  = GoogleSheetConnector.GetInstance();
                string  talkSpreadsheetId = gsc.SpreadsheetIDs["Achievement"];
                Request updateRequest     = new Request();

                var ShortTextCellData = new CellData()
                {
                    UserEnteredValue = new ExtendedValue()
                    {
                        StringValue = ShortText
                    },
                    UserEnteredFormat = null
                };
                var LongTextCellData = new CellData()
                {
                    UserEnteredValue = new ExtendedValue()
                    {
                        StringValue = LongText
                    },
                    UserEnteredFormat = null
                };

                var Fields = "userEnteredValue";

                if (ShortTextChanged || LongTextChanged)
                {
                    Fields = "userEnteredValue,userEnteredFormat";
                    if (MLTranslated)
                    {
                        ShortTextCellData.UserEnteredFormat = new CellFormat()
                        {
                            BackgroundColor = new Color()
                            {
                                Alpha = 1.0f,
                                Red   = 1.0f,
                                Green = 0.66f,
                                Blue  = 0.0f
                            }
                        };

                        LongTextCellData.UserEnteredFormat = new CellFormat()
                        {
                            BackgroundColor = new Color()
                            {
                                Alpha = 1.0f,
                                Red   = 1.0f,
                                Green = 0.66f,
                                Blue  = 0.0f
                            }
                        };
                    }
                    else
                    {
                        ShortTextCellData.UserEnteredFormat = new CellFormat()
                        {
                            BackgroundColor = new Color()
                            {
                                Alpha = 1.0f,
                                Red   = 0.8f,
                                Green = 0.8f,
                                Blue  = 0.02f
                            }
                        };

                        LongTextCellData.UserEnteredFormat = new CellFormat()
                        {
                            BackgroundColor = new Color()
                            {
                                Alpha = 1.0f,
                                Red   = 0.8f,
                                Green = 0.8f,
                                Blue  = 0.02f
                            }
                        };
                    }
                }

                var Rows = new List <RowData>
                {
                    new RowData()
                    {
                        Values = new List <CellData>()
                        {
                            new CellData()
                            {
                                UserEnteredValue = new ExtendedValue()
                                {
                                    StringValue = ID
                                }
                            },
                            ShortTextCellData,
                            new CellData()
                            {
                                UserEnteredValue = new ExtendedValue()
                                {
                                    StringValue = ShortOriginalText
                                }
                            },
                            LongTextCellData,
                            new CellData()
                            {
                                UserEnteredValue = new ExtendedValue()
                                {
                                    StringValue = LongOriginalText
                                }
                            },
                            new CellData()
                            {
                                UserEnteredValue = new ExtendedValue()
                                {
                                    StringValue = D
                                }
                            },
                            new CellData()
                            {
                                UserEnteredValue = new ExtendedValue()
                                {
                                    StringValue = StandardizedTerm_Short
                                }
                            },
                            new CellData()
                            {
                                UserEnteredValue = new ExtendedValue()
                                {
                                    StringValue = StandardizedTerm_Long
                                }
                            },
                        }
                    }
                };

                if (row >= 1)
                {
                    updateRequest.UpdateCells = new UpdateCellsRequest
                    {
                        Range = new GridRange()
                        {
                            SheetId       = 0,
                            StartRowIndex = row,
                            EndRowIndex   = row + 1,
                        },
                        Rows   = Rows,
                        Fields = Fields
                    };
                }
                else
                {
                    updateRequest.AppendCells = new AppendCellsRequest
                    {
                        Rows    = Rows,
                        SheetId = 0,
                        Fields  = Fields
                    };
                }

                return(updateRequest);
            }
예제 #12
0
        public void UpdateSheetFromGameFile(string gameFileRootPath)
        {
            string gameFilePath = gameFileRootPath + Path.DirectorySeparatorChar + "Achievement.bytes";

            //Getting all current entries
            Dictionary <string, AchievementEntry> achievementEntries = new Dictionary <string, AchievementEntry>();

            Console.WriteLine("Getting Achievement Spreadsheet content");
            GoogleSheetConnector gsc = GoogleSheetConnector.GetInstance();
            string talkSpreadsheetId = gsc.SpreadsheetIDs["Achievement"];

            SpreadsheetsResource.ValuesResource.GetRequest request = gsc.Service.Spreadsheets.Values.Get(talkSpreadsheetId, 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)
                {
                    AchievementEntry ae = new AchievementEntry(row);
                    ae.row = rowC;
                    achievementEntries[ae.ID] = ae;
                    rowC++;
                }
            }

            //UpdatingRequests
            var updateRequests = new List <Request>();

            Console.WriteLine("Comparing with games version and calculating updates...");
            //Parse every line in the game file
            System.IO.StreamReader reader = new System.IO.StreamReader(gameFilePath);
            string line;

            while ((line = reader.ReadLine()) != null)
            {
                //Splitting
                string[] data = line.Split('\t');

                //Parsing data
                string ID = data[0];
                string ShortOriginalText = data[1];
                string LongOriginalText  = data[2];
                string D = data[3];

                string StandardizedTerm_Short = StandardizedTermManager.GetInstance().GetTermLocatorText(ShortOriginalText);
                string StandardizedTerm_Long  = StandardizedTermManager.GetInstance().GetTermLocatorText(LongOriginalText);

                if (achievementEntries.ContainsKey(ID))
                {
                    //Compare and update
                    AchievementEntry existingEntry = achievementEntries[ID];
                    bool             needsUpdate   = false;

                    if (!string.IsNullOrEmpty(ShortOriginalText) && existingEntry.ShortOriginalText != ShortOriginalText)
                    {
                        existingEntry.ShortOriginalText = ShortOriginalText;
                        existingEntry.ShortTextChanged  = true;
                        needsUpdate = true;
                    }

                    if (!string.IsNullOrEmpty(LongOriginalText) && existingEntry.LongOriginalText != LongOriginalText)
                    {
                        existingEntry.LongOriginalText = LongOriginalText;
                        existingEntry.LongTextChanged  = true;
                        needsUpdate = true;
                    }

                    if (!string.IsNullOrEmpty(StandardizedTerm_Short) && existingEntry.StandardizedTerm_Short != StandardizedTerm_Short)
                    {
                        existingEntry.StandardizedTerm_Short = StandardizedTerm_Short;
                        needsUpdate = true;
                    }

                    if (!string.IsNullOrEmpty(StandardizedTerm_Long) && existingEntry.StandardizedTerm_Long != StandardizedTerm_Long)
                    {
                        existingEntry.StandardizedTerm_Long = StandardizedTerm_Long;
                        needsUpdate = true;
                    }

                    if (existingEntry.D != D)
                    {
                        existingEntry.D = D;
                        needsUpdate     = true;
                    }

                    if (needsUpdate)
                    {
                        updateRequests.Add(existingEntry.ToGoogleSheetUpdateRequest());
                    }
                }
                else
                {
                    //New one
                    AchievementEntry newEntry = new AchievementEntry();
                    newEntry.ID = ID;
                    newEntry.ShortOriginalText = ShortOriginalText;
                    newEntry.ShortText         = TranslationManager.GetInstance().Translate(StandardizedTerm_Short);
                    newEntry.ShortTextChanged  = true;
                    newEntry.LongOriginalText  = LongOriginalText;
                    newEntry.LongText          = TranslationManager.GetInstance().Translate(StandardizedTerm_Long);
                    newEntry.D = D;
                    newEntry.LongTextChanged        = true;
                    newEntry.MLTranslated           = true;
                    newEntry.StandardizedTerm_Short = StandardizedTerm_Short;
                    newEntry.StandardizedTerm_Long  = StandardizedTerm_Long;

                    updateRequests.Add(newEntry.ToGoogleSheetUpdateRequest());
                }
            }

            Console.WriteLine("Updating spreadsheet...");
            BatchUpdateSpreadsheetRequest batchUpdate = new BatchUpdateSpreadsheetRequest();

            batchUpdate.Requests = new List <Request>();
            int reqHandled = 0;

            //updateRequests.RemoveRange(2, updateRequests.Count - 2);
            foreach (var req in updateRequests)
            {
                batchUpdate.Requests.Add(req);
                reqHandled++;
                if (batchUpdate.Requests.Count >= 500 || reqHandled >= updateRequests.Count)
                {
                    var updateRequest = gsc.Service.Spreadsheets.BatchUpdate(batchUpdate, talkSpreadsheetId);
                    updateRequest.Execute();
                    //Resetting batch update
                    batchUpdate          = new BatchUpdateSpreadsheetRequest();
                    batchUpdate.Requests = new List <Request>();
                }
            }

            Console.WriteLine("Done!");
        }
예제 #13
0
            public Request ToGoogleSheetUpdateRequest()
            {
                GoogleSheetConnector gsc  = GoogleSheetConnector.GetInstance();
                string  talkSpreadsheetId = gsc.SpreadsheetIDs["Talk"];
                Request updateRequest     = new Request();

                var TextCellData = new CellData()
                {
                    UserEnteredValue = new ExtendedValue()
                    {
                        StringValue = Text
                    },
                    UserEnteredFormat = null
                };
                var Fields = "userEnteredValue";

                if (TextChanged)
                {
                    Fields = "userEnteredValue,userEnteredFormat";
                    if (TextMLTranslated)
                    {
                        TextCellData.UserEnteredFormat = new CellFormat()
                        {
                            BackgroundColor = new Color()
                            {
                                Alpha = 1.0f,
                                Red   = 1.0f,
                                Green = 0.66f,
                                Blue  = 0.0f
                            }
                        };
                    }
                    else
                    {
                        TextCellData.UserEnteredFormat = new CellFormat()
                        {
                            BackgroundColor = new Color()
                            {
                                Alpha = 1.0f,
                                Red   = 0.8f,
                                Green = 0.8f,
                                Blue  = 0.02f
                            }
                        };
                    }
                }

                var Rows = new List <RowData>
                {
                    new RowData()
                    {
                        Values = new List <CellData>()
                        {
                            new CellData()
                            {
                                UserEnteredValue = new ExtendedValue()
                                {
                                    StringValue = DialogID
                                },
                            },

                            new CellData()
                            {
                                UserEnteredValue = new ExtendedValue()
                                {
                                    StringValue = TalkerID
                                }
                            },

                            new CellData()
                            {
                                UserEnteredValue = new ExtendedValue()
                                {
                                    StringValue = C
                                }
                            },

                            new CellData()
                            {
                                UserEnteredValue = new ExtendedValue()
                                {
                                    StringValue = D
                                }
                            },

                            TextCellData,

                            new CellData()
                            {
                                UserEnteredValue = new ExtendedValue()
                                {
                                    StringValue = OriginalText
                                }
                            },

                            new CellData()
                            {
                                UserEnteredValue = new ExtendedValue()
                                {
                                    StringValue = PreviousOriginalText
                                }
                            },

                            new CellData()
                            {
                                UserEnteredValue = new ExtendedValue()
                                {
                                    StringValue = NextDialogID
                                }
                            },

                            new CellData()
                            {
                                UserEnteredValue = new ExtendedValue()
                                {
                                    StringValue = I
                                }
                            },

                            new CellData()
                            {
                                UserEnteredValue = new ExtendedValue()
                                {
                                    StringValue = AlternativeNextDialogID
                                }
                            },

                            new CellData()
                            {
                                UserEnteredValue = new ExtendedValue()
                                {
                                    StringValue = K
                                }
                            },

                            new CellData()
                            {
                                UserEnteredValue = new ExtendedValue()
                                {
                                    StringValue = Script
                                }
                            },

                            new CellData()
                            {
                                UserEnteredValue = new ExtendedValue()
                                {
                                    StringValue = SecondScript
                                }
                            },

                            new CellData()
                            {
                                UserEnteredValue = new ExtendedValue()
                                {
                                    StringValue = TranslatorNotes
                                }
                            },

                            new CellData()
                            {
                                UserEnteredValue = new ExtendedValue()
                                {
                                    StringValue = StandardizedTermLocator
                                }
                            },
                        },
                    },
                };

                if (row >= 1)
                {
                    updateRequest.UpdateCells = new UpdateCellsRequest
                    {
                        Range = new GridRange()
                        {
                            SheetId       = 0,
                            StartRowIndex = row,
                            EndRowIndex   = row + 1,
                        },
                        Rows   = Rows,
                        Fields = Fields
                    };
                }
                else
                {
                    updateRequest.AppendCells = new AppendCellsRequest
                    {
                        Rows    = Rows,
                        SheetId = 0,
                        Fields  = Fields
                    };
                }

                return(updateRequest);
            }
예제 #14
0
        public override void UpdateSheetFromGameFile(string inputFolder)
        {
            string bufferFolderPath = inputFolder + Path.DirectorySeparatorChar + "chs" + Path.DirectorySeparatorChar + "battle" + Path.DirectorySeparatorChar + "buffer";

            //Getting all current entries
            Dictionary <string, BufferAsset> entries = new Dictionary <string, BufferAsset>();
            GoogleSheetConnector             gsc     = GoogleSheetConnector.GetInstance();

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

            SpreadsheetsResource.ValuesResource.GetRequest request = gsc.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)
                {
                    BufferAsset ae = new BufferAsset(VariableDefinitions);
                    ae.PopulateBySheetRow(row);
                    ae.Row = rowC;

                    entries[(string)row[0]] = ae;
                    rowC++;
                }
            }

            var updateRequests = new List <Request>();

            Console.WriteLine("Comparing with games version and calculating updates...");
            //Parse every battle schedule file
            string[] files = Directory.GetFiles(bufferFolderPath, "*.bytes");
            for (int i = 0; i < files.Length; i++)
            {
                Console.Title = "[" + AssetName + "] Processing " + i + "/" + files.Length;

                //Reading file
                string bufferFilePathTmp      = files[i];
                System.IO.StreamReader reader = new System.IO.StreamReader(bufferFilePathTmp);
                string line = reader.ReadLine();

                //Construction relative .json path
                int    lastSplitterIndex = bufferFilePathTmp.LastIndexOf(Path.DirectorySeparatorChar);
                string scheduleFilePath  = bufferFilePathTmp.Substring(lastSplitterIndex + 1, bufferFilePathTmp.Length - lastSplitterIndex - 1);
                scheduleFilePath = scheduleFilePath.Replace(".bytes", ".json");

                //Parsing
                string[]    data = line.Split('\t');
                BufferAsset entry;
                if (entries.ContainsKey(scheduleFilePath))
                {
                    //Compare and update
                    entry = entries[scheduleFilePath];
                }
                else
                {
                    //New entry
                    entry = new BufferAsset(VariableDefinitions);
                }

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

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

            HandleUpdateRequests(ref updateRequests);
        }
예제 #15
0
        public void UpdateSheetFromGameFile(string gameFileRootPath)
        {
            string gameFilePath      = gameFileRootPath + Path.DirectorySeparatorChar + "Talk.bytes";
            GoogleSheetConnector gsc = GoogleSheetConnector.GetInstance();
            string talkSpreadsheetId = gsc.SpreadsheetIDs["Talk"];

            Console.WriteLine("Getting Talk Spreadsheet content");

            //Getting all current entries
            Dictionary <string, TalkEntry> talkEntries = new Dictionary <string, TalkEntry>();

            SpreadsheetsResource.ValuesResource.GetRequest request = gsc.Service.Spreadsheets.Values.Get(talkSpreadsheetId, 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)
                {
                    TalkEntry te = new TalkEntry((string)row[0]);
                    te.TalkerID                = (string)row[1];
                    te.C                       = (string)row[2];
                    te.D                       = (string)row[3];
                    te.Text                    = (string)row[4];
                    te.OriginalText            = (string)row[5];
                    te.PreviousOriginalText    = (string)row[6];
                    te.NextDialogID            = (string)row[7];
                    te.I                       = (string)row[8];
                    te.AlternativeNextDialogID = (string)row[9];
                    te.K                       = (string)row[10];
                    te.Script                  = (string)row[11];
                    te.SecondScript            = (string)row[12];
                    if (row.Count > 13)
                    {
                        te.TranslatorNotes = (string)row[13];
                    }
                    if (row.Count > 14)
                    {
                        te.StandardizedTermLocator = (string)row[14];
                    }

                    te.row = rowC;

                    talkEntries[te.DialogID] = te;
                    rowC++;
                }
            }
            //UpdatingRequests
            var updateRequests          = new List <Request>();
            var standardizedTermLocator = StandardizedTermManager.GetInstance();

            Console.WriteLine("Comparing with games version and calculating updates...");
            //Parse every line in the game file
            System.IO.StreamReader reader = new System.IO.StreamReader(gameFilePath);
            string line;

            while ((line = reader.ReadLine()) != null)
            {
                //We first splite the line into the parts
                string[] data = line.Split('\t');

                string dialogID                = data[0];
                string talkerID                = data[1];
                string valueC                  = data[2];
                string valueD                  = data[3];
                string originalText            = data[4];
                string nextDialogId            = data[5];
                string valueI                  = data[6];
                string alternativeNextDialogID = data[7];
                string valueK                  = data[8];
                string script                  = data[9];
                string secondScript            = data[10];
                string standardizedTermText    = standardizedTermLocator.GetTermLocatorText(originalText);

                if (talkEntries.ContainsKey(dialogID))
                {
                    //Compare and update
                    TalkEntry existingEntry = talkEntries[dialogID];
                    bool      needsUpdate   = false;

                    //First we take care of originalText, previousOriginalText and Text
                    if (!string.IsNullOrEmpty(originalText) && existingEntry.OriginalText != originalText)
                    {
                        existingEntry.TextChanged = true;

                        //Update the original Text and previous Text

                        existingEntry.PreviousOriginalText    = existingEntry.OriginalText;
                        existingEntry.OriginalText            = originalText;
                        existingEntry.StandardizedTermLocator = standardizedTermText;
                        needsUpdate = true;
                    }

                    if (string.IsNullOrEmpty(existingEntry.StandardizedTermLocator) && !string.IsNullOrEmpty(standardizedTermText))
                    {
                        existingEntry.StandardizedTermLocator = standardizedTermText;
                        needsUpdate = true;
                    }

                    //Updating TalkerID
                    if (existingEntry.TalkerID != talkerID)
                    {
                        existingEntry.TalkerID = talkerID;
                        needsUpdate            = true;
                    }
                    //Updating NextDialogID
                    if (existingEntry.TalkerID != talkerID)
                    {
                        existingEntry.TalkerID = talkerID;
                        needsUpdate            = true;
                    }

                    //Updating NextDialogID
                    if (existingEntry.NextDialogID != nextDialogId)
                    {
                        existingEntry.NextDialogID = nextDialogId;
                        needsUpdate = true;
                    }

                    //Updating AlternativeNextDialogID
                    if (existingEntry.AlternativeNextDialogID != alternativeNextDialogID)
                    {
                        existingEntry.AlternativeNextDialogID = alternativeNextDialogID;
                        needsUpdate = true;
                    }

                    //Updating C, D, I and K
                    if (existingEntry.C != valueC)
                    {
                        existingEntry.C = valueC;
                        needsUpdate     = true;
                    }

                    if (existingEntry.D != valueD)
                    {
                        existingEntry.D = valueD;
                        needsUpdate     = true;
                    }

                    if (existingEntry.I != valueI)
                    {
                        existingEntry.I = valueI;
                        needsUpdate     = true;
                    }

                    if (existingEntry.K != valueK)
                    {
                        existingEntry.K = valueK;
                        needsUpdate     = true;
                    }

                    //Updating Script and SecondScript

                    if (existingEntry.Script != script)
                    {
                        existingEntry.Script = script;
                        needsUpdate          = true;
                    }

                    if (existingEntry.SecondScript != secondScript)
                    {
                        existingEntry.SecondScript = secondScript;
                        needsUpdate = true;
                    }

                    if (needsUpdate)
                    {
                        updateRequests.Add(existingEntry.ToGoogleSheetUpdateRequest());
                    }
                }
                else
                {
                    //TalkEntry is unknown, add a new one
                    TalkEntry newEntry = new TalkEntry(dialogID);
                    newEntry.TalkerID                = talkerID;
                    newEntry.C                       = valueC;
                    newEntry.D                       = valueD;
                    newEntry.OriginalText            = originalText;
                    newEntry.NextDialogID            = nextDialogId;
                    newEntry.K                       = valueK;
                    newEntry.AlternativeNextDialogID = alternativeNextDialogID;
                    newEntry.I                       = valueI;
                    newEntry.Script                  = script;
                    newEntry.SecondScript            = secondScript;
                    newEntry.StandardizedTermLocator = standardizedTermText;

                    newEntry.TextChanged = true;

                    //Doing intial ML Translation
                    var translatedText = TranslationManager.GetInstance().Translate(standardizedTermText);
                    newEntry.Text             = translatedText;
                    newEntry.TextMLTranslated = true;

                    rowC++;
                    updateRequests.Add(newEntry.ToGoogleSheetUpdateRequest());
                }
            }

            Console.WriteLine("Updating spreadsheet...");
            BatchUpdateSpreadsheetRequest batchUpdate = new BatchUpdateSpreadsheetRequest();

            batchUpdate.Requests = new List <Request>();
            int reqHandled = 0;

            //updateRequests.RemoveRange(2, updateRequests.Count - 2);
            foreach (var req in updateRequests)
            {
                batchUpdate.Requests.Add(req);
                reqHandled++;
                if (batchUpdate.Requests.Count >= 500 || reqHandled >= updateRequests.Count)
                {
                    var updateRequest = gsc.Service.Spreadsheets.BatchUpdate(batchUpdate, talkSpreadsheetId);
                    updateRequest.Execute();
                    //Resetting batch update
                    batchUpdate          = new BatchUpdateSpreadsheetRequest();
                    batchUpdate.Requests = new List <Request>();
                }
            }

            Console.WriteLine("Done!");
        }
예제 #16
0
        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("");
        }
예제 #17
0
            public Request ToGoogleSheetUpdateRequest()
            {
                GoogleSheetConnector gsc  = GoogleSheetConnector.GetInstance();
                string  talkSpreadsheetId = gsc.SpreadsheetIDs["Adjustment"];
                Request updateRequest     = new Request();

                var TitleTextCellData = new CellData()
                {
                    UserEnteredValue = new ExtendedValue()
                    {
                        StringValue = TitleText
                    },
                    UserEnteredFormat = null
                };
                var SecondTitleTextCellData = new CellData()
                {
                    UserEnteredValue = new ExtendedValue()
                    {
                        StringValue = SecondTitle
                    },
                    UserEnteredFormat = null
                };
                var DescriptionTextCellData = new CellData()
                {
                    UserEnteredValue = new ExtendedValue()
                    {
                        StringValue = Description
                    },
                    UserEnteredFormat = null
                };

                var Fields = "userEnteredValue";

                if (TitleChanged || SecondTitleChanged || DescriptionChanged)
                {
                    Fields = "userEnteredValue,userEnteredFormat";
                    if (MLTranslated)
                    {
                        TitleTextCellData.UserEnteredFormat = new CellFormat()
                        {
                            BackgroundColor = new Color()
                            {
                                Alpha = 1.0f,
                                Red   = 1.0f,
                                Green = 0.66f,
                                Blue  = 0.0f
                            }
                        };

                        SecondTitleTextCellData.UserEnteredFormat = new CellFormat()
                        {
                            BackgroundColor = new Color()
                            {
                                Alpha = 1.0f,
                                Red   = 1.0f,
                                Green = 0.66f,
                                Blue  = 0.0f
                            }
                        };

                        DescriptionTextCellData.UserEnteredFormat = new CellFormat()
                        {
                            BackgroundColor = new Color()
                            {
                                Alpha = 1.0f,
                                Red   = 1.0f,
                                Green = 0.66f,
                                Blue  = 0.0f
                            }
                        };
                    }
                    else
                    {
                        TitleTextCellData.UserEnteredFormat = new CellFormat()
                        {
                            BackgroundColor = new Color()
                            {
                                Alpha = 1.0f,
                                Red   = 0.8f,
                                Green = 0.8f,
                                Blue  = 0.02f
                            }
                        };
                        SecondTitleTextCellData.UserEnteredFormat = new CellFormat()
                        {
                            BackgroundColor = new Color()
                            {
                                Alpha = 1.0f,
                                Red   = 0.8f,
                                Green = 0.8f,
                                Blue  = 0.02f
                            }
                        };

                        DescriptionTextCellData.UserEnteredFormat = new CellFormat()
                        {
                            BackgroundColor = new Color()
                            {
                                Alpha = 1.0f,
                                Red   = 0.8f,
                                Green = 0.8f,
                                Blue  = 0.02f
                            }
                        };
                    }
                }

                var Rows = new List <RowData>
                {
                    new RowData()
                    {
                        Values = new List <CellData>()
                        {
                            new CellData()
                            {
                                UserEnteredValue = new ExtendedValue()
                                {
                                    StringValue = ID
                                }
                            },
                            TitleTextCellData,
                            new CellData()
                            {
                                UserEnteredValue = new ExtendedValue()
                                {
                                    StringValue = OriginalTitle
                                }
                            },
                            SecondTitleTextCellData,
                            new CellData()
                            {
                                UserEnteredValue = new ExtendedValue()
                                {
                                    StringValue = OriginalSecondTitle
                                }
                            },
                            DescriptionTextCellData,
                            new CellData()
                            {
                                UserEnteredValue = new ExtendedValue()
                                {
                                    StringValue = OriginalDescription
                                }
                            },
                            new CellData()
                            {
                                UserEnteredValue = new ExtendedValue()
                                {
                                    StringValue = Element1
                                }
                            },
                            new CellData()
                            {
                                UserEnteredValue = new ExtendedValue()
                                {
                                    StringValue = Element2
                                }
                            },
                            new CellData()
                            {
                                UserEnteredValue = new ExtendedValue()
                                {
                                    StringValue = J
                                }
                            },
                            new CellData()
                            {
                                UserEnteredValue = new ExtendedValue()
                                {
                                    StringValue = H
                                }
                            },
                            new CellData()
                            {
                                UserEnteredValue = new ExtendedValue()
                                {
                                    StringValue = NpcId1
                                }
                            },
                            new CellData()
                            {
                                UserEnteredValue = new ExtendedValue()
                                {
                                    StringValue = NpcId2
                                }
                            },
                            new CellData()
                            {
                                UserEnteredValue = new ExtendedValue()
                                {
                                    StringValue = NpcId3
                                }
                            },
                            new CellData()
                            {
                                UserEnteredValue = new ExtendedValue()
                                {
                                    StringValue = StandardizedTermLocator_Title
                                }
                            },
                            new CellData()
                            {
                                UserEnteredValue = new ExtendedValue()
                                {
                                    StringValue = StandardizedTermLocator_SecondTitle
                                }
                            },
                            new CellData()
                            {
                                UserEnteredValue = new ExtendedValue()
                                {
                                    StringValue = StandardizedTermLocator_Description
                                }
                            },
                        }
                    }
                };

                if (row >= 1)
                {
                    updateRequest.UpdateCells = new UpdateCellsRequest
                    {
                        Range = new GridRange()
                        {
                            SheetId       = 0,
                            StartRowIndex = row,
                            EndRowIndex   = row + 1,
                        },
                        Rows   = Rows,
                        Fields = Fields
                    };
                }
                else
                {
                    updateRequest.AppendCells = new AppendCellsRequest
                    {
                        Rows    = Rows,
                        SheetId = 0,
                        Fields  = Fields
                    };
                }

                return(updateRequest);
            }
예제 #18
0
        public void UpdateSheetFromGameFile(string gameFileRootPath)
        {
            string gameFilePath = gameFileRootPath + Path.DirectorySeparatorChar + "Adjustment.bytes";

            //Getting all current entries
            Dictionary <string, AdjustmentEntry> adjustmentEntries = new Dictionary <string, AdjustmentEntry>();

            Console.WriteLine("Getting Adjustment Spreadsheet content");
            GoogleSheetConnector gsc = GoogleSheetConnector.GetInstance();
            string talkSpreadsheetId = gsc.SpreadsheetIDs["Adjustment"];

            SpreadsheetsResource.ValuesResource.GetRequest request = gsc.Service.Spreadsheets.Values.Get(talkSpreadsheetId, 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)
                {
                    AdjustmentEntry ae = new AdjustmentEntry(row);
                    ae.row = rowC;
                    adjustmentEntries[ae.ID] = ae;
                    rowC++;
                }
            }

            //UpdatingRequests
            var updateRequests = new List <Request>();

            Console.WriteLine("Comparing with games version and calculating updates...");
            //Parse every line in the game file
            System.IO.StreamReader reader = new System.IO.StreamReader(gameFilePath);
            string line;

            while ((line = reader.ReadLine()) != null)
            {
                //Splitting
                string[] data = line.Split('\t');
                //Parsing data
                string ID                  = data[0];
                string OriginalTitle       = data[1];
                string OriginalSecondTitle = data[2];
                string OriginalDescription = data[3];
                string Element1            = data[4];
                string Element2            = data[5];
                string J      = data[6];
                string H      = data[7];
                string NpcId1 = data[8];
                string NpcId2 = data[9];
                string NpcId3 = data[10];
                string StandardizedTermLocator_Title       = StandardizedTermManager.GetInstance().GetTermLocatorText(OriginalTitle);
                string StandardizedTermLocator_SecondTitle = StandardizedTermManager.GetInstance().GetTermLocatorText(OriginalSecondTitle);
                string StandardizedTermLocator_Description = StandardizedTermManager.GetInstance().GetTermLocatorText(OriginalDescription);

                if (adjustmentEntries.ContainsKey(ID))
                {
                    //Compare and update
                    AdjustmentEntry existingEntry = adjustmentEntries[ID];
                    bool            needsUpdate   = false;

                    if (!string.IsNullOrEmpty(OriginalTitle) && existingEntry.OriginalTitle != OriginalTitle)
                    {
                        existingEntry.OriginalTitle = OriginalTitle;
                        existingEntry.TitleChanged  = true;
                        needsUpdate = true;
                    }

                    if (!string.IsNullOrEmpty(OriginalSecondTitle) && existingEntry.OriginalSecondTitle != OriginalSecondTitle)
                    {
                        existingEntry.OriginalSecondTitle = OriginalSecondTitle;
                        existingEntry.SecondTitleChanged  = true;
                        needsUpdate = true;
                    }

                    if (!string.IsNullOrEmpty(OriginalDescription) && existingEntry.OriginalDescription != OriginalDescription)
                    {
                        existingEntry.OriginalDescription = OriginalDescription;
                        existingEntry.DescriptionChanged  = true;
                        needsUpdate = true;
                    }

                    if (existingEntry.Element1 != Element1)
                    {
                        existingEntry.Element1 = Element1;
                        needsUpdate            = true;
                    }

                    if (existingEntry.Element2 != Element2)
                    {
                        existingEntry.Element2 = Element2;
                        needsUpdate            = true;
                    }

                    if (existingEntry.J != J)
                    {
                        existingEntry.J = J;
                        needsUpdate     = true;
                    }

                    if (existingEntry.H != H)
                    {
                        existingEntry.H = H;
                        needsUpdate     = true;
                    }

                    if (existingEntry.NpcId1 != NpcId1)
                    {
                        existingEntry.NpcId1 = NpcId1;
                        needsUpdate          = true;
                    }

                    if (existingEntry.NpcId2 != NpcId2)
                    {
                        existingEntry.NpcId2 = NpcId2;
                        needsUpdate          = true;
                    }

                    if (existingEntry.NpcId3 != NpcId3)
                    {
                        existingEntry.NpcId3 = NpcId3;
                        needsUpdate          = true;
                    }

                    if (existingEntry.StandardizedTermLocator_Title != StandardizedTermLocator_Title)
                    {
                        existingEntry.StandardizedTermLocator_Title = StandardizedTermLocator_Title;
                        needsUpdate = true;
                    }

                    if (existingEntry.StandardizedTermLocator_SecondTitle != StandardizedTermLocator_SecondTitle)
                    {
                        existingEntry.StandardizedTermLocator_SecondTitle = StandardizedTermLocator_SecondTitle;
                        needsUpdate = true;
                    }

                    if (existingEntry.StandardizedTermLocator_Description != StandardizedTermLocator_Description)
                    {
                        existingEntry.StandardizedTermLocator_Description = StandardizedTermLocator_Description;
                        needsUpdate = true;
                    }

                    if (needsUpdate)
                    {
                        updateRequests.Add(existingEntry.ToGoogleSheetUpdateRequest());
                    }
                }
                else
                {
                    //New one
                    AdjustmentEntry newEntry = new AdjustmentEntry();
                    newEntry.ID                  = ID;
                    newEntry.TitleText           = TranslationManager.GetInstance().Translate(StandardizedTermLocator_Title);
                    newEntry.OriginalTitle       = OriginalTitle;
                    newEntry.SecondTitle         = TranslationManager.GetInstance().Translate(StandardizedTermLocator_SecondTitle);
                    newEntry.OriginalSecondTitle = OriginalSecondTitle;
                    newEntry.Description         = TranslationManager.GetInstance().Translate(StandardizedTermLocator_Description);
                    newEntry.OriginalDescription = OriginalDescription;
                    newEntry.Element1            = Element1;
                    newEntry.Element2            = Element2;
                    newEntry.J      = J;
                    newEntry.H      = H;
                    newEntry.NpcId1 = NpcId1;
                    newEntry.NpcId2 = NpcId2;
                    newEntry.NpcId3 = NpcId3;
                    newEntry.StandardizedTermLocator_Title       = StandardizedTermLocator_Title;
                    newEntry.StandardizedTermLocator_SecondTitle = StandardizedTermLocator_SecondTitle;
                    newEntry.StandardizedTermLocator_Description = StandardizedTermLocator_Description;

                    newEntry.TitleChanged       = true;
                    newEntry.SecondTitleChanged = true;
                    newEntry.DescriptionChanged = true;
                    newEntry.MLTranslated       = true;

                    updateRequests.Add(newEntry.ToGoogleSheetUpdateRequest());
                }
            }

            Console.WriteLine("Updating spreadsheet...");
            BatchUpdateSpreadsheetRequest batchUpdate = new BatchUpdateSpreadsheetRequest();

            batchUpdate.Requests = new List <Request>();
            int reqHandled = 0;

            //updateRequests.RemoveRange(2, updateRequests.Count - 2);
            foreach (var req in updateRequests)
            {
                batchUpdate.Requests.Add(req);
                reqHandled++;
                if (batchUpdate.Requests.Count >= 500 || reqHandled >= updateRequests.Count)
                {
                    var updateRequest = gsc.Service.Spreadsheets.BatchUpdate(batchUpdate, talkSpreadsheetId);
                    updateRequest.Execute();
                    //Resetting batch update
                    batchUpdate          = new BatchUpdateSpreadsheetRequest();
                    batchUpdate.Requests = new List <Request>();
                }
            }

            Console.WriteLine("Done!");
        }