public static string GetAppInstallDir() { string appInstallDir = null; SteamApps.GetAppInstallDir(new AppId_t(Const.STEAM_APP_ID), out appInstallDir, 1024); return(appInstallDir); }
/// <summary> /// <para>Gets the install folder for a specific AppID. /// This works even if the application is not installed, based on where the game would be installed with the default Steam library location.</para> /// <a href="https://partner.steamgames.com/doc/api/ISteamApps#GetAppInstallDir">https://partner.steamgames.com/doc/api</a> /// </summary> /// <param name="appId"></param> /// <returns></returns> public static string GetAppInstallDir(AppId_t appId) { string results; SteamApps.GetAppInstallDir(appId, out results, 1024); return(results); }
public static void Init() { lock (_initLock) { if (!Instance) { GameObject go = new GameObject(); go.name = "ModLoader"; Instance = go.AddComponent <ModLoader>(); DontDestroyOnLoad(go); SteamAPI.Init(); SteamApps.GetAppInstallDir(AppId_t.SpaceStationOnline, out SteamAppDir, 1024u); AppDataDir = Path.GetFullPath(Application.dataPath); ManagedDir = Path.GetFullPath(Path.Combine(AppDataDir, "Managed")); AppRootDir = Path.GetDirectoryName(AppDataDir); MyGamesModDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), @"My Games\Stationeers\mods"); ModLoaderDir = Path.Combine(AppRootDir, "Mods"); if (!Directory.Exists(ModLoaderDir)) { Directory.CreateDirectory(ModLoaderDir); } if (!Directory.Exists(MyGamesModDir)) { Directory.CreateDirectory(MyGamesModDir); } LoadMods(); } } }
public static string GetSteamTerrariaInstallDir() { SteamApps.GetAppInstallDir(TerrariaAppId_t, out string terrariaInstallLocation, 1000); #if MAC terrariaInstallLocation = Path.Combine(terrariaInstallLocation, "Terraria.app/Contents/MacOS"); #endif return(terrariaInstallLocation); }
public static string GetSteamTMLInstallDir() { SteamApps.GetAppInstallDir(TMLAppID_t, out string tmlInstallDIr, 1000); #if MAC tmlInstallDIr = Path.Combine(tmlInstallDIr, "tModLoader.app/Contents/MacOS"); #endif return(tmlInstallDIr); }
public static string GetGameDirectory(AppId_t appID) { if (!SteamApps.BIsAppInstalled(appID)) { return(""); } string path = ""; SteamApps.GetAppInstallDir(appID, out path, 256); return(path); }
/// <summary> /// Returns the install location of the DLC /// </summary> /// <returns></returns> public string GetInstallDirectory() { string path; if (SteamApps.GetAppInstallDir(AppId, out path, 2048) > 0) { return(path); } else { return(string.Empty); } }
protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); // TODO: use this.Content to load your game content here Font = Content.Load <SpriteFont>(@"Font"); if (!SteamAPI.Init()) { Console.WriteLine("SteamAPI.Init() failed!"); } else { // Steam is running IsSteamRunning = true; // It's important that the next call happens AFTER the call to SteamAPI.Init(). InitializeCallbacks(); SteamUtils.SetOverlayNotificationPosition(ENotificationPosition.k_EPositionTopRight); // Uncomment the next line to adjust the OverlayNotificationPosition. //SteamUtils.SetOverlayNotificationInset(400, 0); // Set collactible data. CurrentLanguage = $"CurrentGameLanguage: {SteamApps.GetCurrentGameLanguage()}"; AvailableLanguages = $"Languages: {SteamApps.GetAvailableGameLanguages()}"; UserStats = $"Reqesting Current Stats - {SteamUserStats.RequestCurrentStats()}"; mNumberOfCurrentPlayers.Set(SteamUserStats.GetNumberOfCurrentPlayers()); var hSteamApiCall = SteamUserStats.FindLeaderboard("Quickest Win"); mCallResultFindLeaderboard.Set(hSteamApiCall); string folder; var length = SteamApps.GetAppInstallDir(SteamUtils.GetAppID(), out folder, 260); InstallDir = $"AppInstallDir: {length} {folder}"; // Get your Steam Avatar (Image) as a Texture2D. UserAvatar = GetSteamUserAvatar(GraphicsDevice); // Get your trimmed Steam User Name. var untrimmedUserName = SteamFriends.GetPersonaName(); // Remove unsupported chars like emojis or other stuff our font cannot handle. untrimmedUserName = ReplaceUnsupportedChars(Font, untrimmedUserName); SteamUserName = untrimmedUserName.Trim(); Exiting += Game1_Exiting; } }
public string SaveDirectoryPath() { if (this.saveDirectoryPath == "") { uint size = SteamApps.GetAppInstallDir((AppId_t)813780, out this.saveDirectoryPath, 500u); if (size <= 0) { } else { } } return(this.saveDirectoryPath); }
public override int Run(string[] arguments) { if (!Steam.Start(Steam.APP_GAME)) { Console.WriteLine("Steam is not running..."); return((int)Steam.ExitCodes.InitSteamFailed); } if (arguments.Length == 0) { Console.WriteLine("Argument \"ID\"(#1) is necessary"); return((int)Steam.ExitCodes.ArgumentsMissing); } if (!uint.TryParse(arguments[0], out uint ID)) { Console.WriteLine("Argument \"ID\"(#1) should be a number"); return((int)Steam.ExitCodes.InvalidArgument); } SteamApps.GetAppInstallDir(Steam.APP_GAME, out Location, 1024); if (arguments.Length >= 2) { Location = arguments[1]; } new Callback <DownloadItemResult_t>(OnDownloadFinished).Register(OnDownloadFinished); if (!SteamUGC.DownloadItem(new PublishedFileId_t(ID), false)) { ExitCode = (int)Steam.ExitCodes.DownLoadFail; } Steam.Run(); Console.WriteLine("Downloading, please wait."); do { System.Threading.Thread.Sleep(100); } while (!Finished); Steam.Stop(); return(ExitCode); }
public List <SteamLaunchableModSource> GetSourceMods() { // source mods List <SteamLaunchableModSource> SourceMods = new List <SteamLaunchableModSource>(); { string sourceMods = SteamProcessInfo.GetSourceModPath(); if (Directory.Exists(sourceMods)) { Directory.GetDirectories(sourceMods) .Where(dr => File.Exists(Path.Combine(dr, "gameinfo.txt"))) .ToList().ForEach(dr => { VObject rootObj = new VObject(); rootObj.Add(VdfConvert.Deserialize(File.ReadAllText(Path.Combine(dr, "gameinfo.txt")))); VObject GameInfoObj = (VObject)rootObj["GameInfo"]; VObject FileSystemObj = (VObject)GameInfoObj["FileSystem"]; VToken appID = FileSystemObj["SteamAppId"]; UInt32 appIdCheck = 0; if (!UInt32.TryParse(appID.ToString(), out appIdCheck)) { return; } if (appIdCheck == 0) { return; } string AppInstallDir = SteamApps.GetAppInstallDir(appIdCheck); if (!string.IsNullOrWhiteSpace(AppInstallDir)) { SteamLaunchableModSource mod = SteamLaunchableModSource.Make(appIdCheck, dr, rootObj); if (mod != null) { SourceMods.Add(mod); } } }); } } return(SourceMods); }
/// <summary> /// Tries to find the directory of the game and the mod folders, both workshop and default /// </summary> /// <returns></returns> public string DetectGameDir() { // This works even if the application is not installed, based on where the game // would be installed with the default Steam library location. // Use 260 as max path length as this is the default windows limit. if (SteamApps.GetAppInstallDir((AppId_t)SteamAppId, out var gamedir, 260) > 0) { // Check if game is really available/installed if (Directory.Exists(gamedir)) { Log.Info("Game directory detected using Steam " + gamedir); _gameDir = gamedir; return(gamedir); } Log.Warn("Steam returned the (default) installation directory, but the game is probably not installed."); } Log.Error("Steam API failed to detect game directory."); // Try to deduce game path from available mod directories var dirs = DetectModDirs(); foreach (var dir in dirs.Where <string>(dir => dir.ToLower().Contains("\\steamapps\\"))) { // Assume steamapps folder to have \workshop\content\268500 subfolders gamedir = Path.GetFullPath(Path.Combine(dir, "../../..", "common", "XCOM 2")); if (Directory.Exists(gamedir)) { Log.Warn("Game directory detected from modding directory " + _gameDir); _gameDir = gamedir; return(gamedir); } } Log.Error("Unable to detect game directory"); return(""); }
/// <summary> /// Tries to find the directory of the game and the mod folders, both workshop and default /// </summary> /// <returns></returns> public static string DetectGameDir() { // try steam string gamedir; if (SteamApps.GetAppInstallDir((AppId_t)APPID, out gamedir, 100) > 0 && Directory.Exists(gamedir)) { _gameDir = gamedir; return(gamedir); } // try modding dirs var dirs = DetectModDirs(); foreach (var dir in dirs.Where(dir => dir.ToLower().Contains("\\steamapps\\"))) { _gameDir = Path.GetFullPath(Path.Combine(dir, "../../..", "common", "XCOM 2")); return(_gameDir); } // abandon hope return(""); }
/// <summary> /// Tries to find the directory of the game and the mod folders, both workshop and default /// </summary> /// <returns></returns> public static string DetectGameDir() { // try steam if (SteamApps.GetAppInstallDir((AppId_t)APPID, out var gamedir, 100) > 0 && Directory.Exists(gamedir)) { Log.Info("Game directory detected using Steam " + gamedir); _gameDir = gamedir; return(gamedir); } // try modding dirs var dirs = DetectModDirs(); foreach (var dir in dirs.Where(dir => dir.ToLower().Contains("\\steamapps\\"))) { _gameDir = Path.GetFullPath(Path.Combine(dir, "../../..", "common", "XCOM 2")); Log.Warn("Game directory detected from fallback method " + _gameDir); return(_gameDir); } Log.Error("Unable to detect game directory"); // abandon hope return(""); }
public void RenderOnGUI() { GUILayout.BeginVertical("box"); m_ScrollPos = GUILayout.BeginScrollView(m_ScrollPos, GUILayout.Width(Screen.width - 215), GUILayout.Height(Screen.height - 33)); GUILayout.Label("BIsSubscribed() : " + SteamApps.BIsSubscribed()); GUILayout.Label("BIsLowViolence() : " + SteamApps.BIsLowViolence()); GUILayout.Label("BIsCybercafe() : " + SteamApps.BIsCybercafe()); GUILayout.Label("BIsVACBanned() : " + SteamApps.BIsVACBanned()); GUILayout.Label("GetCurrentGameLanguage() : " + SteamApps.GetCurrentGameLanguage()); GUILayout.Label("GetAvailableGameLanguages() : " + SteamApps.GetAvailableGameLanguages()); GUILayout.Label("BIsSubscribedApp(SteamUtils.GetAppID()) : " + SteamApps.BIsSubscribedApp(SteamUtils.GetAppID())); GUILayout.Label("BIsDlcInstalled(TestConstants.Instance.k_AppId_PieterwTestDLC) : " + SteamApps.BIsDlcInstalled(TestConstants.Instance.k_AppId_PieterwTestDLC)); GUILayout.Label("GetEarliestPurchaseUnixTime(SteamUtils.GetAppID()) : " + SteamApps.GetEarliestPurchaseUnixTime(SteamUtils.GetAppID())); GUILayout.Label("BIsSubscribedFromFreeWeekend() : " + SteamApps.BIsSubscribedFromFreeWeekend()); GUILayout.Label("GetDLCCount() : " + SteamApps.GetDLCCount()); for (int iDLC = 0; iDLC < SteamApps.GetDLCCount(); ++iDLC) { AppId_t AppID; bool Available; string Name; bool ret = SteamApps.BGetDLCDataByIndex(iDLC, out AppID, out Available, out Name, 128); GUILayout.Label("BGetDLCDataByIndex(" + iDLC + ", out AppID, out Available, out Name, 128) : " + ret + " -- " + AppID + " -- " + Available + " -- " + Name); } if (GUILayout.Button("InstallDLC(TestConstants.Instance.k_AppId_PieterwTestDLC)")) { SteamApps.InstallDLC(TestConstants.Instance.k_AppId_PieterwTestDLC); print("SteamApps.InstallDLC(" + TestConstants.Instance.k_AppId_PieterwTestDLC + ")"); } if (GUILayout.Button("UninstallDLC(TestConstants.Instance.k_AppId_PieterwTestDLC)")) { SteamApps.UninstallDLC(TestConstants.Instance.k_AppId_PieterwTestDLC); print("SteamApps.UninstallDLC(" + TestConstants.Instance.k_AppId_PieterwTestDLC + ")"); } if (GUILayout.Button("RequestAppProofOfPurchaseKey(SteamUtils.GetAppID())")) { SteamApps.RequestAppProofOfPurchaseKey(SteamUtils.GetAppID()); print("SteamApps.RequestAppProofOfPurchaseKey(" + SteamUtils.GetAppID() + ")"); } { string Name; bool ret = SteamApps.GetCurrentBetaName(out Name, 128); if (Name == null) { Name = ""; } GUILayout.Label("GetCurrentBetaName(out Name, 128) : " + ret + " -- " + Name); } if (GUILayout.Button("MarkContentCorrupt(true)")) { bool ret = SteamApps.MarkContentCorrupt(true); print("SteamApps.MarkContentCorrupt(" + true + ") : " + ret); } if (GUILayout.Button("SteamApps.GetInstalledDepots(SteamUtils.GetAppID(), Depots, 32)")) { DepotId_t[] Depots = new DepotId_t[32]; uint ret = SteamApps.GetInstalledDepots(SteamUtils.GetAppID(), Depots, 32); for (int i = 0; i < ret; ++i) { print("SteamApps.GetInstalledDepots(SteamUtils.GetAppID(), Depots, 32) : " + ret + " -- #" + i + " -- " + Depots[i]); } } { string Folder; uint ret = SteamApps.GetAppInstallDir(SteamUtils.GetAppID(), out Folder, 260); if (Folder == null) { Folder = ""; } GUILayout.Label("GetAppInstallDir(SteamUtils.GetAppID(), out Folder, 260) : " + ret + " -- " + Folder); } GUILayout.Label("BIsAppInstalled(SteamUtils.GetAppID()) : " + SteamApps.BIsAppInstalled(SteamUtils.GetAppID())); GUILayout.Label("GetAppOwner() : " + SteamApps.GetAppOwner()); { // Run the test and then use steam://run/480//?test=testing;param2=value2; in your browser to try this out string ret = SteamApps.GetLaunchQueryParam("test"); GUILayout.Label("GetLaunchQueryParam(\"test\") : " + ret); } { ulong BytesDownloaded; ulong BytesTotal; bool ret = SteamApps.GetDlcDownloadProgress(TestConstants.Instance.k_AppId_PieterwTestDLC, out BytesDownloaded, out BytesTotal); GUILayout.Label("GetDlcDownloadProgress(TestConstants.Instance.k_AppId_PieterwTestDLC, out BytesDownloaded, out BytesTotal) : " + ret + " -- " + BytesDownloaded + " -- " + BytesTotal); } GUILayout.Label("GetAppBuildId() : " + SteamApps.GetAppBuildId()); if (GUILayout.Button("RequestAllProofOfPurchaseKeys()")) { SteamApps.RequestAllProofOfPurchaseKeys(); print("SteamApps.RequestAllProofOfPurchaseKeys()"); } if (GUILayout.Button("GetFileDetails(\"steam_api.dll\")")) { SteamAPICall_t handle = SteamApps.GetFileDetails("steam_api.dll"); OnFileDetailsResultCallResult.Set(handle); print("SteamApps.GetFileDetails(" + "\"steam_api.dll\"" + ") : " + handle); } { string CommandLine; int ret = SteamApps.GetLaunchCommandLine(out CommandLine, 260); if (CommandLine == null) { CommandLine = ""; } GUILayout.Label("GetLaunchCommandLine(out CommandLine, 260) : " + ret + " -- " + CommandLine); } GUILayout.Label("BIsSubscribedFromFamilySharing() : " + SteamApps.BIsSubscribedFromFamilySharing()); GUILayout.EndScrollView(); GUILayout.EndVertical(); }
public void RenderOnGUI() { GUILayout.Label("SteamApps.BIsSubscribed() : " + SteamApps.BIsSubscribed()); GUILayout.Label("SteamApps.BIsLowViolence() : " + SteamApps.BIsLowViolence()); GUILayout.Label("SteamApps.BIsCybercafe() : " + SteamApps.BIsCybercafe()); GUILayout.Label("SteamApps.BIsVACBanned() : " + SteamApps.BIsVACBanned()); GUILayout.Label("SteamApps.GetCurrentGameLanguage() : " + SteamApps.GetCurrentGameLanguage()); GUILayout.Label("SteamApps.GetAvailableGameLanguages() : " + SteamApps.GetAvailableGameLanguages()); GUILayout.Label("SteamApps.BIsSubscribedApp(SteamUtils.GetAppID()) : " + SteamApps.BIsSubscribedApp(SteamUtils.GetAppID())); GUILayout.Label("SteamApps.BIsDlcInstalled(110902) : " + SteamApps.BIsDlcInstalled((AppId_t)110902)); // pieterw test DLC GUILayout.Label("SteamApps.GetEarliestPurchaseUnixTime(SteamUtils.GetAppID()) : " + SteamApps.GetEarliestPurchaseUnixTime(SteamUtils.GetAppID())); GUILayout.Label("SteamApps.BIsSubscribedFromFreeWeekend() : " + SteamApps.BIsSubscribedFromFreeWeekend()); GUILayout.Label("SteamApps.GetDLCCount() : " + SteamApps.GetDLCCount()); for (int iDLC = 0; iDLC < SteamApps.GetDLCCount(); ++iDLC) { AppId_t AppID; bool Available; string Name; bool ret = SteamApps.BGetDLCDataByIndex(iDLC, out AppID, out Available, out Name, 128); GUILayout.Label("SteamApps.BGetDLCDataByIndex(" + iDLC + ", out AppID, out Available, out Name, 128) : " + ret + " -- " + AppID + " -- " + Available + " -- " + Name); } if (GUILayout.Button("SteamApps.InstallDLC(110902)")) { SteamApps.InstallDLC((AppId_t)110902); // pieterw test DLC } if (GUILayout.Button("SteamApps.UninstallDLC(110902)")) { SteamApps.UninstallDLC((AppId_t)110902); // pieterw test DLC } if (GUILayout.Button("SteamApps.RequestAppProofOfPurchaseKey(SteamUtils.GetAppID())")) { SteamApps.RequestAppProofOfPurchaseKey(SteamUtils.GetAppID()); } { string Name; bool ret = SteamApps.GetCurrentBetaName(out Name, 128); if (Name == null) { Name = ""; } GUILayout.Label("SteamApps.GetCurrentBetaName(out Name, 128) : " + ret + " -- " + Name); } if (GUILayout.Button("SteamApps.MarkContentCorrupt(true)")) { print("SteamApps.MarkContentCorrupt(true) : " + SteamApps.MarkContentCorrupt(true)); } if (GUILayout.Button("SteamApps.GetInstalledDepots(SteamUtils.GetAppID(), Depots, 32)")) { DepotId_t[] Depots = new DepotId_t[32]; uint ret = SteamApps.GetInstalledDepots(SteamUtils.GetAppID(), Depots, 32); for (int i = 0; i < ret; ++i) { print("SteamApps.GetInstalledDepots(SteamUtils.GetAppID(), Depots, 32) : " + ret + " -- #" + i + " -- " + Depots[i]); } } { string Folder; uint ret = SteamApps.GetAppInstallDir(SteamUtils.GetAppID(), out Folder, 260); if (Folder == null) { Folder = ""; } GUILayout.Label("SteamApps.GetAppInstallDir(480, out Folder, 260) : " + ret + " -- " + Folder); } GUILayout.Label("SteamApps.BIsAppInstalled(480) : " + SteamApps.BIsAppInstalled(SteamUtils.GetAppID())); GUILayout.Label("SteamApps.GetAppOwner() : " + SteamApps.GetAppOwner()); // Run the test and then use steam://run/480//?test=testing;param2=value2; in your browser to try this out GUILayout.Label("SteamApps.GetLaunchQueryParam(\"test\") : " + SteamApps.GetLaunchQueryParam("test")); { ulong BytesDownloaded; ulong BytesTotal; bool ret = SteamApps.GetDlcDownloadProgress((AppId_t)110902, out BytesDownloaded, out BytesTotal); GUILayout.Label("SteamApps.GetDlcDownloadProgress((AppId_t)110902, out BytesDownloaded, out BytesTotal): " + ret + " -- " + BytesDownloaded + " -- " + BytesTotal); } GUILayout.Label("SteamApps.GetAppBuildId(): " + SteamApps.GetAppBuildId()); #if _PS3 if (GUILayout.Button("SteamApps.RegisterActivationCode(\"???\")")) { SteamAPICall_t handle = SteamApps.RegisterActivationCode("???"); new CallResult <RegisterActivationCodeResponse_t>(OnRegisterActivationCodeResponse, handle); new CallResult <AppProofOfPurchaseKeyResponse_t>(OnAppProofOfPurchaseKeyResponse, handle); } #endif }
private static bool GoGCheck() { GetPlatformCheckInfo(out var steamAPIpath, out var steamAPIhash, out var vanillaGoGhash); const string ContentDirectory = "Content"; const string InstallInstructions = "Please restore your Terraria install, then install tModLoader on Steam or by following the README.txt instructions for manual installation."; void Exit(string errorMessage) { errorMessage += $"\r\n\r\n{InstallInstructions}"; Logging.tML.Fatal(errorMessage); UI.Interface.MessageBoxShow(errorMessage); Environment.Exit(1); } // TODO These steam checks should not be here, but I'm afraid to move stuff around right now -Jof bool checkSteam = File.Exists(steamAPIpath); #if !SERVER /*if (!Directory.Exists(ContentDirectory)) { * Exit($"{ContentDirectory} directory could not be found.\r\n\r\nDid you forget to extract tModLoader's Content directory into the tModLoader folder?\r\n\r\nEnsure tModLoader is installed in a separate folder from Terraria."); * return false; * }*/ if (checkSteam) { SocialAPI.LoadSteam(); SteamApps.GetAppInstallDir(Steam.TerrariaAppId_t, out string terrariaInstallLocation, 1000); if (!Directory.Exists(Path.Combine(terrariaInstallLocation, ContentDirectory))) { Exit($"Terraria Steam installation or Terraria Content directory not found.\r\n\r\nPlease ensure Terraria 1.4 is installed through Steam."); return(false); } } #endif if (checkSteam) { VerifySteamAPI(steamAPIpath, steamAPIhash); return(false); } Logging.tML.Info("GoG detected. Disabled steam check."); const string DefaultExe = "Terraria.exe"; string CheckExe = $"Terraria_{Main.versionNumber}.exe"; string vanillaPath = File.Exists(CheckExe) ? CheckExe : DefaultExe; if (!File.Exists(vanillaPath)) { #if SERVER return(false); #else Exit($"{vanillaPath} could not be found.\r\n\r\nGoG installs must have the unmodified Terraria executable to function."); return(false); #endif } if (!HashMatchesFile(vanillaGoGhash, vanillaPath)) { Exit($"{vanillaPath} is not the unmodified Terraria executable.\r\n\r\nGoG installs must have the unmodified Terraria executable to function."); return(false); } return(true); }