mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-18 06:51:47 +00:00
Improved the menu code a bit, made style cleaner and
added some comments to my menu code.
This commit is contained in:
parent
2bf1182d19
commit
863b4e9bbd
5 changed files with 340 additions and 105 deletions
|
@ -25,6 +25,7 @@ string [NUM_BINDED_KEYS] key_bindings =
|
||||||
"messagemode",
|
"messagemode",
|
||||||
"screenshot",
|
"screenshot",
|
||||||
#define NUM_MISC_KEYS NUM_BASIC_KEYS + 4
|
#define NUM_MISC_KEYS NUM_BASIC_KEYS + 4
|
||||||
|
"impulse 0",
|
||||||
"impulse 1",
|
"impulse 1",
|
||||||
"impulse 2",
|
"impulse 2",
|
||||||
"impulse 3",
|
"impulse 3",
|
||||||
|
@ -69,6 +70,8 @@ void () load_keybindings =
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//**** BINDINGS OPTIONS
|
||||||
|
|
||||||
integer (string text, integer key) control_bind_f =
|
integer (string text, integer key) control_bind_f =
|
||||||
{
|
{
|
||||||
local string binding;
|
local string binding;
|
||||||
|
|
|
@ -480,7 +480,7 @@ void () main_menu =
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
options_menu ();
|
MENU_options ();
|
||||||
help_menu ();
|
help_menu ();
|
||||||
Menu_Item (54, 112, "", quit_f, 0);
|
Menu_Item (54, 112, "", quit_f, 0);
|
||||||
Menu_End ();
|
Menu_End ();
|
||||||
|
|
|
@ -1,3 +1,33 @@
|
||||||
|
/*
|
||||||
|
options.qc
|
||||||
|
|
||||||
|
Options menu
|
||||||
|
|
||||||
|
Copyright (C) 2002 Robin Redeker <elmex@x-paste.de>
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public
|
||||||
|
License along with this program; if not, write to:
|
||||||
|
|
||||||
|
Free Software Foundation, Inc.
|
||||||
|
59 Temple Place - Suite 330
|
||||||
|
Boston, MA 02111-1307, USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
some definitions of border values for
|
||||||
|
different things
|
||||||
|
*/
|
||||||
#define MIN_GAMMA 0.4
|
#define MIN_GAMMA 0.4
|
||||||
#define MAX_GAMMA 3
|
#define MAX_GAMMA 3
|
||||||
#define GAMMA_STEP 0.1
|
#define GAMMA_STEP 0.1
|
||||||
|
@ -14,9 +44,19 @@
|
||||||
#define MAX_VOLUME 1.5
|
#define MAX_VOLUME 1.5
|
||||||
#define VOLUME_STEP 0.1
|
#define VOLUME_STEP 0.1
|
||||||
|
|
||||||
//**** VIDEO OPTIONS
|
/****************************
|
||||||
|
* VIDEO OPTIONS
|
||||||
|
* Video settings menu code
|
||||||
|
****************************/
|
||||||
|
|
||||||
|
|
||||||
integer (string text, integer key) video_options_f =
|
/*
|
||||||
|
CB_video_options
|
||||||
|
|
||||||
|
Menu event callback for video options
|
||||||
|
*/
|
||||||
|
integer (string text, integer key)
|
||||||
|
CB_video_options =
|
||||||
{
|
{
|
||||||
local integer selected_crosshair;
|
local integer selected_crosshair;
|
||||||
local float val;
|
local float val;
|
||||||
|
@ -47,21 +87,28 @@ integer (string text, integer key) video_options_f =
|
||||||
switch (text) {
|
switch (text) {
|
||||||
case "gamma":
|
case "gamma":
|
||||||
val = cvar("vid_gamma");
|
val = cvar("vid_gamma");
|
||||||
val = min_max_cnt(MIN_GAMMA, MAX_GAMMA, GAMMA_STEP, val, (key == QFK_RIGHT) && (key != QFK_LEFT));
|
val = min_max_cnt(MIN_GAMMA, MAX_GAMMA, GAMMA_STEP, val,
|
||||||
|
(key == QFK_RIGHT) && (key != QFK_LEFT));
|
||||||
cvar_set("vid_gamma", ftos(val));
|
cvar_set("vid_gamma", ftos(val));
|
||||||
break;
|
break;
|
||||||
case "viewsize":
|
case "viewsize":
|
||||||
val = cvar("viewsize");
|
val = cvar("viewsize");
|
||||||
val = min_max_cnt(MIN_VIEWSIZE, MAX_VIEWSIZE, VIEWSIZE_STEP, val, (key == QFK_RIGHT) && (key != QFK_LEFT));
|
val = min_max_cnt(MIN_VIEWSIZE, MAX_VIEWSIZE, VIEWSIZE_STEP, val,
|
||||||
|
(key == QFK_RIGHT) && (key != QFK_LEFT));
|
||||||
cvar_set("viewsize", ftos(val));
|
cvar_set("viewsize", ftos(val));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
integer () options_video_draw =
|
/*
|
||||||
|
DRAW_video_options
|
||||||
|
|
||||||
|
Drawing function for the video options menu
|
||||||
|
*/
|
||||||
|
integer ()
|
||||||
|
DRAW_video_options =
|
||||||
{
|
{
|
||||||
local string tmp = ftos(cvar("crosshair"));
|
|
||||||
local integer spacing = 120;
|
local integer spacing = 120;
|
||||||
local integer bar_pad;
|
local integer bar_pad;
|
||||||
|
|
||||||
|
@ -69,66 +116,83 @@ integer () options_video_draw =
|
||||||
Draw_CenterPic (160, 4, "gfx/p_option.lmp");
|
Draw_CenterPic (160, 4, "gfx/p_option.lmp");
|
||||||
Draw_String (54, 40, "Video");
|
Draw_String (54, 40, "Video");
|
||||||
Draw_String (54, 50, "-----");
|
Draw_String (54, 50, "-----");
|
||||||
draw_val_item (70, 60, spacing, "Fullscreen", get_cvar_state ("vid_fullscreen"));
|
draw_val_item (70, 60, spacing, "Fullscreen",
|
||||||
draw_val_item (70, 70, spacing, "Crosshair", tmp);
|
cvar("vid_fullscreen") ? "On" : "Off");
|
||||||
draw_val_item (70, 80, spacing, "Show fps", get_cvar_state ("show_fps"));
|
draw_val_item (70, 70, spacing, "Crosshair", ftos(cvar("crosshair")));
|
||||||
draw_val_item (70, 90, spacing, "Show time", get_cvar_state ("show_time"));
|
draw_val_item (70, 80, spacing, "Show fps",
|
||||||
|
cvar("show_fps") ? "On" : "Off");
|
||||||
|
draw_val_item (70, 90, spacing, "Show time",
|
||||||
|
cvar("show_time") ? "On" : "Off");
|
||||||
bar_pad = 90;
|
bar_pad = 90;
|
||||||
|
|
||||||
Draw_String (70, bar_pad + 10, "Gamma:");
|
Draw_String (70, bar_pad + 10, "Gamma:");
|
||||||
draw_perc_bar (118, bar_pad + 10, 15, to_percentage (MIN_GAMMA, MAX_GAMMA, cvar("vid_gamma")));
|
draw_perc_bar (118, bar_pad + 10, 15,
|
||||||
|
to_percentage (MIN_GAMMA, MAX_GAMMA, cvar("vid_gamma")));
|
||||||
Draw_String (118 + (15 + 4)*8 , bar_pad + 10, ftos(cvar("vid_gamma")));
|
Draw_String (118 + (15 + 4)*8 , bar_pad + 10, ftos(cvar("vid_gamma")));
|
||||||
|
|
||||||
Draw_String (70, bar_pad + 20, "Viewsize:");
|
Draw_String (70, bar_pad + 20, "Viewsize:");
|
||||||
draw_perc_bar (142, bar_pad + 20, 12, to_percentage (MIN_VIEWSIZE, MAX_VIEWSIZE, cvar("viewsize")));
|
draw_perc_bar (142, bar_pad + 20, 12,
|
||||||
|
to_percentage (MIN_VIEWSIZE, MAX_VIEWSIZE, cvar("viewsize")));
|
||||||
Draw_String (142 + (12 + 4)*8 , bar_pad + 20, ftos(cvar("viewsize")));
|
Draw_String (142 + (12 + 4)*8 , bar_pad + 20, ftos(cvar("viewsize")));
|
||||||
|
|
||||||
opt_cursor (62, (Menu_GetIndex() * 10) + 60);
|
opt_cursor (62, (Menu_GetIndex() * 10) + 60);
|
||||||
return 1;
|
return 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
void () options_video_menu =
|
/*
|
||||||
|
MENU_video_options
|
||||||
|
|
||||||
|
Menu function for the video options menu.
|
||||||
|
*/
|
||||||
|
void ()
|
||||||
|
MENU_video_options =
|
||||||
{
|
{
|
||||||
local integer bar_pad;
|
local integer bar_pad;
|
||||||
|
|
||||||
Menu_Begin (54, 50, "Video");
|
Menu_Begin (54, 50, "Video");
|
||||||
Menu_FadeScreen (1);
|
Menu_FadeScreen (1);
|
||||||
Menu_Draw (options_video_draw);
|
Menu_Draw (DRAW_video_options);
|
||||||
|
|
||||||
Menu_Item (54, 60, "fullscreen", video_options_f, 0);
|
Menu_Item (54, 60, "fullscreen", CB_video_options, 0);
|
||||||
Menu_Item (54, 70, "crosshair", video_options_f, 0);
|
Menu_Item (54, 70, "crosshair", CB_video_options, 0);
|
||||||
Menu_Item (54, 80, "fps", video_options_f, 0);
|
Menu_Item (54, 80, "fps", CB_video_options, 0);
|
||||||
Menu_Item (54, 80, "time", video_options_f, 0);
|
Menu_Item (54, 80, "time", CB_video_options, 0);
|
||||||
bar_pad = 90;
|
bar_pad = 90;
|
||||||
|
|
||||||
Menu_Item (54, bar_pad + 10, "gamma", video_options_f, 1);
|
Menu_Item (54, bar_pad + 10, "gamma", CB_video_options, 1);
|
||||||
Menu_Item (54, bar_pad + 20, "viewsize", video_options_f, 1);
|
Menu_Item (54, bar_pad + 20, "viewsize", CB_video_options, 1);
|
||||||
Menu_End ();
|
Menu_End ();
|
||||||
};
|
};
|
||||||
|
|
||||||
//**** AUDIO OPTIONS
|
/*************************************
|
||||||
|
* AUDIO OPTIONS
|
||||||
|
* Code for the audio settings menu
|
||||||
|
*************************************/
|
||||||
|
|
||||||
integer (string text, integer key) audio_volume_f =
|
/*
|
||||||
|
CB_audio_options
|
||||||
|
|
||||||
|
Callback for the audio settings.
|
||||||
|
*/
|
||||||
|
integer (string text, integer key)
|
||||||
|
CB_audio_options =
|
||||||
{
|
{
|
||||||
local float volume;
|
local float volume;
|
||||||
|
|
||||||
volume = cvar("volume");
|
volume = cvar("volume");
|
||||||
if(key == QFK_RIGHT) {
|
volume = min_max_cnt(MIN_VOLUME, MAX_VOLUME, VOLUME_STEP, volume, (key == QFK_RIGHT) && (key != QFK_LEFT));
|
||||||
volume += VOLUME_STEP;
|
|
||||||
} else if(key == QFK_LEFT) {
|
|
||||||
volume -= VOLUME_STEP;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(volume > MAX_VOLUME) {
|
|
||||||
volume = MIN_VOLUME;
|
|
||||||
} else if(volume < MIN_VOLUME) {
|
|
||||||
volume = MAX_VOLUME;
|
|
||||||
}
|
|
||||||
cvar_set("volume", ftos(volume));
|
cvar_set("volume", ftos(volume));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
integer () options_audio_draw =
|
/*
|
||||||
|
DRAW_audio_options
|
||||||
|
|
||||||
|
Draws the audio options menu
|
||||||
|
*/
|
||||||
|
integer ()
|
||||||
|
DRAW_audio_options =
|
||||||
{
|
{
|
||||||
local string tmp = ftos(cvar("crosshair"));
|
local string tmp = ftos(cvar("crosshair"));
|
||||||
local integer spacing = 120;
|
local integer spacing = 120;
|
||||||
|
@ -141,29 +205,45 @@ integer () options_audio_draw =
|
||||||
bar_pad = 50;
|
bar_pad = 50;
|
||||||
|
|
||||||
Draw_String (70, bar_pad + 10, "Volume:");
|
Draw_String (70, bar_pad + 10, "Volume:");
|
||||||
draw_perc_bar (126, bar_pad + 10, 15, to_percentage (MIN_VOLUME, MAX_VOLUME, cvar("volume")));
|
draw_perc_bar (126, bar_pad + 10, 15,
|
||||||
|
to_percentage (MIN_VOLUME, MAX_VOLUME, cvar("volume")) );
|
||||||
Draw_String (126 + (15 + 4)*8 , bar_pad + 10, ftos(cvar("volume")));
|
Draw_String (126 + (15 + 4)*8 , bar_pad + 10, ftos(cvar("volume")));
|
||||||
|
|
||||||
opt_cursor (62, (Menu_GetIndex() * 10) + 60);
|
opt_cursor (62, (Menu_GetIndex() * 10) + 60);
|
||||||
return 1;
|
return 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
void () options_audio_menu =
|
/*
|
||||||
|
MENU_audio_options
|
||||||
|
|
||||||
|
Makes the audio menu
|
||||||
|
*/
|
||||||
|
void ()
|
||||||
|
MENU_audio_options =
|
||||||
{
|
{
|
||||||
local integer bar_pad;
|
local integer bar_pad;
|
||||||
|
|
||||||
Menu_Begin (54, 60, "Audio");
|
Menu_Begin (54, 60, "Audio");
|
||||||
Menu_FadeScreen (1);
|
Menu_FadeScreen (1);
|
||||||
Menu_Draw (options_audio_draw);
|
Menu_Draw (DRAW_audio_options);
|
||||||
|
|
||||||
bar_pad = 0;
|
bar_pad = 0;
|
||||||
Menu_Item (54, bar_pad + 10, "volume", audio_volume_f, 1);
|
Menu_Item (54, bar_pad + 10, "volume", CB_audio_options, 1);
|
||||||
Menu_End ();
|
Menu_End ();
|
||||||
};
|
};
|
||||||
|
|
||||||
//**** CONTROL OPTIONS
|
/************************
|
||||||
|
* CONTROL OPTIONS
|
||||||
|
* Control setting code
|
||||||
|
************************/
|
||||||
|
|
||||||
integer (string text, integer key) control_options_f =
|
/*
|
||||||
|
CB_control_options
|
||||||
|
|
||||||
|
Callback for control options
|
||||||
|
*/
|
||||||
|
integer (string text, integer key)
|
||||||
|
CB_control_options =
|
||||||
{
|
{
|
||||||
local float val;
|
local float val;
|
||||||
|
|
||||||
|
@ -185,6 +265,12 @@ integer (string text, integer key) control_options_f =
|
||||||
case "freelook":
|
case "freelook":
|
||||||
Cbuf_AddText ("toggle freelook\n");
|
Cbuf_AddText ("toggle freelook\n");
|
||||||
break;
|
break;
|
||||||
|
case "lookspring":
|
||||||
|
Cbuf_AddText ("toggle lookspring\n");
|
||||||
|
break;
|
||||||
|
case "lookstrafe":
|
||||||
|
Cbuf_AddText ("toggle lookstrafe\n");
|
||||||
|
break;
|
||||||
case "m_pitch":
|
case "m_pitch":
|
||||||
if(cvar("m_pitch") < 0) {
|
if(cvar("m_pitch") < 0) {
|
||||||
Cbuf_AddText ("set m_pitch 0.022\n");
|
Cbuf_AddText ("set m_pitch 0.022\n");
|
||||||
|
@ -205,100 +291,164 @@ integer (string text, integer key) control_options_f =
|
||||||
switch (text) {
|
switch (text) {
|
||||||
case "mouseamp":
|
case "mouseamp":
|
||||||
val = cvar("in_mouse_amp");
|
val = cvar("in_mouse_amp");
|
||||||
val = min_max_cnt(MIN_MOUSE_AMP, MAX_MOUSE_AMP, MOUSE_AMP_STEP, val, (key == QFK_RIGHT) && (key != QFK_LEFT));
|
val = min_max_cnt(MIN_MOUSE_AMP, MAX_MOUSE_AMP, MOUSE_AMP_STEP, val,
|
||||||
|
(key == QFK_RIGHT) && (key != QFK_LEFT));
|
||||||
cvar_set("in_mouse_amp", ftos(val));
|
cvar_set("in_mouse_amp", ftos(val));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
integer () options_controls_draw =
|
/*
|
||||||
|
DRAW_control_options
|
||||||
|
|
||||||
|
Draws the control option menu
|
||||||
|
*/
|
||||||
|
integer ()
|
||||||
|
DRAW_control_options =
|
||||||
{
|
{
|
||||||
local string tmp;
|
|
||||||
local integer cursor_pad = 0, spacing = 120, bar_pad;
|
local integer cursor_pad = 0, spacing = 120, bar_pad;
|
||||||
|
|
||||||
|
Draw_Pic (16, 4, "gfx/qplaque.lmp");
|
||||||
Draw_Pic (16, 4, "gfx/qplaque.lmp");
|
Draw_CenterPic (160, 4, "gfx/p_option.lmp");
|
||||||
Draw_CenterPic (160,4, "gfx/p_option.lmp");
|
|
||||||
Draw_String (54, 40, "Controls");
|
Draw_String (54, 40, "Controls");
|
||||||
Draw_String (54, 50, "--------");
|
Draw_String (54, 50, "--------");
|
||||||
Draw_String (70, 60, "Bindings");
|
Draw_String (70, 60, "Bindings");
|
||||||
|
|
||||||
draw_val_item (70, 70, spacing, "Grab mouse", get_cvar_state ("in_grab"));
|
draw_val_item (70, 70, spacing, "Grab mouse", cvar("in_grab") ? "On" : "Off");
|
||||||
tmp = cvar("cl_forwardspeed") < 400 ? "Off" : "On";
|
draw_val_item (70, 80, spacing, "Auto run", cvar("cl_forwardspeed") < 400 ? "Off" : "On");
|
||||||
draw_val_item (70, 80, spacing, "Auto run", tmp);
|
draw_val_item (70, 90, spacing, "Mouse Invert", cvar("m_pitch") < 0 ? "On" : "Off");
|
||||||
draw_val_item (70, 90, spacing, "Freelook", get_cvar_state ("freelook"));
|
|
||||||
bar_pad = 90;
|
bar_pad = 90;
|
||||||
|
|
||||||
Draw_String (70, bar_pad + 10, "Mouse amp:");
|
Draw_String (70, bar_pad + 10, "Mouse amp:");
|
||||||
draw_perc_bar (150, bar_pad + 10, 12, to_percentage (MIN_MOUSE_AMP, MAX_MOUSE_AMP, cvar("in_mouse_amp")));
|
draw_perc_bar (150, bar_pad + 10, 12, to_percentage (MIN_MOUSE_AMP, MAX_MOUSE_AMP, cvar("in_mouse_amp")));
|
||||||
Draw_String (150 + (12 + 4)*8 , bar_pad + 10, ftos(cvar("in_mouse_amp")));
|
Draw_String (150 + (12 + 4)*8 , bar_pad + 10, ftos(cvar("in_mouse_amp")));
|
||||||
|
|
||||||
tmp = cvar("m_pitch") < 0 ? "On" : "Off";
|
draw_val_item (70, 110, spacing, "Freelook", cvar("freelook") ? "On" : "Off");
|
||||||
draw_val_item (70, 110, spacing, "Mouse Invert", tmp);
|
draw_val_item (70, 120, spacing, "Lookspring", cvar("lookspring") ? "On" : "Off");
|
||||||
|
draw_val_item (70, 130, spacing, "Lookstrafe", cvar("lookstrafe") ? "On" : "Off");
|
||||||
|
|
||||||
opt_cursor (62, (Menu_GetIndex() * 10) + 60 + cursor_pad);
|
opt_cursor (62, (Menu_GetIndex() * 10) + 60 + cursor_pad);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
void () options_controls_menu =
|
/*
|
||||||
|
MENU_control_options
|
||||||
|
|
||||||
|
Menu make function for control options
|
||||||
|
*/
|
||||||
|
void ()
|
||||||
|
MENU_control_options =
|
||||||
{
|
{
|
||||||
Menu_Begin (54, 40, "Controls");
|
Menu_Begin (54, 40, "Controls");
|
||||||
Menu_FadeScreen (1);
|
Menu_FadeScreen (1);
|
||||||
Menu_CenterPic (160, 4, "gfx/p_option.lmp");
|
Menu_CenterPic (160, 4, "gfx/p_option.lmp");
|
||||||
Menu_Draw (options_controls_draw);
|
Menu_Draw (DRAW_control_options);
|
||||||
control_bind_menu ();
|
control_bind_menu ();
|
||||||
Menu_Item (54, 70, "in_grab", control_options_f, 0);
|
Menu_Item (54, 70, "in_grab", CB_control_options, 0);
|
||||||
Menu_Item (54, 80, "autorun", control_options_f, 0);
|
Menu_Item (54, 80, "autorun", CB_control_options, 0);
|
||||||
Menu_Item (54, 90, "freelook", control_options_f, 0);
|
Menu_Item (54, 90, "m_pitch", CB_control_options, 0);
|
||||||
Menu_Item (54, 100, "mouseamp", control_options_f, 1);
|
Menu_Item (54, 100, "mouseamp", CB_control_options, 1);
|
||||||
Menu_Item (54, 110, "m_pitch", control_options_f, 0);
|
Menu_Item (54, 110, "freelook", CB_control_options, 0);
|
||||||
Menu_Item (54, 120, "cl_autorecord", control_options_f, 0);
|
Menu_Item (54, 120, "lookspring", CB_control_options, 0);
|
||||||
|
Menu_Item (54, 130, "lookstrafe", CB_control_options, 0);
|
||||||
Menu_End ();
|
Menu_End ();
|
||||||
};
|
};
|
||||||
|
|
||||||
integer () options_features_draw =
|
/***********************************************
|
||||||
{
|
* FEATURES OPTIONS
|
||||||
local string tmp;
|
* Code of settings for special features of QF
|
||||||
local integer cursor_pad = 0, spacing = 120;
|
***********************************************/
|
||||||
|
|
||||||
|
/*
|
||||||
|
CB_feature_options
|
||||||
|
|
||||||
|
Callback for feature settings
|
||||||
|
*/
|
||||||
|
integer (string text, integer key)
|
||||||
|
CB_feature_options =
|
||||||
|
{
|
||||||
|
switch (text) {
|
||||||
|
case "cl_autorecord":
|
||||||
|
Cbuf_AddText ("toggle cl_autorecord\n");
|
||||||
|
break;
|
||||||
|
case "cl_fraglog":
|
||||||
|
Cbuf_AddText ("toggle cl_fraglog\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
DRAW_feature_options
|
||||||
|
|
||||||
|
Draws the feature option menu
|
||||||
|
*/
|
||||||
|
integer ()
|
||||||
|
DRAW_feature_options =
|
||||||
|
{
|
||||||
|
local integer cursor_pad = 0, spacing = 120;
|
||||||
|
|
||||||
Draw_Pic (16, 4, "gfx/qplaque.lmp");
|
Draw_Pic (16, 4, "gfx/qplaque.lmp");
|
||||||
Draw_CenterPic (160,4, "gfx/p_option.lmp");
|
Draw_CenterPic (160,4, "gfx/p_option.lmp");
|
||||||
Draw_String (54, 40, "Features");
|
Draw_String (54, 40, "Features");
|
||||||
Draw_String (54, 50, "--------");
|
Draw_String (54, 50, "--------");
|
||||||
|
|
||||||
tmp = cvar("cl_autorecord") != 0 ? "On" : "Off";
|
draw_val_item (70, 60, spacing, "Auto Record",
|
||||||
draw_val_item (70, 60, spacing, "Auto Record", tmp);
|
cvar("cl_autorecord") != 0 ? "On" : "Off");
|
||||||
tmp = cvar("cl_fraglog") != 0 ? "On" : "Off";
|
draw_val_item (70, 70, spacing, "Fraglogging",
|
||||||
draw_val_item (70, 70, spacing, "Fraglogging", tmp);
|
cvar("cl_fraglog") != 0 ? "On" : "Off");
|
||||||
|
|
||||||
opt_cursor (62, (Menu_GetIndex() * 10) + 60 + cursor_pad);
|
opt_cursor (62, (Menu_GetIndex() * 10) + 60 + cursor_pad);
|
||||||
return 1;
|
return 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
void () options_features_menu =
|
/*
|
||||||
|
MENU_feature_options
|
||||||
|
|
||||||
|
Makes the feature option menu
|
||||||
|
*/
|
||||||
|
void ()
|
||||||
|
MENU_feature_options =
|
||||||
{
|
{
|
||||||
Menu_Begin (54, 70, "Features");
|
Menu_Begin (54, 70, "Features");
|
||||||
Menu_FadeScreen (1);
|
Menu_FadeScreen (1);
|
||||||
Menu_CenterPic (160, 4, "gfx/p_option.lmp");
|
Menu_CenterPic (160, 4, "gfx/p_option.lmp");
|
||||||
Menu_Draw (options_features_draw);
|
Menu_Draw (DRAW_feature_options);
|
||||||
Menu_Item (54, 70, "cl_autorecord", control_options_f, 0);
|
Menu_Item (54, 70, "cl_autorecord", CB_feature_options, 0);
|
||||||
Menu_Item (54, 80, "cl_fraglog", control_options_f, 0);
|
Menu_Item (54, 80, "cl_fraglog", CB_feature_options, 0);
|
||||||
Menu_End ();
|
Menu_End ();
|
||||||
};
|
};
|
||||||
|
|
||||||
integer (integer key, integer unicode, integer down) options_keyevent =
|
/*************************
|
||||||
|
* MAIN OPTIONS
|
||||||
|
* Main options menu code
|
||||||
|
*************************/
|
||||||
|
|
||||||
|
/*
|
||||||
|
CB_options
|
||||||
|
|
||||||
|
Callback for main options menu
|
||||||
|
*/
|
||||||
|
integer (integer key, integer unicode, integer down)
|
||||||
|
CB_options =
|
||||||
{
|
{
|
||||||
// pre-loading of the bindings and set_key_flag == 0
|
// pre-loading of the bindings and set_key_flag == 0
|
||||||
load_keybindings();
|
load_keybindings();
|
||||||
set_key_flag = 0;
|
set_key_flag = 0;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
//**** MAIN OPTIONS MENU
|
|
||||||
|
|
||||||
void () options_menu =
|
/*
|
||||||
|
MENU_options
|
||||||
|
|
||||||
|
Makes the main options menu
|
||||||
|
*/
|
||||||
|
void ()
|
||||||
|
MENU_options =
|
||||||
{
|
{
|
||||||
local integer spacing = 120;
|
local integer spacing = 120;
|
||||||
|
|
||||||
|
@ -306,11 +456,11 @@ void () options_menu =
|
||||||
Menu_FadeScreen (1);
|
Menu_FadeScreen (1);
|
||||||
Menu_Pic (16, 4, "gfx/qplaque.lmp");
|
Menu_Pic (16, 4, "gfx/qplaque.lmp");
|
||||||
Menu_CenterPic (160, 4, "gfx/p_option.lmp");
|
Menu_CenterPic (160, 4, "gfx/p_option.lmp");
|
||||||
Menu_KeyEvent (options_keyevent);
|
Menu_KeyEvent (CB_options);
|
||||||
options_controls_menu ();
|
MENU_control_options ();
|
||||||
options_video_menu ();
|
MENU_video_options ();
|
||||||
options_audio_menu ();
|
MENU_audio_options ();
|
||||||
options_features_menu ();
|
MENU_feature_options ();
|
||||||
|
|
||||||
Menu_End ();
|
Menu_End ();
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,38 +1,87 @@
|
||||||
float time;
|
/*
|
||||||
void (integer x, integer y) opt_cursor =
|
options_util.qc
|
||||||
|
|
||||||
|
Utilities for the options menu
|
||||||
|
|
||||||
|
Copyright (C) 2002 Robin Redeker <elmex@x-paste.de>
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public
|
||||||
|
License along with this program; if not, write to:
|
||||||
|
|
||||||
|
Free Software Foundation, Inc.
|
||||||
|
59 Temple Place - Suite 330
|
||||||
|
Boston, MA 02111-1307, USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
float time; // holds current time
|
||||||
|
|
||||||
|
/*
|
||||||
|
opt_cursor
|
||||||
|
|
||||||
|
function for drawing the cursor
|
||||||
|
*/
|
||||||
|
void (integer x, integer y)
|
||||||
|
opt_cursor =
|
||||||
{
|
{
|
||||||
|
// use time becaus we want a nice rotaing cursor
|
||||||
Draw_Character (x, y, 12 + (integer (time * 4) & 1));
|
Draw_Character (x, y, 12 + (integer (time * 4) & 1));
|
||||||
};
|
};
|
||||||
|
|
||||||
string (string cvarstr) get_cvar_state =
|
|
||||||
{
|
|
||||||
if(cvar(cvarstr)) {
|
|
||||||
return("On");
|
|
||||||
} else {
|
|
||||||
return("Off");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
void (integer x, integer y, integer size, integer perc_val) draw_perc_bar =
|
|
||||||
|
/*
|
||||||
|
draw_perc_bar
|
||||||
|
|
||||||
|
Draws a percentage bar by giving its size (in
|
||||||
|
chars), x and y position and the percentage from 0 to 100
|
||||||
|
*/
|
||||||
|
void (integer x, integer y, integer size, integer perc_val)
|
||||||
|
draw_perc_bar =
|
||||||
{
|
{
|
||||||
local float perc;
|
local float perc;
|
||||||
local integer i;
|
local integer i;
|
||||||
|
|
||||||
if(perc_val > 100) {
|
if(perc_val > 100) {
|
||||||
perc_val = 100;
|
perc_val = 100;
|
||||||
} else if(perc_val < 0) {
|
} else if(perc_val < 0) {
|
||||||
perc_val = 0;
|
perc_val = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
perc = itof(perc_val) / (100/itof(size));
|
perc = itof(perc_val) / ( 100 / itof(size) );
|
||||||
Draw_Character (x, y, 128);
|
|
||||||
|
/* 128, 129, 130 and 131 are special characters for scrollbars */
|
||||||
|
Draw_Character (x, y, 128); // draw beginning
|
||||||
for (i = 0; i <= size; i++) {
|
for (i = 0; i <= size; i++) {
|
||||||
Draw_Character (x + ((i+1)*8), y, 129);
|
Draw_Character (x + ((i+1)*8), y, 129); // draw the borders
|
||||||
}
|
}
|
||||||
Draw_Character (x + ((i+1)*8), y, 130);
|
Draw_Character (x + ((i+1)*8), y, 130); // draw last char
|
||||||
Draw_Character (x + ((ftoi(perc) + 1) * 8), y, 131);
|
Draw_Character (x + ((ftoi(perc) + 1) * 8), y, 131); // draw slider
|
||||||
};
|
};
|
||||||
|
|
||||||
void (integer x, integer y, integer spacing, string spacechar, string label, string valstr) draw_item =
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
draw_item
|
||||||
|
|
||||||
|
Draws a item with a specific spacing between
|
||||||
|
label and value to positions x, y.
|
||||||
|
Used as helper function for draw_val_item.
|
||||||
|
*/
|
||||||
|
void (integer x, integer y, integer spacing, string spacechar,
|
||||||
|
string label, string valstr)
|
||||||
|
draw_item =
|
||||||
{
|
{
|
||||||
local integer i;
|
local integer i;
|
||||||
Draw_String (x, y, label);
|
Draw_String (x, y, label);
|
||||||
|
@ -42,12 +91,32 @@ void (integer x, integer y, integer spacing, string spacechar, string label, str
|
||||||
Draw_String (x + spacing, y, valstr);
|
Draw_String (x + spacing, y, valstr);
|
||||||
};
|
};
|
||||||
|
|
||||||
void (integer x, integer y, integer spacing, string label, string valstr) draw_val_item =
|
|
||||||
|
/*
|
||||||
|
draw_val_item
|
||||||
|
|
||||||
|
Draws a nice menu item.
|
||||||
|
Use this function for a consistent look of menu items!
|
||||||
|
Example:
|
||||||
|
<Label>.....:<valstr>
|
||||||
|
spacing are the number of the points to put
|
||||||
|
*/
|
||||||
|
void (integer x, integer y, integer spacing, string label, string valstr)
|
||||||
|
draw_val_item =
|
||||||
{
|
{
|
||||||
draw_item (x, y, spacing, ".", label, ":" + valstr);
|
draw_item (x, y, spacing, ".", label, ":" + valstr);
|
||||||
};
|
};
|
||||||
|
|
||||||
integer (float min, float max, float val) to_percentage =
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
to_percentage
|
||||||
|
|
||||||
|
Calculates the percentage of a value relative
|
||||||
|
to a min and max value.
|
||||||
|
*/
|
||||||
|
integer (float min, float max, float val)
|
||||||
|
to_percentage =
|
||||||
{
|
{
|
||||||
local integer perc;
|
local integer perc;
|
||||||
local float max_v = (max-min);
|
local float max_v = (max-min);
|
||||||
|
@ -64,7 +133,20 @@ integer (float min, float max, float val) to_percentage =
|
||||||
return perc;
|
return perc;
|
||||||
};
|
};
|
||||||
|
|
||||||
float (float min, float max, float step, float val, integer cntflag) min_max_cnt =
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
min_max_cnt
|
||||||
|
|
||||||
|
Increases or decreases a value by take
|
||||||
|
care of the bordervalues.
|
||||||
|
min, max are the borders.
|
||||||
|
step is the step by in-/de-creasing.
|
||||||
|
cntflag should be true for increasing and
|
||||||
|
false for decreasing
|
||||||
|
*/
|
||||||
|
float (float min, float max, float step, float val, integer cntflag)
|
||||||
|
min_max_cnt =
|
||||||
{
|
{
|
||||||
if(cntflag) {
|
if(cntflag) {
|
||||||
val += step;
|
val += step;
|
||||||
|
|
|
@ -10,7 +10,7 @@ But you may use not the same prefixes.
|
||||||
Use these prefixes where it makes sense:
|
Use these prefixes where it makes sense:
|
||||||
CB_ Input callback
|
CB_ Input callback
|
||||||
MENU_ Menu making function
|
MENU_ Menu making function
|
||||||
DRAW_ Draw callback
|
DRAW_ Draw
|
||||||
|
|
||||||
|
|
||||||
Comment functions like this:
|
Comment functions like this:
|
||||||
|
|
Loading…
Reference in a new issue