Ejemplo n.º 1
0
        ///Item factory.
        public static LocalizationObjectItem Create(LocalizationItemGroup group, string ID = null, string ItemType = null)
        {
            LocalizationObjectItem created = ScriptableObject.CreateInstance <LocalizationObjectItem>();

            //Use instance ID if ID is not specified.
            //If containing database has any item with duplicated ID, get a random one.
            created._ID = (ID == null)? created.GetInstanceID().ToString() : ID;
            if (group.database != null)
            {
                while (group.database.allItemCache.ContainsKey(created.ID))
                {
                    created._ID = Random.Range(-65535, 65534).ToString();
                }
            }

            //Set ItemType if specified.
            if (ItemType != null)
            {
                created._ItemType = ItemType;
            }

            //Getting referred in the containing group and database.
            created.containerGroup = group;
            group.storedItems.Add(created);
            if (group.database != null)
            {
                group.database.allItemCache.Add(created.ID, created);
            }

            //Asset operation
            AssetDatabase.AddObjectToAsset(created, group);
            created.hideFlags = HideFlags.HideInHierarchy;

            return(created);
        }
Ejemplo n.º 2
0
 void UnloadItemGroup()
 {
     groupCache        = null;
     DrawSideBarBuffer = DrawSideBar_Normal;
     DrawEditorBuffer  = DrawEditor_NoSelection;
     Repaint();
 }
Ejemplo n.º 3
0
 void CreateRecycleBin()
 {
     _RecycleBin                    = LocalizationItemGroup.Create(null, "Recycle Bin");
     _RecycleBin.doRecycle          = false;
     _RecycleBin.AllowAddItemByUser = false;
     AssetDatabase.AddObjectToAsset(_RecycleBin, this);
     _RecycleBin.hideFlags = HideFlags.HideInHierarchy;
 }
Ejemplo n.º 4
0
        ///Clone this item to the target group.
        public LocalizationObjectItem CloneTo(LocalizationItemGroup group)
        {
            LocalizationObjectItem created = LocalizationObjectItem.Create(group, this.ID, this._ItemType);

            //The properties will check and change the type of passed in object, so we directly change the private field.
            created.storage      = this.storage;
            created.storedString = this.storedString;
            return(created);
        }
Ejemplo n.º 5
0
        public LocalizationItemGroup CloneTo(LocalizationDatabase database)
        {
            LocalizationItemGroup newGroup = LocalizationItemGroup.Create(database, this.groupID);

            for (int i = 0; i < storedItems.Count; i++)
            {
                storedItems[i].CloneTo(newGroup);
            }
            return(newGroup);
        }
Ejemplo n.º 6
0
 void DeleteItemGroup(LocalizationItemGroup group)
 {
     if (group == groupCache)
     {
         groupCache       = null;
         DrawEditorBuffer = DrawEditor_NoSelection;
         Repaint();
     }
     group.Destroy();
     OnItemGroupRemoved();
 }
Ejemplo n.º 7
0
 public void OverwriteWith(LocalizationItemGroup source, bool FullForceOverwrite = false)
 {
     this.groupID = source.groupID;
     if (FullForceOverwrite)
     {
         for (int i = storedItems.Count - 1; i >= 0; i--)
         {
             storedItems[i].Destroy();
         }
         for (int i = 0; i < source.storedItems.Count; i++)
         {
             source.storedItems[i].CloneTo(this);
         }
     }
     else
     {
         //For each type of items
         //1. Check if any item with same ID exist in this group
         //2. If no result from step 1, check if any item with same ID exist in the database
         //3. If any result from step 1/2, overwrite the data from source
         //4. If no result from step 1/2, clone the item from source
         foreach (LocalizationObjectItem item in source.storedItems)
         {
             LocalizationObjectItem temp = this.storedItems.Find(e => e.ID.Equals(item.ID));
             if (temp == null)
             {
                 if (this.database.allItemCache.Contains(item.ID))
                 {
                     temp = this.database.allItemCache[item.ID];
                 }
             }
             if (temp != null)
             {
                 temp._ID          = item.ID;
                 temp.StoredString = item.StoredString;
                 temp.Storage      = item.Storage;
             }
             else
             {
                 item.CloneTo(this);
             }
         }
     }
 }
Ejemplo n.º 8
0
        ///Load entry content into Editor block, does not thing to do with (int) selected.
        void LoadItemGroup(LocalizationItemGroup group)
        {
            groupCache        = group;
            DrawSideBarBuffer = DrawSideBar_Normal;
            if (group.ItemCount == 0)
            {
                DrawEditorBuffer = DrawEditor_Empty;
            }
            else
            {
                DrawEditorBuffer = DrawEditor_Normal;
            }

            FilterAndCategorize(group.storedItems, true);

            GUI.FocusControl("0");

            groupCacheBuffer = null;
            Repaint();
        }
Ejemplo n.º 9
0
        public static LocalizationItemGroup Create(LocalizationDatabase database = null, string tag = "Unnamed Group")
        {
            LocalizationItemGroup created = ScriptableObject.CreateInstance <LocalizationItemGroup>();

            created.groupID     = tag;
            created.storedItems = new List <LocalizationObjectItem>();
            created.database    = database;
            if (database != null)
            {
                if (database.entryGroupList.Count > 0)
                {
                    while (database.entryGroupList.Any(e => e.groupID == created.groupID))
                    {
                        created.groupID += "*";
                    }
                }
                database.entryGroupList.Add(created);
                AssetDatabase.AddObjectToAsset(created, database);
                created.hideFlags = HideFlags.HideInHierarchy;
            }


            return(created);
        }
Ejemplo n.º 10
0
        void CreateNewItemGroup()
        {
            LocalizationItemGroup newGroup = LocalizationItemGroup.Create(databaseCache);

            OnDatabaseChanged();
        }