Moving GUI out of the TCP thread
This commit is contained in:
parent
8024b3e806
commit
e323bf47dc
@ -1,4 +1,4 @@
|
|||||||
# AO2XP 2.9.3
|
# AO2XP 2.9.5
|
||||||
|
|
||||||
This is an alternative Attorney Online 2 client, developed in **Python 2.7**,
|
This is an alternative Attorney Online 2 client, developed in **Python 2.7**,
|
||||||
specifically made for older computers running Windows XP that cannot run the
|
specifically made for older computers running Windows XP that cannot run the
|
||||||
|
|||||||
7
demo.py
7
demo.py
@ -5,15 +5,18 @@ from bisect import bisect_left
|
|||||||
|
|
||||||
class DemoPlayer(QtCore.QObject):
|
class DemoPlayer(QtCore.QObject):
|
||||||
MS_Chat = QtCore.pyqtSignal(list)
|
MS_Chat = QtCore.pyqtSignal(list)
|
||||||
newChar = QtCore.pyqtSignal(str)
|
newChar = QtCore.pyqtSignal(int)
|
||||||
newBackground = QtCore.pyqtSignal(str, bool)
|
newBackground = QtCore.pyqtSignal(str, bool)
|
||||||
IC_Log = QtCore.pyqtSignal(str)
|
IC_Log = QtCore.pyqtSignal(str)
|
||||||
OOC_Log = QtCore.pyqtSignal(str)
|
OOC_Log = QtCore.pyqtSignal(str)
|
||||||
charSlots = QtCore.pyqtSignal()
|
charSlots = QtCore.pyqtSignal(list)
|
||||||
loadAllEvidence = QtCore.pyqtSignal(list)
|
loadAllEvidence = QtCore.pyqtSignal(list)
|
||||||
rainbowColor = QtCore.pyqtSignal(str)
|
rainbowColor = QtCore.pyqtSignal(str)
|
||||||
updatePlayerList = QtCore.pyqtSignal(str, int, int, str)
|
updatePlayerList = QtCore.pyqtSignal(str, int, int, str)
|
||||||
timerUpdate = QtCore.pyqtSignal(int, int, int)
|
timerUpdate = QtCore.pyqtSignal(int, int, int)
|
||||||
|
authStatusChanged = QtCore.pyqtSignal(int)
|
||||||
|
updateAreaList = QtCore.pyqtSignal(list)
|
||||||
|
setCharList = QtCore.pyqtSignal(list)
|
||||||
|
|
||||||
def __init__(self, parent):
|
def __init__(self, parent):
|
||||||
super(DemoPlayer, self).__init__(parent)
|
super(DemoPlayer, self).__init__(parent)
|
||||||
|
|||||||
375
gameview.py
375
gameview.py
@ -1,28 +1,22 @@
|
|||||||
import thread, time, os, urllib, random, re, platform, subprocess
|
# This is the main file where everything happens. Honestly, it sucks and the
|
||||||
import charselect, ini, AOsocket, images, packets, demo, buttons
|
# thing is so complex and unsafe that I'm surprised it even works. I wish for
|
||||||
|
# a simpler client. ~ cidoku
|
||||||
|
|
||||||
|
import thread, time, os, urllib, random, platform, subprocess
|
||||||
from os.path import exists, basename
|
from os.path import exists, basename
|
||||||
from ConfigParserEdit import ConfigParser
|
|
||||||
from constants import *
|
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
from pybass_constants import *
|
|
||||||
from PyQt4 import QtGui, QtCore
|
|
||||||
from functools import partial
|
from functools import partial
|
||||||
from ctypes import create_string_buffer
|
from ctypes import create_string_buffer
|
||||||
from urllib2 import Request, urlopen
|
from urllib2 import Request, urlopen
|
||||||
|
from PyQt4 import QtGui, QtCore
|
||||||
|
from ConfigParserEdit import ConfigParser
|
||||||
|
from constants import *
|
||||||
|
from pybass_constants import BASS_ATTRIB_VOL, BASS_ACTIVE_PAUSED, BASS_STREAM_AUTOFREE, BASS_SAMPLE_LOOP
|
||||||
|
import charselect, ini, images, packets, demo, buttons, audio
|
||||||
|
|
||||||
DOWNLOAD_BLACKLIST = []
|
DOWNLOAD_BLACKLIST = []
|
||||||
|
|
||||||
URL_REGEX = r"https?://(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_+.~#?&/=]*)"
|
|
||||||
|
|
||||||
bucket = ""
|
bucket = ""
|
||||||
|
|
||||||
def delay(msec):
|
|
||||||
dieTime = QtCore.QTime.currentTime().addMSecs(msec)
|
|
||||||
|
|
||||||
while QtCore.QTime.currentTime() < dieTime:
|
|
||||||
QtCore.QCoreApplication.processEvents(QtCore.QEventLoop.AllEvents, 100)
|
|
||||||
|
|
||||||
def getCharIni(char, section, value, default=""):
|
def getCharIni(char, section, value, default=""):
|
||||||
tempini = ConfigParser()
|
tempini = ConfigParser()
|
||||||
return ini.read_ini(BASE_PATH + 'characters/' + char.lower() + '/char.ini', section, value, default)
|
return ini.read_ini(BASE_PATH + 'characters/' + char.lower() + '/char.ini', section, value, default)
|
||||||
@ -242,7 +236,6 @@ class ChatLogs(QtGui.QTextEdit):
|
|||||||
|
|
||||||
class AOCharMovie(QtGui.QLabel):
|
class AOCharMovie(QtGui.QLabel):
|
||||||
done = QtCore.pyqtSignal()
|
done = QtCore.pyqtSignal()
|
||||||
usePillow = 0
|
|
||||||
pillowFrames = []
|
pillowFrames = []
|
||||||
pillowFrame = 0
|
pillowFrame = 0
|
||||||
pillowSpeed = 0
|
pillowSpeed = 0
|
||||||
@ -298,6 +291,21 @@ class AOCharMovie(QtGui.QLabel):
|
|||||||
else:
|
else:
|
||||||
self.setAlignment(QtCore.Qt.AlignCenter)
|
self.setAlignment(QtCore.Qt.AlignCenter)
|
||||||
|
|
||||||
|
def findSprite(self, char, emote, prefix):
|
||||||
|
bases = [
|
||||||
|
"{char}/{prefix}{emote}",
|
||||||
|
"{char}/{emote}",
|
||||||
|
"{char}/{prefix}/{emote}"
|
||||||
|
]
|
||||||
|
exts = [".apng", ".png", ".gif", ".webp"]
|
||||||
|
|
||||||
|
for base in bases:
|
||||||
|
for ext in exts:
|
||||||
|
path = BASE_PATH + "characters/" + base.format(char=char, prefix=prefix, emote=emote) + ext
|
||||||
|
if exists(path):
|
||||||
|
return path, ext
|
||||||
|
return None
|
||||||
|
|
||||||
def play(self, pChar, pEmote, emotePrefix, scaling = SCALING_AUTO, singleFrameDuration = -1):
|
def play(self, pChar, pEmote, emotePrefix, scaling = SCALING_AUTO, singleFrameDuration = -1):
|
||||||
if not len(pEmote):
|
if not len(pEmote):
|
||||||
return
|
return
|
||||||
@ -319,106 +327,36 @@ class AOCharMovie(QtGui.QLabel):
|
|||||||
pChar = pChar.lower()
|
pChar = pChar.lower()
|
||||||
pEmote = pEmote.lower()
|
pEmote = pEmote.lower()
|
||||||
|
|
||||||
apngPath = testPath(
|
|
||||||
BASE_PATH + "characters/" + pChar + "/" + emotePrefix + pEmote + ".apng",
|
|
||||||
BASE_PATH + "characters/" + pChar + "/" + emotePrefix + "/" + pEmote + ".apng",
|
|
||||||
BASE_PATH + "characters/" + pChar + "/" + pEmote + ".apng",
|
|
||||||
BASE_PATH + "characters/" + pChar + "/(a)" + pEmote + ".apng",
|
|
||||||
BASE_PATH + "characters/" + pChar + "/(b)" + pEmote + ".apng",
|
|
||||||
BASE_PATH + "characters/" + pChar + "/(a)/" + pEmote + ".apng",
|
|
||||||
BASE_PATH + "characters/" + pChar + "/(b)/" + pEmote + ".apng"
|
|
||||||
)
|
|
||||||
|
|
||||||
placeholderPath = AO2XPpath + "themes/default/oldplaceholder.gif"
|
placeholderPath = AO2XPpath + "themes/default/oldplaceholder.gif"
|
||||||
imgPath = ""
|
imgPath, ext = self.findSprite(pChar, pEmote, emotePrefix)
|
||||||
|
|
||||||
if apngPath:
|
if not imgPath:
|
||||||
imgPath = apngPath
|
if self.prevGifPath:
|
||||||
self.usePillow = 1
|
imgPath = self.prevGifPath
|
||||||
else:
|
else:
|
||||||
pngPath = testPath(
|
|
||||||
BASE_PATH + "characters/" + pChar + "/" + emotePrefix + pEmote + ".png",
|
|
||||||
BASE_PATH + "characters/" + pChar + "/" + emotePrefix + "/" + pEmote + ".png",
|
|
||||||
BASE_PATH + "characters/" + pChar + "/" + pEmote + ".png",
|
|
||||||
BASE_PATH + "characters/" + pChar + "/(a)" + pEmote + ".png",
|
|
||||||
BASE_PATH + "characters/" + pChar + "/(b)" + pEmote + ".png",
|
|
||||||
BASE_PATH + "characters/" + pChar + "/(a)/" + pEmote + ".png",
|
|
||||||
BASE_PATH + "characters/" + pChar + "/(b)/" + pEmote + ".png"
|
|
||||||
)
|
|
||||||
|
|
||||||
if pngPath:
|
|
||||||
imgPath = pngPath
|
|
||||||
self.usePillow = 0
|
|
||||||
else:
|
|
||||||
webpPath = testPath(
|
|
||||||
BASE_PATH + "characters/" + pChar + "/" + emotePrefix + pEmote + ".webp",
|
|
||||||
BASE_PATH + "characters/" + pChar + "/" + emotePrefix + "/" + pEmote + ".webp",
|
|
||||||
BASE_PATH + "characters/" + pChar + "/" + pEmote + ".webp",
|
|
||||||
BASE_PATH + "characters/" + pChar + "/(a)" + pEmote + ".webp",
|
|
||||||
BASE_PATH + "characters/" + pChar + "/(b)" + pEmote + ".webp",
|
|
||||||
BASE_PATH + "characters/" + pChar + "/(a)/" + pEmote + ".webp",
|
|
||||||
BASE_PATH + "characters/" + pChar + "/(b)/" + pEmote + ".webp"
|
|
||||||
)
|
|
||||||
|
|
||||||
if webpPath:
|
|
||||||
imgPath = webpPath
|
|
||||||
self.usePillow = 2
|
|
||||||
else:
|
|
||||||
gifPath = testPath(
|
|
||||||
BASE_PATH + "characters/" + pChar + "/" + emotePrefix + pEmote + ".gif",
|
|
||||||
BASE_PATH + "characters/" + pChar + "/" + emotePrefix + "/" + pEmote + ".gif",
|
|
||||||
BASE_PATH + "characters/" + pChar + "/" + pEmote + ".gif",
|
|
||||||
BASE_PATH + "characters/" + pChar + "/(a)" + pEmote + ".gif",
|
|
||||||
BASE_PATH + "characters/" + pChar + "/(b)" + pEmote + ".gif",
|
|
||||||
BASE_PATH + "characters/" + pChar + "/(a)/" + pEmote + ".gif",
|
|
||||||
BASE_PATH + "characters/" + pChar + "/(b)/" + pEmote + ".gif"
|
|
||||||
)
|
|
||||||
|
|
||||||
if gifPath:
|
|
||||||
imgPath = gifPath
|
|
||||||
self.usePillow = 0
|
|
||||||
else:
|
|
||||||
if ini.read_ini_bool("AO2XP.ini", "General", "download characters"):
|
|
||||||
pass
|
|
||||||
# url = "base/characters/" + pChar.lower() + "/" + emotePrefix + pEmote.lower() + ".gif"
|
|
||||||
# url = url.replace(" ", "%20")
|
|
||||||
# thread.start_new_thread(downloadThread, (url, gifPath))
|
|
||||||
|
|
||||||
if exists(placeholderPath):
|
if exists(placeholderPath):
|
||||||
imgPath = placeholderPath
|
imgPath = placeholderPath
|
||||||
print "[debug] Sprite not found:", pChar, pEmote, emotePrefix
|
print "[debug] Sprite not found:", pChar, pEmote, emotePrefix
|
||||||
else:
|
|
||||||
imgPath = ""
|
|
||||||
self.usePillow = 0
|
|
||||||
|
|
||||||
if imgPath == "":
|
|
||||||
imgPath = self.prevGifPath
|
|
||||||
# Second check just in case
|
|
||||||
if imgPath == "":
|
|
||||||
if exists(placeholderPath):
|
|
||||||
imgPath = placeholderPath
|
|
||||||
print "[debug] Sprite not found: ", pChar, pEmote, emotePrefix
|
|
||||||
else:
|
else:
|
||||||
imgPath = "placeholder.png"
|
imgPath = "placeholder.png"
|
||||||
|
# if ini.read_ini_bool("AO2XP.ini", "General", "download characters"):
|
||||||
|
# url = "base/characters/" + pChar.lower() + "/" + emotePrefix + pEmote.lower() + ".gif"
|
||||||
|
# url = url.replace(" ", "%20")
|
||||||
|
# thread.start_new_thread(downloadThread, (url, gifPath))
|
||||||
else:
|
else:
|
||||||
self.prevGifPath = imgPath
|
self.prevGifPath = imgPath
|
||||||
|
|
||||||
#print "[debug]", pChar, emotePrefix, pEmote, "(!) path is null!" if imgPath == "" else imgPath
|
if ext == ".apng":
|
||||||
|
self.pillowFrames = images.load_apng(imgPath)
|
||||||
if not self.usePillow:
|
|
||||||
self.mMovie.setFileName(imgPath)
|
|
||||||
self.mMovie.start()
|
|
||||||
elif self.usePillow == 1: # apng
|
|
||||||
self.pillowFrames = images.load_apng(apngPath)
|
|
||||||
if len(self.pillowFrames) > 1:
|
if len(self.pillowFrames) > 1:
|
||||||
self.pillowTimer.start(int(self.pillowFrames[0][1] * self.pillowSpeed))
|
self.pillowTimer.start(int(self.pillowFrames[0][1] * self.pillowSpeed))
|
||||||
else:
|
else:
|
||||||
self.pillowTimer.start(int(singleFrameDuration * self.pillowSpeed))
|
self.pillowTimer.start(int(singleFrameDuration * self.pillowSpeed))
|
||||||
|
|
||||||
self.setPillowFrame()
|
self.setPillowFrame()
|
||||||
elif self.usePillow == 2: # webp
|
elif ext == ".webp":
|
||||||
try:
|
try:
|
||||||
self.pillowFrames = images.load_webp(webpPath)
|
self.pillowFrames = images.load_webp(imgPath)
|
||||||
if len(self.pillowFrames) > 1:
|
if len(self.pillowFrames) > 1:
|
||||||
self.pillowTimer.start(int(self.pillowFrames[0][1] * self.pillowSpeed))
|
self.pillowTimer.start(int(self.pillowFrames[0][1] * self.pillowSpeed))
|
||||||
else:
|
else:
|
||||||
@ -433,6 +371,9 @@ class AOCharMovie(QtGui.QLabel):
|
|||||||
imgPath = "placeholder.png"
|
imgPath = "placeholder.png"
|
||||||
self.mMovie.setFileName(imgPath)
|
self.mMovie.setFileName(imgPath)
|
||||||
self.mMovie.start()
|
self.mMovie.start()
|
||||||
|
else:
|
||||||
|
self.mMovie.setFileName(imgPath)
|
||||||
|
self.mMovie.start()
|
||||||
|
|
||||||
if self.showOnPlay:
|
if self.showOnPlay:
|
||||||
self.show()
|
self.show()
|
||||||
@ -669,12 +610,17 @@ class AOMovie(QtGui.QLabel):
|
|||||||
self.pillowLabel.hide()
|
self.pillowLabel.hide()
|
||||||
self.hide()
|
self.hide()
|
||||||
|
|
||||||
|
def finish(self):
|
||||||
|
self.stop()
|
||||||
|
self.done.emit()
|
||||||
|
|
||||||
@QtCore.pyqtSlot(int)
|
@QtCore.pyqtSlot(int)
|
||||||
def frameChange(self, nFrame):
|
def frameChange(self, nFrame):
|
||||||
if nFrame == self.mMovie.frameCount() - 1 and self.playOnce:
|
if nFrame == self.mMovie.frameCount() - 1 and self.playOnce:
|
||||||
delay(self.mMovie.nextFrameDelay())
|
QtCore.QTimer.singleShot(
|
||||||
self.stop()
|
self.mMovie.nextFrameDelay(),
|
||||||
self.done.emit()
|
self.finish
|
||||||
|
)
|
||||||
|
|
||||||
@QtCore.pyqtSlot()
|
@QtCore.pyqtSlot()
|
||||||
def pillowFrameChange(self):
|
def pillowFrameChange(self):
|
||||||
@ -682,7 +628,7 @@ class AOMovie(QtGui.QLabel):
|
|||||||
|
|
||||||
if len(self.pillowFrames) - 1 == self.pillowFrame:
|
if len(self.pillowFrames) - 1 == self.pillowFrame:
|
||||||
if self.playOnce or (self.usePillow == 2 and self.pillowLoops+1 == self.webpLoops):
|
if self.playOnce or (self.usePillow == 2 and self.pillowLoops+1 == self.webpLoops):
|
||||||
delay(int(self.pillowFrames[self.pillowFrame][1] * self.pillowSpeed))
|
self.msleep(int(self.pillowFrames[self.pillowFrame][1] * self.pillowSpeed))
|
||||||
self.stop()
|
self.stop()
|
||||||
self.done.emit()
|
self.done.emit()
|
||||||
elif len(self.pillowFrames) > 1: # loop
|
elif len(self.pillowFrames) > 1: # loop
|
||||||
@ -746,7 +692,7 @@ class WTCEView(QtGui.QLabel):
|
|||||||
super(WTCEView, self).move(self.parent.viewport.x(), self.parent.viewport.y())
|
super(WTCEView, self).move(self.parent.viewport.x(), self.parent.viewport.y())
|
||||||
super(WTCEView, self).resize(self.parent.viewport.size())
|
super(WTCEView, self).resize(self.parent.viewport.size())
|
||||||
|
|
||||||
def frameChange(self, frame):
|
def frameChange(self):
|
||||||
if self.movie.state() != QtGui.QMovie.Running:
|
if self.movie.state() != QtGui.QMovie.Running:
|
||||||
return
|
return
|
||||||
img = self.movie.currentImage()
|
img = self.movie.currentImage()
|
||||||
@ -763,17 +709,30 @@ class WTCEView(QtGui.QLabel):
|
|||||||
|
|
||||||
def showWTCE(self, wtce, variant=0):
|
def showWTCE(self, wtce, variant=0):
|
||||||
self.finished()
|
self.finished()
|
||||||
|
|
||||||
|
wtcefile = BASE_PATH + "sounds/general/sfx-testimony2"
|
||||||
|
if self.parent.wtceSfx:
|
||||||
|
audio.freeHandle(self.parent.wtceSfx)
|
||||||
|
|
||||||
if wtce == 'testimony1':
|
if wtce == 'testimony1':
|
||||||
self.movie.setFileName(AO2XPpath + 'themes/default/witnesstestimony.gif')
|
self.movie.setFileName(AO2XPpath + 'themes/default/witnesstestimony.gif')
|
||||||
elif wtce == 'testimony2':
|
elif wtce == 'testimony2':
|
||||||
self.movie.setFileName(AO2XPpath + 'themes/default/crossexamination.gif')
|
self.movie.setFileName(AO2XPpath + 'themes/default/crossexamination.gif')
|
||||||
elif wtce == "judgeruling":
|
elif wtce == "judgeruling":
|
||||||
if variant == 0:
|
if variant == 0:
|
||||||
|
wtcefile = BASE_PATH + "sounds/general/sfx-notguilty"
|
||||||
self.movie.setFileName(AO2XPpath + 'themes/default/notguilty.gif')
|
self.movie.setFileName(AO2XPpath + 'themes/default/notguilty.gif')
|
||||||
elif variant == 1:
|
elif variant == 1:
|
||||||
|
wtcefile = BASE_PATH + "sounds/general/sfx-guilty"
|
||||||
self.movie.setFileName(AO2XPpath + 'themes/default/guilty.gif')
|
self.movie.setFileName(AO2XPpath + 'themes/default/guilty.gif')
|
||||||
else:
|
else:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
self.parent.wtceSfx = audio.loadHandle(False, wtcefile+".opus" if exists(wtcefile+".opus") else wtcefile+".wav", 0, 0, 0)
|
||||||
|
audio.setHandleAttr(self.parent.wtceSfx, BASS_ATTRIB_VOL, self.parent.sliSoundVolume.value() / 100.0)
|
||||||
|
|
||||||
|
if self.parent.wtceSfx:
|
||||||
|
audio.playHandle(self.parent.wtceSfx, True)
|
||||||
self.show()
|
self.show()
|
||||||
self.movie.start()
|
self.movie.start()
|
||||||
|
|
||||||
@ -888,7 +847,7 @@ class EditEvidenceDialog(QtGui.QDialog):
|
|||||||
def onBrowseClicked(self):
|
def onBrowseClicked(self):
|
||||||
path = str(QtGui.QFileDialog.getOpenFileName(self, "Select an image", BASE_PATH + 'evidence', "Images (*.png)"))
|
path = str(QtGui.QFileDialog.getOpenFileName(self, "Select an image", BASE_PATH + 'evidence', "Images (*.png)"))
|
||||||
if path:
|
if path:
|
||||||
if not "/evidence/" in path.lower():
|
if "/evidence/" not in path.lower():
|
||||||
QtGui.QMessageBox.warning(self, 'Wrong directory', 'Please select a file from the "evidence" directory.')
|
QtGui.QMessageBox.warning(self, 'Wrong directory', 'Please select a file from the "evidence" directory.')
|
||||||
self.onBrowseClicked()
|
self.onBrowseClicked()
|
||||||
return
|
return
|
||||||
@ -921,16 +880,19 @@ class EditEvidenceDialog(QtGui.QDialog):
|
|||||||
class TCPThread(QtCore.QThread):
|
class TCPThread(QtCore.QThread):
|
||||||
connectionError = QtCore.pyqtSignal(str, str, str)
|
connectionError = QtCore.pyqtSignal(str, str, str)
|
||||||
MS_Chat = QtCore.pyqtSignal(list)
|
MS_Chat = QtCore.pyqtSignal(list)
|
||||||
newChar = QtCore.pyqtSignal(str)
|
newChar = QtCore.pyqtSignal(int)
|
||||||
newBackground = QtCore.pyqtSignal(str, bool)
|
newBackground = QtCore.pyqtSignal(str, bool)
|
||||||
IC_Log = QtCore.pyqtSignal(str)
|
IC_Log = QtCore.pyqtSignal(str)
|
||||||
OOC_Log = QtCore.pyqtSignal(str)
|
OOC_Log = QtCore.pyqtSignal(str)
|
||||||
charSlots = QtCore.pyqtSignal()
|
charSlots = QtCore.pyqtSignal(list)
|
||||||
showCharSelect = QtCore.pyqtSignal()
|
showCharSelect = QtCore.pyqtSignal()
|
||||||
loadAllEvidence = QtCore.pyqtSignal(list)
|
loadAllEvidence = QtCore.pyqtSignal(list)
|
||||||
rainbowColor = QtCore.pyqtSignal(str)
|
rainbowColor = QtCore.pyqtSignal(str)
|
||||||
updatePlayerList = QtCore.pyqtSignal(str, int, int, str)
|
updatePlayerList = QtCore.pyqtSignal(str, int, int, str)
|
||||||
timerUpdate = QtCore.pyqtSignal(int, int, int)
|
timerUpdate = QtCore.pyqtSignal(int, int, int)
|
||||||
|
authStatusChanged = QtCore.pyqtSignal(int)
|
||||||
|
updateAreaList = QtCore.pyqtSignal(list)
|
||||||
|
setCharList = QtCore.pyqtSignal(list)
|
||||||
|
|
||||||
send_attempts = 0
|
send_attempts = 0
|
||||||
max_attempts = 5
|
max_attempts = 5
|
||||||
@ -944,7 +906,6 @@ class TCPThread(QtCore.QThread):
|
|||||||
pingtimer = 150
|
pingtimer = 150
|
||||||
rainbow = 0
|
rainbow = 0
|
||||||
sendtick = 0
|
sendtick = 0
|
||||||
tempdata = ""
|
|
||||||
color = QtGui.QColor()
|
color = QtGui.QColor()
|
||||||
color.setHsv(rainbow, 255, 255)
|
color.setHsv(rainbow, 255, 255)
|
||||||
while True:
|
while True:
|
||||||
@ -961,7 +922,7 @@ class TCPThread(QtCore.QThread):
|
|||||||
pingtimer -= 1
|
pingtimer -= 1
|
||||||
|
|
||||||
if pingtimer == 0:
|
if pingtimer == 0:
|
||||||
pingbefore = time.time()
|
# pingbefore = time.time()
|
||||||
self.parent.tcp.send('CH#%')
|
self.parent.tcp.send('CH#%')
|
||||||
pingtimer = 150
|
pingtimer = 150
|
||||||
|
|
||||||
@ -1027,8 +988,7 @@ class Chatbox(QtGui.QLabel):
|
|||||||
|
|
||||||
class GUI(QtGui.QWidget):
|
class GUI(QtGui.QWidget):
|
||||||
mainWindow = None
|
mainWindow = None
|
||||||
# In theory 3 sounds may play at the same time: character, evidence sweep,
|
# In theory 3 sounds may play at the same time: character, evidence sweep, effect
|
||||||
# effect
|
|
||||||
soundChannels = 3
|
soundChannels = 3
|
||||||
soundChannel = 0
|
soundChannel = 0
|
||||||
sound = []
|
sound = []
|
||||||
@ -2124,7 +2084,7 @@ class GUI(QtGui.QWidget):
|
|||||||
|
|
||||||
def _themeCommon(self):
|
def _themeCommon(self):
|
||||||
# IC input and demo slider
|
# IC input and demo slider
|
||||||
viewportRight = max(self.viewport.x() + self.viewport.width(), 512)
|
# viewportRight = max(self.viewport.x() + self.viewport.width(), 512)
|
||||||
|
|
||||||
# IC options
|
# IC options
|
||||||
gameTabsHeight = self.gameTabs.height() - self.gameTabs.findChild(QtGui.QTabBar).height()
|
gameTabsHeight = self.gameTabs.height() - self.gameTabs.findChild(QtGui.QTabBar).height()
|
||||||
@ -2572,8 +2532,11 @@ class GUI(QtGui.QWidget):
|
|||||||
self.tcp.send("RT#judgeruling#" +str(variant)+ "#%")
|
self.tcp.send("RT#judgeruling#" +str(variant)+ "#%")
|
||||||
self.ICChatFocus()
|
self.ICChatFocus()
|
||||||
|
|
||||||
def onPVPacket(self, charName=""):
|
def onPVPacket(self, char=0):
|
||||||
QtGui.QApplication.restoreOverrideCursor()
|
QtGui.QApplication.restoreOverrideCursor()
|
||||||
|
self.myChar = char
|
||||||
|
self.charSelect.hide()
|
||||||
|
charName = self.charList[char][0]
|
||||||
self.setDisabled(False)
|
self.setDisabled(False)
|
||||||
self.gotPV = True
|
self.gotPV = True
|
||||||
if not self.swapping and charName:
|
if not self.swapping and charName:
|
||||||
@ -3045,6 +3008,7 @@ class GUI(QtGui.QWidget):
|
|||||||
self.speaker.wait()
|
self.speaker.wait()
|
||||||
|
|
||||||
def disconnectCommon(self):
|
def disconnectCommon(self):
|
||||||
|
QtGui.QApplication.restoreOverrideCursor()
|
||||||
self.gotPV = False
|
self.gotPV = False
|
||||||
self.charName = ""
|
self.charName = ""
|
||||||
self.onSwitchInventory(True)
|
self.onSwitchInventory(True)
|
||||||
@ -3089,40 +3053,27 @@ class GUI(QtGui.QWidget):
|
|||||||
|
|
||||||
def onOOCReturn(self):
|
def onOOCReturn(self):
|
||||||
text = encodeAOString(self.OOCInput.text()).replace('\\n', '\n')
|
text = encodeAOString(self.OOCInput.text()).replace('\\n', '\n')
|
||||||
if text.startsWith('//'):
|
if text.startsWith("/pos "): # why.......
|
||||||
code = str(self.OOCInput.text()).replace('//', '', 1).replace('\\NEWLINE', '\n')
|
|
||||||
try:
|
|
||||||
exec code
|
|
||||||
except Exception as e:
|
|
||||||
msg = 'code error\n'
|
|
||||||
for arg in e.args:
|
|
||||||
msg += str(arg) + '\n'
|
|
||||||
|
|
||||||
msg = msg.rstrip()
|
|
||||||
self.OOCLog.append(msg)
|
|
||||||
return
|
|
||||||
return
|
|
||||||
elif text.startsWith("/pos "): # why.......
|
|
||||||
ind = self.boxPositions.findText(str(text.split(" ")[1]))
|
ind = self.boxPositions.findText(str(text.split(" ")[1]))
|
||||||
if ind >= 0: self.boxPositions.setCurrentIndex(ind)
|
if ind >= 0: self.boxPositions.setCurrentIndex(ind)
|
||||||
self.OOCInput.clear()
|
self.OOCInput.clear()
|
||||||
return
|
return
|
||||||
|
|
||||||
if self.cbMockText.isChecked():
|
# if self.cbMockText.isChecked():
|
||||||
text = mockString(text)
|
# text = mockString(text)
|
||||||
if self.cbAutoCaps.isChecked():
|
# if self.cbAutoCaps.isChecked():
|
||||||
l = QtCore.QStringList(list(text))
|
# l = QtCore.QStringList(list(text))
|
||||||
l[0] = l[0].toUpper()
|
# l[0] = l[0].toUpper()
|
||||||
|
|
||||||
last = [".", "?", "!", ")", "]"]
|
# last = [".", "?", "!", ")", "]"]
|
||||||
if not l[-1] in last:
|
# if not l[-1] in last:
|
||||||
l.append(".")
|
# l.append(".")
|
||||||
text = l.join("").replace(" i ", " I ").replace("i'm", "I'm").replace("it's", "It's")
|
# text = l.join("").replace(" i ", " I ").replace("i'm", "I'm").replace("it's", "It's")
|
||||||
if self.cbSpacing.isChecked():
|
# if self.cbSpacing.isChecked():
|
||||||
l = QtCore.QStringList(list(text))
|
# l = QtCore.QStringList(list(text))
|
||||||
for i in range(1, len(l)+len(l)-1, 2):
|
# for i in range(1, len(l)+len(l)-1, 2):
|
||||||
l.insert(i, " ")
|
# l.insert(i, " ")
|
||||||
text = l.join("")
|
# text = l.join("")
|
||||||
|
|
||||||
self.sendOOCchat(self.OOCNameInput.text().toUtf8(), text)
|
self.sendOOCchat(self.OOCNameInput.text().toUtf8(), text)
|
||||||
self.OOCInput.clear()
|
self.OOCInput.clear()
|
||||||
@ -4608,38 +4559,10 @@ class GUI(QtGui.QWidget):
|
|||||||
if self.onscreenTimerTimes == [0, 0, 0, 0, 0]:
|
if self.onscreenTimerTimes == [0, 0, 0, 0, 0]:
|
||||||
self.onscreenTimer.stop()
|
self.onscreenTimer.stop()
|
||||||
|
|
||||||
def onDemoClicked(self, item):
|
def setCharSlots(self, data):
|
||||||
fname = demo.getDemoFilename(self.demoItems, item)
|
for i, value in enumerate(data):
|
||||||
|
self.charList[i][1] = int(value)
|
||||||
if not fname:
|
self.charSelect.setCharList(self.charList)
|
||||||
return
|
|
||||||
|
|
||||||
self.playerItems.clear()
|
|
||||||
self.stopMusic()
|
|
||||||
self.ICLog.clear()
|
|
||||||
self.OOCLog.clear()
|
|
||||||
|
|
||||||
if not self.demoPlaying:
|
|
||||||
self.enableWidgets(True)
|
|
||||||
self.tcpThread.stop()
|
|
||||||
self.demoPlaying = True
|
|
||||||
|
|
||||||
self.demoPlayer = demo.DemoPlayer(self)
|
|
||||||
self.demoPlayer.MS_Chat.connect(self.netmsgMS)
|
|
||||||
self.demoPlayer.newChar.connect(self.onPVPacket)
|
|
||||||
self.demoPlayer.newBackground.connect(self.setBackground)
|
|
||||||
self.demoPlayer.OOC_Log.connect(self.OOCLog.append)
|
|
||||||
self.demoPlayer.IC_Log.connect(self.ICLog.append)
|
|
||||||
self.demoPlayer.charSlots.connect(partial(self.charSelect.setCharList, self.charList))
|
|
||||||
self.demoPlayer.loadAllEvidence.connect(self.loadAllEvidence)
|
|
||||||
self.demoPlayer.updatePlayerList.connect(self.updatePlayerList)
|
|
||||||
self.demoPlayer.rainbowColor.connect(self.text.setStyleSheet)
|
|
||||||
self.demoPlayer.timerUpdate.connect(self.startPauseOnscreenTimers)
|
|
||||||
|
|
||||||
self.demoPlayer.start(fname)
|
|
||||||
|
|
||||||
def demoSeek(self, time):
|
|
||||||
self.demoPlayer.seek(time)
|
|
||||||
|
|
||||||
def startGame(self, tcp, playerList, charList, musicList, background, evidence, areas, features=[], joinOOC=[], hpList=[], webAO_bucket=""):
|
def startGame(self, tcp, playerList, charList, musicList, background, evidence, areas, features=[], joinOOC=[], hpList=[], webAO_bucket=""):
|
||||||
self.willDisconnect = False
|
self.willDisconnect = False
|
||||||
@ -4786,12 +4709,14 @@ class GUI(QtGui.QWidget):
|
|||||||
self.tcpThread.newBackground.connect(self.setBackground)
|
self.tcpThread.newBackground.connect(self.setBackground)
|
||||||
self.tcpThread.OOC_Log.connect(self.OOCLog.append)
|
self.tcpThread.OOC_Log.connect(self.OOCLog.append)
|
||||||
self.tcpThread.IC_Log.connect(self.ICLog.append)
|
self.tcpThread.IC_Log.connect(self.ICLog.append)
|
||||||
self.tcpThread.charSlots.connect(partial(self.charSelect.setCharList, self.charList))
|
self.tcpThread.charSlots.connect(self.setCharSlots)
|
||||||
self.tcpThread.showCharSelect.connect(self.charSelect.showCharSelect)
|
self.tcpThread.showCharSelect.connect(self.charSelect.showCharSelect)
|
||||||
self.tcpThread.loadAllEvidence.connect(self.loadAllEvidence)
|
self.tcpThread.loadAllEvidence.connect(self.loadAllEvidence)
|
||||||
self.tcpThread.updatePlayerList.connect(self.updatePlayerList)
|
self.tcpThread.updatePlayerList.connect(self.updatePlayerList)
|
||||||
|
self.tcpThread.authStatusChanged.connect(self.authStatusChanged)
|
||||||
self.tcpThread.rainbowColor.connect(self.text.setStyleSheet)
|
self.tcpThread.rainbowColor.connect(self.text.setStyleSheet)
|
||||||
self.tcpThread.timerUpdate.connect(self.startPauseOnscreenTimers)
|
self.tcpThread.timerUpdate.connect(self.startPauseOnscreenTimers)
|
||||||
|
self.tcpThread.updateAreaList.connect(self.updateAreaList)
|
||||||
self.tcpThread.start()
|
self.tcpThread.start()
|
||||||
|
|
||||||
self.demoPlaying = False
|
self.demoPlaying = False
|
||||||
@ -4799,6 +4724,20 @@ class GUI(QtGui.QWidget):
|
|||||||
self.startDemoRecorder(background)
|
self.startDemoRecorder(background)
|
||||||
self.ICChatInput.setFocus()
|
self.ICChatInput.setFocus()
|
||||||
|
|
||||||
|
def newDemoPlayer(self):
|
||||||
|
self.demoPlayer = demo.DemoPlayer(self)
|
||||||
|
self.demoPlayer.MS_Chat.connect(self.netmsgMS)
|
||||||
|
self.demoPlayer.newChar.connect(self.onPVPacket)
|
||||||
|
self.demoPlayer.newBackground.connect(self.setBackground)
|
||||||
|
self.demoPlayer.OOC_Log.connect(self.OOCLog.append)
|
||||||
|
self.demoPlayer.IC_Log.connect(self.ICLog.append)
|
||||||
|
self.demoPlayer.charSlots.connect(self.setCharSlots)
|
||||||
|
self.demoPlayer.loadAllEvidence.connect(self.loadAllEvidence)
|
||||||
|
self.demoPlayer.updatePlayerList.connect(self.updatePlayerList)
|
||||||
|
self.demoPlayer.rainbowColor.connect(self.text.setStyleSheet)
|
||||||
|
self.demoPlayer.timerUpdate.connect(self.startPauseOnscreenTimers)
|
||||||
|
self.demoPlayer.setCharList.connect(self.onSCPacket)
|
||||||
|
|
||||||
def startDemo(self, fname):
|
def startDemo(self, fname):
|
||||||
self.playerList = []
|
self.playerList = []
|
||||||
self.charList = []
|
self.charList = []
|
||||||
@ -4820,17 +4759,7 @@ class GUI(QtGui.QWidget):
|
|||||||
|
|
||||||
self.onImportEvidence(True)
|
self.onImportEvidence(True)
|
||||||
|
|
||||||
self.demoPlayer = demo.DemoPlayer(self)
|
self.newDemoPlayer()
|
||||||
self.demoPlayer.MS_Chat.connect(self.netmsgMS)
|
|
||||||
self.demoPlayer.newChar.connect(self.onPVPacket)
|
|
||||||
self.demoPlayer.newBackground.connect(self.setBackground)
|
|
||||||
self.demoPlayer.OOC_Log.connect(self.OOCLog.append)
|
|
||||||
self.demoPlayer.IC_Log.connect(self.ICLog.append)
|
|
||||||
self.demoPlayer.charSlots.connect(partial(self.charSelect.setCharList, self.charList))
|
|
||||||
self.demoPlayer.loadAllEvidence.connect(self.loadAllEvidence)
|
|
||||||
self.demoPlayer.updatePlayerList.connect(self.updatePlayerList)
|
|
||||||
self.demoPlayer.rainbowColor.connect(self.text.setStyleSheet)
|
|
||||||
self.demoPlayer.timerUpdate.connect(self.startPauseOnscreenTimers)
|
|
||||||
|
|
||||||
self.playerItems.clear()
|
self.playerItems.clear()
|
||||||
self.stopMusic()
|
self.stopMusic()
|
||||||
@ -4850,6 +4779,28 @@ class GUI(QtGui.QWidget):
|
|||||||
if bg:
|
if bg:
|
||||||
self.demoRecorder.record([["BN", bg, ""]], encode=True)
|
self.demoRecorder.record([["BN", bg, ""]], encode=True)
|
||||||
|
|
||||||
|
def onDemoClicked(self, item):
|
||||||
|
fname = demo.getDemoFilename(self.demoItems, item)
|
||||||
|
|
||||||
|
if not fname:
|
||||||
|
return
|
||||||
|
|
||||||
|
self.playerItems.clear()
|
||||||
|
self.stopMusic()
|
||||||
|
self.ICLog.clear()
|
||||||
|
self.OOCLog.clear()
|
||||||
|
|
||||||
|
if not self.demoPlaying:
|
||||||
|
self.enableWidgets(True)
|
||||||
|
self.tcpThread.stop()
|
||||||
|
self.demoPlaying = True
|
||||||
|
self.newDemoPlayer()
|
||||||
|
|
||||||
|
self.demoPlayer.start(fname)
|
||||||
|
|
||||||
|
def demoSeek(self, time):
|
||||||
|
self.demoPlayer.seek(time)
|
||||||
|
|
||||||
def enableWidgets(self, demo = False):
|
def enableWidgets(self, demo = False):
|
||||||
for widget in [
|
for widget in [
|
||||||
self.OOCInput, self.btnCallMod,
|
self.OOCInput, self.btnCallMod,
|
||||||
@ -4859,10 +4810,11 @@ class GUI(QtGui.QWidget):
|
|||||||
self.tabMusic, self.boxEmotes, self.boxPositions,
|
self.tabMusic, self.boxEmotes, self.boxPositions,
|
||||||
self.cbFlip, self.cbPreanim, self.cbNoInterrupt,
|
self.cbFlip, self.cbPreanim, self.cbNoInterrupt,
|
||||||
self.boxEffects, self.cbSlide, self.cbBench,
|
self.boxEffects, self.cbSlide, self.cbBench,
|
||||||
self.cbAdditive, self.areaItems,
|
self.cbAdditive, self.areaItems, self.boxSounds, self.boxColors,
|
||||||
self.boxColors, self.btnDefenseBar.btnMinus, self.btnProsecutionBar.btnMinus,
|
self.btnDefenseBar.btnMinus, self.btnProsecutionBar.btnMinus,
|
||||||
self.btnDefenseBar.btnPlus, self.btnProsecutionBar.btnPlus, self.btnWitnessTestimony,
|
self.btnDefenseBar.btnPlus, self.btnProsecutionBar.btnPlus,
|
||||||
self.btnCrossExamination, self.btnNotGuilty, self.btnGuilty,
|
self.btnWitnessTestimony, self.btnCrossExamination,
|
||||||
|
self.btnNotGuilty, self.btnGuilty,
|
||||||
self.btnRealization, self.btnShake,
|
self.btnRealization, self.btnShake,
|
||||||
]:
|
]:
|
||||||
widget.setEnabled(not demo)
|
widget.setEnabled(not demo)
|
||||||
@ -4875,7 +4827,35 @@ class GUI(QtGui.QWidget):
|
|||||||
else:
|
else:
|
||||||
self.btnChangeChar.setText('Switch &character')
|
self.btnChangeChar.setText('Switch &character')
|
||||||
|
|
||||||
def updateAreaList(self):
|
def updateAreaList(self, data=None):
|
||||||
|
if data:
|
||||||
|
kind = int(data[0])
|
||||||
|
self.areas[kind] = [data[i] for i in range(1, len(data))]
|
||||||
|
|
||||||
|
# This is much harder than doing it during the handshake because of
|
||||||
|
# the way the music list is implemented
|
||||||
|
if self.noARUP:
|
||||||
|
self.noARUP = False
|
||||||
|
self.areasLen = len(self.areas[kind])
|
||||||
|
print '[client]', 'The server has %d areas' % self.areasLen
|
||||||
|
|
||||||
|
if self.areasLen:
|
||||||
|
for i in range(self.areasLen):
|
||||||
|
area_key, area_val = self.musicList.items()[0]
|
||||||
|
self.areas[4].append(area_val)
|
||||||
|
|
||||||
|
areaitem = QtGui.QListWidgetItem()
|
||||||
|
self.areaItems.addItem(areaitem)
|
||||||
|
|
||||||
|
for j in range(4):
|
||||||
|
if j != kind:
|
||||||
|
self.areas[j].append("")
|
||||||
|
|
||||||
|
# Remove the area from the music list
|
||||||
|
self.musicList.popitem(False)
|
||||||
|
|
||||||
|
self.loadAllMusic()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
for i in range(self.areasLen):
|
for i in range(self.areasLen):
|
||||||
areaPlayers = self.areas[0][i]
|
areaPlayers = self.areas[0][i]
|
||||||
@ -4895,3 +4875,20 @@ class GUI(QtGui.QWidget):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
print "[debug] Couldn't update areas. Details:"
|
print "[debug] Couldn't update areas. Details:"
|
||||||
print "[debug]", e
|
print "[debug]", e
|
||||||
|
|
||||||
|
def authStatusChanged(self, status):
|
||||||
|
statusStrings = ["You have logged out", "Wrong password", "Logged in"]
|
||||||
|
if status == 1:
|
||||||
|
self.login = True
|
||||||
|
self.btnPlayerKick.setDisabled(False)
|
||||||
|
self.btnPlayerBan.setDisabled(False)
|
||||||
|
self.OOCLogin.setText("Lo&g out")
|
||||||
|
elif status == -1:
|
||||||
|
self.login = False
|
||||||
|
self.btnPlayerKick.setDisabled(True)
|
||||||
|
self.btnPlayerBan.setDisabled(True)
|
||||||
|
self.OOCLogin.setText("Lo&gin")
|
||||||
|
self.OOCLog.append("<b>%s</b>" % (statusStrings[status+1]))
|
||||||
|
|
||||||
|
def onSCPacket(self, data):
|
||||||
|
self.charList = data
|
||||||
@ -345,10 +345,8 @@ class MasterServer(QtCore.QThread):
|
|||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
try:
|
try:
|
||||||
tempdata = ""
|
|
||||||
self.msHttp = requests.get("http://servers.aceattorneyonline.com/servers")
|
self.msHttp = requests.get("http://servers.aceattorneyonline.com/servers")
|
||||||
self.msMotd = requests.get("http://servers.aceattorneyonline.com/motd")
|
self.msMotd = requests.get("http://servers.aceattorneyonline.com/motd")
|
||||||
|
|
||||||
if self.msHttp.ok: self.gotServers.emit(json.loads(self.msHttp.content))
|
if self.msHttp.ok: self.gotServers.emit(json.loads(self.msHttp.content))
|
||||||
if self.msMotd.ok: self.gotOOCMsg.emit(self.msMotd.content)
|
if self.msMotd.ok: self.gotOOCMsg.emit(self.msMotd.content)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
75
packets.py
75
packets.py
@ -50,15 +50,14 @@ def handlePackets(caller, total, record=True):
|
|||||||
caller.OOC_Log.emit("<b>%s:</b> %s" % (name, chatmsg.replace("<", "<").replace("<br />","<br />") if len(network) > 3 and network[3] == "0" else chatmsg))
|
caller.OOC_Log.emit("<b>%s:</b> %s" % (name, chatmsg.replace("<", "<").replace("<br />","<br />") if len(network) > 3 and network[3] == "0" else chatmsg))
|
||||||
|
|
||||||
elif header == 'PV':
|
elif header == 'PV':
|
||||||
caller.parent.myChar = int(network[3])
|
caller.newChar.emit(int(network[3]))
|
||||||
caller.parent.charSelect.hide()
|
|
||||||
caller.newChar.emit(caller.parent.charList[caller.parent.myChar][0])
|
|
||||||
|
|
||||||
elif header == 'LE':
|
elif header == 'LE':
|
||||||
del network[0]
|
del network[0]
|
||||||
caller.loadAllEvidence.emit([evi.split('&') for evi in network])
|
caller.loadAllEvidence.emit([evi.split('&') for evi in network])
|
||||||
|
|
||||||
elif header == 'ZZ':
|
elif header == 'ZZ':
|
||||||
|
# TODO: Remove from tcp thread
|
||||||
if caller.parent.modcall:
|
if caller.parent.modcall:
|
||||||
audio.freeHandle(caller.parent.modcall)
|
audio.freeHandle(caller.parent.modcall)
|
||||||
caller.parent.modcall = audio.loadHandle(0, "mod_call.wav", 0, 0, 0)
|
caller.parent.modcall = audio.loadHandle(0, "mod_call.wav", 0, 0, 0)
|
||||||
@ -69,31 +68,14 @@ def handlePackets(caller, total, record=True):
|
|||||||
caller.OOC_Log.emit('<b>[MOD CALL] ' + network[1].replace("\n", "<br />") + '</b>')
|
caller.OOC_Log.emit('<b>[MOD CALL] ' + network[1].replace("\n", "<br />") + '</b>')
|
||||||
else:
|
else:
|
||||||
caller.OOC_Log.emit('<b>[MOD CALL] But there was no extra information. (old server?)</b>')
|
caller.OOC_Log.emit('<b>[MOD CALL] But there was no extra information. (old server?)</b>')
|
||||||
|
|
||||||
elif header == 'CharsCheck':
|
elif header == 'CharsCheck':
|
||||||
del network[0]
|
del network[0]
|
||||||
for i in range(len(network)):
|
caller.charSlots.emit(network)
|
||||||
caller.parent.charList[i][1] = int(network[i])
|
|
||||||
|
|
||||||
caller.charSlots.emit()
|
|
||||||
|
|
||||||
elif header == 'RT':
|
elif header == 'RT':
|
||||||
testimony = network[1]
|
testimony = network[1]
|
||||||
wtcefile = BASE_PATH + "sounds/general/sfx-testimony2"
|
variant = int(network[2]) if testimony == 'judgeruling' else 0
|
||||||
if caller.parent.wtceSfx:
|
|
||||||
audio.freeHandle(caller.parent.wtceSfx)
|
|
||||||
|
|
||||||
if testimony == 'judgeruling':
|
|
||||||
variant = int(network[2])
|
|
||||||
if variant == 0:
|
|
||||||
wtcefile = BASE_PATH + "sounds/general/sfx-notguilty"
|
|
||||||
elif variant == 1:
|
|
||||||
wtcefile = BASE_PATH + "sounds/general/sfx-guilty"
|
|
||||||
else:
|
|
||||||
variant = 0
|
|
||||||
caller.parent.wtceSfx = audio.loadHandle(False, wtcefile+".opus" if exists(wtcefile+".opus") else wtcefile+".wav", 0, 0, 0)
|
|
||||||
audio.setHandleAttr(caller.parent.wtceSfx, BASS_ATTRIB_VOL, caller.parent.sliSoundVolume.value() / 100.0)
|
|
||||||
if caller.parent.wtceSfx:
|
|
||||||
audio.playHandle(caller.parent.wtceSfx, True)
|
|
||||||
caller.parent.wtceSignal.emit(testimony, variant)
|
caller.parent.wtceSignal.emit(testimony, variant)
|
||||||
|
|
||||||
elif header == 'HP':
|
elif header == 'HP':
|
||||||
@ -102,31 +84,22 @@ def handlePackets(caller, total, record=True):
|
|||||||
caller.parent.healthbars.emit(kind, health)
|
caller.parent.healthbars.emit(kind, health)
|
||||||
|
|
||||||
elif header == 'KK':
|
elif header == 'KK':
|
||||||
|
# TODO: Show message from GUI thread
|
||||||
reason = network[1]
|
reason = network[1]
|
||||||
caller.parent.emit(QtCore.SIGNAL('showMessage(QString, QString, QString)'), 'critical', 'Connection lost', 'You were kicked from the server. (%s)' % reason)
|
caller.parent.emit(QtCore.SIGNAL('showMessage(QString, QString, QString)'), 'critical', 'Connection lost', 'You were kicked from the server. (%s)' % reason)
|
||||||
|
|
||||||
elif header == 'KB':
|
elif header == 'KB':
|
||||||
|
# TODO: Show message from GUI thread
|
||||||
reason = network[1]
|
reason = network[1]
|
||||||
caller.parent.emit(QtCore.SIGNAL('showMessage(QString, QString, QString)'), 'critical', 'Connection lost', 'You have been banned from the server. (%s)' % reason)
|
caller.parent.emit(QtCore.SIGNAL('showMessage(QString, QString, QString)'), 'critical', 'Connection lost', 'You have been banned from the server. (%s)' % reason)
|
||||||
|
|
||||||
elif header == 'BB': # message popup (AO 2.9)
|
elif header == 'BB': # message popup (AO 2.9)
|
||||||
|
# TODO: Show message from GUI thread
|
||||||
message = network[1]
|
message = network[1]
|
||||||
caller.parent.emit(QtCore.SIGNAL('showMessage(QString, QString, QString)'), 'information', 'Message from server', message)
|
caller.parent.emit(QtCore.SIGNAL('showMessage(QString, QString, QString)'), 'information', 'Message from server', message)
|
||||||
|
|
||||||
elif header == 'AUTH': # login status (AO 2.9)
|
elif header == 'AUTH': # login status (AO 2.9)
|
||||||
status = int(network[1])
|
caller.authStatusChanged.emit(int(network[1]))
|
||||||
statusStrings = ["You have logged out", "Wrong password", "Logged in"]
|
|
||||||
if status == 1:
|
|
||||||
caller.parent.login = True
|
|
||||||
caller.parent.btnPlayerKick.setDisabled(False)
|
|
||||||
caller.parent.btnPlayerBan.setDisabled(False)
|
|
||||||
caller.parent.OOCLogin.setText("Lo&g out")
|
|
||||||
elif status == -1:
|
|
||||||
caller.parent.login = False
|
|
||||||
caller.parent.btnPlayerKick.setDisabled(True)
|
|
||||||
caller.parent.btnPlayerBan.setDisabled(True)
|
|
||||||
caller.parent.OOCLogin.setText("Lo&gin")
|
|
||||||
caller.OOC_Log.emit("<b>%s</b>" % (statusStrings[status+1]))
|
|
||||||
|
|
||||||
# elif header == "CHECK": #ping
|
# elif header == "CHECK": #ping
|
||||||
# pingafter = time.time()
|
# pingafter = time.time()
|
||||||
@ -145,33 +118,7 @@ def handlePackets(caller, total, record=True):
|
|||||||
|
|
||||||
elif header == 'ARUP':
|
elif header == 'ARUP':
|
||||||
del network[0]
|
del network[0]
|
||||||
kind = int(network[0])
|
caller.updateAreaList.emit(network)
|
||||||
caller.parent.areas[kind] = [network[i] for i in range(1, len(network))]
|
|
||||||
|
|
||||||
# This is much harder than doing it during the handshake because of the way the music list is implemented
|
|
||||||
if caller.parent.noARUP:
|
|
||||||
caller.parent.noARUP = False
|
|
||||||
caller.parent.areasLen = len(caller.parent.areas[kind])
|
|
||||||
print '[client]', 'The server has %d areas' % caller.parent.areasLen
|
|
||||||
|
|
||||||
if caller.parent.areasLen:
|
|
||||||
for i in range(caller.parent.areasLen):
|
|
||||||
area_key, area_val = caller.parent.musicList.items()[0]
|
|
||||||
caller.parent.areas[4].append(area_val)
|
|
||||||
|
|
||||||
areaitem = QtGui.QListWidgetItem()
|
|
||||||
caller.parent.areaItems.addItem(areaitem)
|
|
||||||
|
|
||||||
for j in range(4):
|
|
||||||
if j != kind:
|
|
||||||
caller.parent.areas[j].append("")
|
|
||||||
|
|
||||||
# Remove the area from the music list
|
|
||||||
caller.parent.musicList.popitem(False)
|
|
||||||
|
|
||||||
caller.parent.loadAllMusic()
|
|
||||||
|
|
||||||
caller.parent.updateAreaList()
|
|
||||||
|
|
||||||
elif header == 'TI':
|
elif header == 'TI':
|
||||||
del network[0]
|
del network[0]
|
||||||
@ -186,4 +133,4 @@ def handlePackets(caller, total, record=True):
|
|||||||
# For demos
|
# For demos
|
||||||
elif header == 'SC':
|
elif header == 'SC':
|
||||||
del network[0]
|
del network[0]
|
||||||
caller.parent.charList = [ [char.split('&')[0].decode('utf-8'), 0, "male", True ] for char in network ]
|
caller.setCharList.emit([ [char.split('&')[0].decode('utf-8'), 0, "male", True ] for char in network ])
|
||||||
Loading…
Reference in New Issue
Block a user