private static string GetXCOMRootDirectoryFromVDFConfig() { var configPath = SteamUtilities.GetSteamConfigVDFPath(); Log.Debug("Attempting to determine XCOM Root Directory from Config VDF [ {0} ]", configPath); var lines = File.ReadAllLines(configPath).Where(s => s.Contains(Common.XCOMInstallFolderName)).ToList(); Log.Debug("Found Entries in VDF:\n{0}", string.Join("\n>", lines)); if (lines.Count != 1) { throw new InvalidOperationException("Cannot Determine XCOM Root Directory from Config.VDF"); } // format should be similar to: // "installdir" "X:\\Steam\\steamapps\\common\\XCom-Enemy-Unknown" var regex = new Regex(@"[\""]installdir[\""]\s+[\""](?<installdir>.+)[\""]", RegexOptions.IgnoreCase); var match = regex.Match(lines.First()); var rootDirectory = match.Groups["installdir"].Value; Log.Debug("Regex Matched Install Directory of [ {0} ]", rootDirectory); return(rootDirectory); }
public static async Task <EmbedBuilder> GetEmbedAsync(this Listing game) { var app = await AppDetails.GetAsync(game.AppId).ConfigureAwait(false); string releasetext = app.ReleaseDate.ComingSoon ? "Coming soon! (Date Number may not be accurate)" : "Released on:"; var embed = new EmbedBuilder() .WithAuthor( new EmbedAuthorBuilder() .WithName(string.Join(", ", app.Developers)) ) .WithDescription(SteamUtilities.GetSteamGameDescription(game, app)) .WithImageUrl(app.Screenshots.RandomValue().PathFull) .WithRandomColor() .WithUrl($"https://store.steampowered.com/app/{game.AppId}/") .WithTitle(game.Name) .WithFooter( new EmbedFooterBuilder() .WithText(releasetext) ); if (int.TryParse(app.ReleaseDate.Date[0].ToString(), out int _)) { embed.WithTimestamp(DateTime.ParseExact(app.ReleaseDate.Date, "dd MMM, yyyy", CultureInfo.InvariantCulture, DateTimeStyles.AllowWhiteSpaces)); } else { embed.WithTimestamp(DateTime.ParseExact(app.ReleaseDate.Date, "MMM yyyy", CultureInfo.InvariantCulture, DateTimeStyles.AllowWhiteSpaces)); } return(embed); }
// LOGIC public void Refresh() { if (!SteamManager.initializedMain) { return; } string personaName = SteamFriends.GetFriendPersonaName(m_SteamId); Sprite icon = SteamUtilities.GetMediumAvatar(m_SteamId); EPersonaState state = SteamFriends.GetFriendPersonaState(m_SteamId); m_Name = personaName; m_Icon = icon; m_State = state; }
private void HandleUGCDownload(RemoteStorageDownloadUGCResult_t param, bool bIOFailure) { //TODO: we shoudl probably setup a unique handler for each type of file .. at the moment we are assuming we only ever load the preview image PreviewImageLocation = param.m_pchFileName; Texture2D image; if (SteamUtilities.LoadImageFromDisk(param.m_pchFileName, out image)) { previewImage = image; } else { Debug.LogError("Failed to load preview image (" + param.m_pchFileName + ") from disk!"); } }
public void FromGameServerItem(gameserveritem_t item) { serverID = item.m_steamID; serverName = item.GetServerName(); serverDescription = item.GetGameDescription(); mapName = item.GetMap(); isPasswordProtected = item.m_bPassword; isVAC = item.m_bSecure; maxPlayerCount = item.m_nMaxPlayers; currentPlayerCount = item.m_nPlayers; botPlayers = item.m_nBotPlayers; ping = item.m_nPing; serverVersion = item.m_nServerVersion; tags = item.GetGameTags(); address = item.m_NetAdr; lastTimePlayed = SteamUtilities.ConvertUnixDate(item.m_ulTimeLastPlayed); }
private void RunRefresh() { //needs to be called to ensure we aren't loading a previously stored object. CleanerUtilities.updateRedistributables = true; _pathsInternal.Clear(); foreach (var steamPath in SteamUtilities.SteamPaths()) { _pathsInternal.Add(steamPath); } _filesInternal.Clear(); foreach (var fileViewModel in CleanerUtilities.FindRedistributables().Select(r => new FileViewModel(r.Path, StringUtilities.GetBytesReadable(r.Size)))) { _filesInternal.Add(fileViewModel); } Statistics = CleanerUtilities.TotalFiles() + " files have been found (" + CleanerUtilities.TotalTakenSpace() + ") "; }
public HeathenWorkshopReadCommunityItem(SteamUGCDetails_t itemDetails) { SourceItemDetails = itemDetails; if (itemDetails.m_eFileType != EWorkshopFileType.k_EWorkshopFileTypeCommunity) { Debug.LogWarning("HeathenWorkshopReadItem is designed to display File Type = Community Item, this item is not a community item and may not load correctly."); } m_RemoteStorageDownloadUGCResult = CallResult <RemoteStorageDownloadUGCResult_t> .Create(HandleUGCDownload); TargetApp = itemDetails.m_nConsumerAppID; FileId = itemDetails.m_nPublishedFileId; Title = itemDetails.m_rgchTitle; Description = itemDetails.m_rgchDescription; Visibility = itemDetails.m_eVisibility; Author = new CSteamID(itemDetails.m_ulSteamIDOwner); CreatedOn = SteamUtilities.ConvertUnixDate(itemDetails.m_rtimeCreated); LastUpdated = SteamUtilities.ConvertUnixDate(itemDetails.m_rtimeUpdated); UpVotes = itemDetails.m_unVotesUp; DownVotes = itemDetails.m_unVotesDown; VoteScore = itemDetails.m_flScore; IsBanned = itemDetails.m_bBanned; IsTagsTruncated = itemDetails.m_bTagsTruncated; FileSize = itemDetails.m_nFileSize; Visibility = itemDetails.m_eVisibility; Tags.AddRange(itemDetails.m_rgchTags.Split(',')); uint state = SteamUGC.GetItemState(FileId); StateFlags = (EItemState)state; IsSubscribed = SteamUtilities.WorkshopItemStateHasFlag(StateFlags, EItemState.k_EItemStateSubscribed); if (itemDetails.m_nPreviewFileSize > 0) { var previewCall = SteamRemoteStorage.UGCDownload(itemDetails.m_hPreviewFile, 1); m_RemoteStorageDownloadUGCResult.Set(previewCall, HandleUGCDownloadPreviewFile); } else { Debug.LogWarning("Item [" + Title + "] has no preview file!"); } }
public static string GetXCOMRootDirectory() { Log.Info("Attempting to Locate XCOM Root Directory"); var rootDirectory = Path.Combine(SteamUtilities.GetSteamRootDirectory(), Common.XCOMSteamAppsPath); Log.Debug("Checking for Default Install Location [ {0} ]", rootDirectory); if (!Directory.Exists(rootDirectory)) { Log.Debug("XCOM Not Installed to Default Location, checking Config.VDF"); rootDirectory = GetXCOMRootDirectoryFromVDFConfig(); } // Get the absolute full path try { return(Path.GetFullPath(rootDirectory)); } catch (Exception err) { Log.Error(err); throw; } }
public static string CheckFiles(string path) { SteamUtilities.EnsureIncludedOrExcludedFiles(path); return(path); }
private void AddManifestToSteamConfig() { string steamFolder = SteamUtilities.GetSteamHomeDirectory(); string manifestPath = Path.Combine(Environment.CurrentDirectory, "beatsaber.vrmanifest"); string appConfigPath = Path.Combine(steamFolder, "config", "appconfig.json"); string globalManifestPath = Path.Combine(steamFolder, "config", "steamapps.vrmanifest"); JObject beatSaberManifest = ReadBeatSaberManifest(globalManifestPath); beatSaberManifest["action_manifest_path"] = _actionManifestPath; JObject vrManifest = new JObject { { "applications", new JArray { beatSaberManifest } } }; WriteBeatSaberManifest(manifestPath, vrManifest); JObject appConfig = ReadAppConfig(appConfigPath); JArray manifestPaths = appConfig["manifest_paths"].Value <JArray>(); List <JToken> existing = manifestPaths.Where(p => p.Value <string>() == manifestPath).ToList(); bool updated = false; // only rewrite if path isn't in list already or is not at the top if (manifestPaths.IndexOf(existing.FirstOrDefault()) != 0 || existing.Count > 1) { logger.Info($"Adding '{manifestPath}' to app config"); foreach (JToken token in existing) { manifestPaths.Remove(token); } manifestPaths.Insert(0, manifestPath); updated = true; } else { logger.Info("Manifest is already in app config"); } if (!manifestPaths.Any(s => s.Value <string>().Equals(globalManifestPath, StringComparison.InvariantCultureIgnoreCase))) { logger.Info($"Adding '{globalManifestPath}' to app config"); manifestPaths.Add(globalManifestPath); updated = true; } else { logger.Info("Global manifest is already in app config"); } if (updated) { if (MessageBox.Show( "DynamicOpenVR.BeatSaber has created a .vrmanifest file in your game's root folder and would like to register it within SteamVR. " + $"The file has been created at \"{manifestPath}\" and will be added to the global SteamVR app configuration at \"{appConfigPath}\". " + "Doing this allows SteamVR to properly recognize that the game is now using the new input system when the game is not running. " + "However, it may cause issues on certain systems. You can choose to do this now or wait until you've run the game with " + "DynamicOpenVR enabled and checked everything works.\n\nCan DynamicOpenVR.BeatSaber proceed with the changes?", "DynamicOpenVR needs your permission", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { logger.Info($"Writing app config changes to '{appConfigPath}'"); WriteAppConfig(appConfigPath, appConfig); } else { logger.Warn("Manifest registration canceled by user"); } } }