⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cl_scrn.pas

📁 雷神之锤2(Quake2)Delphi源码
💻 PAS
📖 第 1 页 / 共 3 页
字号:
  ptr := num;
  while (ptr <> #0) and (l <> 0) do begin
    if ( ptr='-') then
      frame := STAT_MINUS
    else
      frame := Byte(ptr^) - Byte('0');

    re.DrawPic (x,y,sb_nums[color][frame]);
    x := x + CHAR_WIDTH;
    Inc(Ptr);
    Dec(l);
  end;
end;


(*
===============
SCR_TouchPics

Allows rendering code to cache all needed sbar graphics
===============
*)
procedure SCR_TouchPics;
var
  i, j: integer;
begin
  for i := 0 to 1 do
    for j:= 0 to 10 do
       re.RegisterPic (sb_nums[i][j]);

  if (crosshair.value<>0) then begin
    if (crosshair.value > 3)  or  (crosshair.value < 0) then
    	crosshair.value := 3;

    Com_sprintf (crosshair_pic, sizeof(crosshair_pic), 'ch%d', [Round(crosshair.value)]);
    re.DrawGetPicSize (@crosshair_width, @crosshair_height, crosshair_pic);
    if (crosshair_width = 0) then
    	crosshair_pic[0] := #0;
  end;
end;

(*
================
SCR_ExecuteLayoutString

================
*)
procedure SCR_ExecuteLayoutString (s: pchar);
var
  x, y: integer;
  value: integer;
  token: pchar;
  width: integer;
  index: integer;
  ci: pclientinfo_t;
  score, ping, time: integer;
  block: array[0..80-1] of char;
  color: integer;
  tmps: String;
begin
  if (cls.state <> ca_active) or (not cl.refresh_prepped) then
    exit;

  if (s = '') then
    exit;

  x := 0;
  y := 0;
  width := 3;

  while (s <> '') do begin
    token := COM_Parse (s);
    if (strcmp(token, 'xl') = 0) then begin
      token := COM_Parse (s);
      x := StrToInt(token);
      continue;
    end;
    if (strcmp(token, 'xr') = 0) then begin
      token := COM_Parse (s);
      x := viddef.width + StrToInt(token);
      continue;
    end;
    if (strcmp(token, 'xv') = 0) then begin
      token := COM_Parse (s);
      x := viddef.width div 2 - 160 + StrToInt(token);
      continue;
    end;
    if (strcmp(token, 'yt') = 0) then begin
      token := COM_Parse (s);
      y := StrToInt(token);
      continue;
    end;
    if (strcmp(token, 'yb') = 0) then begin
      token := COM_Parse (s);
      y := viddef.height + StrToInt(token);
      continue;
    end;
    if (strcmp(token, 'yv') = 0) then begin
      token := COM_Parse (s);
      y := viddef.height div 2 - 120 + StrToInt(token);
      continue;
    end;

    if (strcmp(token, 'pic') = 0) then begin
      // draw a pic from a stat number
      token := COM_Parse (s);
      value := cl.frame.playerstate.stats[StrToInt(token)];
      if (value >= MAX_IMAGES) then
	      Com_Error (ERR_DROP, 'Pic >= MAX_IMAGES', []);
      if (cl.configstrings[CS_IMAGES+value] <> nil) then begin
	      SCR_AddDirtyPoint (x, y);
	      SCR_AddDirtyPoint (x+23, y+23);
	      re.DrawPic (x, y, cl.configstrings[CS_IMAGES+value]);
      end;
      continue;
    end;

    if (strcmp(token, 'client') = 0) then begin
      // draw a deathmatch client block

      token := COM_Parse (s);
      x := viddef.width div 2 - 160 + StrToInt(token);
      token := COM_Parse (s);
      y := viddef.height div 2 - 120 + StrToInt(token);
      SCR_AddDirtyPoint (x, y);
      SCR_AddDirtyPoint (x+159, y+31);

      token := COM_Parse (s);
      value := StrToInt(token);
      if (value >= MAX_CLIENTS) or (value < 0) then
      	Com_Error (ERR_DROP, 'client >= MAX_CLIENTS', []);
      ci := @cl.clientinfo[value];

      token := COM_Parse (s);
      score := StrToInt(token);

      token := COM_Parse (s);
      ping := StrToInt(token);

      token := COM_Parse (s);
      time := StrToInt(token);

      DrawAltString (x+32, y, ci.name);
      DrawString (x+32, y+8,  'Score: ');
      DrawAltString (x+32+7*8, y+8,  va('%d', [score]));
      DrawString (x+32, y+16, va('Ping:  %d', [ping]));
      DrawString (x+32, y+24, va('Time:  %d', [time]));

      if (ci.icon = nil) then
	      ci := @cl.baseclientinfo;
      re.DrawPic (x, y, ci.iconname);
      continue;
    end;

    if (strcmp(token, 'ctf') = 0) then begin
      // draw a ctf client block
      token := COM_Parse (s);
			x := viddef.width div 2 - 160 + StrToInt(token);
			token := COM_Parse (s);
			y := viddef.height div 2 - 120 + StrToInt(token);
			SCR_AddDirtyPoint (x, y);
			SCR_AddDirtyPoint (x+159, y+31);

			token := COM_Parse (s);
			value := StrToInt(token);
			if (value >= MAX_CLIENTS) or (value < 0) then
				Com_Error (ERR_DROP, 'client >= MAX_CLIENTS', []);
			ci := @cl.clientinfo[value];

			token := COM_Parse (s);
			score := StrToInt(token);

			token := COM_Parse (s);
			ping := StrToInt(token);
			if (ping > 999) then
				ping := 999;

      FillChar(block, sizeof(block), 0);
      tmps := PChar(Format('%3d %3d %-12.12s', [score, ping, ci.name]));
      move(tmps[1], block[0], length(tmps));

			if (value=cl.playernum) then
				DrawAltString (x, y, block)
			else
				DrawString (x, y, block);
			continue;
    end;

		if (strcmp(token, 'picn') = 0) then begin
			// draw a pic from a name
			token := COM_Parse (s);
			SCR_AddDirtyPoint (x, y);
			SCR_AddDirtyPoint (x+23, y+23);
			re.DrawPic (x, y, token);
			continue;
    end;

		if (strcmp(token, 'num') = 0) then begin
			// draw a number
			token := COM_Parse (s);
			width := StrToInt(token);
			token := COM_Parse (s);
			value := cl.frame.playerstate.stats[StrToInt(token)];
			SCR_DrawField (x, y, 0, width, value);
			continue;
    end;

		if (strcmp(token, 'hnum') = 0) then begin
			// health number

			width := 3;
			value := cl.frame.playerstate.stats[STAT_HEALTH];
			if (value > 25) then
				color := 0	// green
			else if (value > 0) then
				color := (cl.frame.serverframe shr 2) and 1		// flash
			else
				color := 1;

			if (cl.frame.playerstate.stats[STAT_FLASHES] and 1<>0) then
				re.DrawPic (x, y, 'field_3');

			SCR_DrawField (x, y, color, width, value);
			continue;
    end;

		if (strcmp(token, 'anum') = 0) then begin
			// ammo number

			width := 3;
			value := cl.frame.playerstate.stats[STAT_AMMO];
			if (value > 5) then
				color := 0	// green
			else if (value >= 0) then
				color := (cl.frame.serverframe shr 2) and 1		// flash
			else
				continue;	// negative number = don't show

			if (cl.frame.playerstate.stats[STAT_FLASHES] and 4 > 0) then
				re.DrawPic (x, y, 'field_3');

			SCR_DrawField (x, y, color, width, value);
			continue;
    end;

		if (strcmp(token, 'rnum') = 0) then begin
			// armor number

			width := 3;
			value := cl.frame.playerstate.stats[STAT_ARMOR];
			if (value < 1) then
				continue;

			color := 0;	// green

			if (cl.frame.playerstate.stats[STAT_FLASHES] and 2 > 0) then
				re.DrawPic (x, y, 'field_3');

			SCR_DrawField (x, y, color, width, value);
			continue;
    end;


		if (strcmp(token, 'stat_string') = 0) then begin
			token := COM_Parse (s);
			index := StrToInt(token);
			if (index < 0) or (index >= MAX_CONFIGSTRINGS) then
				Com_Error (ERR_DROP, 'Bad stat_string index', []);
			index := cl.frame.playerstate.stats[index];
			if (index < 0) or (index >= MAX_CONFIGSTRINGS) then
				Com_Error (ERR_DROP, 'Bad stat_string index', []);
			DrawString (x, y, cl.configstrings[index]);
			continue;
    end;

		if (strcmp(token, 'cstring') = 0) then begin
			token := COM_Parse (s);
			DrawHUDString (token, x, y, 320, 0);
			continue;
    end;

		if (strcmp(token, 'string') = 0) then begin
			token := COM_Parse (s);
			DrawString (x, y, token);
			continue;
    end;

		if (strcmp(token, 'cstring2') = 0) then begin
			token := COM_Parse (s);
			DrawHUDString (token, x, y, 320, $80);
			continue;
    end;

		if (strcmp(token, 'string2') = 0) then begin
			token := COM_Parse (s);
			DrawAltString (x, y, token);
			continue;
    end;

		if (strcmp(token, 'if') = 0) then begin
			// draw a number
			token := COM_Parse (s);
			value := cl.frame.playerstate.stats[StrToInt(token)];
			if (value = 0) then begin
				// skip to endif
				while (s<>#0) and (strcmp(token, 'endif')<>0) do begin
					token := COM_Parse (s);
        end;
      end;

			continue;
    end;
  end;
end;


(*
================
SCR_DrawStats

The status bar is a small layout program that
is based on the stats array
================
*)
procedure SCR_DrawStats;
begin
	SCR_ExecuteLayoutString (cl.configstrings[CS_STATUSBAR]);
end;


(*
================
SCR_DrawLayout

================
*)
const STAT_LAYOUTS = 13;

procedure SCR_DrawLayout;
begin
	if (cl.frame.playerstate.stats[STAT_LAYOUTS] = 0) then
		exit;
	SCR_ExecuteLayoutString (cl.layout);
end;

//=======================================================

(*
==================
SCR_UpdateScreen

This is called every frame, and can also be called explicitly to flush
text to the screen.
==================
*)
procedure SCR_UpdateScreen;
var
	numframes: integer;
	i: integer;
	separation: array[0..1] of single;
	w, h: integer;
begin
  separation[0] := 0;
  separation[1] := 0;
	// if the screen is disabled (loading plaque is up, or vid mode changing)
	// do nothing at all
	if (cls.disable_screen <> 0) then begin
		if (Sys_Milliseconds() - cls.disable_screen > 120000) then begin
			cls.disable_screen := 0;
			Com_Printf ('Loading plaque timed out.'#10, []);
    end;
		exit;
  end;

	if (not scr_initialized) or (not con.initialized) then
		exit;				// not initialized yet

	(*
	** range check cl_camera_separation so we don't inadvertently fry someone's
	** brain
	*)
	if ( cl_stereo_separation.value > 1.0 ) then
		Cvar_SetValue( 'cl_stereo_separation', 1.0 )
	else if ( cl_stereo_separation.value < 0 ) then
		Cvar_SetValue( 'cl_stereo_separation', 0.0 );

	if ( cl_stereo.value <> 0 ) then begin
		numframes := 2;
		separation[0] := -cl_stereo_separation.value / 2;
		separation[1] :=  cl_stereo_separation.value / 2;
  end
	else
  begin
		separation[0] := 0;
		separation[1] := 0;
		numframes := 1;
  end;

	for i := 0 to numframes-1 do begin
		re.BeginFrame( separation[i] );

		if (scr_draw_loading=2) then begin
			//  loading plaque over black screen

			re.CinematicSetPalette(nil);
			scr_draw_loading := Integer(false);
			re.DrawGetPicSize (@w, @h, 'loading');
			re.DrawPic ((viddef.width-w)div 2, (viddef.height-h)div 2, 'loading');
//			re.EndFrame();
//			exit;
    end
		// if a cinematic is supposed to be running, handle menus
		// and console specially
		else if (cl.cinematictime > 0) then begin
			if (cls.key_dest=key_menu) then begin
				if (cl.cinematicpalette_active) then begin
					re.CinematicSetPalette(nil);
					cl.cinematicpalette_active := false;
        end;
				M_Draw ();
//				re.EndFrame();
//				exit;
      end
			else if (cls.key_dest=key_console) then
      begin
				if (cl.cinematicpalette_active) then begin
					re.CinematicSetPalette(nil);
					cl.cinematicpalette_active := false;
        end;
				SCR_DrawConsole ();
//				re.EndFrame();
//				exit;
      end
			else
      begin
				SCR_DrawCinematic();
//				re.EndFrame();
//				exit;
      end
    end
		else
    begin

			// make sure the game palette is active
			if (cl.cinematicpalette_active) then begin
				re.CinematicSetPalette(nil);
				cl.cinematicpalette_active := false;
      end;

			// do 3D refresh drawing, and then update the screen
			SCR_CalcVrect ();

			// clear any dirty part of the background
			SCR_TileClear ();

			V_RenderView ( separation[i] );

			SCR_DrawStats ();
			if (cl.frame.playerstate.stats[STAT_LAYOUTS] and 1 > 0) then
				SCR_DrawLayout ();
			if (cl.frame.playerstate.stats[STAT_LAYOUTS] and 2 > 0) then
				CL_DrawInventory ();

			SCR_DrawNet ();
			SCR_CheckDrawCenterString ();

			if (scr_timegraph.value<>0) then
				SCR_DebugGraph (cls.frametime*300, 0);

			if (scr_debuggraph_.value<>0) or (scr_timegraph.value<>0) or
         (scr_netgraph.value<>0) then
				SCR_DrawDebugGraph ();

			SCR_DrawPause ();

			SCR_DrawConsole ();

			M_Draw ();

			SCR_DrawLoading ();
    end;
  end;
	re.EndFrame();
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -