@@ -384,7 +384,7 @@ class MouseState(Event):
384384 """
385385 Attributes:
386386 type (str): Always "MOUSESTATE".
387- pixel (Point): The pixel coordinates of the mouse.
387+ position (Point): The position coordinates of the mouse.
388388 tile (Point): The integer tile coordinates of the mouse on the screen.
389389 state (int): A bitmask of which mouse buttons are currently held.
390390
@@ -397,39 +397,70 @@ class MouseState(Event):
397397 * tcod.event.BUTTON_X2MASK
398398
399399 .. versionadded:: 9.3
400+
401+ .. versionchanged:: Unreleased
402+ Renamed `pixel` attribute to `position`.
400403 """
401404
402405 def __init__ (
403406 self ,
404- pixel : Tuple [int , int ] = (0 , 0 ),
407+ position : Tuple [int , int ] = (0 , 0 ),
405408 tile : Optional [Tuple [int , int ]] = (0 , 0 ),
406409 state : int = 0 ,
407410 ):
408411 super ().__init__ ()
409- self .pixel = Point (* pixel )
412+ self .position = Point (* position )
410413 self .__tile = Point (* tile ) if tile is not None else None
411414 self .state = state
412415
416+ @property
417+ def pixel (self ) -> Point :
418+ warnings .warn (
419+ "The mouse.pixel attribute is deprecated. Use mouse.position instead." ,
420+ DeprecationWarning ,
421+ stacklevel = 2 ,
422+ )
423+ return self .position
424+
425+ @pixel .setter
426+ def pixel (self , value : Point ) -> None :
427+ warnings .warn (
428+ "The mouse.pixel attribute is deprecated. Use mouse.position instead." ,
429+ DeprecationWarning ,
430+ stacklevel = 2 ,
431+ )
432+ self .position = value
433+
413434 @property
414435 def tile (self ) -> Point :
436+ warnings .warn (
437+ "The mouse.tile attribute is deprecated. Use mouse.position of the event returned by context.convert_event instead." ,
438+ DeprecationWarning ,
439+ stacklevel = 2 ,
440+ )
415441 return _verify_tile_coordinates (self .__tile )
416442
417443 @tile .setter
418444 def tile (self , xy : Tuple [int , int ]) -> None :
445+ warnings .warn (
446+ "The mouse.tile attribute is deprecated. Use mouse.position of the event returned by context.convert_event instead." ,
447+ DeprecationWarning ,
448+ stacklevel = 2 ,
449+ )
419450 self .__tile = Point (* xy )
420451
421452 def __repr__ (self ) -> str :
422- return ("tcod.event.%s(pixel =%r, tile=%r, state=%s)" ) % (
453+ return ("tcod.event.%s(position =%r, tile=%r, state=%s)" ) % (
423454 self .__class__ .__name__ ,
424- tuple (self .pixel ),
455+ tuple (self .position ),
425456 tuple (self .tile ),
426457 _describe_bitmask (self .state , _REVERSE_BUTTON_MASK_TABLE_PREFIX ),
427458 )
428459
429460 def __str__ (self ) -> str :
430- return ("<%s, pixel =(x=%i, y=%i), tile=(x=%i, y=%i), state=%s>" ) % (
461+ return ("<%s, position =(x=%i, y=%i), tile=(x=%i, y=%i), state=%s>" ) % (
431462 super ().__str__ ().strip ("<>" ),
432- * self .pixel ,
463+ * self .position ,
433464 * self .tile ,
434465 _describe_bitmask (self .state , _REVERSE_BUTTON_MASK_TABLE ),
435466 )
@@ -439,8 +470,8 @@ class MouseMotion(MouseState):
439470 """
440471 Attributes:
441472 type (str): Always "MOUSEMOTION".
442- pixel (Point): The pixel coordinates of the mouse.
443- pixel_motion (Point): The pixel delta.
473+ position (Point): The pixel coordinates of the mouse.
474+ motion (Point): The pixel delta.
444475 tile (Point): The integer tile coordinates of the mouse on the screen.
445476 tile_motion (Point): The integer tile delta.
446477 state (int): A bitmask of which mouse buttons are currently held.
@@ -452,26 +483,60 @@ class MouseMotion(MouseState):
452483 * tcod.event.BUTTON_RMASK
453484 * tcod.event.BUTTON_X1MASK
454485 * tcod.event.BUTTON_X2MASK
486+
487+ .. versionchanged:: Unreleased
488+ Renamed `pixel` attribute to `position`.
489+ Renamed `pixel_motion` attribute to `motion`.
455490 """
456491
457492 def __init__ (
458493 self ,
459- pixel : Tuple [int , int ] = (0 , 0 ),
460- pixel_motion : Tuple [int , int ] = (0 , 0 ),
494+ position : Tuple [int , int ] = (0 , 0 ),
495+ motion : Tuple [int , int ] = (0 , 0 ),
461496 tile : Optional [Tuple [int , int ]] = (0 , 0 ),
462497 tile_motion : Optional [Tuple [int , int ]] = (0 , 0 ),
463498 state : int = 0 ,
464499 ):
465- super ().__init__ (pixel , tile , state )
466- self .pixel_motion = Point (* pixel_motion )
500+ super ().__init__ (position , tile , state )
501+ self .motion = Point (* motion )
467502 self .__tile_motion = Point (* tile_motion ) if tile_motion is not None else None
468503
504+ @property
505+ def pixel_motion (self ) -> Point :
506+ warnings .warn (
507+ "The mouse.pixel_motion attribute is deprecated. Use mouse.motion instead." ,
508+ DeprecationWarning ,
509+ stacklevel = 2 ,
510+ )
511+ return self .motion
512+
513+ @pixel_motion .setter
514+ def pixel_motion (self , value : Point ) -> None :
515+ warnings .warn (
516+ "The mouse.pixel_motion attribute is deprecated. Use mouse.motion instead." ,
517+ DeprecationWarning ,
518+ stacklevel = 2 ,
519+ )
520+ self .motion = value
521+
469522 @property
470523 def tile_motion (self ) -> Point :
524+ warnings .warn (
525+ "The mouse.tile_motion attribute is deprecated."
526+ " Use mouse.motion of the event returned by context.convert_event instead." ,
527+ DeprecationWarning ,
528+ stacklevel = 2 ,
529+ )
471530 return _verify_tile_coordinates (self .__tile_motion )
472531
473532 @tile_motion .setter
474533 def tile_motion (self , xy : Tuple [int , int ]) -> None :
534+ warnings .warn (
535+ "The mouse.tile_motion attribute is deprecated."
536+ " Use mouse.motion of the event returned by context.convert_event instead." ,
537+ DeprecationWarning ,
538+ stacklevel = 2 ,
539+ )
475540 self .__tile_motion = Point (* xy )
476541
477542 @classmethod
@@ -494,19 +559,19 @@ def from_sdl_event(cls, sdl_event: Any) -> MouseMotion:
494559 return self
495560
496561 def __repr__ (self ) -> str :
497- return ("tcod.event.%s(pixel =%r, pixel_motion =%r, " " tile=%r, tile_motion=%r, state=%s)" ) % (
562+ return ("tcod.event.%s(position =%r, motion =%r, tile=%r, tile_motion=%r, state=%s)" ) % (
498563 self .__class__ .__name__ ,
499- tuple (self .pixel ),
500- tuple (self .pixel_motion ),
564+ tuple (self .position ),
565+ tuple (self .motion ),
501566 tuple (self .tile ),
502567 tuple (self .tile_motion ),
503568 _describe_bitmask (self .state , _REVERSE_BUTTON_MASK_TABLE_PREFIX ),
504569 )
505570
506571 def __str__ (self ) -> str :
507- return ("<%s, pixel_motion =(x=%i, y=%i), tile_motion=(x=%i, y=%i)>" ) % (
572+ return ("<%s, motion =(x=%i, y=%i), tile_motion=(x=%i, y=%i)>" ) % (
508573 super ().__str__ ().strip ("<>" ),
509- * self .pixel_motion ,
574+ * self .motion ,
510575 * self .tile_motion ,
511576 )
512577
@@ -516,7 +581,7 @@ class MouseButtonEvent(MouseState):
516581 Attributes:
517582 type (str): Will be "MOUSEBUTTONDOWN" or "MOUSEBUTTONUP",
518583 depending on the event.
519- pixel (Point): The pixel coordinates of the mouse.
584+ position (Point): The pixel coordinates of the mouse.
520585 tile (Point): The integer tile coordinates of the mouse on the screen.
521586 button (int): Which mouse button.
522587
@@ -527,6 +592,7 @@ class MouseButtonEvent(MouseState):
527592 * tcod.event.BUTTON_RIGHT
528593 * tcod.event.BUTTON_X1
529594 * tcod.event.BUTTON_X2
595+
530596 """
531597
532598 def __init__ (
@@ -559,17 +625,17 @@ def from_sdl_event(cls, sdl_event: Any) -> Any:
559625 return self
560626
561627 def __repr__ (self ) -> str :
562- return "tcod.event.%s(pixel =%r, tile=%r, button=%s)" % (
628+ return "tcod.event.%s(position =%r, tile=%r, button=%s)" % (
563629 self .__class__ .__name__ ,
564- tuple (self .pixel ),
630+ tuple (self .position ),
565631 tuple (self .tile ),
566632 _REVERSE_BUTTON_TABLE_PREFIX [self .button ],
567633 )
568634
569635 def __str__ (self ) -> str :
570- return "<type=%r, pixel =(x=%i, y=%i), tile=(x=%i, y=%i), button=%s)" % (
636+ return "<type=%r, position =(x=%i, y=%i), tile=(x=%i, y=%i), button=%s)" % (
571637 self .type ,
572- * self .pixel ,
638+ * self .position ,
573639 * self .tile ,
574640 _REVERSE_BUTTON_TABLE [self .button ],
575641 )
0 commit comments