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

📄 vid_menu.pas

📁 雷神之锤2(Quake2)Delphi源码
💻 PAS
📖 第 1 页 / 共 2 页
字号:
{----------------------------------------------------------------------------}
{                                                                            }
{ File(s): vid_menu.c, client.h, qmenu.h                                     }
{ Content: Quake2\Win32\ support for qhost                                   }
{                                                                            }
{ Initial conversion by : Mani - mani246@yahoo.com                           }
{ Initial conversion on : 14-Mar-2002                                        }
{                                                                            }
{ This File contains part of convertion of Quake2 source to ObjectPascal.    }
{ More information about this project can be found at:                       }
{ http://www.sulaco.co.za/quake2/                                            }
{                                                                            }
{ Copyright (C) 1997-2001 Id Software, Inc.                                  }
{                                                                            }
{ This program is free software; you can redistribute it and/or              }
{ modify it under the terms of the GNU General Public License                }
{ as published by the Free Software Foundation; either version 2             }
{ of the License, or (at your option) any later version.                     }
{                                                                            }
{ This program is distributed in the hope that it will be useful,            }
{ but WITHOUT ANY WARRANTY; without even the implied warranty of             }
{ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                       }
{                                                                            }
{ See the GNU General Public License for more details.                       }
{                                                                            }
{----------------------------------------------------------------------------}
{ * Updated 04-jun-2002 Juha Hartikainen (juha@linearteam.org)               }
{ - Language fixes                                                                           }
{}
{ * TODO}
{ - Declare needed functions in interface section }
{----------------------------------------------------------------------------}

unit vid_menu;

interface

// conproc.h -- support for qhost

procedure VID_MenuInit; cdecl;
procedure VID_MenuDraw;
function VID_MenuKey( key: integer ): PChar;


implementation

uses
  Windows, SysUtils,
  q_shared,
  client,
  cvar,
  cpas,
  keys,
  cl_scrn,
  vid_dll,
  menu,
  qmenu;


const
  REF_SOFT    = 0;
  REF_OPENGL  = 1;
  REF_3DFX    = 2;
  REF_POWERVR = 3;
  REF_VERITE  = 4;

{extern} {vid_ref, vid_fullscreen, vid_gamma, scr_viewsize,}
var
{static}
  gl_mode, gl_driver, gl_picmip, gl_ext_palettedtexture, gl_finish,
  sw_mode, sw_stipplealpha: cvar_p;

{extern} //procedure M_ForceMenuOff; - function will be called as the unit is mentioned in the uses clause

(*
====================================================================

MENU INTERACTION

====================================================================
*)
const
  SOFTWARE_MENU = 0;
  OPENGL_MENU = 1;

var
  {static}
  s_software_menu,
  s_opengl_menu: menuframework_s;
  s_current_menu: menuframework_p;

  s_current_menu_index: integer;


  s_mode_list,
  s_ref_list: array[0..1] of menulist_s;

  s_tq_slider: menuslider_s;
  s_screensize_slider,
  s_brightness_slider: array[0..1] of menuslider_s;

  s_fs_box: array[0..1] of menulist_s;
  s_stipple_box,
  s_paletted_texture_box,
  s_finish_box: menulist_s;

  s_cancel_action,
  s_defaults_action: array[0..1] of menuaction_s;

{static void}
procedure DriverCallback(unused : pointer);
begin
  s_ref_list[Integer(not Boolean(s_current_menu_index))].curvalue := s_ref_list[s_current_menu_index].curvalue;

  if ( s_ref_list[s_current_menu_index].curvalue = 0 ) then
  begin
    s_current_menu := @s_software_menu;
    s_current_menu_index := 0;
  end
  else
  begin
    s_current_menu := @s_opengl_menu;
    s_current_menu_index := 1;
  end;
end;

{static void}
procedure ScreenSizeCallback (s: pointer) ; //( void *s )
var
  slider: menuslider_p;
begin
  slider := menuslider_p(s);
  Cvar_SetValue( 'viewsize', slider^.curvalue * 10 );
end;

{static void}
procedure BrightnessCallback (s: pointer); //( void *s )
var
  slider: menuslider_p;
  gamma: single;
begin
  slider := menuslider_p(s);
  if ( s_current_menu_index = SOFTWARE_MENU ) then
    s_brightness_slider[1].curvalue := s_brightness_slider[0].curvalue
  else
    s_brightness_slider[0].curvalue := s_brightness_slider[1].curvalue;

  if ( strcomp( vid_ref^.string_, 'soft' ) = 0 ) then
  begin
    gamma := ( 0.8 - ( slider^.curvalue/10.0 - 0.5 ) ) + 0.5;
    Cvar_SetValue( 'vid_gamma', gamma );
  end;
end;

{static void}
procedure ResetDefaults(unused: pointer);  //( void *unused )
begin
  VID_MenuInit();
end;

{static void}
procedure ApplyChanges(unused: pointer); //( void *unused )
var
  gamma, g: single;
  // envbuffer: array[0..1024-1] of Char; Juha: Not needed, made this differently from original
begin
  (*
  ** make values consistent
  *)
  s_fs_box[not s_current_menu_index].curvalue := s_fs_box[s_current_menu_index].curvalue;
  s_brightness_slider[not s_current_menu_index].curvalue := s_brightness_slider[s_current_menu_index].curvalue;
  s_ref_list[not s_current_menu_index].curvalue := s_ref_list[s_current_menu_index].curvalue;

  (*
  ** invert sense so greater:= brighter, and scale to a range of 0.5 to 1.3
  *)
  gamma := ( 0.8 - ( s_brightness_slider[s_current_menu_index].curvalue/10.0 - 0.5 ) ) + 0.5;

  Cvar_SetValue( 'vid_gamma', gamma );
  Cvar_SetValue( 'sw_stipplealpha', s_stipple_box.curvalue );
  Cvar_SetValue( 'gl_picmip', 3 - s_tq_slider.curvalue );
  Cvar_SetValue( 'vid_fullscreen', s_fs_box[s_current_menu_index].curvalue );
  Cvar_SetValue( 'gl_ext_palettedtexture', s_paletted_texture_box.curvalue );
  Cvar_SetValue( 'gl_finish', s_finish_box.curvalue );
  Cvar_SetValue( 'sw_mode', s_mode_list[SOFTWARE_MENU].curvalue );
  Cvar_SetValue( 'gl_mode', s_mode_list[OPENGL_MENU].curvalue );

  case ( s_ref_list[s_current_menu_index].curvalue ) of
    REF_SOFT:
    begin
      Cvar_Set( 'vid_ref', 'soft' );
    end;
    REF_OPENGL:
    begin
      Cvar_Set( 'vid_ref', 'gl' );
      Cvar_Set( 'gl_driver', 'opengl32' );
    end;
    REF_3DFX:
    begin
      Cvar_Set( 'vid_ref', 'gl' );
      Cvar_Set( 'gl_driver', '3dfxgl' );
    end;
    REF_POWERVR:
    begin
      Cvar_Set( 'vid_ref', 'gl' );
      Cvar_Set( 'gl_driver', 'pvrgl' );
    end;
    REF_VERITE:
    begin
      Cvar_Set( 'vid_ref', 'gl' );
      Cvar_Set( 'gl_driver', 'veritegl' );
    end;
  end;

  (*
  ** update appropriate stuff if we're running OpenGL and gamma
  ** has been modified
  *)
  if ( strcmp( vid_ref^.string_, 'gl' ) = 0 ) then
  begin
    if ( vid_gamma^.modified ) then
    begin
      vid_ref^.modified := true;
      if ( strcmp( gl_driver.string_, '3dfxgl' ) = 0 ) then
      begin
        vid_ref^.modified := true;

        g := 2.00 * ( 0.8 - ( vid_gamma^.value - 0.5 ) ) + 1.0{F};
        Windows.SetEnvironmentVariable('SSTV2_GAMMA', PChar(Format('%f', [g])));
        Windows.SetEnvironmentVariable('SST_GAMMA', PChar(Format('%f', [g])));
        vid_gamma^.modified:= false;
      end;
    end;

    if ( gl_driver.modified ) then vid_ref^.modified := true;
  end;

  M_ForceMenuOff();
end;

{static void}
procedure OnCancelChanges(unused: pointer); //( void *unused )
begin
  M_PopMenu();   // declared and defined in another unit check uses clause
end;

(*
** VID_MenuInit
*)
{void}
procedure VID_MenuInit;
var
  i: integer;
const
  resolutions: array[0..11] of PChar = (
    '[320 240  ]',
    '[400 300  ]',
    '[512 384  ]',
    '[640 480  ]',
    '[800 600  ]',

⌨️ 快捷键说明

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