Commit 8c1e7705 authored by NihilisticPandemonium's avatar NihilisticPandemonium
Browse files

Renaming some functions to better match what they do. Also some free...

Renaming some functions to better match what they do.  Also some free formatting changes, cause I see Simpy commit formatting changes too.
parent 85c8eb59
local E, L, V, P, G = unpack(select(2, ...)); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
local DT = E:GetModule('DataTexts')
local AB = E:GetModule('ActionBars')
local E, L, V, P, G = unpack(select(2, ...)) --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
local DT = E:GetModule("DataTexts")
local AB = E:GetModule("ActionBars")
--Lua functions
local _G = _G
......@@ -24,225 +24,247 @@ local GetCVarBool = GetCVarBool
-- GLOBALS: ElvUIGrid
function E:Grid(msg)
msg = msg and tonumber(msg)
if type(msg) == "number" and (msg <= 256 and msg >= 4) then
E.db.gridSize = msg
E:Grid_Show()
elseif ElvUIGrid and ElvUIGrid:IsShown() then
E:Grid_Hide()
else
E:Grid_Show()
end
msg = msg and tonumber(msg)
if type(msg) == "number" and (msg <= 256 and msg >= 4) then
E.db.gridSize = msg
E:Grid_Show()
elseif ElvUIGrid and ElvUIGrid:IsShown() then
E:Grid_Hide()
else
E:Grid_Show()
end
end
function E:LuaError(msg)
msg = lower(msg)
if (msg == 'on') then
DisableAllAddOns()
EnableAddOn("ElvUI");
EnableAddOn("ElvUI_OptionsUI");
SetCVar("scriptErrors", 1)
ReloadUI()
elseif (msg == 'off') then
SetCVar("scriptErrors", 0)
E:Print("Lua errors off.")
else
E:Print("/luaerror on - /luaerror off")
end
msg = lower(msg)
if (msg == "on") then
DisableAllAddOns()
EnableAddOn("ElvUI")
EnableAddOn("ElvUI_OptionsUI")
SetCVar("scriptErrors", 1)
ReloadUI()
elseif (msg == "off") then
SetCVar("scriptErrors", 0)
E:Print("Lua errors off.")
else
E:Print("/luaerror on - /luaerror off")
end
end
function E:BGStats()
DT.ForceHideBGStats = nil;
DT:LoadDataTexts()
DT.ForceHideBGStats = nil
DT:LoadDataTexts()
E:Print(L["Battleground datatexts will now show again if you are inside a battleground."])
E:Print(L["Battleground datatexts will now show again if you are inside a battleground."])
end
local function OnCallback(command)
_G.MacroEditBox:GetScript("OnEvent")(_G.MacroEditBox, "EXECUTE_CHAT_LINE", command)
_G.MacroEditBox:GetScript("OnEvent")(_G.MacroEditBox, "EXECUTE_CHAT_LINE", command)
end
function E:DelayScriptCall(msg)
local secs, command = msg:match("^(%S+)%s+(.*)$")
secs = tonumber(secs)
if (not secs) or (#command == 0) then
self:Print("usage: /in <seconds> <command>")
self:Print("example: /in 1.5 /say hi")
else
E:Delay(secs, OnCallback, command)
end
local secs, command = msg:match("^(%S+)%s+(.*)$")
secs = tonumber(secs)
if (not secs) or (#command == 0) then
self:Print("usage: /in <seconds> <command>")
self:Print("example: /in 1.5 /say hi")
else
E:Delay(secs, OnCallback, command)
end
end
function E:MassGuildKick(msg)
local minLevel, minDays, minRankIndex = split(',', msg)
minRankIndex = tonumber(minRankIndex);
minLevel = tonumber(minLevel);
minDays = tonumber(minDays);
if not minLevel or not minDays then
E:Print("Usage: /cleanguild <minLevel>, <minDays>, [<minRankIndex>]");
return;
end
if minDays > 31 then
E:Print("Maximum days value must be below 32.");
return;
end
if not minRankIndex then minRankIndex = GuildControlGetNumRanks() - 1 end
for i = 1, GetNumGuildMembers() do
local name, _, rankIndex, level, _, _, note, officerNote, connected, _, classFileName = GetGuildRosterInfo(i)
local minLevelx = minLevel
if classFileName == "DEATHKNIGHT" then
minLevelx = minLevelx + 55
end
if not connected then
local years, months, days = GetGuildRosterLastOnline(i)
if days ~= nil and ((years > 0 or months > 0 or days >= minDays) and rankIndex >= minRankIndex) and note ~= nil and officerNote ~= nil and (level <= minLevelx) then
GuildUninvite(name)
end
end
end
SendChatMessage("Guild Cleanup Results: Removed all guild members below rank "..GuildControlGetRankName(minRankIndex)..", that have a minimal level of "..minLevel..", and have not been online for at least: "..minDays.." days.", "GUILD")
local minLevel, minDays, minRankIndex = split(",", msg)
minRankIndex = tonumber(minRankIndex)
minLevel = tonumber(minLevel)
minDays = tonumber(minDays)
if not minLevel or not minDays then
E:Print("Usage: /cleanguild <minLevel>, <minDays>, [<minRankIndex>]")
return
end
if minDays > 31 then
E:Print("Maximum days value must be below 32.")
return
end
if not minRankIndex then
minRankIndex = GuildControlGetNumRanks() - 1
end
for i = 1, GetNumGuildMembers() do
local name, _, rankIndex, level, _, _, note, officerNote, connected, _, classFileName = GetGuildRosterInfo(i)
local minLevelx = minLevel
if classFileName == "DEATHKNIGHT" then
minLevelx = minLevelx + 55
end
if not connected then
local years, months, days = GetGuildRosterLastOnline(i)
if
days ~= nil and ((years > 0 or months > 0 or days >= minDays) and rankIndex >= minRankIndex) and
note ~= nil and
officerNote ~= nil and
(level <= minLevelx)
then
GuildUninvite(name)
end
end
end
SendChatMessage(
"Guild Cleanup Results: Removed all guild members below rank " ..
GuildControlGetRankName(minRankIndex) ..
", that have a minimal level of " ..
minLevel .. ", and have not been online for at least: " .. minDays .. " days.",
"GUILD"
)
end
local num_frames = 0
local function OnUpdate()
num_frames = num_frames + 1
num_frames = num_frames + 1
end
local f = CreateFrame("Frame")
f:Hide()
f:SetScript("OnUpdate", OnUpdate)
local toggleMode, debugTimer = false, 0;
local toggleMode, debugTimer = false, 0
function E:GetCPUImpact()
if not GetCVarBool("scriptProfile") then
E:Print("For `/cpuimpact` to work, you need to enable script profiling via: `/console scriptProfile 1` then reload. Disable after testing by setting it back to 0.")
return
end
if(not toggleMode) then
ResetCPUUsage();
toggleMode, num_frames, debugTimer = true, 0, debugprofilestop();
self:Print("CPU Impact being calculated, type /cpuimpact to get results when you are ready.");
f:Show();
else
f:Hide();
local ms_passed = debugprofilestop() - debugTimer;
UpdateAddOnCPUUsage();
local per, passed = ((num_frames == 0 and 0) or (GetAddOnCPUUsage("ElvUI") / num_frames)), ((num_frames == 0 and 0) or (ms_passed / num_frames));
self:Print("Consumed "..(per and per > 0 and format("%.3f", per) or 0).."ms per frame. Each frame took "..(passed and passed > 0 and format("%.3f", passed) or 0).."ms to render.");
toggleMode = false;
end
if not GetCVarBool("scriptProfile") then
E:Print(
"For `/cpuimpact` to work, you need to enable script profiling via: `/console scriptProfile 1` then reload. Disable after testing by setting it back to 0."
)
return
end
if (not toggleMode) then
ResetCPUUsage()
toggleMode, num_frames, debugTimer = true, 0, debugprofilestop()
self:Print("CPU Impact being calculated, type /cpuimpact to get results when you are ready.")
f:Show()
else
f:Hide()
local ms_passed = debugprofilestop() - debugTimer
UpdateAddOnCPUUsage()
local per, passed =
((num_frames == 0 and 0) or (GetAddOnCPUUsage("ElvUI") / num_frames)),
((num_frames == 0 and 0) or (ms_passed / num_frames))
self:Print(
"Consumed " ..
(per and per > 0 and format("%.3f", per) or 0) ..
"ms per frame. Each frame took " ..
(passed and passed > 0 and format("%.3f", passed) or 0) .. "ms to render."
)
toggleMode = false
end
end
local BLIZZARD_ADDONS = {
"Blizzard_AchievementUI",
"Blizzard_AdventureMap",
"Blizzard_ArchaeologyUI",
"Blizzard_ArenaUI",
"Blizzard_ArtifactUI",
"Blizzard_AuctionUI",
"Blizzard_AuthChallengeUI",
"Blizzard_BarbershopUI",
"Blizzard_BattlefieldMinimap",
"Blizzard_BindingUI",
"Blizzard_BlackMarketUI",
"Blizzard_BoostTutorial",
"Blizzard_Calendar",
"Blizzard_ChallengesUI",
"Blizzard_ClassTrial",
"Blizzard_ClientSavedVariables",
"Blizzard_Collections",
"Blizzard_CombatLog",
"Blizzard_CombatText",
"Blizzard_CompactRaidFrames",
"Blizzard_CUFProfiles",
"Blizzard_DeathRecap",
"Blizzard_DebugTools",
"Blizzard_EncounterJournal",
"Blizzard_FlightMap",
"Blizzard_GarrisonTemplates",
"Blizzard_GarrisonUI",
"Blizzard_GlyphUI",
"Blizzard_GMChatUI",
"Blizzard_GMSurveyUI",
"Blizzard_GuildBankUI",
"Blizzard_GuildControlUI",
"Blizzard_GuildUI",
"Blizzard_InspectUI",
"Blizzard_ItemSocketingUI",
"Blizzard_ItemUpgradeUI",
"Blizzard_LookingForGuildUI",
"Blizzard_MacroUI",
"Blizzard_MapCanvas",
"Blizzard_MovePad",
"Blizzard_NamePlates",
"Blizzard_ObjectiveTracker",
"Blizzard_ObliterumUI",
"Blizzard_OrderHallUI",
"Blizzard_PetBattleUI",
"Blizzard_PVPUI",
"Blizzard_QuestChoice",
"Blizzard_RaidUI",
"Blizzard_SecureTransferUI",
"Blizzard_SharedMapDataProviders",
"Blizzard_SocialUI",
"Blizzard_StoreUI",
"Blizzard_TalentUI",
"Blizzard_TalkingHeadUI",
"Blizzard_TimeManager",
"Blizzard_TokenUI",
"Blizzard_TradeSkillUI",
"Blizzard_TrainerUI",
"Blizzard_Tutorial",
"Blizzard_TutorialTemplates",
"Blizzard_VoidStorageUI",
"Blizzard_WowTokenUI",
"Blizzard_AchievementUI",
"Blizzard_AdventureMap",
"Blizzard_ArchaeologyUI",
"Blizzard_ArenaUI",
"Blizzard_ArtifactUI",
"Blizzard_AuctionUI",
"Blizzard_AuthChallengeUI",
"Blizzard_BarbershopUI",
"Blizzard_BattlefieldMinimap",
"Blizzard_BindingUI",
"Blizzard_BlackMarketUI",
"Blizzard_BoostTutorial",
"Blizzard_Calendar",
"Blizzard_ChallengesUI",
"Blizzard_ClassTrial",
"Blizzard_ClientSavedVariables",
"Blizzard_Collections",
"Blizzard_CombatLog",
"Blizzard_CombatText",
"Blizzard_CompactRaidFrames",
"Blizzard_CUFProfiles",
"Blizzard_DeathRecap",
"Blizzard_DebugTools",
"Blizzard_EncounterJournal",
"Blizzard_FlightMap",
"Blizzard_GarrisonTemplates",
"Blizzard_GarrisonUI",
"Blizzard_GlyphUI",
"Blizzard_GMChatUI",
"Blizzard_GMSurveyUI",
"Blizzard_GuildBankUI",
"Blizzard_GuildControlUI",
"Blizzard_GuildUI",
"Blizzard_InspectUI",
"Blizzard_ItemSocketingUI",
"Blizzard_ItemUpgradeUI",
"Blizzard_LookingForGuildUI",
"Blizzard_MacroUI",
"Blizzard_MapCanvas",
"Blizzard_MovePad",
"Blizzard_NamePlates",
"Blizzard_ObjectiveTracker",
"Blizzard_ObliterumUI",
"Blizzard_OrderHallUI",
"Blizzard_PetBattleUI",
"Blizzard_PVPUI",
"Blizzard_QuestChoice",
"Blizzard_RaidUI",
"Blizzard_SecureTransferUI",
"Blizzard_SharedMapDataProviders",
"Blizzard_SocialUI",
"Blizzard_StoreUI",
"Blizzard_TalentUI",
"Blizzard_TalkingHeadUI",
"Blizzard_TimeManager",
"Blizzard_TokenUI",
"Blizzard_TradeSkillUI",
"Blizzard_TrainerUI",
"Blizzard_Tutorial",
"Blizzard_TutorialTemplates",
"Blizzard_VoidStorageUI",
"Blizzard_WowTokenUI"
}
function E:EnableBlizzardAddOns()
for _, addon in pairs(BLIZZARD_ADDONS) do
local reason = select(5, GetAddOnInfo(addon))
if reason == "DISABLED" then
EnableAddOn(addon)
E:Print("The following addon was re-enabled:", addon)
end
end
for _, addon in pairs(BLIZZARD_ADDONS) do
local reason = select(5, GetAddOnInfo(addon))
if reason == "DISABLED" then
EnableAddOn(addon)
E:Print("The following addon was re-enabled:", addon)
end
end
end
function E:LoadCommands()
self:RegisterChatCommand("in", "DelayScriptCall")
self:RegisterChatCommand("ec", "ToggleConfig")
self:RegisterChatCommand("elvui", "ToggleConfig")
self:RegisterChatCommand("cpuimpact", "GetCPUImpact")
self:RegisterChatCommand("cpuusage", "GetTopCPUFunc")
-- args: module, showall, delay, minCalls
-- Example1: /cpuusage all
-- Example2: /cpuusage Bags true
-- Example3: /cpuusage UnitFrames nil 50 25
-- Note: showall, delay, and minCalls will default if not set
-- arg1 can be "all" this will scan all registered modules!
self:RegisterChatCommand("bgstats", "BGStats")
self:RegisterChatCommand("hellokitty", "HelloKittyToggle")
self:RegisterChatCommand("hellokittyfix", "HelloKittyFix")
self:RegisterChatCommand("harlemshake", "HarlemShakeToggle")
self:RegisterChatCommand("luaerror", "LuaError")
self:RegisterChatCommand("egrid", "Grid")
self:RegisterChatCommand("moveui", "ToggleConfigMode")
self:RegisterChatCommand("resetui", "ResetUI")
self:RegisterChatCommand("cleanguild", "MassGuildKick")
self:RegisterChatCommand("enableblizzard", "EnableBlizzardAddOns")
self:RegisterChatCommand("estatus", "ShowStatusReport")
-- self:RegisterChatCommand("aprilfools", "") --Don't need this until next april fools
if E.private.actionbar.enable then
self:RegisterChatCommand("kb", AB.ActivateBindMode)
end
self:RegisterChatCommand("in", "DelayScriptCall")
self:RegisterChatCommand("ec", "ToggleOptionsUI")
self:RegisterChatCommand("elvui", "ToggleOptionsUI")
self:RegisterChatCommand("cpuimpact", "GetCPUImpact")
self:RegisterChatCommand("cpuusage", "GetTopCPUFunc")
-- args: module, showall, delay, minCalls
-- Example1: /cpuusage all
-- Example2: /cpuusage Bags true
-- Example3: /cpuusage UnitFrames nil 50 25
-- Note: showall, delay, and minCalls will default if not set
-- arg1 can be "all" this will scan all registered modules!
self:RegisterChatCommand("bgstats", "BGStats")
self:RegisterChatCommand("hellokitty", "HelloKittyToggle")
self:RegisterChatCommand("hellokittyfix", "HelloKittyFix")
self:RegisterChatCommand("harlemshake", "HarlemShakeToggle")
self:RegisterChatCommand("luaerror", "LuaError")
self:RegisterChatCommand("egrid", "Grid")
self:RegisterChatCommand("moveui", "ToggleMoveMode")
self:RegisterChatCommand("resetui", "ResetUI")
self:RegisterChatCommand("cleanguild", "MassGuildKick")
self:RegisterChatCommand("enableblizzard", "EnableBlizzardAddOns")
self:RegisterChatCommand("estatus", "ShowStatusReport")
-- self:RegisterChatCommand("aprilfools", "") --Don't need this until next april fools
if E.private.actionbar.enable then
self:RegisterChatCommand("kb", AB.ActivateBindMode)
end
end
......@@ -56,7 +56,7 @@ function E:Grid_Hide()
end
end
function E:ToggleConfigMode(override, configType)
function E:ToggleMoveMode(override, configType)
if InCombatLockdown() then return; end
if override ~= nil and override ~= '' then E.ConfigurationMode = override end
......@@ -181,7 +181,7 @@ end
local function ConfigMode_OnClick(self)
selectedValue = self.value
E:ToggleConfigMode(false, self.value)
E:ToggleMoveMode(false, self.value)
_G.UIDropDownMenu_SetSelectedValue(ElvUIMoverPopupWindowDropDown, self.value);
end
......@@ -291,7 +291,7 @@ function E:CreateMoverPopup()
_G[lock:GetName() .. "Text"]:SetText(L["Lock"])
lock:SetScript("OnClick", function()
E:ToggleConfigMode(true)
E:ToggleMoveMode(true)
if IsAddOnLoaded("ElvUI_OptionsUI") and E.Libs.AceConfigDialog then
E.Libs.AceConfigDialog:Open('ElvUI')
......@@ -350,7 +350,7 @@ function E:CreateMoverPopup()
if mover:IsShown() then
mover:Hide()
E:Grid_Hide()
E:ToggleConfigMode(true)
E:ToggleMoveMode(true)
end
end)
......
......@@ -204,7 +204,7 @@ local function CreateMover(parent, name, text, overlay, snapOffset, postdrag, sh
elseif IsShiftKeyDown() then --Allow hiding a mover temporarily
self:Hide()
elseif self.configString then --OpenConfig
E:ToggleConfig(self.configString)
E:ToggleOptionsUI(self.configString)
end
end
end
......
......@@ -52,7 +52,7 @@ end
local function Click(self, button)
if button == "LeftButton" or (button == "RightButton" and not IsShiftKeyDown()) then
E:ToggleConfig()
E:ToggleOptionsUI()
elseif button == "RightButton" and IsShiftKeyDown() then
ReloadUI()
end
......
......@@ -183,7 +183,7 @@ function AddOn:OnInitialize()
local GameMenuButton = CreateFrame("Button", nil, GameMenuFrame, "GameMenuButtonTemplate")
GameMenuButton:SetText(format("|cfffe7b2c%s|r", AddOnName))
GameMenuButton:SetScript("OnClick", function()
AddOn:ToggleConfig()
AddOn:ToggleOptionsUI()
HideUIPanel(GameMenuFrame)
end)
GameMenuFrame[AddOnName] = GameMenuButton
......@@ -215,7 +215,7 @@ LoadUI:SetScript("OnEvent", function()
end)
function AddOn:PLAYER_REGEN_ENABLED()
self:ToggleConfig()
self:ToggleOptionsUI()
self:UnregisterEvent('PLAYER_REGEN_ENABLED');
end
......@@ -293,7 +293,7 @@ function AddOn:ConfigStopMovingOrSizing()
end
local pageNodes = {}
function AddOn:ToggleConfig(msg)
function AddOn:ToggleOptionsUI(msg)
if InCombatLockdown() then
self:Print(ERR_NOT_IN_COMBAT)
self:RegisterEvent('PLAYER_REGEN_ENABLED')
......
......@@ -33,7 +33,7 @@ local function BuildABConfig()
order = 1,
type = "execute",
name = L["Keybind Mode"],
func = function() AB:ActivateBindMode(); E:ToggleConfig(); GameTooltip:Hide(); end,
func = function() AB:ActivateBindMode(); E:ToggleOptionsUI(); GameTooltip:Hide(); end,
disabled = function() return not E.private.actionbar.enable end,
},
spacer = {
......
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment