Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
slider.qh File Reference
#include "label.qh"
#include "../anim/animation.qh"
Include dependency graph for slider.qh:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  Slider

Functions

string formatStringSpecial (string, float, int)

Function Documentation

◆ formatStringSpecial()

string formatStringSpecial ( string formatStr,
float value,
int decs )

Definition at line 6 of file slider.qc.

7{
8 /* .formatString is usually in the format of "%sx" to print "2" as "2x".
9 * Special options:
10 * "%": apply ftos_decimals_percentage
11 * Any of "smhdwy": apply time-counting functions
12 * Any of "SMHDWY": apply time-counting functions, allowing decimals
13 */
14 if (strlen(formatStr) == 1)
15 switch (formatStr)
16 {
17 case "%": return ftos_decimals_percentage(value, max(0, decs - 2));
18 case "s": return count_seconds(value);
19 case "m": return count_minutes(value);
20 case "h": return count_hours(value);
21 case "d": return count_days(value);
22 case "w": return count_weeks(value);
23 case "y": return count_years(value);
24 case "S": return count_seconds_decs(value, decs);
25 case "M": return count_minutes_decs(value, decs);
26 case "H": return count_hours_decs(value, decs);
27 case "D": return count_days_decs(value, decs);
28 case "W": return count_weeks_decs(value, decs);
29 case "Y": return count_years_decs(value, decs);
30 default: break;
31 }
32 const string txt = ftos_decimals(value, decs);
33 if (formatStr != "")
34 return sprintf(formatStr, txt);
35 return txt;
36}
#define count_minutes_decs(time, decs)
Definition counting.qh:46
#define count_days_decs(time, decs)
Definition counting.qh:27
#define count_weeks(time)
Definition counting.qh:19
#define count_hours(time)
Definition counting.qh:37
#define count_years_decs(time, decs)
Definition counting.qh:9
#define count_days(time)
Definition counting.qh:28
#define count_weeks_decs(time, decs)
Definition counting.qh:18
#define count_seconds_decs(time, decs)
Definition counting.qh:55
#define count_years(time)
Definition counting.qh:10
#define count_seconds(time)
Definition counting.qh:56
#define count_hours_decs(time, decs)
Definition counting.qh:36
#define count_minutes(time)
Definition counting.qh:47
#define strlen
float max(float f,...)
ERASEABLE string ftos_decimals(float number, int decimals)
converts a number to a string with the indicated number of decimals
Definition string.qh:469
ERASEABLE string ftos_decimals_percentage(float number, int decimals)
converts a percentage to a string with the indicated number of decimals
Definition string.qh:480

References count_days, count_days_decs, count_hours, count_hours_decs, count_minutes, count_minutes_decs, count_seconds, count_seconds_decs, count_weeks, count_weeks_decs, count_years, count_years_decs, ftos_decimals(), ftos_decimals_percentage(), max(), and strlen.

Referenced by MixedSlider_rangedIdentifierToText(), and Slider_valueToText().