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