void draw_monsters() { short i,j = 0,k; short width,height; rectangle source_rect,to_rect; location where_draw,store_loc; ter_num_t ter; rectangle monst_rects[4][4] = { {{0,0,36,28}}, {{0,7,18,21},{18,7,36,21}}, {{9,0,27,14},{9,14,27,28}}, {{0,0,18,14},{0,14,18,28},{18,0,36,14},{18,14,36,28}} }; if(is_out()) for(i = 0; i < 10; i++) if(univ.party.out_c[i].exists) { if((point_onscreen(univ.party.p_loc, univ.party.out_c[i].m_loc)) && (can_see_light(univ.party.p_loc, univ.party.out_c[i].m_loc,sight_obscurity) < 5)) { where_draw.x = univ.party.out_c[i].m_loc.x - univ.party.p_loc.x + 4; where_draw.y = univ.party.out_c[i].m_loc.y - univ.party.p_loc.y + 4; for(j = 0; univ.party.out_c[i].what_monst.monst[j] == 0 && j < 7; j++); short picture_wanted; if(j == 7) univ.party.out_c[i].exists = false; // begin watch out else { picture_wanted = get_monst_picnum(univ.party.out_c[i].what_monst.monst[j]); } // end watch out if(univ.party.out_c[i].exists) { get_monst_dims(univ.party.out_c[i].what_monst.monst[j],&width,&height); if(picture_wanted >= 1000) { for(k = 0; k < width * height; k++) { sf::Texture* src_gw; graf_pos_ref(src_gw, source_rect) = spec_scen_g.find_graphic(picture_wanted % 1000 + ((univ.party.out_c[i].direction < 4) ? 0 : (width * height)) + k); to_rect = monst_rects[(width - 1) * 2 + height - 1][k]; to_rect.offset(13 + 28 * where_draw.x,13 + 36 * where_draw.y); rect_draw_some_item(*src_gw, source_rect, terrain_screen_gworld,to_rect, sf::BlendAlpha); } } if(picture_wanted < 1000) { for(k = 0; k < width * height; k++) { source_rect = get_monster_template_rect(picture_wanted,(univ.party.out_c[i].direction < 4) ? 0 : 1,k); to_rect = monst_rects[(width - 1) * 2 + height - 1][k]; to_rect.offset(13 + 28 * where_draw.x,13 + 36 * where_draw.y); int which_sheet = m_pic_index[picture_wanted].i / 20; sf::Texture& monst_gworld = *ResMgr::get<ImageRsrc>("monst" + std::to_string(1 + which_sheet)); rect_draw_some_item(monst_gworld, source_rect, terrain_screen_gworld,to_rect, sf::BlendAlpha); } } } } } if(is_town() || is_combat()) { for(i = 0; i < univ.town.monst.size(); i++) if(univ.town.monst[i].active != 0 && !univ.town.monst[i].invisible && univ.town.monst[i].status[eStatus::INVISIBLE] <= 0) if(point_onscreen(center,univ.town.monst[i].cur_loc) && party_can_see_monst(i)) { where_draw.x = univ.town.monst[i].cur_loc.x - center.x + 4; where_draw.y = univ.town.monst[i].cur_loc.y - center.y + 4; get_monst_dims(univ.town.monst[i].number,&width,&height); for(k = 0; k < width * height; k++) { store_loc = where_draw; store_loc.x += k % width; store_loc.y += k / width; ter = univ.town->terrain(univ.town.monst[i].cur_loc.x,univ.town.monst[i].cur_loc.y); // in bed? if(store_loc.x >= 0 && store_loc.x < 9 && store_loc.y >= 0 && store_loc.y < 9 && (univ.scenario.ter_types[ter].special == eTerSpec::BED) && isHumanoid(univ.town.monst[i].m_type) && (univ.town.monst[i].active == 1 || univ.town.monst[i].target == 6) && width == 1 && height == 1) draw_one_terrain_spot((short) where_draw.x,(short) where_draw.y,10000 + univ.scenario.ter_types[ter].flag1); else if(univ.town.monst[i].picture_num >= 1000) { bool isParty = univ.town.monst[i].picture_num >= 10000; sf::Texture* src_gw; pic_num_t need_pic = (univ.town.monst[i].picture_num % 1000) + k; if(univ.town.monst[i].direction >= 4) need_pic += width * height; if(combat_posing_monster == i + 100) need_pic += (2 * width * height); graf_pos_ref(src_gw, source_rect) = spec_scen_g.find_graphic(need_pic, isParty); Draw_Some_Item(*src_gw, source_rect, terrain_screen_gworld, store_loc, 1, 0); } else { pic_num_t this_monst = univ.town.monst[i].picture_num; int pic_mode = (univ.town.monst[i].direction) < 4 ? 0 : 1; pic_mode += (combat_posing_monster == i + 100) ? 10 : 0; source_rect = get_monster_template_rect(this_monst, pic_mode, k); int which_sheet = m_pic_index[this_monst].i / 20; sf::Texture& monst_gworld = *ResMgr::get<ImageRsrc>("monst" + std::to_string(1 + which_sheet)); Draw_Some_Item(monst_gworld, source_rect, terrain_screen_gworld, store_loc, 1, 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; }