Esempio n. 1
0
    private void OnEnable()
    {
        // Get the target reference
        locTextGroup = target as LocalizedTextsGroup;

        // Inizialize both lits it they aren't yet
        if (locTextGroup.localizedTextsList == null)
        {
            locTextGroup.localizedTextsList = new List <LocalizedText>();
        }


        if (locTextGroup.localGameLanguagesList == null)
        {
            locTextGroup.localGameLanguagesList = new GameLanguageItem[0];
        }

        // Create all the editors for the Localized texts belonging to this group
        if (localizedTextEditors == null)
        {
            CreateEditors();
        }

        // Cache the export/import option from the scriptable object
        syncOption = (SYNC_OPTIONS)locTextGroup.currentSyncOption;

        // In case AllGameLanguages has a valid Instance...
        if (AllGameLanguages.Instance == null)
        {
            return;
        }

        locTextGroup.localGameLanguagesList = AllGameLanguages.Instance.gameLanguagesList.ToArray();

        if (toggles.Length != AllGameLanguages.Instance.gameLanguagesList.Count)
        {
            Array.Resize(ref toggles, AllGameLanguages.Instance.gameLanguagesList.Count);
        }

        // Mark all language import toggles at start
        for (int i = 0; i < toggles.Length; i++)
        {
            toggles[i] = true;
        }

        // Resize the URLs array of Sync settings to match the number
        // of gamelanguages in AllGameLanguages
        if (locTextGroup.remoteCsvUrls.Length != AllGameLanguages.Instance.gameLanguagesList.Count)
        {
            Array.Resize(ref locTextGroup.remoteCsvUrls, AllGameLanguages.Instance.gameLanguagesList.Count);
        }
    }
Esempio n. 2
0
    private void createImportExportBox()
    {
        // Import/Export options
        GUILayout.BeginVertical(GUI.skin.box);

        EditorTools.createTitleBox("Load / save Options", true);

        GUILayout.BeginHorizontal(EditorStyles.inspectorDefaultMargins);
        EditorGUILayout.LabelField("Mode");

        syncOption = (SYNC_OPTIONS)EditorGUILayout.EnumPopup(syncOption, GUILayout.ExpandWidth(true));
        locTextGroup.currentSyncOption = (int)syncOption;

        GUILayout.EndHorizontal();


        if (syncOption == SYNC_OPTIONS.REMOTE_CSV_FILE)
        {
            GUIContent guiCont;
            string     langCode;
            for (int i = 0; i < locTextGroup.localGameLanguagesList.Length; i++)
            {
                langCode = locTextGroup.localGameLanguagesList[i].gameLanguage.code;
                GUILayout.BeginHorizontal(GUI.skin.box);
                if (toggles[i])
                {
                    guiCont = new GUIContent(" " + langCode + "_sheet_URL",
                                             EditorGUIUtility.IconContent("RotateTool").image,
                                             "Importing enabled for " + langCode + " language.");
                }
                else
                {
                    guiCont = new GUIContent(" " + langCode + "_sheet_URL",
                                             EditorGUIUtility.IconContent("RotateTool On").image,
                                             "Importing disabled for " + langCode + " language.");
                }

                locTextGroup.remoteCsvUrls[i] =
                    EditorGUILayout.TextField(guiCont, locTextGroup.remoteCsvUrls[i]);
                GUILayout.EndHorizontal();
            }

            GUILayout.Space(5);

            EditorGUI.BeginDisabledGroup(drawToggles() && filesPending == 0);

            GUILayout.Space(10);

            GUILayout.BeginHorizontal();

            if (GUILayout.Button(new GUIContent(" Import", EditorTools.getIcon("CollabPull"))))
            {
                for (int i = 0; i < locTextGroup.remoteCsvUrls.Length; i++)
                {
                    if (!toggles[i])
                    {
                        continue;
                    }

                    importFromRemoteCsvSheet(i);
                }
            }

            GUILayout.EndHorizontal();

            EditorGUI.EndDisabledGroup();
        }
        else if (syncOption == SYNC_OPTIONS.LOCAL_CSV_FILE)
        {
            string[] fileNames       = new string[locTextGroup.localGameLanguagesList.Length];
            int      count           = 0;
            string   messageFileName = "";

            for (int i = 0; i < locTextGroup.localGameLanguagesList.Length; i++)
            {
                if (!toggles[i])
                {
                    continue;
                }
                count++;
                fileNames[i]     = locTextGroup.name + " - " + locTextGroup.localGameLanguagesList[i].gameLanguage.code + ".csv";
                messageFileName += fileNames[i];

                if (i != locTextGroup.localGameLanguagesList.Length - 1)
                {
                    messageFileName += "\n";
                }
            }

            EditorGUILayout.HelpBox(count +
                                    " files will be loaded/saved from/to folder:\n" +
                                    AKAGF_PATHS.LOCALIZATION_GROUPS_FILES_PATH + locTextGroup.name + "/\n\n" +
                                    "With the names: \n" +
                                    messageFileName, MessageType.Info);

            GUILayout.Space(5);

            EditorGUI.BeginDisabledGroup(drawToggles() && filesPending == 0);

            GUILayout.Space(10);

            GUILayout.BeginHorizontal();

            if (GUILayout.Button(new GUIContent(" Load from file", EditorTools.getIcon("CollabPush"))))
            {
                loadFromCSV(fileNames, GROUPS_CSV_FILES_PATH + locTextGroup.name + "/");
            }

            if (GUILayout.Button(new GUIContent(" Save to file", EditorTools.getIcon("CollabPull"))))
            {
                saveToCSV(fileNames, GROUPS_CSV_FILES_PATH + locTextGroup.name + "/");
            }

            EditorGUI.EndDisabledGroup();
            GUILayout.EndHorizontal();
        }

        GUILayout.Space(5);
        GUILayout.EndVertical();
    }