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

📄 menu.pas

📁 delphi编的不错的贪吃蛇
💻 PAS
📖 第 1 页 / 共 5 页
字号:
  s_keys_center_view_action.generic.ownerdraw := DrawKeyBindingFunc;
  inc(i);
  s_keys_center_view_action.generic.localdata[0] := i;
  s_keys_center_view_action.generic.name :=
    bindnames[s_keys_center_view_action.generic.localdata[0]][1];

  s_keys_mouse_look_action.generic.type_ := MTYPE_ACTION;
  s_keys_mouse_look_action.generic.flags := QMF_GRAYED;
  s_keys_mouse_look_action.generic.x := 0;
  inc(y, 9);
  s_keys_mouse_look_action.generic.y := y;
  s_keys_mouse_look_action.generic.ownerdraw := DrawKeyBindingFunc;
  inc(i);
  s_keys_mouse_look_action.generic.localdata[0] := i;
  s_keys_mouse_look_action.generic.name :=
    bindnames[s_keys_mouse_look_action.generic.localdata[0]][1];

  s_keys_keyboard_look_action.generic.type_ := MTYPE_ACTION;
  s_keys_keyboard_look_action.generic.flags := QMF_GRAYED;
  s_keys_keyboard_look_action.generic.x := 0;
  inc(y, 9);
  s_keys_keyboard_look_action.generic.y := y;
  s_keys_keyboard_look_action.generic.ownerdraw := DrawKeyBindingFunc;
  inc(i);
  s_keys_keyboard_look_action.generic.localdata[0] := i;
  s_keys_keyboard_look_action.generic.name :=
    bindnames[s_keys_keyboard_look_action.generic.localdata[0]][1];

  s_keys_move_up_action.generic.type_ := MTYPE_ACTION;
  s_keys_move_up_action.generic.flags := QMF_GRAYED;
  s_keys_move_up_action.generic.x := 0;
  inc(y, 9);
  s_keys_move_up_action.generic.y := y;
  s_keys_move_up_action.generic.ownerdraw := DrawKeyBindingFunc;
  inc(i);
  s_keys_move_up_action.generic.localdata[0] := i;
  s_keys_move_up_action.generic.name :=
    bindnames[s_keys_move_up_action.generic.localdata[0]][1];

  s_keys_move_down_action.generic.type_ := MTYPE_ACTION;
  s_keys_move_down_action.generic.flags := QMF_GRAYED;
  s_keys_move_down_action.generic.x := 0;
  inc(y, 9);
  s_keys_move_down_action.generic.y := y;
  s_keys_move_down_action.generic.ownerdraw := DrawKeyBindingFunc;
  inc(i);
  s_keys_move_down_action.generic.localdata[0] := i;
  s_keys_move_down_action.generic.name :=
    bindnames[s_keys_move_down_action.generic.localdata[0]][1];

  s_keys_inventory_action.generic.type_ := MTYPE_ACTION;
  s_keys_inventory_action.generic.flags := QMF_GRAYED;
  s_keys_inventory_action.generic.x := 0;
  inc(y, 9);
  s_keys_inventory_action.generic.y := y;
  s_keys_inventory_action.generic.ownerdraw := DrawKeyBindingFunc;
  inc(i);
  s_keys_inventory_action.generic.localdata[0] := i;
  s_keys_inventory_action.generic.name :=
    bindnames[s_keys_inventory_action.generic.localdata[0]][1];

  s_keys_inv_use_action.generic.type_ := MTYPE_ACTION;
  s_keys_inv_use_action.generic.flags := QMF_GRAYED;
  s_keys_inv_use_action.generic.x := 0;
  inc(y, 9);
  s_keys_inv_use_action.generic.y := y;
  s_keys_inv_use_action.generic.ownerdraw := DrawKeyBindingFunc;
  inc(i);
  s_keys_inv_use_action.generic.localdata[0] := i;
  s_keys_inv_use_action.generic.name :=
    bindnames[s_keys_inv_use_action.generic.localdata[0]][1];

  s_keys_inv_drop_action.generic.type_ := MTYPE_ACTION;
  s_keys_inv_drop_action.generic.flags := QMF_GRAYED;
  s_keys_inv_drop_action.generic.x := 0;
  inc(y, 9);
  s_keys_inv_drop_action.generic.y := y;
  s_keys_inv_drop_action.generic.ownerdraw := DrawKeyBindingFunc;
  s_keys_inv_drop_action.generic.localdata[0] := i + 1;
  inc(i);
  s_keys_inv_drop_action.generic.name :=
    bindnames[s_keys_inv_drop_action.generic.localdata[0]][1];

  s_keys_inv_prev_action.generic.type_ := MTYPE_ACTION;
  s_keys_inv_prev_action.generic.flags := QMF_GRAYED;
  s_keys_inv_prev_action.generic.x := 0;
  inc(y, 9);
  s_keys_inv_prev_action.generic.y := y;
  s_keys_inv_prev_action.generic.ownerdraw := DrawKeyBindingFunc;
  s_keys_inv_prev_action.generic.localdata[0] := i + 1;
  inc(i);
  s_keys_inv_prev_action.generic.name :=
    bindnames[s_keys_inv_prev_action.generic.localdata[0]][1];

  s_keys_inv_next_action.generic.type_ := MTYPE_ACTION;
  s_keys_inv_next_action.generic.flags := QMF_GRAYED;
  s_keys_inv_next_action.generic.x := 0;
  inc(y, 9);
  s_keys_inv_next_action.generic.y := y;
  s_keys_inv_next_action.generic.ownerdraw := DrawKeyBindingFunc;
  s_keys_inv_next_action.generic.localdata[0] := i + 1;
  inc(i);
  s_keys_inv_next_action.generic.name :=
    bindnames[s_keys_inv_next_action.generic.localdata[0]][1];

  s_keys_help_computer_action.generic.type_ := MTYPE_ACTION;
  s_keys_help_computer_action.generic.flags := QMF_GRAYED;
  s_keys_help_computer_action.generic.x := 0;
  inc(y, 9);
  s_keys_help_computer_action.generic.y := y;
  s_keys_help_computer_action.generic.ownerdraw := DrawKeyBindingFunc;
  s_keys_help_computer_action.generic.localdata[0] := i + 1;
  inc(i);
  s_keys_help_computer_action.generic.name :=
    bindnames[s_keys_help_computer_action.generic.localdata[0]][1];

  Menu_AddItem(@s_keys_menu, @s_keys_attack_action);
  Menu_AddItem(@s_keys_menu, @s_keys_change_weapon_action);
  Menu_AddItem(@s_keys_menu, @s_keys_walk_forward_action);
  Menu_AddItem(@s_keys_menu, @s_keys_backpedal_action);
  Menu_AddItem(@s_keys_menu, @s_keys_turn_left_action);
  Menu_AddItem(@s_keys_menu, @s_keys_turn_right_action);
  Menu_AddItem(@s_keys_menu, @s_keys_run_action);
  Menu_AddItem(@s_keys_menu, @s_keys_step_left_action);
  Menu_AddItem(@s_keys_menu, @s_keys_step_right_action);
  Menu_AddItem(@s_keys_menu, @s_keys_sidestep_action);
  Menu_AddItem(@s_keys_menu, @s_keys_look_up_action);
  Menu_AddItem(@s_keys_menu, @s_keys_look_down_action);
  Menu_AddItem(@s_keys_menu, @s_keys_center_view_action);
  Menu_AddItem(@s_keys_menu, @s_keys_mouse_look_action);
  Menu_AddItem(@s_keys_menu, @s_keys_keyboard_look_action);
  Menu_AddItem(@s_keys_menu, @s_keys_move_up_action);
  Menu_AddItem(@s_keys_menu, @s_keys_move_down_action);

  Menu_AddItem(@s_keys_menu, @s_keys_inventory_action);
  Menu_AddItem(@s_keys_menu, @s_keys_inv_use_action);
  Menu_AddItem(@s_keys_menu, @s_keys_inv_drop_action);
  Menu_AddItem(@s_keys_menu, @s_keys_inv_prev_action);
  Menu_AddItem(@s_keys_menu, @s_keys_inv_next_action);

  Menu_AddItem(@s_keys_menu, @s_keys_help_computer_action);

  Menu_SetStatusBar(@s_keys_menu, 'enter to change, backspace to clear');
  Menu_Center(@s_keys_menu);
