@@ -384,7 +384,7 @@ class MouseState(Event):
384
384
"""
385
385
Attributes:
386
386
type (str): Always "MOUSESTATE".
387
- pixel (Point): The pixel coordinates of the mouse.
387
+ position (Point): The position coordinates of the mouse.
388
388
tile (Point): The integer tile coordinates of the mouse on the screen.
389
389
state (int): A bitmask of which mouse buttons are currently held.
390
390
@@ -397,39 +397,70 @@ class MouseState(Event):
397
397
* tcod.event.BUTTON_X2MASK
398
398
399
399
.. versionadded:: 9.3
400
+
401
+ .. versionchanged:: Unreleased
402
+ Renamed `pixel` attribute to `position`.
400
403
"""
401
404
402
405
def __init__ (
403
406
self ,
404
- pixel : Tuple [int , int ] = (0 , 0 ),
407
+ position : Tuple [int , int ] = (0 , 0 ),
405
408
tile : Optional [Tuple [int , int ]] = (0 , 0 ),
406
409
state : int = 0 ,
407
410
):
408
411
super ().__init__ ()
409
- self .pixel = Point (* pixel )
412
+ self .position = Point (* position )
410
413
self .__tile = Point (* tile ) if tile is not None else None
411
414
self .state = state
412
415
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
+
413
434
@property
414
435
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
+ )
415
441
return _verify_tile_coordinates (self .__tile )
416
442
417
443
@tile .setter
418
444
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
+ )
419
450
self .__tile = Point (* xy )
420
451
421
452
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)" ) % (
423
454
self .__class__ .__name__ ,
424
- tuple (self .pixel ),
455
+ tuple (self .position ),
425
456
tuple (self .tile ),
426
457
_describe_bitmask (self .state , _REVERSE_BUTTON_MASK_TABLE_PREFIX ),
427
458
)
428
459
429
460
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>" ) % (
431
462
super ().__str__ ().strip ("<>" ),
432
- * self .pixel ,
463
+ * self .position ,
433
464
* self .tile ,
434
465
_describe_bitmask (self .state , _REVERSE_BUTTON_MASK_TABLE ),
435
466
)
@@ -439,8 +470,8 @@ class MouseMotion(MouseState):
439
470
"""
440
471
Attributes:
441
472
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.
444
475
tile (Point): The integer tile coordinates of the mouse on the screen.
445
476
tile_motion (Point): The integer tile delta.
446
477
state (int): A bitmask of which mouse buttons are currently held.
@@ -452,26 +483,60 @@ class MouseMotion(MouseState):
452
483
* tcod.event.BUTTON_RMASK
453
484
* tcod.event.BUTTON_X1MASK
454
485
* tcod.event.BUTTON_X2MASK
486
+
487
+ .. versionchanged:: Unreleased
488
+ Renamed `pixel` attribute to `position`.
489
+ Renamed `pixel_motion` attribute to `motion`.
455
490
"""
456
491
457
492
def __init__ (
458
493
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 ),
461
496
tile : Optional [Tuple [int , int ]] = (0 , 0 ),
462
497
tile_motion : Optional [Tuple [int , int ]] = (0 , 0 ),
463
498
state : int = 0 ,
464
499
):
465
- super ().__init__ (pixel , tile , state )
466
- self .pixel_motion = Point (* pixel_motion )
500
+ super ().__init__ (position , tile , state )
501
+ self .motion = Point (* motion )
467
502
self .__tile_motion = Point (* tile_motion ) if tile_motion is not None else None
468
503
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
+
469
522
@property
470
523
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
+ )
471
530
return _verify_tile_coordinates (self .__tile_motion )
472
531
473
532
@tile_motion .setter
474
533
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
+ )
475
540
self .__tile_motion = Point (* xy )
476
541
477
542
@classmethod
@@ -494,19 +559,19 @@ def from_sdl_event(cls, sdl_event: Any) -> MouseMotion:
494
559
return self
495
560
496
561
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)" ) % (
498
563
self .__class__ .__name__ ,
499
- tuple (self .pixel ),
500
- tuple (self .pixel_motion ),
564
+ tuple (self .position ),
565
+ tuple (self .motion ),
501
566
tuple (self .tile ),
502
567
tuple (self .tile_motion ),
503
568
_describe_bitmask (self .state , _REVERSE_BUTTON_MASK_TABLE_PREFIX ),
504
569
)
505
570
506
571
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)>" ) % (
508
573
super ().__str__ ().strip ("<>" ),
509
- * self .pixel_motion ,
574
+ * self .motion ,
510
575
* self .tile_motion ,
511
576
)
512
577
@@ -516,7 +581,7 @@ class MouseButtonEvent(MouseState):
516
581
Attributes:
517
582
type (str): Will be "MOUSEBUTTONDOWN" or "MOUSEBUTTONUP",
518
583
depending on the event.
519
- pixel (Point): The pixel coordinates of the mouse.
584
+ position (Point): The pixel coordinates of the mouse.
520
585
tile (Point): The integer tile coordinates of the mouse on the screen.
521
586
button (int): Which mouse button.
522
587
@@ -527,6 +592,7 @@ class MouseButtonEvent(MouseState):
527
592
* tcod.event.BUTTON_RIGHT
528
593
* tcod.event.BUTTON_X1
529
594
* tcod.event.BUTTON_X2
595
+
530
596
"""
531
597
532
598
def __init__ (
@@ -559,17 +625,17 @@ def from_sdl_event(cls, sdl_event: Any) -> Any:
559
625
return self
560
626
561
627
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)" % (
563
629
self .__class__ .__name__ ,
564
- tuple (self .pixel ),
630
+ tuple (self .position ),
565
631
tuple (self .tile ),
566
632
_REVERSE_BUTTON_TABLE_PREFIX [self .button ],
567
633
)
568
634
569
635
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)" % (
571
637
self .type ,
572
- * self .pixel ,
638
+ * self .position ,
573
639
* self .tile ,
574
640
_REVERSE_BUTTON_TABLE [self .button ],
575
641
)
0 commit comments