2 CLASS(NexuizCreditsList) EXTENDS(NexuizListBox)
3 METHOD(NexuizCreditsList, configureNexuizCreditsList, void(entity))
4 ATTRIB(NexuizCreditsList, rowsPerItem, float, 1)
5 METHOD(NexuizCreditsList, draw, void(entity))
6 METHOD(NexuizCreditsList, drawListBoxItem, void(entity, float, vector, float))
7 METHOD(NexuizCreditsList, resizeNotify, void(entity, vector, vector, vector, vector))
8 METHOD(NexuizCreditsList, keyDown, float(entity, float, float, float))
10 ATTRIB(NexuizCreditsList, realFontSize, vector, '0 0 0')
11 ATTRIB(NexuizCreditsList, realUpperMargin, float, 0)
12 ATTRIB(NexuizCreditsList, bufferIndex, float, 0)
13 ATTRIB(NexuizCreditsList, scrolling, float, 0)
14 ENDCLASS(NexuizCreditsList)
15 entity makeNexuizCreditsList();
19 float SLIST_FIELD_CNAME;
20 float SLIST_FIELD_PING;
21 float SLIST_FIELD_GAME;
22 float SLIST_FIELD_MOD;
23 float SLIST_FIELD_MAP;
24 float SLIST_FIELD_NAME;
25 float SLIST_FIELD_MAXPLAYERS;
26 float SLIST_FIELD_NUMPLAYERS;
27 float SLIST_FIELD_NUMHUMANS;
28 float SLIST_FIELD_NUMBOTS;
29 float SLIST_FIELD_PROTOCOL;
30 float SLIST_FIELD_FREESLOTS;
31 void CreditsList_UpdateFieldIDs()
33 SLIST_FIELD_CNAME = gethostcacheindexforkey( "cname" );
34 SLIST_FIELD_PING = gethostcacheindexforkey( "ping" );
35 SLIST_FIELD_GAME = gethostcacheindexforkey( "game" );
36 SLIST_FIELD_MOD = gethostcacheindexforkey( "mod" );
37 SLIST_FIELD_MAP = gethostcacheindexforkey( "map" );
38 SLIST_FIELD_NAME = gethostcacheindexforkey( "name" );
39 SLIST_FIELD_MAXPLAYERS = gethostcacheindexforkey( "maxplayers" );
40 SLIST_FIELD_NUMPLAYERS = gethostcacheindexforkey( "numplayers" );
41 SLIST_FIELD_NUMHUMANS = gethostcacheindexforkey( "numhumans" );
42 SLIST_FIELD_NUMBOTS = gethostcacheindexforkey( "numbots" );
43 SLIST_FIELD_PROTOCOL = gethostcacheindexforkey( "protocol" );
44 SLIST_FIELD_FREESLOTS = gethostcacheindexforkey( "freeslots" );
47 entity makeNexuizCreditsList()
50 me = spawnNexuizCreditsList();
51 me.configureNexuizCreditsList(me);
54 void configureNexuizCreditsListNexuizCreditsList(entity me)
56 me.configureNexuizListBox(me);
58 me.bufferIndex = buf_load("nexuiz-credits.txt");
59 me.nItems = buf_getsize(me.bufferIndex);
61 void drawNexuizCreditsList(entity me)
64 if(me.scrolling && time > me.scrolling)
66 me.scrollPos = min(me.scrollPos + frametime * me.itemHeight, me.nItems * me.itemHeight - 1);
67 i = min(me.selectedItem, floor((me.scrollPos + 1) / me.itemHeight - 1));
68 i = max(i, ceil(me.scrollPos / me.itemHeight));
69 me.setSelected(me, i);
73 void resizeNotifyNexuizCreditsList(entity me, vector relOrigin, vector relSize, vector absOrigin, vector absSize)
75 resizeNotifyNexuizListBox(me, relOrigin, relSize, absOrigin, absSize);
77 me.realFontSize_y = me.fontSize / (absSize_y * me.itemHeight);
78 me.realFontSize_x = me.fontSize / (absSize_x * (1 - me.controlWidth));
79 me.realUpperMargin = 0.5 * (1 - me.realFontSize_y);
81 void drawListBoxItemNexuizCreditsList(entity me, float i, vector absSize, float isSelected)
83 // layout: Ping, Credits name, Map name, NP, TP, MP
88 s = bufstr_get(me.bufferIndex, i);
90 if(substring(s, 0, 2) == "**")
92 s = substring(s, 2, strlen(s) - 2);
93 theColor = SKINCOLOR_CREDITS_TITLE;
94 theAlpha = SKINALPHA_CREDITS_TITLE;
96 else if(substring(s, 0, 1) == "*")
98 s = substring(s, 1, strlen(s) - 1);
99 theColor = SKINCOLOR_CREDITS_FUNCTION;
100 theAlpha = SKINALPHA_CREDITS_FUNCTION;
104 theColor = SKINCOLOR_CREDITS_PERSON;
105 theAlpha = SKINALPHA_CREDITS_PERSON;
108 draw_CenterText(me.realUpperMargin * eY + 0.5 * eX, s, me.realFontSize, theColor, theAlpha, 0);
111 float keyDownNexuizCreditsList(entity me, float scan, float ascii, float shift)
114 me.dragScrollTimer = 0;
118 me.scrollPos = max(me.scrollPos - 0.5, 0);
119 else if(scan == K_PGDN)
120 me.scrollPos = min(me.scrollPos + 0.5, me.nItems * me.itemHeight - 1);
121 else if(scan == K_UPARROW)
122 me.scrollPos = max(me.scrollPos - me.itemHeight, 0);
123 else if(scan == K_DOWNARROW)
124 me.scrollPos = min(me.scrollPos + me.itemHeight, me.nItems * me.itemHeight - 1);
126 return keyDownListBox(me, scan, ascii, shift);
128 i = min(me.selectedItem, floor((me.scrollPos + 1) / me.itemHeight - 1));
129 i = max(i, ceil(me.scrollPos / me.itemHeight));
130 me.setSelected(me, i);