void renderer::map (data::map const &map) { static int const layer = -1; for (size_t y = 0; y < array_size (win); y++) for (size_t x = 0; x < array_size (win[y]); x++) win[y][x] = L'_'; static data::glyph const space = { { { 0, 0, L'?' }, { 0, 0, L'?' } } }; static data::glyph const player = { { { 0, 0, L'@' }, { 0, 0, L'@' } } }; int const playerx = (W - !(W % 2)) / 2; int const playery = (H - !(H % 2)) / 2; int const offx = (map.w - W) / 2; int const offy = (map.h - H) / 2; return_unless (!data::glyphs.empty ()); for (int y = 0; y < H; y++) { int const mapy = y + map.y + offy; if (!map.rows.has (mapy)) continue; auto const &row = map.rows[mapy]; for (int x = 0; x < W; x++) { int const mapx = x + map.x + offx; if (!row.has (mapx)) continue; data::map::cell const &cell = row[mapx]; u32 const face = select_face (cell.face, layer); data::glyph const *glyph; int const winy = y * 1; int const winx = x * 2; if (x == playerx && y == playery) glyph = &player; else if (face && face < data::glyphs.size ()) // TODO: warn about face >= size glyph = &data::glyphs[face]; else glyph = &space; return_unless (winy >= 0); return_unless (winx >= 0); return_unless (winy < int (array_size ( win))); return_unless (winx < int (array_size (*win))); win[winy][winx + 0] = (*glyph)[0].text; win[winy][winx + 1] = (*glyph)[1].text; } } }
void Scena::select_object(int x, int y) { int i,m,l; for(i=0;i<pt;i++) if ( select_face(&object[i],x,y)!= -1) // if (!(object[i].selected)) { m=c.model; l=object[i].textur.color1; c.model=FFF; if (!(object[i].selected)) object[i].textur.color1=0xff5555; object[i].selected^=1; object[i].draw(&c,&zb); c.model=m; object[i].textur.color1=l; return; } }
void map_widget::draw () { frame::draw (); if (!map) return; static int const layer = -1; int const W = this->width () / 2; int const H = this->height (); ndk::pen pen (*this); static data::glyph const space = { { { 0, 0, L' ' }, { 0, 0, L' ' } } }; #if HIGHLIGHT_PLAYER static data::glyph const player = { { { 0, 0, L'@' }, { 13, 13, L'@' } } }; #endif #if HIGHLIGHT_PLAYER int const playerx = (W - !(W % 2)) / 2; int const playery = (H - !(H % 2)) / 2; #endif int const offx = (map->w - W) / 2; int const offy = (map->h - H) / 2; return_unless (!data::glyphs.empty ()); for (int y = 1; y < H - 1; y++) { int const mapy = y + map->y + offy; if (!map->rows.has (mapy)) continue; auto const &row = map->rows[mapy]; for (int x = 1; x < W - 1; x++) { int const mapx = x + map->x + offx; if (!row.has (mapx)) continue; data::map::cell const &cell = row[mapx]; u32 const face = select_face (cell.face, layer); data::glyph const *glyph; int const winy = y * 1; int const winx = x * 2; #if HIGHLIGHT_PLAYER if (x == playerx && y == playery) glyph = &player; #else if (0) ; #endif else if (face && face < data::glyphs.size ()) // TODO: warn about face >= size glyph = &data::glyphs[face]; else glyph = &space; return_unless (winy >= 0); return_unless (winx >= 0); return_unless (winy < H); return_unless (winx < W * 2); return_unless (pen.move (winx, winy)); write (pen, *glyph, cell.darkness); } } #if HIGHLIGHT_PLAYER // 19:15 < n0nsense> pippijn: kannst du nethack-mäßig noch den cursor auf den player setzen? if (active ()) { pen.move (playerx, playery); ndk::app->cursor_on (); } else ndk::app->cursor_off (); #endif if (getenv ("DCLIENT_ONESHOT")) { delete ndk::app; exit (0); } pen.set_color ({ }); // reset }