Skip to content

Commit

Permalink
installer organize globalsettings into single dict
Browse files Browse the repository at this point in the history
  • Loading branch information
Die4Ever committed Apr 14, 2024
1 parent 200a07e commit 8e4885e
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 33 deletions.
29 changes: 15 additions & 14 deletions installer/GUI/InstallerWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ def initWindow(self):
row += 1

self.flavors = {}
self.globalsettings = {}

for f in flavors:
row = self.InitFlavorSettings(f, row, pad)
Expand Down Expand Up @@ -189,26 +190,26 @@ def LDDPCheckbox(self, row, padx, pady):

def GlobalFixes(self, row, pad):
# engine.dll speedup fix, this is global
self.speedupfixval = BooleanVar(master=self.frame, value=True)
self.speedupfix = Checkbutton(self.frame, text="Apply Engine.dll speedup fix\nto support higher frame rates.", variable=self.speedupfixval)
self.globalsettings['speedupfix'] = BooleanVar(master=self.frame, value=True)
self.speedupfix = Checkbutton(self.frame, text="Apply Engine.dll speedup fix\nto support higher frame rates.", variable=self.globalsettings['speedupfix'])
self.speedupfix.grid(column=1,row=row, sticky='SW', padx=pad, pady=pad)
Hovertip(self.speedupfix, "Fixes issues with high frame rates.")
self.FixColors(self.speedupfix)
row+=1

# DXVK is also global
if IsWindows():
self.dxvkval = BooleanVar(master=self.frame, value=self.dxvk_default)
self.dxvk = Checkbutton(self.frame, text="Apply DXVK fix for modern computers", variable=self.dxvkval)
self.globalsettings['dxvk'] = BooleanVar(master=self.frame, value=self.dxvk_default)
self.dxvk = Checkbutton(self.frame, text="Apply DXVK fix for modern computers", variable=self.globalsettings['dxvk'])
self.dxvk.grid(column=1,row=row, sticky='SW', padx=pad, pady=pad)
Hovertip(self.dxvk, "DXVK can fix performance issues on modern systems by using Vulkan.")
self.FixColors(self.dxvk)
row+=1
else:
self.dxvkval = DummyCheckbox()
self.globalsettings['dxvk'] = DummyCheckbox()

self.deus_nsf_d3d10val = BooleanVar(master=self.frame, value=False)
self.deus_nsf_d3d10 = Checkbutton(self.frame, text="Deus_nsf tweaked D3D10", variable=self.deus_nsf_d3d10val)
self.globalsettings['deus_nsf_d3d10'] = BooleanVar(master=self.frame, value=False)
self.deus_nsf_d3d10 = Checkbutton(self.frame, text="Deus_nsf tweaked D3D10", variable=self.globalsettings['deus_nsf_d3d10'])
Hovertip(self.deus_nsf_d3d10, "Tweaked D3D10 shaders for a better retro look with more vivid lighting.")
self.deus_nsf_d3d10.grid(column=1,row=row, sticky='SW', padx=pad, pady=pad)
self.FixColors(self.deus_nsf_d3d10)
Expand All @@ -219,8 +220,8 @@ def GlobalFixes(self, row, pad):
# to
# return diffuse;

self.ogl2val = BooleanVar(master=self.frame, value=self.ogl2_default)
self.ogl2 = Checkbutton(self.frame, text="Updated OpenGL 2.0 Renderer", variable=self.ogl2val)
self.globalsettings['ogl2'] = BooleanVar(master=self.frame, value=self.ogl2_default)
self.ogl2 = Checkbutton(self.frame, text="Updated OpenGL 2.0 Renderer", variable=self.globalsettings['ogl2'])
Hovertip(self.ogl2, "Updated OpenGL Renderer for modern systems. An alternative to using D3D10 or D3D9.")
self.ogl2.grid(column=1,row=row, sticky='SW', padx=pad, pady=pad)
self.FixColors(self.ogl2)
Expand Down Expand Up @@ -253,11 +254,11 @@ def _Install(self):
for (k,v) in flavor.items():
flavors[flavorName][k] = v.get()

