Mercurial > wow > buffalo2
view Modules/GuildInfo.lua @ 125:3f4794dca91b
template load order and Script handlers linkage
author | Nenue |
---|---|
date | Sun, 15 Oct 2017 16:47:22 -0400 |
parents | ea2c616a3b4f |
children | 15a7f27b11e6 |
line wrap: on
line source
local print = DEVIAN_WORKSPACE and function(...) print('VnRoster', ...) end or nop VeneerRosterKunMixin = { anchorFrame = 'LFGListFrame', anchorPoint = 'TOPLEFT', AchievementsDirty = true, GuildInfoDirty = true, blocks = {}, } local module = VeneerRosterKunMixin function module:OnLoad() Veneer:AddHandler(self, self.anchorPoint) --self:RegisterEvent('GUILD_ROSTER_UPDATE') --self:RegisterEvent('GUILD_TRADESKILL_UPDATE') self:RegisterEvent('LFG_LIST_SEARCH_RESULT_UPDATED') --self:RegisterEvent('LFG_LIST_SEARCH_RESULTS_RECEIVED') --self:RegisterEvent('LFG_LIST_AVAILABILITY_UPDATE') --self:RegisterEvent('LFG_LIST_LOCK_INFO_RECEIVED') self:RegisterEvent('ADDON_LOADED') hooksecurefunc("LFGListSearchPanel_SelectResult", function(obj) print('LFGListSearchPanel_SelectResult') self.selectedID = obj.selectedResult print('selected =', self.selectedID) self:UpdateAchievementLinks() end) hooksecurefunc("LFGListSearchPanel_SignUp", function(obj) print('LFGListSearchPanel_SignUp', obj.selectedResult) self.selectedID = obj.selectedResult print('selected =', self.selectedID) self:UpdateAchievementLinks() end) end function module:Setup() VeneerHandlerMixin.Setup(self) self:SetParent(LFGListFrame) self:SetPoint('TOPLEFT', LFGListFrame,'TOPRIGHT') self:SetShown(true) end function module:SetDirty() if self:IsVisible() then self:Update() else self.GuildInfoDirty = true self.AchievementsDirty = true end end local firstLoad = true function module:OnShow() print('|cFF00FFFFOnShow()|r') self:Update(firstLoad) firstLoad = nil end function module:UpdateGuildInfo() local numMembers = GetNumGuildMembers() print(numMembers) for i = 1, numMembers do --print(GetGuildRosterInfo(i)) end self.GuildInfoDirty = nil end -- cheevos to link local cheevos = { -- Mythic Prog: Tomb { 11781, -- kj 11780, -- avatar 11779, -- maiden 11776, -- mistress 11778, -- host, 11777, -- sisters 11775, -- harjatan, 11774, -- di, 11773, -- goroth }, -- Completion: Tomb { 11875, -- CE KJ 11874, -- AotC KJ 11790 -- Deceiver's Fall, }, -- Mythic+ { 11162, -- master 11185, -- conqueror } } local cheev = {} function cheev:OnClick() local resultID = LFGListFrame.SearchPanel.selectedResult or self:GetParent().selectedID print('current selection = ', resultID) if ACTIVE_CHAT_EDIT_BOX then ChatEdit_InsertLink(self.link) elseif resultID then local id, activityID, name, comment, voiceChat, iLvl, honorLevel, age, numBNetFriends, numCharFriends, numGuildMates, isDelisted, leaderName = C_LFGList.GetSearchResultInfo(resultID); --print(name, comment, leaderName) ChatFrame_OpenChat("/w "..leaderName.." "..self.link, DEFAULT_CHAT_FRAME) end end function module:UpdateAchievementLinks() print('UpdateAchievementLinks()') local resultID = LFGListFrame.SearchPanel.selectedResult or self.selectedID self:Show() local index = 0 local lastBlock local contentsHeight = 0 for _, group in ipairs(cheevos) do for _, id in ipairs(group) do local _, name, points, completed, month, day, year, description, flags, icon = GetAchievementInfo(id) if completed then index = index + 1 --print(index) local block =self.blocks[index] if not block then block = CreateFrame('Button', 'VeneerRosterKunBlock'..index, self, 'VeneerRosterKunBlock') block:SetScript('OnClick', cheev.OnClick) block:SetID(index) self.blocks[index] = block end block.link = GetAchievementLink(id) block.Icon:SetTexture(icon) block.Label:SetText(name) block:ClearAllPoints() if lastBlock then block:SetPoint('TOPLEFT', lastBlock, 'BOTTOMLEFT', 0, 0) else block:SetPoint('TOPLEFT') end --print(block:GetHeight(), block:GetPoint(1)) block:Show() contentsHeight = contentsHeight + block:GetHeight() --print(index, name, icon) lastBlock = block break; end end end --print(index, #self.blocks) if index < #self.blocks then for i = index+1, #self.blocks do --print('hiding', i) self.blocks[i]:Hide() end end self:SetHeight(contentsHeight) end function module:Update(forced) if self.GuildInfoDirty or forced then self:UpdateGuildInfo() end if self.AchievementsDirty or forced then self:UpdateAchievementLinks() end end function module:SetupGuildUI() self:UnregisterEvent('ADDON_LOADED') end function module:OnEvent(event, ...) print('|cFFFF0088OnEvent()|r', event, ...) if event == 'ADDON_LOADED' then local addon = ... if addon == 'Blizzard_GuildUI' then self:SetupGuildUI() end elseif event == 'LFG_LIST_SEARCH_RESULTS_RECEIVED' then elseif event == 'LFG_LIST_SEARCH_RESULT_UPDATED' then end end