Changeset 656


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

imlib: move generic code back into the platform-agnostic imlib.

Location:
abuse/trunk
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • abuse/trunk/TODO

    r655 r656  
    5959console::draw_char : pareil
    6060VolumeWindow::draw_vol plus grand !!
     61
  • abuse/trunk/src/ant.cpp

    r655 r656  
    448448  {
    449449    fade_out(8);
    450     wm->set_mouse_position(0,0);
     450    wm->SetMousePos(vec2i(0, 0));
    451451    main_screen->clear();
    452452    image *im=cache.img(cache.reg("art/frame.spe","end_level_screen",SPEC_IMAGE,1));
  • abuse/trunk/src/clisp.cpp

    r655 r656  
    21842184      c_target=id;
    21852185      if (main_screen)
    2186         wm->set_mouse_shape(cache.img(c_target)->copy(),x,y);
     2186        wm->SetMouseShape(cache.img(c_target)->copy(), vec2i(x, y));
    21872187    } break;
    21882188    case 276 :
  • abuse/trunk/src/cop.cpp

    r655 r656  
    10491049{
    10501050  fade_out(8);
    1051   wm->set_mouse_position(0,0);
     1051  wm->SetMousePos(vec2i(0, 0));
    10521052  main_screen->clear();
    10531053  image *im=cache.img(cache.reg("art/frame.spe","end_level_screen",SPEC_IMAGE,1));
  • abuse/trunk/src/demo.cpp

    r645 r656  
    123123    int32_t mx,my;
    124124    the_game->game_to_mouse(player_list->pointer_x,player_list->pointer_y,player_list,mx,my);
    125     wm->set_mouse_position(small_render ? mx*2 : mx, small_render ? my*2 : my);
     125    wm->SetMousePos((small_render ? 2 : 1) * vec2i(mx, my));
    126126      }
    127127      else
  • abuse/trunk/src/dev.cpp

    r655 r656  
    278278        if (first->otype==type)
    279279      find=first;
    280       int loop=0;
    281280      if (!find)
    282281      {
     
    286285        find=first;
    287286    }
    288     loop=1;
    289287      }
    290288      if (find)
     
    30033001void pal_win::draw()
    30043002{
    3005   int i,find=-1,d=cur_fg;
     3003  int i,d=cur_fg;
    30063004  if (me)
    30073005  {
     
    30183016      if (d==pat[i])
    30193017      {
    3020     find=i;
    30213018    me->m_surf->Rectangle(vec2i(me->x1() + (i % w) * tw,
    30223019                                me->y1() + (i / w) * th),
     
    35883585  if (dev&EDIT_MODE)
    35893586  {
    3590     wm->set_mouse_shape(cache.img(c_normal)->copy(),1,1);
     3587    wm->SetMouseShape(cache.img(c_normal)->copy(), vec2i(1, 1));
    35913588    pal->load();
    35923589  }
     
    35943591  {
    35953592    if (dev&MAP_MODE) dev-=MAP_MODE;                        // no map mode while playing!
    3596     wm->set_mouse_shape(cache.img(c_target)->copy(),8,8);
     3593    wm->SetMouseShape(cache.img(c_target)->copy(), vec2i(8, 8));
    35973594  }
    35983595  if ((dev&EDIT_MODE) && !dev_menu)
  • abuse/trunk/src/endgame.cpp

    r650 r656  
    182182
    183183  image blank(vec2i(2)); blank.clear();
    184   wm->set_mouse_shape(blank.copy(),0,0);      // don't show mouse
     184  wm->SetMouseShape(blank.copy(), vec2i(0, 0));      // don't show mouse
    185185
    186186
     
    414414  main_screen->clear();
    415415
    416 
    417   wm->set_mouse_shape(cache.img(c_normal)->copy(),1,1);
     416  wm->SetMouseShape(cache.img(c_normal)->copy(), vec2i(1, 1));
    418417  the_game->set_state(MENU_STATE);
    419418}
     
    425424  fade_out(16);
    426425  image blank(vec2i(2, 2)); blank.clear();
    427   wm->set_mouse_shape(blank.copy(),0,0);      // don't show mouse
     426  wm->SetMouseShape(blank.copy(), vec2i(0, 0)); // don't show mouse
    428427  main_screen->clear();
    429428
     
    471470
    472471  fade_out(16);
    473   wm->set_mouse_shape(blank.copy(),0,0);      // don't show mouse
     472  wm->SetMouseShape(blank.copy(), vec2i(0, 0)); // don't show mouse
    474473  show_sell(1);
    475474  wm->Push(new Event(ID_SHOW_SELL,NULL));
     
    481480  fade_out(16);
    482481  image blank(vec2i(2, 2)); blank.clear();
    483   wm->set_mouse_shape(blank.copy(),0,0);      // don't show mouse
     482  wm->SetMouseShape(blank.copy(), vec2i(0, 0));      // don't show mouse
    484483  main_screen->clear();
    485484
     
    528527  show_sell(1);
    529528
    530   wm->set_mouse_shape(cache.img(c_normal)->copy(),1,1);
     529  wm->SetMouseShape(cache.img(c_normal)->copy(), vec2i(1, 1));
    531530  the_game->set_state(MENU_STATE);
    532531}
  • abuse/trunk/src/game.cpp

    r655 r656  
    443443
    444444    if(playing_state(state) &&  !(dev & EDIT_MODE))
    445         wm->set_mouse_shape(cache.img(c_target)->copy(), 8, 8);
     445        wm->SetMouseShape(cache.img(c_target)->copy(), vec2i(8, 8));
    446446    else
    447         wm->set_mouse_shape(cache.img(c_normal)->copy(), 1, 1);
     447        wm->SetMouseShape(cache.img(c_normal)->copy(), vec2i(1, 1));
    448448
    449449    if(old_state == SCENE_STATE && new_state != SCENE_STATE)
     
    12431243    image *blank = new image(vec2i(2, 2));
    12441244    blank->clear();
    1245     wm->set_mouse_shape(blank->copy(), 0, 0); // hide mouse
     1245    wm->SetMouseShape(blank->copy(), vec2i(0, 0)); // hide mouse
    12461246    delete blank;
    12471247    fade_in(cache.img(cdc_logo), 32);
  • abuse/trunk/src/imlib/event.cpp

    r652 r656  
    3535{
    3636    CHECK(screen && pal);
    37     last_keystat = get_key_flags();
    3837    m_pending = 0;
    3938
     
    6261
    6362    m_sprite = new sprite(screen, im, 100, 100);
    64     m_pos = m_lastpos = screen->Size() / 2;
    65     m_button = m_lastbutton = 0;
     63    m_pos = screen->Size() / 2;
    6664    m_center = vec2i(0, 0);
     65    m_button = 0;
    6766
    6867    // Platform-specific stuff
     
    7675{
    7776    ;
     77}
     78
     79void EventHandler::Get(Event &ev)
     80{
     81    // Sleep until there are events available
     82    while(!m_pending)
     83    {
     84        Timer tmp;
     85        IsPending();
     86
     87        if (!m_pending)
     88            tmp.WaitMs(1);
     89    }
     90
     91    // Return first queued event if applicable
     92    Event *ep = (Event *)m_events.first();
     93    if(ep)
     94    {
     95        ev = *ep;
     96        m_events.unlink(ep);
     97        delete ep;
     98        m_pending = m_events.first() != NULL;
     99        return;
     100    }
     101
     102    // Return an event from the platform-specific system
     103    SysEvent(ev);
    78104}
    79105
  • abuse/trunk/src/imlib/event.h

    r654 r656  
    7171    void SysInit();
    7272    void SysWarpMouse(vec2i pos);
     73    void SysEvent(Event &ev);
    7374
    7475  int IsPending();
     
    7879
    7980  int has_mouse() { return 1; }
    80   void set_mouse_shape(image *im, int centerx, int centery)
    81   {
    82     m_sprite->change_visual(im, 1);
    83     m_center = vec2i(centerx, centery);
    84   }
    85   void set_mouse_position(int mx, int my)
    86   {
    87     m_pos = vec2i(Min(mx, m_screen->Size().x - 1),
    88                   Min(my, m_screen->Size().y - 1));
    89     SysWarpMouse(m_pos);
    90   }
     81    void SetMouseShape(image *im, vec2i center)
     82    {
     83        m_sprite->change_visual(im, 1);
     84        m_center = center;
     85    }
     86    void SetMousePos(vec2i pos)
     87    {
     88        m_pos = vec2i(Min(Max(pos.x, 0), m_screen->Size().x - 1),
     89                      Min(Max(pos.y, 0), m_screen->Size().y - 1));
     90        SysWarpMouse(m_pos);
     91    }
    9192
    9293private:
    93     int get_key_flags();
    94 
    9594    linked_list m_events;
    96     int m_pending, last_keystat, last_key;
     95    int m_pending, last_key;
    9796    sprite_controller sc;
    9897
     
    102101    /* Mouse information */
    103102    sprite *m_sprite;
    104     vec2i m_pos, m_lastpos, m_center;
    105     int m_button, m_lastbutton;
     103    vec2i m_pos, m_center;
     104    int m_button;
    106105};
    107106
  • abuse/trunk/src/menu.cpp

    r655 r656  
    399399  {
    400400    image blank(vec2i(2, 2)); blank.clear();
    401     wm->set_mouse_shape(blank.copy(),0,0);      // don't show mouse
     401    wm->SetMouseShape(blank.copy(), vec2i(0, 0));      // don't show mouse
    402402
    403403    LObject *tmp = (LObject *)ss->GetValue();
     
    418418      tmp = (LObject *)CDR(tmp);
    419419    }
    420     wm->set_mouse_shape(cache.img(c_normal)->copy(),1,1);
     420    wm->SetMouseShape(cache.img(c_normal)->copy(), vec2i(1, 1));
    421421  }
    422422}
  • abuse/trunk/src/sdlport/event.cpp

    r652 r656  
    5151
    5252//
    53 // get_key_flags()
    54 // Return the flag for the key modifiers
    55 //
    56 int EventHandler::get_key_flags()
    57 {
    58     SDLMod key_flag = SDL_GetModState();
    59 
    60     return ((key_flag & KMOD_SHIFT) != 0) << 3 |
    61            ((key_flag & KMOD_CTRL) != 0) << 2 |
    62            ((key_flag & KMOD_ALT) != 0) << 1;
    63 }
    64 
    65 //
    6653// IsPending()
    6754// Are there any events in the queue?
     
    7663
    7764//
    78 // get_event()
    7965// Get and handle waiting events
    8066//
    81 void EventHandler::Get(Event &ev)
     67void EventHandler::SysEvent(Event &ev)
    8268{
    83     while(!m_pending)
    84     {
    85         IsPending();
    86 
    87         if (!m_pending)
    88         {
    89             // Sleep for 1 millisecond if there are no events
    90             Timer tmp; tmp.WaitMs(1);
    91         }
    92     }
    93 
    94     Event *ep = (Event *)m_events.first();
    95     if(ep)
    96     {
    97         ev = *ep;
    98         m_events.unlink(ep);
    99         delete ep;
    100         m_pending = m_events.first() != NULL;
    101         return;
    102     }
    103 
    10469    // No more events
    10570    m_pending = 0;
  • abuse/trunk/src/statbar.cpp

    r643 r656  
    251251    {
    252252      if ((current_level->tick_counter()&4)==0)
    253         wm->set_mouse_shape(cache.img(c_mouse1)->copy(),4,4);
    254       else wm->set_mouse_shape(cache.img(c_mouse2)->copy(),4,4);
     253        wm->SetMouseShape(cache.img(c_mouse1)->copy(), vec2i(4, 4));
     254      else wm->SetMouseShape(cache.img(c_mouse2)->copy(), vec2i(4, 4));
    255255      changed_cursor=1;
    256256    } else if (changed_cursor)
    257257    {
    258258      if (!(dev&EDIT_MODE))
    259         wm->set_mouse_shape(cache.img(c_target)->copy(),8,8);
     259        wm->SetMouseShape(cache.img(c_target)->copy(), vec2i(8, 8));
    260260      else
    261         wm->set_mouse_shape(cache.img(c_normal)->copy(),1,1);
     261        wm->SetMouseShape(cache.img(c_normal)->copy(), vec2i(1, 1));
    262262      changed_cursor=0;
    263263    }
Note: See TracChangeset for help on using the changeset viewer.