diff --git a/gameview.py b/gameview.py
index 6553809..9be279b 100644
--- a/gameview.py
+++ b/gameview.py
@@ -252,26 +252,31 @@ class ChatLogs(QtGui.QTextEdit):
def __init__(self, parent, logtype, logfile=None):
QtGui.QTextEdit.__init__(self, parent)
self.type = logtype
- self.savelog = ini.read_ini_bool("AO2XP.ini", "General", "save logs")
- self.combinelog = ini.read_ini_bool("AO2XP.ini", "General", "combined logs")
self.setMouseTracking(True)
self.anchor = None
+ self.savelog = False
+ self.combinelog = False
+ self.set_logfiles(logfile)
+
+ def set_logfiles(self, logfile=None):
+ 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 self.savelog:
+ if not self.logfile:
currtime = time.localtime()
if self.combinelog:
if self.type == 0:
self.logfile = logfile
else:
- self.logfile = open("chatlogs/%d%.2d%.2d_on_%.2d.%.2d.%.2d.txt" % (currtime[0], currtime[1], currtime[2], currtime[3], currtime[4], currtime[5]), "w")
+ self.logfile = "chatlogs/%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 = open("chatlogs/IC_%d%.2d%.2d_on_%.2d.%.2d.%.2d.txt" % (currtime[0], currtime[1], currtime[2], currtime[3], currtime[4], currtime[5]), "w")
+ self.logfile = "chatlogs/IC_%d%.2d%.2d_on_%.2d.%.2d.%.2d.txt" % (currtime[0], currtime[1], currtime[2], currtime[3], currtime[4], currtime[5])
else:
- self.logfile = open("chatlogs/OOC_%d%.2d%.2d_on_%.2d.%.2d.%.2d.txt" % (currtime[0], currtime[1], currtime[2], currtime[3], currtime[4], currtime[5]), "w")
+ self.logfile = "chatlogs/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
@@ -294,23 +299,26 @@ class ChatLogs(QtGui.QTextEdit):
self.logfile.close()
def append(self, text):
- if self.savelog:
- if isinstance(text, str) or isinstance(text, unicode):
- if self.combinelog and not "Log started" in text:
- if self.type == 0:
- self.logfile.write("[IC] "+text.encode("utf-8")+"\n")
+ if self.savelog and not "Log started" in text:
+ with open(self.logfile, "a") as logfile:
+ if isinstance(text, str) or isinstance(text, unicode):
+ text_ = text.encode("utf-8")
+ if self.combinelog:
+ if self.type == 0:
+ logfile.write("[IC] " + text_.replace("", "").replace("", "") +"\n")
+ else:
+ logfile.write("[OOC] " + text_.replace("", "").replace("", "") +"\n")
else:
- self.logfile.write("[OOC] "+text.encode("utf-8")+"\n")
+ logfile.write(text_.replace("", "").replace("", "") + "\n")
else:
- self.logfile.write(text.encode("utf-8")+"\n")
- else:
- if self.combinelog and not "Log started" in text:
- if self.type == 0:
- self.logfile.write("[IC] "+text.toUtf8()+"\n")
+ text_ = text.toUtf8()
+ if self.combinelog:
+ if self.type == 0:
+ logfile.write("[IC] " + text_.replace("", "").replace("", "") +"\n")
+ else:
+ logfile.write("[OOC] " + text_.replace("", "").replace("", "") +"\n")
else:
- self.logfile.write("[OOC] "+text.toUtf8()+"\n")
- else:
- self.logfile.write(text.toUtf8()+"\n")
+ logfile.write(text_.replace("", "").replace("", "") +"\n")
# if "http" in text:
# text = unicode(text) # Get rid of QStrings
diff --git a/options.py b/options.py
index 5cc9edc..9c5ceb0 100644
--- a/options.py
+++ b/options.py
@@ -66,18 +66,20 @@ class Settings(QtGui.QDialog):
defaultoocname_layout.addWidget(defaultoocname_label)
defaultoocname_layout.addWidget(self.defaultoocname)
- defaultshowname_layout = QtGui.QHBoxLayout()
defaultshowname_label = QtGui.QLabel("Default showname")
self.defaultshowname = QtGui.QLineEdit()
- defaultshowname_layout.addWidget(defaultshowname_label)
- defaultshowname_layout.addWidget(self.defaultshowname)
+ defaultoocname_layout.addWidget(defaultshowname_label)
+ defaultoocname_layout.addWidget(self.defaultshowname)
+ savetolog_layout = QtGui.QHBoxLayout()
self.savetolog = QtGui.QCheckBox()
- self.savetolog.setText("Save chat logs to a file*")
+ self.savetolog.setText("Save chat logs to a file")
self.savetolog.setChecked(False)
self.savetolog_combine = QtGui.QCheckBox()
- self.savetolog_combine.setText("Combine OOC and IC chat logs in the same file*")
+ self.savetolog_combine.setText("Combine OOC and IC chat logs in the same file")
self.savetolog_combine.setChecked(False)
+ savetolog_layout.addWidget(self.savetolog)
+ savetolog_layout.addWidget(self.savetolog_combine)
textstaytime_layout = QtGui.QHBoxLayout()
textstaytime_label = QtGui.QLabel("Text stay time (milliseconds)")
@@ -87,6 +89,12 @@ class Settings(QtGui.QDialog):
textstaytime_layout.addWidget(textstaytime_label)
textstaytime_layout.addWidget(self.textstaytime)
+ icoptions_layout = QtGui.QHBoxLayout()
+ self.enableslide = QtGui.QCheckBox()
+ self.enableslide.setText("Display courtroom slide (pan-tilt) animations")
+ self.enableslide.setChecked(True)
+ icoptions_layout.addWidget(self.enableslide)
+
allowdownload = QtGui.QLabel()
allowdownload.setText("Automatically download or stream online from WebAO:")
allowdownload_layout = QtGui.QHBoxLayout()
@@ -145,27 +153,21 @@ class Settings(QtGui.QDialog):
self.check_updates_btn.clicked.connect(self.onUpdateClicked)
update_layout.addWidget(self.check_updates)
update_layout.addWidget(self.check_updates_btn)
-
- savechangeswarn = QtGui.QLabel()
- savechangeswarn.setText("* Change takes effect upon restarting the client")
general_layout.addLayout(defaultoocname_layout)
- general_layout.addLayout(defaultshowname_layout)
+ general_layout.addLayout(savetolog_layout)
general_layout.addWidget(separators[0])
- general_layout.addWidget(self.savetolog)
- general_layout.addWidget(self.savetolog_combine)
general_layout.addLayout(textstaytime_layout)
general_layout.addWidget(separators[1])
- general_layout.addWidget(allowdownload)
- general_layout.addLayout(allowdownload_layout)
- general_layout.addWidget(separators[2])
general_layout.addLayout(currtheme_layout)
general_layout.addLayout(autoconnect_layout)
general_layout.addLayout(autopick_layout)
general_layout.addLayout(autojoinarea_layout)
+ general_layout.addWidget(separators[2])
+ general_layout.addWidget(allowdownload)
+ general_layout.addLayout(allowdownload_layout)
general_layout.addWidget(separators[3])
general_layout.addLayout(update_layout)
- general_layout.addWidget(savechangeswarn, 50, QtCore.Qt.AlignBottom)
###### Audio tab ######
device_label = QtGui.QLabel("Audio device")
@@ -317,6 +319,9 @@ class Settings(QtGui.QDialog):
f.write(self.callwords_edit.toPlainText().toUtf8())
self.gamewindow.gamewidget.text_wait_time = self.textstaytime.value()
+ self.gamewindow.gamewidget.ooclog.set_logfiles()
+ self.gamewindow.gamewidget.icLog.set_logfiles(self.gamewindow.gamewidget.ooclog.logfile)
+
self.hide()
def onCancelClicked(self):