]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/menu/xonotic/dialog_multiplayer_media_demo.qc
36d9597a7dff38152bfc56ee2b2b9a03ee6e9e66
[xonotic/xonotic-data.pk3dir.git] / qcsrc / menu / xonotic / dialog_multiplayer_media_demo.qc
1 #include "dialog_multiplayer_media_demo.qh"
2 #ifndef DIALOG_MULTIPLAYER_MEDIA_DEMO_H
3 #define DIALOG_MULTIPLAYER_MEDIA_DEMO_H
4 #include "tab.qc"
5 CLASS(XonoticDemoBrowserTab, XonoticTab)
6         METHOD(XonoticDemoBrowserTab, fill, void(entity));
7         ATTRIB(XonoticDemoBrowserTab, intendedWidth, float, 0.9)
8         ATTRIB(XonoticDemoBrowserTab, rows, float, 21)
9         ATTRIB(XonoticDemoBrowserTab, columns, float, 6.5)
10         ATTRIB(XonoticDemoBrowserTab, name, string, "DemoBrowser")
11         ATTRIB(XonoticDemoBrowserTab, democlicktype, float, 0)
12 ENDCLASS(XonoticDemoBrowserTab)
13 entity makeXonoticDemoBrowserTab();
14 #endif
15
16 #ifdef IMPLEMENTATION
17 const float DMO_PLAY = 1;
18 const float DMO_TIME = 2;
19 void DemoConfirm_Check_Gamestatus(entity btn, entity me)
20 {
21         if(!(gamestatus & (GAME_CONNECTED | GAME_ISSERVER))) // we're not in a match, lets watch the demo
22         {
23                 if(btn.democlicktype == DMO_PLAY)
24                         { demolist.startDemo(demolist); }
25                 else if(btn.democlicktype == DMO_TIME)
26                         { demolist.timeDemo(demolist); }
27         }
28         else // already in a match, player has to confirm
29         {
30                 if(btn.democlicktype == DMO_PLAY)
31                         { DialogOpenButton_Click(btn, main.demostartconfirmDialog); }
32                 else if(btn.democlicktype == DMO_TIME)
33                         { DialogOpenButton_Click(btn, main.demotimeconfirmDialog); }
34         }
35 }
36
37 entity makeXonoticDemoBrowserTab()
38 {
39         entity me;
40         me = NEW(XonoticDemoBrowserTab);
41         me.configureDialog(me);
42         return me;
43 }
44 void XonoticDemoBrowserTab_fill(entity me)
45 {
46         entity e;
47         demolist = makeXonoticDemoList();
48
49         me.TR(me);
50                 me.TD(me, 1, 0.6, e = makeXonoticTextLabel(1, _("Filter:")));
51                 me.TD(me, 1, 2.9, e = makeXonoticInputBox(0, string_null));
52                         e.onChange = DemoList_Filter_Change;
53                         e.onChangeEntity = demolist;
54
55         me.gotoRC(me, 0, 3.7);
56                 me.TD(me, 1, 1.5, e = makeXonoticCheckBox(0, "cl_autodemo", _("Auto record demos")));
57                 me.TD(me, 1, 1, e = makeXonoticButton(_("Refresh"), '0 0 0'));
58                         e.onClick = DemoList_Refresh_Click;
59                         e.onClickEntity = demolist;
60
61         me.gotoRC(me, 1.5, 0);
62                 me.TD(me, me.rows - 2.5, me.columns, demolist);
63
64         me.gotoRC(me, me.rows - 1, 0);
65                 me.TD(me, 1, me.columns / 2, e = makeXonoticButton_T(_("Timedemo"), '0 0 0',
66                         _("Benchmark how fast your computer can run the highlighted demo")));
67                         e.democlicktype = DMO_TIME;
68                         e.onClick = DemoConfirm_Check_Gamestatus;
69                         e.onClickEntity = me; // demolist is global anyway
70                 me.TD(me, 1, me.columns / 2, e = makeXonoticButton(ZCTX(_("DEMO^Play")), '0 0 0'));
71                         e.democlicktype = DMO_PLAY;
72                         e.onClick = DemoConfirm_Check_Gamestatus;
73                         e.onClickEntity = me; // demolist is global anyway
74 }
75 #endif