-
Notifications
You must be signed in to change notification settings - Fork 808
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Updated deprecated CPanel calls (Continuation & Conclusion) #2194
Updated deprecated CPanel calls (Continuation & Conclusion) #2194
Conversation
local params = vgui.Create( "ControlPresets", CPanel ) | ||
local options = {} | ||
options[ "#preset.default" ] = { | ||
pp_colormod_addr = "0", | ||
pp_colormod_addg = "0", | ||
pp_colormod_addb = "0", | ||
pp_colormod_brightness = "0", | ||
pp_colormod_contrast = "1", | ||
pp_colormod_color = "1", | ||
pp_colormod_mulr = "0", | ||
pp_colormod_mulg = "0", | ||
pp_colormod_mulb = "0", | ||
pp_colormod_inv = "0" | ||
} | ||
params:SetPreset( "colormod" ) | ||
params:AddOption( "#preset.default", options[ "#preset.default" ] ) | ||
for k, v in pairs( table.GetKeys( options[ "#preset.default" ] ) ) do | ||
params:AddConVar( v ) | ||
end | ||
CPanel:AddPanel( params ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's up with this? ControlPanel:ToolPresets
exists and used by you yourself in other files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I knew you would titch on that, but I've been reluctant to use "ToolPreset", because I was unsure: the code implemented originally was a little bit different than the one implemented in the "ToolPreset" function, and generally for all the Post-Processing effects, I am under the impression that the presets implementation isn't really the same as the one for the stools.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In what way is the code different? It calls to the same AddControl( "ComboBox", ...
and with the exact same parameters?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no TOOL:BuildConVarList()
, nor dictionary declaring cvars, unlike for tools.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TOOL:BuildConVarList()
just generates a list of cvars based on TOOL.ClientConVar
, it is not called from ControlPanel:ToolPreset()
.
It is done manually for post processing effects, since there's no TOOL.ClientConVar
alternative for post processing effects.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To illustrate the point further, yes, tools also set the CVars variable:
garrysmod/garrysmod/gamemodes/sandbox/entities/weapons/gmod_tool/stools/finger.lua
Line 578 in f8929bd
CPanel:AddControl( "ComboBox", { MenuButton = 1, Folder = "finger", Options = { [ "#preset.default" ] = ConVarsDefault }, CVars = table.GetKeys( ConVarsDefault ) } ) |
As do the PP effects:
params.CVars = table.GetKeys( params.Options[ "#preset.default" ] ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I will make changes.
Remove unnecessary parameter from Panel:NumSlider Undo unnecessary changes
Hello, I hope you're doing well. :)
This is the continuation of my previously merged PR, about refactoring some deprecated code in CPanel: replacing the instances of
AddControl
.The first one was about the Sandbox Stools, this one is about the Post-Processing effects.
Please don't hesitate to give me feedbacks.