Start of quest writer
This commit is contained in:
parent
c00f3a480d
commit
40e47d36d0
97
auto_quest/npc_dialog_ui.json
Normal file
97
auto_quest/npc_dialog_ui.json
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
{
|
||||||
|
"$schema": "http://www.lavishsoft.com/schema/lgui2Package.json",
|
||||||
|
"type": "stackpanel",
|
||||||
|
"name": "mr.quest_writer.npc_dialog_properties",
|
||||||
|
"_dock": "bottom",
|
||||||
|
"borderBrush": {
|
||||||
|
"color": "#f4f3ee"
|
||||||
|
},
|
||||||
|
"borderThickness": [0, 2, 0, 0],
|
||||||
|
"header": "test",
|
||||||
|
"children": [
|
||||||
|
{
|
||||||
|
"type": "panel",
|
||||||
|
"borderBrush": {
|
||||||
|
"color": "#f4f3ee"
|
||||||
|
},
|
||||||
|
"borderThickness": [0, 0, 0, 1],
|
||||||
|
"margin": [0, 0, 0, 15],
|
||||||
|
"children": [
|
||||||
|
{
|
||||||
|
"type": "textblock",
|
||||||
|
"text": "NPC Dialog Properties",
|
||||||
|
"font": {
|
||||||
|
"bold": true,
|
||||||
|
"heightFactor": 1.2
|
||||||
|
},
|
||||||
|
"horizontalAlignment": "center",
|
||||||
|
"widthFactor": 1
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "textblock",
|
||||||
|
"text": "NPC Name:",
|
||||||
|
"widthFactor": 1,
|
||||||
|
"horizontalAlignment": "left",
|
||||||
|
"font": {
|
||||||
|
"heightFactor": 0.9
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "stackpanel",
|
||||||
|
"orientation": "horizontal",
|
||||||
|
"children": [
|
||||||
|
{
|
||||||
|
"type": "button",
|
||||||
|
"content": "◎",
|
||||||
|
"tooltip": "Set the NPC name to the currently targeted NPC.",
|
||||||
|
"horizontalAlignment": "left",
|
||||||
|
"eventHandlers": {
|
||||||
|
"onRelease": [
|
||||||
|
"method",
|
||||||
|
"MRNPCDialogPropertiesController",
|
||||||
|
"OnSetNPCNameButtonClick"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "textblock",
|
||||||
|
"horizontalAlignment": "left",
|
||||||
|
"widthFactor": 1,
|
||||||
|
"text": "${MRNPCDialogPropertiesController.CurrentNPCName}"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "stackpanel",
|
||||||
|
"orientation": "vertical",
|
||||||
|
"children": [
|
||||||
|
{
|
||||||
|
"type": "textblock",
|
||||||
|
"text": "Dialog Options:",
|
||||||
|
"horizontalAlignment": "left",
|
||||||
|
"widthFactor": 1,
|
||||||
|
"font": {
|
||||||
|
"heightFactor": 0.9
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "textbox",
|
||||||
|
"name": "mr.quest_writer.npc_dialog_dialog_options",
|
||||||
|
"horizontalAlignment": "left",
|
||||||
|
"widthFactor": 1,
|
||||||
|
"tooltip": "A comma separated list of the\nnumber of the dialog option to\npick tomake the quest dialog appear.\n\ne.g. 1,2,1,1,2",
|
||||||
|
"textBinding": {
|
||||||
|
"pullFormat": "${MRNPCDialogPropertiesController.CurrentDialogOptions}",
|
||||||
|
"pullReplaceNull": "",
|
||||||
|
"pushFormat": [
|
||||||
|
"MRNPCDialogPropertiesController.CurrentDialogOptions:Set[\"",
|
||||||
|
"\"]"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@ -1,9 +1,145 @@
|
|||||||
|
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
|
objectdef QuestWriterController
|
||||||
{
|
{
|
||||||
variable string CurrentNPCName
|
|
||||||
variable string CurrentStepType
|
variable string CurrentStepType
|
||||||
variable string CurrentDialogOptions
|
variable weakref CurrentStepProperties
|
||||||
|
|
||||||
variable jsonvalue QuestSteps = []
|
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()
|
method Initialize()
|
||||||
{
|
{
|
||||||
@ -22,43 +158,14 @@ objectdef QuestWriterController
|
|||||||
|
|
||||||
method OnNPCDialogButtonClick()
|
method OnNPCDialogButtonClick()
|
||||||
{
|
{
|
||||||
CurrentStepType:Set["ncp_dialog"]
|
CurrentStepProperties:SetReference[MRNPCDialogPropertiesController]
|
||||||
LGUI2.Element["mr.quest_writer.npc_dialog_properties"]:SetVisibility["visible"]
|
LGUI2.Element["mr.quest_writer.properties_panel"]:AddChild[MRNPCDialogPropertiesController.GetUI]
|
||||||
}
|
|
||||||
|
|
||||||
method OnSetNPCNameButtonClick()
|
|
||||||
{
|
|
||||||
echo "Setting NPC Name to ${Me.Target.Name}"
|
|
||||||
This.CurrentNPCName:Set["${Me.Target.Name}"]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
method OnAddStepButtonClick()
|
method OnAddStepButtonClick()
|
||||||
{
|
{
|
||||||
variable jsonvalue newStep
|
This.QuestSteps:Add["${This.CurrentStepProperties.GetDialogOptions.AsJSON~}"]
|
||||||
|
LGUI2.Element[MRQuestWriterController.events]:FireEventHandler[onNewStepAdded]
|
||||||
newStep:SetValue[$$>"{
|
|
||||||
"type": ${This.CurrentStepType.AsJSON~},
|
|
||||||
"params": {
|
|
||||||
"npc_name": ${This.CurrentNPCName.AsJSON~},
|
|
||||||
"dialog_options": ${This.CurrentDialogOptions.AsJSON~}
|
|
||||||
}
|
|
||||||
}"<$$]
|
|
||||||
This.QuestSteps:Add["${newStep.AsJSON~}"]
|
|
||||||
|
|
||||||
echo "Current Steps ${This.QuestSteps.AsJSON~}"
|
|
||||||
}
|
|
||||||
|
|
||||||
member:jsonvalueref CurrentSteps()
|
|
||||||
{
|
|
||||||
variable jsonvalue questList
|
|
||||||
|
|
||||||
questList:SetValue[$$>"[
|
|
||||||
"Step 1",
|
|
||||||
"Step 2",
|
|
||||||
"Step 3",
|
|
||||||
]"<$$]
|
|
||||||
|
|
||||||
return questList
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -67,7 +174,6 @@ variable(global) QuestWriterController MRQuestWriterController
|
|||||||
|
|
||||||
function main()
|
function main()
|
||||||
{
|
{
|
||||||
echo "${MRQuestWriterController.CurrentSteps.AsJSON~}"
|
|
||||||
while 1
|
while 1
|
||||||
{
|
{
|
||||||
wait 1
|
wait 1
|
||||||
|
|||||||
@ -8,41 +8,6 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"templates": {
|
"templates": {
|
||||||
"mr.quest_writer.quest_steps.list_entry": {
|
|
||||||
"jsontemplate": "listboxitem",
|
|
||||||
"padding": 2,
|
|
||||||
"borderBrush": {
|
|
||||||
"color": "#f4f3ee"
|
|
||||||
},
|
|
||||||
"borderThickness": [0, 0, 0, 1],
|
|
||||||
"content": {
|
|
||||||
"type": "stackpanel",
|
|
||||||
"orientation": "vertical",
|
|
||||||
"-contentContainer": {
|
|
||||||
"jsonTemplate": "listbox.contentContainerFitWidth"
|
|
||||||
},
|
|
||||||
"children": [
|
|
||||||
{
|
|
||||||
"type": "textblock",
|
|
||||||
"horizontalAlignment": "stretch",
|
|
||||||
"font": {
|
|
||||||
"bold": true,
|
|
||||||
"heightFactor": 1.1
|
|
||||||
},
|
|
||||||
"textBinding": {
|
|
||||||
"pullFormat": "${_CONTEXTITEMDATA_.Get[type]}"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "textblock",
|
|
||||||
"horizontalAlignment": "stretch",
|
|
||||||
"textBinding": {
|
|
||||||
"pullFormat": "${_CONTEXTITEMDATA_.Get[params].AsJSON[multiline]}"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"window.title": {
|
"window.title": {
|
||||||
"verticalAlignment": "center",
|
"verticalAlignment": "center",
|
||||||
"margin": [2, 0, 0, 0]
|
"margin": [2, 0, 0, 0]
|
||||||
@ -100,6 +65,11 @@
|
|||||||
"heightFactor": 1,
|
"heightFactor": 1,
|
||||||
"orientation": "horizontal",
|
"orientation": "horizontal",
|
||||||
"children": [
|
"children": [
|
||||||
|
{
|
||||||
|
"type": "panel",
|
||||||
|
"visibility": "hidden",
|
||||||
|
"name": "MRQuestWriterController.events"
|
||||||
|
}
|
||||||
{
|
{
|
||||||
"type": "dockpanel",
|
"type": "dockpanel",
|
||||||
"widthFactor": 0.2,
|
"widthFactor": 0.2,
|
||||||
@ -188,101 +158,11 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "stackpanel",
|
"type": "panel",
|
||||||
"name": "mr.quest_writer.npc_dialog_properties",
|
"widthFactor": 1,
|
||||||
"visibility": "hidden",
|
|
||||||
"_dock": "bottom",
|
"_dock": "bottom",
|
||||||
"borderBrush": {
|
"name": "mr.quest_writer.properties_panel",
|
||||||
"color": "#f4f3ee"
|
"children": []
|
||||||
},
|
|
||||||
"borderThickness": [0, 2, 0, 0],
|
|
||||||
"header": "test",
|
|
||||||
"children": [
|
|
||||||
{
|
|
||||||
"type": "panel",
|
|
||||||
"borderBrush": {
|
|
||||||
"color": "#f4f3ee"
|
|
||||||
},
|
|
||||||
"borderThickness": [0, 0, 0, 1],
|
|
||||||
"margin": [0, 0, 0, 15],
|
|
||||||
"children": [
|
|
||||||
{
|
|
||||||
"type": "textblock",
|
|
||||||
"text": "NPC Dialog Properties",
|
|
||||||
"font": {
|
|
||||||
"bold": true,
|
|
||||||
"heightFactor": 1.2
|
|
||||||
},
|
|
||||||
"horizontalAlignment": "center",
|
|
||||||
"widthFactor": 1
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "textblock",
|
|
||||||
"text": "NPC Name:",
|
|
||||||
"widthFactor": 1,
|
|
||||||
"horizontalAlignment": "left",
|
|
||||||
"font": {
|
|
||||||
"heightFactor": 0.9
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "stackpanel",
|
|
||||||
"orientation": "horizontal",
|
|
||||||
"children": [
|
|
||||||
{
|
|
||||||
"type": "button",
|
|
||||||
"content": "◎",
|
|
||||||
"tooltip": "Set the NPC name to the currently targeted NPC.",
|
|
||||||
"horizontalAlignment": "left",
|
|
||||||
"eventHandlers": {
|
|
||||||
"onRelease": [
|
|
||||||
"method",
|
|
||||||
"MRQuestWriterController",
|
|
||||||
"OnSetNPCNameButtonClick"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "textblock",
|
|
||||||
"horizontalAlignment": "left",
|
|
||||||
"widthFactor": 1,
|
|
||||||
"text": "${MRQuestWriterController.CurrentNPCName}"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "stackpanel",
|
|
||||||
"orientation": "vertical",
|
|
||||||
"children": [
|
|
||||||
{
|
|
||||||
"type": "textblock",
|
|
||||||
"text": "Dialog Options:",
|
|
||||||
"horizontalAlignment": "left",
|
|
||||||
"widthFactor": 1,
|
|
||||||
"font": {
|
|
||||||
"heightFactor": 0.9
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "textbox",
|
|
||||||
"name": "mr.quest_writer.npc_dialog_dialog_options",
|
|
||||||
"horizontalAlignment": "left",
|
|
||||||
"widthFactor": 1,
|
|
||||||
"tooltip": "A comma separated list of the\nnumber of the dialog option to\npick tomake the quest dialog appear.\n\ne.g. 1,2,1,1,2",
|
|
||||||
"textBinding": {
|
|
||||||
"pullFormat": "${MRQuestWriterController.CurrentDialogOptions}",
|
|
||||||
"pullReplaceNull": "",
|
|
||||||
"pushFormat": [
|
|
||||||
"MRQuestWriterController.CurrentDialogOptions:Set[\"",
|
|
||||||
"\"]"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@ -302,12 +182,12 @@
|
|||||||
"heightFactor": 1,
|
"heightFactor": 1,
|
||||||
"widthFactor": 1,
|
"widthFactor": 1,
|
||||||
"itemsBinding": {
|
"itemsBinding": {
|
||||||
"pullFormat": "${MRQuestWriterController.QuestSteps}"
|
"pullFormat": "${MRQuestWriterController.GetQuestStepsForDisplay}",
|
||||||
},
|
"autoPull": false,
|
||||||
"itemViewGenerators": {
|
"pullHook": {
|
||||||
"default": {
|
"elementName": "MRQuestWriterController.events",
|
||||||
"type": "template",
|
"flags": "global",
|
||||||
"template": "mr.quest_writer.quest_steps.list_entry"
|
"event": "onNewStepAdded"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user