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

@ -20,4 +20,30 @@ local colorTbl = {
function gmInte.getColor(name) function gmInte.getColor(name)
return colorTbl[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 end

View File

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