Copyable console, and up2's demand for aliases like fuhquake.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@1935 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2006-02-06 01:06:17 +00:00
parent 8b3c4d9071
commit cf73c8b81e
21 changed files with 206 additions and 58 deletions

View File

@ -448,9 +448,9 @@ ifeq ($(FTE_TARGET),linux)
SV_LDFLAGS=-lz
ifeq ($(USEASM),true)
GLCL_OBJS=$(GL_OBJS) $(GLQUAKE_OBJS) gl_vidlinuxglx.o snd_linux.o cd_linux.o sys_linux.o sys_dosa.o
GLCL_OBJS=$(GL_OBJS) $(GLQUAKE_OBJS) gl_vidlinuxglx.o snd_linux.o snd_alsa.oo cd_linux.o sys_linux.o sys_dosa.o
else
GLCL_OBJS=$(GL_OBJS) $(GLQUAKE_OBJS) gl_vidlinuxglx.o snd_linux.o cd_linux.o sys_linux.o
GLCL_OBJS=$(GL_OBJS) $(GLQUAKE_OBJS) gl_vidlinuxglx.o snd_linux.o snd_alsa.oo cd_linux.o sys_linux.o
endif
GL_EXE_NAME=../fteqw.gl
GLCL_EXE_NAME=../fteqwcl.gl
@ -460,9 +460,9 @@ endif
GLCL_DIR=glcl_linux
ifeq ($(USEASM),true)
SWCL_OBJS=$(SOFTWARE_OBJS) vid_x.o snd_linux.o cd_linux.o sys_linux.o sys_dosa.o
SWCL_OBJS=$(SOFTWARE_OBJS) vid_x.o snd_linux.o snd_alsa.oo cd_linux.o sys_linux.o sys_dosa.o
else
SWCL_OBJS=$(SOFTWARE_OBJS) vid_x.o snd_linux.o cd_linux.o sys_linux.o
SWCL_OBJS=$(SOFTWARE_OBJS) vid_x.o snd_linux.o snd_alsa.oo cd_linux.o sys_linux.o
endif
SW_EXE_NAME=../fteqw.sw
SWCL_EXE_NAME=../fteqwcl.sw
@ -472,9 +472,9 @@ endif
SWCL_DIR=swcl_linux
ifeq ($(USEASM),true)
MCL_OBJS=$(GLQUAKE_OBJS) $(SOFTWARE_OBJS) gl_vidlinuxglx.o vid_x.o snd_linux.o cd_linux.o sys_linux.o sys_dosa.o
MCL_OBJS=$(GLQUAKE_OBJS) $(SOFTWARE_OBJS) gl_vidlinuxglx.o vid_x.o snd_linux.o snd_alsa.oo cd_linux.o sys_linux.o sys_dosa.o
else
MCL_OBJS=$(GLQUAKE_OBJS) $(SOFTWARE_OBJS) gl_vidlinuxglx.o vid_x.o snd_linux.o cd_linux.o sys_linux.o
MCL_OBJS=$(GLQUAKE_OBJS) $(SOFTWARE_OBJS) gl_vidlinuxglx.o vid_x.o snd_linux.o snd_alsa.oo cd_linux.o sys_linux.o
endif
M_EXE_NAME=../fteqw
MCL_EXE_NAME=../fteqwcl
@ -567,6 +567,13 @@ $(OUT_DIR)/%.o $(OUT_DIR)/%.d : %.c
rm -f $@.d.$$$$
$(DO_CC) -I$(OUT_DIR)
$(OUT_DIR)/%.oo $(OUT_DIR)/%.d : %.c
@set -e; rm -f $@.d; \
$(CC) -MM $(ALL_CFLAGS) $< > $@.d.$$$$; \
sed 's,\($*\)\.oo[ :]*,\1.oo $@.d : ,g' < $@.d.$$$$ > $@.d; \
rm -f $@.d.$$$$
$(DO_CC) -I$(OUT_DIR)
ifeq ($(USEASM),true)
$(OUT_DIR)/%.o : %.s sw/*.h
$(DO_AS)

View File

@ -1128,7 +1128,10 @@ void CL_PlayDownloadedDemo(char *name, qboolean success)
if (success == false)
Con_Printf("Failed to download %s\n", name);
else
{
FS_FlushFSHash();
Cbuf_AddText(va("playdemo %s\n", name), RESTRICT_LOCAL);
}
}
#endif

View File

@ -1685,7 +1685,7 @@ void CL_NextDemo (void)
}
sprintf (str,"playdemo %s\n", cls.demos[cls.demonum]);
Cbuf_InsertText (str, RESTRICT_LOCAL);
Cbuf_InsertText (str, RESTRICT_LOCAL, false);
cls.demonum++;
}

View File

@ -3753,7 +3753,7 @@ void CL_ParseServerMessage (void)
{
default:
CL_DumpPacket();
Host_EndGame ("CL_ParseServerMessage: Illegible server message");
Host_EndGame ("CL_ParseServerMessage: Illegible server message (%i)", cmd);
return;
case svc_time:

View File

@ -1367,6 +1367,8 @@ void Con_DrawConsole (int lines, qboolean noback)
rows--;
}
Key_ConsoleDrawSelectionBox();
// draw from the bottom up
if (curcon->display != curcon->current)
{
@ -1467,7 +1469,7 @@ void Con_DrawConsole (int lines, qboolean noback)
// draw the input prompt, user text, and cursor if desired
Con_DrawInput ();
DrawCursor();
}

View File

@ -1383,7 +1383,7 @@ static void ProcessMouse(mouse_t *mouse, usercmd_t *cmd, int pnum)
if(in_xflip.value) mx *= -1;
#endif
if (mouseusedforgui || (key_dest == key_menu && (m_state == m_complex || m_state == m_plugin))
if (mouseusedforgui || (key_dest == key_menu && (m_state == m_complex || m_state == m_plugin) || key_dest == key_console)
#ifdef VM_UI
|| UI_MenuState()
#endif

View File

@ -42,6 +42,8 @@ keydest_t key_dest;
int key_count; // incremented every key event
int con_mousedown[3];
char *keybindings[K_MAX][KEY_MODIFIERSTATES];
qbyte bindcmdlevel[K_MAX][KEY_MODIFIERSTATES];
qboolean consolekeys[K_MAX]; // if true, can't be rebound while in console
@ -382,6 +384,122 @@ void Con_ExecuteLine(console_t *con, char *line)
// may take some time
}
void Key_ConsoleDrawSelectionBox(void)
{
extern cvar_t vid_conwidth, vid_conheight;
extern int mousecursor_x, mousecursor_y;
int xpos, ypos, temp;
int xpos2, ypos2;
char *buf, *bufhead;
int x, y;
if (!con_mousedown[2])
return;
xpos2 = con_mousedown[0];
ypos2 = con_mousedown[1];
xpos = (int)((mousecursor_x*vid_conwidth.value)/(vid.width*8));
ypos = (int)((mousecursor_y*vid_conheight.value)/(vid.height*8));
if (xpos2 < 1)
xpos2 = 1;
if (xpos < 1)
xpos = 1;
if (xpos2 > con_current->linewidth)
xpos2 = con_current->linewidth;
if (xpos > con_current->linewidth)
xpos = con_current->linewidth;
if (xpos2 > xpos)
{
temp = xpos;
xpos = xpos2;
xpos2 = temp;
}
xpos++;
if (ypos2 > ypos)
{
temp = ypos;
ypos = ypos2;
ypos2 = temp;
}
ypos++;
Draw_Fill(xpos2*8, ypos2*8, (xpos - xpos2)*8, (ypos - ypos2)*8, 0);
}
void Key_ConsoleRelease(int key)
{
if (key == K_MOUSE1 && con_mousedown[2])
{
extern cvar_t vid_conwidth, vid_conheight;
extern int mousecursor_x, mousecursor_y;
int xpos, ypos, temp;
char *buf, *bufhead;
int x, y;
xpos = (int)((mousecursor_x*vid_conwidth.value)/(vid.width*8));
ypos = (int)((mousecursor_y*vid_conheight.value)/(vid.height*8));
con_mousedown[2] = false;
if (con_mousedown[0] < 1)
con_mousedown[0] = 1;
if (xpos < 1)
xpos = 1;
if (con_mousedown[0] > con_current->linewidth)
con_mousedown[0] = con_current->linewidth;
if (xpos > con_current->linewidth)
xpos = con_current->linewidth;
if (con_mousedown[0] > xpos)
{
temp = xpos;
xpos = con_mousedown[0];
con_mousedown[0] = temp;
}
xpos++;
if (con_mousedown[1] > ypos)
{
temp = ypos;
ypos = con_mousedown[1];
con_mousedown[1] = temp;
}
ypos++;
ypos += con_current->display-(con_current->vislines/8)+4;
con_mousedown[1] += con_current->display-(con_current->vislines/8)+4;
if (con_current->display != con_current->current)
{
ypos++;
con_mousedown[1]++;
}
con_mousedown[0]--;
xpos--;
temp = (ypos - con_mousedown[1]) * (xpos - con_mousedown[0] + 2) + 1;
bufhead = buf = Z_Malloc(temp);
for (y = con_mousedown[1]; y < ypos; y++)
{
if (y != con_mousedown[1])
{
while(buf > bufhead && buf[-1] == ' ')
buf--;
*buf++ = '\r';
*buf++ = '\n';
}
for (x = con_mousedown[0]; x < xpos; x++)
*buf++ = con_current->text[x + ((y%con_current->totallines)*con_current->linewidth)];
}
while(buf > bufhead && buf[-1] == ' ')
buf--;
*buf++ = '\0';
Sys_SaveClipboard(bufhead);
Z_Free(bufhead);
}
}
/*
====================
Key_Console
@ -407,14 +525,16 @@ void Key_Console (int key)
return;
}
if ((key == K_MOUSE1 || key == K_MOUSE2) && con_main.next)
if ((key == K_MOUSE1 || key == K_MOUSE2))
{
extern cvar_t vid_conwidth, vid_conheight;
extern int mousecursor_x, mousecursor_y;
int xpos, ypos;
xpos = (int)((mousecursor_x*vid_conwidth.value)/(vid.width*8));
ypos = (int)((mousecursor_y*vid_conheight.value)/(vid.height*8));
if (ypos == 0)
con_mousedown[0] = xpos;
con_mousedown[1] = ypos;
if (ypos == 0 && con_main.next)
{
console_t *con;
for (con = &con_main; con; con = con->next)
@ -435,6 +555,8 @@ void Key_Console (int key)
}
}
}
else
con_mousedown[2] = true;
return;
}
@ -1344,6 +1466,9 @@ void Key_Event (int key, qboolean down)
case key_menu:
M_Keyup (key);
break;
case key_console:
Key_ConsoleRelease(key);
break;
default:
break;
}

View File

@ -966,6 +966,26 @@ void M_RemoveAllMenus (void)
}
void DrawCursor(void)
{
extern int mousecursor_x, mousecursor_y;
mpic_t *p;
if (!*cl_cursor.string)
p = NULL;
else
p = Draw_SafeCachePic(cl_cursor.string);
if (p)
{
Draw_ImageColours(1, 1, 1, 1);
Draw_Image(mousecursor_x-cl_cursorbias.value, mousecursor_y-cl_cursorbias.value, cl_cursorsize.value, cl_cursorsize.value, 0, 0, 1, 1, p);
// Draw_TransPic(mousecursor_x-4, mousecursor_y-4, p);
}
else
Draw_Character(mousecursor_x-4, mousecursor_y-4, '+');
}
void M_Complex_Draw(void)
{
extern int mousecursor_x, mousecursor_y;
@ -1001,18 +1021,7 @@ void M_Complex_Draw(void)
MenuDraw(cmenu);
}
if (!*cl_cursor.string)
p = NULL;
else
p = Draw_SafeCachePic(cl_cursor.string);
if (p)
{
Draw_ImageColours(1, 1, 1, 1);
Draw_Image(mousecursor_x-cl_cursorbias.value, mousecursor_y-cl_cursorbias.value, cl_cursorsize.value, cl_cursorsize.value, 0, 0, 1, 1, p);
// Draw_TransPic(mousecursor_x-4, mousecursor_y-4, p);
}
else
Draw_Character(mousecursor_x-4, mousecursor_y-4, '+');
DrawCursor();
}
menuoption_t *M_NextItem(menu_t *m, menuoption_t *old)
@ -1106,7 +1115,7 @@ void M_Complex_Key(int key)
if (key != K_ESCAPE && key != '`')
{
Cbuf_InsertText (va("bind %s \"%s\"\n", Key_KeynumToString (key), currentmenu->selecteditem->bind.command), RESTRICT_LOCAL);
Cbuf_InsertText (va("bind %s \"%s\"\n", Key_KeynumToString (key), currentmenu->selecteditem->bind.command), RESTRICT_LOCAL, false);
}
bindingactive = false;
return;

View File

@ -766,6 +766,10 @@ void M_SListKey(int key)
SListOptionChanged(M_FindCurrentServer());
}
}
else if (key == 'c')
{
Sys_SaveClipboard(NET_AdrToString(selectedserver.adr));
}
else if (key == 'f')
{
serverinfo_t *server;

View File

@ -483,8 +483,8 @@ void M_Keys_Key (int k)
}
else if (k != '`')
{
sprintf (cmd, "bind %s \"%s\"\n", Key_KeynumToString (k), bindnames[keys_cursor].command);
Cbuf_InsertText (cmd, RESTRICT_LOCAL);
sprintf (cmd, "bind %s \"%s\"\n", Key_KeynumToString (k), bindnames[keys_cursor].command, false);
Cbuf_InsertText (cmd, RESTRICT_LOCAL, false);
}
bind_grab = false;

View File

@ -431,7 +431,7 @@ void P_ParticleEffect_f(void)
buf++; //no whitespace please.
if (*buf != '{')
{
Cbuf_InsertText(buf, Cmd_ExecLevel);
Cbuf_InsertText(buf, Cmd_ExecLevel, true);
Con_Printf("This is a multiline command and should be used within config files\n");
return;
}

View File

@ -187,11 +187,10 @@ sfxcache_t *S_LoadOVSound (sfx_t *s, qbyte *data, int datalen, int sndspeed);
S_LoadSound_t AudioInputPlugins[8] =
{
S_LoadWavSound
#ifdef AVAIL_OGGVORBIS
, S_LoadOVSound
S_LoadOVSound,
#endif
S_LoadWavSound
};
qboolean S_RegisterSoundInputPlugin(S_LoadSound_t loadfnc)

View File

@ -277,7 +277,7 @@ qboolean OV_StartDecode(unsigned char *start, unsigned long length, ovdecoderbuf
buffer->pos = 0;
if (p_ov_open_callbacks(buffer, &buffer->vf, NULL, 0, callbacks))
{
Con_Printf("Input does not appear to be an Ogg bitstream.\n");
// Con_Printf("Input does not appear to be an Ogg bitstream.\n");
return false;
}

View File

@ -303,8 +303,8 @@ cshift_t cshift_lava = { {255,80,0}, 150 };
cshift_t cshift_server = { {130,80,50}, 0 };
cvar_t v_gamma = {"gamma", "1", NULL, CVAR_ARCHIVE};
cvar_t v_contrast = {"contrast", "1", NULL, CVAR_ARCHIVE};
cvar_t v_gamma = {"gamma", "0.5", NULL, CVAR_ARCHIVE};
cvar_t v_contrast = {"contrast", "2", NULL, CVAR_ARCHIVE};
qbyte gammatable[256]; // palette is sent through this

View File

@ -221,7 +221,7 @@ Adds a \n to the text
FIXME: actually change the command buffer to do less copying
============
*/
void Cbuf_InsertText (const char *text, int level)
void Cbuf_InsertText (const char *text, int level, qboolean addnl)
{
char *temp;
int templen;
@ -245,7 +245,8 @@ void Cbuf_InsertText (const char *text, int level)
// add the entire text of the file
Cbuf_AddText (text, level);
SZ_Write (&cmd_text[level].buf, "\n", 1);
if (addnl)
SZ_Write (&cmd_text[level].buf, "\n", 1);
// add the copied off data
if (templen)
{
@ -506,8 +507,7 @@ void Cmd_Exec_f (void)
Con_TPrintf (TL_EXECING,name);
// don't execute anything as if it was from server
Cbuf_InsertText ("\n", Cmd_FromGamecode() ? RESTRICT_INSECURE : Cmd_ExecLevel);
Cbuf_InsertText (f, Cmd_FromGamecode() ? RESTRICT_INSECURE : Cmd_ExecLevel);
Cbuf_InsertText (f, Cmd_FromGamecode() ? RESTRICT_INSECURE : Cmd_ExecLevel, true);
BZ_Free(f);
}
@ -684,7 +684,7 @@ void Cmd_Alias_f (void)
if (!strcmp(line, "{"))
multiline = true;
else
Cbuf_InsertText(line, Cmd_ExecLevel); //whoops. Stick the trimmed string back in to the cbuf.
Cbuf_InsertText(line, Cmd_ExecLevel, true); //whoops. Stick the trimmed string back in to the cbuf.
}
else if (!strcmp(Cmd_Argv(2), "{"))
multiline = true;
@ -735,7 +735,7 @@ void Cmd_Alias_f (void)
for (i=2 ; i< c ; i++)
{
strcat (cmd, Cmd_Argv(i));
if (i != c)
if (i != c-1)
strcat (cmd, " ");
}
@ -1708,7 +1708,7 @@ void Cmd_ExecuteString (char *text, int level)
else
execlevel = level;
Cbuf_InsertText ("\n", execlevel);
Cbuf_InsertText ("\n", execlevel, false);
// if the alias value is a command or cvar and
// the alias is called with parameters, add them
@ -1716,19 +1716,19 @@ void Cmd_ExecuteString (char *text, int level)
(Cvar_FindVar(a->value) || (Cmd_Exists(a->value) && a->value[0] != '+' && a->value[0] != '-'))
)
{
Cbuf_InsertText (Cmd_Args(), execlevel);
Cbuf_InsertText (" ", execlevel);
Cbuf_InsertText (Cmd_Args(), execlevel, false);
Cbuf_InsertText (" ", execlevel, false);
}
Cbuf_InsertText (a->value, execlevel);
Cbuf_InsertText (a->value, execlevel, false);
if (execlevel>=RESTRICT_SERVER)
return; //don't do the cmd_argc/cmd_argv stuff. When it's from the server, we had a tendancy to lock aliases, so don't set them anymore.
Cbuf_InsertText (va("set cmd_argc \"%i\"\n", cmd_argc), execlevel);
Cbuf_InsertText (va("set cmd_argc \"%i\"\n", cmd_argc), execlevel, false);
for (i = 0; i < cmd_argc; i++)
Cbuf_InsertText (va("set cmd_argv%i \"%s\"\n", i, cmd_argv[i]), execlevel);
Cbuf_InsertText (va("set cmd_argv%i \"%s\"\n", i, cmd_argv[i]), execlevel, false);
return;
}
}
@ -2260,7 +2260,7 @@ skipblock:
}
}
//whoops. Too far.
Cbuf_InsertText(end, level);
Cbuf_InsertText(end, level, true);
If_Token_Clear(ts);
return;
}
@ -2270,12 +2270,12 @@ skipblock:
{
if (text) //don't bother execing the else bit...
*text = '\0';
Cbuf_InsertText(end, level);
Cbuf_InsertText(end, level, true);
}
else
{
if (text)
Cbuf_InsertText(text+4, level); //ironically, this will do elseif...
Cbuf_InsertText(text+4, level, true); //ironically, this will do elseif...
}
If_Token_Clear(ts);
@ -2292,7 +2292,7 @@ void Cmd_Vstr_f( void )
}
v = Cvar_VariableString(Cmd_Argv(1));
Cbuf_InsertText(va("%s\n", v), Cmd_ExecLevel);
Cbuf_InsertText(v, Cmd_ExecLevel, true);
}
void Cmd_set_f(void)

