moved directory names to constants file + about window

This commit is contained in:
cidoku 2025-02-20 18:54:54 -03:00
parent 0b802b3e95
commit 4951d0ca46
10 changed files with 46 additions and 45 deletions

View File

@ -8,6 +8,7 @@ from PyQt4 import QtGui, QtCore
import audio as AUDIO import audio as AUDIO
import ini import ini
from constants import *
__builtin__.audio = AUDIO __builtin__.audio = AUDIO
del AUDIO del AUDIO
@ -44,9 +45,10 @@ class gamewindow(QtGui.QMainWindow):
self.center() self.center()
self.setWindowTitle("AO2XP") self.setWindowTitle("AO2XP")
self.setWindowIcon(QtGui.QIcon("AO2XP.ico")) 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): def center(self):
frameGm = self.frameGeometry() frameGm = self.frameGeometry()
@ -69,6 +71,16 @@ class gamewindow(QtGui.QMainWindow):
def showSettings(self): def showSettings(self):
self.settingsgui.showSettings() 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: if not debugmode:
# Vanilla downloader # Vanilla downloader
force_downloader = len(sys.argv) > 1 and sys.argv[1] == "download" force_downloader = len(sys.argv) > 1 and sys.argv[1] == "download"
@ -102,8 +114,8 @@ def handler(msg_type, msg_string):
QtCore.qInstallMsgHandler(handler) QtCore.qInstallMsgHandler(handler)
audio.init() audio.init()
shit = gamewindow() game = gamewindow()
shit.show() game.show()
returnc = app.exec_() returnc = app.exec_()
audio.free() audio.free()
sys.exit(returnc) sys.exit(returnc)

BIN
AO2XPbase/icons/about.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

@ -3,7 +3,7 @@ import platform
import websocket import websocket
from game_version import * from constants import *
class AOtcpSocket(object): class AOtcpSocket(object):

View File

@ -1,9 +1,6 @@
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
import os import os
from constants import *
AOpath = "base/"
AO2XPpath = "AO2XPbase/"
#AOpath = "I:/aovanilla1.7.5/client/base/"
class AOToggleButton(QtGui.QLabel): class AOToggleButton(QtGui.QLabel):
pressed = False pressed = False

View File

@ -3,9 +3,7 @@ import socket, thread, time
from os.path import exists from os.path import exists
from functools import partial from functools import partial
from buttons import PixmapButton from buttons import PixmapButton
from constants import *
AOpath = "base/"
AO2XPpath = "AO2XPbase/"
def get_option(section, value, default=""): def get_option(section, value, default=""):
tempini = ConfigParser() tempini = ConfigParser()

3
constants.py Normal file
View File

@ -0,0 +1,3 @@
GAME_VERSION = "2.8.0"
AOpath = "base/"
AO2XPpath = "AO2XPbase/"

View File

