From: terencehill Date: Sun, 26 Apr 2015 12:33:56 +0000 (+0200) Subject: Listbox: highlight item under the cursor X-Git-Tag: xonotic-v0.8.1~55^2~16 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=20387ff9f8cef7536362de05c76cc0062416a64c;p=xonotic%2Fxonotic-data.pk3dir.git Listbox: highlight item under the cursor --- diff --git a/qcsrc/menu/item/listbox.qc b/qcsrc/menu/item/listbox.qc index 478a2063f..558c8a4ea 100644 --- a/qcsrc/menu/item/listbox.qc +++ b/qcsrc/menu/item/listbox.qc @@ -4,11 +4,14 @@ CLASS(ListBox) EXTENDS(Item) METHOD(ListBox, configureListBox, void(entity, float, float)) METHOD(ListBox, draw, void(entity)) METHOD(ListBox, keyDown, float(entity, float, float, float)) + METHOD(ListBox, mouseMove, float(entity, vector)) METHOD(ListBox, mousePress, float(entity, vector)) METHOD(ListBox, mouseDrag, float(entity, vector)) METHOD(ListBox, mouseRelease, float(entity, vector)) METHOD(ListBox, focusLeave, void(entity)) ATTRIB(ListBox, focusable, float, 1) + ATTRIB(ListBox, highlightedItem, int, -1) + ATTRIB(ListBox, highlightedItemTime, float, 0) ATTRIB(ListBox, allowFocusSound, float, 1) ATTRIB(ListBox, selectedItem, int, 0) ATTRIB(ListBox, size, vector, '0 0 0') @@ -40,7 +43,7 @@ CLASS(ListBox) EXTENDS(Item) ATTRIB(ListBox, lastClickedItem, float, -1) ATTRIB(ListBox, lastClickedTime, float, 0) - METHOD(ListBox, drawListBoxItem, void(entity, float, vector, float)) // item number, width/height, selected + METHOD(ListBox, drawListBoxItem, void(entity, int, vector, bool, float)) // item number, width/height, isSelected, highlightedTime METHOD(ListBox, clickListBoxItem, void(entity, float, vector)) // item number, relative clickpos METHOD(ListBox, doubleClickListBoxItem, void(entity, float, vector)) // item number, relative clickpos METHOD(ListBox, setSelected, void(entity, float)) @@ -176,6 +179,22 @@ float ListBox_keyDown(entity me, float key, float ascii, float shift) return 0; return 1; } +float ListBox_mouseMove(entity me, vector pos) +{ + if(pos_x < 0) return 0; + if(pos_y < 0) return 0; + if(pos_x >= 1) return 0; + if(pos_y >= 1) return 0; + if(pos_x < 1 - me.controlWidth) + { + float x; + x = me.highlightedItem; + me.highlightedItem = me.getItemAtPos(me, me.scrollPos + pos.y); + if(x != me.highlightedItem) + me.highlightedItemTime = time; + } + return 1; +} float ListBox_mouseDrag(entity me, vector pos) { float hit; @@ -286,6 +305,7 @@ void ListBox_focusLeave(entity me) // by a mouse click on an item of the list // for example showing a dialog on right click me.pressed = 0; + me.highlightedItem = -1; } void ListBox_updateControlTopBottom(entity me) { @@ -367,6 +387,7 @@ void ListBox_draw(entity me) draw_SetClip(); oldshift = draw_shift; oldscale = draw_scale; + float y; i = me.getItemAtPos(me, me.scrollPos); y = me.getItemStart(me, i) - me.scrollPos; @@ -376,7 +397,7 @@ void ListBox_draw(entity me) vector relSize = eX * (1 - me.controlWidth) + eY * me.getItemHeight(me, i); absSize = boxToGlobalSize(relSize, me.size); draw_scale = boxToGlobalSize(relSize, oldscale); - me.drawListBoxItem(me, i, absSize, (me.selectedItem == i)); + me.drawListBoxItem(me, i, absSize, (me.selectedItem == i), (me.highlightedItem == i) ? me.highlightedItemTime : 0); y += relSize.y; } draw_ClearClip(); @@ -396,8 +417,8 @@ void ListBox_doubleClickListBoxItem(entity me, float i, vector where) // template method } -void ListBox_drawListBoxItem(entity me, float i, vector absSize, float selected) +void ListBox_drawListBoxItem(entity me, int i, vector absSize, bool isSelected, float highlightedTime) { - draw_Text('0 0 0', sprintf(_("Item %d"), i), eX * (8 / absSize.x) + eY * (8 / absSize.y), (selected ? '0 1 0' : '1 1 1'), 1, 0); + draw_Text('0 0 0', sprintf(_("Item %d"), i), eX * (8 / absSize.x) + eY * (8 / absSize.y), (isSelected ? '0 1 0' : '1 1 1'), 1, 0); } #endif diff --git a/qcsrc/menu/xonotic/campaign.qc b/qcsrc/menu/xonotic/campaign.qc index 16967a688..aa234a174 100644 --- a/qcsrc/menu/xonotic/campaign.qc +++ b/qcsrc/menu/xonotic/campaign.qc @@ -5,7 +5,7 @@ CLASS(XonoticCampaignList) EXTENDS(XonoticListBox) METHOD(XonoticCampaignList, configureXonoticCampaignList, void(entity)) ATTRIB(XonoticCampaignList, rowsPerItem, float, 10) METHOD(XonoticCampaignList, draw, void(entity)) - METHOD(XonoticCampaignList, drawListBoxItem, void(entity, float, vector, float)) + METHOD(XonoticCampaignList, drawListBoxItem, void(entity, int, vector, bool, float)) METHOD(XonoticCampaignList, doubleClickListBoxItem, void(entity, float, vector)) METHOD(XonoticCampaignList, resizeNotify, void(entity, vector, vector, vector, vector)) METHOD(XonoticCampaignList, setSelected, void(entity, float)) @@ -237,7 +237,7 @@ void XonoticCampaignList_doubleClickListBoxItem(entity me, float i, vector where { CampaignList_LoadMap(me, me); } -void XonoticCampaignList_drawListBoxItem(entity me, int i, vector absSize, bool isSelected) +void XonoticCampaignList_drawListBoxItem(entity me, int i, vector absSize, bool isSelected, float highlightedTime) { string s; vector theColor; @@ -263,6 +263,8 @@ void XonoticCampaignList_drawListBoxItem(entity me, int i, vector absSize, bool 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)); if(draw_PictureSize(strcat("/maps/", campaign_mapname[i])) == '0 0 0') draw_Picture(me.columnPreviewOrigin * eX, "nopreview_map", me.columnPreviewSize * eX + eY, '1 1 1', theAlpha); diff --git a/qcsrc/menu/xonotic/credits.qc b/qcsrc/menu/xonotic/credits.qc index 67848f914..423677e4f 100644 --- a/qcsrc/menu/xonotic/credits.qc +++ b/qcsrc/menu/xonotic/credits.qc @@ -3,7 +3,7 @@ CLASS(XonoticCreditsList) EXTENDS(XonoticListBox) METHOD(XonoticCreditsList, configureXonoticCreditsList, void(entity)) ATTRIB(XonoticCreditsList, rowsPerItem, float, 1) METHOD(XonoticCreditsList, draw, void(entity)) - METHOD(XonoticCreditsList, drawListBoxItem, void(entity, float, vector, float)) + METHOD(XonoticCreditsList, drawListBoxItem, void(entity, int, vector, bool, float)) METHOD(XonoticCreditsList, resizeNotify, void(entity, vector, vector, vector, vector)) METHOD(XonoticCreditsList, keyDown, float(entity, float, float, float)) METHOD(XonoticCreditsList, destroy, void(entity)) @@ -57,7 +57,7 @@ void XonoticCreditsList_resizeNotify(entity me, vector relOrigin, vector relSize me.realFontSize_x = me.fontSize / (absSize.x * (1 - me.controlWidth)); me.realUpperMargin = 0.5 * (1 - me.realFontSize.y); } -void XonoticCreditsList_drawListBoxItem(entity me, float i, vector absSize, float isSelected) +void XonoticCreditsList_drawListBoxItem(entity me, int i, vector absSize, bool isSelected, float highlightedTime) { // layout: Ping, Credits name, Map name, NP, TP, MP string s; diff --git a/qcsrc/menu/xonotic/cvarlist.qc b/qcsrc/menu/xonotic/cvarlist.qc index 421142aac..26dfb7e99 100644 --- a/qcsrc/menu/xonotic/cvarlist.qc +++ b/qcsrc/menu/xonotic/cvarlist.qc @@ -2,7 +2,7 @@ CLASS(XonoticCvarList) EXTENDS(XonoticListBox) METHOD(XonoticCvarList, configureXonoticCvarList, void(entity)) ATTRIB(XonoticCvarList, rowsPerItem, float, 1) - METHOD(XonoticCvarList, drawListBoxItem, void(entity, float, vector, float)) + METHOD(XonoticCvarList, drawListBoxItem, void(entity, int, vector, bool, float)) METHOD(XonoticCvarList, resizeNotify, void(entity, vector, vector, vector, vector)) METHOD(XonoticCvarList, keyDown, float(entity, float, float, float)) @@ -152,7 +152,7 @@ void XonoticCvarList_resizeNotify(entity me, vector relOrigin, vector relSize, v me.setSelected(me, me.selectedItem); } -void XonoticCvarList_drawListBoxItem(entity me, float i, vector absSize, float isSelected) +void XonoticCvarList_drawListBoxItem(entity me, int i, vector absSize, bool isSelected, float highlightedTime) { string k, v, d; float t; @@ -164,6 +164,8 @@ void XonoticCvarList_drawListBoxItem(entity me, float i, vector absSize, float i 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)); k = bufstr_get(me.handle, i); diff --git a/qcsrc/menu/xonotic/demolist.qc b/qcsrc/menu/xonotic/demolist.qc index 6882fcc5e..5389456fc 100644 --- a/qcsrc/menu/xonotic/demolist.qc +++ b/qcsrc/menu/xonotic/demolist.qc @@ -3,7 +3,7 @@ CLASS(XonoticDemoList) EXTENDS(XonoticListBox) METHOD(XonoticDemoList, configureXonoticDemoList, void(entity)) ATTRIB(XonoticDemoList, rowsPerItem, float, 1) METHOD(XonoticDemoList, resizeNotify, void(entity, vector, vector, vector, vector)) - METHOD(XonoticDemoList, drawListBoxItem, void(entity, float, vector, float)) + METHOD(XonoticDemoList, drawListBoxItem, void(entity, int, vector, bool, float)) METHOD(XonoticDemoList, getDemos, void(entity)) METHOD(XonoticDemoList, startDemo, void(entity)) METHOD(XonoticDemoList, timeDemo, void(entity)) @@ -133,11 +133,13 @@ void XonoticDemoList_resizeNotify(entity me, vector relOrigin, vector relSize, v me.columnNameSize = 1 - 2 * me.realFontSize.x; } -void XonoticDemoList_drawListBoxItem(entity me, float i, vector absSize, float isSelected) +void XonoticDemoList_drawListBoxItem(entity me, int i, vector absSize, bool isSelected, float highlightedTime) { string s; 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)); s = me.demoName(me,i); s = draw_TextShortenToWidth(s, me.columnNameSize, 0, me.realFontSize); diff --git a/qcsrc/menu/xonotic/gametypelist.qc b/qcsrc/menu/xonotic/gametypelist.qc index 0d36c8363..eac075a9c 100644 --- a/qcsrc/menu/xonotic/gametypelist.qc +++ b/qcsrc/menu/xonotic/gametypelist.qc @@ -2,7 +2,7 @@ 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)) @@ -76,12 +76,14 @@ void XonoticGametypeList_saveCvars(entity me) 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); diff --git a/qcsrc/menu/xonotic/keybinder.qc b/qcsrc/menu/xonotic/keybinder.qc index 5c2b898f2..75f4e1f7c 100644 --- a/qcsrc/menu/xonotic/keybinder.qc +++ b/qcsrc/menu/xonotic/keybinder.qc @@ -2,7 +2,7 @@ CLASS(XonoticKeyBinder) EXTENDS(XonoticListBox) METHOD(XonoticKeyBinder, configureXonoticKeyBinder, void(entity)) ATTRIB(XonoticKeyBinder, rowsPerItem, int, 1) - METHOD(XonoticKeyBinder, drawListBoxItem, void(entity, float, vector, float)) + METHOD(XonoticKeyBinder, drawListBoxItem, void(entity, int, vector, bool, float)) METHOD(XonoticKeyBinder, doubleClickListBoxItem, void(entity, float, vector)) METHOD(XonoticKeyBinder, resizeNotify, void(entity, vector, vector, vector, vector)) METHOD(XonoticKeyBinder, setSelected, void(entity, float)) @@ -299,7 +299,7 @@ float XonoticKeyBinder_keyDown(entity me, int key, bool ascii, float shift) } return r; } -void XonoticKeyBinder_drawListBoxItem(entity me, int i, vector absSize, bool isSelected) +void XonoticKeyBinder_drawListBoxItem(entity me, int i, vector absSize, bool isSelected, float highlightedTime) { string s; int j, n; @@ -328,6 +328,9 @@ void XonoticKeyBinder_drawListBoxItem(entity me, int i, vector absSize, bool isS else 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)); + theAlpha = SKINALPHA_KEYGRABBER_KEYS; theColor = SKINCOLOR_KEYGRABBER_KEYS; extraMargin = me.realFontSize.x * 0.5; diff --git a/qcsrc/menu/xonotic/languagelist.qc b/qcsrc/menu/xonotic/languagelist.qc index 8aa0d2c07..9d217fc51 100644 --- a/qcsrc/menu/xonotic/languagelist.qc +++ b/qcsrc/menu/xonotic/languagelist.qc @@ -2,7 +2,7 @@ CLASS(XonoticLanguageList) EXTENDS(XonoticListBox) METHOD(XonoticLanguageList, configureXonoticLanguageList, void(entity)) ATTRIB(XonoticLanguageList, rowsPerItem, float, 1) - METHOD(XonoticLanguageList, drawListBoxItem, void(entity, float, vector, float)) + METHOD(XonoticLanguageList, drawListBoxItem, void(entity, int, vector, bool, float)) METHOD(XonoticLanguageList, resizeNotify, void(entity, vector, vector, vector, vector)) METHOD(XonoticLanguageList, setSelected, void(entity, float)) METHOD(XonoticLanguageList, loadCvars, void(entity)) @@ -55,11 +55,13 @@ void XonoticLanguageList_configureXonoticLanguageList(entity me) me.loadCvars(me); } -void XonoticLanguageList_drawListBoxItem(entity me, float i, vector absSize, float isSelected) +void XonoticLanguageList_drawListBoxItem(entity me, int i, vector absSize, bool isSelected, float highlightedTime) { string s, p; 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)); s = me.languageParameter(me, i, LANGPARM_NAME_LOCALIZED); diff --git a/qcsrc/menu/xonotic/maplist.qc b/qcsrc/menu/xonotic/maplist.qc index d88ad0e8e..74556429b 100644 --- a/qcsrc/menu/xonotic/maplist.qc +++ b/qcsrc/menu/xonotic/maplist.qc @@ -3,7 +3,7 @@ CLASS(XonoticMapList) EXTENDS(XonoticListBox) METHOD(XonoticMapList, configureXonoticMapList, void(entity)) ATTRIB(XonoticMapList, rowsPerItem, float, 4) METHOD(XonoticMapList, draw, void(entity)) - METHOD(XonoticMapList, drawListBoxItem, void(entity, float, vector, float)) + METHOD(XonoticMapList, drawListBoxItem, void(entity, int, vector, bool, float)) METHOD(XonoticMapList, clickListBoxItem, void(entity, float, vector)) METHOD(XonoticMapList, doubleClickListBoxItem, void(entity, float, vector)) METHOD(XonoticMapList, resizeNotify, void(entity, vector, vector, vector, vector)) @@ -159,7 +159,7 @@ void XonoticMapList_doubleClickListBoxItem(entity me, float i, vector where) } } -void XonoticMapList_drawListBoxItem(entity me, float i, vector absSize, float isSelected) +void XonoticMapList_drawListBoxItem(entity me, int i, vector absSize, bool isSelected, float highlightedTime) { // layout: Ping, Map name, Map name, NP, TP, MP string s; @@ -177,8 +177,13 @@ void XonoticMapList_drawListBoxItem(entity me, float i, vector absSize, float is if(isSelected) draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_SELECTED, SKINALPHA_LISTBOX_SELECTED); - else if(included) - draw_Fill('0 0 0', '1 1 0', SKINCOLOR_MAPLIST_INCLUDEDBG, SKINALPHA_MAPLIST_INCLUDEDBG); + else + { + if(included) + draw_Fill('0 0 0', '1 1 0', SKINCOLOR_MAPLIST_INCLUDEDBG, SKINALPHA_MAPLIST_INCLUDEDBG); + if(highlightedTime) + draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_SELECTED, getHighlightAlpha(SKINALPHA_LISTBOX_SELECTED * 0.1, highlightedTime)); + } if(draw_PictureSize(strcat("/maps/", MapInfo_Map_bspname)) == '0 0 0') draw_Picture(me.columnPreviewOrigin * eX, "nopreview_map", me.columnPreviewSize * eX + eY, '1 1 1', theAlpha); diff --git a/qcsrc/menu/xonotic/playerlist.qc b/qcsrc/menu/xonotic/playerlist.qc index d4dc5af05..a7151e1ba 100644 --- a/qcsrc/menu/xonotic/playerlist.qc +++ b/qcsrc/menu/xonotic/playerlist.qc @@ -2,7 +2,7 @@ CLASS(XonoticPlayerList) EXTENDS(XonoticListBox) ATTRIB(XonoticPlayerList, rowsPerItem, float, 1) METHOD(XonoticPlayerList, resizeNotify, void(entity, vector, vector, vector, vector)) - METHOD(XonoticPlayerList, drawListBoxItem, void(entity, float, vector, float)) + METHOD(XonoticPlayerList, drawListBoxItem, void(entity, int, vector, bool, float)) ATTRIB(XonoticPlayerList, allowFocusSound, float, 0) ATTRIB(XonoticPlayerList, realFontSize, vector, '0 0 0') ATTRIB(XonoticPlayerList, columnNameOrigin, float, 0) @@ -92,7 +92,7 @@ void XonoticPlayerList_resizeNotify(entity me, vector relOrigin, vector relSize, me.columnScoreOrigin = me.columnNameOrigin + me.columnNameSize + me.realFontSize.x; } -void XonoticPlayerList_drawListBoxItem(entity me, float i, vector absSize, float isSelected) +void XonoticPlayerList_drawListBoxItem(entity me, int i, vector absSize, bool isSelected, float highlightedTime) { string s; string score; diff --git a/qcsrc/menu/xonotic/playlist.qc b/qcsrc/menu/xonotic/playlist.qc index fbe3c92c6..9730e8417 100644 --- a/qcsrc/menu/xonotic/playlist.qc +++ b/qcsrc/menu/xonotic/playlist.qc @@ -4,7 +4,7 @@ CLASS(XonoticPlayList) EXTENDS(XonoticListBox) ATTRIB(XonoticPlayList, rowsPerItem, float, 1) METHOD(XonoticPlayList, resizeNotify, void(entity, vector, vector, vector, vector)) METHOD(XonoticPlayList, draw, void(entity)) - METHOD(XonoticPlayList, drawListBoxItem, void(entity, float, vector, float)) + METHOD(XonoticPlayList, drawListBoxItem, void(entity, int, vector, bool, float)) METHOD(XonoticPlayList, stopSound, void(entity)) METHOD(XonoticPlayList, startSound, void(entity, float)) METHOD(XonoticPlayList, resumeSound, void(entity)) @@ -170,11 +170,13 @@ void XonoticPlayList_draw(entity me) SUPER(XonoticPlayList).draw(me); } -void XonoticPlayList_drawListBoxItem(entity me, float i, vector absSize, float isSelected) +void XonoticPlayList_drawListBoxItem(entity me, int i, vector absSize, bool isSelected, float highlightedTime) { string s; 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)); if(i == me.playingTrack) { diff --git a/qcsrc/menu/xonotic/screenshotlist.qc b/qcsrc/menu/xonotic/screenshotlist.qc index 225eefb24..fe4be4ed3 100644 --- a/qcsrc/menu/xonotic/screenshotlist.qc +++ b/qcsrc/menu/xonotic/screenshotlist.qc @@ -5,7 +5,7 @@ CLASS(XonoticScreenshotList) EXTENDS(XonoticListBox) METHOD(XonoticScreenshotList, resizeNotify, void(entity, vector, vector, vector, vector)) METHOD(XonoticScreenshotList, setSelected, void(entity, float)) METHOD(XonoticScreenshotList, draw, void(entity)) - METHOD(XonoticScreenshotList, drawListBoxItem, void(entity, float, vector, float)) + METHOD(XonoticScreenshotList, drawListBoxItem, void(entity, int, vector, bool, float)) METHOD(XonoticScreenshotList, getScreenshots, void(entity)) METHOD(XonoticScreenshotList, previewScreenshot, void(entity)) METHOD(XonoticScreenshotList, startScreenshot, void(entity)) @@ -165,11 +165,13 @@ void XonoticScreenshotList_setSelected(entity me, float i) } } -void XonoticScreenshotList_drawListBoxItem(entity me, float i, vector absSize, float isSelected) +void XonoticScreenshotList_drawListBoxItem(entity me, int i, vector absSize, bool isSelected, float highlightedTime) { string s; 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)); s = me.screenshotName(me,i); s = draw_TextShortenToWidth(s, me.columnNameSize, 0, me.realFontSize); diff --git a/qcsrc/menu/xonotic/serverlist.qc b/qcsrc/menu/xonotic/serverlist.qc index 29877c5d5..6eb169d88 100644 --- a/qcsrc/menu/xonotic/serverlist.qc +++ b/qcsrc/menu/xonotic/serverlist.qc @@ -3,7 +3,7 @@ CLASS(XonoticServerList) EXTENDS(XonoticListBox) METHOD(XonoticServerList, configureXonoticServerList, void(entity)) ATTRIB(XonoticServerList, rowsPerItem, float, 1) METHOD(XonoticServerList, draw, void(entity)) - METHOD(XonoticServerList, drawListBoxItem, void(entity, float, vector, float)) + METHOD(XonoticServerList, drawListBoxItem, void(entity, int, vector, bool, float)) METHOD(XonoticServerList, doubleClickListBoxItem, void(entity, float, vector)) METHOD(XonoticServerList, resizeNotify, void(entity, vector, vector, vector, vector)) METHOD(XonoticServerList, keyDown, float(entity, float, float, float)) @@ -961,7 +961,7 @@ void XonoticServerList_doubleClickListBoxItem(entity me, int i, vector where) { ServerList_Connect_Click(NULL, me); } -void XonoticServerList_drawListBoxItem(entity me, int i, vector absSize, bool isSelected) +void XonoticServerList_drawListBoxItem(entity me, int i, vector absSize, bool isSelected, float highlightedTime) { // layout: Ping, Server name, Map name, NP, TP, MP float p; @@ -1017,6 +1017,8 @@ void XonoticServerList_drawListBoxItem(entity me, int i, vector absSize, bool is 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)); s = gethostcachestring(SLIST_FIELD_QCSTATUS, i); m = tokenizebyseparator(s, ":"); diff --git a/qcsrc/menu/xonotic/skinlist.qc b/qcsrc/menu/xonotic/skinlist.qc index 9990c83fe..174e64f48 100644 --- a/qcsrc/menu/xonotic/skinlist.qc +++ b/qcsrc/menu/xonotic/skinlist.qc @@ -3,7 +3,7 @@ CLASS(XonoticSkinList) EXTENDS(XonoticListBox) METHOD(XonoticSkinList, configureXonoticSkinList, void(entity)) ATTRIB(XonoticSkinList, rowsPerItem, float, 4) METHOD(XonoticSkinList, resizeNotify, void(entity, vector, vector, vector, vector)) - METHOD(XonoticSkinList, drawListBoxItem, void(entity, float, vector, float)) + METHOD(XonoticSkinList, drawListBoxItem, void(entity, int, vector, bool, float)) METHOD(XonoticSkinList, getSkins, void(entity)) METHOD(XonoticSkinList, setSkin, void(entity)) METHOD(XonoticSkinList, loadCvars, void(entity)) @@ -149,12 +149,14 @@ void XonoticSkinList_resizeNotify(entity me, vector relOrigin, vector relSize, v me.columnNameSize = 1 - me.columnPreviewSize - 2 * me.realFontSize.x; } -void XonoticSkinList_drawListBoxItem(entity me, float i, vector absSize, float isSelected) +void XonoticSkinList_drawListBoxItem(entity me, int i, vector absSize, bool isSelected, float highlightedTime) { string s; 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)); s = me.skinParameter(me, i, SKINPARM_PREVIEW); draw_Picture(me.columnPreviewOrigin * eX, s, me.columnPreviewSize * eX + eY, '1 1 1', 1); diff --git a/qcsrc/menu/xonotic/soundlist.qc b/qcsrc/menu/xonotic/soundlist.qc index e443a53ef..6d2608c5d 100644 --- a/qcsrc/menu/xonotic/soundlist.qc +++ b/qcsrc/menu/xonotic/soundlist.qc @@ -3,7 +3,7 @@ CLASS(XonoticSoundList) EXTENDS(XonoticListBox) METHOD(XonoticSoundList, configureXonoticSoundList, void(entity)) ATTRIB(XonoticSoundList, rowsPerItem, float, 1) METHOD(XonoticSoundList, resizeNotify, void(entity, vector, vector, vector, vector)) - METHOD(XonoticSoundList, drawListBoxItem, void(entity, float, vector, float)) + METHOD(XonoticSoundList, drawListBoxItem, void(entity, int, vector, bool, float)) METHOD(XonoticSoundList, getSounds, void(entity)) METHOD(XonoticSoundList, soundName, string(entity, float)) METHOD(XonoticSoundList, doubleClickListBoxItem, void(entity, float, vector)) @@ -101,11 +101,13 @@ void XonoticSoundList_resizeNotify(entity me, vector relOrigin, vector relSize, me.columnNameSize = 1 - me.columnNameOrigin - me.realFontSize.x; } -void XonoticSoundList_drawListBoxItem(entity me, float i, vector absSize, float isSelected) +void XonoticSoundList_drawListBoxItem(entity me, int i, vector absSize, bool isSelected, float highlightedTime) { string s; 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)); s = me.soundName(me,i); if(s == cvar_string("menu_cdtrack")) // current menu track diff --git a/qcsrc/menu/xonotic/statslist.qc b/qcsrc/menu/xonotic/statslist.qc index 99c850f13..1702d367a 100644 --- a/qcsrc/menu/xonotic/statslist.qc +++ b/qcsrc/menu/xonotic/statslist.qc @@ -6,7 +6,7 @@ CLASS(XonoticStatsList) EXTENDS(XonoticListBox) METHOD(XonoticStatsList, configureXonoticStatsList, void(entity)) ATTRIB(XonoticStatsList, rowsPerItem, float, 1.4) METHOD(XonoticStatsList, resizeNotify, void(entity, vector, vector, vector, vector)) - METHOD(XonoticStatsList, drawListBoxItem, void(entity, float, vector, float)) + METHOD(XonoticStatsList, drawListBoxItem, void(entity, int, vector, bool, float)) METHOD(XonoticStatsList, getStats, void(entity)) METHOD(XonoticStatsList, doubleClickListBoxItem, void(entity, float, vector)) METHOD(XonoticStatsList, keyDown, float(entity, float, float, float)) @@ -313,10 +313,12 @@ void XonoticStatsList_resizeNotify(entity me, vector relOrigin, vector relSize, #endif } -void XonoticStatsList_drawListBoxItem(entity me, float i, vector absSize, float isSelected) +void XonoticStatsList_drawListBoxItem(entity me, int i, vector absSize, bool isSelected, float highlightedTime) { 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)); string data = bufstr_get(me.listStats, i); string s = car(data); diff --git a/qcsrc/menu/xonotic/util.qc b/qcsrc/menu/xonotic/util.qc index 330b2bb72..49fe79b01 100644 --- a/qcsrc/menu/xonotic/util.qc +++ b/qcsrc/menu/xonotic/util.qc @@ -768,6 +768,22 @@ void dialog_hudpanel_common_notoggle(entity me, string panelname) e.configureXonoticTextSliderValues(e); } +#define FADE_TIME 0.5 +#define MAX_ALPHA_INCREASE 0.1 +#define TRESHOLD_TIME 0.1 +float getHighlightAlpha(float baseAlpha, float highlightedTime) +{ + float alphaIncrease; + if (time - highlightedTime - TRESHOLD_TIME < FADE_TIME) + { + alphaIncrease = max(0, (time - highlightedTime - TRESHOLD_TIME) / FADE_TIME); + alphaIncrease = (1 - alphaIncrease) * MAX_ALPHA_INCREASE; + } + else + alphaIncrease = 0; + return baseAlpha + alphaIncrease; +} + void CheckSendCvars(entity me, string cvarnamestring) { if(me.sendCvars) diff --git a/qcsrc/menu/xonotic/util.qh b/qcsrc/menu/xonotic/util.qh index 80803f854..e7cd1028c 100644 --- a/qcsrc/menu/xonotic/util.qh +++ b/qcsrc/menu/xonotic/util.qh @@ -48,6 +48,8 @@ void dialog_hudpanel_common_notoggle(entity me, string panelname); me.TD(me, 1, 4, e = makeXonoticCheckBox(0, strzone(strcat("hud_panel_", panelname)), _("Enable panel"))); \ DIALOG_HUDPANEL_COMMON_NOTOGGLE() +float getHighlightAlpha(float baseAlpha, float highlightedTime); + string _Nex_ExtResponseSystem_BannedServers; float _Nex_ExtResponseSystem_BannedServersNeedsRefresh; string _Nex_ExtResponseSystem_PromotedServers; diff --git a/qcsrc/menu/xonotic/weaponslist.qc b/qcsrc/menu/xonotic/weaponslist.qc index 46d4e273f..18e5ffb59 100644 --- a/qcsrc/menu/xonotic/weaponslist.qc +++ b/qcsrc/menu/xonotic/weaponslist.qc @@ -4,7 +4,7 @@ CLASS(XonoticWeaponsList) EXTENDS(XonoticListBox) METHOD(XonoticWeaponsList, toString, string(entity)) ATTRIB(XonoticWeaponsList, rowsPerItem, float, 1) METHOD(XonoticWeaponsList, draw, void(entity)) - METHOD(XonoticWeaponsList, drawListBoxItem, void(entity, float, vector, float)) + METHOD(XonoticWeaponsList, drawListBoxItem, void(entity, int, vector, bool, float)) METHOD(XonoticWeaponsList, resizeNotify, void(entity, vector, vector, vector, vector)) METHOD(XonoticWeaponsList, keyDown, float(entity, float, float, float)) ATTRIB(XonoticWeaponsList, realFontSize, vector, '0 0 0') @@ -90,11 +90,13 @@ string XonoticWeaponsList_toString(entity me) } return substring(s, 0, strlen(s) - 2); } -void XonoticWeaponsList_drawListBoxItem(entity me, float i, vector absSize, float isSelected) +void XonoticWeaponsList_drawListBoxItem(entity me, int i, vector absSize, bool isSelected, float highlightedTime) { entity e; 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)); e = get_weaponinfo(stof(argv(i))); string msg = e.message; if(e.spawnflags & WEP_FLAG_MUTATORBLOCKED)