// CSQC_InputEvent : Used to perform actions based on any key pressed, key released and mouse on the client.
// Return value should be 1 if CSQC handled the input, otherwise return 0 to have the input passed to the engine.
// All keys are in ascii.
-// bInputType = 0 is key pressed, 1 is key released, 2 is mouse input.
+// bInputType = 0 is key pressed, 1 is key released, 2 and 3 are mouse input.
// In the case of keyboard input, nPrimary is the ascii code, and nSecondary is 0.
// In the case of mouse input, nPrimary is xdelta, nSecondary is ydelta.
+// In the case of mouse input after a setcursormode(1) call, nPrimary is xpos, nSecondary is ypos.
float CSQC_InputEvent(float bInputType, float nPrimary, float nSecondary)
{
float bSkipKey;
// CSQC_Ent_Remove : Called when the server requests a SSQC / CSQC entity to be removed. Essentially call remove(self) as well.
void CSQC_Ent_Remove()
{
+ if(wasfreed(self))
+ {
+ print("WARNING: CSQC_Ent_Remove called for already removed entity. Packet loss?\n");
+ return;
+ }
if(self.enttype)
Ent_Remove();
remove(self);
Net_VehicleSetup();
bHandled = true;
break;
+ case TE_CSQC_SVNOTICE:
+ cl_notice_read();
+ bHandled = true;
+ break;
default:
// No special logic for this temporary entity; return 0 so the engine can handle it
bHandled = false;
{
float zoomsensitivity, zoomspeed, zoomfactor, zoomdir;
float velocityzoom, curspeed;
+ vector v;
zoomsensitivity = autocvar_cl_zoomsensitivity;
zoomfactor = autocvar_cl_zoomfactor;
if(autocvar_cl_velocityzoom && autocvar_cl_velocityzoom_type) // _type = 0 disables velocity zoom too
{
+ v = pmove_vel;
+ if(csqcplayer)
+ v = csqcplayer.velocity;
+
switch(autocvar_cl_velocityzoom_type)
{
- case 3: curspeed = max(0, v_forward * pmove_vel); break;
- case 2: curspeed = (v_forward * pmove_vel); break;
- case 1: default: curspeed = vlen(pmove_vel); break;
+ case 3: curspeed = max(0, v_forward * v); break;
+ case 2: curspeed = (v_forward * v); break;
+ case 1: default: curspeed = vlen(v); break;
}
velocityzoom = bound(0, drawframetime / max(0.000000001, autocvar_cl_velocityzoom_time), 1); // speed at which the zoom adapts to player velocity
float EnemyHitCheck()
{
- float t;
+ float t, n;
wcross_origin = project_3d_to_2d(trace_endpos);
wcross_origin_z = 0;
- if(trace_networkentity < 1)
+ if(trace_ent)
+ n = trace_ent.entnum;
+ else
+ n = trace_networkentity;
+ if(n < 1)
return SHOTTYPE_HITWORLD;
- if(trace_networkentity > maxclients)
+ if(n > maxclients)
return SHOTTYPE_HITWORLD;
- t = GetPlayerColor(trace_networkentity - 1);
+ t = GetPlayerColor(n - 1);
if(teamplay)
if(t == myteam)
return SHOTTYPE_HITTEAM;
#define BUTTON_3 4
#define BUTTON_4 8
+ float cl_notice_run();
void CSQC_UpdateView(float w, float h)
{
entity e;
eventchase_current_distance = 0; // start from 0 next time
}
}
-
+
// do lockview after event chase camera so that it still applies whenever necessary.
- if(autocvar_cl_lockview || (autocvar__hud_configure && spectatee_status <= 0) || intermission > 1)
+ if(autocvar_cl_lockview)
{
setproperty(VF_ORIGIN, freeze_org);
setproperty(VF_ANGLES, freeze_ang);
}
}
- if(autocvar_hud_postprocessing) // TODO: Remove this code and re-do the postprocess handling in the engine, where it properly belongs.
+ float e1 = (autocvar_hud_postprocessing_maxbluralpha != 0);
+ float e2 = (autocvar_hud_powerup != 0);
+ if(autocvar_hud_postprocessing && (e1 || e2)) // TODO: Remove this code and re-do the postprocess handling in the engine, where it properly belongs.
{
// enable or disable rendering types if they are used or not
- if(cvar("r_glsl_postprocess_uservec1_enable") != (autocvar_hud_postprocessing_maxbluralpha != 0)) { cvar_set("r_glsl_postprocess_uservec1_enable", ftos(autocvar_hud_postprocessing_maxbluralpha != 0)); }
- if(cvar("r_glsl_postprocess_uservec2_enable") != (autocvar_hud_powerup != 0)) { cvar_set("r_glsl_postprocess_uservec2_enable", ftos(autocvar_hud_powerup != 0)); }
-
+ if(cvar("r_glsl_postprocess_uservec1_enable") != e1) { cvar_set("r_glsl_postprocess_uservec1_enable", ftos(e1)); }
+ if(cvar("r_glsl_postprocess_uservec2_enable") != e2) { cvar_set("r_glsl_postprocess_uservec2_enable", ftos(e2)); }
+
// blur postprocess handling done first (used by hud_damage and hud_contents)
if((damage_blurpostprocess_x || content_blurpostprocess_x) && autocvar_chase_active >= 0) // not while the event chase camera is active
{
cvar_set("r_glsl_postprocess_uservec2", "0 0 0 0");
old_sharpen_intensity = 0;
}
+
+ if(cvar("r_glsl_postprocess") == 0)
+ cvar_set("r_glsl_postprocess", "2");
}
+ else if(cvar("r_glsl_postprocess") == 2)
+ cvar_set("r_glsl_postprocess", "0");
if(menu_visible)
menu_show();
wcross_color = stov(autocvar_crosshair_dot_color);
CROSSHAIR_DRAW(wcross_resolution * autocvar_crosshair_dot_size, "gfx/crosshairdot.tga", f * autocvar_crosshair_dot_alpha);
- // FIXME why don't we use wcross_alpha here?
+ // FIXME why don't we use wcross_alpha here?cl_notice_run();
wcross_color = wcross_color_old;
}
}
else if(hud == HUD_BUMBLEBEE)
CSQC_BUMBLE_HUD();
}
+
+ cl_notice_run();
+
// let's reset the view back to normal for the end
setproperty(VF_MIN, '0 0 0');
setproperty(VF_SIZE, '1 0 0' * w + '0 1 0' * h);
acc_lev[i] = stof(argv(i)) / 100.0;
}
// let know that acc_col[] needs to be loaded
- acc_col_x[0] = -1;
+ acc_col[0] = '-1 0 0';
}
HUD_Main(); // always run these functions for alpha checks
if(autocvar_hud_panel_weapons_accuracy && acc_levels)
{
show_accuracy = true;
- if (acc_col_x[0] == -1)
+ if (acc_col[0] == '-1 0 0')
for (i = 0; i < acc_levels; ++i)
acc_col[i] = stov(cvar_string(strcat("accuracy_color", ftos(i))));
}
break;
case 2: // bind
- drawstring(weapon_pos, getcommandkey(ftos(weapon_id), strcat("impulse ", ftos(weapon_id))), '1 1 0' * 0.5 * weapon_size_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+ drawstring(weapon_pos, getcommandkey(ftos(weapon_id), strcat("weapon_group_", ftos(weapon_id))), '1 1 0' * 0.5 * weapon_size_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
break;
case 3: // weapon name
panel_size -= '2 2 0' * panel_bg_padding;
}
+ float acceleration_progressbar_scale;
+ if(autocvar_hud_panel_physics_progressbar && autocvar_hud_panel_physics_acceleration_progressbar_scale > 1)
+ acceleration_progressbar_scale = autocvar_hud_panel_physics_acceleration_progressbar_scale;
+
+ float text_scale;
+ if (autocvar_hud_panel_physics_text_scale <= 0)
+ text_scale = 1;
+ else
+ text_scale = min(autocvar_hud_panel_physics_text_scale, 1);
+
//compute speed
float speed, conversion_factor;
string unit;
//compute layout
float panel_ar = panel_size_x/panel_size_y;
vector speed_offset, acceleration_offset;
- if (panel_ar >= 5)
+ if (panel_ar >= 5 && !acceleration_progressbar_scale)
{
panel_size_x *= 0.5;
if (autocvar_hud_panel_physics_flip)
speed_baralign = (autocvar_hud_panel_physics_baralign == 2);
acceleration_baralign = (autocvar_hud_panel_physics_baralign == 3);
}
- if (autocvar_hud_panel_physics_acceleration_mode == 0)
+ if (autocvar_hud_panel_physics_acceleration_progressbar_mode == 0)
acceleration_baralign = 3; //override hud_panel_physics_baralign value for acceleration
//draw speed
if (autocvar_hud_panel_physics_text == 1 || autocvar_hud_panel_physics_text == 2)
{
tmp_size_x = panel_size_x * 0.75;
- tmp_size_y = panel_size_y;
+ tmp_size_y = panel_size_y * text_scale;
if (speed_baralign)
tmp_offset_x = panel_size_x - tmp_size_x;
//else
//tmp_offset_x = 0;
+ tmp_offset_y = (panel_size_y - tmp_size_y) / 2;
drawstring_aspect(panel_pos + speed_offset + tmp_offset, ftos(speed), tmp_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
//draw speed unit
{
//tmp_offset_y = 0;
tmp_size_x = panel_size_x * (1 - 0.75);
- tmp_size_y = panel_size_y * 0.4;
+ tmp_size_y = panel_size_y * 0.4 * text_scale;
+ tmp_offset_y = (panel_size_y * 0.4 - tmp_size_y) / 2;
drawstring_aspect(panel_pos + speed_offset + tmp_offset, unit, tmp_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
}
}
//top speed
tmp_offset_y = panel_size_y * 0.4;
tmp_size_x = panel_size_x * (1 - 0.75);
- tmp_size_y = panel_size_y - tmp_offset_y;
+ tmp_size_y = (panel_size_y - tmp_offset_y) * text_scale;
+ tmp_offset_y += (panel_size_y - tmp_offset_y - tmp_size_y) / 2;
drawstring_aspect(panel_pos + speed_offset + tmp_offset, ftos(top_speed), tmp_size, '1 0 0', f * panel_fg_alpha, DRAWFLAG_NORMAL);
}
else
HUD_Panel_GetProgressBarColor(acceleration_neg);
else
HUD_Panel_GetProgressBarColor(acceleration);
- HUD_Panel_DrawProgressBar(panel_pos + acceleration_offset, panel_size, "accelbar", acceleration/autocvar_hud_panel_physics_acceleration_max, 0, acceleration_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
+
+ f = acceleration/autocvar_hud_panel_physics_acceleration_max;
+ if (autocvar_hud_panel_physics_acceleration_progressbar_nonlinear)
+ f = sqrt(f);
+
+ if (acceleration_progressbar_scale) // allow progressbar to go out of panel bounds
+ {
+ tmp_size = acceleration_progressbar_scale * panel_size_x * eX + panel_size_y * eY;
+
+ if (acceleration_baralign == 1)
+ tmp_offset_x = panel_size_x - tmp_size_x;
+ else if (acceleration_baralign == 2 || acceleration_baralign == 3)
+ tmp_offset_x = (panel_size_x - tmp_size_x) / 2;
+ else
+ tmp_offset_x = 0;
+ tmp_offset_y = 0;
+ }
+ else
+ {
+ tmp_size = panel_size;
+ tmp_offset = '0 0 0';
+ }
+
+ HUD_Panel_DrawProgressBar(panel_pos + acceleration_offset + tmp_offset, tmp_size, "accelbar", f, 0, acceleration_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
}
+ tmp_size_x = panel_size_x;
+ tmp_size_y = panel_size_y * text_scale;
+ tmp_offset_x = 0;
+ tmp_offset_y = (panel_size_y - tmp_size_y) / 2;
if (autocvar_hud_panel_physics_text == 1 || autocvar_hud_panel_physics_text == 3)
- drawstring_aspect(panel_pos + acceleration_offset, strcat(ftos_decimals(acceleration, 2), "g"), panel_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+ drawstring_aspect(panel_pos + acceleration_offset + tmp_offset, strcat(ftos_decimals(acceleration, 2), "g"), tmp_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
}
// CenterPrint (#16)
HUD_Panel_HlBorder(panel_bg_border + 1.5 * hlBorderSize, '0 0.5 1', 0.25 * (1 - autocvar__menu_alpha));
}
if (!hud_configure_prev)
+ {
+ setcursormode(1);
hudShiftState = 0;
+ }
}
+ else if (hud_configure_prev)
+ setcursormode(0);
hud_configure_prev = autocvar__hud_configure;
HUD_Write_PanelCvar_q("_flip");
HUD_Write_PanelCvar_q("_baralign");
HUD_Write_PanelCvar_q("_progressbar");
- HUD_Write_PanelCvar_q("_acceleration_mode");
+ HUD_Write_PanelCvar_q("_progressbar_acceleration_mode");
+ HUD_Write_PanelCvar_q("_progressbar_acceleration_scale");
+ HUD_Write_PanelCvar_q("_progressbar_acceleration_nonlinear");
HUD_Write_PanelCvar_q("_text");
+ HUD_Write_PanelCvar_q("_text_scale");
break;
case HUD_PANEL_CENTERPRINT:
HUD_Write_PanelCvar_q("_align");
{
string s;
- // we only care for keyboard events
- if(bInputType != 0 && bInputType != 1)
+ if(bInputType == 2)
return false;
if(!autocvar__hud_configure)
if(autocvar__menu_alpha)
return true;
+ if(bInputType == 3)
+ {
+ mousepos_x = nPrimary;
+ mousepos_y = nSecondary;
+ return true;
+ }
+
// allow console bind to work
string con_keys;
float keys;
if(autocvar__menu_alpha == 1)
return;
- mousepos = mousepos + getmousepos() * autocvar_menu_mouse_speed;
-
- mousepos_x = bound(0, mousepos_x, vid_conwidth);
- mousepos_y = bound(0, mousepos_y, vid_conheight);
-
if(mouseClicked)
{
if(prevMouseClicked == 0)