#include "${LavishScript.HomeDirectory}/scripts/mr/common/KnowledgeBook.iss" #include "${LavishScript.HomeDirectory}/scripts/mr/common/JsonHelpers.iss" objectdef SettingsController { variable jsonvalue abilityListItems = "[]" variable jsonvalue currentCastStack = "[]" variable int currentSelectedAvailableAbilityIndex = -1 variable jsonvalue newCastStackItem = "{}" method Initialize() { LavishScript:RegisterEvent[onNewCastStackItemChanged] variable jsonvalue jo jo:ParseFile["${LavishScript.HomeDirectory}/scripts/mr/bot/ability_exports/Ihaihu_shadowknight.json"] abilityListItems:SetValue["${MRJsonHelper.FilterArray[jo, "Details.SpellBookType", "<", 2].AsJSON~}"] } method Shutdown() { } method OnClose() { } method SetCurrentAbility(int selectedIndex) { currentSelectedAvailableAbilityIndex:Set[${selectedIndex}] LGUI2.Element[MRSettingsController.events]:FireEventHandler[onNewCastStackItemChanged] newCastStackItem:SetValue["$$>{ "action": "ability", "name": "${abilityListItems.Get[${selectedIndex}, "Name"]}" "id": "${abilityListItems.Get[${selectedIndex}, "CurrentID"]}" }<$$"] } method OnCastStackAbilityComboChange(string param) { echo "param: ${param}" echo "OnCastStackAbilityComboChange: ${Context.AsJSON~}" newCastStackItem:Set["${Context.Source.Name.Token[3, "."]}", "${Context.Source.SelectedItem.Data.AsJSON~}"] echo "${Context.Source.Name.Token[3, "."]} = ${Context.Source.SelectedItem.Data}" echo "newCastStackItem: ${newCastStackItem.AsJSON[multiline]~}" } method SafeSetNewCastStackItemProperty(string propertyName, string value) { echo "SafeSetNewCastStackItemProperty: ${propertyName} = ${value}" if ${value(exists)} && ${value.NotEqual[""]} { newCastStackItem:Set["${propertyName}", "${value}"] } } member:string SafeGetNewCastStackItemProperty(string propertyName) { if ${newCastStackItem.Has[${propertyName}]} { return ${newCastStackItem.Get[${propertyName}]} } return "" } member GetTargetOptions() { variable jsonvalue targetOptions targetOptions:SetValue[$$>"[ "@Group", "@Raid", "@Me", "@Tank", "@Healer", "@DPS" ]"<$$] ; TODO: Add alias options once aliases are supported return ${targetOptions} } method AddAbility() { echo "AddAbility: ${newCastStackItem.AsJSON[multiline]~}" } }