Ejemplo n.º 1
0
    def doLogin(self, widget):
        name = self.form.widget_user.text
        pwd = self.form.widget_pass.text

        Events.do('showConsole')

        print "Opening stream socket..."
        tcp = Network.TCPSocket()
        try:
            tcp.connect(Network.serverAddress)
        except:
            print "Could not connect to server."
            print "The server could be down.  Try again later."
            tcp.close()
            return 1

        print "Opening datagram socket..."
        udp = Network.UDPSocket()
        tcp.write('bindUDP %i\n' % udp.getsockname()[1])

        newUser = User.User(tcp, udp)
        newUser.name = name
        newUser.pwd = pwd
        if (widget == self.create):
            newUser.isNewUser = True
        if (self.form.widget_guest.checkState == 1):
            newUser.isGuest = True

        self.destroy()
        return 1
Ejemplo n.º 2
0
    def doLogin(self, widget):
        name = self.form.widget_user.text
        pwd = self.form.widget_pass.text

        Events.do('showConsole')

        print "Opening stream socket..."
        tcp = Network.TCPSocket()
        try:
            tcp.connect(Network.serverAddress)
        except:
            print "Could not connect to server."
            print "The server could be down.  Try again later."
            tcp.close()
            return 1
        
        print "Opening datagram socket..."
        udp = Network.UDPSocket()
        tcp.write('bindUDP %i\n' % udp.getsockname()[1])
        
        newUser = User.User(tcp, udp)
        newUser.name = name
        newUser.pwd = pwd
        if(widget == self.create):
            newUser.isNewUser = True
        if(self.form.widget_guest.checkState == 1):
            newUser.isGuest = True

        self.destroy()
        return 1
Ejemplo n.º 3
0
 def enter(self, widget):
     if (self.command.text != ''):
         s = string.split(self.command.text, maxsplit=1)
         self.command.setText('')
         self.setDirty()
         if (len(s) > 1):
             Events.do('command-' + s[0], s[1])
         else:
             Events.do('command-' + s[0])
Ejemplo n.º 4
0
 def enter(self, widget):
     if self.command.text != "":
         s = string.split(self.command.text, maxsplit=1)
         self.command.setText("")
         self.setDirty()
         if len(s) > 1:
             Events.do("command-" + s[0], s[1])
         else:
             Events.do("command-" + s[0])
Ejemplo n.º 5
0
	def handleInputUDP(self):
		packet = self.udp.read()
		if(not packet):
			return
		line = string.split(packet, maxsplit = 1)
		command = 'net ' + line[0]
		if(len(line) > 1):
			Events.do(command, self, line[1])
		else:
			Events.do(command, self)
Ejemplo n.º 6
0
 def handleInputUDP(self):
     packet = self.udp.read()
     if (not packet):
         return
     line = string.split(packet, maxsplit=1)
     command = 'net ' + line[0]
     if (len(line) > 1):
         Events.do(command, self, line[1])
     else:
         Events.do(command, self)
Ejemplo n.º 7
0
 def handleInputTCP(self):
     line = self.tcp.readline()
     if (not line):
         return
     line = line[:-1]
     line = string.split(line, maxsplit=1)
     command = 'net ' + line[0]
     if (len(line) > 1):
         Events.do(command, self, line[1])
     else:
         Events.do(command, self)
Ejemplo n.º 8
0
	def handleInputTCP(self):
		line = self.tcp.readline()
		if(not line):
			return
		line = line[:-1]
		line = string.split(line, maxsplit = 1)
		command = 'net ' + line[0]
		if(len(line) > 1):
			Events.do(command, self, line[1])
		else:
			Events.do(command, self)
Ejemplo n.º 9
0
    def __init__(self):
        Window.__init__(self, 0, 0, getDesktop().width, \
                        getDesktop().height/4, topmost = 1)
        self.setLayout(pyui.layouts.BorderLayoutManager())
        self.outputBox = LineDisplay()
        self.addChild(self.outputBox, pyui.locals.CENTER)
        self.pack()

	Events.addCallbacks('keyDown', self.keyDown)
	
        self.oldout = sys.stdout
        sys.stdout = self
Ejemplo n.º 10
0
    def __init__(self):
        Window.__init__(self, 0, 0, getDesktop().width, \
                        getDesktop().height/4, topmost = 1)
        self.setLayout(pyui.layouts.BorderLayoutManager())
        self.outputBox = LineDisplay()
        self.addChild(self.outputBox, pyui.locals.CENTER)
        self.pack()

        Events.addCallbacks('keyDown', self.keyDown)

        self.oldout = sys.stdout
        sys.stdout = self
