diff --git a/gameview.py b/gameview.py
index f5c0bb3..5272047 100644
--- a/gameview.py
+++ b/gameview.py
@@ -272,8 +272,8 @@ class ChatLogs(QtGui.QTextEdit):
self.savelog = ini.read_ini_bool("AO2XP.ini", "General", "save logs")
self.combinelog = ini.read_ini_bool("AO2XP.ini", "General", "combined logs")
- if not exists("chatlogs"):
- os.mkdir("chatlogs")
+ if not exists("logs"):
+ os.mkdir("logs")
if not self.logfile:
currtime = time.localtime()
@@ -281,12 +281,12 @@ class ChatLogs(QtGui.QTextEdit):
if self.type == 0:
self.logfile = logfile
else:
- self.logfile = "chatlogs/%d%.2d%.2d_on_%.2d.%.2d.%.2d.txt" % (currtime[0], currtime[1], currtime[2], currtime[3], currtime[4], currtime[5])
+ self.logfile = "logs/%d%.2d%.2d_on_%.2d.%.2d.%.2d.txt" % (currtime[0], currtime[1], currtime[2], currtime[3], currtime[4], currtime[5])
else:
if self.type == 0:
- self.logfile = "chatlogs/IC_%d%.2d%.2d_on_%.2d.%.2d.%.2d.txt" % (currtime[0], currtime[1], currtime[2], currtime[3], currtime[4], currtime[5])
+ self.logfile = "logs/IC_%d%.2d%.2d_on_%.2d.%.2d.%.2d.txt" % (currtime[0], currtime[1], currtime[2], currtime[3], currtime[4], currtime[5])
else:
- self.logfile = "chatlogs/OOC_%d%.2d%.2d_on_%.2d.%.2d.%.2d.txt" % (currtime[0], currtime[1], currtime[2], currtime[3], currtime[4], currtime[5])
+ self.logfile = "logs/OOC_%d%.2d%.2d_on_%.2d.%.2d.%.2d.txt" % (currtime[0], currtime[1], currtime[2], currtime[3], currtime[4], currtime[5])
else:
self.logfile = None
@@ -1031,8 +1031,20 @@ class gui(QtGui.QWidget):
self.areaitems = QtGui.QListWidget()
self.areaitems.itemDoubleClicked.connect(self.onAreaClick)
- self.demoitems = QtGui.QListWidget()
- self.demoitems.itemDoubleClicked.connect(self.onDemoClick)
+
+ demoitems_model = QtGui.QFileSystemModel();
+ demoitems_model.setRootPath("logs");
+ demoitems_model.setFilter(QtCore.QDir.Files | QtCore.QDir.AllDirs | QtCore.QDir.NoDotAndDotDot)
+ demoitems_model.setNameFilters(QtCore.QStringList("*.demo"))
+ demoitems_model.setNameFilterDisables(False)
+
+ self.demoitems = QtGui.QTreeView()
+ self.demoitems.setHeaderHidden(True)
+ self.demoitems.doubleClicked.connect(self.onDemoClick)
+ self.demoitems.setModel(demoitems_model);
+ self.demoitems.setRootIndex(demoitems_model.index("logs"));
+ for i in range(1, demoitems_model.columnCount()):
+ self.demoitems.hideColumn(i)
self.icLog = ChatLogs(self.gametab_log, 0, self.ooclog.logfile)
self.icLog.setReadOnly(True)
@@ -3518,6 +3530,21 @@ class gui(QtGui.QWidget):
self.onscreen_timer.stop()
def onDemoClick(self, item):
+ model = self.demoitems.model()
+ if model.isDir(item):
+ return
+
+ path = QtCore.QStringList()
+
+ while item.isValid():
+ fname = model.fileName(item).toLower()
+ if fname == "logs":
+ break
+ path.insert(0, fname)
+ item = item.parent()
+
+ fname = path.join("/")
+
self.playerList.clear()
self.stopMusic()
self.icLog.clear()
@@ -3530,7 +3557,7 @@ class gui(QtGui.QWidget):
self.tcpthread.stop()
self.demo_playing = True
- self.demoplayer.start(item.text())
+ self.demoplayer.start(fname)
def demoSeek(self, time):
self.demoplayer.seek(time)
@@ -3621,7 +3648,7 @@ class gui(QtGui.QWidget):
self.musicitems.clear()
self.areaitems.clear()
- self.demoitems.clear()
+ #self.demoitems.clear()
self.evidencedropdown.clear()
for evi in evidence:
self.evidencedropdown.addItem(evi[0].strip())
@@ -3661,10 +3688,6 @@ class gui(QtGui.QWidget):
self.blipslider.setValue(ini.read_ini_int("AO2XP.ini", "Audio", "Blip volume", 100))
self.onImportEvidence(True)
-
- for demo in os.listdir('chatlogs'):
- if os.path.splitext(basename(demo))[-1].lower() == ".demo":
- self.demoitems.addItem(demo)
self.tcpthread = TCP_Thread(self)
self.tcpthread.MS_Chat.connect(self.netmsg_ms)
@@ -3802,6 +3825,7 @@ class DemoPlayer(QtCore.QObject):
self.demo = []
self.demo_length = len(self.demo)
self.time = 0
+ self.demo_length_ms = 0
self.wait_timer = QtCore.QTimer(self)
self.wait_timer.setSingleShot(True)
self.wait_timer.timeout.connect(self.timer_done)
@@ -3813,6 +3837,7 @@ class DemoPlayer(QtCore.QObject):
def start(self, file):
self.time = 0
+ self.demo_length_ms = 0
self.demo = []
self.mc = []
self.bn = []
@@ -3820,6 +3845,14 @@ class DemoPlayer(QtCore.QObject):
self.last_bg = ""
self.load_demo(file)
self.parent.demoslider.setMaximum(self.demo_length - 1)
+ self.OOC_Log.emit("Demo playback started.")
+
+ secs = self.demo_length_ms / 1000
+ mins = secs / 60
+ hours = mins / 60
+ self.OOC_Log.emit("Approximate duration: %02d:%02d:%02d." % (hours, mins % 60, secs % 60))
+
+ self.OOC_Log.emit("")
self.step()
def playpause(self):
@@ -3827,7 +3860,7 @@ class DemoPlayer(QtCore.QObject):
if not self.paused and self.time < self.demo_length:
self.step()
- def step(self):
+ def step(self, skip_wait=False):
packet = self.demo[self.time]
self.parent.demoslider.blockSignals(True)
self.parent.demoslider.setValue(self.time)
@@ -3835,11 +3868,17 @@ class DemoPlayer(QtCore.QObject):
self.time += 1
if packet[0] == "wait":
- self.wait_timer.start(int(packet[1]))
+ if skip_wait:
+ self.time += 1
+ else:
+ self.wait_timer.start(int(packet[1]))
+ return
+
+ handle_packets(self, [packet])
+ if self.time < self.demo_length:
+ self.wait_timer.start(1)
else:
- handle_packets(self, [packet])
- if self.time < self.demo_length:
- self.wait_timer.start(1)
+ self.OOC_Log.emit("Demo playback finished.")
def seek(self, time):
self.parent.inbox_timer.stop()
@@ -3863,12 +3902,12 @@ class DemoPlayer(QtCore.QObject):
handle_packets(self, [self.bn[t][1]])
self.last_bg = bg
- self.step()
+ self.step(True)
def load_demo(self, file):
last_line = ""
time = 0
- with open("chatlogs/" + file) as f:
+ with open("logs/" + file) as f:
for line in f:
last_line = last_line + line
if last_line.strip()[-1] == "%":
@@ -3878,7 +3917,8 @@ class DemoPlayer(QtCore.QObject):
self.mc.append((time, packet))
elif packet[0] == "BN":
self.bn.append((time, packet))
-
+ elif packet[0] == "wait":
+ self.demo_length_ms += int(packet[1])
last_line = ""
time += 1
self.demo_length = len(self.demo)