Shuffled around some files, started adding property editing for run_path

This commit is contained in:
Malcolm Roberts 2024-01-15 14:50:04 -06:00
parent 8a46c2c4bb
commit c6e1330e17
14 changed files with 432 additions and 164 deletions

View File

@ -1,100 +0,0 @@
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",
"horizontalAlignment": "left",
"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["${Script.CurrentDirectory}/property_editors/npc_dialog_properties.json"]
}
method OnSetNPCNameButtonClick()
{
This.CurrentNPCName:Set["${Me.Target.Name}"]
}
}

View File

@ -0,0 +1,62 @@
#include "${LavishScript.HomeDirectory}/scripts/mr/common/file_helpers.iss"
objectdef NPCDialogPropertiesController
{
variable string CurrentDialogOptions
variable string CurrentNPCName
variable jsonvalue propertyEditorUi ="{}"
variable jsonvalue listViewUi ="{}"
variable string StepType = "npc_dialog"
variable string PropertyPath
member:jsonvalueref GetUI()
{
return propertyEditorUi
}
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 string options = "N/A"
variable string npcName = "N/A"
variable jsonvalue theUi
theUi:SetValue["${this.listViewUi}"]
npcName:Set["${step.Get["params","npc_name"]}"]
options:Set["${step.Get["params","dialog_options"]}"]
theUi:ParseFile["${This.PropertyPath}/list_ui.json"]
theUi.Get["children", 2, "children", 2]:SetString["text", "${npcName}"]
theUi.Get["children", 3, "children", 2]:SetString["text", "${options}"]
return theUi
}
method Initialize()
{
This.PropertyPath:Set["${FileHelpers.GetDirectoryFromFilePath["_FILE_"]}"]
propertyEditorUi:ParseFile["${This.PropertyPath}/editor_ui.json"]
listViewUi:ParseFile["${This.PropertyPath}/list_ui.json"]
}
method OnSetNPCNameButtonClick()
{
This.CurrentNPCName:Set["${Me.Target.Name}"]
}
}

View File

@ -0,0 +1,51 @@
{
"$schema": "http://www.lavishsoft.com/schema/lgui2Package.json",
"type": "stackpanel",
"orientation": "vertical",
"horizontalAlignment": "left",
"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": ""
}
]
},
{
"type": "stackpanel",
"orientation": "horizontal",
"horizontalAlignment": "stretch",
"padding": [5, 0, 0, 0],
"children": [
{
"type": "textblock",
"text": "Options:",
"margin": [0, 0, 5, 0]
},
{
"type": "textblock",
"text": ""
}
]
}
]
}

View File

@ -1,19 +1,26 @@
#ifndef _mr_property_editors_
#define _mr_property_editors_
#includeoptional "${LavishScript.HomeDirectory}/Scripts/mr/auto_quest/property_editors/npc_dialog_properties.iss"
#includeoptional "${LavishScript.HomeDirectory}/Scripts/mr/auto_quest/property_editors/npc_dialog_properties/editor.iss"
#includeoptional "${LavishScript.HomeDirectory}/Scripts/mr/auto_quest/property_editors/run_path_properties/editor.iss"
variable(global) NPCDialogPropertiesController MRNPCDialogPropertiesController
variable(global) RunPathPropertiesController MRRunPathPropertiesController
objectdef PropertyEditors
{
static method GetPropertyEditor( string stepType )
static member GetPropertyEditor( string stepType )
{
switch ( stepType )
if ${stepType.Equal["${MRNPCDialogPropertiesController.StepType}"]}
{
case MRNPCDialogPropertiesController.StepType:
return MRNPCDialogPropertiesController;
return MRNPCDialogPropertiesController;
}
if ${stepType.Equal["${MRRunPathPropertiesController.StepType}"]}
{
return MRRunPathPropertiesController;
}
return null;
}
}

View File

