add: better color menu

This commit is contained in:
Linventif 2024-03-31 15:50:04 +02:00
parent 40ee52e41b
commit d2a86b2182
No known key found for this signature in database
GPG Key ID: FAC0CA60F9AEEC24
2 changed files with 31 additions and 21 deletions

View File

@ -21,3 +21,29 @@ local colorTbl = {
function gmInte.getColor(name)
return colorTbl[name]
end
function gmInte.applyPaint(element, id)
if (element.DoClick) then
element:SetTextColor(gmInte.getColor("font"))
element.Paint = function(self, w, h)
local color = gmInte.getColor("primary")
if (self:IsHovered()) then
color = gmInte.getColor("primary-active")
end
draw.RoundedBox(0, 0, 0, w, h, color)
end
elseif (element.SetTitle) then
element.Paint = function(self, w, h)
draw.RoundedBox(0, 0, 0, w, h, gmInte.getColor("background"))
// first 20px = title bar = primary
draw.RoundedBox(0, 0, 0, w, 22, gmInte.getColor("primary"))
end
end
end
function gmInte.getFrameName(name)
return "Gmod Integration v" .. gmInte.config.version .. " - " .. name
end

View File

@ -6,9 +6,7 @@ function gmInte.openVerifPopup()
frame:SetDraggable(false)
frame:ShowCloseButton(false)
frame:MakePopup()
frame.Paint = function(self, w, h)
draw.RoundedBox(8, 0, 0, w, h, gmInte.getColor("background"))
end
gmInte.applyPaint(frame)
local messageLabel = vgui.Create("DLabel", frame)
messageLabel:Dock(FILL)
@ -31,15 +29,8 @@ function gmInte.openVerifPopup()
gui.OpenURL("https://verif.gmod-integration.com")
end
button:SetSize(buttonGrid:GetColWide() - 10, buttonGrid:GetRowHeight())
gmInte.applyPaint(button)
buttonGrid:AddItem(button)
button:SetTextColor(Color(255, 255, 255))
button.Paint = function(self, w, h)
local color = gmInte.getColor("primary")
if self:IsHovered() then
color = gmInte.getColor("primary-active")
end
draw.RoundedBox(8, 0, 0, w, h, color)
end
local button = vgui.Create("DButton")
button:SetText("Refresh Verification")
@ -48,18 +39,11 @@ function gmInte.openVerifPopup()
gmInte.SendNet("verifyMe")
frame:Close()
end,
function(err)
LocalPlayer():ChatPrint("Failed to refresh verification: " .. err)
function(code, body)
LocalPlayer():ChatPrint("Failed to refresh verification: " .. code)
end)
end
button:SetSize(buttonGrid:GetColWide() - 10, buttonGrid:GetRowHeight())
gmInte.applyPaint(button)
buttonGrid:AddItem(button)
button:SetTextColor(Color(255, 255, 255))
button.Paint = function(self, w, h)
local color = gmInte.getColor("primary")
if self:IsHovered() then
color = gmInte.getColor("primary-active")
end
draw.RoundedBox(8, 0, 0, w, h, color)
end
end