Refactor button colorization
This commit is contained in:
@@ -310,7 +310,6 @@ function shared.Config.Init()
|
||||
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",
|
||||
@@ -324,7 +323,10 @@ function shared.Config.Init()
|
||||
bottom = 2
|
||||
}
|
||||
})
|
||||
button:SetBackdropColor(unpack(color))
|
||||
button.UpdateColor = function(self, state)
|
||||
local color = state and buttonColors.enabled or buttonColors.disabled
|
||||
self:SetBackdropColor(unpack(color))
|
||||
end
|
||||
--spotterEnableButton:SetChecked(Heimdall_Data.config.spotter.enabled)
|
||||
local spotterEnableButtonLabel = button:CreateFontString(nil, "OVERLAY", "GameFontNormal")
|
||||
spotterEnableButtonLabel:SetText(text)
|
||||
@@ -396,13 +398,15 @@ function shared.Config.Init()
|
||||
Heimdall_Data.config.spotter.enabled = not Heimdall_Data.config.spotter.enabled
|
||||
return Heimdall_Data.config.spotter.enabled
|
||||
end)
|
||||
spotterConfigFrame:Add(spotterEnableButton, 1, 5)
|
||||
spotterEnableButton:UpdateColor(Heimdall_Data.config.spotter.enabled)
|
||||
spotterConfigFrame:Add(spotterEnableButton, 1, 6)
|
||||
|
||||
local spotterEveryoneButton = BasicButton("HeimdallSpotterConfigEveryoneButton",
|
||||
spotterConfigFrame.frame, "Everyone", function()
|
||||
Heimdall_Data.config.spotter.everyone = not Heimdall_Data.config.spotter.everyone
|
||||
return Heimdall_Data.config.spotter.everyone
|
||||
end)
|
||||
spotterEveryoneButton:UpdateColor(Heimdall_Data.config.spotter.everyone)
|
||||
spotterConfigFrame:Add(spotterEveryoneButton, 1, 6)
|
||||
|
||||
local spotterHostileButton = BasicButton("HeimdallSpotterConfigHostileButton",
|
||||
@@ -410,6 +414,7 @@ function shared.Config.Init()
|
||||
Heimdall_Data.config.spotter.hostile = not Heimdall_Data.config.spotter.hostile
|
||||
return Heimdall_Data.config.spotter.hostile
|
||||
end)
|
||||
spotterHostileButton:UpdateColor(Heimdall_Data.config.spotter.hostile)
|
||||
spotterConfigFrame:Add(spotterHostileButton, 1, 4)
|
||||
|
||||
local spotterAllianceButton = BasicButton("HeimdallSpotterConfigAllianceButton",
|
||||
@@ -417,6 +422,7 @@ function shared.Config.Init()
|
||||
Heimdall_Data.config.spotter.alliance = not Heimdall_Data.config.spotter.alliance
|
||||
return Heimdall_Data.config.spotter.alliance
|
||||
end)
|
||||
spotterAllianceButton:UpdateColor(Heimdall_Data.config.spotter.alliance)
|
||||
spotterConfigFrame:Add(spotterAllianceButton, 1, 4)
|
||||
|
||||
local spotterStinkyButton = BasicButton("HeimdallSpotterConfigStinkyButton",
|
||||
@@ -424,6 +430,7 @@ function shared.Config.Init()
|
||||
Heimdall_Data.config.spotter.stinky = not Heimdall_Data.config.spotter.stinky
|
||||
return Heimdall_Data.config.spotter.stinky
|
||||
end)
|
||||
spotterStinkyButton:UpdateColor(Heimdall_Data.config.spotter.stinky)
|
||||
spotterConfigFrame:Add(spotterStinkyButton, 1, 4)
|
||||
|
||||
local testEditBox = CreateBasicSmallEditBox("HeimdallSpotterConfigTestEditBox",
|
||||
|
||||
Reference in New Issue
Block a user