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

Automatically find Titanfall installation folder #34

Closed
Alystrasz opened this issue Jan 9, 2022 · 19 comments · Fixed by #53
Closed

Automatically find Titanfall installation folder #34

Alystrasz opened this issue Jan 9, 2022 · 19 comments · Fixed by #53
Assignees
Labels
enhancement New feature or request
Projects

Comments

@Alystrasz
Copy link
Contributor

On Windows, by running Get-Item -Path Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Respawn\Titanfall2\, you can get game folder, without having to ask user for it.

I don't know if we can find game folder this way on Linux?

@0neGal 0neGal added the enhancement New feature or request label Jan 9, 2022
@0neGal
Copy link
Owner

0neGal commented Jan 9, 2022

I don't know if we can find game folder this way on Linux?

We can not. Since it's completely user based (because of Wine), the best we could do is check for if Lutris is installed which has a CLI tool to get paths for installed games and alike, as for executing that command, just use require("child_process").exec or .spawn

@Alystrasz
Copy link
Contributor Author

Is a PR for Windows worth then?
If viper runs on Linux, we can still ask for game path the way we're actually doing it.

@0neGal
Copy link
Owner

0neGal commented Jan 9, 2022

Is a PR for Windows worth then?

I think it is, it'll make the install process far easier for the end user, as they may not even know where it is, and the whole point of Viper is to make everything easier. So I think it's a good idea to implement this.

If viper runs on Linux, we can still ask for game path the way we're actually doing it.

Currently nothing is implemented because simply running the executable will launch the game with the system Wine not Proton, along with no env variables or anything that may or may not be needed to get it running.

However I will be implementing a way for people to add their own custom command to launch, and try and detect most things (if the user is using Steam or Lutris)

@0neGal 0neGal added this to To do in Viper Jan 12, 2022
@0neGal 0neGal pinned this issue Jan 12, 2022
@Alystrasz
Copy link
Contributor Author

Lemme work on this.

@0neGal
Copy link
Owner

0neGal commented Jan 20, 2022

That'd be very nice, because I don't have an easy way to test things in a Windows environment :p

@Alystrasz
Copy link
Contributor Author

I hope you'll be able to help me on the Linux part!

@0neGal
Copy link
Owner

0neGal commented Jan 20, 2022

I will, don't worry, it is mildly more complicated, but I'll handle that part if you want me to.

@Alystrasz
Copy link
Contributor Author

I never tried to run a game on Linux actually, so I don't even know where to start...

There are several possibilities, right?
Like wine, lutris, proton?

@0neGal
Copy link
Owner

0neGal commented Jan 20, 2022

There are several possibilities, right?
Like wine, lutris, proton?

Lutris is simply a program that runs complex scripts to setup games to work and circumvent issues because a game wasn't meant for Linux etc, whether it be a native game or through Wine

Wine is a compatibility layer which simply translates Windows code to Linux, and thereby allows running Windows programs (not an emulator btw, Wine literally stands for Wine-Is-Not-(an)-Emulator)).

Proton is Valve's fork of Wine which focuses on fixing compatibility with games specifically, while the WineHQ team will usually just focus on getting Windows API's translated, hence it's just recommended to use Proton-runtime over the official Wine one.

I personally run my games through Lutris with Proton-GE (a fork of Proton), along with several environment variables, and with all that there's no easy way to assume how to start the game, hence the issue I have in #38

However if a user uses Steam which'll use Proton, we can ask Steam "where's this game" and it'll reply, Lutris also has those cli options, however a user may be using a completely different setup or way of starting Titanfall. Which makes it hard, however we can still somewhat retrieve it, more importantly if a user isn't using Lutris or Steam to install they likely know where they install it and are tech savvy enough to set it manually.

I never tried to run a game on Linux actually, so I don't even know where to start...

The easiest way to get going is either through Steam or Lutris, I did the latter, then after it's installed rename or change which executable is being started from Titanfall2.exe to NorthstarLauncher.exe as for Steam you can't just change which one it launches and you'd have to rename Northstar, or make a symlink.

I lately had some issues with Northstar not being able to authenticate with Origin, originally I had it all in one game in Lutris, where I just ran Northstar Launcher, it'd auto run Origin to authenticate, but for some reason that broke, if I then ran Origin by itself it figured it all out. It happened right after an Origin update, so it's likely something messed with credentials or alike, I don't really know...

@3top1a
Copy link
Contributor

3top1a commented Jan 22, 2022

Just thought I'd give you a simple but cross platform answer I found.


This file C:\Program Files (x86)\Steam\steamapps\libraryfolders.vdf

Contains the paths to all local steam libraries. (excluding the one in the default library)

Then get just get the value in the steam_appid.txt that's located in each game's folder ({library}\steamapps\common\{game}\steam_appid.txt) and you will have a list of all installed games' steam app id.

On my Linux installation this file is at $HOME/.steam/steam/steamapps.

The content of this file for me is:

