Example #1
0
/*
================
Con_DrawInput

Draw the editline after a ] prompt
================
*/
void Con_DrawInput( void )
{
	int     y;
	char    prompt[ MAX_STRING_CHARS ];
	vec4_t  color;
	qtime_t realtime;

	if ( cls.state != CA_DISCONNECTED && !( cls.keyCatchers & KEYCATCH_CONSOLE ) )
	{
		return;
	}

	Com_RealTime( &realtime );

	y = con.vislines - ( SCR_ConsoleFontCharHeight() * 2 ) + 2;

	Com_sprintf( prompt,  sizeof( prompt ), "^0[^3%02d%c%02d^0]^7 %s", realtime.tm_hour, ( realtime.tm_sec & 1 ) ? ':' : ' ', realtime.tm_min, cl_consolePrompt->string );

	color[ 0 ] = 1.0f;
	color[ 1 ] = 1.0f;
	color[ 2 ] = 1.0f;
	color[ 3 ] = ( scr_conUseOld->integer ? 1.0f : con.displayFrac * 2.0f );

	SCR_DrawSmallStringExt( con.xadjust + cl_conXOffset->integer, y + 10, prompt, color, qfalse, qfalse );

	Q_CleanStr( prompt );
	Field_Draw( &g_consoleField, con.xadjust + cl_conXOffset->integer + SCR_ConsoleFontStringWidth( prompt, strlen( prompt ) ), y + 10, qtrue, qtrue, color[ 3 ] );
}
/*
================
Con_DrawInput

Draw the editline after a ] prompt
================
*/
void Con_DrawInput (void) {
	int		y;

	if ( cls.state != CA_DISCONNECTED && !(Key_GetCatcher( ) & KEYCATCH_CONSOLE ) ) {
		return;
	}

	y = con.vislines - ( SMALLCHAR_HEIGHT * (re->Language_IsAsian() ? 1.5 : 2) );

	re->SetColor( con.color );

	SCR_DrawSmallChar( (int)(con.xadjust + 1 * SMALLCHAR_WIDTH), y, CONSOLE_PROMPT_CHAR );

	Field_Draw( &g_consoleField, (int)(con.xadjust + 2 * SMALLCHAR_WIDTH), y,
				SCREEN_WIDTH - 3 * SMALLCHAR_WIDTH, qtrue, qtrue );
}
Example #3
0
/*
================
Con_DrawInput

Draw the editline after a ] prompt
================
*/
void Con_DrawInput( int linePosition, float overrideAlpha )
{
	char    prompt[ MAX_STRING_CHARS ];
	vec4_t  color;
	qtime_t realtime;

	Com_RealTime( &realtime );
	Com_sprintf( prompt,  sizeof( prompt ), "^0[^3%02d%c%02d^0]^7 %s", realtime.tm_hour, ( realtime.tm_sec & 1 ) ? ':' : ' ', realtime.tm_min, con_prompt->string );

	color[ 0 ] = 1.0f;
	color[ 1 ] = 1.0f;
	color[ 2 ] = 1.0f;
	color[ 3 ] = consoleState.currentAlphaFactor * overrideAlpha;

	SCR_DrawSmallStringExt( consoleState.margin.sides + consoleState.padding.sides, linePosition, prompt, color, qfalse, qfalse );

	Q_CleanStr( prompt );
	Field_Draw( g_consoleField, consoleState.margin.sides + consoleState.padding.sides + SCR_ConsoleFontStringWidth( prompt, strlen( prompt ) ), linePosition, qtrue, qtrue, color[ 3 ] );
}
Example #4
0
File: qmenu.c Project: ZwS/qudos
void
Menu_Draw(menuframework_s * menu)
{
	int		i;
	menucommon_s   *item;

	/*
	 * * draw contents
	 */
	for (i = 0; i < menu->nitems; i++) {
		switch (((menucommon_s *) menu->items[i])->type) {
		case MTYPE_FIELD:
			Field_Draw((menufield_s *) menu->items[i]);
			break;
		case MTYPE_SLIDER:
			Slider_Draw((menuslider_s *) menu->items[i]);
			break;
		case MTYPE_LIST:
			MenuList_Draw((menulist_s *) menu->items[i]);
			break;
		case MTYPE_SPINCONTROL:
			SpinControl_Draw((menulist_s *) menu->items[i]);
			break;
		case MTYPE_ACTION:
			Action_Draw((menuaction_s *) menu->items[i]);
			break;
		case MTYPE_SEPARATOR:
			Separator_Draw((menuseparator_s *) menu->items[i]);
			break;
		}
	}

	/*
	 * * now check mouseovers - psychospaz
	 */
	cursor.menu = menu;

	if (cursor.mouseaction) {
		menucommon_s   *lastitem = cursor.menuitem;

		refreshCursorLink();

		for (i = menu->nitems; i >= 0; i--) {
			int		type;
			int		len;
			int		min        [2], max[2];

			item = ((menucommon_s *) menu->items[i]);

			if (!item || item->type == MTYPE_SEPARATOR)
				continue;

			max[0] = min[0] = menu->x + item->x + RCOLUMN_OFFSET;	/* + 2 chars for space +
										 * cursor */
			max[1] = min[1] = menu->y + item->y;
			max[1] += 8;

			switch (item->type) {
			case MTYPE_ACTION:
				{
					len = strlen(item->name);

					if (item->flags & QMF_LEFT_JUSTIFY) {
						min[0] += LCOLUMN_OFFSET * 2;
						max[0] = min[0] + len * 8;
					} else {
						min[0] -= len * 8 + 24;
					}

					type = MENUITEM_ACTION;
				}
				break;
			case MTYPE_SLIDER:
				{
					min[0] -= 16;
					max[0] += (SLIDER_RANGE + 2) * 8 + 16;
					type = MENUITEM_SLIDER;
				}
				break;
			case MTYPE_LIST:
			case MTYPE_SPINCONTROL:
				{
					int		len;
					menulist_s     *spin = menu->items[i];


					if (item->name) {
						len = strlen(item->name);
						min[0] -= len * 8 - LCOLUMN_OFFSET * 2;
					}
					len = strlen(spin->itemnames[spin->curvalue]);
					max[0] += len * 8;

					type = MENUITEM_ROTATE;
				}
				break;
			case MTYPE_FIELD:
				{
					menufield_s    *text = menu->items[i];

					len = text->visible_length + 2;

					max[0] += len * 8;
					type = MENUITEM_TEXT;
				}
				break;
			default:
				continue;
			}

			if (cursor.x >= min[0] &&
			    cursor.x <= max[0] &&
			    cursor.y >= min[1] &&
			    cursor.y <= max[1]) {
				/* new item */
				if (lastitem != item) {
					int		j;

					for (j = 0; j < MENU_CURSOR_BUTTON_MAX; j++) {
						cursor.buttonclicks[j] = 0;
						cursor.buttontime[j] = 0;
					}
				}
				cursor.menuitem = item;
				cursor.menuitemtype = type;

				menu->cursor = i;

				break;
			}
		}
	}
	cursor.mouseaction = false;

	item = Menu_ItemAtCursor(menu);

	if (item && item->cursordraw) {
		item->cursordraw(item);
	} else if (menu->cursordraw) {
		menu->cursordraw(menu);
	} else if (item && item->type != MTYPE_FIELD) {
		if (item->flags & QMF_LEFT_JUSTIFY) {
			Draw_Char(menu->x + item->x - 24 + item->cursor_offset, menu->y + item->y, 12 + ((int)(Sys_Milliseconds() / 250) & 1), 255);
		} else {
			Draw_Char(menu->x + item->cursor_offset, menu->y + item->y, 12 + ((int)(Sys_Milliseconds() / 250) & 1), 255);
		}
	}
	if (item) {
		if (item->statusbarfunc)
			item->statusbarfunc((void *)item);
		else if (item->statusbar)
			Menu_DrawStatusBar(item->statusbar);
		else
			Menu_DrawStatusBar(menu->statusbar);

	} else {
		Menu_DrawStatusBar(menu->statusbar);
	}
}
Example #5
0
/*
==========================
Menu_Draw
==========================
*/
void Menu_Draw (menuframework_s *menu)
{
	int i;
	menucommon_s *item;

	//
	// draw contents
	//
	for (i = 0; i < menu->nitems; i++)
	{
		// skip hidden items
		if ( ((menucommon_s *)menu->items[i])->flags & QMF_HIDDEN )
			continue;

		switch ( ((menucommon_s *)menu->items[i])->type )
		{
		case MTYPE_FIELD:
			Field_Draw( ( menufield_s * )menu->items[i] );
			break;
		case MTYPE_SLIDER:
			Slider_Draw( (menuslider_s *)menu->items[i] );
			break;
		case MTYPE_LIST:
			MenuList_Draw( (menulist_s *)menu->items[i] );
			break;
		case MTYPE_SPINCONTROL:
			SpinControl_Draw( (menulist_s *)menu->items[i] );
			break;
		case MTYPE_ACTION:
			Action_Draw( (menuaction_s *)menu->items[i] );
			break;
		case MTYPE_SEPARATOR:
			Separator_Draw( (menuseparator_s *)menu->items[i] );
			break;
		}
	}

	// added Psychspaz's mouse support
	//
	// now check mouseovers - psychospaz
	//
	cursor.menu = menu;

	if (cursor.mouseaction)
	{
		menucommon_s *lastitem = cursor.menuitem;
		UI_RefreshCursorLink();

		for (i = menu->nitems; i >= 0 ; i--)
		{
			int		type, len;
			int		min[2], max[2];
			float	x1, y1, w1, h1;

			item = ((menucommon_s * )menu->items[i]);

			if (!item || item->type == MTYPE_SEPARATOR)
				continue;

			x1 = menu->x + item->x + RCOLUMN_OFFSET; // + 2 chars for space + cursor
			y1 = menu->y + item->y;
			w1 = 0;			h1 = MENU_FONT_SIZE;
			SCR_AdjustFrom640 (&x1, &y1, &w1, &h1, ALIGN_CENTER);
			min[0] = x1;	max[0] = x1+w1;
			min[1] = y1;	max[1] = y1+h1;
		//	max[0] = min[0] = SCR_ScaledVideo(menu->x + item->x + RCOLUMN_OFFSET); //+ 2 chars for space + cursor
		//	max[1] = min[1] = SCR_ScaledVideo(menu->y + item->y);
		//	max[1] += SCR_ScaledVideo(MENU_FONT_SIZE);

			switch (item->type)
			{
				case MTYPE_ACTION:
					{
						len = strlen(item->name);
						
						if (item->flags & QMF_LEFT_JUSTIFY)
						{
							min[0] += SCR_ScaledVideo(LCOLUMN_OFFSET*2);
							max[0] = min[0] + SCR_ScaledVideo(len*MENU_FONT_SIZE);
						}
						else
							min[0] -= SCR_ScaledVideo(len*MENU_FONT_SIZE + MENU_FONT_SIZE*3);

						type = MENUITEM_ACTION;
					}
					break;
				case MTYPE_SLIDER:
					{
						if (item->name)
						{
							len = strlen(item->name);
							min[0] -= SCR_ScaledVideo(len*MENU_FONT_SIZE - LCOLUMN_OFFSET*2);
						}
						else
							min[0] -= SCR_ScaledVideo(16);
						max[0] += SCR_ScaledVideo((SLIDER_RANGE + 4)*MENU_FONT_SIZE);
						type = MENUITEM_SLIDER;
					}
					break;
				case MTYPE_LIST:
				case MTYPE_SPINCONTROL:
					{
						int len;
						menulist_s *spin = menu->items[i];


						if (item->name)
						{
							len = strlen(item->name);
							min[0] -= SCR_ScaledVideo(len*MENU_FONT_SIZE - LCOLUMN_OFFSET*2);
						}

						len = strlen(spin->itemnames[spin->curvalue]);
						max[0] += SCR_ScaledVideo(len*MENU_FONT_SIZE);

						type = MENUITEM_ROTATE;
					}
					break;
				case MTYPE_FIELD:
					{
						menufield_s *text = menu->items[i];

						len = text->visible_length + 2;

						max[0] += SCR_ScaledVideo(len*MENU_FONT_SIZE);
						type = MENUITEM_TEXT;
					}
					break;
				default:
					continue;
			}

			if (cursor.x>=min[0] && 
				cursor.x<=max[0] &&
				cursor.y>=min[1] && 
				cursor.y<=max[1])
			{
				// new item
				if (lastitem!=item)
				{
					int j;

					for (j=0; j<MENU_CURSOR_BUTTON_MAX; j++)
					{
						cursor.buttonclicks[j] = 0;
						cursor.buttontime[j] = 0;
					}
				}

				cursor.menuitem = item;
				cursor.menuitemtype = type;
				
				menu->cursor = i;

				break;
			}
		}
	}

	cursor.mouseaction = false;
	// end mouseover code

	item = Menu_ItemAtCursor(menu);

	if (item && item->cursordraw)
	{
		item->cursordraw(item);
	}
	else if (menu->cursordraw)
	{
		menu->cursordraw(menu);
	}
	else if (item && item->type != MTYPE_FIELD)
	{
		if (item->flags & QMF_LEFT_JUSTIFY)
		{
			SCR_DrawChar (menu->x+item->x+item->cursor_offset-24, menu->y+item->y,
						ALIGN_CENTER, 12+((int)(Sys_Milliseconds()/250)&1),
						255,255,255,255, false, true);
		}
		else
		{
			SCR_DrawChar (menu->x+item->cursor_offset, menu->y+item->y,
						ALIGN_CENTER, 12+((int)(Sys_Milliseconds()/250)&1),
						255,255,255,255, false, true);
		}
	}

	if (item)
	{
		if (item->statusbarfunc)
			item->statusbarfunc ( (void *)item );
		else if (item->statusbar)
			Menu_DrawStatusBar (item->statusbar);
		else
			Menu_DrawStatusBar (menu->statusbar);
	}
	else
		Menu_DrawStatusBar( menu->statusbar );
}
Example #6
0
void Menu_Draw( menuframework_s *menu )
{
	int i;
	menucommon_s *item;

	/*
	** draw contents
	*/
	for ( i = 0; i < menu->nitems; i++ )
	{
		switch ( ( ( menucommon_s * ) menu->items[i] )->type )
		{
		case MTYPE_FIELD:
			Field_Draw( ( menufield_s * ) menu->items[i] );
			break;
		case MTYPE_SLIDER:
			Slider_Draw( ( menuslider_s * ) menu->items[i] );
			break;
		case MTYPE_LIST:
			MenuList_Draw( ( menulist_s * ) menu->items[i] );
			break;
		case MTYPE_SPINCONTROL:
			SpinControl_Draw( ( menulist_s * ) menu->items[i] );
			break;
		case MTYPE_ACTION:
			Action_Draw( ( menuaction_s * ) menu->items[i] );
			break;
		case MTYPE_SEPARATOR:
			Separator_Draw( ( menuseparator_s * ) menu->items[i] );
			break;
		}
	}

	item = (menucommon_s *) Menu_ItemAtCursor( menu );

	if ( item && item->cursordraw )
	{
		item->cursordraw( item );
	}
	else if ( menu->cursordraw )
	{
		menu->cursordraw( menu );
	}
	else if ( item && item->type != MTYPE_FIELD )
	{
		if ( item->flags & QMF_LEFT_JUSTIFY )
		{
			Draw_Char( menu->x + item->x - 24 + item->cursor_offset, menu->y + item->y, 12 + ( ( int ) ( Sys_Milliseconds()/250 ) & 1 ) );
		}
		else
		{
			Draw_Char( menu->x + item->cursor_offset, menu->y + item->y, 12 + ( ( int ) ( Sys_Milliseconds()/250 ) & 1 ) );
		}
	}

	if ( item )
	{
		if ( item->statusbarfunc )
			item->statusbarfunc( ( void * ) item );
		else if ( item->statusbar )
			Menu_DrawStatusBar( item->statusbar );
		else
			Menu_DrawStatusBar( menu->statusbar );

	}
	else
	{
		Menu_DrawStatusBar( menu->statusbar );
	}
}
Example #7
0
void Menu_Draw ( menuframework_t *menu )
{
	char scratch[MAX_QPATH];
	static int yaw;
//	int maxframe = 29;
	entity_t entity;
	int i;
	menucommon_t *item;
	refdef_t refdef;

	// Draw rotating Quake II Symbol
	memset( &refdef, 0, sizeof( refdef ) );
	memset( &entity, 0, sizeof( entity ) );

	refdef.x = 0;
	refdef.y = 0;
	refdef.width = viddef.width;
	refdef.height = viddef.height;
	refdef.fov_x = 35;
	refdef.fov_y = CalcFov( refdef.fov_x, refdef.width, refdef.height );
	refdef.time = cls.realtime * 0.001;
	refdef.areabits = NULL;
	refdef.num_entities = 1;
	//refdef.lightstyles = 5;			// Gentle Pulse
	refdef.lightstyles = 63;			// Testing (FULLBRIGHT)
	refdef.rdflags = RDF_NOWORLDMODEL;
	refdef.blend[0] = 1.0;
	refdef.blend[1] = 1.0;
	refdef.blend[2] = 1.0;
	refdef.blend[3] = 0.0;
	refdef.dlights = NULL;
	refdef.num_dlights = 0;
	refdef.num_particles = 0;
	refdef.particles = NULL;
	VectorSet(refdef.viewangles, 1.0, 0.0, 0.0);
	VectorClear(refdef.vieworg);

	//if (!strcmp(vid_ref->string, "soft"))
	//	Com_sprintf( scratch, sizeof( scratch ), "models/items/quaddama/tris.md2");
	//else
		Com_sprintf( scratch, sizeof( scratch ), "models/MenuModel/quad.md2");

	entity.model = re.RegisterModel( scratch );
	//entity.Model_Type = 0;
	entity.flags = RF_MINLIGHT | RF_DEPTHHACK | RF_FULLBRIGHT | RF_GLOW | RF_NOSHADOW;
	entity.origin[0] = 80;
	entity.origin[1] = 0;
	entity.origin[2] = -18;	// -18 compensates for the float height of the model
	VectorCopy( entity.origin, entity.oldorigin );
	entity.frame = 0;
	entity.oldframe = 0;
	entity.backlerp = 0.0;
	entity.angles[1] = yaw++;
	if ( ++yaw > 360 )
		yaw -= 360;

	refdef.entities = &entity;

	// Fog the scene
	//refdef.blend[0] = 0.55;
	//refdef.blend[1] = 0.55;
	//refdef.blend[2] = 0.55;
	//refdef.blend[3] = 0.55;

	if (cl_3dmenubg->value)
	{
		// Draw scene
		MenuRefdefActive = 1;
		re.RenderFrame( &refdef );
		//Menu_DrawBackground("q2bg.tga");
	}

	// Draw the menu version information
	if (cl_menustamp->value > 0)
	{
		/*
		1 - Regular string
		2 - Regular string plus drop shadow (green... not effective)
		3 - All green string
		*/
		if (cl_menustamp->value == 1)
		{
			// Draw the text
			Menu_DrawString (viddef.width - (strlen(MENUSTAMP) * FONTSIZE) - (FONTSIZE * 3), viddef.height - FONTSIZE, MENUSTAMP);
		}
		else if (cl_menustamp->value == 2)
		{
			// Draw the drop shadow (we need black characters)
			DrawAltString (viddef.width - (strlen(MENUSTAMP) * FONTSIZE) - (FONTSIZE * 3) - 1, viddef.height - FONTSIZE, MENUSTAMP);

			// Draw the text
			Menu_DrawString (viddef.width - (strlen(MENUSTAMP) * FONTSIZE) - (FONTSIZE * 3), viddef.height - FONTSIZE - 1, MENUSTAMP);
		}
		else if (cl_menustamp->value == 3)
		{
			// Draw the text
			DrawAltString (viddef.width - (strlen(MENUSTAMP) * FONTSIZE) - (FONTSIZE * 3), viddef.height - FONTSIZE, MENUSTAMP);
		}
	}

	// Menu drawing prevention hack for main menu
	if ((menu->x == -1) && (menu->y == -1))
		return;

	/*
	** draw contents
	*/
	for ( i = 0; i < menu->nitems; i++ )
	{
		switch ( ( ( menucommon_t * ) menu->items[i] )->type )
		{
		case MTYPE_FIELD:
			Field_Draw( ( menufield_t * ) menu->items[i] );
			break;
		case MTYPE_SLIDER:
			Slider_Draw( ( menuslider_t * ) menu->items[i] );
			break;
		case MTYPE_LIST:
			MenuList_Draw( ( menulist_t * ) menu->items[i] );
			break;
		case MTYPE_SPINCONTROL:
			SpinControl_Draw( ( menulist_t * ) menu->items[i] );
			break;
		case MTYPE_ACTION:
			Action_Draw( ( menuaction_t * ) menu->items[i] );
			break;
		case MTYPE_SEPARATOR:
			Separator_Draw( ( menuseparator_t * ) menu->items[i] );
			break;
		}
	}

	item = Menu_ItemAtCursor( menu );

	if ( item && item->cursordraw )
	{
		item->cursordraw( item );
	}
	else if ( menu->cursordraw )
	{
		menu->cursordraw( menu );
	}
	else if ( item && item->type != MTYPE_FIELD )
	{
		if ( item->flags & QMF_LEFT_JUSTIFY )
		{
			Draw_Char( menu->x + item->x - 24 + item->cursor_offset, menu->y + item->y, 12 + ( ( int ) ( Sys_Milliseconds()/250 ) & 1 ) );
		}
		else
		{
			Draw_Char( menu->x + item->cursor_offset, menu->y + item->y, 12 + ( ( int ) ( Sys_Milliseconds()/250 ) & 1 ) );
		}
	}

	if ( item )
	{
		if ( item->statusbarfunc )
			item->statusbarfunc( ( void * ) item );
		else if ( item->statusbar )
			Menu_DrawStatusBar( item->statusbar );
		else
			Menu_DrawStatusBar( menu->statusbar );

	}
	else
	{
		Menu_DrawStatusBar( menu->statusbar );
	}
}