Skip to content

Commit

Permalink
installer smarter GetVersion()
Browse files Browse the repository at this point in the history
  • Loading branch information
Die4Ever committed Mar 28, 2024
1 parent 85abb85 commit 1d59595
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
2 changes: 1 addition & 1 deletion installer/GUI/InstallerWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def initWindow(self):
self.width = 350
self.height = 500
self.lastprogress = ''
self.root.title("Deus Ex Randomizer Installer " + GetVersion())
self.root.title("Deus Ex Randomizer " + GetVersion() + " Installer")

dxvk_default = CheckVulkan()# this takes a second or so
ogl2_default = dxvk_default or not IsWindows()
Expand Down
33 changes: 32 additions & 1 deletion installer/Install/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def info(*args):
import certifi
import ssl
import subprocess
import re
except Exception as e:
info('ERROR: importing', e)
raise
Expand All @@ -56,8 +57,38 @@ def GetDryrun() -> bool:
def IsWindows() -> bool:
return os.name == 'nt'

version = None
def GetVersion():
return 'v2.6' # TODO: make this automatic
global version
if version:
return version

p = GetPackagesPath('vanilla') / 'DeusEx.u'
assert p.exists()
data = p.read_bytes()

i = data.find(b'class DXRVersion extends Info;')
data = data[i:]
i = data.find(b'////// you probably don\'t need to touch the stuff below')
data = data[:i]

i = data.find(b'static function CurrentVersion(')
CurrentVersion = data[i:]
i = CurrentVersion.find(b'}')
CurrentVersion = CurrentVersion[:i].decode('iso_8859_1')
m = re.search(r'major=(\d+);\s+minor=(\d+);\s+patch=(\d+);\s+build=(\d+);', CurrentVersion, flags=re.MULTILINE)
version = 'v' + m.group(1) + '.' + m.group(2) + '.' + m.group(3) + '.' + m.group(4)

i = data.find(b'static function string VersionString(')
VersionString = data[i:]
i = VersionString.find(b'}')
VersionString = VersionString[:i].decode('iso_8859_1')

m = re.search(r'status = "(.*)";', VersionString, flags=re.MULTILINE)
if m and m.group(1):
version += ' ' + m.group(1)

return version

def CheckVulkan() -> bool:
if not IsWindows():
Expand Down

0 comments on commit 1d59595

Please sign in to comment.