]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/menu/xonotic/demolist.qc
Merge branch 'martin-t/shield' into 'master'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / menu / xonotic / demolist.qc
index 9f5909676298fc15dc2e08027bf374d1cbf3afb1..b527542a5965b1408ed6e299c856ccb414b846df 100644 (file)
@@ -1,41 +1,11 @@
-#ifdef INTERFACE
-CLASS(XonoticDemoList) EXTENDS(XonoticListBox)
-       METHOD(XonoticDemoList, configureXonoticDemoList, void(entity))
-       ATTRIB(XonoticDemoList, rowsPerItem, float, 1)
-       METHOD(XonoticDemoList, resizeNotify, void(entity, vector, vector, vector, vector))
-       METHOD(XonoticDemoList, drawListBoxItem, void(entity, float, vector, float))
-       METHOD(XonoticDemoList, getDemos, void(entity))
-       METHOD(XonoticDemoList, startDemo, void(entity))
-       METHOD(XonoticDemoList, timeDemo, void(entity))
-       METHOD(XonoticDemoList, demoName, string(entity, float))
-       METHOD(XonoticDemoList, doubleClickListBoxItem, void(entity, float, vector))
-       METHOD(XonoticDemoList, keyDown, float(entity, float, float, float))
-       METHOD(XonoticDemoList, destroy, void(entity))
-       METHOD(XonoticDemoList, showNotify, void(entity))
-
-       ATTRIB(XonoticDemoList, listDemo, float, -1)
-       ATTRIB(XonoticDemoList, realFontSize, vector, '0 0 0')
-       ATTRIB(XonoticDemoList, columnNameOrigin, float, 0)
-       ATTRIB(XonoticDemoList, columnNameSize, float, 0)
-       ATTRIB(XonoticDemoList, realUpperMargin, float, 0)
-       ATTRIB(XonoticDemoList, origin, vector, '0 0 0')
-       ATTRIB(XonoticDemoList, itemAbsSize, vector, '0 0 0')
-
-       ATTRIB(XonoticDemoList, filterString, string, string_null)
-ENDCLASS(XonoticDemoList)
-
-entity demolist; // for reference elsewhere
-entity makeXonoticDemoList();
-void DemoList_Refresh_Click(entity btn, entity me);
-void DemoList_Filter_Change(entity box, entity me);
-#endif
-
-#ifdef IMPLEMENTATION
+#include "demolist.qh"
+
+#include "inputbox.qh"
 
 entity makeXonoticDemoList()
 {
        entity me;
-       me = spawnXonoticDemoList();
+       me = NEW(XonoticDemoList);
        me.configureXonoticDemoList(me);
        return me;
 }
@@ -43,7 +13,7 @@ entity makeXonoticDemoList()
 void XonoticDemoList_configureXonoticDemoList(entity me)
 {
        me.configureXonoticListBox(me);
-       me.getDemos(me);
+       me.nItems = 0;
 }
 
 string XonoticDemoList_demoName(entity me, float i)
@@ -57,7 +27,7 @@ string XonoticDemoList_demoName(entity me, float i)
        return s;
 }
 
-// if subdir is TRUE look in subdirectories too (1 level)
+// if subdir is true look in subdirectories too (1 level)
 void getDemos_for_ext(entity me, string ext, float subdir)
 {
        string s;
@@ -71,7 +41,7 @@ void getDemos_for_ext(entity me, string ext, float subdir)
                s=strcat(s, "*", ext);
 
        float list, i, n;
-       list = search_begin(s, FALSE, TRUE);
+       list = search_begin(s, false, true);
        if(list >= 0)
        {
                n = search_getsize(list);
@@ -84,15 +54,15 @@ void getDemos_for_ext(entity me, string ext, float subdir)
                        {
                                s = strreplace("/", "^7/", s); // clear colors at the forward slash
                                s = strcat("/", rgb_to_hexcolor(SKINCOLOR_DEMOLIST_SUBDIR), s); // add a forward slash for sorting, then color
-                               bufstr_add(me.listDemo, s, TRUE);
+                               bufstr_add(me.listDemo, s, true);
                        }
-                       else { bufstr_add(me.listDemo, s, TRUE); }
+                       else { bufstr_add(me.listDemo, s, true); }
                }
                search_end(list);
        }
 
        if (subdir)
-               getDemos_for_ext(me, ext, FALSE);
+               getDemos_for_ext(me, ext, false);
 }
 
 void XonoticDemoList_getDemos(entity me)
@@ -105,10 +75,10 @@ void XonoticDemoList_getDemos(entity me)
                me.nItems = 0;
                return;
        }
-       getDemos_for_ext(me, ".dem", TRUE);
+       getDemos_for_ext(me, ".dem", true);
        me.nItems = buf_getsize(me.listDemo);
        if(me.nItems > 0)
-               buf_sort(me.listDemo, 128, FALSE);
+               buf_sort(me.listDemo, 128, false);
 }
 
 void XonoticDemoList_destroy(entity me)
@@ -122,19 +92,24 @@ void XonoticDemoList_resizeNotify(entity me, vector relOrigin, vector relSize, v
        me.itemAbsSize = '0 0 0';
        SUPER(XonoticDemoList).resizeNotify(me, relOrigin, relSize, absOrigin, absSize);
 
-       me.realFontSize_y = me.fontSize / (me.itemAbsSize_y = (absSize_y * me.itemHeight));
-       me.realFontSize_x = me.fontSize / (me.itemAbsSize_x = (absSize_x * (1 - me.controlWidth)));
-       me.realUpperMargin = 0.5 * (1 - me.realFontSize_y);
+       me.realFontSize_y = me.fontSize / (me.itemAbsSize_y = (absSize.y * me.itemHeight));
+       me.realFontSize_x = me.fontSize / (me.itemAbsSize_x = (absSize.x * (1 - me.controlWidth)));
+       me.realUpperMargin = 0.5 * (1 - me.realFontSize.y);
 
-       me.columnNameOrigin = me.realFontSize_x;
-       me.columnNameSize = 1 - 2 * me.realFontSize_x;
+       me.columnNameOrigin = me.realFontSize.x;
+       me.columnNameSize = 1 - 2 * me.realFontSize.x;
 }
 
-void XonoticDemoList_drawListBoxItem(entity me, float i, vector absSize, float isSelected)
+void XonoticDemoList_drawListBoxItem(entity me, int i, vector absSize, bool isSelected, bool isFocused)
 {
        string s;
        if(isSelected)
                draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_SELECTED, SKINALPHA_LISTBOX_SELECTED);
+       else if(isFocused)
+       {
+               me.focusedItemAlpha = getFadedAlpha(me.focusedItemAlpha, SKINALPHA_LISTBOX_FOCUSED, SKINFADEALPHA_LISTBOX_FOCUSED);
+               draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_FOCUSED, me.focusedItemAlpha);
+       }
 
        s = me.demoName(me,i);
        s = draw_TextShortenToWidth(s, me.columnNameSize, 0, me.realFontSize);
@@ -222,5 +197,3 @@ float XonoticDemoList_keyDown(entity me, float scan, float ascii, float shift)
                return SUPER(XonoticDemoList).keyDown(me, scan, ascii, shift);
        }
 }
-#endif
-