mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-05 20:45:43 +00:00
Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
133980c4d2 | ||
|
|
334fc86b20 | ||
|
|
70ee78f6e2 | ||
|
|
a43f4d5ba6 | ||
|
|
220e9d8344 |
No files matched your search
@@ -48,7 +48,7 @@ object StoreLaunch {
|
|||||||
if (sidecar.store != Store.ROCKSTAR) lines += "rem Written by DroidDeck for ${sidecar.store.label}: ${sidecar.title}. Steam's shortcut runs this file."
|
if (sidecar.store != Store.ROCKSTAR) lines += "rem Written by DroidDeck for ${sidecar.store.label}: ${sidecar.title}. Steam's shortcut runs this file."
|
||||||
lines += "cd /d \"%~dp0$dir\""
|
lines += "cd /d \"%~dp0$dir\""
|
||||||
for ((k, v) in sidecar.env) if (ENV_NAME.matches(k)) lines += "set \"$k=${v.replace("\"", "")}\""
|
for ((k, v) in sidecar.env) if (ENV_NAME.matches(k)) lines += "set \"$k=${v.replace("\"", "")}\""
|
||||||
val args = sidecar.args.joinToString(" ") { if (sidecar.store == Store.ROCKSTAR) batchArg(it) else quoteArg(it) }
|
val args = sidecar.args.joinToString(" ") { if (sidecar.store == Store.ROCKSTAR || sidecar.store == Store.GOG && (it.any { c -> c in BATCH_META } || ' ' in it && it.endsWith('\\'))) batchArg(it) else quoteArg(it) }
|
||||||
val run = "\"%~dp0$exe\"" + (if (args.isNotEmpty()) " $args" else "")
|
val run = "\"%~dp0$exe\"" + (if (args.isNotEmpty()) " $args" else "")
|
||||||
if (sidecar.store == Store.EPIC || sidecar.store == Store.UBISOFT) {
|
if (sidecar.store == Store.EPIC || sidecar.store == Store.UBISOFT) {
|
||||||
lines += "set \"$ROOT_VAR=Z:\""
|
lines += "set \"$ROOT_VAR=Z:\""
|
||||||
@@ -105,6 +105,8 @@ object StoreLaunch {
|
|||||||
return lines.joinToString("\r\n") + "\r\n"
|
return lines.joinToString("\r\n") + "\r\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private const val BATCH_META = "%^&|<>()\""
|
||||||
|
|
||||||
private val ENV_NAME = Regex("[A-Za-z_][A-Za-z0-9_]*")
|
private val ENV_NAME = Regex("[A-Za-z_][A-Za-z0-9_]*")
|
||||||
|
|
||||||
private fun batchArg(arg: String): String {
|
private fun batchArg(arg: String): String {
|
||||||
@@ -141,6 +143,7 @@ object StoreLaunch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun adopt(folder: File, sidecar: StoreGameSidecar): StoreGameSidecar {
|
fun adopt(folder: File, sidecar: StoreGameSidecar): StoreGameSidecar {
|
||||||
|
if (sidecar.store == Store.GOG) return com.droiddeck.launcher.stores.gog.GogBackend.adoptPlayTask(folder, sidecar)
|
||||||
if (sidecar.store !in listOf(Store.UBISOFT, Store.ROCKSTAR) || !sidecar.isInstalled) return sidecar
|
if (sidecar.store !in listOf(Store.UBISOFT, Store.ROCKSTAR) || !sidecar.isInstalled) return sidecar
|
||||||
if (sidecar.store == Store.ROCKSTAR && java.nio.file.Files.isSymbolicLink(File(folder, LAUNCHER).toPath())) return sidecar.copy(launcher = null)
|
if (sidecar.store == Store.ROCKSTAR && java.nio.file.Files.isSymbolicLink(File(folder, LAUNCHER).toPath())) return sidecar.copy(launcher = null)
|
||||||
val wrongExe = !sidecar.exeFile(folder).isFile || sidecar.exe.contains("installer", ignoreCase = true) || sidecar.exe.contains("autorun", ignoreCase = true)
|
val wrongExe = !sidecar.exeFile(folder).isFile || sidecar.exe.contains("installer", ignoreCase = true) || sidecar.exe.contains("autorun", ignoreCase = true)
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import com.droiddeck.launcher.stores.StoreGameSidecar
|
|||||||
import com.droiddeck.launcher.stores.StoreInstallRoot
|
import com.droiddeck.launcher.stores.StoreInstallRoot
|
||||||
import com.droiddeck.launcher.stores.StoreInstalls
|
import com.droiddeck.launcher.stores.StoreInstalls
|
||||||
import com.droiddeck.launcher.stores.StoreLanguage
|
import com.droiddeck.launcher.stores.StoreLanguage
|
||||||
|
import com.droiddeck.launcher.stores.StoreLaunch
|
||||||
import com.droiddeck.launcher.stores.StoreLoginActivity
|
import com.droiddeck.launcher.stores.StoreLoginActivity
|
||||||
import com.droiddeck.launcher.stores.StoreNet
|
import com.droiddeck.launcher.stores.StoreNet
|
||||||
import com.droiddeck.launcher.stores.StoresState
|
import com.droiddeck.launcher.stores.StoresState
|
||||||
@@ -21,6 +22,22 @@ import java.io.File
|
|||||||
import java.util.concurrent.atomic.AtomicBoolean
|
import java.util.concurrent.atomic.AtomicBoolean
|
||||||
|
|
||||||
object GogBackend : StoreBackend {
|
object GogBackend : StoreBackend {
|
||||||
|
const val PLAY_TASK_READ = "gogPlayTaskRead"
|
||||||
|
|
||||||
|
fun withPlayTask(folder: File, sidecar: StoreGameSidecar, replaceExe: Boolean): StoreGameSidecar {
|
||||||
|
if (!runCatching { GogDownloadManager.manifestsReadable(folder) }.getOrDefault(false)) return sidecar.copy(extra = sidecar.extra - PLAY_TASK_READ)
|
||||||
|
val task = runCatching { GogDownloadManager.declaredGameTask(folder, sidecar.id) }.getOrNull()?.takeIf { replaceExe || it.args.isNotEmpty() }
|
||||||
|
val next = if (task != null) sidecar.copy(exe = task.path, workdir = task.workDir, args = task.args) else sidecar
|
||||||
|
return next.copy(extra = next.extra + (PLAY_TASK_READ to "1"))
|
||||||
|
}
|
||||||
|
|
||||||
|
fun adoptPlayTask(folder: File, sidecar: StoreGameSidecar): StoreGameSidecar {
|
||||||
|
if (sidecar.store != Store.GOG || !sidecar.isInstalled || PLAY_TASK_READ in sidecar.extra) return sidecar
|
||||||
|
val next = withPlayTask(folder, sidecar, replaceExe = false)
|
||||||
|
if (PLAY_TASK_READ !in next.extra) return sidecar
|
||||||
|
return runCatching { StoreLaunch.writeLauncher(folder, next).also { it.write(folder) } }.getOrDefault(sidecar)
|
||||||
|
}
|
||||||
|
|
||||||
override val store: Store = Store.GOG
|
override val store: Store = Store.GOG
|
||||||
|
|
||||||
override fun signIn(context: Context) {
|
override fun signIn(context: Context) {
|
||||||
@@ -136,12 +153,13 @@ object GogBackend : StoreBackend {
|
|||||||
val sidecar = StoreGameSidecar(
|
val sidecar = StoreGameSidecar(
|
||||||
Store.GOG, game.gameId, game.title, exe = result.exeRelative.ifEmpty { "" },
|
Store.GOG, game.gameId, game.title, exe = result.exeRelative.ifEmpty { "" },
|
||||||
workdir = result.workDir,
|
workdir = result.workDir,
|
||||||
|
args = result.args,
|
||||||
installVersion = result.buildId, installedAt = System.currentTimeMillis(),
|
installVersion = result.buildId, installedAt = System.currentTimeMillis(),
|
||||||
cover = item.tallImageUrl ?: item.imageUrl, hero = item.imageUrl,
|
cover = item.tallImageUrl ?: item.imageUrl, hero = item.imageUrl,
|
||||||
logo = item.logoUrl ?: fetchLogo(game.gameId),
|
logo = item.logoUrl ?: fetchLogo(game.gameId),
|
||||||
extra = mapOf(com.droiddeck.launcher.frontend.WinCompSources.GOG_DEPENDENCIES to result.dependencies.joinToString(","))
|
extra = mapOf(com.droiddeck.launcher.frontend.WinCompSources.GOG_DEPENDENCIES to result.dependencies.joinToString(","))
|
||||||
+ (if (result.dependenciesRead) mapOf(com.droiddeck.launcher.frontend.WinCompSources.LIST_READ to "1") else emptyMap())
|
+ (if (result.dependenciesRead) mapOf(com.droiddeck.launcher.frontend.WinCompSources.LIST_READ to "1") else emptyMap())
|
||||||
+ mapOf(StoreLanguage.EXTRA to installedLanguage),
|
+ mapOf(StoreLanguage.EXTRA to installedLanguage, PLAY_TASK_READ to "1"),
|
||||||
)
|
)
|
||||||
if (sidecar.exe.isEmpty()) handle.log("gog: no exe found in ${folder.name}; pick one in Steam settings › Added games")
|
if (sidecar.exe.isEmpty()) handle.log("gog: no exe found in ${folder.name}; pick one in Steam settings › Added games")
|
||||||
StoreInstalls.complete(app, folder, onStep = { done, steps -> handle.stageProgress(done.toLong(), steps.toLong()) }, sidecar = if (sidecar.exe.isEmpty()) sidecar.copy(exe = "game.exe") else sidecar)
|
StoreInstalls.complete(app, folder, onStep = { done, steps -> handle.stageProgress(done.toLong(), steps.toLong()) }, sidecar = if (sidecar.exe.isEmpty()) sidecar.copy(exe = "game.exe") else sidecar)
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import android.util.Log;
|
|||||||
import com.droiddeck.launcher.frontend.AddedGames;
|
import com.droiddeck.launcher.frontend.AddedGames;
|
||||||
import com.droiddeck.launcher.stores.StoreLanguage;
|
import com.droiddeck.launcher.stores.StoreLanguage;
|
||||||
import com.droiddeck.launcher.stores.StoreLog;
|
import com.droiddeck.launcher.stores.StoreLog;
|
||||||
|
import com.droiddeck.launcher.stores.ea.EaPaths;
|
||||||
import com.droiddeck.launcher.stores.download.StoreDownloadTier;
|
import com.droiddeck.launcher.stores.download.StoreDownloadTier;
|
||||||
|
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
@@ -68,6 +69,7 @@ public final class GogDownloadManager {
|
|||||||
public String language;
|
public String language;
|
||||||
/** GOG's working directory for the exe: "" is the install root, null when no task declared it. */
|
/** GOG's working directory for the exe: "" is the install root, null when no task declared it. */
|
||||||
public String workDir;
|
public String workDir;
|
||||||
|
public List<String> args = new ArrayList<>();
|
||||||
Result(String exeRelative, String buildId, long bytes) { this.exeRelative = exeRelative; this.buildId = buildId; this.bytes = bytes; }
|
Result(String exeRelative, String buildId, long bytes) { this.exeRelative = exeRelative; this.buildId = buildId; this.bytes = bytes; }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -250,7 +252,7 @@ public final class GogDownloadManager {
|
|||||||
writeFile(new File(installPath, MARKER), ("{\"gameId\":\"" + game.gameId + "\",\"generation\":1}").getBytes("UTF-8"));
|
writeFile(new File(installPath, MARKER), ("{\"gameId\":\"" + game.gameId + "\",\"generation\":1}").getBytes("UTF-8"));
|
||||||
GameTask task = pickTask(installPath, game.gameId, null, game.title);
|
GameTask task = pickTask(installPath, game.gameId, null, game.title);
|
||||||
out.result = new Result(task == null ? "" : task.path, "", planned);
|
out.result = new Result(task == null ? "" : task.path, "", planned);
|
||||||
if (task != null) out.result.workDir = task.workDir;
|
if (task != null) { out.result.workDir = task.workDir; out.result.args = task.args; }
|
||||||
return out;
|
return out;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
out.error = "exception: " + e.getClass().getSimpleName();
|
out.error = "exception: " + e.getClass().getSimpleName();
|
||||||
@@ -306,6 +308,7 @@ public final class GogDownloadManager {
|
|||||||
GogMaintenance.captureOffline(game.gameId, installPath, downloads);
|
GogMaintenance.captureOffline(game.gameId, installPath, downloads);
|
||||||
Result result = new Result(exe, "", total);
|
Result result = new Result(exe, "", total);
|
||||||
result.workDir = task.workDir;
|
result.workDir = task.workDir;
|
||||||
|
result.args = task.args;
|
||||||
return result;
|
return result;
|
||||||
} catch (InstallerException e) {
|
} catch (InstallerException e) {
|
||||||
throw e;
|
throw e;
|
||||||
@@ -756,7 +759,7 @@ public final class GogDownloadManager {
|
|||||||
* one; any other {@code goggame-*.info} in the folder is only the fallback. Builds without a
|
* one; any other {@code goggame-*.info} in the folder is only the fallback. Builds without a
|
||||||
* manifest fall through to the hint and search below.
|
* manifest fall through to the hint and search below.
|
||||||
*/
|
*/
|
||||||
private static GameTask declaredGameTask(File installPath, String gameId) {
|
static GameTask declaredGameTask(File installPath, String gameId) {
|
||||||
File own = gameId == null || gameId.isEmpty() ? null : new File(installPath, "goggame-" + gameId + ".info");
|
File own = gameId == null || gameId.isEmpty() ? null : new File(installPath, "goggame-" + gameId + ".info");
|
||||||
if (own != null && !own.isFile()) own = null;
|
if (own != null && !own.isFile()) own = null;
|
||||||
List<File> others = new ArrayList<>();
|
List<File> others = new ArrayList<>();
|
||||||
@@ -780,12 +783,28 @@ public final class GogDownloadManager {
|
|||||||
return best;
|
return best;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static boolean manifestsReadable(File installPath) {
|
||||||
|
File[] files = installPath.listFiles();
|
||||||
|
if (files == null) return false;
|
||||||
|
for (File f : files) {
|
||||||
|
if (!f.isFile() || !f.getName().startsWith("goggame-") || !f.getName().endsWith(".info")) continue;
|
||||||
|
try {
|
||||||
|
new JSONObject(new String(Files.readAllBytes(f.toPath()), StandardCharsets.UTF_8));
|
||||||
|
} catch (Exception e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
static final class GameTask {
|
static final class GameTask {
|
||||||
final String path;
|
final String path;
|
||||||
/** GOG's working directory for the task: "" is the install root, null when no task declared it. */
|
/** GOG's working directory for the task: "" is the install root, null when no task declared it. */
|
||||||
final String workDir;
|
final String workDir;
|
||||||
final int rank;
|
final int rank;
|
||||||
GameTask(String path, String workDir, int rank) { this.path = path; this.workDir = workDir; this.rank = rank; }
|
final List<String> args;
|
||||||
|
GameTask(String path, String workDir, int rank) { this(path, workDir, rank, Collections.<String>emptyList()); }
|
||||||
|
GameTask(String path, String workDir, int rank, List<String> args) { this.path = path; this.workDir = workDir; this.rank = rank; this.args = args; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The task this manifest would be played from, or null when it names none that exists. */
|
/** The task this manifest would be played from, or null when it names none that exists. */
|
||||||
@@ -806,9 +825,11 @@ public final class GogDownloadManager {
|
|||||||
if (rank == 0 || (best != null && rank <= best.rank)) continue;
|
if (rank == 0 || (best != null && rank <= best.rank)) continue;
|
||||||
String path = task.optString("path", "").replace('\\', '/').replaceAll("/+", "/").replaceFirst("^(\\.?/)+", "");
|
String path = task.optString("path", "").replace('\\', '/').replaceAll("/+", "/").replaceFirst("^(\\.?/)+", "");
|
||||||
if (path.isEmpty()) continue;
|
if (path.isEmpty()) continue;
|
||||||
|
if (!new File(installPath, path).isFile()) path = EaPaths.INSTANCE.relativeOnDisk(installPath, path);
|
||||||
|
if (path == null) continue;
|
||||||
File exe = new File(installPath, path);
|
File exe = new File(installPath, path);
|
||||||
if (!exe.isFile() || gogSupportExe(exe.getName()) || !inside(installPath, exe)) continue;
|
if (!exe.isFile() || gogSupportExe(exe.getName()) || !inside(installPath, exe)) continue;
|
||||||
best = new GameTask(path, taskWorkDir(installPath, task), rank);
|
best = new GameTask(path, taskWorkDir(installPath, task), rank, EaPaths.INSTANCE.splitArgs(task.optString("arguments", "")));
|
||||||
}
|
}
|
||||||
return best;
|
return best;
|
||||||
}
|
}
|
||||||
@@ -825,6 +846,10 @@ public final class GogDownloadManager {
|
|||||||
while (dir.startsWith("./")) dir = dir.substring(2);
|
while (dir.startsWith("./")) dir = dir.substring(2);
|
||||||
dir = dir.replaceAll("^/+", "").replaceAll("/+$", "");
|
dir = dir.replaceAll("^/+", "").replaceAll("/+$", "");
|
||||||
if (dir.isEmpty() || dir.equals(".")) return "";
|
if (dir.isEmpty() || dir.equals(".")) return "";
|
||||||
|
if (!new File(installPath, dir).isDirectory()) {
|
||||||
|
dir = EaPaths.INSTANCE.relativeOnDisk(installPath, dir);
|
||||||
|
if (dir == null) return "";
|
||||||
|
}
|
||||||
File folder = new File(installPath, dir);
|
File folder = new File(installPath, dir);
|
||||||
return folder.isDirectory() && inside(installPath, folder) ? dir : "";
|
return folder.isDirectory() && inside(installPath, folder) ? dir : "";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -181,7 +181,7 @@ internal object GogMaintenance {
|
|||||||
}
|
}
|
||||||
val sidecar = StoreGameSidecar.parse(journal.getJSONObject("sidecar").toString()) ?: error("The original GOG settings are missing")
|
val sidecar = StoreGameSidecar.parse(journal.getJSONObject("sidecar").toString()) ?: error("The original GOG settings are missing")
|
||||||
target.write(folder)
|
target.write(folder)
|
||||||
StoreInstalls.complete(context, folder, sidecar.copy(installVersion = target.build, state = StoreGameSidecar.STATE_INSTALLED))
|
StoreInstalls.complete(context, folder, GogBackend.withPlayTask(folder, sidecar.copy(installVersion = target.build, state = StoreGameSidecar.STATE_INSTALLED), replaceExe = true))
|
||||||
check(GogFiles.journal(folder).delete()) { "Could not finish the GOG recovery record" }
|
check(GogFiles.journal(folder).delete()) { "Could not finish the GOG recovery record" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -284,7 +284,7 @@ internal object GogMaintenance {
|
|||||||
val target = GogInstallRecord.read(folder)?.takeIf { proposal.operation == GogOperation.PATCH || proposal.operation == GogOperation.REFRESH && proposal.target.source != "depot" } ?: proposal.target
|
val target = GogInstallRecord.read(folder)?.takeIf { proposal.operation == GogOperation.PATCH || proposal.operation == GogOperation.REFRESH && proposal.target.source != "depot" } ?: proposal.target
|
||||||
check(target.verified) { "The patch completed, but its resulting version could not be verified. Inspect the game or use a full offline refresh." }
|
check(target.verified) { "The patch completed, but its resulting version could not be verified. Inspect the game or use a full offline refresh." }
|
||||||
target.write(folder)
|
target.write(folder)
|
||||||
StoreInstalls.complete(app, folder, sidecar.copy(installVersion = target.build.ifBlank { target.version }, state = StoreGameSidecar.STATE_INSTALLED))
|
StoreInstalls.complete(app, folder, GogBackend.withPlayTask(folder, sidecar.copy(installVersion = target.build.ifBlank { target.version }, state = StoreGameSidecar.STATE_INSTALLED), replaceExe = true))
|
||||||
check(GogFiles.journal(folder).delete()) { "Could not finish the GOG recovery record" }
|
check(GogFiles.journal(folder).delete()) { "Could not finish the GOG recovery record" }
|
||||||
runCatching { cleanCaches() }.onFailure { handle.log("gog: completed; could not remove expendable cache: ${it.message}") }
|
runCatching { cleanCaches() }.onFailure { handle.log("gog: completed; could not remove expendable cache: ${it.message}") }
|
||||||
checkedAt.remove(folder.path)
|
checkedAt.remove(folder.path)
|
||||||
@@ -397,6 +397,7 @@ internal object GogMaintenance {
|
|||||||
val task = GogDownloadManager.pickTask(folder, game.gameId, GogContent.tempExecutable(target.manifest), game.title)
|
val task = GogDownloadManager.pickTask(folder, game.gameId, GogContent.tempExecutable(target.manifest), game.title)
|
||||||
val result = GogDownloadManager.Result(task?.path ?: "", build.id, disk)
|
val result = GogDownloadManager.Result(task?.path ?: "", build.id, disk)
|
||||||
result.workDir = task?.workDir
|
result.workDir = task?.workDir
|
||||||
|
result.args = task?.args.orEmpty()
|
||||||
result.language = target.language
|
result.language = target.language
|
||||||
result.dependencies = target.manifest.optJSONArray("dependencies")?.strings().orEmpty()
|
result.dependencies = target.manifest.optJSONArray("dependencies")?.strings().orEmpty()
|
||||||
result.dependenciesRead = true
|
result.dependenciesRead = true
|
||||||
|
|||||||
@@ -1,7 +1,12 @@
|
|||||||
package com.droiddeck.launcher.stores.gog
|
package com.droiddeck.launcher.stores.gog
|
||||||
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
import com.droiddeck.launcher.stores.Store
|
||||||
|
import com.droiddeck.launcher.stores.StoreGameSidecar
|
||||||
|
import com.droiddeck.launcher.stores.StoreLaunch
|
||||||
import org.junit.Assert.assertEquals
|
import org.junit.Assert.assertEquals
|
||||||
|
import org.junit.Assert.assertFalse
|
||||||
|
import org.junit.Assert.assertTrue
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.robolectric.RobolectricTestRunner
|
import org.robolectric.RobolectricTestRunner
|
||||||
@@ -336,4 +341,161 @@ class GogGameExeTest {
|
|||||||
assertEquals("System", task.workDir)
|
assertEquals("System", task.workDir)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private val dosboxManifest = """{"playTasks":[
|
||||||
|
{"category":"game","isPrimary":true,"path":"DOSBOX\\DOSBox.exe","workingDir":"DOSBOX","type":"FileTask",
|
||||||
|
"arguments":"-conf \"..\\dosboxRiva.conf\" -conf \"..\\dosboxRiva_single.conf\" -noconsole -c \"exit\""}]}"""
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun aCaseMismatchedDosboxTaskWinsOverTheDosExe() {
|
||||||
|
withFolder { root ->
|
||||||
|
root.exe("RIVA.EXE", 65536)
|
||||||
|
root.exe("dosbox/DOSBOX.EXE", 4096)
|
||||||
|
File(root, "goggame-1207658797.info").writeText(dosboxManifest)
|
||||||
|
val task = GogDownloadManager.pickTask(root, "1207658797", null, "Realms of Arkania 3")
|
||||||
|
assertEquals("dosbox/DOSBOX.EXE", task.path)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun aTasksArgumentsAndWorkingDirectoryAreCarriedThrough() {
|
||||||
|
withFolder { root ->
|
||||||
|
root.exe("RIVA.EXE", 65536)
|
||||||
|
root.exe("dosbox/DOSBOX.EXE", 4096)
|
||||||
|
File(root, "goggame-1207658797.info").writeText(dosboxManifest)
|
||||||
|
val task = GogDownloadManager.pickTask(root, "1207658797", null, "Realms of Arkania 3")
|
||||||
|
assertEquals("dosbox", task.workDir)
|
||||||
|
assertEquals(
|
||||||
|
listOf("-conf", "..\\dosboxRiva.conf", "-conf", "..\\dosboxRiva_single.conf", "-noconsole", "-c", "exit"),
|
||||||
|
task.args,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun aTasksArgumentsReachTheLauncherScript() {
|
||||||
|
withFolder { root ->
|
||||||
|
root.exe("dosbox/DOSBOX.EXE", 4096)
|
||||||
|
File(root, "goggame-1207658797.info").writeText(dosboxManifest)
|
||||||
|
val task = GogDownloadManager.pickTask(root, "1207658797", null, "Realms of Arkania 3")
|
||||||
|
val sidecar = StoreGameSidecar(Store.GOG, "1207658797", "Realms of Arkania 3", task.path, workdir = task.workDir, args = task.args)
|
||||||
|
val script = StoreLaunch.launcherText(sidecar)
|
||||||
|
assertTrue(script, script.contains("cd /d \"%~dp0dosbox\""))
|
||||||
|
assertTrue(script, script.contains("\"%~dp0dosbox\\DOSBOX.EXE\" -conf ..\\dosboxRiva.conf -conf ..\\dosboxRiva_single.conf -noconsole -c exit"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun anArgumentWithSpacesIsKeptAsOneArgument() {
|
||||||
|
withFolder { root ->
|
||||||
|
root.exe("game.exe", 4096)
|
||||||
|
File(root, "goggame-7.info").writeText(
|
||||||
|
"""{"playTasks":[{"category":"game","isPrimary":true,"path":"game.exe","arguments":"-cfg \"my config.ini\" -windowed"}]}""",
|
||||||
|
)
|
||||||
|
assertEquals(listOf("-cfg", "my config.ini", "-windowed"), GogDownloadManager.pickTask(root, "7", null, "Some Game").args)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun aTaskWithoutArgumentsKeepsNoneAndItsExactCasePath() {
|
||||||
|
withFolder { root ->
|
||||||
|
root.exe("System/witcher.exe", 4096)
|
||||||
|
File(root, "goggame-1207658924.info").writeText(
|
||||||
|
"""{"playTasks":[{"category":"game","isPrimary":true,"path":"System\\witcher.exe","workingDir":"System","type":"FileTask"}]}""",
|
||||||
|
)
|
||||||
|
val task = GogDownloadManager.pickTask(root, "1207658924", null, "The Witcher: Enhanced Edition")
|
||||||
|
assertEquals("System/witcher.exe", task.path)
|
||||||
|
assertEquals("System", task.workDir)
|
||||||
|
assertEquals(emptyList<String>(), task.args)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun aSearchedExecutableHasNoArguments() {
|
||||||
|
withFolder { root ->
|
||||||
|
root.exe("kain.exe", 4096)
|
||||||
|
assertEquals(emptyList<String>(), GogDownloadManager.pickTask(root, null, null, "Blood Omen: Legacy of Kain").args)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun anInstalledGameWithoutItsTaskArgumentsIsRepairedOnce() {
|
||||||
|
withFolder { root ->
|
||||||
|
root.exe("RIVA.EXE", 65536)
|
||||||
|
root.exe("dosbox/DOSBOX.EXE", 4096)
|
||||||
|
File(root, "goggame-1207658797.info").writeText(dosboxManifest)
|
||||||
|
val stale = StoreGameSidecar(Store.GOG, "1207658797", "Realms of Arkania 3", "RIVA.EXE")
|
||||||
|
stale.write(root)
|
||||||
|
val adopted = StoreLaunch.adopt(root, stale)
|
||||||
|
assertEquals("dosbox/DOSBOX.EXE", adopted.exe)
|
||||||
|
assertEquals("dosbox", adopted.workdir)
|
||||||
|
assertEquals("-noconsole", adopted.args[4])
|
||||||
|
assertEquals(StoreLaunch.LAUNCHER, adopted.launcher)
|
||||||
|
assertTrue(File(root, StoreLaunch.LAUNCHER).readText().contains("DOSBOX.EXE\" -conf"))
|
||||||
|
val saved = StoreGameSidecar.read(root)!!
|
||||||
|
assertEquals("dosbox/DOSBOX.EXE", saved.exe)
|
||||||
|
assertEquals(adopted.args, saved.args)
|
||||||
|
assertEquals("1", saved.extra[GogBackend.PLAY_TASK_READ])
|
||||||
|
assertTrue(StoreLaunch.adopt(root, saved) === saved)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun anInstalledGameWhoseTaskHasNoArgumentsKeepsItsExe() {
|
||||||
|
withFolder { root ->
|
||||||
|
root.exe("bin/game.exe", 4096)
|
||||||
|
root.exe("other.exe", 65536)
|
||||||
|
File(root, "goggame-1.info").writeText("""{"playTasks":[{"category":"game","isPrimary":true,"path":"bin\\game.exe","type":"FileTask"}]}""")
|
||||||
|
val sidecar = StoreGameSidecar(Store.GOG, "1", "Game", "other.exe")
|
||||||
|
val adopted = StoreLaunch.adopt(root, sidecar)
|
||||||
|
assertEquals("other.exe", adopted.exe)
|
||||||
|
assertTrue(adopted.args.isEmpty())
|
||||||
|
assertEquals("1", adopted.extra[GogBackend.PLAY_TASK_READ])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun anUnreadableManifestIsRetriedOnceItReadsAgain() {
|
||||||
|
withFolder { root ->
|
||||||
|
root.exe("RIVA.EXE", 65536)
|
||||||
|
root.exe("dosbox/DOSBOX.EXE", 4096)
|
||||||
|
val manifest = File(root, "goggame-1207658797.info")
|
||||||
|
manifest.writeText(dosboxManifest.take(40))
|
||||||
|
val stale = StoreGameSidecar(Store.GOG, "1207658797", "Realms of Arkania 3", "RIVA.EXE")
|
||||||
|
stale.write(root)
|
||||||
|
assertTrue(StoreLaunch.adopt(root, stale) === stale)
|
||||||
|
assertFalse(GogBackend.PLAY_TASK_READ in StoreGameSidecar.read(root)!!.extra)
|
||||||
|
manifest.writeText(dosboxManifest)
|
||||||
|
val adopted = StoreLaunch.adopt(root, StoreGameSidecar.read(root)!!)
|
||||||
|
assertEquals("dosbox/DOSBOX.EXE", adopted.exe)
|
||||||
|
assertEquals("1", adopted.extra[GogBackend.PLAY_TASK_READ])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun anUpdatedBuildTakesItsNewPlayTask() {
|
||||||
|
withFolder { root ->
|
||||||
|
root.exe("bin/game.exe", 4096)
|
||||||
|
root.exe("old.exe", 65536)
|
||||||
|
File(root, "goggame-1.info").writeText("""{"playTasks":[{"category":"game","isPrimary":true,"path":"bin\\game.exe","arguments":"-a b","type":"FileTask"}]}""")
|
||||||
|
val read = StoreGameSidecar(Store.GOG, "1", "Game", "old.exe", extra = mapOf(GogBackend.PLAY_TASK_READ to "1"))
|
||||||
|
val updated = GogBackend.withPlayTask(root, read, replaceExe = true)
|
||||||
|
assertEquals("bin/game.exe", updated.exe)
|
||||||
|
assertEquals(listOf("-a", "b"), updated.args)
|
||||||
|
File(root, "goggame-1.info").writeText("{")
|
||||||
|
assertFalse(GogBackend.PLAY_TASK_READ in GogBackend.withPlayTask(root, read, replaceExe = true).extra)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun taskArgumentsWithBatchCharactersStayOneArgument() {
|
||||||
|
withFolder { root ->
|
||||||
|
root.exe("dosbox/DOSBOX.EXE", 4096)
|
||||||
|
val sidecar = StoreGameSidecar(Store.GOG, "1", "Game", "dosbox/DOSBOX.EXE", args = listOf("-conf", "base&extra.conf", "-noconsole", "-savedir", "C:\\My Saves\\", "-windowed"))
|
||||||
|
StoreLaunch.writeLauncher(root, sidecar)
|
||||||
|
val text = File(root, StoreLaunch.LAUNCHER).readText()
|
||||||
|
assertTrue(text.contains("-conf ^\"base^&extra.conf^\" -noconsole"))
|
||||||
|
assertTrue(text.contains("-savedir ^\"C:\\My Saves\\\\^\" -windowed"))
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -984,15 +984,10 @@ def valve_picks(steam_root):
|
|||||||
return sorted(picks, key=int)
|
return sorted(picks, key=int)
|
||||||
|
|
||||||
|
|
||||||
def launch_platforms(entry):
|
|
||||||
return {part.strip() for option in entry.get("launch_options", ())
|
|
||||||
for part in option["oslist"].split(",") if part.strip()}
|
|
||||||
|
|
||||||
|
|
||||||
def tool_platforms(steam_root):
|
def tool_platforms(steam_root):
|
||||||
entries = appinfo_entries(os.path.join(steam_root, "appcache", "appinfo.vdf"))
|
entries = appinfo_entries(os.path.join(steam_root, "appcache", "appinfo.vdf"))
|
||||||
platforms = {app: entry["oslist"] | launch_platforms(entry) for app, entry in entries.items() if entry["type"] == "tool"}
|
return {app: entry["oslist"] for app, entry in entries.items()
|
||||||
return {app: found for app, found in platforms.items() if found & {"linux", "windows"}}
|
if entry["type"] == "tool" and entry["oslist"] & {"linux", "windows"}}
|
||||||
|
|
||||||
|
|
||||||
def native_targets(steam_root, apps):
|
def native_targets(steam_root, apps):
|
||||||
@@ -1232,16 +1227,8 @@ def plan_mapping(current, installed, runnable, default, auto, native=None, picks
|
|||||||
changes["0"] = default
|
changes["0"] = default
|
||||||
for app in sorted((set(current) | installed | picks | set(auto) | set(overrides) | native_choices | set(tools)) - {"0"}, key=app_order):
|
for app in sorted((set(current) | installed | picks | set(auto) | set(overrides) | native_choices | set(tools)) - {"0"}, key=app_order):
|
||||||
name = current.get(app, "")
|
name = current.get(app, "")
|
||||||
if app in tools and "linux" in tools[app]:
|
if app in tools and "linux" in tools[app] and "windows" not in tools[app]:
|
||||||
if "windows" not in tools[app]:
|
if name and (name.lower() in runnable or "proton" in name.lower()):
|
||||||
if name and (name.lower() in runnable or "proton" in name.lower()):
|
|
||||||
changes[app] = None
|
|
||||||
continue
|
|
||||||
if app in overrides:
|
|
||||||
target = overrides[app]
|
|
||||||
if target is not DEFERRED_GAME_TOOL and (target or None) != (name or None):
|
|
||||||
changes[app] = target or None
|
|
||||||
elif name and (name == auto.get(app) or unrunnable(name, runnable) or name.lower() in removed):
|
|
||||||
changes[app] = None
|
changes[app] = None
|
||||||
continue
|
continue
|
||||||
if app in overrides:
|
if app in overrides:
|
||||||
|
|||||||
@@ -73,56 +73,6 @@ class ToolPlatformsTest(unittest.TestCase):
|
|||||||
self.assertEqual(auto["900001"], TOOL)
|
self.assertEqual(auto["900001"], TOOL)
|
||||||
self.assertEqual(auto["976730"], TOOL)
|
self.assertEqual(auto["976730"], TOOL)
|
||||||
|
|
||||||
def add_launch_only_linux_tool(self):
|
|
||||||
self.entries[900007] = {"common": {"type": "Tool", "oslist": "windows"}, "config": {"launch": {
|
|
||||||
"0": {"executable": "bin\\win64\\start.exe", "config": {"oslist": "windows"}},
|
|
||||||
"1": {"executable": "bin\\start.sh", "config": {"oslist": "linux", "osarch": "64"}},
|
|
||||||
}}}
|
|
||||||
self.write_appinfo()
|
|
||||||
|
|
||||||
def test_linux_launch_entry_counts_as_a_linux_platform(self):
|
|
||||||
self.add_launch_only_linux_tool()
|
|
||||||
self.assertEqual(self.platforms()["900007"], {"windows", "linux"})
|
|
||||||
self.assertEqual(self.platforms()["900001"], {"windows"})
|
|
||||||
|
|
||||||
def test_tool_with_a_linux_build_is_not_given_proton_before_install(self):
|
|
||||||
self.add_launch_only_linux_tool()
|
|
||||||
changes, auto = self.plan({"0": TOOL})
|
|
||||||
self.assertNotIn("900007", changes)
|
|
||||||
self.assertNotIn("900007", auto)
|
|
||||||
self.assertEqual(changes["900001"], TOOL)
|
|
||||||
|
|
||||||
def test_own_proton_mapping_on_a_tool_with_a_linux_build_is_cleared(self):
|
|
||||||
self.add_launch_only_linux_tool()
|
|
||||||
changes, auto = self.plan({"0": TOOL, "900007": TOOL}, {"900007": TOOL})
|
|
||||||
self.assertIsNone(changes["900007"])
|
|
||||||
self.assertNotIn("900007", auto)
|
|
||||||
|
|
||||||
def test_user_selection_on_a_tool_with_a_linux_build_survives(self):
|
|
||||||
self.add_launch_only_linux_tool()
|
|
||||||
for name in (TOOL, "custom-windows"):
|
|
||||||
with self.subTest(name=name):
|
|
||||||
changes, auto = self.plan({"0": TOOL, "900007": name}, {"976730": TOOL})
|
|
||||||
self.assertNotIn("900007", changes)
|
|
||||||
|
|
||||||
def test_stale_tool_on_a_tool_with_a_linux_build_is_cleared(self):
|
|
||||||
self.add_launch_only_linux_tool()
|
|
||||||
for name, removed in (("GE-Proton11-7", ("GE-Proton11-7",)), ("proton_9", ())):
|
|
||||||
with self.subTest(name=name):
|
|
||||||
changes, auto = self.plan({"0": TOOL, "900007": name}, removed=removed)
|
|
||||||
self.assertIsNone(changes["900007"])
|
|
||||||
self.assertNotIn("900007", auto)
|
|
||||||
|
|
||||||
def test_explicit_request_on_a_tool_with_a_linux_build_is_applied(self):
|
|
||||||
self.add_launch_only_linux_tool()
|
|
||||||
changes, auto = self.plan({"0": TOOL}, overrides={"900007": TOOL})
|
|
||||||
self.assertEqual(changes["900007"], TOOL)
|
|
||||||
changes, auto = self.plan({"0": TOOL, "900007": TOOL}, overrides={"900007": None})
|
|
||||||
self.assertIsNone(changes["900007"])
|
|
||||||
changes, auto = self.plan({"0": TOOL, "900007": TOOL}, overrides={"900007": TOOL})
|
|
||||||
self.assertNotIn("900007", changes)
|
|
||||||
self.assertNotIn("900007", auto)
|
|
||||||
|
|
||||||
def test_removed_ge_proton_is_cleared_with_or_without_saved_ownership(self):
|
def test_removed_ge_proton_is_cleared_with_or_without_saved_ownership(self):
|
||||||
for saved in ({}, {"1826330": "GE-Proton11-7"}):
|
for saved in ({}, {"1826330": "GE-Proton11-7"}):
|
||||||
with self.subTest(saved=saved):
|
with self.subTest(saved=saved):
|
||||||
|
|||||||
Reference in new issue
Block a user