update the menu code to be built using separate compilation

This commit is contained in:
Bill Currie 2002-07-17 19:00:56 +00:00
parent fb4ef47af6
commit 21a4d6f547
39 changed files with 354 additions and 128 deletions

View file

@ -1943,7 +1943,6 @@ AC_OUTPUT(
tools/qwaq/progs.src tools/qwaq/progs.src
cs-code/Makefile cs-code/Makefile
cs-code/menu.src
doc/Makefile doc/Makefile
doc/man/Makefile doc/man/Makefile

2
cs-code/.gitignore vendored
View file

@ -1,6 +1,6 @@
*.dat *.dat
*.gz *.gz
*.h *.qfo
*.src *.src
*.sym *.sym
.vimrc .vimrc

View file

@ -15,19 +15,27 @@ GZ=.gz
else else
GZ= GZ=
endif endif
STRIP=$(shell echo -n $(srcdir)/ | sed -e 's/[^/]//g' | wc -c) STRIP=$(shell echo `echo -n $(srcdir)/ | sed -e 's/[^/]//g' | wc -c`)
pkgdata_DATA= menu.dat$(GZ) pkgdata_DATA= menu.dat$(GZ)
menu_src= \ menu_src= \
cbuf_def.qc cmd_def.qc controls_o.qc cvar_def.qc draw_def.qc file_def.qc \ cbuf.r client_menu.qc cmd.r controls_o.qc cvar.r draw.r file.r \
game_def.qc inputline_def.qc inputline_util.qc key_defs.qc menu.qc \ game.r inputline.r inputline_util.qc key.r \
menu_def.qc menu_pics.qc menu_util.qc options.qc options_util.qc \ menu.r menu_pics.qc menu_util.qc options.qc options_util.qc \
servlist.qc string_def.qc stringh_def.qc object.r servlist.qc string.r stringh.r object.r
menu.dat$(GZ): menu.src $(menu_src) $(QFCC_DEP) %.qfo: %.r
$(QFCC) $(QCFLAGS) $(QCPPFLAGS) -p $(STRIP) -P $< $(QFCC) $(QCFLAGS) $(QCPPFLAGS) -p $(STRIP) -c -o $@ $<
%.qfo: %.qc
$(QFCC) $(QCFLAGS) $(QCPPFLAGS) -p $(STRIP) -c -o $@ $<
menu_obj=$(addsuffix .qfo,$(basename $(menu_src)))
menu.dat$(GZ): $(menu_obj) $(QFCC_DEP)
$(QFCC) $(QCFLAGS) -p $(STRIP) -o menu.dat $(menu_obj)
$(GZIP) $(GZIP)
EXTRA_DIST= $(menu_src) EXTRA_DIST= $(menu_src)
CLEANFILES= *.dat *.sym *.gz CLEANFILES= *.dat *.sym *.gz *.qfo

9
cs-code/cbuf.h Normal file
View file

@ -0,0 +1,9 @@
#ifndef __cbuf_h
#define __cbuf_h
@extern void (string text) Cbuf_AddText;
@extern void (string text) Cbuf_InsertText;
@extern void () Cbuf_Execute;
@extern void () Cbuf_Execute_Sets;
#endif//__cbuf_h

View file

@ -1,3 +1,5 @@
#include "cbuf.h"
void (string text) Cbuf_AddText = #0; void (string text) Cbuf_AddText = #0;
void (string text) Cbuf_InsertText = #0; void (string text) Cbuf_InsertText = #0;
void () Cbuf_Execute = #0; void () Cbuf_Execute = #0;

8
cs-code/client_menu.h Normal file
View file

@ -0,0 +1,8 @@
#ifndef __client_menu_h
#define __client_menu_h
#include "inputline.h"
@extern inputline_t input_active;
#endif

View file

@ -1,7 +1,32 @@
entity self; #include "menu.h"
.float nextthink; #include "file.h"
.float frame; #include "cmd.h"
.void () think; #include "draw.h"
#include "key.h"
#include "inputline.h"
#include "string.h"
#include "cbuf.h"
#include "options.h"
#include "servlist.h"
#include "game.h"
#include "client_menu.h"
string [6] dot_name = {
"gfx/menudot1.lmp",
"gfx/menudot2.lmp",
"gfx/menudot3.lmp",
"gfx/menudot4.lmp",
"gfx/menudot5.lmp",
"gfx/menudot6.lmp",
};
void (integer x, integer y) spinner =
{
local integer i = integer(time * 10) % 6;
local qpic_t p = Draw_CachePic (dot_name[i], 1);
Draw_Pic (x, y, p);
};
integer do_single_player; integer do_single_player;
@ -439,8 +464,6 @@ void () main_menu =
void () menu_init = void () menu_init =
{ {
load_menu_pics ();
lanConfig_port_il = InputLine_Create (4, 8, ' '); lanConfig_port_il = InputLine_Create (4, 8, ' ');
InputLine_SetWidth (lanConfig_port_il, 10); InputLine_SetWidth (lanConfig_port_il, 10);
lanConfig_join_il = InputLine_Create (4, 24, ' '); lanConfig_join_il = InputLine_Create (4, 24, ' ');

11
cs-code/cmd.h Normal file
View file

@ -0,0 +1,11 @@
#ifndef __cmd_h
#define __cmd_h
@extern void (string name, void () func) Cmd_AddCommand;
@extern integer () Cmd_Argc;
@extern string (integer arg) Cmd_Argv;
@extern string (integer arg) Cmd_Args;
@extern string (integer arg) Cmd_Argu;
@extern void (string value) Cmd_Return;
#endif//__cmd_h

View file

@ -1,3 +1,5 @@
#include "cmd.h"
void (string name, void () func) Cmd_AddCommand = #0; void (string name, void () func) Cmd_AddCommand = #0;
integer () Cmd_Argc = #0; integer () Cmd_Argc = #0;
string (integer arg) Cmd_Argv = #0; string (integer arg) Cmd_Argv = #0;

7
cs-code/controls_o.h Normal file
View file

@ -0,0 +1,7 @@
#ifndef __controls_o_h
#define __controls_o_h
@extern void () MENU_control_binding;
@extern void () load_keybindings;
#endif//__controls_o_h

View file

@ -24,6 +24,13 @@
Boston, MA 02111-1307, USA Boston, MA 02111-1307, USA
*/ */
#include "menu.h"
#include "stringh.h"
#include "draw.h"
#include "game.h"
#include "key.h"
#include "string.h"
#include "options_util.h"
integer set_key_flag; // holds flag for the key-setting integer set_key_flag; // holds flag for the key-setting

6
cs-code/cvar.h Normal file
View file

@ -0,0 +1,6 @@
#ifndef __cvar_h
#define __cvar_h
@extern string (string varname) Cvar_GetCvarString;
#endif __cvar_h

View file

@ -1 +1,3 @@
#include "cvar.h"
string (string varname) Cvar_GetCvarString = #0; string (string varname) Cvar_GetCvarString = #0;

22
cs-code/draw.h Normal file
View file

@ -0,0 +1,22 @@
#ifndef __draw_h
#define __draw_h
struct _qpic_t = {
integer width;
integer height;
};
typedef _qpic_t [] qpic_t;
@extern qpic_t (string name, integer alpha) Draw_CachePic;
@extern void (integer x, integer y, qpic_t pic) Draw_Pic;
@extern void (integer x, integer y, qpic_t pic) Draw_CenterPic;
@extern void (integer x, integer y, integer chr) Draw_Character;
@extern void (integer x, integer y, string text) Draw_String;
@extern void (integer x, integer y, string text, integer n) Draw_nString;
@extern void (integer x, integer y, string text) Draw_AltString;
@extern void (integer x, integer y, integer w, integer h, integer c) Draw_Fill;
@extern void (integer x, integer y, integer width, integer lines) text_box;
#endif//__draw_h

59
cs-code/draw.r Normal file
View file

@ -0,0 +1,59 @@
#include "draw.h"
qpic_t (string name, integer alpha) Draw_CachePic = #0;
void (integer x, integer y, qpic_t pic) Draw_Pic = #0;
void (integer x, integer y, qpic_t pic) Draw_CenterPic = #0;
void (integer x, integer y, integer chr) Draw_Character = #0;
void (integer x, integer y, string text) Draw_String = #0;
void (integer x, integer y, string text, integer n) Draw_nString = #0;
void (integer x, integer y, string text) Draw_AltString = #0;
void (integer x, integer y, integer w, integer h, integer c) Draw_Fill = #0;
void (integer x, integer y, integer width, integer lines) text_box =
{
local integer cx, cy, n;
local qpic_t p;
cx = x;
cy = y;
p = Draw_CachePic ("gfx/box_tl.lmp", 1);
Draw_Pic (cx, cy, p);
p = Draw_CachePic ("gfx/box_ml.lmp", 1);
for (n = 0; n < lines; n++) {
cy += 8;
Draw_Pic (cx, cy, p);
}
p = Draw_CachePic ("gfx/box_bl.lmp", 1);
Draw_Pic (cx, cy + 8, p);
cx += 8;
while (width > 0) {
cy = y;
p = Draw_CachePic ("gfx/box_tm.lmp", 1);
Draw_Pic (cx, cy, p);
p = Draw_CachePic ("gfx/box_mm.lmp", 1);
for (n = 0; n < lines; n++) {
cy += 8;
if (n == 1)
p = Draw_CachePic ("gfx/box_mm2.lmp", 1);
Draw_Pic (cx, cy, p);
}
p = Draw_CachePic ("gfx/box_bm.lmp", 1);
Draw_Pic (cx, cy + 8, p);
width -= 2;
cx += 16;
}
cy = y;
p = Draw_CachePic ("gfx/box_tr.lmp", 1);
Draw_Pic (cx, cy, p);
p = Draw_CachePic ("gfx/box_mr.lmp", 1);
for (n = 0; n < lines; n++) {
cy += 8;
Draw_Pic (cx, cy, p);
}
p = Draw_CachePic ("gfx/box_br.lmp", 1);
Draw_Pic (cx, cy + 8, p);
};

View file

@ -1,16 +0,0 @@
struct _qpic_t = {
integer width;
integer height;
};
typedef _qpic_t [] qpic_t;
qpic_t (string name, integer alpha) Draw_CachePic = #0;
void (integer x, integer y, qpic_t pic) Draw_Pic = #0;
void (integer x, integer y, qpic_t pic) Draw_CenterPic = #0;
void (integer x, integer y, integer chr) Draw_Character = #0;
void (integer x, integer y, string text) Draw_String = #0;
void (integer x, integer y, string text, integer n) Draw_nString = #0;
void (integer x, integer y, string text) Draw_AltString = #0;
void (integer x, integer y, integer w, integer h, integer c) Draw_Fill = #0;

9
cs-code/file.h Normal file
View file

@ -0,0 +1,9 @@
#ifndef __file_h
#define __file_h
//FIXME need a proper file struct, string sucks
@extern string (string path, string mode) File_Open;
@extern void (string file) File_Close;
@extern string (string file) File_GetLine;
#endif//__file_h

View file

@ -1,3 +1,5 @@
#include "file.h"
//FIXME need a proper file struct, string sucks //FIXME need a proper file struct, string sucks
string (string path, string mode) File_Open = #0; string (string path, string mode) File_Open = #0;
void (string file) File_Close = #0; void (string file) File_Close = #0;

20
cs-code/game.h Normal file
View file

@ -0,0 +1,20 @@
#ifndef __game_h
#define __game_h
@extern float(string s) cvar; // return cvar.value
@extern void(string var, string val) cvar_set; // sets cvar.value
@extern string(float f) ftos; // converts float to string
@extern integer(float f) ftoi; // converts float to integer
@extern string(integer i) itos; // converts interger to string
@extern float(integer i) itof; // converts interger to string
@extern integer(string str) stoi; // converts string to integer
@extern float(string str) stof; // converts string to float
@extern void(string s) dprint;
@extern entity self;
@extern .float nextthink;
@extern .float frame;
@extern .void () think;
@extern float time;
#endif//__game_h

View file

@ -1,3 +1,5 @@
#include "game.h"
float(string s) cvar = #45; // return cvar.value float(string s) cvar = #45; // return cvar.value
void(string var, string val) cvar_set = #72; // sets cvar.value void(string var, string val) cvar_set = #72; // sets cvar.value
string(float f) ftos = #26; // converts float to string string(float f) ftos = #26; // converts float to string
@ -7,3 +9,9 @@ float(integer i) itof = #111; // converts interger to string
integer(string str) stoi = #113; // converts string to integer integer(string str) stoi = #113; // converts string to integer
float(string str) stof = #81; // converts string to float float(string str) stof = #81; // converts string to float
void(string s) dprint = #25; void(string s) dprint = #25;
entity self;
.float nextthink;
.float frame;
.void () think;
float time;

16
cs-code/inputline.h Normal file
View file

@ -0,0 +1,16 @@
#ifndef __inputline_h
#define __inputline_h
struct _inputline_t = {}; // opaque type :)
typedef _inputline_t [] inputline_t;
@extern inputline_t (integer lines, integer size, integer prompt) InputLine_Create;
@extern void (inputline_t il, integer width) InputLine_SetWidth;
@extern void (inputline_t il) InputLine_Destroy;
@extern void (inputline_t il) InputLine_Clear;
@extern void (inputline_t il, integer ch) InputLine_Process;
@extern void (inputline_t il, integer x, integer y, integer cursor) InputLine_Draw;
@extern void (inputline_t il, string str) InputLine_SetText;
@extern string (inputline_t il) InputLine_GetText;
#endif//__inputline-h

View file

@ -1,5 +1,5 @@
struct _inputline_t = {}; // opaque type :) #include "inputline.h"
typedef _inputline_t [] inputline_t;
inputline_t (integer lines, integer size, integer prompt) InputLine_Create = #0; inputline_t (integer lines, integer size, integer prompt) InputLine_Create = #0;
void (inputline_t il, integer width) InputLine_SetWidth = #0; void (inputline_t il, integer width) InputLine_SetWidth = #0;
void (inputline_t il) InputLine_Destroy = #0; void (inputline_t il) InputLine_Destroy = #0;

10
cs-code/key.h Normal file
View file

@ -0,0 +1,10 @@
#ifndef __key_h
#define __key_h
#include "QF/keys.h"
@extern string (integer target, integer keynum, string binding) Key_SetBinding;
@extern integer (integer target, integer bindnum, string binding) Key_LookupBinding;
@extern integer (integer target, string binding) Key_CountBinding;
@extern string (integer keynum) Key_KeynumToString;
#endif//__key_h

View file

@ -1,4 +1,5 @@
#include "QF/keys.h" #include "key.h"
string (integer target, integer keynum, string binding) Key_SetBinding = #0; string (integer target, integer keynum, string binding) Key_SetBinding = #0;
integer (integer target, integer bindnum, string binding) Key_LookupBinding = #0; integer (integer target, integer bindnum, string binding) Key_LookupBinding = #0;
integer (integer target, string binding) Key_CountBinding = #0; integer (integer target, string binding) Key_CountBinding = #0;

27
cs-code/menu.h Normal file
View file

@ -0,0 +1,27 @@
#ifndef __menu_h
#define __menu_h
@extern void (integer x, integer y, string text) Menu_Begin;
@extern void (integer val) Menu_FadeScreen;
@extern void (integer () func) Menu_Draw;
@extern void (integer () func) Menu_EnterHook;
@extern void (integer () func) Menu_LeaveHook;
@extern void (integer x, integer y, string name) Menu_Pic;
@extern void (integer x, integer y, string name) Menu_CenterPic;
@extern void (integer x, integer y, string text, integer (string text, integer key) func, integer allkeys) Menu_Item;
@extern void (void (integer x, integer y) func) Menu_Cursor;
@extern void (integer (integer key, integer unicode, integer down) func) Menu_KeyEvent;
@extern void () Menu_End;
@extern void (string name) Menu_TopMenu;
@extern void (string name) Menu_SelectMenu;
@extern void (integer () func) Menu_SetQuit;
@extern void () Menu_Quit;
@extern integer () Menu_GetIndex;
@extern float () random;
@extern float () traceon;
@extern float () traceoff;
@extern string () gametype;
@extern string (...) sprintf;
#endif//__menu_h;

View file

@ -1,3 +1,5 @@
#include "menu.h"
void (integer x, integer y, string text) Menu_Begin = #0; void (integer x, integer y, string text) Menu_Begin = #0;
void (integer val) Menu_FadeScreen = #0; void (integer val) Menu_FadeScreen = #0;
void (integer () func) Menu_Draw = #0; void (integer () func) Menu_Draw = #0;

View file

@ -1,25 +0,0 @@
menu.dat
@srcdir@/cbuf_def.qc
@srcdir@/cmd_def.qc
@srcdir@/cvar_def.qc
@srcdir@/draw_def.qc
@srcdir@/file_def.qc
@srcdir@/game_def.qc
@srcdir@/inputline_def.qc
@srcdir@/key_defs.qc
@srcdir@/menu_def.qc
@srcdir@/string_def.qc
@srcdir@/stringh_def.qc
@srcdir@/menu_pics.qc
@srcdir@/inputline_util.qc
@srcdir@/menu_util.qc
@srcdir@/options_util.qc
@srcdir@/controls_o.qc
@srcdir@/options.qc
@srcdir@/servlist.qc
@srcdir@/menu.qc
@srcdir@/object.r

View file

@ -1,11 +1,3 @@
string [6] dot_name = {
"gfx/menudot1.lmp",
"gfx/menudot2.lmp",
"gfx/menudot3.lmp",
"gfx/menudot4.lmp",
"gfx/menudot5.lmp",
"gfx/menudot6.lmp",
};
void () void ()
load_menu_pics = load_menu_pics =

View file

@ -1,56 +0,0 @@
float time;
void (integer x, integer y) spinner =
{
local integer i = integer(time * 10) % 6;
local qpic_t p = Draw_CachePic (dot_name[i], 1);
Draw_Pic (x, y, p);
};
void (integer x, integer y, integer width, integer lines) text_box =
{
local integer cx, cy, n;
local qpic_t p;
cx = x;
cy = y;
p = Draw_CachePic ("gfx/box_tl.lmp", 1);
Draw_Pic (cx, cy, p);
p = Draw_CachePic ("gfx/box_ml.lmp", 1);
for (n = 0; n < lines; n++) {
cy += 8;
Draw_Pic (cx, cy, p);
}
p = Draw_CachePic ("gfx/box_bl.lmp", 1);
Draw_Pic (cx, cy + 8, p);
cx += 8;
while (width > 0) {
cy = y;
p = Draw_CachePic ("gfx/box_tm.lmp", 1);
Draw_Pic (cx, cy, p);
p = Draw_CachePic ("gfx/box_mm.lmp", 1);
for (n = 0; n < lines; n++) {
cy += 8;
if (n == 1)
p = Draw_CachePic ("gfx/box_mm2.lmp", 1);
Draw_Pic (cx, cy, p);
}
p = Draw_CachePic ("gfx/box_bm.lmp", 1);
Draw_Pic (cx, cy + 8, p);
width -= 2;
cx += 16;
}
cy = y;
p = Draw_CachePic ("gfx/box_tr.lmp", 1);
Draw_Pic (cx, cy, p);
p = Draw_CachePic ("gfx/box_mr.lmp", 1);
for (n = 0; n < lines; n++) {
cy += 8;
Draw_Pic (cx, cy, p);
}
p = Draw_CachePic ("gfx/box_br.lmp", 1);
Draw_Pic (cx, cy + 8, p);
};

13
cs-code/options.h Normal file
View file

@ -0,0 +1,13 @@
#ifndef __options_h
#define __options_h
@extern void () MENU_video_options;
@extern void () MENU_audio_options;
@extern void () MENU_control_options;
@extern void () MENU_feature_options;
@extern void () MENU_player_options;
@extern void () MENU_network_options;
@extern void () MENU_options;
@extern void (integer x, integer y, integer spacing, string label, string valstr) draw_val_item;
#endif//__options_r

View file

@ -24,6 +24,17 @@
Boston, MA 02111-1307, USA Boston, MA 02111-1307, USA
*/ */
#include "options.h"
#include "cbuf.h"
#include "menu.h"
#include "game.h"
#include "draw.h"
#include "cvar.h"
#include "key.h"
#include "inputline.h"
#include "controls_o.h"
#include "options_util.h"
/* /*
some definitions of border values for some definitions of border values for
different things different things

11
cs-code/options_util.h Normal file
View file

@ -0,0 +1,11 @@
#ifndef __options_util_h
#define __options_util_h
@extern void (integer x, integer y) opt_cursor;
@extern void (integer x, integer y, integer size, integer perc_val) draw_perc_bar;
@extern void (integer x, integer y, integer spacing, string spacechar, string label, string valstr) draw_item;
@extern void (integer x, integer y, integer spacing, string label, string valstr) draw_val_item;
@extern integer (float min, float max, float val) to_percentage;
@extern float (float min, float max, float step, float val, integer cntflag) min_max_cnt;
#endif//__options_util_h

View file

@ -24,8 +24,9 @@
Boston, MA 02111-1307, USA Boston, MA 02111-1307, USA
*/ */
#include "draw.h"
float time; // holds current time #include "game.h"
#include "string.h"
/* /*
opt_cursor opt_cursor

6
cs-code/servlist.h Normal file
View file

@ -0,0 +1,6 @@
#ifndef __servlist_h
#define __servlist_h
@extern void () server_list_menu;
#endif//__servlist_h

View file

@ -1,4 +1,9 @@
void (integer x, integer y, integer width, integer lines) text_box; #include "menu.h"
#include "draw.h"
#include "inputline.h"
#include "options_util.h"
#include "controls_o.h"
#include "client_menu.h"
integer () servlist_favorates_draw = integer () servlist_favorates_draw =
{ {
@ -20,7 +25,6 @@ integer serv_nfull;
integer serv_nempty; integer serv_nempty;
inputline_t serv_maxping; inputline_t serv_maxping;
inputline_t serv_game; inputline_t serv_game;
inputline_t input_active;
integer () servlist_filter_draw = integer () servlist_filter_draw =
{ {

9
cs-code/string.h Normal file
View file

@ -0,0 +1,9 @@
#ifndef __string_h
#define __string_h
@extern string (integer old, integer new, string str) String_ReplaceChar;
@extern string (integer pos, integer len, string str) String_Cut;
@extern integer (string str) String_Len;
@extern integer (string str, integer pos) String_GetChar;
#endif

View file

@ -1,3 +1,5 @@
#include "string.h"
string (integer old, integer new, string str) String_ReplaceChar = #0; string (integer old, integer new, string str) String_ReplaceChar = #0;
string (integer pos, integer len, string str) String_Cut = #0; string (integer pos, integer len, string str) String_Cut = #0;
integer (string str) String_Len = #0; integer (string str) String_Len = #0;

12
cs-code/stringh.h Normal file
View file

@ -0,0 +1,12 @@
#ifndef __stringh_h
#define __stringh_h
@extern integer () StringHash_Create;
@extern integer (integer hashid) StringHash_Destroy;
@extern integer (integer hashid, string key, string value, integer value_id) StringHash_Set;
@extern string (integer hashid, string key, integer value_id) StringHash_Get;
@extern integer (integer hashid) StringHash_Length;
@extern string (integer hashid, integer idx, integer value_id) StringHash_GetIdx;
@extern integer (integer hashid, integer idx, string value, integer value_id) StringHash_SetIdx;
#endif//__stringh_h

View file

@ -1,3 +1,5 @@
#include "stringh.h"
integer () StringHash_Create = #0; integer () StringHash_Create = #0;
integer (integer hashid) StringHash_Destroy = #0; integer (integer hashid) StringHash_Destroy = #0;
integer (integer hashid, string key, string value, integer value_id) StringHash_Set = #0; integer (integer hashid, string key, string value, integer value_id) StringHash_Set = #0;