From: terencehill Date: Sun, 3 May 2015 14:39:44 +0000 (+0200) Subject: Listbox / Picker: Implement item fading in a different way so that it gets influenced... X-Git-Tag: xonotic-v0.8.1~55^2~5 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=21f6206d1928dfe54da1c255a7060b3ea0319713;p=xonotic%2Fxonotic-data.pk3dir.git Listbox / Picker: Implement item fading in a different way so that it gets influenced by menu_slowmo --- diff --git a/qcsrc/menu/item/listbox.qc b/qcsrc/menu/item/listbox.qc index 2bc24b266..3c3e53aac 100644 --- a/qcsrc/menu/item/listbox.qc +++ b/qcsrc/menu/item/listbox.qc @@ -11,7 +11,7 @@ CLASS(ListBox) EXTENDS(Item) METHOD(ListBox, focusLeave, void(entity)) ATTRIB(ListBox, focusable, float, 1) ATTRIB(ListBox, focusedItem, int, -1) - ATTRIB(ListBox, focusedItemTime, float, 0) + ATTRIB(ListBox, focusedItemAlpha, float, 0.3) ATTRIB(ListBox, allowFocusSound, float, 1) ATTRIB(ListBox, selectedItem, int, 0) ATTRIB(ListBox, size, vector, '0 0 0') @@ -43,7 +43,7 @@ CLASS(ListBox) EXTENDS(Item) ATTRIB(ListBox, lastClickedItem, float, -1) ATTRIB(ListBox, lastClickedTime, float, 0) - METHOD(ListBox, drawListBoxItem, void(entity, int, vector, bool, float)) // item number, width/height, isSelected, highlightedTime + METHOD(ListBox, drawListBoxItem, void(entity, int, vector, bool, bool)) // item number, width/height, isSelected, isFocused 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)) @@ -191,7 +191,7 @@ float ListBox_mouseMove(entity me, vector pos) x = me.focusedItem; me.focusedItem = me.getItemAtPos(me, me.scrollPos + pos.y); if(x != me.focusedItem) - me.focusedItemTime = time; + me.focusedItemAlpha = SKINALPHA_LISTBOX_FOCUSED; } return 1; } @@ -397,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.focusedItem == i) ? me.focusedItemTime : 0); + me.drawListBoxItem(me, i, absSize, (me.selectedItem == i), (me.focusedItem == i)); y += relSize.y; } draw_ClearClip(); @@ -417,7 +417,7 @@ void ListBox_doubleClickListBoxItem(entity me, float i, vector where) // template method } -void ListBox_drawListBoxItem(entity me, int i, vector absSize, bool isSelected, float highlightedTime) +void ListBox_drawListBoxItem(entity me, int i, vector absSize, bool isSelected, bool isFocused) { 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); } diff --git a/qcsrc/menu/xonotic/campaign.qc b/qcsrc/menu/xonotic/campaign.qc index 2462f7d03..ce939c324 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, int, vector, bool, float)) + METHOD(XonoticCampaignList, drawListBoxItem, void(entity, int, vector, bool, bool)) 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, float highlightedTime) +void XonoticCampaignList_drawListBoxItem(entity me, int i, vector absSize, bool isSelected, bool isFocused) { string s; vector theColor; @@ -263,8 +263,11 @@ 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_FOCUSED, getHighlightAlpha(SKINALPHA_LISTBOX_FOCUSED, SKINFADEALPHA_LISTBOX_FOCUSED, highlightedTime)); + else if(isFocused) + { + me.focusedItemAlpha = getFadedAlpha(me.focusedItemAlpha, SKINALPHA_LISTBOX_FOCUSED, SKINFADEALPHA_LISTBOX_FOCUSED); + draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_FOCUSED, me.focusedItemAlpha); + } 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/charmap.qc b/qcsrc/menu/xonotic/charmap.qc index 48e72b7bd..68c0e566f 100644 --- a/qcsrc/menu/xonotic/charmap.qc +++ b/qcsrc/menu/xonotic/charmap.qc @@ -12,7 +12,7 @@ CLASS(XonoticCharmap) EXTENDS(XonoticPicker) METHOD(XonoticCharmap, cellSelect, void(entity, vector)) METHOD(XonoticCharmap, cellIsValid, bool(entity, vector)) - METHOD(XonoticCharmap, cellDraw, void(entity, vector, vector, float)) + METHOD(XonoticCharmap, cellDraw, void(entity, vector, vector)) METHOD(XonoticCharmap, charOffset, vector) ENDCLASS(XonoticCharmap) entity makeXonoticCharmap(entity controlledInputBox); @@ -106,7 +106,7 @@ bool XonoticCharmap_cellIsValid(entity me, vector cell) return true; } -void XonoticCharmap_cellDraw(entity me, vector cell, vector cellPos, float highlightedTime) +void XonoticCharmap_cellDraw(entity me, vector cell, vector cellPos) { draw_CenterText(cellPos + me.charOffset, charmap_cellToChar(me, cell), me.realFontSize, SKINCOLOR_CHARMAP_CHAR, SKINALPHA_CHARMAP_CHAR, 0); } diff --git a/qcsrc/menu/xonotic/credits.qc b/qcsrc/menu/xonotic/credits.qc index 423677e4f..b74a3d3cb 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, int, vector, bool, float)) + METHOD(XonoticCreditsList, drawListBoxItem, void(entity, int, vector, bool, bool)) 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, int i, vector absSize, bool isSelected, float highlightedTime) +void XonoticCreditsList_drawListBoxItem(entity me, int i, vector absSize, bool isSelected, bool isFocused) { // layout: Ping, Credits name, Map name, NP, TP, MP string s; diff --git a/qcsrc/menu/xonotic/crosshairpicker.qc b/qcsrc/menu/xonotic/crosshairpicker.qc index eda416f68..1441ebcb3 100644 --- a/qcsrc/menu/xonotic/crosshairpicker.qc +++ b/qcsrc/menu/xonotic/crosshairpicker.qc @@ -7,7 +7,7 @@ CLASS(XonoticCrosshairPicker) EXTENDS(XonoticPicker) METHOD(XonoticCrosshairPicker, cellSelect, void(entity, vector)) METHOD(XonoticCrosshairPicker, cellIsValid, bool(entity, vector)) - METHOD(XonoticCrosshairPicker, cellDraw, void(entity, vector, vector, float)) + METHOD(XonoticCrosshairPicker, cellDraw, void(entity, vector, vector)) ENDCLASS(XonoticCrosshairPicker) entity makeXonoticCrosshairPicker(); #endif @@ -56,7 +56,7 @@ bool XonoticCrosshairPicker_cellIsValid(entity me, vector cell) return true; } -void XonoticCrosshairPicker_cellDraw(entity me, vector cell, vector cellPos, float highlightedTime) +void XonoticCrosshairPicker_cellDraw(entity me, vector cell, vector cellPos) { vector sz, rgb; string cross = strcat("/gfx/crosshair", crosshairpicker_cellToCrosshair(me, cell)); diff --git a/qcsrc/menu/xonotic/cvarlist.qc b/qcsrc/menu/xonotic/cvarlist.qc index a00ff6027..172eb58a6 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, int, vector, bool, float)) + METHOD(XonoticCvarList, drawListBoxItem, void(entity, int, vector, bool, bool)) 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, int i, vector absSize, bool isSelected, float highlightedTime) +void XonoticCvarList_drawListBoxItem(entity me, int i, vector absSize, bool isSelected, bool isFocused) { string k, v, d; float t; @@ -164,8 +164,11 @@ void XonoticCvarList_drawListBoxItem(entity me, int i, vector absSize, bool isSe 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_FOCUSED, getHighlightAlpha(SKINALPHA_LISTBOX_FOCUSED, SKINFADEALPHA_LISTBOX_FOCUSED, highlightedTime)); + else if(isFocused) + { + me.focusedItemAlpha = getFadedAlpha(me.focusedItemAlpha, SKINALPHA_LISTBOX_FOCUSED, SKINFADEALPHA_LISTBOX_FOCUSED); + draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_FOCUSED, me.focusedItemAlpha); + } k = bufstr_get(me.handle, i); diff --git a/qcsrc/menu/xonotic/demolist.qc b/qcsrc/menu/xonotic/demolist.qc index df1b08a4d..c69681b19 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, int, vector, bool, float)) + METHOD(XonoticDemoList, drawListBoxItem, void(entity, int, vector, bool, bool)) METHOD(XonoticDemoList, getDemos, void(entity)) METHOD(XonoticDemoList, startDemo, void(entity)) METHOD(XonoticDemoList, timeDemo, void(entity)) @@ -133,13 +133,16 @@ void XonoticDemoList_resizeNotify(entity me, vector relOrigin, vector relSize, v me.columnNameSize = 1 - 2 * me.realFontSize.x; } -void XonoticDemoList_drawListBoxItem(entity me, int i, vector absSize, bool isSelected, float highlightedTime) +void XonoticDemoList_drawListBoxItem(entity me, int i, vector absSize, bool isSelected, bool isFocused) { 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_FOCUSED, getHighlightAlpha(SKINALPHA_LISTBOX_FOCUSED, SKINFADEALPHA_LISTBOX_FOCUSED, highlightedTime)); + else if(isFocused) + { + me.focusedItemAlpha = getFadedAlpha(me.focusedItemAlpha, SKINALPHA_LISTBOX_FOCUSED, SKINFADEALPHA_LISTBOX_FOCUSED); + draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_FOCUSED, me.focusedItemAlpha); + } 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 10dc7a76b..c0a351b31 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, int, vector, bool, float)) + METHOD(XonoticGametypeList, drawListBoxItem, void(entity, int, vector, bool, bool)) METHOD(XonoticGametypeList, resizeNotify, void(entity, vector, vector, vector, vector)) METHOD(XonoticGametypeList, setSelected, void(entity, float)) METHOD(XonoticGametypeList, loadCvars, void(entity)) @@ -76,14 +76,17 @@ void XonoticGametypeList_saveCvars(entity me) owner.gameTypeChangeNotify(owner); } } -void XonoticGametypeList_drawListBoxItem(entity me, int i, vector absSize, bool isSelected, float highlightedTime) +void XonoticGametypeList_drawListBoxItem(entity me, int i, vector absSize, bool isSelected, bool isFocused) { 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_FOCUSED, getHighlightAlpha(SKINALPHA_LISTBOX_FOCUSED, SKINFADEALPHA_LISTBOX_FOCUSED, highlightedTime)); + else if(isFocused) + { + me.focusedItemAlpha = getFadedAlpha(me.focusedItemAlpha, SKINALPHA_LISTBOX_FOCUSED, SKINFADEALPHA_LISTBOX_FOCUSED); + draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_FOCUSED, me.focusedItemAlpha); + } 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 09fac4f28..02f41efd2 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, int, vector, bool, float)) + METHOD(XonoticKeyBinder, drawListBoxItem, void(entity, int, vector, bool, bool)) 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, float highlightedTime) +void XonoticKeyBinder_drawListBoxItem(entity me, int i, vector absSize, bool isSelected, bool isFocused) { string s; int j, n; @@ -328,8 +328,11 @@ 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_FOCUSED, getHighlightAlpha(SKINALPHA_LISTBOX_FOCUSED, SKINFADEALPHA_LISTBOX_FOCUSED, highlightedTime)); + else if(isFocused) + { + me.focusedItemAlpha = getFadedAlpha(me.focusedItemAlpha, SKINALPHA_LISTBOX_FOCUSED, SKINFADEALPHA_LISTBOX_FOCUSED); + draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_FOCUSED, me.focusedItemAlpha); + } theAlpha = SKINALPHA_KEYGRABBER_KEYS; theColor = SKINCOLOR_KEYGRABBER_KEYS; diff --git a/qcsrc/menu/xonotic/languagelist.qc b/qcsrc/menu/xonotic/languagelist.qc index e6ef90a4c..4f0101341 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, int, vector, bool, float)) + METHOD(XonoticLanguageList, drawListBoxItem, void(entity, int, vector, bool, bool)) METHOD(XonoticLanguageList, resizeNotify, void(entity, vector, vector, vector, vector)) METHOD(XonoticLanguageList, setSelected, void(entity, float)) METHOD(XonoticLanguageList, loadCvars, void(entity)) @@ -55,13 +55,16 @@ void XonoticLanguageList_configureXonoticLanguageList(entity me) me.loadCvars(me); } -void XonoticLanguageList_drawListBoxItem(entity me, int i, vector absSize, bool isSelected, float highlightedTime) +void XonoticLanguageList_drawListBoxItem(entity me, int i, vector absSize, bool isSelected, bool isFocused) { 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_FOCUSED, getHighlightAlpha(SKINALPHA_LISTBOX_FOCUSED, SKINFADEALPHA_LISTBOX_FOCUSED, highlightedTime)); + else if(isFocused) + { + me.focusedItemAlpha = getFadedAlpha(me.focusedItemAlpha, SKINALPHA_LISTBOX_FOCUSED, SKINFADEALPHA_LISTBOX_FOCUSED); + draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_FOCUSED, me.focusedItemAlpha); + } s = me.languageParameter(me, i, LANGPARM_NAME_LOCALIZED); diff --git a/qcsrc/menu/xonotic/maplist.qc b/qcsrc/menu/xonotic/maplist.qc index 4003a36d7..1e2039b79 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, int, vector, bool, float)) + METHOD(XonoticMapList, drawListBoxItem, void(entity, int, vector, bool, bool)) 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, int i, vector absSize, bool isSelected, float highlightedTime) +void XonoticMapList_drawListBoxItem(entity me, int i, vector absSize, bool isSelected, bool isFocused) { // layout: Ping, Map name, Map name, NP, TP, MP string s; @@ -181,8 +181,11 @@ void XonoticMapList_drawListBoxItem(entity me, int i, vector absSize, bool isSel { 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_FOCUSED, getHighlightAlpha(SKINALPHA_LISTBOX_FOCUSED, SKINFADEALPHA_LISTBOX_FOCUSED, highlightedTime)); + if(isFocused) + { + me.focusedItemAlpha = getFadedAlpha(me.focusedItemAlpha, SKINALPHA_LISTBOX_FOCUSED, SKINFADEALPHA_LISTBOX_FOCUSED); + draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_FOCUSED, me.focusedItemAlpha); + } } if(draw_PictureSize(strcat("/maps/", MapInfo_Map_bspname)) == '0 0 0') diff --git a/qcsrc/menu/xonotic/picker.qc b/qcsrc/menu/xonotic/picker.qc index 86eb7dc90..77b934862 100644 --- a/qcsrc/menu/xonotic/picker.qc +++ b/qcsrc/menu/xonotic/picker.qc @@ -17,11 +17,12 @@ CLASS(XonoticPicker) EXTENDS(Item) METHOD(XonoticPicker, moveFocus, void(entity, vector, vector)) METHOD(XonoticPicker, cellSelect, void(entity, vector)) - METHOD(XonoticPicker, cellDraw, void(entity, vector, vector, float)) + METHOD(XonoticPicker, cellDraw, void(entity, vector, vector)) METHOD(XonoticPicker, cellIsValid, bool(entity, vector)) ATTRIB(XonoticPicker, realCellSize, vector, '0 0 0') ATTRIB(XonoticPicker, selectedCell, vector, '-1 -1 0') ATTRIB(XonoticPicker, focusedCell, vector, '-1 -1 0') + ATTRIB(XonoticPicker, focusedCellAlpha, float, 0) ATTRIB(XonoticPicker, focusedCellTime, float, 0) ATTRIB(XonoticPicker, pressedCell, vector, '-1 -1 0') ENDCLASS(XonoticPicker) @@ -57,7 +58,7 @@ float XonoticPicker_mouseMove(entity me, vector coords) } if(me.focusedCell != prevFocusedCell) - me.focusedCellTime = time; + me.focusedCellAlpha = SKINALPHA_LISTBOX_FOCUSED; return 1; } @@ -153,7 +154,7 @@ bool XonoticPicker_cellIsValid(entity me, vector cell) return true; } -void XonoticPicker_cellDraw(entity me, vector cell, vector cellPos, float highlightTime) +void XonoticPicker_cellDraw(entity me, vector cell, vector cellPos) { } @@ -186,10 +187,13 @@ void XonoticPicker_draw(entity me) else if(cell == me.focusedCell && me.focused) { if(!me.pressed || me.focusedCell == me.pressedCell) - draw_Fill(cellPos, me.realCellSize, SKINCOLOR_LISTBOX_FOCUSED, getHighlightAlpha(SKINALPHA_LISTBOX_FOCUSED, SKINFADEALPHA_LISTBOX_FOCUSED, me.focusedCellTime)); + { + me.focusedCellAlpha = getFadedAlpha(me.focusedCellAlpha, SKINALPHA_LISTBOX_FOCUSED, SKINFADEALPHA_LISTBOX_FOCUSED); + draw_Fill(cellPos, me.realCellSize, SKINCOLOR_LISTBOX_FOCUSED, me.focusedCellAlpha); + } } - me.cellDraw(me, cell, cellPos, (me.focusedCell == cell) ? me.focusedCellTime : 0); + me.cellDraw(me, cell, cellPos); } } diff --git a/qcsrc/menu/xonotic/playerlist.qc b/qcsrc/menu/xonotic/playerlist.qc index a7151e1ba..f6fba8bc8 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, int, vector, bool, float)) + 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) @@ -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, int i, vector absSize, bool isSelected, float highlightedTime) +void XonoticPlayerList_drawListBoxItem(entity me, int i, vector absSize, bool isSelected, bool isFocused) { string s; string score; diff --git a/qcsrc/menu/xonotic/playlist.qc b/qcsrc/menu/xonotic/playlist.qc index 744b0be90..b29748930 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, int, vector, bool, float)) + METHOD(XonoticPlayList, drawListBoxItem, void(entity, int, vector, bool, bool)) METHOD(XonoticPlayList, stopSound, void(entity)) METHOD(XonoticPlayList, startSound, void(entity, float)) METHOD(XonoticPlayList, resumeSound, void(entity)) @@ -170,13 +170,16 @@ void XonoticPlayList_draw(entity me) SUPER(XonoticPlayList).draw(me); } -void XonoticPlayList_drawListBoxItem(entity me, int i, vector absSize, bool isSelected, float highlightedTime) +void XonoticPlayList_drawListBoxItem(entity me, int i, vector absSize, bool isSelected, bool isFocused) { 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_FOCUSED, getHighlightAlpha(SKINALPHA_LISTBOX_FOCUSED, SKINFADEALPHA_LISTBOX_FOCUSED, highlightedTime)); + else if(isFocused) + { + me.focusedItemAlpha = getFadedAlpha(me.focusedItemAlpha, SKINALPHA_LISTBOX_FOCUSED, SKINFADEALPHA_LISTBOX_FOCUSED); + draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_FOCUSED, me.focusedItemAlpha); + } if(i == me.playingTrack) { diff --git a/qcsrc/menu/xonotic/screenshotlist.qc b/qcsrc/menu/xonotic/screenshotlist.qc index 9cd26cad1..3482dcc47 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, int, vector, bool, float)) + METHOD(XonoticScreenshotList, drawListBoxItem, void(entity, int, vector, bool, bool)) METHOD(XonoticScreenshotList, getScreenshots, void(entity)) METHOD(XonoticScreenshotList, previewScreenshot, void(entity)) METHOD(XonoticScreenshotList, startScreenshot, void(entity)) @@ -165,13 +165,16 @@ void XonoticScreenshotList_setSelected(entity me, float i) } } -void XonoticScreenshotList_drawListBoxItem(entity me, int i, vector absSize, bool isSelected, float highlightedTime) +void XonoticScreenshotList_drawListBoxItem(entity me, int i, vector absSize, bool isSelected, bool isFocused) { 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_FOCUSED, getHighlightAlpha(SKINALPHA_LISTBOX_FOCUSED, SKINFADEALPHA_LISTBOX_FOCUSED, highlightedTime)); + else if(isFocused) + { + me.focusedItemAlpha = getFadedAlpha(me.focusedItemAlpha, SKINALPHA_LISTBOX_FOCUSED, SKINFADEALPHA_LISTBOX_FOCUSED); + draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_FOCUSED, me.focusedItemAlpha); + } 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 56f62e452..00ce425f0 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, int, vector, bool, float)) + METHOD(XonoticServerList, drawListBoxItem, void(entity, int, vector, bool, bool)) 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, float highlightedTime) +void XonoticServerList_drawListBoxItem(entity me, int i, vector absSize, bool isSelected, bool isFocused) { // layout: Ping, Server name, Map name, NP, TP, MP float p; @@ -1017,8 +1017,11 @@ 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_FOCUSED, getHighlightAlpha(SKINALPHA_LISTBOX_FOCUSED, SKINFADEALPHA_LISTBOX_FOCUSED, highlightedTime)); + else if(isFocused) + { + me.focusedItemAlpha = getFadedAlpha(me.focusedItemAlpha, SKINALPHA_LISTBOX_FOCUSED, SKINFADEALPHA_LISTBOX_FOCUSED); + draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_FOCUSED, me.focusedItemAlpha); + } s = gethostcachestring(SLIST_FIELD_QCSTATUS, i); m = tokenizebyseparator(s, ":"); diff --git a/qcsrc/menu/xonotic/skinlist.qc b/qcsrc/menu/xonotic/skinlist.qc index d689295ae..de1dafaae 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, int, vector, bool, float)) + METHOD(XonoticSkinList, drawListBoxItem, void(entity, int, vector, bool, bool)) METHOD(XonoticSkinList, getSkins, void(entity)) METHOD(XonoticSkinList, setSkin, void(entity)) METHOD(XonoticSkinList, loadCvars, void(entity)) @@ -149,14 +149,17 @@ void XonoticSkinList_resizeNotify(entity me, vector relOrigin, vector relSize, v me.columnNameSize = 1 - me.columnPreviewSize - 2 * me.realFontSize.x; } -void XonoticSkinList_drawListBoxItem(entity me, int i, vector absSize, bool isSelected, float highlightedTime) +void XonoticSkinList_drawListBoxItem(entity me, int i, vector absSize, bool isSelected, bool isFocused) { 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_FOCUSED, getHighlightAlpha(SKINALPHA_LISTBOX_FOCUSED, SKINFADEALPHA_LISTBOX_FOCUSED, highlightedTime)); + else if(isFocused) + { + me.focusedItemAlpha = getFadedAlpha(me.focusedItemAlpha, SKINALPHA_LISTBOX_FOCUSED, SKINFADEALPHA_LISTBOX_FOCUSED); + draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_FOCUSED, me.focusedItemAlpha); + } 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 a23db9302..3e37c34f1 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, int, vector, bool, float)) + METHOD(XonoticSoundList, drawListBoxItem, void(entity, int, vector, bool, bool)) METHOD(XonoticSoundList, getSounds, void(entity)) METHOD(XonoticSoundList, soundName, string(entity, float)) METHOD(XonoticSoundList, doubleClickListBoxItem, void(entity, float, vector)) @@ -101,13 +101,16 @@ void XonoticSoundList_resizeNotify(entity me, vector relOrigin, vector relSize, me.columnNameSize = 1 - me.columnNameOrigin - me.realFontSize.x; } -void XonoticSoundList_drawListBoxItem(entity me, int i, vector absSize, bool isSelected, float highlightedTime) +void XonoticSoundList_drawListBoxItem(entity me, int i, vector absSize, bool isSelected, bool isFocused) { 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_FOCUSED, getHighlightAlpha(SKINALPHA_LISTBOX_FOCUSED, SKINFADEALPHA_LISTBOX_FOCUSED, highlightedTime)); + else if(isFocused) + { + me.focusedItemAlpha = getFadedAlpha(me.focusedItemAlpha, SKINALPHA_LISTBOX_FOCUSED, SKINFADEALPHA_LISTBOX_FOCUSED); + draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_FOCUSED, me.focusedItemAlpha); + } 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 ee2cdf08d..cb0116967 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, int, vector, bool, float)) + METHOD(XonoticStatsList, drawListBoxItem, void(entity, int, vector, bool, bool)) METHOD(XonoticStatsList, getStats, void(entity)) METHOD(XonoticStatsList, doubleClickListBoxItem, void(entity, float, vector)) METHOD(XonoticStatsList, keyDown, float(entity, float, float, float)) @@ -313,12 +313,15 @@ void XonoticStatsList_resizeNotify(entity me, vector relOrigin, vector relSize, #endif } -void XonoticStatsList_drawListBoxItem(entity me, int i, vector absSize, bool isSelected, float highlightedTime) +void XonoticStatsList_drawListBoxItem(entity me, int i, vector absSize, bool isSelected, bool isFocused) { 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_FOCUSED, getHighlightAlpha(SKINALPHA_LISTBOX_FOCUSED, SKINFADEALPHA_LISTBOX_FOCUSED, highlightedTime)); + else if(isFocused) + { + me.focusedItemAlpha = getFadedAlpha(me.focusedItemAlpha, SKINALPHA_LISTBOX_FOCUSED, SKINFADEALPHA_LISTBOX_FOCUSED); + draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_FOCUSED, me.focusedItemAlpha); + } 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 58d1d934f..a80b03fe1 100644 --- a/qcsrc/menu/xonotic/util.qc +++ b/qcsrc/menu/xonotic/util.qc @@ -768,19 +768,13 @@ void dialog_hudpanel_common_notoggle(entity me, string panelname) e.configureXonoticTextSliderValues(e); } -#define FADE_TIME 0.5 -#define TRESHOLD_TIME 0.1 -float getHighlightAlpha(float startAlpha, float targetAlpha, float highlightedTime) +float getFadedAlpha(float currentAlpha, float startAlpha, float targetAlpha) { - float theAlpha; - if((time - highlightedTime - TRESHOLD_TIME) < FADE_TIME) - { - float f = max(0, (time - highlightedTime - TRESHOLD_TIME) / FADE_TIME); - theAlpha = startAlpha + f * (targetAlpha - startAlpha); - } + if(startAlpha < targetAlpha) + currentAlpha = min(currentAlpha + frametime * 0.5, targetAlpha); else - theAlpha = targetAlpha; - return theAlpha; + currentAlpha = max(currentAlpha - frametime * 0.5, targetAlpha); + return currentAlpha; } void CheckSendCvars(entity me, string cvarnamestring) diff --git a/qcsrc/menu/xonotic/util.qh b/qcsrc/menu/xonotic/util.qh index f880c2f47..2564a86ed 100644 --- a/qcsrc/menu/xonotic/util.qh +++ b/qcsrc/menu/xonotic/util.qh @@ -48,7 +48,7 @@ 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 startAlpha, float targetAlpha, float highlightedTime); +float getFadedAlpha(float currentAlpha, float startAlpha, float targetAlpha); string _Nex_ExtResponseSystem_BannedServers; float _Nex_ExtResponseSystem_BannedServersNeedsRefresh; diff --git a/qcsrc/menu/xonotic/weaponslist.qc b/qcsrc/menu/xonotic/weaponslist.qc index 038f8d4c7..30e7767bc 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, int, vector, bool, float)) + METHOD(XonoticWeaponsList, drawListBoxItem, void(entity, int, vector, bool, bool)) 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,13 +90,16 @@ string XonoticWeaponsList_toString(entity me) } return substring(s, 0, strlen(s) - 2); } -void XonoticWeaponsList_drawListBoxItem(entity me, int i, vector absSize, bool isSelected, float highlightedTime) +void XonoticWeaponsList_drawListBoxItem(entity me, int i, vector absSize, bool isSelected, bool isFocused) { 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_FOCUSED, getHighlightAlpha(SKINALPHA_LISTBOX_FOCUSED, SKINFADEALPHA_LISTBOX_FOCUSED, highlightedTime)); + else if(isFocused) + { + me.focusedItemAlpha = getFadedAlpha(me.focusedItemAlpha, SKINALPHA_LISTBOX_FOCUSED, SKINFADEALPHA_LISTBOX_FOCUSED); + draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_FOCUSED, me.focusedItemAlpha); + } e = get_weaponinfo(stof(argv(i))); string msg = e.message; if(e.spawnflags & WEP_FLAG_MUTATORBLOCKED)