Files
OmicronFrames/src/frames.lua
omicron e72c4b3e3f Allow size and range check features to be configured.
This also improves the range check to fall back to UnitInRange if no
friendly spell is available
2023-04-01 01:20:39 +02:00

113 lines
3.2 KiB
Lua

-- Copyright 2023 <omicron.me@protonmail.com>
--
-- This file is part of Omicron Frames
--
-- Omicron Frames is free software: you can redistribute it and/or modify it
-- under the terms of the GNU General Public License as published by the Free
-- Software Foundation, either version 3 of the License, or (at your option)
-- any later version.
--
-- Omicron Frames is distributed in the hope that it will be useful, but
-- WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
-- more details.
--
-- You should have received a copy of the GNU General Public License along with
-- Omicron Frames. If not, see <https://www.gnu.org/licenses/>.
local omif = select(2, ...)
local function RangeConfig()
local _, class = UnitClass("player")
if class == "SHAMAN" then
return {
friendly = "Healing Surge",
enemy = "Lightning Bolt",
fade = 0.2
}
else
return {
fade = 0.2
}
end
end
local types = omif.GetModule("types")
local UnitFrame = types.UnitFrame
local UnitGroup = types.UnitGroup
-- re-parent all blizzard frames and then hide the new parent
function HideBlizzardFrames()
local toggleFrame = CreateFrame("Frame", nil, UIParent)
blizzardFrames = {
PlayerFrame,
TargetFrame,
FocusFrame,
PartyFrame,
CompactRaidFrameContainer
}
for _, frame in ipairs(blizzardFrames) do
frame:SetParent(toggleFrame)
end
toggleFrame:Hide()
end
function CreateRaidFrames(left, top, config)
local width = config.size.width
local height = config.size.height
local group = UnitGroup:new(left, top, width, height)
for i=0,5 do
for j=0,4 do
local num = i*5 + j + 1
local frame = UnitFrame:new("raid" .. num, config)
group:AddUnitFrame(frame)
end
end
end
function CreatePartyFrames(left, top, config)
local width = config.size.width
local height = config.size.height
local group = UnitGroup:new(left, top, width, height)
local player = UnitFrame:new("player", config)
group:AddUnitFrame(player)
for i=1,4 do
local frame = UnitFrame:new("party" .. i, config)
group:AddUnitFrame(frame)
end
group:Sort()
end
function CreateTargetFrames(left, top, config)
local width = config.size.width
local height = config.size.height
local focus = UnitFrame:new("focus", config)
focus:SetPosition(left, top)
local target = UnitFrame:new("target", config)
target:SetPosition(left, top - height)
for i=1,4 do
local boss = UnitFrame:new("boss" .. i, config)
boss:SetPosition(left, top-(i+1)*height)
end
end
function CreateFrames()
config = {
size = {
width = 110,
height = 45,
},
range = RangeConfig(),
hideInRaid = true,
}
CreatePartyFrames(0, -290, config)
config.hideInRaid = false
CreateRaidFrames(0, -290, config)
CreateTargetFrames(110*3+50, -245, config)
HideBlizzardFrames()
end
omif.SetEventHandler("OMICRON_LOADING", CreateFrames)