start implementing the api for input lines and clean up a couple csqc

prototype issues.
This commit is contained in:
Bill Currie 2002-01-23 22:37:44 +00:00
parent 68637eea9e
commit 85588c8fcb
12 changed files with 100 additions and 13 deletions

7
cs-code/inputline_def.qc Normal file
View File

@ -0,0 +1,7 @@
struct _inputline_t = {}; // opaque type :)
typedef _inputline_t [] inputline_t;
inputline_t (integer lines, integer width, integer prompt) InputLine_Create = #0;
void (inputline_t il) InputLine_Destroy = #0;
void (inputline_t il) InputLine_Clear = #0;
void (inputline_t il, integer ch) InputLine_Process = #0;
void (inputline_t il, integer x, integer y, integer cursor) InputLine_Draw = #0;

View File

@ -309,6 +309,8 @@ string lanConfig_portname;
string lanConfig_joinname; string lanConfig_joinname;
#define NUM_LANCONFIG_CMDS 3 #define NUM_LANCONFIG_CMDS 3
integer [NUM_LANCONFIG_CMDS] lanConfig_cursor_table = { 72, 92, 124 }; integer [NUM_LANCONFIG_CMDS] lanConfig_cursor_table = { 72, 92, 124 };
inputline_t lanConfig_port_il;
inputline_t lanConfig_join_il;
integer () join_draw = integer () join_draw =
{ {
@ -443,6 +445,8 @@ void () main_menu =
void () menu_init = void () menu_init =
{ {
lanConfig_port_il = InputLine_Create (4, 8, ' ');
lanConfig_join_il = InputLine_Create (4, 24, ' ');
switch (gametype ()) { switch (gametype ()) {
case "netquake": case "netquake":
do_single_player = 1; do_single_player = 1;

View File

@ -3,6 +3,7 @@ menu.dat
@srcdir@/cbuf_def.qc @srcdir@/cbuf_def.qc
@srcdir@/draw_def.qc @srcdir@/draw_def.qc
@srcdir@/file_def.qc @srcdir@/file_def.qc
@srcdir@/inputline_def.qc
@srcdir@/menu_def.qc @srcdir@/menu_def.qc
@srcdir@/string_def.qc @srcdir@/string_def.qc

View File

@ -65,8 +65,6 @@ void Cbuf_Execute (void);
// Normally called once per frame, but may be explicitly invoked. // Normally called once per frame, but may be explicitly invoked.
// Do not call inside a command function! // Do not call inside a command function!
struct progs_s;
void Cbuf_Progs_Init (struct progs_s *pr);
//=========================================================================== //===========================================================================

View File

@ -36,7 +36,9 @@ void BI_Init ();
struct progs_s; struct progs_s;
void Cbuf_Progs_Init (struct progs_s *pr);
void File_Progs_Init (struct progs_s *pr); void File_Progs_Init (struct progs_s *pr);
void InputLine_Progs_Init (struct progs_s *pr);
void String_Progs_Init (struct progs_s *pr); void String_Progs_Init (struct progs_s *pr);
#endif//__QF_csqc_h #endif//__QF_csqc_h

View File

@ -332,6 +332,7 @@ Menu_Init (void)
Cbuf_Progs_Init (&menu_pr_state); Cbuf_Progs_Init (&menu_pr_state);
File_Progs_Init (&menu_pr_state); File_Progs_Init (&menu_pr_state);
InputLine_Progs_Init (&menu_pr_state);
String_Progs_Init (&menu_pr_state); String_Progs_Init (&menu_pr_state);
PR_Cmds_Init (&menu_pr_state); PR_Cmds_Init (&menu_pr_state);
R_Progs_Init (&menu_pr_state); R_Progs_Init (&menu_pr_state);

View File

@ -8,4 +8,4 @@ libQFgamecode_builtins_la_LDFLAGS= -version-info 1:0:0
libQFgamecode_builtins_la_SOURCES= pr_cmds.c libQFgamecode_builtins_la_SOURCES= pr_cmds.c
libQFcsqc_la_LDFLAGS= -version-info 1:0:0 libQFcsqc_la_LDFLAGS= -version-info 1:0:0
libQFcsqc_la_SOURCES= bi_init.c bi_cbuf.c bi_file.c bi_string.c libQFcsqc_la_SOURCES= bi_init.c bi_cbuf.c bi_file.c bi_inputline.c bi_string.c

View File

@ -43,8 +43,6 @@ static const char rcsid[] =
#include "QF/vfs.h" #include "QF/vfs.h"
#include "QF/zone.h" #include "QF/zone.h"
#define RETURN_STRING(p, s) ((p)->pr_globals[OFS_RETURN].integer_var = PR_SetString((p), s))
#define MAX_HANDLES 20 #define MAX_HANDLES 20
static VFile *handles[MAX_HANDLES]; static VFile *handles[MAX_HANDLES];

View File

@ -30,10 +30,13 @@ static const char rcsid[] =
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
# include "config.h" # include "config.h"
#endif #endif
#include "QF/cmd.h" #include "QF/csqc.h"
#include "QF/progs.h" #include "QF/progs.h"
static void (*const cbuf_progs_init)(struct progs_s *) = Cbuf_Progs_Init; static void (*const cbuf_progs_init)(struct progs_s *) = Cbuf_Progs_Init;
static void (*const file_progs_init)(struct progs_s *) = File_Progs_Init;
static void (*const inputline_progs_init)(struct progs_s *) = InputLine_Progs_Init;
static void (*const string_progs_init)(struct progs_s *) = String_Progs_Init;
void void
BI_Init () BI_Init ()

View File

@ -0,0 +1,78 @@
/*
bi_inputline.c
CSQC inputline builtins
Copyright (C) 1996-1997 Id Software, Inc.
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
*/
static const char rcsid[] =
"$Id$";
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#ifdef HAVE_STRING_H
# include "string.h"
#endif
#ifdef HAVE_STRINGS_H
# include "strings.h"
#endif
#include "QF/console.h"
#include "QF/progs.h"
#include "QF/zone.h"
static void
bi_InputLine_Create (progs_t *pr)
{
}
static void
bi_InputLine_Destroy (progs_t *pr)
{
}
static void
bi_InputLine_Clear (progs_t *pr)
{
}
static void
bi_InputLine_Process (progs_t *pr)
{
}
static void
bi_InputLine_Draw (progs_t *pr)
{
}
void
InputLine_Progs_Init (progs_t *pr)
{
PR_AddBuiltin (pr, "InputLine_Create", bi_InputLine_Create, -1);
PR_AddBuiltin (pr, "InputLine_Destroy", bi_InputLine_Destroy, -1);
PR_AddBuiltin (pr, "InputLine_Clear", bi_InputLine_Clear, -1);
PR_AddBuiltin (pr, "InputLine_Process", bi_InputLine_Process, -1);
PR_AddBuiltin (pr, "InputLine_Draw", bi_InputLine_Draw, -1);
}

View File

@ -1,7 +1,7 @@
/* /*
bi_cbuf.c bi_string.c
CSQC cbuf builtins CSQC string builtins
Copyright (C) 1996-1997 Id Software, Inc. Copyright (C) 1996-1997 Id Software, Inc.
@ -41,8 +41,6 @@ static const char rcsid[] =
#include "QF/progs.h" #include "QF/progs.h"
#include "QF/zone.h" #include "QF/zone.h"
#define RETURN_STRING(p, s) ((p)->pr_globals[OFS_RETURN].integer_var = PR_SetString((p), s))
static void static void
bi_String_ReplaceChar (progs_t *pr) bi_String_ReplaceChar (progs_t *pr)
{ {

View File

@ -40,9 +40,6 @@ static const char rcsid[] =
#include <QF/progs.h> #include <QF/progs.h>
#include <QF/zone.h> #include <QF/zone.h>
#define RETURN_EDICT(p, e) ((p)->pr_globals[OFS_RETURN].integer_var = EDICT_TO_PROG(p, e))
#define RETURN_STRING(p, s) ((p)->pr_globals[OFS_RETURN].integer_var = PR_SetString((p), s))
int *read_result; //FIXME: eww int *read_result; //FIXME: eww
static void static void