private static void ConvertActors(PixelCrushers.DialogueSystem.ChatMapper.ChatMapperProject chatMapperProject, DialogueDatabase database)
 {
     database.actors = new List<Actor>();
     foreach (var chatMapperActor in chatMapperProject.Assets.Actors) {
         database.actors.Add (new Actor (chatMapperActor));
     }
 }
 private static void ConvertLocations(PixelCrushers.DialogueSystem.ChatMapper.ChatMapperProject chatMapperProject, DialogueDatabase database)
 {
     database.locations = new List<Location>();
     foreach (var chatMapperLocation in chatMapperProject.Assets.Locations) {
         database.locations.Add (new Location (chatMapperLocation));
     }
 }
        /// <summary>
        /// Initializes a new ConversationModel.
        /// </summary>
        /// <param name="database">The database to use.</param>
        /// <param name="title">The title of the conversation in the database.</param>
        /// <param name="actor">Actor.</param>
        /// <param name="conversant">Conversant.</param>
        /// <param name="allowLuaExceptions">If set to <c>true</c> allow Lua exceptions.</param>
        /// <param name="isDialogueEntryValid">Is dialogue entry valid.</param>
        /// <param name="initialDialogueEntryID">Initial dialogue entry ID (-1 to start at beginning).</param>
        /// <param name="stopAtFirstValid">If set to <c>true</c> stop at first valid link from the initial entry.</param>
        public ConversationModel(DialogueDatabase database, string title, Transform actor, Transform conversant, 
		                         bool allowLuaExceptions, IsDialogueEntryValidDelegate isDialogueEntryValid,
		                         int initialDialogueEntryID = -1, bool stopAtFirstValid = false)
        {
            this.allowLuaExceptions = allowLuaExceptions;
            this.database = database;
            this.IsDialogueEntryValid = isDialogueEntryValid;
            DisplaySettings displaySettings = DialogueManager.DisplaySettings;
            if (displaySettings != null) {
                if (displaySettings.cameraSettings != null) entrytagFormat = displaySettings.cameraSettings.entrytagFormat;
                if (displaySettings.inputSettings != null) {
                    emTagForOldResponses = displaySettings.inputSettings.emTagForOldResponses;
                    includeInvalidEntries = displaySettings.inputSettings.includeInvalidEntries;
                }
            }
            Conversation conversation = database.GetConversation(title);
            if (conversation != null) {
                SetParticipants(conversation, actor, conversant);
                if (initialDialogueEntryID == -1) {
                    FirstState = GetState(conversation.GetFirstDialogueEntry(), true, stopAtFirstValid);
                    FixFirstStateSequence();
                } else {
                    FirstState = GetState(conversation.GetDialogueEntry(initialDialogueEntryID), true, stopAtFirstValid);
                }
            } else {
                FirstState = null;
                if (DialogueDebug.LogErrors) Debug.LogWarning(string.Format("{0}: Conversation '{1}' not found in database.", new System.Object[] { DialogueDebug.Prefix, title }));
            }
        }
 private static void ConvertItems(PixelCrushers.DialogueSystem.ChatMapper.ChatMapperProject chatMapperProject, DialogueDatabase database)
 {
     database.items = new List<Item>();
     foreach (var chatMapperItem in chatMapperProject.Assets.Items) {
         database.items.Add (new Item (chatMapperItem));
     }
 }
 /// <summary>
 /// The main export method. Exports a voiceover script to a CSV file.
 /// </summary>
 /// <param name="database">Source database.</param>
 /// <param name="filename">Target CSV filename.</param>
 /// <param name="exportActors">If set to <c>true</c> export actors.</param>
 public static void Export(DialogueDatabase database, string filename, bool exportActors, EntrytagFormat entrytagFormat)
 {
     using (StreamWriter file = new StreamWriter(filename, false, Encoding.UTF8)) {
         ExportDatabaseProperties(database, file);
         if (exportActors) ExportActors(database, file);
         ExportConversations(database, entrytagFormat, file);
     }
 }
 /// <summary>
 /// Adds a database to the master database, and updates the Lua environment.
 /// </summary>
 /// <param name='database'>
 /// The database to add.
 /// </param>
 public void Add(DialogueDatabase database)
 {
     if ((database != null) && !loadedDatabases.Contains(database)) {
         if (loadedDatabases.Count == 0) DialogueLua.InitializeChatMapperVariables();
         DialogueLua.AddChatMapperVariables(database, loadedDatabases);
         masterDatabase.Add(database);
         loadedDatabases.Add(database);
     }
 }
 private static void ExportActors(DialogueDatabase database, StreamWriter file)
 {
     file.WriteLine(string.Empty);
     file.WriteLine("---Actors---");
     file.WriteLine("Name,Description");
     foreach (var actor in database.actors) {
         file.WriteLine(CleanField(actor.Name) + "," + CleanField(actor.LookupValue("Description")));
     }
 }
 private void CreateConversationList(DialogueDatabase database)
 {
     List<string> list = new List<string>();
     if (database != null) {
         list.Add(string.Empty);
         foreach (var conversation in database.conversations) {
             list.Add(conversation.Title);
         }
     }
     conversationList = list.ToArray();
 }
 public ActionConversationPicker(DialogueDatabase database, string currentConversation, bool usePicker)
 {
     this.database = database ?? FindInitialDatabase();
     this.currentConversation = currentConversation;
     this.usePicker = usePicker;
     UpdateTitles();
     bool currentConversationIsInDatabase = (database != null) || (currentIndex >= 0);
     if (usePicker && !string.IsNullOrEmpty(currentConversation) && !currentConversationIsInDatabase) {
         this.usePicker = false;
     }
 }