Ejemplo n.º 11
0
def run():
    global root, window, system, input, events, done
    cm = ogre.ControllerManager()
    while (not done):
        input.capture()
        if (input.isKeyDown(ogre.KC_ESCAPE)):
            Events.do('quit')
        '''evt = events.pop()
		while(evt):
			print evt.mId
			evt = events.pop()
		if(input.mouseRelativeX or input.mouseRelativeY):
			cegui.System.getSingleton().injectMouseMove( \
				input.mouseRelativeX * window.width, \
				input.mouseRelativeY * window.height)'''
        root.renderOneFrame()
Ejemplo n.º 12
0
def run():
	global root, window, system, input, events, done
	cm = ogre.ControllerManager()
	while(not done):
		input.capture()
		if(input.isKeyDown(ogre.KC_ESCAPE)):
			Events.do('quit')
		'''evt = events.pop()
		while(evt):
			print evt.mId
			evt = events.pop()
		if(input.mouseRelativeX or input.mouseRelativeY):
			cegui.System.getSingleton().injectMouseMove( \
				input.mouseRelativeX * window.width, \
				input.mouseRelativeY * window.height)'''
		root.renderOneFrame()
Ejemplo n.º 13
0
def login(user, command = ''):
    if(command == 'user'):
        print "Sending username..."
        if(user.isGuest):
            user.tcp.write('login guest ' + user.name + '\n')
        elif(user.isNewUser):
            user.tcp.write('login newuser ' + user.name + '\n')
        else:
            user.tcp.write('login user ' + user.name + '\n')
    elif(command == 'pass'):
        print "Sending password..."
        user.tcp.write('login pass ' + user.pwd + '\n')
    elif(command == 'ok'):
        print "Login successful!"
        Core.user = user
        Events.do('hideConsole')
        Events.do('start')
    elif(command == 'badpass'):
        print "Login incorrect.  Bad user/password info."
        user.closeAll()
        init()
    elif(command == 'taken'):
        print "That username is taken.  Please choose another."
        user.closeAll()
        init()
    elif(command == 'duplicate'):
        print "That user is already logged in.  If you were disconnected allow a few minutes for your user name to reset."
        user.closeAll()
        init()
    elif(command[:6] == 'bindUDP'):
        print "Binding game datagram socket..."
        user.udp.connect((Network.serverAddress[0], int(command[8:])))
        user.tcp.write('login bindUDP ' + user.udp.getsockname()[1])
    else:
        print "An unknown error occured."
        init()
        user.closeAll()
Ejemplo n.º 14
0
def login(user, command=''):
    if (command == 'user'):
        print "Sending username..."
        if (user.isGuest):
            user.tcp.write('login guest ' + user.name + '\n')
        elif (user.isNewUser):
            user.tcp.write('login newuser ' + user.name + '\n')
        else:
            user.tcp.write('login user ' + user.name + '\n')
    elif (command == 'pass'):
        print "Sending password..."
        user.tcp.write('login pass ' + user.pwd + '\n')
    elif (command == 'ok'):
        print "Login successful!"
        Core.user = user
        Events.do('hideConsole')
        Events.do('start')
    elif (command == 'badpass'):
        print "Login incorrect.  Bad user/password info."
        user.closeAll()
        init()
    elif (command == 'taken'):
        print "That username is taken.  Please choose another."
        user.closeAll()
        init()
    elif (command == 'duplicate'):
        print "That user is already logged in.  If you were disconnected allow a few minutes for your user name to reset."
        user.closeAll()
        init()
    elif (command[:6] == 'bindUDP'):
        print "Binding game datagram socket..."
        user.udp.connect((Network.serverAddress[0], int(command[8:])))
        user.tcp.write('login bindUDP ' + user.udp.getsockname()[1])
    else:
        print "An unknown error occured."
        init()
        user.closeAll()
Ejemplo n.º 15
0
#Copyright (C) 2004-2005 Randall Leeds
#
#This file is part of The Street.
#
#The Street 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.
#
#The Street 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 The Street; if not, write to the Free Software
#Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301

#Sets up events for the Scripts module.

from StreetModules import Scripts, Events

Events.addCallbacks('runscript', Scripts.run)
Events.addCallbacks('command-run', Scripts.run)

Scripts.install('StreetScripts')
Ejemplo n.º 16
0
#Copyright (C) 2004-2005 Randall Leeds
#
#This file is part of The Street.
#
#The Street 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.
#
#The Street 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 The Street; if not, write to the Free Software
#Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301

#Initialize core event callbacks at startup time.

from StreetModules import Events
from StreetModules.Client import Core

