void draw_town_boat(location center) { location where_draw; rectangle source_rect; short i; sf::Texture& vehicle_gworld = *ResMgr::get<ImageRsrc>("vehicle"); for(i = 0; i < univ.party.boats.size(); i++) if((univ.party.boats[i].which_town == univ.town.num) && ((point_onscreen(center, univ.party.boats[i].loc)) && (can_see_light(center, univ.party.boats[i].loc,sight_obscurity) < 5) && (univ.party.in_boat != i) && (pt_in_light(center,univ.party.boats[i].loc)))) { where_draw.x = univ.party.boats[i].loc.x - center.x + 4; where_draw.y = univ.party.boats[i].loc.y - center.y + 4; Draw_Some_Item(vehicle_gworld, calc_rect(1,0), terrain_screen_gworld, where_draw, 1, 0); } for(i = 0; i < univ.party.horses.size(); i++) if((univ.party.horses[i].which_town == univ.town.num) && ((point_onscreen(center, univ.party.horses[i].loc)) && (can_see_light(center, univ.party.horses[i].loc,sight_obscurity) < 5) && (univ.party.in_horse != i) && (pt_in_light(center,univ.party.horses[i].loc)))) { where_draw.x = univ.party.horses[i].loc.x - center.x + 4; where_draw.y = univ.party.horses[i].loc.y - center.y + 4; Draw_Some_Item(vehicle_gworld, calc_rect(1,1), terrain_screen_gworld, where_draw, 1, 0); } }
//short dest; // 0 - terrain gworld 1 - screen // if terrain_to_draw is -1, do black // if terrain_to_draw >= 10000, force to draw graphic which is terrain_to_draw - 10000 void draw_one_terrain_spot (short i,short j,short terrain_to_draw) { rectangle where_draw; rectangle source_rect; sf::Texture* source_gworld; short anim_type = 0; location l; l.x = i; l.y = j; if(supressing_some_spaces && (l != ok_space[0]) && (l != ok_space[1]) && (l != ok_space[2]) && (l != ok_space[3])) return; where_draw = calc_rect(i,j); where_draw.offset(13,13); if(terrain_to_draw == -1) { fill_rect(terrain_screen_gworld, where_draw, sf::Color::Black); return; } if(terrain_to_draw >= 10000) { // force using a specific graphic terrain_to_draw -= 10000; int which_sheet = terrain_to_draw / 50; source_gworld = ResMgr::get<ImageRsrc>("ter" + std::to_string(1 + which_sheet)).get(); terrain_to_draw %= 50; source_rect = calc_rect(terrain_to_draw % 10, terrain_to_draw / 10); anim_type = -1; } else if(univ.scenario.ter_types[terrain_to_draw].picture >= 2000) { // custom graf_pos_ref(source_gworld, source_rect) = spec_scen_g.find_graphic(univ.scenario.ter_types[terrain_to_draw].picture - 2000 + (anim_ticks % 4)); anim_type = 0; } else if(univ.scenario.ter_types[terrain_to_draw].picture >= 1000) { // custom graf_pos_ref(source_gworld, source_rect) = spec_scen_g.find_graphic(univ.scenario.ter_types[terrain_to_draw].picture - 1000); } else if(univ.scenario.ter_types[terrain_to_draw].picture >= 960) { // animated source_gworld = ResMgr::get<ImageRsrc>("teranim").get(); terrain_to_draw = univ.scenario.ter_types[terrain_to_draw].picture; source_rect = calc_rect(4 * ((terrain_to_draw - 960) / 5) + (anim_ticks % 4),(terrain_to_draw - 960) % 5); anim_type = 0; } else { terrain_to_draw = univ.scenario.ter_types[terrain_to_draw].picture; int which_sheet = terrain_to_draw / 50; source_gworld = ResMgr::get<ImageRsrc>("ter" + std::to_string(1 + which_sheet)).get(); terrain_to_draw %= 50; source_rect = calc_rect(terrain_to_draw % 10, terrain_to_draw / 10); anim_type = -1; } if(anim_type >= 0) { if((is_town()) || (is_out())) anim_onscreen = true; } rect_draw_some_item(*source_gworld, source_rect, terrain_screen_gworld, where_draw); }
int map_enter(lua_State *L,struct map *m,struct object *obj) { struct tile *tl = tile_withpos(m,&obj->cur); if (tl == NULL) { luaL_error(L,"[map_enter]invalid pos[%d:%d]",obj->cur.x,obj->cur.y); return -1; } struct point bl,tr; if (calc_rect(m,&obj->cur,obj->range,&bl,&tr) < 0) { luaL_error(L,"[map_enter]invalid pos[%d:%d],range[%d]",obj->cur.x,obj->cur.y,obj->range); return -1; } int sindex = 1; int oindex = 1; int x,y; for(y = bl.y;y <= tr.y;y++) { for(x = bl.x;x <= tr.x;x++) { struct tile *tl = tile_withrc(m,y,x); if (tl == NULL) return -1; struct dlink *dl = tile_level(tl, COMMON_LEVEL); make_table(L,dl,obj,-1,&sindex,&oindex,0); if (obj->level != COMMON_LEVEL) { dl = tile_level(tl, obj->level); make_table(L,dl,obj,-1,&sindex,&oindex,0); } } } tile_push(tl, obj->level, &obj->node); return 0; }
void enc_tile(jxr_t *p, rect_t *tile) { rect_t mb_window[2]; rect_t is_tile_edge; uint32_t mby, mbx; enc_tile_header(p->out, &p->param); //printf("%d, %d, %d, %d\n", tile->left, tile->right, tile->top, tile->bottom); for (mby = tile->top; mby <= tile->bottom; mby++) { for (mbx = tile->left; mbx <= tile->right; mbx++) { //printf("(%3d, %3d)", mbx, mby); check_tile_edge(&is_tile_edge, mbx, mby, tile); calc_rect(mb_window, mbx, mby, p->param.mb_width, p->param.mb_height); //printf("%d, %d, %d, %d\n", mb_window[0].left, mb_window[0].right, mb_window[0].top, mb_window[0].bottom); enc_mb_stage1(p, mb_window, &is_tile_edge, mbx, mby); enc_mb_stage2(p, tile, &is_tile_edge, mbx, mby); //printf("\n"); //if (mbx == 0 && mby == 1) exit(0); } } write_align(&p->out[0]); if (get_flag(p->param.flags, FREQUENCY_MODE_CODESTREAM_FLAG)) { write_align(&p->out[1]); write_align(&p->out[2]); write_align(&p->out[3]); } int mbs = (tile->right - tile->left + 1) * (tile->bottom - tile->top + 1); int tb = get_total_bits(p->out); //printf("|Total : %d[bits]|MBs : %d| %3.2f[bits/MB]|Comp. Ratio %f|\n", tb, mbs, (float)tb/mbs, (float)tb/(mbs*6144)); }
void cPict::drawPresetBoom(short num, Rect to_rect){ if(!isSheetSet(SHEET_BOOM)) throw xMissingSheet(SHEET_BOOM); GWorldPtr from_gw = boom; Rect from_rect = calc_rect(num % 8, num / 8); to_rect.right = to_rect.left + 28; to_rect.bottom = to_rect.top + 36; PaintRect(&to_rect); rect_draw_some_item(from_gw, from_rect, to_rect, (Point){0,0}, transparent); }
void cPict::drawPresetTer(short num, Rect to_rect){ printf("Getting terrain icon from sheet %i.\n",num / 50); if(!isSheetSet(SHEET_TER,num / 50)) throw xMissingSheet(SHEET_TER,num / 50); GWorldPtr from_gw = ter[num / 50]; num = num % 50; Rect from_rect = calc_rect(num % 10, num / 10); if (to_rect.right - to_rect.left > 28) InsetRect(&to_rect,4,0); rect_draw_some_item(from_gw, from_rect, to_rect, (Point){0,0}); }
void cPict::drawPresetTerAnim(short num, Rect to_rect){ Rect from_rect = calc_rect(4 * (num / 5) + animFrame, num % 5); if(!isSheetSet(SHEET_TER_ANIM)) throw xMissingSheet(SHEET_TER_ANIM); GWorldPtr from_gw = teranim; printf("Getting animated terrain graphic %i from sheet 20", num); if (to_rect.right - to_rect.left > 28) { InsetRect(&to_rect,4,0); to_rect.right = to_rect.left + 28; } rect_draw_some_item(from_gw, from_rect, to_rect, (Point){0,0}); }
// Give the position of the monster graphic in the template in memory //mode; // 0 - left 1 - right +10 - combat mode rectangle get_monster_template_rect (pic_num_t picture_wanted,short mode,short which_part) { short adj = 0; if(mode >= 10) { adj += 4; mode -= 10; } if(mode == 0) adj++; picture_wanted = (m_pic_index[picture_wanted].i + which_part) % 20; return calc_rect(2 * (picture_wanted / 10) + adj, picture_wanted % 10); }
void draw_items(HDC hdc) { short i; RECT source_rect,draw_rect; location where_draw; short pic_num; for (i = 0; i < 64; i++) { if (town.preset_items[i].item_code >= 0) { where_draw.x = town.preset_items[i].item_loc.x - cen_x + 4; where_draw.y = town.preset_items[i].item_loc.y - cen_y + 4; pic_num = scen_item_list.scen_items[town.preset_items[i].item_code].graphic_num; if ((where_draw.x >= 0) && (where_draw.x <= 8) && (where_draw.y >= 0) && (where_draw.y <= 8)) { if (pic_num >= 150) { source_rect = get_custom_rect(pic_num - 150); draw_rect = calc_rect(where_draw.x,where_draw.y); OffsetRect(&draw_rect,8,8); rect_draw_some_item(spec_scen_g,source_rect, ter_draw_gworld, draw_rect, 1, 0); } else { source_rect = get_item_template_rect(pic_num); draw_rect = calc_rect(where_draw.x,where_draw.y); OffsetRect(&draw_rect,8,8); if (pic_num >= 45) { draw_rect.top += 9; draw_rect.bottom -= 9; draw_rect.left += 5; draw_rect.right -= 5; } rect_draw_some_item((pic_num < 45) ? items_gworld : tiny_obj_gworld,source_rect, ter_draw_gworld, draw_rect, 1, 0); } } } } }
static Rect calcDefMonstRect(short i, short animFrame){ Rect r = calc_rect(2 * (i / 10), i % 10); switch(animFrame){ // Sequence is right-facing, attack, left-facing, attack case 1: OffsetRect(&r,112,0); break; case 2: OffsetRect(&r,28,0); break; case 3: OffsetRect(&r,140,0); break; } return r; }
void cPict::drawPresetItem(short num, Rect to_rect){ to_rect.right = to_rect.left + 28; to_rect.bottom = to_rect.top + 36; PaintRect(&to_rect); GWorldPtr from_gw; Rect from_rect = {0,0,18,18}; if (num < 45) { if(!isSheetSet(SHEET_ITEM)) throw xMissingSheet(SHEET_ITEM); from_gw = item; from_rect = calc_rect(num % 5, num / 5); }else{ if(!isSheetSet(SHEET_TINY_ITEM)) throw xMissingSheet(SHEET_TINY_ITEM); from_gw = tinyItem; InsetRect(&to_rect,5,9); OffsetRect(&from_rect,18 * (num % 10), 18 * (num / 10)); } rect_draw_some_item(from_gw, from_rect, to_rect, (Point){0,0}, transparent); }
int _aoi_viewlist(lua_State *L) { struct aoi_context *aoi = lua_touserdata(L, 1); struct object *obj = lua_touserdata(L, 2); struct tile *tl = tile_withpos(&aoi->map,&obj->cur); if (tl == NULL) { luaL_error(L,"[_aoi_viewlist]invalid pos[%d:%d]",obj->cur.x,obj->cur.y); return 0; } struct point bl,tr; if (calc_rect(&aoi->map,&obj->cur,obj->range,&bl,&tr) < 0) { luaL_error(L,"[_aoi_viewlist]invalid pos[%d:%d],range[%d]",obj->cur.x,obj->cur.y,obj->range); return 0; } lua_newtable(L); int sindex = 1; int oindex = 1; int x,y; for(y = bl.y;y <= tr.y;y++) { for(x = bl.x;x <= tr.x;x++) { struct tile *tl = tile_withrc(&aoi->map,y,x); if (tl == NULL) { luaL_error(L,"[_aoi_viewlist]invalid rc[%d:%d],range[%d]",y,x); return 0; } struct dlink *dl = tile_level(tl, COMMON_LEVEL); make_table(L,dl,obj,-1,&sindex,&oindex,1); if (obj->level != COMMON_LEVEL) { dl = tile_level(tl, obj->level); make_table(L,dl,obj,-1,&sindex,&oindex,1); } } } return 1; }
void OSystem_PalmZodiac::setFeatureState(Feature f, bool enable) { switch (f) { /* case kFeatureFullscreenMode: if (_gfxLoaded) if (OPTIONS_TST(kOptModeWide) && _initMode != GFX_WIDE) { _fullscreen = enable; hotswap_gfx_mode(_mode); } break; */ case kFeatureAspectRatioCorrection: if (_mode == GFX_WIDE) { _ratio.adjustAspect = (_ratio.adjustAspect + 1) % 3; calc_rect(true); TwGfxSetClip(_palmScreenP, &_dstRect); clearScreen(); } break; } }
void draw_monsts(HDC hdc) { short i,k,width,height,m_start_pic; GWorldPtr from_gworld; RECT source_rect; location where_draw,store_loc; for (i = 0; i < 60; i++) if (t_d.creatures[i].number != 0) { where_draw.x = t_d.creatures[i].start_loc.x - cen_x + 4; where_draw.y = t_d.creatures[i].start_loc.y - cen_y + 4; width = scenario.scen_monsters[t_d.creatures[i].number].x_width; height = scenario.scen_monsters[t_d.creatures[i].number].y_width; for (k = 0; k < width * height; k++) { store_loc = where_draw; if ((where_draw.x == minmax(0,8,where_draw.x)) && (where_draw.y == minmax(0,8,where_draw.y)) && (scenario.scen_monsters[t_d.creatures[i].number].picture_num >= 1000)) { source_rect = get_custom_rect((scenario.scen_monsters[t_d.creatures[i].number].picture_num + k) % 1000); store_loc.x += k % width; store_loc.y += k / width; Draw_Some_Item(spec_scen_g, source_rect, ter_draw_gworld, store_loc, 1, 0); } else if (scenario.scen_monsters[t_d.creatures[i].number].picture_num < 1000) { m_start_pic = m_pic_index[scenario.scen_monsters[t_d.creatures[i].number].picture_num] + k; from_gworld = monst_gworld[m_start_pic / 20]; m_start_pic = m_start_pic % 20; source_rect = calc_rect(2 * (m_start_pic / 10), m_start_pic % 10); store_loc.x += k % width; store_loc.y += k / width; Draw_Some_Item(from_gworld, source_rect, ter_draw_gworld, store_loc, 1, 0); } } } }
void draw_fields(location where){ if(!point_onscreen(center,where)) return; if(party_can_see(where) >= 6) return; location where_draw(4 + where.x - center.x, 4 + where.y - center.y); sf::Texture& fields_gworld = *ResMgr::get<ImageRsrc>("fields"); if(is_out()){ if(univ.out.is_spot(where.x,where.y)) Draw_Some_Item(fields_gworld,calc_rect(4,0),terrain_screen_gworld,where_draw,1,0); return; } if(univ.town.is_force_wall(where.x,where.y)) Draw_Some_Item(fields_gworld,calc_rect(0,1),terrain_screen_gworld,where_draw,1,0); if(univ.town.is_fire_wall(where.x,where.y)) Draw_Some_Item(fields_gworld,calc_rect(1,1),terrain_screen_gworld,where_draw,1,0); if(univ.town.is_antimagic(where.x,where.y)) Draw_Some_Item(fields_gworld,calc_rect(2,1),terrain_screen_gworld,where_draw,1,0); if(univ.town.is_scloud(where.x,where.y)) Draw_Some_Item(fields_gworld,calc_rect(3,1),terrain_screen_gworld,where_draw,1,0); if(univ.town.is_ice_wall(where.x,where.y)) Draw_Some_Item(fields_gworld,calc_rect(4,1),terrain_screen_gworld,where_draw,1,0); if(univ.town.is_blade_wall(where.x,where.y)) Draw_Some_Item(fields_gworld,calc_rect(5,1),terrain_screen_gworld,where_draw,1,0); if(univ.town.is_sleep_cloud(where.x,where.y)) Draw_Some_Item(fields_gworld,calc_rect(6,1),terrain_screen_gworld,where_draw,1,0); if(univ.town.is_block(where.x,where.y)) Draw_Some_Item(fields_gworld,calc_rect(3,0),terrain_screen_gworld,where_draw,1,0); if(univ.town.is_spot(where.x,where.y)) Draw_Some_Item(fields_gworld,calc_rect(4,0),terrain_screen_gworld,where_draw,1,0); if(univ.town.is_web(where.x,where.y)) Draw_Some_Item(fields_gworld,calc_rect(5,0),terrain_screen_gworld,where_draw,1,0); if(univ.town.is_crate(where.x,where.y)) Draw_Some_Item(fields_gworld,calc_rect(6,0),terrain_screen_gworld,where_draw,1,0); if(univ.town.is_barrel(where.x,where.y)) Draw_Some_Item(fields_gworld,calc_rect(7,0),terrain_screen_gworld,where_draw,1,0); if(univ.town.is_fire_barr(where.x,where.y) || univ.town.is_force_barr(where.x,where.y)) Draw_Some_Item(*ResMgr::get<ImageRsrc>("teranim"),calc_rect(8+(anim_ticks%4),4),terrain_screen_gworld,where_draw,1,0); if(univ.town.is_quickfire(where.x,where.y)) Draw_Some_Item(fields_gworld,calc_rect(7,1),terrain_screen_gworld,where_draw,1,0); if(univ.town.is_sm_blood(where.x,where.y)) Draw_Some_Item(fields_gworld,calc_rect(0,3),terrain_screen_gworld,where_draw,1,0); if(univ.town.is_med_blood(where.x,where.y)) Draw_Some_Item(fields_gworld,calc_rect(1,3),terrain_screen_gworld,where_draw,1,0); if(univ.town.is_lg_blood(where.x,where.y)) Draw_Some_Item(fields_gworld,calc_rect(2,3),terrain_screen_gworld,where_draw,1,0); if(univ.town.is_sm_slime(where.x,where.y)) Draw_Some_Item(fields_gworld,calc_rect(3,3),terrain_screen_gworld,where_draw,1,0); if(univ.town.is_lg_slime(where.x,where.y)) Draw_Some_Item(fields_gworld,calc_rect(4,3),terrain_screen_gworld,where_draw,1,0); if(univ.town.is_ash(where.x,where.y)) Draw_Some_Item(fields_gworld,calc_rect(5,3),terrain_screen_gworld,where_draw,1,0); if(univ.town.is_bones(where.x,where.y)) Draw_Some_Item(fields_gworld,calc_rect(6,3),terrain_screen_gworld,where_draw,1,0); if(univ.town.is_rubble(where.x,where.y)) Draw_Some_Item(fields_gworld,calc_rect(7,3),terrain_screen_gworld,where_draw,1,0); if(univ.town.is_force_cage(where.x,where.y)) { Draw_Some_Item(fields_gworld,calc_rect(1,0),terrain_screen_gworld,where_draw,1,0); forcecage_locs.push_back(where_draw); } }
int map_update(lua_State *L,struct map *m,struct object *obj,struct point *np) { struct point op = obj->cur; obj->cur = *np; struct tile *otl = tile_withpos(m,&op); struct tile *ntl = tile_withpos(m,&obj->cur); if (otl == ntl) return 0; tile_pop(&obj->node); tile_push(ntl, obj->level, &obj->node); struct point obl, otr; if (calc_rect(m, &op, obj->range, &obl, &otr) < 0) return -1; struct point nbl, ntr; if (calc_rect(m, &obj->cur, obj->range, &nbl, &ntr) < 0) return -1; int sindex = 1; int oindex = 1; int x, y; for (y = nbl.y; y <= ntr.y; y++) { for (x = nbl.x; x <= ntr.x; x++) { if (x >= obl.x && x <= otr.x && y >= obl.y && y <= otr.y) continue; struct tile *tl = tile_withrc(m,y,x); if (tl == NULL) return -1; struct dlink *dl = tile_level(tl, COMMON_LEVEL); make_table(L,dl,obj,-3,&sindex,&oindex,0); if (obj->level != COMMON_LEVEL) { dl = tile_level(tl, obj->level); make_table(L,dl,obj,-3,&sindex,&oindex,0); } } } for (y = obl.y; y <= otr.y; y++) { for (x = obl.x; x <= otr.x; x++) { if (x >= nbl.x && x <= ntr.x && y >= nbl.y && y <= ntr.y) continue; struct tile *tl = tile_withrc(m,y,x); if (tl == NULL) return -1; struct dlink *dl = tile_level(tl, COMMON_LEVEL); make_table(L,dl,obj,-1,&sindex,&oindex,0); if (obj->level != COMMON_LEVEL) { dl = tile_level(tl, obj->level); make_table(L,dl,obj,-1,&sindex,&oindex,0); } } } return 0; }
//short mode; // 0 - put pcs in gworld 1 - only rectangle around active pc void draw_pcs(location center,short mode) { rectangle source_rect,active_pc_rect; location where_draw; if(!univ.party.is_alive()) return; if(!can_draw_pcs) return; // Draw current pc on top int pcs[6] = {0,1,2,3,4,5}; if(current_pc < 6) std::swap(pcs[5], pcs[current_pc]); for(int j = 0; j < 6; j++) { int i = pcs[j]; if(univ.party[i].main_status == eMainStatus::ALIVE) if(point_onscreen(center, univ.party[i].combat_pos) && (cartoon_happening || party_can_see(univ.party[i].combat_pos) < 6)){ where_draw.x = univ.party[i].combat_pos.x - center.x + 4; where_draw.y = univ.party[i].combat_pos.y - center.y + 4; sf::Texture* from_gw; pic_num_t pic = univ.party[i].which_graphic; if(pic >= 1000) { bool isParty = pic >= 10000; pic_num_t need_pic = pic % 1000; if(univ.party[i].direction >= 4) need_pic++; if(combat_posing_monster == i) need_pic += 2; graf_pos_ref(from_gw, source_rect) = spec_scen_g.find_graphic(need_pic, isParty); } else if(pic >= 100) { // Note that we assume it's a 1x1 graphic. // PCs can't be larger than that, but we leave it to the scenario designer to avoid assigning larger graphics. pic_num_t need_pic = pic - 100; int mode = 0; if(univ.party[current_pc].direction >= 4) mode++; if(combat_posing_monster == i) mode += 10; source_rect = get_monster_template_rect(need_pic, mode, 0); int which_sheet = m_pic_index[need_pic].i / 20; from_gw = ResMgr::get<ImageRsrc>("monst" + std::to_string(1 + which_sheet)).get(); } else { source_rect = calc_rect(2 * (pic / 8), pic % 8); if(univ.party[i].direction >= 4) source_rect.offset(28,0); if(combat_posing_monster == i) source_rect.offset(0,288); from_gw = ResMgr::get<ImageRsrc>("pcs").get(); } if(mode == 0) { Draw_Some_Item(*from_gw, source_rect, terrain_screen_gworld, where_draw, 1, 0); } if((current_pc == i) && (mode == 1) && !monsters_going) { active_pc_rect.top = 18 + where_draw.y * 36; active_pc_rect.left = 18 + where_draw.x * 28; active_pc_rect.bottom = 54 + where_draw.y * 36; active_pc_rect.right = 46 + where_draw.x * 28; active_pc_rect.offset(ul); frame_roundrect(mainPtr, active_pc_rect, 8, sf::Color::Magenta); } } } }
void draw_party_symbol(location center) { rectangle source_rect; location target(4,4); short i = 0; if(!can_draw_pcs) return; if(!univ.party.is_alive()) return; if((is_town()) && (univ.town.p_loc.x > 70)) return; if(overall_mode == MODE_LOOK_TOWN || cartoon_happening) { target.x += univ.town.p_loc.x - center.x; target.y += univ.town.p_loc.y - center.y; } if((univ.party.in_boat < 0) && (univ.party.in_horse < 0)) { i = first_active_pc(); sf::Texture* from_gw; pic_num_t pic = univ.party[i].which_graphic; if(pic >= 1000) { bool isParty = pic >= 10000; pic_num_t need_pic = pic % 1000; if(univ.party.direction >= 4) need_pic++; graf_pos_ref(from_gw, source_rect) = spec_scen_g.find_graphic(need_pic, isParty); } else if(pic >= 100) { // Note that we assume it's a 1x1 graphic. // PCs can't be larger than that, but we leave it to the scenario designer to avoid assigning larger graphics. pic_num_t need_pic = pic - 100; int mode = 0; if(univ.party.direction >= 4) mode++; source_rect = get_monster_template_rect(need_pic, mode, 0); int which_sheet = m_pic_index[need_pic].i / 20; from_gw = ResMgr::get<ImageRsrc>("monst" + std::to_string(1 + which_sheet)).get(); } else { source_rect = calc_rect(2 * (pic / 8), pic % 8); if(univ.party.direction >= 4) source_rect.offset(28,0); from_gw = ResMgr::get<ImageRsrc>("pcs").get(); } ter_num_t ter = 0; if(is_out()) ter = univ.out[univ.party.p_loc.x][univ.party.p_loc.y]; else if(is_town() || is_combat()) ter = univ.town->terrain(univ.town.p_loc.x,univ.town.p_loc.y); // now wedge in bed graphic if(is_town() && univ.scenario.ter_types[ter].special == eTerSpec::BED) draw_one_terrain_spot((short) target.x,(short) target.y,10000 + univ.scenario.ter_types[ter].flag1); else Draw_Some_Item(*from_gw, source_rect, terrain_screen_gworld, target, 1, 0); } else if(univ.party.in_boat >= 0) { if(univ.party.direction == DIR_N) i = 2; else if(univ.party.direction == DIR_S) i = 3; else i = univ.party.direction > DIR_S; Draw_Some_Item(*ResMgr::get<ImageRsrc>("vehicle"), calc_rect(i,0), terrain_screen_gworld, target, 1, 0); }else { i = univ.party.direction > 3; Draw_Some_Item(*ResMgr::get<ImageRsrc>("vehicle"), calc_rect(i + 2, 1), terrain_screen_gworld, target, 1, 0); } }
void draw_terrain() { short q,r,x,i,small_i; location which_pt,where_draw; RECT draw_rect,clipping_rect = {8,8,260,332}; unsigned char t_to_draw; RECT tiny_to,tiny_to_base = {29,37,36,44},tiny_from,from_rect,to_rect; HBITMAP store_bmp; COLORREF gray = RGB(128,128,128); COLORREF red = RGB(255,0,0); COLORREF white = RGB(255,255,255); HBRUSH new_brush; HDC hdc; HPEN old_pen; if (overall_mode >= 60) return; if (cur_viewing_mode == 0) { paint_pattern(ter_draw_gworld,0,terrain_rect,1); } hdc = CreateCompatibleDC(main_dc); SetBkMode(hdc,TRANSPARENT); SelectObject(hdc,small_bold_font); store_bmp = (HBITMAP)SelectObject(hdc,ter_draw_gworld); new_brush = CreateSolidBrush(gray); FrameRect(hdc,&terrain_rect,new_brush); DeleteObject(new_brush); old_pen = (HPEN)SelectObject(hdc,GetStockObject(NULL_PEN)); SelectObject(hdc,store_bmp); if (cur_viewing_mode == 0) { for (q = 0; q < 9; q++) for (r = 0; r < 9; r++) { where_draw.x = q; where_draw.y = r; if (editing_town == TRUE) { t_to_draw = t_d.terrain[cen_x + q - 4][cen_y + r - 4]; } else { if (cen_x + q - 4 == -1) t_to_draw = borders[3][cen_y + r - 4]; else if (cen_x + q - 4 == 48) t_to_draw = borders[1][cen_y + r - 4]; else if (cen_y + r - 4 == -1) t_to_draw = borders[0][cen_x + q - 4]; else if (cen_y + r - 4 == 48) t_to_draw = borders[2][cen_x + q - 4]; else t_to_draw = current_terrain.terrain[cen_x + q - 4][cen_y + r - 4]; } draw_one_terrain_spot(q,r,t_to_draw); which_pt.x = cen_x + q - 4; which_pt.y =cen_y + r - 4; tiny_to = tiny_to_base; OffsetRect(&tiny_to,28 * q, 36 * r); // draw start icon, if starting point if ((editing_town == TRUE) && (cur_town == scenario.which_town_start) && (scenario.where_start.x == cen_x + q - 4) && (scenario.where_start.y == cen_y + r - 4)) { from_rect = start_button_from; to_rect = tiny_to; to_rect.left -= 14; rect_draw_some_item(editor_mixed,from_rect,ter_draw_gworld,to_rect,0,0); OffsetRect(&tiny_to,0,-7); } if ((editing_town == FALSE) && (scenario.out_sec_start.x == cur_out.x) && (scenario.out_sec_start.y == cur_out.y) && (scenario.out_start.x == cen_x + q - 4) && (scenario.out_start.y == cen_y + r - 4)) { from_rect = start_button_from; to_rect = tiny_to; to_rect.left -= 14; rect_draw_some_item(editor_mixed,from_rect,ter_draw_gworld,to_rect,0,0); OffsetRect(&tiny_to,0,-7); } small_i = small_icons[scenario.ter_types[t_to_draw].special]; if ((small_i == 30) && (scenario.ter_types[t_to_draw].flag2 >= 5)) small_i = 31; if ((small_i == 31) && (scenario.ter_types[t_to_draw].flag2 == 10)) small_i = 32; tiny_from = base_small_button_from; OffsetRect(&tiny_from,7 * (small_i % 10),7 * (small_i / 10)); if (small_i > 0) { rect_draw_some_item(editor_mixed,tiny_from,ter_draw_gworld,tiny_to,0,0); OffsetRect(&tiny_to,0,-7); } if (is_special(cen_x + q - 4,cen_y + r - 4) == TRUE) { tiny_from = base_small_button_from; OffsetRect(&tiny_from,7 * (7),7 * (0)); rect_draw_some_item(editor_mixed,tiny_from,ter_draw_gworld,tiny_to,0,0); OffsetRect(&tiny_to,0,-7); } if ((t_to_draw == 7) || (t_to_draw == 10) || (t_to_draw == 13) || (t_to_draw == 16)) { tiny_from = base_small_button_from; OffsetRect(&tiny_from,7 * (3),7 * (2)); rect_draw_some_item(editor_mixed,tiny_from,ter_draw_gworld,tiny_to,0,0); OffsetRect(&tiny_to,0,-7); } if (editing_town == FALSE) { for (i = 0; i < 4; i++) if ((cen_x + q - 4 == current_terrain.wandering_locs[i].x) && (cen_y + r - 4 == current_terrain.wandering_locs[i].y)) { tiny_from = base_small_button_from; OffsetRect(&tiny_from,7 * (2),7 * (1)); rect_draw_some_item(editor_mixed,tiny_from,ter_draw_gworld,tiny_to,0,0); OffsetRect(&tiny_to,0,-7); i = 4; } } if (editing_town == TRUE) { for (i = 0; i < 4; i++) if ((cen_x + q - 4 == town.start_locs[i].x) && (cen_y + r - 4 == town.start_locs[i].y)) { tiny_from = base_small_button_from; OffsetRect(&tiny_from,7 * (6 + i),7 * (1)); rect_draw_some_item(editor_mixed,tiny_from,ter_draw_gworld,tiny_to,0,0); OffsetRect(&tiny_to,0,-7); } for (i = 0; i < 4; i++) if ((cen_x + q - 4 == town.wandering_locs[i].x) && (cen_y + r - 4 == town.wandering_locs[i].y)) { tiny_from = base_small_button_from; OffsetRect(&tiny_from,7 * (2),7 * (1)); rect_draw_some_item(editor_mixed,tiny_from,ter_draw_gworld,tiny_to,0,0); OffsetRect(&tiny_to,0,-7); i = 4; } if (is_web(cen_x + q - 4,cen_y + r - 4) == TRUE) { from_rect = calc_rect(5,0); Draw_Some_Item(field_gworld,from_rect,ter_draw_gworld,where_draw,1,0); } if (is_crate(cen_x + q - 4,cen_y + r - 4) == TRUE) { from_rect = calc_rect(6,0); Draw_Some_Item(field_gworld,from_rect,ter_draw_gworld,where_draw,1,0); } if (is_barrel(cen_x + q - 4,cen_y + r - 4) == TRUE) { from_rect = calc_rect(7,0); Draw_Some_Item(field_gworld,from_rect,ter_draw_gworld,where_draw,1,0); } if (is_fire_barrier(cen_x + q - 4,cen_y + r - 4) == TRUE) { from_rect = calc_rect(0,2); Draw_Some_Item(field_gworld,from_rect,ter_draw_gworld,where_draw,1,0); } if (is_quickfire(cen_x + q - 4,cen_y + r - 4) == TRUE) { from_rect = calc_rect(7,1); Draw_Some_Item(field_gworld,from_rect,ter_draw_gworld,where_draw,1,0); } if (is_force_barrier(cen_x + q - 4,cen_y + r - 4) == TRUE) { from_rect = calc_rect(2,2); Draw_Some_Item(field_gworld,from_rect,ter_draw_gworld,where_draw,1,0); } for (i = 0; i < 8; i++) if (is_sfx(cen_x + q - 4,cen_y + r - 4,i)) { from_rect = calc_rect(i,3); Draw_Some_Item(field_gworld,from_rect,ter_draw_gworld,where_draw,1,0); } for (x = 0; x < 64; x++) if ((cen_x + q - 4 == town.preset_items[x].item_loc.x) && (cen_y + r - 4 == town.preset_items[x].item_loc.y) && (town.preset_items[x].item_code >= 0)) { } for (x = 0; x < 60; x++) if ((cen_x + q - 4 == t_d.creatures[x].start_loc.x) && (cen_y + r - 4 == t_d.creatures[x].start_loc.y) && (t_d.creatures[x].number != 0)) { } } } if (editing_town == TRUE) { draw_monsts(hdc); draw_items(hdc); } store_bmp = (HBITMAP)SelectObject(hdc,ter_draw_gworld); ClipRect(hdc,&clipping_rect); if (editing_town == TRUE) { // draw info rects for (i = 0; i < 16; i++) if (t_d.room_rect[i].left > -1) { draw_rect.left = 22 + 28 * (t_d.room_rect[i].left - cen_x + 4); draw_rect.right = 22 + 28 * (t_d.room_rect[i].right - cen_x + 4); draw_rect.top = 24 + 36 * (t_d.room_rect[i].top - cen_y + 4); draw_rect.bottom = 24 + 36 * (t_d.room_rect[i].bottom - cen_y + 4); //c = GetNearestPaletteIndex(hpal,red); new_brush = CreateSolidBrush(red); FrameRect(hdc,&draw_rect,new_brush); DeleteObject(new_brush); } // draw border rect draw_rect.left = 21 + 28 * (town.in_town_rect.left - cen_x + 4); draw_rect.right = 21 + 28 * (town.in_town_rect.right - cen_x + 4); draw_rect.top = 25 + 36 * (town.in_town_rect.top - cen_y + 4); draw_rect.bottom = 25 + 36 * (town.in_town_rect.bottom - cen_y + 4); // c = GetNearestPaletteIndex(hpal,white); new_brush = CreateSolidBrush(white); FrameRect(hdc,&draw_rect,new_brush); DeleteObject(new_brush); } if (editing_town == FALSE) { // draw info rects for (i = 0; i < 8; i++) if (current_terrain.info_rect[i].left > -1) { draw_rect.left = 22 + 28 * (current_terrain.info_rect[i].left - cen_x + 4); draw_rect.right = 22 + 28 * (current_terrain.info_rect[i].right - cen_x + 4); draw_rect.top = 24 + 36 * (current_terrain.info_rect[i].top - cen_y + 4); draw_rect.bottom = 24 + 36 * (current_terrain.info_rect[i].bottom - cen_y + 4); //c = GetNearestPaletteIndex(hpal,red); new_brush = CreateSolidBrush(red); FrameRect(hdc,&draw_rect,new_brush); DeleteObject(new_brush); } } undo_clip(hdc); SelectObject(hdc,store_bmp); small_any_drawn = FALSE; } if (cur_viewing_mode == 1) { if (small_any_drawn == FALSE) { InsetRect(&terrain_rect,1,1); paint_pattern(ter_draw_gworld,0,terrain_rect,1); InsetRect(&terrain_rect,-1,-1); //FrameRect(&terrain_rect); } for (q = 0; q < ((editing_town == TRUE) ? max_dim[town_type] : 48); q++) for (r = 0; r < ((editing_town == TRUE) ? max_dim[town_type] : 48); r++) { t_to_draw = (editing_town == TRUE) ? t_d.terrain[q][r] : current_terrain.terrain[q][r]; if ((small_what_drawn[q][r] != t_to_draw) || (small_any_drawn == FALSE)) { draw_one_tiny_terrain_spot(q,r,t_to_draw,hdc); small_what_drawn[q][r] = t_to_draw; } } small_any_drawn = TRUE; } SelectObject(hdc,old_pen); DeleteObject(hdc); //draw_cur_string(); place_location(); rect_draw_some_item(ter_draw_gworld,terrain_rect,ter_draw_gworld,world_screen,0,1); }