Example #10
0
 public QuestPicker(DialogueDatabase database, string currentQuest, bool usePicker)
 {
     this.database = database ?? EditorTools.FindInitialDatabase();
     this.currentQuest = currentQuest;
     this.usePicker = usePicker;
     UpdateTitles();
     bool currentQuestIsInDatabase = (database != null) || (currentIndex >= 0);
     if (usePicker && !string.IsNullOrEmpty(currentQuest) && !currentQuestIsInDatabase) {
         this.usePicker = false;
     }
 }
 private static void ConvertProjectAttributes(PixelCrushers.DialogueSystem.ChatMapper.ChatMapperProject chatMapperProject, DialogueDatabase database)
 {
     database.version = chatMapperProject.Version;
     database.author = chatMapperProject.Author;
     database.description = chatMapperProject.Description;
     database.emphasisSettings = new EmphasisSetting[4];
     database.emphasisSettings[0] = new EmphasisSetting(chatMapperProject.EmphasisColor1, chatMapperProject.EmphasisStyle1);
     database.emphasisSettings[1] = new EmphasisSetting(chatMapperProject.EmphasisColor2, chatMapperProject.EmphasisStyle2);
     database.emphasisSettings[2] = new EmphasisSetting(chatMapperProject.EmphasisColor3, chatMapperProject.EmphasisStyle3);
     database.emphasisSettings[3] = new EmphasisSetting(chatMapperProject.EmphasisColor4, chatMapperProject.EmphasisStyle4);
 }
Example #12
0
 /// <summary>
 /// Convert the ArticyData, using the preferences in Prefs, into a dialogue database.
 /// </summary>
 /// <param name='articyData'>
 /// Articy data.
 /// </param>
 /// <param name='prefs'>
 /// Prefs.
 /// </param>
 /// <param name='database'>
 /// Dialogue database.
 /// </param>
 public void Convert(ArticyData articyData, ConverterPrefs prefs, DialogueDatabase database)
 {
     if (articyData != null) {
         Setup(articyData, prefs, database);
         ConvertProjectAttributes();
         ConvertEntities();
         ConvertLocations();
         if (prefs.FlowFragmentMode == ConverterPrefs.FlowFragmentModes.Quests) {
             ConvertFlowFragmentsToQuests();
         }
         ConvertVariables();
         ConvertDialogues();
     }
 }