Events.addCallbacks('init', Core.init)
Events.addCallbacks('run', Core.run)
Events.addCallbacks('quit', Core.quit)
Events.addCallbacks('command-quit', Core.quit)
Events.addCallbacks('cleanup', Core.cleanup)
Ejemplo n.º 17
0
#Copyright (C) 2004-2005 Randall Leeds
#
#This file is part of The Street.
#
#The Street 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.
#
#The Street 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 The Street; if not, write to the Free Software
#Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301

#Set up the chat callbacks

from StreetModules import Events
from StreetModules.Server import Chat

Events.addCallbacks('net tell', Chat.tell)
Ejemplo n.º 18
0
#Copyright (C) 2004-2005 Randall Leeds
#
#This file is part of The Street.
#
#The Street 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.
#
#The Street 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 The Street; if not, write to the Free Software
#Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301

#Initializes one quake-like console window.
from StreetModules import Events
from StreetModules.Client import Console

Events.addCallbacks('init_END', Console.init)
Events.addCallbacks('showConsole', Console.showConsole)
Events.addCallbacks('hideConsole', Console.hideConsole)
Events.addCallbacks('run_END', Console.close)
Ejemplo n.º 19
0
def keyDown(event):
	Events.do('keyDown', event)
	if(event.key == 27):
		Events.do('quit')
		return 1
	return 0
Ejemplo n.º 20
0
def keyUp(evt):
	cegui.System.getSingleton().injectKeyUp(evt.key)
	Events.do('keyUp', evt.key)
Ejemplo n.º 21
0
#Copyright (C) 2004-2005 Randall Leeds
#
#This file is part of The Street.
#
#The Street 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.
#
#The Street 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 The Street; if not, write to the Free Software
#Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301

#Initialize core event callbacks at startup time.

from StreetModules import Events
from StreetModules.Client import Core

Events.addCallbacks('init', Core.init)
Events.addCallbacks('run', Core.run)
Events.addCallbacks('quit', Core.quit)
Events.addCallbacks('command-quit', Core.quit)

Ejemplo n.º 22
0
def keyUp(evt):
    cegui.System.getSingleton().injectKeyUp(evt.key)
    Events.do('keyUp', evt.key)
Ejemplo n.º 23
0
def mouseMoved(evt):
	global window
	x = evt.relX * window.width
	y = evt.relY * window.height
	cegui.System.getSingleton().injectMouseMove(x, y)
	Events.do('mouseMove', x, y)
Ejemplo n.º 24
0
def render():
	getRenderer().clear()
	Events.do('render')
	drawFPS()
Ejemplo n.º 25
0
# Copyright (C) 2004-2005 Randall Leeds
#
# This file is part of The Street.
#
# The Street 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.
#
# The Street 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 The Street; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301

# Initialize core event callbacks at startup time.

from StreetModules import Events
from StreetModules.Client import Core

Events.addCallbacks("init", Core.init)
Events.addCallbacks("run", Core.run)
Events.addCallbacks("quit", Core.quit)
Events.addCallbacks("command-quit", Core.quit)
Ejemplo n.º 26
0
#Copyright (C) 2004-2005 Randall Leeds
#
#This file is part of The Street.
#
#The Street 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.
#
#The Street 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 The Street; if not, write to the Free Software
#Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301

#Provides a small command bar at the bottom of the screen

from StreetModules import Events
from StreetModules.Client import CommandLine

Events.addCallbacks('start', CommandLine.init)
Ejemplo n.º 27
0
#Copyright (C) 2004-2005 Randall Leeds
#
#This file is part of The Street.
#
#The Street 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.
#
#The Street 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 The Street; if not, write to the Free Software
#Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301

#Sets up the Core module.

from StreetModules import Events
from StreetModules.Server import Core

Events.addCallbacks('init', Core.init)
Events.addCallbacks('run', Core.run)
Events.addCallbacks('quit', Core.quit)
Ejemplo n.º 28
0
def keyDown(evt):
	cegui.System.getSingleton().injectKeyDown(evt.key)
	cegui.System.getSingleton().injectChar(evt.keyChar)
	Events.do('keyDown', evt.key)
	print 'Generated keyDown event with key:' + evt.key
Ejemplo n.º 29
0
	
	def write(self, text):
		self.oldout.write(text)
		self.logFile.write(text)
		self.logFile.flush()
		
	def __del__(self):
		self.logFile.close()

print 'Starting up The Street client...'

print 'Setting up client output logging...'
clientLogger = Logger()

print 'Executing startup scripts...'
startScripts = glob.glob('StreetScripts/Startup/*.py')
startScripts += glob.glob('StreetScripts/Client/Startup/*.py')
startScripts += glob.glob('StreetScripts/Client/User/Startup/*.py')
for script in startScripts:
	print '\t%s' % script
	execfile(script)