end;

procedure Keys_MenuDraw;                // static
begin
  Menu_AdjustCursor(@s_keys_menu, 1);
  Menu_Draw(@s_keys_menu);
end;

function Keys_MenuKey(Key: Integer): PChar;
var
  item: menuAction_p;
  cmd: array[0..1024 - 1] of Char;
begin
  item := menuaction_p(Menu_ItemAtCursor(@s_keys_menu));

  if (bind_grab <> 0) then
  begin
    if (key <> K_ESCAPE) and (key <> ord('`')) then
    begin
      Com_sprintf(cmd, sizeof(cmd), 'bind "%s" "%s"'#10,
        [Key_KeynumToString(key), bindnames[item^.generic.localdata[0]][0]]);
      Cbuf_InsertText(cmd);
    end;

    Menu_SetStatusBar(@s_keys_menu, 'enter to change, backspace to clear');
    bind_grab := Integer(False);
    result := menu_out_sound;
    exit;
  end;

  case key of
    K_KP_ENTER, K_ENTER:
      begin
        KeyBindingFunc(item);
        Result := menu_in_sound;
        exit;
      end;
    K_BACKSPACE, K_DEL, K_KP_DEL:
      begin                             // delete bindings
        M_UnbindCommand(bindnames[item^.generic.localdata[0]][0]);
        Result := menu_out_sound;
        exit;
      end;
  else
    result := Default_MenuKey(@s_keys_menu, key);
  end;
