From: Mario Date: Tue, 11 Aug 2015 16:28:36 +0000 (+1000) Subject: Merge branch 'master' into terencehill/itemstime X-Git-Tag: xonotic-v0.8.1~12^2 X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=commitdiff_plain;h=3108bc8ea930e133184d3055677d706c7ecaa833 Merge branch 'master' into terencehill/itemstime # Conflicts: # qcsrc/client/hud.qc # qcsrc/client/hud_config.qc # qcsrc/common/stats.qh # qcsrc/menu/xonotic/mainwindow.qc # qcsrc/server/autocvars.qh --- 3108bc8ea930e133184d3055677d706c7ecaa833 diff --cc qcsrc/client/hud.qc index 55de7b7f5a,9019afc18f..c422892ea3 --- a/qcsrc/client/hud.qc +++ b/qcsrc/client/hud.qc @@@ -4582,311 -4604,6 +4604,252 @@@ void HUD_CenterPrint (void } } - // Buffs (#18) - // - void HUD_Buffs(void) - { - if(intermission == 2) return; - int buffs = getstati(STAT_BUFFS, 0, 24); - if(!autocvar__hud_configure) - { - if(!autocvar_hud_panel_buffs) return; - if(spectatee_status == -1) return; - if(getstati(STAT_HEALTH) <= 0) return; - if(!buffs) return; - } - else - { - buffs = Buff_Type_first.items; // force first buff - } - - int b = 0; // counter to tell other functions that we have buffs - entity e; - string s = ""; - for(e = Buff_Type_first; e; e = e.enemy) if(buffs & e.items) - { - ++b; - string o = strcat(rgb_to_hexcolor(Buff_Color(e.items)), Buff_PrettyName(e.items)); - if(s == "") - s = o; - else - s = strcat(s, " ", o); - } - - HUD_Panel_UpdateCvars(); - - draw_beginBoldFont(); - - vector pos, mySize; - pos = panel_pos; - mySize = panel_size; - - HUD_Panel_DrawBg(bound(0, b, 1)); - if(panel_bg_padding) - { - pos += '1 1 0' * panel_bg_padding; - mySize -= '2 2 0' * panel_bg_padding; - } - - //float panel_ar = mySize_x/mySize_y; - //bool is_vertical = (panel_ar < 1); - //float buff_iconalign = autocvar_hud_panel_buffs_iconalign; - vector buff_offset = '0 0 0'; - - for(e = Buff_Type_first; e; e = e.enemy) if(buffs & e.items) - { - //DrawNumIcon(pos + buff_offset, mySize, shield, "shield", is_vertical, buff_iconalign, '1 1 1', 1); - drawcolorcodedstring_aspect(pos + buff_offset, s, mySize, panel_fg_alpha * 0.5, DRAWFLAG_NORMAL); - } - - draw_endBoldFont(); - } - +// ItemsTime (#XX) +// +const float ITEMSTIME_MAXITEMS = 10; +float ItemsTime_time[ITEMSTIME_MAXITEMS]; +float ItemsTime_availableTime[ITEMSTIME_MAXITEMS]; +string GetItemsTimePicture(float i) +{ + switch(i) + { + case 0: return "item_large_armor"; + case 1: return "item_mega_health"; + case 2: return "item_strength"; + case 3: return "item_shield"; + case 4: return "item_mega_health"; + case 5: return "item_strength"; + case 6: return "item_shield"; + case 7: return "fuelregen"; + case 8: return "jetpack"; + case 9: return "superweapons"; + default: return ""; + } +} + +void DrawItemsTimeItem(vector myPos, vector mySize, float ar, float itemcode, float item_time, bool item_available, float item_availableTime) +{ + float t = 0; + vector color = '0 0 0'; + float picalpha; + + if(autocvar_hud_panel_itemstime_hidespawned == 2) + picalpha = 1; + else if(item_available) + { + float BLINK_FACTOR = 0.15; + float BLINK_BASE = 0.85; + float BLINK_FREQ = 5; + picalpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); + } + else + picalpha = 0.3; + t = floor(item_time - time + 0.999); + if(t < 5) + color = '0.7 0 0'; + else if(t < 10) + color = '0.7 0.7 0'; + else + color = '1 1 1'; + + vector picpos, numpos; + if(autocvar_hud_panel_itemstime_iconalign) + { + numpos = myPos; + picpos = myPos + eX * (ar - 1) * mySize_y; + } + else + { + numpos = myPos + eX * mySize_y; + picpos = myPos; + } + + if(t > 0 && autocvar_hud_panel_itemstime_progressbar) + { + vector p_pos, p_size; + if(autocvar_hud_panel_itemstime_progressbar_reduced) + { + p_pos = numpos; + p_size = eX * ((ar - 1)/ar) * mySize_x + eY * mySize_y; + } + else + { + p_pos = myPos; + p_size = mySize; + } + HUD_Panel_DrawProgressBar(p_pos, p_size, autocvar_hud_panel_itemstime_progressbar_name, t/autocvar_hud_panel_itemstime_progressbar_maxtime, 0, autocvar_hud_panel_itemstime_iconalign, color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL); + } + + if(t > 0 && autocvar_hud_panel_itemstime_text) + drawstring_aspect(numpos, ftos(t), eX * ((ar - 1)/ar) * mySize_x + eY * mySize_y, color, panel_fg_alpha, DRAWFLAG_NORMAL); + else + picpos.x = myPos.x + mySize.x / 2 - mySize.y / 2; + if(item_availableTime) + drawpic_aspect_skin_expanding(picpos, GetItemsTimePicture(itemcode), '1 1 0' * mySize_y, '1 1 1', panel_fg_alpha * picalpha, DRAWFLAG_NORMAL, item_availableTime); + drawpic_aspect_skin(picpos, GetItemsTimePicture(itemcode), '1 1 0' * mySize_y, '1 1 1', panel_fg_alpha * picalpha, DRAWFLAG_NORMAL); +} + +void HUD_ItemsTime(void) +{ + if(!autocvar__hud_configure) + { + if(!( + (autocvar_hud_panel_itemstime == 1 && spectatee_status != 0) + || (autocvar_hud_panel_itemstime == 2 && (spectatee_status != 0 || warmup_stage)) + )) { return; } + + ItemsTime_time[0] = getstatf(STAT_ARMOR_LARGE_TIME); + ItemsTime_time[1] = getstatf(STAT_HEALTH_MEGA_TIME); + ItemsTime_time[2] = getstatf(STAT_INVISIBLE_TIME); + ItemsTime_time[3] = getstatf(STAT_SPEED_TIME); + ItemsTime_time[4] = getstatf(STAT_EXTRALIFE_TIME); + ItemsTime_time[5] = getstatf(STAT_STRENGTH_TIME); + ItemsTime_time[6] = getstatf(STAT_SHIELD_TIME); + ItemsTime_time[7] = getstatf(STAT_FUELREGEN_TIME); + ItemsTime_time[8] = getstatf(STAT_JETPACK_TIME); + ItemsTime_time[9] = getstatf(STAT_SUPERWEAPONS_TIME); + } + else + { + // do not show here mutator-dependent items + ItemsTime_time[0] = time + 0; + ItemsTime_time[1] = time + 8; + ItemsTime_time[2] = -1; // mutator-dependent + ItemsTime_time[3] = -1; // mutator-dependent + ItemsTime_time[4] = -1; // mutator-dependent + ItemsTime_time[5] = time + 0; + ItemsTime_time[6] = time + 4; + ItemsTime_time[7] = time + 49; + ItemsTime_time[8] = -1; + ItemsTime_time[9] = time + 28; + } + + float i; + float count = 0; + if(autocvar_hud_panel_itemstime_hidespawned == 1) + for (i = 0; i < ITEMSTIME_MAXITEMS; ++i) + count += (ItemsTime_time[i] > time || -ItemsTime_time[i] > time); + else if(autocvar_hud_panel_itemstime_hidespawned == 2) + for (i = 0; i < ITEMSTIME_MAXITEMS; ++i) + count += (ItemsTime_time[i] > time); + else + for (i = 0; i < ITEMSTIME_MAXITEMS; ++i) + count += (ItemsTime_time[i] != -1); + if (count == 0) + return; + + HUD_Panel_UpdateCvars(); + + vector pos, mySize; + pos = panel_pos; + mySize = panel_size; + + if(panel_bg_padding) + { + pos += '1 1 0' * panel_bg_padding; + mySize -= '2 2 0' * panel_bg_padding; + } + + float rows, columns; + float ar = max(2, autocvar_hud_panel_itemstime_ratio) + 1; + rows = HUD_GetRowCount(count, mySize, ar); + columns = ceil(count/rows); + + vector itemstime_size = eX * mySize.x*(1/columns) + eY * mySize.y*(1/rows); + + vector offset = '0 0 0'; + float newSize; + if(autocvar_hud_panel_itemstime_dynamicsize) + { + if(autocvar__hud_configure) + if(menu_enabled != 2) + HUD_Panel_DrawBg(1); // also draw the bg of the entire panel + + // reduce panel to avoid spacing items + if(itemstime_size.x / itemstime_size.y < ar) + { + newSize = rows * itemstime_size.x / ar; + pos.y += (mySize.y - newSize) / 2; + mySize.y = newSize; + itemstime_size.y = mySize.y / rows; + } + else + { + newSize = columns * itemstime_size.y * ar; + pos.x += (mySize.x - newSize) / 2; + mySize.x = newSize; + itemstime_size.x = mySize.x / columns; + } + panel_pos = pos - '1 1 0' * panel_bg_padding; + panel_size = mySize + '2 2 0' * panel_bg_padding; + } + else + { + if(itemstime_size.x/itemstime_size.y > ar) + { + newSize = ar * itemstime_size.y; + offset.x = itemstime_size.x - newSize; + pos.x += offset.x/2; + itemstime_size.x = newSize; + } + else + { + newSize = 1/ar * itemstime_size.x; + offset.y = itemstime_size.y - newSize; + pos.y += offset.y/2; + itemstime_size.y = newSize; + } + } + + HUD_Panel_DrawBg(1); + + float row = 0, column = 0; + bool item_available; + for (i = 0; i < ITEMSTIME_MAXITEMS; ++i) { + if (ItemsTime_time[i] == -1) + continue; + + float item_time = ItemsTime_time[i]; + if(item_time < -1) + { + item_available = true; + item_time = -item_time; + } + else + item_available = (item_time <= time); + + if(ItemsTime_time[i] >= 0) + { + if(time <= ItemsTime_time[i]) + ItemsTime_availableTime[i] = 0; + else if(ItemsTime_availableTime[i] == 0) + ItemsTime_availableTime[i] = time; + } + else if(ItemsTime_availableTime[i] == 0) + ItemsTime_availableTime[i] = time; + + float f = (time - ItemsTime_availableTime[i]) * 2; + f = (f > 1) ? 0 : bound(0, f, 1); + + if(autocvar_hud_panel_itemstime_hidespawned == 1) + if(!(ItemsTime_time[i] > time || -ItemsTime_time[i] > time)) + continue; + + if(autocvar_hud_panel_itemstime_hidespawned == 2) + if(!(ItemsTime_time[i] > time)) + continue; + + DrawItemsTimeItem(pos + eX * column * (itemstime_size.x + offset.x) + eY * row * (itemstime_size.y + offset.y), itemstime_size, ar, i, item_time, item_available, f); + ++row; + if(row >= rows) + { + row = 0; + column = column + 1; + } + } +} + ++ /* ================== Main HUD system diff --cc qcsrc/client/hud.qh index 0bd85defc4,894066028f..72e3326429 --- a/qcsrc/client/hud.qh +++ b/qcsrc/client/hud.qh @@@ -142,27 -142,25 +142,26 @@@ float old_p_healthtime, old_p_armortime int prev_p_health, prev_p_armor; - #define HUD_PANELS(HUD_PANEL) \ - HUD_PANEL(WEAPONS , HUD_Weapons , weapons) \ - HUD_PANEL(AMMO , HUD_Ammo , ammo) \ - HUD_PANEL(POWERUPS , HUD_Powerups , powerups) \ - HUD_PANEL(HEALTHARMOR , HUD_HealthArmor , healtharmor) \ - HUD_PANEL(NOTIFY , HUD_Notify , notify) \ - HUD_PANEL(TIMER , HUD_Timer , timer) \ - HUD_PANEL(RADAR , HUD_Radar , radar) \ - HUD_PANEL(SCORE , HUD_Score , score) \ - HUD_PANEL(RACETIMER , HUD_RaceTimer , racetimer) \ - HUD_PANEL(VOTE , HUD_Vote , vote) \ - HUD_PANEL(MODICONS , HUD_ModIcons , modicons) \ - HUD_PANEL(PRESSEDKEYS , HUD_PressedKeys , pressedkeys) \ - HUD_PANEL(CHAT , HUD_Chat , chat) \ - HUD_PANEL(ENGINEINFO , HUD_EngineInfo , engineinfo) \ - HUD_PANEL(INFOMESSAGES , HUD_InfoMessages , infomessages) \ - HUD_PANEL(PHYSICS , HUD_Physics , physics) \ - HUD_PANEL(CENTERPRINT , HUD_CenterPrint , centerprint) \ - HUD_PANEL(BUFFS , HUD_Buffs , buffs) \ + #define HUD_PANELS(HUD_PANEL) \ + HUD_PANEL(WEAPONS , HUD_Weapons , weapons) \ + HUD_PANEL(AMMO , HUD_Ammo , ammo) \ + HUD_PANEL(POWERUPS , HUD_Powerups , powerups) \ + HUD_PANEL(HEALTHARMOR , HUD_HealthArmor , healtharmor) \ + HUD_PANEL(NOTIFY , HUD_Notify , notify) \ + HUD_PANEL(TIMER , HUD_Timer , timer) \ + HUD_PANEL(RADAR , HUD_Radar , radar) \ + HUD_PANEL(SCORE , HUD_Score , score) \ + HUD_PANEL(RACETIMER , HUD_RaceTimer , racetimer) \ + HUD_PANEL(VOTE , HUD_Vote , vote) \ + HUD_PANEL(MODICONS , HUD_ModIcons , modicons) \ + HUD_PANEL(PRESSEDKEYS , HUD_PressedKeys , pressedkeys) \ + HUD_PANEL(CHAT , HUD_Chat , chat) \ + HUD_PANEL(ENGINEINFO , HUD_EngineInfo , engineinfo) \ + HUD_PANEL(INFOMESSAGES , HUD_InfoMessages , infomessages) \ + HUD_PANEL(PHYSICS , HUD_Physics , physics) \ + HUD_PANEL(CENTERPRINT , HUD_CenterPrint , centerprint) \ HUD_PANEL(MAPVOTE , MapVote_Draw , mapvote) \ + HUD_PANEL(ITEMSTIME , HUD_ItemsTime , itemstime) \ // always add new panels to the end of list #define HUD_PANEL(NAME, draw_func, name) \ diff --cc qcsrc/common/stats.qh index 7c915696d7,f6faf634db..eb6b0ea970 --- a/qcsrc/common/stats.qh +++ b/qcsrc/common/stats.qh @@@ -170,11 -170,11 +170,11 @@@ const int STAT_PL_CROUCH_MAX3 const int STAT_PL_CROUCH_VIEW_OFS1 = 117; const int STAT_PL_CROUCH_VIEW_OFS2 = 118; const int STAT_PL_CROUCH_VIEW_OFS3 = 119; -// 120 empty? -// 121 empty? -// 122 empty? -// 123 empty? -// 124 empty? +const int STAT_WEAPONSINMAP = 120; +const int STAT_WEAPONSINMAP2 = 121; +const int STAT_WEAPONSINMAP3 = 122; - const int STAT_CTF_FLAGSTATUS = 123; - // 124 empty? ++const int STAT_BUFF_TIME = 123; ++const int STAT_CTF_FLAGSTATUS = 124; // 125 empty? // 126 empty? // 127 empty? diff --cc qcsrc/menu/xonotic/mainwindow.qc index 2a4635a408,a3e0727fba..4ca94c9b02 --- a/qcsrc/menu/xonotic/mainwindow.qc +++ b/qcsrc/menu/xonotic/mainwindow.qc @@@ -128,15 -128,7 +128,10 @@@ void MainWindow_configureMainWindow(ent i.configureDialog(i); me.addItemRightCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z); - i = NEW(XonoticHUDBuffsDialog); - i.configureDialog(i); - me.addItemRightCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z); - + i = NEW(XonoticHUDItemsTimeDialog); + i.configureDialog(i); + me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z); - // dialogs used by settings me.userbindEditDialog = i = NEW(XonoticUserbindEditDialog); i.configureDialog(i); diff --cc qcsrc/server/autocvars.qh index 758fbe1d29,5e1c01a11b..0b6d044753 --- a/qcsrc/server/autocvars.qh +++ b/qcsrc/server/autocvars.qh @@@ -625,10 -625,9 +625,10 @@@ float autocvar_sv_gameplayfix_q2airacce int autocvar_sv_gentle; #define autocvar_sv_gravity cvar("sv_gravity") string autocvar_sv_intermission_cdtrack; +float autocvar_sv_itemstime; - float autocvar_sv_jumpspeedcap_max; + string autocvar_sv_jumpspeedcap_max; float autocvar_sv_jumpspeedcap_max_disable_on_ramps; - float autocvar_sv_jumpspeedcap_min; + string autocvar_sv_jumpspeedcap_min; float autocvar_sv_jumpvelocity; bool autocvar_sv_logscores_bots; bool autocvar_sv_logscores_console;