Skip to content
This repository has been archived by the owner on Jun 1, 2019. It is now read-only.

Commit

Permalink
file/folder restructure
Browse files Browse the repository at this point in the history
  • Loading branch information
wardz committed May 14, 2017
1 parent c1b56ab commit 73d7c74
Show file tree
Hide file tree
Showing 12 changed files with 478 additions and 483 deletions.
8 changes: 4 additions & 4 deletions FocusFrame.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
local _G = getfenv(0)
local Focus = assert(_G.FocusData, "FocusData not loaded.")
local Focus = assert(_G.FocusCore, "FocusCore not loaded.")
local AurasUpdate

FocusFrameDB = FocusFrameDB or { unlock = true, scale = 1 }
Expand Down Expand Up @@ -470,7 +470,7 @@ FocusFrame.cast.border = FocusFrame.cast:CreateTexture("FocusCastingBarBorder",
FocusFrame.cast.border:SetPoint("TOPLEFT", -23, 20)
FocusFrame.cast.border:SetPoint("TOPRIGHT", 23, 20)
FocusFrame.cast.border:SetHeight(50)
FocusFrame.cast.border:SetTexture("Interface\\AddOns\\FocusFrame\\media\\UI-CastingBar-Border-Small.blp")
FocusFrame.cast.border:SetTexture("Interface\\AddOns\\FocusFrame\\Media\\UI-CastingBar-Border-Small.blp")

FocusFrame.cast.text = FocusFrame.cast:CreateFontString("FocusCastingBarText", "OVERLAY")
FocusFrame.cast.text:SetTextColor(1, 1, 1)
Expand All @@ -496,7 +496,7 @@ FocusFrame.cast.shield = FocusFrame.cast:CreateTexture("FocusCastingBarShield",
FocusFrame.cast.shield:SetPoint("TOPLEFT", -28, 20)
FocusFrame.cast.shield:SetPoint("TOPRIGHT", 18, 20)
FocusFrame.cast.shield:SetHeight(50)
FocusFrame.cast.shield:SetTexture("Interface\\AddOns\\FocusFrame\\media\\UI-CastingBar-Small-Shield.blp")
FocusFrame.cast.shield:SetTexture("Interface\\AddOns\\FocusFrame\\Media\\UI-CastingBar-Small-Shield.blp")
FocusFrame.cast.shield:Hide()

-- Register events
Expand Down Expand Up @@ -549,7 +549,7 @@ SlashCmdList.FOCUSOPTIONS = function(msg)
FocusFrameDB.disableNameplateScan = not FocusFrameDB.disableNameplateScan
local x = FocusFrameDB.disableNameplateScan
Focus:ToggleNameplateScan(not x)
print("Nameplate scanning %s", x and "disabled" or "enabled")
print("Nameplate scanning %s.", x and "disabled" or "enabled")
elseif cmd == "reset" then
FocusFrameDB = { scale = 1, unlock = true }
FocusFrame:SetScale(1)
Expand Down
17 changes: 8 additions & 9 deletions FocusFrame.toc
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,15 @@
## Version: 1.2.0
## SavedVariables: FocusFrameDB

libs\FocusData\buffs.lua
libs\FocusData\spells.lua
libs\FocusData\spellCastingCore.lua
libs\FocusData\FocusData.lua
libs\FocusData\FocusCmds.lua
libs\FocusCore\SpellGlobals.lua
libs\FocusCore\SpellCore.lua
libs\FocusCore\FocusCore.lua
libs\FocusCore\SlashCommands.lua

FocusFrame.xml
FocusFrame.lua

mods\loader.lua
mods\enemyFrames.lua
mods\classPortraits.lua
mods\clickcast.lua
Plugins\Loader.lua
Plugins\EnemyFrames.lua
Plugins\ClassPortraits.lua
Plugins\ClickCast.lua
10 changes: 3 additions & 7 deletions mods/classPortraits.lua → Plugins/ClassPortraits.lua
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
-- Adds support for ClassPortraits and ClassPortraits_Vanilla.
local OnLoad = function(Focus, addonName)
local iconPath
if addonName == "ClassPortraits_Vanilla" then
iconPath = "Interface\\Addons\\ClassPortraits_Vanilla\\UI-CLASSES-CIRCLES"
else
iconPath = "Interface\\Addons\\ClassPortraits\\UI-CLASSES-CIRCLES"
end
local iconPath = "Interface\\Addons\\" .. addonName .. "\\UI-CLASSES-CIRCLES"

local CLASS_COORDS = {
["HUNTER"] = { 0, 0.25, 0.25, 0.5 },
Expand All @@ -31,8 +26,9 @@ local OnLoad = function(Focus, addonName)
end
end

-- "post-hook" event functions used in FocusFrame.lua
Focus:OnEvent("FOCUS_UNITID_EXISTS", UpdatePortrait) -- on focus targeted
Focus:OnEvent("UNIT_PORTRAIT_UPDATE", UpdatePortrait) -- while focus is targeted
Focus:OnEvent("UNIT_PORTRAIT_UPDATE", UpdatePortrait) -- while focus is targeted only
end

Focus_Loader:Register("ClassPortraits", OnLoad)
Expand Down
64 changes: 64 additions & 0 deletions Plugins/ClickCast.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
-- luna clickcasting support
-- note: clique support is not possible afaik
Focus_Loader:Register("LunaUnitFrames", function(Focus)
local orig_lufmo = SlashCmdList.LUFMO
local L = LunaUF and LunaUF.L
if not L or not LunaUF.Mouseover then return end

SlashCmdList.LUFMO = function(msg, editbox)
local frame = GetMouseFocus()

if msg and strfind(frame:GetName() or "", "FocusFrame") then
Focus:CastSpellByName(msg)
else
orig_lufmo(msg, editbox)
end
end

FocusFrame_OnClick = function(btn)
if btn == "UNKNOWN" then
btn = LunaUF.clickedButton
end

--[[if Luna_Custom_ClickFunction and Luna_Custom_ClickFunction(btn, "target") then
return
end]]

local button = (IsControlKeyDown() and "Ctrl-" or "") .. (IsShiftKeyDown() and "Shift-" or "") .. (IsAltKeyDown() and "Alt-" or "") .. L[btn]
local action = LunaUF.db.profile.clickcasting.bindings[button]

if not action then
return
elseif action == L["menu"] then
if SpellIsTargeting() then
return SpellStopTargeting()
end
elseif action == L["target"] then
if SpellIsTargeting() then
Focus:Call(SpellTargetUnit)
elseif CursorHasItem() then
Focus:Call(DropItemOnUnit)
else
Focus:TargetFocus()
end
else
Focus:TargetFocus()
LunaUF:Mouseover(action)
Focus:TargetPrevious()
end
end
end)

--[[Loader:Register("pfUI", function(Focus)
local orig_pfcast = SlashCmdList.PFCAST
SlashCmdList.PFCAST = function(arg1, arg2)
local frame = GetMouseFocus()
if arg1 and strfind(frame:GetName() or "", "FocusFrame") then
Focus:Call(CastSpellByName, arg1)
else
orig_PFCAST(arg1, arg2)
end
end
end)]]
12 changes: 6 additions & 6 deletions mods/enemyFrames.lua → Plugins/EnemyFrames.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Focus_Loader:Register("enemyFrames", function(Focus)
if not CreateCooldown or not SPELLCASTINGCOREgetPrioBuff then return end

local getPrioBuff, floor, GetTime = SPELLCASTINGCOREgetPrioBuff, floor, GetTime
local getPrioBuff, floor, GetTime = SPELLCASTINGCOREgetPrioBuff, math.floor, GetTime

local portraitDebuff = CreateFrame("Frame", "FocusPortraitDebuff", FocusFrame)
portraitDebuff:SetFrameLevel(0)
Expand Down Expand Up @@ -40,6 +40,7 @@ Focus_Loader:Register("enemyFrames", function(Focus)
portraitDebuff.cd:SetAlpha(1)

local function Round(num, idp)
idp = idp or num > 3 and 0 or 1
local mult = 10^(idp or 0)

return floor(num * mult + 0.5) / mult
Expand All @@ -58,7 +59,7 @@ Focus_Loader:Register("enemyFrames", function(Focus)

local t = prioBuff.timeEnd - GetTime()
portraitDebuff.debuffText:SetTexture(prioBuff.icon)
portraitDebuff.duration:SetText(Round(t, t > 3 and 0 or 1))
portraitDebuff.duration:SetText(Round(t))
portraitDebuff.debuffText:Show()
portraitDebuff.cd:SetTimers(prioBuff.timeStart, prioBuff.timeEnd)
portraitDebuff.cd:Show()
Expand All @@ -77,19 +78,18 @@ Focus_Loader:Register("enemyFrames", function(Focus)
end

local refresh = 0
local f = CreateFrame("Frame")
f:SetScript("OnUpdate", function()
portraitDurationFrame:SetScript("OnUpdate", function()
refresh = refresh - arg1
if refresh < 0 then
if ENEMYFRAMESPLAYERDATA.targetPortraitDebuff and Focus:FocusExists() then
if ENEMYFRAMESPLAYERDATA.targetPortraitDebuff and CURR_FOCUS_TARGET then
UpdatePortraitDebuff()
else
--if portraitDebuff:IsVisible() then
portraitDebuff:Hide()
portraitDebuff.cd:Hide()
portraitDebuff.bgText:Hide()
portraitDebuff.debuffText:Hide()
portraitDebuff.duration:SetText(nil)
portraitDebuff.duration:SetText(nil) -- don't hide parent frame or else we cant reuse frame for OnUpdate
--end
end

Expand Down
2 changes: 1 addition & 1 deletion mods/loader.lua → Plugins/Loader.lua
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ end
function Loader:ADDON_LOADED(addonName)
local addon = self.addons[addonName]
if addon then
local success = pcall(addon.init, FocusData, addonName)
local success = pcall(addon.init, FocusCore, addonName)
addon.loaded = success
addon.hasRan = true

Expand Down
15 changes: 7 additions & 8 deletions libs/FocusData/FocusData.lua → libs/FocusCore/FocusCore.lua
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
------------
-- API documentation can be generated using LDoc or viewed here:
-- https://wardz.github.io/FocusFrame/
-- @module FocusData
-- @module FocusCore
-- @author Wardz
-- @license MIT
local _G = getfenv(0)
if _G.FocusData then return end
if _G.FocusCore then return end

-- Vars
local Focus = {}
Expand Down Expand Up @@ -37,7 +37,6 @@ local GetCast = FSPELLCASTINGCOREgetCast
--[[
@TODO
- optimize nameplate scanning
- add AceLibrary support if possible
- rewrite spellcastingcore completely
- update raid mark, leader icon etc on focus leave party and duel
]]
Expand All @@ -51,7 +50,7 @@ do

DEFAULT_CHAT_FRAME:AddMessage(string.format(str or "nil", arg1, arg2, arg3, arg4))
end
FocusData_Log = log
FocusCore_Log = log
end

--------------------------------
Expand Down Expand Up @@ -276,12 +275,12 @@ end
do
local UnitBuff, UnitDebuff, UnitIsEnemy = UnitBuff, UnitDebuff, UnitIsEnemy

local scantip = CreateFrame("GameTooltip", "FocusDataScantip", nil, "GameTooltipTemplate")
local scantip = CreateFrame("GameTooltip", "FocusCoreScantip", nil, "GameTooltipTemplate")
scantip:SetOwner(UIParent, "ANCHOR_NONE")
scantip:SetFrameStrata("TOOLTIP")

local scantipTextLeft1 = _G["FocusDataScantipTextLeft1"]
local scantipTextRight1 = _G["FocusDataScantipTextRight1"]
local scantipTextLeft1 = _G["FocusCoreScantipTextLeft1"]
local scantipTextRight1 = _G["FocusCoreScantipTextRight1"]
local playersFaction = UnitFactionGroup("player")

-- Store buff into spellcastingcore db
Expand Down Expand Up @@ -1141,4 +1140,4 @@ do
end

-- Add to global namespace
_G.FocusData = Focus
_G.FocusCore = Focus
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ if SlashCmdList.MFOCUS then return end

-- Upvalues
local _G = getfenv(0)
local Focus = _G.FocusData
local Focus = _G.FocusCore
local strfind, strlower, gsub = string.find, string.lower, string.gsub
local GetContainerNumSlots = GetContainerNumSlots

Expand Down Expand Up @@ -89,8 +89,8 @@ SlashCmdList.FITEM = function(msg)
return Focus:ShowError()
end

local scantip = _G.FocusDataScantip
local scantipTextLeft1 = _G.FocusDataScantipTextLeft1
local scantip = _G.FocusCoreScantip
local scantipTextLeft1 = _G.FocusCoreScantipTextLeft1

-- Loop through inventory (gear)
for i = 19, 1, -1 do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ local GainAfflict = function()
if FOCUS_BUFFS_TO_TRACK[s] then
if CURR_FOCUS_TARGET and CURR_FOCUS_TARGET == c then
local unit = Focus:GetData("unit")
if unit then return end -- buffs will be added in FocusData sync instead
if unit then return end -- buffs will be added in FocusCore sync instead
end

newbuff(c, s, 1, false)
Expand Down Expand Up @@ -468,7 +468,7 @@ local GainAfflict = function()
--else
if CURR_FOCUS_TARGET and CURR_FOCUS_TARGET == c then
local unit = Focus:GetData("unit")
if unit then return end -- buffs will be added in FocusData sync instead
if unit then return end -- buffs will be added in FocusCore sync instead
end
newbuff(c, s, st, false, nil, true)
--end
Expand Down Expand Up @@ -822,7 +822,10 @@ do
local function OnUpdate()
refresh = refresh - arg1
if refresh < 0 then
if FSPELLCASTINGCOREstrictAuras and not Focus:FocusExists() then return end
if FSPELLCASTINGCOREstrictAuras and not Focus:FocusExists() then
refresh = interval
return
end
tableMaintenance(false)
refresh = interval
end
Expand All @@ -839,7 +842,7 @@ do
events:RegisterEvent("VARIABLES_LOADED")
events:SetScript("OnEvent", function()
if event == "VARIABLES_LOADED" then
Focus = assert(FocusData, "FocusData not loaded.")
Focus = assert(FocusCore, "FocusCore not loaded.")
FSPELLCASTINGCOREstrictAuras = FocusFrameDB and FocusFrameDB.strictAuras
events:UnregisterEvent("VARIABLES_LOADED")
events:RegisterEvent("PLAYER_ENTERING_WORLD")
Expand Down
Loading

0 comments on commit 73d7c74

Please sign in to comment.