Mercurial > wow > whichrankdoeswhat
comparison main.lua @ 8:e6382ba088c3
Potentially avoid side tabs being glued to lib-st widgets.
| author | Farmbuyer of US-Kilrogg <farmbuyer@gmail.com> |
|---|---|
| date | Fri, 27 Jan 2012 01:31:29 +0000 |
| parents | 332550e56fd2 |
| children | 3a2beea01a28 |
comparison
equal
deleted
inserted
replaced
| 7:332550e56fd2 | 8:e6382ba088c3 |
|---|---|
| 76 local st_displayed_rows = 15 --math.floor(366/st_rowheight) | 76 local st_displayed_rows = 15 --math.floor(366/st_rowheight) |
| 77 local st_colwidth = 65 | 77 local st_colwidth = 65 |
| 78 local sidetabs | 78 local sidetabs |
| 79 local incomplete | 79 local incomplete |
| 80 | 80 |
| 81 -- Remove children widgets without explicitly Release()'ing them. | 81 -- Remove children ST widgets without explicitly Release()'ing them. |
| 82 local function DisownChildren (container) | 82 local function DisownChildren (container) |
| 83 for i,v in ipairs(container.children) do | 83 for i,v in ipairs(container.children) do |
| 84 container.children[i] = nil | 84 container.children[i] = nil |
| 85 v.frame:Hide() | 85 v.frame:Hide() |
| 86 v.frame:ClearAllPoints() | 86 v.frame:ClearAllPoints() |
| 127 end | 127 end |
| 128 | 128 |
| 129 | 129 |
| 130 function addon:OnEnable() | 130 function addon:OnEnable() |
| 131 self:RegisterEvent("GUILD_RANKS_UPDATE") | 131 self:RegisterEvent("GUILD_RANKS_UPDATE") |
| 132 self:RegisterChatCommand("wrdw", "OnChatCommand") | 132 self:RegisterChatCommand("wrdw", "OnSlashCommand") |
| 133 | 133 |
| 134 -- Ideally, most of this stuff wouldn't be done at load time at all; this | 134 -- Ideally, most of this stuff wouldn't be done at load time at all; this |
| 135 -- whole addon should be LoD. | 135 -- whole addon should be LoD. |
| 136 if (not IsGuildLeader()) and self.db.profile.guildcontrol then | 136 if (not IsGuildLeader()) and self.db.profile.guildcontrol then |
| 137 local function onclick() addon:BuildWindow() end | 137 local function onclick() addon:BuildWindow() end |
| 158 else | 158 else |
| 159 self:Disable() | 159 self:Disable() |
| 160 end | 160 end |
| 161 end | 161 end |
| 162 | 162 |
| 163 function addon:OnChatCommand (input) | 163 function addon:OnSlashCommand (input) |
| 164 if not NUM_RANK_FLAGS then -- in case a GM didn't get it loaded earlier | 164 if not NUM_RANK_FLAGS then -- in case a GM didn't get it loaded earlier |
| 165 GuildFrame_LoadUI() | 165 GuildFrame_LoadUI() |
| 166 UIParentLoadAddOn("Blizzard_GuildControlUI") | 166 UIParentLoadAddOn("Blizzard_GuildControlUI") |
| 167 end | 167 end |
| 168 if not input or input:trim() == "" then | 168 if not input or input:trim() == "" then |
| 370 self.vault_sts[tab] = ST | 370 self.vault_sts[tab] = ST |
| 371 end | 371 end |
| 372 end | 372 end |
| 373 | 373 |
| 374 | 374 |
| 375 -- Under normal conditions, this massive wodge is built once, and then merely | |
| 376 -- :Show'n and :Hide'n. Only if info gets out of date do we release/destroy | |
| 377 -- the UI elements and rebuild. | |
| 375 function addon:BuildWindow() | 378 function addon:BuildWindow() |
| 376 local need_tabs | 379 local need_tabs |
| 377 if self.display then | 380 if self.display then |
| 378 self.display:Hide() | 381 self.display:Hide() |
| 379 else | 382 else |
| 380 self.display = AceGUI:Create("Frame") | 383 self.display = AceGUI:Create("Frame") |
| 381 self.display:SetTitle("Which Rank Does What") | 384 self.display:SetTitle("Which Rank Does What") |
| 382 self.display:SetLayout("Fill") | 385 self.display:SetLayout("Fill") |
| 386 self.display:EnableResize(false) | |
| 383 self.display:SetStatusTable{ | 387 self.display:SetStatusTable{ |
| 384 width = (st_colwidth+4) * (NUM_RANK_FLAGS-1) -- flag columns | 388 width = (st_colwidth+4) * (NUM_RANK_FLAGS-1) -- flag columns |
| 385 + 105, -- rank label column | 389 + 105, -- rank label column |
| 386 height = 500, | 390 height = 500, |
| 387 } | 391 } |
| 389 self.display:SetCallback("OnClose", function(_d) | 393 self.display:SetCallback("OnClose", function(_d) |
| 390 if incomplete or (not self.perms) then | 394 if incomplete or (not self.perms) then |
| 391 -- stuff changed while open | 395 -- stuff changed while open |
| 392 self.perms = nil | 396 self.perms = nil |
| 393 self.display = nil | 397 self.display = nil |
| 398 if sidetabs then for i,s in ipairs(sidetabs) do | |
| 399 s:Hide() | |
| 400 s:ClearAllPoints() | |
| 401 s:SetParent(nil) -- Blizzard does this too. Huh. | |
| 402 end end | |
| 394 sidetabs = nil | 403 sidetabs = nil |
| 395 AceGUI:Release(_d) | 404 AceGUI:Release(_d) |
| 396 end | 405 end |
| 397 end) | 406 end) |
| 398 if self.display.EnableResize then | |
| 399 self.display:EnableResize(false) | |
| 400 end | |
| 401 need_tabs = true | 407 need_tabs = true |
| 402 end | 408 end |
| 403 | 409 |
| 404 if not self.perms then | 410 if not self.perms then |
| 405 need_tabs = true | 411 need_tabs = true |
| 406 self:BuildPerms() -- creates self.perms and self.vault | 412 self:BuildPerms() -- creates self.perms and self.vault |
| 407 DisownChildren(self.display) | 413 DisownChildren(self.display) |
| 408 -- Could be new rows, fewer rows, changed tickboxes... ugh, trying to | 414 -- Could be new rows, fewer rows, changed tickboxes... ugh, trying to |
| 409 -- update the scrolltable is a pain. Throw it out and start over. | 415 -- update the scrolltable is a pain. Throw it out and start over. |
| 416 if sidetabs then for i,s in ipairs(sidetabs) do | |
| 417 s:Hide() | |
| 418 s:ClearAllPoints() | |
| 419 s:SetParent(nil) -- Blizzard does this too. Huh. | |
| 420 end end | |
| 410 if self.main_st and self.main_st.st then | 421 if self.main_st and self.main_st.st then |
| 411 self.main_st:Release() | 422 self.main_st:Release() |
| 412 end | 423 end |
| 413 if self.vault_sts then for i = 1, #self.vault_sts do | 424 if self.vault_sts then for i = 1, #self.vault_sts do |
| 414 if self.vault_sts[i] and self.vault_sts[i].st then | 425 if self.vault_sts[i] and self.vault_sts[i].st then |
