Example #1
0
/*
 * @brief Provides a real-time visual representation of latency and packet loss
 * via a small graph drawn on screen.
 */
static void Cl_DrawNetGraph(void) {
	int32_t i, j, x, y, h;

	if (!cl_draw_net_graph->value)
		return;

	x = r_context.width - NET_GRAPH_WIDTH;
	y = r_context.height - NET_GRAPH_Y - NET_GRAPH_HEIGHT;

	R_DrawFill(x, y, NET_GRAPH_WIDTH, NET_GRAPH_HEIGHT, 8, 0.2);

	for (i = 0; i < NET_GRAPH_WIDTH; i++) {

		j = (num_net_graph_samples - i) & (NET_GRAPH_WIDTH - 1);
		h = net_graph_samples[j].value * NET_GRAPH_HEIGHT;

		if (!h)
			continue;

		x = r_context.width - i;
		y = r_context.height - NET_GRAPH_Y - h;

		R_DrawFill(x, y, 1, h, net_graph_samples[j].color, 0.5);
	}
}
Example #2
0
/**
 * @brief
 */
static void Cl_DrawConsole_Buffer(void) {
	r_pixel_t cw, ch, height;

	R_BindFont("small", &cw, &ch);

	if (cls.state == CL_ACTIVE) {
		height = r_context.height * 0.5;
		R_DrawFill(0, 0, r_context.width, height, 7, 0.3);
	} else {
		height = r_context.height;
		R_DrawFill(0, 0, r_context.width, height, 0, 1.0);
	}

	cl_console.width = r_context.width / cw;
	cl_console.height = (height / ch) - 1;

	char *lines[cl_console.height];
	const size_t count = Con_Tail(&cl_console, lines, cl_console.height);

	r_pixel_t y = (cl_console.height - count) * ch;

	for (size_t i = 0; i < count; i++) {
		R_DrawString(0, y, lines[i], CON_COLOR_DEFAULT);
		g_free(lines[i]);
		y += ch;
	}
}
Example #3
0
/**
 * @sa SCR_DrawLoading
 */
static void SCR_DrawLoadingBar (int x, int y, int w, int h, int percent)
{
	const vec4_t color = {0.3f, 0.3f, 0.3f, 0.7f};
	const vec4_t colorBar = {0.8f, 0.8f, 0.8f, 0.7f};

	R_DrawFill(x, y, w, h, color);

	if (percent != 0)
		R_DrawFill((int)(x + (h * 0.2)), (int)(y + (h * 0.2)), (int)((w - (h * 0.4)) * percent * 0.01), (int)(h * 0.6), colorBar);
}
Example #4
0
/*
 * =================
 * UI_Draw
 * =================
 */
void UI_Draw(void)
{
    if (cls.key_dest != key_menu)
    {
        return;
    }

    // dim everything behind it down
    if ((cl.cinematictime > 0) || (cls.state == ca_disconnected))
    {
        if (R_DrawFindPic("/gfx/ui/menu_background.pcx"))
        {
            R_DrawStretchPic(0, 0, viddef.width, viddef.height, "/gfx/ui/menu_background.pcx", 1.0);
        }
        else
        {
            R_DrawFill(0, 0, viddef.width, viddef.height, 0, 0, 0, 255);
        }
    }
    // ingame menu uses alpha
    else if (R_DrawFindPic("/gfx/ui/menu_background.pcx"))
    {
        R_DrawStretchPic(0, 0, viddef.width, viddef.height, "/gfx/ui/menu_background.pcx", menu_alpha->value);
    }
    else
    {
        R_DrawFill(0, 0, viddef.width, viddef.height, 0, 0, 0, (int)(menu_alpha->value * 255));
    }

    // Knigthmare- added Psychospaz's mouse support
    UI_RefreshCursorMenu();

    m_drawfunc();

    // delay playing the enter sound until after the
    // menu has been drawn, to avoid delay while
    // caching images
    if (m_entersound)
    {
        S_StartLocalSound(menu_in_sound);
        m_entersound = false;
    }

    // Knigthmare- added Psychospaz's mouse support
    //menu cursor for mouse usage :)
    UI_Draw_Cursor();
}
Example #5
0
/**
 * @brief Renders text and images
 * @sa SEQ_InitStartup
 * @param[in] context Sequence context
 * @param[in] backgroundObjects if true, draw background objects, else display foreground objects
 */
static void SEQ_Render2D (sequenceContext_t *context, bool backgroundObjects)
{
	seq2D_t *s2d;
	int i, j;
	int height = 0;

	/* add texts */
	for (i = 0, s2d = context->obj2Ds; i < context->numObj2Ds; i++, s2d++) {
		if (!s2d->inuse)
			continue;
		if (backgroundObjects != s2d->inBackground)
			continue;

		if (s2d->relativePos && height > 0) {
			s2d->pos[1] += height;
			s2d->relativePos = false;
		}
		/* advance in time */
		for (j = 0; j < 4; j++) {
			s2d->color[j] += cls.frametime * s2d->fade[j];
			if (s2d->color[j] < 0.0)
				s2d->color[j] = 0.0;
			else if (s2d->color[j] > 1.0)
				s2d->color[j] = 1.0;
		}
		for (j = 0; j < 2; j++) {
			s2d->pos[j] += cls.frametime * s2d->speed[j];
			s2d->size[j] += cls.frametime * s2d->enlarge[j];
		}

		/* outside the screen? */
		/** @todo We need this check - but this does not work */
		/*if (s2d->pos[1] >= VID_NORM_HEIGHT || s2d->pos[0] >= VID_NORM_WIDTH)
			continue;*/

		/* render */
		R_Color(s2d->color);

		/* image can be background */
		if (s2d->image[0] != '\0') {
			const image_t *image = R_FindImage(s2d->image, it_pic);
			R_DrawImage(s2d->pos[0], s2d->pos[1], image);
		}

		/* bgcolor can be overlay */
		if (s2d->bgcolor[3] > 0.0)
			R_DrawFill(s2d->pos[0], s2d->pos[1], s2d->size[0], s2d->size[1], s2d->bgcolor);

		/* render */
		R_Color(s2d->color);

		/* gettext placeholder */
		if (s2d->text) {
			int maxWidth = (int) s2d->size[0];
			if (maxWidth <= 0)
				maxWidth = VID_NORM_WIDTH;
			height += UI_DrawString(s2d->font, s2d->align, s2d->pos[0], s2d->pos[1], s2d->pos[0], maxWidth, -1 /** @todo use this for some nice line spacing */, _(s2d->text));
		}
	}
	R_Color(NULL);
}
Example #6
0
/**
 * @brief Fills a box of pixels with a single color
 */
void UI_DrawFill (int x, int y, int w, int h, const vec4_t color)
{
	R_DrawFill(x, y, w, h, color);
}