d64a990d23475360fae077c0ad7adb608e21ee12
[xonotic/xonotic-data.pk3dir.git] / qcsrc / menu / xonotic / slider_sbfadetime.qc
1 #ifndef SLIDER_SBFADETIME_H
2 #define SLIDER_SBFADETIME_H
3 #include "textslider.qc"
4 CLASS(XonoticScoreboardFadeTimeSlider, XonoticTextSlider)
5         METHOD(XonoticScoreboardFadeTimeSlider, configureXonoticScoreboardFadeTimeSlider, void(entity));
6         METHOD(XonoticScoreboardFadeTimeSlider, loadCvars, void(entity));
7         METHOD(XonoticScoreboardFadeTimeSlider, saveCvars, void(entity));
8 ENDCLASS(XonoticScoreboardFadeTimeSlider)
9 entity makeXonoticScoreboardFadeTimeSlider();
10 #endif
11
12 #ifdef IMPLEMENTATION
13 entity makeXonoticScoreboardFadeTimeSlider()
14 {
15         entity me;
16         me = NEW(XonoticScoreboardFadeTimeSlider);
17         me.configureXonoticScoreboardFadeTimeSlider(me);
18         return me;
19 }
20 void XonoticScoreboardFadeTimeSlider_configureXonoticScoreboardFadeTimeSlider(entity me)
21 {
22         me.configureXonoticTextSlider(me, "scoreboard_fadeinspeed");
23         me.addValue(me, ZCTX(_("PART^Slow")),     "5 2.5");
24         me.addValue(me, ZCTX(_("PART^Normal")),   "10 5");
25         me.addValue(me, ZCTX(_("PART^Fast")),     "15 7.5");
26         me.addValue(me, ZCTX(_("PART^Instant")),  "0 0");
27         me.configureXonoticTextSliderValues(me);
28 }
29 void XonoticScoreboardFadeTimeSlider_loadCvars(entity me)
30 {
31         me.setValueFromIdentifier(me, sprintf("%s %s",
32                 cvar_string("scoreboard_fadeinspeed"),
33                 cvar_string("scoreboard_fadeoutspeed")
34         ));
35 }
36 void XonoticScoreboardFadeTimeSlider_saveCvars(entity me)
37 {
38         if(me.value >= 0 || me.value < me.nValues)
39         {
40                 tokenize_console(me.getIdentifier(me));
41                 cvar_set("scoreboard_fadeinspeed", argv(0));
42                 cvar_set("scoreboard_fadeoutspeed", argv(1));
43         }
44 }
45 #endif