@ -0,0 +1,74 @@
#include "${LavishScript.HomeDirectory}/scripts/mr/common/file_helpers.iss"
objectdef RunPathPropertiesController
{
variable jsonvalue PropertyEditorUi ="{}"
variable jsonvalue ListViewUi ="{}"
variable jsonvalue PathToRun = "[]"
variable string StepType = "run_path"
variable string PropertyPath
member:jsonvalueref GetUI()
{
return PropertyEditorUi
}
member:float GetDistanceFromLastPoint()
{
if ${PathToRun.Used} == 0
{
return 0
}
variable jsonvalueref lastPoint = PathToRun.Get[${PathToRun.Used}]
return ${Math.Distance["${Me.Loc.X}", "${Me.Loc.Y}", "${Me.Loc.Z}", "${lastPoint.Get["x"]}", "${lastPoint.Get["y"]}", "${lastPoint.Get["z"]}"]}
}
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 theUi
theUi:SetValue["${this.ListViewUi}"]
theUi:ParseFile["${This.PropertyPath}/list_ui.json"]
; theUi.Get["children", 2, "children", 2]:SetString["text", "${npcName}"]
; theUi.Get["children", 3, "children", 2]:SetString["text", "${options}"]
return theUi
}
method Initialize()
{
This.PropertyPath:Set["${FileHelpers.GetDirectoryFromFilePath["_FILE_"]}"]
PropertyEditorUi:ParseFile["${This.PropertyPath}/editor_ui.json"]
ListViewUi:ParseFile["${This.PropertyPath}/list_ui.json"]
}
method OnAddPointClick()
{
PathToRun:Add[$$>"{
x: ${Me.Loc.X},
y: ${Me.Loc.Y},
z: ${Me.Loc.Z}
}"<$$]
}
}

View File

@ -0,0 +1,63 @@
{
"$schema": "http://www.lavishsoft.com/schema/lgui2Package.json",
"type": "stackpanel",
"name": "mr.quest_writer.run_path_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": "Run Path Properties",
"font": {
"bold": true,
"heightFactor": 1.2
},
"horizontalAlignment": "center",
"widthFactor": 1
}
]
},
{
"type": "button",
"name": "mr.quest_writer.run_path_properties.add_point",
"content": "Add Point",
"tooltip": "Add a point.",
"horizontalAlignment": "stretch",
"eventHandlers": {
"onRelease": [
"method",
"MRRunPathPropertiesController",
"OnAddPointClick"
]
}
},
{
"type": "stackpanel",
"widthFactor": 1,
"children": [
{
"type": "textblock",
"text": "Distance From Last"
},
{
"type": "textblock",
"textBinding": {
"pullFormat": "${MRRunPathPropertiesController.GetDistanceFromLastPoint}"
}
}
]
}
]
}

View File

@ -0,0 +1,51 @@
{
"$schema": "http://www.lavishsoft.com/schema/lgui2Package.json",
"type": "stackpanel",
"orientation": "vertical",
"horizontalAlignment": "left",
"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": ""
}
]
},
{
"type": "stackpanel",
"orientation": "horizontal",
"horizontalAlignment": "stretch",
"padding": [5, 0, 0, 0],
"children": [
{
"type": "textblock",
"text": "Options:",
"margin": [0, 0, 5, 0]
},
{
"type": "textblock",
"text": ""
}
]
}
]
}

View File

@ -89,10 +89,11 @@ objectdef QuestWriterController
Script:End
}
method OnNPCDialogButtonClick()
method OnConfigureNewStep()
{
CurrentStepProperties:SetReference[MRNPCDialogPropertiesController]
LGUI2.Element["mr.quest_writer.properties_panel"]:AddChild[MRNPCDialogPropertiesController.GetUI]
LGUI2.Element["mr.quest_writer.properties_panel"]:ClearChildren
CurrentStepProperties:SetReference[${PropertyEditors.GetPropertyEditor[${Context.Source.Metadata.Get["stepType"]}]}]
LGUI2.Element["mr.quest_writer.properties_panel"]:AddChild[CurrentStepProperties.GetUI]
}
method OnTestStepButtonClick()
@ -107,6 +108,7 @@ objectdef QuestWriterController
{
This.QuestSteps:Add["${This.CurrentStepProperties.GetDialogOptions.AsJSON~}"]
LGUI2.Element[MRQuestWriterController.events]:FireEventHandler[onNewStepAdded]
LGUI2.Element["mr.quest_writer.properties_panel"]:ClearChildren
}
}

View File

@ -168,11 +168,12 @@
"name": "mr.quest_writer.npc_dialog",
"content": "NPC Dialog",
"widthFactor": 1,
"_stepType": "npc_dialog",
"eventHandlers": {
"onRelease": [
"method",
"MRQuestWriterController",
"OnNPCDialogButtonClick"
"OnConfigureNewStep"
]
}
},
@ -180,13 +181,29 @@
"type": "button",
"name": "mr.quest_writer.run_path",
"content": "Run Path",
"widthFactor": 1
"_stepType": "run_path",
"widthFactor": 1,
"eventHandlers": {
"onRelease": [
"method",
"MRQuestWriterController",
"OnConfigureNewStep"
]
}
},
{
"type": "button",
"name": "mr.quest_writer.kill_mobs",
"content": "Kill Mobs",
"widthFactor": 1
"_stepType": "kill_mobs",
"widthFactor": 1,
"eventHandlers": {
"onRelease": [
"method",
"MRQuestWriterController",
"OnConfigureNewStep"
]
}
}
]
}

