mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-29 23:52:22 +00:00
fix the menu keybinding not working bug
This commit is contained in:
parent
797dcc49e2
commit
2b1fd8e8c0
7 changed files with 17 additions and 25 deletions
|
@ -28,9 +28,16 @@
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifndef __QF_idparse_h
|
||||||
|
#define __QF_idparse_h
|
||||||
|
|
||||||
extern const char *com_token;
|
extern const char *com_token;
|
||||||
|
|
||||||
|
struct cbuf_args_s;
|
||||||
|
|
||||||
const char *COM_Parse (const char *data);
|
const char *COM_Parse (const char *data);
|
||||||
void COM_TokenizeString (const char *str, cbuf_args_t *args);
|
void COM_TokenizeString (const char *str, struct cbuf_args_s *args);
|
||||||
|
|
||||||
extern struct cbuf_interpreter_s id_interp;
|
extern struct cbuf_interpreter_s id_interp;
|
||||||
|
|
||||||
|
#endif//__QF_idparse_h
|
||||||
|
|
|
@ -380,12 +380,12 @@ extern imt_t game_target;
|
||||||
|
|
||||||
extern struct keybind_s {
|
extern struct keybind_s {
|
||||||
char *str;
|
char *str;
|
||||||
struct cbuf_s *cbuf;
|
|
||||||
} keybindings[IMT_LAST][QFK_LAST];
|
} keybindings[IMT_LAST][QFK_LAST];
|
||||||
extern int keydown[QFK_LAST];
|
extern int keydown[QFK_LAST];
|
||||||
|
|
||||||
|
struct cbuf_s;
|
||||||
void Key_Event (knum_t key, short unicode, qboolean down);
|
void Key_Event (knum_t key, short unicode, qboolean down);
|
||||||
void Key_Init (void);
|
void Key_Init (struct cbuf_s *cb);
|
||||||
void Key_Init_Cvars (void);
|
void Key_Init_Cvars (void);
|
||||||
void Key_WriteBindings (VFile *f);
|
void Key_WriteBindings (VFile *f);
|
||||||
void Key_ClearStates (void);
|
void Key_ClearStates (void);
|
||||||
|
|
|
@ -38,21 +38,10 @@ static const char rcsid[] =
|
||||||
# include <strings.h>
|
# include <strings.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "QF/cbuf.h"
|
|
||||||
#include "QF/idparse.h"
|
|
||||||
#include "QF/keys.h"
|
#include "QF/keys.h"
|
||||||
#include "QF/progs.h"
|
#include "QF/progs.h"
|
||||||
#include "QF/zone.h"
|
#include "QF/zone.h"
|
||||||
|
|
||||||
static cbuf_t *cbuf; //FIXME use a properly allocated cbuf rather than this hack
|
|
||||||
|
|
||||||
static inline void
|
|
||||||
check_cbuf (void)
|
|
||||||
{
|
|
||||||
if (!cbuf)
|
|
||||||
cbuf = Cbuf_New (&id_interp);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
bi_Key_SetBinding
|
bi_Key_SetBinding
|
||||||
|
|
||||||
|
@ -64,16 +53,12 @@ bi_Key_SetBinding (progs_t *pr)
|
||||||
int target = P_INT (pr, 0);
|
int target = P_INT (pr, 0);
|
||||||
int keynum = P_INT (pr, 1);
|
int keynum = P_INT (pr, 1);
|
||||||
const char *binding = P_STRING (pr, 2);
|
const char *binding = P_STRING (pr, 2);
|
||||||
cbuf_t *tcb = cbuf_active;
|
|
||||||
|
|
||||||
if(strlen(binding) == 0 || binding[0] == '\0') {
|
if(strlen(binding) == 0 || binding[0] == '\0') {
|
||||||
binding = NULL; /* unbind a binding */
|
binding = NULL; /* unbind a binding */
|
||||||
}
|
}
|
||||||
|
|
||||||
check_cbuf ();
|
|
||||||
cbuf_active = cbuf;
|
|
||||||
Key_SetBinding (target, keynum, binding);
|
Key_SetBinding (target, keynum, binding);
|
||||||
cbuf_active = tcb;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -64,6 +64,7 @@ struct keybind_s keybindings[IMT_LAST][QFK_LAST];
|
||||||
int keydown[QFK_LAST];
|
int keydown[QFK_LAST];
|
||||||
|
|
||||||
static int keyhelp;
|
static int keyhelp;
|
||||||
|
static cbuf_t *cbuf;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char *name;
|
char *name;
|
||||||
|
@ -386,10 +387,8 @@ Key_Game (knum_t key, short unicode)
|
||||||
{
|
{
|
||||||
const char *kb;
|
const char *kb;
|
||||||
char cmd[1024];
|
char cmd[1024];
|
||||||
cbuf_t *cbuf;
|
|
||||||
|
|
||||||
kb = Key_GetBinding(game_target, key);
|
kb = Key_GetBinding(game_target, key);
|
||||||
cbuf = keybindings[game_target][key].cbuf;
|
|
||||||
if (!kb && (game_target > IMT_0))
|
if (!kb && (game_target > IMT_0))
|
||||||
kb = Key_GetBinding(IMT_0, key);
|
kb = Key_GetBinding(IMT_0, key);
|
||||||
|
|
||||||
|
@ -794,8 +793,10 @@ Key_ClearStates (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Key_Init (void)
|
Key_Init (cbuf_t *cb)
|
||||||
{
|
{
|
||||||
|
cbuf = cb;
|
||||||
|
|
||||||
OK_Init ();
|
OK_Init ();
|
||||||
|
|
||||||
// register our functions
|
// register our functions
|
||||||
|
@ -848,5 +849,4 @@ Key_SetBinding (imt_t target, knum_t keynum, const char *binding)
|
||||||
if (binding) {
|
if (binding) {
|
||||||
keybindings[target][keynum].str = strdup(binding);
|
keybindings[target][keynum].str = strdup(binding);
|
||||||
}
|
}
|
||||||
keybindings[target][keynum].cbuf = cbuf_active;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -934,7 +934,7 @@ Host_Init (void)
|
||||||
NET_Init ();
|
NET_Init ();
|
||||||
|
|
||||||
W_LoadWadFile ("gfx.wad");
|
W_LoadWadFile ("gfx.wad");
|
||||||
Key_Init ();
|
Key_Init (host_cbuf);
|
||||||
Mod_Init ();
|
Mod_Init ();
|
||||||
|
|
||||||
CL_Demo_Init ();
|
CL_Demo_Init ();
|
||||||
|
|
|
@ -219,7 +219,7 @@ IN_Shutdown (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Key_Init (void)
|
Key_Init (struct cbuf_s *cb)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1757,7 +1757,7 @@ Host_Init (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
W_LoadWadFile ("gfx.wad");
|
W_LoadWadFile ("gfx.wad");
|
||||||
Key_Init ();
|
Key_Init (cl_cbuf);
|
||||||
Mod_Init ();
|
Mod_Init ();
|
||||||
|
|
||||||
CL_Demo_Init();
|
CL_Demo_Init();
|
||||||
|
|
Loading…
Reference in a new issue