Skip to content

Commit ccf36fb

Browse files
Applying style guide to code.
1 parent 665b61b commit ccf36fb

File tree

6 files changed

+313
-335
lines changed

6 files changed

+313
-335
lines changed

Broker.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ local function OnBrokerTooltipShow(tt)
99
tt:AddLine(Elephant.L['activefilters'])
1010

1111
local filter
12-
for _,filter in pairs(Elephant.db.profile.filters) do
12+
for _, filter in pairs(Elephant.db.profile.filters) do
1313
tt:AddLine(" " .. filter, 1.0, 1.0, 1.0, 1.0)
1414
end
1515

Event.lua

Lines changed: 62 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ color does not exist.
77
]]
88
local function GetClassColorByGUID(guid)
99
if guid and guid ~= "" then
10-
local _, englishClass = GetPlayerInfoByGUID(guid)
11-
if englishClass then
12-
local classColorTable = RAID_CLASS_COLORS[englishClass];
13-
if classColorTable then
14-
return Elephant:MakeTextHexColor(classColorTable.r, classColorTable.g, classColorTable.b)
10+
local _, english_class = GetPlayerInfoByGUID(guid)
11+
if english_class then
12+
local class_color_table = RAID_CLASS_COLORS[english_class];
13+
if class_color_table then
14+
return Elephant:MakeTextHexColor(class_color_table.r, class_color_table.g, class_color_table.b)
1515
end
1616
end
1717
end
@@ -25,24 +25,24 @@ integer for them.
2525
2626
Returns nil if a channel cannot be found.
2727
]]
28-
local function getCIndexFromChannelName(channelName)
29-
if channelName == "" then
28+
local function GetChannelIndexFromChannelName(channel_name)
29+
if channel_name == "" then
3030
return nil
3131
end
3232

33-
channelName = string.lower(channelName)
34-
local cIndex
35-
for k, v in pairs(Elephant.L['generalchats']) do
36-
if (channelName == k) or string.find(channelName, k .. " - ") then
37-
cIndex = k
33+
channel_name = string.lower(channel_name)
34+
local channel_index
35+
for general_chat_channel_name, _ in pairs(Elephant.L['generalchats']) do
36+
if (channel_name == general_chat_channel_name) or string.find(channel_name, general_chat_channel_name .. " - ") then
37+
channel_index = general_chat_channel_name
3838
break
3939
end
4040
end
41-
if cIndex == nil then
41+
if channel_index == nil then
4242
-- Custom channel name
43-
cIndex = channelName
43+
channel_index = channel_name
4444
end
45-
return cIndex
45+
return channel_index
4646
end
4747

