2 CLASS(NexuizPlayerList) EXTENDS(NexuizListBox)
3 ATTRIB(NexuizPlayerList, rowsPerItem, float, 1)
4 METHOD(NexuizPlayerList, resizeNotify, void(entity, vector, vector, vector, vector))
5 METHOD(NexuizPlayerList, drawListBoxItem, void(entity, float, vector, float))
6 ATTRIB(NexuizPlayerList, realFontSize, vector, '0 0 0')
7 ATTRIB(NexuizPlayerList, columnNameOrigin, float, 0)
8 ATTRIB(NexuizPlayerList, columnNameSize, float, 0)
9 ATTRIB(NexuizPlayerList, realUpperMargin, float, 0)
10 ATTRIB(NexuizPlayerList, origin, vector, '0 0 0')
11 ATTRIB(NexuizPlayerList, itemAbsSize, vector, '0 0 0')
12 METHOD(NexuizPlayerList, setPlayerList, void(entity, string))
13 METHOD(NexuizPlayerList, getPlayerList, string(entity, float, float))
14 ATTRIB(NexuizPlayerList, playerList, float, -1)
15 ENDCLASS(NexuizPlayerList)
16 entity makeNexuizPlayerList();
21 #define PLAYERPARM_SCORE 0
22 #define PLAYERPARM_PING 1
23 #define PLAYERPARM_NAME 2
24 #define PLAYERPARM_COUNT 3
26 entity makeNexuizPlayerList()
29 me = spawnNexuizPlayerList();
30 me.configureNexuizListBox(me);
34 void setPlayerListNexuizPlayerList(entity me, string plist)
36 dprint(plist,"------------\n");
42 me.nItems = tokenizebyseparator(plist, "\n");
43 for(i = 0; i < me.nItems; ++i)
45 bufstr_set(buf, i * PLAYERPARM_COUNT + PLAYERPARM_NAME, argv(i)); // -666 100 "^4Nex ^2Player"
48 for(i = 0; i < me.nItems; ++i)
50 s = bufstr_get(buf, i * PLAYERPARM_COUNT + PLAYERPARM_NAME);
52 bufstr_set(buf, i * PLAYERPARM_COUNT + PLAYERPARM_SCORE, argv(0)); // -666
53 bufstr_set(buf, i * PLAYERPARM_COUNT + PLAYERPARM_PING, argv(1)); // 100
54 bufstr_set(buf, i * PLAYERPARM_COUNT + PLAYERPARM_NAME, argv(2)); // ^4Nex ^2Player
59 string getPlayerListNexuizPlayerList(entity me, float i, float key)
61 return bufstr_get(me.playerList, i * PLAYERPARM_COUNT + key);
64 void resizeNotifyNexuizPlayerList(entity me, vector relOrigin, vector relSize, vector absOrigin, vector absSize)
66 me.origin = absOrigin;
67 me.itemAbsSize = '0 0 0';
68 resizeNotifyNexuizListBox(me, relOrigin, relSize, absOrigin, absSize);
70 me.realFontSize_y = me.fontSize / (me.itemAbsSize_y = (absSize_y * me.itemHeight));
71 me.realFontSize_x = me.fontSize / (me.itemAbsSize_x = (absSize_x * (1 - me.controlWidth)));
72 me.realUpperMargin = 0.5 * (1 - me.realFontSize_y);
74 me.columnNameOrigin = me.realFontSize_x;
75 me.columnNameSize = 1 - 2 * me.realFontSize_x;
78 void drawListBoxItemNexuizPlayerList(entity me, float i, vector absSize, float isSelected)
81 float maxTextLen, textLen;
83 vector theOrigin, theSize, theColor;
88 s = me.getPlayerList(me, i, PLAYERPARM_NAME);
89 maxTextLen = strlen(draw_TextShortenToWidth(strdecolorize(s), 0.95 * me.columnNameSize / me.realFontSize_x, 0));
90 brightness = cvar("r_textbrightness");
91 theOrigin = me.realUpperMargin * eY + (me.columnNameOrigin + 0.00 * (me.columnNameSize - draw_TextWidth(s, 0) * me.realFontSize_x)) * eX ;
92 theSize = me.realFontSize;
96 for(j = 0; j < strlen(s); ++j)
98 ch = substring(s, j, 1);
101 ch2 = substring(s, j+1, 1);
102 if(ch2 == "0" || stof(ch2))// digit?
106 case 0: theColor = '0 0 0'; theAlpha = 1; break;
107 case 1: theColor = '1 0 0'; theAlpha = 1; break;
108 case 2: theColor = '0 1 0'; theAlpha = 1; break;
109 case 3: theColor = '1 1 0'; theAlpha = 1; break;
110 case 4: theColor = '0 0 1'; theAlpha = 1; break;
111 case 5: theColor = '0 1 1'; theAlpha = 1; break;
112 case 6: theColor = '1 0 1'; theAlpha = 1; break;
113 case 7: theColor = '1 1 1'; theAlpha = 1; break;
114 case 8: theColor = '1 1 1'; theAlpha = 0.5; break;
115 case 9: theColor = '0.5 0.5 0.5'; theAlpha = 1; break;
117 theColor = theColor * (1 - brightness) + brightness * '1 1 1';
123 if (textLen < maxTextLen)
125 draw_Text(theOrigin, ch, theSize, theColor, theAlpha, 0);
126 theOrigin += eX * draw_TextWidth(ch, 0) * me.realFontSize_x;
131 draw_Text(theOrigin, "...", theSize, theColor, theAlpha, 0);