diff --git a/AlignGrid.lua b/AlignGrid.lua new file mode 100644 index 0000000..56196a2 --- /dev/null +++ b/AlignGrid.lua @@ -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) + diff --git a/MiniPlayerFrame.lua b/MiniPlayerFrame.lua index 0cfd400..67d8cde 100644 --- a/MiniPlayerFrame.lua +++ b/MiniPlayerFrame.lua @@ -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) @@ -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) @@ -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 @@ -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) diff --git a/TurtleTweaks.toc b/TurtleTweaks.toc index 02f7147..a9b6da3 100644 --- a/TurtleTweaks.toc +++ b/TurtleTweaks.toc @@ -10,6 +10,7 @@ Data\WoWCodexWeapons.lua Core.lua +AlignGrid.lua AutoRepair.lua CastbarPosition.lua ChatArrowKeys.lua