Add hook to set scoreboard row color per player. #1250

Merged
merged 4 commits into from Oct 3, 2016

Projects

None yet

6 participants

@JLVerified
Contributor

Removes the hard-coding and opens it up for easier customization.

@Kefta
Contributor
Kefta commented Sep 29, 2016 edited

The type check isn't really necessary. If someone returns something invalid in the hook, they'll notice the error immediately.

@JLVerified
Contributor

I was trying to maintain consistency, seeing as the function directly above has the same behavior. Should it be removed?

@robotboy655 robotboy655 added the TTT label Sep 29, 2016
@Kefta
Contributor
Kefta commented Sep 30, 2016

You don't need the local function at all; you can just integrate it into the main function

- end
+ local c = RowColorForPlayer(ply)
+
+ surface.SetDrawColor(c.r, c.g, c.b, c.a)
@markusmarkusz
markusmarkusz Sep 30, 2016 edited Contributor

You could use clr(c) here.
But this change wouldn't be necessary.

+ local c = RowColorForPlayer(ply)
+
+ surface.SetDrawColor(c.r, c.g, c.b, c.a)
+ surface.DrawRect(0, 0, self:GetWide(), SB_ROW_HEIGHT)
@fruitwasp
fruitwasp Sep 30, 2016 edited

PANEL.Paint has width and height parameters. Let's use width here.

+
+ return Color(0, 0, 0, 0)
+end
+
function PANEL:Paint()
@fruitwasp
fruitwasp Sep 30, 2016

width and height parameters to use on line 129

+ end
+
+ return Color(0, 0, 0, 0)
+end
@svdm
svdm Oct 2, 2016 Collaborator

This is creating new Color objects for every single row that's rendered. It would be more efficient to create the colors once and just return them in this function. Same as is being done with namecolor right above here.

@svdm svdm merged commit 8c3dcc7 into garrynewman:master Oct 3, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment