private void LoadData(TranslateData translateData) { loadedTranslateData = translateData; CleanData(); translatorBehaviour.Load(translateData); translateDataUI.Initialize(translateData, confirmation); }
public void Initialize(TranslateData translateData, ConfirmationPopupBehaviour confirmationPopupBehaviour) { CleanUp(); this.translateData = translateData; this.confirmation = confirmationPopupBehaviour; // Set up bindings. disposables.Add(new InputFieldBinding(projectNameField, () => translateData.Name, delegate(string value) { value = value.Trim(' '); UpdateProjectName(value); SetDirty(true); })); disposables.Add(new InputFieldBinding(projectDescriptionField, () => translateData.Description, delegate(string value) { translateData.Description = value; SetDirty(true); })); disposables.Add(new ButtonBinding(projectDescriptionCollapseButton, () => projectDescriptionField.gameObject.SetActive(!projectDescriptionField.gameObject.activeSelf))); disposables.Add(new ButtonBinding(addTranslateSheetButton, delegate { TranslateSheetData sheetData = new TranslateSheetData(); translateData.TranslateSheets.Add(sheetData); AddTranslateSheetUIElement(sheetData); })); // Set up UI. SetDirty(false); UpdateProjectName(); BuildUI(); }
private void SaveData(TranslateData translateData, string path, bool reload) { string json = JsonConvert.SerializeObject(translateData, Formatting.Indented); File.WriteAllText(path, json); if (reload) { LoadFromPath(path); } translateDataUI.SetDirty(false); }
private void LoadFromPath(string path) { if (File.Exists(path)) { dataPath = path; TranslateData data = JsonConvert.DeserializeObject <TranslateData>(File.ReadAllText(path)); LoadData(data); } else { Debug.LogError($"File at path '{path}' does not exist."); } }
/// <summary> /// Loads the given <see cref="TranslateData"/> and creates the required <see cref="Translator"/>s. /// </summary> public void Load(TranslateData translateData) { this.translateData = translateData; LoadInputText(); Reload(); }