From: FruitieX Date: Tue, 29 Jun 2010 13:44:38 +0000 (+0300) Subject: "complain" message bubble for weaponicons panel X-Git-Tag: xonotic-v0.1.0preview~457^2~54 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=7feae33db7baea2b1c83d591cdb38befc976b7fe;p=xonotic%2Fxonotic-data.pk3dir.git "complain" message bubble for weaponicons panel --- diff --git a/hud_wickedhud_default.cfg b/hud_wickedhud_default.cfg index dfb3a89fa..f75510141 100644 --- a/hud_wickedhud_default.cfg +++ b/hud_wickedhud_default.cfg @@ -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" diff --git a/qcsrc/client/Main.qc b/qcsrc/client/Main.qc index b34e84379..369f8741c 100644 --- a/qcsrc/client/Main.qc +++ b/qcsrc/client/Main.qc @@ -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; diff --git a/qcsrc/client/hud.qc b/qcsrc/client/hud.qc index dac378fa7..b2830bbb9 100644 --- a/qcsrc/client/hud.qc +++ b/qcsrc/client/hud.qc @@ -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) diff --git a/qcsrc/client/hud.qh b/qcsrc/client/hud.qh index 16bbdfaeb..7dd5d6aa5 100644 --- a/qcsrc/client/hud.qh +++ b/qcsrc/client/hud.qh @@ -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; diff --git a/qcsrc/common/constants.qh b/qcsrc/common/constants.qh index 29d2704fd..87d12ff31 100644 --- a/qcsrc/common/constants.qh +++ b/qcsrc/common/constants.qh @@ -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; diff --git a/qcsrc/server/cl_weaponsystem.qc b/qcsrc/server/cl_weaponsystem.qc index 15898759e..3f8581a43 100644 --- a/qcsrc/server/cl_weaponsystem.qc +++ b/qcsrc/server/cl_weaponsystem.qc @@ -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"); }