Пример #1
0
 public void ProcessDatabases()
 {
     try {
         List<DialogueDatabase> distinct = prefs.databases.Distinct().ToList();
         MasterIDs masterIDs = new MasterIDs();
         for (int i = 0; i < distinct.Count; i++) {
             var database = distinct[i];
             if (database != null) {
                 EditorUtility.DisplayProgressBar("Processing Databases (Phase 1/2)", database.name, i / prefs.databases.Count);
                 GetNewIDs(database, masterIDs);
             }
         }
         for (int i = 0; i < distinct.Count; i++) {
             var database = distinct[i];
             if (database != null) {
                 EditorUtility.DisplayProgressBar("Processing Databases (Phase 2/2)", database.name, i / prefs.databases.Count);
                 ProcessDatabase(database, masterIDs);
                 EditorUtility.SetDirty(database);
             }
         }
         Debug.Log(string.Format("{0}: Assigned unique IDs to {1} databases.", DialogueDebug.Prefix, prefs.databases.Count));
         AssetDatabase.SaveAssets();
     } finally {
         EditorUtility.ClearProgressBar();
     }
 }
Пример #2
0
        private void ProcessConversations(DialogueDatabase database, MasterIDs masterIDs)
        {
            Dictionary <int, int> newIDs = GetNewConversationIDs(database, masterIDs);

            foreach (var conversation in database.conversations)
            {
                if (newIDs.ContainsKey(conversation.id))
                {
                    if (verbose)
                    {
                        report += string.Format("\nConversation '{0}': ID [{1}]-->[{2}]", conversation.Title, conversation.id, newIDs[conversation.id]);
                    }
                    conversation.id = newIDs[conversation.id];
                    ProcessFieldIDs(database, conversation.fields, masterIDs);
                    foreach (DialogueEntry entry in conversation.dialogueEntries)
                    {
                        entry.conversationID = conversation.id;
                        ProcessFieldIDs(database, entry.fields, masterIDs);
                        foreach (var link in entry.outgoingLinks)
                        {
                            if (newIDs.ContainsKey(link.originConversationID))
                            {
                                link.originConversationID = newIDs[link.originConversationID];
                            }
                            if (newIDs.ContainsKey(link.destinationConversationID))
                            {
                                link.destinationConversationID = newIDs[link.destinationConversationID];
                            }
                        }
                    }
                }
            }
        }
Пример #3
0
 private void GetNewItemIDs(DialogueDatabase database, MasterIDs masterIDs)
 {
     foreach (var item in database.items)
     {
         if (masterIDs.items.ContainsKey(item.Name))
         {
             masterIDs.items[item.Name].oldID = item.id;
         }
         else
         {
             int newID;
             if (item.id <= masterIDs.highestItemID)
             {
                 masterIDs.highestItemID++;
                 newID = masterIDs.highestItemID;
             }
             else
             {
                 masterIDs.highestItemID = item.id;
                 newID = item.id;
             }
             masterIDs.items.Add(item.Name, new IDConversion(item.id, newID));
         }
     }
 }
Пример #4
0
 private void GetNewActorIDs(DialogueDatabase database, MasterIDs masterIDs)
 {
     foreach (var actor in database.actors)
     {
         if (masterIDs.actors.ContainsKey(actor.Name))
         {
             masterIDs.actors[actor.Name].oldID = actor.id;
         }
         else
         {
             int newID;
             if (actor.id <= masterIDs.highestActorID)
             {
                 masterIDs.highestActorID++;
                 newID = masterIDs.highestActorID;
             }
             else
             {
                 masterIDs.highestActorID = actor.id;
                 newID = actor.id;
             }
             masterIDs.actors.Add(actor.Name, new IDConversion(actor.id, newID));
         }
     }
 }
