void CChannelN::ShowString(double time /*seconds*/, char* buf)
{
	if(int(time) != int(lastTime)/*time - lastTime > 1*/) {
		PaintBkgr();
		lastTime = time;
	}
	double position /*(0..1)*/ = time - double(int(time));


	int h=Form1->ImageCode->ClientHeight;
	int w=Form1->ImageCode->ClientWidth;
	int pos = int(w * position);
	LOCKCODE;
	DCTYPE dc;
	GET_CODEDC(dc);
	int PenCol;


	Form1->Memo1->Lines->Add(buf);
	int tw;
	TEXTWIDTH(dc,buf,tw);
	SET_REDPEN(dc);
	TEXTOUT(dc,buf,pos-tw,1,PenCol); //-tw
	LINE(dc,pos,0,pos,h,PenCol);
	UNLOCKCODE;

		h=Form1->Image3->ClientHeight;
		LOCK(bmpCanvas);
		GET_DC(dc);
		SET_REDPEN(dc);
		LINE(dc,pos,0,pos,h,PenCol);
		UNLOCK(bmpCanvas);


}
Example #2
0
void win_draw_bar(win_t *win)
{
	int len, x, y, w, tw;
	win_env_t *e;
	win_bar_t *l, *r;
	XftDraw *d;
	const XftColor *bg, *fg;

	if ((l = &win->bar.l)->buf == NULL || (r = &win->bar.r)->buf == NULL)
		return;

	e = &win->env;
	y = win->h + font->ascent + V_TEXT_PAD;
	w = win->w - 2*H_TEXT_PAD;
	d = XftDrawCreate(e->dpy, win->buf.pm, DefaultVisual(e->dpy, e->scr),
	                  DefaultColormap(e->dpy, e->scr));

	if (win->fullscreen && !win->light)
		bg = &win->bg, fg = &win->fg;
	else
		bg = &win->fg, fg = &win->bg;

	XSetForeground(e->dpy, gc, bg->pixel);
	XFillRectangle(e->dpy, win->buf.pm, gc, 0, win->h, win->w, win->bar.h);

	XSetForeground(e->dpy, gc, fg->pixel);
	XSetBackground(e->dpy, gc, bg->pixel);

	if ((len = strlen(r->buf)) > 0) {
		if ((tw = TEXTWIDTH(win, r->buf, len)) > w)
			return;
		x = win->w - tw - H_TEXT_PAD;
		w -= tw;
		win_draw_text(win, d, fg, x, y, r->buf, len, tw);
	}
	if ((len = strlen(l->buf)) > 0) {
		x = H_TEXT_PAD;
		w -= 2 * H_TEXT_PAD; /* gap between left and right parts */
		win_draw_text(win, d, fg, x, y, l->buf, len, w);
	}
	XftDrawDestroy(d);
}
Example #3
0
void CCam::targetCam(camInfo_t *ci)
{

	if (this->targetClientNum < 0 || this->targetClientNum > (MAX_CLIENTS-1) || !IS_INFOVALID(this->targetClientNum) || IS_DEAD(eth32.cg.clientNum))
	{
		this->targetClientNum = -1;
		return;
	}

	player_t *player = &eth32.cg.players[targetClientNum];

	int w = ci->x2 - ci->x1;
	int h = ci->y2 - ci->y1;

	// Set the view
	memcpy(&camRefDef, &eth32.cg.refdef, sizeof(refdef_t));
	// fov
	camRefDef.fov_x = (w>h) ? ci->fov : ci->fov * w / h;
	camRefDef.fov_y = (h>w) ? ci->fov : ci->fov * h / w;
	// origin
	vec3_t origin;
	VectorCopy( player->orHead.origin, origin );
	VectorMA( origin, -(int)ci->distance, eth32.cg.refdef->viewaxis[0], origin );
	VectorCopy(origin, camRefDef.vieworg);

	// view angle
	vec3_t camAngle;

	VectorCopy(eth32.cg.refdefViewAngles, camAngle);
	AnglesToAxis(camAngle, camRefDef.viewaxis);

	// Draw the spycam
	drawCam(ci->x1, ci->y1, w, h, &camRefDef, qfalse);

	strcpy(this->str, player->name);
	Draw.Text(ci->x1 + (w / 2) - (TEXTWIDTH(this->str) / 2), ci->y1 + h - 22 , 0.24f, str, GUI_FONTCOLOR1, qfalse, qtrue, &eth32.cg.media.fontArial, true);
}
Example #4
0
void CCam::enemyCam(camInfo_t *ci)
{
	int entityNum = nearestEntity();

	if (entityNum == -1)
		return;

	player_t *player = &eth32.cg.players[entityNum];

	int w = ci->x2 - ci->x1;
	int h = ci->y2 - ci->y1;

	// Set the view
	memcpy(&camRefDef, &eth32.cg.refdef, sizeof(refdef_t));
	// fov
	camRefDef.fov_x = (w>h) ? ci->fov : ci->fov * w / h;
	camRefDef.fov_y = (h>w) ? ci->fov : ci->fov * h / w;
	// origin
	VectorCopy( player->lerpOrigin, camRefDef.vieworg );

	if (player->currentState->eFlags & EF_CROUCHING)
		camRefDef.vieworg[2] += CROUCH_VIEWHEIGHT;
	else if (player->currentState->eFlags & EF_PRONE)
		camRefDef.vieworg[2] += PRONE_VIEWHEIGHT;
	else
		camRefDef.vieworg[2] += DEFAULT_VIEWHEIGHT;

	// view angle
	AnglesToAxis(player->currentState->apos.trBase, camRefDef.viewaxis);

	// Draw the spycam
	drawCam(ci->x1, ci->y1, w, h, &camRefDef, qfalse);

	sprintf(this->str, player->name);
	Draw.Text(ci->x1 + (w / 2) - (TEXTWIDTH(this->str) / 2), ci->y1 + h - 22 , 0.24f, str, GUI_FONTCOLOR1, qfalse, qtrue, &eth32.cg.media.fontArial, true);
}
Example #5
0
void CCam::mortarCam(camInfo_t *ci)
{
	if (eth32.cg.snap->ps.ammo == 0)
		return;

// Set mortar trajectory from current view
	vec3_t angles, forward;
	VectorCopy(eth32.cg.refdef->viewaxis[ROLL], forward);
	VectorCopy(eth32.cg.snap->ps.viewangles, angles);
	angles[PITCH] -= 60.f;
	AngleVectors(angles, forward, NULL, NULL);
	forward[0] *= 3000 * 1.1f;
	forward[1] *= 3000 * 1.1f;
	forward[2] *= 1500 * 1.1f;

	trajectory_t mortarTrajectory;
	mortarTrajectory.trType = TR_GRAVITY;
	mortarTrajectory.trTime = eth32.cg.time;
	VectorCopy(eth32.cg.muzzle, mortarTrajectory.trBase);
	VectorCopy(forward, mortarTrajectory.trDelta);

	// Calculate mortar impact
	int timeOffset = 0;
	trace_t mortarTrace;
	vec3_t mortarImpact;
	VectorCopy(mortarTrajectory.trBase, mortarImpact);
	#define TIME_STEP 20
	while (timeOffset < 10000) {
		vec3_t nextPos;
		timeOffset += TIME_STEP;
		BG_EvaluateTrajectory(&mortarTrajectory, eth32.cg.time + timeOffset, nextPos, qfalse, 0);
		orig_CG_Trace(&mortarTrace, mortarImpact, 0, 0, nextPos, eth32.cg.snap->ps.clientNum, MASK_MISSILESHOT);
		if ((mortarTrace.fraction != 1)
				// Stop if we hit sky
				&& !((mortarTrace.surfaceFlags & SURF_NODRAW) || (mortarTrace.surfaceFlags & SURF_NOIMPACT))
				&& (mortarTrace.contents != 0)) {
			break;
		}
		VectorCopy(nextPos, mortarImpact);
	}

	memcpy(&camRefDef, &eth32.cg.refdef, sizeof(refdef_t));

	// kobject: add some angles
	vec3_t	dpos;
	vec3_t	camOrg;

	dpos[0] = eth32.cg.refdef->vieworg[0]-mortarImpact[0];
	dpos[1] = eth32.cg.refdef->vieworg[1]-mortarImpact[1];
	dpos[2] = 0.0f;
	VectorNormalizeFast( dpos );
	VectorCopy( mortarImpact, camOrg );
	VectorMA( camOrg, ci->distance * sinf(ci->angle * M_PI/180.0), zAxis, camOrg );
	VectorMA( camOrg, ci->distance * cosf(ci->angle * M_PI/180.0), dpos, camOrg );

	int w = ci->x2 - ci->x1;
	int h = ci->y2 - ci->y1;

	camRefDef.fov_x = (w>h) ? ci->fov : ci->fov * w / h;
	camRefDef.fov_y = (h>w) ? ci->fov : ci->fov * h / w;

	VectorCopy(camOrg, camRefDef.vieworg);

	vec3_t camAngle;
	VectorCopy(eth32.cg.refdefViewAngles, camAngle);
	camAngle[PITCH] = ci->angle;

	AnglesToAxis(camAngle, camRefDef.viewaxis);

	drawCam(ci->x1, ci->y1, w, h, &camRefDef, qtrue);

	// Draw impact time
	sprintf(this->str, "^7Impact Time: ^b%.1f ^7seconds", (float)timeOffset / 1000.0f);
	Draw.Text(ci->x1 + (w / 2) - (TEXTWIDTH(this->str) / 2), ci->y1 + h - 22 , 0.24f, str, GUI_FONTCOLOR1, qfalse, qtrue, &eth32.cg.media.fontArial, true);

}