]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/menu/xonotic/dialog_multiplayer_media_demo.c
Merge branch 'master' into TimePath/issue-1170
[xonotic/xonotic-data.pk3dir.git] / qcsrc / menu / xonotic / dialog_multiplayer_media_demo.c
index 893178e48c049ff0a3d2cd1a113850c773160928..092355126fe44f3b476934248c309090ebd073fa 100644 (file)
@@ -3,14 +3,35 @@ CLASS(XonoticDemoBrowserTab) EXTENDS(XonoticTab)
        METHOD(XonoticDemoBrowserTab, fill, void(entity))
        ATTRIB(XonoticDemoBrowserTab, title, string, _("Demo"))
        ATTRIB(XonoticDemoBrowserTab, intendedWidth, float, 0.9)
-       ATTRIB(XonoticDemoBrowserTab, rows, float, 20)
-       ATTRIB(XonoticDemoBrowserTab, columns, float, 4)
-       ATTRIB(XonoticDemoBrowserTab, name, string, "DemoBrowser")      
+       ATTRIB(XonoticDemoBrowserTab, rows, float, 21)
+       ATTRIB(XonoticDemoBrowserTab, columns, float, 6.5)
+       ATTRIB(XonoticDemoBrowserTab, name, string, "DemoBrowser")
+       ATTRIB(XonoticDemoBrowserTab, democlicktype, float, 0)
 ENDCLASS(XonoticDemoBrowserTab)
 entity makeXonoticDemoBrowserTab();
+const float DMO_PLAY = 1;
+const float DMO_TIME = 2;
 #endif
 
 #ifdef IMPLEMENTATION
+void DemoConfirm_Check_Gamestatus(entity btn, entity me)
+{
+       if(!(gamestatus & (GAME_CONNECTED | GAME_ISSERVER))) // we're not in a match, lets watch the demo
+       {
+               if(btn.democlicktype == DMO_PLAY)
+                       { demolist.startDemo(demolist); }
+               else if(btn.democlicktype == DMO_TIME)
+                       { demolist.timeDemo(demolist); }
+       }
+       else // already in a match, player has to confirm
+       {
+               if(btn.democlicktype == DMO_PLAY)
+                       { DialogOpenButton_Click(btn, main.demostartconfirmDialog); }
+               else if(btn.democlicktype == DMO_TIME)
+                       { DialogOpenButton_Click(btn, main.demotimeconfirmDialog); }
+       }
+}
+
 entity makeXonoticDemoBrowserTab()
 {
        entity me;
@@ -20,28 +41,33 @@ entity makeXonoticDemoBrowserTab()
 }
 void XonoticDemoBrowserTab_fill(entity me)
 {
-       entity e, dlist;
+       entity e;
+       demolist = makeXonoticDemoList();
 
        me.TR(me);
-               me.TD(me, 1, 4, e = makeXonoticCheckBox(0, "cl_autodemo", _("Automatically record demos while playing")));
-       me.TR(me);
-       me.TR(me);
-               me.TD(me, 1, 0.5, e = makeXonoticTextLabel(0, _("Filter:")));
-               me.TD(me, 1, 3.5, e = makeXonoticInputBox(0, string_null));
-                       dlist = makeXonoticDemoList();
+               me.TD(me, 1, 0.6, e = makeXonoticTextLabel(1, _("Filter:")));
+               me.TD(me, 1, 2.9, e = makeXonoticInputBox(0, string_null));
                        e.onChange = DemoList_Filter_Change;
-                       e.onChangeEntity = dlist;
-                       dlist.controlledTextbox = e;
-                       
-       me.TR(me);
-               me.TD(me, me.rows - 4, me.columns, dlist);
-               
+                       e.onChangeEntity = demolist;
+                       demolist.controlledTextbox = e;
+
+       me.gotoRC(me, 0, 3.7);
+               me.TD(me, 1, 1.5, e = makeXonoticCheckBox(0, "cl_autodemo", _("Auto record demos")));
+               me.TD(me, 1, 1, e = makeXonoticButton(_("Refresh"), '0 0 0'));
+                       e.onClick = DemoList_Refresh_Click;
+                       e.onClickEntity = demolist;
+
+       me.gotoRC(me, 1.5, 0);
+               me.TD(me, me.rows - 2.5, me.columns, demolist);
+
        me.gotoRC(me, me.rows - 1, 0);
                me.TD(me, 1, me.columns / 2, e = makeXonoticButton(_("Timedemo"), '0 0 0'));
-                       e.onClick = TimeDemo_Click;
-                       e.onClickEntity = dlist;
+                       e.democlicktype = DMO_TIME;
+                       e.onClick = DemoConfirm_Check_Gamestatus;
+                       e.onClickEntity = me; // demolist is global anyway
                me.TD(me, 1, me.columns / 2, e = makeXonoticButton(ZCTX(_("DEMO^Play")), '0 0 0'));
-                       e.onClick = StartDemo_Click;
-                       e.onClickEntity = dlist;
+                       e.democlicktype = DMO_PLAY;
+                       e.onClick = DemoConfirm_Check_Gamestatus;
+                       e.onClickEntity = me; // demolist is global anyway
 }
 #endif