Пример #5
0
 private void GetNewLocationIDs(DialogueDatabase database, MasterIDs masterIDs)
 {
     foreach (var location in database.locations)
     {
         if (masterIDs.locations.ContainsKey(location.Name))
         {
             masterIDs.locations[location.Name].oldID = location.id;
         }
         else
         {
             int newID;
             if (location.id <= masterIDs.highestLocationID)
             {
                 masterIDs.highestLocationID++;
                 newID = masterIDs.highestLocationID;
             }
             else
             {
                 masterIDs.highestLocationID = location.id;
                 newID = location.id;
             }
             masterIDs.locations.Add(location.Name, new IDConversion(location.id, newID));
         }
     }
 }
Пример #6
0
 private void GetNewVariableIDs(DialogueDatabase database, MasterIDs masterIDs)
 {
     foreach (var variable in database.variables)
     {
         if (masterIDs.variables.ContainsKey(variable.Name))
         {
             masterIDs.variables[variable.Name].oldID = variable.id;
         }
         else
         {
             int newID;
             if (variable.id <= masterIDs.highestVariableID)
             {
                 masterIDs.highestVariableID++;
                 newID = masterIDs.highestVariableID;
             }
             else
             {
                 masterIDs.highestVariableID = variable.id;
                 newID = variable.id;
             }
             masterIDs.variables.Add(variable.Name, new IDConversion(variable.id, newID));
         }
     }
 }
Пример #7
0
        private void ProcessFieldIDs(DialogueDatabase database, List <Field> fields, MasterIDs masterIDs)
        {
            foreach (var field in fields)
            {
                int oldID = Tools.StringToInt(field.value);
                switch (field.type)
                {
                case FieldType.Actor:
                    Actor actor = database.GetActor(oldID);
                    if (actor != null)
                    {
                        field.value = FindIDConversion(actor.Name, masterIDs.actors, oldID).ToString();
                    }
                    break;

                case FieldType.Item:
                    Item item = database.GetItem(oldID);
                    if (item != null)
                    {
                        field.value = FindIDConversion(item.Name, masterIDs.items, oldID).ToString();
                    }
                    break;

                case FieldType.Location:
                    Location location = database.GetLocation(oldID);
                    if (location != null)
                    {
                        field.value = FindIDConversion(location.Name, masterIDs.locations, oldID).ToString();
                    }
                    break;
                }
            }
        }
Пример #8
0
 public void ProcessDatabases()
 {
     try
     {
         List <DialogueDatabase> distinct = prefs.databases.Distinct().ToList();
         MasterIDs masterIDs = new MasterIDs();
         for (int i = 0; i < distinct.Count; i++)
         {
             var database = distinct[i];
             if (database != null)
             {
                 EditorUtility.DisplayProgressBar("Processing Databases (Phase 1/2)", database.name, i / prefs.databases.Count);
                 GetNewIDs(database, masterIDs);
             }
         }
         for (int i = 0; i < distinct.Count; i++)
         {
             var database = distinct[i];
             if (database != null)
             {
                 EditorUtility.DisplayProgressBar("Processing Databases (Phase 2/2)", database.name, i / prefs.databases.Count);
                 ProcessDatabase(database, masterIDs);
                 EditorUtility.SetDirty(database);
             }
         }
         Debug.Log(string.Format("{0}: Assigned unique IDs to {1} databases.", DialogueDebug.Prefix, prefs.databases.Count));
         AssetDatabase.SaveAssets();
     }
     finally
     {
         EditorUtility.ClearProgressBar();
     }
 }
Пример #9
0
 private void GetNewIDs(DialogueDatabase database, MasterIDs masterIDs)
 {
     if (verbose)
     {
         Debug.Log(string.Format("{0}: Determining new IDs for database {1}", DialogueDebug.Prefix, database.name));
     }
     GetNewActorIDs(database, masterIDs);
     GetNewItemIDs(database, masterIDs);
     GetNewLocationIDs(database, masterIDs);
     GetNewVariableIDs(database, masterIDs);
 }
Пример #10
0
 private void GetNewIDs(DialogueDatabase database, MasterIDs masterIDs)
 {
     if (verbose)
     {
         report += "\nDetermining new IDs for database " + database.name;
     }
     GetNewActorIDs(database, masterIDs);
     GetNewItemIDs(database, masterIDs);
     GetNewLocationIDs(database, masterIDs);
     GetNewVariableIDs(database, masterIDs);
 }
