Ignore:
Timestamp:
May 16, 2011, 2:37:19 AM (9 years ago)
Author:
Sam Hocevar
Message:

imlib: make JCFont use vec2i classes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • abuse/trunk/src/console.cpp

    r665 r668  
    3535void console::redraw()
    3636{
    37   if (con_win)
    38   {
     37    if (!con_win)
     38        return;
     39
    3940    con_win->clear();
    40     char *s=screen;
    41     int dx,dy,xa=fnt->width(),ya=fnt->height(),i,j;
    42     for (j=0,dy=wy(); j<h; j++,dy+=ya)
    43     {
    44       for (i=0,dx=wx(); i<w; i++,s++,dx+=xa)
    45       {
    46     if (*s)
    47       fnt->put_char(con_win->m_surf,dx,dy,*s);
    48       }
    49     }
    50     fnt->put_char(con_win->m_surf,wx()+cx*xa,wy()+cy*ya,'_');
    51   }
     41    char *s = screen;
     42    int xa = fnt->Size().x, ya = fnt->Size().y;
     43    for (int j = 0, dy = wy(); j < h; j++, dy += ya)
     44        for (int i = 0, dx = wx(); i < w; i++, s++, dx += xa)
     45            if (*s)
     46                fnt->PutChar(con_win->m_surf, vec2i(dx, dy), *s);
     47    fnt->PutChar(con_win->m_surf, vec2i(wx() + cx * xa, wy() + cy * ya), '_');
    5248}
    5349
     
    9894void console::draw_cursor()
    9995{
    100   if (con_win)
    101     fnt->put_char(con_win->m_surf,cx*fnt->width()+wx(),cy*fnt->height()+wy(),'_');
     96    if (!con_win)
     97        return;
     98
     99    fnt->PutChar(con_win->m_surf,
     100                 vec2i(cx, cy) * fnt->Size() + vec2i(wx(), wy()), '_');
    102101}
    103102
     
    105104void console::draw_char(int x, int y, char ch)
    106105{
    107   if (con_win)
    108   {
    109     int fw=fnt->width(),fh=fnt->height();
    110     int dx=wx()+x*fw,dy=wy()+y*fh;
    111     con_win->m_surf->Bar(vec2i(dx, dy), vec2i(dx + fw - 1, dy + fh - 1),
    112                          wm->black());
    113     fnt->put_char(con_win->m_surf,dx,dy,ch);
    114   }
     106    if (!con_win)
     107        return;
     108
     109    vec2i fs = fnt->Size();
     110    vec2i pos = vec2i(wx(), wy()) + vec2i(x, y) * fs;
     111    con_win->m_surf->Bar(pos, pos + fs - vec2i(1), wm->black());
     112    fnt->PutChar(con_win->m_surf, pos, ch);
    115113}
    116114
Note: See TracChangeset for help on using the changeset viewer.