View File

@ -42,7 +42,7 @@ void Cbuf_AddText (const char *text, int level);
// as new commands are generated from the console or keybindings,
// the text is added to the end of the command buffer.
void Cbuf_InsertText (const char *text, int level);
void Cbuf_InsertText (const char *text, int level, qboolean addnl);
// when a command wants to issue other commands immediately, the text is
// inserted at the beginning of the buffer, before any remaining unexecuted
// commands.

View File

@ -2540,7 +2540,7 @@ void COM_Gamedir (char *dir)
"exec config.cfg\n"
"exec fte.cfg\n"
"exec frontend.cfg\n"
"cl_warncmd 1\n", RESTRICT_LOCAL);
"cl_warncmd 1\n", RESTRICT_LOCAL, false);
}
}

View File

@ -629,7 +629,7 @@ int VARGS Plug_Cvar_GetString(void *offset, unsigned int mask, const long *arg)
int VARGS Plug_Cmd_AddText(void *offset, unsigned int mask, const long *arg)
{
if (VM_LONG(arg[1]))
Cbuf_InsertText(VM_POINTER(arg[0]), RESTRICT_LOCAL);
Cbuf_InsertText(VM_POINTER(arg[0]), RESTRICT_LOCAL, false);
else
Cbuf_AddText(VM_POINTER(arg[0]), RESTRICT_LOCAL);

View File

@ -28,7 +28,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef CDS_FULLSCREEN
#define CDS_FULLSCREEN 4
#define CDS_FULLSCREEN 4
#endif
#ifndef WM_XBUTTONDOWN

View File

@ -3848,7 +3848,7 @@ void SV_Init (quakeparms_t *parms)
Con_TPrintf (STL_INITED);
Cbuf_InsertText ("exec server.cfg\nexec ftesrv.cfg\n", RESTRICT_LOCAL);
Cbuf_InsertText ("exec server.cfg\nexec ftesrv.cfg\n", RESTRICT_LOCAL, false);
// process command line arguments
Cbuf_Execute ();

View File

@ -1532,7 +1532,7 @@ void D_DrawSpans16 (espan_t *pspan)
} while ((pspan = pspan->pnext) != NULL);
}
/*
void D_DrawSpans16From8 (espan_t *pspan)
{
int count, spancount;
@ -1662,8 +1662,7 @@ void D_DrawSpans16From8 (espan_t *pspan)
} while ((pspan = pspan->pnext) != NULL);
}
*/
#if !id386