Пример #11
0
 private void ProcessDatabase(DialogueDatabase database, MasterIDs masterIDs)
 {
     if (verbose)
     {
         report += "\nConverting IDs in database " + database.name;
     }
     ProcessConversations(database, masterIDs);
     ProcessActors(database, masterIDs);
     ProcessItems(database, masterIDs);
     ProcessLocations(database, masterIDs);
     ProcessVariables(database, masterIDs);
 }
Пример #12
0
 private void ProcessDatabase(DialogueDatabase database, MasterIDs masterIDs)
 {
     if (verbose)
     {
         Debug.Log(string.Format("{0}: Converting IDs in database {1}", DialogueDebug.Prefix, database.name));
     }
     ProcessConversations(database, masterIDs);
     ProcessActors(database, masterIDs);
     ProcessItems(database, masterIDs);
     ProcessLocations(database, masterIDs);
     ProcessVariables(database, masterIDs);
 }
Пример #13
0
 private void ProcessVariables(DialogueDatabase database, MasterIDs masterIDs)
 {
     foreach (var variable in database.variables)
     {
         int newID = FindIDConversion(variable.Name, masterIDs.variables, variable.id);
         if (newID != variable.id)
         {
             if (verbose)
             {
                 report += string.Format("Variable {0}: ID [{1}]-->[{2}]", variable.Name, variable.id, newID);
             }
             variable.id = newID;
         }
         ProcessFieldIDs(database, variable.fields, masterIDs);
     }
 }
Пример #14
0
 private void ProcessItems(DialogueDatabase database, MasterIDs masterIDs)
 {
     foreach (var item in database.items)
     {
         int newID = FindIDConversion(item.Name, masterIDs.items, item.id);
         if (newID != item.id)
         {
             if (verbose)
             {
                 report += string.Format("\nItem {0}: ID [{1}]-->[{2}]", item.Name, item.id, newID);
             }
             item.id = newID;
         }
         ProcessFieldIDs(database, item.fields, masterIDs);
     }
 }
Пример #15
0
 private void ProcessActors(DialogueDatabase database, MasterIDs masterIDs)
 {
     foreach (var actor in database.actors)
     {
         int newID = FindIDConversion(actor.Name, masterIDs.actors, actor.id);
         if (newID != actor.id)
         {
             if (verbose)
             {
                 Debug.Log(string.Format("{0}: Actor {1}: ID [{2}]-->[{3}]", DialogueDebug.Prefix, actor.Name, actor.id, newID));
             }
             actor.id = newID;
         }
         ProcessFieldIDs(database, actor.fields, masterIDs);
     }
 }
Пример #16
0
 private void ProcessLocations(DialogueDatabase database, MasterIDs masterIDs)
 {
     foreach (var location in database.locations)
     {
         int newID = FindIDConversion(location.Name, masterIDs.locations, location.id);
         if (newID != location.id)
         {
             if (verbose)
             {
                 report += string.Format("\nLocation {0}: ID [{1}]-->[{2}]", location.Name, location.id, newID);
             }
             location.id = newID;
         }
         ProcessFieldIDs(database, location.fields, masterIDs);
     }
 }
Пример #17
0
 private void ProcessActors(DialogueDatabase database, MasterIDs masterIDs)
 {
     foreach (var actor in database.actors)
     {
         int newID = FindIDConversion(actor.Name, masterIDs.actors, actor.id);
         if (newID != actor.id)
         {
             if (verbose)
             {
                 report += string.Format("\nActor {0}: ID [{1}]-->[{2}]", actor.Name, actor.id, newID);
             }
             actor.id = newID;
         }
         ProcessFieldIDs(database, actor.fields, masterIDs);
     }
 }
Пример #18
0
 private void ProcessLocations(DialogueDatabase database, MasterIDs masterIDs)
 {
     foreach (var location in database.locations)
     {
         int newID = FindIDConversion(location.Name, masterIDs.locations, location.id);
         if (newID != location.id)
         {
             if (verbose)
             {
                 Debug.Log(string.Format("{0}: Location {1}: ID [{2}]-->[{3}]", DialogueDebug.Prefix, location.Name, location.id, newID));
             }
             location.id = newID;
         }
         ProcessFieldIDs(database, location.fields, masterIDs);
     }
 }
