Skip to content

Commit

Permalink
initial checkins
Browse files Browse the repository at this point in the history
  • Loading branch information
doctorguile committed Mar 12, 2014
1 parent 9605bc2 commit 2472181
Show file tree
Hide file tree
Showing 36 changed files with 25,020 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
*~

*.py[cod]

# C extensions
Expand Down
8 changes: 8 additions & 0 deletions TODO.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package exe and dmg
check new version available
sh script for linux

extract mp3 from resources?
custom emoticons?
how to set input lag?
cliclient?
16 changes: 16 additions & 0 deletions __init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
cross-platform GGPO GUI Client using PyQt.
It provides a lightweight, simple and consistent ggpo
that will run on all major desktop operating systems.
"""

__author__ = 'papasi'
__copyright__ = 'Copyright (c) 2014'
__license__ = 'GPL'
__credits__ = [
('Tony Cannon (Ponder), Tom Cannon (ProtomCannon)',
'http://ggpo.net'),
('Pau Oliva Fora (@pof)',
'http://poliva.github.io/ggpo/'),
]
1 change: 1 addition & 0 deletions ggpo/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# -*- coding: utf-8 -*-
1 change: 1 addition & 0 deletions ggpo/common/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# -*- coding: utf-8 -*-
133 changes: 133 additions & 0 deletions ggpo/common/cliclient.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
# -*- coding: utf-8 -*-
import sip
# Tell qt to return python string instead of QString
# These are only needed for Python v2 but are harmless for Python v3.
sip.setapi('QString', 2)
sip.setapi('QVariant', 2)
import threading
from playerstate import PlayerStates
from controller import Controller


def chatResponse(name, msg):
print "<" + name + "> " + msg


def bailoutCallback(msg):
def bailout():
print msg
sys.exit()

return bailout


def msgCallback(msg=''):
def printmsg(*args):
if args:
print msg + ' '.join(args)
else:
print msg

return printmsg


def playerStateChange(name, state):
if state == PlayerStates.QUIT:
print '-!- ' + name + " left"
elif state == PlayerStates.AVAILABLE:
print '-!- ' + name + " becomes available"
elif state == PlayerStates.AFK:
print '-!- ' + name + " is away from keyboard"
elif state == PlayerStates.PLAYING:
print '-!- ' + name + " started a game"


def cliclient(argv):
# thread = QtCore.QThread()
g = Controller()

if not g.connectTcp():
sys.exit()
g.connectUdp()

def refreshUsers():
print "-!- Player list"
for p in g.available.keys():
print p
for p in g.awayfromkb.keys():
print p + ' (AFK)'
for p, p2 in g.playing.items():
print p + ' vs ' + p2

def loadRooms():
keys = sorted(g.channels.keys())
for k in keys:
print k + ' - ' + g.channels[k]['title']

def readlineLoop():
commands = {
"/challenge": g.sendChallenge,
"/cancel": g.sendCancelChallenge,
"/accept": g.sendAcceptChallenge,
"/decline": g.sendDeclineChallenge,
"/watch": g.sendSpectateRequest,
"/join": g.sendJoinChannelRequest,
"/list": g.sendListChannels,
"/users": g.sendListUsers,
"/motd": g.sendMOTDRequest,
"/away": lambda: g.sendToggleAFK(1),
"/afk": lambda: g.sendToggleAFK(1),
"/back": lambda: g.sendToggleAFK(0),
"/exit": sys.exit,
"/quit": sys.exit,
}
commandsReqArg = ["challenge", "cancel", "accept", "decline", "watch", "join"]

while True:
line = sys.stdin.readline().strip()
if not line:
continue
words = line.split(None, 1)
cmd = words[0]
if cmd in commands:
cb = commands[cmd]
if cmd[1:] in commandsReqArg:
if len(words) == 2:
cb(words[1])
else:
cb()
else:
if line.startswith('/'):
print "Available commands\n"
print "\n".join(sorted(commands.keys()))
else:
g.sendChat(line)

g.sigServerDisconnected.connect(bailoutCallback('-!- Disconnected from server'))
g.sigLoginSuccess.connect(msgCallback('-!- Logged In'))
g.sigLoginFailed.connect(bailoutCallback('-!- Invalid username / password'))
g.sigActionFailed.connect(msgCallback('-!- Failed - '))
g.sigStatusMessage.connect(msgCallback('-!- '))
g.sigChallengeDeclined.connect(msgCallback('-!- Challege declined by '))
g.sigChallengeCancelled.connect(msgCallback('-!- Challege cancelled by '))
g.sigChallengeReceived.connect(msgCallback('-!- Challege sent by '))
g.sigMotdReceived.connect(msgCallback('-!- Message of the day - '))
g.sigPlayerStateChange.connect(playerStateChange)
g.sigChatReceived.connect(chatResponse)
g.sigPlayersLoaded.connect(refreshUsers)
g.sigChannelsLoaded.connect(loadRooms)

t = threading.Thread(target=g.selectLoop)
t.daemon = True
t.start()

g.sendWelcome()
g.sendAuth(argv[1], argv[2])
readlineLoop()


if __name__ == '__main__':
import sys

print(sys.argv[0])
cliclient(sys.argv)
Loading

0 comments on commit 2472181

Please sign in to comment.