示例#1
0
 def inputDone(self):
   if self.text == "save":
     try:
       self.lvlarea.lvl.save()
       tinygui.popup("level saved as '%s'" % self.lvlarea.lvl.levelname)
     except Exception, e:
       tinygui.popup("exception caught while saving: %s" % str(e))
示例#2
0
 def inputDone(self):
   """Tries to load the tileset. If it fails, it displays an error"""
   try:
     self.tsa.lvlarea.lvl.tileset = level.Tileset(self.text)
     tinygui.popup("tileset %s loaded" % (self.text))
   except (IOError, pygame.error):
     tinygui.popup("tileset %s does not exist" % (self.text))
示例#3
0
 def inputDone(self):
   """Tries to load the Level. If it fails, a dummy level is created."""
   try:
     self.lvlarea.updateLevel(level.load(self.text, None))
     tinygui.popup("level %s loaded" % (self.text))
   except IOError:
     self.lvlarea.updateLevel(level.load(None, None))
     self.lvlarea.lvl.levelname = self.text
     tinygui.popup("new level %s" % (self.text))
示例#4
0
  def inputDone(self):
    if self.text == "save":
      try:
        self.lvlarea.lvl.save()
        tinygui.popup("level saved as '%s'" % self.lvlarea.lvl.levelname)
      except Exception, e:
        tinygui.popup("exception caught while saving: %s" % str(e))

    elif self.text == "info":
      tinygui.popup("level is %s * %s big." % (self.lvlarea.lvl.w, self.lvlarea.lvl.h))

    elif self.text[:4] == "w = ":
      try:
        w = int(self.text[4:])
      except:
        tinygui.popup("error in input.")
        return
      if w <= 0:
        tinygui.popup("invalid value.")
      elif w == self.lvlarea.lvl.w:
        tinygui.popup("level width unchanged.")
      elif w < self.lvlarea.lvl.w:
        for row in self.lvlarea.lvl.level:
          del row[w:]
      elif w > self.lvlarea.lvl.w:
        for row in self.lvlarea.lvl.level:
          row.extend([0] * (w - self.lvlarea.lvl.w))

      self.lvlarea.lvl.w = w
      self.lvlarea.updateLevel()