mrbot/auto_quest/writer.iss

124 lines
3.4 KiB
Plaintext

#include "${LavishScript.HomeDirectory}/Scripts/mr/auto_quest/property_editors/property_editors.iss"
#include "${LavishScript.HomeDirectory}/Scripts/mr/auto_quest/actions/actions.iss"
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
variable jsonvalue listItem
do
{
stepItem:SetValue["${This.FormatPropertiesForDisplay["${stepIterator.Value.AsJSON~}"].AsJSON~}"]
stepItem:Set["_dock", "\"left\""]
stepItem:Set["widthFactor", "0.8"]
listItem:SetValue[$$>"{
"type": "dockpanel",
"widthFactor": .18,
"children": [
${stepItem.AsJSON~},
{
"type": "button",
"content": "Test",
"_dock": "right",
"verticalAlignment": "center",
"_step": ${stepIterator.Value.AsJSON~}
"eventHandlers": {
"onRelease": {
"type": "method",
"object": "MRQuestWriterController",
"method": "OnTestStepButtonClick",
}
}
}
]
}"<$$]
listItems:Add["${listItem.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 OnTestStepButtonClick()
{
variable jsonvalue step
step:SetValue["${Context.Source.Metadata.Get["step"].AsJSON~}"]
echo "${step.AsJSON~}"
QueueCommand call RunAction ${step.Get["type"]} "${step.Get["params"].AsJSON~}"
}
method OnAddStepButtonClick()
{
This.QuestSteps:Add["${This.CurrentStepProperties.GetDialogOptions.AsJSON~}"]
LGUI2.Element[MRQuestWriterController.events]:FireEventHandler[onNewStepAdded]
}
}
variable(global) QuestWriterController MRQuestWriterController
function main()
{
while 1
{
ExecuteQueued
wait 1
}
}