예제 #1
0
 private void LoadData(TranslateData translateData)
 {
     loadedTranslateData = translateData;
     CleanData();
     translatorBehaviour.Load(translateData);
     translateDataUI.Initialize(translateData, confirmation);
 }
예제 #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();
        }
예제 #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);
        }
예제 #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.");
     }
 }
예제 #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();
 }