private void DrawDlgFile(DlgFile dlgFile, ref DlgFile dlgFileToDelete) { EditorGUILayout.BeginHorizontal(); dlgFile.filename = EditorGUILayout.TextField(dlgFile.filename); if (GUILayout.Button("...", EditorStyles.miniButtonRight, GUILayout.Width(22))) { dlgFile.filename = EditorUtility.OpenFilePanel("Select Dlg.Xml File", lastXmlPath, "xml"); lastXmlPath = EditorWindowTools.GetDirectoryName(dlgFile.filename); GUIUtility.keyboardControl = 0; } dlgFile.actorID = ActorListIndexToActorID(EditorGUILayout.Popup(ActorIDToActorListIndex(dlgFile.actorID), actorList, GUILayout.Width(200))); dlgFile.conversantID = ActorListIndexToActorID(EditorGUILayout.Popup(ActorIDToActorListIndex(dlgFile.conversantID), actorList, GUILayout.Width(200))); if (GUILayout.Button("-", EditorStyles.miniButtonRight, GUILayout.Width(22))) dlgFileToDelete = dlgFile; EditorGUILayout.EndHorizontal(); }
private void LoadVariablesFromDlgFile(DlgFile dlgFile) { try { Dlg dlg = Dlg.Load(dlgFile.filename); if (dlg != null) { if (dlg.EntryList != null) { dlg.EntryList.ForEach(entry => LoadVariablesFromLocalStrings(entry.Text, dlg.name)); } if (dlg.ReplyList != null) { dlg.ReplyList.ForEach(reply => LoadVariablesFromLocalStrings(reply.Text, dlg.name)); } } } catch (System.Exception e) { Debug.LogError(string.Format("{0}: Failed to load {1}. Error: {2}", DialogueDebug.Prefix, dlgFile.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)); } }