1- ''' Camera Radial Menu - drewcification 091720 '''
1+ """ Camera Radial Menu - drewcification 091720 """
22from direct .directtools .DirectGeometry import *
33from direct .gui .DirectFrame import DirectFrame , OnscreenImage , OnscreenText
44from direct .showbase .DirectObject import DirectObject
@@ -15,19 +15,19 @@ def __init__(self, nodepath: NodePath, desc: str):
1515
1616class RadialMenu (DirectObject ):
1717 def __init__ (self , * items ):
18- '''
18+ """
1919 Initialize using the set of items specified
2020 Set of items should be passed as RadialItems
21- '''
21+ """
2222 DirectObject .__init__ (self )
2323 # Initialize variables
24- self .isActive = 0
25- self .selected = 0
24+ self .isActive : bool = False
25+ self .selected : int = 0
2626
27- self .items = items
27+ self .items : List [ RadialItem ] = items
2828
2929 # Load the palletized gui model
30- gui = loader .loadModel ("resources/camera_gui.bam" )
30+ gui : NodePath = loader .loadModel ("resources/camera_gui.bam" )
3131
3232 # Create the frame
3333 self .frame = DirectFrame (geom = gui .find ("**/radial_menu_bg" ), parent = hidden , scale = 1.3 , relief = None )
@@ -41,7 +41,7 @@ def __init__(self, *items):
4141
4242 # Load all the and calculate their positions
4343 self .itemAngle = 360 / len (items )
44- self .itemImages = []
44+ self .itemImages : List [ OnscreenImage ] = []
4545 for i in range (len (items )):
4646 x = .38 * math .cos (i * deg2Rad (self .itemAngle ))
4747 z = .38 * math .sin (i * deg2Rad (self .itemAngle ))
@@ -50,19 +50,19 @@ def __init__(self, *items):
5050 self .itemImages .append (img )
5151
5252 def activate (self ):
53- ''' Shows the menu and spawns the mouse reader task '''
53+ """ Shows the menu and spawns the mouse reader task """
5454 self .frame .reparentTo (aspect2d )
5555 taskMgr .add (self .radialTask , 'cam-radialTask' )
5656 self .isActive = 1
5757
5858 def deactivate (self ):
59- ''' Hides the menu and kills the mouse reader task '''
59+ """ Hides the menu and kills the mouse reader task """
6060 taskMgr .remove ('cam-radialTask' )
6161 self .frame .reparentTo (hidden )
6262 self .isActive = 0
6363
6464 def destroy (self ):
65- ''' Destroy everything '''
65+ """ Destroy everything """
6666 self .frame .destroy ()
6767 self .selector .destroy ()
6868 for item in self .itemImages :
@@ -74,12 +74,12 @@ def destroy(self):
7474 del self .frame
7575 del self .selector
7676
77- def getChoice (self ):
78- ''' Convenience Function Get the selected item '''
77+ def getChoice (self ) -> int :
78+ """ Convenience Function Get the selected item """
7979 return self .selected
8080
8181 def radialTask (self , task ):
82- ''' Reads the mouse position and calculates which object it is looking at '''
82+ """ Reads the mouse position and calculates which object it is looking at """
8383 # Initialize these as 0 incase we can't read the mouses position
8484 mouseX = 0
8585 mouseY = 0
0 commit comments