]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge branch 'master' into terencehill/cursormode
authorterencehill <piuntn@gmail.com>
Wed, 14 Mar 2012 21:10:32 +0000 (22:10 +0100)
committerterencehill <piuntn@gmail.com>
Wed, 14 Mar 2012 21:10:32 +0000 (22:10 +0100)
1  2 
qcsrc/client/Main.qc
qcsrc/client/View.qc
qcsrc/client/hud.qc
qcsrc/client/hud_config.qc

diff --combined qcsrc/client/Main.qc
index d054deb651d4d8a00e519a17bf3e4c9caa4fd22c,12343e6a24bac333753628e7ca63fe473f126318..8a9c350bceff29afa896bf658b94cff311d97f8e
@@@ -371,10 -371,9 +371,10 @@@ float button_zoom
  // 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;
@@@ -779,6 -778,11 +779,11 @@@ void Ent_Remove(
  // 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);
@@@ -1163,6 -1167,10 +1168,10 @@@ float CSQC_Parse_TempEntity(
                        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;
diff --combined qcsrc/client/View.qc
index 46770d051ffb262d2e5dff8c2736ffc09d50c5b8,66d7dd31c4b1ae258043002bc381a81109d9ddfc..e04a9704d6b58d011c223792b11c0d2fe1284e37
@@@ -94,6 -94,7 +94,7 @@@ vector GetCurrentFov(float fov
  {
        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
@@@ -220,14 -225,18 +225,18 @@@ void TrueAim_Init(
  
  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;
@@@ -365,6 -374,7 +374,7 @@@ float checkfail[16]
  
  #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);
@@@ -1477,7 -1497,7 +1497,7 @@@ void CSQC_common_hud(void
                  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
diff --combined qcsrc/client/hud.qc
index 87b07370493992d51f47f971d14dfc36cb196a17,a0872b61885cafa8faf5f5fdcd29642477b8b56c..0101c08708240b59fc307646a08f93f8ff15877c
@@@ -662,7 -662,7 +662,7 @@@ void HUD_Weapons(void
        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
@@@ -4366,6 -4366,16 +4366,16 @@@ void HUD_Physics(void
                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)
@@@ -5097,13 -5137,8 +5137,13 @@@ void HUD_Main (void
                        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;
  
index d5e84f5277cb0d26c216d590c0406c87c4172cee,a53112bbd4b0495fe21483484b7818ebfd93c31c..7f999ba77dc8d3f98d05b5cf4399843ec357a73b
@@@ -159,8 -159,11 +159,11 @@@ void HUD_Panel_ExportCfg(string cfgname
                                        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");
@@@ -631,7 -634,8 +634,7 @@@ float HUD_Panel_InputEvent(float bInput
  {
        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;
@@@ -1072,6 -1069,11 +1075,6 @@@ void HUD_Panel_Mouse(
        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)