WoWInterface SVN PetListPlus

Compare Revisions

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

Rev 1 → Rev 2

Main.lua New file
0,0 → 1,130
PetListPlus = CreateFrame("Frame", "PetListPlusFrame", PetPaperDollFrame)
 
local self = PetListPlus
 
self:RegisterEvent("ADDON_LOADED")
 
self:SetScript("OnEvent", function(...) self:OnEvent(...) end)
PetPaperDollFrameCompanionFrame:SetScript("OnShow", function()
PetPaperDollFrameCompanionFrame:Hide()
self:UpdateButtons()
end)
 
function self:OnEvent(this, event, arg1)
if event == "ADDON_LOADED" and arg1 == "PetListPlus" then
self:UnregisterEvent("ADDON_LOADED")
self:SetupFrames()
end
end
 
function self:SetupFrames()
self:SetAllPoints(PetPaperDollFrame)
 
self.bg = self:CreateTexture()
--self.bg:SetTexture(1,0,0)
self.bg:SetAllPoints(self)
 
--Close Button
self.close = CreateFrame("Button", "$parentCloseButton", self, "UIPanelButtonTemplate")
self.close:SetText(CLOSE)
self.close:SetWidth(80)
self.close:SetHeight(22)
self.close:SetPoint("CENTER", self, "TOPLEFT", 305, -422)
self.close:SetScript("OnClick", function() HideUIPanel(CharacterFrame) end)
 
self.model = CreateFrame("DressUpModel", "$parentModel", self)
self.model:SetWidth(315)
self.model:SetHeight(110)
self.model:SetPoint("TOPLEFT", 24, -75)
 
local modelBG = self.model:CreateTexture(nil, "BACKGROUND")
modelBG:SetAllPoints(self.model)
modelBG:SetTexture("Interface\\PetPaperDollFrame\\UI-PetFrame-Frame")
modelBG:SetTexCoord(0,0.6,0,0.9)
--modelBG:SetTexture(1,0,0)
 
self.buttons = {}
self.buttons[1] = self:CreateCompanionButton(1)
self.buttons[1]:SetPoint("TOPLEFT", self.model, "BOTTOMLEFT")
self.buttons[2] = self:CreateCompanionButton(2)
self.buttons[2]:SetPoint("TOPLEFT", self.buttons[1], "TOPRIGHT", 1, 0)
 
for i=3, 14 do
self.buttons[i] = self:CreateCompanionButton(i)
self.buttons[i]:SetPoint("TOPLEFT", self.buttons[i-2], "BOTTOMLEFT")
end
 
self.scrollBar = CreateFrame("Slider", "$parentCatSlider", self, "UIPanelScrollBarTemplate")
self.scrollBar:SetPoint("TOPLEFT", self.buttons[2], "TOPRIGHT", 0, -16)
self.scrollBar:SetPoint("BOTTOMLEFT", self.buttons[#self.buttons], "BOTTOMRIGHT", 0, 16)
self.scrollBar:SetWidth(16)
self.scrollBar:SetMinMaxValues(0,0)
self.scrollBar:SetValueStep(2)
self.scrollBar:SetScript("OnValueChanged", function()
-- if self.scrollBar:GetValue()%2 == 1 then
-- self.scrollBar:SetValue(self.scrollBar:GetValue() + 1)
-- else
self:UpdateButtons()
-- end
end)
self.scrollBar:SetValue(0)
end
 
function self:CreateCompanionButton(num)
local button = CreateFrame("CheckButton", "$parentButton" .. num, self, "SecureFrameTemplate")
button:SetWidth(150)
button:SetHeight(32)
 
button.icon = button:CreateTexture("$parentIcon", "ARTWORK")
button.icon:SetWidth(32)
button.icon:SetHeight(32)
button.icon:SetTexture("Interface\\Icons\\Ability_BackStab")
button.icon:SetPoint("TOPLEFT")
 
button.name = button:CreateFontString("$parentName", "ARTWORK", "GameFontNormal")
button.name:SetTextColor(1,1,1)
button.name:SetJustifyH("LEFT")
button.name:SetPoint("TOPLEFT", button.icon, "TOPRIGHT", 5, -2)
button.name:SetPoint("BOTTOMRIGHT")
 
button:SetScript("OnClick", function()
self.model:SetCreature(button:GetID())
end)
 
return button
end
 
function self:UpdateButtons()
local creatureID, creatureName, spellID, icon
local count = 1
local mode = PetPaperDollFrameCompanionFrame.mode
local numComp = GetNumCompanions(mode)
local scrollMax = GetNumCompanions(mode)-#self.buttons
 
for i=1, numComp do
if count <= #self.buttons and i > self.scrollBar:GetValue() then
creatureID, creatureName, spellID, icon = GetCompanionInfo(mode, i)
if creatureID then --Not nil
self.buttons[count]:Show()
self.buttons[count]:SetID(creatureID)
self.buttons[count].icon:SetTexture(icon)
self.buttons[count].name:SetText(creatureName)
count = count + 1
end
end
end
if (GetNumCompanions(mode)-#self.buttons)%2 == 1 then
scrollMax = GetNumCompanions(mode)-#self.buttons + 1
end
self.scrollBar:SetMinMaxValues(0,math.max(scrollMax, 0))
 
if GetNumCompanions(mode) - #self.buttons > 0 then
self.scrollBar:Show()
else
self.scrollBar:Hide()
end
 
for i = count, #self.buttons do
self.buttons[i]:Hide()
end
end
PetListPlus.toc New file
0,0 → 1,9
## Interface: 30000
## Title: PetList+
## Author: Syzgyn
## Notes: Improved Companion Frame
## Version 0.1.wowi:revision
## SavedVariables: PLPSV
## SavedVariablesPerCharacter: PLPSVPC
 
Main.lua
\ No newline at end of file