Mercurial > wow > onering3
comparison OneRing3.lua @ 0:54e8dbc97ee3
initial commit of onering3
| author | Bryan McLemore <kaelten@gmail.com> |
|---|---|
| date | Fri, 17 Apr 2009 04:19:16 -0500 |
| parents | |
| children | b4037e0bbae1 |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:54e8dbc97ee3 |
|---|---|
| 1 | |
| 2 local OneBag3 = LibStub('AceAddon-3.0'):GetAddon('OneBag3') | |
| 3 local OneRing3 = LibStub('AceAddon-3.0'):NewAddon('OneRing3', 'OneCore-1.0', 'OneFrame-1.0', 'OneConfig-1.0', 'OnePlugin-1.0', 'AceHook-3.0', 'AceEvent-3.0', 'AceConsole-3.0') | |
| 4 local AceDB3 = LibStub('AceDB-3.0') | |
| 5 local L = LibStub("AceLocale-3.0"):GetLocale("OneRing3") | |
| 6 | |
| 7 OneRing3:InitializePluginSystem() | |
| 8 | |
| 9 --- Handles the do once configuration, including db, frames and configuration | |
| 10 function OneRing3:OnInitialize() | |
| 11 self.db = OneBag3.db | |
| 12 self.displayName = "OneRing3" | |
| 13 | |
| 14 self.bagIndexes = {-2} | |
| 15 self.forcedCols = 4 | |
| 16 | |
| 17 self.frame = self:CreateMainFrame("OneRingFrame") | |
| 18 self.frame.handler = self | |
| 19 | |
| 20 table.insert(OneBag3.frame.childrenFrames, self.frame) | |
| 21 | |
| 22 self.frame:SetPosition(self.db.profile.position) | |
| 23 self.frame:CustomizeFrame(self.db.profile) | |
| 24 | |
| 25 self.frame.moneyframe:Hide() | |
| 26 self.frame.sidebarButton:Hide() | |
| 27 self.frame.configButton:Hide() | |
| 28 | |
| 29 self.frame.name:ClearAllPoints() | |
| 30 self.frame.name:SetPoint("TOPLEFT", "OneRingFrame", "TOPLEFT", 10, -15) | |
| 31 | |
| 32 self.frame:SetScript("OnShow", function() | |
| 33 if not self.frame.slots then | |
| 34 self.frame.slots = {} | |
| 35 end | |
| 36 | |
| 37 self:BuildFrame() | |
| 38 self:OrganizeFrame() | |
| 39 self:UpdateFrame() | |
| 40 | |
| 41 local UpdateBag = function(event, bag) | |
| 42 self:UpdateBag(bag) | |
| 43 end | |
| 44 | |
| 45 self:RegisterEvent("BAG_UPDATE", UpdateBag) | |
| 46 self:RegisterEvent("BAG_UPDATE_COOLDOWN", UpdateBag) | |
| 47 self:RegisterEvent("UPDATE_INVENTORY_ALERTS", "UpdateFrame") | |
| 48 | |
| 49 self.frame.name:SetText(L["%s's KeyRing"]:format(UnitName("player"))) | |
| 50 | |
| 51 self.frame:ClearAllPoints() | |
| 52 if not OneBag3.frame:IsVisible() then | |
| 53 self.frame:SetPoint("CENTER", UIParent, "CENTER", 0, 0) | |
| 54 else | |
| 55 self.frame:SetPoint("BOTTOMLEFT", OneBag3.frame, "TOPLEFT", 0, 8) | |
| 56 end | |
| 57 end) | |
| 58 | |
| 59 self.frame:SetScript("OnHide", function() | |
| 60 self:UnregisterEvent("BAG_UPDATE") | |
| 61 self:UnregisterEvent("BAG_UPDATE_COOLDOWN") | |
| 62 self:UnregisterEvent("UPDATE_INVENTORY_ALERTS") | |
| 63 end) | |
| 64 end | |
| 65 | |
| 66 --- Sets up hooks and registers events | |
| 67 function OneRing3:OnEnable() | |
| 68 self:SecureHook("ToggleKeyRing", function() | |
| 69 if self.frame:IsVisible() then | |
| 70 self.frame:Hide() | |
| 71 else | |
| 72 self.frame:Show() | |
| 73 end | |
| 74 | |
| 75 local shownContainerID = IsBagOpen(KEYRING_CONTAINER) | |
| 76 if ( shownContainerID ) then | |
| 77 local frame = getglobal("ContainerFrame"..shownContainerID) | |
| 78 frame:Hide() | |
| 79 end | |
| 80 end) | |
| 81 end | |
| 82 |
