예제 #1
0
파일: ui_atoms.c 프로젝트: raynorpat/cake3
void QDECL Com_Error(int level, const char *error, ...)
{
va_list         argptr;
char            text[1024];

va_start(argptr, error);
Q_vsnprintf(text, sizeof(text), error, argptr);
va_end(argptr);

trap_Error(text);
}
예제 #2
0
/*
* G_Error
* 
* Abort the server with a game error
*/
void G_Error( const char *format, ... )
{
	char msg[1024];
	va_list	argptr;

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

	trap_Error( msg );
}
예제 #3
0
static JSBool sys_error(JSContext *cx, unsigned argc, jsval *vp)
{
    JSString *s;
    char *message;
    if (!JS_ConvertArguments(cx, argc, JS_ARGV(cx, vp), "S", &s))
        return JS_FALSE;
    message = JS_EncodeString(cx, s);
    trap_Error(message);
    JS_free(cx, message);
    JS_SET_RVAL(cx, vp, JSVAL_VOID);
    return JS_TRUE;
}
예제 #4
0
/*
=================
UI_PushMenu
=================
*/
void UI_PushMenu( menuframework_s *menu )
{
	int				i;
	menucommon_s*	item;

	// avoid stacking menus invoked by hotkeys
	for (i=0 ; i<uis.menusp ; i++)
	{
		if (uis.stack[i] == menu)
		{
			uis.menusp = i;
			break;
		}
	}

	if (i == uis.menusp)
	{
		if (uis.menusp >= MAX_MENUDEPTH)
			trap_Error("UI_PushMenu: menu stack overflow");

		uis.stack[uis.menusp++] = menu;
	}

	uis.activemenu = menu;

	// default cursor position
	menu->cursor      = 0;
	menu->cursor_prev = 0;

	// pushmenu pushmenu has more priority than popmenu
	soundTime = 0;
	UI_StartSound( menu_in_sound );
	soundTime = uis.realtime + 150;

	trap_Key_SetCatcher( KEYCATCH_UI );

	// force first available item to have focus
	for (i=0; i<menu->nitems; i++)
	{
		item = (menucommon_s *)menu->items[i];
		if (!(item->flags & (QMF_GRAYED|QMF_MOUSEONLY|QMF_INACTIVE)))
		{
			menu->cursor_prev = -1;
			Menu_SetCursor( menu, i );
			break;
		}
	}

	uis.firstdraw = qtrue;
}
예제 #5
0
/*
===============
UI_SetLerpFrameAnimation
===============
*/
static void UI_SetLerpFrameAnimation( playerInfo_t *ci, lerpFrame_t *lf, int newAnimation ) {
    animation_t	*anim;

    lf->animationNumber = newAnimation;
    newAnimation &= ~ANIM_TOGGLEBIT;

    if ( newAnimation < 0 || newAnimation >= MAX_ANIMATIONS ) {
        trap_Error( va("Bad animation number: %i", newAnimation) );
    }

    anim = &ci->animations[ newAnimation ];

    lf->animation = anim;
    lf->animationTime = lf->frameTime + anim->initialLerp;
}
예제 #6
0
/*
 =================
 UI_PopMenu
 =================
 */
void UI_PopMenu(void) {
  trap_S_StartLocalSound(menu_out_sound, CHAN_LOCAL_SOUND);

  uis.menusp--;

  if (uis.menusp < 0)
    trap_Error("UI_PopMenu: menu stack underflow");

  if (uis.menusp) {
    uis.activemenu = uis.stack[uis.menusp - 1];
    uis.firstdraw = qtrue;
  } else {
    UI_ForceMenuOff();
  }
}
예제 #7
0
파일: players.c 프로젝트: icanhas/yantar
/*
 * UI_SetLerpFrameAnimation
 */
