mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-02-17 01:11:45 +00:00
Worked on the options-menu and made gamma-bar more useable and
moved control-binding (still in construction) to a extra-submenu.
This commit is contained in:
parent
60e99d724b
commit
ecc20a7d17
5 changed files with 200 additions and 172 deletions
|
@ -11,7 +11,7 @@ QCPPFLAGS=-I. -I$(srcdir) -I$(top_builddir)/include -I$(top_srcdir)/include
|
|||
|
||||
pkgdata_DATA= menu.dat
|
||||
|
||||
menu_src= menu.qc options.qc cbuf_def.qc draw_def.qc file_def.qc menu_def.qc string_def.qc game_def.qc
|
||||
menu_src= menu.qc options.qc cbuf_def.qc draw_def.qc file_def.qc menu_def.qc string_def.qc game_def.qc controls_o.qc options_util.qc
|
||||
|
||||
menu.dat: menu.src $(menu_src)
|
||||
$(QFCC) $(QCFLAGS) $(QCPPFLAGS) -P $<
|
||||
|
|
95
cs-code/controls_o.qc
Normal file
95
cs-code/controls_o.qc
Normal file
|
@ -0,0 +1,95 @@
|
|||
#define NUM_BINDED_KEYS 3
|
||||
string [NUM_BINDED_KEYS] key_bindings =
|
||||
{
|
||||
"+attack",
|
||||
"impulse 10",
|
||||
"+jump"
|
||||
};
|
||||
string [NUM_BINDED_KEYS] key_bindings_keys =
|
||||
{
|
||||
"none",
|
||||
"none",
|
||||
"none"
|
||||
};
|
||||
|
||||
integer set_key_flag;
|
||||
|
||||
void () load_keybindings =
|
||||
{
|
||||
local integer i, keynum;
|
||||
|
||||
for(i = 0;i < NUM_BINDED_KEYS; i++) {
|
||||
keynum = Key_LookupBinding(IMT_0, key_bindings[i]);
|
||||
if(keynum == -1) {
|
||||
key_bindings_keys[i] = "<none>";
|
||||
} else {
|
||||
key_bindings_keys[i] = Key_KeynumToString(keynum);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
integer (string text, integer key) control_bind_f =
|
||||
{
|
||||
local string binding;
|
||||
local integer retval = 0;
|
||||
|
||||
switch (text) {
|
||||
case "set_attack_key":
|
||||
binding = key_bindings[0];
|
||||
break;
|
||||
case "set_next_weap_key":
|
||||
binding = key_bindings[1];
|
||||
break;
|
||||
case "set_jump_key":
|
||||
binding = key_bindings[2];
|
||||
break;
|
||||
}
|
||||
|
||||
if(set_key_flag) {
|
||||
Key_SetBinding (IMT_0, key, binding);
|
||||
|
||||
set_key_flag = 0;
|
||||
retval = 1;
|
||||
} else {
|
||||
if(key == QFK_RETURN) {
|
||||
set_key_flag = 1;
|
||||
|
||||
retval = 1;
|
||||
} else if(key == QFK_BACKSPACE) {
|
||||
Key_SetBinding (IMT_0, Key_LookupBinding(IMT_0, binding), "");
|
||||
|
||||
retval = 1;
|
||||
}
|
||||
}
|
||||
|
||||
load_keybindings();
|
||||
return retval;
|
||||
};
|
||||
|
||||
integer () control_bind_draw =
|
||||
{
|
||||
local integer cursor_pad = 0;
|
||||
|
||||
Draw_String (20, 20, "Attack: " + key_bindings_keys[0]);
|
||||
Draw_String (20, 30, "Next weapon: " + key_bindings_keys[1]);
|
||||
Draw_String (20, 40, "Jump/Swim up: " + key_bindings_keys[2]);
|
||||
Draw_String (20, 70, "Backspace => Del binding");
|
||||
Draw_String (20, 80, "Enter => New binding");
|
||||
|
||||
opt_cursor (12, (Menu_GetIndex() * 10) + 20 + cursor_pad);
|
||||
|
||||
return 1;
|
||||
};
|
||||
|
||||
void () control_bind_menu =
|
||||
{
|
||||
Menu_Begin (54, 90, "Bindings");
|
||||
Menu_FadeScreen (1);
|
||||
Menu_Draw (control_bind_draw);
|
||||
// Menu_KeyEvent (control_bind_keyevent);
|
||||
Menu_Item (20, 20, "set_attack_key", control_bind_f, 1);
|
||||
Menu_Item (20, 30, "set_next_weap_key", control_bind_f, 1);
|
||||
Menu_Item (20, 40, "set_jump_key", control_bind_f, 1);
|
||||
Menu_End ();
|
||||
};
|
||||
|
|
@ -9,5 +9,8 @@ menu.dat
|
|||
@srcdir@/menu_def.qc
|
||||
@srcdir@/string_def.qc
|
||||
|
||||
@srcdir@/options_util.qc
|
||||
|
||||
@srcdir@/controls_o.qc
|
||||
@srcdir@/options.qc
|
||||
@srcdir@/menu.qc
|
||||
|
|
|
@ -1,19 +1,38 @@
|
|||
float time;
|
||||
#define MIN_GAMMA 0.4
|
||||
#define MAX_GAMMA 3
|
||||
#define GAMMA_STEP 0.1
|
||||
|
||||
integer set_key_flag;
|
||||
|
||||
void (integer x, integer y) opt_cursor =
|
||||
//**** VIDEO OPTIONS
|
||||
|
||||
integer (string text, integer key) video_gamma_f =
|
||||
{
|
||||
Draw_Character (x, y, 12 + (integer (time * 4) & 1));
|
||||
local float gamma;
|
||||
|
||||
switch (text) {
|
||||
case "gamma":
|
||||
gamma = cvar("vid_gamma");
|
||||
if(key == QFK_RIGHT) {
|
||||
gamma += GAMMA_STEP;
|
||||
} else if(key == QFK_LEFT) {
|
||||
gamma -= GAMMA_STEP;
|
||||
}
|
||||
|
||||
if(gamma > MAX_GAMMA) {
|
||||
gamma = MIN_GAMMA;
|
||||
} else if(gamma < MIN_GAMMA) {
|
||||
gamma = MAX_GAMMA;
|
||||
}
|
||||
cvar_set("vid_gamma", ftos(gamma));
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
};
|
||||
|
||||
integer (string text, integer key) video_options_f =
|
||||
{
|
||||
local integer selected_crosshair;
|
||||
local float gamma;
|
||||
|
||||
switch (text) {
|
||||
case "fullscreen":
|
||||
Cbuf_AddText ("toggle vid_fullscreen\n");
|
||||
|
@ -26,74 +45,10 @@ integer (string text, integer key) video_options_f =
|
|||
}
|
||||
cvar_set("crosshair", itos(selected_crosshair));
|
||||
break;
|
||||
case "gamma":
|
||||
// FIX KEYS
|
||||
gamma = cvar("vid_gamma");
|
||||
gamma += GAMMA_STEP;
|
||||
/* if(key == QFK_RIGHT) {
|
||||
gamma += GAMMA_STEP;
|
||||
} else if(key == QFK_LEFT) {
|
||||
gamma -= GAMMA_STEP;
|
||||
}
|
||||
*/
|
||||
if(gamma > MAX_GAMMA) {
|
||||
gamma = MIN_GAMMA;
|
||||
// } else if(gamma < MIN_GAMMA) {
|
||||
// gamma = MIN_GAMMA;
|
||||
}
|
||||
cvar_set("vid_gamma", ftos(gamma));
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
};
|
||||
|
||||
integer (string text, integer key) control_options_f =
|
||||
{
|
||||
switch (text) {
|
||||
case "in_grab":
|
||||
Cbuf_AddText ("toggle in_grab\n");
|
||||
break;
|
||||
case "autorun":
|
||||
if(cvar("cl_forwardspeed") < 400) {
|
||||
Cbuf_AddText ("set cl_forwardspeed 400\n");
|
||||
Cbuf_AddText ("set cl_backspeed 400\n");
|
||||
} else {
|
||||
Cbuf_AddText ("set cl_forwardspeed 200\n");
|
||||
Cbuf_AddText ("set cl_backspeed 200\n");
|
||||
}
|
||||
break;
|
||||
case "set_key":
|
||||
if(set_key_flag) {
|
||||
set_key_flag = 0;
|
||||
} else {
|
||||
set_key_flag = 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
};
|
||||
|
||||
|
||||
/* FIXME - how to catch a key ?
|
||||
void (string text, integer key) set_key_f =
|
||||
{
|
||||
Cbuf_AddText ("in_bind IMT_0 ");
|
||||
Cbuf_AddText (itos(key));
|
||||
Cbuf_AddText (" \"+jump\"\n");
|
||||
};
|
||||
*/
|
||||
|
||||
// ********* OPTIONS
|
||||
|
||||
string (string cvarstr) get_cvar_state =
|
||||
{
|
||||
if(cvar(cvarstr)) {
|
||||
return("On");
|
||||
} else {
|
||||
return("Off");
|
||||
}
|
||||
};
|
||||
|
||||
integer () gamma_to_percentage =
|
||||
{
|
||||
local float gamma = cvar("vid_gamma");
|
||||
|
@ -115,62 +70,58 @@ integer () gamma_to_percentage =
|
|||
return gam_perc;
|
||||
};
|
||||
|
||||
|
||||
void (integer x, integer y, integer perc_val) draw_perc_bar =
|
||||
integer () options_video_draw =
|
||||
{
|
||||
local integer perc;
|
||||
if(perc_val > 100) {
|
||||
perc_val = 100;
|
||||
} else if(perc_val < 0) {
|
||||
perc_val = 0;
|
||||
}
|
||||
perc = perc_val / 5;
|
||||
Draw_String (x, y, "[---------------------]");
|
||||
Draw_Character (x + ((perc + 1) * 8), y, '*');
|
||||
local string tmp = ftos(cvar("crosshair"));
|
||||
Draw_Pic (16, 4, "gfx/qplaque.lmp");
|
||||
Draw_CenterPic (160, 4, "gfx/p_option.lmp");
|
||||
Draw_String (54, 40, "Video");
|
||||
Draw_String (54, 50, "-----");
|
||||
Draw_String (70, 60, "Fullscreen: " + get_cvar_state("vid_fullscreen"));
|
||||
Draw_String (70, 70, "Crosshair: " + tmp);
|
||||
|
||||
Draw_String (70, 80, "Gamma:");
|
||||
draw_perc_bar (118, 80, 15, gamma_to_percentage());
|
||||
Draw_String (118 + (15 + 4)*8 , 80, ftos(cvar("vid_gamma")));
|
||||
opt_cursor (62, (Menu_GetIndex() * 10) + 60);
|
||||
return 1;
|
||||
};
|
||||
|
||||
#define NUM_BINDED_KEYS 3
|
||||
string [NUM_BINDED_KEYS] key_bindings = {
|
||||
"+attack",
|
||||
"impulse 10",
|
||||
"+jump"
|
||||
};
|
||||
string [NUM_BINDED_KEYS] key_bindings_keys = {
|
||||
"none",
|
||||
"none",
|
||||
"none"
|
||||
};
|
||||
|
||||
void () load_keybindings =
|
||||
void () options_video_menu =
|
||||
{
|
||||
local integer i, keynum;
|
||||
Menu_Begin (54, 50, "Video");
|
||||
Menu_FadeScreen (1);
|
||||
Menu_Draw (options_video_draw);
|
||||
|
||||
for(i = 0;i < NUM_BINDED_KEYS; i++) {
|
||||
keynum = Key_LookupBinding(IMT_0, key_bindings[i]);
|
||||
if(keynum == -1) {
|
||||
key_bindings_keys[i] = "<none>";
|
||||
} else {
|
||||
key_bindings_keys[i] = Key_KeynumToString(keynum);
|
||||
}
|
||||
Menu_Item (54, 60, "fullscreen", video_options_f, 0);
|
||||
Menu_Item (54, 70, "crosshair", video_options_f, 0);
|
||||
Menu_Item (54, 80, "gamma", video_gamma_f, 1);
|
||||
Menu_End ();
|
||||
};
|
||||
|
||||
|
||||
//**** CONTROL OPTIONS
|
||||
|
||||
integer (string text, integer key) control_options_f =
|
||||
{
|
||||
switch (text) {
|
||||
case "in_grab":
|
||||
Cbuf_AddText ("toggle in_grab\n");
|
||||
return 0;
|
||||
case "autorun":
|
||||
if(cvar("cl_forwardspeed") < 400) {
|
||||
Cbuf_AddText ("set cl_forwardspeed 400\n");
|
||||
Cbuf_AddText ("set cl_backspeed 400\n");
|
||||
} else {
|
||||
Cbuf_AddText ("set cl_forwardspeed 200\n");
|
||||
Cbuf_AddText ("set cl_backspeed 200\n");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
integer (integer key, integer unicode, integer down) options_controls_keyevent =
|
||||
{
|
||||
local integer tmp;
|
||||
|
||||
if(set_key_flag) {
|
||||
tmp = Menu_GetIndex () - 2;
|
||||
Key_SetBinding (IMT_0, key, key_bindings[tmp]);
|
||||
set_key_flag = 0;
|
||||
|
||||
load_keybindings();
|
||||
return 1;
|
||||
}
|
||||
if((key == QFK_BACKSPACE) && (Menu_GetIndex () > 1)) {
|
||||
Key_SetBinding (IMT_0, Key_LookupBinding(IMT_0, key_bindings[Menu_GetIndex () - 2]), "");
|
||||
}
|
||||
|
||||
load_keybindings();
|
||||
return 0;
|
||||
};
|
||||
|
@ -187,22 +138,12 @@ integer () options_controls_draw =
|
|||
Draw_String (54, 40, "Controls");
|
||||
Draw_String (54, 50, "--------");
|
||||
Draw_String (70, 60, "Grab mouse: " + get_cvar_state ("in_grab"));
|
||||
|
||||
tmp = "On";
|
||||
if(cvar("cl_forwardspeed") < 400) {
|
||||
tmp = "Off";
|
||||
}
|
||||
Draw_String (70, 70, "Auto run: " + tmp);
|
||||
Draw_String (54, 80, "Bindings");
|
||||
Draw_String (70, 90, "Attack: " + key_bindings_keys[0]);
|
||||
Draw_String (70, 100, "Next weapon: " + key_bindings_keys[1]);
|
||||
Draw_String (70, 110, "Jump/Swim up: " + key_bindings_keys[2]);
|
||||
Draw_String (70, 130, "Backspace => Del binding");
|
||||
Draw_String (70, 140, "Enter => New binding");
|
||||
|
||||
if(Menu_GetIndex() > 1) {
|
||||
cursor_pad = 10;
|
||||
}
|
||||
Draw_String (70, 80, "Bindings");
|
||||
opt_cursor (62, (Menu_GetIndex() * 10) + 60 + cursor_pad);
|
||||
|
||||
return 1;
|
||||
|
@ -217,57 +158,15 @@ void () options_controls_menu =
|
|||
Menu_KeyEvent (options_controls_keyevent);
|
||||
Menu_Item (54, 60, "in_grab", control_options_f, 0);
|
||||
Menu_Item (54, 70, "autorun", control_options_f, 0);
|
||||
Menu_Item (54, 90, "set_key", control_options_f, 0);
|
||||
Menu_Item (54, 100, "set_key", control_options_f, 0);
|
||||
Menu_Item (54, 110, "set_key", control_options_f, 0);
|
||||
control_bind_menu ();
|
||||
Menu_End ();
|
||||
};
|
||||
|
||||
|
||||
#define NUM_VIDEOCONFIG_CMDS 3
|
||||
integer [NUM_VIDEOCONFIG_CMDS] videoConfig_cursor_table = { 60, 70, 80 };
|
||||
|
||||
integer (integer key, integer unicode, integer down) options_video_keyevent =
|
||||
{
|
||||
if (key == QFK_RETURN) {
|
||||
} else if(key == QFK_RIGHT) {
|
||||
}
|
||||
// i have a question ;)
|
||||
return 0;
|
||||
};
|
||||
|
||||
integer () options_video_draw =
|
||||
{
|
||||
local string tmp = ftos(cvar("crosshair"));
|
||||
Draw_Pic (16, 4, "gfx/qplaque.lmp");
|
||||
Draw_CenterPic (160, 4, "gfx/p_option.lmp");
|
||||
Draw_String (54, 40, "Video");
|
||||
Draw_String (54, 50, "-----");
|
||||
Draw_String (70, 60, "Fullscreen: " + get_cvar_state("vid_fullscreen"));
|
||||
Draw_String (70, 70, "Crosshair: " + tmp);
|
||||
|
||||
Draw_String (70, 80, "Gamma:");
|
||||
draw_perc_bar (118, 80, gamma_to_percentage());
|
||||
opt_cursor (62, (Menu_GetIndex() * 10) + 60);
|
||||
return 1;
|
||||
};
|
||||
|
||||
void () options_video_menu =
|
||||
{
|
||||
Menu_Begin (54, 50, "Video");
|
||||
Menu_FadeScreen (1);
|
||||
Menu_Draw (options_video_draw);
|
||||
Menu_KeyEvent (options_video_keyevent);
|
||||
|
||||
Menu_Item (54, 60, "fullscreen", video_options_f, 0);
|
||||
Menu_Item (54, 70, "crosshair", video_options_f, 0);
|
||||
Menu_Item (54, 80, "gamma", video_options_f, 0);
|
||||
Menu_End ();
|
||||
};
|
||||
|
||||
integer (integer key, integer unicode, integer down) options_keyevent =
|
||||
{
|
||||
load_keybindings();
|
||||
// pre-loading of the bindings and set_key_flag == 0
|
||||
load_keybindings();
|
||||
set_key_flag = 0;
|
||||
return 0;
|
||||
};
|
||||
|
|
31
cs-code/options_util.qc
Normal file
31
cs-code/options_util.qc
Normal file
|
@ -0,0 +1,31 @@
|
|||
float time;
|
||||
void (integer x, integer y) opt_cursor =
|
||||
{
|
||||
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 =
|
||||
{
|
||||
local integer perc, i;
|
||||
if(perc_val > 100) {
|
||||
perc_val = 100;
|
||||
} else if(perc_val < 0) {
|
||||
perc_val = 0;
|
||||
}
|
||||
perc = perc_val / (100/size);
|
||||
Draw_String (x, y, "[");
|
||||
for (i = 0; i <= (size+1); i++) {
|
||||
Draw_String (x + ((i+1)*8), y, "-");
|
||||
}
|
||||
Draw_String (x + ((i+1)*8), y, "]");
|
||||
Draw_Character (x + ((perc + 1) * 8), y, '*');
|
||||
};
|
Loading…
Reference in a new issue