Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add functions to change OS and overwrite loading of libraries. #1

Closed
NoXPhasma opened this issue Oct 6, 2018 · 12 comments
Closed

Add functions to change OS and overwrite loading of libraries. #1

NoXPhasma opened this issue Oct 6, 2018 · 12 comments

Comments

@NoXPhasma
Copy link
Contributor

Would be great if you could add functions so it's possible to change the OS on runtime. Default is Windows 7 but some installer need to run as XP. Another feature which would be really helpful is to overwrite how libraries are loaded.

For example, Little Nightmares needs xact installed but also set xaudio2_6 and xaudio2_7 to native. Another example is that some games need .net and then set mscoree to builtin.

@simons-public
Copy link
Owner

You can do most of that (if winetricks is installed) using the util.protontricks function. For example:

from protontricks import util

def main():
    if not util.checkinstalled('winxp'):
        util.protontricks('winxp')

As far as dotnet goes, I'm working on the option to make win32 prefix that can be used with the versions of dotnet that won't install on a win64 prefix.

@NoXPhasma
Copy link
Contributor Author

I didn't know that it's that easy to change the OS with winetricks. For the library override, this is set in the user.reg file, as far as I know. Is there a way to set this with winetricks as well? The winetricks man page doesn't say anything about that.

@NoXPhasma
Copy link
Contributor Author

I found out that we can override the dlls temporarily with an environment variable: os.environ["WINEDLLOVERRIDES"] = "xaudio2_6,xaudio2_7=n"

I don't think that a function to write this into the config is necessary. If you agree you can close this issue.

@simons-public
Copy link
Owner

Yeah winetricks documentation is a bit lacking, but looking at the sources (it's all shell script) it looks like it does set overrides in the registry when it runs.

I think overriding with the environment variable is a good way to do it too, I'll go ahead and close the issue.

@NoXPhasma
Copy link
Contributor Author

NoXPhasma commented Oct 7, 2018

Hmm, somehow the command doesn't work for me. No environment variable will be applied. To get sure I tried with os.environ["DXVK_HUD"] = "fps", but no FPS counter shows up.

The same is with os.environ["WINEDLLOVERRIDES"] = "xaudio2_6,xaudio2_7=n" That should override those libs to native and by that stop audio crackling in Little Nightmares, but never gets applied.

This is the script I'm working on:

import os
from protonfixes import util


def main():
    """ Little Nightmares
        Install xact and override libraries
    """

    # if not already installed, install xact
    if not util.checkinstalled('xact'):
        util.protontricks('xact')

    os.environ["DXVK_HUD"] = "fps"
    os.environ["WINEDLLOVERRIDES"] = "xaudio2_6,xaudio2_7=n;"

edit
The script will be executed, so that is not the problem :)

@NoXPhasma
Copy link
Contributor Author

So, this won't work, because Proton overwrites these variables in the proton file.

s = ""
for dll in dlloverrides:
    setting = dlloverrides[dll]
    if len(s) > 0:
        s = s + ";" + dll + "=" + setting
    else:
        s = dll + "=" + setting
env["WINEDLLOVERRIDES"] = s

@NoXPhasma
Copy link
Contributor Author

I've created a pull request on Proton to allow own overrides with WINEDLLOVERRIDES environment variable: ValveSoftware/Proton#1705

@pchome
Copy link
Contributor

pchome commented Oct 7, 2018

Looking for similar feature for user_settings per game. But env already set from os.environ at the time protonfixes loaded. So manipulating os.environ will not work.
proton.in:106
proton.in:142

Quick hack for fix.py (copy/paste from def run_fix(gameid):):

def game_settings():
    """ Loads a gamefix module by it's gameid
    """
    gameid = game_id()

    if gameid is not None:
        localpath = os.path.expanduser('~/.config/protonfixes/localfixes')
        if os.path.isfile(os.path.join(localpath, gameid + '.py')):
            open(os.path.join(localpath, '__init__.py'), 'a').close()
            sys.path.append(os.path.expanduser('~/.config/protonfixes'))
            try:
                game_module = import_module('localfixes.' + gameid)
                print('Using local protonfix settings for gameid', gameid)
                return game_module.game_settings()
            except ImportError:
                print('No local protonfix settings found for gameid', gameid)
        else:
            try:
                game_module = import_module('protonfixes.gamefixes.' + gameid)
                print('Using protonfix settings for gameid', gameid)
                return game_module.game_settings()
            except ImportError:
                print('No protonfix settings found for gameid', gameid)

    print('No protonfix settings found for gameid', game_id())

user_settings.py (after user_settings = {"DXVK_LOG_LEVEL": "info",})

import protonfixes
from protonfixes import fix
try:
  user_settings.update(fix.game_settings())
except:
  pass

.config/protonfixes/localfixes/1234.py

def game_settings():
    return {
        "WINEDEBUG" : "-all,+loaddll",
    }

test.py output

Running protonfixes
Using local protonfix for gameid 1234
Using local protonfix settings for gameid 1234
Proton: env updated
Proton: DXVK_LOG_LEVEL = info
Proton: WINEDEBUG = -all,+loaddll

@simons-public , please provide official solution to do this.
@NoXPhasma , this should fix DXVK_HUD issue.

@NoXPhasma
Copy link
Contributor Author

@pchome The pull request I send to Proton will allow using WINEDLLOVERRIDES and works fine, I tested it. We'll see if Valve will accept that.

Using DXVK_HUD was just a test to see if changing environment variables does work. Usually this variable will set by users and shouldn't be in gamefixes.

@pchome
Copy link
Contributor

pchome commented Oct 7, 2018

@NoXPhasma

Using DXVK_HUD was just a test to see if changing environment variables does work.

To get sure I tried with os.environ["DXVK_HUD"] = "fps", but no FPS counter shows up.

I mentioned DXVK_HUD as an example too. But, despite I only care about protonfixes/localfixes/, gamefixes can force e.g. PROTON_NO_ESYNC or PROTON_NO_D3D11 to fix known problems.

WINEDLLOVERRIDES

Can you please include fix for WINEDLLPATH in your PR? There is similar problem.

I have WINEDLLPATH="$HOME/.local/lib64/wine:$HOME/.local/lib/wine", and it's sad Proton don't use libraries placed there (like locally built lsteamclient, nvapi, etc.).

@NoXPhasma
Copy link
Contributor Author

My pull request has been merged. Just a matter of time till it gets released.

@pchome
Copy link
Contributor

pchome commented Oct 17, 2018

@NoXPhasma

My pull request has been merged. Just a matter of time till it gets released.

  1. It already released hours ago
  2. Not a problem anymore, use util.winedll_override('dllname', 'x') (see README)

simons-public pushed a commit that referenced this issue Oct 26, 2018
simons-public pushed a commit that referenced this issue Nov 13, 2020
fixed the installation of pip and the python packages
techtonik pushed a commit to techtonik/protonfixes that referenced this issue Feb 24, 2021
techtonik pushed a commit to techtonik/protonfixes that referenced this issue Feb 24, 2021
…dier

fixed the installation of pip and the python packages
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants