Esempio n. 1
0
    def __init__(self, argv=[]):
        super(AIOApplication, self).__init__(argv)

        self.tcpthread = ClientThread()
        self.udpthread = UDPThread()
        self.udpthread.start()

        self.musicvol = ini.read_ini_int("aaio.ini", "Audio", "Music volume",
                                         100)
        self.sndvol = ini.read_ini_int("aaio.ini", "Audio", "Sound volume",
                                       100)
        self.blipvol = ini.read_ini_int("aaio.ini", "Audio", "Blip volume",
                                        100)
        self.fps = 60 if ini.read_ini_bool("aaio.ini", "General", "High FPS",
                                           True) else 30

        self.mainwindow = AIOMainWindow(self)
        self.mainwindow.show()
Esempio n. 2
0
def init(freq=48000):
    """
Initialize BASS and the opus plugin
    """
    global dll, use_ctypes
    if not dll:
        if platform.system() == "Darwin":
            dll = ctypes.CDLL(dllf)
            use_ctypes = True
        else:
            import pybass as dll

    dll.BASS_Init(ini.read_ini_int("aaio.ini", "Audio", "device", -1), freq, 0,
                  0, 0)
    dll.BASS_PluginLoad(os.path.abspath(opus), 0)
Esempio n. 3
0
    def showSettings(self):
        self.show()

        if os.path.exists("aaio.ini"):
            self.inifile.read("aaio.ini")
            try:
                self.defaultoocname.setText(
                    ini.read_ini("aaio.ini", "General",
                                 "OOC name").decode("utf-8"))
            except:
                self.defaultoocname.setText(
                    ini.read_ini("aaio.ini", "General", "OOC name"))

            chatbox_ind = self.chatboximage_dropdown.findText(
                ini.read_ini("aaio.ini", "General", "Chatbox image"))
            if chatbox_ind > 0:
                self.chatboximage_dropdown.setCurrentIndex(chatbox_ind)

            self.ms_lineedit.setText(
                ini.read_ini("aaio.ini", "MasterServer", "IP"))
            self.device_list.setCurrentIndex(
                ini.read_ini_int("aaio.ini", "Audio", "Device",
                                 BASS_GetDevice()))
            self.musicslider.setValue(
                ini.read_ini_int("aaio.ini", "Audio", "Music volume", 100))
            self.soundslider.setValue(
                ini.read_ini_int("aaio.ini", "Audio", "Sound volume", 100))
            self.blipslider.setValue(
                ini.read_ini_int("aaio.ini", "Audio", "Blip volume", 100))

            self.up_buttons[0].setText(
                getControlName(
                    ini.read_ini_int("aaio.ini", "Controls", "up1",
                                     QtCore.Qt.Key_W)))
            self.up_buttons[1].setText(
                getControlName(
                    ini.read_ini_int("aaio.ini", "Controls", "up2",
                                     QtCore.Qt.Key_Up)))
            self.down_buttons[0].setText(
                getControlName(
                    ini.read_ini_int("aaio.ini", "Controls", "down1",
                                     QtCore.Qt.Key_S)))
            self.down_buttons[1].setText(
                getControlName(
                    ini.read_ini_int("aaio.ini", "Controls", "down2",
                                     QtCore.Qt.Key_Down)))
            self.left_buttons[0].setText(
                getControlName(
                    ini.read_ini_int("aaio.ini", "Controls", "left1",
                                     QtCore.Qt.Key_A)))
            self.left_buttons[1].setText(
                getControlName(
                    ini.read_ini_int("aaio.ini", "Controls", "left2",
                                     QtCore.Qt.Key_Left)))
            self.right_buttons[0].setText(
                getControlName(
                    ini.read_ini_int("aaio.ini", "Controls", "right1",
                                     QtCore.Qt.Key_D)))
            self.right_buttons[1].setText(
                getControlName(
                    ini.read_ini_int("aaio.ini", "Controls", "right2",
                                     QtCore.Qt.Key_Right)))
            self.run_button.setText(
                getControlName(
                    ini.read_ini_int("aaio.ini", "Controls", "run",
                                     QtCore.Qt.Key_Shift)))

        else:
            self.defaultoocname.setText("")
            self.chatboximage_dropdown.setCurrentIndex(0)
            self.ms_lineedit.setText("aaio-ms.aceattorneyonline.com:27011")
            self.device_list.setCurrentIndex(BASS_GetDevice())
            self.musicslider.setValue(100)
            self.soundslider.setValue(100)
            self.blipslider.setValue(100)

            self.up_buttons[0].setText("Key_W")
            self.up_buttons[1].setText("Key_Up")
            self.down_buttons[0].setText("Key_S")
            self.down_buttons[1].setText("Key_Down")
            self.left_buttons[0].setText("Key_A")
            self.left_buttons[1].setText("Key_Left")
            self.right_buttons[0].setText("Key_D")
            self.right_buttons[1].setText("Key_Right")
            self.run_button.setText("Key_Shift")

        self.tabs.setCurrentIndex(0)
        self.show()
