-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCEPGP_BulkAward.lua
160 lines (134 loc) · 4.28 KB
/
CEPGP_BulkAward.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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
local CEPGPBA_AddonName, _addon = ... -- addonName="CEPGP_BulkAward"
CEPGPBA = {};
local function CreateButton(parent)
local button
button = CreateFrame("Button", nil, parent)
button:SetNormalFontObject("GameFontNormal")
local ntex
ntex = button:CreateTexture()
ntex:SetTexture("Interface/Buttons/UI-Panel-Button-Up")
ntex:SetTexCoord(0, 0.625, 0, 0.6875)
ntex:SetAllPoints()
button:SetNormalTexture(ntex)
local htex
htex = button:CreateTexture()
htex:SetTexture("Interface/Buttons/UI-Panel-Button-Highlight")
htex:SetTexCoord(0, 0.625, 0, 0.6875)
htex:SetAllPoints()
button:SetHighlightTexture(htex)
local ptex
ptex = button:CreateTexture()
ptex:SetTexture("Interface/Buttons/UI-Panel-Button-Down")
ptex:SetTexCoord(0, 0.625, 0, 0.6875)
ptex:SetAllPoints()
button:SetPushedTexture(ptex)
return button
end
local function CreateMultilineEditBox(parent)
local backdrop = {
bgFile = "Interface/BUTTONS/WHITE8X8",
edgeFile = "Interface/GLUES/Common/Glue-Tooltip-Border",
tile = true,
edgeSize = 8,
tileSize = 8,
insets = {
left = 5,
right = 5,
top = 5,
bottom = 5,
},
}
local f = CreateFrame("Frame", "$parent_MultilineEdit", parent, BackdropTemplateMixin and "BackdropTemplate")
f:SetSize(500, 300)
--f:SetPoint("CENTER")
f:SetFrameStrata("BACKGROUND")
f:SetBackdrop(backdrop)
f:SetBackdropColor(0, 0, 0)
f.SF = CreateFrame("ScrollFrame", "$parent_ScrollFrame", f, "UIPanelScrollFrameTemplate")
f.SF:SetPoint("TOPLEFT", f, 12, -30)
f.SF:SetPoint("BOTTOMRIGHT", f, -30, 10)
f.Text = CreateFrame("EditBox", "$parent_Edit", f)
f.Text:SetMultiLine(true)
f.Text:SetSize(500, 300)
f.Text:SetPoint("TOPLEFT", f.SF)
f.Text:SetPoint("BOTTOMRIGHT", f.SF)
f.Text:SetMaxLetters(99999)
f.Text:SetFontObject(GameFontNormal)
f.Text:SetAutoFocus(false) -- do not steal focus from the game
f.Text:SetScript("OnEscapePressed",
function(self)
self:ClearFocus()
end)
f.SF:SetScrollChild(f.Text)
return f
end
function CEPGPBA_OnApplyChanges(text)
if text == nil then
print("CEPGP_BA: Something went wrong, can't get the task text from the editbox")
return
end
-- Split text into lines
for ln in string.gmatch(text, "[^\r\n]+") do
local player, amount, msg
local split = CEPGP_split(ln,",")
player = split[1]
amount = split[2]
msg = split[3]
do
CEPGP_addEP(player, tonumber(amount), msg)
end
if _G["CEPGP_traffic"]:IsVisible() then
CEPGP_UpdateTrafficScrollBar();
end
end -- end for all lines
end
function CEPGPBA_Initialise()
-- Create interface options panel
local panel
panel = CreateFrame("FRAME");
panel.name = "CEPGP Bulk Award";
local titleText
titleText = panel:CreateFontString("CEPGP_BA_titleText", "OVERLAY", "GameFontNormalLarge");
titleText:SetPoint("TOPLEFT", panel, "TOPLEFT", 15, -15);
titleText:SetText("CEPGP Bulk Operations: Mass Awards");
local taskBox
taskBox = CreateMultilineEditBox(panel)
taskBox:SetPoint("TOPLEFT", titleText, "BOTTOMLEFT", 0, -10);
-- Apply Button --
local okButton
okButton = CreateButton(panel)
okButton:SetPoint("TOPLEFT", taskBox, "BOTTOMLEFT", 0, -10)
okButton:SetWidth(150)
okButton:SetHeight(25)
okButton:SetText("Apply Changes")
okButton:SetScript("OnClick", function()
CEPGPBA_OnApplyChanges(taskBox.Text:GetText())
end)
local clearButton = CreateButton(panel)
clearButton:SetPoint("TOPLEFT", okButton, "TOPRIGHT", 10, 0)
clearButton:SetWidth(100)
clearButton:SetHeight(25)
clearButton:SetText("Clear")
clearButton:SetScript("OnClick", function()
taskBox.Text:SetText("")
end)
taskBox.Text:SetFocus()
InterfaceOptions_AddCategory(panel);
-- Register plugin with CEPGP
CEPGP_addPlugin(addonName, panel, true, function()
end);
end
function CEPGPBA_OnEvent(self, event, arg1)
if event == "ADDON_LOADED" and arg1 == CEPGPBA_AddonName then
CEPGPBA_Initialise();
end
end
function CEPGPBA_CreateFrames()
local mainFrame
mainFrame = CreateFrame("Frame", "CEPGP_BA_award_raid_popup", _G["CEPGP_award_raid_popup"]);
mainFrame:SetScale(1.0);
mainFrame:RegisterEvent("ADDON_LOADED");
mainFrame:SetScript("OnEvent", CEPGPBA_OnEvent);
end
-- START HERE --
CEPGPBA_CreateFrames();