Example #13
0
		public static void initNPCBattleVariables(DialogueDatabase aDatabase) {
		
		//	v.fields.Add(new Field(all[i]._BATTLENAME,"0",FieldType.Number));
		
			DialogueManager.PreloadMasterDatabase();
			List<NPCBattlesRow> all = NPCBattles.Instance.Rows;
		
			for(int i = 0;i<all.Count;i++) {
				string varName = DialogueLua.GetVariable(all[i]._BattleName).AsString;
				if(varName.Length==0||varName=="nil") {
						DialogueLua.SetVariable(all[i]._BattleName,500);
					} else {
					}
			}
		} 
 private static void ConvertConversations(PixelCrushers.DialogueSystem.ChatMapper.ChatMapperProject chatMapperProject, DialogueDatabase database)
 {
     database.conversations = new List<Conversation>();
     foreach (var chatMapperConversation in chatMapperProject.Assets.Conversations) {
         Conversation conversation = new Conversation(chatMapperConversation);
         SetConversationStartCutsceneToNone(conversation);
         foreach (DialogueEntry entry in conversation.dialogueEntries) {
             foreach (Link link in entry.outgoingLinks) {
                 if (link.destinationConversationID == 0) link.destinationConversationID = conversation.id;
                 if (link.originConversationID == 0) link.originConversationID = conversation.id;
             }
         }
         database.conversations.Add(conversation);
     }
 }
        public override string Draw(string currentValue, DialogueDatabase dataBase)
        {
            if (currentValue == string.Empty)
                currentValue = questStateStrings[0];

            int currentIndex = 0;
            for (int i = 0; i < questStateStrings.Length; i++) {
                var item = questStateStrings [i];
                if (item == currentValue) {
                    currentIndex = i;
                    break;
                }
            }

            int index = EditorGUILayout.Popup(currentIndex, questStateStrings);

            return questStateStrings[index];
        }
Example #16
0
        /// <summary>
        /// Merges a source database into a destination database. Note that if the destination database
        /// has an actor marked IsPlayer, then the source database will use this actor instead of
        /// any IsPlayer actors in the source database. Similarly, only one Alert variable will be added.
        /// This variation allows selective merge of only certain types of assets.
        /// </summary>
        /// <param name="destination">Destination.</param>
        /// <param name="source">Source.</param>
        /// <param name="conflictingIDRule">Specifies how to handle conflicting IDs.</param>
        public static void Merge(DialogueDatabase destination, DialogueDatabase source, ConflictingIDRule conflictingIDRule,
		                         bool mergeProperties, bool mergeActors, bool mergeItems, bool mergeLocations, 
		                         bool mergeVariables, bool mergeConversations)
        {
            if ((destination != null) && (source != null)) {
                switch (conflictingIDRule) {
                case ConflictingIDRule.AllowConflictingIDs:
                    MergeAllowConflictingIDs(destination, source, mergeProperties, mergeActors, mergeItems, mergeLocations, mergeVariables, mergeConversations);
                    break;
                case ConflictingIDRule.AssignUniqueIDs:
                    MergeAssignUniqueIDs(destination, source, mergeProperties, mergeActors, mergeItems, mergeLocations, mergeVariables, mergeConversations);
                    break;
                default:
                    Debug.LogError(string.Format("{0}: Internal error. Unsupported merge type: {1}", new System.Object[] { DialogueDebug.Prefix, conflictingIDRule }));
                    break;
                }
            }
        }
        private static void ExportConversations(DialogueDatabase database, EntrytagFormat entrytagFormat, StreamWriter file)
        {
            file.WriteLine(string.Empty);
            file.WriteLine("---Conversations---");

            // Find all languages: (TO BE IMPLEMENTED LATER)
            //List<string> otherDialogueText = new List<string>();
            //foreach (var conversation in database.conversations) {
            //	foreach (var entry in conversation.dialogueEntries) {
            //		foreach (var field in entry.fields) {
            //		}
            //	}
            //}

            // Cache actor names:
            Dictionary<int, string> actorNames = new Dictionary<int, string>();

            // Export all conversations:
            foreach (var conversation in database.conversations) {
                file.WriteLine(string.Empty);
                file.WriteLine(string.Format("Conversation {0},{1}", conversation.id, CleanField(conversation.Title)));
                file.WriteLine(string.Format("Description,{0}", CleanField(conversation.Description)));
                StringBuilder sb = new StringBuilder("entrytag,Actor,Dialogue Text");
                //foreach (var fieldTitle in otherDialogueText) {
                //	sb.AppendFormat(",{0}", CleanField(fieldTitle));
                //}
                file.WriteLine(sb.ToString());
                foreach (var entry in conversation.dialogueEntries) {
                    if (entry.id > 0) {
                        if (!actorNames.ContainsKey(entry.ActorID)) {
                            Actor actor = database.GetActor(entry.ActorID);
                            actorNames.Add(entry.ActorID, (actor != null) ? CleanField(actor.Name) : "ActorNotFound");
                        }
                        string actorName = actorNames[entry.ActorID];
                        string entrytag = database.GetEntrytag(conversation, entry, entrytagFormat);
                        string lineText = CleanField(entry.SubtitleText);
                        file.WriteLine(string.Format("{0},{1},{2}", entrytag, actorName, lineText));
                    }
                }
            }
        }
 public bool Draw()
 {
     bool changed = false;
     EditorGUILayout.BeginHorizontal();
     if (usePicker) {
         var newDatabase = EditorGUILayout.ObjectField("Reference Database", database, typeof(DialogueDatabase), false) as DialogueDatabase;
         if (newDatabase != database) {
             database = newDatabase;
             UpdateTitles();
         }
     } else {
         var newConversation = EditorGUILayout.TextField("Conversation", currentConversation);
         if (newConversation != currentConversation) {
             changed = true;
             currentConversation = newConversation;
         }
     }
     var newToggleValue = EditorGUILayout.Toggle(usePicker, EditorStyles.radioButton, GUILayout.Width(20));
     if (newToggleValue != usePicker) {
         usePicker = newToggleValue;
         if (usePicker && (database == null)) database = EditorTools.FindInitialDatabase();
         UpdateTitles();
     }
     EditorGUILayout.EndHorizontal();
     if (usePicker) {
         var newIndex = EditorGUILayout.Popup("Conversation", currentIndex, titles);
         if ((newIndex != currentIndex) && (0 <= newIndex) && (newIndex < titles.Length)) {
             changed = true;
             currentIndex = newIndex;
             currentConversation = titles[currentIndex];
         }
         if (database != initialDatabase && database != null && initialDatabase != null) {
             EditorGUILayout.HelpBox("The Dialogue Manager's Initial Database is " + initialDatabase.name +
                                     ". Make sure to load " + this.database.name +
                                     " before using this conversation. You can use the Extra Databases component to load additional databases.",
                                     MessageType.Info);
         }
     }
     return changed;
 }
