==================
*/
-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)
{
// 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"));
mySize_y = 0.23; // 0.23 * width, trial and error...
break;
case 4:
- mySize_x = 0.8; // 8/10 * height, as panel cant support more than 10 entries...
- mySize_y = 1/8; // 1/8 * width
+ mySize_x = 1.2; // 12/10 * height, as panel cant support more than 10 entries...
+ mySize_y = 1/12; // 1/12 * width
break;
case 5:
mySize_y = 1/4.1; // 1/4.1 * width, trial and error...
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;
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;
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)
{
mouseClicked = 1;
return true;
}
- if(bInputType == 1) {// key released
+ else if(bInputType == 1) {// key released
mouseClicked = 0;
return true;
}
}
- return false;
+ else if(nPrimary == K_ESCAPE)
+ {
+ localcmd("menu_showhudexit\n");
+ }
+
+ else if(hit_con_bind)
+ return false;
+
+ return true; // Suppress ALL other input
}
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)
{
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
void HUD_Inventory()
{
- float id = 1;
+ float id = HUD_PANEL_INVENTORY;
float i;
float stat_items;
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
// Powerups (#2)
//
void HUD_Powerups() {
- float id = 2;
+ float id = HUD_PANEL_POWERUPS;
float stat_items;
stat_items = getstati(STAT_ITEMS);
//
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);
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);
}
float entries, height;
- entries = bound(1, floor(8 * mySize_y/mySize_x), 10);
+ entries = bound(1, floor(12 * mySize_y/mySize_x), 10);
height = mySize_y/entries;
vector fontsize;
- fontsize = '0.33 0.33 0' * height;
+ fontsize = '0.5 0.5 0' * height;
float a;
float when;
string s;
+ vector pos_attacker, pos_victim;
+ vector weap_pos;
+ float width_attacker, width_victim;
+ string attacker, victim;
+
float i, j;
for(j = 0; j < entries; ++j)
{
a = 0;
}
+ // TODO: maybe print in team colors?
+ // TODO: maybe this could be cleaned up somehow...
+ //
// X [did action to] Y
- if(WEP_VALID(killnotify_deathtype[j]))
+ if(hud_configure || WEP_VALID(killnotify_deathtype[j]) || killnotify_deathtype[j] == DEATH_FALL)
{
- self = get_weaponinfo(killnotify_deathtype[j]);
- drawpic_skin(pos + eX * 0.5 * mySize_x - eX * 0.5 * height + eY * 0.25 * height + eY * i * height, strcat("weapon", self.netname), '1 0.5 0' * height, '1 1 1', hud_fg_alpha * a, DRAWFLAG_NORMAL);
- drawcolorcodedstring(pos + eY * 0.33 * height + eY * i * height, textShortenToWidth(killnotify_attackers[j], 0.5 * mySize_x - 0.5 * height, fontsize, stringwidth_colors), fontsize, hud_fg_alpha * a, DRAWFLAG_NORMAL);
- drawcolorcodedstring(pos + eY * 0.33 * height + eX * 0.5 * mySize_x + eX * 0.5 * height + eY * i * height, textShortenToWidth(killnotify_victims[j], 0.5 * mySize_x - 0.5 * height, fontsize, stringwidth_colors), fontsize, hud_fg_alpha * a, DRAWFLAG_NORMAL);
- }
- else if(killnotify_deathtype[j] == DEATH_FALL)
- {
- drawpic_skin(pos + eX * 0.5 * mySize_x - eX * 0.5 * height + eY * 0.25 * height + eY * i * height, "notify_pushoffedge", '1 0.5 0' * height, '1 1 1', hud_fg_alpha * a, DRAWFLAG_NORMAL);
- drawcolorcodedstring(pos + eY * 0.33 * height + eY * i * height, textShortenToWidth(killnotify_attackers[j], 0.5 * mySize_x - 0.5 * height, fontsize, stringwidth_colors), fontsize, hud_fg_alpha * a, DRAWFLAG_NORMAL);
- drawcolorcodedstring(pos + eY * 0.33 * height + eX * 0.5 * mySize_x + eX * 0.5 * height + eY * i * height, textShortenToWidth(killnotify_victims[j], 0.5 * mySize_x - 0.5 * height, fontsize, stringwidth_colors), fontsize, hud_fg_alpha * a, DRAWFLAG_NORMAL);
+ if(hud_configure)
+ {
+ attacker = textShortenToWidth("Player1", 0.5 * mySize_x - height, fontsize, stringwidth_colors);
+ victim = textShortenToWidth("Player2", 0.5 * mySize_x - height, fontsize, stringwidth_colors);
+ }
+ else
+ {
+ attacker = textShortenToWidth(killnotify_attackers[j], 0.5 * mySize_x - height, fontsize, stringwidth_colors);
+ victim = textShortenToWidth(killnotify_victims[j], 0.5 * mySize_x - height, fontsize, stringwidth_colors);
+ }
+ width_attacker = stringwidth(attacker, TRUE, fontsize);
+ width_victim = stringwidth(victim, TRUE, fontsize);
+ pos_attacker = pos + eX * 0.5 * ((0.5 * mySize_x - height) - width_attacker) + eY * 0.5 * fontsize_y + eY * i * height;
+ pos_victim = pos + eX * 0.5 * ((0.5 * mySize_x - height) - width_victim) + eY * 0.5 * fontsize_y + eX * 0.5 * mySize_x + eX * height + eY * i * height;
+ weap_pos = pos + eX * 0.5 * mySize_x - eX * height + eY * i * height;
+
+ if(hud_configure) // example actions for config mode
+ {
+ drawpic_skin(weap_pos, strcat("weapon", "electro"), '2 1 0' * height, '1 1 1', hud_fg_alpha, DRAWFLAG_NORMAL);
+ drawcolorcodedstring(pos_attacker, attacker, fontsize, hud_fg_alpha, DRAWFLAG_NORMAL);
+ drawcolorcodedstring(pos_victim, victim, fontsize, hud_fg_alpha, DRAWFLAG_NORMAL);
+ }
+ else if(WEP_VALID(killnotify_deathtype[j]))
+ {
+ self = get_weaponinfo(killnotify_deathtype[j]);
+ drawpic_skin(weap_pos, strcat("weapon", self.netname), '2 1 0' * height, '1 1 1', hud_fg_alpha * a, DRAWFLAG_NORMAL);
+ drawcolorcodedstring(pos_attacker, attacker, fontsize, hud_fg_alpha * a, DRAWFLAG_NORMAL);
+ drawcolorcodedstring(pos_victim, victim, fontsize, hud_fg_alpha * a, DRAWFLAG_NORMAL);
+ }
+ else if(killnotify_deathtype[j] == DEATH_FALL)
+ {
+ drawpic_skin(weap_pos, "notify_pushoffedge", '2 1 0' * height, '1 1 1', hud_fg_alpha * a, DRAWFLAG_NORMAL);
+ drawcolorcodedstring(pos_attacker, attacker, fontsize, hud_fg_alpha * a, DRAWFLAG_NORMAL);
+ drawcolorcodedstring(pos_victim, victim, fontsize, hud_fg_alpha * a, DRAWFLAG_NORMAL);
+ }
}
// Y [used by] X
- else if(killnotify_deathtype[j] == DEATH_KILL)
- {
- drawpic_skin(pos + eY * 0.25 * height + eY * i * height, "notify_selfkill", '1 0.5 0' * height, '1 1 1', hud_fg_alpha * a, DRAWFLAG_NORMAL);
- drawcolorcodedstring(pos + eX * height + eY * 0.33 * height + eY * i * height, textShortenToWidth(killnotify_attackers[j], mySize_x - height, fontsize, stringwidth_colors), fontsize, hud_fg_alpha * a, DRAWFLAG_NORMAL);
- }
- else if(killnotify_deathtype[j] == INFO_GOTFLAG)
- {
- if(killnotify_victims[j] == "^1RED^7 flag")
- s = "red";
- else
- s = "blue";
- drawpic_skin(pos + eY * i * height, strcat("flag_", s, "_carrying"), '1 1 0' * height, '1 1 1', hud_fg_alpha * a, DRAWFLAG_NORMAL);
- drawcolorcodedstring(pos + eX * height + eY * 0.33 * height + eY * i * height, textShortenToWidth(killnotify_attackers[j], mySize_x - height, fontsize, stringwidth_colors), fontsize, hud_fg_alpha * a, DRAWFLAG_NORMAL);
- }
- else if(killnotify_deathtype[j] == INFO_RETURNFLAG)
- {
- if(killnotify_victims[j] == "^1RED^7 flag")
- s = "red";
- else
- s = "blue";
- drawpic_skin(pos + eY * i * height, strcat("flag_", s, "_taken"), '1 1 0' * height, '1 1 1', hud_fg_alpha * a, DRAWFLAG_NORMAL);
- drawcolorcodedstring(pos + eX * height + eY * 0.33 * height + eY * i * height, textShortenToWidth(killnotify_attackers[j], mySize_x - height, fontsize, stringwidth_colors), fontsize, hud_fg_alpha * a, DRAWFLAG_NORMAL);
- }
- else if(killnotify_deathtype[j] == INFO_LOSTFLAG)
+ else
{
- if(killnotify_victims[j] == "^1RED^7 flag")
- s = "red";
- else
- s = "blue";
- drawpic_skin(pos + eY * i * height, strcat("flag_", s, "_lost"), '1 1 0' * height, '1 1 1', hud_fg_alpha * a, DRAWFLAG_NORMAL);
- drawcolorcodedstring(pos + eX * height + eY * 0.33 * height + eY * i * height, textShortenToWidth(killnotify_attackers[j], mySize_x - height, fontsize, stringwidth_colors), fontsize, hud_fg_alpha * a, DRAWFLAG_NORMAL);
+ attacker = textShortenToWidth(killnotify_attackers[j], mySize_x - 2 * height, fontsize, stringwidth_colors);
+
+ width_attacker = stringwidth(attacker, TRUE, fontsize);
+ pos_attacker = pos + eX * 0.5 * (mySize_x - width_attacker + 2 * height) + eY * 0.5 * fontsize_y + eY * i * height;
+
+ weap_pos = pos + eX * 0.5 * (mySize_x - width_attacker) - eX * height + eY * i * height;
+ if(killnotify_deathtype[j] == DEATH_KILL)
+ {
+ drawpic_skin(weap_pos, "notify_selfkill", '2 1 0' * height, '1 1 1', hud_fg_alpha * a, DRAWFLAG_NORMAL);
+ drawcolorcodedstring(pos_attacker, attacker, fontsize, hud_fg_alpha * a, DRAWFLAG_NORMAL);
+ }
+ else if(killnotify_deathtype[j] == INFO_GOTFLAG)
+ {
+ if(killnotify_victims[j] == "^1RED^7 flag")
+ s = "red";
+ else
+ s = "blue";
+ drawpic_skin(weap_pos, strcat("flag_", s, "_carrying"), '1 1 0' * height, '1 1 1', hud_fg_alpha * a, DRAWFLAG_NORMAL);
+ drawcolorcodedstring(pos_attacker, attacker, fontsize, hud_fg_alpha * a, DRAWFLAG_NORMAL);
+ }
+ else if(killnotify_deathtype[j] == INFO_RETURNFLAG)
+ {
+ if(killnotify_victims[j] == "^1RED^7 flag")
+ s = "red";
+ else
+ s = "blue";
+ drawpic_skin(weap_pos, strcat("flag_", s, "_taken"), '1 1 0' * height, '1 1 1', hud_fg_alpha * a, DRAWFLAG_NORMAL);
+ drawcolorcodedstring(pos_attacker, attacker, fontsize, hud_fg_alpha * a, DRAWFLAG_NORMAL);
+ }
+ else if(killnotify_deathtype[j] == INFO_LOSTFLAG)
+ {
+ if(killnotify_victims[j] == "^1RED^7 flag")
+ s = "red";
+ else
+ s = "blue";
+ drawpic_skin(weap_pos, strcat("flag_", s, "_lost"), '1 1 0' * height, '1 1 1', hud_fg_alpha * a, DRAWFLAG_NORMAL);
+ drawcolorcodedstring(pos_attacker, attacker, fontsize, hud_fg_alpha * a, DRAWFLAG_NORMAL);
+ }
}
}
/* This will come later.
//
void HUD_Timer()
{
- float id = 5;
+ float id = HUD_PANEL_TIMER;
vector pos, mySize;
pos = HUD_Panel_GetPos(id);
mySize = HUD_Panel_GetSize(id);
//
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);
//
void HUD_Score()
{
- float id = 7;
+ float id = HUD_PANEL_SCORE;
vector pos, mySize;
pos = HUD_Panel_GetPos(id);
mySize = HUD_Panel_GetSize(id);
// 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);
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);
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);
//
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);
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);
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");
+
}