Esempio n. 4
0
    def __init__(self, ao_app):
        super(Options, self).__init__()
        self.ao_app = ao_app

        self.inifile = ConfigParser()
        self.setWindowTitle("Settings")
        self.setFixedSize(400, 400)
        self.hide()

        main_layout = QtGui.QVBoxLayout(self)
        save_layout = QtGui.QHBoxLayout()

        self.tabs = QtGui.QTabWidget()
        self.tabs.resize(320 - 16, 480 - 40)
        self.tabs.move(8, 8)

        general_tab = QtGui.QWidget()
        controls_tab = QtGui.QWidget()
        audio_tab = QtGui.QWidget()
        advanced_tab = QtGui.QWidget()
        general_layout = QtGui.QVBoxLayout(general_tab)
        general_layout.setAlignment(QtCore.Qt.AlignTop)
        controls_layout = QtGui.QVBoxLayout(controls_tab)
        controls_layout.setAlignment(QtCore.Qt.AlignTop)
        audio_layout = QtGui.QFormLayout(audio_tab)
        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.setContentsMargins(0, 0, 0, 0)
        advanced_layout = QtGui.QVBoxLayout(advanced_tab)
        advanced_layout.setAlignment(QtCore.Qt.AlignTop)

        savebtn = QtGui.QPushButton()
        savebtn.setText("Save")
        savebtn.clicked.connect(self.onSaveClicked)
        cancelbtn = QtGui.QPushButton()
        cancelbtn.setText("Cancel")
        cancelbtn.clicked.connect(self.onCancelClicked)

        separators = []
        for i in range(2):  # increase if needed
            separator = QtGui.QFrame()
            separator.setFixedSize(separator.size().width(), 16)
            separators.append(separator)

        ###### General tab ######
        defaultoocname_layout = QtGui.QHBoxLayout()
        defaultoocname_label = QtGui.QLabel("Default OOC name")
        self.defaultoocname = QtGui.QLineEdit()
        defaultoocname_layout.addWidget(defaultoocname_label)
        defaultoocname_layout.addWidget(self.defaultoocname)

        chatboximage_layout = QtGui.QHBoxLayout()
        chatboximage_label = QtGui.QLabel("Chatbox image")
        self.chatboximage_dropdown = QtGui.QComboBox()
        self.chatboximage_dropdown.currentIndexChanged.connect(
            self.onChangeChatbox)
        chatboximage_layout.addWidget(chatboximage_label)
        chatboximage_layout.addWidget(self.chatboximage_dropdown)

        self.chatboximage = QtGui.QLabel()

        for file in os.listdir("data/misc/"):
            if file.lower().startswith("chatbox_") and file.lower().endswith(
                    ".png"):
                self.chatboximage_dropdown.addItem(file)

        #savechangeswarn = QtGui.QLabel()
        #savechangeswarn.setText("* Change takes effect upon restarting the client")

        general_layout.addLayout(defaultoocname_layout)
        general_layout.addWidget(separators[0])
        general_layout.addLayout(chatboximage_layout)
        general_layout.addWidget(self.chatboximage, 0, QtCore.Qt.AlignCenter)
        #general_layout.addWidget(savechangeswarn, 50, QtCore.Qt.AlignBottom)

        ###### Controls tab ######
        self.changingBind = [
        ]  # [pushbutton object, control name, control index]

        up_layout = QtGui.QHBoxLayout()
        down_layout = QtGui.QHBoxLayout()
        left_layout = QtGui.QHBoxLayout()
        right_layout = QtGui.QHBoxLayout()
        run_layout = QtGui.QHBoxLayout()
        up_label = QtGui.QLabel("Up")
        down_label = QtGui.QLabel("Down")
        left_label = QtGui.QLabel("Left")
        right_label = QtGui.QLabel("Right")
        run_label = QtGui.QLabel("Run")
        self.up_buttons = [QtGui.QPushButton(), QtGui.QPushButton()]
        self.down_buttons = [QtGui.QPushButton(), QtGui.QPushButton()]
        self.left_buttons = [QtGui.QPushButton(), QtGui.QPushButton()]
        self.right_buttons = [QtGui.QPushButton(), QtGui.QPushButton()]
        self.run_button = QtGui.QPushButton()

        for b in self.up_buttons:
            b.clicked.connect(
                partial(self.changeBind, b, "up", self.up_buttons.index(b)))
        for b in self.down_buttons:
            b.clicked.connect(
                partial(self.changeBind, b, "down",
                        self.down_buttons.index(b)))
        for b in self.left_buttons:
            b.clicked.connect(
                partial(self.changeBind, b, "left",
                        self.left_buttons.index(b)))
        for b in self.right_buttons:
            b.clicked.connect(
                partial(self.changeBind, b, "right",
                        self.right_buttons.index(b)))
        self.run_button.clicked.connect(
            partial(self.changeBind, self.run_button, "run", 0))

        for i in range(len(self.up_buttons)):
            ao_app.controls["up"][i] = ini.read_ini_int(
                "aaio.ini", "Controls", "up%d" % (i + 1),
                ao_app.controls["up"][i])
        for i in range(len(self.down_buttons)):
            ao_app.controls["down"][i] = ini.read_ini_int(
                "aaio.ini", "Controls", "down%d" % (i + 1),
                ao_app.controls["down"][i])
        for i in range(len(self.left_buttons)):
            ao_app.controls["left"][i] = ini.read_ini_int(
                "aaio.ini", "Controls", "left%d" % (i + 1),
                ao_app.controls["left"][i])
        for i in range(len(self.right_buttons)):
            ao_app.controls["right"][i] = ini.read_ini_int(
                "aaio.ini", "Controls", "right%d" % (i + 1),
                ao_app.controls["right"][i])
        ao_app.controls["run"][0] = ini.read_ini_int("aaio.ini", "Controls",
                                                     "run",
                                                     ao_app.controls["run"][0])

        up_layout.addWidget(up_label)
        for b in self.up_buttons:
            up_layout.addWidget(b)
        down_layout.addWidget(down_label)
        for b in self.down_buttons:
            down_layout.addWidget(b)
        left_layout.addWidget(left_label)
        for b in self.left_buttons:
            left_layout.addWidget(b)
        right_layout.addWidget(right_label)
        for b in self.right_buttons:
            right_layout.addWidget(b)
        run_layout.addWidget(run_label)
        run_layout.addWidget(self.run_button)

        controls_layout.addLayout(up_layout)
        controls_layout.addLayout(down_layout)
        controls_layout.addLayout(left_layout)
        controls_layout.addLayout(right_layout)
        controls_layout.addLayout(run_layout)

        ###### Audio tab ######
        device_label = QtGui.QLabel("Audio device")
        self.device_list = QtGui.QComboBox()
        audio_layout.setWidget(0, QtGui.QFormLayout.LabelRole, device_label)
        audio_layout.setWidget(0, QtGui.QFormLayout.FieldRole,
                               self.device_list)

        audio_layout.setWidget(1, QtGui.QFormLayout.FieldRole, separators[1])

        volumelabel = QtGui.QLabel("Sound volume")
        musiclabel = QtGui.QLabel("Music")
        soundlabel = QtGui.QLabel("Sounds")
        bliplabel = QtGui.QLabel("Blips")
        self.musicslider = QtGui.QSlider(QtCore.Qt.Horizontal, self)
        self.soundslider = QtGui.QSlider(QtCore.Qt.Horizontal, self)
        self.blipslider = QtGui.QSlider(QtCore.Qt.Horizontal, self)
        self.musicslider.setRange(0, 100)
        self.soundslider.setRange(0, 100)
        self.blipslider.setRange(0, 100)
        audio_layout.setWidget(2, QtGui.QFormLayout.LabelRole, musiclabel)
        audio_layout.setWidget(2, QtGui.QFormLayout.FieldRole,
                               self.musicslider)
        audio_layout.setWidget(3, QtGui.QFormLayout.LabelRole, soundlabel)
        audio_layout.setWidget(3, QtGui.QFormLayout.FieldRole,
                               self.soundslider)
        audio_layout.setWidget(4, QtGui.QFormLayout.LabelRole, bliplabel)
        audio_layout.setWidget(4, QtGui.QFormLayout.FieldRole, self.blipslider)

        info = BASS_DEVICEINFO()
        ind = 0
        while BASS_GetDeviceInfo(ind, info):
            self.device_list.addItem(info.name)
            ind += 1

        ###### Advanced tab ######
        ms_layout = QtGui.QHBoxLayout()
        ms_label = QtGui.QLabel("MasterServer IP")
        self.ms_lineedit = QtGui.QLineEdit()

        ms_layout.addWidget(ms_label)
        ms_layout.addWidget(self.ms_lineedit)

        advanced_layout.addLayout(ms_layout)

        self.tabs.addTab(general_tab, "General")
        self.tabs.addTab(controls_tab, "Controls")
        self.tabs.addTab(audio_tab, "Audio")
        self.tabs.addTab(advanced_tab, "Advanced")

        save_layout.addWidget(savebtn, 100, QtCore.Qt.AlignRight)
        save_layout.addWidget(cancelbtn, 0, QtCore.Qt.AlignRight)
        main_layout.addWidget(self.tabs)
        main_layout.addLayout(save_layout)

        ao_app.installEventFilter(self)
