예제 #1
0
 def __init__(self):
     super(GameMenu, self).__init__("Game menu")
     self.append_item(ClickableItem(self, "Create a new game", self.create_game))
     self.append_item(ClickableItem(self, "Join a game", self.join_game))
     self.append_item(ClickableItem(self, "Observe a game", self.observe_game))
     self.append_item(ClickableItem(self, "Disconnect from server", self.do_disconnect))
     del self.hotkeys[(key.ESCAPE, 0)]
     system.speak(self.title)
예제 #2
0
 def __init__(self):
     super(ConnectMenu, self).__init__("Connect to a server")
     self.hostname = TextboxItem(self, "Hostname", value="code-metropolis.com")
     self.port = TextboxItem(self, "Port", value=str(application.port))
     self.name = TextboxItem(self, "Screen Name", value=os.getlogin().title())
     for i in [self.hostname, self.port, self.name]:
         self.append_item(i)
     self.append_item(ClickableItem(self, "Connect", self.do_connect))
     system.speak(self.title)
예제 #3
0
 def do_connect(self, control):
     host, port, name = self.hostname.value, self.port.value, self.name.value
     try:
         port = int(port)
     except ValueError:
         system.speak("Invalid port number: %s." % port)
     else:
         if host and port and name:
             # Don't accept any input for the time being...
             application.window.clear_handlers()
             system.speak("Connecting...")
             connector = reactor.connectTCP(host, port, Factory(name))
             logging.info("Connecting to %s as %s.", connector.getDestination(), name)
         else:
             system.speak("All fields are required.")
     return True
예제 #4
0
 def observe_game(self, control):
     system.speak("Observe a game.")
예제 #5
0
 def join_game(self, control):
     system.speak("Join a game.")
예제 #6
0
 def create_game(self, control):
     system.speak("Create a game.")
예제 #7
0
 def __init__(self):
     super(MainMenu, self).__init__("Game Menu")
     del self.hotkeys[(key.ESCAPE, 0)]
     self.append_item(ClickableItem(self, "Connect To Server", self.do_connect))
     self.append_item(ClickableItem(self, "Quit the game", lambda control: pyglet.app.exit()))
     system.speak(self.title)
예제 #8
0
def announce(message = 'No message', error = False):
 if error:
  system.speak('Error: %s' % message)
 else:
  system.speak(message)
예제 #9
0
 def do_fire(self):
  """Fire the weapons."""
  system.speak('Fired.')
예제 #10
0
 def clientConnectionLost(self, connector, reason):
  system.speak('Connection lost: %s' % reason.getErrorMessage())
  self.recover()
예제 #11
0
 def clientConnectionFailed(self, connector, reason):
  system.speak('Connection failed: %s' % reason.getErrorMessage())
  self.recover()