end;

procedure M_Menu_Keys_f;
begin
  Keys_MenuInit();
  M_PushMenu(@Keys_MenuDraw, @Keys_MenuKey);
end;

{
====================================

CONTROLS MENU

====================================
}
// ALL VARS ARE STATIC HERE
var
  win_noalttab: cvar_p;

  s_options_menu: MenuFramework_s;
  s_options_defaults_action, s_options_customize_options_action: menuaction_s;
  s_options_sensitivity_slider: menuslider_s;
  s_options_freelook_box, s_options_noalttab_box,
    s_options_alwaysrun_box,
    s_options_invertmouse_box,
    s_options_lookspring_box,
    s_options_lookstrafe_box,
    s_options_crosshair_box: menulist_s;
  s_options_sfxvolume_slider: menuslider_s;
  s_options_joystick_box,
    s_options_cdvolume_box,
    s_options_quality_list,
    s_options_compatibility_list,
    s_options_console_action: menulist_s;

procedure CrosshairFunc(Unused: Pointer); // static
begin
  Cvar_SetValue('crosshair', s_options_crosshair_box.curvalue);
end;

procedure JoystickFunc(Unused: Pointer); // static
begin
  Cvar_SetValue('in_joystick', s_options_joystick_box.curvalue);
end;

procedure CustomizeControlsFunc(Unused: Pointer); // static
begin
  M_Menu_Keys_f();
end;

procedure AlwaysRunFunc(Unused: Pointer); // static
begin
  Cvar_SetValue('cl_run', s_options_alwaysrun_box.curvalue);
end;

procedure FreeLookFunc(Unused: Pointer); // static
begin
  Cvar_SetValue('freelook', s_options_freelook_box.curvalue);
end;

procedure MouseSpeedFunc(Unused: Pointer); // static
begin
  Cvar_SetValue('sensitivity', s_options_sensitivity_slider.curvalue / 2);
end;

procedure NoAltTabFunc(Unused: Pointer); // static
begin
  Cvar_SetValue('win_noalttab', s_options_noalttab_box.curvalue);
end;

function ClampCvar(Min, Max, Value: Single): Single; // static
begin
  if (value < min) then
    result := min
  else if (value > max) then
    result := max
  else
    result := value;
end;

