mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-22 20:41:20 +00:00
Do key dest changing properly.
key_demo wasn't so well thought out. This seems to be much better (and nq is known to be working nicely).
This commit is contained in:
parent
16c8b2a18d
commit
c3d41326b3
10 changed files with 58 additions and 86 deletions
|
@ -369,8 +369,8 @@ typedef enum {
|
|||
|
||||
typedef enum {
|
||||
IMT_CONSOLE,
|
||||
IMT_DEMO,
|
||||
IMT_MOD,
|
||||
IMT_DEMO,
|
||||
IMT_0,
|
||||
IMT_1,
|
||||
IMT_2,
|
||||
|
@ -394,7 +394,6 @@ typedef enum {
|
|||
// key_none should, preferably, be last
|
||||
typedef enum {
|
||||
key_game,
|
||||
key_demo,
|
||||
key_console,
|
||||
key_message,
|
||||
key_menu,
|
||||
|
@ -408,7 +407,7 @@ typedef struct {
|
|||
} kbutton_t;
|
||||
|
||||
extern keydest_t key_dest;
|
||||
extern imt_t game_target;
|
||||
extern imt_t key_game_target;
|
||||
extern knum_t key_togglemenu;
|
||||
extern knum_t key_toggleconsole;
|
||||
|
||||
|
@ -425,6 +424,7 @@ void Key_WriteBindings (QFile *f);
|
|||
void Key_ClearStates (void);
|
||||
const char *Key_GetBinding (imt_t imt, knum_t key);
|
||||
void Key_SetBinding (imt_t target, knum_t keynum, const char *binding);
|
||||
void Key_SetKeyDest(keydest_t kd);
|
||||
|
||||
|
||||
const char *Key_KeynumToString (knum_t keynum);
|
||||
|
|
|
@ -120,11 +120,9 @@ ToggleConsole_f (void)
|
|||
Con_ClearTyping (input_line, 0);
|
||||
|
||||
if (key_dest == key_console && !con_data.force_commandline) {
|
||||
key_dest = key_game;
|
||||
game_target = IMT_0;
|
||||
Key_SetKeyDest (key_game);
|
||||
} else {
|
||||
key_dest = key_console;
|
||||
game_target = IMT_CONSOLE;
|
||||
Key_SetKeyDest (key_console);
|
||||
}
|
||||
|
||||
ClearNotify ();
|
||||
|
@ -136,11 +134,9 @@ ToggleChat_f (void)
|
|||
Con_ClearTyping (input_line, 0);
|
||||
|
||||
if (key_dest == key_console && !con_data.force_commandline) {
|
||||
key_dest = key_game;
|
||||
game_target = IMT_0;
|
||||
Key_SetKeyDest (key_game);
|
||||
} else {
|
||||
key_dest = key_console;
|
||||
game_target = IMT_CONSOLE;
|
||||
Key_SetKeyDest (key_console);
|
||||
}
|
||||
|
||||
ClearNotify ();
|
||||
|
@ -162,8 +158,7 @@ MessageMode_f (void)
|
|||
if (con_data.force_commandline)
|
||||
return;
|
||||
chat_team = false;
|
||||
key_dest = key_message;
|
||||
game_target = IMT_CONSOLE;
|
||||
Key_SetKeyDest (key_message);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -172,8 +167,7 @@ MessageMode2_f (void)
|
|||
if (con_data.force_commandline)
|
||||
return;
|
||||
chat_team = true;
|
||||
key_dest = key_message;
|
||||
game_target = IMT_CONSOLE;
|
||||
Key_SetKeyDest (key_message);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -329,8 +323,7 @@ C_Say (inputline_t *il)
|
|||
Cbuf_AddText (con_data.cbuf, "say \"");
|
||||
Cbuf_AddText (con_data.cbuf, line);
|
||||
Cbuf_AddText (con_data.cbuf, "\"\n");
|
||||
key_dest = key_game;
|
||||
game_target = IMT_0;
|
||||
Key_SetKeyDest (key_game);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -343,8 +336,7 @@ C_SayTeam (inputline_t *il)
|
|||
Cbuf_AddText (con_data.cbuf, "say_team \"");
|
||||
Cbuf_AddText (con_data.cbuf, line);
|
||||
Cbuf_AddText (con_data.cbuf, "\"\n");
|
||||
key_dest = key_game;
|
||||
game_target = IMT_0;
|
||||
Key_SetKeyDest (key_game);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -473,8 +465,7 @@ C_KeyEvent (knum_t key, short unicode, qboolean down)
|
|||
} else {
|
||||
Con_ClearTyping (say_line, 1);
|
||||
}
|
||||
key_dest = key_game;
|
||||
game_target = IMT_0;
|
||||
Key_SetKeyDest (key_game);
|
||||
return;
|
||||
case key_console:
|
||||
if (!con_data.force_commandline) {
|
||||
|
@ -482,7 +473,6 @@ C_KeyEvent (knum_t key, short unicode, qboolean down)
|
|||
return;
|
||||
}
|
||||
case key_game:
|
||||
case key_demo:
|
||||
Menu_Enter ();
|
||||
return;
|
||||
default:
|
||||
|
|
|
@ -367,8 +367,7 @@ bi_Menu_SelectMenu (progs_t *pr)
|
|||
if (name && *name)
|
||||
menu = Hash_Find (menu_hash, name);
|
||||
if (menu) {
|
||||
key_dest = key_menu;
|
||||
game_target = IMT_CONSOLE;
|
||||
Key_SetKeyDest (key_menu);
|
||||
if (menu->enter_hook) {
|
||||
run_menu_pre ();
|
||||
PR_ExecuteProgram (&menu_pr_state, menu->enter_hook);
|
||||
|
@ -378,11 +377,9 @@ bi_Menu_SelectMenu (progs_t *pr)
|
|||
if (name && *name)
|
||||
Sys_Printf ("no menu \"%s\"\n", name);
|
||||
if (con_data.force_commandline) {
|
||||
key_dest = key_console;
|
||||
game_target = IMT_CONSOLE;
|
||||
Key_SetKeyDest (key_console);
|
||||
} else {
|
||||
key_dest = key_game;
|
||||
game_target = IMT_0;
|
||||
Key_SetKeyDest (key_game);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -700,12 +697,10 @@ void
|
|||
Menu_Enter ()
|
||||
{
|
||||
if (!top_menu) {
|
||||
key_dest = key_console;
|
||||
game_target = IMT_CONSOLE;
|
||||
Key_SetKeyDest (key_console);
|
||||
return;
|
||||
}
|
||||
key_dest = key_menu;
|
||||
game_target = IMT_CONSOLE;
|
||||
Key_SetKeyDest (key_menu);
|
||||
menu = Hash_Find (menu_hash, top_menu);
|
||||
if (menu && menu->enter_hook) {
|
||||
run_menu_pre ();
|
||||
|
@ -726,11 +721,9 @@ Menu_Leave ()
|
|||
menu = menu->parent;
|
||||
if (!menu) {
|
||||
if (con_data.force_commandline) {
|
||||
key_dest = key_console;
|
||||
game_target = IMT_CONSOLE;
|
||||
Key_SetKeyDest (key_console);
|
||||
} else {
|
||||
key_dest = key_game;
|
||||
game_target = IMT_0;
|
||||
Key_SetKeyDest (key_game);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,13 +59,14 @@ static __attribute__ ((used)) const char rcsid[] =
|
|||
/* key up events are sent even if in console mode */
|
||||
|
||||
VISIBLE keydest_t key_dest = key_console;
|
||||
VISIBLE imt_t game_target = IMT_CONSOLE;
|
||||
VISIBLE imt_t key_game_target = IMT_0;
|
||||
VISIBLE knum_t key_togglemenu = QFK_ESCAPE;
|
||||
VISIBLE knum_t key_toggleconsole = QFK_BACKQUOTE;
|
||||
|
||||
VISIBLE struct keybind_s keybindings[IMT_LAST][QFK_LAST];
|
||||
VISIBLE int keydown[QFK_LAST];
|
||||
|
||||
static imt_t game_target = IMT_CONSOLE;
|
||||
static int keyhelp;
|
||||
static cbuf_t *cbuf;
|
||||
|
||||
|
@ -76,8 +77,8 @@ typedef struct {
|
|||
|
||||
imtname_t imtnames[] = {
|
||||
{"IMT_CONSOLE", IMT_CONSOLE},
|
||||
{"IMT_DEMO", IMT_DEMO},
|
||||
{"IMT_MOD", IMT_MOD},
|
||||
{"IMT_DEMO", IMT_DEMO},
|
||||
{"IMT_0", IMT_0},
|
||||
{"IMT_1", IMT_1},
|
||||
{"IMT_2", IMT_2},
|
||||
|
@ -457,25 +458,6 @@ Key_Game (knum_t key, short unicode)
|
|||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
Key_Demo
|
||||
|
||||
Interactive line editing and console scrollback
|
||||
*/
|
||||
static void
|
||||
Key_Demo (knum_t key, short unicode)
|
||||
{
|
||||
const char *kb;
|
||||
|
||||
// escape is un-bindable
|
||||
if (keydown[key] == 1 && key && Key_Game (key, unicode))
|
||||
return;
|
||||
|
||||
kb = Key_GetBinding (IMT_DEMO, key);
|
||||
if (kb)
|
||||
process_binding (key, kb);
|
||||
}
|
||||
|
||||
/*
|
||||
Key_Console
|
||||
|
||||
|
@ -877,9 +859,6 @@ Key_Event (knum_t key, short unicode, qboolean down)
|
|||
case key_game:
|
||||
Key_Game (key, unicode);
|
||||
break;
|
||||
case key_demo:
|
||||
Key_Demo (key, unicode);
|
||||
break;
|
||||
case key_message:
|
||||
case key_menu:
|
||||
case key_console:
|
||||
|
@ -965,3 +944,21 @@ Key_SetBinding (imt_t target, knum_t keynum, const char *binding)
|
|||
keybindings[target][keynum].str = strdup(binding);
|
||||
}
|
||||
}
|
||||
|
||||
VISIBLE void
|
||||
Key_SetKeyDest(keydest_t kd)
|
||||
{
|
||||
key_dest = kd;
|
||||
switch (key_dest) {
|
||||
default:
|
||||
Sys_Error ("Bad key_dest");
|
||||
case key_game:
|
||||
game_target = key_game_target;
|
||||
break;
|
||||
case key_console:
|
||||
case key_message:
|
||||
case key_menu:
|
||||
game_target = IMT_CONSOLE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -127,6 +127,8 @@ CL_StopPlayback (void)
|
|||
cls.demofile = NULL;
|
||||
CL_SetState (ca_disconnected);
|
||||
cls.demoplayback = 0;
|
||||
key_game_target = IMT_0;
|
||||
Key_SetKeyDest (key_game);
|
||||
|
||||
if (cls.timedemo)
|
||||
CL_FinishTimeDemo ();
|
||||
|
@ -357,8 +359,8 @@ CL_StartDemo (void)
|
|||
cls.demoplayback = true;
|
||||
CL_SetState (ca_connected);
|
||||
cls.forcetrack = 0;
|
||||
key_dest = key_demo;
|
||||
game_target = IMT_DEMO;
|
||||
key_game_target = IMT_DEMO;
|
||||
Key_SetKeyDest (key_game);
|
||||
|
||||
while ((c = Qgetc (cls.demofile)) != '\n')
|
||||
if (c == '-')
|
||||
|
|
|
@ -259,8 +259,7 @@ CL_EstablishConnection (const char *host)
|
|||
CL_SetState (ca_connected);
|
||||
cls.signon = 0; // need all the signon messages
|
||||
// before playing
|
||||
key_dest = key_game;
|
||||
game_target = IMT_0;
|
||||
Key_SetKeyDest (key_game);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -429,20 +428,13 @@ CL_SetState (cactive_t state)
|
|||
if (state == ca_active) {
|
||||
// entering active state
|
||||
r_active = true;
|
||||
if (cls.demoplayback) {
|
||||
game_target = IMT_DEMO;
|
||||
key_dest = key_demo;
|
||||
} else {
|
||||
game_target = IMT_0;
|
||||
key_dest = key_game;
|
||||
}
|
||||
Key_SetKeyDest (key_game);
|
||||
IN_ClearStates ();
|
||||
VID_SetCaption ("");
|
||||
} else if (old_state == ca_active) {
|
||||
// leaving active state
|
||||
r_active = false;
|
||||
game_target = IMT_CONSOLE;
|
||||
key_dest = key_console;
|
||||
Key_SetKeyDest (key_console);
|
||||
VID_SetCaption ("Disconnected");
|
||||
}
|
||||
if (state == ca_connected)
|
||||
|
|
|
@ -1253,7 +1253,7 @@ Sbar_FinaleOverlay (void)
|
|||
int remaining;
|
||||
|
||||
//FIXME cleaner test
|
||||
if (key_dest != key_game && key_dest != key_demo)
|
||||
if (key_dest != key_game)
|
||||
return;
|
||||
|
||||
scr_copyeverything = 1;
|
||||
|
@ -1274,7 +1274,7 @@ Sbar_DrawCenterPrint (void)
|
|||
return;
|
||||
|
||||
//FIXME cleaner test
|
||||
if (key_dest != key_game && key_dest != key_demo)
|
||||
if (key_dest != key_game)
|
||||
return;
|
||||
|
||||
Sbar_DrawCenterString (overlay_view, -1);
|
||||
|
|
|
@ -49,6 +49,7 @@ static __attribute__ ((used)) const char rcsid[] = "$Id$";
|
|||
#include "QF/cmd.h"
|
||||
#include "QF/cvar.h"
|
||||
#include "QF/dstring.h"
|
||||
#include "QF/keys.h"
|
||||
#include "QF/msg.h"
|
||||
#include "QF/qendian.h"
|
||||
#include "QF/sys.h"
|
||||
|
@ -147,6 +148,8 @@ CL_StopPlayback (void)
|
|||
cls.demoplayback2 = 0;
|
||||
demotime_cached = 0;
|
||||
net_blocksend = 0;
|
||||
key_game_target = IMT_0;
|
||||
Key_SetKeyDest (key_game);
|
||||
|
||||
if (cls.timedemo)
|
||||
CL_FinishTimeDemo ();
|
||||
|
@ -898,6 +901,8 @@ CL_StartDemo (void)
|
|||
}
|
||||
|
||||
cls.demoplayback = true;
|
||||
key_game_target = IMT_DEMO;
|
||||
Key_SetKeyDest (key_game);
|
||||
net_blocksend = 1;
|
||||
if (strequal (QFS_FileExtension (name->str), ".mvd")) {
|
||||
cls.demoplayback2 = true;
|
||||
|
|
|
@ -1149,8 +1149,7 @@ CL_SetState (cactive_t state)
|
|||
// leaving active state
|
||||
IN_ClearStates ();
|
||||
r_active = false;
|
||||
game_target = IMT_CONSOLE;
|
||||
key_dest = key_console;
|
||||
Key_SetKeyDest (key_console);
|
||||
|
||||
// Auto demo recorder stops here
|
||||
if (cl_autorecord->int_val && cls.demorecording)
|
||||
|
@ -1160,13 +1159,7 @@ CL_SetState (cactive_t state)
|
|||
VID_SetCaption (cls.servername->str);
|
||||
IN_ClearStates ();
|
||||
r_active = true;
|
||||
if (cls.demoplayback) {
|
||||
game_target = IMT_DEMO;
|
||||
key_dest = key_demo;
|
||||
} else {
|
||||
game_target = IMT_0;
|
||||
key_dest = key_game;
|
||||
}
|
||||
Key_SetKeyDest (key_game);
|
||||
|
||||
// Auto demo recorder starts here
|
||||
if (cl_autorecord->int_val && !cls.demoplayback
|
||||
|
|
|
@ -1713,7 +1713,7 @@ Sbar_FinaleOverlay (void)
|
|||
int remaining;
|
||||
|
||||
//FIXME cleaner test
|
||||
if (key_dest != key_game && key_dest != key_demo)
|
||||
if (key_dest != key_game)
|
||||
return;
|
||||
|
||||
scr_copyeverything = 1;
|
||||
|
@ -1734,7 +1734,7 @@ Sbar_DrawCenterPrint (void)
|
|||
return;
|
||||
|
||||
//FIXME cleaner test
|
||||
if (key_dest != key_game && key_dest != key_demo)
|
||||
if (key_dest != key_game)
|
||||
return;
|
||||
|
||||
Sbar_DrawCenterString (overlay_view, -1);
|
||||
|
|
Loading…
Reference in a new issue