]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/menu/xonotic/gametypelist.qc
Listbox: highlight item under the cursor
[xonotic/xonotic-data.pk3dir.git] / qcsrc / menu / xonotic / gametypelist.qc
index a3b79631e0dbf1f9f3016f838d3faeef405186d8..eac075a9c041f16f78b1f139ff505c245e5c5af5 100644 (file)
@@ -2,12 +2,13 @@
 CLASS(XonoticGametypeList) EXTENDS(XonoticListBox)
        METHOD(XonoticGametypeList, configureXonoticGametypeList, void(entity))
        ATTRIB(XonoticGametypeList, rowsPerItem, float, 2)
-       METHOD(XonoticGametypeList, drawListBoxItem, void(entity, float, vector, float))
+       METHOD(XonoticGametypeList, drawListBoxItem, void(entity, int, vector, bool, float))
        METHOD(XonoticGametypeList, resizeNotify, void(entity, vector, vector, vector, vector))
        METHOD(XonoticGametypeList, setSelected, void(entity, float))
        METHOD(XonoticGametypeList, loadCvars, void(entity))
        METHOD(XonoticGametypeList, saveCvars, void(entity))
        METHOD(XonoticGametypeList, keyDown, float(entity, float, float, float))
+       METHOD(XonoticGametypeList, clickListBoxItem, void(entity, float, vector))
 
        ATTRIB(XonoticGametypeList, realFontSize, vector, '0 0 0')
        ATTRIB(XonoticGametypeList, realUpperMargin, float, 0)
@@ -30,12 +31,11 @@ entity makeXonoticGametypeList(void)
 }
 void XonoticGametypeList_configureXonoticGametypeList(entity me)
 {
-       float i;
        me.configureXonoticListBox(me);
        me.nItems = GameType_GetCount();
 
        // we want the pics mipmapped
-       for(i = 0; i < GameType_GetCount(); ++i)
+       for(int i = 0; i < GameType_GetCount(); ++i)
                draw_PreloadPictureWithFlags(GameType_GetIcon(i), PRECACHE_PIC_MIPMAP);
 
        me.loadCvars(me);
@@ -45,7 +45,6 @@ void XonoticGametypeList_setSelected(entity me, float i)
        SUPER(XonoticGametypeList).setSelected(me, i);
        me.saveCvars(me);
 }
-
 void XonoticGametypeList_loadCvars(entity me)
 {
        float t;
@@ -67,23 +66,28 @@ void XonoticGametypeList_loadCvars(entity me)
 }
 void XonoticGametypeList_saveCvars(entity me)
 {
-       float t;
-       t = GameType_GetID(me.selectedItem);
-       if(t == MapInfo_CurrentGametype())
+       int t = GameType_GetID(me.selectedItem);
+       if (t == MapInfo_CurrentGametype()) {
                return;
+       }
        MapInfo_SwitchGameType(t);
-       me.parent.gameTypeChangeNotify(me.parent);
+       entity owner = me.parent;
+       if (owner) { // not set immediately
+               owner.gameTypeChangeNotify(owner);
+       }
 }
-void XonoticGametypeList_drawListBoxItem(entity me, float i, vector absSize, float isSelected)
+void XonoticGametypeList_drawListBoxItem(entity me, int i, vector absSize, bool isSelected, float highlightedTime)
 {
        string s1, s2;
 
        if(isSelected)
                draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_SELECTED, SKINALPHA_LISTBOX_SELECTED);
+       else if(highlightedTime)
+               draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_SELECTED, getHighlightAlpha(SKINALPHA_LISTBOX_SELECTED * 0.1, highlightedTime));
 
        draw_Picture(me.columnIconOrigin * eX, GameType_GetIcon(i), me.columnIconSize * eX + eY, '1 1 1', SKINALPHA_LISTBOX_SELECTED);
        s1 = GameType_GetName(i);
-       
+
        if(_MapInfo_GetTeamPlayBool(GameType_GetID(i)))
                s2 = _("teamplay");
        else
@@ -111,15 +115,19 @@ void XonoticGametypeList_resizeNotify(entity me, vector relOrigin, vector relSiz
        me.columnNameOrigin = me.columnIconOrigin + me.columnIconSize + (0.5 * me.realFontSize.x);
        me.columnNameSize = 1 - me.columnIconSize - (1.5 * me.realFontSize.x);
 }
-
 float XonoticGametypeList_keyDown(entity me, float scan, float ascii, float shift)
 {
        if(scan == K_ENTER || scan == K_KP_ENTER)
        {
+               m_play_click_sound(MENU_SOUND_EXECUTE);
                me.parent.gameTypeSelectNotify(me.parent);
                return 1;
        }
 
        return SUPER(XonoticGametypeList).keyDown(me, scan, ascii, shift);
 }
+void XonoticGametypeList_clickListBoxItem(entity me, float i, vector where)
+{
+       m_play_click_sound(MENU_SOUND_SELECT);
+}
 #endif