14 if (
strlen(formatStr) == 1)
34 return sprintf(formatStr, txt);
42 if (allowAnim && me.animated)
48 me.sliderAnim.update(me.sliderAnim, t, me.sliderValue, val);
52 me.setSliderValue(me, val);
62 return sprintf(
"%d (%s)", me.value, me.valueToText(me, me.value));
66 SUPER(
Slider).resizeNotify(me, relOrigin, relSize, absOrigin, absSize);
67 me.controlWidth = absSize.x == 0 ? 0 : (absSize.y / absSize.x);
73 val *= me.valueDisplayMultiplier;
79 me.valueSpace =
bound(0, theValueSpace, 1);
80 me.keepspaceLeft = 1 - me.valueSpace;
86 me.sliderValue = theValue;
87 me.valueStep = theValueStep;
88 me.valueMin = theValueMin;
89 me.valueMax = theValueMax;
90 me.valueKeyStep = theValueKeyStep;
91 me.valuePageStep = theValuePageStep;
93 if (
fabs(
floor(me.valueStep * 100 + 0.5) - (me.valueStep * 100)) < 0.01)
95 if (
fabs(
floor(me.valueStep * 10 + 0.5) - (me.valueStep * 10)) < 0.01)
97 if (
fabs(
floor(me.valueStep * 1 + 0.5) - (me.valueStep * 1)) < 0.01)
102 if (me.disabled)
return 0;
133 me.applyButton.disabled =
false;
139 if (me.disabled)
return 0;
162 if (me.disabled)
return 0;
167 if (pos.x < 0 - me.tolerance.x) hit = 0;
168 if (pos.y < 0 - me.tolerance.y) hit = 0;
169 if (pos.x >= 1 - me.valueSpace + me.tolerance.x) hit = 0;
170 if (pos.y >= 1 + me.tolerance.y) hit = 0;
176 float f =
bound(0, (pos.x - me.pressOffset - 0.5 * me.controlWidth) / (1 - me.valueSpace - me.controlWidth), 1);
177 v = f * (me.valueMax - me.valueMin) + me.valueMin;
180 if (f > 0 && f < 1 && me.valueStep)
181 v =
floor(0.5 + v / me.valueStep) * me.valueStep;
184 if(me.previousValue != me.value)
185 me.applyButton.disabled =
false;
199 if (pos.x < 0)
return false;
200 if (pos.y < 0)
return false;
201 if (pos.x >= 1 -
this.valueSpace)
return false;
202 if (pos.y >= 1)
return false;
204 if (
fabs(pos.x - controlCenter) <= 0.5 *
this.controlWidth)
213 float clickValue, pageValue, inRange;
214 clickValue =
median(0, (pos.x -
this.pressOffset - 0.5 *
this.controlWidth) / (1 -
this.valueSpace -
this.controlWidth), 1) * (this.
valueMax - this.
valueMin) + this.
valueMin;
216 if (pos.x < controlCenter)
220 pageValue =
max(pageValue, clickValue);
226 pageValue =
min(pageValue, clickValue);
232 if (pageValue == clickValue)
246 if (me.disabled)
return 0;
252 me.focusable = !me.disabled;
258 me.focusable = !me.disabled;
260 if (me.disabled)
draw_alpha *= me.disabledAlpha;
262 if (me.valueMax > me.valueMin)
265 controlLeft = (me.sliderValue - me.valueMin) / (me.valueMax - me.valueMin) * (1 - me.valueSpace - me.controlWidth);
273 if (me.sliderAnim.finished)
276 me.sliderAnim =
NULL;
279 if (me.valueMax > me.valueMin)
280 me.setText(me, me.valueToText(me, me.value));
282 if (me.valueSpace > 0)
float autocvar_menu_animations
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
virtual void mousePress()
#define count_minutes_decs(time, decs)
#define count_days_decs(time, decs)
#define count_weeks(time)
#define count_hours(time)
#define count_years_decs(time, decs)
#define count_weeks_decs(time, decs)
#define count_seconds_decs(time, decs)
#define count_years(time)
#define count_seconds(time)
#define count_hours_decs(time, decs)
#define count_minutes(time)
entity makeHostedEasing(entity obj, void(entity, float) objSetter, float(float, float, float, float) func, float animDuration, float animStartValue, float animEnd)
float easingQuadOut(float tickTime, float animDuration, float animStart, float animDelta)
float Slider_keyDown(entity me, float key, float ascii, float shift)
void Slider_showNotify(entity me)
float Slider_mouseDrag(entity me, vector pos)
void Slider_setValue(entity me, float val, bool allowAnim)
void Slider_setSliderValue(entity me, float val)
string Slider_valueToText(entity me, float val)
float Slider_mouseRelease(entity me, vector pos)
string formatStringSpecial(string formatStr, float value, int decs)
void Slider_configureSliderVisuals(entity me, float sz, float theAlign, float theValueSpace, string gfx)
void Slider_configureSliderValues(entity me, float theValueMin, float theValue, float theValueMax, float theValueStep, float theValueKeyStep, float theValuePageStep)
string Slider_toString(entity me)
float Slider_keyUp(entity me, float key, float ascii, float shift)
void Slider_resizeNotify(entity me, vector relOrigin, vector relSize, vector absOrigin, vector absSize)
void Slider_draw(entity me)
ERASEABLE float median(float a, float b, float c)
ERASEABLE float almost_in_bounds(float a, float b, float c)
strcat(_("^F4Countdown stopped!"), "\n^BG", _("Teams are too unbalanced."))
#define METHOD(cname, name, prototype)
ERASEABLE string ftos_decimals(float number, int decimals)
converts a number to a string with the indicated number of decimals
ERASEABLE string ftos_decimals_percentage(float number, int decimals)
converts a percentage to a string with the indicated number of decimals