Esempio n. 5
0
def downloadChar(name):
    mirrors = ["http://s3.wasabisys.com/webao/base/characters/",
            "http://s3.wasabisys.com/aov-webao/base/characters/",
            "http://s3.us-west-1.wasabisys.com/vanilla-assets/base/characters/"]
    
    for mirror in mirrors:
        print("trying "+mirror+name.lower()+"/"+"... ")
        a = requests.get(mirror+name.lower()+"/"+"char.ini")
        if not a.ok:
            print("ERROR")
            continue
        else:
            print("character exists on site")
            if not os.path.exists("base/characters/"+name): os.mkdir("base/characters/"+name)
            if not os.path.exists("base/characters/"+name+"/emotions"): os.mkdir("base/characters/"+name+"/emotions")
            open("base/characters/"+name+"/char.ini", "wb").write(a.content)
            open("ini.ini", "wb").write(a.content)
            
            total_emotes = ini.read_ini_int("ini.ini", "emotions", "number")
            print("%d total emotes" % total_emotes)
            for i in range(total_emotes):
                sound = ini.read_ini("ini.ini", "soundn", str(i+1), "1")
                emote = ini.read_ini("ini.ini", "emotions", str(i+1)).split("#")
                emotepre = emote[1]
                emoteanim = emote[2]

                if sound and sound != "1" and sound != "0" and sound != "-" and not os.path.exists("base/sounds/general/"+sound+".wav"):
                    print("[%d]" % (i+1), "attempting to download sound "+sound+"... ")
                    urlsound = requests.get(mirror+"sounds/general/"+sound.lower()+".wav")
                    if urlsound.ok:
                        print("OK!")
                        open("base/sounds/general/"+sound+".wav", "wb").write(urlsound.content)
                    else:
                        print("ERROR")

                if emotepre != "-":
                    download_missing_emote(mirror,name,"",emotepre,"gif")
                
                download_missing_emote(mirror,name,"(a)",emoteanim,"gif")
                download_missing_emote(mirror,name,"(b)",emoteanim,"gif")

                download_missing_emote(mirror,name,"",emoteanim,"png")

                if not os.path.exists("base/characters/"+name+"/emotions/button%d_off.png" % (i+1)):
                    button_off = requests.get(mirror+name.lower()+"/"+"emotions/button%d_off.png" % (i+1))
                    if button_off.ok:
                        print("[%d]" % (i+1), "downloaded button%d_off.png" % (i+1))
                        open("base/characters/"+name+"/emotions/button%d_off.png" % (i+1), "wb").write(button_off.content)

                if not os.path.exists("base/characters/"+name+"/emotions/button%d_on.png" % (i+1)):
                    button_on = requests.get(mirror+name.lower()+"emotions/button%d_on.png" % (i+1))
                    if button_on.ok:
                        print("[%d]" % (i+1), "downloaded button%d_on.png" % (i+1))
                        open("base/characters/"+name+"/emotions/button%d_on.png" % (i+1), "wb").write(button_on.content)

            char_icon = requests.get(mirror+name.lower()+"char_icon.png")
            if char_icon.ok:
                print("downloaded char_icon.png")
                open("base/characters/"+name+"/char_icon.png", "wb").write(char_icon.content)
            objection = requests.get(mirror+name.lower()+"objection.wav")
            if objection.ok:
                print("downloaded objection.wav")
                open("base/characters/"+name+"/objection.wav", "wb").write(objection.content)
            holdit = requests.get(mirror+name.lower()+"holdit.wav")
            if holdit.ok:
                print("downloaded holdit.wav")
                open("base/characters/"+name+"/holdit.wav", "wb").write(holdit.content)
            takethat = requests.get(mirror+name.lower()+"takethat.wav")
            if takethat.ok:
                print("downloaded takethat.wav")
                open("base/characters/"+name+"/takethat.wav", "wb").write(takethat.content)
            custom_gif = requests.get(mirror+name.lower()+"custom.gif")
            custom_wav = requests.get(mirror+name.lower()+"custom.wav")
            if custom_gif.ok:
                print("downloaded custom.gif")
                open("base/characters/"+name+"/custom.gif", "wb").write(custom_gif.content)
            if custom_wav.ok:
                print("downloaded custom.wav")
                open("base/characters/"+name+"/custom.wav", "wb").write(custom_wav.content)
            print("finished downloading character "+name)
            return
