-#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;
}
void XonoticDemoList_configureXonoticDemoList(entity me)
{
me.configureXonoticListBox(me);
- me.getDemos(me);
+ me.nItems = 0;
}
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;
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);
{
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)
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)
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);
return SUPER(XonoticDemoList).keyDown(me, scan, ascii, shift);
}
}
-#endif
-