Skip to content

Commit

Permalink
style: cool little white icons
Browse files Browse the repository at this point in the history
  • Loading branch information
googer committed Jan 11, 2025
1 parent 0126969 commit 435cbb7
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 16 deletions.
28 changes: 24 additions & 4 deletions lua/menu/gwater2_params.lua
Original file line number Diff line number Diff line change
Expand Up @@ -215,18 +215,20 @@ local performance = {

slider:SetValue(gwater2.solver:GetMaxParticles())
local panel = slider:GetParent()
local button = panel:Add("DButton")
local button = panel:Add("DImageButton")
button:Dock(RIGHT)
button:SetText("")
button:SetImage("icon16/accept.png")
button:SetWide(button:GetTall())
button:SizeToContents()
button:SetKeepAspect(true)
button:SetStretchToFit(false)
button.Paint = nil
panel.button_apply = button
function button:DoClick()
local frame = styling.create_blocking_frame()
frame:SetSize(600, 300)
frame:Center()
frame:SetScreenLock(false)
frame:ShowCloseButton(false)

local label = frame:Add("DLabel")
label:Dock(TOP)
Expand All @@ -253,7 +255,9 @@ local performance = {
local confirm = vgui.Create("DImageButton", buttons)
confirm:SetPos(600 * (3/4) - 10, 0)
confirm:SetSize(20, 20)
confirm:SetImage("icon16/accept.png")
confirm:SetText("5")
confirm:SetFont("GWater2TextMono")
confirm:SetKeepAspect(true)
confirm.Paint = nil
function confirm:DoClick()
gwater2.solver:Destroy()
Expand All @@ -266,9 +270,25 @@ local performance = {
_util.emit_sound("select_ok")
end

confirm:SetEnabled(false)
confirm:SetColor(Color(255, 255, 255))
for i=1, 4 do
timer.Simple(i, function()
if not IsValid(confirm) then return end
confirm:SetText(tostring(5-i))
end)
end
timer.Simple(5, function()
if not IsValid(confirm) then return end
confirm:SetImage("icon16/accept.png")
confirm:SetText("")
confirm:SetEnabled(true)
end)

local deny = vgui.Create("DImageButton", buttons)
deny:SetPos(600 * (1/4) - 10, 0)
deny:SetSize(20, 20)
deny:SetKeepAspect(true)
deny:SetImage("icon16/cross.png")
deny.Paint = nil
function deny:DoClick()
Expand Down
37 changes: 25 additions & 12 deletions lua/menu/gwater2_util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -279,12 +279,13 @@ local function make_parameter_scratch(tab, locale_parameter_name, parameter_name
-- if we can't get parameter, let's hope .setup() does that for us
slider:SetDecimals(parameter.decimals)

local button = panel:Add("DButton")
local button = panel:Add("DImageButton")
panel.button = button
button:SetText("")
button:SetImage("icon16/arrow_refresh.png")
button:SetWide(button:GetTall())
button:Dock(RIGHT)
button:SetImage("gwater2/icons/reset.png")
button:SizeToContents()
button:SetKeepAspect(true)
button:SetStretchToFit(false)
button.Paint = nil
button.DoClick = slider_functions.reset

Expand All @@ -299,6 +300,8 @@ local function make_parameter_scratch(tab, locale_parameter_name, parameter_name
-- call custom setup function
if parameter.setup then parameter.setup(slider) end

if panel.label.fancycolor then button:SetColor(panel.label.fancycolor) end

gwater2.options.initialised[parameter_id] = {parameter, slider}

button.DoClick = slider_functions.reset
Expand Down Expand Up @@ -361,17 +364,22 @@ local function make_parameter_color(tab, locale_parameter_name, parameter_name,
mixer:SetWangs(true)
-- mixer:SetColor(gwater2.parameters[parameter_id])

local button = panel:Add("DButton")
local button = panel:Add("DImageButton")
panel.button = button
button:Dock(RIGHT)
button:SetText("")
button:SetImage("icon16/arrow_refresh.png")
button:SetWide(button:GetTall())
button:SetImage("gwater2/icons/reset.png")
button:SizeToContents()
button:SetKeepAspect(true)
button:SetStretchToFit(false)
button.Paint = nil
button.DoClick = color_functions.reset

panel:SizeToContents()

if parameter.setup then parameter.setup(mixer) end

if panel.label.fancycolor then button:SetColor(panel.label.fancycolor) end

gwater2.options.initialised[parameter_id] = {parameter, mixer}

-- TODO: find something to reset editing to false when user stops editing color
Expand Down Expand Up @@ -407,13 +415,15 @@ local function make_parameter_check(tab, locale_parameter_name, parameter_name,
check:Dock(FILL)
check:DockMargin(5, 0, 5, 0)
check:SetText("")
local button = panel:Add("DButton")
local button = panel:Add("DImageButton")
panel.button = button
button:Dock(RIGHT)
button:SetText("")
button:SetImage("icon16/arrow_refresh.png")
button:SetWide(button:GetTall())
button:SetImage("gwater2/icons/reset.png")
button:SizeToContents()
button:SetKeepAspect(true)
button:SetStretchToFit(false)
button.Paint = nil
button.DoClick = check_functions.reset

local parameter_id = string.lower(parameter_name):gsub(" ", "_")
panel.parameter = parameter_id
Expand All @@ -423,6 +433,9 @@ local function make_parameter_check(tab, locale_parameter_name, parameter_name,
pcall(check_functions.init_setvalue, panel)
-- if we can't get parameter, let's hope .setup() does that for us
if parameter.setup then parameter.setup(check) end

if panel.label.fancycolor then button:SetColor(panel.label.fancycolor) end

gwater2.options.initialised[parameter_id] = {parameter, check}

button.DoClick = check_functions.reset
Expand Down
Binary file added materials/gwater2/icons/reset.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 435cbb7

Please sign in to comment.