#!/usr/bin/env python # Copyright (c) 2002 Sean R. Lynch # # This file is part of PythonVerse. # # PythonVerse is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # PythonVerse is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with PythonVerse; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # -*-Python-*- import os, sys, string, bisect, transutil, asyncore, time from types import * import OpenVerse import pvui_pygame as ui def loop(): """Loop until the ui says we're done.""" while 1: delay = ui.poll() if delay < 0: break elif delay == 0: asyncore.poll() else: now = time.time() when = now + delay while now < when: asyncore.poll(when - now) now = time.time() def main(argv): # FIXME - just for testing, specific to OpenVerse try: nick = argv[1] server = argv[2] port = int(argv[3]) avatar = argv[4] except: print >> sys.stderr, 'Usage: %s ' % argv[0] print >> sys.stderr, 'Uses your existing ~/.OpenVerse directories (for now)' print >> sys.stderr, ' must be a valid avatar definition file in anims' print >> sys.stderr, 'You must have pygame from www.pygame.org installed, with the modules' print >> sys.stderr, 'pygame.image and pygame.font working (depends on SDL, SDL_image, and SDL_ttf)' print >> sys.stderr, 'Escape to quit, alt-f to toggle fullscreen mode.' sys.exit(1) ui.init() client = ui.Client() conn = OpenVerse.ServerConnection(server, port, client, nick, avatar) client.set_server(conn) # Enter the event loop loop() if __name__ == '__main__': main(sys.argv)