print 'Initializing the client...'
Events.do('init')
print 'The Street is up and running.'
Events.do('run')
print "Shutting down the client..."
print "Running shutdown events..."
Events.do('cleanup')
print "Client offline."
Ejemplo n.º 30
0
#Copyright (C) 2004-2005 Randall Leeds
#
#This file is part of The Street.
#
#The Street 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.
#
#The Street 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 The Street; if not, write to the Free Software
#Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301

#Set up the chat callbacks

from StreetModules import Events
from StreetModules.Client import Chat

Events.addCallbacks('net tell', Chat.recvTell)
Events.addCallbacks('command-tell', Chat.sendTell)
Ejemplo n.º 31
0
#Copyright (C) 2004-2005 Randall Leeds
#
#This file is part of The Street.
#
#The Street 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.
#
#The Street 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 The Street; if not, write to the Free Software
#Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301

#Initializes the User module
from StreetModules import Events, User

Events.addCallbacks('net bindUDP', User.bindUDP)
Ejemplo n.º 32
0
#Copyright (C) 2004-2005 Randall Leeds
#
#This file is part of The Street.
#
#The Street 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.
#
#The Street 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 The Street; if not, write to the Free Software
#Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301

#Sets up the callbacks for the Login module.

from StreetModules import Events
from StreetModules.Client import LoginClient

Events.addCallbacks('init_END', LoginClient.init)

Events.addCallbacks('net login', LoginClient.login)
Events.addCallbacks('net logout', LoginClient.logout)
Ejemplo n.º 33
0
def render():
    getRenderer().clear()
    Events.do('render')
    drawFPS()
Ejemplo n.º 34
0
 def closeAll(self):
     Events.do('net logout', self)
     Network.TCPSocket.close(self.tcp)
     Network.UDPSocket.close(self.udp)
Ejemplo n.º 35
0
def keyDown(evt):
    cegui.System.getSingleton().injectKeyDown(evt.key)
    cegui.System.getSingleton().injectChar(evt.keyChar)
    Events.do('keyDown', evt.key)
    print 'Generated keyDown event with key:' + evt.key
Ejemplo n.º 36
0
        self.logFile = file('clientlog.txt', 'w')
    
    def write(self, text):
        self.oldout.write(text)
        self.logFile.write(text)
	self.logFile.flush()
        
    def __del__(self):
        self.logFile.close()

print 'Starting up The Street client...'

print 'Setting up client output logging...'
clientLogger = Logger()

print 'Executing startup scripts...'
startScripts = glob.glob('StreetScripts/Startup/*.py')
startScripts += glob.glob('StreetScripts/Client/Startup/*.py')
startScripts += glob.glob('StreetScripts/Client/User/Startup/*.py')
for script in startScripts:
    print '\t%s' % script
    execfile(script)

print 'Initializing the client...'
Events.do('init')
print 'The Street client is up and running.'
Events.do('run')
print "Shutting down the client..."
print "Running shutdown events..."
Events.do('quit')
print "Client offline."
Ejemplo n.º 37
0
def mouseMoved(evt):
    global window
    x = evt.relX * window.width
    y = evt.relY * window.height
    cegui.System.getSingleton().injectMouseMove(x, y)
    Events.do('mouseMove', x, y)
Ejemplo n.º 38
0
def keyDown(event):
    Events.do("keyDown", event)
    if event.key == 27:
        Events.do("quit")
        return 1
    return 0
Ejemplo n.º 39
0
def keyDown(event):
    Events.do('keyDown', event)
    if (event.key == 27):
        Events.do('quit')
        return 1
    return 0
Ejemplo n.º 40
0
	def closeAll(self):
		Events.do('net logout', self)
		Network.TCPSocket.close(self.tcp)
		Network.UDPSocket.close(self.udp)
Ejemplo n.º 41
0
#along with The Street; if not, write to the Free Software
#Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301

import glob
import signal
import sys

from StreetModules import Events
from StreetModules.Server import Core

def quit(signum, frame):
	Core.running = False

signal.signal(signal.SIGINT, quit)

print "Running startup scripts..."
startScripts = glob.glob('StreetScripts/Startup/*.py')
startScripts += glob.glob('StreetScripts/Server/Startup/*.py')
for script in startScripts:
	print script
	execfile(script)

print "Running initialization events..."
Events.do('init')
print "Server is up and running!"
Events.do('run')
print "Server shutting down..."
print "Running shutdown events..."
Events.do('quit')
print "Server is offline."
Ejemplo n.º 42
0
def render():
    getRenderer().clear()
    Events.do("render")
    drawFPS()