MCPcopy Create free account
hub / github.com/NetHack/NetHack / ghack_reinit_map_window

Function ghack_reinit_map_window

outdated/win/gnome/gnmap.c:445–525  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

443}
444
445void
446ghack_reinit_map_window()
447{
448 GnomeCanvasImage *bg;
449 double width, height, x, y;
450 int i;
451
452 /* ghack_map_clear(NULL, NULL); */
453
454 width = COLNO * ghack_glyph_width();
455 height = ROWNO * ghack_glyph_height();
456
457 gnome_canvas_set_scroll_region(GNOME_CANVAS(ghack_map.canvas), 0, 0,
458 width + 2 * ghack_glyph_width(),
459 height + 2 * ghack_glyph_height());
460
461 /* remove everything currently in the canvas map */
462 gtk_object_destroy(GTK_OBJECT(myCanvasGroup));
463
464 /* Put some groups back */
465 myCanvasGroup = GNOME_CANVAS_GROUP(gnome_canvas_item_new(
466 gnome_canvas_root(GNOME_CANVAS(ghack_map.canvas)),
467 gnome_canvas_group_get_type(), "x", 0.0, "y", 0.0, NULL));
468
469 /* Tile the map background with a pretty image */
470 if (background != NULL) {
471 /* Tile the map background */
472 for (y = 0; y < height + background->rgb_height;
473 y += background->rgb_height) {
474 for (x = 0; x < width + background->rgb_width;
475 x += background->rgb_width) {
476 bg = GNOME_CANVAS_IMAGE(gnome_canvas_item_new(
477 myCanvasGroup, gnome_canvas_image_get_type(), "x",
478 (double) x, "y", (double) y, "width",
479 (double) background->rgb_width, "height",
480 (double) background->rgb_height, "image", background,
481 "anchor", (GtkAnchorType) GTK_ANCHOR_CENTER, NULL));
482 gnome_canvas_item_lower_to_bottom(GNOME_CANVAS_ITEM(bg));
483 }
484 }
485 }
486
487 /* ghack_map.map is an array of canvas images. Each cell of
488 * the array will contain one tile. Here, we create the
489 * space for the cells and then create the cells for easy
490 * access later.
491 */
492 for (i = 0, y = 0; y < height; y += ghack_glyph_height()) {
493 for (x = 0; x < width; x += ghack_glyph_width()) {
494 ghack_map.map[i++] = GNOME_CANVAS_IMAGE(gnome_canvas_item_new(
495 myCanvasGroup, gnome_canvas_image_get_type(), "x", (double) x,
496 "y", (double) y, "width", (double) ghack_glyph_width(),
497 "height", (double) ghack_glyph_height(), "anchor",
498 GTK_ANCHOR_NORTH_WEST, NULL));
499 }
500 }
501
502 if (petmark != NULL) {

Callers 1

ghack_settings_dialogFunction · 0.85

Calls 5

ghack_glyph_widthFunction · 0.85
ghack_glyph_heightFunction · 0.85
ghack_map_cliparoundFunction · 0.85
ghack_map_cursor_toFunction · 0.85
doredrawFunction · 0.85

Tested by

no test coverage detected