예제 #1
0
        void OnEnable()
        {
            m_Collection      = target as LocalizationTableCollection;
            m_Tables          = serializedObject.FindProperty("m_Tables");
            m_SharedTableData = serializedObject.FindProperty("m_SharedTableData");
            m_Group           = serializedObject.FindProperty("m_Group");
            m_Extensions      = serializedObject.FindProperty("m_Extensions");

            m_ExtensionsList                   = new ReorderableListExtended(serializedObject, m_Extensions);
            m_ExtensionsList.AddMenuType       = typeof(CollectionExtension);
            m_ExtensionsList.RequiredAttribute = target is StringTableCollection ? typeof(StringTableCollectionExtensionAttribute) : typeof(AssetTableCollectionExtensionAttribute);
            m_ExtensionsList.Header            = Styles.extensions;
            m_ExtensionsList.NoItemMenuItem    = Styles.noExtensions;
            m_ExtensionsList.CreateNewInstance = (type) =>
            {
                var instance = Activator.CreateInstance(type) as CollectionExtension;
                instance.TargetCollection = (target as LocalizationTableCollection);
                instance.Initialize();
                return(instance);
            };

            LocalizationEditorSettings.EditorEvents.TableAddedToCollection     += OnTableModified;
            LocalizationEditorSettings.EditorEvents.TableRemovedFromCollection += OnTableModified;
            Undo.undoRedoPerformed += RefreshTables;
            RefreshTables();
        }
예제 #2
0
 public EntryTreeView(Type assetType, LocalizationTableCollection selected, Action <LocalizationTableCollection, SharedTableData.SharedTableEntry> selectionHandler)
 {
     m_Selected         = selected;
     m_AssetType        = assetType;
     m_SelectionHandler = selectionHandler;
     Reload();
 }
예제 #3
0
 void OnTableModified(LocalizationTableCollection col, LocalizationTable tbl)
 {
     if (col == m_Collection)
     {
         RefreshTables();
     }
 }
예제 #4
0
 void EditorEvents_CollectionModifiedWithSender(object sender, LocalizationTableCollection collection)
 {
     if (sender != this)
     {
         EditorEvents_CollectionModified(collection);
     }
 }
예제 #5
0
        void ResolveTableCollection()
        {
            m_PossibleTableCollection.Clear();
            m_Collection = LocalizationEditorSettings.GetCollectionFromTable(m_TargetTable);

            if (m_TargetTable.SharedData == null)
            {
                return;
            }

            m_SharedTableDataSerializedObject = new SerializedObject(m_TargetTable.SharedData);
            m_TableCollectionName             = m_SharedTableDataSerializedObject.FindProperty("m_TableCollectionName");

            if (m_Collection != null)
            {
                m_CollectionButton = new GUIContent("Select Collection", EditorGUIUtility.ObjectContent(m_Collection, m_Collection.GetType()).image);
                return;
            }

            m_SharedTableDataCollection = LocalizationEditorSettings.GetCollectionForSharedTableData(m_TargetTable.SharedData);
            if (m_SharedTableDataCollection != null)
            {
                return;
            }

            LocalizationEditorSettings.FindLooseStringTablesUsingSharedTableData(m_TargetTable.SharedData, m_PossibleTableCollection);
        }
예제 #6
0
        void TableCollectionSelected(LocalizationTableCollection ltc)
        {
            m_TableContents.Clear();

            if (m_CurrentEditor != null)
            {
                m_CurrentEditor.OnDisable();
            }

            if (ltc == null || ltc.TableType == null)
            {
                return;
            }

            var editorType = GetEditorTypeForCollection(ltc.GetType());

            if (editorType == null)
            {
                return;
            }

            m_CurrentEditor = (TableEditor)Activator.CreateInstance(editorType);
            m_CurrentEditor.TableCollection = ltc;
            m_TableContents.Add(m_CurrentEditor);
            m_CurrentEditor.StretchToParentSize();
            m_CurrentEditor.OnEnable();
        }
        void CreateCollection()
        {
            var assetDirectory = EditorUtility.SaveFolderPanel("Create Table Collection", "Assets/", "");

            if (string.IsNullOrEmpty(assetDirectory))
            {
                return;
            }

            LocalizationTableCollection createdCollection = null;

            if (m_CollectionTypePopup.value == typeof(StringTableCollection))
            {
                createdCollection = LocalizationEditorSettings.CreateStringTableCollection(m_TableCollectionName.value, assetDirectory, GetSelectedLocales());
            }
            if (m_CollectionTypePopup.value == typeof(AssetTableCollection))
            {
                createdCollection = LocalizationEditorSettings.CreateAssetTableCollection(m_TableCollectionName.value, assetDirectory, GetSelectedLocales());
            }

            // Select the root asset and open the table editor window.
            Selection.activeObject = createdCollection;
            LocalizationTablesWindow.ShowWindow(createdCollection);
            InitializeTableName();
        }
