]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/menu/xonotic/screenshotlist.qc
Listbox / Picker: Implement item fading in a different way so that it gets influenced...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / menu / xonotic / screenshotlist.qc
index 5801d3be79be77a59e67572f9407c29603dfae15..3482dcc4728ade920a74961d077dc49c8a18dcc5 100644 (file)
@@ -5,7 +5,7 @@ CLASS(XonoticScreenshotList) EXTENDS(XonoticListBox)
        METHOD(XonoticScreenshotList, resizeNotify, void(entity, vector, vector, vector, vector))
        METHOD(XonoticScreenshotList, setSelected, void(entity, float))
        METHOD(XonoticScreenshotList, draw, void(entity))
-       METHOD(XonoticScreenshotList, drawListBoxItem, void(entity, float, vector, float))
+       METHOD(XonoticScreenshotList, drawListBoxItem, void(entity, int, vector, bool, bool))
        METHOD(XonoticScreenshotList, getScreenshots, void(entity))
        METHOD(XonoticScreenshotList, previewScreenshot, void(entity))
        METHOD(XonoticScreenshotList, startScreenshot, void(entity))
@@ -71,7 +71,7 @@ string XonoticScreenshotList_screenshotName(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 getScreenshots_for_ext(entity me, string ext, float subdir)
 {
        string s;
@@ -85,7 +85,7 @@ void getScreenshots_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);
@@ -98,15 +98,15 @@ void getScreenshots_for_ext(entity me, string ext, float subdir)
                        {
                                s = strreplace("/", "^7/", s); // clear colors at the forward slash
                                s = strcat("/", rgb_to_hexcolor(SKINCOLOR_SCREENSHOTLIST_SUBDIR), s); // add a forward slash for sorting, then color
-                               bufstr_add(me.listScreenshot, s, TRUE);
+                               bufstr_add(me.listScreenshot, s, true);
                        }
-                       else { bufstr_add(me.listScreenshot, s, TRUE); }
+                       else { bufstr_add(me.listScreenshot, s, true); }
                }
                search_end(list);
        }
 
        if (subdir)
-               getScreenshots_for_ext(me, ext, FALSE);
+               getScreenshots_for_ext(me, ext, false);
 }
 
 void XonoticScreenshotList_getScreenshots(entity me)
@@ -119,12 +119,12 @@ void XonoticScreenshotList_getScreenshots(entity me)
                me.nItems = 0;
                return;
        }
-       getScreenshots_for_ext(me, ".jpg", TRUE);
-       getScreenshots_for_ext(me, ".tga", TRUE);
-       getScreenshots_for_ext(me, ".png", TRUE);
+       getScreenshots_for_ext(me, ".jpg", true);
+       getScreenshots_for_ext(me, ".tga", true);
+       getScreenshots_for_ext(me, ".png", true);
        me.nItems = buf_getsize(me.listScreenshot);
        if(me.nItems > 0)
-               buf_sort(me.listScreenshot, 128, FALSE);
+               buf_sort(me.listScreenshot, 128, false);
 }
 
 void XonoticScreenshotList_destroy(entity me)
@@ -165,11 +165,16 @@ void XonoticScreenshotList_setSelected(entity me, float i)
        }
 }
 
-void XonoticScreenshotList_drawListBoxItem(entity me, float i, vector absSize, float isSelected)
+void XonoticScreenshotList_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.screenshotName(me,i);
        s = draw_TextShortenToWidth(s, me.columnNameSize, 0, me.realFontSize);