]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge branch 'master' into terencehill/hud_updates 353/head
authorterencehill <piuntn@gmail.com>
Mon, 22 Aug 2016 13:10:10 +0000 (15:10 +0200)
committerterencehill <piuntn@gmail.com>
Mon, 22 Aug 2016 13:10:10 +0000 (15:10 +0200)
Conflicts:
qcsrc/client/hud/hud.qc

17 files changed:
1  2 
qcsrc/client/autocvars.qh
qcsrc/client/hud/hud.qc
qcsrc/client/hud/hud.qh
qcsrc/client/hud/panel/powerups.qc
qcsrc/client/hud/panel/quickmenu.qc
qcsrc/client/hud/panel/scoreboard.qc
qcsrc/client/mapvoting.qc
qcsrc/client/view.qc
qcsrc/common/minigames/minigame/bd.qc
qcsrc/common/minigames/minigame/c4.qc
qcsrc/common/minigames/minigame/nmm.qc
qcsrc/common/minigames/minigame/pong.qc
qcsrc/common/minigames/minigame/pp.qc
qcsrc/common/minigames/minigame/ps.qc
qcsrc/common/minigames/minigame/snake.qc
qcsrc/common/minigames/minigame/ttt.qc
qcsrc/common/mutators/mutator/itemstime/itemstime.qc

Simple merge
index f48d789c3ce55fd990684007217db724cc8d349f,f9ac20627518e16b4fbcec3b225b8540a6908e21..d200e2c6c522e67f05b009f301f9a03f5677d9db
@@@ -358,6 -357,18 +356,8 @@@ void HUD_Vehicle(
        }
  }
  
 -bool HUD_Panel_CheckFlags(int showflags)
 -{
 -    TC(int, showflags);
 -      if ( HUD_Minigame_Showpanels() )
 -              return showflags & PANEL_SHOW_MINIGAME;
 -      if(intermission == 2)
 -              return showflags & PANEL_SHOW_MAPVOTE;
 -      return showflags & PANEL_SHOW_MAINGAME;
 -}
 -