Пример #19
0
 private void ProcessItems(DialogueDatabase database, MasterIDs masterIDs)
 {
     foreach (var item in database.items)
     {
         int newID = FindIDConversion(item.Name, masterIDs.items, item.id);
         if (newID != item.id)
         {
             if (verbose)
             {
                 Debug.Log(string.Format("{0}: Item {1}: ID [{2}]-->[{3}]", DialogueDebug.Prefix, item.Name, item.id, newID));
             }
             item.id = newID;
         }
         ProcessFieldIDs(database, item.fields, masterIDs);
     }
 }
Пример #20
0
 public void ProcessDatabases()
 {
     try
     {
         report = "Unique ID Tool Report:";
         List <DialogueDatabase> distinct = prefs.databases.Distinct().ToList();
         MasterIDs masterIDs = new MasterIDs();
         for (int i = 0; i < distinct.Count; i++)
         {
             var database = distinct[i];
             if (database != null)
             {
                 EditorUtility.DisplayProgressBar("Processing Databases (Phase 1/2)", database.name, i / prefs.databases.Count);
                 GetNewIDs(database, masterIDs);
                 if (!VerifyUniqueConversationIDs(database))
                 {
                     return;
                 }
             }
         }
         for (int i = 0; i < distinct.Count; i++)
         {
             var database = distinct[i];
             if (database != null)
             {
                 EditorUtility.DisplayProgressBar("Processing Databases (Phase 2/2)", database.name, i / prefs.databases.Count);
                 ProcessDatabase(database, masterIDs);
                 EditorUtility.SetDirty(database);
             }
         }
         if (verbose)
         {
             report += "\n";
         }
         report += "Assigned unique IDs to " + prefs.databases.Count + " databases.";
         AssetDatabase.SaveAssets();
     }
     finally
     {
         EditorUtility.ClearProgressBar();
         Debug.Log(report);
     }
 }
Пример #21
0
 private void ProcessDatabase(DialogueDatabase database, MasterIDs masterIDs)
 {
     if (verbose) Debug.Log(string.Format("{0}: Converting IDs in database {1}", DialogueDebug.Prefix, database.name));
     ProcessConversations(database, masterIDs);
     ProcessActors(database, masterIDs);
     ProcessItems(database, masterIDs);
     ProcessLocations(database, masterIDs);
     ProcessVariables(database, masterIDs);
 }
Пример #22
0
 private void GetNewIDs(DialogueDatabase database, MasterIDs masterIDs)
 {
     if (verbose) Debug.Log(string.Format("{0}: Determining new IDs for database {1}", DialogueDebug.Prefix, database.name));
     GetNewActorIDs(database, masterIDs);
     GetNewItemIDs(database, masterIDs);
     GetNewLocationIDs(database, masterIDs);
     GetNewVariableIDs(database, masterIDs);
 }
Пример #23
0
 private void GetNewItemIDs(DialogueDatabase database, MasterIDs masterIDs)
 {
     foreach (var item in database.items) {
         if (masterIDs.items.ContainsKey(item.Name)) {
             masterIDs.items[item.Name].oldID = item.id;
         } else {
             int newID;
             if (item.id <= masterIDs.highestItemID) {
                 masterIDs.highestItemID++;
                 newID = masterIDs.highestItemID;
             } else {
                 masterIDs.highestItemID = item.id;
                 newID = item.id;
             }
             masterIDs.items.Add(item.Name, new IDConversion(item.id, newID));
         }
     }
 }
