Mercurial > wow > raid-target-tactics
comparison Main.lua @ 10:f93b554bb7cf
class implementation,
Icon class for Raid Target Icons
author | Jay Bird <a4blank@yahoo.com> |
---|---|
date | Sun, 28 Nov 2010 18:59:31 +0300 |
parents | 6e160ec1ef0f |
children | d2cbfe498c4d |
comparison
equal
deleted
inserted
replaced
9:7201711b23e9 | 10:f93b554bb7cf |
---|---|
4 local L = LibStub("AceLocale-3.0"):GetLocale("RaidTargetTactics") | 4 local L = LibStub("AceLocale-3.0"):GetLocale("RaidTargetTactics") |
5 | 5 |
6 | 6 |
7 local LDB = LibStub("LibDataBroker-1.1", true) | 7 local LDB = LibStub("LibDataBroker-1.1", true) |
8 local LDBIcon = LibStub("LibDBIcon-1.0", true) | 8 local LDBIcon = LibStub("LibDBIcon-1.0", true) |
9 local AceGUI = LibStub("AceGUI-3.0") | |
9 | 10 |
10 local RTTIcon = LibStub("LibDataBroker-1.1"):NewDataObject("RTTIcon", { | 11 local RTTIcon = LibStub("LibDataBroker-1.1"):NewDataObject("RTTIcon", { |
11 type = "data source", | 12 type = "data source", |
12 text = "Raid Target Tactics", | 13 text = "Raid Target Tactics", |
13 icon = "Interface\\TARGETINGFRAME\\UI-RaidTargetingIcon_8", | 14 icon = "Interface\\TARGETINGFRAME\\UI-RaidTargetingIcon_8", |
30 function RTT:OnInitialize() | 31 function RTT:OnInitialize() |
31 self.db = LibStub("AceDB-3.0"):New("TacticsSettings", defaults, true) | 32 self.db = LibStub("AceDB-3.0"):New("TacticsSettings", defaults, true) |
32 | 33 |
33 LDBIcon:Register("RTTIcon", RTTIcon, self.db.profile.minimap) | 34 LDBIcon:Register("RTTIcon", RTTIcon, self.db.profile.minimap) |
34 self:InitFrame() | 35 self:InitFrame() |
35 if self.f:IsShown() != self.db.profile.visible then | 36 if self.f:IsShown() ~= self.db.profile.visible then |
36 if self.db.profile.visible then | 37 if self.db.profile.visible then |
37 self:ShowFrame() | 38 self:ShowFrame() |
38 else | 39 else |
39 self:HideFrame() | 40 self:HideFrame() |
40 end | 41 end |
41 end | 42 end |
42 end | 43 end |
43 | 44 |
44 function RTT:InitFrame() | 45 function RTT:InitFrame() |
45 self.f = CreateFrame("Frame", nil, UIParent) | 46 self.f = CreateFrame("Frame", nil, UIParent) |
46 self.f:SetWidth(100) | 47 self.f:SetWidth(300) |
47 self.f:SetHeight(200) | 48 self.f:SetHeight(200) |
49 self.f:SetAlpha(0.8) | |
48 self.f:SetPoint("LEFT", UIParent, "LEFT", 10, 0) | 50 self.f:SetPoint("LEFT", UIParent, "LEFT", 10, 0) |
51 --[[self.f:SetBackdrop({bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", | |
52 edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", | |
53 tile = true, tileSize = 16, edgeSize = 16, | |
54 insets = { left = 4, right = 4, top = 4, bottom = 4 }}) | |
55 ]] | |
56 local backdrop = { | |
57 -- path to the background texture | |
58 bgFile = "Interface\\FrameGeneral\\UI-Background-Marble", | |
59 -- path to the border texture | |
60 edgeFile = "Interface\\DialogFrame\\UI-DialogBox-Gold-Border", | |
61 -- true to repeat the background texture to fill the frame, false to scale it | |
62 tile = true, | |
63 -- size (width or height) of the square repeating background tiles (in pixels) | |
64 tileSize = 256, | |
65 -- thickness of edge segments and square size of edge corners (in pixels) | |
66 edgeSize = 32, | |
67 -- distance from the edges of the frame to those of the background texture (in pixels) | |
68 insets = { | |
69 left = 11, | |
70 right = 12, | |
71 top = 12, | |
72 bottom = 11 | |
73 } | |
74 } | |
75 self.f:SetBackdrop(backdrop) | |
76 self.f:SetFrameStrata("HIGH") | |
77 --self.f:SetBackdropColor(0, 0, 0, 0.5) | |
78 | |
79 self.fields = {} | |
80 self.selects = {} | |
81 for num, icon in ipairs(RaidIcons) do | |
82 icon:draw(self.f, 20, num * -20) | |
83 | |
84 local field = CreateFrame("EditBox", "__RTT_EditBox_" .. tostring(num), self.f, "InputBoxTemplate") | |
85 field:SetAutoFocus(false) | |
86 field:SetFontObject(ChatFontNormal) | |
87 field:SetWidth(100) | |
88 field:SetHeight(16) | |
89 field:SetTextInsets(0, 0, 3, 3) | |
90 field:SetPoint("TOPLEFT", 40, num * -20) | |
91 table.insert(self.fields, field) | |
92 field:Show() | |
93 | |
94 local userSelect = AceGUI:Create("Dropdown") | |
95 userSelect.frame:SetParent(self.f) | |
96 local raid = {} | |
97 for i=1, GetNumRaidMembers() do | |
98 raid[i] = UnitName("raid" .. i) | |
99 end | |
100 userSelect:SetList(raid) | |
101 userSelect:SetWidth(100) | |
102 userSelect:SetHeight(16) | |
103 userSelect:SetPoint("TOPLEFT", 160, num * -20) | |
104 table.insert(self.selects, userSelect) | |
105 userSelect.frame:Show() | |
106 end | |
49 end | 107 end |
50 | 108 |
51 function RTT:OnIconClick() | 109 function RTT:OnIconClick() |
52 if self.db.profile.visible then | 110 if self.db.profile.visible then |
53 self:HideFrame() | 111 self:HideFrame() |
54 else | 112 else |
55 self:ShowFrame() | 113 self:ShowFrame() |
56 end | 114 end |
57 self.db.profile.visible = !self.db.profile.visible | 115 self.db.profile.visible = not self.db.profile.visible |
58 end | 116 end |
59 | 117 |
60 function RTT:HideFrame() | 118 function RTT:HideFrame() |
61 self.f:Hide() | 119 self.f:Hide() |
62 end | 120 end |