Exemple #1
0
void remote_draw_names_render(void)
{
	int					n,x,y,text_size;
	d3col				col;
	obj_type			*obj;
	
	if (!net_setup.client.joined) return;
	if (!setup.network.show_names) return;

	gl_2D_view_interface();
	
	glDisable(GL_DEPTH_TEST);
	
		// draw all names

	text_size=-1;

	obj=server.objs;

	for (n=0;n!=server.count.obj;n++) {
	
		if (obj->draw.remote_name.on) {

				// get 2D position in screen resolution

			x=obj->draw.remote_name.proj_pnt.x;
			y=setup.screen.y_sz-obj->draw.remote_name.proj_pnt.y;

				// covert to interface resolution

			x=(x*hud.scale_x)/setup.screen.x_sz;
			y=(y*hud.scale_y)/setup.screen.y_sz;

				// draw text
				
			if (text_size!=obj->draw.remote_name.size) {
				text_size=obj->draw.remote_name.size;
				gl_text_start(text_size);
			}

			object_get_tint(obj,&col);
			gl_text_draw(x,y,obj->name,tx_center,FALSE,&col,obj->draw.remote_name.fade);
		}
		
		obj++;
	}

	gl_text_end();		// can call end without a start
}
Exemple #2
0
JSValueRef js_obj_chat_func(JSContextRef cx,JSObjectRef func,JSObjectRef j_obj,size_t argc,const JSValueRef argv[],JSValueRef *exception)
{
	char			msg[max_view_chat_str_len];
	d3col			col;
	obj_type		*obj;
	
	if (!script_check_param_count(cx,func,argc,1,exception)) return(script_null_to_value(cx));
	
	obj=object_get_attach(j_obj);
	script_value_to_string(cx,argv[0],msg,max_view_chat_str_len);
	
	if ((net_setup.mode!=net_mode_none) && (object_networkable(obj))) net_client_send_chat(obj,msg);
	object_get_tint(obj,&col);
	chat_add_message(obj,msg,&col);

	return(script_null_to_value(cx));
}
Exemple #3
0
bool player_message_input(int tick,obj_type *obj)
{
	int				len;
	char			ch,nstr[chat_str_len];
	char			*c,*msg;
	d3col			col;
	
	if (!net_setup.client.joined) return(TRUE);
	
		// scores
		
	if (input_action_get_state(nc_score)) {
		if (!network_score_key_down) {
			hud.score.on=!hud.score.on;
			network_score_key_down=TRUE;
		}
	}
	else {
		network_score_key_down=FALSE;
	}
		
		// chatting

	if (hud.chat.type_on) {
	
			// get last raw key as character
			
		ch=input_get_last_raw_key();
		input_clear_last_raw_key();
		
		if (ch==0x0) return(FALSE);
		
			// get current message len
			
		msg=hud.chat.type_str;
		len=strlen(msg);
		
			// escape cancels
			
		if (ch==0x1B) {
			hud.chat.type_on=FALSE;
			return(FALSE);
		}
		
			// return ends entry
			
		if (ch==0xD) {
			hud.chat.type_on=FALSE;
			if (len>1) {
				msg[len-1]=0x0;
				net_client_send_chat(obj->remote.uid,msg);
				object_get_tint(obj,&col);
				chat_add_message(tick,obj->name,msg,&col);
			}
			return(FALSE);
		}
		
			// delete
			
		if (ch==0x8) {
			len-=2;
			if (len<0) len=0;

			msg[len++]='_';
			msg[len]=0x0;

			return(FALSE);
		}
		
			// eliminate certain characters
			
		if (((ch<'!') || (ch>'z')) && (ch!=0x20)) return(FALSE);
		
			// force start a new line if too many characters
			
		if (len>=(chat_str_len-1)) {
			nstr[0]=0x0;
			
			c=strrchr(msg,' ');
			if (c!=NULL) {
				if ((int)(c-msg)>5) {
					strcpy(nstr,(c+1));
					*c=0x0;
				}
			}
			
			msg[len-1]=0x0;
			net_client_send_chat(obj->remote.uid,msg);
			object_get_tint(obj,&col);
			chat_add_message(tick,obj->name,msg,&col);
			
			strcpy(msg,nstr);
			len=strlen(msg);
		}
		
			// add new character
			
		if (len>0) len--;
		
		msg[len++]=ch;
		msg[len++]='_';
		msg[len]=0x0;
	
		return(FALSE);
	}
	
	if (input_action_get_state(nc_message)) {
		hud.chat.type_on=TRUE;
		
		input_clear_all_last_raw_key();
		
		hud.chat.type_str[0]='_';
		hud.chat.type_str[1]=0x0;
		
		return(FALSE);
	}
	
	return(TRUE);
}