private void LoadActorsFromEntry(Struct entry) { if (entry == null) return; string tag = entry.Speaker; if (string.IsNullOrEmpty(tag)) return; if (prefs.Actors.Find(a => string.Equals(a.tag, tag)) != null) return; int actorID = GetNextActorID(); prefs.Actors.Add(new ActorSetting(actorID, TagToActorName(tag), tag)); }
private Item JrlStructToItem(Struct jrlStruct, int itemID) { // Create the item: string itemName = DialogueLua.StringToTableIndex(jrlStruct.GetElementValue("Tag")); if (string.IsNullOrEmpty(itemName)) itemName = itemID.ToString(); Item item = template.CreateItem(itemID, itemName); // Set the misc. fields: Field.SetValue(item.fields, "Is Item", false); Field.SetValue(item.fields, "XP", Tools.StringToInt(jrlStruct.GetElementValue("XP"))); Field.SetValue(item.fields, "Priority", Tools.StringToInt(jrlStruct.GetElementValue("Priority"))); Field.SetValue(item.fields, "Comment", jrlStruct.Comment); // Set the localized description: foreach (var localString in jrlStruct.GetLocalStrings("Name")) { if (localString != null) { if (localString.LanguageID == DefaultLanguageID) { Field.SetValue(item.fields, "Description", ProcessText(localString.value)); } else { string languageName = LanguageIDToLanguageName(localString.languageId); string localizedDescriptionName = string.Format("Description {0}", languageName); Field.SetValue(item.fields, localizedDescriptionName, ProcessText(localString.value), FieldType.Localization); } } } // Set the entries: //List<Struct> entryList = jrlStruct.GetElementStructs("EntryList"); List<Struct> entryList = jrlStruct.GetElementStructs("EntryList"); entryList = entryList.OrderBy(entry => Tools.StringToInt(entry.GetElementValue("ID"))).ToList(); Field.SetValue(item.fields, "Entry Count", (entryList != null) ? entryList.Count : 0); if (entryList != null) { for (int i = 0; i < entryList.Count; i++) { int entryNum = i + 1; int entryID = Tools.StringToInt(entryList[i].GetElementValue("ID")); Field.SetValue(item.fields, string.Format("Entry {0} ID", entryNum), entryID); Field.SetValue(item.fields, string.Format("Entry {0} State", entryNum), "unassigned"); foreach (var localString in entryList[i].GetLocalStrings("Text")) { if (localString != null) { if (localString.LanguageID == DefaultLanguageID) { Field.SetValue(item.fields, string.Format("Entry {0}", entryNum), ProcessText(localString.value)); } else { string languageName = LanguageIDToLanguageName(localString.languageId); string localizedDescriptionName = string.Format("Entry {0} {1}", entryNum, languageName); Field.SetValue(item.fields, localizedDescriptionName, ProcessText(localString.value), FieldType.Localization); } } } Field.SetValue(item.fields, string.Format("Entry {0} End", entryNum), entryList[i].End); } } return item; }
private void MarkEntryScripts(Struct structEntry, DialogueEntry dialogueEntry, string dlgName) { string actionScript = structEntry.Script; string questUpdate = structEntry.Quest; bool hasActionScript = !string.IsNullOrEmpty(actionScript); bool hasQuestUpdate = !string.IsNullOrEmpty(questUpdate); if (hasActionScript || hasQuestUpdate) { if (prefs.ScriptHandlingType == ScriptHandlingType.CustomLuaFunction) { dialogueEntry.userScript = string.Empty; if (hasActionScript) { dialogueEntry.userScript = string.Format("NWScript(\"{0}\")", actionScript); } if (hasQuestUpdate) { if (hasActionScript) dialogueEntry.userScript += "; "; dialogueEntry.userScript += string.Format("Item[\"{0}\"].Entry_{0}_State", DialogueLua.StringToTableIndex(questUpdate), structEntry.QuestEntry); } } else { dialogueEntry.userScript = string.Format("{0}{1} {2}", "--", actionScript, questUpdate); } if (reportQuestsAndScriptsFlag) { Debug.LogWarning(string.Format("{0}: '{1}' entry {2} {3}: {4} {5} -> {6}", DialogueDebug.Prefix, dlgName, structEntry.id, GetTextSnippet(dialogueEntry), actionScript, questUpdate, dialogueEntry.userScript)); } } }
private void MarkLinkCondition(Struct structEntry, Conversation conversation, int destinationDialogueID, string dlgName) { string conditionScript = structEntry.Active; bool hasConditionScript = !string.IsNullOrEmpty(conditionScript); if (hasConditionScript) { DialogueEntry dialogueEntry = conversation.GetDialogueEntry(destinationDialogueID); if (dialogueEntry != null) { if (prefs.ScriptHandlingType == ScriptHandlingType.CustomLuaFunction) { dialogueEntry.conditionsString = string.Format("NWScript(\"{0}\")", conditionScript); } else { dialogueEntry.conditionsString = string.Format("{0}{1}", "true --", conditionScript); } if (reportQuestsAndScriptsFlag) { Debug.LogWarning(string.Format("{0}: '{1}' entry {2} {3} active condition: {4} -> {5}", DialogueDebug.Prefix, dlgName, structEntry.id, GetTextSnippet(dialogueEntry), conditionScript, dialogueEntry.conditionsString)); } } } }
private int LookupSpeaker(Struct entry, int defaultID) { string speakerTag = (entry != null) ? entry.Speaker : null; if (!string.IsNullOrEmpty(speakerTag)) { ActorSetting actorSetting = prefs.Actors.Find(a => string.Equals(speakerTag, a.tag)); if (actorSetting == null) { Debug.LogWarning(string.Format("{0}: Entry {1} references a speaker with tag '{2}', but this tag isn't in the Actors list.", DialogueDebug.Prefix, entry.ID, speakerTag)); } else { return actorSetting.id; } } return defaultID; }