Exemple #1
0
void Map::draw(Torbit& target)
{
    const bool z = zoom;
    int less_x = 0;
    int less_y = 0; // how much is the screen larger than the map?
    if (!get_torus_x() && get_xl() * (z+1) < screen_xl)
     less_x = screen_xl - get_xl() * (z+1);
    if (!get_torus_y() && get_yl() * (z+1) < screen_yl)
     less_y = screen_yl - get_yl() * (z+1);

    for     (int x = less_x/2; x < screen_xl-less_x/2; x += get_xl()*(z+1)) {
        for (int y = less_y;   y < screen_yl;          y += get_yl()*(z+1)) {
            draw_at(target, x, y);
            if (less_y != 0) break;
        }
        if (less_x != 0) break;
    }

    // Draw the screen border
    const int c = useR->screen_border_colored
                ? color[COL_SCREEN_BORDER] : 0;
    if (less_x) {
        rectfill(target.get_al_bitmap(), 0, 0, less_x/2 - 1,
         screen_yl - 1, c);
        rectfill(target.get_al_bitmap(), screen_xl - less_x/2, 0,
         screen_xl - 1, screen_yl - 1, c);
    }
    if (less_y)
     rectfill(target.get_al_bitmap(), less_x/2, 0,
     screen_xl - less_x/2 - 1, less_y - 1, c);
}
Exemple #2
0
void Map::load_masked_screen_rectangle(Torbit& src)
{
    if (get_xl() != src.get_xl() || get_yl() != src.get_yl()) return;
    const int&  x  = screen_x;
    const int&  y  = screen_y;
    const int&  xl = get_xl();
    const int&  yl = get_yl();
    const bool& tx = get_torus_x();
    const bool& ty = get_torus_y();
    const int min_w = screen_xl;
    const int min_h = screen_yl;
    BITMAP* s = src.get_al_bitmap();
    BITMAP* b =     get_al_bitmap();
                masked_blit(s, b, x,    y,    x,    y,    min_w, min_h);
    if (tx)     masked_blit(s, b, x-xl, y,    x-xl, y,    min_w, min_h);
    if (ty)     masked_blit(s, b, x,    y-yl, x,    y-yl, min_w, min_h);
    if (tx&&ty) masked_blit(s, b, x-xl, y-yl, x-xl, y-yl, min_w, min_h);
}
Exemple #3
0
void Map::draw_at(
    Torbit&   target,
    const int offx, // start this much away from the screen's upper left edge
    const int offy
) {
    const int& mapxl = get_xl();
    const int& mapyl = get_yl();
    const int  scrx = !zoom ? screen_x: Help::mod(screen_x+screen_xl/4, mapxl);
    const int  scry = !zoom ? screen_y: Help::mod(screen_y+screen_yl/4, mapyl);
    const int  lx = std::min(!zoom ? screen_xl : screen_xl / 2, mapxl);
    const int  ly = std::min(!zoom ? screen_yl : screen_yl / 2, mapyl);
    const bool short_x = scrx + lx > mapxl;
    const bool short_y = scry + ly > mapyl;
    const int  shoby_x = short_x ? scrx + lx - mapxl : 0;
    const int  shoby_y = short_y ? scry + ly - mapyl : 0;

    if (! zoom) {
        masked_blit(get_al_bitmap(), target.get_al_bitmap(),
         scrx, scry, // source x/y start
         offx, offy, // target x/y start
         short_x ? mapxl - scrx : lx, // x-length and y-length of area to copy
         short_y ? mapyl - scry : ly);
        if (short_x && get_torus_x()) {
            masked_blit(get_al_bitmap(), target.get_al_bitmap(),
             0, scry,
             offx + mapxl - scrx,
             offy,
             scrx + lx - mapxl,
             short_y ? mapyl - scry : ly);
        }
        if (short_y && get_torus_y()) {
            masked_blit(get_al_bitmap(), target.get_al_bitmap(),
             scrx, 0,
             offx,
             offy + mapyl - scry,
             short_x ? mapxl - scrx : lx,
             scry + ly - mapyl);
        }
        if (short_x && short_y && get_torus_x() && get_torus_y()) {
            masked_blit(get_al_bitmap(), target.get_al_bitmap(),
             0, 0,
             offx + mapxl - scrx,
             offy + mapyl - scry,
             scrx + lx - mapxl,
             scry + ly - mapyl);
        }
    }
    else {
        // This is the above code copied, but with zoom things hacked in
        blit_double(get_al_bitmap(), target.get_al_bitmap(),
         scrx, scry, // source x/y start
         short_x ? mapxl - scrx : lx, // x-length and y-length of the source
         short_y ? mapyl - scry : ly,
         offx, // target x/y start
         offy);
        if (short_x && get_torus_x()) {
            blit_double(get_al_bitmap(), target.get_al_bitmap(),
             0, scry,
             shoby_x,
             short_y ? mapyl - scry : ly,
             offx + 2 * (mapxl - scrx),
             offy);
        }
        if (short_y && get_torus_y()) {
            blit_double(get_al_bitmap(), target.get_al_bitmap(),
             scrx, 0,
             short_x ? mapxl - scrx : lx,
             shoby_y,
             offx,
             offy + 2 * (mapyl - scry));
        }
        if (short_x && short_y && get_torus_x() && get_torus_y()) {
            blit_double(get_al_bitmap(), target.get_al_bitmap(),
             0, 0,
             shoby_x,
             shoby_y,
             offx + 2 * (mapxl - scrx),
             offy + 2 * (mapyl - scry));
        }
    }
    // end if/else zoom
}
Exemple #4
0
void draw_shadow_centered_text(
 Torbit& bmp, FONT* f, const char* s, int x, int y, int c, int sc) {
    textout_centre_ex(bmp.get_al_bitmap(), f, s, x+1, y+1, sc, -1);
    textout_centre_ex(bmp.get_al_bitmap(), f, s, x  , y  , c,  -1);
}
Exemple #5
0
void draw_shaded_text(Torbit& bmp, FONT* f, const char* s,
 int x, int y, int r, int g, int b) {
    textout_ex(bmp.get_al_bitmap(), f, s, x+2, y+2, makecol(r/4, g/4, b/4),-1);
    textout_ex(bmp.get_al_bitmap(), f, s, x+1, y+1, makecol(r/2, g/2, b/2),-1);
    textout_ex(bmp.get_al_bitmap(), f, s, x  , y  , makecol(r  , g  , b  ),-1);
}
Exemple #6
0
void Cutbit::draw(
    Torbit&      target_torbit,
    const int    x,
    const int    y,
    const int    fx,
    const int    fy,
    const bool   mirr,
    const double rot,
    const double scal,
    const Mode   mode) const
{
    BITMAP* target = target_torbit.get_al_bitmap();
    if (bitmap && fx >= 0 && fy >= 0 && fx < x_frames && fy < y_frames) {
        // Schneide zunaechst ein Subbitmap aus unter Beachtung der Framewahl
        // Hat das Bild keine Frames, entfaellt +1 fuer den aeusseren Rahmen.
        BITMAP* sprite;
        if (x_frames == 1 && y_frames == 1)
             sprite = create_sub_bitmap(bitmap, 0, 0, xl, yl);
        else sprite = create_sub_bitmap(bitmap, fx * (xl+1) + 1,
                                                fy * (yl+1) + 1, xl, yl);
        if (mode == NORMAL) {
            target_torbit.draw_from(sprite, x, y, mirr, rot, scal);
        }
        else {
            const int PINK  = color[COL_PINK];
            const int BLACK = color[COL_BLACK];
            const int GREY  = color[COL_EDITOR_DARK];
            const int size  = xl > yl ? xl : yl;
            Torbit excerpt(size, size);
            excerpt.clear_to_color(PINK);
            excerpt.draw_from(sprite, 0, 0, mirr, rot, scal);
            if (mode == NOOW) {
                target_torbit.draw     (excerpt.get_al_bitmap(), x, y);
                target_torbit.draw_from(excerpt.get_al_bitmap(), x, y);
            }
            else if (mode == NOOW_EDITOR) {
                for  (int ix = 0; ix < size; ++ix)
                 for (int iy = 0; iy < size; ++iy) {
                    const int c = target_torbit.get_pixel(x + ix, y + iy);
                    const int e = excerpt      .get_pixel(    ix,     iy);
                    if ((c == BLACK || c == PINK || c == GREY)
                     &&  e != BLACK && e != PINK)
                     target_torbit.set_pixel(x + ix, y + iy, e);
            }   }
            else if (mode == DARK
                  || mode == DARK_EDITOR) {
                for  (int ix = 0; ix < size; ++ix)
                 for (int iy = 0; iy < size; ++iy)
                 if (excerpt.get_pixel(ix, iy) != PINK)
                 target_torbit.set_pixel(x+ix, y+iy, mode==DARK ? PINK : GREY);
            }
        }
        // Fertig
        destroy_bitmap(sprite);
    }

    // Keine gueltige Frame-Angabe
    else {
        int          col_text = makecol(255, 255, 255);
        int          col_back = makecol( 64,  64,  64);
        if (!bitmap) col_back = makecol(255,  64,  64);
        std::ostringstream str;
        str << "( " << fx << " | " << fy << " )";
        textout_ex(target, font, "Frame?!?!", x, y,        col_text, col_back);
        textout_ex(target, font, str.str().c_str(), x, y+8,col_text, col_back);
    }
}