starting work on offline demo player

This commit is contained in:
cidoku 2025-03-11 17:58:57 -03:00
parent 4dae88a809
commit 2be05f1a54
6 changed files with 179 additions and 129 deletions

View File

@ -58,7 +58,7 @@ class gamewindow(QtGui.QMainWindow):
def showGame(self, tcp, playerlist, charlist, musiclist, background, evidence, areas, features=[], oocjoin=[], hplist=[], webAO_bucket=""):
self.gamewidget.disconnectnow = False
self.gamewidget.startGame(tcp, playerlist, charlist, musiclist, background, evidence, areas, features, oocjoin, hplist, webAO_bucket)
self.gamewidget.start_game(tcp, playerlist, charlist, musiclist, background, evidence, areas, features, oocjoin, hplist, webAO_bucket)
self.stackwidget.setCurrentWidget(self.gamewidget)
def returnToMenu(self):

View File

@ -43,7 +43,7 @@ self.musicareatabs.setGeometry(814 - 288, 468, 288, 258)
self.musicitems.setGeometry(8, 8, 268, 184)
self.musicsearch.setGeometry(8, self.musicitems.size().height() + 16, 268, self.musicsearch.sizeHint().height())
self.icLog.setGeometry(8, 8, 714 - 304 - 22, 212)
self.iclog.setGeometry(8, 8, 714 - 304 - 22, 212)
self.evidencedropdown.setGeometry(8, 8, 192, 20)
self.privatedropdown.setGeometry(8, 8, 192, 20)
@ -77,18 +77,18 @@ self.evidencesave.move(3 + self.evidenceload.x() + self.evidenceload.size().widt
self.evidencepresent.move((714 - 304 - 22) / 2 - self.evidencepresent.button_off.size().width() / 2, self.evidencedesc.y() - self.evidencepresent.button_off.size().height())
self.msgqueueList.setGeometry(8, 8, 714 - 304 - 22, 180)
self.playerList.setGeometry(8, 8, 268, 180)
self.removeQueue.resize(self.removeQueue.sizeHint())
self.removeQueue.move(8, self.msgqueueList.size().height() + 16)
self.clearQueue.move(self.removeQueue.x() + self.removeQueue.size().width(), self.removeQueue.y())
self.msgqueue_list.setGeometry(8, 8, 714 - 304 - 22, 180)
self.player_list.setGeometry(8, 8, 268, 180)
self.remove_queue.resize(self.remove_queue.sizeHint())
self.remove_queue.move(8, self.msgqueue_list.size().height() + 16)
self.clear_queue.move(self.remove_queue.x() + self.remove_queue.size().width(), self.remove_queue.y())
self.playerPair.resize(self.playerPair.sizeHint())
self.playerKick.resize(self.playerKick.sizeHint())
self.playerBan.resize(self.playerBan.sizeHint())
self.playerPair.move(8, self.playerList.size().height() + 16)
self.playerKick.move(8 + self.playerPair.x() + self.playerPair.size().width(), self.playerList.size().height() + 16)
self.playerBan.move(8 + self.playerKick.x() + self.playerKick.size().width(), self.playerList.size().height() + 16)
self.player_pair.resize(self.player_pair.sizeHint())
self.player_kick.resize(self.player_kick.sizeHint())
self.player_ban.resize(self.player_ban.sizeHint())
self.player_pair.move(8, self.player_list.size().height() + 16)
self.player_kick.move(8 + self.player_pair.x() + self.player_pair.size().width(), self.player_list.size().height() + 16)
self.player_ban.move(8 + self.player_kick.x() + self.player_kick.size().width(), self.player_list.size().height() + 16)
self.notmutedlabel.move(8, 8)
self.unmutedlist.setGeometry(8, 24, 160, 192)

View File

@ -107,7 +107,7 @@ class DemoPlayer(QtCore.QObject):
packets.handle_packets(self, [self.bn[t][1]], False)
self.last_bg = bg
self.step(True)
self.step()
def load_demo(self, file):
last_line = ""

View File

@ -687,7 +687,7 @@ class ZoomLines(QtGui.QLabel):
img = self.movie.currentImage()
self.setPixmap(QtGui.QPixmap.fromImage(img))
def setZoom(self, on, dir=0):
def set_zoom(self, on, dir=0):
self.movie.stop()
if not on:
self.hide()
@ -699,9 +699,9 @@ class ZoomLines(QtGui.QLabel):
self.movie.setFileName(AO2XPpath + 'themes/default/prosecution_speedlines.gif')
self.movie.start()
class WTCE_View(QtGui.QLabel):
class WTCEView(QtGui.QLabel):
def __init__(self, parent):
super(WTCE_View, self).__init__(parent)
super(WTCEView, self).__init__(parent)
self.movie = QtGui.QMovie()
self.movie.frameChanged.connect(self.frame_change)
self.finalframe_timer = QtCore.QTimer()
@ -724,7 +724,7 @@ class WTCE_View(QtGui.QLabel):
self.movie.stop()
self.hide()
def showWTCE(self, wtce, variant=0):
def show_WTCE(self, wtce, variant=0):
self.finished()
if wtce == 'testimony1':
self.movie.setFileName(AO2XPpath + 'themes/default/witnesstestimony.gif')
@ -744,7 +744,7 @@ class EditEvidenceDialog(QtGui.QDialog):
def __init__(self, gamegui):
super(EditEvidenceDialog, self).__init__()
self.gamegui = gamegui
self.setTitle()
self.set_title()
self.resize(512, 384)
self.setModal(True)
@ -762,18 +762,18 @@ class EditEvidenceDialog(QtGui.QDialog):
self.save = QtGui.QPushButton(self)
self.save.setText('Save')
self.save.clicked.connect(self.onSave)
self.save.clicked.connect(self.on_save)
self.save.move(256 - self.save.size().width() - 8, 384 - self.save.size().height() - 2)
self.cancel = QtGui.QPushButton(self)
self.cancel.setText('Cancel')
self.cancel.clicked.connect(self.onCancel)
self.cancel.clicked.connect(self.on_cancel)
self.cancel.move(264 + 16, 384 - self.cancel.size().height() - 2)
self.choosepic = QtGui.QComboBox(self)
self.choosepic.setGeometry(self.eviname.x() + self.eviname.size().width() - 128 - 84, self.eviname.y() + 70 - 32, 128, 24)
self.filenames = []
self.browse = QtGui.QPushButton(self)
self.browse.setText('Browse')
self.browse.clicked.connect(self.onBrowse)
self.browse.clicked.connect(self.on_browse)
self.browse.move(self.choosepic.x() + self.choosepic.width() + 8, self.choosepic.y())
files = os.listdir(AOpath + 'evidence')
@ -794,17 +794,17 @@ class EditEvidenceDialog(QtGui.QDialog):
self.emptyfile = i
self.editing = False
self.choosepic.currentIndexChanged.connect(self.choosePicChange)
self.choosepic.currentIndexChanged.connect(self.choose_pic_change)
self.choosepic.setCurrentIndex(i)
def choosePicChange(self, ind):
def choose_pic_change(self, ind):
self.filename = self.filenames[ind]
if exists(AOpath + 'evidence/' + self.filename):
self.evipicture.setPixmap(QtGui.QPixmap(AOpath + 'evidence/' + self.filename))
else:
self.evipicture.setPixmap(QtGui.QPixmap(AO2XPpath + 'themes/default/evidence_selected.png'))
def onSave(self):
def on_save(self):
name = encode_ao_str(self.eviname.text())
desc = encode_ao_str(self.evidesc.toPlainText())
@ -832,27 +832,27 @@ class EditEvidenceDialog(QtGui.QDialog):
self.evipicture.setPixmap(evipic)
self.filename = 'empty.png'
self.editing = False
self.setTitle()
self.set_title()
self.choosepic.setCurrentIndex(self.emptyfile)
self.hide()
def onCancel(self):
def on_cancel(self):
self.eviname.setText('')
self.evidesc.setText('')
evipic = QtGui.QPixmap(AOpath + 'evidence/empty.png')
self.evipicture.setPixmap(evipic)
self.filename = 'empty.png'
self.editing = False
self.setTitle()
self.set_title()
self.choosepic.setCurrentIndex(self.emptyfile)
self.hide()
def onBrowse(self):
def on_browse(self):
path = str(QtGui.QFileDialog.getOpenFileName(self, "Select an image", AOpath + 'evidence', "Images (*.png)"))
if path:
if not "/evidence/" in path.lower():
QtGui.QMessageBox.warning(self, 'Wrong directory', 'Please select a file from the "evidence" directory.')
self.onBrowse()
self.on_browse()
return
file = basename(path)
@ -861,9 +861,9 @@ class EditEvidenceDialog(QtGui.QDialog):
self.choosepic.setCurrentIndex(ind)
else:
QtGui.QMessageBox.warning(self, 'Not a valid file', 'Please select a PNG image.')
self.onBrowse()
self.on_browse()
def EditEvidence(self, ind):
def edit_evidence(self, ind):
self.editing = True
self.edit_ind = ind
evidence = self.gamegui.privateevidence if self.gamegui.privateinv else self.gamegui.evidence
@ -877,10 +877,10 @@ class EditEvidenceDialog(QtGui.QDialog):
self.setWindowTitle("Edit evidence" if not self.gamegui.privateinv else "Edit evidence in private inventory")
self.show()
def setTitle(self):
def set_title(self):
self.setWindowTitle('Add evidence' if not self.gamegui.privateinv else "Add evidence to private inventory")
class TCP_Thread(QtCore.QThread):
class TCPThread(QtCore.QThread):
connectionError = QtCore.pyqtSignal(str, str, str)
MS_Chat = QtCore.pyqtSignal(list)
newChar = QtCore.pyqtSignal(str)
@ -899,7 +899,7 @@ class TCP_Thread(QtCore.QThread):
stop_now = False
def __init__(self, parent):
super(TCP_Thread, self).__init__(parent)
super(TCPThread, self).__init__(parent)
self.parent = parent
def run(self):
@ -949,7 +949,7 @@ class TCP_Thread(QtCore.QThread):
self.send_attempts = 0
#print "[warning] message discarded"
del self.parent.msgqueue[0]
self.parent.msgqueueList.takeItem(0)
self.parent.msgqueue_list.takeItem(0)
continue
elif error == -1:
self.parent.emit(QtCore.SIGNAL('showMessage(QString, QString, QString)'), 'critical', 'Connection lost', "%s connection to server lost." % ("WebSocket" if self.parent.tcp.isWS else "TCP"))
@ -1006,7 +1006,7 @@ class GUI(QtGui.QWidget):
privateinv = False
scaling = [SCALING_AUTO, SCALING_AUTO]
WTCEsignal = QtCore.pyqtSignal(str, int)
wtcesignal = QtCore.pyqtSignal(str, int)
healthbars = QtCore.pyqtSignal(int, int)
gotPing = QtCore.pyqtSignal(int)
@ -1014,7 +1014,7 @@ class GUI(QtGui.QWidget):
super(GUI, self).__init__(parent)
self.gamewindow = parent
self.gotPing.connect(self.setPing)
self.gotPing.connect(self.set_ping)
for i in range(self.chatmessage_size):
self.m_chatmessage.append("")
@ -1114,8 +1114,8 @@ class GUI(QtGui.QWidget):
self.presentedevi.setGeometry(16, 16, 140, 140)
self.presentedevi.hide()
self.wtceview = WTCE_View(self)
self.WTCEsignal.connect(self.wtceview.showWTCE)
self.wtceview = WTCEView(self)
self.wtcesignal.connect(self.wtceview.show_WTCE)
self.objectionview = AOMovie(self.viewport)
self.objectionview.resize(VIEWPORT_W, VIEWPORT_H)
@ -1132,7 +1132,7 @@ class GUI(QtGui.QWidget):
self.whiteflash.timeout.connect(partial(self.setWhiteFlash, False))
self.screenshake = QtCore.QTimer()
self.screenshake.timeout.connect(self.screenShakeTick)
self.screenshake.timeout.connect(self.screen_shake_tick)
self.shakes_remaining = 0
self.onscreen_timer_labels = []
@ -1169,7 +1169,7 @@ class GUI(QtGui.QWidget):
self.oocinput.returnPressed.connect(self.onOOCreturn)
self.ooclogin = QtGui.QPushButton("Lo&gin", self)
self.ooclogin.clicked.connect(self.onOOCLoginBtn)
self.ooclogin.clicked.connect(self.on_ooc_login)
self.gametabs = QtGui.QTabWidget(self)
self.gametab_log = QtGui.QWidget() # the IC chat log
@ -1193,11 +1193,11 @@ class GUI(QtGui.QWidget):
self.areaitems.itemDoubleClicked.connect(self.onAreaClick)
self.demoitems = demo.get_demo_treeview()
self.demoitems.doubleClicked.connect(self.onDemoClick)
self.demoitems.doubleClicked.connect(self.on_demo_click)
self.icLog = ChatLogs(self.gametab_log, 0, self.ooclog.logfile)
self.icLog.setReadOnly(True)
self.icLog.textChanged.connect(self.icLogChanged)
self.iclog = ChatLogs(self.gametab_log, 0, self.ooclog.logfile)
self.iclog.setReadOnly(True)
self.iclog.textChanged.connect(self.icLogChanged)
self.evidencedropdown = QtGui.QComboBox(self.gametab_evidence)
self.evidencedropdown.currentIndexChanged.connect(self.changeGlobalEvidence)
@ -1253,28 +1253,28 @@ class GUI(QtGui.QWidget):
self.evidencemoveallglobal.hide()
self.evidenceswitchglobal.hide()
self.msgqueueList = QtGui.QListWidget(self.gametab_msgqueue)
self.msgqueueList.itemClicked.connect(self.onClicked_msgqueue)
self.removeQueue = QtGui.QPushButton(self.gametab_msgqueue)
self.removeQueue.setText('Delete')
self.removeQueue.clicked.connect(self.onClicked_removeQueue)
self.clearQueue = QtGui.QPushButton(self.gametab_msgqueue)
self.clearQueue.setText('Clear')
self.clearQueue.clicked.connect(self.onClicked_clearQueue)
self.msgqueue_list = QtGui.QListWidget(self.gametab_msgqueue)
self.msgqueue_list.itemClicked.connect(self.onClicked_msgqueue)
self.remove_queue = QtGui.QPushButton(self.gametab_msgqueue)
self.remove_queue.setText('Delete')
self.remove_queue.clicked.connect(self.onClicked_remove_queue)
self.clear_queue = QtGui.QPushButton(self.gametab_msgqueue)
self.clear_queue.setText('Clear')
self.clear_queue.clicked.connect(self.onClicked_clear_queue)
self.playerList = QtGui.QListWidget(self.gametab_players)
self.playerList.itemClicked.connect(self.onClicked_playerList)
self.playerPair = QtGui.QPushButton(self.gametab_players)
self.playerPair.setText('Pair')
self.playerPair.clicked.connect(self.onClicked_playerPair)
self.playerKick = QtGui.QPushButton(self.gametab_players)
self.playerKick.setText('Kick')
self.playerKick.clicked.connect(self.onClicked_playerKick)
self.playerKick.setDisabled(True)
self.playerBan = QtGui.QPushButton(self.gametab_players)
self.playerBan.setText('Ban')
self.playerBan.clicked.connect(self.onClicked_playerBan)
self.playerBan.setDisabled(True)
self.player_list = QtGui.QListWidget(self.gametab_players)
self.player_list.itemClicked.connect(self.onClicked_playerList)
self.player_pair = QtGui.QPushButton(self.gametab_players)
self.player_pair.setText('Pair')
self.player_pair.clicked.connect(self.onClicked_playerPair)
self.player_kick = QtGui.QPushButton(self.gametab_players)
self.player_kick.setText('Kick')
self.player_kick.clicked.connect(self.onClicked_playerKick)
self.player_kick.setDisabled(True)
self.player_ban = QtGui.QPushButton(self.gametab_players)
self.player_ban.setText('Ban')
self.player_ban.clicked.connect(self.onClicked_playerBan)
self.player_ban.setDisabled(True)
self.unmutedlist = QtGui.QListWidget(self.gametab_mute)
self.mutedlist = QtGui.QListWidget(self.gametab_mute)
@ -1317,7 +1317,7 @@ class GUI(QtGui.QWidget):
self.ypairoffset.setValue(0)
self.ypairoffset_l = QtGui.QLabel("Y offset", self.gametab_pair)
self.pairoffsetreset = QtGui.QPushButton("Reset", self.gametab_pair)
self.pairoffsetreset.clicked.connect(self.resetOffsets)
self.pairoffsetreset.clicked.connect(self.reset_offsets)
self.pair_order = QtGui.QComboBox(self.gametab_pair)
self.pair_order.addItem("Front")
self.pair_order.addItem("Behind")
@ -1365,7 +1365,7 @@ class GUI(QtGui.QWidget):
self.posdropdown = QtGui.QComboBox(self)
self.posdropdown.addItems(["def", "pro", "wit", "hld", "hlp", "jud"])
self.posdropdown.currentIndexChanged.connect(self.setPosition)
self.posdropdown.currentIndexChanged.connect(self.set_position)
self.posdropdown.setToolTip('Select your position in the courtroom')
self.flipbutton = QtGui.QCheckBox(self)
@ -1449,11 +1449,11 @@ class GUI(QtGui.QWidget):
self.nextemotepage.show()
self.realizationbtn = buttons.AOToggleButton(self, 265 + 164, 192 + 304, "realization")
self.realizationbtn.clicked.connect(self.onRealizationButton)
self.realizationbtn.clicked.connect(self.on_realization_button)
self.realizationbtn.setToolTip('Show the next message with a realization effect')
self.realizationsnd = audio.loadhandle(False, AOpath + 'sounds/general/sfx-realization.wav', 0, 0, 0)
self.shakebtn = buttons.AOToggleButton(self, 265+42 + 164, 192 + 304, "screenshake") # AO 2.8
self.shakebtn.clicked.connect(self.onShakeButton)
self.shakebtn.clicked.connect(self.on_shake_button)
self.shakebtn.setToolTip('Show the next message with a shaking effect')
self.customobject = buttons.CustomObjection(self, 250 + 516 - 30, 312 + 40)
@ -1500,9 +1500,9 @@ class GUI(QtGui.QWidget):
self.musicslider.setRange(0, 100)
self.soundslider.setRange(0, 100)
self.blipslider.setRange(0, 100)
self.musicslider.valueChanged.connect(self.changeMusicVolume)
self.soundslider.valueChanged.connect(self.changeSoundVolume)
self.blipslider.valueChanged.connect(self.changeBlipVolume)
self.musicslider.valueChanged.connect(self.change_music_volume)
self.soundslider.valueChanged.connect(self.change_sound_volume)
self.blipslider.valueChanged.connect(self.change_blip_volume)
self.sliderlabel1 = QtGui.QLabel("Music", self)
self.sliderlabel2 = QtGui.QLabel("SFX", self)
self.sliderlabel3 = QtGui.QLabel("Blips", self)
@ -1510,7 +1510,7 @@ class GUI(QtGui.QWidget):
self.pinglabel = QtGui.QLabel(self)
self.demoslider = QtGui.QSlider(QtCore.Qt.Horizontal, self)
self.demoslider.valueChanged.connect(self.demoSeek)
self.demoslider.valueChanged.connect(self.demo_seek)
self.demoslider.setVisible(False)
self.demoslider.setMinimum(0)
@ -1592,11 +1592,11 @@ class GUI(QtGui.QWidget):
QtGui.QMessageBox.critical(None, "Unable to load theme", "There was a problem loading the current theme \"%s\":\n\n%s." % (theme, e))
os._exit(-2)
def resetOffsets(self):
def reset_offsets(self):
self.pairoffset.setValue(0)
self.ypairoffset.setValue(0)
def screenShakeTick(self):
def screen_shake_tick(self):
self.shakes_remaining -= 1
shakeforce = 8
if self.shakes_remaining:
@ -1620,18 +1620,18 @@ class GUI(QtGui.QWidget):
def icchat_focus(self):
self.icchatinput.setFocus()
def onRealizationButton(self):
def on_realization_button(self):
if self.realizationbtn.isPressed():
self.effectdropdown.setCurrentIndex(1) # realization
elif self.effectdropdown.currentText() == "realization":
self.effectdropdown.setCurrentIndex(0)
self.icchat_focus()
def onShakeButton(self):
def on_shake_button(self):
self.sfxbutton.setChecked(False)
self.icchat_focus()
def onOOCLoginBtn(self):
def on_ooc_login(self):
if not self.oocnameinput.text():
self.oocnameinput.setText("unnamed")
@ -1643,10 +1643,10 @@ class GUI(QtGui.QWidget):
else:
self.sendOOCchat(self.oocnameinput.text().toUtf8(), "/logout")
def setPing(self, newping):
def set_ping(self, newping):
self.pinglabel.setText("Ping: %d" % newping)
def setPosition(self, ind):
def set_position(self, ind):
if not self.oocnameinput.text():
self.oocnameinput.setText("unnamed")
self.posdropdown.setCurrentIndex(ind)
@ -1664,7 +1664,7 @@ class GUI(QtGui.QWidget):
else:
self.sendOOCchat(self.oocnameinput.text().toUtf8(), "/pos "+self.charside)
def changeMusicVolume(self, value):
def change_music_volume(self, value):
if self.music:
audio.sethandleattr(self.music, BASS_ATTRIB_VOL, value / 100.0)
if value == 0:
@ -1672,7 +1672,7 @@ class GUI(QtGui.QWidget):
elif audio.handleisactive(self.music) == BASS_ACTIVE_PAUSED:
audio.playhandle(self.music, False)
def changeSoundVolume(self, value):
def change_sound_volume(self, value):
if self.sound:
audio.sethandleattr(self.sound, BASS_ATTRIB_VOL, value / 100.0)
audio.sethandleattr(self.realizationsnd, BASS_ATTRIB_VOL, value / 100.0)
@ -1682,7 +1682,7 @@ class GUI(QtGui.QWidget):
if self.modcall:
audio.sethandleattr(self.modcall, BASS_ATTRIB_VOL, value / 100.0)
def changeBlipVolume(self, value):
def change_blip_volume(self, value):
if self.blipsnd:
audio.sethandleattr(self.blipsnd, BASS_ATTRIB_VOL, value / 100.0)
@ -1839,14 +1839,14 @@ class GUI(QtGui.QWidget):
self.tcp.send("RT#judgeruling#" +str(variant)+ "#%")
self.icchat_focus()
def onPVPacket(self, charname):
def onPVPacket(self, charname=""):
self.gamewindow.setFixedSize(self.width, self.height)
self.gamewindow.center()
if not self.swapping:
if not self.swapping and charname:
self.loadCharacter(charname)
def loadCharacter(self, charname):
self.msgqueueList.clear()
self.msgqueue_list.clear()
self.msgqueue = []
self.effectdropdown.clear()
self.emotedropdown.clear()
@ -1980,7 +1980,7 @@ class GUI(QtGui.QWidget):
def onEditEvidence(self):
if not self.evidence:
return QtGui.QMessageBox.information(self, 'No evidence', "There's no evidence on the court record.")
self.evidence_editor.EditEvidence(self.selectedevi)
self.evidence_editor.edit_evidence(self.selectedevi)
def onDeleteEvidence(self):
if self.selectedevi == -1:
@ -2166,26 +2166,26 @@ class GUI(QtGui.QWidget):
self.icchat_focus()
def onClicked_msgqueue(self, item):
for i in range(len(self.msgqueueList)):
if self.msgqueueList.item(i) == item:
for i in range(len(self.msgqueue_list)):
if self.msgqueue_list.item(i) == item:
self.selectedmsg = i
def onClicked_playerList(self, item):
for i in range(len(self.playerList)):
sel = self.playerList.item(i)
for i in range(len(self.player_list)):
sel = self.player_list.item(i)
if sel == item:
s = sel.text()
self.selectedplayer = s[1:s.indexOf("]")]
def onClicked_removeQueue(self):
if len(self.msgqueueList) == 0:
def onClicked_remove_queue(self):
if len(self.msgqueue_list) == 0:
return QtGui.QMessageBox.information(self, "No messages in queue", 'Enter a message on the game chat to add one.')
if self.selectedmsg == -1:
return QtGui.QMessageBox.information(self, 'No message selected', 'Select a message from the list to remove it.')
self.msgqueueList.takeItem(self.selectedmsg)
self.msgqueue_list.takeItem(self.selectedmsg)
del self.msgqueue[self.selectedmsg]
def onClicked_clearQueue(self):
def onClicked_clear_queue(self):
return QtGui.QMessageBox.information(self, "Clear queue", 'Not implemented.')
def onClicked_playerPair(self):
@ -2282,9 +2282,9 @@ class GUI(QtGui.QWidget):
def disconnectCommon(self):
self.onSwitchInventory(True)
self.selectedplayer = -1
self.playerList.clear()
self.playerKick.setDisabled(True)
self.playerBan.setDisabled(True)
self.player_list.clear()
self.player_kick.setDisabled(True)
self.player_ban.setDisabled(True)
self.demo_recorder = None
self.ooclogin.setText("Lo&gin")
self.login = False
@ -2306,7 +2306,7 @@ class GUI(QtGui.QWidget):
self.tcp.send('MC#' + content + '#' + str(self.mychar) + '#%')
def icLogChanged(self):
if self.icLog.verticalScrollBar().value() == self.icLog.verticalScrollBar().maximum(): self.icLog.verticalScrollBar().setValue(self.icLog.verticalScrollBar().maximum())
if self.iclog.verticalScrollBar().value() == self.iclog.verticalScrollBar().maximum(): self.iclog.verticalScrollBar().setValue(self.iclog.verticalScrollBar().maximum())
def ooclog_update(self):
if self.ooclog.verticalScrollBar().value() == self.ooclog.verticalScrollBar().maximum(): self.ooclog.verticalScrollBar().setValue(self.ooclog.verticalScrollBar().maximum())
@ -2508,7 +2508,7 @@ class GUI(QtGui.QWidget):
msg += "%"
self.msgqueueList.addItem(self.icchatinput.text())
self.msgqueue_list.addItem(self.icchatinput.text())
self.msgqueue.append(msg)
self.lastmsg = msg
@ -2711,7 +2711,7 @@ class GUI(QtGui.QWidget):
special = not chatmsgcomp or chatmsgcomp.isspace()
if examine or (f_char_id == self.mychar and (special or m_chatmessage[CHATMSG] == chatmsgcomp)): # our message showed up
del self.msgqueue[0]
self.msgqueueList.takeItem(0)
self.msgqueue_list.takeItem(0)
if self.additivebtn.isChecked():
self.icchatinput.insert(" ")
@ -2738,7 +2738,7 @@ class GUI(QtGui.QWidget):
logcharname += " (???)"
if evidence == -1:
self.icLog.append(timestamp + '%s: %s' % (logcharname, chatmsg))
self.iclog.append(timestamp + '%s: %s' % (logcharname, chatmsg))
else:
eviname = '(NULL) %d' % evidence
try:
@ -2746,7 +2746,7 @@ class GUI(QtGui.QWidget):
except:
pass
self.icLog.append(timestamp + '%s: %s\n%s presented an evidence: %s' % (logcharname, chatmsg, f_char, eviname.strip()))
self.iclog.append(timestamp + '%s: %s\n%s presented an evidence: %s' % (logcharname, chatmsg, f_char, eviname.strip()))
self.is_additive = (m_chatmessage[ADDITIVE] == "1")
@ -2910,7 +2910,7 @@ class GUI(QtGui.QWidget):
self.handle_chatmessage_2()
def handle_chatmessage_2(self):
self.zoom.setZoom(False)
self.zoom.set_zoom(False)
self.char.stop()
self.effectview.stop()
@ -3136,9 +3136,9 @@ class GUI(QtGui.QWidget):
self.char.move(0,0)
if side == "pro" or side == "hlp" or side == "wit":
self.zoom.setZoom(True, 1)
self.zoom.set_zoom(True, 1)
else:
self.zoom.setZoom(True, 0)
self.zoom.set_zoom(True, 0)
f_anim_state = 0
text_is_blue = int(self.m_chatmessage[TEXT_COLOR]) == 4
@ -3619,23 +3619,26 @@ class GUI(QtGui.QWidget):
self.evidencedropdown.setCurrentIndex(self.selectedevi)
def updatePlayerList(self, pid, op, utype, data=""):
if not self.playerlist:
return
pid = str(pid)
if op == 0: # Add or remove player
if utype == 0: # Add a player
self.playerList.addItem("[%s]" % pid)
self.player_list.addItem("[%s]" % pid)
if not pid in self.playerlist:
self.playerlist[pid] = ["", "", "", ""]
if utype == 1: # Remove a player
item = self.playerList.findItems("[%s]" % pid, QtCore.Qt.MatchStartsWith)
item = self.player_list.findItems("[%s]" % pid, QtCore.Qt.MatchStartsWith)
if item:
self.playerList.takeItem(self.playerList.row(item[0]))
self.player_list.takeItem(self.player_list.row(item[0]))
if pid in self.playerlist:
del self.playerlist[pid]
else: # Update a player
if pid in self.playerlist:
self.playerlist[pid][utype] = data
item = self.playerList.findItems("[%s]" % pid, QtCore.Qt.MatchStartsWith)
item = self.player_list.findItems("[%s]" % pid, QtCore.Qt.MatchStartsWith)
if item:
name = self.playerlist[pid][0]
char = self.playerlist[pid][1]
@ -3687,7 +3690,7 @@ class GUI(QtGui.QWidget):
if self.onscreen_timer_times == [0, 0, 0, 0, 0]:
self.onscreen_timer.stop()
def onDemoClick(self, item):
def on_demo_click(self, item):
model = self.demoitems.model()
if model.isDir(item):
return
@ -3703,9 +3706,9 @@ class GUI(QtGui.QWidget):
fname = path.join("/")
self.playerList.clear()
self.player_list.clear()
self.stopMusic()
self.icLog.clear()
self.iclog.clear()
self.ooclog.clear()
if not self.demo_playing:
for widget in [self.oocinput, self.callmodbtn, self.changechar, self.oocnameinput, self.ooclogin, self.gametab_evidence, self.gametab_msgqueue, self.gametab_iniswap, self.gametab_mute, self.gametab_pair, self.gametab_misc, self.gametab_players, self.gametab_music, self.emotedropdown, self.posdropdown, self.flipbutton, self.sfxbutton, self.nointerruptbtn, self.effectdropdown, self.slidebutton, self.deskbtn, self.additivebtn, self.areaitems, self.shownameedit, self.colordropdown]:
@ -3717,10 +3720,10 @@ class GUI(QtGui.QWidget):
self.demoplayer.start(fname)
def demoSeek(self, time):
def demo_seek(self, time):
self.demoplayer.seek(time)
def startGame(self, tcp, playerlist, charlist, musiclist, background, evidence, areas, features=[], oocjoin=[], hplist=[], webAO_bucket=""):
def start_game(self, tcp, playerlist, charlist, musiclist, background, evidence, areas, features=[], oocjoin=[], hplist=[], webAO_bucket=""):
self.willDisconnect = False
self.mychar = -1
self.mychatcolor = 0
@ -3753,7 +3756,7 @@ class GUI(QtGui.QWidget):
else:
self.charselect.showCharSelect(False)
#putting it down here because some servers won't allow you to switch areas without picking a character first
# Putting it down here because some servers won't allow you to switch areas without picking a character first
autojoinarea = get_option("General", "auto join area").decode('utf-8')
if autojoinarea != "": self.sendMC(autojoinarea)
@ -3806,7 +3809,6 @@ class GUI(QtGui.QWidget):
self.musicitems.clear()
self.areaitems.clear()
#self.demoitems.clear()
self.evidencedropdown.clear()
for evi in evidence:
self.evidencedropdown.addItem(evi[0].strip())
@ -3816,10 +3818,10 @@ class GUI(QtGui.QWidget):
self.ooclog.append("\n"+logstart)
else:
self.ooclog.append(logstart)
if self.icLog.toPlainText():
self.icLog.append("\n"+logstart)
if self.iclog.toPlainText():
self.iclog.append("\n"+logstart)
else:
self.icLog.append(logstart)
self.iclog.append(logstart)
self.setBackground(background.lower())
self.set_scene(True)
@ -3847,12 +3849,12 @@ class GUI(QtGui.QWidget):
self.onImportEvidence(True)
self.tcpthread = TCP_Thread(self)
self.tcpthread = TCPThread(self)
self.tcpthread.MS_Chat.connect(self.netmsg_ms)
self.tcpthread.newChar.connect(self.onPVPacket)
self.tcpthread.newBackground.connect(self.setBackground)
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.showCharSelect.connect(self.charselect.showCharSelect)
self.tcpthread.allEvidence.connect(self.allEvidence)
@ -3866,20 +3868,66 @@ class GUI(QtGui.QWidget):
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.IC_Log.connect(self.iclog.append)
self.demoplayer.charSlots.connect(partial(self.charselect.setCharList, self.charlist))
self.demoplayer.allEvidence.connect(self.allEvidence)
self.demoplayer.updatePlayerList.connect(self.updatePlayerList)
self.demoplayer.rainbowColor.connect(self.text.setStyleSheet)
self.demoplayer.timerUpdate.connect(self.start_pause_timers)
self.start_demo_recorder()
self.start_demo_recorder(background)
self.icchatinput.setFocus()
def start_demo_recorder(self):
def start_demo(self, fname):
self.playerlist = []
self.charlist = []
self.evidence = []
self.areas = []
self.areas_len = 0
self.features = ['noencryption', 'yellowtext', 'prezoom', 'flipping', 'customobjections', 'fastloading', 'deskmod', 'evidence', 'cccc_ic_support', 'arup', 'casing_alerts', 'modcall_reason', 'looping_sfx', 'additive', 'effects', 'y_offset', 'expanded_desk_mods', 'auth_packet', 'custom_blips']
self.musiclist = OrderedDict([])
self.charselect.hide()
self.onPVPacket()
self.setBackground("default")
self.set_scene(True)
self.chatbox.hide()
self.musicslider.setValue(ini.read_ini_int("AO2XP.ini", "Audio", "Music volume", 100))
self.soundslider.setValue(ini.read_ini_int("AO2XP.ini", "Audio", "Sound volume", 100))
self.blipslider.setValue(ini.read_ini_int("AO2XP.ini", "Audio", "Blip volume", 100))
self.onImportEvidence(True)
self.demoplayer = demo.DemoPlayer(self)
self.demoplayer.MS_Chat.connect(self.netmsg_ms)
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.allEvidence.connect(self.allEvidence)
self.demoplayer.updatePlayerList.connect(self.updatePlayerList)
self.demoplayer.rainbowColor.connect(self.text.setStyleSheet)
self.demoplayer.timerUpdate.connect(self.start_pause_timers)
self.player_list.clear()
self.stopMusic()
self.iclog.clear()
self.ooclog.clear()
for widget in [self.oocinput, self.callmodbtn, self.changechar, self.oocnameinput, self.ooclogin, self.gametab_evidence, self.gametab_msgqueue, self.gametab_iniswap, self.gametab_mute, self.gametab_pair, self.gametab_misc, self.gametab_players, self.gametab_music, self.emotedropdown, self.posdropdown, self.flipbutton, self.sfxbutton, self.nointerruptbtn, self.effectdropdown, self.slidebutton, self.deskbtn, self.additivebtn, self.areaitems, self.shownameedit, self.colordropdown]:
widget.setEnabled(False)
self.demoslider.setVisible(True)
self.icchatinput.setVisible(False)
self.demo_playing = True
self.demoplayer.start(fname)
def start_demo_recorder(self, bg):
if ini.read_ini_bool("AO2XP.ini", "General", "record demos", False):
self.demo_recorder = demo.DemoRecorder()
self.demo_recorder.start()
self.demo_recorder.record([["SC"] + [char[0] for char in self.charlist]], encode=True)
self.demo_recorder.record([["BN", bg, ""]], encode=True)

View File

@ -302,6 +302,8 @@ class lobby(QtGui.QWidget):
self.serverinfo.hide()
self.settingsbtn.hide()
self.aoserverinfo.tcp.send('askchaa#%')
#self.gamewindow.gamewidget.start_demo("test.demo")
#self.gamewindow.stackwidget.setCurrentWidget(self.gamewindow.gamewidget)
def onClicked_cancelconnect(self):
self.connectingimg.hide()

View File

@ -346,7 +346,7 @@ class Settings(QtGui.QDialog):
if not (self.savelogs_state == self.savetolog.isChecked() and self.combinelogs_state == self.savetolog_combine.isChecked()):
self.gamewindow.gamewidget.ooclog.set_logfiles()
self.gamewindow.gamewidget.icLog.set_logfiles(self.gamewindow.gamewidget.ooclog.logfile)
self.gamewindow.gamewidget.iclog.set_logfiles(self.gamewindow.gamewidget.ooclog.logfile)
if not self.savedemos_state == self.savedemos.isChecked():
if self.savedemos.isChecked():