Frame: use Half-Life from Steam where it is, read only

The Android container on the Frame shows the headset's Steam folders at the
same paths, read only. At start the app looks for steamapps/common/Half-Life
(valve/liblist.gam) in the Steam library and in the other libraries
libraryfolders.vdf lists, and gives the engine that folder as XASH3D_RODIR.
The engine searches it after the writable folder, so the saves, the
settings and the files this app puts in /sdcard/Documents/Lambda1VR (the
replacement models and sprites) win over Steam's. Nothing is written into the
Steam folder. If there's no Half-Life there, a copy in Documents is used as
before, and a [data] line in the log says which one it was.

Builds. Haven't tried it on the headset yet.
This commit is contained in:
Madison committed 2026-10-04 23:38:22 +09:00
1 parent 571fed0ef5
commit a4f12f84fd
2 files changed
+78 -7

No files matched your search

@@ -151,6 +151,53 @@ import static android.system.Os.setenv;
System.exit(0);
}
/**
* The Frame's Android container shows the headset's Steam folders at the same paths, read only. If
* Half-Life is installed there, the game's files can be used from where they are instead of a copy.
* Looks in the Steam library folders (the main one, and the others libraryfolders.vdf lists, such as
* one on an SD card) for steamapps/common/Half-Life/valve/liblist.gam. Returns the Half-Life folder or null.
*/
private String findSteamHalfLife()
{
final String steam = "/home/steamos/.local/share/Steam";
java.util.ArrayList<String> libraries = new java.util.ArrayList<String>();
libraries.add(steam);
try
{
BufferedReader br = new BufferedReader(new FileReader(steam + "/steamapps/libraryfolders.vdf"));
String line;
while ((line = br.readLine()) != null)
{
// "path" "/some/library"
line = line.trim();
if (line.startsWith("\"path\""))
{
String[] parts = line.split("\"");
if (parts.length >= 4 && !libraries.contains(parts[3]))
{
libraries.add(parts[3]);
}
}
}
br.close();
} catch (IOException e)
{
Log.i(TAG, "[data] no libraryfolders.vdf: " + e.getMessage());
}
for (String library : libraries)
{
File liblist = new File(library + "/steamapps/common/Half-Life/valve/liblist.gam");
if (liblist.canRead())
{
return library + "/steamapps/common/Half-Life";
}
Log.i(TAG, "[data] no Half-Life in the Steam library " + library);
}
return null;
}
public void create()
{
copy_asset(getFilesDir().getPath(), "extras.pak", false);
@@ -509,6 +556,22 @@ import static android.system.Os.setenv;
try {
ApplicationInfo info = getApplicationInfo();
setenv("XASH3D_BASEDIR", DATA_DIR, true);
if (BuildConfig.STEAM_FRAME)
{
// Half-Life from Steam, read only, in place. The folder above is searched after it, so what's
// in there (the saves, the settings, this app's own models and sprites) wins over Steam's files.
String steamHalfLife = findSteamHalfLife();
if (steamHalfLife != null)
{
setenv("XASH3D_RODIR", steamHalfLife, true);
Log.i(TAG, "[data] game files: Steam, in place, read only (" + steamHalfLife + "); saves and settings in " + DATA_DIR);
}
else
{
Log.i(TAG, "[data] game files: no Steam install of Half-Life found, using the copy in " + DATA_DIR);
}
}
setenv("XASH3D_GAMELIBDIR", info.nativeLibraryDir, true);
setenv("XASH3D_GAMEDIR", "valve", true);
setenv( "XASH3D_EXTRAS_PAK1", getFilesDir().getPath() + "/extras.pak", true );