hydralauncher / hydra

Hydra is a game launcher with its own embedded bittorrent client
MIT License
10.67k stars 2.5k forks source link

[BUG] Installers are not handled correctly on Linux (using Lutris or Wine) #299

Closed scrlkx closed 4 months ago

scrlkx commented 5 months ago

Describe the bug We already have the ability to handle running game installers using Lutris or Wine as you can see here and here.

However, there is something wrong on the lines above it. We have an extra logic that appends a setup.exe to the file path which results in an invalid path to the game file. And, when this path is not found, we just call shell.openPath(gamePath) and, as Linux doesn't know how to open .exe files, it just does it's best opening with Archive Manager or something like that.

That means the lines that handle opening the installer with Lutris or Wine never reach. Removing this piece of code seems to fix the issue, but I assume they are there for a reason?

const setupPath = path.join(gamePath, "setup.exe");
if (!fs.existsSync(setupPath)) {
    shell.openPath(gamePath);
    return true;
}

On the lines above, gamePath is a valid path (pointing to the installer file), but setupPath it's not. fs.existsSync(setupPath) will always be false so we will always do shell.openPath(gamePath);.

To Reproduce Steps to reproduce the behavior:

  1. Open Hydra on a Linux distribution
  2. Download any game
  3. After download is finish, click on Install

Note that, what will happend after you click install depends on which distribution/desktop environment you are running. In case of GNOME it should open Archive Manager.

Expected behavior In case Lutris or Wine are installed, the game installer should open on them. I'm not so sure about what should happen if they are not.

Screenshots If applicable, add screenshots to help explain your problem.

Additional context

zamitto commented 4 months ago

Ok, let me see if I understood your issue and PR (I'm I downloaded two games Crow Country and Rabit and Steel.

Crow Country

It has a setup.exe inside the download folder. So with and without your PR, wine opens the setup.exe

Rabit and Steel

It has a .rar file inside the download folder.

Is this the expected result when the download does not have a setup.exe?

scrlkx commented 4 months ago

When I created this issue I was trying to install a game that had an installer file but it was not called setup.exe. I should have mentioned the game's name in the issue, as I can't remember it anymore. I assumed that it was not common for a game to have a setup.exe and that games tend to come with different installer names. I did some tests by installing some random games today and noticed that this is not the case.

Just to clarify:

In both cases, I think adding a dialog saying "The game installer was not found, please check yourself and add the game to the library later" would be good.

scrlkx commented 4 months ago

The game I was trying to install was 18 Wheels of Steel: Across America.

zamitto commented 4 months ago

May I suggest something?

  1. If there is a setup.exe inside the gamePath, we call wine ${setupPath} and return
  2. If there is not asetup.exe but there is any other .exe file, we call wine ${gamePath}
  3. If not, we open the directory using shell.openPath(gamePath)

The Windows conditional remains the same as it is in your PR. These checks should happen after that.

What do you think @scrlkx? If you think it is good enough, could you implement this in your PR?

zamitto commented 4 months ago

I think it solves both problems

scrlkx commented 4 months ago

That's sounds good, I will take another look into it later.