13
common/file_helpers.iss Normal file
View File

@ -0,0 +1,13 @@
#ifndef _mr_file_helpers_
#define _mr_file_helpers_
objectdef FileHelpers
{
static member:string GetDirectoryFromFilePath(string fullPathToFile)
{
variable int lastTokenNum = ${Math.Calc[${fullPathToFile.Count["/"]} + 1]}
return ${fullPathToFile.ReplaceSubstring["${fullPathToFile.Token[${lastTokenNum}, "/"]}", ""]}
}
}
#endif

71
mr.iss
View File

@ -1,24 +1,23 @@
#include "${LavishScript.HomeDirectory}/Scripts/EQ2Navigation/EQ2Nav_Lib.iss"
variable EQ2Nav Nav
function StopRunning()
{
echo "Stop Running"
press -hold "${Nav.MOVEBACKWARD}"
waitframe
press -release "${Nav.MOVEBACKWARD}"
}
function main(... params)
{
if !${Script[Relay](exists)}
{
RunScript "${LavishScript.HomeDirectory}/Scripts/mr/common/Relay"
}
variable string command = ${params[1].Lower}
if ${command.Equal["osa"]}
if ${command.Equal["init"]}
{
alias mr run mr
if !${Script[Relay](exists)}
{
RunScript "${LavishScript.HomeDirectory}/Scripts/mr/common/Relay"
}
if !${Script[Movement](exists)}
{
RunScript "${LavishScript.HomeDirectory}/Scripts/mr/common/Navigation/Movement"
}
}
elseif ${command.Equal["osa"]}
{
run mr/osa/osa
}
@ -35,43 +34,9 @@ function main(... params)
{
run mr/auto_quest/writer
}
elseif ${command.Equal["!c"]}
{
variable jsonvalue rest = []
rest:Erase[1]
if !${MRNav(exists)}
{
RunScript "${LavishScript.HomeDirectory}/Scripts/mr/common/Navigation/Movement"
}
run mr/commands/ProcessCommand ${rest}
}
elseif ${command.Equal["test"]}
{
Nav.AUTORUN:Set["num lock"]
Nav.MOVEBACKWARD:Set["s"]
Nav.STRAFELEFT:Set["e"]
Nav.STRAFERIGHT:Set["q"]
; run mr/common/Navigation/test
echo "loading map"
Nav:UseLSO[FALSE]
Nav:LoadMap
Nav.SmartDestinationDetection:Set[FALSE]
Nav.BackupTime:Set[3]
Nav.StrafeTime:Set[3]
echo "moving to crafting"
Nav.DestinationPrecision:Set[1]
Nav:MoveToRegion["guild hall"]
do
{
Nav:Pulse
wait 1
}
while ${Nav.Moving}
call StopRunning
run mr/test
}
}
}

12
test.iss Normal file
View File

@ -0,0 +1,12 @@
function main()
{
variable string someValue = "some_npc_name"
variable string options = "some_option_value_1, some_option_value_2, some_option_value_3"
variable jsonvalue theUi
theUi:ParseFile["test.json"]
theUi.Get["children", 2, "children", 2]:SetString["text", "${someValue}"]
echo "${theUi.Get["children", 3, "children", 2]}"
theUi.Get["children", 3, "children", 2]:SetString["text", "${options}"]
echo "Value: ${theUi}
}

51
test.json Normal file
View File

@ -0,0 +1,51 @@
{
"$schema": "http://www.lavishsoft.com/schema/lgui2Package.json",
"type": "stackpanel",
"orientation": "vertical",
"horizontalAlignment": "left",
"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": ""
}
]
},
{
"type": "stackpanel",
"orientation": "horizontal",
"horizontalAlignment": "stretch",
"padding": [5, 0, 0, 0],
"children": [
{
"type": "textblock",
"text": "Options:",
"margin": [0, 0, 5, 0]
},
{
"type": "textblock",
"text": ""
}
]
}
]
}