]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/menu/xonotic/playerlist.qc
Merge branch 'master' into develop
[xonotic/xonotic-data.pk3dir.git] / qcsrc / menu / xonotic / playerlist.qc
index db3ac8a207aae1b99524a3cc11c1aa40adfed1f1..1edc5b8400c8cc6347f5916125ebc34c850e5e0d 100644 (file)
@@ -1,33 +1,12 @@
-#ifndef PLAYERLIST_H
-#define PLAYERLIST_H
-#include "listbox.qc"
-CLASS(XonoticPlayerList, XonoticListBox)
-       ATTRIB(XonoticPlayerList, rowsPerItem, float, 1)
-       METHOD(XonoticPlayerList, resizeNotify, void(entity, vector, vector, vector, vector))
-       METHOD(XonoticPlayerList, drawListBoxItem, void(entity, int, vector, bool, bool))
-       ATTRIB(XonoticPlayerList, allowFocusSound, float, 0)
-       ATTRIB(XonoticPlayerList, realFontSize, vector, '0 0 0')
-       ATTRIB(XonoticPlayerList, columnNameOrigin, float, 0)
-       ATTRIB(XonoticPlayerList, columnNameSize, float, 0)
-       ATTRIB(XonoticPlayerList, columnScoreOrigin, float, 0)
-       ATTRIB(XonoticPlayerList, columnScoreSize, float, 0)
-       ATTRIB(XonoticPlayerList, realUpperMargin, float, 0)
-       ATTRIB(XonoticPlayerList, origin, vector, '0 0 0')
-       ATTRIB(XonoticPlayerList, itemAbsSize, vector, '0 0 0')
-       METHOD(XonoticPlayerList, setPlayerList, void(entity, string))
-       METHOD(XonoticPlayerList, getPlayerList, string(entity, float, float))
-       ATTRIB(XonoticPlayerList, playerList, float, -1)
-ENDCLASS(XonoticPlayerList)
-entity makeXonoticPlayerList();
-#endif
-
-#ifdef IMPLEMENTATION
-
-const float PLAYERPARM_SCORE = 0;
-const float PLAYERPARM_PING = 1;
-const float PLAYERPARM_TEAM = 2;
-const float PLAYERPARM_NAME = 3;
-const float PLAYERPARM_COUNT = 4;
+#include "playerlist.qh"
+
+.float realUpperMargin2;
+
+const int PLAYERPARM_SCORE = 0;
+const int PLAYERPARM_PING = 1;
+const int PLAYERPARM_TEAM = 2;
+const int PLAYERPARM_NAME = 3;
+const int PLAYERPARM_COUNT = 4;
 
 entity makeXonoticPlayerList()
 {
@@ -54,7 +33,7 @@ void XonoticPlayerList_setPlayerList(entity me, string plist)
                s = bufstr_get(buf, i * PLAYERPARM_COUNT + PLAYERPARM_NAME);
                n = tokenize_console(s);
 
-               if(n == 4)
+               if(n == PLAYERPARM_COUNT)
                {
                        bufstr_set(buf, i * PLAYERPARM_COUNT + PLAYERPARM_SCORE, argv(0)); // -666
                        bufstr_set(buf, i * PLAYERPARM_COUNT + PLAYERPARM_PING,  argv(1)); // 100
@@ -82,8 +61,10 @@ void XonoticPlayerList_resizeNotify(entity me, vector relOrigin, vector relSize,
        me.itemAbsSize = '0 0 0';
        SUPER(XonoticPlayerList).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.itemAbsSize.y = absSize.y * me.itemHeight;
+       me.itemAbsSize.x = absSize.x * (1 - me.controlWidth);
+       me.realFontSize.y = me.fontSize / me.itemAbsSize.y;
+       me.realFontSize.x = me.fontSize / me.itemAbsSize.x;
        me.realUpperMargin = 0.5 * (1 - me.realFontSize.y);
 
        // this list does 1 char left and right margin
@@ -127,7 +108,7 @@ void XonoticPlayerList_drawListBoxItem(entity me, int i, vector absSize, bool is
                if((t = strstrofs(score, ",", 0)) >= 0)
                        score = substring(score, 0, t);
 
-               if(stof(score) == -666)
+               if(stof(score) == FRAGS_SPECTATOR)
                        score = _("spectator");
        }
 
@@ -137,5 +118,3 @@ void XonoticPlayerList_drawListBoxItem(entity me, int i, vector absSize, bool is
        score = draw_TextShortenToWidth(score, me.columnScoreSize, 0, me.realFontSize);
        draw_Text(me.realUpperMargin2 * eY + (me.columnScoreOrigin + 1.00 * (me.columnScoreSize - draw_TextWidth(score, 1, me.realFontSize))) * eX, score, me.realFontSize, rgb, 1, 0);
 }
-
-#endif