Add other text fields for spotter config

This commit is contained in:
2025-01-06 22:30:07 +01:00
parent 2dabe7959f
commit f5a4b49935

View File

@@ -336,8 +336,8 @@ function shared.Config.Init()
---@param name string ---@param name string
---@param parent Frame ---@param parent Frame
---@param text string ---@param text string
---@param onDone fun(text: string) ---@param onDone fun(editBox: Frame)
local function CreateBasicSmallEditBox(name, parent, text, onDone) local function CreateBasicSmallEditBox(name, parent, text, initialValue, onDone)
local container = GridFrame.new(name, parent, 1, 1) local container = GridFrame.new(name, parent, 1, 1)
local editBox = CreateFrame("EditBox", name .. "EditBox", container.frame) local editBox = CreateFrame("EditBox", name .. "EditBox", container.frame)
local editBoxtext = editBox:CreateFontString(nil, "OVERLAY", "GameFontNormal") local editBoxtext = editBox:CreateFontString(nil, "OVERLAY", "GameFontNormal")
@@ -351,7 +351,7 @@ function shared.Config.Init()
edgeFile = "Interface/Tooltips/UI-Tooltip-Border", edgeFile = "Interface/Tooltips/UI-Tooltip-Border",
tile = true, tile = true,
tileSize = 2, tileSize = 2,
edgeSize = 2, edgeSize = 12,
insets = { insets = {
left = 2, left = 2,
right = 2, right = 2,
@@ -361,15 +361,10 @@ function shared.Config.Init()
}) })
editBox:SetBackdropColor(0.8, 0.8, 0.8, 1) editBox:SetBackdropColor(0.8, 0.8, 0.8, 1)
editBox:SetBackdropBorderColor(0.5, 0.5, 0.5, 1) editBox:SetBackdropBorderColor(0.5, 0.5, 0.5, 1)
editBox:SetScript("OnEnterPressed", function() editBox:SetScript("OnEnterPressed", function() editBox:ClearFocus() end)
onDone(editBox:GetText()) editBox:SetScript("OnEscapePressed", function() editBox:ClearFocus() end)
end) editBox:SetScript("OnEditFocusLost", function() onDone(editBox) end)
editBox:SetScript("OnEscapePressed", function() editBox:SetText(initialValue)
editBox:ClearFocus()
end)
editBox:SetScript("OnEditFocusLost", function()
onDone(editBox:GetText())
end)
container:Add(editBoxtext, 1, 1) container:Add(editBoxtext, 1, 1)
container:Add(editBox, 2, 1) container:Add(editBox, 2, 1)
-- I don't understand why this hack is necessary -- I don't understand why this hack is necessary
@@ -388,7 +383,7 @@ function shared.Config.Init()
do do
local spotterConfigFrame = GridFrame.new("HeimdallSpotterConfig", local spotterConfigFrame = GridFrame.new("HeimdallSpotterConfig",
UIParent, 12, 20) UIParent, 12, 20)
configFrame:Add(spotterConfigFrame, 6, 3) configFrame:Add(spotterConfigFrame, 5, 3)
local title = spotterConfigFrame.frame:CreateFontString(nil, "ARTWORK", "GameFontNormal") local title = spotterConfigFrame.frame:CreateFontString(nil, "ARTWORK", "GameFontNormal")
title:SetText("Spotter") title:SetText("Spotter")
@@ -434,15 +429,49 @@ function shared.Config.Init()
stinkyButton:UpdateColor(Heimdall_Data.config.spotter.stinky) stinkyButton:UpdateColor(Heimdall_Data.config.spotter.stinky)
spotterConfigFrame:Add(stinkyButton, 1, 4) spotterConfigFrame:Add(stinkyButton, 1, 4)
local notifyChannel = CreateBasicSmallEditBox("HeimdallSpotterConfigTestEditBox", local notifyChannel = CreateBasicSmallEditBox("HeimdallSpotterConfigNotifyChannel",
spotterConfigFrame.frame, "Notify Channel", function(text) spotterConfigFrame.frame, "Notify Channel",
Heimdall_Data.config.spotter.notifyChannel,
function(self)
local text = self:GetText()
if string.match(text, "%S+") then if string.match(text, "%S+") then
Heimdall_Data.config.spotter.notifyChannel = text Heimdall_Data.config.spotter.notifyChannel = text
print("Notify channel set to", tostring(text))
else else
print("Invalid channel name", tostring(text)) print("Invalid channel name", tostring(text))
self:SetText(Heimdall_Data.config.spotter.notifyChannel)
end end
end) end)
spotterConfigFrame:Add(notifyChannel, 2, 4) spotterConfigFrame:Add(notifyChannel, 2, 4)
local zoneOverride = CreateBasicSmallEditBox("HeimdallSpotterConfigZoneOverride",
spotterConfigFrame.frame, "Zone Override",
Heimdall_Data.config.spotter.zoneOverride,
function(self)
local text = self:GetText()
if string.match(text, "%S+") then
Heimdall_Data.config.spotter.zoneOverride = text
print("Zone override set to", tostring(text))
else
print("Invalid zone override", tostring(text))
self:SetText(Heimdall_Data.config.spotter.zoneOverride)
end
end)
spotterConfigFrame:Add(zoneOverride, 2, 4)
local throttleTime = CreateBasicSmallEditBox("HeimdallSpotterConfigThrottleTime",
spotterConfigFrame.frame, "Throttle Time",
Heimdall_Data.config.spotter.throttleTime,
function(self)
local text = self:GetText()
if string.match(text, "%d+") then
Heimdall_Data.config.spotter.throttleTime = tonumber(text)
else
print("Invalid throttle time", tostring(text))
self:SetText(Heimdall_Data.config.spotter.throttleTime)
end
end)
spotterConfigFrame:Add(throttleTime, 2, 4)
end end
--local spotterEveryoneButton = BasicButton("HeimdallSpotterEveryone", spotterConfigFrame, "Everyone", function(state) --local spotterEveryoneButton = BasicButton("HeimdallSpotterEveryone", spotterConfigFrame, "Everyone", function(state)