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