Changeset 652
- Timestamp:
- May 14, 2011, 4:00:48 PM (11 years ago)
- Location:
- abuse/trunk/src
- Files:
-
- 2 deleted
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
abuse/trunk/src/imlib/Makefile.am
r643 r652 27 27 video.cpp video.h \ 28 28 event.cpp event.h \ 29 mouse.htiming.h jdir.h visobj.h \29 timing.h jdir.h visobj.h \ 30 30 $(NULL) 31 31 -
abuse/trunk/src/imlib/event.cpp
r643 r652 27 27 #include "event.h" 28 28 #include "video.h" 29 #include "filter.h" 30 31 // 32 // Constructor 33 // 34 EventHandler::EventHandler(image *screen, palette *pal) 35 { 36 CHECK(screen && pal); 37 last_keystat = get_key_flags(); 38 m_pending = 0; 39 40 m_screen = screen; 41 42 // Mouse stuff 43 uint8_t mouse_sprite[]= 44 { 45 0, 2, 0, 0, 0, 0, 0, 0, 46 2, 1, 2, 0, 0, 0, 0, 0, 47 2, 1, 1, 2, 0, 0, 0, 0, 48 2, 1, 1, 1, 2, 0, 0, 0, 49 2, 1, 1, 1, 1, 2, 0, 0, 50 2, 1, 1, 1, 1, 1, 2, 0, 51 0, 2, 1, 1, 2, 2, 0, 0, 52 0, 0, 2, 1, 1, 2, 0, 0, 53 0, 0, 2, 1, 1, 2, 0, 0, 54 0, 0, 0, 2, 2, 0, 0, 0 55 }; 56 57 Filter f; 58 f.Set(1, pal->brightest(1)); 59 f.Set(2, pal->darkest(1)); 60 image *im = new image(vec2i(8, 10), mouse_sprite); 61 f.Apply(im); 62 63 m_sprite = new sprite(screen, im, 100, 100); 64 m_pos = m_lastpos = screen->Size() / 2; 65 m_button = m_lastbutton = 0; 66 m_center = vec2i(0, 0); 67 68 // Platform-specific stuff 69 SysInit(); 70 } 29 71 30 72 // … … 33 75 EventHandler::~EventHandler() 34 76 { 35 delete mouse;77 ; 36 78 } 37 79 -
abuse/trunk/src/imlib/event.h
r645 r652 28 28 #include "keys.h" 29 29 #include "sprite.h" 30 #include "mouse.h"31 30 32 31 class Jwindow; … … 70 69 } 71 70 72 JCMouse *mouse; 73 sprite *mouse_sprite() { return mouse->mouse_sprite(); } 71 void SysInit(); 72 void SysWarpMouse(vec2i pos); 73 74 74 int IsPending(); 75 75 void Get(Event &ev); 76 76 void add_redraw(int X1, int Y1, int X2, int Y2, void *Start); 77 void mouse_status(int &x, int &y, int &button) 77 void flush_screen(); 78 79 int has_mouse() { return 1; } 80 void set_mouse_shape(image *im, int centerx, int centery) 78 81 { 79 if (mouse) 80 { 81 x = mouse->x(); 82 y = mouse->y(); 83 button = mouse->button(); 84 } else x = y = button = 0; 82 m_sprite->change_visual(im); 83 m_center = vec2i(-centerx, -centery); 85 84 } 86 void flush_screen(); 87 int has_mouse() { return mouse->exists(); } 88 void set_mouse_shape(image *im, int centerx, int centery) { mouse->set_shape(im, -centerx, -centery); } 89 void set_mouse_position(int mx, int my) { if (mouse) mouse->set_position(mx, my); } 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 } 90 91 91 92 private: … … 93 94 94 95 linked_list m_events; 95 int m here, m_pending, last_keystat, last_key;96 int m_pending, last_keystat, last_key; 96 97 sprite_controller sc; 98 99 image *m_screen; 100 101 protected: 102 /* Mouse information */ 103 sprite *m_sprite; 104 vec2i m_pos, m_lastpos, m_center; 105 int m_button, m_lastbutton; 97 106 }; 98 107 -
abuse/trunk/src/imlib/jwindow.cpp
r650 r652 328 328 void WindowManager::flush_screen() 329 329 { 330 Jwindow *p, *q;331 332 330 int mx = 0, my = 0; 333 image *mouse_pic = NULL, *mouse_save = NULL; 334 335 if(has_mouse()) 336 { 337 mouse_pic = mouse_sprite()->visual; 338 mouse_save = mouse_sprite()->save; 339 mx = mouse->drawx(); 340 my = mouse->drawy(); 341 342 mouse_save->PutPart(m_surf, 0, 0, mx, my, 343 mx + mouse_pic->Size().x - 1, 344 my + mouse_pic->Size().y - 1); 345 m_surf->PutImage(mouse_pic, vec2i(mx, my), 1); 346 } 347 348 for(p = m_first; p; p = p->next) 349 if(!p->is_hidden()) 331 332 if (has_mouse()) 333 { 334 mx = (m_pos - m_center).x; 335 my = (m_pos - m_center).y; 336 337 m_sprite->save->PutPart(m_surf, 0, 0, mx, my, 338 mx + m_sprite->visual->Size().x - 1, 339 my + m_sprite->visual->Size().y - 1); 340 m_surf->PutImage(m_sprite->visual, vec2i(mx, my), 1); 341 } 342 343 for (Jwindow *p = m_first; p; p = p->next) 344 if (!p->is_hidden()) 350 345 m_surf->delete_dirty(p->x, p->y, p->x + p->l, p->y + p->h); 351 346 update_dirty(m_surf); 352 347 353 if (has_mouse())354 m_surf->PutImage(m ouse_save, vec2i(mx, my));355 356 for (p = m_first; p; p = p->next)357 { 358 if (p->is_hidden())348 if (has_mouse()) 349 m_surf->PutImage(m_sprite->save, vec2i(mx, my)); 350 351 for (Jwindow *p = m_first; p; p = p->next) 352 { 353 if (p->is_hidden()) 359 354 continue; 360 355 361 if (has_mouse())356 if (has_mouse()) 362 357 { 363 mouse_save->PutPart(p->m_surf, 0, 0, mx - p->x, my - p->y, 364 mx - p->x + mouse_pic->Size().x - 1, 365 my - p->y + mouse_pic->Size().y - 1); 366 p->m_surf->PutImage(mouse_pic, vec2i(mx - p->x, my - p->y), 1); 358 m_sprite->save->PutPart(p->m_surf, 0, 0, mx - p->x, my - p->y, 359 mx - p->x + m_sprite->visual->Size().x - 1, 360 my - p->y + m_sprite->visual->Size().y - 1); 361 p->m_surf->PutImage(m_sprite->visual, 362 vec2i(mx - p->x, my - p->y), 1); 367 363 } 368 364 369 365 // m_surf->delete_dirty(p->x, p->y, p->x+p->l, p->y+p->h); 370 for (q = p->next; q; q = q->next)371 if (!q->is_hidden())366 for (Jwindow *q = p->next; q; q = q->next) 367 if (!q->is_hidden()) 372 368 p->m_surf->delete_dirty(q->x - p->x, q->y - p->y, 373 374 369 q->x + q->l - p->x, 370 q->y + q->h - p->y); 375 371 update_dirty(p->m_surf, p->x, p->y); 376 if (has_mouse())377 p->m_surf->PutImage(m ouse_save, vec2i(mx - p->x, my - p->y), 0);372 if (has_mouse()) 373 p->m_surf->PutImage(m_sprite->save, vec2i(mx - p->x, my - p->y), 0); 378 374 } 379 375 } -
abuse/trunk/src/sdlport/Makefile.am
r623 r652 6 6 libsdlport_a_SOURCES = \ 7 7 video.cpp \ 8 mouse.cpp \9 8 event.cpp \ 10 9 sound.cpp sound.h \ -
abuse/trunk/src/sdlport/event.cpp
r647 r652 30 30 #include "palette.h" 31 31 #include "video.h" 32 #include "mouse.h"33 32 #include "event.h" 34 33 #include "timing.h" … … 40 39 short mouse_buttons[5] = { 0, 0, 0, 0, 0 }; 41 40 42 // 43 // Constructor 44 // 45 EventHandler::EventHandler(image *screen, palette *pal) 46 { 47 CHECK(screen && pal); 48 mouse = new JCMouse(screen, pal); 49 mhere = mouse->exists(); 50 last_keystat = get_key_flags(); 51 m_pending = 0; 52 41 void EventHandler::SysInit() 42 { 53 43 // Ignore activate events 54 44 SDL_EventState(SDL_ACTIVEEVENT, SDL_IGNORE); 45 } 46 47 void EventHandler::SysWarpMouse(vec2i pos) 48 { 49 SDL_WarpMouse(pos.x, pos.y); 55 50 } 56 51 … … 112 107 // NOTE : that the mouse status should be known 113 108 // even if another event has occurred. 114 ev.mouse_move.x = m ouse->x();115 ev.mouse_move.y = m ouse->y();116 ev.mouse_button = m ouse->button();109 ev.mouse_move.x = m_pos.x; 110 ev.mouse_move.y = m_pos.y; 111 ev.mouse_button = m_button; 117 112 118 113 // Gather next event … … 173 168 ev.mouse_button &= (0xff - RIGHT_BUTTON); 174 169 } 175 mouse->update(ev.mouse_move.x, ev.mouse_move.y, ev.mouse_button); 170 m_pos = vec2i(ev.mouse_move.x, ev.mouse_move.y); 171 m_button = ev.mouse_button; 176 172 177 173 // Sort out other kinds of events
Note: See TracChangeset
for help on using the changeset viewer.