"libraryfolders"
{
"contentstatsid"                "4001220649266302598"
"0"
{
"path"          "/home/reee/.local/share/Steam"
"label"         ""
"contentid"             "4001220649266302598"
"totalsize"             "0"
"update_clean_bytes_tally"              "4178971275"
"time_last_update_corruption"           "0"
"apps"
{
}
}
"1"
{
"path"          "/qd/Games"
"label"         ""
"contentid"             "5077979835901325881"
"totalsize"             "970750840832"
"update_clean_bytes_tally"              "318568649"
"time_last_update_corruption"           "0"
"apps"
{
"10"            "292616113"
"70"            "532006241"
"100"           "1260581818"
"220"           "3766825842"
"440"           "24787089354"
"480"           "1906055"
"550"           "15050282522"
"730"           "29551158514"
"745"           "158517065"
"4000"          "4117247071"
"17410"         "7745606603"
"50130"         "8400223089"
"107410"                "44320657959"
"205930"                "1756734456"
"207140"                "737401713"
"218620"                "82153135141"
"220200"                "4780889206"
"223470"                "7639087316"
"228980"                "557380686"
"233450"                "507303801"
"233800"                "417057776"
"238090"                "25212463702"
"243750"                "3249928416"
"244850"                "37635686865"
"255710"                "11901211692"
"271240"                "1498721912"
"298740"                "5254094583"
"310560"                "43093628811"
"322330"                "2552336589"
"359320"                "21029542985"
"365670"                "701365361"
"427520"                "1757013010"
"438100"                "803988632"
"447040"                "26328581251"
"476530"                "157126400"
"544550"                "4698859370"
"581630"                "1251787612"
"605230"                "718203420"
"677620"                "18379376574"
"739630"                "18114929166"
"839310"                "6219808577"
"961940"                "399675883"
"1054830"               "506437594"
"1070560"               "11307"
"1113280"               "910331459"
"1128810"               "835095615"
"1237970"               "68431323338"
"1245040"               "1036890088"
"1255980"               "5718209028"
"1278060"               "2455041087"
"1391110"               "635367359"
"1420170"               "909583887"
"1454190"               "1209857772"
"1493710"               "1105066334"
"1568590"               "357126891"
"1580130"               "1107619726"
}
}
}

From this you can find where TF2 is installed just by parsing it.

Here's two .vdf parsers I found:
One from p0358 (on npm)
One from lukezbihlyj (php)
Another from rossengeorgiev (on npm too)

@0neGal
Copy link
Owner

0neGal commented Jan 22, 2022

I only think that's actually useful for Linux, as the PowerShell/Get-Item method should work regardless of it's installed through Steam, although feel free to correct me on that.

@3top1a
Copy link
Contributor

3top1a commented Jan 22, 2022

I only think that's actually useful for Linux, as the PowerShell/Get-Item method should work regardless of it's installed through Steam, although feel free to correct me on that.

Isn't that only going to work if the game has been run at least one?

@0neGal
Copy link
Owner

0neGal commented Jan 22, 2022

Isn't that only going to work if the game has been run at least one?

Likely, unless the installer sets up the regkeys, likely not. However I think we should at least prioritize it, and if nothing is found use the VDF method as a fallback.

@3top1a
Copy link
Contributor

3top1a commented Jan 22, 2022

Isn't that only going to work if the game has been run at least one?

Likely, unless the installer sets up the regkeys, likely not. However I think we should at least prioritize it, and if nothing is found use the VDF method as a fallback.

I agree, makes most sense as a fallback, and it also works on Linux.

@0neGal
Copy link
Owner

0neGal commented Jan 22, 2022

I would also say using rossengeorgiev's parser would probably be the best idea here...

@3top1a
Copy link
Contributor

3top1a commented Jan 22, 2022

Screenshot_index js - titanfalllocationtest - VSCodium_2

Here's a simple script I did that finds the path of Titanfall 2

vdf = require('simple-vdf');
const fs = require('fs')

fs.readFile('/home/reee/.steam/steam/steamapps/libraryfolders.vdf', 'utf-8',
function (err,vdf_text) {
    if (err) {
        return console.log(err);
    }
    data = vdf.parse(vdf_text);

    //data['libraryfolders']
    // `.length - 1` This is because the last value is `contentstatsid`
    for (let pathIterator = 0; pathIterator < Object.values(data['libraryfolders']).length - 1; pathIterator++) {
        let data_array = Object.values(data['libraryfolders'][pathIterator])
        // Print current location
        console.log("=== %s ===", data_array[0])
        
        if (fs.existsSync(data_array[0] + "/steamapps/common/Titanfall2/")) {
            console.log("TITANFALL FOUND AT: %s", data_array[0])
        }
    }
});

@3top1a
Copy link
Contributor

3top1a commented Jan 22, 2022

I have not tested it on Windows yet though

@3top1a
Copy link
Contributor

3top1a commented Jan 22, 2022

I've forked and started working on automatic detection, I'll open a PR once I'm done

@0neGal
Copy link
Owner

0neGal commented Jan 22, 2022

I merged #51 and #52 into #53, as there's no real benefit to having two PR's, well, the original reason I did was because I managed to mess up some things with Git.

@0neGal 0neGal linked a pull request Jan 24, 2022 that will close this issue
Viper automation moved this from To do to Done Jan 25, 2022
@0neGal 0neGal unpinned this issue Jan 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Viper
Done
Development

Successfully merging a pull request may close this issue.

3 participants