A numeric stepper (fl_counter): a value with a button above it to increase it, a button below it to decrease it and an optional title. Set the allowed range with set_min_max and the current value with set_value, read it with get_value, and override on_click to react to a change or to reject it by returning false. The character creation uses it to pick the skin of the model. Derives from fl_base_panel.

Summary

Methods

Disables the increase button while the value is at the maximum and the decrease button while it is at the minimum, and enables them otherwise.
Decreases the value by one, clamped to the configured range.
Returns the current value of the counter.
Increases the value by one, clamped to the configured range.
Init()client
Creates the title label and the increase and decrease buttons.
Called before the value changes when one of the buttons is clicked.
Draws the current value in the middle of the counter.
Positions the label and both buttons and refreshes the enabled state of the buttons.
Called after a button click has changed the value.
Sets the color of the title and the value.
Sets the font of the title and the value.
Sets the highest value the counter can reach.
Sets the lowest value the counter can reach.
Sets both the lowest and the highest value the counter can reach.
Sets the title shown above the counter.
Sets the current value.

Methods

Disables the increase button while the value is at the maximum and the decrease button while it is at the minimum, and enables them otherwise.

Decreases the value by one, clamped to the configured range. Calls on_click first and leaves the value unchanged if it returns false; calls post_click afterward.

Returns the current value of the counter.

Returns

  • Number

Increases the value by one, clamped to the configured range. Calls on_click first and leaves the value unchanged if it returns false; calls post_click afterward.

Creates the title label and the increase and decrease buttons.

PANEL:on_click(_value)

client packages/active_ui/views/base/cl_counter.lua:196

Called before the value changes when one of the buttons is clicked. Does nothing by default; override it to react to the change, and return false from it to reject the change.

self.skin.on_click = function(panel, value)
  surface.PlaySound('buttons/blip1.wav')

  self.model.Entity:SetSkin(value - 1)
end

Parameters

  • _value Number the value about to be set; the old value is passed as a second argument

Draws the current value in the middle of the counter.

Parameters

  • w Number panel width
  • h Number panel height

PANEL:PerformLayout(w, h)

client packages/active_ui/views/base/cl_counter.lua:49

Positions the label and both buttons and refreshes the enabled state of the buttons.

Parameters

  • w Number panel width
  • h Number panel height

Called after a button click has changed the value. Does nothing by default; meant to be overridden.

PANEL:set_color(color)

client packages/active_ui/views/base/cl_counter.lua:126

Sets the color of the title and the value.

Parameters

  • color Color

Sets the font of the title and the value.

Parameters

  • font String font name

Sets the highest value the counter can reach.

Parameters

  • max Number

Sets the lowest value the counter can reach.

Parameters

  • min Number

PANEL:set_min_max(min, max)

client packages/active_ui/views/base/cl_counter.lua:103

Sets both the lowest and the highest value the counter can reach.

Parameters

  • min Number
  • max Number

Sets the title shown above the counter.

Parameters

  • text String

PANEL:set_value(value)

client packages/active_ui/views/base/cl_counter.lua:111

Sets the current value. The value is not clamped and on_click is not called.

Parameters

  • value Number

Defined in