4848
--[[
@@ -58,19 +58,19 @@ local function HandleMessage(prat_struct, event, ...)
5858
end
5959

6060
-- Getting info from event args
61-
local message, sender, _, _, _, flags, _, _, channelName, _, _, guid = ...
61+
local message, sender, _, _, _, flags, _, _, channel_name, _, _, guid = ...
6262
if flags == "" then
6363
flags = nil
6464
end
6565

6666
-- Sometimes we need to log two messages for the price of one.
67-
local msg, msg2
67+
local new_message_struct, new_message_struct_2
6868
-- Channels
6969
if event == "CHAT_MSG_CHANNEL" or event == "CHAT_MSG_CHANNEL_NOTICE" then
70-
cIndex = getCIndexFromChannelName(channelName)
70+
local channel_index = GetChannelIndexFromChannelName(channel_name)
7171

72-
-- cIndex == nil should never happen, but better to ignore than crash.
73-
if cIndex == nil or Elephant:IsFiltered(cIndex) then return end
72+
-- channel_index == nil should never happen, but better to ignore than crash.
73+
if channel_index == nil or Elephant:IsFiltered(channel_index) then return end
7474

7575
if event == "CHAT_MSG_CHANNEL" then
7676
-- Fixing error where structure for channel does not exist
@@ -79,74 +79,74 @@ local function HandleMessage(prat_struct, event, ...)
7979
-- event for that channel. In this case though, the client cannot be
8080
-- displaying that log, so we don't have to update the buttons like
8181
-- when a YOU_JOINED event happens.
82-
Elephant:InitCustomStructure(cIndex, channelName)
83-
if not Elephant.dbpc.char.logs[cIndex].enabled then
82+
Elephant:MaybeInitCustomStructure(channel_index, channel_name)
83+
if not Elephant.dbpc.char.logs[channel_index].enabled then
8484
return
8585
end
8686

8787
if prat_struct then
88-
msg = {
88+
new_message_struct = {
8989
['time'] = time(),
9090
['prat'] = prat_struct.message,
9191
['lineid'] = prat_struct.line_id,
9292
}
9393
else
94-
msg = {
94+
new_message_struct = {
9595
['time'] = time(),
9696
['arg1'] = message,
9797
['arg6'] = flags,
98-
['arg9'] = channelName,
98+
['arg9'] = channel_name,
9999
['clColor'] = GetClassColorByGUID(guid)
100100
}
101101
if sender ~= "" then
102-
msg['arg2'] = sender
102+
new_message_struct['arg2'] = sender
103103
end
104104
end
105-
Elephant:CaptureNewMessage(msg, cIndex)
105+
Elephant:CaptureNewMessage(new_message_struct, channel_index)
106106
end
107107

108108
if event == "CHAT_MSG_CHANNEL_NOTICE" then
109109
if message == "YOU_JOINED" or message == "YOU_CHANGED" then
110-
Elephant:InitCustomStructure(cIndex, channelName)
111-
if not Elephant.dbpc.char.logs[cIndex].enabled then
110+
Elephant:MaybeInitCustomStructure(channel_index, channel_name)
111+
if not Elephant.dbpc.char.logs[channel_index].enabled then
112112
return
113113
end
114114

115-
Elephant:CaptureNewMessage( { ['type'] = "SYSTEM", ['arg1'] = Elephant.L['customchat']['join'] } , cIndex)
116-
if Elephant.dbpc.char.currentlogindex == cIndex then
115+
Elephant:CaptureNewMessage( { ['type'] = "SYSTEM", ['arg1'] = Elephant.L['customchat']['join'] } , channel_index)
116+
if Elephant.dbpc.char.currentlogindex == channel_index then
117117
Elephant:UpdateCurrentLogButtons()
118118
end
119119
end
120120
if message == "YOU_LEFT" then
121-
if not Elephant.dbpc.char.logs[cIndex] or Elephant.dbpc.char.logs[cIndex].enabled then
121+
if not Elephant.dbpc.char.logs[channel_index] or Elephant.dbpc.char.logs[channel_index].enabled then
122122
return
123123
end
124124

125-
Elephant:CaptureNewMessage( { ['type'] = "SYSTEM", ['arg1'] = Elephant.L['customchat']['leave'] } , cIndex)
126-
Elephant:CaptureNewMessage( { ['arg1'] = " " } , cIndex)
127-
if Elephant.dbpc.char.currentlogindex == cIndex then
125+
Elephant:CaptureNewMessage( { ['type'] = "SYSTEM", ['arg1'] = Elephant.L['customchat']['leave'] } , channel_index)
126+
Elephant:CaptureNewMessage( { ['arg1'] = " " } , channel_index)
127+
if Elephant.dbpc.char.currentlogindex == channel_index then
128128
Elephant:UpdateCurrentLogButtons()
129129
Elephant:ForceCurrentLogDeleteButtonStatus(true)
130130
end
131131
end
132132
end
133-
-- Not channel messages
134133
else
134+
-- Not channel messages
135135
if prat_struct then
136-
msg = {
136+
new_message_struct = {
137137
['time'] = time(),
138138
['prat'] = prat_struct.message,
139139
['lineid'] = prat_struct.line_id,
140140
['type'] = Elephant.db.profile.events[event].type,
141141
}
142142
else
143-
msg = {
143+
new_message_struct = {
144144
['time'] = time(),
145145
['type'] = Elephant.db.profile.events[event].type,
146146
['arg1'] = message,
147147
}
148148

149-
if event == "CHAT_MSG_BATTLEGROUND" or
149+
if event == "CHAT_MSG_BATTLEGROUND" or
150150
event == "CHAT_MSG_BATTLEGROUND_LEADER" or
151151
event == "CHAT_MSG_WHISPER" or
152152
event == "CHAT_MSG_WHISPER_INFORM" or
@@ -172,12 +172,12 @@ local function HandleMessage(prat_struct, event, ...)
172172
event == "CHAT_MSG_INSTANCE_CHAT" or
173173
event == "CHAT_MSG_INSTANCE_CHAT_LEADER"
174174
then
175-
msg.arg2 = sender
176-
msg.clColor = GetClassColorByGUID(guid)
175+
new_message_struct.arg2 = sender
176+
new_message_struct.clColor = GetClassColorByGUID(guid)
177177
end
178178

179179
if event == "CHAT_MSG_WHISPER" then
180-
msg.arg6 = flags
180+
new_message_struct.arg6 = flags
181181
end
182182

183183
if event == "PARTY_LOOT_METHOD_CHANGED" then
@@ -195,43 +195,43 @@ local function HandleMessage(prat_struct, event, ...)
195195
end
196196
end
197197

198-
msg2 = {
198+
new_message_struct_2 = {
199199
['time'] = time(),
200200
['type'] = Elephant.db.profile.events[event].type
201201
}
202202

203203
-- Name of player may be unknown here, if interface
204204
-- has just been loaded
205205
if player == "Unknown" then
206-
msg2.arg1 = "<" .. Elephant.L['masterlooternameunknown'] .. ">"
206+
new_message_struct_2.arg1 = "<" .. Elephant.L['masterlooternameunknown'] .. ">"
207207
elseif player ~= Elephant.tempConf.masterlooter then
208208
Elephant.tempConf.masterlooter = player
209209

210-
msg2.arg1 = format(Elephant.L['masterlooterchanged'], player)
210+
new_message_struct_2.arg1 = format(Elephant.L['masterlooterchanged'], player)
211211
end
212212
else
213213
Elephant.tempConf.masterlooter = nil
214214
end
215215

216216
if method ~= Elephant.tempConf.lootmethod then
217217
Elephant.tempConf.lootmethod = method
218-
msg.arg1 = Elephant.L['lootmethod'][method]
218+
new_message_struct.arg1 = Elephant.L['lootmethod'][method]
219219
else
220-
-- Warning: msg2 might also be nil
221-
msg = msg2
222-
msg2 = nil
220+
-- Warning: new_message_struct_2 might also be nil
221+
new_message_struct = new_message_struct_2
222+
new_message_struct_2 = nil
223223
end
224224
end
225225
end
226226

227227
-- Finally, capture the message if it is not nil
228-
if msg ~= nil then
229-
local k
230-
for k in pairs(Elephant.db.profile.events[event].channels) do
231-
if Elephant.db.profile.events[event].channels[k] ~= 0 and Elephant.dbpc.char.logs[k].enabled then
232-
Elephant:CaptureNewMessage(msg, k)
233-
if msg2 ~= nil then
234-
Elephant:CaptureNewMessage(msg2, k)
228+
if new_message_struct ~= nil then
229+
local channel_index
230+
for channel_index in pairs(Elephant.db.profile.events[event].channels) do
231+
if Elephant.db.profile.events[event].channels[channel_index] ~= 0 and Elephant.dbpc.char.logs[channel_index].enabled then
232+
Elephant:CaptureNewMessage(new_message_struct, channel_index)
233+
if new_message_struct_2 ~= nil then
234+
Elephant:CaptureNewMessage(new_message_struct_2, channel_index)
235235
end
236236
end
237237
end
@@ -253,23 +253,23 @@ loaded.
253253
function Elephant:RegisterEventsRefresh()
254254
Elephant:UnregisterAllEvents()
255255

256-
local event
256+
local event_type
257257
if Prat and Elephant.db.profile.prat then
258258
Prat.RegisterChatEvent(Elephant, Prat.Events.POST_ADDMESSAGE)
259259

260260
-- Registering additional events not handled by Prat
261-
for event, v in pairs(Elephant.db.profile.events) do
262-
if v.register_with_prat then
263-
Elephant:RegisterEvent(event, HandleMessage, nil)
261+
for event_type, event_struct in pairs(Elephant.db.profile.events) do
262+
if event_struct.register_with_prat then
263+
Elephant:RegisterEvent(event_type, HandleMessage, nil)
264264
end
265265
end
266266
else
267267
if not Prat and Elephant.db.profile.prat then
268268
Elephant:Print("|cffff0000" .. Elephant.L['noprat'] .. "|r")
269269
end
270270

271-
for event, v in pairs(Elephant.db.profile.events) do
272-
Elephant:RegisterEvent(event, HandleMessage, nil)
271+
for event_type, event_struct in pairs(Elephant.db.profile.events) do
272+
Elephant:RegisterEvent(event_type, HandleMessage, nil)
273273
end
274274
end
275275
end

Interface-Dropdown.lua

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Utility method to sort the dropdowns menu
33
choices alphabetically.
44
]]
55
local function SortTable(arg1, arg2)
6-
local i=1
6+
local i = 1
77
local j
88

99
repeat
@@ -28,7 +28,6 @@ end
2828
--[[ Dropdowns ]]
2929
-- See below local functions declaration for dropdown
3030
-- creation function associations
31-
3231
local function DropdownCustomChatsInitialize()
3332
local info = {}
3433
info.text = Elephant.L['chatnames']['custom']

0 commit comments

Comments
 (0)