X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fclient%2Fhud.qc;h=c4bd34bc6b8aabdab7f70462ba3ccbbb77d7cac1;hb=1c4689c881297c46fffec3cf5a588967eb9d7dd0;hp=8c2f246bc205be25d7b4935289a8f129c75271e5;hpb=02822bfc374b7e1edbbf650000b6ac409602d73f;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/client/hud.qc b/qcsrc/client/hud.qc index 8c2f246bc..c4bd34bc6 100644 --- a/qcsrc/client/hud.qc +++ b/qcsrc/client/hud.qc @@ -550,26 +550,6 @@ HUD panels ================== */ -string HUD_Panel_GetName(float id) -{ - switch(id) { - case 0: return "weaponicons"; break; - case 1: return "inventory"; break; - case 2: return "powerups"; break; - case 3: return "healtharmor"; break; - case 4: return "notify"; break; - case 5: return "timer"; break; - case 6: return "radar"; break; - case 7: return "score"; break; - case 8: return "racetimer"; break; - case 9: return "vote"; break; - case 10: return "modicons"; break; - case 11: return "pressedkeys"; break; - case 12: return "chat"; break; - default: return ""; - } -} - // Save the config void HUD_Panel_ExportCfg(string cfgname) { @@ -604,7 +584,7 @@ void HUD_Panel_ExportCfg(string cfgname) // common cvars for all panels float i; - for (i = 0; i < panel_cnt; ++i) + for (i = 0; i < HUD_PANEL_NUM; ++i) { fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), " ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i)))), "\n")); fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_pos \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_pos")), "\"", "\n")); @@ -896,7 +876,7 @@ vector HUD_Panel_CheckMove(float id, vector myPos, vector mySize) myCenter = '0 0 0'; // shut up fteqcc, there IS a reference targCenter = '0 0 0'; // shut up fteqcc, there IS a reference - for (i = 0; i < panel_cnt; ++i) { + for (i = 0; i < HUD_PANEL_NUM; ++i) { if(i == id || !HUD_Panel_CheckActive(i)) continue; @@ -1000,7 +980,7 @@ vector HUD_Panel_CheckResize(float id, vector myPos, vector mySize) myCenter = '0 0 0'; // shut up fteqcc, there IS a reference targCenter = '0 0 0'; // shut up fteqcc, there IS a reference - for (i = 0; i < panel_cnt; ++i) { + for (i = 0; i < HUD_PANEL_NUM; ++i) { if(i == id || !HUD_Panel_CheckActive(i)) continue; @@ -1161,11 +1141,26 @@ void HUD_Panel_SetPosSize(float id, vector resizeorigin) float mouseClicked; float prevMouseClicked; // previous state +float prevMouseClickedTime; // time during previous mouse click, to check for doubleclicks +vector prevMouseClickedPos; // pos during previous mouse click, to check for doubleclicks float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary) { if(!hud_configure) return false; + // allow console bind to work + string con_keys; + float keys; + con_keys = findkeysforcommand("toggleconsole"); + keys = tokenize(con_keys); + + float hit_con_bind, i; + for (i = 0; i < keys; ++i) + { + if(nPrimary == stof(argv(i))) + hit_con_bind = 1; + } + prevMouseClicked = mouseClicked; if(nPrimary == K_MOUSE1) { @@ -1179,7 +1174,12 @@ float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary) } } else if(nPrimary == K_ESCAPE) - cvar_set("_hud_configure", "0"); + { + localcmd("menu_showhudexit\n"); + } + + else if(hit_con_bind) + return false; return true; // Suppress ALL other input } @@ -1200,16 +1200,26 @@ void HUD_Panel_Mouse() if(mouseClicked) { + if(time - prevMouseClickedTime < 0.4 && prevMouseClicked == 0 && prevMouseClickedPos == mousepos) + { + mouseClicked = 0; // to prevent spam, I guess. + print("Doubleclick!\n"); + return; + } + float i, border; vector panelPos; vector panelSize; - for(i = 0; i <= panel_cnt; ++i) + for(i = 0; i <= HUD_PANEL_NUM; ++i) { panelPos = HUD_Panel_GetPos(i); panelSize = HUD_Panel_GetSize(i); border = HUD_Panel_GetBorder(i); if(prevMouseClicked == 0) { + prevMouseClickedTime = time; + prevMouseClickedPos = mousepos; + // move if(mousepos_x >= panelPos_x && mousepos_y >= panelPos_y && mousepos_x <= panelPos_x + panelSize_x && mousepos_y <= panelPos_y + panelSize_y) { @@ -1314,7 +1324,7 @@ float weaponorder_cmp(float i, float j, entity pass) void HUD_WeaponIcons() { - float id = 0; + float id = HUD_PANEL_WEAPONICONS; float alpha, stat_weapons; // "constants" vector pos, mySize, accuracy_color; float i, weapid, fade, weapon_stats, weapon_hit, weapon_damage, weapon_cnt; // variables @@ -1456,7 +1466,7 @@ string GetAmmoPicture(float i) void HUD_Inventory() { - float id = 1; + float id = HUD_PANEL_INVENTORY; float i; float stat_items; @@ -1482,13 +1492,17 @@ void HUD_Inventory() a = 100; if(cvar("hud_inventory_onlycurrent")) { - if (stat_items & GetAmmoItemCode(i)) { + if(hud_configure) + i = 2; + if (stat_items & GetAmmoItemCode(i) || hud_configure) { drawpic_skin(pos, GetAmmoPicture(i), '1 1 0' * mySize_y, '1 1 1', hud_fg_alpha, DRAWFLAG_NORMAL); if(a < 10) HUD_DrawXNum(pos + eX * mySize_y + eY * 0.25 * mySize_y, a, strlen(ftos(a)), 0, 0.5 * mySize_y, '0.7 0 0', 0, 0, hud_fg_alpha, DRAWFLAG_NORMAL); else HUD_DrawXNum(pos + eX * mySize_y + eY * 0.25 * mySize_y, a, strlen(ftos(a)), 0, 0.5 * mySize_y, '1 1 1', 0, 0, hud_fg_alpha, DRAWFLAG_NORMAL); } + if(hud_configure) + break; } else { if (a > 0) { if(mySize_x/mySize_y >= 10) { // arrange horizontally @@ -1543,7 +1557,7 @@ void HUD_Inventory() // Powerups (#2) // void HUD_Powerups() { - float id = 2; + float id = HUD_PANEL_POWERUPS; float stat_items; stat_items = getstati(STAT_ITEMS); @@ -1767,7 +1781,7 @@ void HUD_Powerups() { // void HUD_HealthArmor(void) { - float id = 3; + float id = HUD_PANEL_HEALTHARMOR; vector pos, mySize; pos = HUD_Panel_GetPos(id); mySize = HUD_Panel_GetSize(id); @@ -2398,7 +2412,7 @@ void HUD_Centerprint(string s1, float type, float msg) void HUD_Notify (void) { - float id = 4; + float id = HUD_PANEL_NOTIFY; vector pos, mySize; pos = HUD_Panel_GetPos(id); mySize = HUD_Panel_GetSize(id); @@ -2664,7 +2678,7 @@ void HUD_Notify (void) // void HUD_Timer() { - float id = 5; + float id = HUD_PANEL_TIMER; vector pos, mySize; pos = HUD_Panel_GetPos(id); mySize = HUD_Panel_GetSize(id); @@ -2723,7 +2737,7 @@ void HUD_Timer() // void HUD_Radar(void) { - float id = 6; + float id = HUD_PANEL_RADAR; vector pos, mySize; pos = HUD_Panel_GetPos(id); mySize = HUD_Panel_GetSize(id); @@ -2849,7 +2863,7 @@ void HUD_Radar(void) // void HUD_Score() { - float id = 7; + float id = HUD_PANEL_SCORE; vector pos, mySize; pos = HUD_Panel_GetPos(id); mySize = HUD_Panel_GetSize(id); @@ -2997,7 +3011,7 @@ void HUD_Score() // Race timer (#8) // void HUD_RaceTimer (void) { - float id = 8; + float id = HUD_PANEL_RACETIMER; vector pos, mySize; pos = HUD_Panel_GetPos(id); mySize = HUD_Panel_GetSize(id); @@ -3140,7 +3154,7 @@ float vote_change; // "time" when vote_active changed void HUD_VoteWindow(void) { - float id = 9; + float id = HUD_PANEL_VOTE; vector pos, mySize; pos = HUD_Panel_GetPos(id); mySize = HUD_Panel_GetSize(id); @@ -3646,7 +3660,7 @@ void HUD_ModIcons(void) if (gametype != GAME_KEYHUNT && gametype != GAME_CTF && gametype != GAME_NEXBALL && gametype != GAME_CTS && gametype != GAME_RACE && !hud_configure) return; - float id = 10; + float id = HUD_PANEL_MODICONS; vector pos, mySize; pos = HUD_Panel_GetPos(id); mySize = HUD_Panel_GetSize(id); @@ -3687,7 +3701,7 @@ void HUD_ModIcons(void) // void HUD_DrawPressedKeys(void) { - float id = 11; + float id = HUD_PANEL_PRESSEDKEYS; vector pos, mySize; pos = HUD_Panel_GetPos(id); mySize = HUD_Panel_GetSize(id); @@ -3718,7 +3732,7 @@ void HUD_DrawPressedKeys(void) float chat_prevtime; void HUD_Chat(void) { - float id = 12; + float id = HUD_PANEL_CHAT; vector pos, mySize; pos = HUD_Panel_GetPos(id); mySize = HUD_Panel_GetSize(id); @@ -3941,4 +3955,8 @@ void HUD_Main (void) HUD_ShowSpeed(); if (cvar("cl_showacceleration")) HUD_ShowAcceleration(); + + if (hud_configure && spectatee_status) // try to join if we are in hud_configure mode, but still spectating (in order to get rid of motd and such) + localcmd("cmd selectteam auto; cmd join\n"); + }