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
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.
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
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.
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
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
Sets the current value. The value is not clamped and on_click is not called.
Parameters
- value Number