コード例 #1
0
ファイル: widgets.py プロジェクト: svk/harmless7drl
 def __init__(self, width, okay = string.printable, query = None, acceptEmpty = False, centered = False, *args, **kwargs):
     Widget.__init__(self, *args, **kwargs)
     self.width = width
     self.okay = list( okay )
     self.data = []
     self.query = query
     self.centered = centered
     self.height = 4
     self.resize()
コード例 #2
0
ファイル: gamewidget.py プロジェクト: svk/harmless7drl
 def __init__(self, *args, **kwargs):
     Widget.__init__( self, *args, **kwargs )
     name = self.main.query( TextInputWidget, 32, okay = string.letters, query = "Please enter your name: ", centered = True )
     self.context = GameContext()
     self.context.game = self
     self.initialized = False
     try:
         from harmless7drl import loadOldGame
         context = loadOldGame( name )
         wasLoaded = True
     except IOError:
         from harmless7drl import beginNewGame
         gender = self.main.query( SelectionMenuWidget, choices = [
             ('female', "Female"),
             ('male', "Male"),
         ], padding = 5, centered = True, title = "Please select your gender:", noInvert = True )
         context = beginNewGame( self.context, name, gender )
         wasLoaded = False
         from plot import displayIntro
         self.context = context
         displayIntro( self )
     self.context = context
     self.initialized = True
     self.name = None
     self.player = context.player
     context.game = self
     self.context = context
     self.cursor = None
     self.movementKeys = {
         'h': (-1, 0),
         'l': (1, 0),
         'j': (0, 1),
         'k': (0, -1),
         'y': (-1, -1),
         'u': (1, -1),
         'b': (-1, 1),
         'n': (1, 1),
         'west': (-1, 0),
         'east': (1, 0),
         'south': (0, 1),
         'north': (0, -1),
         'northwest': (-1, -1),
         'northeast': (1, -1),
         'southwest': (-1, 1),
         'southeast': (1, 1),
     }
     self.textfieldheight = 4
     screenw, screenh = self.ui.dimensions()
     self.turnlogWrapper = TextWrapper( screenw, self.textfieldheight )
     self.turnlogLines = []
     self.restrictVisionByFov = True
     self.visualEffects = {}
     self.proposedPath = None
     self.startled = False
     if wasLoaded:
         self.log( "Welcome back!" )
コード例 #3
0
ファイル: widgets.py プロジェクト: svk/harmless7drl
 def __init__(self, choices = [], title = None, centered = False, noInvert = False, padding = 0, cancelable = False, *args, **kwargs):
     Widget.__init__(self, *args, **kwargs)
     self.title = title
     self.cancelable = cancelable
     self.choices = choices # symbol, description
     self.selection = 0
     self.noInvert = noInvert
     self.width = max( map( lambda syde : len(syde[1]) + 2 + 2, self.choices ) )
     self.centered = centered
     self.xoffset = 2 if not self.centered else 1
     if self.title:
         self.yoffset = 2
         self.width = max( len(self.title), self.width )
     else:
         self.yoffset = 1
     self.width += self.xoffset + 1
     self.width += padding
     self.height = len( self.choices ) + 1 + self.yoffset
     self.resize()
コード例 #4
0
ファイル: widgets.py プロジェクト: svk/harmless7drl
 def __init__(self, dt = 0.1, *args, **kwargs):
     Widget.__init__(self, *args, **kwargs)
     self.t = time.time() + dt
コード例 #5
0
ファイル: widgets.py プロジェクト: svk/harmless7drl
 def __init__(self, *args, **kwargs):
     Widget.__init__(self, *args, **kwargs)
コード例 #6
0
ファイル: widgets.py プロジェクト: svk/harmless7drl
 def __init__(self, game, *args, **kwargs):
     Widget.__init__(self, *args, **kwargs)
     self.game = game
     self.game.cursor = self.game.player.tile.x, self.game.player.tile.y
     self.visibility = game.playerVisibility( game.player.fov() )
     self.description = ""
コード例 #7
0
ファイル: widgets.py プロジェクト: svk/harmless7drl
 def __init__(self, acceptZ = False, *args, **kwargs):
     Widget.__init__(self, *args, **kwargs)
     self.movementKeys = MovementKeys
     self.acceptZ = acceptZ