static void
UI_SetLerpFrameAnimation(Playerinfo *ci, Lerpframe *lf, int newAnimation)
{
	Anim *anim;

	lf->animationNumber = newAnimation;
	newAnimation &= ~ANIM_TOGGLEBIT;

	if(newAnimation < 0 || newAnimation >= MAX_ANIMATIONS)
		trap_Error(va("Bad animation number: %i", newAnimation));

	anim = &ci->animations[ newAnimation ];

	lf->animation = anim;
	lf->animationTime = lf->frameTime + anim->initialLerp;
}
예제 #8
0
파일: q_shared.c 프로젝트: boutetnico/ETrun
void QDECL Com_Error(int level, const char *error, ...) {
	va_list argptr;
	char    text[1024];

	// Nico, silent GCC
	(void)level;

	va_start(argptr, error);
	Q_vsnprintf(text, sizeof (text), error, argptr);
	va_end(argptr);

#ifdef CGAMEDLL
	CG_Error("%s", text);
#elif defined GAMEDLL
	G_Error("%s", text);
#else
	trap_Error(va("%s", text));
#endif
}
예제 #9
0
/*
=================
UI_PopMenu
=================
*/
void UI_PopMenu (void)
{
	// popmenu sound has some priority, but pushmenu has more priority
	UI_StartSound( menu_out_sound );
	soundTime = uis.realtime + 150;

	uis.menusp--;

	if (uis.menusp < 0)
		trap_Error ("UI_PopMenu: menu stack underflow");

	if (uis.menusp) {
		uis.activemenu = uis.stack[uis.menusp-1];
		uis.firstdraw = qtrue;
	}
	else {
		UI_ForceMenuOff ();
	}

}
예제 #10
0
/*
===============
UI_SetLerpFrameAnimation
===============
*/
static void UI_SetLerpFrameAnimation( uiPlayerInfo_t *pi, lerpFrame_t *lf, int newAnimation ) {
	animation_t	*anim;

	lf->animationNumber = newAnimation;
	newAnimation &= ~ANIM_TOGGLEBIT;

#ifdef TA_PLAYERSYS
	if ( newAnimation < 0 || newAnimation >= MAX_TOTALANIMATIONS )
#else
	if ( newAnimation < 0 || newAnimation >= MAX_ANIMATIONS )
#endif
	{
		trap_Error( va("Bad animation number: %i", newAnimation) );
	}

#ifdef TA_PLAYERSYS
	anim = &pi->playercfg.animations[ newAnimation ];
#else
	anim = &pi->animations[ newAnimation ];
#endif

	lf->animation = anim;
	lf->animationTime = lf->frameTime + anim->initialLerp;
}
예제 #11
0
void Menu_Draw(menuframework_s *menu)
{
	int				i;
	menucommon_s	*itemptr;

	// draw menu
	for (i=0; i<menu->nitems; i++) {
		itemptr = (menucommon_s*)menu->items[i];

		if (itemptr->flags & QMF_HIDDEN) {
			continue;
		}

		if (itemptr->ownerdraw) {
			// total subclassing, owner draws everything
			itemptr->ownerdraw(itemptr);
		} else {
			switch (itemptr->type) {
			case MTYPE_RADIOBUTTON:
				RadioButton_Draw((menuradiobutton_s*)itemptr);
				break;

			case MTYPE_FIELD:
				MenuField_Draw((menufield_s*)itemptr);
				break;

			case MTYPE_SLIDER:
				Slider_Draw((menuslider_s*)itemptr);
				break;

			case MTYPE_SPINCONTROL:
				SpinControl_Draw((menulist_s*)itemptr);
				break;

			case MTYPE_ACTION:
				Action_Draw((menuaction_s*)itemptr);
				break;

			case MTYPE_BITMAP:
				Bitmap_Draw((menubitmap_s*)itemptr);
				break;

			case MTYPE_TEXT:
				Text_Draw((menutext_s*)itemptr);
				break;

			case MTYPE_SCROLLLIST:
				ScrollList_Draw((menulist_s*)itemptr);
				break;

			case MTYPE_PTEXT:
				PText_Draw((menutext_s*)itemptr);
				break;

			case MTYPE_BTEXT:
				BText_Draw((menutext_s*)itemptr);
				break;

			case MTYPE_BUTTON:
				Button_Draw((menubutton_s*)itemptr);
				break;
			default:
				trap_Error(va("Menu_Draw: unknown type %d", itemptr->type));
			}
		}
#ifndef NDEBUG
		if (uis.debug) {
			int	x;
			int	y;
			int	w;
			int	h;

			if (!(itemptr->flags & QMF_INACTIVE)) {
				x = itemptr->left;
				y = itemptr->top;
				w = itemptr->right - itemptr->left + 1;
				h =	itemptr->bottom - itemptr->top + 1;

				if (itemptr->flags & QMF_HASMOUSEFOCUS) {
					SCR_DrawRect(x, y, w, h, 1.0f, colorYellow);
				} else {
					SCR_DrawRect(x, y, w, h, 1.0f, colorWhite);
				}
			}
		}
#endif
	}

	itemptr = Menu_ItemAtCursor(menu);
	if (itemptr && itemptr->statusbar) {
		itemptr->statusbar((void *) itemptr);
	}
}
예제 #12
0
void Menu_AddItem(menuframework_s *menu, void *item)
{
	menucommon_s	*itemptr;

	if (menu->nitems >= MAX_MENUITEMS) {
		trap_Error ("Menu_AddItem: excessive items");
	}

	menu->items[menu->nitems] = item;
	((menucommon_s*)menu->items[menu->nitems])->parent = menu;
	((menucommon_s*)menu->items[menu->nitems])->menuPosition = menu->nitems;
	((menucommon_s*)menu->items[menu->nitems])->flags &= ~QMF_HASMOUSEFOCUS;

	// perform any item specific initializations
	itemptr = (menucommon_s*)item;
	if (!(itemptr->flags & QMF_NODEFAULTINIT)) {
		switch (itemptr->type) {
		case MTYPE_ACTION:
			Action_Init((menuaction_s*)item);
			break;

		case MTYPE_FIELD:
			MenuField_Init((menufield_s*)item);
			break;

		case MTYPE_SPINCONTROL:
			SpinControl_Init((menulist_s*)item);
			break;

		case MTYPE_RADIOBUTTON:
			RadioButton_Init((menuradiobutton_s*)item);
			break;

		case MTYPE_SLIDER:
			Slider_Init((menuslider_s*)item);
			break;

		case MTYPE_BITMAP:
			Bitmap_Init((menubitmap_s*)item);
			break;

		case MTYPE_TEXT:
			Text_Init((menutext_s*)item);
			break;

		case MTYPE_SCROLLLIST:
			ScrollList_Init((menulist_s*)item);
			break;

		case MTYPE_PTEXT:
			PText_Init((menutext_s*)item);
			break;

		case MTYPE_BTEXT:
			BText_Init((menutext_s*)item);
			break;

		case MTYPE_BUTTON:
			Button_Init((menubutton_s*)item);
			break;

		default:
			trap_Error(va("Menu_Init: unknown type %d", itemptr->type));
		}
	}

	menu->nitems++;
}
예제 #13
0
/*
===================
UI_Field_Draw

Handles horizontal scrolling and cursor blinking
x, y, are in pixels
===================
*/
void UI_Field_Draw( mfield_t *edit, int x, int y, int style, vec4_t color ) {
	int		len;
	int		charw;
	int		drawLen;
	int		prestep;
	int		cursorChar;
	char	str[MAX_STRING_CHARS];

	drawLen = edit->widthInChars;
	len     = strlen( edit->buffer ) + 1;

	// guarantee that cursor will be visible
	if ( len <= drawLen ) {
		prestep = 0;
	} else {
		if ( edit->scroll + drawLen > len ) {
			edit->scroll = len - drawLen;
			if ( edit->scroll < 0 ) {
				edit->scroll = 0;
			}
		}
		prestep = edit->scroll;
	}

	if ( prestep + drawLen > len ) {
		drawLen = len - prestep;
	}

	// extract <drawLen> characters from the field at <prestep>
	if ( drawLen >= MAX_STRING_CHARS ) {
		trap_Error( "drawLen >= MAX_STRING_CHARS" );
	}
	memcpy( str, edit->buffer + prestep, drawLen );
	str[ drawLen ] = 0;

	UI_DrawString( x, y, str, style, color );

	// draw the cursor
	if (!(style & UI_PULSE)) {
		return;
	}

	if ( trap_Key_GetOverstrikeMode() ) {
		cursorChar = 11;
	} else {
		cursorChar = 10;
	}

	style &= ~UI_PULSE;
	style |= UI_BLINK;

	if (style & UI_SMALLFONT)
	{
		charw =	SMALLCHAR_WIDTH;
	}
	else if (style & UI_GIANTFONT)
	{
		charw =	GIANTCHAR_WIDTH;
	}
	else
	{
		charw =	BIGCHAR_WIDTH;
	}

	if (style & UI_CENTER)
	{
		len = strlen(str);
		x = x - len*charw/2;
	}
	else if (style & UI_RIGHT)
	{
		len = strlen(str);
		x = x - len*charw;
	}
	
	UI_DrawChar( x + ( edit->cursor - prestep ) * charw, y, cursorChar, style & ~(UI_CENTER|UI_RIGHT), color );
}
예제 #14
0
파일: cg_demos.c 프로젝트: entdark/q3mme
void demoPlaybackInit(void) {
	char projectFile[MAX_OSPATH];

	demo.length = trap_MME_DemoLength();
	demo.initDone = qtrue;
	demo.autoLoad = qfalse;
	demo.play.time = 0;
	demo.play.lastTime = 0;
	demo.play.fraction = 0;
	demo.play.speed = 1.0;
	demo.play.paused = 0;

	demo.move.acceleration = 8;
	demo.move.friction = 8;
	demo.move.speed = 400;
	
	demo.line.locked = qfalse;
	demo.line.offset = 0;
	demo.line.speed = 1.0f;
	demo.line.points = 0;

	demo.loop.total = 0;

	demo.editType = editCamera;
	demo.viewType = viewChase;

	demo.camera.flags = CAM_ORIGIN | CAM_ANGLES;

	VectorClear( demo.chase.origin );
	VectorClear( demo.chase.angles );
	VectorClear( demo.chase.velocity );
	
	demo.chase.distance = 0;
	demo.chase.locked = qfalse;
	demo.chase.target = -1;
	
	demo.dof.focus = 256.0f;
	demo.dof.radius = 5.0f;
	demo.dof.target = -1;

	demo.camera.target = -1;
	demo.camera.fov = 0;
	demo.camera.smoothPos = posBezier;
	demo.camera.smoothAngles = angleQuat;

	hudInitTables();
	demoSynchMusic( -1, 0 );

	demo.media.additiveWhiteShader = trap_R_RegisterShader( "mme_additiveWhite" );
	demo.media.mouseCursor = trap_R_RegisterShaderNoMip( "menu/art/3_cursor2" );
	demo.media.switchOn = trap_R_RegisterShaderNoMip( "menu/art/switch_on" );
	demo.media.switchOff = trap_R_RegisterShaderNoMip( "menu/art/switch_off" );

	trap_AddCommand("camera");
	trap_AddCommand("edit");
	trap_AddCommand("view");
	trap_AddCommand("chase");
	trap_AddCommand("dof");
	trap_AddCommand("speed");
	trap_AddCommand("pause");
	trap_AddCommand("seek");
	trap_AddCommand("demoSeek");
	trap_AddCommand("find");
	trap_AddCommand("capture");
	trap_AddCommand("hudInit");
	trap_AddCommand("hudToggle");
	trap_AddCommand("line");
	trap_AddCommand("save");
	trap_AddCommand("load");
	trap_AddCommand("effect");
	trap_AddCommand("+seek");
	trap_AddCommand("-seek");
	trap_AddCommand("-seek");
	trap_AddCommand("musicPlay");
	trap_AddCommand("cut");

	trap_SendConsoleCommand("exec mme.cfg\n");
	trap_SendConsoleCommand("exec mmedemos.cfg\n");
	trap_Cvar_Set( "mov_captureName", "" );
	trap_Cvar_VariableStringBuffer( "mme_demoStartProject", projectFile, sizeof( projectFile ));
	if (projectFile[0]) {
		trap_Cvar_Set( "mme_demoStartProject", "" );
		demo.autoLoad = demoProjectLoad( projectFile );
		if (demo.autoLoad) {
			if (!demo.capture.start && !demo.capture.end) {
				trap_Error( "Loaded project file with empty capture range\n");
			}
			/* Check if the project had a cvar for the name else use project */
			if (!mov_captureName.string[0]) {
				trap_Cvar_Set( "mov_captureName", projectFile );
				trap_Cvar_Update( &mov_captureName );
			}
			trap_SendConsoleCommand("exec mmelist.cfg\n");
			demo.play.time = demo.capture.start - 1000;
			demo.capture.locked = qtrue;
			demo.capture.active = qtrue;
		} else {
			trap_Error( va("Couldn't load project %s\n", projectFile ));
		}
	}
}