/trunk
self.expandList = {} |
self.currentTab = "achievements" |
self.currentCat = 0 |
self.currentCat = -1 |
self.currentAch = 0 |
self.currentSort = "completed d" |
self.frame:Show() |
end |
end |
function self:SetCategory(id) |
if id == nil then id = self.currentAch end |
if not self.masterList[id] then return end |
local category = GetAchievementCategory(self.currentAch) |
self.currentCat = category |
local _, catParent = GetCategoryInfo(category) |
if catParent == -1 then |
self:RefreshCategoryButtons() |
self:RefreshAchievementButtons() |
else |
for _, tab in next, {"achievements", "statistics"} do |
for k, v in next, self.categories[tab] do |
if v.id == catParent then |
v.collapsed = false |
self:RefreshCategoryButtons() |
self:RefreshAchievementButtons() |
return |
end |
end |
end |
end |
end |
------------------------------------------------------------- |
--Frame Stuff |
------------------------------------------------------------- |
button:SetScript("OnClick", function() |
local id = button:GetID() |
self.currentAch = id |
if GetPreviousAchievement(id) and (not GetNextAchievement(id)) then |
self.expandList[id] = not self.expandList[id] |
if self.masterList[id] then |
self.currentAch = id |
if GetPreviousAchievement(id) and (not GetNextAchievement(id)) then |
self.expandList[id] = not self.expandList[id] |
end |
self:RefreshAchievementButtons(false) |
self:SetDisplayAchievement(id) |
end |
self:RefreshAchievementButtons(false) |
self:SetDisplayAchievement(id) |
end) |
button:SetScript("OnMouseWheel", function() |
self:ButtonScroll(arg1, "achScroll", "achOffset") |
local button = CreateFrame("Button", name, parent) |
button:SetHeight(30) |
button:SetWidth(100) |
--button:SetNormalTexture("Interface\\DialogFrame\\UI-DialogBox-Header") |
button:SetHighlightTexture("Interface\\PaperDollInfoFrame\\UI-Character-Tab-Highlight", "ADD") |
--these lists work for both achievements and statistics, though statistics are populated and displayed differently |
end |
function self:SetChainCategory(id, cat) |
local nextId, prevId |
if not self.masterList[id] then self:Print(id) end |
self.masterList[id].category = cat |
--Go through previous achievements |
prevId = self.masterList[id].previous |
while prevId do |
self.masterList[prevId].category = cat |
prevId = self.masterList[prevId].previous |
end |
--Go through next achievements |
nextId = self.masterList[id].next |
while nextId do |
self.masterList[nextId].category = cat |
nextId = self.masterList[nextId].next |
end |
end |
function self:PopulateCategories(tab) |
local list, name, parent |
end |
end |
function self:RefreshCategoryButtons() |
local count = 0 |
local buttonNum = 1 |
for k, v in next, self.categories[self.currentTab] do |
count = count + 1 |
if buttonNum <= #self.frame.catButtons and count > self.catOffset then |
self.frame.catButtons[buttonNum].text:SetText(v.name) |
self.frame.catButtons[buttonNum]:SetID(v.id) |
if v.id == self.currentCat then |
self.frame.catButtons[buttonNum]:LockHighlight() |
else |
self.frame.catButtons[buttonNum]:UnlockHighlight() |
end |
self.frame.catButtons[buttonNum]:Show() |
buttonNum = buttonNum + 1 |
end |
if v.collapsed == false then |
for subK, subV in next, v.children do |
count = count + 1 |
if buttonNum <= #self.frame.catButtons and count > self.catOffset then |
self.frame.catButtons[buttonNum].text:SetText(" " .. subV.name) |
self.frame.catButtons[buttonNum]:SetID(subV.id) |
if subV.id == self.currentCat then |
self.frame.catButtons[buttonNum]:LockHighlight() |
else |
self.frame.catButtons[buttonNum]:UnlockHighlight() |
end |
self.frame.catButtons[buttonNum]:Show() |
buttonNum = buttonNum + 1 |
end |
end |
end |
end |
self.frame.catScroll:SetMinMaxValues(0,math.max(count-#self.frame.catButtons, 0)) |
if count-#self.frame.catButtons > 0 then |
self.frame.catScroll:Show() |
else |
self.frame.catScroll:Hide() |
end |
for i = buttonNum, #self.frame.catButtons do |
self.frame.catButtons[i]:Hide() |
end |
end |
function self:RefreshAchievementButtons(sortStr) |
local count = 0 |
local buttonNum = 1 |
local prevId |
--sortStr = true dont change the table, sort it |
-- false dont change the table, dont sort it |
-- nil reset the table, sort it by name then completed |
if sortStr then |
preserveSort(self.displayTable, self.sortFuncs[sortStr]) |
elseif sortStr == nil then |
self.displayTable = {} |
for _, id in next, (self.seriesList[self.currentCat] or {}) do |
tinsert(self.displayTable, id) |
end |
preserveSort(self.displayTable, self.sortFuncs["name a"]) |
preserveSort(self.displayTable, self.sortFuncs["completed d"]) |
end |
for _, id in next, self.displayTable do |
count = count + 1 |
if buttonNum <= #self.frame.achButtons and count > self.achOffset then |
self:SetAchievementButton(buttonNum, id, 1) |
buttonNum = buttonNum + 1 |
end |
prevId = GetPreviousAchievement(id) |
if prevId and (not GetNextAchievement(id)) then |
if (self.currentCat ~= -2) and (self.expandList[id]) then |
while prevId do |
count = count + 1 |
if buttonNum <= #self.frame.achButtons and count > self.achOffset then |
self:SetAchievementButton(buttonNum, prevId, 10) |
buttonNum = buttonNum + 1 |
end |
prevId = GetPreviousAchievement(prevId) |
end |
end |
end |
end |
self.frame.achScroll:SetMinMaxValues(0,math.max(count-#self.frame.achButtons, 0)) |
if count-#self.frame.achButtons > 0 then |
self.frame.achScroll:Show() |
else |
self.frame.achScroll:Hide() |
end |
for i = buttonNum, #self.frame.achButtons do |
self.frame.achButtons[i]:Hide() |
self.frame.achButtons[i].offset:SetWidth(1) |
end |
self.compPointsText:SetText(GetComparisonAchievementPoints()) --Called to get the correct Achievement points |
end |
function self:SetAchievementButton(button, id, offset) |
local id, name, points, completed, month, day, year, description, _, icon, reward = GetAchievementInfo(id) |
if completed then completed = month .. "/" .. day .. "/0" .. year else completed = "" end |
if not offset then offset = 1 end |
self.frame.achButtons[button]:SetWidth(300) |
self.frame.achButtons[button].name:SetText(name) |
self.frame.achButtons[button].completed:SetText(completed) |
self.frame.achButtons[button]:SetID(id) |
self.frame.achButtons[button].expand:SetTextColor(1,0,0) |
self.frame.achButtons[button].expand:SetText("!") |
self.frame.achButtons[button].expand:Show() |
elseif self.currentCat ~= -2 then --If we're searching, we dont want to see the + or - |
elseif self.currentCat > 0 then --If we're searching or at the summary, we dont want to see the + or - |
self.frame.achButtons[button].expand:SetTextColor(1,1,1) |
if GetPreviousAchievement(id) and (not GetNextAchievement(id)) then --There's a sub achievement |
self.frame.achButtons[button].expand:Show() |
if id == nil then id = self.currentAch end |
if not self.masterList[id] then return end |
self.frame:Show() |
--self.frame:Show() |
self.currentAch = id |
--Update the category list |
--On second thought, I dont want it doing this. |
--[[ |
local category = GetAchievementCategory(id) |
if not category == self.currentCat then |
local _, catParent = GetCategoryInfo(category) |
if catParent == -1 then |
self.currentCat = category |
else |
end |
--On third thought, I only want to do it if we're coming from the summary frame. |
if self.currentCat == -1 then |
self:SetCategory(self.currentAch) |
end |
]]-- |
--Update this achievement |
self.masterList[id].searchString = self:GetSearchString(id) |
end |
end |
------------------------------------------------------------- |
--Refresh Stuff |
------------------------------------------------------------- |
function self:RefreshCriteriaButtons() |
local criteriaName, criteriaType, criteriaCompleted, criteriaQuantity, criteriaReqQuantity,_ ,criteriaFlags, criteriaAssetID, icon, quantityStr |
--local c = self.masterList[self.currentAch] or {} |
end |
end |
function self:RefreshCategoryButtons() |
local count = 0 |
local buttonNum = 1 |
for k, v in next, self.categories[self.currentTab] do |
count = count + 1 |
if buttonNum <= #self.frame.catButtons and count > self.catOffset then |
self.frame.catButtons[buttonNum].text:SetText(v.name) |
self.frame.catButtons[buttonNum]:SetID(v.id) |
if v.id == self.currentCat then |
self.frame.catButtons[buttonNum]:LockHighlight() |
else |
self.frame.catButtons[buttonNum]:UnlockHighlight() |
end |
self.frame.catButtons[buttonNum]:Show() |
buttonNum = buttonNum + 1 |
end |
if v.collapsed == false then |
for subK, subV in next, v.children do |
count = count + 1 |
if buttonNum <= #self.frame.catButtons and count > self.catOffset then |
self.frame.catButtons[buttonNum].text:SetText(" " .. subV.name) |
self.frame.catButtons[buttonNum]:SetID(subV.id) |
if subV.id == self.currentCat then |
self.frame.catButtons[buttonNum]:LockHighlight() |
else |
self.frame.catButtons[buttonNum]:UnlockHighlight() |
end |
self.frame.catButtons[buttonNum]:Show() |
buttonNum = buttonNum + 1 |
end |
end |
end |
end |
self.frame.catScroll:SetMinMaxValues(0,math.max(count-#self.frame.catButtons, 0)) |
if count-#self.frame.catButtons > 0 then |
self.frame.catScroll:Show() |
else |
self.frame.catScroll:Hide() |
end |
for i = buttonNum, #self.frame.catButtons do |
self.frame.catButtons[i]:Hide() |
end |
end |
function self:RefreshAchievementButtons(sortStr) |
local count = 0 |
local buttonNum = 1 |
local prevId |
--sortStr = true dont change the table, sort it |
-- false dont change the table, dont sort it |
-- nil reset the table, sort it by name then completed |
if sortStr then |
preserveSort(self.displayTable, self.sortFuncs[sortStr]) |
elseif sortStr == nil then |
self.displayTable = {} |
for _, id in next, (self.seriesList[self.currentCat] or {}) do |
tinsert(self.displayTable, id) |
end |
preserveSort(self.displayTable, self.sortFuncs["name a"]) |
preserveSort(self.displayTable, self.sortFuncs["completed d"]) |
end |
for _, id in next, self.displayTable do |
count = count + 1 |
if buttonNum <= #self.frame.achButtons and count > self.achOffset then |
self:SetAchievementButton(buttonNum, id, 1) |
buttonNum = buttonNum + 1 |
end |
prevId = GetPreviousAchievement(id) |
if prevId and (not GetNextAchievement(id)) then |
if (self.currentCat ~= -2) and (self.expandList[id]) then |
while prevId do |
count = count + 1 |
if buttonNum <= #self.frame.achButtons and count > self.achOffset then |
self:SetAchievementButton(buttonNum, prevId, 10) |
buttonNum = buttonNum + 1 |
end |
prevId = GetPreviousAchievement(prevId) |
end |
end |
end |
end |
--Start summary category stuff. We assume all the above stuff has done nothing. |
if self.currentCat == -1 then --Summary category |
--Incredibly hackish on my part :\ |
self.frame.achButtons[buttonNum]:SetWidth(300) |
self.frame.achButtons[buttonNum].name:SetText("Recent Achievements:") |
self.frame.achButtons[buttonNum].completed:SetText("") |
self.frame.achButtons[buttonNum].compare:SetText("") |
self.frame.achButtons[buttonNum].points:SetText("") |
self.frame.achButtons[buttonNum]:SetID(-1) |
self.frame.achButtons[buttonNum].expand:Hide() |
self.frame.achButtons[buttonNum].comparison:Hide() |
self.frame.achButtons[buttonNum].background:SetTexture("Interface\\AchievementFrame\\UI-Achievement-Parchment-Horizontal-Desaturated") |
self.frame.achButtons[buttonNum].offset:SetWidth(1) |
self.frame.achButtons[buttonNum]:Show() |
buttonNum = buttonNum + 1 |
for k,id in next, {GetLatestCompletedAchievements()} do |
self:SetAchievementButton(buttonNum, id) |
buttonNum = buttonNum + 1 |
end |
self.frame.achButtons[buttonNum]:SetWidth(300) |
self.frame.achButtons[buttonNum].name:SetText("Recent Statistics:") |
self.frame.achButtons[buttonNum].completed:SetText("") |
self.frame.achButtons[buttonNum].compare:SetText("") |
self.frame.achButtons[buttonNum].points:SetText("") |
self.frame.achButtons[buttonNum]:SetID(-1) |
self.frame.achButtons[buttonNum].expand:Hide() |
self.frame.achButtons[buttonNum].comparison:Hide() |
self.frame.achButtons[buttonNum].background:SetTexture("Interface\\AchievementFrame\\UI-Achievement-Parchment-Horizontal-Desaturated") |
self.frame.achButtons[buttonNum].offset:SetWidth(1) |
self.frame.achButtons[buttonNum]:Show() |
buttonNum = buttonNum + 1 |
for k,id in next, {GetLatestUpdatedStats()} do |
statId = GetAchievementInfoFromCriteria(id) |
self:SetAchievementButton(buttonNum, statId) |
buttonNum = buttonNum + 1 |
end |
end |
--End summary category stuff. |
--Scroll bar Stuff |
self.frame.achScroll:SetMinMaxValues(0,math.max(count-#self.frame.achButtons, 0)) |
if count-#self.frame.achButtons > 0 then |
self.frame.achScroll:Show() |
else |
self.frame.achScroll:Hide() |
end |
for i = buttonNum, #self.frame.achButtons do |
self.frame.achButtons[i]:Hide() |
self.frame.achButtons[i].offset:SetWidth(1) |
end |
end |
------------------------------------------------------------- |
--Comparison Stuff |
------------------------------------------------------------- |
--self:ComparisonUpdate() |
--self:RefreshAchievementButtons(false) |
end |
------------------------------------------------------------- |
--Tracking Stuff |
------------------------------------------------------------- |
function self:CreateTracker() |
end |