Ejemplo n.º 1
0
 private void LoadData(TranslateData translateData)
 {
     loadedTranslateData = translateData;
     CleanData();
     translatorBehaviour.Load(translateData);
     translateDataUI.Initialize(translateData, confirmation);
 }
Ejemplo n.º 2
0
        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();
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
 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.");
     }
 }
Ejemplo n.º 5
0
 /// <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();
 }