moved directory names to constants file + about window
This commit is contained in:
parent
0b802b3e95
commit
4951d0ca46
20
AO2XP.py
20
AO2XP.py
@ -8,6 +8,7 @@ from PyQt4 import QtGui, QtCore
|
||||
|
||||
import audio as AUDIO
|
||||
import ini
|
||||
from constants import *
|
||||
|
||||
__builtin__.audio = AUDIO
|
||||
del AUDIO
|
||||
@ -44,9 +45,10 @@ class gamewindow(QtGui.QMainWindow):
|
||||
self.center()
|
||||
self.setWindowTitle("AO2XP")
|
||||
self.setWindowIcon(QtGui.QIcon("AO2XP.ico"))
|
||||
self.setWindowFlags(QtCore.Qt.WindowMinimizeButtonHint)
|
||||
self.setWindowFlags(QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowTitleHint | QtCore.Qt.WindowMinimizeButtonHint | QtCore.Qt.WindowCloseButtonHint)
|
||||
|
||||
self.settingsgui = options.Settings()
|
||||
self.settingsgui = options.Settings(self)
|
||||
self.aboutgui = self.aboutBox()
|
||||
|
||||
def center(self):
|
||||
frameGm = self.frameGeometry()
|
||||
@ -68,6 +70,16 @@ class gamewindow(QtGui.QMainWindow):
|
||||
|
||||
def showSettings(self):
|
||||
self.settingsgui.showSettings()
|
||||
|
||||
def aboutBox(self):
|
||||
box = QtGui.QMessageBox()
|
||||
box.setText("AO2XP %s\nRunning on %s %s %s (Python %s)\n\n2019-2025 headshot / cidoku" % (GAME_VERSION, platform.system(), platform.release(), platform.machine(), platform.python_version()))
|
||||
box.setWindowTitle("About AO2XP")
|
||||
box.setStandardButtons(QtGui.QMessageBox.Close)
|
||||
box.setWindowIcon(QtGui.QIcon("AO2XP.ico"))
|
||||
box.setIconPixmap(QtGui.QPixmap(AO2XPpath + "icons/about.png"))
|
||||
box.button(QtGui.QMessageBox.Close).setText('Take that!')
|
||||
return box
|
||||
|
||||
if not debugmode:
|
||||
# Vanilla downloader
|
||||
@ -102,8 +114,8 @@ def handler(msg_type, msg_string):
|
||||
QtCore.qInstallMsgHandler(handler)
|
||||
|
||||
audio.init()
|
||||
shit = gamewindow()
|
||||
shit.show()
|
||||
game = gamewindow()
|
||||
game.show()
|
||||
returnc = app.exec_()
|
||||
audio.free()
|
||||
sys.exit(returnc)
|
||||
|
BIN
AO2XPbase/icons/about.png
Normal file
BIN
AO2XPbase/icons/about.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.1 KiB |
@ -3,7 +3,7 @@ import platform
|
||||
|
||||
import websocket
|
||||
|
||||
from game_version import *
|
||||
from constants import *
|
||||
|
||||
|
||||
class AOtcpSocket(object):
|
||||
|
@ -1,9 +1,6 @@
|
||||
from PyQt4 import QtCore, QtGui
|
||||
import os
|
||||
|
||||
AOpath = "base/"
|
||||
AO2XPpath = "AO2XPbase/"
|
||||
#AOpath = "I:/aovanilla1.7.5/client/base/"
|
||||
from constants import *
|
||||
|
||||
class AOToggleButton(QtGui.QLabel):
|
||||
pressed = False
|
||||
|
@ -3,9 +3,7 @@ import socket, thread, time
|
||||
from os.path import exists
|
||||
from functools import partial
|
||||
from buttons import PixmapButton
|
||||
|
||||
AOpath = "base/"
|
||||
AO2XPpath = "AO2XPbase/"
|
||||
from constants import *
|
||||
|
||||
def get_option(section, value, default=""):
|
||||
tempini = ConfigParser()
|
||||
|
3
constants.py
Normal file
3
constants.py
Normal file
@ -0,0 +1,3 @@
|
||||
GAME_VERSION = "2.8.0"
|
||||
AOpath = "base/"
|
||||
AO2XPpath = "AO2XPbase/"
|
17
gameview.py
17
gameview.py
@ -1,6 +1,7 @@
|
||||
import thread, time, os, buttons, urllib, charselect, ini, random
|
||||
from os.path import exists, basename
|
||||
from ConfigParserEdit import ConfigParser
|
||||
from constants import *
|
||||
|
||||
from pybass_constants import *
|
||||
from PyQt4 import QtGui, QtCore
|
||||
@ -11,10 +12,6 @@ from urllib2 import Request, urlopen
|
||||
import AOsocket
|
||||
import images
|
||||
|
||||
AOpath = "base/"
|
||||
AO2XPpath = "AO2XPbase/"
|
||||
#AOpath = 'I:/aovanilla1.7.5/client/base/'
|
||||
|
||||
DESK_MOD = 1
|
||||
PREANIM = 2
|
||||
CHARNAME = 3
|
||||
@ -2903,7 +2900,7 @@ class gui(QtGui.QWidget):
|
||||
self.specialstream = 2
|
||||
if (musl.startswith("https") and error == 2) or self.specialstream:
|
||||
print "[audio] Downloading music with urllib2"
|
||||
self.download_thread = DownloadThread(self, mus)
|
||||
self.download_thread = music_download_thread(self, mus)
|
||||
self.download_thread.finished_signal.connect(self.playDownloadedMusic)
|
||||
self.download_thread.start()
|
||||
|
||||
@ -3572,12 +3569,12 @@ class TCP_Thread(QtCore.QThread):
|
||||
except:
|
||||
pass
|
||||
|
||||
class DownloadThread(QtCore.QThread):
|
||||
class music_download_thread(QtCore.QThread):
|
||||
# Part of the evil HTTPS music download hack for XP systems
|
||||
finished_signal = QtCore.pyqtSignal(int)
|
||||
|
||||
def __init__(self, caller, url):
|
||||
super(DownloadThread, self).__init__()
|
||||
super(music_download_thread, self).__init__()
|
||||
self.caller = caller
|
||||
self.url = url
|
||||
|
||||
@ -3586,8 +3583,8 @@ class DownloadThread(QtCore.QThread):
|
||||
|
||||
def download(self, url):
|
||||
headers = {
|
||||
'User-Agent': 'AO2XP',
|
||||
'Accept': 'audio/mpeg, audio/x-mpeg, audio/x-mpeg-3, audio/mpeg3, */*',
|
||||
'User-Agent': "AO2XP %s" % (GAME_VERSION),
|
||||
'Accept': '*/*',
|
||||
'Accept-Encoding': 'gzip, deflate',
|
||||
'Accept-Language': 'en-US,en;q=0.9',
|
||||
'Connection': 'keep-alive',
|
||||
@ -3613,8 +3610,6 @@ class DownloadThread(QtCore.QThread):
|
||||
break
|
||||
stream += chunk
|
||||
bytes_downloaded += len(chunk)
|
||||
#progress = int((bytes_downloaded / float(file_length)) * 100)
|
||||
#print "[debug] progress: %d%%" % progress
|
||||
|
||||
self.caller.stream = create_string_buffer(stream)
|
||||
self.finished_signal.emit(file_length)
|
16
mainmenu.py
16
mainmenu.py
@ -7,11 +7,7 @@ from PyQt4 import QtGui, QtCore
|
||||
import hardware
|
||||
import AOsocket
|
||||
import ini
|
||||
from game_version import *
|
||||
|
||||
AOpath = "base/"
|
||||
AO2XPpath = "AO2XPbase/"
|
||||
#AOpath = "I:/aovanilla1.7.5/client/base/"
|
||||
from constants import *
|
||||
|
||||
def decode_ao_str(text):
|
||||
return text.replace("<percent>", "%").replace("<pound>", "#").replace("<num>", "#").replace("<and>", "&").replace("<dollar>", "$")
|
||||
@ -74,15 +70,10 @@ class lobby(QtGui.QWidget):
|
||||
self.connectingimg.setPixmap(self.pix_connecting)
|
||||
self.connectingimg.hide()
|
||||
|
||||
self.clientver = QtGui.QLabel(self)
|
||||
self.clientver.setText('AO2XP %s by Headshot' % GAME_VERSION)
|
||||
self.clientver.resize(self.clientver.sizeHint())
|
||||
self.clientver.move(self.pix_lobby.size().width() - self.clientver.size().width(), 0)
|
||||
|
||||
self.settingsbtn = QtGui.QPushButton(self)
|
||||
self.settingsbtn.setText("Settings")
|
||||
self.settingsbtn.resize(self.settingsbtn.sizeHint())
|
||||
self.settingsbtn.move(self.clientver.x() - self.settingsbtn.size().width() - 8, 0)
|
||||
self.settingsbtn.move(self.pix_lobby.size().width() - self.settingsbtn.size().width(), 0)
|
||||
self.settingsbtn.clicked.connect(self.onSettingsClicked)
|
||||
|
||||
self.btn_public = PicButton(self.pix_btn_public, self)
|
||||
@ -308,7 +299,6 @@ class lobby(QtGui.QWidget):
|
||||
self.serverlist.hide()
|
||||
self.onlineplayers.hide()
|
||||
self.serverinfo.hide()
|
||||
self.clientver.hide()
|
||||
self.settingsbtn.hide()
|
||||
self.aoserverinfo.tcp.send('askchaa#%')
|
||||
|
||||
@ -324,7 +314,6 @@ class lobby(QtGui.QWidget):
|
||||
self.serverlist.show()
|
||||
self.onlineplayers.show()
|
||||
self.serverinfo.show()
|
||||
self.clientver.show()
|
||||
self.settingsbtn.show()
|
||||
|
||||
def onClicked_serverlist(self, item):
|
||||
@ -652,4 +641,3 @@ class AOServerInfo(QtCore.QThread):
|
||||
if not pid in playerlist:
|
||||
playerlist[pid] = []
|
||||
playerlist[pid].append(network[2].decode('utf-8'))
|
||||
|
22
options.py
22
options.py
@ -7,21 +7,22 @@ try:
|
||||
except: pass
|
||||
|
||||
from PyQt4 import QtGui, QtCore
|
||||
from constants import *
|
||||
|
||||
import ini
|
||||
|
||||
AOpath = "base/"
|
||||
AO2XPpath = "AO2XPbase/"
|
||||
#AOpath = "I:\\aovanilla1.7.5\\client\\base\\"
|
||||
|
||||
class Settings(QtGui.QDialog):
|
||||
def __init__(self):
|
||||
def __init__(self, parent):
|
||||
super(Settings, self).__init__()
|
||||
self.setModal(True)
|
||||
self.gamewindow = parent
|
||||
self.parent = parent
|
||||
|
||||
self.inifile = ConfigParser()
|
||||
self.setWindowTitle("Settings")
|
||||
self.setWindowTitle("AO2XP Settings")
|
||||
self.setFixedSize(480, 512)
|
||||
self.setWindowIcon(QtGui.QIcon("AO2XP.ico"))
|
||||
self.setWindowFlags(QtCore.Qt.WindowCloseButtonHint)
|
||||
self.hide()
|
||||
|
||||
main_layout = QtGui.QVBoxLayout(self)
|
||||
@ -48,6 +49,9 @@ class Settings(QtGui.QDialog):
|
||||
self.cancelbtn = QtGui.QPushButton()
|
||||
self.cancelbtn.setText("Cancel")
|
||||
self.cancelbtn.clicked.connect(self.onCancelClicked)
|
||||
self.aboutbtn = QtGui.QPushButton()
|
||||
self.aboutbtn.setText("About...")
|
||||
self.aboutbtn.clicked.connect(self.onAboutClicked)
|
||||
|
||||
separators = []
|
||||
for i in range(5):
|
||||
@ -198,6 +202,7 @@ class Settings(QtGui.QDialog):
|
||||
|
||||
save_layout.addWidget(self.savebtn, 100, QtCore.Qt.AlignRight)
|
||||
save_layout.addWidget(self.cancelbtn, 0, QtCore.Qt.AlignRight)
|
||||
save_layout.addWidget(self.aboutbtn, 0, QtCore.Qt.AlignLeft)
|
||||
main_layout.addWidget(self.tabs)
|
||||
main_layout.addLayout(save_layout)
|
||||
|
||||
@ -290,6 +295,9 @@ class Settings(QtGui.QDialog):
|
||||
|
||||
def onCancelClicked(self):
|
||||
self.hide()
|
||||
|
||||
def onAboutClicked(self):
|
||||
self.gamewindow.aboutgui.exec_()
|
||||
|
||||
def onUpdateClicked(self):
|
||||
import updater
|
||||
@ -303,4 +311,4 @@ class Settings(QtGui.QDialog):
|
||||
def onReloadAudio(self):
|
||||
audio.free()
|
||||
audio.init()
|
||||
print "reloaded audio"
|
||||
print "[audio] Reloaded audio system"
|
@ -6,7 +6,7 @@ except: pass
|
||||
|
||||
from PyQt4 import QtGui, QtCore
|
||||
|
||||
from game_version import *
|
||||
from constants import *
|
||||
|
||||
returncode = -1
|
||||
assetfile = {
|
||||
|
Loading…
Reference in New Issue
Block a user