Esempio n. 6
0
from PyQt4 import QtCore, QtGui
from os import path
import ctypes, ini, sys

if not path.exists("bass.dll"):
	ctypes.windll.user32.MessageBoxA(0, "bass.dll is missing on the game folder.\nthis file is required for audio playback.\ndid you extract all the game files correctly?", "unable to launch game", 0)
	sys.exit(1)
from pybass import *

from AIOApplication import AIOApplication

if not path.exists("data"):
	ctypes.windll.user32.MessageBoxA(0, "the folder named \"data\" could not be found.\ndid you extract all the game files properly? the folder \"data\" must be situated in the same folder as the game.", "unable to launch game", 0) #if you're using linux, then i'm sorry, but not yet. just use wine for the time being
	sys.exit(1)

device = ini.read_ini_int("aaio.ini", "Audio", "Device", -1)

if not BASS_Init(device, 44100, 0, 0, 0):
	sys.exit(1)

app = AIOApplication(sys.argv)
app.setWindowIcon(QtGui.QIcon("icon.ico"))
app.exec_()
BASS_Free()
Esempio n. 7
0
    def showSettings(self):
        if exists("AO2XP.ini"):
            self.inifile.read("AO2XP.ini")
            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"))
            try:
                self.defaultoocname.setText(
                    ini.read_ini(self.inifile, "General",
                                 "OOC name").decode("utf-8"))
            except:
                self.defaultoocname.setText(
                    ini.read_ini(self.inifile, "General", "OOC name"))
            try:
                self.defaultshowname.setText(
                    ini.read_ini(self.inifile, "General",
                                 "showname").decode("utf-8"))
            except:
                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_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_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.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.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.blipslider.setValue(
                ini.read_ini_int(self.inifile, "Audio", "Blip volume", 100))
        else:
            self.savetolog.setChecked(False)
            self.savetolog_combine.setChecked(False)
            self.defaultoocname.setText("")
            self.defaultshowname.setText("")
            self.allowdownload_sounds.setChecked(True)
            self.allowdownload_music.setChecked(True)
            self.allowdownload_evidence.setChecked(True)
            self.currtheme.setCurrentIndex(self.themes.index("default"))
            self.check_updates.setChecked(True)

            self.device_list.setCurrentIndex(audio.getcurrdevice())
            self.musicslider.setValue(100)
            self.soundslider.setValue(100)
            self.blipslider.setValue(100)

        self.callwords_edit.clear()
        if exists(AO2XPpath + "callwords.ini"):
            with open(AO2XPpath + "callwords.ini") as f:
                for line in f:
                    self.callwords_edit.append(line.rstrip().decode("utf-8"))

        self.tabs.setCurrentIndex(0)
        self.show()
