/trunk
Version 3.3.3 |
- Moved dragonriding mounts into their own menu. |
Version 3.3.2 |
- Minor Druid logic updates. |
## Title: Livestock |
## Notes: Enables easy random summoning of vanity pets and mounts, including the option of "smart mounting" |
## Author: Kharthus - Deathwing(US) |
## Version: 3.3.2 |
## Version: 3.3.3 |
## SavedVariablesPerCharacter: LivestockSettings |
LibRecompense\RecompenseTools.lua |
L.LIVESTOCK_FONTSTRING_SHOWCRITTERSLABEL = "Critters" |
L.LIVESTOCK_FONTSTRING_SHOWLANDLABEL = "Land" |
L.LIVESTOCK_FONTSTRING_SHOWFLYINGLABEL = "Flying" |
L.LIVESTOCK_FONTSTRING_SHOWDRAGONLABEL = "Dragon" |
L.LIVESTOCK_FONTSTRING_SHOWWATERLABEL = "Water" |
L.LIVESTOCK_FONTSTRING_SHOWSMARTLABEL = "Smart" |
L.LIVESTOCK_FONTSTRING_MACROBUTTONSTITLE = "Please read the documentation before clicking these buttons!" |
</Scripts> |
</ScrollFrame> |
<ScrollFrame name="LivestockDragonMenuScrollFrameTemplate" inherits="FauxScrollFrameTemplate" virtual="true"> |
<Anchors> |
<Anchor point="TOPLEFT"> |
<Offset> |
<AbsDimension x="0" y="-8"/> |
</Offset> |
</Anchor> |
<Anchor point="BOTTOMRIGHT"> |
<Offset> |
<AbsDimension x="-30" y="8"/> |
</Offset> |
</Anchor> |
</Anchors> |
<Scripts> |
<OnVerticalScroll> |
FauxScrollFrame_OnVerticalScroll(self, offset, 15, Livestock.DragonMenuUpdate) |
</OnVerticalScroll> |
</Scripts> |
</ScrollFrame> |
<ScrollFrame name="LivestockWaterMenuScrollFrameTemplate" inherits="FauxScrollFrameTemplate" virtual="true"> |
<Anchors> |
<Anchor point="TOPLEFT"> |
</ScrollFrame> |
<Frame name="LivestockMenuFrame" parent="UIParent" inherits="LivestockBlueFrameTemplate" movable="true" enableMouse="true" frameStrata="TOOLTIP" hidden="true"> |
<Size x="580" y="40" /> |
<Size x="695" y="40" /> |
<Anchors> |
<Anchor point="CENTER"> |
<Offset x="-150" y="250" /> |
</Scripts> |
</Button> |
<Button name="LivestockWaterMountMenuButton" inherits="GameMenuButtonTemplate"> |
<Button name="LivestockDragonMountMenuButton" inherits="GameMenuButtonTemplate"> |
<Size x="105" y="25"/> |
<Anchors> |
<Anchor point="LEFT" relativeTo="LivestockFlyingMountMenuButton" relativePoint="RIGHT"> |
</Anchors> |
<Scripts> |
<OnClick> |
Livestock.HeaderButtonOnClick("Dragon") |
</OnClick> |
</Scripts> |
</Button> |
<Button name="LivestockWaterMountMenuButton" inherits="GameMenuButtonTemplate"> |
<Size x="105" y="25"/> |
<Anchors> |
<Anchor point="LEFT" relativeTo="LivestockDragonMountMenuButton" relativePoint="RIGHT"> |
<Offset x="10" y="0" /> |
</Anchor> |
</Anchors> |
<Scripts> |
<OnClick> |
Livestock.HeaderButtonOnClick("Water") |
</OnClick> |
</Scripts> |
nagrand = 1, -- Use Garrison Mounts in Nagrand zone |
travelform = 0, -- enable / disable including Travel Forms in Smart Mount behavior (for druids only) |
partyfave = 0, -- enable / disable using favorite pets / mounts in parties |
version = 3.1, -- SL updates (separate enables for the three mount menus) |
version = 3.1, -- SL updates (separate enables for the four mount menus) |
} |
LIVESTOCK_VERSION = GetAddOnMetadata("Livestock", "Version") |
["LivestockCritterMenuButton"] = L.LIVESTOCK_FONTSTRING_SHOWCRITTERSLABEL, |
["LivestockLandMountMenuButton"] = L.LIVESTOCK_FONTSTRING_SHOWLANDLABEL, |
["LivestockFlyingMountMenuButton"] = L.LIVESTOCK_FONTSTRING_SHOWFLYINGLABEL, |
["LivestockDragonMountMenuButton"] = L.LIVESTOCK_FONTSTRING_SHOWDRAGONLABEL, |
["LivestockWaterMountMenuButton"] = L.LIVESTOCK_FONTSTRING_SHOWWATERLABEL, |
["LivestockCritterMacroButton"] = L.LIVESTOCK_FONTSTRING_SHOWCRITTERSLABEL, |
["LivestockLandMountMacroButton"] = L.LIVESTOCK_FONTSTRING_SHOWLANDLABEL, |
local debug = false |
local modelcounter, LivestockClass = 0 |
local mountfail, critterfail |
local crittersText, landText, flyingText, waterText, mountstable, critterstable, temp = {}, {}, {}, {}, {}, {}, {} -- tables that will be reused |
local crittersText, landText, flyingText, dragonText, waterText, mountstable, critterstable, temp = {}, {}, {}, {}, {}, {}, {}, {} -- tables that will be reused |
local buildtable = { -- this table contains information that we will use for building and rebuilding menus as well as hiding menus |
["CRITTER"] = {token = "Critter", text = crittersText, settings = LivestockSettings.Critters}, |
["LAND"] = {token = "Land", text = landText, settings = LivestockSettings.Mounts}, |
["FLYING"] = { token = "Flying", text = flyingText, settings = LivestockSettings.Mounts}, |
["DRAGON"] = { token = "Dragon", text = dragonText, settings = LivestockSettings.Mounts}, |
["WATER"] = { token = "Water", text = waterText, settings = LivestockSettings.Mounts}, |
} |
local menuLength = 30 |
if LivestockSettings.Mounts[k].show == 1 then |
LivestockSettings.Mounts[k].enableLand = 1 |
LivestockSettings.Mounts[k].enableFlying = 1 |
LivestockSettings.Mounts[k].enableDragon = 1 |
LivestockSettings.Mounts[k].enableWater = 1 |
local name2 = strconcat(k, "-") |
elseif LivestockSettings.Mounts[k].show == 0 then |
LivestockSettings.Mounts[k].enableLand = 0 |
LivestockSettings.Mounts[k].enableFlying = 0 |
LivestockSettings.Mounts[k].enableDragon = 0 |
LivestockSettings.Mounts[k].enableWater = 0 |
LivestockSettings.Mounts[k].show = nil |
end |
if LivestockSettings.Mounts[k].enableDragon == nil then |
LivestockSettings.Mounts[k].enableDragon = 1 |
end |
end |
LivestockSettings.version = defaults.version |
elseif LivestockSettings.version < defaults.version then |
Livestock.BuildMenu("FLYING") |
end |
function Livestock.DragonMenuUpdate() |
Livestock.BuildMenu("DRAGON") |
end |
function Livestock.WaterMenuUpdate() |
Livestock.BuildMenu("WATER") |
end |
-- Menu creation: |
function Livestock.BuildMenu(kind) -- type is a string, either "CRITTER", "LAND", "FLYING", or "WATER" |
function Livestock.BuildMenu(kind) -- type is a string, either "CRITTER", "LAND", "FLYING", "DRAGON", or "WATER" |
kind = string.upper(kind) |
local token = buildtable[kind].token -- buildtable contains references and variables that are specific to each type of menu, indexed by the same string as the variable type |
local settings, mounts, critters = LivestockSettings.Mounts |
elseif kind == "FLYING" then -- code is the same for flying mounts with the appropriate changes; perhaps this could be a function call? |
mounts = 0 |
for k in orderedPairs(settings) do |
if (settings[k].type == "flying" or settings[k].type == "combo" or settings[k].type == "dragon") then |
if (settings[k].type == "flying" or settings[k].type == "combo") then |
mounts = mounts + 1 |
tinsert(mountstable, settings[k].index) |
end |
end |
elseif kind == "DRAGON" then -- code is the same for dragon mounts with the appropriate changes; perhaps this could be a function call? |
mounts = 0 |
for k in orderedPairs(settings) do |
if (settings[k].type == "dragon") then |
mounts = mounts + 1 |
tinsert(mountstable, settings[k].index) |
end |
end |
elseif kind == "WATER" then -- code is the same for water mounts with the appropriate changes; perhaps this could be a function call? |
mounts = 0 |
for k in orderedPairs(settings) do |
header = "LivestockLandMountMenuButton" |
elseif kind == "FLYING" then |
header = "LivestockFlyingMountMenuButton" |
elseif kind == "DRAGON" then |
header = "LivestockDragonMountMenuButton" |
elseif kind == "WATER" then |
header = "LivestockWaterMountMenuButton" |
end |
index = critterstable[buttonplusoffset] |
petID, _, _, _, _, _, _, name = C_PetJournal.GetPetInfoByIndex(index) |
_, _, _, _, _, creatureID = C_PetJournal.GetPetInfoByPetID(petID) |
elseif kind == "LAND" or kind == "FLYING" or kind == "WATER" then |
elseif kind == "LAND" or kind == "FLYING" or kind == "DRAGON" or kind == "WATER" then |
index = mountstable[buttonplusoffset] |
name = C_MountJournal.GetMountInfoByID(index) |
creatureID = C_MountJournal.GetMountInfoExtraByID(index) |
if name and text and (kind == "CRITTER" and settings[name].show == 1) or |
(kind == "LAND" and settings[name].enableLand == 1) or |
(kind == "FLYING" and settings[name].enableFlying == 1) or |
(kind == "DRAGON" and settings[name].enableDragon == 1) or |
(kind == "WATER" and settings[name].enableWater == 1) then -- if the name isn't nil (Blizzard bug sometimes returns nil for companion names >:o) and the settings say this companion is selected then |
if text.SetTextColor ~= nil then |
text:SetTextColor(1, 1, 1) -- set the color of the text to be white |
else |
text:SetTextColor(0.4, 0.4, 0.4) -- color the fontstring according to the new setting |
end |
elseif companionType == "DRAGON" and name then |
settings[name].enableDragon = 1 - settings[name].enableDragon -- toggle the shown setting |
if settings[name].enableDragon == 1 then |
text:SetTextColor(1, 1, 1) |
else |
text:SetTextColor(0.4, 0.4, 0.4) -- color the fontstring according to the new setting |
end |
elseif companionType == "WATER" and name then |
settings[name].enableWater = 1 - settings[name].enableWater -- toggle the shown setting |
if settings[name].enableWater == 1 then |
if companionType == "FLYING" then |
settings[k].enableFlying = 1 |
end |
if companionType == "DRAGON" then |
settings[k].enableDragon = 1 |
end |
if companionType == "WATER" then |
settings[k].enableWater = 1 |
end |
if companionType == "FLYING" then |
settings[k].enableFlying = 0 |
end |
if companionType == "DRAGON" then |
settings[k].enableDragon = 0 |
end |
if companionType == "WATER" then |
settings[k].enableWater = 0 |
end |
LivestockSettings.Mounts[name] = { -- save the index and set the default show value to on |
enableLand = 1, |
enableFlying = 1, |
enableDragon = 1, |
enableWater = 1, |
index = i, |
spellID = spellID, |
if LivestockSettings.newmount == 1 then |
LivestockSettings.Mounts[name].enableLand = 0 |
LivestockSettings.Mounts[name].enableFlying = 0 |
LivestockSettings.Mounts[name].enableDragon = 0 |
LivestockSettings.Mounts[name].enableWater = 0 |
end |
mountstable[name] = true |
Livestock.RecycleTable(temp) |
for k in pairs(LivestockSettings.Mounts) do -- go through the dragon mounts and add the ones that are selected to the temp table |
if (LivestockSettings.Mounts[k].type == "dragon" and LivestockSettings.Mounts[k].enableFlying == 1) then |
if (LivestockSettings.Mounts[k].type == "dragon" and LivestockSettings.Mounts[k].enableDragon == 1) then |
local _, _, _, _, isUsable = C_MountJournal.GetMountInfoByID(LivestockSettings.Mounts[k].index) |
if isUsable == true then |
tinsert(temp, LivestockSettings.Mounts[k].index) |
if (debug) then |
local name = C_MountJournal.GetMountInfoByID(number) |
local _, _, _, _, mountType = C_MountJournal.GetMountInfoExtraByID(number) |
print(format("MOUNT: flying mount is '%s', index '%s', mountType '%s'", name, number, mountType)) |
print(format("MOUNT: dragonriding mount is '%s', index '%s', mountType '%s'", name, number, mountType)) |
end |
C_MountJournal.SummonByID(number) |
if cmd == "nomount" then |
LivestockSettings.Mounts[spellName].enableLand = 0 |
LivestockSettings.Mounts[spellName].enableFlying = 0 |
LivestockSettings.Mounts[spellName].enableDragon = 0 |
LivestockSettings.Mounts[spellName].enableWater = 0 |
print(format(L.LIVESTOCK_INTERFACE_CONFIRMREMOVE, spellName)) |
else |
LivestockSettings.Mounts[spellName].enableLand = 1 |
LivestockSettings.Mounts[spellName].enableFlying = 1 |
LivestockSettings.Mounts[spellName].enableDragon = 1 |
LivestockSettings.Mounts[spellName].enableWater = 1 |
print(format(L.LIVESTOCK_INTERFACE_CONFIRMADD, spellName)) |
end |