Mercurial > wow > raid-target-tactics
comparison Main.lua @ 8:6e160ec1ef0f
locale, add DBIcon, experiment with frames
| author | Jay Bird <a4blank@yahoo.com> |
|---|---|
| date | Mon, 22 Nov 2010 08:39:57 -0500 |
| parents | d067c361c4e9 |
| children | f93b554bb7cf |
comparison
equal
deleted
inserted
replaced
| 7:b68bfda72a47 | 8:6e160ec1ef0f |
|---|---|
| 1 | 1 |
| 2 | 2 |
| 3 RTT = LibStub("AceAddon-3.0"):NewAddon("RaidTargetTactics", "AceConsole-3.0") | 3 RTT = LibStub("AceAddon-3.0"):NewAddon("RaidTargetTactics", "AceConsole-3.0") |
| 4 --local L = LibStub("AceLocale-3.0"):GetLocale("RaidTargetTactics") | 4 local L = LibStub("AceLocale-3.0"):GetLocale("RaidTargetTactics") |
| 5 | 5 |
| 6 | |
| 7 local LDB = LibStub("LibDataBroker-1.1", true) | |
| 8 local LDBIcon = LibStub("LibDBIcon-1.0", true) | |
| 9 | |
| 10 local RTTIcon = LibStub("LibDataBroker-1.1"):NewDataObject("RTTIcon", { | |
| 11 type = "data source", | |
| 12 text = "Raid Target Tactics", | |
| 13 icon = "Interface\\TARGETINGFRAME\\UI-RaidTargetingIcon_8", | |
| 14 OnClick = function() RTT:OnIconClick() end, | |
| 15 OnTooltipShow = function(tooltip) | |
| 16 tooltip:AddLine("Raid Target Tactics") | |
| 17 tooltip:AddLine(L.Minimap_Icon_Tooltip) | |
| 18 end, | |
| 19 }) | |
| 20 | |
| 21 local defaults = { | |
| 22 profile = { | |
| 23 visible = true, | |
| 24 minimap = { | |
| 25 hide = false, | |
| 26 }, | |
| 27 }, | |
| 28 } | |
| 6 | 29 |
| 7 function RTT:OnInitialize() | 30 function RTT:OnInitialize() |
| 8 self.db = LibStub("AceDB-3.0"):New("TacticsSettings", defaults, true) | 31 self.db = LibStub("AceDB-3.0"):New("TacticsSettings", defaults, true) |
| 9 local AceGUI = LibStub("AceGUI-3.0") | |
| 10 -- Create a container frame | |
| 11 local f = AceGUI:Create("Frame") | |
| 12 f:SetCallback("OnClose",function(widget) AceGUI:Release(widget) end) | |
| 13 f:SetTitle("AceGUI-3.0 Example") | |
| 14 f:SetStatusText("Status Bar") | |
| 15 f:SetLayout("Flow") | |
| 16 -- Create a button | |
| 17 local btn = AceGUI:Create("Button") | |
| 18 btn:SetWidth(170) | |
| 19 btn:SetText("Button !") | |
| 20 btn:SetCallback("OnClick", function() print("Click!") end) | |
| 21 -- Add the button to the container | |
| 22 f:AddChild(btn) | |
| 23 | 32 |
| 33 LDBIcon:Register("RTTIcon", RTTIcon, self.db.profile.minimap) | |
| 34 self:InitFrame() | |
| 35 if self.f:IsShown() != self.db.profile.visible then | |
| 36 if self.db.profile.visible then | |
| 37 self:ShowFrame() | |
| 38 else | |
| 39 self:HideFrame() | |
| 40 end | |
| 41 end | |
| 24 end | 42 end |
| 25 | 43 |
| 44 function RTT:InitFrame() | |
| 45 self.f = CreateFrame("Frame", nil, UIParent) | |
| 46 self.f:SetWidth(100) | |
| 47 self.f:SetHeight(200) | |
| 48 self.f:SetPoint("LEFT", UIParent, "LEFT", 10, 0) | |
| 49 end | |
| 50 | |
| 51 function RTT:OnIconClick() | |
| 52 if self.db.profile.visible then | |
| 53 self:HideFrame() | |
| 54 else | |
| 55 self:ShowFrame() | |
| 56 end | |
| 57 self.db.profile.visible = !self.db.profile.visible | |
| 58 end | |
| 59 | |
| 60 function RTT:HideFrame() | |
| 61 self.f:Hide() | |
| 62 end | |
| 63 | |
| 64 function RTT:ShowFrame() | |
| 65 self.f:Show() | |
| 66 end | |
| 67 | |
| 68 | |
| 69 | |
| 70 |
