pythonverse

Python-based client for OpenVerse with extra features
git clone https://code.literati.org/pythonverse.git
Log | Files | Refs | README | LICENSE

PythonVerse (2303B)


      1 #!/usr/bin/env python
      2 # Copyright (c) 2002 Sean R. Lynch <seanl@chaosring.org>
      3 #
      4 # This file is part of PythonVerse.
      5 #
      6 # PythonVerse is free software; you can redistribute it and/or modify
      7 # it under the terms of the GNU General Public License as published by
      8 # the Free Software Foundation; either version 2 of the License, or
      9 # (at your option) any later version.
     10 # 
     11 # PythonVerse is distributed in the hope that it will be useful,
     12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
     13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     14 # GNU General Public License for more details.
     15 # 
     16 # You should have received a copy of the GNU General Public License
     17 # along with PythonVerse; if not, write to the Free Software
     18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
     19 #
     20 # -*-Python-*-
     21 
     22 
     23 import os, sys, string, bisect, transutil, asyncore, time
     24 from types import *
     25 import OpenVerse
     26 import pvui_pygame as ui
     27 
     28 
     29 def loop():
     30     """Loop until the ui says we're done."""
     31     while 1:
     32         delay = ui.poll()
     33         if delay < 0: break
     34         elif delay == 0: asyncore.poll()
     35         else:
     36             now = time.time()
     37             when = now + delay
     38             while now < when:
     39                 asyncore.poll(when - now)
     40                 now = time.time()
     41         
     42 
     43 def main(argv):
     44     # FIXME - just for testing, specific to OpenVerse
     45     try:
     46         nick = argv[1]
     47         server = argv[2]
     48         port = int(argv[3])
     49         avatar = argv[4]
     50     except:
     51         print >> sys.stderr, 'Usage: %s <nick> <server> <port> <avatar>' % argv[0]
     52         print >> sys.stderr, 'Uses your existing ~/.OpenVerse directories (for now)'
     53         print >> sys.stderr, '<avatar> must be a valid avatar definition file in anims'
     54         print >> sys.stderr, 'You must have pygame from www.pygame.org installed, with the modules'
     55         print >> sys.stderr, 'pygame.image and pygame.font working (depends on SDL, SDL_image, and SDL_ttf)'
     56         print >> sys.stderr, 'Escape to quit, alt-f to toggle fullscreen mode.'
     57         sys.exit(1)
     58         
     59     ui.init()
     60     client = ui.Client()
     61     conn = OpenVerse.ServerConnection(server, port, client, nick, avatar)
     62     client.set_server(conn)
     63     # Enter the event loop
     64     loop()
     65 
     66 if __name__ == '__main__': main(sys.argv)