Exemplo n.º 1
0
// process this frame for the chatbox
int chatbox_process(int key_in)
{	
	int key_out;

	key_out = key_in;

	// if the chatbox hasn't explicitly been created, we can't do any processing
	if(!Chatbox_created){
		return key_out;
	}

	// process the incoming key appropriately
	if (key_in == -1) {
		key_out = Chat_window.process();
	} else {
		key_out = Chat_window.process(key_in);
	}

	// look for special keypresses
	switch(key_out){
	// line recall up one
	case KEY_UP:
		chatbox_recall_up();
		key_out = 0;
		break;
	
	// line recall down one
	case KEY_DOWN:
		chatbox_recall_down();
		key_out = 0;
		break;
	}

	// if we're supposed to be checking our own scroll buttons
	if((Chatbox_mode_flags & CHATBOX_FLAG_BUTTONS) && (Chatbox_mode_flags & CHATBOX_FLAG_DRAW_BOX)){
		if ( Chatbox_buttons[gr_screen.res][CHATBOX_SCROLL_UP].button.pressed() ) {
			chatbox_scroll_up();
		}

		if ( Chatbox_buttons[gr_screen.res][CHATBOX_SCROLL_DOWN].button.pressed() ) {
			chatbox_scroll_down();
		}

		if ( Chatbox_buttons[gr_screen.res][CHATBOX_TOGGLE_SIZE].button.pressed() ){
			chatbox_toggle_size();
		}
	}

	// check to see if the enter text button has been pressed
	if ( Chat_enter_text.pressed() ) {
		Chat_inputbox.set_focus();
	}

	// check to see if the current input text needs to be split up and sent automaticall
	chatbox_autosplit_line();	

	return key_out;
}
Exemplo n.º 2
0
void multi_pause_button_pressed(int n)
{
	switch (n) {
	// the scroll up button
	case MP_SCROLL_UP :
		chatbox_scroll_up();
		break;

	// the scroll down button
	case MP_SCROLL_DOWN :
		chatbox_scroll_down();
		break;

	// the exit mission
	case MP_EXIT_MISSION :
		multi_quit_game(PROMPT_ALL);
		break;
	}
}
Exemplo n.º 3
0
// int Test_color = 0;
void chatbox_add_line(const char *msg, int pid, int add_id)
{
	int backup;
	int	n_lines,idx;
	int	n_chars[3];		
	const char	*p_str[3];			// for the initial line (unindented)
	char msg_extra[CHATBOX_STRING_LEN];

	if(!Chatbox_created){
		return;
	}

	// maybe stick on who sent the message	
	if(add_id){
		if(MULTI_STANDALONE(Net_players[pid])){
			sprintf(msg_extra, NOX("%s %s"), NOX("<SERVER>"), msg );
		} else {
			sprintf(msg_extra, NOX("%s: %s"), Net_players[pid].m_player->short_callsign, msg );
		}
	} else {
		strcpy_s(msg_extra,msg);
	}	
	Assert(strlen(msg_extra) < (CHATBOX_STRING_LEN - 2));	

	// split the text up into as many lines as necessary
	n_lines = split_str(msg_extra, Chatbox_disp_w, n_chars, p_str, 3);
	Assert(n_lines != -1);	

	// setup the first line -- be sure to clear out the line
	memset( Brief_chat_lines[Brief_current_add_line], 0, CHATBOX_STRING_LEN );

	// add the player id #
	Brief_chat_lines[Brief_current_add_line][0] = (char)(pid % 16);	
	// Brief_chat_lines[Brief_current_add_line][0] = (char)Test_color;	
	// Test_color = (Test_color == MAX_PLAYERS - 1) ? 0 : Test_color++;

	// set the indent to 0
	Brief_chat_indents[Brief_current_add_line] = 0;

	// copy in the chars
	strncpy(&Brief_chat_lines[Brief_current_add_line][1],p_str[0],CHATBOX_STRING_LEN - 1);
	if(n_chars[0] >= CHATBOX_STRING_LEN){
		Brief_chat_lines[Brief_current_add_line][CHATBOX_STRING_LEN - 1] = '\0';
	} else {
		Brief_chat_lines[Brief_current_add_line][n_chars[0] + 1] = '\0';
	}
	
	// increment the total line count if we haven't reached the max already
	if(Num_brief_chat_lines<MAX_BRIEF_CHAT_LINES){
		Num_brief_chat_lines++;
	}
	
	// get the index of the next string to add text to
	Brief_current_add_line = Brief_chat_next_index[Brief_current_add_line];	
	
	// if we have more than 1 line, re-split everything so that the rest are indented
	if(n_lines > 1){
		// split up the string after the first break-marker
		n_lines = split_str(msg_extra + n_chars[0],Chatbox_disp_w - CHAT_LINE_INDENT,n_chars,p_str,3);
		Assert(n_lines != -1);		

		// setup these remaining lines
		for(idx=0;idx<n_lines;idx++){
			// add the player id#
			Brief_chat_lines[Brief_current_add_line][0] = (char)(pid % 16);	

			// add the proper indent
			Brief_chat_indents[Brief_current_add_line] = CHAT_LINE_INDENT;

			// copy in the line text itself
			strncpy(&Brief_chat_lines[Brief_current_add_line][1],p_str[idx],CHATBOX_STRING_LEN-1); 
			if(n_chars[idx] >= CHATBOX_STRING_LEN){
				Brief_chat_lines[Brief_current_add_line][CHATBOX_STRING_LEN - 1] = '\0';
			} else {
				Brief_chat_lines[Brief_current_add_line][n_chars[idx] + 1] = '\0';
			}
			
			// increment the total line count if we haven't reached the max already
			if(Num_brief_chat_lines<MAX_BRIEF_CHAT_LINES){
				Num_brief_chat_lines++;
			}
			
			// get the index of the next line to add text to
			Brief_current_add_line = Brief_chat_next_index[Brief_current_add_line];				
		}
	}
			
	// COMMAND LINE OPTION
	if(Cmdline_multi_stream_chat_to_file && Multi_chat_stream!=NULL && msg[0] != '\0'){ // stream to the file if we're supposed to
		cfwrite_string(msg,Multi_chat_stream);
		cfwrite_char('\n',Multi_chat_stream);
	}	

	// if this line of text is from the player himself, automatically go to the bottom of
	// the chat list
	if(pid == MY_NET_PLAYER_NUM){
		if(Num_brief_chat_lines > Chatbox_max_lines){
			Brief_start_display_index = Brief_current_add_line;
			for(backup = 1;backup <= Chatbox_max_lines;backup++){
				Brief_start_display_index = Brief_chat_prev_index[Brief_start_display_index];
			}
		}
	}
	// if we have enough lines of text to require scrolling, scroll down by one.
	else { 
		chatbox_scroll_down();
	}	
}