private void startSteam_Click(object sender, EventArgs e) { Thread thread = new Thread(() => { if (SteamAPI.IsSteamRunning()) { this.SteamUUID = SteamUser.GetSteamID().ToString(); SteamAPI.Shutdown(); this.DialogResult = DialogResult.OK; this.Close(); } else { this.BeginInvoke((MethodInvoker)async delegate { startSteam.Enabled = false; startSteam.Text = "STARTING..."; Process.Start("steam://"); startSteam.Text = "PLEASE WAIT..."; await Task.Delay(10000); while (tryToGetSteamUID(false) == false) { await Task.Delay(2000); } }); } }); thread.Start(); }
private static void Unlock(string achievementId) { if (SteamAPI.IsSteamRunning() && instance.IsRunning) { SteamUserStats.SetAchievement(achievementId); } }
/// <summary> /// Searches for the specified term. /// </summary> /// <param name="wiki">The wiki to search from</param> /// <param name="term">The term to search for</param> /// <param name="getTerm">The method to get the term</param> public static void DoSearch(Dictionary <GameCulture, string> wiki, ref string term, Action getTerm) { var searchUrl = string.Empty; if (GetInstance <ClientConfig>().UseActiveGameCulture&& wiki.ContainsKey(LanguageManager.Instance.ActiveCulture)) { getTerm(); searchUrl = wiki[LanguageManager.Instance.ActiveCulture]; } else { var oldGameCulture = LanguageManager.Instance.ActiveCulture; LanguageManager.Instance.SetLanguage(DEFAULT_GAME_CULTURE); getTerm(); LanguageManager.Instance.SetLanguage(oldGameCulture); searchUrl = wiki[DEFAULT_GAME_CULTURE]; } if (GetInstance <ClientConfig>().UseSteamOverlay&& SteamAPI.IsSteamRunning() && SteamUtils.IsOverlayEnabled()) { SteamFriends.ActivateGameOverlayToWebPage(searchUrl.Replace("%s", term)); } else { Process.Start(searchUrl.Replace("%s", term)); } }
private static void ConfirmSteamRunning() { if (!SteamAPI.IsSteamRunning()) { throw new SteamInitializationException("Steam does not appear to be running"); } }
void PlayingFunc() { uint networkSize; var networkBuffer = new byte[8000]; var inputBuffer = new byte[8000]; var decompressBuffer = new byte[20000]; while (true) { if (Program.CloseOnNext) { return; } if (SteamAPI.IsSteamRunning() && SteamNetworking.IsP2PPacketAvailable(out networkSize)) { CSteamID remotUSer; if (SteamNetworking.ReadP2PPacket(networkBuffer, (uint)networkBuffer.Length, out networkSize, out remotUSer)) { PlaySoundFromNetworkData(remotUSer.m_SteamID, networkBuffer, networkSize, inputBuffer, decompressBuffer); } } else { Thread.Sleep(networkCheckIntervalMs); } NotifyNotTalking(); } }
private bool tryToGetSteamUID(bool showAlerts) { SteamAPI.Init(); if (SteamAPI.IsSteamRunning()) { startSteam.Text = "STEAM STARTED !"; try { this.SteamUUID = SteamUser.GetSteamID().ToString(); SteamAPI.Shutdown(); this.DialogResult = DialogResult.OK; this.Close(); } catch (Exception de) { if (showAlerts) { MetroMessageBox.Show(this, "Veuillez vous connecter sur Steam.", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } else { if (showAlerts) { MetroMessageBox.Show(this, "Steam n'est toujours pas lancé...", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Information); } } return(false); }
public void Init() { if (!SteamAPI.Init() && !this.initalized) { Logger.Info("Steam-INIT FAILED! Retry in 5 Seconds..."); return; } this.initalized = true; if (SteamAPI.IsSteamRunning() && !this.running) { this.running = true; Task.Run(() => { while (true) { if (this.queue.Count >= 1) { Logger.Info("Enqueue Call!"); Action callback = this.queue[0]; callback(); this.queue.RemoveAt(0); Thread.Sleep(100); } SteamAPI.RunCallbacks(); Thread.Sleep(100); } }); Logger.Info("ID: " + this.GetSteamID() + ", Name: " + this.GetUsername() + ", Account: " + this.GetAccountID()); } }
private static void InitializeInner() { var initialized = SteamAPI.InitSafe(); for (var i = 0; i < 3 && !initialized; i++) { Logging.Debug($"Delayed Steam initialization, attempt #{i + 1} {(SteamAPI.IsSteamRunning() ? "" : "(Steam not running)")}"); Thread.Sleep(150); try { SteamAPI.Shutdown(); } catch (Exception e) { Logging.Debug("Steam API shutdown not required: " + e); } initialized = SteamAPI.Init(); } if (!initialized) { Logging.Debug("Still not initialized…"); if (!SteamAPI.RestartAppIfNecessary(new AppId_t(244210u))) { MessageBox.Show("Steam can’t be initialized.", "Steam Inactive", MessageBoxButtons.OK, MessageBoxIcon.Hand); } Environment.Exit(0); } RunCallbacks().Forget(); SteamUtils.SetOverlayNotificationPosition(ENotificationPosition.k_EPositionBottomLeft); }
void TimerOnElapsed(object sender) { try { if (tickCounter % 300 == 0) { if (!IsOnline) { if (SteamAPI.Init() && SteamAPI.IsSteamRunning()) { IsOnline = true; SteamOnline(); } } } if (IsOnline) { if (SteamAPI.IsSteamRunning()) { SteamAPI.RunCallbacks(); } else { IsOnline = false; SteamOffline(); } } } catch (Exception ex) { Trace.TraceError(ex.ToString()); } tickCounter++; }
public static ProvideAuthToken SteamAuthTokenProvider() { const int maxTicketLength = 256; var cacheTimeOut = TimeSpan.FromMinutes(30); Maybe <AuthToken> cachedAuthToken = Maybe.Nothing <AuthToken>(); DateTime? cacheTime = null; return(() => { if (SteamAPI.IsSteamRunning() && SteamManager.Initialized) { if (!cacheTime.HasValue || (DateTime.Now - cacheTime) > cacheTimeOut) { uint ticketLength; var ticket = new byte[maxTicketLength]; SteamUser.GetAuthSessionTicket(ticket, maxTicketLength, out ticketLength); cachedAuthToken = Maybe.Just(Authentication.SteamAuthToken(ticket, ticketLength)); cacheTime = DateTime.Now; } } else { cachedAuthToken = Maybe.Nothing <AuthToken>(); } return cachedAuthToken; }); }
public static void Update() { if (SteamAPI.IsSteamRunning() && instance.IsRunning) { SteamAPI.RunCallbacks(); } }
public SteamManager() { if (!SteamAPI.IsSteamRunning()) { throw new Exception("Steam not running!"); } }
static void Main(string[] args) { #if DEBUG args = new string[] { "211420" }; // Dark Souls Prepare To Die Edition #endif if (args.Length == 0) { return; } uint appId = Convert.ToUInt32(args[0]); if (appId == 0) { return; } string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "steam_appid.txt"); if (!File.Exists(path)) { File.Create(path).Dispose(); } using (var tw = new StreamWriter(path, false)) { tw.WriteLine(appId.ToString()); } if (!SteamAPI.IsSteamRunning()) { // steam isn't running so we don't do anything return; } if (!SteamAPI.Init()) { /** * This could happen for a number of reason but probably * steam_appid.txt not being present or appid being invalid. */ Console.WriteLine( "[Steamworks.NET] SteamAPI_Init() failed. Refer to Valve's documentation or the comment above this line for more information."); } if (!SteamUserStats.ResetAllStats(true)) { /** * Please refer to the comment below this line for more information. */ Console.WriteLine( "[Steamworks.NET] SteamUserStats.ResetAllStats(true) failed. Refer to Valve's documentation or the comment above this line for more information."); } File.Delete(path); SteamAPI.Shutdown(); Environment.Exit(0); }
private void SteamThread() { while (SteamAPI.IsSteamRunning()) { SteamAPI.RunCallbacks(); Thread.Sleep(500); } }
private async void timer1_Tick(object sender, EventArgs e) { try { if (!SteamAPI.Init()) { if (SteamAPI.IsSteamRunning()) { steamLBL.ForeColor = Color.DarkBlue; steamLBL.Text = "Steam Running.."; steamSTATUS.Image = HDDowngradeTool.Properties.Resources.dotred; } else { steamLBL.ForeColor = Color.Gold; await Task.Delay(200); steamLBL.Text = "Steam OFF"; await Task.Delay(100); steamLBL.ForeColor = Color.Maroon; steamSTATUS.Image = HDDowngradeTool.Properties.Resources.dotred; } //SteamUtils.GetAppID(); } else { steamLBL.ForeColor = Color.ForestGreen; steamLBL.Text = "Steam ON"; steamSTATUS.Image = HDDowngradeTool.Properties.Resources.dotgreen; cbPATCH.Enabled = true; kryptonButton1.Enabled = true; await Task.Delay(200); bool IsDE = SteamApps.BIsAppInstalled(new AppId_t(221380)); if (!IsDE) { MessageBox.Show("Please Buy or Install Age of Empires II: Definitive Edition before you proceed!", "Game Missing"); cbPATCH.Enabled = false; timer1.Stop(); } var versionInfo = FileVersionInfo.GetVersionInfo(SaveDirectoryPath() + @"\AoK HD.exe"); string version = versionInfo.FileVersion; //string[] sver = version.Split('.'); label1.Text = "Current Version: " + version; timer1.Stop(); } } catch (SystemException) { steamLBL.ForeColor = Color.Black; steamLBL.Text = "Steam OFF"; steamSTATUS.Image = HDDowngradeTool.Properties.Resources.dotred; } }
private void StartSteamIfRequiredAndConfirm() { if (SteamAPI.IsSteamRunning()) { return; } ConfirmSteamPath(); StartSteam(); ConfirmSteamRunning(); }
public static void UploadWorkshopLevel() { if (SteamAPI.IsSteamRunning() && instance.IsRunning) { string path = Level.CurrentLevelButton.Path; string name = Level.CurrentLevelButton.Name; bool fileExists = SteamRemoteStorage.FileExists(name); if (instance.myLevels.Contains(name.ToLower())) { MessageBox.StatusMessage = new MessageBox("Level was already published! Delete it in Steam first", new Vector2(217, 190), 120); } else { MessageBox.StatusMessage = new MessageBox("Publishing to the workshop...", new Vector2(217, 190), 999999); instance.IsPublishing = true; Console.WriteLine("Fetching file data..."); string levelData = File.ReadAllText(path + "/LevelData.xml"); // Upload level data byte[] Data = new byte[Encoding.UTF8.GetByteCount(levelData)]; Encoding.UTF8.GetBytes(levelData, 0, levelData.Length, Data, 0); Console.WriteLine("Starting file upload..."); bool isSuccess = SteamRemoteStorage.FileWrite(name, Data, Data.Length); // Upload preview image Data = File.ReadAllBytes(LevelSaver.CustomLevelsPath + "/Preview.png"); Console.WriteLine("Starting preview file upload..."); string previewFileName = name + "_thumbnail"; isSuccess = isSuccess && SteamRemoteStorage.FileWrite(previewFileName, Data, Data.Length); Console.WriteLine("Finished file upload.. success = " + isSuccess.ToString()); if (isSuccess) { string[] tags = new string[0]; string workshopName = name; string workshopDescription = name; // Publish to workshop SteamAPICall_t handle = SteamRemoteStorage.PublishWorkshopFile(name, previewFileName, SteamUtils.GetAppID(), workshopName, workshopDescription, ERemoteStoragePublishedFileVisibility.k_ERemoteStoragePublishedFileVisibilityPublic, tags, EWorkshopFileType.k_EWorkshopFileTypeCommunity); Console.WriteLine("Started the workshop upload..."); instance.RemoteStoragePublishFileResult.Set(handle); instance.myLevels.Add(name.ToLower()); } else { instance.IsPublishing = false; System.Windows.Forms.MessageBox.Show( "An unexpected error occured while uploading the level data", "Failed to publish workshop file"); } } } }
private void T_Tick(object sender, EventArgs e) { labelSteamStatus.Content = "Steam Link Status : " + (SteamAPI.IsSteamRunning() ? "available" : "not available"); SteamAPI.RunCallbacks(); if (pending != null) { pending(); pending = null; } }
public static bool Check(RequirementVO req) { int val = !string.IsNullOrEmpty(req.ID) && SteamAPI.IsSteamRunning() && Steamworks.SteamUserStats.GetAchievement(req.ID, out bool done) && done ? 1 : 0; return(RequirementsSvc.Check(req, val)); }
public override void OnEnter() { isRunning.Value = SteamAPI.IsSteamRunning(); if (isRunning.Value) { Fsm.Event(running); } else { Fsm.Event(notRunning); } }
private static void DoSearch(string url, string term) { // check if steam is running and if the game is using the steam overlay if (SteamAPI.IsSteamRunning() && SteamUtils.IsOverlayEnabled()) { SteamFriends.ActivateGameOverlayToWebPage(url.Replace("%s", term)); } else { Process.Start(url.Replace("%s", term)); } }
private void tmrCheckSteam_Tick(object sender, EventArgs e) { var isSteamRunning = SteamAPI.IsSteamRunning() || Settings.Default.ignoreclient; lblSteamStatus.Text = isSteamRunning ? (Settings.Default.ignoreclient ? localization.strings.steam_ignored : localization.strings.steam_running) : localization.strings.steam_notrunning; lblSteamStatus.ForeColor = isSteamRunning ? Color.Green : Color.Black; picSteamStatus.Image = isSteamRunning ? Resources.imgTrue : Resources.imgFalse; tmrCheckSteam.Interval = isSteamRunning ? 5000 : 500; skipGameToolStripMenuItem.Enabled = isSteamRunning; pauseIdlingToolStripMenuItem.Enabled = isSteamRunning; IsSteamReady = isSteamRunning; }
private void TmrCheckSteam_Tick(object sender, EventArgs e) { var isSteamRunning = SteamAPI.IsSteamRunning() || Settings.Default.ignoreclient; LblSteamStatus.Text = isSteamRunning ? (Settings.Default.ignoreclient ? localization.strings.steam_ignored : localization.strings.steam_running) : localization.strings.steam_notrunning; LblSteamStatus.ForeColor = isSteamRunning ? Color.Green : Color.Black; PbxSteamStatus.Image = isSteamRunning ? Resources.imgTrue : Resources.imgFalse; TmrCheckSteam.Interval = isSteamRunning ? 5000 : 500; MnuGameSkip.Enabled = isSteamRunning; MnuGamePause.Enabled = isSteamRunning; IsSteamReady = isSteamRunning; }
public void GetTicket(bool goToPayment = false) { if ((Time.unscaledTime - this.lastRequestTicketTime) > this.MIN_RETRY_DELAY) { this.lastRequestTicketTime = Time.unscaledTime; this.goToPayment = goToPayment; if (SteamManager.Initialized && SteamAPI.IsSteamRunning()) { ticket = new byte[0x400]; SteamUser.GetAuthSessionTicket(ticket, 0x400, out ticketLength); } } }
public static void LoadWorkshopLevels() { if (SteamAPI.IsSteamRunning() && instance.IsRunning) { instance.subscribedItemButtonMap = new Dictionary<UGCHandle_t, WorkshopLevelButton>(); instance.subscribedThumbnailButtonMap = new Dictionary<UGCHandle_t, WorkshopLevelButton>(); instance.subscriptions = new Stack<PublishedFileId_t>(); instance.levelDataStack = new Stack<UGCHandle_t>(); instance.levelThumbnailStack = new Stack<UGCHandle_t>(); SteamAPICall_t handle = SteamRemoteStorage.EnumerateUserSubscribedFiles(0); instance.RemoteStorageEnumerateUserSubscribedFilesResult.Set(handle); } }
public void ResetAchievements() { if (active && SteamAPI.IsSteamRunning()) { try { SteamUserStats.ResetAllStats(bAchievementsToo: true); } catch (Exception) { } } }
public static DetectionResult TryInitSteam() { if (SteamAPI.Init()) { return(DetectionResult.Ok()); } if (!SteamAPI.IsSteamRunning()) { return(DetectionResult.SteamNotRunning()); } return(DetectionResult.NotRunBySteam()); }
public static void DownloadProgress(ulong mid, Action <ulong, ulong> onProgress = null, Action onComplete = null) { if (!SteamWorkshop._loaded) { throw new SteamWorkshopException("Unable to connect to Steam Client, is it open?"); } if (SteamWorkshop.IsInstalled(mid)) { Action action2 = onComplete; if (action2 == null) { return; } action2(); return; } PublishedFileId_t publishedFileId = SteamWorkshop.GetPublishedFileId(mid); Task.Factory.StartNew(() => { ulong num; ulong num1; do { SteamUGC.GetItemDownloadInfo(publishedFileId, out num, out num1); Action <ulong, ulong> action = onProgress; if (action != null) { action(num, num1); } else { } Thread.Sleep(1000); }while (!SteamWorkshop.IsInstalled(mid) && SteamAPI.IsSteamRunning()); if (!SteamAPI.IsSteamRunning()) { return; } if (SteamWorkshop.IsInstalled(mid)) { Action action1 = onComplete; if (action1 == null) { return; } action1(); } }); }
private bool CheckPrerequisites() { if (Instance) { return(false); } // checks to check if Steam connection should be initialized if (!Application.platform.IsDesktopPlatform()) { Debug.Log("Current platform is not Steam compatible, destroying SteamManager.", this); return(false); } #if !DISABLESTEAMWORKS if (!Environment.GetCommandLineArgs().Contains("enablesteam") && !Application.isEditor) { Debug.Log("Program not launched from Steam client and not editor, destroying SteamManager.", this); return(false); } if (!SteamAPI.IsSteamRunning()) { Debug.Log("Steam is not running, destroying SteamManager.", this); return(false); } // sanity checks to ensure Steamworks.NET is setup correctly if (!Packsize.Test()) { Debug.LogError("[Steamworks.NET] Packsize Test returned false, the wrong version of Steamworks.NET is being run in this platform.", this); return(false); } if (!DllCheck.Test()) { Debug.LogError("[Steamworks.NET] DllCheck Test returned false, One or more of the Steamworks binaries seems to be the wrong version.", this); return(false); } #endif #if !DISABLESTEAMWORKS return(true); #else // project compiled or editor target set for Steamworks-incompatible platform return(false); #endif }
public void DebugInfo() { if (SteamAPI.IsSteamRunning()) { Game1.debugOutput = "steam is running"; if (SteamUser.BLoggedOn()) { Game1.debugOutput += ", user logged on"; } } else { Game1.debugOutput = "steam is not running"; SteamAPI.Init(); } }