9bb4f85802
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
59 lines
2.0 KiB
C#
59 lines
2.0 KiB
C#
using System.Text;
|
|
using CVRManager.Models;
|
|
|
|
namespace CVRManager.Services;
|
|
|
|
public static class AppManifest
|
|
{
|
|
public static string LocalBuildId(InstallInfo i)
|
|
{
|
|
try
|
|
{
|
|
var path = Paths.Manifest(i);
|
|
if (!File.Exists(path)) return "";
|
|
return Vdf.ParseDocument(File.ReadAllText(path)).Dict("AppState")?.Str("buildid") ?? "";
|
|
}
|
|
catch { return ""; }
|
|
}
|
|
|
|
public static string LocalBranch(InstallInfo i)
|
|
{
|
|
try
|
|
{
|
|
var path = Paths.Manifest(i);
|
|
if (!File.Exists(path)) return "";
|
|
var key = Vdf.ParseDocument(File.ReadAllText(path)).Dict("AppState")?.Dict("UserConfig")?.Str("BetaKey") ?? "";
|
|
return key.Length == 0 ? "public" : key;
|
|
}
|
|
catch { return ""; }
|
|
}
|
|
|
|
public static void Write(string gameDir, string buildId, string branch)
|
|
{
|
|
var dir = Path.Combine(gameDir, "steamapps");
|
|
Directory.CreateDirectory(dir);
|
|
var sb = new StringBuilder();
|
|
sb.AppendLine("\"AppState\"");
|
|
sb.AppendLine("{");
|
|
sb.AppendLine($"\t\"appid\"\t\t\"{Paths.AppId}\"");
|
|
sb.AppendLine("\t\"Universe\"\t\t\"1\"");
|
|
sb.AppendLine("\t\"name\"\t\t\"ChilloutVR\"");
|
|
sb.AppendLine("\t\"StateFlags\"\t\t\"4\"");
|
|
sb.AppendLine($"\t\"installdir\"\t\t\"{Path.GetFileName(gameDir)}\"");
|
|
sb.AppendLine($"\t\"buildid\"\t\t\"{buildId}\"");
|
|
sb.AppendLine("\t\"UserConfig\"");
|
|
sb.AppendLine("\t{");
|
|
sb.AppendLine("\t\t\"language\"\t\t\"english\"");
|
|
sb.AppendLine($"\t\t\"BetaKey\"\t\t\"{branch}\"");
|
|
sb.AppendLine("\t}");
|
|
sb.AppendLine("\t\"MountedConfig\"");
|
|
sb.AppendLine("\t{");
|
|
sb.AppendLine($"\t\t\"BetaKey\"\t\t\"{branch}\"");
|
|
sb.AppendLine("\t}");
|
|
sb.AppendLine("}");
|
|
var file = Path.Combine(dir, $"appmanifest_{Paths.AppId}.acf");
|
|
File.WriteAllText(file + ".tmp", sb.ToString());
|
|
File.Move(file + ".tmp", file, true);
|
|
}
|
|
}
|