Rename functions
Eyal Solnik [10-02-15 - 18:34]
diff --git a/Menu.lua b/Menu.lua
index 6040dc7..57d2f1b 100644
--- a/Menu.lua
+++ b/Menu.lua
@@ -42,13 +42,31 @@ local function getMenuText(text, command)
-- We cannot inline this because GetBindingKey may return more than one binding for a single command,
-- and so when it returns more than one it messes up GetBindingText and we only need the first one.
local binding = GetBindingKey(command)
- return text .. " (|cff82c5ff" .. GetBindingText(binding) .. FONT_COLOR_CODE_CLOSE .. ")";
+ return text .. " (|cff82c5ff" .. GetBindingText(binding) .. FONT_COLOR_CODE_CLOSE .. ")"
else
- return text;
+ return text
end
end
-local function insertItem(name, order)
+local function insertItem(text, func)
+ table.insert(menu, {
+ text = text,
+ notCheckable = 1,
+ func = func,
+ })
+end
+
+local function insertSeparator()
+ if #menu > 0 then
+ table.insert(menu, {
+ text = "",
+ notCheckable = 1,
+ disabled = true,
+ })
+ end
+end
+
+local function insertInterface(name, order)
local interface = addon.display:GetInterface(name)
if interface and order > 0 then
local inCombat = UnitAffectingCombat("player")
@@ -77,24 +95,6 @@ local function insertItem(name, order)
end
end
-local function insertSimpleItem(text, func)
- table.insert(menu, {
- text = text,
- notCheckable = 1,
- func = func,
- })
-end
-
-local function insertSeparator()
- if #menu > 0 then
- table.insert(menu, {
- text = "",
- notCheckable = 1,
- disabled = true,
- })
- end
-end
-
local function comp(a, b)
return a.order < b.order
end
@@ -106,20 +106,20 @@ function addon:BuildMenu()
wipe(menu)
for name, order in pairs(self.db.profile.menu) do
- insertItem(name, order)
+ insertInterface(name, order)
end
table.sort(menu, comp)
if not self.db.profile.hideLogoutButtons then
insertSeparator()
- insertSimpleItem(LOGOUT, function()
+ insertItem(LOGOUT, function()
Logout()
HideUIPanel(GameMenuFrame)
end)
end
if not self.db.profile.hideLogoutButtons then
- insertSimpleItem(EXIT_GAME, function()
+ insertItem(EXIT_GAME, function()
Quit()
HideUIPanel(GameMenuFrame)
end)
@@ -127,14 +127,14 @@ function addon:BuildMenu()
if not self.db.profile.hideReloadUIButton then
insertSeparator()
- insertSimpleItem(L["Reload UI"], function()
+ insertItem(L["Reload UI"], function()
ReloadUI()
end)
end
if not self.db.profile.hideOptionsButton then
insertSeparator()
- insertSimpleItem(L["Options"], function()
+ insertItem(L["Options"], function()
if not InterfaceOptionsFrame:IsVisible() then
HideUIPanel(GameMenuFrame)
InterfaceOptionsFrame_OpenToCategory(addon.name)