Added options menu. Can now be find in options.qc.

Only mouse-grab, fullscreen and crosshair can be changed by
it now.
This commit is contained in:
Robin Redeker 2002-01-29 19:04:24 +00:00
parent 0906ac5694
commit 6c1fbd079c
5 changed files with 136 additions and 6 deletions

View file

@ -11,7 +11,7 @@ QCPPFLAGS=-I. -I$(srcdir) -I$(top_builddir)/include -I$(top_srcdir)/include
pkgdata_DATA= menu.dat
menu_src= menu.qc cbuf_def.qc draw_def.qc file_def.qc menu_def.qc string_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
menu.dat: menu.src $(menu_src)
$(QFCC) $(QCFLAGS) $(QCPPFLAGS) -P $<

5
cs-code/game_def.qc Normal file
View file

@ -0,0 +1,5 @@
float(string s) cvar = #45; // return cvar.value
void(string var, string val) cvar_set = #72; // sets cvar.value
string(float f) ftos = #26; // converts float to string
integer(float f) ftoi = #110; // converts float to integer
string(integer i) itos = #112; // converts interger to string

View file

@ -1,4 +1,3 @@
#include "QF/keys.h"
float () random = #0;
string () gametype = #0;
@ -417,10 +416,7 @@ void () multi_player_menu =
Menu_End ();
};
void () options_menu =
{
Menu_Item (54, 72, "", quit_f);
};
void () help_menu =
{

128
cs-code/options.qc Normal file
View file

@ -0,0 +1,128 @@
#include "QF/keys.h"
float time;
void (integer x, integer y) opt_cursor =
{
Draw_Character (x, y, 12 + (integer (time * 4) & 1));
};
void (string text, integer key) video_options_f =
{
local integer selected_crosshair;
switch (text) {
case "fullscreen":
Cbuf_AddText ("toggle vid_fullscreen\n");
return;
case "crosshair":
selected_crosshair = ftoi(cvar("crosshair"));
selected_crosshair++;
if(selected_crosshair >= 3) {
selected_crosshair = 0;
}
cvar_set("crosshair", itos(selected_crosshair));
}
};
void (string text, integer key) control_options_f =
{
switch (text) {
case "in_grab":
Cbuf_AddText ("toggle in_grab\n");
return;
}
};
/* 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 (integer key, integer unicode, integer down) options_controls_keyevent =
{
if (key == QFK_RETURN) {
} else {
}
return 0;
};
integer () options_controls_draw =
{
local string tmp;
Draw_Pic (16, 4, "gfx/qplaque.lmp");
Draw_CenterPic (160, 4, "gfx/p_option.lmp");
Draw_String (54, 40, "Controls");
Draw_String (54, 50, "--------");
Draw_String (70, 60, "Grab mouse: " + get_cvar_state ("in_grab"));
opt_cursor (62, (Menu_GetIndex() * 10) + 60);
return 1;
};
void () options_controls_menu =
{
Menu_Begin (54, 40, "Controls");
Menu_CenterPic (160, 4, "gfx/p_option.lmp");
Menu_Draw (options_controls_draw);
Menu_KeyEvent (options_controls_keyevent);
Menu_Item (54, 60, "in_grab", control_options_f);
Menu_End ();
};
integer (integer key, integer unicode, integer down) options_video_keyevent =
{
if (key == QFK_RETURN) {
} else {
}
// 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);
opt_cursor (62, (Menu_GetIndex() * 10) + 60);
return 1;
};
void () options_video_menu =
{
Menu_Begin (54, 50, "Video");
Menu_Draw (options_video_draw);
Menu_KeyEvent (options_video_keyevent);
Menu_Item (54, 60, "fullscreen", video_options_f);
Menu_Item (54, 70, "crosshair", video_options_f);
Menu_End ();
};
void () options_menu =
{
Menu_Begin (54, 72, "");
Menu_Pic (16, 4, "gfx/qplaque.lmp");
Menu_CenterPic (160, 4, "gfx/p_option.lmp");
options_video_menu ();
options_controls_menu ();
Menu_End ();
};

View file

@ -1 +1,2 @@
string (integer old, integer new, string str) String_ReplaceChar = #0;