X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fclient%2Fhud%2Fpanel%2Fmodicons.qc;h=bf302fdfa3f3cff6f2fcc701e269821a4a8b1f7f;hb=451e02a2857d8c671f6dcf6a0639ea7c609b3ba9;hp=b869f96194534954de800f66802e31917832e309;hpb=c6ebaefab2aca7df4648dac3ccdd4b52de45d0ed;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/client/hud/panel/modicons.qc b/qcsrc/client/hud/panel/modicons.qc index b869f9619..bf302fdfa 100644 --- a/qcsrc/client/hud/panel/modicons.qc +++ b/qcsrc/client/hud/panel/modicons.qc @@ -4,7 +4,7 @@ #include #include // TODO: remove -// Mod icons panel (#10) +// Mod icons (#10) bool mod_active; // is there any active mod icon? @@ -16,27 +16,11 @@ void DrawCAItem(vector myPos, vector mySize, float aspect_ratio, int layout, int vector color = '0 0 0'; switch(i) { - case 0: - stat = STAT(REDALIVE); - pic = "player_red.tga"; - color = '1 0 0'; - break; - case 1: - stat = STAT(BLUEALIVE); - pic = "player_blue.tga"; - color = '0 0 1'; - break; - case 2: - stat = STAT(YELLOWALIVE); - pic = "player_yellow.tga"; - color = '1 1 0'; - break; + case 0: stat = STAT(REDALIVE); pic = "player_red"; color = '1 0 0'; break; + case 1: stat = STAT(BLUEALIVE); pic = "player_blue"; color = '0 0 1'; break; + case 2: stat = STAT(YELLOWALIVE); pic = "player_yellow"; color = '1 1 0'; break; default: - case 3: - stat = STAT(PINKALIVE); - pic = "player_pink.tga"; - color = '1 0 1'; - break; + case 3: stat = STAT(PINKALIVE); pic = "player_pink"; color = '1 0 1'; break; } if(mySize.x/mySize.y > aspect_ratio) @@ -108,6 +92,7 @@ void HUD_Mod_CTF_Reset() redflag_statuschange_time = blueflag_statuschange_time = yellowflag_statuschange_time = pinkflag_statuschange_time = neutralflag_statuschange_time = 0; } +int autocvar__teams_available; void HUD_Mod_CTF(vector pos, vector mySize) { vector redflag_pos, blueflag_pos, yellowflag_pos, pinkflag_pos, neutralflag_pos; @@ -122,6 +107,8 @@ void HUD_Mod_CTF(vector pos, vector mySize) float fs, fs2, fs3, size1, size2; vector e1, e2; + int nteams = autocvar__teams_available; + redflag = (stat_items/CTF_RED_FLAG_TAKEN) & 3; blueflag = (stat_items/CTF_BLUE_FLAG_TAKEN) & 3; yellowflag = (stat_items/CTF_YELLOW_FLAG_TAKEN) & 3; @@ -137,9 +124,9 @@ void HUD_Mod_CTF(vector pos, vector mySize) if (autocvar__hud_configure) { redflag = 1; blueflag = 2; - if (team_count >= 3) + if (nteams & BIT(2)) yellowflag = 2; - if (team_count >= 4) + if (nteams & BIT(3)) pinkflag = 3; ctf_oneflag = neutralflag = 0; // disable neutral flag in hud editor? } @@ -201,18 +188,24 @@ void HUD_Mod_CTF(vector pos, vector mySize) break; \ } \ } MACRO_END - X(red, myteam != NUM_TEAM_1); - X(blue, myteam != NUM_TEAM_2); - X(yellow, myteam != NUM_TEAM_3 && team_count >= 3); - X(pink, myteam != NUM_TEAM_4 && team_count >= 4); + X(red, myteam != NUM_TEAM_1 && (nteams & BIT(0))); + X(blue, myteam != NUM_TEAM_2 && (nteams & BIT(1))); + X(yellow, myteam != NUM_TEAM_3 && (nteams & BIT(2))); + X(pink, myteam != NUM_TEAM_4 && (nteams & BIT(3))); X(neutral, ctf_oneflag); #undef X + int tcount = 2; + if(nteams & BIT(2)) + tcount = 3; + if(nteams & BIT(3)) + tcount = 4; + if (ctf_oneflag) { // hacky, but these aren't needed red_icon = red_icon_prevstatus = blue_icon = blue_icon_prevstatus = yellow_icon = yellow_icon_prevstatus = pink_icon = pink_icon_prevstatus = string_null; fs = fs2 = fs3 = 1; - } else switch (team_count) { + } else switch (tcount) { default: case 2: fs = 0.5; fs2 = 0.5; fs3 = 0.5; break; case 3: fs = 1; fs2 = 0.35; fs3 = 0.35; break; @@ -267,6 +260,8 @@ void HUD_Mod_CTF(vector pos, vector mySize) #define X(team) MACRO_BEGIN { \ f = bound(0, team##flag_statuschange_elapsedtime * 2, 1); \ + if (team##_icon && ctf_stalemate) \ + drawpic_aspect_skin(team##flag_pos, "flag_stalemate", flag_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); \ if (team##_icon_prevstatus && f < 1) \ drawpic_aspect_skin_expanding(team##flag_pos, team##_icon_prevstatus, flag_size, '1 1 1', panel_fg_alpha * team##_alpha_prevstatus, DRAWFLAG_NORMAL, f); \ if (team##_icon) \ @@ -288,8 +283,9 @@ void HUD_Mod_KH(vector pos, vector mySize) mod_active = 1; // keyhunt should never hide the mod icons panel // Read current state - int state = STAT(KH_KEYS); + if(!state) return; + int i, key_state; int all_keys, team1_keys, team2_keys, team3_keys, team4_keys, dropped_keys, carrying_keys; all_keys = team1_keys = team2_keys = team3_keys = team4_keys = dropped_keys = carrying_keys = 0; @@ -320,9 +316,7 @@ void HUD_Mod_KH(vector pos, vector mySize) } // Calculate slot measurements - vector slot_size; - if(all_keys == 4 && mySize.x * 0.5 < mySize.y && mySize.y * 0.5 < mySize.x) { // Quadratic arrangement @@ -352,11 +346,10 @@ void HUD_Mod_KH(vector pos, vector mySize) // Make icons blink in case of RUN HERE - float blink = 0.6 + sin(2*M_PI*time) / 2.5; // Oscillate between 0.2 and 1 - float alpha; - alpha = 1; - + float alpha = 1; if(carrying_keys) + { + float blink = 0.6 + sin(2 * M_PI * time) * 0.4; // Oscillate between 0.2 and 1 switch(myteam) { case NUM_TEAM_1: if(team1_keys == all_keys) alpha = blink; break; @@ -364,6 +357,7 @@ void HUD_Mod_KH(vector pos, vector mySize) case NUM_TEAM_3: if(team3_keys == all_keys) alpha = blink; break; case NUM_TEAM_4: if(team4_keys == all_keys) alpha = blink; break; } + } // Draw icons @@ -521,9 +515,9 @@ void HUD_Mod_Race(vector pos, vector mySize) entity me; me = playerslots[player_localnum]; float score; - score = me.(scores[ps_primary]); + score = me.(scores(ps_primary)); - if(!(scores_flags[ps_primary] & SFL_TIME) || teamplay) // race/cts record display on HUD + if(!(scores_flags(ps_primary) & SFL_TIME) || teamplay) // race/cts record display on HUD return; // no records in the actual race // clientside personal record @@ -643,29 +637,15 @@ void DrawDomItem(vector myPos, vector mySize, float aspect_ratio, int layout, in vector color = '0 0 0'; switch(i) { - case 0: - stat = STAT(DOM_PPS_RED); - pic = "dom_icon_red"; - color = '1 0 0'; - break; - case 1: - stat = STAT(DOM_PPS_BLUE); - pic = "dom_icon_blue"; - color = '0 0 1'; - break; - case 2: - stat = STAT(DOM_PPS_YELLOW); - pic = "dom_icon_yellow"; - color = '1 1 0'; - break; + case 0: stat = STAT(DOM_PPS_RED); pic = "dom_icon_red"; color = '1 0 0'; break; + case 1: stat = STAT(DOM_PPS_BLUE); pic = "dom_icon_blue"; color = '0 0 1'; break; + case 2: stat = STAT(DOM_PPS_YELLOW); pic = "dom_icon_yellow"; color = '1 1 0'; break; default: - case 3: - stat = STAT(DOM_PPS_PINK); - pic = "dom_icon_pink"; - color = '1 0 1'; - break; + case 3: stat = STAT(DOM_PPS_PINK); pic = "dom_icon_pink"; color = '1 0 1'; break; } - float pps_ratio = stat / STAT(DOM_TOTAL_PPS); + float pps_ratio = 0; + if(STAT(DOM_TOTAL_PPS)) + pps_ratio = stat / STAT(DOM_TOTAL_PPS); if(mySize.x/mySize.y > aspect_ratio) { @@ -732,18 +712,7 @@ void HUD_Mod_Dom(vector myPos, vector mySize) void HUD_ModIcons_SetFunc() { - switch(gametype) - { - case MAPINFO_TYPE_KEYHUNT: HUD_ModIcons_GameType = HUD_Mod_KH; break; - case MAPINFO_TYPE_CTF: HUD_ModIcons_GameType = HUD_Mod_CTF; break; - case MAPINFO_TYPE_NEXBALL: HUD_ModIcons_GameType = HUD_Mod_NexBall; break; - case MAPINFO_TYPE_CTS: - case MAPINFO_TYPE_RACE: HUD_ModIcons_GameType = HUD_Mod_Race; break; - case MAPINFO_TYPE_CA: - case MAPINFO_TYPE_FREEZETAG: HUD_ModIcons_GameType = HUD_Mod_CA; break; - case MAPINFO_TYPE_DOMINATION: HUD_ModIcons_GameType = HUD_Mod_Dom; break; - case MAPINFO_TYPE_KEEPAWAY: HUD_ModIcons_GameType = HUD_Mod_Keepaway; break; - } + HUD_ModIcons_GameType = gametype.m_modicons; } int mod_prev; // previous state of mod_active to check for a change @@ -758,9 +727,6 @@ void HUD_ModIcons() if(!HUD_ModIcons_GameType) return; } - HUD_Panel_UpdateCvars(); - - draw_beginBoldFont(); if(mod_active != mod_prev) { mod_change = time; @@ -772,12 +738,19 @@ void HUD_ModIcons() else mod_alpha = bound(0, 1 - (time - mod_change) * 2, 1); + //if(mod_alpha <= 0) + // return; + panel_fade_alpha *= mod_alpha; + HUD_Panel_LoadCvars(); + + draw_beginBoldFont(); + if (autocvar_hud_panel_modicons_dynamichud) HUD_Scale_Enable(); else HUD_Scale_Disable(); - if(mod_alpha) - HUD_Panel_DrawBg(mod_alpha); + + HUD_Panel_DrawBg(); if(panel_bg_padding) {