Just sync with @mittorn's native_touch menu branch
This commit is contained in:
parent
555ceaea3a
commit
f48dabe500
@ -36,7 +36,6 @@ cvar_t *ui_showmodels;
|
||||
|
||||
uiStatic_t uiStatic;
|
||||
|
||||
char uiEmptyString[256];
|
||||
const char *uiSoundIn = "media/launch_upmenu1.wav";
|
||||
const char *uiSoundOut = "media/launch_dnmenu1.wav";
|
||||
const char *uiSoundLaunch = "media/launch_select2.wav";
|
||||
@ -1181,11 +1180,11 @@ void UI_MouseMove( int x, int y )
|
||||
prevDown = true, cursorDY = 0;
|
||||
else
|
||||
if( y - uiStatic.cursorY )
|
||||
cursorDY = y - uiStatic.cursorY;
|
||||
cursorDY += y - uiStatic.cursorY;
|
||||
}
|
||||
else
|
||||
cursorDY = 0;
|
||||
|
||||
//Con_Printf("%d %d %f\n",x, y, cursorDY);
|
||||
if( !uiStatic.menuActive )
|
||||
return;
|
||||
|
||||
@ -1593,7 +1592,6 @@ void UI_Init( void )
|
||||
|
||||
CHECK_MAP_LIST( TRUE );
|
||||
|
||||
memset( uiEmptyString, ' ', sizeof( uiEmptyString )); // HACKHACK
|
||||
uiStatic.initialized = true;
|
||||
|
||||
// setup game info
|
||||
|
@ -383,7 +383,6 @@ extern uiStatic_t uiStatic;
|
||||
|
||||
#define DLG_X ((uiStatic.width - 640) / 2 - 192) // Dialogs are 640px in width
|
||||
|
||||
extern char uiEmptyString[256]; // HACKHACK
|
||||
extern const char *uiSoundIn;
|
||||
extern const char *uiSoundOut;
|
||||
extern const char *uiSoundKey;
|
||||
|
@ -178,7 +178,7 @@ static void UI_Controls_ParseKeysList( void )
|
||||
|
||||
sprintf( str, "^6%s^7", token ); // enable uiPromptTextColor
|
||||
StringConcat( uiControls.keysDescription[i], str, strlen( str ) + 1 );
|
||||
StringConcat( uiControls.keysDescription[i], uiEmptyString, 256 ); // empty
|
||||
AddSpaces( uiControls.keysDescription[i], 256 ); // empty
|
||||
uiControls.keysDescriptionPtr[i] = uiControls.keysDescription[i];
|
||||
strcpy( uiControls.keysBind[i], "" );
|
||||
strcpy( uiControls.firstKey[i], "" );
|
||||
@ -205,14 +205,14 @@ static void UI_Controls_ParseKeysList( void )
|
||||
else strncpy( uiControls.secondKey[i], KEY_KeynumToString( keys[1] ), sizeof( uiControls.secondKey[i] ));
|
||||
|
||||
StringConcat( uiControls.keysDescription[i], str, CMD_LENGTH );
|
||||
StringConcat( uiControls.keysDescription[i], uiEmptyString, CMD_LENGTH );
|
||||
AddSpaces( uiControls.keysDescription[i], CMD_LENGTH );
|
||||
|
||||
// HACKHACK this color should be get from kb_keys.lst
|
||||
if( !strnicmp( uiControls.firstKey[i], "MOUSE", 5 ))
|
||||
sprintf( str, "^5%s^7", uiControls.firstKey[i] ); // cyan
|
||||
else sprintf( str, "^3%s^7", uiControls.firstKey[i] ); // yellow
|
||||
StringConcat( uiControls.keysDescription[i], str, KEY1_LENGTH );
|
||||
StringConcat( uiControls.keysDescription[i], uiEmptyString, KEY1_LENGTH );
|
||||
AddSpaces( uiControls.keysDescription[i], KEY1_LENGTH );
|
||||
|
||||
// HACKHACK this color should be get from kb_keys.lst
|
||||
if( !strnicmp( uiControls.secondKey[i], "MOUSE", 5 ))
|
||||
@ -220,7 +220,7 @@ static void UI_Controls_ParseKeysList( void )
|
||||
else sprintf( str, "^3%s^7", uiControls.secondKey[i] ); // yellow
|
||||
|
||||
StringConcat( uiControls.keysDescription[i], str, KEY2_LENGTH );
|
||||
StringConcat( uiControls.keysDescription[i], uiEmptyString, KEY2_LENGTH );
|
||||
AddSpaces( uiControls.keysDescription[i],KEY2_LENGTH );
|
||||
uiControls.keysDescriptionPtr[i] = uiControls.keysDescription[i];
|
||||
i++;
|
||||
}
|
||||
@ -443,11 +443,11 @@ static void UI_Controls_Init( void )
|
||||
uiControls.menu.keyFunc = UI_Controls_KeyFunc;
|
||||
|
||||
StringConcat( uiControls.hintText, "Action", CMD_LENGTH );
|
||||
StringConcat( uiControls.hintText, uiEmptyString, CMD_LENGTH-4 );
|
||||
AddSpaces( uiControls.hintText, CMD_LENGTH-4 );
|
||||
StringConcat( uiControls.hintText, "Key/Button", KEY1_LENGTH );
|
||||
StringConcat( uiControls.hintText, uiEmptyString, KEY1_LENGTH-8 );
|
||||
AddSpaces( uiControls.hintText, KEY1_LENGTH-8 );
|
||||
StringConcat( uiControls.hintText, "Alternate", KEY2_LENGTH );
|
||||
StringConcat( uiControls.hintText, uiEmptyString, KEY2_LENGTH );
|
||||
AddSpaces( uiControls.hintText, KEY2_LENGTH );
|
||||
|
||||
uiControls.background.generic.id = ID_BACKGROUND;
|
||||
uiControls.background.generic.type = QMTYPE_BITMAP;
|
||||
|
@ -206,10 +206,10 @@ static void UI_CreateGame_GetMapsList( void )
|
||||
if( numMaps >= UI_MAXGAMES ) break;
|
||||
StringConcat( uiCreateGame.mapName[numMaps], token, sizeof( uiCreateGame.mapName[0] ));
|
||||
StringConcat( uiCreateGame.mapsDescription[numMaps], token, MAPNAME_LENGTH );
|
||||
StringConcat( uiCreateGame.mapsDescription[numMaps], uiEmptyString, MAPNAME_LENGTH );
|
||||
AddSpaces( uiCreateGame.mapsDescription[numMaps], MAPNAME_LENGTH );
|
||||
if(( pfile = COM_ParseFile( pfile, token )) == NULL ) break; // unexpected end of file
|
||||
StringConcat( uiCreateGame.mapsDescription[numMaps], token, TITLE_LENGTH );
|
||||
StringConcat( uiCreateGame.mapsDescription[numMaps], uiEmptyString, TITLE_LENGTH );
|
||||
AddSpaces( uiCreateGame.mapsDescription[numMaps], TITLE_LENGTH );
|
||||
uiCreateGame.mapsDescriptionPtr[numMaps] = uiCreateGame.mapsDescription[numMaps];
|
||||
numMaps++;
|
||||
}
|
||||
@ -276,9 +276,9 @@ static void UI_CreateGame_Init( void )
|
||||
uiCreateGame.menu.keyFunc = UI_CreateGame_KeyFunc;
|
||||
|
||||
StringConcat( uiCreateGame.hintText, "Map", MAPNAME_LENGTH );
|
||||
StringConcat( uiCreateGame.hintText, uiEmptyString, MAPNAME_LENGTH );
|
||||
AddSpaces( uiCreateGame.hintText, MAPNAME_LENGTH );
|
||||
StringConcat( uiCreateGame.hintText, "Title", TITLE_LENGTH );
|
||||
StringConcat( uiCreateGame.hintText, uiEmptyString, TITLE_LENGTH );
|
||||
AddSpaces( uiCreateGame.hintText, TITLE_LENGTH );
|
||||
|
||||
uiCreateGame.background.generic.id = ID_BACKGROUND;
|
||||
uiCreateGame.background.generic.type = QMTYPE_BITMAP;
|
||||
|
@ -125,20 +125,20 @@ static void UI_InternetGames_GetGamesList( void )
|
||||
if( i >= UI_MAX_SERVERS ) break;
|
||||
info = uiStatic.serverNames[i];
|
||||
StringConcat( uiInternetGames.gameDescription[i], Info_ValueForKey( info, "host" ), GAME_LENGTH );
|
||||
StringConcat( uiInternetGames.gameDescription[i], uiEmptyString, GAME_LENGTH );
|
||||
AddSpaces( uiInternetGames.gameDescription[i], GAME_LENGTH );
|
||||
StringConcat( uiInternetGames.gameDescription[i], Info_ValueForKey( info, "map" ), MAPNAME_LENGTH );
|
||||
StringConcat( uiInternetGames.gameDescription[i], uiEmptyString, MAPNAME_LENGTH );
|
||||
AddSpaces( uiInternetGames.gameDescription[i], MAPNAME_LENGTH );
|
||||
if( !strcmp( Info_ValueForKey( info, "dm" ), "1" ))
|
||||
StringConcat( uiInternetGames.gameDescription[i], "deathmatch", TYPE_LENGTH );
|
||||
else if( !strcmp( Info_ValueForKey( info, "coop" ), "1" ))
|
||||
StringConcat( uiInternetGames.gameDescription[i], "coop", TYPE_LENGTH );
|
||||
else if( !strcmp( Info_ValueForKey( info, "team" ), "1" ))
|
||||
StringConcat( uiInternetGames.gameDescription[i], "teamplay", TYPE_LENGTH );
|
||||
StringConcat( uiInternetGames.gameDescription[i], uiEmptyString, TYPE_LENGTH );
|
||||
AddSpaces( uiInternetGames.gameDescription[i], TYPE_LENGTH );
|
||||
StringConcat( uiInternetGames.gameDescription[i], Info_ValueForKey( info, "numcl" ), MAXCL_LENGTH );
|
||||
StringConcat( uiInternetGames.gameDescription[i], "\\", MAXCL_LENGTH );
|
||||
StringConcat( uiInternetGames.gameDescription[i], Info_ValueForKey( info, "maxcl" ), MAXCL_LENGTH );
|
||||
StringConcat( uiInternetGames.gameDescription[i], uiEmptyString, MAXCL_LENGTH );
|
||||
AddSpaces( uiInternetGames.gameDescription[i], MAXCL_LENGTH );
|
||||
uiInternetGames.gameDescriptionPtr[i] = uiInternetGames.gameDescription[i];
|
||||
}
|
||||
|
||||
@ -268,13 +268,13 @@ static void UI_InternetGames_Init( void )
|
||||
uiInternetGames.menu.keyFunc = UI_InternetGames_KeyFunc;
|
||||
|
||||
StringConcat( uiInternetGames.hintText, "Game", GAME_LENGTH );
|
||||
StringConcat( uiInternetGames.hintText, uiEmptyString, GAME_LENGTH );
|
||||
AddSpaces( uiInternetGames.hintText, GAME_LENGTH );
|
||||
StringConcat( uiInternetGames.hintText, "Map", MAPNAME_LENGTH );
|
||||
StringConcat( uiInternetGames.hintText, uiEmptyString, MAPNAME_LENGTH );
|
||||
AddSpaces( uiInternetGames.hintText, MAPNAME_LENGTH );
|
||||
StringConcat( uiInternetGames.hintText, "Type", TYPE_LENGTH );
|
||||
StringConcat( uiInternetGames.hintText, uiEmptyString, TYPE_LENGTH );
|
||||
AddSpaces( uiInternetGames.hintText, TYPE_LENGTH );
|
||||
StringConcat( uiInternetGames.hintText, "Num/Max Clients", MAXCL_LENGTH );
|
||||
StringConcat( uiInternetGames.hintText, uiEmptyString, MAXCL_LENGTH );
|
||||
AddSpaces( uiInternetGames.hintText, MAXCL_LENGTH );
|
||||
|
||||
uiInternetGames.background.generic.id = ID_BACKGROUND;
|
||||
uiInternetGames.background.generic.type = QMTYPE_BITMAP;
|
||||
|
@ -131,20 +131,21 @@ static void UI_LanGame_GetGamesList( void )
|
||||
continue; // filter by game
|
||||
#endif
|
||||
StringConcat( uiLanGame.gameDescription[i], Info_ValueForKey( info, "host" ), GAME_LENGTH );
|
||||
StringConcat( uiLanGame.gameDescription[i], uiEmptyString, GAME_LENGTH );
|
||||
AddSpaces( uiLanGame.gameDescription[i], GAME_LENGTH );
|
||||
StringConcat( uiLanGame.gameDescription[i], Info_ValueForKey( info, "map" ), MAPNAME_LENGTH );
|
||||
StringConcat( uiLanGame.gameDescription[i], uiEmptyString, MAPNAME_LENGTH );
|
||||
AddSpaces( uiLanGame.gameDescription[i], MAPNAME_LENGTH );
|
||||
|
||||
if( !strcmp( Info_ValueForKey( info, "dm" ), "1" ))
|
||||
StringConcat( uiLanGame.gameDescription[i], "deathmatch", TYPE_LENGTH );
|
||||
else if( !strcmp( Info_ValueForKey( info, "coop" ), "1" ))
|
||||
StringConcat( uiLanGame.gameDescription[i], "coop", TYPE_LENGTH );
|
||||
else if( !strcmp( Info_ValueForKey( info, "team" ), "1" ))
|
||||
StringConcat( uiLanGame.gameDescription[i], "teamplay", TYPE_LENGTH );
|
||||
StringConcat( uiLanGame.gameDescription[i], uiEmptyString, TYPE_LENGTH );
|
||||
AddSpaces( uiLanGame.gameDescription[i], TYPE_LENGTH );
|
||||
StringConcat( uiLanGame.gameDescription[i], Info_ValueForKey( info, "numcl" ), MAXCL_LENGTH );
|
||||
StringConcat( uiLanGame.gameDescription[i], "\\", MAXCL_LENGTH );
|
||||
StringConcat( uiLanGame.gameDescription[i], Info_ValueForKey( info, "maxcl" ), MAXCL_LENGTH );
|
||||
StringConcat( uiLanGame.gameDescription[i], uiEmptyString, MAXCL_LENGTH );
|
||||
AddSpaces( uiLanGame.gameDescription[i], MAXCL_LENGTH );
|
||||
uiLanGame.gameDescriptionPtr[i] = uiLanGame.gameDescription[i];
|
||||
}
|
||||
|
||||
@ -274,13 +275,13 @@ static void UI_LanGame_Init( void )
|
||||
uiLanGame.menu.keyFunc = UI_LanGame_KeyFunc;
|
||||
|
||||
StringConcat( uiLanGame.hintText, "Game", GAME_LENGTH );
|
||||
StringConcat( uiLanGame.hintText, uiEmptyString, GAME_LENGTH );
|
||||
AddSpaces( uiLanGame.hintText, GAME_LENGTH );
|
||||
StringConcat( uiLanGame.hintText, "Map", MAPNAME_LENGTH );
|
||||
StringConcat( uiLanGame.hintText, uiEmptyString, MAPNAME_LENGTH );
|
||||
AddSpaces( uiLanGame.hintText, MAPNAME_LENGTH );
|
||||
StringConcat( uiLanGame.hintText, "Type", TYPE_LENGTH );
|
||||
StringConcat( uiLanGame.hintText, uiEmptyString, TYPE_LENGTH );
|
||||
AddSpaces( uiLanGame.hintText, TYPE_LENGTH );
|
||||
StringConcat( uiLanGame.hintText, "Num/Max Clients", MAXCL_LENGTH );
|
||||
StringConcat( uiLanGame.hintText, uiEmptyString, MAXCL_LENGTH );
|
||||
AddSpaces( uiLanGame.hintText, MAXCL_LENGTH );
|
||||
|
||||
uiLanGame.background.generic.id = ID_BACKGROUND;
|
||||
uiLanGame.background.generic.type = QMTYPE_BITMAP;
|
||||
|
@ -41,7 +41,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
#define ID_MSGBOX 12
|
||||
#define ID_MSGTEXT 13
|
||||
#define ID_NAME 14
|
||||
#define ID_CANCEL 14
|
||||
#define ID_COLOR 15
|
||||
#define ID_PREVIEW 16
|
||||
#define ID_TEXTURE 17
|
||||
@ -52,6 +51,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
#define ID_SP 23
|
||||
#define ID_ADDITIVE 24
|
||||
#define ID_EDITOR 25
|
||||
#define ID_CANCEL 26
|
||||
#define ID_YES 130
|
||||
#define ID_NO 131
|
||||
typedef struct
|
||||
@ -232,6 +232,10 @@ static void UI_TouchButtons_UpdateFields()
|
||||
else
|
||||
uiTouchButtons.textureid = 0;
|
||||
uiTouchButtons.name.buffer[0] = 0;
|
||||
uiTouchButtons.name.cursor = 0;
|
||||
uiTouchButtons.texture.cursor = 0;
|
||||
uiTouchButtons.command.cursor = 0;
|
||||
|
||||
}
|
||||
static void UI_TouchButtons_DisableButtons()
|
||||
{
|
||||
@ -398,6 +402,8 @@ static void UI_TouchButtons_Callback( void *self, int event )
|
||||
CLIENT_COMMAND(0, command);
|
||||
snprintf( command, 256, "touch_setcolor %s %d %d %d %d\n", uiTouchButtons.name.buffer, CURCOLOR1(red), CURCOLOR1(green), CURCOLOR1(blue),CURCOLOR1(alpha) );
|
||||
CLIENT_COMMAND(1, command);
|
||||
uiTouchButtons.name.buffer[0] = 0;
|
||||
uiTouchButtons.name.cursor = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
134
mainui/utils.cpp
134
mainui/utils.cpp
@ -42,6 +42,20 @@ void DBG_AssertFunction( BOOL fExpr, const char* szExpr, const char* szFile, int
|
||||
}
|
||||
#endif // DEBUG
|
||||
|
||||
void AddSpaces(char *s, int size)
|
||||
{
|
||||
int len = strlen(s);
|
||||
|
||||
size += len - ColorStrlen(s);
|
||||
|
||||
while( len < size - 1 )
|
||||
{
|
||||
s[len] = ' ';
|
||||
len++;
|
||||
}
|
||||
s[len] = '\0';
|
||||
}
|
||||
|
||||
int ColorStrlen( const char *str )
|
||||
{
|
||||
const char *p;
|
||||
@ -360,16 +374,19 @@ void UI_ScrollList_Init( menuScrollList_s *sl )
|
||||
UI_ScaleCoords( &sl->generic.x, &sl->generic.y, &sl->generic.width, &sl->generic.height );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
=================
|
||||
UI_ScrollList_Key
|
||||
=================
|
||||
================
|
||||
*/
|
||||
|
||||
const char *UI_ScrollList_Key( menuScrollList_s *sl, int key, int down )
|
||||
{
|
||||
const char *sound = 0;
|
||||
int arrowWidth, arrowHeight, upX, upY, downX, downY;
|
||||
int i, y;
|
||||
bool noscroll = false;
|
||||
|
||||
if( !down )
|
||||
{
|
||||
@ -394,34 +411,44 @@ const char *UI_ScrollList_Key( menuScrollList_s *sl, int key, int down )
|
||||
upY = sl->generic.y2 + UI_OUTLINE_WIDTH;
|
||||
downX = sl->generic.x2 + sl->generic.width2 - arrowWidth;
|
||||
downY = sl->generic.y2 + (sl->generic.height2 - arrowHeight) - UI_OUTLINE_WIDTH;
|
||||
noscroll = true; // don't scroll to current when mouse used
|
||||
|
||||
// ADAMIX
|
||||
if( UI_CursorInRect( sl->scrollBarX, sl->scrollBarY, sl->scrollBarWidth, sl->scrollBarHeight ))
|
||||
if( UI_CursorInRect( upX, upY + arrowHeight, arrowWidth, sl->scrollBarY - upY - arrowHeight ) ||
|
||||
UI_CursorInRect( upX, sl->scrollBarY + sl->scrollBarHeight , arrowWidth, downY - ( sl->scrollBarY + sl->scrollBarHeight ) ) )
|
||||
{
|
||||
sl->scrollBarSliding = true;
|
||||
break;
|
||||
//break;
|
||||
}
|
||||
// ADAMIX END
|
||||
|
||||
// Now see if either up or down has focus
|
||||
if( UI_CursorInRect( upX, upY, arrowWidth, arrowHeight ))
|
||||
{
|
||||
if( sl->curItem != 0 )
|
||||
if( sl->topItem > 5 )
|
||||
{
|
||||
sl->curItem--;
|
||||
sl->topItem-=5;
|
||||
sound = uiSoundMove;
|
||||
}
|
||||
else sound = uiSoundBuzz;
|
||||
else
|
||||
{
|
||||
sl->topItem = 0;
|
||||
sound = uiSoundBuzz;
|
||||
}
|
||||
break;
|
||||
}
|
||||
else if( UI_CursorInRect( downX, downY, arrowWidth, arrowHeight ))
|
||||
{
|
||||
if( sl->curItem != sl->numItems - 1 )
|
||||
if( sl->topItem < sl->numItems - sl->numRows - 5 )
|
||||
{
|
||||
sl->curItem++;
|
||||
sl->topItem+=5;
|
||||
sound = uiSoundMove;
|
||||
}
|
||||
else sound = uiSoundBuzz;
|
||||
else
|
||||
{
|
||||
sl->topItem = sl->numItems - sl->numRows;
|
||||
sound = uiSoundBuzz;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@ -500,11 +527,16 @@ const char *UI_ScrollList_Key( menuScrollList_s *sl, int key, int down )
|
||||
else sound = uiSoundBuzz;
|
||||
break;
|
||||
}
|
||||
|
||||
sl->topItem = sl->curItem - sl->numRows + 1;
|
||||
if( sl->topItem < 0 ) sl->topItem = 0;
|
||||
if( sl->topItem > sl->numItems - sl->numRows )
|
||||
sl->topItem = sl->numItems - sl->numRows;
|
||||
if( !noscroll )
|
||||
{
|
||||
if( sl->curItem < sl->topItem )
|
||||
sl->topItem = sl->curItem;
|
||||
if( sl->curItem > sl->topItem + sl->numRows - 1 )
|
||||
sl->topItem = sl->curItem - sl->numRows + 1;
|
||||
if( sl->topItem < 0 ) sl->topItem = 0;
|
||||
if( sl->topItem > sl->numItems - sl->numRows )
|
||||
sl->topItem = sl->numItems - sl->numRows;
|
||||
}
|
||||
|
||||
if( sound && ( sl->generic.flags & QMF_SILENT ))
|
||||
sound = uiSoundNull;
|
||||
@ -620,49 +652,95 @@ void UI_ScrollList_Draw( menuScrollList_s *sl )
|
||||
downX = sl->generic.x2 + sl->generic.width2 - arrowWidth;
|
||||
downY = sl->generic.y2 + (sl->generic.height2 - arrowHeight) - UI_OUTLINE_WIDTH;
|
||||
|
||||
int step = (sl->numItems <= 1 ) ? 1 : (downY - upY - arrowHeight) / (sl->numItems - 1);
|
||||
|
||||
if( cursorDown && !sl->scrollBarSliding )
|
||||
{
|
||||
if( UI_CursorInRect( sl->generic.x2, sl->generic.y2, sl->generic.width2 - arrowWidth, sl->generic.height2 ))
|
||||
{
|
||||
static float ac_y = 0;
|
||||
ac_y += cursorDY;
|
||||
cursorDY = 0;
|
||||
if( ac_y > sl->generic.charHeight / 2 )
|
||||
{
|
||||
sl->topItem -= ac_y/ sl->generic.charHeight - 0.5;
|
||||
if( sl->topItem < 0 )
|
||||
sl->topItem = 0;
|
||||
ac_y = 0;
|
||||
}
|
||||
if( ac_y < -sl->generic.charHeight / 2 )
|
||||
{
|
||||
sl->topItem -= ac_y/ sl->generic.charHeight - 0.5 ;
|
||||
if( sl->topItem > sl->numItems - sl->numRows )
|
||||
sl->topItem = sl->numItems - sl->numRows;
|
||||
ac_y = 0;
|
||||
}
|
||||
}
|
||||
else if( UI_CursorInRect( sl->scrollBarX, sl->scrollBarY, sl->scrollBarWidth, sl->scrollBarHeight ))
|
||||
{
|
||||
static float ac_y = 0;
|
||||
ac_y += cursorDY;
|
||||
cursorDY = 0;
|
||||
if( ac_y < -step )
|
||||
{
|
||||
sl->topItem += ac_y / step + 0.5;
|
||||
if( sl->topItem < 0 )
|
||||
sl->topItem = 0;
|
||||
ac_y = 0;
|
||||
}
|
||||
if( ac_y > step )
|
||||
{
|
||||
sl->topItem += ac_y / step + 0.5;
|
||||
if( sl->topItem > sl->numItems - sl->numRows )
|
||||
sl->topItem = sl->numItems - sl->numRows;
|
||||
ac_y = 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// draw the arrows base
|
||||
UI_FillRect( upX, upY + arrowHeight, arrowWidth, downY - upY - arrowHeight, uiInputFgColor );
|
||||
|
||||
|
||||
// ADAMIX
|
||||
sl->scrollBarX = upX + sl->generic.charHeight/4;
|
||||
sl->scrollBarWidth = arrowWidth - sl->generic.charHeight/4;
|
||||
|
||||
int step = (sl->numItems <= 1 ) ? 1 : (downY - upY - arrowHeight) / (sl->numItems - 1);
|
||||
|
||||
if(((downY - upY - arrowHeight) - (((sl->numItems-1)*sl->generic.charHeight)/2)) < 2)
|
||||
{
|
||||
sl->scrollBarHeight = (downY - upY - arrowHeight) - (step * (sl->numItems-1));
|
||||
sl->scrollBarY = upY + arrowHeight + (step*sl->curItem);
|
||||
sl->scrollBarHeight = (downY - upY - arrowHeight) - (step * (sl->numItems - sl->numRows));
|
||||
sl->scrollBarY = upY + arrowHeight + (step*sl->topItem);
|
||||
}
|
||||
else
|
||||
{
|
||||
sl->scrollBarHeight = downY - upY - arrowHeight - (((sl->numItems-1) * sl->generic.charHeight) / 2);
|
||||
sl->scrollBarY = upY + arrowHeight + (((sl->curItem) * sl->generic.charHeight)/2);
|
||||
sl->scrollBarHeight = downY - upY - arrowHeight - (((sl->numItems- sl->numRows) * sl->generic.charHeight) / 2);
|
||||
sl->scrollBarY = upY + arrowHeight + (((sl->topItem) * sl->generic.charHeight)/2);
|
||||
}
|
||||
|
||||
if( sl->scrollBarSliding )
|
||||
{
|
||||
int dist = uiStatic.cursorY - sl->scrollBarY - (sl->scrollBarHeight>>2);
|
||||
int dist = uiStatic.cursorY - sl->scrollBarY - (sl->scrollBarHeight>>1);
|
||||
|
||||
if((((dist / 2) > (sl->generic.charHeight / 2)) || ((dist / 2) < (sl->generic.charHeight / 2))) && sl->curItem <= (sl->numItems - 1) && sl->curItem >= 0)
|
||||
if((((dist / 2) > (sl->generic.charHeight / 2)) || ((dist / 2) < (sl->generic.charHeight / 2))) && sl->topItem <= (sl->numItems - sl->numRows - 1) && sl->topItem >= 0)
|
||||
{
|
||||
if(sl->generic.callback)
|
||||
sl->generic.callback( sl, QM_CHANGED );
|
||||
|
||||
if((dist / 2) > ( sl->generic.charHeight / 2 ) && sl->curItem < ( sl->numItems - 1 ))
|
||||
if((dist / 2) > ( sl->generic.charHeight / 2 ) && sl->topItem < ( sl->numItems - sl->numRows - 1 ))
|
||||
{
|
||||
sl->curItem++;
|
||||
sl->topItem++;
|
||||
}
|
||||
|
||||
if((dist / 2) < -(sl->generic.charHeight / 2) && sl->curItem > 0 )
|
||||
if((dist / 2) < -(sl->generic.charHeight / 2) && sl->topItem > 0 )
|
||||
{
|
||||
sl->curItem--;
|
||||
sl->topItem--;
|
||||
}
|
||||
}
|
||||
|
||||
sl->topItem = sl->curItem - sl->numRows + 1;
|
||||
//sl->topItem = sl->curItem - sl->numRows + 1;
|
||||
if( sl->topItem < 0 ) sl->topItem = 0;
|
||||
if( sl->topItem > ( sl->numItems - sl->numRows ))
|
||||
if( sl->topItem > ( sl->numItems - sl->numRows - 1 ))
|
||||
sl->topItem = sl->numItems - sl->numRows;
|
||||
}
|
||||
|
||||
|
@ -109,6 +109,7 @@ inline float RemapVal( float val, float A, float B, float C, float D)
|
||||
return C + (D - C) * (val - A) / (B - A);
|
||||
}
|
||||
|
||||
extern void AddSpaces( char *s, int size );
|
||||
extern int ColorStrlen( const char *str ); // returns string length without color symbols
|
||||
extern const int g_iColorTable[8];
|
||||
extern void COM_FileBase( const char *in, char *out ); // ripped out from hlsdk 2.3
|
||||
|
Loading…
Reference in New Issue
Block a user