Add a basic ass enable spotter button

This commit is contained in:
2025-01-06 20:10:02 +01:00
parent dfb2f687d0
commit 546aa27bb1

View File

@@ -165,8 +165,6 @@ StaticGridFrame = {
if canPlace then
local x = (col - 1) * self.cellWidth
local y = -(row - 1) * self.cellHeight
print(string.format("frame:SetWidth(%d)", self.cellWidth * colspan))
print(string.format("frame:SetHeight(%d)", self.cellHeight * rowspan))
frame:SetWidth(self.cellWidth * colspan)
frame:SetHeight(self.cellHeight * rowspan)
frame:SetPoint("TOPLEFT", self.frame, "TOPLEFT", x, y)
@@ -199,7 +197,7 @@ StaticGridFrame = {
local configFrame = StaticGridFrame.new("HeimdallConfig",
UIParent,
40, 12,
{ w = 1024+512, h = 1024 })
{ w = 1024 + 512, h = 1024 })
configFrame:MakeMovable()
local colors = {
@@ -211,33 +209,53 @@ local colors = {
{ 0, 1, 1, 1 },
{ 1, 1, 1, 1 },
}
for i = 1, 200 do
local frame = CreateFrame("Frame", "HeimdallConfigFrame" .. i, UIParent)
frame:SetBackdrop({
bgFile = "Interface/Tooltips/UI-Tooltip-Background",
tileSize = 64,
tile = true
})
frame:SetBackdropColor(unpack(colors[i % #colors + 1]))
frame:SetBackdropBorderColor(0.5, 0.5, 0.5, 1)
configFrame:Add(frame, 4, 2)
end
--for i = 1, 200 do
-- local frame = CreateFrame("Frame", "HeimdallConfigFrame" .. i, UIParent)
-- frame:SetBackdrop({
-- bgFile = "Interface/Tooltips/UI-Tooltip-Background",
-- tileSize = 64,
-- tile = true
-- })
-- frame:SetBackdropColor(unpack(colors[i % #colors + 1]))
-- frame:SetBackdropBorderColor(0.5, 0.5, 0.5, 1)
-- configFrame:Add(frame, 4, 2)
--end
---@diagnostic disable-next-line: missing-fields
shared.Config = {}
function shared.Config.Init()
local buttonColors = {
enabled = { 1, 0, 0, 1 },
disabled = { 0, 1, 0, 1 }
}
---@param name string
---@param parent Frame
---@param text string
---@param onClick fun(state: boolean)
---@param onClick fun(): boolean
local function BasicButton(name, parent, text, onClick)
local button = CreateFrame("CheckButton", name, parent, "UICheckButtonTemplate")
button.text = button:CreateFontString(nil, "OVERLAY", "GameFontNormal")
button.text:SetText(text)
button.text:SetPoint("LEFT", button, "RIGHT", 0, 0)
button:SetSize(24, 24)
button:SetScript("OnClick", function()
onClick(button:GetChecked())
local button = CreateFrame("Frame", name, parent)
button:SetScript("OnMouseDown", function()
local res = onClick()
local color = res and buttonColors.enabled or buttonColors.disabled
button:SetBackdropColor(unpack(color))
end)
local color = Heimdall_Data.config.spotter.enabled and buttonColors.enabled or buttonColors.disabled
button:SetBackdrop({
bgFile = "Interface/Tooltips/UI-Tooltip-Background",
edgeFile = "Interface/Tooltips/UI-Tooltip-Border",
tile = true,
tileSize = 2,
edgeSize = 2,
insets = {
left = 2,
right = 2,
top = 2,
bottom = 2
}
})
button:SetBackdropColor(unpack(color))
--spotterEnableButton:SetChecked(Heimdall_Data.config.spotter.enabled)
local spotterEnableButtonLabel = button:CreateFontString(nil, "OVERLAY", "GameFontNormal")
spotterEnableButtonLabel:SetText(text)
spotterEnableButtonLabel:SetAllPoints(button)
return button
end
-----@param name string
@@ -295,36 +313,20 @@ function shared.Config.Init()
-- end
--
-- local title = configFrame.frame:CreateFontString(nil, "ARTWORK", "GameFontNormal")
-- title:SetText("Heimdall Config")
-- configFrame:Add(title, 1, 12)
local title = configFrame.frame:CreateFontString(nil, "ARTWORK", "GameFontNormal")
title:SetText("Heimdall Config")
configFrame:Add(title, 1, 12)
-- local spotterConfigFrame = GridFrame.new("HeimdallSpotterConfig",
-- configFrame.frame, 12, 20, { w: 0,h: 0 })
-- configFrame:Add(spotterConfigFrame.frame, 12, 6)
-- spotterConfigFrame.frame:SetBackdrop({
-- bgFile = "Interface/Tooltips/UI-Tooltip-Background",
-- edgeFile = "Interface/Tooltips/UI-Tooltip-Border",
-- tile = true,
-- tileSize = 4,
-- edgeSize = 4,
-- insets = {
-- left = 4,
-- right = 4,
-- top = 4,
-- bottom = 4
-- }
-- })
-- spotterConfigFrame.frame:SetBackdropColor(1, 0, 0, 0.8)
-- spotterConfigFrame.frame:SetBackdropBorderColor(0.5, 0.5, 0.5, 1)
-- spotterConfigFrame:Show()
local spotterConfigFrame = GridFrame.new("HeimdallSpotterConfig",
configFrame.frame, 12, 20)
configFrame:Add(spotterConfigFrame.frame, 6, 3)
--local spotterEnableButton = BasicButton("HeimdallSpotterEnable", spotterConfigFrame, "Enable Spotter",
-- function(state)
-- Heimdall_Data.config.spotter.enabled = state
-- end)
--spotterEnableButton:SetPoint("TOPLEFT", spotterConfigFrame, "TOPLEFT", 4, -4)
--spotterEnableButton:SetChecked(Heimdall_Data.config.spotter.enabled)
local spotterEnableButton = BasicButton("HeimdallSpotterConfigEnableButton",
spotterConfigFrame.frame, "Enable Spotter", function()
Heimdall_Data.config.spotter.enabled = not Heimdall_Data.config.spotter.enabled
return Heimdall_Data.config.spotter.enabled
end)
spotterConfigFrame:Add(spotterEnableButton, 1, 3)
--local spotterEveryoneButton = BasicButton("HeimdallSpotterEveryone", spotterConfigFrame, "Everyone", function(state)
-- Heimdall_Data.config.spotter.everyone = state