Skip to content
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

Merged

Conversation

RubisetCie
Copy link
Contributor

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.

Comment on lines 68 to 87
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 )
Copy link
Collaborator

@robotboy655 robotboy655 Jan 24, 2025

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.

Copy link
Contributor Author

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.

Copy link
Collaborator

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?

Copy link
Contributor Author

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.

Copy link
Collaborator

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.

Copy link
Collaborator

@robotboy655 robotboy655 Jan 24, 2025

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:

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" ] )

Copy link
Contributor Author

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.

@robotboy655 robotboy655 added the Enhancement The pull request enhances current functionality. label Jan 24, 2025
Remove unnecessary parameter from Panel:NumSlider
Undo unnecessary changes
@robotboy655 robotboy655 merged commit 59f4daa into Facepunch:master Jan 27, 2025
@RubisetCie RubisetCie deleted the dedeprecation-update-followup branch January 29, 2025 12:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement The pull request enhances current functionality.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants