fixed favorite servers. added setting to auto connect to favorite server on login
This commit is contained in:
parent
cbb548869a
commit
ed6a6cc3b2
@ -1546,9 +1546,9 @@ class gui(QtGui.QWidget):
|
|||||||
|
|
||||||
def onMusicClick(self, item):
|
def onMusicClick(self, item):
|
||||||
if "cccc_ic_support" in self.features and self.showname:
|
if "cccc_ic_support" in self.features and self.showname:
|
||||||
self.tcp.send('MC#' + item.text().toUtf8() + '#' + str(self.mychar) + '#' + self.showname + '#%')
|
self.tcp.send('MC#' + item.text() + '#' + str(self.mychar) + '#' + self.showname + '#%')
|
||||||
else:
|
else:
|
||||||
self.tcp.send('MC#' + item.text().toUtf8() + '#' + str(self.mychar) + '#%')
|
self.tcp.send('MC#' + item.text() + '#' + str(self.mychar) + '#%')
|
||||||
|
|
||||||
def icLogChanged(self):
|
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())
|
||||||
|
35
mainmenu.py
35
mainmenu.py
@ -6,6 +6,7 @@ from PyQt4 import QtGui, QtCore
|
|||||||
|
|
||||||
import hardware
|
import hardware
|
||||||
import AOsocket
|
import AOsocket
|
||||||
|
import ini
|
||||||
from game_version import *
|
from game_version import *
|
||||||
|
|
||||||
AOpath = "base/"
|
AOpath = "base/"
|
||||||
@ -49,11 +50,21 @@ class lobby(QtGui.QWidget):
|
|||||||
self.pix_btn_connect = QtGui.QPixmap(AO2XPpath+'themes/default/connect.png')
|
self.pix_btn_connect = QtGui.QPixmap(AO2XPpath+'themes/default/connect.png')
|
||||||
self.pix_connecting = QtGui.QPixmap(AO2XPpath+'themes/default/loadingbackground.png')
|
self.pix_connecting = QtGui.QPixmap(AO2XPpath+'themes/default/loadingbackground.png')
|
||||||
|
|
||||||
|
self.autoconnect = None
|
||||||
|
|
||||||
if exists(AOpath+'serverlist.txt'):
|
if exists(AOpath+'serverlist.txt'):
|
||||||
with open(AOpath+'serverlist.txt') as file:
|
with open(AOpath+'serverlist.txt') as file:
|
||||||
self.favoriteslist = [line.rstrip().split(':') for line in file]
|
self.favoriteslist = [line.rstrip().split(':') for line in file]
|
||||||
|
|
||||||
|
autoconnect_id = ini.read_ini_int("AO2XP.ini", "General", "auto connect")
|
||||||
|
if autoconnect_id >= 0:
|
||||||
|
try:
|
||||||
|
self.autoconnect = self.favoriteslist[autoconnect_id]
|
||||||
|
except:
|
||||||
|
print "[debug] Can't autoconnect to server."
|
||||||
else:
|
else:
|
||||||
self.favoriteslist = ['127.0.0.1:27017:your server (port 27017)'.split(':'), '127.0.0.1:27016:your server (port 27016)'.split(':'),]
|
self.favoriteslist = []
|
||||||
|
#self.favoriteslist = ['127.0.0.1:27017:your server (port 27017)'.split(':'), '127.0.0.1:27016:your server (port 27016)'.split(':'),]
|
||||||
|
|
||||||
self.lobbyimg = QtGui.QLabel(self)
|
self.lobbyimg = QtGui.QLabel(self)
|
||||||
self.lobbyimg.setPixmap(self.pix_lobby)
|
self.lobbyimg.setPixmap(self.pix_lobby)
|
||||||
@ -180,15 +191,24 @@ class lobby(QtGui.QWidget):
|
|||||||
self.aoserverinfo.readySoon.connect(self.connectcancel.hide)
|
self.aoserverinfo.readySoon.connect(self.connectcancel.hide)
|
||||||
self.aoserverinfo.setWindowTitle.connect(self.gamewindow.setWindowTitle)
|
self.aoserverinfo.setWindowTitle.connect(self.gamewindow.setWindowTitle)
|
||||||
self.aoserverinfo.canConnect.connect(self.canConnect)
|
self.aoserverinfo.canConnect.connect(self.canConnect)
|
||||||
|
|
||||||
self.masterserver = MasterServer()
|
self.masterserver = MasterServer()
|
||||||
self.masterserver.gotServers.connect(self.onGetServers)
|
self.masterserver.gotServers.connect(self.onGetServers)
|
||||||
self.masterserver.gotOOCMsg.connect(self.newOOCMessage)
|
self.masterserver.gotOOCMsg.connect(self.newOOCMessage)
|
||||||
self.masterserver.msgbox_signal.connect(self.showMessageBox)
|
self.masterserver.msgbox_signal.connect(self.showMessageBox)
|
||||||
self.masterserver.start()
|
self.masterserver.start()
|
||||||
|
|
||||||
|
if self.autoconnect:
|
||||||
|
self.aoserverinfo.setIP(self.autoconnect[-1], self.autoconnect[0], self.autoconnect[1], self.autoconnect[2])
|
||||||
|
print '[debug]', 'Connecting automatically to ip: ' + self.autoconnect[0] + ', port: ' + str(self.autoconnect[1]) + ", websocket port: " + str(self.autoconnect[2])
|
||||||
|
self.aoserverinfo.stop()
|
||||||
|
self.aoserverinfo.start()
|
||||||
|
|
||||||
def canConnect(self):
|
def canConnect(self):
|
||||||
self.can_connect = True
|
self.can_connect = True
|
||||||
|
if self.autoconnect:
|
||||||
|
self.autoconnect = None # We only want to autoconnect on first login after all
|
||||||
|
self.onClicked_connect()
|
||||||
|
|
||||||
def onGetServers(self, servers):
|
def onGetServers(self, servers):
|
||||||
if self.tab == 0: self.serverlist.clear()
|
if self.tab == 0: self.serverlist.clear()
|
||||||
@ -234,7 +254,7 @@ class lobby(QtGui.QWidget):
|
|||||||
self.serverlist.clear()
|
self.serverlist.clear()
|
||||||
self.serverinfo.setText("")
|
self.serverinfo.setText("")
|
||||||
for sv in self.favoriteslist:
|
for sv in self.favoriteslist:
|
||||||
self.serverlist.addItem(QtGui.QListWidgetItem(sv[2]))
|
self.serverlist.addItem(QtGui.QListWidgetItem(sv[-1]))
|
||||||
|
|
||||||
def onClicked_refresh(self):
|
def onClicked_refresh(self):
|
||||||
self.serverlist.clear()
|
self.serverlist.clear()
|
||||||
@ -262,14 +282,15 @@ class lobby(QtGui.QWidget):
|
|||||||
ip = self.actual_serverlist[i][0]
|
ip = self.actual_serverlist[i][0]
|
||||||
port = str(self.actual_serverlist[i][1])
|
port = str(self.actual_serverlist[i][1])
|
||||||
name = self.actual_serverlist[i][2]
|
name = self.actual_serverlist[i][2]
|
||||||
|
ws = self.actual_serverlist[i][-1]
|
||||||
|
|
||||||
for sv in self.favoriteslist:
|
for sv in self.favoriteslist:
|
||||||
if sv[0] == ip and sv[1] == port:
|
if sv[0] == ip and sv[1] == port:
|
||||||
return QtGui.QMessageBox.information(self, "Error", "This server already exists in your favorites list, named '%s'" % sv[2])
|
return QtGui.QMessageBox.information(self, "Error", "This server already exists in your favorites list, named '%s'" % sv[2])
|
||||||
|
|
||||||
self.favoriteslist.append([ip, port, name])
|
self.favoriteslist.append([ip, port, ws, name])
|
||||||
with open(AOpath+'serverlist.txt', "a") as file:
|
with open(AOpath+'serverlist.txt', "a") as file:
|
||||||
file.write("%s:%s:%s\n" % (ip, port, name))
|
file.write("%s:%s:%s:%s\n" % (ip, port, ws, name))
|
||||||
file.close()
|
file.close()
|
||||||
|
|
||||||
def onClicked_connect(self):
|
def onClicked_connect(self):
|
||||||
@ -320,8 +341,8 @@ class lobby(QtGui.QWidget):
|
|||||||
self.aoserverinfo.setIP(text, self.actual_serverlist[i][0], self.actual_serverlist[i][1], self.actual_serverlist[i][-1])
|
self.aoserverinfo.setIP(text, self.actual_serverlist[i][0], self.actual_serverlist[i][1], self.actual_serverlist[i][-1])
|
||||||
print '[debug]', 'ind: ' + str(i) + ', ip: ' + self.actual_serverlist[i][0] + ', port: ' + str(self.actual_serverlist[i][1]) + ", websocket port: " + str(self.actual_serverlist[i][-1])
|
print '[debug]', 'ind: ' + str(i) + ', ip: ' + self.actual_serverlist[i][0] + ', port: ' + str(self.actual_serverlist[i][1]) + ", websocket port: " + str(self.actual_serverlist[i][-1])
|
||||||
elif self.tab == 1:
|
elif self.tab == 1:
|
||||||
self.aoserverinfo.setIP(text, *self.favoriteslist[i][:2])
|
self.aoserverinfo.setIP(text, self.favoriteslist[i][0], self.favoriteslist[i][1], self.favoriteslist[i][2])
|
||||||
print '[debug]', 'ind: ' + str(i) + ', ip: ' + self.favoriteslist[i][0] + ', port: ' + str(self.favoriteslist[i][1])
|
print '[debug]', 'ind: ' + str(i) + ', ip: ' + self.favoriteslist[i][0] + ', port: ' + str(self.favoriteslist[i][1]) + ", websocket port: " + str(self.favoriteslist[i][2])
|
||||||
|
|
||||||
self.aoserverinfo.stop()
|
self.aoserverinfo.stop()
|
||||||
self.aoserverinfo.start()
|
self.aoserverinfo.start()
|
||||||
|
500
options.py
500
options.py
@ -15,261 +15,275 @@ AO2XPpath = "AO2XPbase/"
|
|||||||
#AOpath = "I:\\aovanilla1.7.5\\client\\base\\"
|
#AOpath = "I:\\aovanilla1.7.5\\client\\base\\"
|
||||||
|
|
||||||
class Settings(QtGui.QDialog):
|
class Settings(QtGui.QDialog):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(Settings, self).__init__()
|
super(Settings, self).__init__()
|
||||||
self.setModal(True)
|
self.setModal(True)
|
||||||
|
|
||||||
self.inifile = ConfigParser()
|
self.inifile = ConfigParser()
|
||||||
self.setWindowTitle("Settings")
|
self.setWindowTitle("Settings")
|
||||||
self.setFixedSize(480, 512)
|
self.setFixedSize(480, 512)
|
||||||
self.hide()
|
self.hide()
|
||||||
|
|
||||||
main_layout = QtGui.QVBoxLayout(self)
|
main_layout = QtGui.QVBoxLayout(self)
|
||||||
save_layout = QtGui.QHBoxLayout()
|
save_layout = QtGui.QHBoxLayout()
|
||||||
|
|
||||||
self.tabs = QtGui.QTabWidget()
|
self.tabs = QtGui.QTabWidget()
|
||||||
self.tabs.resize(320-16, 480-40)
|
self.tabs.resize(320-16, 480-40)
|
||||||
self.tabs.move(8, 8)
|
self.tabs.move(8, 8)
|
||||||
|
|
||||||
general_tab = QtGui.QWidget()
|
general_tab = QtGui.QWidget()
|
||||||
audio_tab = QtGui.QWidget()
|
audio_tab = QtGui.QWidget()
|
||||||
callwords_tab = QtGui.QWidget()
|
callwords_tab = QtGui.QWidget()
|
||||||
general_layout = QtGui.QVBoxLayout(general_tab)
|
general_layout = QtGui.QVBoxLayout(general_tab)
|
||||||
general_layout.setAlignment(QtCore.Qt.AlignTop)
|
general_layout.setAlignment(QtCore.Qt.AlignTop)
|
||||||
audio_layout = QtGui.QFormLayout(audio_tab)
|
audio_layout = QtGui.QFormLayout(audio_tab)
|
||||||
audio_layout.setLabelAlignment(QtCore.Qt.AlignLeading | QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
|
audio_layout.setLabelAlignment(QtCore.Qt.AlignLeading | QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
|
||||||
audio_layout.setFormAlignment(QtCore.Qt.AlignLeading | QtCore.Qt.AlignLeft | QtCore.Qt.AlignTop)
|
audio_layout.setFormAlignment(QtCore.Qt.AlignLeading | QtCore.Qt.AlignLeft | QtCore.Qt.AlignTop)
|
||||||
callwords_layout = QtGui.QVBoxLayout(callwords_tab)
|
callwords_layout = QtGui.QVBoxLayout(callwords_tab)
|
||||||
callwords_layout.setAlignment(QtCore.Qt.AlignTop)
|
callwords_layout.setAlignment(QtCore.Qt.AlignTop)
|
||||||
|
|
||||||
savebtn = QtGui.QPushButton()
|
savebtn = QtGui.QPushButton()
|
||||||
savebtn.setText("Save")
|
savebtn.setText("Save")
|
||||||
savebtn.clicked.connect(self.onSaveClicked)
|
savebtn.clicked.connect(self.onSaveClicked)
|
||||||
cancelbtn = QtGui.QPushButton()
|
cancelbtn = QtGui.QPushButton()
|
||||||
cancelbtn.setText("Cancel")
|
cancelbtn.setText("Cancel")
|
||||||
cancelbtn.clicked.connect(self.onCancelClicked)
|
cancelbtn.clicked.connect(self.onCancelClicked)
|
||||||
|
|
||||||
separators = []
|
separators = []
|
||||||
for i in range(5):
|
for i in range(5):
|
||||||
separator = QtGui.QFrame()
|
separator = QtGui.QFrame()
|
||||||
separator.setFixedSize(separator.size().width(), 12)
|
separator.setFixedSize(separator.size().width(), 12)
|
||||||
separators.append(separator)
|
separators.append(separator)
|
||||||
|
|
||||||
###### General tab ######
|
###### General tab ######
|
||||||
self.savetolog = QtGui.QCheckBox()
|
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.setChecked(False)
|
||||||
self.savetolog_combine = QtGui.QCheckBox()
|
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)
|
self.savetolog_combine.setChecked(False)
|
||||||
|
|
||||||
defaultoocname_layout = QtGui.QHBoxLayout()
|
defaultoocname_layout = QtGui.QHBoxLayout()
|
||||||
defaultoocname_label = QtGui.QLabel("Default OOC name")
|
defaultoocname_label = QtGui.QLabel("Default OOC name")
|
||||||
self.defaultoocname = QtGui.QLineEdit()
|
self.defaultoocname = QtGui.QLineEdit()
|
||||||
defaultoocname_layout.addWidget(defaultoocname_label)
|
defaultoocname_layout.addWidget(defaultoocname_label)
|
||||||
defaultoocname_layout.addWidget(self.defaultoocname)
|
defaultoocname_layout.addWidget(self.defaultoocname)
|
||||||
|
|
||||||
defaultshowname_layout = QtGui.QHBoxLayout()
|
defaultshowname_layout = QtGui.QHBoxLayout()
|
||||||
defaultshowname_label = QtGui.QLabel("Default showname")
|
defaultshowname_label = QtGui.QLabel("Default showname")
|
||||||
self.defaultshowname = QtGui.QLineEdit()
|
self.defaultshowname = QtGui.QLineEdit()
|
||||||
defaultshowname_layout.addWidget(defaultshowname_label)
|
defaultshowname_layout.addWidget(defaultshowname_label)
|
||||||
defaultshowname_layout.addWidget(self.defaultshowname)
|
defaultshowname_layout.addWidget(self.defaultshowname)
|
||||||
|
|
||||||
allowdownload = QtGui.QLabel()
|
allowdownload = QtGui.QLabel()
|
||||||
allowdownload.setText("Automatically download or stream online from WebAO:")
|
allowdownload.setText("Automatically download or stream online from WebAO:")
|
||||||
allowdownload_layout = QtGui.QHBoxLayout()
|
allowdownload_layout = QtGui.QHBoxLayout()
|
||||||
self.allowdownload_chars = QtGui.QCheckBox("Characters")
|
self.allowdownload_chars = QtGui.QCheckBox("Characters")
|
||||||
self.allowdownload_sounds = QtGui.QCheckBox("Sounds")
|
self.allowdownload_sounds = QtGui.QCheckBox("Sounds")
|
||||||
self.allowdownload_music = QtGui.QCheckBox("Music")
|
self.allowdownload_music = QtGui.QCheckBox("Music")
|
||||||
self.allowdownload_evidence = QtGui.QCheckBox("Evidence")
|
self.allowdownload_evidence = QtGui.QCheckBox("Evidence")
|
||||||
allowdownload_layout.addWidget(self.allowdownload_chars)
|
allowdownload_layout.addWidget(self.allowdownload_chars)
|
||||||
allowdownload_layout.addWidget(self.allowdownload_sounds)
|
allowdownload_layout.addWidget(self.allowdownload_sounds)
|
||||||
allowdownload_layout.addWidget(self.allowdownload_music)
|
allowdownload_layout.addWidget(self.allowdownload_music)
|
||||||
allowdownload_layout.addWidget(self.allowdownload_evidence)
|
allowdownload_layout.addWidget(self.allowdownload_evidence)
|
||||||
|
|
||||||
currtheme_layout = QtGui.QHBoxLayout()
|
currtheme_layout = QtGui.QHBoxLayout()
|
||||||
currtheme_label = QtGui.QLabel("Current theme")
|
currtheme_label = QtGui.QLabel("Current theme")
|
||||||
self.currtheme = QtGui.QComboBox()
|
self.currtheme = QtGui.QComboBox()
|
||||||
self.themes = listdir(AO2XPpath+"ao2xp_themes")
|
self.themes = listdir(AO2XPpath+"ao2xp_themes")
|
||||||
for theme in self.themes:
|
for theme in self.themes:
|
||||||
if exists(AO2XPpath+"ao2xp_themes/"+theme+"/theme.py"):
|
if exists(AO2XPpath+"ao2xp_themes/"+theme+"/theme.py"):
|
||||||
self.currtheme.addItem(theme)
|
self.currtheme.addItem(theme)
|
||||||
currtheme_layout.addWidget(currtheme_label)
|
currtheme_layout.addWidget(currtheme_label)
|
||||||
currtheme_layout.addWidget(self.currtheme)
|
currtheme_layout.addWidget(self.currtheme)
|
||||||
|
|
||||||
|
autoconnect_layout = QtGui.QHBoxLayout()
|
||||||
|
autoconnect_label = QtGui.QLabel("Connect automatically to this server")
|
||||||
|
self.autoconnect = QtGui.QComboBox()
|
||||||
|
self.autoconnect.addItem("Always show server list")
|
||||||
|
if exists(AOpath+'serverlist.txt'):
|
||||||
|
with open(AOpath+'serverlist.txt') as file:
|
||||||
|
for server in [line.rstrip().split(':') for line in file]:
|
||||||
|
self.autoconnect.addItem(server[-1])
|
||||||
|
autoconnect_layout.addWidget(autoconnect_label)
|
||||||
|
autoconnect_layout.addWidget(self.autoconnect)
|
||||||
|
|
||||||
update_layout = QtGui.QHBoxLayout()
|
update_layout = QtGui.QHBoxLayout()
|
||||||
self.check_updates = QtGui.QCheckBox("Check for AO2XP updates on startup")
|
self.check_updates = QtGui.QCheckBox("Check for AO2XP updates on startup")
|
||||||
self.check_updates_btn = QtGui.QPushButton()
|
self.check_updates_btn = QtGui.QPushButton()
|
||||||
self.check_updates_btn.setText("Check now...")
|
self.check_updates_btn.setText("Check now...")
|
||||||
self.check_updates_btn.clicked.connect(self.onUpdateClicked)
|
self.check_updates_btn.clicked.connect(self.onUpdateClicked)
|
||||||
update_layout.addWidget(self.check_updates)
|
update_layout.addWidget(self.check_updates)
|
||||||
update_layout.addWidget(self.check_updates_btn)
|
update_layout.addWidget(self.check_updates_btn)
|
||||||
|
|
||||||
savechangeswarn = QtGui.QLabel()
|
savechangeswarn = QtGui.QLabel()
|
||||||
savechangeswarn.setText("* Change takes effect upon restarting the client")
|
savechangeswarn.setText("* Change takes effect upon restarting the client")
|
||||||
|
|
||||||
general_layout.addWidget(self.savetolog)
|
general_layout.addWidget(self.savetolog)
|
||||||
general_layout.addWidget(self.savetolog_combine, 0, QtCore.Qt.AlignRight)
|
general_layout.addWidget(self.savetolog_combine, 0, QtCore.Qt.AlignRight)
|
||||||
general_layout.addWidget(separators[0])
|
general_layout.addWidget(separators[0])
|
||||||
general_layout.addLayout(defaultoocname_layout)
|
general_layout.addLayout(defaultoocname_layout)
|
||||||
general_layout.addLayout(defaultshowname_layout)
|
general_layout.addLayout(defaultshowname_layout)
|
||||||
general_layout.addWidget(separators[1])
|
general_layout.addWidget(separators[1])
|
||||||
general_layout.addWidget(allowdownload)
|
general_layout.addWidget(allowdownload)
|
||||||
general_layout.addLayout(allowdownload_layout)
|
general_layout.addLayout(allowdownload_layout)
|
||||||
general_layout.addWidget(separators[2])
|
general_layout.addWidget(separators[2])
|
||||||
general_layout.addLayout(currtheme_layout)
|
general_layout.addLayout(currtheme_layout)
|
||||||
general_layout.addWidget(separators[3])
|
general_layout.addWidget(separators[3])
|
||||||
general_layout.addLayout(update_layout)
|
general_layout.addLayout(autoconnect_layout)
|
||||||
general_layout.addWidget(savechangeswarn, 50, QtCore.Qt.AlignBottom)
|
general_layout.addLayout(update_layout)
|
||||||
|
general_layout.addWidget(savechangeswarn, 50, QtCore.Qt.AlignBottom)
|
||||||
|
|
||||||
###### Audio tab ######
|
###### Audio tab ######
|
||||||
device_label = QtGui.QLabel("Audio device")
|
device_label = QtGui.QLabel("Audio device")
|
||||||
self.device_list = QtGui.QComboBox()
|
self.device_list = QtGui.QComboBox()
|
||||||
audio_layout.setWidget(0, QtGui.QFormLayout.LabelRole, device_label)
|
audio_layout.setWidget(0, QtGui.QFormLayout.LabelRole, device_label)
|
||||||
audio_layout.setWidget(0, QtGui.QFormLayout.FieldRole, self.device_list)
|
audio_layout.setWidget(0, QtGui.QFormLayout.FieldRole, self.device_list)
|
||||||
audio_layout.setWidget(1, QtGui.QFormLayout.FieldRole, separators[4])
|
audio_layout.setWidget(1, QtGui.QFormLayout.FieldRole, separators[4])
|
||||||
|
|
||||||
volumelabel = QtGui.QLabel("Sound volume")
|
volumelabel = QtGui.QLabel("Sound volume")
|
||||||
musiclabel = QtGui.QLabel("Music")
|
musiclabel = QtGui.QLabel("Music")
|
||||||
soundlabel = QtGui.QLabel("Sounds")
|
soundlabel = QtGui.QLabel("Sounds")
|
||||||
bliplabel = QtGui.QLabel("Blips")
|
bliplabel = QtGui.QLabel("Blips")
|
||||||
self.musicslider = QtGui.QSlider(QtCore.Qt.Horizontal, self)
|
self.musicslider = QtGui.QSlider(QtCore.Qt.Horizontal, self)
|
||||||
self.soundslider = QtGui.QSlider(QtCore.Qt.Horizontal, self)
|
self.soundslider = QtGui.QSlider(QtCore.Qt.Horizontal, self)
|
||||||
self.blipslider = QtGui.QSlider(QtCore.Qt.Horizontal, self)
|
self.blipslider = QtGui.QSlider(QtCore.Qt.Horizontal, self)
|
||||||
self.musicslider.setRange(0, 100)
|
self.musicslider.setRange(0, 100)
|
||||||
self.soundslider.setRange(0, 100)
|
self.soundslider.setRange(0, 100)
|
||||||
self.blipslider.setRange(0, 100)
|
self.blipslider.setRange(0, 100)
|
||||||
audio_layout.setWidget(2, QtGui.QFormLayout.LabelRole, musiclabel)
|
audio_layout.setWidget(2, QtGui.QFormLayout.LabelRole, musiclabel)
|
||||||
audio_layout.setWidget(2, QtGui.QFormLayout.FieldRole, self.musicslider)
|
audio_layout.setWidget(2, QtGui.QFormLayout.FieldRole, self.musicslider)
|
||||||
audio_layout.setWidget(3, QtGui.QFormLayout.LabelRole, soundlabel)
|
audio_layout.setWidget(3, QtGui.QFormLayout.LabelRole, soundlabel)
|
||||||
audio_layout.setWidget(3, QtGui.QFormLayout.FieldRole, self.soundslider)
|
audio_layout.setWidget(3, QtGui.QFormLayout.FieldRole, self.soundslider)
|
||||||
audio_layout.setWidget(4, QtGui.QFormLayout.LabelRole, bliplabel)
|
audio_layout.setWidget(4, QtGui.QFormLayout.LabelRole, bliplabel)
|
||||||
audio_layout.setWidget(4, QtGui.QFormLayout.FieldRole, self.blipslider)
|
audio_layout.setWidget(4, QtGui.QFormLayout.FieldRole, self.blipslider)
|
||||||
|
|
||||||
self.reloadaudio = QtGui.QPushButton(text="Reload audio system")
|
self.reloadaudio = QtGui.QPushButton(text="Reload audio system")
|
||||||
self.reloadaudio.clicked.connect(self.onReloadAudio)
|
self.reloadaudio.clicked.connect(self.onReloadAudio)
|
||||||
audio_layout.setWidget(5, QtGui.QFormLayout.FieldRole, self.reloadaudio)
|
audio_layout.setWidget(5, QtGui.QFormLayout.FieldRole, self.reloadaudio)
|
||||||
|
|
||||||
for device in audio.getdevices():
|
for device in audio.getdevices():
|
||||||
self.device_list.addItem(device)
|
self.device_list.addItem(device)
|
||||||
|
|
||||||
###### Callwords tab ######
|
###### Callwords tab ######
|
||||||
self.callwords_edit = QtGui.QTextEdit()
|
self.callwords_edit = QtGui.QTextEdit()
|
||||||
|
|
||||||
callwords_wordwrap = QtGui.QCheckBox("Word Wrap")
|
callwords_wordwrap = QtGui.QCheckBox("Word Wrap")
|
||||||
callwords_wordwrap.setChecked(True)
|
callwords_wordwrap.setChecked(True)
|
||||||
callwords_wordwrap.stateChanged.connect(self.callwordsWordWrapCheckbox)
|
callwords_wordwrap.stateChanged.connect(self.callwordsWordWrapCheckbox)
|
||||||
|
|
||||||
callwords_instructions = QtGui.QLabel()
|
callwords_instructions = QtGui.QLabel()
|
||||||
callwords_instructions.setText("Separate callwords with newlines (ENTER key).")
|
callwords_instructions.setText("Separate callwords with newlines (ENTER key).")
|
||||||
|
|
||||||
callwords_layout.addWidget(self.callwords_edit)
|
callwords_layout.addWidget(self.callwords_edit)
|
||||||
callwords_layout.addWidget(callwords_wordwrap, 0, QtCore.Qt.AlignRight)
|
callwords_layout.addWidget(callwords_wordwrap, 0, QtCore.Qt.AlignRight)
|
||||||
callwords_layout.addWidget(callwords_instructions)
|
callwords_layout.addWidget(callwords_instructions)
|
||||||
|
|
||||||
self.tabs.addTab(general_tab, "General")
|
self.tabs.addTab(general_tab, "General")
|
||||||
self.tabs.addTab(audio_tab, "Audio")
|
self.tabs.addTab(audio_tab, "Audio")
|
||||||
self.tabs.addTab(callwords_tab, "Callwords")
|
self.tabs.addTab(callwords_tab, "Callwords")
|
||||||
|
|
||||||
save_layout.addWidget(savebtn, 100, QtCore.Qt.AlignRight)
|
save_layout.addWidget(savebtn, 100, QtCore.Qt.AlignRight)
|
||||||
save_layout.addWidget(cancelbtn, 0, QtCore.Qt.AlignRight)
|
save_layout.addWidget(cancelbtn, 0, QtCore.Qt.AlignRight)
|
||||||
main_layout.addWidget(self.tabs)
|
main_layout.addWidget(self.tabs)
|
||||||
main_layout.addLayout(save_layout)
|
main_layout.addLayout(save_layout)
|
||||||
|
|
||||||
def showSettings(self):
|
def showSettings(self):
|
||||||
if exists("AO2XP.ini"):
|
if exists("AO2XP.ini"):
|
||||||
self.inifile.read("AO2XP.ini")
|
self.inifile.read("AO2XP.ini")
|
||||||
self.savetolog.setChecked(ini.read_ini_bool(self.inifile, "General", "save logs"))
|
self.savetolog.setChecked(ini.read_ini_bool(self.inifile, "General", "save logs"))
|
||||||
self.savetolog_combine.setChecked(ini.read_ini_bool(self.inifile, "General", "combined logs"))
|
self.savetolog_combine.setChecked(ini.read_ini_bool(self.inifile, "General", "combined logs"))
|
||||||
try:
|
try:
|
||||||
self.defaultoocname.setText(ini.read_ini(self.inifile, "General", "OOC name").decode("utf-8"))
|
self.defaultoocname.setText(ini.read_ini(self.inifile, "General", "OOC name").decode("utf-8"))
|
||||||
except:
|
except:
|
||||||
self.defaultoocname.setText(ini.read_ini(self.inifile, "General", "OOC name"))
|
self.defaultoocname.setText(ini.read_ini(self.inifile, "General", "OOC name"))
|
||||||
try:
|
try:
|
||||||
self.defaultshowname.setText(ini.read_ini(self.inifile, "General", "showname").decode("utf-8"))
|
self.defaultshowname.setText(ini.read_ini(self.inifile, "General", "showname").decode("utf-8"))
|
||||||
except:
|
except:
|
||||||
self.defaultshowname.setText(ini.read_ini(self.inifile, "General", "showname"))
|
self.defaultshowname.setText(ini.read_ini(self.inifile, "General", "showname"))
|
||||||
self.allowdownload_chars.setChecked(ini.read_ini_bool(self.inifile, "General", "download characters"))
|
self.allowdownload_chars.setChecked(ini.read_ini_bool(self.inifile, "General", "download characters"))
|
||||||
self.allowdownload_sounds.setChecked(ini.read_ini_bool(self.inifile, "General", "download sounds"))
|
self.allowdownload_sounds.setChecked(ini.read_ini_bool(self.inifile, "General", "download sounds"))
|
||||||
self.allowdownload_music.setChecked(ini.read_ini_bool(self.inifile, "General", "download music"))
|
self.allowdownload_music.setChecked(ini.read_ini_bool(self.inifile, "General", "download music"))
|
||||||
self.allowdownload_evidence.setChecked(ini.read_ini_bool(self.inifile, "General", "download evidence"))
|
self.allowdownload_evidence.setChecked(ini.read_ini_bool(self.inifile, "General", "download evidence"))
|
||||||
self.currtheme.setCurrentIndex(self.themes.index(ini.read_ini(self.inifile, "General", "theme", "default")))
|
self.currtheme.setCurrentIndex(self.themes.index(ini.read_ini(self.inifile, "General", "theme", "default")))
|
||||||
self.check_updates.setChecked(ini.read_ini_bool(self.inifile, "General", "install updates", True))
|
self.autoconnect.setCurrentIndex(ini.read_ini_int(self.inifile, "General", "auto connect", -1) + 1)
|
||||||
|
self.check_updates.setChecked(ini.read_ini_bool(self.inifile, "General", "install updates", True))
|
||||||
|
|
||||||
self.device_list.setCurrentIndex(ini.read_ini_int(self.inifile, "Audio", "device", audio.getcurrdevice()))
|
self.device_list.setCurrentIndex(ini.read_ini_int(self.inifile, "Audio", "device", audio.getcurrdevice()))
|
||||||
self.musicslider.setValue(ini.read_ini_int(self.inifile, "Audio", "Music volume", 100))
|
self.musicslider.setValue(ini.read_ini_int(self.inifile, "Audio", "Music volume", 100))
|
||||||
self.soundslider.setValue(ini.read_ini_int(self.inifile, "Audio", "Sound volume", 100))
|
self.soundslider.setValue(ini.read_ini_int(self.inifile, "Audio", "Sound volume", 100))
|
||||||
self.blipslider.setValue(ini.read_ini_int(self.inifile, "Audio", "Blip volume", 100))
|
self.blipslider.setValue(ini.read_ini_int(self.inifile, "Audio", "Blip volume", 100))
|
||||||
else:
|
else:
|
||||||
self.savetolog.setChecked(False)
|
self.savetolog.setChecked(False)
|
||||||
self.savetolog_combine.setChecked(False)
|
self.savetolog_combine.setChecked(False)
|
||||||
self.defaultoocname.setText("")
|
self.defaultoocname.setText("")
|
||||||
self.defaultshowname.setText("")
|
self.defaultshowname.setText("")
|
||||||
self.allowdownload_sounds.setChecked(True)
|
self.allowdownload_sounds.setChecked(True)
|
||||||
self.allowdownload_music.setChecked(True)
|
self.allowdownload_music.setChecked(True)
|
||||||
self.allowdownload_evidence.setChecked(True)
|
self.allowdownload_evidence.setChecked(True)
|
||||||
self.currtheme.setCurrentIndex(self.themes.index("default"))
|
self.currtheme.setCurrentIndex(self.themes.index("default"))
|
||||||
self.check_updates.setChecked(True)
|
self.check_updates.setChecked(True)
|
||||||
|
|
||||||
self.device_list.setCurrentIndex(audio.getcurrdevice())
|
self.device_list.setCurrentIndex(audio.getcurrdevice())
|
||||||
self.musicslider.setValue(100)
|
self.musicslider.setValue(100)
|
||||||
self.soundslider.setValue(100)
|
self.soundslider.setValue(100)
|
||||||
self.blipslider.setValue(100)
|
self.blipslider.setValue(100)
|
||||||
|
|
||||||
self.callwords_edit.clear()
|
self.callwords_edit.clear()
|
||||||
if exists(AO2XPpath+"callwords.ini"):
|
if exists(AO2XPpath+"callwords.ini"):
|
||||||
with open(AO2XPpath+"callwords.ini") as f:
|
with open(AO2XPpath+"callwords.ini") as f:
|
||||||
for line in f:
|
for line in f:
|
||||||
self.callwords_edit.append(line.rstrip().decode("utf-8"))
|
self.callwords_edit.append(line.rstrip().decode("utf-8"))
|
||||||
|
|
||||||
self.tabs.setCurrentIndex(0)
|
self.tabs.setCurrentIndex(0)
|
||||||
self.show()
|
self.show()
|
||||||
|
|
||||||
def callwordsWordWrapCheckbox(self, newstate):
|
def callwordsWordWrapCheckbox(self, newstate):
|
||||||
if newstate:
|
if newstate:
|
||||||
self.callwords_edit.setWordWrapMode(QtGui.QTextOption.WrapAtWordBoundaryOrAnywhere)
|
self.callwords_edit.setWordWrapMode(QtGui.QTextOption.WrapAtWordBoundaryOrAnywhere)
|
||||||
else:
|
else:
|
||||||
self.callwords_edit.setWordWrapMode(0)
|
self.callwords_edit.setWordWrapMode(0)
|
||||||
|
|
||||||
def onSaveClicked(self):
|
def onSaveClicked(self):
|
||||||
if not self.inifile.has_section("General"): self.inifile.add_section("General")
|
if not self.inifile.has_section("General"): self.inifile.add_section("General")
|
||||||
if not self.inifile.has_section("Audio"): self.inifile.add_section("Audio")
|
if not self.inifile.has_section("Audio"): self.inifile.add_section("Audio")
|
||||||
self.inifile.set("General", "save logs", self.savetolog.isChecked())
|
self.inifile.set("General", "save logs", self.savetolog.isChecked())
|
||||||
self.inifile.set("General", "combined logs", self.savetolog_combine.isChecked())
|
self.inifile.set("General", "combined logs", self.savetolog_combine.isChecked())
|
||||||
self.inifile.set("General", "OOC name", self.defaultoocname.text().toUtf8())
|
self.inifile.set("General", "OOC name", self.defaultoocname.text().toUtf8())
|
||||||
self.inifile.set("General", "showname", self.defaultshowname.text().toUtf8())
|
self.inifile.set("General", "showname", self.defaultshowname.text().toUtf8())
|
||||||
self.inifile.set("General", "download characters", self.allowdownload_chars.isChecked())
|
self.inifile.set("General", "download characters", self.allowdownload_chars.isChecked())
|
||||||
self.inifile.set("General", "download sounds", self.allowdownload_sounds.isChecked())
|
self.inifile.set("General", "download sounds", self.allowdownload_sounds.isChecked())
|
||||||
self.inifile.set("General", "download music", self.allowdownload_music.isChecked())
|
self.inifile.set("General", "download music", self.allowdownload_music.isChecked())
|
||||||
self.inifile.set("General", "download evidence", self.allowdownload_evidence.isChecked())
|
self.inifile.set("General", "download evidence", self.allowdownload_evidence.isChecked())
|
||||||
self.inifile.set("General", "theme", self.currtheme.currentText())
|
self.inifile.set("General", "theme", self.currtheme.currentText())
|
||||||
self.inifile.set("General", "install updates", self.check_updates.isChecked())
|
self.inifile.set("General", "auto connect", self.autoconnect.currentIndex() - 1)
|
||||||
|
self.inifile.set("General", "install updates", self.check_updates.isChecked())
|
||||||
|
|
||||||
self.inifile.set("Audio", "device", self.device_list.currentIndex())
|
self.inifile.set("Audio", "device", self.device_list.currentIndex())
|
||||||
self.inifile.set("Audio", "Music volume", self.musicslider.value())
|
self.inifile.set("Audio", "Music volume", self.musicslider.value())
|
||||||
self.inifile.set("Audio", "Sound volume", self.soundslider.value())
|
self.inifile.set("Audio", "Sound volume", self.soundslider.value())
|
||||||
self.inifile.set("Audio", "Blip volume", self.blipslider.value())
|
self.inifile.set("Audio", "Blip volume", self.blipslider.value())
|
||||||
|
|
||||||
self.inifile.write(open("AO2XP.ini", "w"))
|
self.inifile.write(open("AO2XP.ini", "w"))
|
||||||
|
|
||||||
with open(AO2XPpath+"callwords.ini", "w") as f:
|
with open(AO2XPpath+"callwords.ini", "w") as f:
|
||||||
f.write(self.callwords_edit.toPlainText().toUtf8())
|
f.write(self.callwords_edit.toPlainText().toUtf8())
|
||||||
|
|
||||||
self.hide()
|
self.hide()
|
||||||
|
|
||||||
def onCancelClicked(self):
|
def onCancelClicked(self):
|
||||||
self.hide()
|
self.hide()
|
||||||
|
|
||||||
def onUpdateClicked(self):
|
def onUpdateClicked(self):
|
||||||
import updater
|
import updater
|
||||||
code = updater.checkForUpdates()
|
code = updater.checkForUpdates()
|
||||||
if code == 0:
|
if code == 0:
|
||||||
subprocess.Popen(["./AO2XPupdat"])
|
subprocess.Popen(["./AO2XPupdat"])
|
||||||
_exit(0)
|
_exit(0)
|
||||||
elif osname == "Darwin": # bundle
|
elif osname == "Darwin": # bundle
|
||||||
os.chdir(Cocoa.NSBundle.mainBundle().resourcePath()) # return to Resources folder
|
os.chdir(Cocoa.NSBundle.mainBundle().resourcePath()) # return to Resources folder
|
||||||
|
|
||||||
def onReloadAudio(self):
|
def onReloadAudio(self):
|
||||||
audio.free()
|
audio.free()
|
||||||
audio.init()
|
audio.init()
|
||||||
print "reloaded audio"
|
print "reloaded audio"
|
Loading…
Reference in New Issue
Block a user