Esempio n. 8
0
    def __init__(self, ao_app):
        super(Options, self).__init__()
        self.ao_app = ao_app

        self.inifile = ConfigParser()
        self.setWindowTitle("Settings")
        self.setFixedSize(400, 400)

        main_layout = QtGui.QVBoxLayout(self)
        save_layout = QtGui.QHBoxLayout()

        self.tabs = QtGui.QTabWidget()
        self.tabs.resize(320 - 16, 480 - 40)
        self.tabs.move(8, 8)

        general_tab = QtGui.QWidget()
        controls_tab = QtGui.QWidget()
        audio_tab = QtGui.QWidget()
        theme_tab = QtGui.QWidget()
        advanced_tab = QtGui.QWidget()
        general_layout = QtGui.QVBoxLayout(general_tab)
        general_layout.setAlignment(QtCore.Qt.AlignTop)
        controls_layout = QtGui.QVBoxLayout(controls_tab)
        controls_layout.setAlignment(QtCore.Qt.AlignTop)
        audio_layout = QtGui.QFormLayout(audio_tab)
        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.setContentsMargins(0, 0, 0, 0)
        theme_layout = QtGui.QVBoxLayout(theme_tab)
        theme_layout.setAlignment(QtCore.Qt.AlignTop)
        advanced_layout = QtGui.QVBoxLayout(advanced_tab)
        advanced_layout.setAlignment(QtCore.Qt.AlignTop)

        savebtn = QtGui.QPushButton()
        savebtn.setText("Save")
        savebtn.clicked.connect(self.onSaveClicked)
        cancelbtn = QtGui.QPushButton()
        cancelbtn.setText("Cancel")
        cancelbtn.clicked.connect(self.onCancelClicked)

        separators = []
        for i in range(2):  # increase if needed
            separator = QtGui.QFrame()
            separator.setFixedSize(separator.size().width(), 16)
            separators.append(separator)

        ###### General tab ######
        defaultoocname_layout = QtGui.QHBoxLayout()
        defaultoocname_label = QtGui.QLabel("Default OOC name")
        self.defaultoocname = QtGui.QLineEdit()
        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)

        #savechangeswarn = QtGui.QLabel()
        #savechangeswarn.setText("* Change takes effect upon restarting the client")

        general_layout.addLayout(defaultoocname_layout)
        general_layout.addLayout(defaultshowname_layout)
        #general_layout.addWidget(separators[0])
        #general_layout.addWidget(savechangeswarn, 50, QtCore.Qt.AlignBottom)

        ###### Theme tab ######
        themeview_layout = QtGui.QHBoxLayout()
        self.themeview = QtGui.QListWidget()
        #self.themeview.setViewMode(QtGui.QListWidget.IconMode)
        self.themeview.setIconSize(QtCore.QSize(96, 96))
        #self.themeview.setResizeMode(QtGui.QListWidget.Adjust)
        self.themeview.setMovement(QtGui.QListWidget.Static)
        self.themeview.setItemDelegate(HTMLDelegate(self.themeview))

        self.themes = []
        for theme in os.listdir("data/themes"):
            if not os.path.exists("data/themes/" + theme + "/theme.ini"):
                continue

            themename = ini.read_ini("data/themes/" + theme + "/theme.ini",
                                     "Theme", "name", "unknown theme")
            themedesc = ini.read_ini("data/themes/" + theme + "/theme.ini",
                                     "Theme", "description")
            themeauthor = ini.read_ini("data/themes/" + theme + "/theme.ini",
                                       "Theme", "author")

            thumbnail = "data/themes/" + theme + "/thumbnail.png"
            if not os.path.exists(thumbnail):
                thumbnail = "data/misc/unknown_theme.png"

            text = "<b>" + themename + "</b>"
            if themedesc or themeauthor: text += "<br/>"
            if themedesc:
                text += themedesc + "<br/>"
            if themeauthor:
                text += "Author: " + themeauthor

            item = QtGui.QListWidgetItem(QtGui.QIcon(thumbnail), text)
            self.themes.append([theme, themename])
            self.themeview.addItem(item)

        themeview_layout.addWidget(self.themeview)

        theme_layout.addLayout(themeview_layout)

        ###### Controls tab ######
        self.changingBind = [
        ]  # [pushbutton object, control name, control index]

        up_layout = QtGui.QHBoxLayout()
        down_layout = QtGui.QHBoxLayout()
        left_layout = QtGui.QHBoxLayout()
        right_layout = QtGui.QHBoxLayout()
        run_layout = QtGui.QHBoxLayout()
        up_label = QtGui.QLabel("Up")
        down_label = QtGui.QLabel("Down")
        left_label = QtGui.QLabel("Left")
        right_label = QtGui.QLabel("Right")
        run_label = QtGui.QLabel("Run")
        self.up_buttons = [QtGui.QPushButton(), QtGui.QPushButton()]
        self.down_buttons = [QtGui.QPushButton(), QtGui.QPushButton()]
        self.left_buttons = [QtGui.QPushButton(), QtGui.QPushButton()]
        self.right_buttons = [QtGui.QPushButton(), QtGui.QPushButton()]
        self.run_button = QtGui.QPushButton()

        for b in self.up_buttons:
            b.clicked.connect(
                partial(self.changeBind, b, "up", self.up_buttons.index(b)))
        for b in self.down_buttons:
            b.clicked.connect(
                partial(self.changeBind, b, "down",
                        self.down_buttons.index(b)))
        for b in self.left_buttons:
            b.clicked.connect(
                partial(self.changeBind, b, "left",
                        self.left_buttons.index(b)))
        for b in self.right_buttons:
            b.clicked.connect(
                partial(self.changeBind, b, "right",
                        self.right_buttons.index(b)))
        self.run_button.clicked.connect(
            partial(self.changeBind, self.run_button, "run", 0))

        for i in range(len(self.up_buttons)):
            ao_app.controls["up"][i] = ini.read_ini_int(
                "aaio.ini", "Controls", "up%d" % (i + 1),
                ao_app.controls["up"][i])
        for i in range(len(self.down_buttons)):
            ao_app.controls["down"][i] = ini.read_ini_int(
                "aaio.ini", "Controls", "down%d" % (i + 1),
                ao_app.controls["down"][i])
        for i in range(len(self.left_buttons)):
            ao_app.controls["left"][i] = ini.read_ini_int(
                "aaio.ini", "Controls", "left%d" % (i + 1),
                ao_app.controls["left"][i])
        for i in range(len(self.right_buttons)):
            ao_app.controls["right"][i] = ini.read_ini_int(
                "aaio.ini", "Controls", "right%d" % (i + 1),
                ao_app.controls["right"][i])
        ao_app.controls["run"][0] = ini.read_ini_int("aaio.ini", "Controls",
                                                     "run",
                                                     ao_app.controls["run"][0])

        up_layout.addWidget(up_label)
        for b in self.up_buttons:
            up_layout.addWidget(b)
        down_layout.addWidget(down_label)
        for b in self.down_buttons:
            down_layout.addWidget(b)
        left_layout.addWidget(left_label)
        for b in self.left_buttons:
            left_layout.addWidget(b)
        right_layout.addWidget(right_label)
        for b in self.right_buttons:
            right_layout.addWidget(b)
        run_layout.addWidget(run_label)
        run_layout.addWidget(self.run_button)

        controls_layout.addLayout(up_layout)
        controls_layout.addLayout(down_layout)
        controls_layout.addLayout(left_layout)
        controls_layout.addLayout(right_layout)
        controls_layout.addLayout(run_layout)

        ###### Audio tab ######
        device_label = QtGui.QLabel("Audio device")
        self.device_list = QtGui.QComboBox()
        audio_layout.setWidget(0, QtGui.QFormLayout.LabelRole, device_label)
        audio_layout.setWidget(0, QtGui.QFormLayout.FieldRole,
                               self.device_list)

        audio_layout.setWidget(1, QtGui.QFormLayout.FieldRole, separators[0])

        volumelabel = QtGui.QLabel("Sound volume")
        musiclabel = QtGui.QLabel("Music")
        soundlabel = QtGui.QLabel("Sounds")
        bliplabel = QtGui.QLabel("Blips")
        self.musicslider = QtGui.QSlider(QtCore.Qt.Horizontal, self)
        self.soundslider = QtGui.QSlider(QtCore.Qt.Horizontal, self)
        self.blipslider = QtGui.QSlider(QtCore.Qt.Horizontal, self)
        self.musicslider.setRange(0, 100)
        self.soundslider.setRange(0, 100)
        self.blipslider.setRange(0, 100)
        audio_layout.setWidget(2, QtGui.QFormLayout.LabelRole, musiclabel)
        audio_layout.setWidget(2, QtGui.QFormLayout.FieldRole,
                               self.musicslider)
        audio_layout.setWidget(3, QtGui.QFormLayout.LabelRole, soundlabel)
        audio_layout.setWidget(3, QtGui.QFormLayout.FieldRole,
                               self.soundslider)
        audio_layout.setWidget(4, QtGui.QFormLayout.LabelRole, bliplabel)
        audio_layout.setWidget(4, QtGui.QFormLayout.FieldRole, self.blipslider)

        for device in audio.getdevices():
            self.device_list.addItem(device)

        ###### Advanced tab ######
        ms_layout = QtGui.QHBoxLayout()
        ms_label = QtGui.QLabel("MasterServer IP")
        self.ms_lineedit = QtGui.QLineEdit()

        ms_layout.addWidget(ms_label)
        ms_layout.addWidget(self.ms_lineedit)

        self.fps_checkbox = QtGui.QCheckBox("60 FPS mode", self)

        advanced_layout.addLayout(ms_layout)
        advanced_layout.addWidget(separators[1])
        advanced_layout.addWidget(self.fps_checkbox)

        self.tabs.addTab(general_tab, "General")
        self.tabs.addTab(theme_tab, "Theme")
        self.tabs.addTab(controls_tab, "Controls")
        self.tabs.addTab(audio_tab, "Audio")
        self.tabs.addTab(advanced_tab, "Advanced")

        save_layout.addWidget(savebtn, 100, QtCore.Qt.AlignRight)
        save_layout.addWidget(cancelbtn, 0, QtCore.Qt.AlignRight)
        main_layout.addWidget(self.tabs)
        main_layout.addLayout(save_layout)

        ao_app.installEventFilter(self)
        self.hide()
