200 lines
7.8 KiB
Lua
200 lines
7.8 KiB
Lua
local addonname, shared = ...
|
|
---@cast shared HeimdallShared
|
|
---@cast addonname string
|
|
|
|
local configFrame = CreateFrame("Frame", "HeimdallConfig", UIParent)
|
|
|
|
---@diagnostic disable-next-line: missing-fields
|
|
shared.Config = {}
|
|
function shared.Config.Init()
|
|
local function PutBelow(a, b)
|
|
a:SetPoint("LEFT", b, "LEFT", 0, -24)
|
|
end
|
|
local function PutRight(a, b)
|
|
a:SetPoint("LEFT", b, "LEFT", 128, 0)
|
|
end
|
|
---@param name string
|
|
---@param parent Frame
|
|
---@param text string
|
|
---@param onClick function
|
|
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", onClick)
|
|
button.PutBelow = PutBelow
|
|
button.PutRight = PutRight
|
|
return button
|
|
end
|
|
|
|
configFrame:SetSize(256 + 256, 512)
|
|
configFrame:SetPoint("CENTER")
|
|
configFrame:SetFrameStrata("HIGH")
|
|
configFrame:EnableMouse(true)
|
|
configFrame:SetMovable(true)
|
|
configFrame:SetResizable(false)
|
|
configFrame: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
|
|
}
|
|
})
|
|
configFrame:SetBackdropColor(0, 0, 0, 0.8)
|
|
configFrame:SetBackdropBorderColor(0.5, 0.5, 0.5, 1)
|
|
|
|
configFrame:SetMovable(true)
|
|
configFrame:EnableMouse(true)
|
|
configFrame:RegisterForDrag("LeftButton")
|
|
configFrame:SetScript("OnDragStart", function(self)
|
|
self:StartMoving()
|
|
end)
|
|
configFrame:SetScript("OnDragStop", function(self)
|
|
self:StopMovingOrSizing()
|
|
end)
|
|
configFrame:SetScript("OnShow", function(self)
|
|
self:SetScale(1)
|
|
end)
|
|
|
|
local title = configFrame:CreateFontString(nil, "ARTWORK", "GameFontNormal")
|
|
title:SetText("Heimdall Config")
|
|
title:SetPoint("TOP", configFrame, "TOP", 0, -8)
|
|
|
|
local spotterConfigFrame = CreateFrame("Frame", "HeimdallSpotterConfig", configFrame)
|
|
spotterConfigFrame:SetSize(256, 128)
|
|
spotterConfigFrame:SetPoint("TOPLEFT", configFrame, "TOPLEFT", 8, -24)
|
|
spotterConfigFrame: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:SetBackdropColor(0, 0, 0, 0.8)
|
|
spotterConfigFrame:SetBackdropBorderColor(0.5, 0.5, 0.5, 1)
|
|
|
|
local spotterEnableButton = BasicButton("HeimdallSpotterEnable", spotterConfigFrame, "Enable Spotter", function()
|
|
Heimdall_Data.config.spotter.enabled = spotterEnableButton:GetChecked()
|
|
end)
|
|
spotterEnableButton:SetPoint("TOPLEFT", spotterConfigFrame, "TOPLEFT", 4, -4)
|
|
spotterEnableButton:SetChecked(Heimdall_Data.config.spotter.enabled)
|
|
|
|
local spotterEveryoneButton = BasicButton("HeimdallSpotterEveryone", spotterConfigFrame, "Everyone", function()
|
|
Heimdall_Data.config.spotter.everyone = spotterEveryoneButton:GetChecked()
|
|
end)
|
|
spotterEveryoneButton:PutRight(spotterEnableButton)
|
|
spotterEveryoneButton:SetChecked(Heimdall_Data.config.spotter.everyone)
|
|
|
|
local spotterHostileButton = BasicButton("HeimdallSpotterHostile", spotterConfigFrame, "Hostile", function()
|
|
Heimdall_Data.config.spotter.hostile = spotterHostileButton:GetChecked()
|
|
end)
|
|
spotterHostileButton:PutBelow(spotterEnableButton)
|
|
spotterHostileButton:SetChecked(Heimdall_Data.config.spotter.hostile)
|
|
|
|
local spotterAllianceButton = BasicButton("HeimdallSpotterAlliance", spotterConfigFrame, "Alliance", function()
|
|
Heimdall_Data.config.spotter.alliance = spotterAllianceButton:GetChecked()
|
|
end)
|
|
spotterAllianceButton:PutRight(spotterHostileButton)
|
|
spotterAllianceButton:SetChecked(Heimdall_Data.config.spotter.alliance)
|
|
|
|
local spotterStinkyButton = BasicButton("HeimdallSpotterStinky", spotterConfigFrame, "Stinky", function()
|
|
Heimdall_Data.config.spotter.stinky = spotterStinkyButton:GetChecked()
|
|
end)
|
|
spotterStinkyButton:PutBelow(spotterHostileButton)
|
|
spotterStinkyButton:SetChecked(Heimdall_Data.config.spotter.stinky)
|
|
|
|
local spotterThrottleBox = CreateFrame("EditBox", "HeimdallSpotterThrottle", configFrame)
|
|
spotterThrottleBox.text = spotterThrottleBox:CreateFontString(nil, "OVERLAY", "GameFontNormal")
|
|
spotterThrottleBox.text:SetText("Throttle Time")
|
|
spotterThrottleBox.text:SetPoint("TOPLEFT", spotterThrottleBox, "TOPLEFT", 0, 8 + 4)
|
|
spotterThrottleBox:SetNumeric(true)
|
|
spotterThrottleBox:SetSize(128 - 8, 24)
|
|
spotterThrottleBox:SetPoint("LEFT", spotterAllianceButton, "LEFT", 0, -24 - 8 - 4)
|
|
spotterThrottleBox:SetAutoFocus(false)
|
|
spotterThrottleBox:SetFontObject("GameFontNormal")
|
|
spotterThrottleBox:SetText(Heimdall_Data.config.spotter.throttleTime)
|
|
spotterThrottleBox: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
|
|
}
|
|
})
|
|
spotterThrottleBox:SetBackdropColor(0.8, 0.8, 0.8, 1)
|
|
spotterThrottleBox:SetBackdropBorderColor(0.5, 0.5, 0.5, 1)
|
|
spotterThrottleBox:SetScript("OnEnterPressed", function()
|
|
local throttleTime = tonumber(spotterThrottleBox:GetText())
|
|
if throttleTime then
|
|
Heimdall_Data.config.spotter.throttleTime = throttleTime
|
|
end
|
|
end)
|
|
spotterThrottleBox:SetScript("OnEscapePressed", function()
|
|
spotterThrottleBox:ClearFocus()
|
|
end)
|
|
-- ---@type table
|
|
-- local spotterEnableButton = CreateFrame("Button", "HeimdallSpotterEnable", configFrame, "UIPanelButtonTemplate")
|
|
-- spotterEnableButton:SetText("Enable Spotter")
|
|
-- spotterEnableButton:SetSize(100, 30)
|
|
-- spotterEnableButton:SetPoint("TOPLEFT", configFrame, "TOPLEFT", 10, -40)
|
|
-- spotterEnableButton:SetScript("OnClick", function()
|
|
-- print("Button was clicked!")
|
|
-- end)
|
|
--
|
|
-- -- Create a text element
|
|
-- local text = configFrame:CreateFontString(nil, "ARTWORK", "GameFontHighlight")
|
|
-- text:SetText("This is some text in the frame.")
|
|
-- text:SetPoint("TOPLEFT", configFrame, "TOPLEFT", 10, -80)
|
|
--
|
|
-- -- Create a small edit box
|
|
-- local smallEditBox = CreateFrame("EditBox", nil, configFrame)
|
|
-- smallEditBox:SetSize(200, 20)
|
|
-- smallEditBox:SetPoint("TOPLEFT", configFrame, "TOPLEFT", 10, -110)
|
|
-- smallEditBox:SetAutoFocus(false)
|
|
-- smallEditBox:SetFontObject("GameFontNormal")
|
|
-- smallEditBox:SetScript("OnEnterPressed", function()
|
|
-- print("Entered text: " .. smallEditBox:GetText())
|
|
-- end)
|
|
--
|
|
-- -- Create a large edit box
|
|
-- local largeEditBox = CreateFrame("EditBox", nil, configFrame)
|
|
-- largeEditBox:SetSize(280, 100)
|
|
-- largeEditBox:SetPoint("TOP", configFrame, "TOP", 0, -150)
|
|
-- largeEditBox:SetAutoFocus(false)
|
|
-- largeEditBox:SetFontObject("GameFontNormal")
|
|
-- largeEditBox:SetMultiLine(true)
|
|
-- largeEditBox:EnableMouse(true)
|
|
-- largeEditBox:SetMaxLetters(0)
|
|
-- largeEditBox:SetScript("OnEscapePressed", function()
|
|
-- largeEditBox:ClearFocus()
|
|
-- end)
|
|
|
|
configFrame:Show()
|
|
print("Heimdall - Config loaded")
|
|
end
|
|
|
|
SlashCmdList["HEIMDALL_CONFIG"] = function()
|
|
configFrame:Show()
|
|
end
|
|
SLASH_HEIMDALL_CONFIG1 = "/heimdall_config"
|
|
SLASH_HEIMDALL_CONFIG2 = "/hc"
|