void OnVerifyGoogleService(string Result, string Error) { if (Result.Contains("Authorization is required to perform that action")) { ShowWarning("You need to authorize the webservice before using it. Check the steps 4 and 5 in the WebService Script"); mWebService_Status = "Offline"; return; } try { var data = SimpleJSON.JSON.Parse(Result).AsObject; int version = int.Parse(data["script_version"]); int requiredVersion = LocalizationManager.GetRequiredWebServiceVersion(); if (requiredVersion == version) { mWebService_Status = "Online"; ClearErrors(); } else { mWebService_Status = "UnsupportedVersion"; ShowError("The current Google WebService is not supported.\nPlease, delete the WebService from the Google Drive and Install the latest version."); } } catch (Exception) { ShowError("Unable to access the WebService"); mWebService_Status = "Offline"; } }
void OnVerifyGoogleService(string Result, string Error) { if (Result.Contains("Authorization is required to perform that action")) { ShowWarning("You need to authorize the webservice before using it. Check the steps 4 and 5 in the WebService Script"); mWebService_Status = "Offline"; return; } try { var data = SimpleJSON.JSON.Parse(Result).AsObject; int version = int.Parse(data["script_version"]); int requiredVersion = LocalizationManager.GetRequiredWebServiceVersion(); mWebService_Status = (requiredVersion <= version ? "Online" : "UnsupportedVersion"); ClearErrors(); } catch (Exception) { ShowError("Unable to access the WebService"); mWebService_Status = "Offline"; } }
public string Import_Google_Result(string JsonString, eSpreadsheetUpdateMode UpdateMode, bool saveInPlayerPrefs = false) { try { string ErrorMsg = string.Empty; if (string.IsNullOrEmpty(JsonString) || JsonString == "\"\"") { return(ErrorMsg); } int idxV = JsonString.IndexOf("version=", StringComparison.Ordinal); int idxSV = JsonString.IndexOf("script_version=", StringComparison.Ordinal); if (idxV < 0 || idxSV < 0) { return("Invalid Response from Google, Most likely the WebService needs to be updated"); } idxV += "version=".Length; idxSV += "script_version=".Length; string newSpreadsheetVersion = JsonString.Substring(idxV, JsonString.IndexOf(",", idxV, StringComparison.Ordinal) - idxV); var scriptVersion = int.Parse(JsonString.Substring(idxSV, JsonString.IndexOf(",", idxSV, StringComparison.Ordinal) - idxSV)); if (newSpreadsheetVersion.Length > 19) // Check for corruption { newSpreadsheetVersion = string.Empty; } if (scriptVersion != LocalizationManager.GetRequiredWebServiceVersion()) { return("The current Google WebService is not supported.\nPlease, delete the WebService from the Google Drive and Install the latest version."); } //Debug.Log (Google_LastUpdatedVersion + " - " + newSpreadsheetVersion); if (saveInPlayerPrefs && !IsNewerVersion(Google_LastUpdatedVersion, newSpreadsheetVersion)) #if UNITY_EDITOR { return(""); } #else { return("LanguageSource is up-to-date"); } #endif if (saveInPlayerPrefs) { string PlayerPrefName = GetSourcePlayerPrefName(); PersistentStorage.SaveFile(PersistentStorage.eFileType.Persistent, "I2Source_" + PlayerPrefName, "[i2e]" + StringObfucator.Encode(JsonString) + ".loc"); PersistentStorage.SetSetting_String("I2SourceVersion_" + PlayerPrefName, newSpreadsheetVersion); PersistentStorage.ForceSaveSettings(); } Google_LastUpdatedVersion = newSpreadsheetVersion; if (UpdateMode == eSpreadsheetUpdateMode.Replace) { ClearAllData(); } int CSVstartIdx = JsonString.IndexOf("[i2category]", StringComparison.Ordinal); while (CSVstartIdx > 0) { CSVstartIdx += "[i2category]".Length; int endCat = JsonString.IndexOf("[/i2category]", CSVstartIdx, StringComparison.Ordinal); string category = JsonString.Substring(CSVstartIdx, endCat - CSVstartIdx); endCat += "[/i2category]".Length; int endCSV = JsonString.IndexOf("[/i2csv]", endCat, StringComparison.Ordinal); string csv = JsonString.Substring(endCat, endCSV - endCat); CSVstartIdx = JsonString.IndexOf("[i2category]", endCSV, StringComparison.Ordinal); Import_I2CSV(category, csv, UpdateMode); // Only the first CSV should clear the Data if (UpdateMode == eSpreadsheetUpdateMode.Replace) { UpdateMode = eSpreadsheetUpdateMode.Merge; } } if (I2Utils.IsPlaying()) { SaveLanguages(true); } #if UNITY_EDITOR if (!string.IsNullOrEmpty(ErrorMsg)) { UnityEditor.EditorUtility.SetDirty(this); } #endif return(ErrorMsg); } catch (System.Exception e) { Debug.LogWarning(e); return(e.ToString()); } }
public string Import_Google_Result(string JsonString, eSpreadsheetUpdateMode UpdateMode) { string ErrorMsg = string.Empty; if (string.IsNullOrEmpty(JsonString) || JsonString == "\"\"") { Debug.Log("Language Source was up to date"); return(ErrorMsg); } if (UpdateMode == eSpreadsheetUpdateMode.Replace) { ClearAllData(); } int idxV = JsonString.IndexOf("version="); int idxSV = JsonString.IndexOf("script_version="); if (idxV < 0 || idxSV < 0) { return("Invalid Response from Google, Most likely the WebService needs to be updated"); } idxV += "version=".Length; idxSV += "script_version=".Length; Google_LastUpdatedVersion = JsonString.Substring(idxV, JsonString.IndexOf(",", idxV) - idxV); var version = int.Parse(JsonString.Substring(idxSV, JsonString.IndexOf(",", idxSV) - idxSV)); if (version < LocalizationManager.GetRequiredWebServiceVersion()) { return("The current Google WebService is not supported.\nPlease, delete the WebService from the Google Drive and Install the latest version."); } int CSVstartIdx = JsonString.IndexOf("[i2category]"); while (CSVstartIdx > 0) { CSVstartIdx += "[i2category]".Length; int endCat = JsonString.IndexOf("[/i2category]", CSVstartIdx); string category = JsonString.Substring(CSVstartIdx, endCat - CSVstartIdx); endCat += "[/i2category]".Length; int endCSV = JsonString.IndexOf("[/i2csv]", endCat); string csv = JsonString.Substring(endCat, endCSV - endCat); CSVstartIdx = JsonString.IndexOf("[i2category]", endCSV); Import_CSV(category, csv, UpdateMode, ','); // Only the first CSV should clear the Data if (UpdateMode == eSpreadsheetUpdateMode.Replace) { UpdateMode = eSpreadsheetUpdateMode.Merge; } } #if UNITY_EDITOR if (!string.IsNullOrEmpty(ErrorMsg)) { UnityEditor.EditorUtility.SetDirty(this); } #endif return(ErrorMsg); }
public string Import_Google_Result(string JsonString, eSpreadsheetUpdateMode UpdateMode, bool saveInPlayerPrefs = false) { string ErrorMsg = string.Empty; if (string.IsNullOrEmpty(JsonString) || JsonString == "\"\"") { return(ErrorMsg); } int idxV = JsonString.IndexOf("version="); int idxSV = JsonString.IndexOf("script_version="); if (idxV < 0 || idxSV < 0) { return("Invalid Response from Google, Most likely the WebService needs to be updated"); } idxV += "version=".Length; idxSV += "script_version=".Length; string newSpreadsheetVersion = JsonString.Substring(idxV, JsonString.IndexOf(",", idxV) - idxV); var scriptVersion = int.Parse(JsonString.Substring(idxSV, JsonString.IndexOf(",", idxSV) - idxSV)); if (scriptVersion != LocalizationManager.GetRequiredWebServiceVersion()) { return("The current Google WebService is not supported.\nPlease, delete the WebService from the Google Drive and Install the latest version."); } //Debug.Log (Google_LastUpdatedVersion + " - " + newSpreadsheetVersion); if (!saveInPlayerPrefs && newSpreadsheetVersion.CompareTo(Google_LastUpdatedVersion) <= 0) #if UNITY_EDITOR { return(""); } #else { return("LanguageSource is up-to-date"); } #endif if (saveInPlayerPrefs) { string PlayerPrefName = GetSourcePlayerPrefName(); PlayerPrefs.SetString("I2Source_" + PlayerPrefName, JsonString); PlayerPrefs.SetString("I2SourceVersion_" + PlayerPrefName, newSpreadsheetVersion); PlayerPrefs.Save(); } Google_LastUpdatedVersion = newSpreadsheetVersion; if (UpdateMode == eSpreadsheetUpdateMode.Replace) { ClearAllData(); } int CSVstartIdx = JsonString.IndexOf("[i2category]"); while (CSVstartIdx > 0) { CSVstartIdx += "[i2category]".Length; int endCat = JsonString.IndexOf("[/i2category]", CSVstartIdx); string category = JsonString.Substring(CSVstartIdx, endCat - CSVstartIdx); endCat += "[/i2category]".Length; int endCSV = JsonString.IndexOf("[/i2csv]", endCat); string csv = JsonString.Substring(endCat, endCSV - endCat); CSVstartIdx = JsonString.IndexOf("[i2category]", endCSV); Import_I2CSV(category, csv, UpdateMode); // Only the first CSV should clear the Data if (UpdateMode == eSpreadsheetUpdateMode.Replace) { UpdateMode = eSpreadsheetUpdateMode.Merge; } } #if UNITY_EDITOR if (!string.IsNullOrEmpty(ErrorMsg)) { UnityEditor.EditorUtility.SetDirty(this); } #endif return(ErrorMsg); }
public string Import_Google_Result(string JsonString, eSpreadsheetUpdateMode UpdateMode, bool saveInPlayerPrefs = false) { string empty = string.Empty; if (string.IsNullOrEmpty(JsonString) || JsonString == "\"\"") { return(empty); } int num = JsonString.IndexOf("version=", StringComparison.Ordinal); int num2 = JsonString.IndexOf("script_version=", StringComparison.Ordinal); if (num < 0 || num2 < 0) { return("Invalid Response from Google, Most likely the WebService needs to be updated"); } num += "version=".Length; num2 += "script_version=".Length; string text = JsonString.Substring(num, JsonString.IndexOf(",", num, StringComparison.Ordinal) - num); int num3 = int.Parse(JsonString.Substring(num2, JsonString.IndexOf(",", num2, StringComparison.Ordinal) - num2)); if (text.Length > 19) { text = string.Empty; } if (num3 != LocalizationManager.GetRequiredWebServiceVersion()) { return("The current Google WebService is not supported.\nPlease, delete the WebService from the Google Drive and Install the latest version."); } if (saveInPlayerPrefs && !IsNewerVersion(Google_LastUpdatedVersion, text)) { return("LanguageSource is up-to-date"); } if (saveInPlayerPrefs) { string sourcePlayerPrefName = GetSourcePlayerPrefName(); PlayerPrefs.SetString("I2Source_" + sourcePlayerPrefName, JsonString); PlayerPrefs.SetString("I2SourceVersion_" + sourcePlayerPrefName, text); PlayerPrefs.Save(); } Google_LastUpdatedVersion = text; if (UpdateMode == eSpreadsheetUpdateMode.Replace) { ClearAllData(); } int num4 = JsonString.IndexOf("[i2category]", StringComparison.Ordinal); while (num4 > 0) { num4 += "[i2category]".Length; int num5 = JsonString.IndexOf("[/i2category]", num4, StringComparison.Ordinal); string category = JsonString.Substring(num4, num5 - num4); num5 += "[/i2category]".Length; int num6 = JsonString.IndexOf("[/i2csv]", num5, StringComparison.Ordinal); string i2CSVstring = JsonString.Substring(num5, num6 - num5); num4 = JsonString.IndexOf("[i2category]", num6, StringComparison.Ordinal); Import_I2CSV(category, i2CSVstring, UpdateMode); if (UpdateMode == eSpreadsheetUpdateMode.Replace) { UpdateMode = eSpreadsheetUpdateMode.Merge; } } return(empty); }