Esempio n. 9
0
    def showSettings(self):
        self.show()

        if os.path.exists("aaio.ini"):
            self.inifile.read("aaio.ini")
            try:
                self.defaultoocname.setText(
                    ini.read_ini("aaio.ini", "General",
                                 "OOC name").decode("utf-8"))
            except:
                self.defaultoocname.setText(
                    ini.read_ini("aaio.ini", "General", "OOC name"))

            try:
                self.defaultshowname.setText(
                    ini.read_ini("aaio.ini", "General",
                                 "Showname").decode("utf-8"))
            except:
                self.defaultshowname.setText(
                    ini.read_ini("aaio.ini", "General", "Showname"))

            selectedtheme = ini.read_ini("aaio.ini", "General", "Theme")
            for i in range(len(self.themes)):
                theme, themename = self.themes[i]

                if theme == selectedtheme:
                    self.themeview.setCurrentRow(i)
                    break

            self.ms_lineedit.setText(
                ini.read_ini("aaio.ini", "MasterServer", "IP"))
            self.device_list.setCurrentIndex(
                ini.read_ini_int("aaio.ini", "Audio", "Device",
                                 audio.getcurrdevice()))
            self.musicslider.setValue(
                ini.read_ini_int("aaio.ini", "Audio", "Music volume", 100))
            self.soundslider.setValue(
                ini.read_ini_int("aaio.ini", "Audio", "Sound volume", 100))
            self.blipslider.setValue(
                ini.read_ini_int("aaio.ini", "Audio", "Blip volume", 100))

            self.up_buttons[0].setText(
                getControlName(
                    ini.read_ini_int("aaio.ini", "Controls", "up1",
                                     QtCore.Qt.Key_W)))
            self.up_buttons[1].setText(
                getControlName(
                    ini.read_ini_int("aaio.ini", "Controls", "up2",
                                     QtCore.Qt.Key_Up)))
            self.down_buttons[0].setText(
                getControlName(
                    ini.read_ini_int("aaio.ini", "Controls", "down1",
                                     QtCore.Qt.Key_S)))
            self.down_buttons[1].setText(
                getControlName(
                    ini.read_ini_int("aaio.ini", "Controls", "down2",
                                     QtCore.Qt.Key_Down)))
            self.left_buttons[0].setText(
                getControlName(
                    ini.read_ini_int("aaio.ini", "Controls", "left1",
                                     QtCore.Qt.Key_A)))
            self.left_buttons[1].setText(
                getControlName(
                    ini.read_ini_int("aaio.ini", "Controls", "left2",
                                     QtCore.Qt.Key_Left)))
            self.right_buttons[0].setText(
                getControlName(
                    ini.read_ini_int("aaio.ini", "Controls", "right1",
                                     QtCore.Qt.Key_D)))
            self.right_buttons[1].setText(
                getControlName(
                    ini.read_ini_int("aaio.ini", "Controls", "right2",
                                     QtCore.Qt.Key_Right)))
            self.run_button.setText(
                getControlName(
                    ini.read_ini_int("aaio.ini", "Controls", "run",
                                     QtCore.Qt.Key_Shift)))

            self.fps_checkbox.setChecked(
                ini.read_ini_bool("aaio.ini", "General", "High FPS", True))

        else:
            self.defaultoocname.setText("")
            self.defaultshowname.setText("")

            for i in range(len(self.themes)):
                theme, themename = self.themes[i]

                if theme == "default":
                    self.themeview.setCurrentRow(i)
                    break

            self.ms_lineedit.setText("aaio-ms.aceattorneyonline.com:27011")
            self.device_list.setCurrentIndex(audio.getcurrdevice())
            self.musicslider.setValue(100)
            self.soundslider.setValue(100)
            self.blipslider.setValue(100)

            self.up_buttons[0].setText("Key_W")
            self.up_buttons[1].setText("Key_Up")
            self.down_buttons[0].setText("Key_S")
            self.down_buttons[1].setText("Key_Down")
            self.left_buttons[0].setText("Key_A")
            self.left_buttons[1].setText("Key_Left")
            self.right_buttons[0].setText("Key_D")
            self.right_buttons[1].setText("Key_Right")
            self.run_button.setText("Key_Shift")

            self.fps_checkbox.setChecked(True)

        self.tabs.setCurrentIndex(0)
        self.show()