WoWInterface SVN EventEquip

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /
    from Rev 1 to Rev 2
    Reverse comparison

Rev 1 → Rev 2

trunk/EventEquip/EventEquip.lua New file
0,0 → 1,267
--[[
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 gmd = GearManagerDialog
local GameTooltip = GameTooltip
local tkDrop = LibStub("tekKonfig-Dropdown")
local eventSelected, setSelected, previousGear
local sets = {"None"}
local events = {"Primary Talent Spec",
"Secondary Talent Spec",
"In Town",
-- "Mounted",
-- "PvP",
}
local defaults = { previousGear = {},
["Primary Talent Spec"] = "None",
["Secondary Talent Spec"] = "None",
["In Town"] = "None",
["Mounted"] = "None",
["PvP"] = "None",
}
 
local function CollectPrevious()
for i=1,19 do
EventEquipDB.previousGear[i] = GetInventoryItemLink("player", i)
end
end
 
local function EquipPrevious()
for i=1,19 do
EquipItemByName(EventEquipDB.previousGear[i])
end
end
 
--[[EventEquip["Mounted"] = function()
end
 
EventEquip["PvP"] = function()
end]]--
 
function EventEquip.PLAYER_UPDATE_RESTING()
local set = EventEquipDB["In Town"]
if IsResting() then
CollectPrevious()
EquipmentManager_EquipSet(set)
else
EquipPrevious()
end
end
 
EventEquip["In Town"] = function()
local set = EventEquipDB["In Town"]
if set == "None" then
EventEquip:UnregisterEvent("PLAYER_UPDATE_RESTING")
return
else --if not EventEquip:IsEventRegistered("PLAYER_UPDATE_RESTING") then
EventEquip:RegisterEvent("PLAYER_UPDATE_RESTING")
end
end
 
function EventEquip.UNIT_SPELLCAST_SUCCEEDED(unit, spell)
if unit == "player" then
if spell == "Activate Primary Spec" then
EquipmentManager_EquipSet(EventEquipDB["Primary Talent Spec"])
elseif spell == "Activate Secondary Spec" 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
EventEquip:UnregisterEvent("UNIT_SPELLCAST_SUCCEEDED")
return
else
EventEquip:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED")
end
end
 
EventEquip["Secondary Talent Spec"] = function()
local set = EventEquipDB["Secondary Talent Spec"]
if set == "None" and EventEquipDB["Primary Talent Spec"] == "None" then
EventEquip:UnregisterEvent("UNIT_SPELLCAST_SUCCEEDED")
return
else
EventEquip:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED")
end
end
 
local function CollectSets()
sets = {"None"}
local num = GetNumEquipmentSets()
for i=1,num do
sets[i+1] = GetEquipmentSetInfo(i)
end
return sets
end
 
local function OnEnter(self, text)
GameTooltip:SetOwner(self, "ANCHOR_TOPRIGHT")
GameTooltip:SetText(text)
GameTooltip:Show()
end
 
local function OnLeave()
GameTooltip:Hide()
end
 
local function SetUpOptions()
local eeOpts = CreateFrame("Frame", "EEOptions", gmd)
eeOpts:SetPoint("TOPLEFT", gmd, "BOTTOMLEFT", 3, 4)
eeOpts:SetWidth(260)
eeOpts:SetHeight(276)
local eebg = eeOpts:CreateTexture("eebg")
eebg:SetTexture("Interface\\PaperDollInfoFrame\\UI-Character-StatBackground")
eebg:SetAllPoints(eeOpts)
eebg:SetTexCoord(0,.92,0.01,.61)
local header = eeOpts:CreateFontString(nil, "ARTWORK", "GameFontNormalLarge")
header:SetParent(eeOpts)
header:SetPoint("TOP", eeOpts, "TOP", 0,-15)
header:SetText("EventEquip")
local subheader = eeOpts:CreateFontString(nil, "ARTWORK", "GameFontHighlight")
subheader:SetParent(eeOpts)
subheader:SetPoint("TOPLEFT", eeOpts, "TOPLEFT", 15,-35)
subheader:SetPoint("RIGHT", eeOpts, "RIGHT", -20,0)
subheader:SetHeight(30)
subheader:SetNonSpaceWrap(true)
subheader:SetJustifyH("LEFT")
subheader:SetText("Select an event and then a set to equip during that event.")
local setsDrop, setsText = tkDrop.new(eeOpts, "Sets")
setsDrop:SetPoint("CENTER", eeOpts, "CENTER", 0, -45)
setsDrop:SetWidth(200)
local function OnClick(self)
UIDropDownMenu_SetSelectedValue(setsDrop, self.value)
setSelected = sets[self.value]
setsText:SetText(setSelected)
end
UIDropDownMenu_Initialize(setsDrop, function()
local current, info = UIDropDownMenu_GetSelectedValue(setsDrop), UIDropDownMenu_CreateInfo()
for k,v in pairs(CollectSets()) do
info.text, info.value, info.func, info.checked = v, k, OnClick, v == current
UIDropDownMenu_AddButton(info)
end
end)
setsDrop:SetScript("OnEnter", function(self) OnEnter(self, "This is the set currently assigned to the above event.") end)
setsDrop:SetScript("OnLeave", OnLeave)
local setsLabel = setsDrop:CreateFontString(nil, "ARTWORK", "GameFontNormal")
setsLabel:SetText("Sets")
setsLabel:SetPoint("BOTTOM", setsDrop, "TOP", 0, 5)
local eventDrop, eventText = tkDrop.new(eeOpts, "Event")
eventDrop:SetPoint("CENTER", eeOpts, "CENTER", 0, 20)
eventDrop:SetWidth(200)
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
UIDropDownMenu_Initialize(eventDrop, function()
local current, info = UIDropDownMenu_GetSelectedValue(eventDrop), UIDropDownMenu_CreateInfo()
for k,v in pairs(events) do
info.text, info.value, info.func, info.checked = v, k, OnClick, v == current
UIDropDownMenu_AddButton(info)
end
end)
eventDrop:SetScript("OnEnter", function(self) OnEnter(self, "Choose an event.") end)
eventDrop:SetScript("OnLeave", OnLeave)
local eventLabel = eventDrop:CreateFontString(nil, "ARTWORK", "GameFontNormal")
eventLabel:SetText("Events")
eventLabel:SetPoint("BOTTOM", eventDrop, "TOP", 0, 5)
local saveButton = CreateFrame("Button", nil, eeOpts, "UIPanelButtonTemplate")
saveButton:SetPoint("BOTTOM", eeOpts, "BOTTOM", 0, 30)
saveButton:SetText("Save Event")
saveButton:SetHeight(25)
saveButton:SetWidth(125)
saveButton:SetScript("OnEnter", function(self)
OnEnter(self, "Click to save this set to this event.")
end)
saveButton:SetScript("OnLeave", OnLeave)
saveButton:SetScript("OnClick", function()
if eventSelected and setSelected or setsText:GetText() == EventEquipDB[eventSelected] then
EventEquipDB[eventSelected] = setSelected or setsText:GetText()
if setSelected == "None" or setsText:GetText() == "None" then
DEFAULT_CHAT_FRAME:AddMessage("EventEquip: Set removed from Event -"..eventSelected.."-",.8,1,.2)
else
DEFAULT_CHAT_FRAME:AddMessage("EventEquip: Set -"..EventEquipDB[eventSelected].."- assigned to Event -"..eventSelected.."-",.8,1,.2)
end
else
DEFAULT_CHAT_FRAME:AddMessage("EventEquip: You must select an event and a set to save!",.8,1,.2)
end
EventEquip[eventSelected]()
end)
end
 
local function CreateButton()
local eeButton = CreateFrame("Button", nil, gmd)
eeButton:SetWidth(22)
eeButton:SetHeight(22)
eeButton:SetPoint("BOTTOM", gmd, "BOTTOM", 2,12)
eeButton:SetNormalTexture("Interface\\Minimap\\Tracking\\Repair.blp")
eeButton:SetHighlightTexture("Interface\\Buttons\\UI-Panel-Button-Highlight.blp")
eeButton:GetHighlightTexture():SetTexCoord(0,.64,0,.64)
eeButton:SetScript("OnEnter", function(self) OnEnter(self, "Click to open the EventEquip window.") end)
eeButton:SetScript("OnLeave", OnLeave)
eeButton:SetScript("OnMouseDown", function()
if not EEOptions then
SetUpOptions()
return
end
if EEOptions:IsShown() then
EEOptions:Hide()
else
EEOptions:Show()
end
end)
end
 
local function SetScriptHook(frame, script, func)
if frame:GetScript(script) then
frame:HookScript(script, func)
else
frame:SetScript(script, func)
end
end
 
function EventEquip.PLAYER_ENTERING_WORLD()
EventEquipDB = EventEquipDB or {}
for k,v in pairs(defaults) do
if type(EventEquipDB[k]) == "nil" then
EventEquipDB[k] = v
end
end
 
CollectSets()
CreateButton()
 
for k,v in pairs(events) do
EventEquip[v]()
end
 
SetScriptHook(GearManagerDialogSaveSet, "OnClick", function()
if EEOptions then
EEOptions:Hide()
end
end)
 
EventEquip:UnregisterEvent("PLAYER_ENTERING_WORLD")
end
 
EventEquip:SetScript("OnEvent", function(self,event,...)
return self[event](...) --just passing event args atm
end)
 
EventEquip:RegisterEvent("PLAYER_ENTERING_WORLD")
\ No newline at end of file Property changes : Added: svn:mime-type + text/plain Added: svn:eol-style + native
trunk/EventEquip/EventEquip.toc New file
0,0 → 1,11
## Interface: 30100
## Title: EventEquip
## Author: Seerah
## Version: 1.0
## Notes: Equip item sets created by the in-game Equipment Manager based on events.
## SavedVariablesPerCharacter: EventEquipDB
 
libs\LibStub\LibStub.lua
libs\tekKonfigDropdown
 
EventEquip.lua
\ No newline at end of file Property changes : Added: svn:eol-style + native Added: svn:mime-type + text/plain
trunk/EventEquip/libs/LibStub/LibStub.lua New file
0,0 → 1,30
-- LibStub is a simple versioning stub meant for use in Libraries. http://www.wowace.com/wiki/LibStub for more info
-- LibStub is hereby placed in the Public Domain Credits: Kaelten, Cladhaire, ckknight, Mikk, Ammo, Nevcairiel, joshborke
local LIBSTUB_MAJOR, LIBSTUB_MINOR = "LibStub", 2 -- NEVER MAKE THIS AN SVN REVISION! IT NEEDS TO BE USABLE IN ALL REPOS!
local LibStub = _G[LIBSTUB_MAJOR]
 
if not LibStub or LibStub.minor < LIBSTUB_MINOR then
LibStub = LibStub or {libs = {}, minors = {} }
_G[LIBSTUB_MAJOR] = LibStub
LibStub.minor = LIBSTUB_MINOR
 
function LibStub:NewLibrary(major, minor)
assert(type(major) == "string", "Bad argument #2 to `NewLibrary' (string expected)")
minor = assert(tonumber(strmatch(minor, "%d+")), "Minor version must either be a number or contain a number.")
 
local oldminor = self.minors[major]
if oldminor and oldminor >= minor then return nil end
self.minors[major], self.libs[major] = minor, self.libs[major] or {}
return self.libs[major], oldminor
end
 
function LibStub:GetLibrary(major, silent)
if not self.libs[major] and not silent then
error(("Cannot find a library instance of %q."):format(tostring(major)), 2)
end
return self.libs[major], self.minors[major]
end
 
function LibStub:IterateLibraries() return pairs(self.libs) end
setmetatable(LibStub, { __call = LibStub.GetLibrary })
end
Property changes : Added: svn:mime-type + text/plain Added: svn:eol-style + native
trunk/EventEquip/libs/tekKonfigDropdown.lua New file
0,0 → 1,81
 
local lib, oldminor = LibStub:NewLibrary("tekKonfig-Dropdown", 2)
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
GameTooltip:SetOwner(self, "ANCHOR_TOPRIGHT")
GameTooltip:SetText(self.tiptext, nil, nil, nil, nil, true)
end
end
 
 
local function OnClick(self)
ToggleDropDownMenu(nil, nil, self:GetParent())
PlaySound("igMainMenuOptionCheckBoxOn")
end
 
local function OnHide() CloseDropDownMenus() end
 
 
-- Create a dropdown.
-- All args optional, parent recommended
function lib.new(parent, label, ...)
local container = CreateFrame("Frame", nil, parent)
container:SetWidth(149+13) container:SetHeight(32+24)
if select("#", ...) > 0 then container:SetPoint(...) end
 
local name = "tekKonfigDropdown"..GetTime() -- Sadly, some of these frames must be named
local f = CreateFrame("Frame", name, parent)
f:SetWidth(149) f:SetHeight(32)
f:SetPoint("TOPLEFT", container, -13, -24)
f:EnableMouse(true)
f:SetScript("OnHide", OnHide)
f:SetScript("OnEnter", ShowTooltip)
f:SetScript("OnLeave", HideTooltip)
 
local ltex = f:CreateTexture(name.."Left", "ARTWORK")
ltex:SetWidth(25) ltex:SetHeight(64)
ltex:SetPoint("TOPLEFT", 0, 17)
ltex:SetTexture("Interface\\Glues\\CharacterCreate\\CharacterCreate-LabelFrame")
ltex:SetTexCoord(0, 0.1953125, 0, 1)
 
local mtex = f:CreateTexture(nil, "ARTWORK")
mtex:SetWidth(115) mtex:SetHeight(64)
mtex:SetPoint("LEFT", ltex, "RIGHT")
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)
text:SetJustifyH("RIGHT")
 
local button = CreateFrame("Button", nil, f)
button:SetWidth(24) button:SetHeight(24)
button:SetPoint("TOPRIGHT", rtex, -16, -18)
button:SetScript("OnClick", OnClick)
 
button:SetNormalTexture("Interface\\ChatFrame\\UI-ChatIcon-ScrollDown-Up")
button:SetPushedTexture("Interface\\ChatFrame\\UI-ChatIcon-ScrollDown-Down")
button:SetHighlightTexture("Interface\\Buttons\\UI-Common-MouseHilight")
button:SetDisabledTexture("Interface\\ChatFrame\\UI-ChatIcon-ScrollDown-Disabled")
button:GetHighlightTexture():SetBlendMode("ADD")
 
local labeltext = f:CreateFontString(nil, "BACKGROUND", "GameFontNormal")--GameFontHighlight
labeltext:SetPoint("BOTTOMLEFT", f, "TOPLEFT", 16, 3)
labeltext:SetText(label)
 
return f, text, container
end
 
Property changes : Added: svn:eol-style + native Added: svn:mime-type + text/plain