diff --git a/ElvUI_SLE/modules/equipmanager.lua b/ElvUI_SLE/modules/equipmanager.lua new file mode 100644 index 0000000..c5419c8 --- /dev/null +++ b/ElvUI_SLE/modules/equipmanager.lua @@ -0,0 +1,83 @@ +--Raid mark bar. Similar to quickmark which just semms to be impossible to skin +local E, L, V, P, G, _ = unpack(ElvUI); --Inport: Engine, Locales, PrivateDB, ProfileDB, GlobalDB, Localize Underscore +-- local EM = E:NewModule('SLE_EquipManager', 'AceHook-3.0', 'AceEvent-3.0'); +local EM = E:GetModule('SLE_EquipManager') + +local GetEquipmentSetInfo = GetEquipmentSetInfo +local GetSpecialization = GetSpecialization +local IsInInstance = IsInInstance +local GetActiveSpecGroup = GetActiveSpecGroup +local UseEquipmentSet = UseEquipmentSet +local GetNumWorldPVPAreas = GetNumWorldPVPAreas +local GetWorldPVPAreaInfo = GetWorldPVPAreaInfo +local gsub, strfind = string.gsub, string.find, string.sub + +function EM:Equip(event) + local primary = GetSpecialization() + if primary ~= nil then + local inInstance, instanceType = IsInInstance() + if (event == "ACTIVE_TALENT_GROUP_CHANGED") then + if GetActiveSpecGroup() == 1 then + UseEquipmentSet(E.private.sle.equip.primary) + else + UseEquipmentSet(E.private.sle.equip.secondary) + end + end + if (instanceType == "party" or instanceType == "raid") then + UseEquipmentSet(E.private.sle.equip.instance) + end + if (instanceType == "pvp" or instanceType == "arena") then + UseEquipmentSet(E.private.sle.equip.pvp) + end + if E.private.sle.equip.pvp ~= "NONE" then + for i = 1, GetNumWorldPVPAreas() do + local _, localizedName, isActive = GetWorldPVPAreaInfo(i) + + if (GetRealZoneText() == localizedName and isActive) then + UseEquipmentSet(E.private.sle.equip.pvp) + end + end + end + end +end + +function EM:EquipSpamFilter(event, msg, ...) + if strfind(msg, string.gsub(ERR_LEARN_ABILITY_S:gsub('%.', '%.'), '%%s', '(.*)')) then + return true + elseif strfind(msg, string.gsub(ERR_LEARN_SPELL_S:gsub('%.', '%.'), '%%s', '(.*)')) then + return true + elseif strfind(msg, string.gsub(ERR_SPELL_UNLEARNED_S:gsub('%.', '%.'), '%%s', '(.*)')) then + return true + elseif strfind(msg, string.gsub(ERR_LEARN_PASSIVE_S:gsub('%.', '%.'), '%%s', '(.*)')) then + return true + end + + return false, msg, ... +end + +function EM:EnableSpamFilter() + ChatFrame_AddMessageEventFilter("CHAT_MSG_SYSTEM", EM.EquipSpamFilter) +end + +function EM:DisableSpamFilter() + ChatFrame_RemoveMessageEventFilter("CHAT_MSG_SYSTEM", EM.EquipSpamFilter) +end + +function EM:SpamThrottle() + if E.private.sle.equip.spam then + EM:EnableSpamFilter() + else + EM:DisableSpamFilter() + end +end + +function EM:Initialize() + EM:SpamThrottle() + if not E.private.sle.equip.enable then return end + self:RegisterEvent("PLAYER_ENTERING_WORLD", "Equip") + self:RegisterEvent("ACTIVE_TALENT_GROUP_CHANGED", "Equip") + self:RegisterEvent("PLAYER_TALENT_UPDATE", "Equip") + self:RegisterEvent("ZONE_CHANGED", "Equip") +end + +-- E:RegisterModule(EM:GetName()) \ No newline at end of file diff --git a/ElvUI_SLE/modules/exprepbar.lua b/ElvUI_SLE/modules/exprepbar.lua new file mode 100644 index 0000000..58c2d5e --- /dev/null +++ b/ElvUI_SLE/modules/exprepbar.lua @@ -0,0 +1,272 @@ +local E, L, V, P, G, _ = unpack(ElvUI); --Inport: Engine, Locales, PrivateDB, ProfileDB, GlobalDB, Localize Underscore +local M = E:GetModule('Misc'); + +local strMatchCombat = {} +local tinsert, gsub, format = tinsert, string.gsub, format +local GetXPExhaustion = GetXPExhaustion +local SetMinMaxValues = SetMinMaxValues +local GetFactionInfo = GetFactionInfo +local GetGuildInfo = GetGuildInfo + +tinsert(strMatchCombat, (gsub(FACTION_STANDING_INCREASED,"%%%d?%$?s", "(.+)"))) +tinsert(strMatchCombat, (gsub(FACTION_STANDING_INCREASED_GENERIC,"%%%d?%$?s", "(.+)"))) +tinsert(strMatchCombat, (gsub(FACTION_STANDING_INCREASED_BONUS,"%%%d?%$?s", "(.+)"))) +tinsert(strMatchCombat, (gsub(FACTION_STANDING_INCREASED_DOUBLE_BONUS,"%%%d?%$?s", "(.+)"))) +tinsert(strMatchCombat, (gsub(FACTION_STANDING_INCREASED_ACH_BONUS,"%%%d?%$?s", "(.+)"))) +local strChangeMatch = (gsub(FACTION_STANDING_CHANGED,"%%%d?%$?s", "(.+)")) +local strGuildChangeMatch = {} +tinsert(strGuildChangeMatch, (gsub(FACTION_STANDING_CHANGED_GUILD,"%%%d?%$?s", "(.+)"))) +tinsert(strGuildChangeMatch, (gsub(FACTION_STANDING_CHANGED_GUILDNAME,"%%%d?%$?s", "(.+)"))) + +local collapsed = {} +local guildName + +function M:UpdateExperience(event) + local bar = self.expBar + + if(UnitLevel('player') == MAX_PLAYER_LEVEL) or IsXPUserDisabled() then + bar:Hide() + else + bar:Show() + + local cur, max = self:GetXP('player') + bar.statusBar:SetMinMaxValues(0, max) + bar.statusBar:SetValue(cur - 1 >= 0 and cur - 1 or 0) + bar.statusBar:SetValue(cur) + + local rested = GetXPExhaustion() + local text = '' + local textFormat = E.db.general.experience.textFormat + + if rested and rested > 0 then + bar.rested:SetMinMaxValues(0, max) + bar.rested:SetValue(math.min(cur + rested, max)) + + if E.db.sle.exprep.explong then + if textFormat == 'PERCENT' then + text = format('%d%% '..L['Rested:']..' %d%%', cur / max * 100, rested / max * 100) + elseif textFormat == 'CURMAX' then + text = format('%s - %s '..L['Rested:']..' %s', cur, max, rested) + elseif textFormat == 'CURPERC' then + text = format('%s - %d%% '..L['Rested:']..' %s [%d%%]', cur, cur / max * 100, rested, rested / max * 100) + end + else + if textFormat == 'PERCENT' then + text = format('%d%% R:%d%%', cur / max * 100, rested / max * 100) + elseif textFormat == 'CURMAX' then + text = format('%s - %s R:%s', E:ShortValue(cur), E:ShortValue(max), E:ShortValue(rested)) + elseif textFormat == 'CURPERC' then + text = format('%s - %d%% R:%s [%d%%]', E:ShortValue(cur), cur / max * 100, E:ShortValue(rested), rested / max * 100) + end + end + else + bar.rested:SetMinMaxValues(0, 1) + bar.rested:SetValue(0) + + if E.db.sle.exprep.explong then + if textFormat == 'PERCENT' then + text = format('%d%%', cur / max * 100) + elseif textFormat == 'CURMAX' then + text = format('%s - %s', cur, max) + elseif textFormat == 'CURPERC' then + text = format('%s - %d%%', cur, cur / max * 100) + end + else + if textFormat == 'PERCENT' then + text = format('%d%%', cur / max * 100) + elseif textFormat == 'CURMAX' then + text = format('%s - %s', E:ShortValue(cur), E:ShortValue(max)) + elseif textFormat == 'CURPERC' then + text = format('%s - %d%%', E:ShortValue(cur), cur / max * 100) + end + end + end + + bar.text:SetText(text) + end + + self:UpdateExpRepAnchors() +end + +function M:UpdateReputation(event) + local bar = self.repBar + + local ID = 100 + local name, reaction, min, max, value = GetWatchedFactionInfo() + local numFactions = GetNumFactions(); + + if not name then + bar:Hide() + else + bar:Show() + + local text = '' + local textFormat = E.db.general.reputation.textFormat + local color = FACTION_BAR_COLORS[reaction] + bar.statusBar:SetStatusBarColor(color.r, color.g, color.b) + + bar.statusBar:SetMinMaxValues(0, max - min) + bar.statusBar:SetValue(value - min) + + for i=1, numFactions do + local factionName, _, standingID,_,_,_,_,_,_,_,_,_,_, factionID = GetFactionInfo(i); + local friendID, friendRep, friendMaxRep, _, _, _, friendTextLevel = GetFriendshipReputation(factionID); + if factionName == name then + if friendID ~= nil then + isFriend = true + friendText = friendTextLevel + else + ID = standingID + end + end + end + + + if E.db.sle.exprep.replong then + if textFormat == 'PERCENT' then + text = format('%d%% [%s]', ((value - min) / (max - min) * 100), isFriend and friendText or _G['FACTION_STANDING_LABEL'..ID]) + elseif textFormat == 'CURMAX' then + text = format('%s - %s [%s]', value - min, max - min, isFriend and friendText or _G['FACTION_STANDING_LABEL'..ID]) + elseif textFormat == 'CURPERC' then + text = format('%s - %d%% [%s]', value - min, ((value - min) / (max - min) * 100), isFriend and friendText or _G['FACTION_STANDING_LABEL'..ID]) + end + else + if textFormat == 'PERCENT' then + text = format('%s: %d%% [%s]', name, ((value - min) / (max - min) * 100), isFriend and friendText or _G['FACTION_STANDING_LABEL'..ID]) + elseif textFormat == 'CURMAX' then + text = format('%s: %s - %s [%s]', name, E:ShortValue(value - min), E:ShortValue(max - min), isFriend and friendText or _G['FACTION_STANDING_LABEL'..ID]) + elseif textFormat == 'CURPERC' then + text = format('%s: %s - %d%% [%s]', name, E:ShortValue(value - min), ((value - min) / (max - min) * 100), isFriend and friendText or _G['FACTION_STANDING_LABEL'..ID]) + end + end + + bar.text:SetText(text) + end + + self:UpdateExpRepAnchors() +end + +function M:ChatMsgCombat(event, ...) + if not E.private.sle.exprep.autotrack then return end + + local messg = ... + local found + for i, v in ipairs(strMatchCombat) do + found = (string.match(messg,strMatchCombat[i])) + if found then + if GUILD and guildName and (found == GUILD) then + found = guildName + end + break + end + end + if found then + M:setWatchedFaction(found) + end +end + +function M:CombatTextUpdate(event, ...) + if not E.private.sle.exprep.autotrack then return end + + local messagetype, faction, amount = ... + if messagetype ~= "FACTION" then return end + if (not amount) or (amount < 0) then return end + if GUILD and faction and guildName and (faction == GUILD) then + faction = guildName + end + if faction then + M:setWatchedFaction(faction) + end +end + +function M:ChatMsgSys(event, ...) + if not E.private.sle.exprep.autotrack then return end + + local messg = ... + local found + local newfaction = (string.match(messg,strChangeMatch)) and select(2,string.match(messg,strChangeMatch)) + if newfaction then + if guildName and (newfaction == GUILD) then + found = guildName + else + found = newfaction + end + else + local guildfaction + for i, v in ipairs(strGuildChangeMatch) do + guildfaction = (string.match(messg,strGuildChangeMatch[i])) + if guildfaction then + break + end + end + if guildfaction and guildName then + found = guildName + end + end + if found then + M:setWatchedFaction(found) + end +end + +function M:PlayerRepLogin() + if IsInGuild() then + guildName = (GetGuildInfo("player")) + if not guildName then + M:RegisterEvent("GUILD_ROSTER_UPDATE", 'PlayerGuildRosterUpdate') + end + end +end +function M:PlayerGuildRosterUpdate() + if IsInGuild() then + guildName = (GetGuildInfo("player")) + end + if guildName then + M:UnregisterEvent("GUILD_ROSTER_UPDATE") + end +end + +function M:PlayerGuildRepUdate() + if IsInGuild() then + guildName = (GetGuildInfo("player")) + if not guildName then + M:RegisterEvent("GUILD_ROSTER_UPDATE", 'PlayerGuildRosterUpdate') + end + else + guildName = nil + end +end + +function M:setWatchedFaction(faction) + wipe(collapsed) + local i,j = 1, GetNumFactions() + while i <= j do + local name,_,_,_,_,_,_,_,isHeader,isCollapsed,_,isWatched = GetFactionInfo(i) + if name == faction then + if not (isWatched or IsFactionInactive(i)) then + SetWatchedFactionIndex(i) + end + break + end + if isHeader and isCollapsed then + ExpandFactionHeader(i) + collapsed[i] = true + j = GetNumFactions() + end + i = i+1 + end + if next(collapsed) then + for k=i,1,-1 do + if collapsed[k] then + CollapseFactionHeader(k) + end + end + end +end + +hooksecurefunc(M, "Initialize", function(self,...) + M:RegisterEvent("CHAT_MSG_COMBAT_FACTION_CHANGE", 'ChatMsgCombat') + M:RegisterEvent("COMBAT_TEXT_UPDATE", 'CombatTextUpdate') + M:RegisterEvent("CHAT_MSG_SYSTEM", 'ChatMsgSys') + M:RegisterEvent("PLAYER_LOGIN", 'PlayerRepLogin') + M:RegisterEvent("PLAYER_GUILD_UPDATE", 'PlayerGuildRepUdate') +end) \ No newline at end of file diff --git a/ElvUI_SLE/modules/farm.lua b/ElvUI_SLE/modules/farm.lua new file mode 100644 index 0000000..f69b379 --- /dev/null +++ b/ElvUI_SLE/modules/farm.lua @@ -0,0 +1,607 @@ +local E, L, V, P, G, _ = unpack(ElvUI); --Inport: Engine, Locales, PrivateDB, ProfileDB, GlobalDB +local B = LibStub("LibBabble-SubZone-3.0") +local BL = B:GetLookupTable() +-- local F = E:NewModule('SLE_Farm', 'AceHook-3.0', 'AceEvent-3.0'); +local F = E:GetModule('SLE_Farm') +local SLE = E:GetModule('SLE'); + +local SeedAnchor, ToolAnchor, PortalAnchor +local tsort, format = table.sort, format +local farmzones = { BL["Sunsong Ranch"], BL["The Halfhill Market"] } +local size +local Zcheck = false +local GetSubZoneText = GetSubZoneText +local InCombatLockdown = InCombatLockdown +local GetItemCount = GetItemCount +local Point = Point +local GetItemInfo = GetItemInfo + + +FseedButtons = {} +FtoolButtons = {} +FportalButtons = {} + +local seeds = { + --Seeds general + [79102] = { 1 }, -- Green Cabbage + [89328] = { 1 }, -- Jade Squash + [80590] = { 1 }, -- Juicycrunch Carrot + [80592] = { 1 }, -- Mogu Pumpkin + [80594] = { 1 }, -- Pink Turnip + [80593] = { 1 }, -- Red Blossom Leek + [80591] = { 1 }, -- Scallion + [89329] = { 1 }, -- Striped Melon + [80595] = { 1 }, -- White Turnip + [89326] = { 1 }, -- Witchberry + --Bags general + [80809] = { 2 }, -- Green Cabbage + [89848] = { 2 }, -- Jade Squash + [84782] = { 2 }, -- Juicycrunch Carrot + [85153] = { 2 }, -- Mogu Pumpkin + [85162] = { 2 }, -- Pink Turnip + [85158] = { 2 }, -- Red Blossom Leek + [84783] = { 2 }, -- Scallion + [89849] = { 2 }, -- Striped Melon + [85163] = { 2 }, -- White Turnip + [89847] = { 2 }, -- Witchberry + --Seeds special + [85216] = { 3 }, -- Enigma + [85217] = { 3 }, -- Magebulb + [85219] = { 3 }, -- Ominous + [89202] = { 3 }, -- Raptorleaf + [85215] = { 3 }, -- Snakeroot + [89233] = { 3 }, -- Songbell + [91806] = { 3 }, -- Unstable Portal + [89197] = { 3 }, -- Windshear Cactus + --Bags special + [95449] = { 4 }, -- Enigma + [95451] = { 4 }, -- Magebulb + [95457] = { 4 }, -- Raptorleaf + [95447] = { 4 }, -- Snakeroot + [95445] = { 4 }, -- Songbell + [95454] = { 4 }, -- Windshear Cactus + --Trees lol + [85267] = { 5 }, -- Autumn Blossom Sapling + [85268] = { 5 }, -- Spring Blossom Sapling + [85269] = { 5 }, -- Winter Blossom Sapling +} + +local addseeds = { + [95434] = { 80809 }, -- Green Cabbage + [95437] = { 89848 }, -- Jade Squash + [95436] = { 84782 }, -- Juicycrunch Carrot + [95438] = { 85153 }, -- Mogu Pumpkin + [95439] = { 85162 }, -- Pink Turnip + [95440] = { 85158 }, -- Red Blossom Leek + [95441] = { 84783 }, -- Scallion + [95442] = { 89849 }, -- Striped Melon + [95443] = { 85163 }, -- White Turnip + [95444] = { 89847 }, -- Witchberry + + [95450] = { 95449 }, -- Enigma + [95452] = { 95451 }, -- Magebulb + [95458] = { 95457 }, -- Raptorleaf + [95448] = { 95447 }, -- Snakeroot + [95446] = { 95445 }, -- Songbell + [95456] = { 95454 }, -- Windshear Cactus +} + +local tools = { + [79104] = { 1 }, -- Rusy Watering Can + [80513] = { 1 }, -- Vintage Bug Sprayer + [89880] = { 1 }, -- Dented Shovel + [89815] = { 1 }, -- Master Plow +} + +local portals = { + [91850] = { "Horde" }, -- Orgrimmar Portal Shard + [91861] = { "Horde" }, -- Thunder Bluff Portal Shard + [91862] = { "Horde" }, -- Undercity Portal Shard + [91863] = { "Horde" }, -- Silvermoon Portal Shard + + [91860] = { "Alliance" }, -- Stormwind Portal Shard + [91864] = { "Alliance" }, -- Ironforge Portal Shard + [91865] = { "Alliance" }, -- Darnassus Portal Shard + [91866] = { "Alliance" }, -- Exodar Portal Shard +} + +local quests = { +--Tillers counsil + [31945] = {80591, 84783}, -- Gina, Scallion + [31946] = {80590, 84782}, -- Mung-Mung, Juicycrunch Carrot + [31947] = {79102, 80809}, -- Farmer Fung, Green Cabbage + [31949] = {89326, 89847}, -- Nana, Witchberry + [30527] = {89329, 89849}, -- Haohan, Striped Melon + --Farmer Yoon + [31943] = {89326, 89847}, -- Witchberry + [31942] = {89329, 89849}, -- Striped Melon + [31941] = {89328, 89848}, -- Jade Squash + [31669] = {79102, 80809}, -- Green Cabbage + [31670] = {80590, 84782}, -- Juicycrunch Carrot + [31672] = {80592, 85153}, -- Mogu Pumpkin + [31673] = {80593, 85158}, -- Red Blossom Leek + [31674] = {80594, 85162}, -- Pink Turnip + [31675] = {80595, 85163}, -- White Turnip + [31671] = {80591, 84783}, -- Scallion + --Work Orders + [32645] = {89326, 89847}, -- Witchberry (Alliance Only) + [32653] = {89329, 89849}, -- Striped Melon + --[31941] = {89328, 89848}, -- Jade Squash + [32649] = {79102, 80809}, -- Green Cabbage + --[31670] = {80590, 84782}, -- Juicycrunch Carrot + [32658] = {80592, 85153}, -- Mogu Pumpkin + [32642] = {80593, 85158}, -- Red Blossom Leek (Horde Only) + --[31674] = {80594, 85162}, -- Pink Turnip + [32647] = {80595, 85163}, -- White Turnip + --[31671] = {80591, 84783}, -- Scallion +} + +local buttoncounts = {} + +function F:CanSeed() + local subzone = GetSubZoneText() + for _, zone in ipairs(farmzones) do + if (zone == subzone) then + return true + end + end + return false +end + +function F:OnFarm() + return GetSubZoneText() == farmzones[1] +end + +function F:InventoryUpdate(event) + if InCombatLockdown() then + F:RegisterEvent("PLAYER_REGEN_ENABLED", "InventoryUpdate") + return + else + F:UnregisterEvent("PLAYER_REGEN_ENABLED") + end + + local SeedChange = false + for i = 1, 5 do + for _, button in ipairs(FseedButtons[i]) do + button.items = GetItemCount(button.itemId, nil, true) + if i == 2 or i == 4 then + for id, v in pairs(addseeds) do + if button.itemId == addseeds[id][1] then + local nCount = GetItemCount(id, nil, true) + button.items = button.items + nCount + end + end + end + if not buttoncounts[button.itemId] then + buttoncounts[button.itemId] = button.items + end + if button.items ~= buttoncounts[button.itemId] then + SeedChange = true + buttoncounts[button.itemId] = button.items + end + button.text:SetText(button.items) + button.icon:SetDesaturated(button.items == 0) + button.icon:SetAlpha(button.items == 0 and .25 or 1) + end + end + + for _, button in ipairs(FtoolButtons) do + button.items = GetItemCount(button.itemId) + if not buttoncounts[button.itemId] then + buttoncounts[button.itemId] = button.items + end + if button.items ~= buttoncounts[button.itemId] then + SeedChange = true + buttoncounts[button.itemId] = button.items + end + button.icon:SetDesaturated(button.items == 0) + button.icon:SetAlpha(button.items == 0 and .25 or 1) + end + + for _, button in ipairs(FportalButtons) do + button.items = GetItemCount(button.itemId) + if not buttoncounts[button.itemId] then + buttoncounts[button.itemId] = button.items + end + if button.items ~= buttoncounts[button.itemId] then + SeedChange = true + buttoncounts[button.itemId] = button.items + end + button.text:SetText(button.items) + button.icon:SetDesaturated(button.items == 0) + button.icon:SetAlpha(button.items == 0 and .25 or 1) + end + + if event and event ~= "BAG_UPDATE_COOLDOWN" and SeedChange == true then + F:UpdateLayout() + end +end + +function F:UpdateBarLayout(bar, anchor, buttons) + local count = 0 + size = E.db.sle.farm.size + bar:ClearAllPoints() + bar:Point("LEFT", anchor, "LEFT", 0, 0) + + for i, button in ipairs(buttons) do + button:ClearAllPoints() + if not button.items then F:InventoryUpdate() end + if not E.db.sle.farm.active or button.items > 0 then + button:Point("TOPLEFT", bar, "TOPLEFT", (count * (size+(E.PixelMode and 2 or 1)))+(E.PixelMode and 1 or 0), -1) + button:Show() + button:Size(size, size) + count = count + 1 + else + button:Hide() + end + end + + bar:Width(1) + bar:Height(size+2) + + return count +end + +function F:QuestItems(itemID) + for i = 1, GetNumQuestLogEntries() do + for qid, sid in pairs(quests) do + if qid == select(9,GetQuestLogTitle(i)) then + if itemID == sid[1] or itemID == sid[2] then + return true + end + end + end + end + + return false +end + +function F:UpdateButtonCooldown(button) + if button.cooldown then + button.cooldown:SetCooldown(GetItemCooldown(button.itemId)) + end +end + +function F:UpdateCooldown() + if not F:CanSeed() then return end + + for i = 1, 5 do + for _, button in ipairs(FseedButtons[i]) do + F:UpdateButtonCooldown(button) + end + end + for _, button in ipairs(FtoolButtons) do + F:UpdateButtonCooldown(button) + end + for _, button in ipairs(FportalButtons) do + F:UpdateButtonCooldown(button) + end +end + +function F:UpdateSeedBarLayout(seedBar, anchor, buttons, category) + local count = 0 + local db = E.db.sle.farm + size = db.size + local seedor = db.seedor + local id + seedBar:ClearAllPoints() + if category == 1 then + if seedor == "TOP" or seedor == "BOTTOM" then + seedBar:Point(seedor.."LEFT", anchor, (E.PixelMode and 0 or -2), seedor == "TOP" and 0 or (E.PixelMode and 2 or 0)) + elseif seedor == "LEFT" or seedor == "RIGHT" then + seedBar:Point("TOP"..seedor, anchor, E.PixelMode and 2 or (seedor == "LEFT" and 0 or 2), (E.PixelMode and -2 or -2)) + end + + else + if _G[("FarmSeedBar%d"):format(category-1)]:IsShown() then + if seedor == "TOP" or seedor == "BOTTOM" then + seedBar:Point("TOPLEFT", _G[("FarmSeedBar%d"):format(category-1)], "TOPRIGHT", (E.PixelMode and 0 or -1), 0) + elseif seedor == "LEFT" or seedor == "RIGHT" then + seedBar:Point("TOPLEFT", _G[("FarmSeedBar%d"):format(category-1)], "BOTTOMLEFT", 0, (E.PixelMode and 0 or 1)) + end + else + F:UpdateSeedBarLayout(seedBar, anchor, buttons, category-1) + end + end + + + for i, button in ipairs(buttons) do + id = button:GetName():gsub("FarmButton", "") + id = tonumber(id) + button:ClearAllPoints() + if not E.db.sle.farm.active or button.items > 0 then + if seedor == "TOP" or seedor == "BOTTOM" then + local mult = seedor == "TOP" and -1 or 1 + button:Point(seedor.."LEFT", seedBar, E.PixelMode and 1 or 2, mult*(count * (size+(E.PixelMode and 2 or 1)))-(E.PixelMode and 1 or 0)) + elseif seedor == "LEFT" or seedor == "RIGHT" then + local mult = seedor == "RIGHT" and -1 or 1 + button:Point("TOPLEFT", seedBar, "TOPLEFT", mult*(count * (size+(E.PixelMode and 2 or 1)))-(E.PixelMode and 1 or 0), E.PixelMode and 1 or 2) + end + button:Show() + button:Size(size, size) + count = count + 1 + else + button:Hide() + end + if E.db.sle.farm.quest then + if not F:CanSeed() then + seedBar:Width(size+2) + seedBar:Height(size+2) + return count + end + if F:QuestItems(id) then + ActionButton_ShowOverlayGlow(button) + else + ActionButton_HideOverlayGlow(button) + end + else + ActionButton_HideOverlayGlow(button) + end + end + + seedBar:Width(size+2) + seedBar:Height(size+2) + + return count +end + +function F:UpdateBar(bar, layoutfunc, zonecheck, anchor, buttons, category) + bar:Show() + + local count = layoutfunc(self, bar, anchor, buttons, category) + if (E.private.sle.farm.enable and count > 0 and zonecheck(self) and not InCombatLockdown()) then + bar:Show() + else + bar:Hide() + end +end + +function F:BAG_UPDATE_COOLDOWN() + F:InventoryUpdate() + F:UpdateCooldown() +end + +function F:Zone(event) + if F:CanSeed() then + F:RegisterEvent("BAG_UPDATE", "InventoryUpdate") + F:RegisterEvent("BAG_UPDATE_COOLDOWN") + F:RegisterEvent("UNIT_QUEST_LOG_CHANGED", "UpdateLayout") + F:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED", "InventoryUpdate") + + F:InventoryUpdate(event) + F:UpdateLayout() + Zcheck = true + else + F:UnregisterEvent("BAG_UPDATE") + F:UnregisterEvent("BAG_UPDATE_COOLDOWN") + F:UnregisterEvent("UNIT_QUEST_LOG_CHANGED") + F:UnregisterEvent("UNIT_SPELLCAST_SUCCEEDED") + if Zcheck then + F:UpdateLayout() + Zcheck = false + end + end +end + +function F:UpdateLayout(event, unit) + if not SeedAnchor then return end + --For updating borders after quest was complited. for some reason events fires before quest disappeares from log + if event == "UNIT_QUEST_LOG_CHANGED" then + if unit == "player" then + E:Delay(1, F.UpdateLayout) + else + return + end + end + if InCombatLockdown() then + F:RegisterEvent("PLAYER_REGEN_ENABLED", "UpdateLayout") + return + else + F:UnregisterEvent("PLAYER_REGEN_ENABLED") + end + F:UpdateBar(_G["FarmToolBar"], F.UpdateBarLayout, F.OnFarm, ToolAnchor, FtoolButtons) + F:UpdateBar(_G["FarmPortalBar"], F.UpdateBarLayout, F.OnFarm, PortalAnchor, FportalButtons) + for i=1, 5 do + F:UpdateBar(_G[("FarmSeedBar%d"):format(i)], F.UpdateSeedBarLayout, F.CanSeed, SeedAnchor, FseedButtons[i], i) + end + F:ResizeFrames() +end + +local function onClick(self, mousebutton) + if mousebutton == "LeftButton" then + if InCombatLockdown() and not self.macro then + SLE:Print(L["We are sorry, but you can't do this now. Try again after the end of this combat."]) + return + end + self:SetAttribute("type", self.buttonType) + self:SetAttribute(self.buttonType, self.sortname) + if self.id and self.id ~= 2 and self.id ~= 4 and E.db.sle.farm.autotarget and UnitName("target") ~= L["Tilled Soil"] then + F:AutoTarget(self) + end + if self.cooldown then + self.cooldown:SetCooldown(GetItemCooldown(self.itemId)) + end + if not self.macro then self.macro = true end + elseif mousebutton == "RightButton" and self.allowDrop then + self:SetAttribute("type", "click") + local container, slot = SLE:BagSearch(self.itemId) + if container and slot then + PickupContainerItem(container, slot) + DeleteCursorItem() + end + end + F:InventoryUpdate() +end + +local function onEnter(self) + GameTooltip:SetOwner(self, 'ANCHOR_TOPLEFT', 2, 4) + GameTooltip:ClearLines() + GameTooltip:AddDoubleLine(self.sortname) + if self.allowDrop then + GameTooltip:AddLine(L['Right-click to drop the item.']) + end + GameTooltip:Show() +end + +local function onLeave() + GameTooltip:Hide() +end + +function F:AutoTarget(button) + local container, slot = SLE:BagSearch(button.itemId) + if container and slot then + button:SetAttribute("type", "macro") + button:SetAttribute("macrotext", format("/targetexact %s \n/use %s %s", L["Tilled Soil"], container, slot)) + end +end + +function F:CreateFarmButton(index, owner, buttonType, name, texture, allowDrop, id) + size = E.db.sle.farm.size + local button = CreateFrame("Button", ("FarmButton%d"):format(index), owner, "SecureActionButtonTemplate") + button:Size(size, size) + button:SetTemplate('Default', true) + + button.sortname = name + button.itemId = index + button.allowDrop = allowDrop + button.buttonType = buttonType + button.id = id + button.macro = false + + button.icon = button:CreateTexture(nil, "OVERLAY") + button.icon:SetTexture(texture) + button.icon:SetTexCoord(0.1, 0.9, 0.1, 0.9) + button.icon:SetInside() + + button.text = button:CreateFontString(nil, "OVERLAY") + button.text:SetFont(E.media.normFont, 12, "OUTLINE") + button.text:SetPoint("BOTTOMRIGHT", button, 1, 2) + + if select(3, GetItemCooldown(button.itemId)) == 1 then + button.cooldown = CreateFrame("Cooldown", ("FarmButton%dCooldown"):format(index), button) + button.cooldown:SetAllPoints(button) + end + + button:SetScript("OnEnter", onEnter) + button:SetScript("OnLeave", onLeave) + button:SetScript("OnMouseDown", onClick) + + return button +end + +function F:ResizeFrames() + local seedor = E.db.sle.farm.seedor + if seedor == "TOP" or seedor == "BOTTOM" then + SeedAnchor:Size((size+(E.PixelMode and 2 or 1))*5-(E.PixelMode and 0 or 1), (size+(E.PixelMode and 2 or 1))*10-(E.PixelMode and 0 or 1)) + elseif seedor == "LEFT" or seedor == "RIGHT" then + SeedAnchor:Size((size+(E.PixelMode and 2 or 1))*10-(E.PixelMode and 0 or 1), (size+(E.PixelMode and 2 or 1))*5-(E.PixelMode and 0 or 1)) + end + ToolAnchor:Size((size+(E.PixelMode and 2 or 1))*5-(E.PixelMode and 0 or 1), size+(E.PixelMode and 2 or 1)-(E.PixelMode and 0 or 1)) + PortalAnchor:Size((size+(E.PixelMode and 2 or 1))*5-(E.PixelMode and 0 or 1), size+(E.PixelMode and 2 or 1)-(E.PixelMode and 0 or 1)) +end + +function F:FramesPosition() + SeedAnchor:Point("LEFT", E.UIParent, "LEFT", 24, -160) + ToolAnchor:Point("BOTTOMLEFT", SeedAnchor, "TOPLEFT", 0, E.PixelMode and 1 or 5) + PortalAnchor:Point("BOTTOMLEFT", ToolAnchor, "TOPLEFT", 0, E.PixelMode and 1 or 5) +end + +function F:CreateFrames() + size = E.db.sle.farm.size + SeedAnchor = CreateFrame("Frame", "SeedAnchor", E.UIParent) + SeedAnchor:SetFrameStrata("BACKGROUND") + + ToolAnchor = CreateFrame("Frame", "ToolAnchor", E.UIParent) + ToolAnchor:SetFrameStrata("BACKGROUND") + + PortalAnchor = CreateFrame("Frame", "PortalAnchor", E.UIParent) + PortalAnchor:SetFrameStrata("BACKGROUND") + + F:ResizeFrames() + F:FramesPosition() + + E:CreateMover(SeedAnchor, "FarmSeedMover", L["Farm Seed Bars"], nil, nil, nil, "ALL,S&L,S&L MISC") + E:CreateMover(ToolAnchor, "FarmToolMover", L["Farm Tool Bar"], nil, nil, nil, "ALL,S&L,S&L MISC") + E:CreateMover(PortalAnchor, "FarmPortalMover", L["Farm Portal Bar"], nil, nil, nil, "ALL,S&L,S&L MISC") + + for id, v in pairs(seeds) do + seeds[id] = { v[1], GetItemInfo(id) } + end + + for id, v in pairs(tools) do + tools[id] = { GetItemInfo(id) } + end + + for id, v in pairs(portals) do + portals[id] = { v[1], GetItemInfo(id) } + end + + for i = 1, 5 do + local seedBar = CreateFrame("Frame", ("FarmSeedBar%d"):format(i), UIParent) + seedBar:SetFrameStrata("BACKGROUND") + + seedBar:SetPoint("CENTER", SeedAnchor, "CENTER", 0, 0) + + FseedButtons[i] = FseedButtons[i] or {} + + for id, v in pairs(seeds) do + if v[1] == i then + tinsert(FseedButtons[i], F:CreateFarmButton(id, seedBar, "item", v[2], v[11], E.private.sle.farm.seedtrash, i)) + end + tsort(FseedButtons[i], function(a, b) return a.sortname < b.sortname end) + end + end + + local toolBar = CreateFrame("Frame", "FarmToolBar", UIParent) + toolBar:SetFrameStrata("BACKGROUND") + toolBar:SetPoint("CENTER", ToolAnchor, "CENTER", 0, 0) + for id, v in pairs(tools) do + tinsert(FtoolButtons, F:CreateFarmButton(id, toolBar, "item", v[1], v[10], true, nil)) + end + + local portalBar = CreateFrame("Frame", "FarmPortalBar", UIParent) + portalBar:SetFrameStrata("BACKGROUND") + portalBar:SetPoint("CENTER", PortalAnchor, "CENTER", 0, 0) + local playerFaction = UnitFactionGroup('player') + for id, v in pairs(portals) do + if v[1] == playerFaction then + tinsert(FportalButtons, F:CreateFarmButton(id, portalBar, "item", v[2], v[11], false, nil)) + end + end + + F:RegisterEvent("ZONE_CHANGED", "Zone") + F:RegisterEvent("ZONE_CHANGED_NEW_AREA", "Zone") + F:RegisterEvent("ZONE_CHANGED_INDOORS", "Zone") + F:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED", "InventoryUpdate") + + E:Delay(10, F.Zone) +end + +function F:StartFarmBarLoader() + F:UnregisterEvent("PLAYER_ENTERING_WORLD") + + local noItem = false + -- preload item links to prevent errors + for id, _ in pairs(seeds) do + if select(2, GetItemInfo(id)) == nil then noItem = true end + end + for id, _ in pairs(tools) do + if select(2, GetItemInfo(id)) == nil then noItem = true end + end + for id, _ in pairs(portals) do + if select(2, GetItemInfo(id)) == nil then noItem = true end + end + if noItem then + E:Delay(5, F.StartFarmBarLoader) + else + F.CreateFrames() + end +end + +function F:Initialize() + if not E.private.sle.farm.enable then return end + + self:RegisterEvent("PLAYER_ENTERING_WORLD", "StartFarmBarLoader") +end + +-- E:RegisterModule(F:GetName()) \ No newline at end of file diff --git a/ElvUI_SLE/modules/loot.lua b/ElvUI_SLE/modules/loot.lua new file mode 100644 index 0000000..a22c4b5 --- /dev/null +++ b/ElvUI_SLE/modules/loot.lua @@ -0,0 +1,141 @@ +local E, L, V, P, G, _ = unpack(ElvUI); --Inport: Engine, Locales, PrivateDB, ProfileDB, GlobalDB, Localize Underscore +-- local LT = E:NewModule('SLE_Loot', 'AceHook-3.0', 'AceEvent-3.0') +local LT = E:GetModule('SLE_Loot') +local check = false +local t = 0 +local loottemp = {} +local MyName = E.myname +local IsInGroup, IsInRaid, IsPartyLFG = IsInGroup, IsInRaid, IsPartyLFG +local GetNumGroupMembers, GetRaidRosterInfo = GetNumGroupMembers, GetRaidRosterInfo +local GetLootSlotType, GetLootSlotLink, GetLootSlotInfo = GetLootSlotType, GetLootSlotLink, GetLootSlotInfo +local GetNumLootItems, GetItemInfo = GetNumLootItems, GetItemInfo +local IsLeftControlKeyDown = IsLeftControlKeyDown +local loot = {} +local numbers = {} +local n = 0 +local Tremove = table.remove + +local function Check() + local name, rank, isML + for x = 1, GetNumGroupMembers() do + name, rank, _, _, _, _, _, _, _, _, isML = GetRaidRosterInfo(x) + if name == MyName and isML then + return true + elseif name == MyName and rank == 1 then + return true + elseif name == MyName and rank == 2 then + return true + end + end + return false +end + +local function Merge() + local p, k + for i = 1, #loot do + k = 1 + while loot[i] ~= loot[k] do k = k + 1 end + if i ~= k then + numbers[i] = numbers[i] + numbers[k] + Tremove(numbers, k) + Tremove(loot, k) + n = n - 1 + end + end +end + +local function PopulateTable(q) + local p, k + for i = 1, GetNumLootItems() do + if GetLootSlotType(i) == 1 then + local _, item, quantity, quality = GetLootSlotInfo(i) + local link, ilvl + + if quality >= q then + link = GetLootSlotLink(i) + ilvl = select(4, GetItemInfo(link)) + + n = n + 1 + loot[n] = link + loot[n] = loot[n].." (ilvl: "..ilvl..")" + numbers[n] = quantity + end + end + end + Merge() +end + +local function Channel() + local channel + if E.db.sle.loot.chat ~= "SAY" and IsPartyLFG() then + return "INSTANCE_CHAT" + end + if E.db.sle.loot.chat == "RAID" and not IsInRaid() then + return "PARTY" + end + return E.db.sle.loot.chat +end + +local function List() + for i = 1, n do + if numbers[i] == 1 then + SendChatMessage(i..". "..loot[i], Channel()) + elseif numbers[i] > 1 then + SendChatMessage(i..". "..numbers[i].."x"..loot[i], Channel()) + end + if i == n then + loot = {} + numbers = {} + n = 0 + end + end +end + +function LT:Announce() + if not IsInGroup() then return end -- not in group, exit. + local m = 0 + local q = E.db.sle.loot.quality == "EPIC" and 4 or E.db.sle.loot.quality == "RARE" and 3 or E.db.sle.loot.quality == "UNCOMMON" and 2 + + if (Check() and E.db.sle.loot.auto) or (IsLeftControlKeyDown() and (IsInGroup() or IsInRaid())) then + for i = 1, GetNumLootItems() do + if GetLootSlotType(i) == 1 then + for j = 1, t do + if GetLootSlotLink(i) == loottemp[j] then + check = true + end + end + end + end + if check == false or IsLeftControlKeyDown() then + PopulateTable(q) + if n ~= 0 then + SendChatMessage(L["Loot Dropped:"], Channel()) + List() + end + end + for i = 1, GetNumLootItems() do + if GetLootSlotType(i) == 1 then + loottemp[i] = GetLootSlotLink(i) + end + end + t = GetNumLootItems() + check = false + end +end + +function LT:LootShow() + local instance = IsInInstance() + LootHistoryFrame:SetAlpha(E.db.sle.lootalpha or 1) + + if (not instance and E.db.sle.lootwin) then + LootHistoryFrame:Hide() + end +end + +function LT:Initialize() + self:RegisterEvent('PLAYER_ENTERING_WORLD', 'LootShow'); + if not E.private.sle.loot.enable then return end + self:RegisterEvent("LOOT_OPENED", "Announce") +end + +-- E:RegisterModule(LT:GetName()) \ No newline at end of file diff --git a/ElvUI_SLE/modules/nameplates.lua b/ElvUI_SLE/modules/nameplates.lua new file mode 100644 index 0000000..3900a7c --- /dev/null +++ b/ElvUI_SLE/modules/nameplates.lua @@ -0,0 +1,110 @@ +local E, L, V, P, G = unpack(ElvUI); +local NP = E:GetModule('NamePlates') +local LSM = LibStub("LibSharedMedia-3.0") + +local UnitCanAttack, UnitDetailedThreatSituation, GetThreatStatusColor = UnitCanAttack, UnitDetailedThreatSituation, GetThreatStatusColor +local GetNumGroupMembers, GetNumSubgroupMembers = GetNumGroupMembers, GetNumSubgroupMembers +local IsInRaid, IsInGroup, UnitGUID, UnitName = IsInRaid, IsInGroup, UnitGUID, UnitName +local format, twipe = string.format, table.wipe +local rosterTimer + +function Hex(r, g, b) + return format('|cFF%02x%02x%02x', r * 255, g * 255, b * 255) +end + +NP.GroupMembers = {} + +hooksecurefunc(NP, 'CreatePlate', function(self, frame) + local myPlate = self.CreatedPlates[frame] + if not myPlate then return end + + if not myPlate.threatInfo then + myPlate.threatInfo = myPlate:CreateFontString(nil, "OVERLAY") + myPlate.threatInfo:SetPoint("BOTTOMLEFT", myPlate.healthBar, "BOTTOMLEFT", 1, 2) + myPlate.threatInfo:SetJustifyH("LEFT") + end + if not frame.targetcount then + myPlate.targetcount = myPlate:CreateFontString(nil, "OVERLAY") + myPlate.targetcount:SetPoint('BOTTOMRIGHT', myPlate.healthBar, 'BOTTOMRIGHT', 1, 2) + myPlate.targetcount:SetJustifyH("RIGHT") + end + myPlate.threatInfo:FontTemplate(LSM:Fetch("font", NP.db.font), NP.db.fontSize, NP.db.fontOutline) + myPlate.targetcount:FontTemplate(LSM:Fetch("font", NP.db.font), NP.db.fontSize, NP.db.fontOutline) +end) + +hooksecurefunc(NP, 'GetThreatReaction', function(self, frame) + local myPlate = self.CreatedPlates[frame] + if not myPlate then return end + + if myPlate.threatInfo then + myPlate.threatInfo:SetText() + + if E.db.sle.nameplate.showthreat then + local unit = frame.unit + if not unit then + for i=1, 4 do + if frame.guid == UnitGUID(('boss%d'):format(i)) then + unit = ('boss%d'):format(i) + break + end + end + end + + if unit and not UnitIsPlayer(unit) and UnitCanAttack('player', unit) then + local status, percent = select(2, UnitDetailedThreatSituation('player', unit)) + if (status) then + myPlate.threatInfo:SetFormattedText('%s%.0f%%|r', Hex(GetThreatStatusColor(status)), percent) + else + myPlate.threatInfo:SetFormattedText('|cFF808080%s|r', L["None"]) + end + end + end + end + if E.db.sle.nameplate.targetcount and myPlate.targetcount then + myPlate.targetcount:SetText() + if frame.guid then + local targetCount = 0 + local target + for name, unitid in pairs(NP.GroupMembers) do + target = ("%starget"):format(unitid) + if UnitExists(target) and UnitGUID(target) == frame.guid then + targetCount = targetCount + 1 + end + end + --Set the target count text + if not (targetCount == 0) then + myPlate.targetcount:SetText(('[%d]'):format(targetCount)) + end + end + end +end) + +function NP:AddToRoster(unitId) + local unitName = UnitName(unitId) + if unitName then + self.GroupMembers[unitName] = unitId + end +end + +function NP:UpdateRoster() + twipe(self.GroupMembers) + + local groupSize = IsInRaid() and GetNumGroupMembers() or IsInGroup() and GetNumSubgroupMembers() or 0 + local groupType = IsInRaid() and "raid" or IsInGroup() and "party" or "solo" + + for index = 1, groupSize do + self:AddToRoster(groupType..index) + end + + if groupType == 'party' then + self:AddToRoster('player') + end +end + +function NP:StartRosterUpdate() + if not rosterTimer or NP:TimeLeft(rosterTimer) == 0 then + rosterTimer = NP:ScheduleTimer('UpdateRoster', 1) + end +end + +NP:RegisterEvent("GROUP_ROSTER_UPDATE", "StartRosterUpdate") \ No newline at end of file diff --git a/ElvUI_SLE/modules/pvpmover.lua b/ElvUI_SLE/modules/pvpmover.lua new file mode 100644 index 0000000..fa680a1 --- /dev/null +++ b/ElvUI_SLE/modules/pvpmover.lua @@ -0,0 +1,26 @@ +local E, L, V, P, G, _ = unpack(ElvUI); --Inport: Engine, Locales, PrivateDB, ProfileDB, GlobalDB +-- local P = E:NewModule('SLE_PvPMover', 'AceHook-3.0', 'AceEvent-3.0'); +local P = E:GetModule('SLE_PvPMover'); +local holder = CreateFrame("Frame", "SLE_PvP", E.UIParent) + + +local function update() + if WorldStateCaptureBar1 then + local bar = WorldStateCaptureBar1 + bar:HookScript("OnShow", function(self) self:SetPoint("TOP", WorldStateAlwaysUpFrame, "BOTTOM", 0, -10) end) + bar:Hide() + bar:Show() + P:UnregisterEvent("UPDATE_WORLD_STATES") + end +end + +function P:Initialize() + holder:SetSize(10, 58) + holder:SetPoint("TOP", E.UIParent, "TOP", -5, -15) + WorldStateAlwaysUpFrame:ClearAllPoints() + WorldStateAlwaysUpFrame:SetPoint("CENTER", holder) + self:RegisterEvent("UPDATE_WORLD_STATES", update) + E:CreateMover(holder, "PvPMover", "PvP", nil, nil, nil, "ALL,S&L,S&L MISC") +end + +-- E:RegisterModule(P:GetName()) \ No newline at end of file diff --git a/ElvUI_SLE/modules/raidutility.lua b/ElvUI_SLE/modules/raidutility.lua new file mode 100644 index 0000000..60cd544 --- /dev/null +++ b/ElvUI_SLE/modules/raidutility.lua @@ -0,0 +1,41 @@ +local E, L, V, P, G, _ = unpack(ElvUI); --Inport: Engine, Locales, PrivateDB, ProfileDB, GlobalDB, Localize Underscore +--local RU = E:GetModule('RaidUtility'); +local M = E:GetModule('Misc'); + +--E.RaidUtility = RU + +--For moving raid utility button +M.InitializeSLE = M.Initialize +function M:Initialize() + M.InitializeSLE(self) + E:CreateMover(RaidUtility_ShowButton, "RaidUtility_Mover", L["Raid Utility"], nil, nil, nil, "ALL,S&L,S&L MISC") + local mover = RaidUtility_Mover + local frame = RaidUtility_ShowButton + if E.db.movers == nil then E.db.movers = {} end + + mover:HookScript("OnDragStart", function(self) + frame:ClearAllPoints() + frame:SetPoint("CENTER", self) + end) + + local function dropfix() + local point, anchor, point2, x, y = mover:GetPoint() + frame:ClearAllPoints() + if string.find(point, "BOTTOM") then + frame:SetPoint(point, anchor, point2, x, y) + else + frame:SetPoint(point, anchor, point2, x, y) + end + end + + mover:HookScript("OnDragStop", dropfix) + + if E.db.movers.RaidUtility_Mover == nil then + frame:ClearAllPoints() + frame:SetPoint("TOP", E.UIParent, "TOP", -400, E.Border) + else + dropfix() + end +end + +RaidUtility_ShowButton:RegisterForDrag("") --Unregister any buttons for dragging. diff --git a/ElvUI_SLE/modules/tooltip.lua b/ElvUI_SLE/modules/tooltip.lua new file mode 100644 index 0000000..81a0edf --- /dev/null +++ b/ElvUI_SLE/modules/tooltip.lua @@ -0,0 +1,67 @@ +local E, L, V, P, G, _ = unpack(ElvUI); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB +local TT = E:GetModule('Tooltip'); + +--Defaults (Need to be moved.) +P['tooltip']['mouseOffsetX'] = 0 +P['tooltip']['mouseOffsetY'] = 0 +P['tooltip']['overrideCombat'] = false + +local iconPath = [[Interface\AddOns\ElvUI_SLE\media\textures\]] + +TT.GameTooltip_SetDefaultAnchorSLE = TT.GameTooltip_SetDefaultAnchor +function TT:GameTooltip_SetDefaultAnchor(tt, parent) + TT:GameTooltip_SetDefaultAnchorSLE(tt, parent) + if E.private["tooltip"].enable ~= true then return end + if(tt:GetAnchorType() ~= "ANCHOR_CURSOR") then return end + if InCombatLockdown() and self.db.visibility.combat then + tt:Hide() + return + end + if(parent) then + if(self.db.cursorAnchor) then + TT:AnchorFrameToMouse(tt); + return + end + end +end + +function TT:AnchorFrameToMouse(frame) + if frame:GetAnchorType() ~= "ANCHOR_CURSOR" then return end + --if (E.db.tooltip.onlyMod and not (IsShiftKeyDown() or IsControlKeyDown() or IsAltKeyDown())) then return end + local x, y = GetCursorPosition(); + local scale = frame:GetEffectiveScale(); + local tipWidth = frame:GetWidth(); + frame:ClearAllPoints(); + frame:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT", (x/scale + (E.db.tooltip.mouseOffsetX - tipWidth/2)), (y/scale + E.db.tooltip.mouseOffsetY)); +end + + + +TT.GameTooltip_OnTooltipSetUnitSLE = TT.GameTooltip_OnTooltipSetUnit +function TT:GameTooltip_OnTooltipSetUnit(tt) + TT:GameTooltip_OnTooltipSetUnitSLE(tt) + if not E.db.sle.tooltipicon then return end + local unit = select(2, tt:GetUnit()) + if(UnitIsPlayer(unit)) then + local text = GameTooltipTextLeft1:GetText() + local faction = UnitFactionGroup(unit) + if not faction then faction = "Neutral" end + GameTooltipTextLeft1:SetText("|T"..iconPath..faction..".blp:15:15:0:0:64:64:2:56:2:56|t "..text) + end +end + +function TT:AddonName_OnUpdate(self, elapsed) + TT:AnchorFrameToMouse(self); +end + +--function TT:MODIFIER_STATE_CHANGED(event, key) + --if InCombatLockdown() and E.db.tooltip.combathide and not (E.db.tooltip.overrideCombat and IsShiftKeyDown()) then + -- GameTooltip:Hide() + --end +--end + +TT.InitializeSLE = TT.Initialize +function TT:Initialize() + TT:InitializeSLE() + self:HookScript(GameTooltip, "OnUpdate", "AddonName_OnUpdate"); +end \ No newline at end of file diff --git a/ElvUI_SLE/modules/uibuttons.lua b/ElvUI_SLE/modules/uibuttons.lua new file mode 100644 index 0000000..ecae51a --- /dev/null +++ b/ElvUI_SLE/modules/uibuttons.lua @@ -0,0 +1,183 @@ +local E, L, V, P, G, _ = unpack(ElvUI); --Inport: Engine, Locales, PrivateDB, ProfileDB, GlobalDB, Localize Underscore +-- local UB = E:NewModule('SLE_UIButtons', 'AceHook-3.0', 'AceEvent-3.0'); +local UB = E:GetModule('SLE_UIButtons'); +local Btemplate = "SecureActionButtonTemplate" +local NumBut = 5 + +local UIBFrame = CreateFrame('Frame', "UIBFrame", E.UIParent); +local Cbutton = CreateFrame("Button", "ConfigUIButton", UIBFrame, Btemplate) +local Rbutton = CreateFrame("Button", "ReloadUIButton", UIBFrame, Btemplate) +local Mbutton = CreateFrame("Button", "MoveUIButton", UIBFrame, Btemplate) +local Bbutton = CreateFrame("Button", "Bbutton", UIBFrame, Btemplate) +local Abutton = CreateFrame("Button", "Abutton", UIBFrame, Btemplate) +if IsAddOnLoaded("iFilger_ConfigUI") then + local Fbutton = CreateFrame("Button", "Fbutton", UIBFrame, Btemplate) + NumBut = 6 +end + +local ButtonTable = { +Cbutton, +Rbutton, +Mbutton, +Bbutton, +Abutton, +} + +function UB:CreateFrame() + UIBFrame:SetFrameLevel(5); + UIBFrame:SetFrameStrata('BACKGROUND'); + UIBFrame:Point("LEFT", E.UIParent, "LEFT", -2, 0); + + UIBFrame:SetScript("OnUpdate", function(self,event,...) + UB:Mouseover() + end) +end + +function UB:Create(button, symbol, text, name, desc) + button:CreateBackdrop() + local button_text = button:CreateFontString(nil, 'OVERLAY') + button_text:SetFont(E["media"].normFont, 10) + button_text:SetText(symbol) + button_text:SetPoint("CENTER", button, "CENTER") + button:SetAttribute("type1", "macro") + if button == Bbutton then + if IsAddOnLoaded("DXE_Loader") then + button:SetAttribute("macrotext1", "/dxe config") + elseif IsAddOnLoaded("Bigwigs") then + button:SetAttribute("macrotext1", "/bigwigs") + elseif IsAddOnLoaded("DBM-Core") then + button:SetAttribute("macrotext1", "/dbm options") + elseif IsAddOnLoaded("VEM-Core") then + button:SetAttribute("macrotext1", "/vem") + end + elseif button == Abutton then + if IsAddOnLoaded("ACP") then + button:SetAttribute("macrotext1", "/acp") + elseif IsAddOnLoaded("Ampere") then + button:SetAttribute("macrotext1", "/ampere") + else + button:SetAttribute("macrotext1", "/stam") + end + else + button:SetAttribute("macrotext1", text) + end + + button:SetScript("OnEnter", function(self) + GameTooltip:SetOwner(self, "ANCHOR_TOP", 30,0) + GameTooltip:AddLine(name, .6, .6, .6, .6, .6, 1) + GameTooltip:AddLine(desc, 1, 1, 1, 1, 1, 1) + GameTooltip:Show() + end) + + button:SetScript("OnLeave", function(self) + GameTooltip:Hide() + end) +end + +function UB:CreateButtons() + UB:Create(Cbutton, "C", "/ec", L["ElvUI Config"], L["Click to toggle config window"]) --Config + UB:Create(Rbutton, "R", "/rl", L["Reload UI"], L["Click to reload your interface"]) --Reload + UB:Create(Mbutton, "M", "/moveui", L["Move UI"], L["Click to unlock moving ElvUI elements"]) --Move UI + UB:Create(Bbutton, "B", nil, L["Boss Mod"], L["Click to toggle the Configuration/Option Window from the Bossmod (DXE, DBM or Bigwigs) you have enabled."])--Boss Mod + UB:Create(Abutton, "A", nil, L["AddOns Manager"], L["Click to toggle the AddOn Manager frame (stAddOnManager, Ampere or ACP) you have enabled."])--Addon Manager + if Fbutton then + UB:Create(Fbutton, "F", "/ifilger", "iFilger", L["Click to toggle iFilger's config UI"]) + end +end + +function UB:FrameSize() + local db = E.db.sle.uibuttons + UB:MoverSize() + + for i = 1, 5 do + ButtonTable[i]:Size(db.size) + end + if Fbutton then + Fbutton:Size(db.size) + end + + UB:Positioning() +end + +function UB:Positioning() + local db = E.db.sle.uibuttons + for i = 1, 5 do + ButtonTable[i]:ClearAllPoints() + end + if Fbutton then + Fbutton:ClearAllPoints() + end + --position check + if db.position == "uib_vert" then + Cbutton:Point("TOP", UIBFrame, "TOP", 0, (E.PixelMode and -1 or -2)) + Rbutton:Point("TOP", Cbutton, "BOTTOM", 0, (E.PixelMode and -db.spacing or -(db.spacing+2))) + Mbutton:Point("TOP", Rbutton, "BOTTOM", 0, (E.PixelMode and -db.spacing or -(db.spacing+2))) + Bbutton:Point("TOP", Mbutton, "BOTTOM", 0, (E.PixelMode and -db.spacing or -(db.spacing+2))) + Abutton:Point("TOP", Bbutton, "BOTTOM", 0, (E.PixelMode and -db.spacing or -(db.spacing+2))) + if Fbutton then + Fbutton:Point("TOP", Abutton, "BOTTOM", 0, (E.PixelMode and -db.spacing or -(db.spacing+2))) + end + else + Cbutton:Point("LEFT", UIBFrame, "LEFT", (E.PixelMode and 1 or 2), 0) + Rbutton:Point("LEFT", Cbutton, "RIGHT", (E.PixelMode and db.spacing or db.spacing+2), 0) + Mbutton:Point("LEFT", Rbutton, "RIGHT", (E.PixelMode and db.spacing or db.spacing+2), 0) + Bbutton:Point("LEFT", Mbutton, "RIGHT", (E.PixelMode and db.spacing or db.spacing+2), 0) + Abutton:Point("LEFT", Bbutton, "RIGHT", (E.PixelMode and db.spacing or db.spacing+2), 0) + if Fbutton then + Fbutton:Point("LEFT", Abutton, "RIGHT", (E.PixelMode and db.spacing or db.spacing+2), 0) + end + end +end + +function UB:MoverSize() + local db = E.db.sle.uibuttons + if db.position == "uib_vert" then + UIBFrame:SetWidth(db.size + (E.PixelMode and 2 or 4)) + UIBFrame:SetHeight((db.size*NumBut)+((E.PixelMode and db.spacing or db.spacing+2)*(NumBut-1))+2) + else + UIBFrame:SetWidth((db.size*NumBut)+((E.PixelMode and db.spacing or db.spacing+2)*(NumBut-1))+2) + UIBFrame:SetHeight(db.size + (E.PixelMode and 2 or 4)) + end +end + +function UB:Start() + if E.db.sle.uibuttons.enable then + UIBFrame:Show() + else + UIBFrame:Hide() + end +end + +function UB:Mouseover() + local self = UIBFrame + if E.db.sle.uibuttons.mouse then + if (MouseIsOver(self)) then + UIFrameFadeIn(self, 0.2, self:GetAlpha(), 1) + --UIBFrame:SetAlpha(1) + else + UIFrameFadeOut(self, 0.2, self:GetAlpha(), 0) + --UIBFrame:SetAlpha(0) + end + else + UIBFrame:SetAlpha(1) + end +end + +function UB:UpdateAll() + UB:FrameSize() + UB:Start() +end + +function UB:Initialize() + UB:CreateFrame() + UB:FrameSize() + UB:CreateButtons() + UB:Start() + + E.FrameLocks['UIBFrame'] = true + + E:CreateMover(UIBFrame, "UIBFrameMover", L["UI Buttons"], nil, nil, nil, "ALL,S&L,S&L MISC") + UB:MoverSize() +end + +-- E:RegisterModule(UB:GetName()) \ No newline at end of file diff --git a/ElvUI_SLE/modules/vehicle.lua b/ElvUI_SLE/modules/vehicle.lua new file mode 100644 index 0000000..805f40d --- /dev/null +++ b/ElvUI_SLE/modules/vehicle.lua @@ -0,0 +1,140 @@ +local E, L, V, P, G = unpack(ElvUI); +-- local EVB = E:NewModule("SLE_EnhancedVehicleBar"); +local EVB = E:GetModule("SLE_EnhancedVehicleBar") +local AB = E:GetModule("ActionBars"); +local LAB = LibStub("LibActionButton-1.0") + +-- Regular Button for these bars are 52. 52 * .71 = ~37.. I just rounded it up to 40 and called it good. +function EVB:Animate(bar, x, y, duration) + bar.anim = bar:CreateAnimationGroup('Move_In') + bar.anim.in1 = bar.anim:CreateAnimation('Translation') + bar.anim.in1:SetDuration(0) + bar.anim.in1:SetOrder(1) + bar.anim.in2 = bar.anim:CreateAnimation('Translation') + bar.anim.in2:SetDuration(duration) + bar.anim.in2:SetOrder(2) + bar.anim.in2:SetSmoothing('OUT') + bar.anim.out1 = bar:CreateAnimationGroup('Move_Out') + bar.anim.out2 = bar.anim.out1:CreateAnimation('Translation') + bar.anim.out2:SetDuration(duration) + bar.anim.out2:SetOrder(1) + bar.anim.out2:SetSmoothing('IN') + bar.anim.in1:SetOffset(x, y) + bar.anim.in2:SetOffset(-x, -y) + bar.anim.out2:SetOffset(x, y) + bar.anim.out1:SetScript('OnFinished', function() bar:Hide() end) +end + +function EVB:AnimSlideIn(bar) + if not bar.anim then + Animate(bar) + end + + bar.anim.out1:Stop() + bar.anim:Play() +end + +function EVB:AnimSlideOut(bar) + if bar.anim then + bar.anim:Finish() + end + + bar.anim:Stop() + bar.anim.out1:Play() +end + +function EVB:CreateExtraButtonSet() + local bar = self.bar + bar.buttons = {} + for i = 1, 7 do + i = i == 7 and 12 or i + + bar.buttons[i] = LAB:CreateButton(i, format(bar:GetName().."Button%d", i), bar, nil); + bar.buttons[i]:SetState(0, "action", i); + + for k = 1, 14 do + bar.buttons[i]:SetState(k, "action", (k - 1) * 12 + i) + end + + if i == 12 then + bar.buttons[i]:SetState(12, "custom", AB.customExitButton) + end + + bar.buttons[i]:Size(self.size); + + if (i == 1) then + bar.buttons[i]:SetPoint('BOTTOMLEFT', self.spacing, self.spacing) + else + local prev = i == 12 and bar.buttons[6] or bar.buttons[i-1]; + bar.buttons[i]:SetPoint('LEFT', prev, 'RIGHT', self.spacing, 0) + end + + AB:StyleButton(bar.buttons[i]); + RegisterStateDriver(bar.buttons[i], 'visibility', '[petbattle] hide; [vehicleui][overridebar][shapeshift][possessbar] show; hide') + + end +end + +function EVB:Initialize() + if (not E.private.sle.vehicle.enable) then return end; + + local visibility = "[petbattle] hide; [vehicleui][overridebar][shapeshift][possessbar] hide; show" + local page = format("[vehicleui] %d; [possessbar] %d; [overridebar] %d; [shapeshift] 13;", GetVehicleBarIndex(), GetVehicleBarIndex(), GetOverrideBarIndex()); + local bindButtons = "ACTIONBUTTON"; + + hooksecurefunc(AB, "PositionAndSizeBar", function(self, barName) + local bar = self["handledBars"][barName] + if (self.db[barName].enabled) then + UnregisterStateDriver(bar, 'visibility'); + RegisterStateDriver(bar, 'visibility', visibility); + end + end); + + local size = 40; + local spacing = E:Scale(AB.db["bar1"].buttonspacing); + local bar = CreateFrame("Frame", "ElvUISLEEnhancedVehicleBar", UIParent, "SecureHandlerStateTemplate"); + + self.size = size; + self.spacing = spacing; + + bar:SetWidth((size * 7) + (spacing * 8)); + bar:SetHeight(size + (spacing * 2)); + bar:SetTemplate("Transparent"); + bar:CreateShadow(); + if (E:GetModule("EnhancedShadows", true)) then + E:GetModule("EnhancedShadows"):RegisterShadow(bar.shadow); + end + + bar:SetPoint("BOTTOM", 0, 34); + bar:HookScript("OnShow", function(frame) self:AnimSlideIn(frame) end); + RegisterStateDriver(bar, 'visibility', '[petbattle] hide; [vehicleui][overridebar][shapeshift][possessbar] show; hide'); + RegisterStateDriver(bar, 'page', page); + + bar:SetAttribute("_onstate-page", [[ + if HasTempShapeshiftActionBar() and self:GetAttribute("hasTempBar") then + newstate = GetTempShapeshiftBarIndex() or newstate + end + + if newstate ~= 0 then + self:SetAttribute("state", newstate) + control:ChildUpdate("state", newstate) + else + local newCondition = self:GetAttribute("newCondition") + if newCondition then + newstate = SecureCmdOptionParse(newCondition) + self:SetAttribute("state", newstate) + control:ChildUpdate("state", newstate) + end + end + ]]); + + self:Animate(bar, 0, -(bar:GetHeight()), 1); + + self.bar = bar; + + self:CreateExtraButtonSet(); + + AB:UpdateButtonConfig(bar, bindButtons); +end + +-- E:RegisterModule(EVB:GetName()) \ No newline at end of file