Beispiel #1
0
void play_see_monster_str(unsigned short m, location monst_loc) {
	short pic, spec;
	ePicType type;
	pic = univ.scenario.scen_monsters[m].picture_num;
	type =  get_monst_pictype(m);
	spec = univ.scenario.scen_monsters[m].see_spec;
	// Then run the special, if any
	if(spec > -1){
		queue_special(eSpecCtx::SEE_MONST, 0, spec, monst_loc);
	}
}
Beispiel #2
0
void place_talk_str(char *str_to_place,char *str_to_place2,short color,Rect c_rect)
// color 0 - regular  1 - darker
{
	Rect area_rect;
	
	Rect face_rect = {6,6,38,38};
	Rect title_rect = {19,48,42,260};
	Rect dest_rect,help_from = {85,36,101,54};
	Str255 fn2 = "\pDungeon Bold";
	Str255 fn3 = "\pPalatino";

	short i,j,str_len,line_height = 17;
	Str255 p_str,str,str_to_draw,str_to_draw2;
	short text_len[257],current_rect,store_last_word_break = 0,start_of_last_kept_word = -1;
	short last_line_break = 0,last_word_break = 0,on_what_line = 0,last_stored_word_break = 0;
	bool force_skip = false;
	short face_to_draw;
	
	RGBColor c[7] = {{0,0,0},{0,0,32767},{0,0,14535},{0,0,26623},{0,0,59391},
	{0,40959,0},{0,24575,0}};
	
	GrafPtr old_port;
	
	GetPort(&old_port);
	SetPort( talk_gworld);

	// This redundancy is to try to keep the font from disappearing
	GetFNum(fn2,&dungeon_font_num);
	if (dungeon_font_num == 0)
		GetFNum(fn3,&dungeon_font_num);
		
	TextFont(dungeon_font_num);
	//TextFont(geneva_font_num);
	TextSize(18);
	TextFace(0);

	if (c_rect.right > 0) {
		ClipRect(&c_rect);	
		}

	GetPortBounds(talk_gworld,&area_rect);
	FrameRect(&area_rect);
	InsetRect(&area_rect,1,1);
	tileImage(area_rect,bg_gworld,bg[12]);

	// Put help button
	GetPortBounds(dlg_buttons_gworld[3][0], &help_from);
	talk_help_rect.right = talk_help_rect.left + help_from.right - help_from.left;
	talk_help_rect.bottom = talk_help_rect.top + help_from.bottom - help_from.top;
	rect_draw_some_item(dlg_buttons_gworld[3][0],help_from,talk_gworld,talk_help_rect);
	
	// Place face of talkee
	if ((color == 0) && (c_rect.right == 0)) { 
		////
		SetPort(GetWindowPort(mainPtr));
		face_to_draw = scenario.scen_monsters[store_monst_type].default_facial_pic;
		if (store_talk_face_pic >= 0)
			face_to_draw = store_talk_face_pic;
		if (store_talk_face_pic >= 1000) {
			draw_dialog_graphic(  talk_gworld, face_rect, store_talk_face_pic, PICT_CUSTOM + PICT_TALK, false,1);
			}
			else {
				i = get_monst_picnum(store_monst_type);
				if (face_to_draw <= 0)
					draw_dialog_graphic(talk_gworld, face_rect, i, get_monst_pictype(store_monst_type), false,1);
				else draw_dialog_graphic(talk_gworld, face_rect, face_to_draw, PICT_MONST, false,1);
			}
		SetPort( talk_gworld);
		}
	// Place name oftalkee
	RGBForeColor(&c[3]);
	dest_rect = title_rect;
	OffsetRect(&dest_rect,1,1);
	char_port_draw_string( talk_gworld,dest_rect,title_string,2,18);
	OffsetRect(&dest_rect,-1,-1);
	RGBForeColor(&c[4]);
	char_port_draw_string( talk_gworld,dest_rect,title_string,2,18);
		
	// Place buttons at bottom.
	if (color == 0)
		RGBForeColor(&c[5]);
		else RGBForeColor(&c[6]);
	for (i = 0; i < 9; i++) 
		if ((talk_end_forced == false) || (i == 6) || (i == 5)) {
			OffsetRect(&preset_words[i].word_rect,0,8);
			char_port_draw_string( talk_gworld,preset_words[i].word_rect,preset_words[i].word,2,18);
			OffsetRect(&preset_words[i].word_rect,0,-8);
			}
	// Place bulk of what said. Save words.
	//TextSize(14);
	if (color == 0)
		for (i = 0; i < 50; i++)
			store_words[i].word_rect.left = store_words[i].word_rect.right = 0;
			
	str_len = (short) strlen((char *)str_to_place);
	if (str_len == 0) {
		sprintf((char *) str_to_place,".");
		}	
	strcpy((char *) str,str_to_place);
	strcpy((char *) p_str,str_to_place);
	c2pstr((char*)p_str);	
	for (i = 0; i < 257; i++)
		text_len[i]= 0;
	MeasureText(256,p_str,text_len);

	dest_rect = word_place_rect;

	current_rect = 0;
	
	if (color == 0)
		RGBForeColor(&c[2]);
		else RGBForeColor(&c[1]);
	MoveTo(dest_rect.left + 1 , dest_rect.top + 1 + line_height * on_what_line + 9);
	//for (i = 0;text_len[i] != text_len[i + 1], i < str_len;i++) {
	for (i = 0;i < str_len;i++) {
		if (((str[i] != 39) && ((str[i] < 65) || (str[i] > 122)) && ((str[i] < 48) || (str[i] > 57))) && (color == 0)) { // New word, so set up a rect
			if (((i - store_last_word_break >= 4) || (i >= str_len - 1)) 
			 && (i - last_stored_word_break >= 4) && (talk_end_forced == false)) {
				store_words[current_rect].word_rect.left = dest_rect.left + (text_len[store_last_word_break] - text_len[last_line_break]) - 2;
				store_words[current_rect].word_rect.right = dest_rect.left + (text_len[i + 1] - text_len[last_line_break]) - 1;
				store_words[current_rect].word_rect.top = dest_rect.top + 1 + line_height * on_what_line - 5;
				store_words[current_rect].word_rect.bottom = dest_rect.top + 1 + line_height * on_what_line + 13;
				
				if ((str[store_last_word_break] < 48) || (str[store_last_word_break] == 96) 
					|| (str[store_last_word_break] > 122)
					|| ((str[store_last_word_break] >= 58) && (str[store_last_word_break] <= 64)))
						store_last_word_break++;

				// adjust for if this word will be scrolled down
				//if (((text_len[i] - text_len[last_line_break] > (dest_rect.right - dest_rect.left - 6)) 
		  		//	&& (last_word_break > last_line_break)) || (str[i] == '|')) {
		  		//	OffsetRect(&store_words[current_rect].word_rect,5 + -1 * store_words[current_rect].word_rect.left,line_height);
		  		//	}
				
				store_words[current_rect].word[0] = str[store_last_word_break];
				store_words[current_rect].word[1] = str[store_last_word_break + 1];
				store_words[current_rect].word[2] = str[store_last_word_break + 2];
				store_words[current_rect].word[3] = str[store_last_word_break + 3];
				store_words[current_rect].word[4] = 0;
				for (j = 0; j < 4; j++)
					if ((store_words[current_rect].word[j] >= 65) && (store_words[current_rect].word[j] <= 90))
						store_words[current_rect].word[j] += 32;
				if (scan_for_response(store_words[current_rect].word) < 0) {
					store_words[current_rect].word_rect.left = store_words[current_rect].word_rect.right = 0;
					}
					else {
						start_of_last_kept_word = store_last_word_break;
						if (current_rect < 49)
							current_rect++;
					
						//FrameRect(&store_words[current_rect].word_rect);
						}
				last_stored_word_break = i + 1;
				}
			}
		if (((text_len[i] - text_len[last_line_break] > (dest_rect.right - dest_rect.left - 6)) 
		  && (last_word_break > last_line_break)) || (str[i] == '|') || (i == str_len - 1)) {
			if (str[i] == '|') {
				str[i] = ' ';
		 		force_skip = true;
	 			}
	 		store_last_word_break = last_word_break;
	 		if (i == str_len - 1)
	 			last_word_break = i + 2;
			sprintf((char *)str_to_draw,"                                                         ");
			strncpy ((char *) str_to_draw,(char *) str + last_line_break,(size_t) (last_word_break - last_line_break - 1));
			sprintf((char *)str_to_draw2," %s",str_to_draw);
			str_to_draw2[0] = (char) strlen((char *)str_to_draw);
			DrawString(str_to_draw2);
			on_what_line++;
			MoveTo(dest_rect.left + 1 , dest_rect.top + 1 + line_height * on_what_line + 9);
			last_line_break = last_word_break;
			if (force_skip == true) {
				force_skip = false;
				i++;
				last_line_break++;
				last_word_break++;
				}
			if ((start_of_last_kept_word >= last_line_break) && (current_rect > 0)) {
				//SysBeep(2);
	 			OffsetRect(&store_words[current_rect - 1].word_rect,5 + -1 * store_words[current_rect - 1].word_rect.left,line_height);				
				}
		}
		if (str[i] == ' ') { // New word
			store_last_word_break = last_word_break = i + 1;
			}
		if (on_what_line == 17)
			i = 10000;
		}
		
	// Now for string 2
	str_len = (short) strlen((char *)str_to_place2);
	start_of_last_kept_word = -1;
	
	if (str_len > 0) {
		
	strcpy((char *) str,str_to_place2);
	strcpy((char *) p_str,str_to_place2);
	c2pstr((char*)p_str);	
	for (i = 0; i < 257; i++)
		text_len[i]= 0;
	MeasureText(256,p_str,text_len);
	
	last_line_break = store_last_word_break = last_word_break = last_stored_word_break = 0;
	MoveTo(dest_rect.left + 1 , dest_rect.top + 1 + line_height * on_what_line + 9);
	//for (i = 0;text_len[i] != text_len[i + 1], i < str_len;i++) 
	for (i = 0;i < str_len;i++) {
		if (((str[i] != 39) && ((str[i] < 65) || (str[i] > 122)) && ((str[i] < 48) || (str[i] > 57))) && (color == 0))  { // New word, so set up a rect
			if (((i - store_last_word_break >= 4) || (i >= str_len - 1)) 
			 && (i - last_stored_word_break >= 4) && (talk_end_forced == false)) {
				store_words[current_rect].word_rect.left = dest_rect.left + (text_len[store_last_word_break] - text_len[last_line_break]) - 2;
				store_words[current_rect].word_rect.right = dest_rect.left + (text_len[i + 1] - text_len[last_line_break]) - 1;
				store_words[current_rect].word_rect.top = dest_rect.top + 1 + line_height * on_what_line - 5;
				store_words[current_rect].word_rect.bottom = dest_rect.top + 1 + line_height * on_what_line + 13;
				
				if ((str[store_last_word_break] < 48) || (str[store_last_word_break] == 96) 
					|| (str[store_last_word_break] > 122)
					|| ((str[store_last_word_break] >= 58) && (str[store_last_word_break] <= 64)))
						store_last_word_break++;

				// adjust for if this word will be scrolled down
				//if (((text_len[i] - text_len[last_line_break] > (dest_rect.right - dest_rect.left - 6)) 
		  		//	&& (last_word_break > last_line_break)) || (str[i] == '|')) {
		  		//	OffsetRect(&store_words[current_rect].word_rect,5 + -1 * store_words[current_rect].word_rect.left,line_height);
		  		//	}
				store_words[current_rect].word[0] = str[store_last_word_break];
				store_words[current_rect].word[1] = str[store_last_word_break + 1];
				store_words[current_rect].word[2] = str[store_last_word_break + 2];
				store_words[current_rect].word[3] = str[store_last_word_break + 3];
				store_words[current_rect].word[4] = 0;
				for (j = 0; j < 4; j++)
					if ((store_words[current_rect].word[j] >= 65) && (store_words[current_rect].word[j] <= 90))
						store_words[current_rect].word[j] += 32;
				if (scan_for_response(store_words[current_rect].word) < 0)
					store_words[current_rect].word_rect.left = store_words[current_rect].word_rect.right = 0;
					else {
						start_of_last_kept_word = store_last_word_break;
						if (current_rect < 49)
							current_rect++;
					
						//FrameRect(&store_words[current_rect].word_rect);
						}
				last_stored_word_break = i + 1;
				}
			}
		if (((text_len[i] - text_len[last_line_break] > (dest_rect.right - dest_rect.left - 6)) 
		  && (last_word_break > last_line_break)) || (str[i] == '|') || (i == str_len - 1)) {
			if (str[i] == '|') {
				str[i] = ' ';
		 		force_skip = true;
	 			}
	 		store_last_word_break = last_word_break;
	 		if (i == str_len - 1)
	 			last_word_break = i + 2;
			sprintf((char *)str_to_draw,"                                                         ");
			strncpy ((char *) str_to_draw,(char *) str + last_line_break,(size_t) (last_word_break - last_line_break - 1));
			sprintf((char *)str_to_draw2," %s",str_to_draw);
			str_to_draw2[0] = (char) strlen((char *)str_to_draw);
			DrawString(str_to_draw2);
			on_what_line++;
			MoveTo(dest_rect.left + 1 , dest_rect.top + 1 + line_height * on_what_line + 9);
			last_line_break = last_word_break;
			if (force_skip == true) {
				force_skip = false;
				i++;
				last_line_break++;
				last_word_break++;
				}
			if ((start_of_last_kept_word >= last_line_break) && (current_rect > 0)) {
	 			OffsetRect(&store_words[current_rect - 1].word_rect,5 + -1 * store_words[current_rect - 1].word_rect.left,line_height);				
				}
		}
		if (str[i] == ' ') { // New word
			store_last_word_break = last_word_break = i + 1;
			}
		if (on_what_line == 17)
			i = 10000;
		}
	}
	
	ForeColor(blackColor);
	GetPortBounds(talk_gworld,&area_rect);
	Rect oldRect = area_rect;
	ClipRect(&area_rect);
	
	// Finally place processed graphics
	SetPort(GetWindowPort(mainPtr));
	rect_draw_some_item(talk_gworld,oldRect,talk_area_rect,ul);
	SetPort(old_port);
	
	// Clean up strings
	for (i = 0; i < 50; i++)
		for (j = 0; j < 4; j++)
			if ((store_words[current_rect].word[j] >= 65) && (store_words[current_rect].word[j] <= 90))
				store_words[current_rect].word[j] += 32;

}