예제 #8
0
        public TableTreeViewItem(LocalizationTableCollection collection, int id) :
            base(id, 0)
        {
            TableCollection = collection;

            if (collection != null)
            {
                displayName = collection.TableCollectionName;
            }
        }
예제 #9
0
 public TableEntryTreeViewItem(LocalizationTableCollection collection, SharedTableData.SharedTableEntry sharedEntry, int id, int depth) :
     base(id, depth)
 {
     TableCollection = collection;
     if (sharedEntry != null)
     {
         SharedEntry = sharedEntry;
         displayName = SharedEntry.Key;
     }
 }
    /// <summary>
    /// (Editor only)
    /// Gets a locale to use in edit mode in the editor.
    /// </summary>
    /// <param name="tableCollection">Optional table collection with which to filter the available locales.</param>
    /// <returns>The locale, null if none usable found.</returns>

    static Locale Editor_GetValidLocaleInEditMode(LocalizationTableCollection tableCollection)
    {
        foreach (var locale in LocalizationEditorSettings.GetLocales())
        {
            if (locale != null && (tableCollection == null || tableCollection.GetTable(locale.Identifier) != null))
            {
                return(locale);
            }
        }

        return(null);
    }
        void DoTableAndEntryGUI(Rect rect, SerializedProperty property)
        {
            var        tableRef = new SerializedTableReference(property.FindPropertyRelative("tableReference"));
            var        entryRef = new SerializedTableEntryReference(property.FindPropertyRelative("tableEntryReference"));
            GUIContent valueLabel;

            if (tableRef.Reference.ReferenceType != TableReference.Type.Empty && entryRef.Reference.ReferenceType != TableEntryReference.Type.Empty)
            {
                LocalizationTableCollection collection = null;
                if (m_TableType == typeof(StringTable))
                {
                    collection = LocalizationEditorSettings.GetStringTableCollection(tableRef.Reference);
                }
                else
                {
                    collection = LocalizationEditorSettings.GetAssetTableCollection(tableRef.Reference);
                }
                valueLabel = new GUIContent($"{GetTableLabel(tableRef.Reference)}/{GetEntryLabel(entryRef.Reference, collection?.SharedData)}");
            }
            else
            {
                valueLabel = Styles.none;
            }

            var dropDownPosition = EditorGUI.PrefixLabel(rect, Styles.reference);

            if (EditorGUI.DropdownButton(dropDownPosition, valueLabel, FocusType.Passive))
            {
                Type assetType;
                if (m_TableType == typeof(AssetTable))
                {
                    var assetTableCollection = m_Collection as AssetTableCollection;
                    assetType = assetTableCollection.GetEntryAssetType(entryRef.Reference);
                }
                else
                {
                    assetType = typeof(string);
                }

                var treeSelection = new TableEntryTreeView(assetType, (c, e) =>
                {
                    entryRef.Reference = e != null ? e.Id : SharedTableData.EmptyId;
                    tableRef.Reference = c != null ? c.TableCollectionNameReference : default(TableReference);
                    property.serializedObject.ApplyModifiedProperties();
                });
                PopupWindow.Show(dropDownPosition, new TreeViewPopupWindow(treeSelection)
                {
                    Width = dropDownPosition.width
                });
            }
        }
