mirror of
https://github.com/UberGames/lilium-voyager.git
synced 2024-11-10 06:31:47 +00:00
* (bug 3324) Incorrect use of sizeof (beast <info@dbwatersports.com>)
* (bug 2946) Console scrolling broken (identified by misantropia) + Field_VariableSizeDraw contained a hack to ensure the cursor was always visible. Unfortunately this interfered with scrolling long lines. Move the hack to a different place + Removed commented code in the same function + Reworked Field_KeyDownEvent to use a switch( ... ) and set edit->scroll in every case, thereby avoiding scrolling issues when "Home" or "End" are pressed
This commit is contained in:
parent
5e35d88b9b
commit
2ea6b8b512
2 changed files with 65 additions and 74 deletions
|
@ -306,7 +306,7 @@ EDIT FIELDS
|
||||||
Field_Draw
|
Field_Draw
|
||||||
|
|
||||||
Handles horizontal scrolling and cursor blinking
|
Handles horizontal scrolling and cursor blinking
|
||||||
x, y, amd width are in pixels
|
x, y, and width are in pixels
|
||||||
===================
|
===================
|
||||||
*/
|
*/
|
||||||
void Field_VariableSizeDraw( field_t *edit, int x, int y, int width, int size, qboolean showCursor ) {
|
void Field_VariableSizeDraw( field_t *edit, int x, int y, int width, int size, qboolean showCursor ) {
|
||||||
|
@ -317,8 +317,8 @@ void Field_VariableSizeDraw( field_t *edit, int x, int y, int width, int size, q
|
||||||
char str[MAX_STRING_CHARS];
|
char str[MAX_STRING_CHARS];
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
drawLen = edit->widthInChars;
|
drawLen = edit->widthInChars - 1; // - 1 so there is always a space for the cursor
|
||||||
len = strlen( edit->buffer ) + 1;
|
len = strlen( edit->buffer );
|
||||||
|
|
||||||
// guarantee that cursor will be visible
|
// guarantee that cursor will be visible
|
||||||
if ( len <= drawLen ) {
|
if ( len <= drawLen ) {
|
||||||
|
@ -331,14 +331,6 @@ void Field_VariableSizeDraw( field_t *edit, int x, int y, int width, int size, q
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
prestep = edit->scroll;
|
prestep = edit->scroll;
|
||||||
|
|
||||||
/*
|
|
||||||
if ( edit->cursor < len - drawLen ) {
|
|
||||||
prestep = edit->cursor; // cursor at start
|
|
||||||
} else {
|
|
||||||
prestep = len - drawLen;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( prestep + drawLen > len ) {
|
if ( prestep + drawLen > len ) {
|
||||||
|
@ -379,7 +371,7 @@ void Field_VariableSizeDraw( field_t *edit, int x, int y, int width, int size, q
|
||||||
cursorChar = 10;
|
cursorChar = 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
i = drawLen - ( Q_PrintStrlen( str ) + 1 );
|
i = drawLen - Q_PrintStrlen( str );
|
||||||
|
|
||||||
if ( size == SMALLCHAR_WIDTH ) {
|
if ( size == SMALLCHAR_WIDTH ) {
|
||||||
SCR_DrawSmallChar( x + ( edit->cursor - prestep - i ) * size, y, cursorChar );
|
SCR_DrawSmallChar( x + ( edit->cursor - prestep - i ) * size, y, cursorChar );
|
||||||
|
@ -444,54 +436,50 @@ void Field_KeyDownEvent( field_t *edit, int key ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
key = tolower( key );
|
||||||
len = strlen( edit->buffer );
|
len = strlen( edit->buffer );
|
||||||
|
|
||||||
if ( key == K_DEL ) {
|
switch ( key ) {
|
||||||
if ( edit->cursor < len ) {
|
case K_DEL:
|
||||||
memmove( edit->buffer + edit->cursor,
|
if ( edit->cursor < len ) {
|
||||||
edit->buffer + edit->cursor + 1, len - edit->cursor );
|
memmove( edit->buffer + edit->cursor,
|
||||||
}
|
edit->buffer + edit->cursor + 1, len - edit->cursor );
|
||||||
return;
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case K_RIGHTARROW:
|
||||||
|
if ( edit->cursor < len ) {
|
||||||
|
edit->cursor++;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case K_LEFTARROW:
|
||||||
|
if ( edit->cursor > 0 ) {
|
||||||
|
edit->cursor--;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case K_HOME:
|
||||||
|
edit->cursor = 0;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case K_END:
|
||||||
|
edit->cursor = len;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case K_INS:
|
||||||
|
key_overstrikeMode = !key_overstrikeMode;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( key == K_RIGHTARROW )
|
// Change scroll is cursor if no longer visible
|
||||||
{
|
if ( edit->cursor < edit->scroll ) {
|
||||||
if ( edit->cursor < len ) {
|
edit->scroll = edit->cursor;
|
||||||
edit->cursor++;
|
} else if ( edit->cursor >= edit->scroll + edit->widthInChars && edit->cursor <= len ) {
|
||||||
}
|
edit->scroll = edit->cursor - edit->widthInChars + 1;
|
||||||
|
|
||||||
if ( edit->cursor >= edit->scroll + edit->widthInChars && edit->cursor <= len )
|
|
||||||
{
|
|
||||||
edit->scroll++;
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( key == K_LEFTARROW )
|
|
||||||
{
|
|
||||||
if ( edit->cursor > 0 ) {
|
|
||||||
edit->cursor--;
|
|
||||||
}
|
|
||||||
if ( edit->cursor < edit->scroll )
|
|
||||||
{
|
|
||||||
edit->scroll--;
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( key == K_HOME || ( tolower(key) == 'a' && keys[K_CTRL].down ) ) {
|
|
||||||
edit->cursor = 0;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( key == K_END || ( tolower(key) == 'e' && keys[K_CTRL].down ) ) {
|
|
||||||
edit->cursor = len;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( key == K_INS ) {
|
|
||||||
key_overstrikeMode = !key_overstrikeMode;
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -568,34 +568,37 @@ static void ArenaServers_Remove( void )
|
||||||
|
|
||||||
// find address in master list
|
// find address in master list
|
||||||
for (i=0; i<g_arenaservers.numfavoriteaddresses; i++)
|
for (i=0; i<g_arenaservers.numfavoriteaddresses; i++)
|
||||||
if (!Q_stricmp(g_arenaservers.favoriteaddresses[i],servernodeptr->adrstr))
|
|
||||||
break;
|
|
||||||
|
|
||||||
// delete address from master list
|
|
||||||
if (i <= g_arenaservers.numfavoriteaddresses-1)
|
|
||||||
{
|
{
|
||||||
if (i < g_arenaservers.numfavoriteaddresses-1)
|
if (!Q_stricmp(g_arenaservers.favoriteaddresses[i],servernodeptr->adrstr))
|
||||||
{
|
{
|
||||||
// shift items up
|
// delete address from master list
|
||||||
memcpy( &g_arenaservers.favoriteaddresses[i], &g_arenaservers.favoriteaddresses[i+1], (g_arenaservers.numfavoriteaddresses - i - 1)*sizeof(MAX_ADDRESSLENGTH));
|
if (i < g_arenaservers.numfavoriteaddresses-1)
|
||||||
|
{
|
||||||
|
// shift items up
|
||||||
|
memcpy( &g_arenaservers.favoriteaddresses[i], &g_arenaservers.favoriteaddresses[i+1], (g_arenaservers.numfavoriteaddresses - i - 1)* MAX_ADDRESSLENGTH );
|
||||||
|
}
|
||||||
|
g_arenaservers.numfavoriteaddresses--;
|
||||||
|
memset( &g_arenaservers.favoriteaddresses[g_arenaservers.numfavoriteaddresses], 0, MAX_ADDRESSLENGTH );
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
g_arenaservers.numfavoriteaddresses--;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// find address in server list
|
// find address in server list
|
||||||
for (i=0; i<g_numfavoriteservers; i++)
|
for (i=0; i<g_numfavoriteservers; i++)
|
||||||
if (&g_favoriteserverlist[i] == servernodeptr)
|
|
||||||
break;
|
|
||||||
|
|
||||||
// delete address from server list
|
|
||||||
if (i <= g_numfavoriteservers-1)
|
|
||||||
{
|
{
|
||||||
if (i < g_numfavoriteservers-1)
|
if (&g_favoriteserverlist[i] == servernodeptr)
|
||||||
{
|
{
|
||||||
// shift items up
|
|
||||||
memcpy( &g_favoriteserverlist[i], &g_favoriteserverlist[i+1], (g_numfavoriteservers - i - 1)*sizeof(servernode_t));
|
// delete address from server list
|
||||||
|
if (i < g_numfavoriteservers-1)
|
||||||
|
{
|
||||||
|
// shift items up
|
||||||
|
memcpy( &g_favoriteserverlist[i], &g_favoriteserverlist[i+1], (g_numfavoriteservers - i - 1)*sizeof(servernode_t));
|
||||||
|
}
|
||||||
|
g_numfavoriteservers--;
|
||||||
|
memset( &g_favoriteserverlist[ g_numfavoriteservers ], 0, sizeof(servernode_t));
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
g_numfavoriteservers--;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
g_arenaservers.numqueriedservers = g_arenaservers.numfavoriteaddresses;
|
g_arenaservers.numqueriedservers = g_arenaservers.numfavoriteaddresses;
|
||||||
|
|
Loading…
Reference in a new issue