From af4bcd07f40bf2e0e1c1eebdc8b0b04e5d92677b Mon Sep 17 00:00:00 2001 From: Craig Date: Fri, 23 Apr 2010 02:07:28 +0000 Subject: make Tool subclasses call Tool.__init__ and remove redundant __init__ related code from Tool subclasses --- (limited to 'tools.py') diff --git a/tools.py b/tools.py index eb345c9..f18131a 100644 --- a/tools.py +++ b/tools.py @@ -38,7 +38,7 @@ class Tool(object): def __init__(self,gameInstance): self.game = gameInstance - self.name = 'Tool' + self.name = self.__class__.name def handleEvents(self,event): handled = True @@ -92,8 +92,7 @@ class CircleTool(Tool): toolAccelerator = _("c") def __init__(self,gameInstance): - self.game = gameInstance - self.name = 'Circle' + Tool.__init__(self,gameInstance) self.pt1 = None self.radius = 40 @@ -132,8 +131,7 @@ class BoxTool(Tool): toolAccelerator = _("b") def __init__(self,gameInstance): - self.game = gameInstance - self.name = 'Box' + Tool.__init__(self,gameInstance) self.pt1 = None self.rect = None self.width = 80 @@ -177,8 +175,7 @@ class TriangleTool(Tool): toolAccelerator = _("t") def __init__(self,gameInstance): - self.game = gameInstance - self.name = 'Triangle' + Tool.__init__(self,gameInstance) self.pt1 = None self.vertices = None self.line_delta = [0, -80] @@ -221,8 +218,7 @@ class PolygonTool(Tool): toolAccelerator = _("p") def __init__(self,gameInstance): - self.game = gameInstance - self.name = 'Polygon' + Tool.__init__(self,gameInstance) self.vertices = None self.previous_vertices = None @@ -276,8 +272,7 @@ class MagicPenTool(Tool): toolAccelerator = _("d") def __init__(self,gameInstance): - self.game = gameInstance - self.name = 'Magicpen' + Tool.__init__(self,gameInstance) self.vertices = None self.previous_vertices = None @@ -321,10 +316,6 @@ class GrabTool(Tool): icon = 'grab' toolTip = _("Grab") toolAccelerator = _("g") - - def __init__(self,gameInstance): - self.game = gameInstance - self.name = 'Grab' def handleToolEvent(self,event): if event.type == MOUSEBUTTONDOWN: @@ -353,8 +344,7 @@ class JointTool(Tool): toolAccelerator = "j" def __init__(self,gameInstance): - self.game = gameInstance - self.name = 'Joint' + Tool.__init__(self,gameInstance) self.jb1 = self.jb2 = self.jb1pos = self.jb2pos = None def handleToolEvent(self,event): @@ -395,8 +385,7 @@ class PinTool(Tool): toolAccelerator = _("o") def __init__(self,gameInstance): - self.game = gameInstance - self.name = 'Pin' + Tool.__init__(self,gameInstance) self.jb1 = self.jb1pos = None def handleToolEvent(self,event): @@ -419,8 +408,7 @@ class MotorTool(Tool): toolAccelerator = _("m") def __init__(self,gameInstance): - self.game = gameInstance - self.name = 'Motor' + Tool.__init__(self,gameInstance) self.jb1 = self.jb1pos = None def handleToolEvent(self,event): @@ -444,8 +432,7 @@ class RollTool(Tool): toolAccelerator = _("r") def __init__(self,gameInstance): - self.game = gameInstance - self.name = 'Roll' + Tool.__init__(self,gameInstance) self.jb1 = self.jb1pos = None def handleToolEvent(self,event): @@ -472,8 +459,7 @@ class DestroyTool(Tool): toolAccelerator = _("e") def __init__(self,gameInstance): - self.game = gameInstance - self.name = 'Destroy' + Tool.__init__(self,gameInstance) self.vertices = None def handleToolEvent(self,event): -- cgit v0.9.1