speedupfix = self.speedupfixval.get()
dxvk = self.dxvkval.get()
deus_nsf_d3d10 = self.deus_nsf_d3d10val.get()
ogl2 = self.ogl2val.get()
flavors = Install.Install(self.exe, flavors, speedupfix, dxvk, deus_nsf_d3d10, ogl2)
globalsettings = {}
for (key, val) in self.globalsettings.items():
globalsettings[key] = val.get()

flavors = Install.Install(self.exe, flavors, globalsettings)
flavorstext = ', '.join(flavors.keys())
extra = ''
if 'Vanilla' in flavors and IsWindows():
Expand Down
38 changes: 19 additions & 19 deletions installer/Install/Install.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ def UnattendedInstall(installpath:str, downloadmirrors):

dxvk_default = IsWindows() and CheckVulkan()

ret = Install(p, settings, speedupfix=True, dxvk=dxvk_default, ogl2=dxvk_default)
globalsettings = dict(speedupfix=True, dxvk=dxvk_default, deus_nsf_d3d10=False, ogl2=dxvk_default)

ret = Install(p, settings, globalsettings)


def DetectFlavors(exe:Path) -> list:
Expand All @@ -43,13 +45,13 @@ def DetectFlavors(exe:Path) -> list:
return _DetectFlavors(system)


def Install(exe:Path, flavors:dict, speedupfix:bool, dxvk:bool, deus_nsf_d3d10:bool=False, OGL2:bool=False) -> dict:
def Install(exe:Path, flavors:dict, globalsettings:dict) -> dict:
assert exe.exists(), str(exe)
assert exe.name.lower() == 'deusex.exe'
system:Path = exe.parent
assert system.name.lower() == 'system'

info('Installing flavors:', flavors, speedupfix, exe)
info('Installing flavors:', flavors, globalsettings, exe)

for(f, settings) in flavors.items():
ret={}
Expand All @@ -59,7 +61,7 @@ def Install(exe:Path, flavors:dict, speedupfix:bool, dxvk:bool, deus_nsf_d3d10:b
continue

if 'Vanilla'==f:
ret = InstallVanilla(system, settings, speedupfix, Vulkan=dxvk, deus_nsf_d3d10=deus_nsf_d3d10, OGL2=OGL2)
ret = InstallVanilla(system, settings, globalsettings)
if 'Vanilla? Madder.'==f:
ret = CreateModConfigs(system, settings, 'VMD', 'VMDSim')
if 'GMDX v9'==f:
Expand All @@ -75,18 +77,18 @@ def Install(exe:Path, flavors:dict, speedupfix:bool, dxvk:bool, deus_nsf_d3d10:b
if ret and settings:
settings.update(ret)

if speedupfix:
if globalsettings['speedupfix']:
EngineDllFix(system)

CopyDXVK(system, dxvk)
InstallOGL2(system, OGL2)
CopyDXVK(system, globalsettings['dxvk'])
InstallOGL2(system, globalsettings['ogl2'])

debug("Install returning", flavors)

return flavors


def InstallVanilla(system:Path, settings:dict, speedupfix:bool, Vulkan:bool, deus_nsf_d3d10:bool, OGL2:bool):
def InstallVanilla(system:Path, settings:dict, globalsettings:dict):
gameroot = system.parent

if not settings.get('install') and not settings.get('LDDP') and not settings.get('FixVanilla'):
Expand Down Expand Up @@ -117,8 +119,7 @@ def InstallVanilla(system:Path, settings:dict, speedupfix:bool, Vulkan:bool, deu
CopyTo(exe_source, exedest)
ini = GetSourcePath() / 'Configs' / "DeusExDefault.ini"
VanillaFixConfigs(system=system, exename='DeusEx', kentie=kentie,
Vulkan=Vulkan, deus_nsf_d3d10=deus_nsf_d3d10, OGL2=OGL2,
speedupfix=speedupfix, sourceINI=ini)
globalsettings=globalsettings, sourceINI=ini)
else:
info('skipping fixing of vanilla')

Expand All @@ -139,20 +140,19 @@ def InstallVanilla(system:Path, settings:dict, speedupfix:bool, Vulkan:bool, deu

ini = GetSourcePath() / 'Configs' / "DXRandoDefault.ini"
VanillaFixConfigs(system=system, exename=exename, kentie=kentie,
Vulkan=Vulkan, deus_nsf_d3d10=deus_nsf_d3d10, OGL2=OGL2,
speedupfix=speedupfix, sourceINI=ini, ZeroRando=settings.get('ZeroRando', False))
globalsettings=globalsettings, sourceINI=ini, ZeroRando=settings.get('ZeroRando', False))

dxrroot = gameroot / 'DXRando'
Mkdir((dxrroot / 'Maps'), exist_ok=True, parents=True)
Mkdir((dxrroot / 'System'), exist_ok=True, parents=True)
CopyPackageFiles('vanilla', gameroot, ['DeusEx.u'])
CopyD3DRenderers(system, deus_nsf_d3d10)
CopyD3DRenderers(system, globalsettings['deus_nsf_d3d10'])

if settings.get('mirrors'):
MapVariants.InstallMirrors(dxrroot / 'Maps', settings.get('downloadcallback'), 'Vanilla')


def VanillaFixConfigs(system, exename, kentie, Vulkan, deus_nsf_d3d10, OGL2, speedupfix, sourceINI: Path, ZeroRando=False):
def VanillaFixConfigs(system, exename, kentie, globalsettings:dict, sourceINI: Path, ZeroRando=False):
defini_dest:Path = system / (exename+'Default.ini') # I don't think Kentie cares about this file, but Han's Launchbox does
CopyTo(sourceINI, defini_dest)
c = Config.Config(defini_dest.read_bytes())
Expand All @@ -178,12 +178,12 @@ def VanillaFixConfigs(system, exename, kentie, Vulkan, deus_nsf_d3d10, OGL2, spe
'DeusEx.DXRando', 'DeusEx.DXRFlags', 'DeusEx.DXRTelemetry', 'DeusEx.DXRMenuScreenNewGame')),
changes
)
elif not Vulkan and IsWindows():
elif not globalsettings['dxvk'] and IsWindows():
changes['Galaxy.GalaxyAudioSubsystem'] = {'Latency': '80'}

