Skip to content

Commit

Permalink
Added align grid
Browse files Browse the repository at this point in the history
  • Loading branch information
mitjafelicijan committed Aug 7, 2024
1 parent d0a5364 commit 91ee7f6
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 6 deletions.
62 changes: 62 additions & 0 deletions AlignGrid.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
local feature = ns.Register({
identifier = "AlignGrid",
description = "Draws an align grid on a screen if Ctrl+Alt+Shift is being pressed.",
category = "interface",
config = {},
data = {}
})

local frame = CreateFrame("Frame", nil, UIParent)

frame:RegisterEvent("ADDON_LOADED")

frame:SetScript("OnEvent", function()
if not ns.IsEnabled(feature.identifier) then return end

if event == "ADDON_LOADED" then
frame.grid = CreateFrame("Frame")
frame.grid:Hide()
frame.grid:SetAllPoints(UIParent)

local w, h = GetScreenWidth() * UIParent:GetEffectiveScale(), GetScreenHeight() * UIParent:GetEffectiveScale()
local ratio = w / h
local sqsize = w / 20
local wline = floor(sqsize - mod(sqsize, 2))
local hline = floor(sqsize / ratio - mod((sqsize / ratio), 2))

-- Plot vertical lines.
for i = 0, wline do
local t = frame.grid:CreateTexture(nil, "BACKGROUND")
if i == wline / 2 then
t:SetTexture(1, 1, 0, 0.7) -- Yellow line in the middle
else
t:SetTexture(0, 0, 0, 0.7) -- Black lines elsewhere
end
t:SetPoint("TOPLEFT", frame.grid, "TOPLEFT", i * w / wline - 1, 0)
t:SetPoint("BOTTOMRIGHT", frame.grid, "BOTTOMLEFT", i * w / wline + 1, 0)
end

-- Plot horizontal lines.
for i = 0, hline do
local t = frame.grid:CreateTexture(nil, "BACKGROUND")
if i == hline / 2 then
t:SetTexture(1, 1, 0, 0.7) -- Yellow line in the middle
else
t:SetTexture(0, 0, 0, 0.7) -- Black lines elsewhere
end
t:SetPoint("TOPLEFT", frame.grid, "TOPLEFT", 0, -i * h / hline + 1)
t:SetPoint("BOTTOMRIGHT", frame.grid, "TOPRIGHT", 0, -i * h / hline - 1)
end
end

frame:SetScript("OnUpdate", function()
if IsControlKeyDown() and IsShiftKeyDown() and IsAltKeyDown() then
frame.grid:Show()
else
frame.grid:Hide()
end
end)

frame:UnregisterEvent("ADDON_LOADED")
end)

14 changes: 8 additions & 6 deletions MiniPlayerFrame.lua
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ frame:SetScript("OnEvent", function()
local power = UnitPowerType("player")
local currentHealth = UnitHealth("player")
local maxHealth = UnitHealthMax("player")
local currentMana = UnitMana("player")
local maxMana = UnitManaMax("player")
local currentPower = UnitMana("player")
local maxPower = UnitManaMax("player")

if event == "ADDON_LOADED" and not feature.data.initialized then
frame:SetPoint("CENTER", UIParent, "CENTER", 0, -feature.config.offset)
Expand Down Expand Up @@ -79,7 +79,7 @@ frame:SetScript("OnEvent", function()
frame.primary:EnableMouse(false)

-- Setting up the texture.
frame.border = frame:CreateTexture(nil, "OVERLAY")
frame.border = frame:CreateTexture(nil, "BORDER")
frame.border:SetTexture("Interface\\AddOns\\TurtleTweaks\\UI\\MiniUnitFrame.tga")
frame.border:SetAllPoints(frame)
frame.border:SetTexCoord(0, 1, 0, 0.5)
Expand Down Expand Up @@ -109,7 +109,9 @@ frame:SetScript("OnEvent", function()
if power == 0 or power == 2 then
frame.border:SetTexCoord(0.0, 1.0, 0.0, 0.5) -- two slot
else
frame.border:SetTexCoord(0.0, 1.0, 0.5, 1.0) -- three slot
frame.border:SetTexCoord(0.0, 1.0, 0.0, 0.5) -- two slot
-- TODO: Not implemented yet. Getting mana in shapeshifting form is not trivial.
-- frame.border:SetTexCoord(0.0, 1.0, 0.5, 1.0) -- three slot
end
end

Expand All @@ -127,8 +129,8 @@ frame:SetScript("OnEvent", function()
frame.health:Show()

-- Update primary bar.
frame.primary:SetMinMaxValues(0, maxMana)
frame.primary:SetValue(currentMana)
frame.primary:SetMinMaxValues(0, maxPower)
frame.primary:SetValue(currentPower)
frame.primary:Show()
end
end)
Expand Down
1 change: 1 addition & 0 deletions TurtleTweaks.toc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Data\WoWCodexWeapons.lua

Core.lua

AlignGrid.lua
AutoRepair.lua
CastbarPosition.lua
ChatArrowKeys.lua
Expand Down

0 comments on commit 91ee7f6

Please sign in to comment.