]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/menu/xonotic/demolist.qc
Merge branch 'TimePath/monstersys' into 'master'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / menu / xonotic / demolist.qc
index 9f5909676298fc15dc2e08027bf374d1cbf3afb1..f46ee407b6c82ecc8fa272df54e6eb7df379645c 100644 (file)
@@ -1,9 +1,11 @@
-#ifdef INTERFACE
-CLASS(XonoticDemoList) EXTENDS(XonoticListBox)
+#ifndef DEMOLIST_H
+#define DEMOLIST_H
+#include "listbox.qc"
+CLASS(XonoticDemoList, 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, drawListBoxItem, void(entity, int, vector, bool, bool))
        METHOD(XonoticDemoList, getDemos, void(entity))
        METHOD(XonoticDemoList, startDemo, void(entity))
        METHOD(XonoticDemoList, timeDemo, void(entity))
@@ -24,8 +26,11 @@ CLASS(XonoticDemoList) EXTENDS(XonoticListBox)
        ATTRIB(XonoticDemoList, filterString, string, string_null)
 ENDCLASS(XonoticDemoList)
 
+#ifndef IMPLEMENTATION
+// public:
 entity demolist; // for reference elsewhere
 entity makeXonoticDemoList();
+#endif
 void DemoList_Refresh_Click(entity btn, entity me);
 void DemoList_Filter_Change(entity box, entity me);
 #endif
@@ -35,7 +40,7 @@ void DemoList_Filter_Change(entity box, entity me);
 entity makeXonoticDemoList()
 {
        entity me;
-       me = spawnXonoticDemoList();
+       me = NEW(XonoticDemoList);
        me.configureXonoticDemoList(me);
        return me;
 }
@@ -57,7 +62,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 +76,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 +89,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 +110,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 +127,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);