예제 #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
예제 #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
예제 #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])
예제 #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])
예제 #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)
예제 #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)
예제 #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)
예제 #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)
예제 #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
예제 #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
예제 #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()
예제 #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()
예제 #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()
예제 #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()
예제 #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')
예제 #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)
예제 #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)
예제 #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)
예제 #19
0
def keyDown(event):
	Events.do('keyDown', event)
	if(event.key == 27):
		Events.do('quit')
		return 1
	return 0
예제 #20
0
def keyUp(evt):
	cegui.System.getSingleton().injectKeyUp(evt.key)
	Events.do('keyUp', evt.key)
예제 #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)

예제 #22
0
def keyUp(evt):
    cegui.System.getSingleton().injectKeyUp(evt.key)
    Events.do('keyUp', evt.key)
예제 #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)
예제 #24
0
def render():
	getRenderer().clear()
	Events.do('render')
	drawFPS()
예제 #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)
예제 #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)
예제 #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)
예제 #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
예제 #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."
예제 #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)
예제 #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)
예제 #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)
예제 #33
0
def render():
    getRenderer().clear()
    Events.do('render')
    drawFPS()
예제 #34
0
 def closeAll(self):
     Events.do('net logout', self)
     Network.TCPSocket.close(self.tcp)
     Network.UDPSocket.close(self.udp)
예제 #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
예제 #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."
예제 #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)
예제 #38
0
def keyDown(event):
    Events.do("keyDown", event)
    if event.key == 27:
        Events.do("quit")
        return 1
    return 0
예제 #39
0
def keyDown(event):
    Events.do('keyDown', event)
    if (event.key == 27):
        Events.do('quit')
        return 1
    return 0
예제 #40
0
	def closeAll(self):
		Events.do('net logout', self)
		Network.TCPSocket.close(self.tcp)
		Network.UDPSocket.close(self.udp)
예제 #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."
예제 #42
0
def render():
    getRenderer().clear()
    Events.do("render")
    drawFPS()