#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"] if ${jo.Type.NotEqual["object"]} { echo "Error parsing ability list" return } variable jsonvalueref keys keys:SetReference[jo.Keys] variable int idx for (idx:Set[1] ; ${idx} < ${keys.Used} ; idx:Inc) { variable string key key:Set["${keys.Get[${idx}]}"] variable jsonvalue abilityItem = "{}" if ${jo.Get["${key}"].Get[1, "spellBookType"]} < 2 { abilityItem:SetValue["$$>{ "Name": "${key~}", "TargetType": ${jo.Get["${key}"].Get[1, "targetType"]}, "IsBeneficial": ${jo.Get["${key}"].Get[1, "isBeneficial"]}, "GroupRestricted": ${jo.Get["${key}"].Get[1, "groupRestricted"]}, "MaxAoeTargets": ${jo.Get["${key}"].Get[1, "maxAoeTargets"]} }<$$"] abilityListItems:Add["${abilityItem.AsJSON}"] } } } method Shutdown() { } method OnClose() { } method ToggleTargetVisibilityBySelectedAbility(int selectedAbilityIndex) { if ${abilityListItems.Get[${selectedAbilityIndex}, "TargetType"]} != 1 { echo "Hide target: ${abilityListItems.Get[${selectedAbilityIndex}, "TargetType"]}" LGUI2.Element["castStack.ability.target"].Parent:SetVisibility[Hidden] } else { echo "Show target: ${abilityListItems.Get[${selectedAbilityIndex}, "TargetType"]}" LGUI2.Element["castStack.ability.target"].Parent:SetVisibility[Visible] } } method SetCurrentAbility(int selectedIndex) { This:ToggleTargetVisibilityBySelectedAbility[${selectedIndex}] currentSelectedAvailableAbilityIndex:Set[${selectedIndex}] LGUI2.Element[MRSettingsController.events]:FireEventHandler[onNewCastStackItemChanged] newCastStackItem:SetValue["$$>{ "action": "ability", "name": "${abilityListItems.Get[${selectedIndex}, "Name"]}" }<$$"] } method OnCastStackAbilityComboChange(string param) { This:SafeSetNewCastStackItemProperty["${Context.Source.Name.Token[3, "."]}", "${Context.Source.SelectedItem.Data.AsJSON~}"] } method SafeSetNewCastStackItemProperty(string propertyName, string 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]~}" } }