]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
"complain" message bubble for weaponicons panel
authorFruitieX <rasse@rasse-lappy.localdomain>
Tue, 29 Jun 2010 13:44:38 +0000 (16:44 +0300)
committerFruitieX <rasse@rasse-lappy.localdomain>
Tue, 29 Jun 2010 13:44:38 +0000 (16:44 +0300)
hud_wickedhud_default.cfg
qcsrc/client/Main.qc
qcsrc/client/hud.qc
qcsrc/client/hud.qh
qcsrc/common/constants.qh
qcsrc/server/cl_weaponsystem.qc

index dfb3a89fa944d0a10ad4e49c1de2219cef573f59..f755101411bc21882cd7c947ee402da6335815f5 100644 (file)
@@ -25,6 +25,10 @@ seta hud_weaponicons_pos "0.930000 0.090000" "position of this panel"
 seta hud_weaponicons_size "0.040000 0.490000" "size of this panel"
 seta hud_weaponicons_number 1 "show number of weapon"
 seta hud_weaponicons_accuracy_yellow 40 "percentage at which the accuracy color is yellow"
+seta hud_weaponicons_complainbubble 1 "complain bubble (out of ammo, weapon not available etc)"
+seta hud_weaponicons_complainbubble_size 1 "size multiplier of the complain bubble"
+seta hud_weaponicons_complainbubble_time 1 "time that a new entry stays until it fades out"
+seta hud_weaponicons_complainbubble_fadetime 0.25 "fade out time"
 seta hud_weaponicons_bg "border_weaponicons" "if set to something else than \"\" = override default background"
 seta hud_weaponicons_bg_color "" "if set to something else than \"\" = override default panel background color"
 seta hud_weaponicons_bg_color_team "" "override panel color with team color in team based games"
index b34e843793311ddfc9a13b9dcd3450daf24409a7..369f8741ca061c5302ba41ce379530509e99ad73 100644 (file)
@@ -183,6 +183,7 @@ void CSQC_Init(void)
        minimapname = strzone(minimapname);
 
        WarpZone_Init();
+       hud_configure_prev = -1;
 }
 
 // CSQC_Shutdown : Called every time the CSQC code is shutdown (changing maps, quitting, etc)
@@ -1251,6 +1252,18 @@ void Net_Notify() {
        }
 }
 
+void Net_WeaponComplain() {
+       complain_weapon = ReadByte();
+
+       if(complain_weapon_name)
+               strunzone(complain_weapon_name);
+       complain_weapon_name = strzone(ReadString());
+
+       complain_weapon_type = ReadByte();
+
+       complain_weapon_time = time;
+}
+
 // CSQC_Parse_TempEntity : Handles all temporary entity network data in the CSQC layer.
 // You must ALWAYS first acquire the temporary ID, which is sent as a byte.
 // Return value should be 1 if CSQC handled the temporary entity, otherwise return 0 to have the engine process the event.
@@ -1321,6 +1334,10 @@ float CSQC_Parse_TempEntity()
                        Net_Notify();
                        bHandled = true;
                        break;
+               case TE_CSQC_WEAPONCOMPLAIN:
+                       Net_WeaponComplain();
+                       bHandled = true;
+                       break;
                default:
                        // No special logic for this temporary entity; return 0 so the engine can handle it
                        bHandled = false;
index dac378fa719796dbd8b936e8a9009a1877849cd6..b2830bbb966fc4ce75933678b9eb586d115d5e0e 100644 (file)
@@ -1586,6 +1586,13 @@ void HUD_WeaponIcons(void)
 
        columns = ceil(WEP_COUNT/rows);
        float row, column;
+
+       float a;
+       float when;
+       when = cvar("hud_weaponicons_complainbubble_time");
+       float fadetime;
+       fadetime = cvar("hud_weaponicons_complainbubble_fadetime");
+
        for(i = 0; i < weapon_cnt; ++i)
        {
                self = weaponorder[i];
@@ -1625,6 +1632,45 @@ void HUD_WeaponIcons(void)
                        drawpic_skin(pos + eX * column * mySize_x*(1/columns) + eY * row * mySize_y*(1/rows), strcat("weapon", self.netname), eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows), '0 0 0', HUD_Panel_GetFgAlpha(id) * 0.5, DRAWFLAG_NORMAL);
                }
 
