예제 #1
0
//==========================================
// BOT_InitPersistant
// Persistant after respawns. To be class definition in the future
//==========================================
static void BOT_InitPersistant( edict_t *self )
{
	float sv_skill;
	//standard stuff
	self->think = NULL;
	self->nextThink = level.time + 1;
	self->ai->type = AI_ISBOT;
	self->classname = "bot";
	self->yaw_speed = AI_DEFAULT_YAW_SPEED;
	self->die = player_die;

	// set skill based on sv_skilllevel cvar
	sv_skill = trap_Cvar_Value( "sv_skilllevel" ); // 0 = easy, 2 = hard
	sv_skill += random(); // so we have a float between 0 and 3 meaning the server skill
	clamp( sv_skill, 0.1f, 3.0f );
	self->ai->pers.skillLevel = sv_skill/3.0f; // the same being a fraction of 1.
	if( self->ai->pers.skillLevel < 0.1f ) self->ai->pers.skillLevel = 0.1f;

	self->yaw_speed -= 20 * ( 1.0f - self->ai->pers.skillLevel );

	if( self->r.client->netname[0] )
		self->ai->pers.netname = self->r.client->netname;
	else
		self->ai->pers.netname = "SomeBot";

	G_Printf( "%s skill %i\n", self->r.client->netname, (int)( self->ai->pers.skillLevel * 100 ) );

	//class: always set up default first
	BOT_DMclass_InitPersistant( self );
}
예제 #2
0
static int MapsList_CreateScrollbox( int parent_width, int yoffset )
{
    int i;
    menucommon_t *menuitem;
    int width, scrollbar_id;
    const int lineheight = trap_SCR_strHeight( uis.fontSystemSmall );

    width = parent_width / 2 - 8;
    mapList_viewable_items = MAPPIC_HEIGHT / lineheight - 1;

    menuitem = UI_InitMenuItem( "m_mapList_scrollbar", NULL, 0, yoffset,
                                MTYPE_SCROLLBAR, ALIGN_RIGHT_TOP,
                                uis.fontSystemSmall, MapsList_UpdateScrollbar );
    menuitem->scrollbar_id = scrollbar_id = s_startserver_menu.nitems;
    Q_strncpyz( menuitem->title, va( "m_mapList_scrollbar%i_curvalue", scrollbar_id ), sizeof( menuitem->title ) );
    UI_SetupScrollbar( menuitem, mapList_viewable_items, trap_Cvar_Value( menuitem->title ), 0, 0 );
    Menu_AddItem( &s_startserver_menu, menuitem );

    for( i = 0; i < mapList_viewable_items; i++ )
    {
        menuitem = UI_InitMenuItem( va( "m_maps_button_%i", i ), "",
                                    -width, yoffset,
                                    MTYPE_ACTION, ALIGN_LEFT_TOP,
                                    uis.fontSystemSmall, MapsList_ChooseMap );
        menuitem->callback_doubleclick = StartServerActionFunc;
        menuitem->ownerdraw = MapsList_UpdateButton;
        menuitem->scrollbar_id = scrollbar_id;
        menuitem->localdata[0] = i;
        menuitem->localdata[1] = i;
        menuitem->width = width;
        menuitem->statusbar = mapList_gamemap_statusbar;

        menuitem->pict.shader = uis.whiteShader;
        menuitem->pict.shaderHigh = uis.whiteShader;

        Vector4Copy( colorWhite, menuitem->pict.colorHigh );
        Vector4Copy( ( i & 1 ) ? colorDkGrey : colorMdGrey, menuitem->pict.color );
        menuitem->pict.color[3] = menuitem->pict.colorHigh[3] = 0.65f;
        menuitem->pict.yoffset = 0;
        menuitem->pict.xoffset = 0;
        menuitem->pict.width = width;
        menuitem->pict.height = lineheight;

        Menu_AddItem( &s_startserver_menu, menuitem );

        yoffset += lineheight;
    }

    yoffset += lineheight;

    return yoffset;
}
예제 #3
0
void Com_DPrintf( const char *format, ... )
{
	va_list	argptr;
	char msg[1024];

	va_start( argptr, format );
	Q_vsnprintfz( msg, sizeof( msg ), format, argptr );
	va_end( argptr );

	if( trap_Cvar_Value("developer") > 0 ) {
		trap_Print( msg );
	}
}
예제 #4
0
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 );
    }
}
예제 #5
0
파일: cg_chat.cpp 프로젝트: Picmip/qfusion
/*
** CG_DrawChat
*/
void CG_DrawChat( cg_gamechat_t *chat, int x, int y, char *fontName, struct qfontface_s *font, int fontSize,
				  int width, int height, int padding_x, int padding_y, vec4_t backColor, struct shader_s *backShader ) {
	int i, j;
	int s, e, w;
	int utf_len;
	int l, total_lines, lines;
	int x_offset, y_offset;
	int font_height;
	int pass;
	int lastcolor;
	int message_mode;
	int wait_time, fade_time;
	const cg_gamemessage_t *msg;
	const char *text;
	char tstr[GAMECHAT_STRING_SIZE];
	vec4_t fontColor;
	bool chat_active = false;
	bool background_drawn = false;
	int corner_radius = 12 * cgs.vidHeight / 600;
	int background_y;
	int first_candidate;

	font_height = trap_SCR_FontHeight( font );
	message_mode = (int)trap_Cvar_Value( "con_messageMode" );
	chat_active = ( chat->lastMsgTime + GAMECHAT_WAIT_IN_TIME + GAMECHAT_FADE_IN_TIME > cg.realTime || message_mode );
	lines = 0;
	total_lines = /*!message_mode ? 0 : */ 1;

	if( chat_active ) {
		wait_time = GAMECHAT_WAIT_IN_TIME;
		fade_time = GAMECHAT_FADE_IN_TIME;
	} else {
		wait_time = GAMECHAT_WAIT_OUT_TIME;
		fade_time = GAMECHAT_FADE_OUT_TIME;
	}

	if( chat_active != chat->lastActive ) {
		// smooth fade ins and fade outs
		chat->lastActiveChangeTime = cg.realTime - ( 1.0 - chat->activeFrac ) * ( wait_time + fade_time );
	}

	if( cg.realTime >= chat->lastActiveChangeTime + wait_time ) {
		int time_diff, time_interval;

		time_diff = cg.realTime - ( chat->lastActiveChangeTime + wait_time );
		time_interval = fade_time;

		if( time_diff <= time_interval ) {
			chat->activeFrac = (float)time_diff / time_interval;
		} else {
			chat->activeFrac = 1;
		}
	} else {
		chat->activeFrac = 0;
	}

	if( chat_active ) {
		backColor[3] *= chat->activeFrac;
	} else {
		backColor[3] *= ( 1.0 - chat->activeFrac );
	}

	for( i = 0; i < GAMECHAT_STACK_SIZE; i++ ) {
		bool old_msg;

		l = chat->nextMsg - 1 - i;
		if( l < 0 ) {
			l = GAMECHAT_STACK_SIZE + l;
		}

		msg = &chat->messages[l];
		text = msg->text;
		old_msg = !message_mode && ( cg.realTime > msg->time + GAMECHAT_NOTIFY_TIME );

		if( !background_drawn && backColor[3] ) {
			if( old_msg ) {
				// keep the box being drawn for a while to prevent it from flickering
				// upon arrival of the possibly entered chat message
				if( !( !chat_active && cg.realTime <= chat->lastActiveChangeTime + 200 ) ) {
					break;
				}
			}

			background_y = y;
			trap_R_DrawStretchPic( x, background_y, width, height - corner_radius,
								   0.0f, 0.0f, 1.0f, 0.5f, backColor, backShader );
			background_y += height - corner_radius;

			if( trap_IN_IME_GetCandidates( NULL, 0, 10, NULL, &first_candidate ) ) {
				int candidates_height = ( first_candidate ? 3 : 5 ) * font_height;
				trap_R_DrawStretchPic( x, background_y, width, candidates_height,
									   0.0f, 0.5f, 1.0f, 0.5f, backColor, backShader );
				background_y += candidates_height;
			}

			trap_R_DrawStretchPic( x, background_y, corner_radius, corner_radius,
								   0.0f, 0.5f, 0.5f, 1.0f, backColor, backShader );
			trap_R_DrawStretchPic( x + corner_radius, background_y, width - corner_radius * 2, corner_radius,
								   0.5f, 0.5f, 0.5f, 1.0f, backColor, backShader );
			trap_R_DrawStretchPic( x + width - corner_radius, background_y, corner_radius, corner_radius,
								   0.5f, 0.5f, 1.0f, 1.0f, backColor, backShader );

			background_drawn = true;
		}

		// unless user is typing something, only display recent messages
		if( old_msg ) {
			break;
		}

		pass = 0;
		lines = 0;
		lastcolor = ColorIndex( COLOR_WHITE );

parse_string:
		l = 1;
		s = e = 0;
		while( 1 ) {
			int len;

			memset( tstr, 0, sizeof( tstr ) );

			// skip whitespaces at start
			for( ; text[s] == '\n' || Q_IsBreakingSpace( text + s ); s = Q_Utf8SyncPos( text, s + 1, UTF8SYNC_RIGHT ) ) ;

			// empty string
			if( !text[s] ) {
				break;
			}

			w = -1;
			len = trap_SCR_StrlenForWidth( text + s, font, width - padding_x * 2 );
			clamp_low( len, 1 );

			for( j = s; ( j < ( s + len ) ) && text[j] != '\0'; j += utf_len ) {
				utf_len = Q_Utf8SyncPos( text + j, 1, UTF8SYNC_RIGHT );
				memcpy( tstr + j - s, text + j, utf_len );

				if( text[j] == '\n' || Q_IsBreakingSpace( text + j ) ) {
					w = j; // last whitespace
				}
				if( text[j] == '\n' ) {
					break;
				}
			}
			e = j; // end

			// try to word avoid splitting words, unless no other options
			if( text[j] != '\0' && w > 0 ) {
				// stop at the last encountered whitespace
				j = w;
			}

			tstr[j - s] = '\0';

			Vector4Copy( color_table[lastcolor], fontColor );
			fontColor[3] = chat_active ? chat->activeFrac : 1.0 - chat->activeFrac;

			if( pass ) {
				// now actually render the line
				x_offset = padding_x;
				y_offset = height - padding_y - font_height - ( total_lines + lines - l ) * ( font_height + 2 );
				if( y_offset < padding_y ) {
					break;
				}

				trap_SCR_DrawClampString( x + x_offset, y + y_offset, tstr,
										  x + padding_x, y + padding_y, x - padding_x + width, y - padding_y + height, font, fontColor );

				l++;
			} else {
				// increase the lines counter
				lines++;
			}

			if( !text[j] ) {
				// fast path: we don't need two passes in case of one-liners..
				if( lines == 1 ) {
					x_offset = padding_x;
					y_offset = height - font_height - total_lines * ( font_height + 2 );
					if( y_offset < padding_y ) {
						break;
					}

					trap_SCR_DrawClampString( x + x_offset, y + y_offset, tstr,
											  x + padding_x, y + padding_y, x - padding_x + width, y - padding_y + height, font, fontColor );

					total_lines++;
					pass++;
				}
				break;
			}

			if( pass ) {
				// grab the last color token to carry it over to the next line
				lastcolor = Q_ColorStrLastColor( lastcolor, tstr, j - s );
			}

			s = j;
		}

		if( !pass ) {
			pass++;
			goto parse_string;
		} else {
			total_lines += lines;
		}
	}

	// let the engine know where the input line should be drawn
	trap_SCR_DrawChat( x + padding_x, y + height - padding_y - font_height, width - padding_x, font );

	chat->lastActive = chat_active;
}
예제 #6
0
파일: ui_tv.c 프로젝트: Racenet/racesow
static void M_TV_Init( void )
{
	int i, yoffset, xoffset, vspacing;
	static char titlename[64];
	menucommon_t *menuitem;
	int scrollwindow_height, scrollwindow_width, scrollbar_id;

	yoffset = 0;
	xoffset = 0;

	s_tv_menu.nitems = 0;

	Q_snprintfz( titlename, sizeof( titlename ), "%s TV", trap_Cvar_String( "gamename" ) );

	menuitem = UI_InitMenuItem( "m_tv_title1", titlename, 0, yoffset, MTYPE_SEPARATOR, ALIGN_CENTER_TOP, uis.fontSystemBig, NULL );
	Menu_AddItem( &s_tv_menu, menuitem );
	yoffset += 2 *trap_SCR_strHeight( menuitem->font );

	// scrollbar
	if( uis.vidWidth < 800 )
		scrollwindow_width = uis.vidWidth * 0.85;
	else
		scrollwindow_width = uis.vidWidth * 0.75;

	xoffset = scrollwindow_width / 2;

	vspacing = trap_SCR_strHeight( uis.fontSystemSmall ) + 4;
	scrollwindow_height = uis.vidHeight - ( yoffset + ( 16 * trap_SCR_strHeight( uis.fontSystemBig ) ) );
	max_menu_channels = scrollwindow_height / vspacing;
	if( max_menu_channels < 5 )
		max_menu_channels = 5;

	menuitem = UI_InitMenuItem( "m_tv_titlerow", NULL, -xoffset, yoffset, MTYPE_SEPARATOR, ALIGN_LEFT_TOP, uis.fontSystemSmall, NULL );
	Q_snprintfz( menuitem->title, MAX_STRING_CHARS, 
			ROW_PATTERN,
			COLUMN_WIDTH_NO, "No", 
			COLUMN_WIDTH_NAME, "", "Server",
			COLUMN_WIDTH_PLAYERS, "", " Pl/Sp",
			COLUMN_WIDTH_GAMETYPE, "", "Gametype",
			COLUMN_WIDTH_MAPNAME, "", "Map",
			COLUMN_WIDTH_MATCHNAME, "", "Match"
	);
	Menu_AddItem( &s_tv_menu, menuitem );
	yoffset += trap_SCR_strHeight( menuitem->font );

	menuitem = UI_InitMenuItem( "m_tv_scrollbar", NULL, xoffset, yoffset, MTYPE_SCROLLBAR, ALIGN_LEFT_TOP, uis.fontSystemSmall, M_TV_UpdateScrollbar );
	menuitem->vspacing = vspacing;
	menuitem->scrollbar_id = scrollbar_id = s_tv_menu.nitems; //give the scrollbar an id to pass onto its list
	Q_strncpyz( menuitem->title, va( "ui_tv_scrollbar%i_curvalue", scrollbar_id ), sizeof( menuitem->title ) );
	if( !trap_Cvar_Value( menuitem->title ) )
		trap_Cvar_SetValue( menuitem->title, 0 );
	UI_SetupScrollbar( menuitem, max_menu_channels, trap_Cvar_Value( menuitem->title ), 0, 0 );
	Menu_AddItem( &s_tv_menu, menuitem );

	for( i = 0; i < max_menu_channels; i++ )
	{
		menuitem = UI_InitMenuItem( va( "m_tv_button_%i", i ), NO_CHANNEL_STRING, -xoffset, yoffset, MTYPE_ACTION,
		                            ALIGN_LEFT_TOP, uis.fontSystemSmall, NULL );
		menuitem->callback_doubleclick = M_TV_JoinChannel;
		menuitem->scrollbar_id = scrollbar_id; //id of the scrollbar so that mwheelup/down can scroll from the list
		menuitem->height = vspacing;
		menuitem->statusbar = "press ENTER to watch";
		menuitem->ownerdraw = M_UpdateChannelButton;
		menuitem->localdata[0] = i; // line in the window
		menuitem->localdata[1] = i; // line in list
		menuitem->width = scrollwindow_width; // adjust strings to this width
		Menu_AddItem( &s_tv_menu, menuitem );

		// create an associated picture to the items to act as window background
		menuitem->pict.shader = uis.whiteShader;
		menuitem->pict.shaderHigh = uis.whiteShader;
		Vector4Copy( colorWhite, menuitem->pict.colorHigh );
		Vector4Copy( ( i & 1 ) ? colorDkGrey : colorMdGrey, menuitem->pict.color );
		menuitem->pict.color[3] = menuitem->pict.colorHigh[3] = 0.65f;
		menuitem->pict.yoffset = 0;
		menuitem->pict.xoffset = 0;
		menuitem->pict.width = scrollwindow_width;
		menuitem->pict.height = vspacing;

		yoffset += vspacing;
	}

	yoffset += 1.5 * trap_SCR_strHeight( menuitem->font );

	menuitem = UI_InitMenuItem( "m_tv_refresh", "refresh", -xoffset, yoffset, MTYPE_ACTION, ALIGN_LEFT_TOP, uis.fontSystemBig, M_TV_RefreshFunc );
	Menu_AddItem( &s_tv_menu, menuitem );
	UI_SetupButton( menuitem, qtrue );

	menuitem = UI_InitMenuItem( "m_tv_disconnect", "watch", xoffset, yoffset, MTYPE_ACTION, ALIGN_RIGHT_TOP, uis.fontSystemBig, M_TV_JoinChannel );
	Menu_AddItem( &s_tv_menu, menuitem );
	UI_SetupButton( menuitem, qtrue );
	xoffset -= ( menuitem->width + 16 );

	menuitem = UI_InitMenuItem( "m_tv_setup", "main menu", xoffset, yoffset, MTYPE_ACTION, ALIGN_RIGHT_TOP, uis.fontSystemBig, M_TV_MenuMainFunc );
	Menu_AddItem( &s_tv_menu, menuitem );
	UI_SetupButton( menuitem, qtrue );
	xoffset -= ( menuitem->width + 16 );

	if( uis.clientState >= CA_ACTIVE )
	{
		menuitem = UI_InitMenuItem( "m_tv_chasecam", "chasecam", xoffset, yoffset, MTYPE_ACTION, ALIGN_RIGHT_TOP, uis.fontSystemBig, M_TV_SpecModeMenuFunc );
		Menu_AddItem( &s_tv_menu, menuitem );
		UI_SetupButton( menuitem, qtrue );
		xoffset -= ( menuitem->width + 16 );
	}

	Menu_Center( &s_tv_menu );
	Menu_Init( &s_tv_menu, qfalse );

	Menu_SetStatusBar( &s_tv_menu, NULL );
}
예제 #7
0
static void Performance_Init( void )
{
    menucommon_t *menuitem;
    int yoffset = 0;

    char custom_resolution[64];
    static char **resolutions;

    static char *colordepth_names[] = { "desktop", "16 bits", "32 bits", 0 };

    static char *plighting_names[] = { "vertex (fast)", "lightmaps (normal)", "per pixel (quality)", "per pixel (no specular)", 0 };

    static char **texfilter_names;
    int anisotropic, spinindex;

#ifndef PREDEFINES_PROFILES
    if( !gfx_profiles )
    {
        int i = 0, num, total, len;
        char *current, buffer[1024];
        total = trap_FS_GetFileList( "profiles", ".cfg", NULL, 0, 0, 0 );

        if( total )
            gfx_profiles = UI_Malloc( sizeof( char * ) * ( total + 1 ) );

        while( i < total )
        {
            if( ( num = trap_FS_GetFileList( "profiles", ".cfg", buffer, sizeof( buffer ), i, total ) ) == 0 )
            {
                i++; // can happen if the filename is too long to fit into the buffer or we're done
                continue;
            }

            // add profiles to profiles list
            for( current = buffer ; num ; i++, num--, current += len )
            {
                len = strlen( current ) + 1;
                if( strncmp( current, "gfx_", 4 ) )
                    continue;

                COM_StripExtension( current );

                gfx_profiles[i] = UI_Malloc( strlen( current + 4 ) + 1 );
                strcpy( gfx_profiles[i], current + 4 );
            }
        }
    }
#endif

    if( !resolutions )
    {   // count video modes
        int i, width, height;
        qboolean wideScreen;

        for( i = 0; trap_VID_GetModeInfo( &width, &height, &wideScreen, i - 1 ); i++ ) ;

        resolutions = (char **)UI_Malloc( sizeof( char * ) * ( i + 1 ) );

        for( i = 0; trap_VID_GetModeInfo( &width, &height, &wideScreen, i - 1 ); i++ )
        {
            Q_snprintfz( custom_resolution, sizeof( custom_resolution ), "%s%s%i x %i", i ? "" : "custom: ", ( wideScreen ? "W " : "" ), width, height );
            resolutions[i] = UI_CopyString( custom_resolution );
        }
        resolutions[i] = NULL;
    }

    if( !texfilter_names )
    {
        int i, count;

        for( count = 0; ; count++ )
        {
            if( trap_Cvar_Value( "gl_ext_texture_filter_anisotropic_max" ) <= (1<<count) )
                break;
        }

        texfilter_names = (char **)UI_Malloc( sizeof( char * ) * ( count + 1 + 1 ) );

        texfilter_names[0] = UI_CopyString( "bilinear" );
        for( i = 0; i < count; i++ )
            texfilter_names[i+1] = UI_CopyString( va( "trilinear %ixAF", (1<<i) ) );
        texfilter_names[i+1] = NULL;
    }

    menuitem = UI_InitMenuItem( "m_performance_title1", "GRAPHICS OPTIONS", 0, yoffset, MTYPE_SEPARATOR, ALIGN_CENTER_TOP, uis.fontSystemBig, NULL );
    Menu_AddItem( &s_performance_menu, menuitem );
    yoffset += trap_SCR_strHeight( menuitem->font );
    yoffset += trap_SCR_strHeight( menuitem->font );

    menuitem = UI_InitMenuItem( "m_performance_profile", "profile", 0, yoffset, MTYPE_SPINCONTROL, ALIGN_RIGHT_TOP, uis.fontSystemSmall, NULL );
    Menu_AddItem( &s_performance_menu, menuitem );
    UI_SetupSpinControl( menuitem, gfx_profiles, trap_Cvar_Value( "ui_gfxprofile" ) );
    yoffset += trap_SCR_strHeight( menuitem->font );
    yoffset += trap_SCR_strHeight( menuitem->font );

    menuitem = UI_InitMenuItem( "m_performance_applyprofile", "apply profile", 0, yoffset, MTYPE_ACTION, ALIGN_CENTER_TOP, uis.fontSystemBig, ApplyProfileButton );
    Menu_AddItem( &s_performance_menu, menuitem );
    yoffset += 1.5 * UI_SetupButton( menuitem, qtrue );

    menuitem = UI_InitMenuItem( "m_performance_resolution", "resolution", 0, yoffset, MTYPE_SPINCONTROL, ALIGN_RIGHT_TOP, uis.fontSystemSmall, NULL );
    Menu_AddItem( &s_performance_menu, menuitem );
    UI_SetupSpinControl( menuitem, resolutions, max( trap_Cvar_Value( "r_mode" ), -1 ) + 1 );
    yoffset += trap_SCR_strHeight( menuitem->font );

    menuitem = UI_InitMenuItem( "m_performance_fullscreen", "fullscreen", 0, yoffset, MTYPE_SPINCONTROL, ALIGN_RIGHT_TOP, uis.fontSystemSmall, NULL );
    Menu_AddItem( &s_performance_menu, menuitem );
    UI_SetupSpinControl( menuitem, noyes_names, trap_Cvar_Value( "vid_fullscreen" ) != 0 );
    yoffset += trap_SCR_strHeight( menuitem->font );

    menuitem = UI_InitMenuItem( "m_performance_swapinterval", "vertical sync", 0, yoffset, MTYPE_SPINCONTROL, ALIGN_RIGHT_TOP, uis.fontSystemSmall, NULL );
    Menu_AddItem( &s_performance_menu, menuitem );
    UI_SetupSpinControl( menuitem, noyes_names, trap_Cvar_Value( "r_swapinterval" ) );
    yoffset += trap_SCR_strHeight( menuitem->font );

    menuitem = UI_InitMenuItem( "m_performance_gamma", "brightness", 0, yoffset, MTYPE_SLIDER, ALIGN_RIGHT_TOP, uis.fontSystemSmall, NULL );
    Menu_AddItem( &s_performance_menu, menuitem );
    UI_SetupSlider( menuitem, 12, bound( (int)( trap_Cvar_Value( "r_gamma" ) * 10.0f ), 5, 13 ), 5, 13 );
    yoffset += trap_SCR_strHeight( menuitem->font );

    menuitem = UI_InitMenuItem( "m_performance_colorbits", "color quality", 0, yoffset, MTYPE_SPINCONTROL, ALIGN_RIGHT_TOP, uis.fontSystemSmall, NULL );
    Menu_AddItem( &s_performance_menu, menuitem );
    if( !Q_stricmp( trap_Cvar_String( "r_colorbits" ), "16" ) )
        UI_SetupSpinControl( menuitem, colordepth_names, 1 );
    else if( !Q_stricmp( trap_Cvar_String( "r_colorbits" ), "32" ) )
        UI_SetupSpinControl( menuitem, colordepth_names, 2 );
    else
        UI_SetupSpinControl( menuitem, colordepth_names, 0 );
    yoffset += trap_SCR_strHeight( menuitem->font );

    menuitem = UI_InitMenuItem( "m_performance_picmip", "texture quality", 0, yoffset, MTYPE_SLIDER, ALIGN_RIGHT_TOP, uis.fontSystemSmall, NULL );
    Menu_AddItem( &s_performance_menu, menuitem );
    UI_SetupSlider( menuitem, 12, 6-trap_Cvar_Value( "r_picmip" ), 0, 6 );
    yoffset += trap_SCR_strHeight( menuitem->font );

    menuitem = UI_InitMenuItem( "m_performance_filter", "texture filter", 0, yoffset, MTYPE_SPINCONTROL, ALIGN_RIGHT_TOP, uis.fontSystemSmall, NULL );
    Menu_AddItem( &s_performance_menu, menuitem );
    anisotropic = trap_Cvar_Value( "r_texturefilter" );
    if( anisotropic >= 2 )
        spinindex = NEARESTEXPOF2( anisotropic ) + 1;
    else if( !Q_stricmp( trap_Cvar_String( "r_texturemode" ), "GL_LINEAR_MIPMAP_NEAREST" ) )
        spinindex = 0;
    else
        spinindex = 1;
    UI_SetupSpinControl( menuitem, texfilter_names, spinindex );
    yoffset += trap_SCR_strHeight( menuitem->font );

    menuitem = UI_InitMenuItem( "m_performance_skymip", "sky quality", 0, yoffset, MTYPE_SLIDER, ALIGN_RIGHT_TOP, uis.fontSystemSmall, NULL );
    Menu_AddItem( &s_performance_menu, menuitem );
    UI_SetupSlider( menuitem, 12, (trap_Cvar_Value( "r_fastsky" ) ? 0 : 4-trap_Cvar_Value( "r_skymip" )), 0, 4 );
    yoffset += trap_SCR_strHeight( menuitem->font );

    menuitem = UI_InitMenuItem( "m_performance_LOD_slider", "geometry level of detail", 0, yoffset, MTYPE_SLIDER, ALIGN_RIGHT_TOP, uis.fontSystemSmall, NULL );
    Menu_AddItem( &s_performance_menu, menuitem );
    UI_SetupSlider( menuitem, 12, 4-max( trap_Cvar_Value( "r_lodbias" ), NEARESTEXPOF2( trap_Cvar_Value( "r_subdivisions" ) ) ), 0, 4 );
    yoffset += trap_SCR_strHeight( menuitem->font );

#if 0
    menuitem = UI_InitMenuItem( "m_performance_glsl", "opengl shaders", 0, yoffset, MTYPE_SPINCONTROL, ALIGN_RIGHT_TOP, uis.fontSystemSmall, NULL );
    Menu_AddItem( &s_performance_menu, menuitem );
    UI_SetupSpinControl( menuitem, offon_names, trap_Cvar_Value( "gl_ext_GLSL" ) );
    yoffset += trap_SCR_strHeight( menuitem->font );
#endif

    if( trap_Cvar_Value( "r_lighting_vertexlight" ) )
        spinindex = 0;
    else if( !trap_Cvar_Value( "r_lighting_deluxemapping" ) )
        spinindex = 1;
    else if( trap_Cvar_Value( "r_lighting_specular" ) )
        spinindex = 2;
    else
        spinindex = 3;

    menuitem = UI_InitMenuItem( "m_performance_pplighting", "lighting", 0, yoffset, MTYPE_SPINCONTROL, ALIGN_RIGHT_TOP, uis.fontSystemSmall, NULL );
    Menu_AddItem( &s_performance_menu, menuitem );
    UI_SetupSpinControl( menuitem, plighting_names, spinindex );
    yoffset += trap_SCR_strHeight( menuitem->font );

    yoffset += trap_SCR_strHeight( menuitem->font );

    menuitem = UI_InitMenuItem( "m_performance_back", "back", -16, yoffset, MTYPE_ACTION, ALIGN_RIGHT_TOP, uis.fontSystemBig, M_genericBackFunc );
    Menu_AddItem( &s_performance_menu, menuitem );
    UI_SetupButton( menuitem, qtrue );
    menuitem = UI_InitMenuItem( "m_performance_apply", "apply", 16, yoffset, MTYPE_ACTION, ALIGN_LEFT_TOP, uis.fontSystemBig, ApplyButton );
    Menu_AddItem( &s_performance_menu, menuitem );
    yoffset += UI_SetupButton( menuitem, qtrue ) + UI_BUTTONBOX_VERTICAL_SPACE;;

    yoffset += trap_SCR_strHeight( uis.fontSystemSmall );

    menuitem = UI_InitMenuItem( "m_performance_advanced", "advanced options", 0, yoffset, MTYPE_ACTION, ALIGN_CENTER_TOP, uis.fontSystemBig, AdvancedButton );
    Menu_AddItem( &s_performance_menu, menuitem );
    UI_SetupButton( menuitem, qtrue );

    Menu_Center( &s_performance_menu );
    Menu_Init( &s_performance_menu, qfalse );
}
예제 #8
0
//=================
//TeamConfig_MenuInit
//=================
static qboolean TeamConfig_MenuInit( void )
{
	menucommon_t *menuitem;
	m_listitem_t *item;
	playermodelinfo_s *playermodel;
	int yoffset = 0;

	static char *team_names[] =
	{
		"PLAYERS",
		"ALPHA",
		"BETA",
		0
	};

	if( playermodelsItemsList.numItems == 0 )
		return qfalse;

	s_team_config_menu.nitems = 0;

	currentTEAM = TEAM_ALPHA;
	UpdateTeamCvars();

	// title
	menuitem = UI_InitMenuItem( "m_TeamConfig_title1", "TEAM ASPECT SETUP", 0, yoffset, MTYPE_SEPARATOR, ALIGN_CENTER_TOP, uis.fontSystemBig, NULL );
	Menu_AddItem( &s_team_config_menu, menuitem );
	yoffset += trap_SCR_strHeight( menuitem->font );

	yoffset += trap_SCR_strHeight( menuitem->font );

	// team
	menuitem = UI_InitMenuItem( "m_TeamConfig_team", "team", 0, yoffset, MTYPE_SPINCONTROL, ALIGN_RIGHT_TOP, uis.fontSystemSmall, ChangeTeamCallback );
	UI_SetupSpinControl( menuitem, team_names, TEAM_ALPHA - TEAM_PLAYERS );
	Menu_AddItem( &s_team_config_menu, menuitem );

	yoffset += trap_SCR_strHeight( menuitem->font );

	// padding
	yoffset += trap_SCR_strHeight( menuitem->font );

	// model
	menuitem = UI_InitMenuItem( "m_TeamConfig_forcemodel", "force a team model", 0, yoffset, MTYPE_SPINCONTROL, ALIGN_RIGHT_TOP, uis.fontSystemSmall, M_TeamConfig_ApplyChanges );
	UI_SetupSpinControl( menuitem, noyes_names, ( model->string[0] != 0 ) );
	Menu_AddItem( &s_team_config_menu, menuitem );
	hasForcedModelMenuItem = menuitem;

	yoffset += trap_SCR_strHeight( menuitem->font );

	menuitem = UI_InitMenuItem( "m_TeamConfig_model", "model", 0, yoffset, MTYPE_SPINCONTROL, ALIGN_RIGHT_TOP, uis.fontSystemSmall, TeamModelCallback );
	UI_SetupSpinControl( menuitem, playermodelsItemsList.item_names, 0 );
	Menu_AddItem( &s_team_config_menu, menuitem );

	yoffset += trap_SCR_strHeight( menuitem->font );

	item = UI_FindItemInScrollListWithId( &playermodelsItemsList, 0 );
	playermodel = (playermodelinfo_s *)item->data;
	menuitem = UI_InitMenuItem( "m_TeamConfig_skin", "skin", 0, yoffset, MTYPE_SPINCONTROL, ALIGN_RIGHT_TOP, uis.fontSystemSmall, M_TeamConfig_ApplyChanges );
	UI_SetupSpinControl( menuitem, playermodel->skinnames, 0 );
	Menu_AddItem( &s_team_config_menu, menuitem );

	yoffset += trap_SCR_strHeight( menuitem->font );

	M_GetTeamModel();

	// padding
	yoffset += trap_SCR_strHeight( menuitem->font );

	// color
	menuitem = UI_InitMenuItem( "m_TeamConfig_forcecolor", "force a team color", 0, yoffset, MTYPE_SPINCONTROL, ALIGN_RIGHT_TOP, uis.fontSystemSmall, ForceAColorCallback );
	UI_SetupSpinControl( menuitem, noyes_names, ( color->string[0] != 0 ) );
	Menu_AddItem( &s_team_config_menu, menuitem );
	hasForcedColorMenuItem = menuitem;

	yoffset += trap_SCR_strHeight( menuitem->font );

	menuitem = UI_InitMenuItem( "m_TeamConfig_colorred", "red", 0, yoffset, MTYPE_SLIDER, ALIGN_RIGHT_TOP, uis.fontSystemSmall, M_TeamConfig_ColorRedCallback );
	Menu_AddItem( &s_team_config_menu, menuitem );
	UI_SetupSlider( menuitem, 12, playerColor[0], 0, 255 );

	yoffset += trap_SCR_strHeight( menuitem->font );

	menuitem = UI_InitMenuItem( "m_TeamConfig_colorgreen", "green", 0, yoffset, MTYPE_SLIDER, ALIGN_RIGHT_TOP, uis.fontSystemSmall, M_TeamConfig_ColorGreenCallback );
	Menu_AddItem( &s_team_config_menu, menuitem );
	UI_SetupSlider( menuitem, 12, playerColor[1], 0, 255 );

	yoffset += trap_SCR_strHeight( menuitem->font );

	menuitem = UI_InitMenuItem( "m_TeamConfig_colorblue", "blue", 0, yoffset, MTYPE_SLIDER, ALIGN_RIGHT_TOP, uis.fontSystemSmall, M_TeamConfig_ColorBlueCallback );
	Menu_AddItem( &s_team_config_menu, menuitem );
	UI_SetupSlider( menuitem, 12, playerColor[2], 0, 255 );

	M_GetTeamColor();

	yoffset += trap_SCR_strHeight( menuitem->font );

	// padding
	yoffset += trap_SCR_strHeight( menuitem->font );

	menuitem = UI_InitMenuItem( "m_TeamConfig_MyTeamAlpha", "switch my team to show as team ALPHA", 60, yoffset, MTYPE_SPINCONTROL, ALIGN_RIGHT_TOP, uis.fontSystemSmall, M_TeamConfig_MyTeamAlpha );
	UI_SetupSpinControl( menuitem, noyes_names, ( trap_Cvar_Value( "cg_forceMyTeamAlpha" ) ) );
	Menu_AddItem( &s_team_config_menu, menuitem );

	yoffset += trap_SCR_strHeight( menuitem->font );

	menuitem = UI_InitMenuItem( "m_TeamConfig_TeamPlayersTeamBeta", "show teamless players as team BETA players", 60, yoffset, MTYPE_SPINCONTROL, ALIGN_RIGHT_TOP, uis.fontSystemSmall, M_TeamConfig_TeamPlayersTeamBeta );
	UI_SetupSpinControl( menuitem, noyes_names, ( trap_Cvar_Value( "cg_forceTeamPlayersTeamBeta" ) ) );
	Menu_AddItem( &s_team_config_menu, menuitem );

	yoffset += trap_SCR_strHeight( menuitem->font );

	// padding
	yoffset += trap_SCR_strHeight( menuitem->font );

	// help
	menuitem = UI_InitMenuItem( "m_TeamConfig_HelpText", "If you want to always force your teammates and your enemies to a specific look,", 10, yoffset, MTYPE_SEPARATOR, ALIGN_CENTER_TOP, uis.fontSystemSmall, NULL );
	Menu_AddItem( &s_team_config_menu, menuitem );
	yoffset += trap_SCR_strHeight( menuitem->font );

	menuitem = UI_InitMenuItem( "m_TeamConfig_HelpText2", "set both of the above options and configure ALPHA and BETA teams", 10, yoffset, MTYPE_SEPARATOR, ALIGN_CENTER_TOP, uis.fontSystemSmall, NULL );
	Menu_AddItem( &s_team_config_menu, menuitem );
	yoffset += trap_SCR_strHeight( menuitem->font );

	// padding
	yoffset += trap_SCR_strHeight( menuitem->font );

	// back
	menuitem = UI_InitMenuItem( "m_TeamConfig_back", "back", 0, yoffset, MTYPE_ACTION, ALIGN_CENTER_TOP, uis.fontSystemBig, M_TeamConfig_SaveAndClose );
	Menu_AddItem( &s_team_config_menu, menuitem );
	UI_SetupButton( menuitem, qtrue );

	Menu_Center( &s_team_config_menu );
	Menu_Init( &s_team_config_menu, qfalse );

	return qtrue;
}
예제 #9
0
static qboolean StartServer_MenuInit( void )
{
    menucommon_t *menuitem_settings_background;
    menucommon_t *menuitem, *col_title;
    static char *skill_names[] = { "easy", "normal", "hard", 0 };
    static char *sortmethod_names[] = { "file name", "title", 0 };
    cvar_t *cvar_lastmap;
    int maxclients;
    int scrollwindow_width, xoffset, yoffset = 0; //leave some room for preview pic

    trap_Cvar_Get( "ui_maplist_sortmethod", "1", CVAR_ARCHIVE );

    // create a list with the installed gametype names
    ui_gametype_names = trap_Cvar_Get( "ui_gametype_names", ";", CVAR_NOSET );
    if( !UI_CreateFileNamesListCvar( ui_gametype_names, "progs/gametypes", ".gt", ';' ) )
        trap_Cvar_ForceSet( "ui_gametype_names", "dm;" );

    if( uis.vidWidth < 800 )
        scrollwindow_width = uis.vidWidth * 0.85;
    else if( uis.vidWidth < 1024 )
        scrollwindow_width = uis.vidWidth * 0.75;
    else
        scrollwindow_width = uis.vidWidth * 0.45;
    xoffset = scrollwindow_width / 2;

    // convert to item names format
    M_StartServer_MakeGametypesNames( ui_gametype_names->string );

    s_startserver_menu.nitems = 0;

    menuitem = UI_InitMenuItem( "m_startserver_title1", "SERVER SETUP", 0, yoffset, MTYPE_SEPARATOR, ALIGN_CENTER_TOP, uis.fontSystemBig, NULL );
    Menu_AddItem( &s_startserver_menu, menuitem );
    yoffset += trap_SCR_strHeight( menuitem->font );

    // separator
    yoffset += trap_SCR_strHeight( menuitem->font );

    menuitem = UI_InitMenuItem( "m_startserver_map", "initial map", 0, yoffset, MTYPE_SEPARATOR, ALIGN_CENTER_TOP, uis.fontSystemMedium, NULL );
    Menu_AddItem( &s_startserver_menu, menuitem );
    yoffset += trap_SCR_strHeight( menuitem->font );

    yoffset += trap_SCR_strHeight( menuitem->font ) * 0.5;

    // order type
    menuitem = col_title = UI_InitMenuItem( "m_startserver_order_title", "order by: ", -xoffset - LCOLUMN_OFFSET / 2, yoffset, MTYPE_SEPARATOR, ALIGN_LEFT_TOP, uis.fontSystemSmall, NULL );
    Menu_AddItem( &s_startserver_menu, menuitem );

    menuitem = UI_InitMenuItem( "m_startserver_order", NULL, col_title->x + trap_SCR_strWidth( col_title->title, uis.fontSystemSmall, 0 ),
                                yoffset, MTYPE_SPINCONTROL, ALIGN_LEFT_TOP, uis.fontSystemSmall, StartServer_UpdateOrderMethod );
    UI_SetupSpinControl( menuitem, sortmethod_names, trap_Cvar_Value( "ui_maplist_sortmethod" ) );
    Menu_AddItem( &s_startserver_menu, menuitem );

    menuitem = UI_InitMenuItem( "m_startserver_mappic", NULL, xoffset - MAPPIC_WIDTH - 8, yoffset, MTYPE_SEPARATOR, ALIGN_CENTER_TOP, uis.fontSystemSmall, NULL );
    Menu_AddItem( &s_startserver_menu, menuitem );

    cvar_lastmap = trap_Cvar_Get( "ui_startserver_lastselectedmap", "", CVAR_NOSET );
    MapsList_CreateItems( cvar_lastmap->string );
    MapsList_ChooseMap( NULL );

    yoffset += trap_SCR_strHeight( menuitem->font );
    yoffset = MapsList_CreateScrollbox( scrollwindow_width, yoffset );

    yoffset += trap_SCR_strHeight( menuitem->font ) * 0.5;

    menuitem_settings_background = UI_InitMenuItem( "m_startserver_settings_back", "", -xoffset, yoffset, MTYPE_SEPARATOR, ALIGN_LEFT_TOP, uis.fontSystemSmall, NULL );
    Menu_AddItem( &s_startserver_menu, menuitem_settings_background );
    // create an associated picture to the items to act as window background
    menuitem = menuitem_settings_background;
    menuitem->ownerdraw = M_StartServer_DrawSettingsBox;
    menuitem->pict.shader = uis.whiteShader;
    menuitem->pict.shaderHigh = NULL;
    Vector4Copy( colorMdGrey, menuitem->pict.color );
    menuitem->pict.color[3] = 0;
    menuitem->pict.yoffset = 0;
    menuitem->pict.xoffset = 0;
    menuitem->pict.width = scrollwindow_width;
    menuitem->pict.height = yoffset + menuitem->pict.yoffset; // will be set later

    yoffset += trap_SCR_strHeight( menuitem->font );

    // g_gametype
    m_gametype = mapList_suggested_gametype ? mapList_suggested_gametype : SuggestGameType( NULL );
    menuitem = m_gametypes_item = UI_InitMenuItem( "m_startserver_gametype", "gametype", -130, yoffset, MTYPE_SPINCONTROL, ALIGN_RIGHT_TOP, uis.fontSystemSmall, M_GametypeFunc );
    menuitem->statusbar = "select the server gametype";
    UI_SetupSpinControl( menuitem, startserver_gametype_names, m_gametype );
    Menu_AddItem( &s_startserver_menu, menuitem );
    //yoffset += trap_SCR_strHeight( menuitem->font );

    // g_timelimit
    menuitem = UI_InitMenuItem( "m_startserver_timelimit", "time limit", 100, yoffset, MTYPE_FIELD, ALIGN_RIGHT_TOP, uis.fontSystemSmall, NULL );
    menuitem->statusbar = "0 = no limit";
    UI_SetupField( menuitem, trap_Cvar_String( "g_timelimit" ), 6, -1 );
    UI_SetupFlags( menuitem, F_NUMBERSONLY );
    Menu_AddItem( &s_startserver_menu, menuitem );
    yoffset += trap_SCR_strHeight( menuitem->font );

    // sv_skilllevel
    menuitem = UI_InitMenuItem( "m_startserver_skill", "skill level", -130, yoffset, MTYPE_SPINCONTROL, ALIGN_RIGHT_TOP, uis.fontSystemSmall, M_SkillLevelFunc );
    m_skill = trap_Cvar_Value( "sv_skilllevel" );
    menuitem->statusbar = "select server skill level";
    UI_SetupSpinControl( menuitem, skill_names, m_skill );
    Menu_AddItem( &s_startserver_menu, menuitem );
    //yoffset += trap_SCR_strHeight( menuitem->font );

    // g_scorelimit
    menuitem = UI_InitMenuItem( "m_startserver_scorelimit", "score limit", 100, yoffset, MTYPE_FIELD, ALIGN_RIGHT_TOP, uis.fontSystemSmall, NULL );
    menuitem->statusbar = "0 = no limit";
    UI_SetupField( menuitem, trap_Cvar_String( "g_scorelimit" ), 6, -1 );
    UI_SetupFlags( menuitem, F_NUMBERSONLY );
    Menu_AddItem( &s_startserver_menu, menuitem );
    yoffset += trap_SCR_strHeight( menuitem->font );

    // sv_cheats
    menuitem = UI_InitMenuItem( "m_startserver_cheats", "cheats", -130, yoffset, MTYPE_SPINCONTROL, ALIGN_RIGHT_TOP, uis.fontSystemSmall, M_CheatsFunc );
    m_cheats = trap_Cvar_Value( "sv_cheats" );
    menuitem->statusbar = "enable cheats on the server";
    UI_SetupSpinControl( menuitem, offon_names, m_cheats );
    Menu_AddItem( &s_startserver_menu, menuitem );
    //yoffset += trap_SCR_strHeight( menuitem->font );

    // g_numbots
    menuitem = UI_InitMenuItem( "m_startserver_numbots", "number of bots", 100, yoffset, MTYPE_FIELD, ALIGN_RIGHT_TOP, uis.fontSystemSmall, NULL );
    menuitem->statusbar = "Can't be more than maxclients";
    UI_SetupField( menuitem, trap_Cvar_String( "g_numbots" ), 6, -1 );
    UI_SetupFlags( menuitem, F_NUMBERSONLY );
    Menu_AddItem( &s_startserver_menu, menuitem );
    yoffset += trap_SCR_strHeight( menuitem->font );

    // g_instagib
    menuitem = UI_InitMenuItem( "m_startserver_instagib", "instagib", -130, yoffset, MTYPE_SPINCONTROL, ALIGN_RIGHT_TOP, uis.fontSystemSmall, M_InstagibFunc );
    m_instagib = trap_Cvar_Value( "g_instagib" );
    menuitem->statusbar = "enable instagib mode";
    UI_SetupSpinControl( menuitem, offon_names, m_instagib );
    Menu_AddItem( &s_startserver_menu, menuitem );
    //yoffset += trap_SCR_strHeight( menuitem->font );

    // sv_maxclients
    /*
    ** maxclients determines the maximum number of players that can join
    ** the game.  If maxclients is only "1" then we should default the menu
    ** option to 8 players, otherwise use whatever its current value is.
    */
    maxclients = trap_Cvar_Value( "sv_maxclients" ) <= 1 ? 8 : trap_Cvar_Value( "sv_maxclients" );
    menuitem = UI_InitMenuItem( "m_startserver_maxplayers", "max players", 100, yoffset, MTYPE_FIELD, ALIGN_RIGHT_TOP, uis.fontSystemSmall, NULL );
    UI_SetupField( menuitem, va( "%i", maxclients ), 6, -1 );
    UI_SetupFlags( menuitem, F_NUMBERSONLY );
    Menu_AddItem( &s_startserver_menu, menuitem );
    yoffset += trap_SCR_strHeight( menuitem->font );

    // sv_public
    menuitem = UI_InitMenuItem( "m_startserver_public", "public", -130, yoffset, MTYPE_SPINCONTROL, ALIGN_RIGHT_TOP, uis.fontSystemSmall, M_PublicFunc );
    m_public = trap_Cvar_Value( "sv_public" );
    menuitem->statusbar = "announce this server to metaservers";
    UI_SetupSpinControl( menuitem, offon_names, m_public );
    Menu_AddItem( &s_startserver_menu, menuitem );
    //yoffset += trap_SCR_strHeight( menuitem->font );

    // sv_hostname
    menuitem = UI_InitMenuItem( "m_startserver_hostname", "server name", 100, yoffset, MTYPE_FIELD, ALIGN_RIGHT_TOP, uis.fontSystemSmall, NULL );
    UI_SetupField( menuitem, trap_Cvar_String( "sv_hostname" ), 14, -1 );
    Menu_AddItem( &s_startserver_menu, menuitem );
    yoffset += trap_SCR_strHeight( menuitem->font );

    yoffset += trap_SCR_strHeight( menuitem->font ) * 0.5;

    // here ends the settings background, set it's image height now
    menuitem_settings_background->pict.height = yoffset - menuitem_settings_background->pict.height + ( 0.5 * trap_SCR_strHeight( menuitem->font ) );

    yoffset += trap_SCR_strHeight( menuitem->font );

    // begin button
    menuitem = UI_InitMenuItem( "m_startserver_begin", "begin", 16, yoffset, MTYPE_ACTION, ALIGN_LEFT_TOP, uis.fontSystemBig, StartServerActionFunc );
    Menu_AddItem( &s_startserver_menu, menuitem );
    UI_SetupButton( menuitem, qtrue );

    menuitem = UI_InitMenuItem( "m_startserver_back", "back", -16, yoffset, MTYPE_ACTION, ALIGN_RIGHT_TOP, uis.fontSystemBig, M_genericBackFunc );
    Menu_AddItem( &s_startserver_menu, menuitem );
    yoffset += UI_SetupButton( menuitem, qtrue ) + UI_BUTTONBOX_VERTICAL_SPACE;

    Menu_Center( &s_startserver_menu );
    s_startserver_menu.x = ( uis.vidWidth / 2 );
    Menu_Init( &s_startserver_menu, qfalse );
    return qtrue;
}
예제 #10
0
static void MapsList_CreateItems( const char *lastmap )
{
    int i, j, validmaps;
    int order;
    maplist_item_t *items;
    char mapinfo[MAX_CONFIGSTRING_CHARS], *mapname, *fullname;

    UI_FreeScrollItemList( &mapList );

    for( validmaps = 0; trap_ML_GetMapByNum( validmaps, NULL, 0 ); validmaps++ )
        ;

    if( !validmaps )
    {
        Menu_SetStatusBar( &s_startserver_menu, "No maps found" );
        return;
    }

    order = trap_Cvar_Value( "ui_maplist_sortmethod" );
    items = UI_Malloc( sizeof( *items ) * validmaps );
    for( i = 0; i < validmaps; i++ )
    {
        trap_ML_GetMapByNum( i, mapinfo, sizeof( mapinfo ) );

        mapname = mapinfo;
        fullname = mapinfo + strlen( mapname ) + 1;

        if( order )
            items[i].name = UI_CopyString( *fullname ? fullname : mapname );
        else
            items[i].name = UI_CopyString( mapname );
        items[i].mapname = UI_CopyString( mapname );
        items[i].index = i;

        // uppercase the first letter and letters that follow whitespaces
        if( order )
        {
            if( *fullname )
            {
                items[i].name[0] = toupper( items[i].name[0] );
                for( j = 1; items[i].name[j]; j++ )
                    if( items[i].name[j-1] == ' ' )
                        items[i].name[j] = toupper( items[i].name[j] );
            }
            else
            {
                Q_strlwr( items[i].name );
            }
        }
        else
        {
            Q_strlwr( items[i].name );
        }
    }

    qsort( items, validmaps, sizeof( *items ), ( int ( * )( const void *, const void * ) )MapList_MapSort );

    for( i = 0; i < validmaps; i++ )
    {
        if( !strcmp( items[i].mapname, lastmap ) )
            mapList_cur_idx = i;

        UI_AddItemToScrollList( &mapList, items[i].name, (void *)((size_t)(items[i].index)) );
        UI_Free( items[i].mapname );
        UI_Free( items[i].name );
    }

    UI_Free( items );
}