CopyTo(sourceINI, DXRandoini)

if not speedupfix:
if not globalsettings['speedupfix']:
if 'DeusExe' not in changes:
changes['DeusExe'] = {}
changes['DeusExe'].update({'FPSLimit': '120'})
Expand All @@ -198,7 +198,7 @@ def VanillaFixConfigs(system, exename, kentie, Vulkan, deus_nsf_d3d10, OGL2, spe
changes['D3D10Drv.D3D10RenderDevice'] = {}
changes['D3D10Drv.D3D10RenderDevice'].update({'FPSLimit': '0', 'VSync': 'False'})

if deus_nsf_d3d10:
if globalsettings['deus_nsf_d3d10']:
if 'D3D10Drv.D3D10RenderDevice' not in changes:
changes['D3D10Drv.D3D10RenderDevice'] = {}
changes['D3D10Drv.D3D10RenderDevice'].update({'ClassicLighting': 'False'})
Expand All @@ -209,10 +209,10 @@ def VanillaFixConfigs(system, exename, kentie, Vulkan, deus_nsf_d3d10, OGL2, spe
changes['DeusEx.DXRFlags'] = {}
changes['DeusEx.DXRFlags'].update({'gamemode': '4'})

if IsWindows() and not Vulkan:
if IsWindows() and not globalsettings['dxvk']:
changes['Engine.Engine'] = {'GameRenderDevice': 'D3D9Drv.D3D9RenderDevice'}
elif not IsWindows():
if OGL2:
if globalsettings['ogl2']:
changes['Engine.Engine'] = {'GameRenderDevice': 'OpenGLDrv.OpenGLRenderDevice'}
else:
changes['Engine.Engine'] = {'GameRenderDevice': 'D3D9Drv.D3D9RenderDevice'}
Expand Down

0 comments on commit 8e4885e

Please sign in to comment.