Пример #24
0
 private void GetNewLocationIDs(DialogueDatabase database, MasterIDs masterIDs)
 {
     foreach (var location in database.locations) {
         if (masterIDs.locations.ContainsKey(location.Name)) {
             masterIDs.locations[location.Name].oldID = location.id;
         } else {
             int newID;
             if (location.id <= masterIDs.highestLocationID) {
                 masterIDs.highestLocationID++;
                 newID = masterIDs.highestLocationID;
             } else {
                 masterIDs.highestLocationID = location.id;
                 newID = location.id;
             }
             masterIDs.locations.Add(location.Name, new IDConversion(location.id, newID));
         }
     }
 }
Пример #25
0
 private void GetNewVariableIDs(DialogueDatabase database, MasterIDs masterIDs)
 {
     foreach (var variable in database.variables) {
         if (masterIDs.variables.ContainsKey(variable.Name)) {
             masterIDs.variables[variable.Name].oldID = variable.id;
         } else {
             int newID;
             if (variable.id <= masterIDs.highestVariableID) {
                 masterIDs.highestVariableID++;
                 newID = masterIDs.highestVariableID;
             } else {
                 masterIDs.highestVariableID = variable.id;
                 newID = variable.id;
             }
             masterIDs.variables.Add(variable.Name, new IDConversion(variable.id, newID));
         }
     }
 }
Пример #26
0
 private void ProcessActors(DialogueDatabase database, MasterIDs masterIDs)
 {
     foreach (var actor in database.actors) {
         int newID = FindIDConversion(actor.Name, masterIDs.actors, actor.id);
         if (newID != actor.id) {
             if (verbose) Debug.Log(string.Format("{0}: Actor {1}: ID [{2}]-->[{3}]", DialogueDebug.Prefix, actor.Name, actor.id, newID));
             actor.id = newID;
         }
         ProcessFieldIDs(database, actor.fields, masterIDs);
     }
 }
Пример #27
0
 private void ProcessLocations(DialogueDatabase database, MasterIDs masterIDs)
 {
     foreach (var location in database.locations) {
         int newID = FindIDConversion(location.Name, masterIDs.locations, location.id);
         if (newID != location.id) {
             if (verbose) Debug.Log(string.Format("{0}: Location {1}: ID [{2}]-->[{3}]", DialogueDebug.Prefix, location.Name, location.id, newID));
             location.id = newID;
         }
         ProcessFieldIDs(database, location.fields, masterIDs);
     }
 }
Пример #28
0
        private Dictionary <int, int> GetNewConversationIDs(DialogueDatabase database, MasterIDs masterIDs)
        {
            Dictionary <int, int> newIDs = new Dictionary <int, int>();

            foreach (var conversation in database.conversations)
            {
                int newID = conversation.id;
                if (conversation.id <= masterIDs.highestConversationID)
                {
                    masterIDs.highestConversationID++;
                    newID = masterIDs.highestConversationID;
                    newIDs.Add(conversation.id, newID);
                }
                else
                {
                    masterIDs.highestConversationID = conversation.id;
                }
            }
            return(newIDs);
        }
Пример #29
0
 private Dictionary<int, int> GetNewConversationIDs(DialogueDatabase database, MasterIDs masterIDs)
 {
     Dictionary<int, int> newIDs = new Dictionary<int, int>();
     foreach (var conversation in database.conversations) {
         int newID = conversation.id;
         if (conversation.id <= masterIDs.highestConversationID) {
             masterIDs.highestConversationID++;
             newID = masterIDs.highestConversationID;
             newIDs.Add(conversation.id, newID);
         } else {
             masterIDs.highestConversationID = conversation.id;
         }
     }
     return newIDs;
 }
Пример #30
0
 private void ProcessFieldIDs(DialogueDatabase database, List<Field> fields, MasterIDs masterIDs)
 {
     foreach (var field in fields) {
         int oldID = Tools.StringToInt(field.value);
         switch (field.type) {
         case FieldType.Actor:
             Actor actor = database.GetActor(oldID);
             if (actor != null) field.value = FindIDConversion(actor.Name, masterIDs.actors, oldID).ToString();
             break;
         case FieldType.Item:
             Item item = database.GetItem(oldID);
             if (item != null) field.value = FindIDConversion(item.Name, masterIDs.items, oldID).ToString();
             break;
         case FieldType.Location:
             Location location = database.GetLocation(oldID);
             if (location != null) field.value = FindIDConversion(location.Name, masterIDs.locations, oldID).ToString();
             break;
         }
     }
 }
