-
Notifications
You must be signed in to change notification settings - Fork 74
/
AceGUIWidget-DungeonToolsNewPullButton.lua
140 lines (115 loc) · 3.86 KB
/
AceGUIWidget-DungeonToolsNewPullButton.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
local Type, Version = "MDTNewPullButton", 1
local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
local MDT = DungeonTools
local L = MDT.L
local width,height = 248,32
--Methods
local methods = {
["OnAcquire"] = function(self)
self:SetWidth(width);
self:SetHeight(height);
end,
["Initialize"] = function(self)
self.callbacks = {};
function self.callbacks.OnClickNormal(_, mouseButton)
if not MouseIsOver(MDT.main_frame.sidePanel.pullButtonsScrollFrame.frame) then return end
if(IsControlKeyDown())then
elseif(IsShiftKeyDown()) then
else
if(mouseButton == "RightButton") then
--L_EasyMenu
else
--normal click?
MDT:AddPull()
if MDT.liveSessionActive and MDT:GetCurrentPreset().uid == MDT.livePresetUID then
MDT:LiveSession_SendPulls(MDT:GetPulls())
end
end
end
end
function self.callbacks.OnDragStart()
--
end
function self.callbacks.OnDragStop()
--
end
function self.callbacks.OnKeyDown(self, key)
if (key == "ESCAPE") then
--
end
end
--Set pullNumber
self.pullNumber:SetText(L["+ Add pull"])
self.pullNumber:Show()
self.frame:SetScript("OnClick", self.callbacks.OnClickNormal);
self.frame:SetScript("OnKeyDown", self.callbacks.OnKeyDown);
self.frame:EnableKeyboard(false);
self.frame:SetMovable(true);
self.frame:RegisterForDrag("LeftButton");
self.frame:SetScript("OnDragStart", self.callbacks.OnDragStart);
self.frame:SetScript("OnDragStop", self.callbacks.OnDragStop);
self:Enable();
end,
["SetTitle"] = function(self, title)
self.titletext = title;
self.title:SetText(title);
end,
["Disable"] = function(self)
self.background:Hide();
self.frame:Disable();
end,
["Enable"] = function(self)
self.background:Show();
self.frame:Enable();
end,
["Pick"] = function(self)
self.frame:LockHighlight();
end,
["ClearPick"] = function(self)
self.frame:UnlockHighlight();
end,
["SetIndex"] = function(self, index)
self.index = index
end,
["GetIndex"] = function(self)
return self.index;
end,
}
--Constructor
local function Constructor()
local name = "MDTNewPullButton"..AceGUI:GetNextWidgetNum(Type);
local button = CreateFrame("BUTTON", name, UIParent, "OptionsListButtonTemplate");
button:SetHeight(height);
button:SetWidth(width);
button.dgroup = nil;
button.data = {};
local background = button:CreateTexture(nil, "BACKGROUND");
button.background = background;
background:SetTexture("Interface\\BUTTONS\\UI-Listbox-Highlight2.blp");
background:SetBlendMode("ADD");
background:SetVertexColor(0.5, 0.5, 0.5, 0.25);
background:SetPoint("TOP", button, "TOP");
background:SetPoint("BOTTOM", button, "BOTTOM");
background:SetPoint("LEFT", button, "LEFT");
background:SetPoint("RIGHT", button, "RIGHT");
button.description = {};
button:SetScript("OnEnter", function()
end);
button:SetScript("OnLeave", function()
end);
local pullNumber = button:CreateFontString(nil,"OVERLAY", "GameFontNormal")
pullNumber:SetHeight(18)
pullNumber:SetJustifyH("CENTER");
pullNumber:SetPoint("LEFT", button, "LEFT",5,0);
local widget = {
frame = button,
pullNumber = pullNumber,
background = background,
type = Type
}
for method, func in pairs(methods) do
widget[method] = func
end
return AceGUI:RegisterAsWidget(widget);
end
AceGUI:RegisterWidgetType(Type, Constructor, Version)