示例#1
0
void display_acceuil(game_state* s,displayer* d)
{
    blit_background(d,s->background);
    blit_text(d,"Quel est ton nom ? ",370,300);
    blit_text(d,get_str(s->common_data->name),500,400);
    flip_screen(d);
}
示例#2
0
int get_text(struct s_context *cxt, const char * msg, char * input_text)
{
	int got_text = 0;

	char tmp[32] = {""};

	SDL_Rect txt;
	SDL_Rect input_box;

	SDL_Event ev;

	txt.x = 120;
	txt.y = 180;

	input_box.h = 40;
	input_box.w = 300;
	input_box.x = 170;
	input_box.y = 310;

	clear_screen(cxt);

	blit_text(cxt, 30, msg, "res/f.ttf", txt);

	while(!got_text)
	{
		SDL_FillRect(cxt->screen, &input_box, SDL_MapRGB(cxt->screen->format, 255, 255, 255));

		while(SDL_PollEvent(&ev))
		{
			const Uint8 *keybrd =  SDL_GetKeyboardState(NULL);

			if(keybrd[SDL_SCANCODE_BACKSPACE])
				tmp[strlen(tmp) - 1] = '\0';

			else if(keybrd[SDL_SCANCODE_RETURN])
				got_text = 1;

			if(ev.type == SDL_TEXTINPUT)
				strcat(tmp, ev.text.text);

			else if(ev.type == SDL_QUIT)
				return SDL_QUIT;
		}

		blit_text(cxt, 30, tmp, "res/f.ttf", input_box);

		show(*cxt);
	}

	sscanf(tmp, "%s", input_text);

	return 0;
}
示例#3
0
/*
	blit the shadow mask of the text
*/
static void blit_text_string_mask(char *str, Color4 *color, int max_width, int flags) {
	blit_text(0, 1, str, color, max_width, flags);
	blit_text(2, 1, str, color, max_width, flags);
	blit_text(1, 0, str, color, max_width, flags);
	blit_text(1, 2, str, color, max_width, flags);

	blit_text(0, 0, str, color, max_width, flags);
	blit_text(2, 0, str, color, max_width, flags);
	blit_text(0, 2, str, color, max_width, flags);
	blit_text(2, 2, str, color, max_width, flags);
}
示例#4
0
void
Display::blit_image(string img, SDL_Rect p, int center){

	SDL_Surface *image = NULL;
	image = SDL_LoadBMP(img.c_str());
	if(!image) {
		SDL_Color c = {255, 0, 0};
		blit_text("missing", "RabidScience.ttf", 20,c,p);
	}else{
		if (center == 1){
			p.x = p.x - image->w/2;
			p.y = p.y - image->h/2;
		}
		SDL_BlitSurface(image, NULL, screen, &p);
	}
	SDL_FreeSurface(image);
}
示例#5
0
void blit_button(displayer* d, bouton* b)
{
    TTF_SetFontStyle(d->police,b->style);
    blit_text(d,get_str(b->text),b->x,b->y);
    TTF_SetFontStyle(d->police,TTF_STYLE_NORMAL);
}
示例#6
0
/*
	first blit black outline, then blit text in color
*/
static void blit_text_string(char *str, TextColor color, int max_width, int flags) {
	blit_text_string_mask(str, &text_colors[BLACK], max_width, flags);
	blit_text(1, 1, str, &text_colors[color], max_width, flags);
}
示例#7
0
void render_servers()
{
	if(r_DrawConsole)
		return;
	
	if(server_discovery_started)
	{
		pthread_mutex_lock(&servers_mutex);
		
		blit_text(0, vid_height * 5 / 6, 0xff, 0xff, 0xff, 
			s_backbuffer, "Servers unqueried:");
	
		blit_text(150, vid_height * 5 / 6, 0xff, 0xff, 0xff, 
			s_backbuffer, "%u", num_servers_unqueried);

		blit_text(0, vid_height * 5 / 6 + 14, 0xff, 0xff, 0xff, 
			s_backbuffer, "Servers queried:");
		
		blit_text(150, vid_height * 5 / 6 + 14, 0xff, 0xff, 0xff, 
			s_backbuffer, "%u", num_servers_queried);
		
		blit_text(0, vid_height * 5 / 6 + 28, 0xff, 0xff, 0xff, 
			s_backbuffer, "Servers found:");
		
		blit_text(150, vid_height * 5 / 6 + 28, 0xff, 0xff, 0xff, 
			s_backbuffer, "%u", num_servers_found);

		if(num_servers_new_proto)
		{
			blit_text(0, vid_height * 5 / 6 + 42, 0xff, 0xff, 0xff, 
				s_backbuffer, "Servers found requiring new version:");
		
			blit_text(275, vid_height * 5 / 6 + 42, 0xff, 0xff, 0xff, 
				s_backbuffer, "%u", num_servers_new_proto);
		}

		
		blit_text(50, vid_height / 6, 0xff, 0xff, 0xff, 
			s_backbuffer, "Server");

		blit_text(50 + 264, vid_height / 6, 0xff, 0xff, 0xff, 
			s_backbuffer, "Port");

		blit_text(50 + 264 + 64, vid_height / 6, 0xff, 0xff, 0xff, 
			s_backbuffer, "Ping");

		blit_text(50 + 264 + 64 + 64, vid_height / 6, 0xff, 0xff, 0xff, 
			s_backbuffer, "Key");
			
		blit_text(50 + 264 + 64 + 64, vid_height / 6 + 16, 0xff, 0xff, 0xff, 
			s_backbuffer, "Required?");
			

		blit_text(50 + 32, vid_height / 6 + 14, 0xff, 0xff, 0xff, 
			s_backbuffer, "Map");
		
		blit_text(50 + 32 + 264, vid_height / 6 + 14, 0xff, 0xff, 0xff, 
			s_backbuffer, "Players");

		struct found_server_t *cserver = found_servers;
		int i = 1;
		int server = 0;
			
		while(cserver && i <= 8)
		{
			if(server >= top_server_visible)
			{
				blit_text(50, vid_height / 6 + i * 32, 0xef, 0x6f, 0xff, 
					s_backbuffer, "%s", cserver->host_name->text);
	
				blit_text(50 + 264, vid_height / 6 + i * 32, 0xef, 0x6f, 0xff, 
					s_backbuffer, "%u", ntohs(cserver->port));
	
				blit_text(50 + 264 + 64, vid_height / 6 + i * 32, 0xef, 0x6f, 0xff, 
					s_backbuffer, "%.2fms", cserver->ping * 1000.0);
	
				if(cserver->authenticating)
				{
					blit_text_centered(50 + 264 + 64 + 64 + 12, vid_height / 6 + i * 32 + 6, 
						0xef, 0x6f, 0xff, s_backbuffer, "Y");
				}
	
				blit_text(50 + 32, vid_height / 6 + i * 32 + 14, 0xef, 0x6f, 0xff, 
					s_backbuffer, "%s", cserver->map_name->text);
				
				blit_text(50 + 32 + 264, vid_height / 6 + i * 32 + 14, 0xef, 0x6f, 0xff, 
					s_backbuffer, "%u/%u", cserver->num_players, cserver->max_players);
				
				if(server == selected_server)
				{
					struct blit_params_t params;
						
					params.red = 0x54;
					params.green = 0xa6;
					params.blue = 0xf9;
					params.alpha = 0x7f;
					
					params.dest = s_backbuffer;
					params.dest_x = 48;
					params.dest_y = vid_height / 6 + i * 32 - 2;
					params.width = 475;
					params.height = 32;
				
					alpha_draw_rect(&params);
				}
				
				i++;
			}
			
			LL_NEXT(cserver);
			server++;
		}
		
		pthread_mutex_unlock(&servers_mutex);
	}
}