예제 #12
0
        public GenericAssetTableListViewMultiColumnHeader(MultiColumnHeaderState state, GenericAssetTableListView <T1, T2> parent, LocalizationTableCollection collection)
            : base(state)
        {
            height         += k_MetadataLabelHeight;
            m_Parent        = parent;
            TableCollection = collection;

            var visibleColumns = new List <int>();

            for (int i = 0; i < state.columns.Length; ++i)
            {
                if (state.columns[i] is VisibleColumn col && col.Visible)
                {
                    visibleColumns.Add(i);
                }
        void Init(SerializedProperty property)
        {
            if (m_PlatformOverridesList == null)
            {
                m_PlatformOverridesList = new ReorderableList(property.serializedObject, property.FindPropertyRelative("m_PlatformOverrides"))
                {
                    drawElementCallback   = DrawListElement,
                    drawHeaderCallback    = DrawListHeader,
                    onAddDropdownCallback = DrawAddDropdown,
                    elementHeightCallback = GetHeight
                };

                var             target          = m_PlatformOverridesList.serializedProperty.serializedObject.targetObject;
                SharedTableData sharedTableData = target as SharedTableData ?? (target as LocalizationTable)?.SharedData;
                Debug.Assert(sharedTableData != null, "Shared Table Data is null. Platform Override can only be used on a Shared Table Entry.");
                m_Collection = LocalizationEditorSettings.GetCollectionForSharedTableData(sharedTableData);
                m_TableType  = m_Collection.GetType() == typeof(StringTableCollection) ? typeof(StringTable) : typeof(AssetTable);
            }
        }
        void AddCollection(LocalizationTableCollection collection, bool defaultSelectState)
        {
            if (!SelectedTableIndexes.TryGetValue(collection, out var selectedTables))
            {
                selectedTables = defaultSelectState ? new HashSet <int>(Enumerable.Range(0, collection.Tables.Count)) : new HashSet <int>();
                SelectedTableIndexes[collection] = selectedTables;
            }

            var collectionElement = new Foldout {
                text = collection.TableCollectionName, name = collection.TableCollectionName, value = selectedTables.Count > 0
            };

            m_ContentContainer.Add(collectionElement);
            for (int i = 0; i < collection.Tables.Count; ++i)
            {
                // TODO: We could get the table name without loading the actual asset by using the instance Id and getting the file name.
                var tableName = collection.Tables[i].asset.name;

                var toggleRow = new VisualElement {
                    name = tableName, style = { flexDirection = FlexDirection.Row }
                };
                collectionElement.Add(toggleRow);
                var toggle = new Toggle {
                    value = selectedTables.Contains(i)
                };
                toggleRow.Add(toggle);
                toggleRow.Add(new Label(tableName));

                int index = i;
                toggle.RegisterValueChangedCallback(evt =>
                {
                    if (evt.newValue)
                    {
                        selectedTables.Add(index);
                    }
                    else
                    {
                        selectedTables.Remove(index);
                    }
                });
            }
        }
예제 #15
0
        TreeViewItem FindOrCreateGroup(TreeViewItem root, LocalizationTableCollection collection, ref int nodeId)
        {
            var currentRoot = root;

            if (collection.Group == collection.DefaultGroupName)
            {
                return(currentRoot);
            }

            var subGroups = collection.Group.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries);

            foreach (var g in subGroups)
            {
                var foundGroup = currentRoot.children?.FirstOrDefault(c => c.displayName == g);
                if (foundGroup == null)
                {
                    var node = new TreeViewItem(nodeId++, 0, g);
                    currentRoot.AddChild(node);
                    foundGroup = node;
                }
                currentRoot = foundGroup;
            }
            return(currentRoot);
        }
예제 #16
0
 public StringTableListView(LocalizationTableCollection tableCollection) :
     base(tableCollection)
 {
 }
 protected virtual void CheckContents(TTable table, string label, AddressableAssetSettings settings, LocalizationTableCollection collection)
 {
 }
 /// <summary>
 /// TODO wait for update on the package to notify the tables that the collection has been updated.
 /// </summary>
 /// <param name="events"></param>
 /// <param name="sender"></param>
 /// <param name="collection"></param>
 public static void RaiseCollectionMod(this LocalizationEditorEvents events, object sender, LocalizationTableCollection collection)
 {
     // events.RaiseCollectionModified(sender, collection);
 }
예제 #19
0
 void OnCollectionChange(LocalizationTableCollection col) => ResolveTableCollection();
예제 #20
0
 public void Select(LocalizationTableCollection collection) => m_AssetTablesField.value = collection;
예제 #21
0
 void EditorEvents_CollectionModified(LocalizationTableCollection obj)
 {
     s_TableChoicesLabels = null;
     s_TableChoices       = null;
     ClearPropertyDataCache();
 }
 public void SetSelection(LocalizationTableCollection collection)
 {
     SelectedTableIndexes.Clear();
     SelectedTableIndexes[collection] = new HashSet <int>(Enumerable.Range(0, collection.Tables.Count));
     Initialize(false);
 }
 void EditorEvents_CollectionModified(LocalizationTableCollection obj) => ClearPropertyDataCache();
예제 #24
0
 protected override TreeViewItem FindOrCreateGroup(TreeViewItem root, LocalizationTableCollection collection, ref int nodeId)
 {
     return(root);
 }