4 CLASS(XonoticCreditsList, XonoticListBox)
5 METHOD(XonoticCreditsList, configureXonoticCreditsList, void(entity))
6 ATTRIB(XonoticCreditsList, rowsPerItem, float, 1)
7 METHOD(XonoticCreditsList, draw, void(entity))
8 METHOD(XonoticCreditsList, drawListBoxItem, void(entity, int, vector, bool, bool))
9 METHOD(XonoticCreditsList, resizeNotify, void(entity, vector, vector, vector, vector))
10 METHOD(XonoticCreditsList, keyDown, float(entity, float, float, float))
11 METHOD(XonoticCreditsList, destroy, void(entity))
12 ATTRIB(XonoticCreditsList, selectionDoesntMatter, bool, true)
14 ATTRIB(XonoticCreditsList, realFontSize, vector, '0 0 0')
15 ATTRIB(XonoticCreditsList, realUpperMargin, float, 0)
16 ATTRIB(XonoticCreditsList, bufferIndex, float, 0)
17 ATTRIB(XonoticCreditsList, scrolling, float, 0)
19 ATTRIB(XonoticCreditsList, alphaBG, float, 0)
20 ENDCLASS(XonoticCreditsList)
21 entity makeXonoticCreditsList();
25 entity makeXonoticCreditsList()
28 me = NEW(XonoticCreditsList);
29 me.configureXonoticCreditsList(me);
32 void XonoticCreditsList_configureXonoticCreditsList(entity me)
34 me.configureXonoticListBox(me);
36 me.bufferIndex = buf_load(language_filename("xonotic-credits.txt"));
37 me.nItems = buf_getsize(me.bufferIndex);
39 void XonoticCreditsList_destroy(entity me)
41 buf_del(me.bufferIndex);
43 void XonoticCreditsList_draw(entity me)
47 me.scrollPos = bound(0, (time - me.scrolling) * me.itemHeight, me.nItems * me.itemHeight - 1);
48 me.scrollPosTarget = me.scrollPos;
50 SUPER(XonoticCreditsList).draw(me);
52 void XonoticCreditsList_resizeNotify(entity me, vector relOrigin, vector relSize, vector absOrigin, vector absSize)
54 SUPER(XonoticCreditsList).resizeNotify(me, relOrigin, relSize, absOrigin, absSize);
56 me.realFontSize_y = me.fontSize / (absSize.y * me.itemHeight);
57 me.realFontSize_x = me.fontSize / (absSize.x * (1 - me.controlWidth));
58 me.realUpperMargin = 0.5 * (1 - me.realFontSize.y);
60 void XonoticCreditsList_drawListBoxItem(entity me, int i, vector absSize, bool isSelected, bool isFocused)
62 // layout: Ping, Credits name, Map name, NP, TP, MP
67 s = bufstr_get(me.bufferIndex, i);
69 if(substring(s, 0, 2) == "**")
71 s = substring(s, 2, strlen(s) - 2);
72 theColor = SKINCOLOR_CREDITS_TITLE;
73 theAlpha = SKINALPHA_CREDITS_TITLE;
75 else if(substring(s, 0, 1) == "*")
77 s = substring(s, 1, strlen(s) - 1);
78 theColor = SKINCOLOR_CREDITS_FUNCTION;
79 theAlpha = SKINALPHA_CREDITS_FUNCTION;
83 theColor = SKINCOLOR_CREDITS_PERSON;
84 theAlpha = SKINALPHA_CREDITS_PERSON;
87 draw_CenterText(me.realUpperMargin * eY + 0.5 * eX, s, me.realFontSize, theColor, theAlpha, 0);
90 float XonoticCreditsList_keyDown(entity me, float key, float ascii, float shift)
93 return SUPER(XonoticCreditsList).keyDown(me, key, ascii, shift);