objectdef NPCDialogPropertiesController { variable string CurrentDialogOptions variable string CurrentNPCName variable jsonvalue ui ="{}" variable string StepType = "npc_dialog" member:jsonvalueref GetUI() { return ui } member:jsonvalueref GetDialogOptions() { variable jsonvalue dialogOptions dialogOptions:SetValue[$$>"{ "type": "${This.StepType}", "params": { "npc_name": ${This.CurrentNPCName.AsJSON~}, "dialog_options": ${This.CurrentDialogOptions.AsJSON~} } }"<$$] return dialogOptions } member:jsonvalueref GetDisplayForProperties(jsonvalueref step) { variable jsonvalue stepItem variable string options variable string npcName options:Set["${step.Get["params","dialog_options"]}"] npcName:Set["${step.Get["params","npc_name"]}"] stepItem:SetValue[$$>"{ "type": "stackpanel", "orientation": "vertical", "children": [ { "type": "textblock", "horizontalAlignment": "stretch", "font": { "bold": true, "heightFactor": 1.1 }, "text": "NPC Dialog" }, { "type": "stackpanel", "orientation": "horizontal", "horizontalAlignment": "stretch", "padding": [5, 0, 0, 0], "children": [ { "type": "textblock", "text": "NPC Name:", "margin": [0, 0, 5, 0] }, { "type": "textblock", "text": ${npcName.AsJSON~} } ] }, { "type": "stackpanel", "orientation": "horizontal", "horizontalAlignment": "stretch", "padding": [5, 0, 0, 0], "children": [ { "type": "textblock", "text": "Options:", "margin": [0, 0, 5, 0] }, { "type": "textblock", "text": ${options.AsJSON~} } ] } ] }"<$$] return stepItem } method Initialize() { ui:ParseFile["npc_dialog_ui.json"] } method OnSetNPCNameButtonClick() { This.CurrentNPCName:Set["${Me.Target.Name}"] } } variable(global) NPCDialogPropertiesController MRNPCDialogPropertiesController objectdef QuestWriterController { variable string CurrentStepType variable weakref CurrentStepProperties variable jsonvalue QuestSteps = [] member:jsonvalueref FormatPropertiesForDisplay(jsonvalue step) { variable jsonvalue stepItem if ${step.Get["type"].Equal["${MRNPCDialogPropertiesController.StepType}"]} { stepItem:SetValue["${MRNPCDialogPropertiesController.GetDisplayForProperties[step].AsJSON~}"] return stepItem } else { return null } } member:string GetQuestStepsForDisplay() { variable jsoniterator stepIterator This.QuestSteps:GetIterator[stepIterator] if ${stepIterator:First(exists)} { variable jsonvalue listItems = "[]" variable jsonvalue stepItem do { listItems:Add["${This.FormatPropertiesForDisplay["${stepIterator.Value.AsJSON~}"].AsJSON~}"] } while ${stepIterator:Next(exists)} } return ${listItems.AsJSON~} } method Initialize() { LGUI2:LoadPackageFile["writer.json"] } method Shutdown() { LGUI2:UnloadPackageFile["writer.json"] } method OnClose() { Script:End } method OnNPCDialogButtonClick() { CurrentStepProperties:SetReference[MRNPCDialogPropertiesController] LGUI2.Element["mr.quest_writer.properties_panel"]:AddChild[MRNPCDialogPropertiesController.GetUI] } method OnAddStepButtonClick() { This.QuestSteps:Add["${This.CurrentStepProperties.GetDialogOptions.AsJSON~}"] LGUI2.Element[MRQuestWriterController.events]:FireEventHandler[onNewStepAdded] } } variable(global) QuestWriterController MRQuestWriterController function main() { while 1 { wait 1 } }