/
--[[ |
POSSIBLE EVENTS: |
Mounted |
In town |
Spec (for dual spec) |
Stance/form |
Mana Regen(?) |
PvP --PLAYER_FLAGS_CHANGED, then check for arg1 == "player", then UnitIsPVP("player") |
... |
don't forget to get locals of the global Blizz stuff for performance tweaking |
]] |
local EventEquip = CreateFrame("Frame") |
local mountDelay = CreateFrame("Frame") |
mountDelay:Hide() |
local gmd = GearManagerDialog |
local GameTooltip = GameTooltip |
local tkDrop = LibStub("tekKonfig-Dropdown") |
local eventSelected, setSelected, previousGear |
local eventSelected, setSelected, previousGear, wasPvP, wasMounted, wasResting |
local counter = 0 |
local sets = {"None"} |
local events = {"Primary Talent Spec", |
"Secondary Talent Spec", |
"In Town", |
-- "Mounted", |
-- "PvP", |
"Mounted", |
"PvP", |
} |
local defaults = { previousGear = {}, |
["Primary Talent Spec"] = "None", |
["In Town"] = "None", |
["Mounted"] = "None", |
["PvP"] = "None", |
-- ["Battleground/Arena"] = "None", |
} |
local function CollectPrevious() |
-- print("collecting...") |
EventEquipDB.previousGear = {} |
for i=1,19 do |
EventEquipDB.previousGear[i] = GetInventoryItemLink("player", i) |
end |
end |
local function EquipPrevious() |
-- print("equipping...") |
for i=1,19 do |
EquipItemByName(EventEquipDB.previousGear[i]) |
if EventEquipDB.previousGear[i] == nil then |
EquipmentManager_UnequipItemInSlot(i) |
else |
EquipItemByName(EventEquipDB.previousGear[i]) |
end |
end |
end |
--[[EventEquip["Mounted"] = function() |
local function Mounted() |
if IsMounted() and not wasMounted then --if I am mounted now and wasn't before... |
if not wasResting then --only collect gear and equip mounted set if *not* in town |
CollectPrevious() |
EquipmentManager_EquipSet(EventEquipDB["Mounted"]) |
end |
wasMounted = true |
elseif not IsMounted() and wasMounted then --if I am not mounted anymore but just was... |
if wasResting and EventEquipDB["In Town"] ~= "None" then --if in town, equip that set if there is one |
EquipmentManager_EquipSet(EventEquipDB["In Town"]) |
else |
EquipPrevious() |
end |
wasMounted = false |
end |
end |
function EventEquip.COMPANION_UPDATE(kind) |
if kind == "MOUNT" then --if it's a mount and not a pet... |
mountDelay:Show() --delay IsMounted() check to make sure I'm actually mounted or not - checking at same time as event doesn't work (and the event seems to fire randomly) |
end |
end |
EventEquip["Mounted"] = function() |
if EventEquipDB["Mounted"] == "None" then |
EventEquip:UnregisterEvent("COMPANION_UPDATE") |
return |
else |
EventEquip:RegisterEvent("COMPANION_UPDATE") |
end |
end |
function EventEquip.PLAYER_FLAGS_CHANGED(unit) |
if unit == "player" then |
if UnitIsPVP("player") then |
-- print("is pvp flagged") |
if not wasPvP then |
-- print("just pvp flagged") |
if not wasResting then |
CollectPrevious() |
end |
EquipmentManager_EquipSet(EventEquipDB["PvP"]) |
wasPvP = true |
end |
else |
-- print("not pvp flagged") |
if wasPvP then |
-- print("just removed pvp") |
wasPvP = false |
if wasResting and EventEquipDB["In Town"] ~= "None" then |
EquipmentManager_EquipSet(EventEquipDB["In Town"]) |
else |
EquipPrevious() |
end |
end |
end |
end |
end |
EventEquip["PvP"] = function() |
if EventEquipDB["PvP"] == "None" then |
EventEquip:UnregisterEvent("PLAYER_FLAGS_CHANGED") |
return |
else |
EventEquip:RegisterEvent("PLAYER_FLAGS_CHANGED") |
end |
end |
--function EventEquip.ZONE_CHANGED_NEW_AREA() |
-- local instance, kind = IsInInstance() |
--[[ if IsResting() then --if in town... |
print("is resting") |
if not wasPvP or wasMounted then --and not coming from a battleground or not mounted |
CollectPrevious() |
end |
EquipmentManager_EquipSet(EventEquipDB["In Town"]) |
wasResting = true |
else |
if instance and kind == "party" or kind=="pvp" or kind=="arena" then --"party" is only for testing in Stockades |
print("in instance") |
if not wasResting then |
CollectPrevious() |
end |
EquipmentManager_EquipSet(EventEquipDB["Battleground/Arena"]) |
wasPvP = true |
else |
print("not resting and not in instance") |
if wasPvP or wasResting then |
wasPvP = false |
wasResting = false |
if IsMounted() and EventEquipDB["Mounted"] ~= "None" then |
EquipmentManager_EquipSet(EventEquipDB["Mounted"]) |
else |
EquipPrevious() |
end |
end |
end]]-- |
--end |
--[[EventEquip["Battleground/Arena"] = function() |
if EventEquipDB["Battleground/Arena"] == "None" and EventEquipDB["In Town"] == "None" then |
EventEquip:UnregisterEvent("ZONE_CHANGED_NEW_AREA") |
return |
else |
EventEquip:RegisterEvent("ZONE_CHANGED_NEW_AREA") |
end |
end]]-- |
function EventEquip.PLAYER_UPDATE_RESTING() |
local set = EventEquipDB["In Town"] |
if IsResting() then |
CollectPrevious() |
EquipmentManager_EquipSet(set) |
-- print("in town") |
if not wasMounted then |
CollectPrevious() |
end |
EquipmentManager_EquipSet(EventEquipDB["In Town"]) |
wasResting = true |
else |
EquipPrevious() |
-- print("outside town") |
-- print("mounted: "..tostring(wasMounted)) |
if wasMounted and EventEquipDB["Mounted"] ~= "None" then |
EquipmentManager_EquipSet(EventEquipDB["Mounted"]) |
else |
EquipPrevious() |
end |
wasResting = false |
end |
end |
EventEquip["In Town"] = function() |
local set = EventEquipDB["In Town"] |
if set == "None" then |
if EventEquipDB["In Town"] == "None" then |
EventEquip:UnregisterEvent("PLAYER_UPDATE_RESTING") |
return |
else --if not EventEquip:IsEventRegistered("PLAYER_UPDATE_RESTING") then |
else |
EventEquip:RegisterEvent("PLAYER_UPDATE_RESTING") |
end |
end |
--[[EventEquip["In Town"] = function() |
if EventEquipDB["In Town"] == "None" and EventEquipDB["Battleground/Arena"] == "None" then |
EventEquip:UnregisterEvent("ZONE_CHANGED_NEW_AREA") |
return |
else |
EventEquip:RegisterEvent("ZONE_CHANGED_NEW_AREA") |
end |
end]]-- |
function EventEquip.UNIT_SPELLCAST_SUCCEEDED(unit, spell) |
if unit == "player" then |
if spell == "Activate Primary Spec" then |
if spell == "Activate Primary Spec" and EventEquipDB["Primary Talent Spec"] ~= "None" then |
EquipmentManager_EquipSet(EventEquipDB["Primary Talent Spec"]) |
elseif spell == "Activate Secondary Spec" then |
elseif spell == "Activate Secondary Spec" and EventEquipDB["Secondary Talent Spec"] ~= "None" then |
EquipmentManager_EquipSet(EventEquipDB["Secondary Talent Spec"]) |
end |
end |
end |
EventEquip["Primary Talent Spec"] = function() |
local set = EventEquipDB["Primary Talent Spec"] |
if set == "None" and EventEquipDB["Secondary Talent Spec"] == "None" then |
if EventEquipDB["Primary Talent Spec"] == "None" and EventEquipDB["Secondary Talent Spec"] == "None" then |
EventEquip:UnregisterEvent("UNIT_SPELLCAST_SUCCEEDED") |
return |
else |
end |
EventEquip["Secondary Talent Spec"] = function() |
local set = EventEquipDB["Secondary Talent Spec"] |
if set == "None" and EventEquipDB["Primary Talent Spec"] == "None" then |
if EventEquipDB["Secondary Talent Spec"] == "None" and EventEquipDB["Primary Talent Spec"] == "None" then |
EventEquip:UnregisterEvent("UNIT_SPELLCAST_SUCCEEDED") |
return |
else |
local function OnClick(self) |
UIDropDownMenu_SetSelectedValue(eventDrop, self.value) |
eventSelected = events[self.value] |
print(eventSelected, self.value) |
eventText:SetText(eventSelected) |
setsText:SetText(EventEquipDB[eventSelected]) |
end |
EventEquip[v]() |
end |
if UnitIsPVP("player") == 1 then |
wasPvP = true |
else |
wasPvP = false |
end |
-- local _,kind = IsInInstance() |
-- if kind == "pvp" or kind == "arena" then |
-- wasPvP = true |
-- else |
-- wasPvP = false |
-- end |
if IsMounted() == 1 then |
wasMounted = true |
else |
wasMounted = false |
end |
if IsResting() == 1 then |
wasResting = true |
else |
wasResting = false |
end |
-- print("waspvp:"..tostring(wasPvP)) |
-- print("wasResting:"..tostring(wasResting)) |
-- print("wasmounted:"..tostring(wasMounted)) |
SetScriptHook(GearManagerDialogSaveSet, "OnClick", function() |
if EEOptions then |
EEOptions:Hide() |
end |
end) |
SetScriptHook(GearManagerDialog, "OnHide", function() |
if EEOptions then |
EEOptions:Hide() |
end |
end) |
EventEquip:UnregisterEvent("PLAYER_ENTERING_WORLD") |
end |
mountDelay:SetScript("OnUpdate", function(self, elapsed) |
counter = counter + elapsed |
if counter >= .5 then |
mountDelay:Hide() |
counter = 0 |
Mounted() |
end |
end) |
EventEquip:SetScript("OnEvent", function(self,event,...) |
return self[event](...) --just passing event args atm |
end) |
## Interface: 30100 |
## Title: EventEquip |
## Author: Seerah |
## Version: 0.1a |
## Version: 0.2 |
## Notes: Equip item sets created by the in-game Equipment Manager based on events. |
## SavedVariablesPerCharacter: EventEquipDB |
local lib, oldminor = LibStub:NewLibrary("tekKonfig-Dropdown", 2) |
local lib, oldminor = LibStub:NewLibrary("tekKonfig-Dropdown", 3) |
if not lib then return end |
oldminor = oldminor or 0 |
local GameTooltip = GameTooltip |
local function HideTooltip() GameTooltip:Hide() end |
local function ShowTooltip(self) |
if self.tiptext then |
if self.frame.tiptext then |
GameTooltip:SetOwner(self, "ANCHOR_TOPRIGHT") |
GameTooltip:SetText(self.tiptext, nil, nil, nil, nil, true) |
GameTooltip:SetText(self.frame.tiptext, nil, nil, nil, nil, true) |
end |
end |
local function ShowTooltip2(self) ShowTooltip(self.container) end |
local function OnClick(self) |
-- Create a dropdown. |
-- All args optional, parent recommended |
function lib.new(parent, label, ...) |
local container = CreateFrame("Frame", nil, parent) |
local container = CreateFrame("Button", nil, parent) |
container:SetWidth(149+13) container:SetHeight(32+24) |
container:SetScript("OnEnter", ShowTooltip) |
container:SetScript("OnLeave", HideTooltip) |
if select("#", ...) > 0 then container:SetPoint(...) end |
local name = "tekKonfigDropdown"..GetTime() -- Sadly, some of these frames must be named |
f:SetPoint("TOPLEFT", container, -13, -24) |
f:EnableMouse(true) |
f:SetScript("OnHide", OnHide) |
f:SetScript("OnEnter", ShowTooltip) |
f:SetScript("OnLeave", HideTooltip) |
container.frame = f |
local ltex = f:CreateTexture(name.."Left", "ARTWORK") |
ltex:SetWidth(25) ltex:SetHeight(64) |
ltex:SetTexture("Interface\\Glues\\CharacterCreate\\CharacterCreate-LabelFrame") |
ltex:SetTexCoord(0, 0.1953125, 0, 1) |
local rtex = f:CreateTexture(nil, "ARTWORK") |
rtex:SetWidth(25) rtex:SetHeight(64) |
rtex:SetPoint("RIGHT") |
rtex:SetTexture("Interface\\Glues\\CharacterCreate\\CharacterCreate-LabelFrame") |
rtex:SetTexCoord(0.8046875, 1, 0, 1) |
local mtex = f:CreateTexture(nil, "ARTWORK") |
mtex:SetWidth(115) mtex:SetHeight(64) |
mtex:SetPoint("LEFT", ltex, "RIGHT") |
mtex:SetPoint("RIGHT", rtex, "LEFT") |
mtex:SetTexture("Interface\\Glues\\CharacterCreate\\CharacterCreate-LabelFrame") |
mtex:SetTexCoord(0.1953125, 0.8046875, 0, 1) |
local rtex = f:CreateTexture(nil, "ARTWORK") |
rtex:SetWidth(25) rtex:SetHeight(64) |
rtex:SetPoint("LEFT", mtex, "RIGHT") |
rtex:SetTexture("Interface\\Glues\\CharacterCreate\\CharacterCreate-LabelFrame") |
rtex:SetTexCoord(0.8046875, 1, 0, 1) |
local text = f:CreateFontString(name.."Text", "ARTWORK", "GameFontHighlightSmall") |
text:SetWidth(0) text:SetHeight(10) |
text:SetPoint("RIGHT", rtex, -43, 2) |
button:SetWidth(24) button:SetHeight(24) |
button:SetPoint("TOPRIGHT", rtex, -16, -18) |
button:SetScript("OnClick", OnClick) |
button:SetScript("OnEnter", ShowTooltip2) |
button.container = container |
button:SetNormalTexture("Interface\\ChatFrame\\UI-ChatIcon-ScrollDown-Up") |
button:SetPushedTexture("Interface\\ChatFrame\\UI-ChatIcon-ScrollDown-Down") |
button:GetHighlightTexture():SetBlendMode("ADD") |
local labeltext = f:CreateFontString(nil, "BACKGROUND", "GameFontNormal")--GameFontHighlight |
labeltext:SetPoint("BOTTOMLEFT", f, "TOPLEFT", 16, 3) |
labeltext:SetPoint("BOTTOMLEFT", container, "TOPLEFT", 16-13, 3-24) |
labeltext:SetText(label) |
return f, text, container |
return f, text, container, labeltext |
end |