@ -1,6 +1,7 @@
import thread, time, os, buttons, urllib, charselect, ini, random import thread, time, os, buttons, urllib, charselect, ini, random
from os.path import exists, basename from os.path import exists, basename
from ConfigParserEdit import ConfigParser from ConfigParserEdit import ConfigParser
from constants import *
from pybass_constants import * from pybass_constants import *
from PyQt4 import QtGui, QtCore from PyQt4 import QtGui, QtCore
@ -11,10 +12,6 @@ from urllib2 import Request, urlopen
import AOsocket import AOsocket
import images import images
AOpath = "base/"
AO2XPpath = "AO2XPbase/"
#AOpath = 'I:/aovanilla1.7.5/client/base/'
DESK_MOD = 1 DESK_MOD = 1
PREANIM = 2 PREANIM = 2
CHARNAME = 3 CHARNAME = 3
@ -2903,7 +2900,7 @@ class gui(QtGui.QWidget):
self.specialstream = 2 self.specialstream = 2
if (musl.startswith("https") and error == 2) or self.specialstream: if (musl.startswith("https") and error == 2) or self.specialstream:
print "[audio] Downloading music with urllib2" 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.finished_signal.connect(self.playDownloadedMusic)
self.download_thread.start() self.download_thread.start()
@ -3572,12 +3569,12 @@ class TCP_Thread(QtCore.QThread):
except: except:
pass pass
class DownloadThread(QtCore.QThread): class music_download_thread(QtCore.QThread):
# Part of the evil HTTPS music download hack for XP systems # Part of the evil HTTPS music download hack for XP systems
finished_signal = QtCore.pyqtSignal(int) finished_signal = QtCore.pyqtSignal(int)
def __init__(self, caller, url): def __init__(self, caller, url):
super(DownloadThread, self).__init__() super(music_download_thread, self).__init__()
self.caller = caller self.caller = caller
self.url = url self.url = url
@ -3586,8 +3583,8 @@ class DownloadThread(QtCore.QThread):
def download(self, url): def download(self, url):
headers = { headers = {
'User-Agent': 'AO2XP', 'User-Agent': "AO2XP %s" % (GAME_VERSION),
'Accept': 'audio/mpeg, audio/x-mpeg, audio/x-mpeg-3, audio/mpeg3, */*', 'Accept': '*/*',
'Accept-Encoding': 'gzip, deflate', 'Accept-Encoding': 'gzip, deflate',
'Accept-Language': 'en-US,en;q=0.9', 'Accept-Language': 'en-US,en;q=0.9',
'Connection': 'keep-alive', 'Connection': 'keep-alive',
@ -3613,8 +3610,6 @@ class DownloadThread(QtCore.QThread):
break break
stream += chunk stream += chunk
bytes_downloaded += len(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.caller.stream = create_string_buffer(stream)
self.finished_signal.emit(file_length) self.finished_signal.emit(file_length)

View File

@ -7,11 +7,7 @@ from PyQt4 import QtGui, QtCore
import hardware import hardware
import AOsocket import AOsocket
import ini import ini
from game_version import * from constants import *
AOpath = "base/"
AO2XPpath = "AO2XPbase/"
#AOpath = "I:/aovanilla1.7.5/client/base/"
def decode_ao_str(text): def decode_ao_str(text):
return text.replace("<percent>", "%").replace("<pound>", "#").replace("<num>", "#").replace("<and>", "&").replace("<dollar>", "$") 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.setPixmap(self.pix_connecting)
self.connectingimg.hide() 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 = QtGui.QPushButton(self)
self.settingsbtn.setText("Settings") self.settingsbtn.setText("Settings")
self.settingsbtn.resize(self.settingsbtn.sizeHint()) 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.settingsbtn.clicked.connect(self.onSettingsClicked)
self.btn_public = PicButton(self.pix_btn_public, self) self.btn_public = PicButton(self.pix_btn_public, self)
@ -308,7 +299,6 @@ class lobby(QtGui.QWidget):
self.serverlist.hide() self.serverlist.hide()
self.onlineplayers.hide() self.onlineplayers.hide()
self.serverinfo.hide() self.serverinfo.hide()
self.clientver.hide()
self.settingsbtn.hide() self.settingsbtn.hide()
self.aoserverinfo.tcp.send('askchaa#%') self.aoserverinfo.tcp.send('askchaa#%')
@ -324,7 +314,6 @@ class lobby(QtGui.QWidget):
self.serverlist.show() self.serverlist.show()
self.onlineplayers.show() self.onlineplayers.show()
self.serverinfo.show() self.serverinfo.show()
self.clientver.show()
self.settingsbtn.show() self.settingsbtn.show()
def onClicked_serverlist(self, item): def onClicked_serverlist(self, item):
@ -652,4 +641,3 @@ class AOServerInfo(QtCore.QThread):
if not pid in playerlist: if not pid in playerlist:
playerlist[pid] = [] playerlist[pid] = []
playerlist[pid].append(network[2].decode('utf-8')) playerlist[pid].append(network[2].decode('utf-8'))

View File

@ -7,21 +7,22 @@ try:
except: pass except: pass
from PyQt4 import QtGui, QtCore from PyQt4 import QtGui, QtCore
from constants import *
import ini import ini
AOpath = "base/"
AO2XPpath = "AO2XPbase/"
#AOpath = "I:\\aovanilla1.7.5\\client\\base\\"
class Settings(QtGui.QDialog): class Settings(QtGui.QDialog):
def __init__(self): def __init__(self, parent):
super(Settings, self).__init__() super(Settings, self).__init__()
self.setModal(True) self.setModal(True)
self.gamewindow = parent
self.parent = parent
self.inifile = ConfigParser() self.inifile = ConfigParser()
self.setWindowTitle("Settings") self.setWindowTitle("AO2XP Settings")
self.setFixedSize(480, 512) self.setFixedSize(480, 512)
self.setWindowIcon(QtGui.QIcon("AO2XP.ico"))
self.setWindowFlags(QtCore.Qt.WindowCloseButtonHint)
self.hide() self.hide()
main_layout = QtGui.QVBoxLayout(self) main_layout = QtGui.QVBoxLayout(self)
@ -48,6 +49,9 @@ class Settings(QtGui.QDialog):
self.cancelbtn = QtGui.QPushButton() self.cancelbtn = QtGui.QPushButton()
self.cancelbtn.setText("Cancel") self.cancelbtn.setText("Cancel")
self.cancelbtn.clicked.connect(self.onCancelClicked) self.cancelbtn.clicked.connect(self.onCancelClicked)
self.aboutbtn = QtGui.QPushButton()
self.aboutbtn.setText("About...")
self.aboutbtn.clicked.connect(self.onAboutClicked)
separators = [] separators = []
for i in range(5): 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.savebtn, 100, QtCore.Qt.AlignRight)
save_layout.addWidget(self.cancelbtn, 0, 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.addWidget(self.tabs)
main_layout.addLayout(save_layout) main_layout.addLayout(save_layout)
@ -291,6 +296,9 @@ class Settings(QtGui.QDialog):
def onCancelClicked(self): def onCancelClicked(self):
self.hide() self.hide()
def onAboutClicked(self):
self.gamewindow.aboutgui.exec_()
def onUpdateClicked(self): def onUpdateClicked(self):
import updater import updater
code = updater.checkForUpdates() code = updater.checkForUpdates()
@ -303,4 +311,4 @@ class Settings(QtGui.QDialog):
def onReloadAudio(self): def onReloadAudio(self):
audio.free() audio.free()
audio.init() audio.init()
print "reloaded audio" print "[audio] Reloaded audio system"

View File

@ -6,7 +6,7 @@ except: pass
from PyQt4 import QtGui, QtCore from PyQt4 import QtGui, QtCore
from game_version import * from constants import *
returncode = -1 returncode = -1
assetfile = { assetfile = {