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