procedure ControlsSetMenuItemValues;    // static
begin
  s_options_sfxvolume_slider.curvalue := Cvar_VariableValue('s_volume') * 10;
  s_options_cdvolume_box.curvalue := Integer(Cvar_VariableValue('cd_nocd') = 0);
  s_options_quality_list.curvalue := Integer(Cvar_VariableValue('s_loadas8bit') = 0);
  s_options_sensitivity_slider.curvalue := (sensitivity^.value) * 2;

  Cvar_SetValue('cl_run', ClampCvar(0, 1, cl_run^.value));
  s_options_alwaysrun_box.curvalue := trunc(cl_run^.Value);

  s_options_invertmouse_box.curvalue := Integer(m_pitch^.value < 0);

  Cvar_SetValue('lookspring', ClampCvar(0, 1, lookspring^.value));
  s_options_lookspring_box.curvalue := trunc(lookspring^.Value);

  Cvar_SetValue('lookstrafe', ClampCvar(0, 1, lookstrafe^.value));
  s_options_lookstrafe_box.curvalue := trunc(lookstrafe^.Value);

  Cvar_SetValue('freelook', ClampCvar(0, 1, freelook^.value));
  s_options_freelook_box.curvalue := trunc(freelook^.Value);

  Cvar_SetValue('crosshair', ClampCvar(0, 3, crosshair^.value));
  s_options_crosshair_box.curvalue := trunc(crosshair^.Value);

  Cvar_SetValue('in_joystick', ClampCvar(0, 1, in_joystick^.value));
  s_options_joystick_box.curvalue := trunc(in_joystick^.Value);

  s_options_noalttab_box.curvalue := trunc(win_noalttab^.Value);
end;

