void draw_mirror_fg (ALLEGRO_BITMAP *bitmap, struct pos *p, enum em em, enum vm vm) { struct coord c; ALLEGRO_BITMAP *mirror = NULL; switch (em) { case DUNGEON: switch (vm) { case CGA: mirror = dc_mirror; break; case EGA: mirror = de_mirror; break; case VGA: mirror = dv_mirror; break; } break; case PALACE: switch (vm) { case CGA: mirror = pc_mirror; break; case EGA: mirror = pe_mirror; break; case VGA: mirror = pv_mirror; break; } break; } if (hgc) mirror = apply_palette (mirror, hgc_palette); ALLEGRO_BITMAP *b = mirror_bitmap[p->floor + 1][p->place + 1]; if (b) draw_bitmapc (b, bitmap, mirror_reflex_coord (p, &c), 0); int h = al_get_bitmap_height (mirror); draw_bitmap_regionc (mirror, bitmap, 0, 0, 22, h, mirror_coord (p, &c), 0); }
int main(int argc, char** argv) { // Set output precision int decimals = 16; // Process input parameters if (argc != 3) { std::cout << "Usage: mirror_grid filename.grdecl direction" << std::endl; std::cout << "(replace direction with either x or y)" << std::endl; exit(1); } const char* eclipsefilename = argv[1]; std::string direction(argv[2]); if ( ! ((direction == "x") || (direction == "y")) ) { std::cerr << "Unrecognized input parameter for direction: '" << direction << "'. Should be either x or y (maybe also z later)." << std::endl; exit(1); } // Parse grdecl file std::cout << "Parsing grid file '" << eclipsefilename << "' ..." << std::endl; Opm::Parser parser; Opm::ParseContext parseContext; const Opm::Deck deck(parser.parseFile(eclipsefilename , parseContext)); if ( ! (deck.hasKeyword("SPECGRID") && deck.hasKeyword("COORD") && deck.hasKeyword("ZCORN")) ) { std::cerr << "Grid file " << eclipsefilename << "are missing keywords SPECGRID, COORD or ZCORN!" << std::endl; exit(1); } // Create new grid file std::string mirrored_eclipsefilename = std::string(eclipsefilename); std::string::size_type last_dot = mirrored_eclipsefilename.find_last_of('.'); mirrored_eclipsefilename = mirrored_eclipsefilename.substr(0, last_dot) + "_mirrored-" + direction + ".grdecl"; std::ofstream outfile; outfile.open(mirrored_eclipsefilename.c_str(), std::ios::out | std::ios::trunc); if (!outfile) { std::cerr << "Can't open output file " << mirrored_eclipsefilename << std::endl; exit(1); } outfile.precision(decimals); outfile.setf(std::ios::fixed); // Print init message printInitMessage(outfile, eclipsefilename, direction); // Mirror keywords mirror_mapaxes(deck, direction, outfile); mirror_specgrid(deck, direction, outfile); mirror_coord(deck, direction, outfile); mirror_zcorn(deck, direction, outfile); mirror_celldata<int>("ACTNUM", deck, direction, outfile); mirror_celldata<double>("PERMX", deck, direction, outfile); mirror_celldata<double>("PERMY", deck, direction, outfile); mirror_celldata<double>("PERMZ", deck, direction, outfile); mirror_celldata<double>("PORO", deck, direction, outfile); mirror_celldata<int>("SATNUM", deck, direction, outfile); mirror_celldata<double>("NTG", deck, direction, outfile); mirror_celldata<double>("SWCR", deck, direction, outfile); mirror_celldata<double>("SOWCR", deck, direction, outfile); }
void draw_mirror (ALLEGRO_BITMAP *bitmap, struct pos *p, enum em em, enum vm vm) { if (con (p)->fg != MIRROR) return; struct coord c; ALLEGRO_BITMAP *mirror = NULL; switch (em) { case DUNGEON: switch (vm) { case CGA: mirror = dc_mirror; break; case EGA: mirror = de_mirror; break; case VGA: mirror = dv_mirror; break; } break; case PALACE: switch (vm) { case CGA: mirror = pc_mirror; break; case EGA: mirror = pe_mirror; break; case VGA: mirror = pv_mirror; break; } break; } if (hgc) mirror = apply_palette (mirror, hgc_palette); ALLEGRO_BITMAP *b = mirror_bitmap[p->floor + 1][p->place + 1]; if (b) draw_bitmapc (b, bitmap, mirror_reflex_coord (p, &c), 0); draw_bitmapc (mirror, bitmap, mirror_coord (p, &c), 0); }
void update_mirror_bitmap (ALLEGRO_BITMAP *bitmap, struct pos *p) { struct coord c; ALLEGRO_BITMAP *b = mirror_bitmap[p->floor + 1][p->place + 1]; if (! b) return; int i; for (i = 0; i < anima_nmemb; i++) draw_anim_if_at_pos (bitmap, &anima[i], p, vm); mirror_coord (p, &c); draw_bitmap_region (bitmap, b, c.x + 22, c.y + 3, MIRROR_BITMAP_W, MIRROR_BITMAP_H, 0, 0, ALLEGRO_FLIP_HORIZONTAL); }
void draw_mirror (ALLEGRO_BITMAP *bitmap, struct pos *p, enum em em, enum vm vm) { ALLEGRO_BITMAP *mirror = NULL; switch (em) { case DUNGEON: switch (vm) { case CGA: mirror = dc_mirror; break; case EGA: mirror = de_mirror; break; case VGA: mirror = dv_mirror; break; } break; case PALACE: switch (vm) { case CGA: mirror = pc_mirror; break; case EGA: mirror = pe_mirror; break; case VGA: mirror = pv_mirror; break; } break; } /* make mirror black */ struct rect r; new_rect (&r, p->room, PLACE_WIDTH * p->place + 2, PLACE_HEIGHT * p->floor + 3, PLACE_WIDTH - 10, PLACE_HEIGHT - 16); draw_filled_rect (bitmap, &r, BLACK); /* draw floor reflex */ draw_floor_reflex (bitmap, p, em, vm); /* draw mirror properly */ if (vm == VGA) mirror = apply_hue_palette (mirror); if (hgc) mirror = apply_palette (mirror, hgc_palette); if (peq (p, &mouse_pos)) mirror = apply_palette (mirror, selection_palette); struct coord c; draw_bitmapc (mirror, bitmap, mirror_coord (p, &c), 0); }
static void create_mirror_bitmaps (int last_room, int room) { struct coord c; struct pos p; p.room = room; for (p.floor = FLOORS; p.floor >= -1; p.floor--) for (p.place = -1; p.place < PLACES; p.place++) { ALLEGRO_BITMAP **b = &mirror_bitmap[p.floor + 1][p.place + 1]; if (*b) { al_destroy_bitmap (*b); *b = NULL; } if (con (&p)->fg != MIRROR) continue; mirror_coord (&p, &c); *b = create_bitmap (MIRROR_BITMAP_W, MIRROR_BITMAP_H); clear_bitmap (*b, TRANSPARENT_COLOR); } }
void draw_mirror_fg (ALLEGRO_BITMAP *bitmap, struct pos *p, struct frame *f, enum em em, enum vm vm) { ALLEGRO_BITMAP *mirror = NULL; switch (em) { case DUNGEON: switch (vm) { case CGA: mirror = dc_mirror; break; case EGA: mirror = de_mirror; break; case VGA: mirror = dv_mirror; break; } break; case PALACE: switch (vm) { case CGA: mirror = pc_mirror; break; case EGA: mirror = pe_mirror; break; case VGA: mirror = pv_mirror; break; } break; } /* make mirror black */ struct rect r; new_rect (&r, p->room, PLACE_WIDTH * p->place + 2, PLACE_HEIGHT * p->floor + 3, 13, PLACE_HEIGHT - 16); draw_filled_rect (bitmap, &r, BLACK); /* draw floor reflex */ draw_floor_reflex (bitmap, p, em, vm); ignore_clipping_rectangle_intersection = true; /* draw anim */ if (f) { push_clipping_rectangle (bitmap, PLACE_WIDTH * p->place + 2, PLACE_HEIGHT * p->floor + 3, 16, PLACE_HEIGHT - 9); struct anim *a = get_anim_by_id (f->parent_id); struct anim a0 = *a; invert_frame_dir (&a0.f, &a0.f); a0.f.c.x = (2 * PLACE_WIDTH * p->place + 36) - (a->f.c.x + al_get_bitmap_width (a->f.b)); draw_anim_frame (bitmap, &a0, vm); pop_clipping_rectangle (); } /* draw mirror properly */ if (vm == VGA) mirror = apply_hue_palette (mirror); if (hgc) mirror = apply_palette (mirror, hgc_palette); if (peq (p, &mouse_pos)) mirror = apply_palette (mirror, selection_palette); struct coord c; int h = al_get_bitmap_height (mirror); push_reset_clipping_rectangle (bitmap); draw_bitmap_regionc (mirror, bitmap, 0, 0, 22, h, mirror_coord (p, &c), 0); pop_clipping_rectangle (); ignore_clipping_rectangle_intersection = false; }