Example #1
0
// We need a seperate function, since our messages are in colour... and transparent
void VXSCR_DrawTrackerString (void)
{
	byte	rgba[4];
	char	*start, image[256], fullpath[MAX_PATH];
	int		l;
	int		j;
	int		x, y;
	int		i, printable_chars;
	float	alpha = 1;
	float	scale = bound(0.1, amf_tracker_scale.value, 10);
	float	im_scale = bound(0.1, amf_tracker_images_scale.value, 10);

	StringToRGB(amf_tracker_frame_color.string);

	if (!active_track)
		return;

	memset(rgba, 255, sizeof(byte) * 4);

	y = vid.height * 0.2 / scale + amf_tracker_y.value;

	// Draw the max allowed trackers allowed at the same time
	// the latest ones are always shown.
	for (i = 0; i < max_active_tracks; i++)
	{
		// Time expired for this tracker, don't draw it.
		if (trackermsg[i].die < r_refdef2.time)
			continue;

		// Get the start of the tracker message.
		start = trackermsg[i].msg;

		// Fade the text as it gets older.
		alpha = min(1, (trackermsg[i].die - r_refdef2.time) / 2);

		// Loop through the tracker message and parse it.
		while (start[0])
		{
			l = printable_chars = 0;

			// Find the number of printable characters for the next line.
			while (start[l] && start[l] != '\n')
			{
				// Look for any escape codes for images and color codes.

				// Image escape.
				if (start[l] == '\\') 
				{
					// We found opening slash, get image name now.
					int from, to;

					from = to = ++l;

					for( ; start[l]; l++) 
					{
						if (start[l] == '\n')
							break; // Something bad, we didn't find a closing slash.

						if (start[l] == '\\')
							break; // Found a closing slash.

						to = l + 1;
					}

					if (to > from)
						printable_chars += 2; // We got potential image name, treat image as two printable characters.

					if (start[l] == '\\')
						l++; // Advance.

					continue;
				}

				// Get rid of color codes.
				if (start[l] == '&')
				{
					if (start[l + 1] == 'r') 
					{
						l += 2;
						continue;
					}
					else if (start[l + 1] == 'c' && start[l + 2] && start[l + 3] && start[l + 4]) 
					{
						l += 5;
						continue;
					}
				}

				printable_chars++;	// Increment count of printable chars.
				l++;				// Increment count of any chars in string untill end or new line.
			}

			// Place the tracker.
			x = scale * (amf_tracker_align_right.value ? (vid.width / scale - printable_chars * 8) - 8 : 8);
			x += amf_tracker_x.value;

			// Draw the string.
			for (j = 0; j < l;)
			{
				if (start[j] == '\\') 
				{ 
					// We found opening slash, get image name now
					int from, to;

					from = to = ++j;

					for( ; start[j]; j++) 
					{
						if (start[j] == '\n')
							break; // Something bad, we does't found closing slash.

						if (start[j] == '\\')
							break; // Found closing slash.

						to = j + 1;
					}

					if (to > from) 
					{ 
						// We got potential image name, treat image as two printable characters.
						mpic_t *pic;
						int size = to - from;

						size = min(size, (int)sizeof(image) - 1);

						memcpy(image, (start + from), size); // Copy image name to temp buffer.
						image[size] = 0;

						if (image[0])
						{
							snprintf(fullpath, sizeof(fullpath), "textures/tracker/%s", image);

							if ((pic = Draw_CachePicSafe(fullpath, false, true)))
							{
								Draw_FitPic(
										(float)x - 0.5 * 8 * 2 * (im_scale - 1) * scale, 
										(float)y - 0.5 * 8 * (im_scale - 1) * scale, 
										im_scale * 8 * 2 * scale,
										im_scale * 8 * scale, pic);
							}
						}

						x += 8 * 2 * scale;
					}

					if (start[j] == '\\')
						j++; // Advance.

					continue;
				}

				if (start[j] == '&') 
				{
					if (start[j + 1] == 'r')	
					{
						memset(rgba, 255, sizeof(byte) * 4);
						j += 2;
						continue;
					}
					else if (start[j + 1] == 'c' && start[j + 2] && start[j + 3] && start[j + 4])
					{
						rgba[0] = (byte)(255 * ((float)(start[j + 2] - '0') / 9));
						rgba[1] = (byte)(255 * ((float)(start[j + 3] - '0') / 9));
						rgba[2] = (byte)(255 * ((float)(start[j + 4] - '0') / 9));

						j += 5;
						continue;
					}
				}

				rgba[3] = 255 * alpha;
				Draw_SColoredCharacterW (x, y, char2wc(start[j]), RGBAVECT_TO_COLOR(rgba), scale);

				j++;
				x += 8 * scale;
			}

			y += 8 * scale;	// Next line.

			start += l;

			if (*start == '\n')
				start++; // Skip the \n
		}
	}
}
Example #2
0
//
// Button - Set the hover image for the button when it is toggled.
//
void EZ_button_SetToggledHoverImage(ez_button_t *button, const char *toggled_hover_image)
{
	button->toggled_hover_image = toggled_hover_image ? Draw_CachePicSafe(toggled_hover_image, false, true) : NULL;
}
Example #3
0
//
// Button - Set the hover image for the button.
//
void EZ_button_SetHoverImage(ez_button_t *button, const char *hover_image)
{
	button->hover_image = hover_image ? Draw_CachePicSafe(hover_image, false, true) : NULL;
}
Example #4
0
//
// Button - Set the hover image for the button.
//
void EZ_button_SetPressedImage(ez_button_t *button, const char *pressed_image)
{
	button->pressed_image = pressed_image ? Draw_CachePicSafe(pressed_image, false, true) : NULL;
}
Example #5
0
//
// Button - Set the normal image for the button.
//
void EZ_button_SetNormalImage(ez_button_t *button, const char *normal_image)
{
	button->normal_image = normal_image ? Draw_CachePicSafe(normal_image, false, true) : NULL;
}