procedure ControlsResetDefaultsFunc(Unused: Pointer); // static
begin
  Cbuf_AddText('exec default.cfg'#10);
  Cbuf_Execute();

  ControlsSetMenuItemValues();
end;

procedure InvertMouseFunc(Unused: Pointer); // static
begin
  Cvar_SetValue('m_pitch', -m_pitch^.value);
end;

procedure LookspringFunc(Unused: Pointer); // static
begin
  Cvar_SetValue('lookspring', Integer(Trunc(lookspring^.value) = 0));
end;

procedure LookstrafeFunc(Unused: Pointer); // static
begin
  Cvar_SetValue('lookstrafe', Integer(Trunc(lookstrafe^.value) = 0));
end;

procedure UpdateVolumeFunc(Unused: Pointer); // static
begin
  Cvar_SetValue('s_volume', s_options_sfxvolume_slider.curvalue / 10);
end;

procedure UpdateCDVolumeFunc(Unused: Pointer); // static
begin
  Cvar_SetValue('cd_nocd', Integer(Trunc(s_options_cdvolume_box.curvalue) = 0));
end;

procedure ConsoleFunc(Unused: Pointer); // static
begin
  {
  ** the proper way to do this is probably to have ToggleConsole_f accept a parameter
  }

  if cl.attractloop then
  begin
    Cbuf_AddText('killserver'#10);
    exit;
  end;

  Key_ClearTyping();
  Con_ClearNotify();

  M_ForceMenuOff();
  cls.key_dest := key_console;
end;

procedure UpdateSoundQualityFunc(Unused: Pointer); // static
begin
  if Trunc(s_options_quality_list.curvalue) <> 0 then
  begin
    Cvar_SetValue('s_khz', 22);
    Cvar_SetValue('s_loadas8bit', Integer(False));
  end
  else
  begin
    Cvar_SetValue('s_khz', 11);
    Cvar_SetValue('s_loadas8bit', Integer(True));
  end;

  Cvar_SetValue('s_primary', s_options_compatibility_list.curvalue);

  M_DrawTextBox(8, 120 - 48, 36, 3);
  M_Print(16 + 16, 120 - 48 + 8, 'Restarting the sound system. This');
  M_Print(16 + 16, 120 - 48 + 16, 'could take up to a minute, so');
  M_Print(16 + 16, 120 - 48 + 24, 'please be patient.');

  // the text box won't show up unless we do a buffer swap
  re.EndFrame();

  CL_Snd_Restart_f();
end;

const
  cd_music_items: array[0..2] of PChar = ('disabled', 'enabled', nil);
  quality_items: array[0..2] of PChar = ('low', 'high', nil);
  compatibility_items: array[0..2] of PChar = ('max compatibilty', 'max performance', nil);
  yesno_names: array[0..2] of PChar = ('no', 'yes', nil);
  crosshair_names: array[0..4] of PChar = ('none', 'cross', 'dot', 'angle', nil);

procedure Options_MenuInit;
begin
  win_noalttab := Cvar_Get('win_noalttab', '0', CVAR_ARCHIVE);

  {
  ** configure controls menu and menu items
  }
  s_options_menu.x := viddef.Width div 2;
  s_options_menu.y := viddef.Height div 2 - 58;
  s_options_menu.nitems := 0;

  s_options_sfxvolume_slider.generic.type_ := MTYPE_SLIDER;
  s_options_sfxvolume_slider.generic.x := 0;
  s_options_sfxvolume_slider.generic.y := 0;
  s_options_sfxvolume_slider.generic.name := 'effects volume';
  s_options_sfxvolume_slider.generic.callback := UpdateVolumeFunc;
  s_options_sfxvolume_slider.minvalue := 0;
  s_options_sfxvolume_slider.maxvalue := 10;
  s_options_sfxvolume_slider.curvalue := Cvar_VariableValue('s_volume') * 10;

  s_options_cdvolume_box.generic.type_ := MTYPE_SPINCONTROL;
  s_options_cdvolume_box.generic.x := 0;
  s_options_cdvolume_box.generic.y := 10;
  s_options_cdvolume_box.generic.name := 'CD music';
  s_options_cdvolume_box.generic.callback := UpdateCDVolumeFunc;
  s_options_cdvolume_box.itemnames := @cd_music_items;
  s_options_cdvolume_box.curvalue := Integer(Cvar_VariableValue('cd_nocd') = 0);

  s_options_quality_list.generic.type_ := MTYPE_SPINCONTROL;
  s_options_quality_list.generic.x := 0;
  s_options_quality_list.generic.y := 20;
  ;
  s_options_quality_list.generic.name := 'sound quality';
  s_options_quality_list.generic.callback := UpdateSoundQualityFunc;
  s_options_quality_list.itemnames := @quality_items;
  s_options_quality_list.curvalue := Integer(Cvar_VariableValue('s_loadas8bit') = 0);

  s_options_compatibility_list.generic.type_ := MTYPE_SPINCONTROL;
  s_options_compatibility_list.generic.x := 0;
  s_options_compatibility_list.generic.y := 30;
  s_options_compatibility_list.generic.name := 'sound compatibility';
  s_options_compatibility_list.generic.callback := UpdateSoundQualityFunc;
  s_options_compatibility_list.itemnames := @compatibility_items;
  s_options_compatibility_list.curvalue := Integer(Cvar_VariableValue('s_primary') <> 0);

  s_options_sensitivity_slider.generic.type_ := MTYPE_SLIDER;
  s_options_sensitivity_slider.generic.x := 0;
  s_options_sensitivity_slider.generic.y := 50;
  s_options_sensitivity_slider.generic.name := 'mouse speed';
  s_options_sensitivity_slider.generic.callback := MouseSpeedFunc;
  s_options_sensitivity_slider.minvalue := 2;
  s_options_sensitivity_slider.maxvalue := 22;

  s_options_alwaysrun_box.generic.type_ := MTYPE_SPINCONTROL;
  s_options_alwaysrun_box.generic.x := 0;
  s_options_alwaysrun_box.generic.y := 60;
  s_options_alwaysrun_box.generic.name := 'always run';
  s_options_alwaysrun_box.generic.callback := AlwaysRunFunc;
  s_options_alwaysrun_box.itemnames := @yesno_names;

  s_options_invertmouse_box.generic.type_ := MTYPE_SPINCONTROL;
  s_options_invertmouse_box.generic.x := 0;
  s_options_invertmouse_box.generic.y := 70;
  s_options_invertmouse_box.generic.name := 'invert mouse';
  s_options_invertmouse_box.generic.callback := InvertMouseFunc;

⌨️ 快捷键说明

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