From a61017349c59c993a04dceec9a9e53f5cbe8a3db Mon Sep 17 00:00:00 2001 From: Bunny67 Date: Sun, 31 Dec 2017 03:40:14 +0300 Subject: [PATCH] 3 --- 2/3/4/5/6/7/ElvUI/Core/Commands.lua | 130 +++++++++++++++++++++++++++ 2/3/4/5/6/7/ElvUI/Core/Load_Core.xml | 2 +- 2 files changed, 131 insertions(+), 1 deletion(-) create mode 100644 2/3/4/5/6/7/ElvUI/Core/Commands.lua diff --git a/2/3/4/5/6/7/ElvUI/Core/Commands.lua b/2/3/4/5/6/7/ElvUI/Core/Commands.lua new file mode 100644 index 0000000..01e640b --- /dev/null +++ b/2/3/4/5/6/7/ElvUI/Core/Commands.lua @@ -0,0 +1,130 @@ +local E, L, V, P, G = unpack(ElvUI); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB + +--Cache global variables +--Lua functions +local _G = _G +local tonumber, type = tonumber, type +local format, lower, match = string.format, string.lower, string.match +--WoW API / Variables +local UIFrameFadeOut, UIFrameFadeIn = UIFrameFadeOut, UIFrameFadeIn +local EnableAddOn, DisableAddOn, DisableAllAddOns = EnableAddOn, DisableAddOn, DisableAllAddOns +local SetCVar = SetCVar +local ReloadUI = ReloadUI +local GetAddOnInfo = GetAddOnInfo + +function E:EnableAddon(addon) + local _, _, _, _, _, reason, _ = GetAddOnInfo(addon) + if reason ~= "MISSING" then + EnableAddOn(addon) + ReloadUI() + else + E:Print(format("Addon '%s' not found.", addon)) + end +end + +function E:DisableAddon(addon) + local _, _, _, _, _, reason, _ = GetAddOnInfo(addon) + if reason ~= "MISSING" then + DisableAddOn(addon) + ReloadUI() + else + E:Print(format("Addon '%s' not found.", addon)) + end +end + +function FarmMode() + if E.private.general.minimap.enable ~= true then return end + + if Minimap:IsShown() then + UIFrameFadeOut(Minimap, 0.3) + UIFrameFadeIn(FarmModeMap, 0.3) + Minimap.fadeInfo.finishedFunc = function() Minimap:Hide() _G.MinimapZoomIn:Click() _G.MinimapZoomOut:Click() Minimap:SetAlpha(1) end + FarmModeMap.enabled = true + else + UIFrameFadeOut(FarmModeMap, 0.3) + UIFrameFadeIn(Minimap, 0.3) + FarmModeMap.fadeInfo.finishedFunc = function() FarmModeMap:Hide() _G.MinimapZoomIn:Click() _G.MinimapZoomOut:Click() Minimap:SetAlpha(1) end + FarmModeMap.enabled = false + end +end + +function E:FarmMode(msg) + if E.private.general.minimap.enable ~= true then return end + if msg and type(tonumber(msg)) == "number" and tonumber(msg) <= 500 and tonumber(msg) >= 20 then + E.db.farmSize = tonumber(msg) + FarmModeMap:SetWidth(tonumber(msg)) + FarmModeMap:SetHeight(tonumber(msg)) + end + + FarmMode() +end + +function E:Grid(msg) + if msg and type(tonumber(msg)) == "number" and tonumber(msg) <= 256 and tonumber(msg) >= 4 then + E.db.gridSize = msg + E:Grid_Show() + else + if(EGrid) then + E:Grid_Hide() + else + E:Grid_Show() + end + end +end + +function E:LuaError(msg) + msg = lower(msg) + if msg == "on" then + DisableAllAddOns() + EnableAddOn("ElvUI") + EnableAddOn("ElvUI_Config") + SetCVar("ShowErrors", "1") + ReloadUI() + elseif msg == "off" then + SetCVar("ShowErrors", "0") + E:Print("Lua errors off.") + else + E:Print("/luaerror on - /luaerror off") + end +end + +function E:BGStats() + local DT = E:GetModule("DataTexts") + DT.ForceHideBGStats = nil + DT:LoadDataTexts() + + E:Print(L["Battleground datatexts will now show again if you are inside a battleground."]) +end + +local function OnCallback(command) + MacroEditBox:GetScript("OnEvent")(MacroEditBox, "EXECUTE_CHAT_LINE", command) +end + +function E:DelayScriptCall(msg) + local secs, command = match(msg, "^([^%s]+)%s+(.*)$") + secs = tonumber(secs) + if (not secs) or (getn(command) == 0) then + self:Print("usage: /in ") + self:Print("example: /in 1.5 /say hi") + else + E:ScheduleTimer(OnCallback, secs, command) + end +end + +function E:LoadCommands() + self:RegisterChatCommand("in", "DelayScriptCall") + self:RegisterChatCommand("ec", "ToggleConfig") + self:RegisterChatCommand("elvui", "ToggleConfig") + self:RegisterChatCommand("bgstats", "BGStats") + self:RegisterChatCommand("luaerror", "LuaError") + self:RegisterChatCommand("egrid", "Grid") + self:RegisterChatCommand("moveui", "ToggleConfigMode") + self:RegisterChatCommand("resetui", "ResetUI") + self:RegisterChatCommand("enable", "EnableAddon") + self:RegisterChatCommand("disable", "DisableAddon") + self:RegisterChatCommand("farmmode", "FarmMode") + +-- if E:GetModule("ActionBars") and E.private.actionbar.enable then +-- self:RegisterChatCommand("kb", E:GetModule("ActionBars").ActivateBindMode) +-- end +end \ No newline at end of file diff --git a/2/3/4/5/6/7/ElvUI/Core/Load_Core.xml b/2/3/4/5/6/7/ElvUI/Core/Load_Core.xml index d4c82a0..799e0f9 100644 --- a/2/3/4/5/6/7/ElvUI/Core/Load_Core.xml +++ b/2/3/4/5/6/7/ElvUI/Core/Load_Core.xml @@ -5,7 +5,7 @@