Example #19
0
        public void Draw()
        {
            if (showReferenceDatabase) {

                // Show with reference database field:
                EditorGUILayout.BeginHorizontal();
                if (usePicker) {
                    var newDatabase = EditorGUILayout.ObjectField("Reference Database", database, typeof(DialogueDatabase), false) as DialogueDatabase;
                    if (newDatabase != database) {
                        database = newDatabase;
                        UpdateTitles();
                    }
                } else {
                    currentQuest = EditorGUILayout.TextField("Quest Name", currentQuest);
                }
                DrawToggle();
                EditorGUILayout.EndHorizontal();

                if (usePicker) {
                    currentIndex = EditorGUILayout.Popup("Quest Name", currentIndex, titles);
                    if (0 <= currentIndex && currentIndex < titles.Length) currentQuest = titles[currentIndex];
                    if (!showReferenceDatabase) {
                        DrawToggle();
                    }
                }
            } else {

                // Show without reference database field:
                EditorGUILayout.BeginHorizontal();
                if (usePicker) {
                    currentIndex = EditorGUILayout.Popup("Quest Name", currentIndex, titles);
                    if (0 <= currentIndex && currentIndex < titles.Length) currentQuest = titles[currentIndex];
                } else {
                    currentQuest = EditorGUILayout.TextField("Quest Name", currentQuest);
                }
                DrawToggle();
                EditorGUILayout.EndHorizontal();
            }
        }
        private void CheckDatabase()
        {
            if (internalDebug) Debug.Log ("CheckDatabase, selection=" + Selection.activeObject + ", savedInstanceID=" + databaseInstanceID);
            if (Selection.activeObject == null) return;
            DialogueDatabase newDatabase = Selection.activeObject as DialogueDatabase;
            if ((newDatabase == null) && (database == null)) {
                newDatabase = EditorUtility.InstanceIDToObject(databaseInstanceID) as DialogueDatabase;
            }
            if ((newDatabase != null) && (newDatabase != database)) {

                if (database != null) {
                    EditorPrefs.DeleteKey(ConversationIDKey);
                }

                //---Unused: bool skipReset = false;
                database = newDatabase;
                databaseInstanceID = database.GetInstanceID();
                if (internalDebug) Debug.Log ("CheckDatabase - set savedInstanceID to " + databaseInstanceID);
                database.SyncAll();
                Reset(); //if (!skipReset) Reset();
                Repaint();
            }
        }
 public void Draw()
 {
     EditorGUILayout.BeginHorizontal();
     if (usePicker) {
         var newDatabase = EditorGUILayout.ObjectField("Reference Database", database, typeof(DialogueDatabase), false) as DialogueDatabase;
         if (newDatabase != database) {
             database = newDatabase;
             UpdateTitles();
         }
     } else {
         currentConversation = EditorGUILayout.TextField(new GUIContent("Conversation Title:", "The title defined in the dialogue database"), currentConversation);
     }
     var newToggleValue = EditorGUILayout.Toggle(usePicker, EditorStyles.radioButton, GUILayout.Width(20));
     if (newToggleValue != usePicker) {
         usePicker = newToggleValue;
         if (usePicker && (database == null)) database = FindInitialDatabase();
         UpdateTitles();
     }
     EditorGUILayout.EndHorizontal();
     if (usePicker) {
         currentIndex = EditorGUILayout.Popup("Conversation Title:", currentIndex, titles);
         if (0 <= currentIndex && currentIndex < titles.Length) currentConversation = titles[currentIndex];
     }
 }
        // This method will probably move to a more appropriate location in a future version:
        private void ValidateDatabase(DialogueDatabase database, bool debug)
        {
            if (database == null || database.actors == null || database.conversations == null) return;
            if (database.actors.Count < 1) database.actors.Add(template.CreateActor(1, "Player", true));

            // Keeps track of nodes that are already connected (link's IsConnector=false):
            HashSet<string> alreadyConnected = new HashSet<string>();

            // Check each conversation:
            foreach (Conversation conversation in database.conversations) {

                // Check item and location fields:
                foreach (Field field in conversation.fields) {
                    if (field.type == FieldType.Location) {
                        if (database.GetLocation(Tools.StringToInt(field.value)) == null) {
                            if (debug) Debug.Log (string.Format ("Fixing location field '{0}' for conversation {1}", field.title, conversation.id));
                            if (database.locations.Count < 1) database.locations.Add(template.CreateLocation(1, "Nowhere"));
                            field.value = database.locations[0].id.ToString();
                        }
                    } else if (field.type == FieldType.Item) {
                        if (database.GetItem(Tools.StringToInt(field.value)) == null) {
                            if (debug) Debug.Log (string.Format ("Fixing item field '{0}' for conversation {1}", field.title, conversation.id));
                            if (database.items.Count < 1) database.items.Add(template.CreateItem(1, "No Item"));
                            field.value = database.items[0].id.ToString();
                        }
                    }
                }

                // Get valid actor IDs for conversation:
                int conversationActorID = (database.GetActor(conversation.ActorID) != null) ? conversation.ActorID : database.actors[0].id;
                if (conversationActorID != conversation.ActorID) {
                    if (debug) Debug.Log (string.Format ("Fixing actor ID for conversation {0}", conversation.id));
                    conversation.ActorID = conversationActorID;
                }
                int conversationConversantID = (database.GetActor(conversation.ConversantID) != null) ? conversation.ConversantID : database.actors[0].id;
                if (conversationConversantID != conversation.ConversantID) {
                    if (debug) Debug.Log (string.Format ("Fixing conversant ID for conversation {0}", conversation.id));
                    conversation.ConversantID = conversationConversantID;
                }

                // Check all dialogue entries:
                foreach (DialogueEntry entry in conversation.dialogueEntries) {

                    // Make sure actor IDs are valid:
                    if (database.GetActor(entry.ActorID) == null) {
                        if (debug) Debug.Log (string.Format ("Fixing actor ID for conversation {0}, entry {1}: actor ID {2}-->{3}", conversation.id, entry.id, entry.ActorID, ((entry.ConversantID == conversationConversantID) ? conversationActorID : conversationConversantID)));
                        entry.ActorID = (entry.ConversantID == conversationConversantID) ? conversationActorID : conversationConversantID;
                    }
                    if (database.GetActor(entry.ConversantID) == null) {
                        if (debug) Debug.Log (string.Format ("Fixing conversant ID for conversation {0}, entry {1}: conversant ID {2}-->{3}", conversation.id, entry.id, entry.ConversantID, ((entry.ActorID == conversationConversantID) ? conversationActorID : conversationConversantID)));
                        entry.ConversantID = (entry.ActorID == conversationConversantID) ? conversationActorID : conversationConversantID;
                    }

                    // Make sure all outgoing links' origins point to this conversation and entry, and set as connector:
                    foreach (Link link in entry.outgoingLinks) {
                        if (link.originConversationID != conversation.id) {
                            if (debug) Debug.Log (string.Format ("Fixing link.originConversationID convID={0}, entryID={1}", conversation.id, entry.id));
                            link.originConversationID = conversation.id;
                        }
                        if (link.originDialogueID != entry.id) {
                            if (debug) Debug.Log (string.Format ("Fixing link.originDialogueID convID={0}, entryID={1}", conversation.id, entry.id));
                            link.originDialogueID = entry.id;
                        }
                        link.isConnector = true;
                    }
                }

                // Traverse tree, assigning non-connector to the first occurrence in the tree:
                AssignConnectors(conversation.GetFirstDialogueEntry(), conversation, alreadyConnected, new HashSet<int>(), 0);
            }
        }
 private void MergeDatabase()
 {
     if (databaseToMerge != null) {
         DatabaseMerger.Merge(database, databaseToMerge, conflictingIDRule, mergeProperties, mergeActors, mergeItems, mergeLocations, mergeVariables, mergeConversations);
         Debug.Log(string.Format("{0}: Merged contents of {1} into {2}.", DialogueDebug.Prefix, databaseToMerge.name, database.name));
         databaseToMerge = null;
     }
 }
 private void DrawMergeSection()
 {
     EditorWindowTools.StartIndentedSection();
     EditorGUILayout.BeginVertical(GroupBoxStyle);
     EditorGUILayout.HelpBox("Use this feature to add the contents of another database to this database.", MessageType.None);
     EditorGUILayout.BeginHorizontal();
     EditorGUILayout.LabelField("Database to Merge into " + database.name);
     databaseToMerge = EditorGUILayout.ObjectField(databaseToMerge, typeof(DialogueDatabase), false) as DialogueDatabase;
     EditorGUILayout.EndHorizontal();
     mergeProperties = EditorGUILayout.Toggle("Merge DB Properties", mergeProperties);
     mergeActors = EditorGUILayout.Toggle("Merge Actors", mergeActors);
     mergeItems = EditorGUILayout.Toggle("Merge Items", mergeItems);
     mergeLocations = EditorGUILayout.Toggle("Merge Locations", mergeLocations);
     mergeVariables = EditorGUILayout.Toggle("Merge Variables", mergeVariables);
     mergeConversations = EditorGUILayout.Toggle("Merge Conversations", mergeConversations);
     EditorGUILayout.BeginHorizontal();
     conflictingIDRule = (DatabaseMerger.ConflictingIDRule) EditorGUILayout.EnumPopup("If IDs Conflict", conflictingIDRule, GUILayout.Width(300));
     GUILayout.FlexibleSpace();
     EditorGUI.BeginDisabledGroup(databaseToMerge == null);
     if (GUILayout.Button("Merge...", GUILayout.Width (100))) {
         if (ConfirmMerge()) MergeDatabase();
     }
     EditorGUI.EndDisabledGroup();
     EditorGUILayout.EndHorizontal();
     EditorGUILayout.EndVertical();
     EditorWindowTools.EndIndentedSection();
 }
 private void ConvertJrl(JrlFile jrlFile, int itemID, DialogueDatabase database)
 {
     Jrl jrl = null;
     try {
         jrl = Jrl.Load(jrlFile.filename, prefs.Encoding);
     } catch (System.Exception e) {
         Debug.LogError(string.Format("{0}: Failed to load {1}. Make sure the file is a valid journal, and check the encoding type. Error: {2}", DialogueDebug.Prefix, jrlFile.filename, e.Message));
     }
     try {
         if (jrl == null) return;
         foreach (var jrlStruct in jrl.Categories) {
             Item item = JrlStructToItem(jrlStruct, itemID++);
             database.items.Add(item);
         }
     } catch (System.Exception e) {
         Debug.LogError(string.Format("{0}: Failed to convert {1}. Error: {2}", DialogueDebug.Prefix, jrlFile.filename, e.Message));
     }
 }
 private void ConvertDlg(DlgFile dlgFile, int conversationID, DialogueDatabase database)
 {
     Dlg dlg = null;
     try {
         dlg = Dlg.Load(dlgFile.filename, prefs.Encoding);
     } catch (System.Exception e) {
         Debug.LogError(string.Format("{0}: Failed to load {1}. Make sure the file is a valid dialog, and check the encoding type. Error: {2}", DialogueDebug.Prefix, dlgFile.filename, e.Message));
         return;
     }
     try {
         if (dlg == null) return;
         CurrentActorID = dlgFile.actorID;
         CurrentConversantID = dlgFile.conversantID;
         database.version = dlg.version;
         activeLanguages.Clear();
         Conversation conversation = DlgToConversation(dlg, conversationID);
         database.conversations.Add(conversation);
         AddActiveLanguagesToAllDialogueEntries(conversation);
     } catch (System.Exception e) {
         Debug.LogError(string.Format("{0}: Failed to convert {1}. Error: {2}", DialogueDebug.Prefix, dlgFile.filename, e.Message));
     }
 }
        private void AddVariablesToDatabase(DialogueDatabase database)
        {
            int variableID = 1;

            // Add custom variables:
            foreach (var variable in prefs.Variables) {
                database.variables.Add(template.CreateVariable(variableID++, DialogueLua.StringToTableIndex(variable.variableName), string.Empty));
            }

            // Add predefined variables:
            foreach (KeyValuePair<string,string> kvp in AuroraPredefinedTokens.All) {
                database.variables.Add(template.CreateVariable(variableID++, kvp.Value, string.Empty));
            }
        }
 private void AddJournalEntriesToDatabase(DialogueDatabase database)
 {
     int itemID = 1;
     foreach (var jrlFile in prefs.JrlFiles) {
         if (!Tools.IsStringNullOrEmptyOrWhitespace(jrlFile.filename)) {
             EditorUtility.DisplayProgressBar("Converting Journal Files", Path.GetFileName(jrlFile.filename), (float) itemID / (float) prefs.JrlFiles.Count);
             ConvertJrl(jrlFile, itemID++, database);
         }
     }
 }
        private void AddEmphasesToDatabase(DialogueDatabase database)
        {
            // <StartAction> tag:
            database.emphasisSettings[StartActionEmphasis].bold = true;
            database.emphasisSettings[StartActionEmphasis].italic = true;
            database.emphasisSettings[StartActionEmphasis].color = Color.red;

            // <StartCheck> tag:
            database.emphasisSettings[StartCheckEmphasis].bold = true;
            database.emphasisSettings[StartCheckEmphasis].color = Color.green;

            // <StartHighlight> tag:
            database.emphasisSettings[StartHighlightEmphasis].bold = true;
            database.emphasisSettings[StartHighlightEmphasis].color = Color.blue;
        }
 private void AddConversationsToDatabase(DialogueDatabase database)
 {
     int conversationID = 1;
     foreach (var dlgFile in prefs.DlgFiles) {
         if (!Tools.IsStringNullOrEmptyOrWhitespace(dlgFile.filename)) {
             EditorUtility.DisplayProgressBar("Converting Aurora Files", Path.GetFileName(dlgFile.filename), (float) conversationID / (float) prefs.DlgFiles.Count);
             ConvertDlg(dlgFile, conversationID++, database);
         }
     }
 }
Example #31
0
 public override void Reset()
 {
     database = null;
 }