+               // draw the complain message
+               if(time - complain_weapon_time < when + fadetime && self.weapon == complain_weapon && cvar("hud_weaponicons_complainbubble"))
+               {
+                       if(fadetime)
+                       {
+                               if(complain_weapon_time + when > time)
+                                       a = 1;
+                               else
+                                       a = bound(0, (complain_weapon_time + when + fadetime - time) / fadetime, 1);
+                       }
+                       else
+                       {
+                               if(complain_weapon_time + when > time)
+                                       a = 1;
+                               else
+                                       a = 0;
+                       }
+
+                       vector complain_bubble_size = '100 50 0' * bound(0.25, cvar("hud_weaponicons_complainbubble_size"), 2);
+                       drawpic_skin(pos + eX * column * mySize_x*(1/columns) + eY * row * mySize_y*(1/rows) - complain_bubble_size + 0.5 * (eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows)), "weapon_complainbubble", complain_bubble_size, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
+
+                       string s;
+                       vector color;
+                       if(complain_weapon_type == 0) {
+                               s = "Out of ammo for the";
+                               color = '1 0 0';
+                       }
+                       else if(complain_weapon_type == 1) {
+                               s = "You don't have the";
+                               color = '1 1 0';
+                       }
+                       else {
+                               s = "Map doesn't have the";
+                               color = '1 1 1';
+                       }
+                       drawstring_aspect(pos + eX * column * mySize_x*(1/columns) + eY * row * mySize_y*(1/rows) - complain_bubble_size + eX * 0.05 * complain_bubble_size_x + eY * (1/6) * complain_bubble_size_y + 0.5 * (eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows)), s, eX * 0.9 * complain_bubble_size_x + eY * 0.2 * complain_bubble_size_y, 0.2 * complain_bubble_size_y, color, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
+                       drawstring_aspect(pos + eX * column * mySize_x*(1/columns) + eY * row * mySize_y*(1/rows) - complain_bubble_size + eX * 0.05 * complain_bubble_size_x + eY * (11/30) * complain_bubble_size_y + 0.5 * (eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows)), complain_weapon_name, eX * 0.9 * complain_bubble_size_x + eY * 0.25 * complain_bubble_size_y, 0.25 * complain_bubble_size_y, '1 0 0', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
+               }
+
                ++row;
                if(row >= rows)
                {
@@ -4523,7 +4569,6 @@ void HUD_Reset (void)
                HUD_Mod_CTF_Reset();
 }
 
-float hud_configure_prev = -1;
 void HUD_Main (void)
 {
        if(disable_menu_alphacheck == 1)
index 16bbdfaebf23003ee7e5bef699c6e91c91e4e1e4..7dd5d6aa5e6812b1c991cd42346c9c88ce4fe191 100644 (file)
@@ -13,6 +13,11 @@ float weapon_hits[WEP_MAXCOUNT];
 float weapon_fired[WEP_MAXCOUNT];
 float weapon_number;
 
+float complain_weapon;
+string complain_weapon_name;
+float complain_weapon_type;
+float complain_weapon_time;
+
 float ps_primary, ps_secondary;
 float ts_primary, ts_secondary;
 
@@ -27,6 +32,7 @@ float hud_accuracy_border_thickness;
 
 float hud_configure;
 float hud_configure_checkcollisions;
+float hud_configure_prev;
 
 float hudShiftState;
 const float S_SHIFT = 1;
index 29d2704fd43a3376387041408e084afb857530fe..87d12ff31f96ad812d2c2e8dcd25280a6b843a62 100644 (file)
@@ -58,6 +58,7 @@ const float TE_CSQC_VOTERESET = 109;
 const float TE_CSQC_ANNOUNCE = 110;
 const float TE_CSQC_TARGET_MUSIC = 111;
 const float TE_CSQC_NOTIFY = 112;
+const float TE_CSQC_WEAPONCOMPLAIN = 113;
 
 const float RACE_NET_CHECKPOINT_HIT_QUALIFYING = 0; // byte checkpoint, short time, short recordtime, string recordholder
 const float RACE_NET_CHECKPOINT_CLEAR = 1;
index 15898759ede6b82578b755a365ecebcda5a1cc36..3f8581a432df5685604aaf365af5cf449c9b25e0 100644 (file)
@@ -907,6 +907,16 @@ void CL_SpawnWeaponentity()
        self.exteriorweaponentity.nextthink = time;
 };
 
+void Send_WeaponComplain (entity e, float wpn, string wpnname, float type)
+{
+       msg_entity = e;
+       WriteByte(MSG_ONE, SVC_TEMPENTITY);
+       WriteByte(MSG_ONE, TE_CSQC_WEAPONCOMPLAIN);
+       WriteByte(MSG_ONE, wpn);
+       WriteString(MSG_ONE, wpnname);
+       WriteByte(MSG_ONE, type);
+}
+
 .float hasweapon_complain_spam;
 
 float client_hasweapon(entity cl, float wpn, float andammo, float complain)
@@ -949,6 +959,7 @@ float client_hasweapon(entity cl, float wpn, float andammo, float complain)
                                {
                                        play2(cl, "weapons/unavailable.wav");
                                        sprint(cl, strcat("You don't have any ammo for the ^2", W_Name(wpn), "\n"));
+                                       Send_WeaponComplain (cl, wpn, W_Name(wpn), 0);
                                }
                                return FALSE;
                        }
@@ -962,6 +973,7 @@ float client_hasweapon(entity cl, float wpn, float andammo, float complain)
                if(weaponsInMap & weaponbit)
                {
                        sprint(cl, strcat("You do not have the ^2", W_Name(wpn), "\n") );
+                       Send_WeaponComplain (cl, wpn, W_Name(wpn), 1);
 
                        if(cvar("g_showweaponspawns"))
                        {
@@ -989,7 +1001,10 @@ float client_hasweapon(entity cl, float wpn, float andammo, float complain)
                        }
                }
                else
+               {
+                       Send_WeaponComplain (cl, wpn, W_Name(wpn), 2);
                        sprint(cl, strcat("The ^2", W_Name(wpn), "^7 is ^1NOT AVAILABLE^7 in this map\n") );
+               }
 
                play2(cl, "weapons/unavailable.wav");
        }