+ bool HUD_Minigame_Showpanels();
  void HUD_Panel_Draw(entity panent)
  {
        panel = panent;
Simple merge
Simple merge
index 69d57908788f10512a5bb3ee8d9de162ac65aca5,22a9827acc3f2a12b6b305db7bc4dc7aaac0a636..65997f46ebb0a9199ff8dde59756e88663b6d593
@@@ -1,11 -1,10 +1,11 @@@
  #include "quickmenu.qh"
 -// QuickMenu (#23)
  
  #include <common/ent_cs.qh>
- #include <client/hud/all.qh>
+ #include <client/hud/_mod.qh>
  #include <client/mapvoting.qh>
  
 +// QuickMenu (#23)
 +
  // QUICKMENU_MAXLINES must be <= 10
  const int QUICKMENU_MAXLINES = 10;
  // visible entries are loaded from QuickMenu_Buffer into QuickMenu_Page_* arrays
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
index 0000000000000000000000000000000000000000,3fe9de6d7d5f849ea9356d04b6930a59caf76769..1252c34ed75c3fab38ab84286146186c99931bf7
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,434 +1,434 @@@
 -    HUD_Panel_UpdateCvars();
+ #include "itemstime.qh"
+ REGISTER_MUTATOR(itemstime, true);
+ REGISTER_NET_TEMP(itemstime)
+ #ifdef SVQC
+ void IT_Write(entity e, int i, float f) {
+     if (!IS_REAL_CLIENT(e)) return;
+     msg_entity = e;
+     WriteHeader(MSG_ONE, itemstime);
+     WriteByte(MSG_ONE, i);
+     WriteFloat(MSG_ONE, f);
+ }
+ #endif
+ #ifdef CSQC
+ // reserve one more spot for superweapons time
+ float ItemsTime_time[Items_MAX + 1];
+ float ItemsTime_availableTime[Items_MAX + 1];
+ NET_HANDLE(itemstime, bool isNew)
+ {
+     int i = ReadByte();
+     float f = ReadFloat();
+     return = true;
+     ItemsTime_time[i] = f;
+ }
+ #endif
+ #ifdef CSQC
+ void Item_ItemsTime_Init()
+ {
+     FOREACH(Items, true, LAMBDA(
+         ItemsTime_time[it.m_id] = -1;
+     ));
+     ItemsTime_time[Items_MAX] = -1;
+ }
+ STATIC_INIT(ItemsTime_Init) {
+     Item_ItemsTime_Init();
+ }
+ int autocvar_hud_panel_itemstime = 2;
+ float autocvar_hud_panel_itemstime_dynamicsize = 1;
+ float autocvar_hud_panel_itemstime_ratio = 2;
+ int autocvar_hud_panel_itemstime_iconalign;
+ bool autocvar_hud_panel_itemstime_progressbar = 0;
+ float autocvar_hud_panel_itemstime_progressbar_maxtime = 30;
+ string autocvar_hud_panel_itemstime_progressbar_name = "progressbar";
+ float autocvar_hud_panel_itemstime_progressbar_reduced;
+ bool autocvar_hud_panel_itemstime_hidespawned = 1;
+ bool autocvar_hud_panel_itemstime_hidelarge = false;
+ int autocvar_hud_panel_itemstime_text = 1;
+ #define hud_panel_itemstime_hidelarge autocvar_hud_panel_itemstime_hidelarge
+ #else
+ #define hud_panel_itemstime_hidelarge false
+ #endif
+ bool Item_ItemsTime_SpectatorOnly(GameItem it)
+ {
+     return (false
+     || it == ITEM_ArmorMega     || (it == ITEM_ArmorLarge && !hud_panel_itemstime_hidelarge)
+     || it == ITEM_HealthMega    || (it == ITEM_HealthLarge && !hud_panel_itemstime_hidelarge)
+     );
+ }
+ bool Item_ItemsTime_Allow(GameItem it)
+ {
+     return (false
+     || it.instanceOfPowerup
+     || Item_ItemsTime_SpectatorOnly(it)
+     );
+ }
+ #ifdef SVQC
+ // reserve one more spot for superweapons time
+ float it_times[Items_MAX + 1];
+ void Item_ItemsTime_Init()
+ {
+     FOREACH(Items, Item_ItemsTime_Allow(it), LAMBDA(
+         it_times[it.m_id] = -1;
+     ));
+     it_times[Items_MAX] = -1;
+ }
+ STATIC_INIT(ItemsTime_Init) {
+     // items time
+     Item_ItemsTime_Init();
+ }
+ void Item_ItemsTime_ResetTimes()
+ {
+     FOREACH(Items, Item_ItemsTime_Allow(it), LAMBDA(
+         it_times[it.m_id] = (it_times[it.m_id] == -1) ? -1 : 0;
+     ));
+     it_times[Items_MAX] = (it_times[Items_MAX] == -1) ? -1 : 0;
+ }
+ void Item_ItemsTime_ResetTimesForPlayer(entity e)
+ {
+     FOREACH(Items, Item_ItemsTime_Allow(it), LAMBDA(
+         IT_Write(e, it.m_id, (it_times[it.m_id] == -1) ? -1 : 0);
+     ));
+     IT_Write(e, Items_MAX, (it_times[Items_MAX] == -1) ? -1 : 0);
+ }
+ void Item_ItemsTime_SetTimesForPlayer(entity e)
+ {
+     FOREACH(Items, Item_ItemsTime_Allow(it), LAMBDA(
+         IT_Write(e, it.m_id, it_times[it.m_id]);
+     ));
+     IT_Write(e, Items_MAX, it_times[Items_MAX]);
+ }
+ void Item_ItemsTime_SetTime(entity e, float t)
+ {
+     if (!autocvar_sv_itemstime)
+         return;
+     GameItem item = e.itemdef;
+     if (item.instanceOfGameItem)
+     {
+               if (!item.instanceOfWeaponPickup)
+                       it_times[item.m_id] = t;
+               else if (e.weapons & WEPSET_SUPERWEAPONS)
+                       it_times[Items_MAX] = t;
+     }
+ }
+ void Item_ItemsTime_SetTimesForAllPlayers()
+ {
+     FOREACH_CLIENT(IS_REAL_CLIENT(it) && (warmup_stage || !IS_PLAYER(it) || autocvar_sv_itemstime == 2), LAMBDA(Item_ItemsTime_SetTimesForPlayer(it)));
+ }
+ float Item_ItemsTime_UpdateTime(entity e, float t)
+ {
+     bool isavailable = (t == 0);
+     FOREACH_ENTITY_FLOAT(pure_data, false,
+     {
+         if(!(it.itemdef == e.itemdef || ((e.weapons & WEPSET_SUPERWEAPONS) && (it.weapons & WEPSET_SUPERWEAPONS) && clienttype(it) == CLIENTTYPE_NOTACLIENT)))
+             continue;
+         if (e == it) continue;
+         if (it.scheduledrespawntime <= time)
+             isavailable = true;
+         else if (t == 0 || it.scheduledrespawntime < t)
+             t = it.scheduledrespawntime;
+     });
+     if (isavailable)
+         t = -t; // let know the client there's another available item
+     return t;
+ }
+ MUTATOR_HOOKFUNCTION(itemstime, reset_map_global)
+ {
+     Item_ItemsTime_ResetTimes();
+     // ALL the times need to be reset before .reset()ing each item
+     // since Item_Reset schedules respawn of superweapons and powerups
+     FOREACH_ENTITY_FLOAT(pure_data, false,
+     {
+         if(IS_CLIENT(it))
+             continue;
+         if (it.reset) Item_ItemsTime_SetTime(it, 0);
+     });
+     Item_ItemsTime_SetTimesForAllPlayers();
+ }
+ MUTATOR_HOOKFUNCTION(itemstime, MakePlayerObserver)
+ {
+     entity player = M_ARGV(0, entity);
+     Item_ItemsTime_SetTimesForPlayer(player);
+ }
+ MUTATOR_HOOKFUNCTION(itemstime, ClientConnect, CBC_ORDER_LAST)
+ {
+     entity player = M_ARGV(0, entity);
+       if(IS_PLAYER(player))
+       {
+               // client became player on connection skipping putObserverInServer step
+               if (IS_REAL_CLIENT(player))
+               if (warmup_stage || autocvar_sv_itemstime == 2)
+                       Item_ItemsTime_SetTimesForPlayer(player);
+       }
+ }
+ MUTATOR_HOOKFUNCTION(itemstime, PlayerSpawn)
+ {
+     if (warmup_stage || autocvar_sv_itemstime == 2) return;
+     entity player = M_ARGV(0, entity);
+     Item_ItemsTime_ResetTimesForPlayer(player);
+ }
+ #endif
+ #ifdef CSQC
+ void DrawItemsTimeItem(vector myPos, vector mySize, float ar, string item_icon, 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.5;
+     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(autocvar_hud_panel_itemstime_text)
+     {
+         if(t > 0)
+             drawstring_aspect(numpos, ftos(t), eX * ((ar - 1)/ar) * mySize_x + eY * mySize_y, color, panel_fg_alpha, DRAWFLAG_NORMAL);
+         else if(precache_pic("gfx/hud/default/checkmark")) // COMPAT: check if this image exists, as 0.8.1 clients lack it
+             drawpic_aspect_skin(numpos, "checkmark", eX * (ar - 1) * mySize_y + eY * mySize_y, '1 1 1', panel_fg_alpha * picalpha, DRAWFLAG_NORMAL);
+         else // legacy code, if the image is missing just center the icon
+             picpos.x = myPos.x + mySize.x / 2 - mySize.y / 2;
+     }
+     if (item_availableTime)
+         drawpic_aspect_skin_expanding(picpos, item_icon, '1 1 0' * mySize_y, '1 1 1', panel_fg_alpha * picalpha, DRAWFLAG_NORMAL, item_availableTime);
+     drawpic_aspect_skin(picpos, item_icon, '1 1 0' * mySize_y, '1 1 1', panel_fg_alpha * picalpha, DRAWFLAG_NORMAL);
+ }
+ void HUD_ItemsTime()
+ {
+     if (!autocvar__hud_configure)
+     {
+         if (!(
+             (autocvar_hud_panel_itemstime == 1 && spectatee_status != 0)
+         ||    (autocvar_hud_panel_itemstime == 2 && (spectatee_status != 0 || warmup_stage || STAT(ITEMSTIME) == 2))
+             )) { return; }
+     }
+     else
+     {
+         ItemsTime_time[ITEM_ArmorMega.m_id] = time + 0;
+         ItemsTime_time[ITEM_HealthMega.m_id] = time + 8;
+         ItemsTime_time[ITEM_Strength.m_id] = time + 0;
+         ItemsTime_time[ITEM_Shield.m_id] = time + 4;
+     }
+     int count = 0;
+     if (autocvar_hud_panel_itemstime_hidespawned == 1)
+     {
+         FOREACH(Items, Item_ItemsTime_Allow(it), LAMBDA(
+             count += (ItemsTime_time[it.m_id] > time || -ItemsTime_time[it.m_id] > time);
+         ));
+         count += (ItemsTime_time[Items_MAX] > time || -ItemsTime_time[Items_MAX] > time);
+     }
+     else if (autocvar_hud_panel_itemstime_hidespawned == 2)
+     {
+         FOREACH(Items, Item_ItemsTime_Allow(it), LAMBDA(
+             count += (ItemsTime_time[it.m_id] > time);
+         ));
+         count += (ItemsTime_time[Items_MAX] > time);
+     }
+     else
+     {
+         FOREACH(Items, Item_ItemsTime_Allow(it), LAMBDA(
+             count += (ItemsTime_time[it.m_id] != -1);
+         ));
+         count += (ItemsTime_time[Items_MAX] != -1);
+     }
+     if (count == 0)
+         return;
 -            HUD_Panel_DrawBg(1); // also draw the bg of the entire panel
++    HUD_Panel_LoadCvars();
+     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 (hud_configure_menu_open != 2)
 -    HUD_Panel_DrawBg(1);
++            HUD_Panel_DrawBg(); // 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_Scale_Enable();
++    HUD_Panel_DrawBg();
+     float row = 0, column = 0;
+     bool item_available;
+     int id = 0;
+     string icon = "";
+     FOREACH(Items, Item_ItemsTime_Allow(it) && ItemsTime_time[it.m_id] != -1, LAMBDA(
+       id = it.m_id;
+       icon = it.m_icon;
+ LABEL(iteration)
+         float item_time = ItemsTime_time[id];
+         if (item_time < -1)
+         {
+             item_available = true;
+             item_time = -item_time;
+         }
+         else
+             item_available = (item_time <= time);
+         if (ItemsTime_time[id] >= 0)
+         {
+             if (time <= ItemsTime_time[id])
+                 ItemsTime_availableTime[id] = 0;
+             else if (ItemsTime_availableTime[id] == 0)
+                 ItemsTime_availableTime[id] = time;
+         }
+         else if (ItemsTime_availableTime[id] == 0)
+             ItemsTime_availableTime[id] = time;
+         float f = (time - ItemsTime_availableTime[id]) * 2;
+         f = (f > 1) ? 0 : bound(0, f, 1);
+         if (autocvar_hud_panel_itemstime_hidespawned == 1)
+             if (!(ItemsTime_time[id] > time || -ItemsTime_time[id] > time))
+                 continue;
+         if (autocvar_hud_panel_itemstime_hidespawned == 2)
+             if (!(ItemsTime_time[id] > time))
+                 continue;
+         DrawItemsTimeItem(pos + eX * column * (itemstime_size.x + offset.x) + eY * row * (itemstime_size.y + offset.y), itemstime_size, ar, icon, item_time, item_available, f);
+         ++row;
+         if (row >= rows)
+         {
+             row = 0;
+             column = column + 1;
+         }
+         if(id == Items_MAX) // can happen only in the last fake iteration
+               break;
+     ));
+     // add another fake iteration for superweapons time
+     if(id < Items_MAX && ItemsTime_time[Items_MAX] != -1)
+     {
+               id = Items_MAX;
+               icon = "superweapons";
+               goto iteration;
+     }
+ }
+ #endif