Ignore:
Timestamp:
May 15, 2011, 6:22:17 AM (11 years ago)
Author:
Sam Hocevar
Message:

game: refactor the mouse/game coordinate conversion logic.

File:
1 edited

Legend:

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

    r655 r657  
    785785void level::draw_areas(view *v)
    786786{
    787   int32_t sx1,sy1,sx2,sy2;
    788   area_controller *a=area_list;
    789   for (; a; a=a->next)
    790   {
    791     int c1,c2;
    792     if (a->active)
    793     {
    794       c1=morph_sel_frame_color;
    795       c2=wm->bright_color();
    796     } else
    797     {
    798       c2=morph_sel_frame_color;
    799       c1=wm->bright_color();
    800     }
    801 
    802     the_game->game_to_mouse(a->x,a->y,v,sx1,sy1);
    803     the_game->game_to_mouse(a->x+a->w,a->y+a->h,v,sx2,sy2);
    804     main_screen->Rectangle(vec2i(sx1, sy1), vec2i(sx2, sy2), c1);
    805     main_screen->Bar(vec2i(sx1 - 1, sy1 - 1), vec2i(sx1 + 1, sy1 + 1), c2);
    806     main_screen->Bar(vec2i(sx2 - 1, sy2 - 1), vec2i(sx2 + 1, sy2 + 1), c2);
    807   }
     787    for (area_controller *a = area_list; a; a = a->next)
     788    {
     789        int c1 = a->active ? morph_sel_frame_color : wm->bright_color();
     790        int c2 = a->active ? wm->bright_color() : morph_sel_frame_color;
     791
     792        vec2i pos1 = the_game->GameToMouse(vec2i(a->x, a->y), v);
     793        vec2i pos2 = the_game->GameToMouse(vec2i(a->x + a->w, a->y + a->h), v);
     794        main_screen->Rectangle(pos1, pos2, c1);
     795        main_screen->Bar(pos1 - vec2i(1, 1), pos1 + vec2i(1, 1), c2);
     796        main_screen->Bar(pos2 - vec2i(1, 1), pos2 + vec2i(1, 1), c2);
     797    }
    808798}
    809799
Note: See TracChangeset for help on using the changeset viewer.