Пример #31
0
 private void ProcessItems(DialogueDatabase database, MasterIDs masterIDs)
 {
     foreach (var item in database.items) {
         int newID = FindIDConversion(item.Name, masterIDs.items, item.id);
         if (newID != item.id) {
             if (verbose) Debug.Log(string.Format("{0}: Item {1}: ID [{2}]-->[{3}]", DialogueDebug.Prefix, item.Name, item.id, newID));
             item.id = newID;
         }
         ProcessFieldIDs(database, item.fields, masterIDs);
     }
 }
Пример #32
0
 private void ProcessConversations(DialogueDatabase database, MasterIDs masterIDs)
 {
     Dictionary<int, int> newIDs = GetNewConversationIDs(database, masterIDs);
     foreach (var conversation in database.conversations) {
         if (newIDs.ContainsKey(conversation.id)) {
             if (verbose) Debug.Log(string.Format("{0}: Conversation '{1}': ID [{2}]-->[{3}]", DialogueDebug.Prefix, conversation.Title, conversation.id, newIDs[conversation.id]));
             conversation.id = newIDs[conversation.id];
             ProcessFieldIDs(database, conversation.fields, masterIDs);
             foreach (DialogueEntry entry in conversation.dialogueEntries) {
                 entry.conversationID = conversation.id;
                 ProcessFieldIDs(database, entry.fields, masterIDs);
                 foreach (var link in entry.outgoingLinks) {
                     if (newIDs.ContainsKey(link.originConversationID)) link.originConversationID = newIDs[link.originConversationID];
                     if (newIDs.ContainsKey(link.destinationConversationID)) link.destinationConversationID = newIDs[link.destinationConversationID];
                 }
             }
         }
     }
 }
Пример #33
0
 private void ProcessVariables(DialogueDatabase database, MasterIDs masterIDs)
 {
     foreach (var variable in database.variables) {
         int newID = FindIDConversion(variable.Name, masterIDs.variables, variable.id);
         if (newID != variable.id) {
             if (verbose) Debug.Log(string.Format("{0}: Variable {1}: ID [{2}]-->[{3}]", DialogueDebug.Prefix, variable.Name, variable.id, newID));
             variable.id = newID;
         }
         ProcessFieldIDs(database, variable.fields, masterIDs);
     }
 }
Пример #34
0
        private Dictionary <int, int> GetNewConversationIDs(DialogueDatabase database, MasterIDs masterIDs)
        {
            Dictionary <int, int> newIDs = new Dictionary <int, int>();

            foreach (var conversation in database.conversations)
            {
                int newID = conversation.id;
                if (conversation.id <= masterIDs.highestConversationID)
                {
                    masterIDs.highestConversationID++;
                    newID = masterIDs.highestConversationID;
                    if (!newIDs.ContainsKey(conversation.id))
                    {
                        newIDs.Add(conversation.id, newID);
                    }
                    else
                    {
                        var s = "Unique ID Tool error: In '" + database + "' more than one conversation uses ID " + conversation.id + ".";
                        Debug.LogError(s, database);
                        report += "\n" + s;
                    }
                }
                else
                {
                    masterIDs.highestConversationID = conversation.id;
                }
            }
            return(newIDs);
        }
Пример #35
0
 private void GetNewActorIDs(DialogueDatabase database, MasterIDs masterIDs)
 {
     foreach (var actor in database.actors) {
         if (masterIDs.actors.ContainsKey(actor.Name)) {
             masterIDs.actors[actor.Name].oldID = actor.id;
         } else {
             int newID;
             if (actor.id <= masterIDs.highestActorID) {
                 masterIDs.highestActorID++;
                 newID = masterIDs.highestActorID;
             } else {
                 masterIDs.highestActorID = actor.id;
                 newID = actor.id;
             }
             masterIDs.actors.Add(actor.Name, new IDConversion(actor.id, newID));
         }
     }
 }