static void MapsList_ChooseMap( menucommon_t *menuitem ) { char path[MAX_CONFIGSTRING_CHARS + 6]; // wsw: Medar: could do this in not so ugly way m_listitem_t *item; menucommon_t *mapitem; char mapinfo[MAX_CONFIGSTRING_CHARS]; const char *mapname, *fullname; int id = ( menuitem ? menuitem->localdata[1] : mapList_cur_idx ); mapitem = UI_MenuItemByName( "m_startserver_map" ); if( mapitem ) Q_strncpyz( mapitem->title, "initial map", sizeof( mapitem->title ) ); mapList_suggested_gametype = 0; item = UI_FindItemInScrollListWithId( &mapList, id ); if( item && item->name ) { if( !trap_ML_GetMapByNum( (int)((size_t)item->data), mapinfo, sizeof( mapinfo ) ) ) return; mapname = mapinfo; fullname = mapinfo + strlen( mapname ) + 1; if( menuitem ) { mapList_cur_idx = id; trap_Cvar_ForceSet( "ui_startserver_lastselectedmap", "" ); } if( mapitem ) { Q_strncatz( mapitem->title, ": " S_COLOR_WHITE, sizeof( mapitem->title ) ); if( !trap_Cvar_Value( "ui_maplist_sortmethod" ) ) Q_strncatz( mapitem->title, mapname, sizeof( mapitem->title ) ); else Q_strncatz( mapitem->title, *fullname ? fullname : mapname, sizeof( mapitem->title ) ); } #ifdef SUGGEST_MAP_GAMETYPE mapList_suggested_gametype = SuggestGameType( mapname ); // if( m_gametypes_item ) // { // m_gametypes_item->curvalue = mapList_suggested_gametype; // M_GametypeFunc( m_gametypes_item ); // } #endif Q_snprintfz( path, sizeof( path ), "levelshots/%s.jpg", mapname ); s_levelshot = trap_R_RegisterLevelshot( path, trap_R_RegisterPic( PATH_UKNOWN_MAP_PIC ), NULL ); } }
/* * UI_DrawConnectScreen */ void UI_DrawConnectScreen( const char *serverName, const char *rejectmessage, int downloadType, const char *downloadFilename, float downloadPercent, int downloadSpeed, int connectCount, qboolean demoplaying, qboolean backGround ) { qboolean localhost, design = qfalse; char str[MAX_QPATH]; int x, y, xoffset, yoffset, width, height; unsigned int maxwidth; qboolean downloadFromWeb; char hostName[MAX_CONFIGSTRING_CHARS], mapname[MAX_CONFIGSTRING_CHARS], mapmessage[MAX_CONFIGSTRING_CHARS], gametype[MAX_CONFIGSTRING_CHARS], gametypeTitle[MAX_CONFIGSTRING_CHARS], gametypeVersion[MAX_CONFIGSTRING_CHARS], gametypeAuthor[MAX_CONFIGSTRING_CHARS], matchName[MAX_CONFIGSTRING_CHARS]; uis.demoplaying = demoplaying; //trap_S_StopBackgroundTrack(); localhost = (qboolean)( !serverName || !serverName[0] || !Q_stricmp( serverName, "localhost" ) ); trap_GetConfigString( CS_MAPNAME, mapname, sizeof( mapname ) ); trap_GetConfigString( CS_MESSAGE, mapmessage, sizeof( mapmessage ) ); if( backGround ) { Q_snprintfz( str, sizeof( str ), UI_SHADER_BACKGROUND, uis.backgroundNum ); trap_R_DrawStretchPic( 0, 0, uis.vidWidth, uis.vidHeight, 0, 0, 1, 1, colorWhite, trap_R_RegisterPic( str ) ); } // // not yet connected // x = 64; y = 64; xoffset = yoffset = 0; if( demoplaying ) Q_snprintfz( str, sizeof( str ), "Loading demo: %s", serverName ); else if( localhost ) Q_strncpyz( str, "Loading...", sizeof( str ) ); else if( mapname[0] ) Q_snprintfz( str, sizeof( str ), "Connecting to %s", serverName ); else Q_snprintfz( str, sizeof( str ), "Awaiting connection... %i", connectCount ); trap_SCR_DrawString( x + xoffset, y + yoffset, ALIGN_LEFT_TOP, str, uis.fontSystemBig, colorWhite ); yoffset += trap_SCR_strHeight( uis.fontSystemBig ); if( design && !rejectmessage ) rejectmessage = "Connection was interrupted because the weather sux :P"; if( rejectmessage ) { x = uis.vidWidth / 2; y = uis.vidHeight / 3; height = trap_SCR_strHeight( uis.fontSystemMedium ) * 4; Q_strncpyz( str, "Refused: ", sizeof( str ) ); width = max( trap_SCR_strWidth( str, uis.fontSystemMedium, 0 ), trap_SCR_strWidth( rejectmessage, uis.fontSystemSmall, 0 ) ); width += 32 * 2; xoffset = UISCR_HorizontalAlignOffset( ALIGN_CENTER_MIDDLE, width ); yoffset = UISCR_VerticalAlignOffset( ALIGN_CENTER_MIDDLE, height ); UI_DrawBox( x + xoffset, y + yoffset, width, height, colorWarsowOrange, colorWhite, NULL, colorDkGrey ); yoffset += trap_SCR_strHeight( uis.fontSystemMedium ); xoffset += 32; trap_SCR_DrawString( x + xoffset, y + yoffset, ALIGN_LEFT_TOP, str, uis.fontSystemMedium, colorWhite ); yoffset += trap_SCR_strHeight( uis.fontSystemMedium ); trap_SCR_DrawString( x + xoffset, y + yoffset, ALIGN_LEFT_TOP, rejectmessage, uis.fontSystemSmall, colorBlack ); return; } if( mapname[0] ) { char levelshot[MAX_QPATH]; struct shader_s *levelshotShader; qboolean isDefaultlevelshot = qtrue; // // connected // x = 64; y = uis.vidHeight - 300; xoffset = yoffset = 0; width = uis.vidWidth; height = 200; UI_DrawBox( x + xoffset, y + yoffset, width, height, colorWarsowPurple, colorWhite, NULL, colorDkGrey ); xoffset += 16; yoffset += 16 + 4; maxwidth = uis.vidWidth - ( x + xoffset ); trap_GetConfigString( CS_HOSTNAME, hostName, sizeof( hostName ) ); trap_GetConfigString( CS_GAMETYPENAME, gametype, sizeof( gametype ) ); trap_GetConfigString( CS_GAMETYPETITLE, gametypeTitle, sizeof( gametypeTitle ) ); trap_GetConfigString( CS_GAMETYPEVERSION, gametypeVersion, sizeof( gametypeVersion ) ); trap_GetConfigString( CS_GAMETYPEAUTHOR, gametypeAuthor, sizeof( gametypeAuthor ) ); trap_GetConfigString( CS_MATCHNAME, matchName, sizeof( matchName ) ); Q_snprintfz( levelshot, sizeof( levelshot ), "levelshots/%s.jpg", mapname ); levelshotShader = trap_R_RegisterLevelshot( levelshot, uis.whiteShader, &isDefaultlevelshot ); if( !isDefaultlevelshot ) { int lw, lh, lx, ly; lh = height - 8; lw = lh * ( 4.0f/3.0f ); lx = uis.vidWidth - lw; ly = y + 4; trap_R_DrawStretchPic( lx, ly, lw, lh, 0, 0, 1, 1, colorWhite, levelshotShader ); } if( !localhost && !demoplaying ) { Q_snprintfz( str, sizeof( str ), "Server: %s", hostName ); trap_SCR_DrawStringWidth( x + xoffset, y + yoffset, ALIGN_LEFT_TOP, str, maxwidth, uis.fontSystemSmall, colorWhite ); yoffset += trap_SCR_strHeight( uis.fontSystemSmall ) + 8; } if( mapmessage[0] && Q_stricmp( mapname, mapmessage ) ) { Q_snprintfz( str, sizeof( str ), "Level: "S_COLOR_ORANGE"%s", COM_RemoveColorTokens( mapmessage ) ); trap_SCR_DrawStringWidth( x + xoffset, y + yoffset, ALIGN_LEFT_TOP, str, maxwidth, uis.fontSystemSmall, colorWhite ); yoffset += trap_SCR_strHeight( uis.fontSystemSmall ) + 8; } Q_snprintfz( str, sizeof( str ), "Map: %s", mapname ); trap_SCR_DrawStringWidth( x + xoffset, y + yoffset, ALIGN_LEFT_TOP, str, maxwidth, uis.fontSystemSmall, colorWhite ); yoffset += trap_SCR_strHeight( uis.fontSystemSmall ) + 8; if( matchName[0] ) { Q_snprintfz( str, sizeof( str ), "Match: %s", matchName ); trap_SCR_DrawStringWidth( x + xoffset, y + yoffset, ALIGN_LEFT_TOP, str, maxwidth, uis.fontSystemSmall, colorWhite ); yoffset += trap_SCR_strHeight( uis.fontSystemSmall ) + 8; } yoffset += trap_SCR_strHeight( uis.fontSystemSmall ) + 8; Q_snprintfz( str, sizeof( str ), "Gametype: "S_COLOR_ORANGE"%s", COM_RemoveColorTokens( gametypeTitle ) ); trap_SCR_DrawStringWidth( x + xoffset, y + yoffset, ALIGN_LEFT_TOP, str, maxwidth, uis.fontSystemSmall, colorWhite ); yoffset += trap_SCR_strHeight( uis.fontSystemSmall ) + 8; Q_snprintfz( str, sizeof( str ), "Version: %s", COM_RemoveColorTokens( gametypeVersion ) ); trap_SCR_DrawStringWidth( x + xoffset, y + yoffset, ALIGN_LEFT_TOP, str, maxwidth, uis.fontSystemSmall, colorWhite ); yoffset += trap_SCR_strHeight( uis.fontSystemSmall ) + 8; Q_snprintfz( str, sizeof( str ), "Author: %s", gametypeAuthor ); trap_SCR_DrawStringWidth( x + xoffset, y + yoffset, ALIGN_LEFT_TOP, str, maxwidth, uis.fontSystemSmall, colorWhite ); yoffset += trap_SCR_strHeight( uis.fontSystemSmall ) + 8; } // downloading if( design && !downloadFilename ) { downloadFilename = "http://www.warsow.net/autoupdate/basewsw/map_wdm9a.pk3"; downloadType = 2; downloadPercent = 65.8; downloadSpeed = 325; } if( downloadType && downloadFilename ) { size_t len; const char *s; downloadFromWeb = ( downloadType == 2 ); x = uis.vidWidth / 2; y = uis.vidHeight / 3; width = 400; height = 128 - trap_SCR_strHeight( uis.fontSystemSmall ); if( uis.vidWidth <= width ) width = uis.vidWidth - 64; maxwidth = width - 48; xoffset = UISCR_HorizontalAlignOffset( ALIGN_CENTER_MIDDLE, width ); yoffset = UISCR_VerticalAlignOffset( ALIGN_CENTER_MIDDLE, height ); // adjust the box size for the extra number of lines needed to draw the file path s = downloadFilename; while( ( len = trap_SCR_StrlenForWidth( s, uis.fontSystemSmall, maxwidth ) ) > 0 ) { s += len; height += trap_SCR_strHeight( uis.fontSystemSmall ); } UI_DrawBox( x + xoffset, y + yoffset, width, height, colorWarsowPurple, colorWhite, NULL, colorDkGrey ); xoffset += 24; yoffset += 24; trap_SCR_DrawStringWidth( x + xoffset, y + yoffset, ALIGN_LEFT_TOP, downloadFromWeb ? "Downloading from web" : "Downloading from server", maxwidth, uis.fontSystemSmall, colorWhite ); yoffset += trap_SCR_strHeight( uis.fontSystemSmall ); s = downloadFilename; while( ( len = trap_SCR_DrawStringWidth( x + xoffset, y + yoffset, ALIGN_LEFT_TOP, s, maxwidth, uis.fontSystemSmall, colorWhite ) ) > 0 ) { s += len; yoffset += trap_SCR_strHeight( uis.fontSystemSmall ); } yoffset += 16; UI_DrawPicBar( x + xoffset, y + yoffset, maxwidth, 24, ALIGN_LEFT_TOP, downloadPercent, trap_R_RegisterPic( "gfx/ui/progressbar" ),colorDkGrey, colorOrange ); Q_snprintfz( str, sizeof( str ), "%3.1f%c", downloadPercent, '%' ); trap_SCR_DrawStringWidth( x + xoffset + 12, y + yoffset + 12, ALIGN_LEFT_MIDDLE, str, maxwidth, uis.fontSystemSmall, colorWhite ); Q_snprintfz( str, sizeof( str ), "%ik/s", downloadSpeed ); trap_SCR_DrawStringWidth( x + xoffset + maxwidth - 12, y + yoffset + 12, ALIGN_RIGHT_MIDDLE, str, maxwidth, uis.fontSystemSmall, colorWhite ); yoffset += 24 + 8; } }