Playermenu working now fine.

Added some api-functions to complete playermenu.
(Playermenu isn't still finished)
This commit is contained in:
Robin Redeker 2002-03-19 17:07:56 +00:00
parent 504ee0014f
commit 489bc7291a
8 changed files with 69 additions and 27 deletions

View File

@ -409,9 +409,7 @@ void ()
MENU_control_binding =
{
init_binding_hash (); // init the keybinding hashes
load_keybindings (); // load the keybindings into hashes
set_key_flag = 0;
load_keybindings (); // load the keybindings into hashes // FIXME
Menu_Begin (54, 60, "Bindings");
Menu_Pic (16, 4, "gfx/qplaque.lmp");

View File

@ -6,3 +6,5 @@ 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;
void (inputline_t il, string str) InputLine_SetText = #0;
string (inputline_t il) InputLine_GetText = #0;

View File

@ -24,21 +24,4 @@
Boston, MA 02111-1307, USA
*/
/*
InputLine_SetText
Inserts characters of a string into
a inputline.
*/
void (inputline_t il, string str)
InputLine_SetText =
{
local integer i, charint;
charint = String_GetChar(str,0);
for(i = 0; charint != 0; i++) {
InputLine_Process(il, String_GetChar(str,i));
charint = String_GetChar(str,i);
}
};
/* EMPTY YET - REMOVE FILE? */

View File

@ -1,9 +1,3 @@
float () random = #0;
float () traceon = #0;
float () traceoff = #0;
string () gametype = #0;
string (...) sprintf = #0;
entity self;
.float nextthink;
.float frame;

View File

@ -1,5 +1,6 @@
menu.dat
@srcdir@/cvar_def.qc
@srcdir@/cbuf_def.qc
@srcdir@/draw_def.qc
@srcdir@/file_def.qc

View File

@ -14,3 +14,9 @@ void (string name) Menu_SelectMenu = #0;
void (integer () func) Menu_SetQuit = #0;
void () Menu_Quit = #0;
integer () Menu_GetIndex = #0;
float () random = #0;
float () traceon = #0;
float () traceoff = #0;
string () gametype = #0;
string (...) sprintf = #0;

View File

@ -437,6 +437,8 @@ MENU_feature_options =
* Player settings, generally name, team, and color
***************************************************/
string playername_cvar; // name of the cvar holding playername (gametype dependend)
// input for playername
string player_config_playername;
inputline_t player_config_plname_il;
@ -479,6 +481,9 @@ KEYEV_player_options =
break;
case QFK_RETURN:
if (player_config_iactive) {
if(player_config_iactive == player_config_plname_il) {
cvar_set(playername_cvar,InputLine_GetText(player_config_plname_il));
}
player_config_iactive = NIL;
} else {
if (player_config_cursor == 0) {
@ -555,6 +560,23 @@ DRAW_player_options =
return 1;
};
/*
CB_ME_player_options
Entercallback for the playermenu.
For initalising the playername and teamname.
*/
integer ()
CB_ME_player_options =
{
if(gametype() == "quakeworld") {
playername_cvar = "name";
} else {
playername_cvar = "_cl_name";
}
dprint("DOO\n");
InputLine_SetText (player_config_plname_il, Cvar_GetCvarString(playername_cvar));
};
/*
MENU_player_options
@ -571,6 +593,7 @@ MENU_player_options =
Menu_Begin (54, 80, "Player");
Menu_FadeScreen (1);
Menu_KeyEvent (KEYEV_player_options);
Menu_EnterHook (CB_ME_player_options);
Menu_Draw (DRAW_player_options);
Menu_End ();
};

View File

@ -127,6 +127,39 @@ bi_InputLine_Process (progs_t *pr)
Con_ProcessInputLine (line, ch);
}
/*
bi_InputLine_SetText
Sets the inputline to a specified text
*/
static void
bi_InputLine_SetText (progs_t *pr)
{
pr_type_t *handle = pr->pr_globals + G_INT (pr, OFS_PARM0);
inputline_t *il = *(inputline_t **)handle;
const char *str = G_STRING (pr, OFS_PARM1);
/* this was segfault trap:
il->lines[il->edit_line][0] is promt character
*/
strncpy(il->lines[il->edit_line] + 1,str,il->line_size - 1);
il->lines[il->edit_line][il->line_size-1] = '\0';
}
/*
bi_InputLine_GetText
Gets the text from a inputline
*/
static void
bi_InputLine_GetText (progs_t *pr)
{
pr_type_t *handle = pr->pr_globals + G_INT (pr, OFS_PARM0);
inputline_t *il = *(inputline_t **)handle;
RETURN_STRING(pr, il->lines[il->edit_line]+1);
}
static void
bi_InputLine_Draw (progs_t *pr)
{
@ -173,6 +206,8 @@ InputLine_Progs_Init (progs_t *pr)
PR_Resources_Register (pr, "InputLine", res, bi_il_clear);
PR_AddBuiltin (pr, "InputLine_Create", bi_InputLine_Create, -1);
PR_AddBuiltin (pr, "InputLine_SetWidth", bi_InputLine_SetWidth, -1);
PR_AddBuiltin (pr, "InputLine_SetText", bi_InputLine_SetText, -1);
PR_AddBuiltin (pr, "InputLine_GetText", bi_InputLine_GetText, -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);