示例#1
0
        public GameDataViewModel(GameData data, ITileCreator creator,SteamAPI steamAPI)
            : base(data, creator)
        {
            _steamAPI = steamAPI;

            UpdateImageFromSteamCommand= new LabeledRelayCommand("Update image from Steam", () => UpdateImageFromSteam(), () => Model != null);
            UpdateIsInstalledCommand = new LabeledRelayCommand("Update Installation status", () => UpdateIsInstalled(), () => Model != null);
        }
示例#2
0
// ReSharper disable once UnusedMember.Local
        private void OnDisable()
        {
            if (_isOwningInstance)
            {
                CancelAuthTicket();

                SteamAPI.Shutdown();

                IsInitialized = false;
            }
        }
示例#3
0
 public override void Close()
 {
     if (!IsHosting)
     {
         return;
     }
     SteamGameServer.EnableHeartbeats(false);
     SteamGameServer.LogOff();
     GameServer.Shutdown();
     SteamAPI.Shutdown();
     IsHosting = false;
 }
        private void SteamCallbackLoop(object context)
        {
            Monitor.Enter(this._steamCallbackLock);
            while (this.IsSteamValid)
            {
                SteamAPI.RunCallbacks();
                Monitor.Wait(this._steamCallbackLock);
            }

            Monitor.Exit(this._steamCallbackLock);
            SteamAPI.Shutdown();
        }
示例#5
0
        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 didSelectBeatmap(BeatmapDifficultyViewController controller, IDifficultyBeatmap beatmap)
        {
            Logger.Debug($"beatmap {beatmap.difficulty} selected");
            if (!_partyFlowCoordinator || !_partyFlowCoordinator.isActivated)
            {
                toggleButtons(true);
                return;
            }

            toggleButtons(false);
            SteamAPI.SetDifficulty((byte)beatmap.difficulty);
        }
示例#7
0
        private void OnDestroy()
        {
            if (!Instance)
            {
                return;
            }

            Instance = null;
#if !DISABLESTEAMWORKS
            SteamAPI.Shutdown();
#endif
        }
示例#8
0
        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;
        }
示例#9
0
 public override void OnEnter()
 {
     isRunning.Value = SteamAPI.IsSteamRunning();
     if (isRunning.Value)
     {
         Fsm.Event(running);
     }
     else
     {
         Fsm.Event(notRunning);
     }
 }
示例#10
0
        public List <LeaderboardEntry> FetchLeaderboard()
        {
            SteamAPICall_t handle = SteamUserStats.FindLeaderboard(name);

            m_FoundLeaderboard.Set(handle);
            Console.WriteLine("Searching for leaderboard " + this.name + ", holup");
            while (!done)
            {
                SteamAPI.RunCallbacks();
            }
            return(this.leaderboard);
        }
示例#11
0
    public void OnEnable()
    {
        Instance = this;

        SteamAPI.Init();

        OnCreateItemResult = CallResult <CreateItemResult_t> .Create(OnCreateItemResultFunc);

        OnSubmitItemUpdateResult = CallResult <SubmitItemUpdateResult_t> .Create(OnSubmitItemUpdateResultFunc);

        OnSteamUGCQueryCompleted = CallResult <SteamUGCQueryCompleted_t> .Create(OnSteamUGCQueryCompletedCallFunc);
    }
示例#12
0
    void OnDestroy()
    {
        if (current == exitGame)
        {
            SteamAPI.Shutdown();
        }

        if (CameraFade.InstanceExists())
        {
            CameraFade.Instance.m_OnFadeFinish -= ActivateManualty;
        }
    }
示例#13
0
        private bool Relaunch()
        {
            var appId = uint.Parse(textBox1.Text);

            if (!SteamAPI.RestartAppIfNecessary(new AppId_t(appId)))
            {
                MessageBox.Show("Cannot relaunch.", Program.Title, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }

            return(true);
        }
示例#14
0
 private void InitializeSteam()
 {
     try
     {
         SteamAPI.Init();
     }
     catch (Exception value)
     {
         Console.WriteLine(value);
         Exit();
     }
 }
示例#15
0
        public async Task <string> Share()
        {
            var ret = SteamRemoteStorage.FileShare(name);

            result.Set(ret);
            while (!finished)
            {
                SteamAPI.RunCallbacks();
                await Task.Delay(100);
            }
            return(url);
        }
示例#16
0
 public override void _Ready()
 {
     runOnSteam();
     if (SteamAPI.Init())
     {
         GD.Print(SteamFriends.GetPersonaName());
     }
     else
     {
         GD.Print("[STEAMWORKS] Failed to initialize Steam. Please make sure that the Steam client is open.");
     }
 }
示例#17
0
 private void OnDestroy()
 {
     if (!(s_instance != this))
     {
         s_instance = null;
         if (m_bInitialized)
         {
             Debug.Log("Shutting down steamworks");
             SteamAPI.Shutdown();
         }
     }
 }
示例#18
0
 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));
     }
 }
        protected void didSelectLevel(LevelListViewController controller, IBeatmapLevel level)
        {
            Logger.Debug($"level {level.levelID} selected");

            if (!_partyFlowCoordinator || !_partyFlowCoordinator.isActivated)
            {
                toggleButtons(true);
                return;
            }
            toggleButtons(false);
            SteamAPI.SetSong(level.levelID, level.songName);
        }
示例#20
0
 // Token: 0x060009E2 RID: 2530 RVA: 0x00047BC4 File Offset: 0x00045DC4
 private void Awake()
 {
     if (SteamManager.s_instance != null)
     {
         UnityEngine.Object.Destroy(base.gameObject);
         return;
     }
     SteamManager.s_instance = this;
     SteamManager.APP_ID     = this.LoadAPPID();
     ZLog.Log("Using steam APPID:" + SteamManager.APP_ID.ToString());
     if (!SteamManager.ACCEPTED_APPIDs.Contains(SteamManager.APP_ID))
     {
         ZLog.Log("Invalid APPID");
         Application.Quit();
         return;
     }
     if (SteamManager.s_EverInialized)
     {
         throw new Exception("Tried to Initialize the SteamAPI twice in one session!");
     }
     UnityEngine.Object.DontDestroyOnLoad(base.gameObject);
     if (!Packsize.Test())
     {
         Debug.LogError("[Steamworks.NET] Packsize Test returned false, the wrong version of Steamworks.NET is being run in this platform.", this);
     }
     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);
     }
     try
     {
         if (SteamAPI.RestartAppIfNecessary((AppId_t)SteamManager.APP_ID))
         {
             Application.Quit();
             return;
         }
     }
     catch (DllNotFoundException arg)
     {
         Debug.LogError("[Steamworks.NET] Could not load [lib]steam_api.dll/so/dylib. It's likely not in the correct location. Refer to the README for more details.\n" + arg, this);
         Application.Quit();
         return;
     }
     this.m_bInitialized = SteamAPI.Init();
     if (!this.m_bInitialized)
     {
         Debug.LogError("[Steamworks.NET] SteamAPI_Init() failed. Refer to Valve's documentation or the comment above this line for more information.", this);
         return;
     }
     ZLog.Log("Authentication:" + SteamNetworkingSockets.InitAuthentication().ToString());
     SteamManager.s_EverInialized = true;
 }
示例#21
0
    private void Awake()
    {
        // Only one instance of SteamManager at a time!
        if (s_instance != null)
        {
            Destroy(gameObject);
            return;
        }
        s_instance = this;

        if (s_EverInialized)
        {
            // This is almost always an error.
            // The most common case where this happens is the SteamManager getting desstroyed via Application.Quit() and having some code in some OnDestroy which gets called afterwards, creating a new SteamManager.
            throw new System.Exception("Tried to Initialize the SteamAPI twice in one session!");
        }

        // We want our SteamManager Instance to persist across scenes.
        DontDestroyOnLoad(gameObject);

        if (!Packsize.Test())
        {
            Debug.LogError("[Steamworks.NET] Packsize Test returned false, the wrong version of Steamworks.NET is being run in this platform.", this);
        }

        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);
        }

        // Initialize the SteamAPI, if Init() returns false this can happen for many reasons.
        // Some examples include:
        // Steam Client is not running.
        // Launching from outside of steam without a steam_appid.txt file in place.
        // Running under a different OS User or Access level (for example running "as administrator")
        // Valve's documentation for this is located here:
        // https://partner.steamgames.com/documentation/getting_started
        // https://partner.steamgames.com/documentation/example // Under: Common Build Problems
        // https://partner.steamgames.com/documentation/bootstrap_stats // At the very bottom

        // If you're running into Init issues try running DbgView prior to launching to get the internal output from Steam.
        // http://technet.microsoft.com/en-us/sysinternals/bb896647.aspx
        m_bInitialized = SteamAPI.Init();
        if (!m_bInitialized)
        {
            Debug.LogError("[Steamworks.NET] SteamAPI_Init() failed. Refer to Valve's documentation or the comment above this line for more information.", this);

            return;
        }

        s_EverInialized = true;
    }
示例#22
0
        public static void Main(string[] args)
        {
            Console.Write("Please enter the game's AppID (found in the store url): ");

            m_GameID = Console.ReadLine();

            File.WriteAllText(AppDomain.CurrentDomain.BaseDirectory + @"\steam_appid.txt", m_GameID);

            init();
            SteamAPI.RunCallbacks();
            getSchema();

            Console.WriteLine("Press spacebar to unlock achievements, or escape to exit.");

            while (true)
            {
                // Must be called from the primary thread.
                SteamAPI.RunCallbacks();

                if (Console.KeyAvailable)
                {
                    ConsoleKeyInfo info = Console.ReadKey(true);

                    if (info.Key == ConsoleKey.Escape)
                    {
                        break;
                    }
                    else if (info.Key == ConsoleKey.Spacebar)
                    {
                        for (int i = 0; i < names.Count; i++)
                        {
                            SteamUserStats.SetAchievement(names[i]);
                            Console.WriteLine("Unlocking \'" + ufNames[i] + "\'...");
                        }
                        if (!SteamUserStats.StoreStats())
                        {
                            Console.WriteLine("Achievements failed to unlock...");
                        }
                        else
                        {
                            Console.WriteLine("Achievements successfully unlocked.");
                        }
                        break;
                    }
                }

                Thread.Sleep(50);
            }
            Console.WriteLine("Press <ENTER> to exit");
            Console.ReadLine();
            SteamAPI.Shutdown();
        }
示例#23
0
        protected override void OnFormRunFrame()
        {
            base.OnFormRunFrame();

            utils.HandleLogging();

            if (!factory_list_init.m_bHasInitialized)
            {
                return;
            }

            SteamAPI.RunCallbacks();
        }
示例#24
0
    public bool Initialize()
    {
        this.isInitialized = SteamAPI.Init();

        if (this.isInitialized)
        {
            RegisterCallbacks();
        }

        SignalStateChanged();

        return(this.isInitialized);
    }
示例#25
0
 private void OnDestroy()
 {
     if (SteamManager.s_instance != this)
     {
         return;
     }
     SteamManager.s_instance = null;
     if (!this.m_bInitialized)
     {
         return;
     }
     SteamAPI.Shutdown();
 }
示例#26
0
 // Token: 0x060009ED RID: 2541 RVA: 0x00047F12 File Offset: 0x00046112
 protected virtual void OnDestroy()
 {
     if (SteamManager2.s_instance != this)
     {
         return;
     }
     SteamManager2.s_instance = null;
     if (!this.m_bInitialized)
     {
         return;
     }
     SteamAPI.Shutdown();
 }
示例#27
0
 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);
     }
 }
示例#28
0
        public static void Update(float dt)
        {
#if STEAMWORKS
            if (SteamInitialized)
            {
                SteamAPI.RunCallbacks();
            }
            if (_overlayTimer > 0)
            {
                _overlayTimer -= dt;
            }
#endif
        }
 // Token: 0x06008627 RID: 34343 RVA: 0x002F0928 File Offset: 0x002EEB28
 private void FABMDEHEDNO()
 {
     if (!this.FMLHGNJJDEA)
     {
         return;
     }
     SteamAPI.RunCallbacks();
     if (!this.MEMEGFOKJBG)
     {
         SteamAPI.Shutdown();
         base.enabled = true;
     }
 }
 // Token: 0x06008620 RID: 34336 RVA: 0x002EFDF7 File Offset: 0x002EDFF7
 private void BGDONBMDPGM()
 {
     if (!this.FMLHGNJJDEA)
     {
         return;
     }
     SteamAPI.RunCallbacks();
     if (!this.MEMEGFOKJBG)
     {
         SteamAPI.Shutdown();
         base.enabled = false;
     }
 }
示例#31
0
 public void ResetAchievements()
 {
     if (active && SteamAPI.IsSteamRunning())
     {
         try
         {
             SteamUserStats.ResetAllStats(bAchievementsToo: true);
         }
         catch (Exception)
         {
         }
     }
 }
示例#32
0
文件: Main.cs 项目: ta0soft/STEAMp3
 //private void p_Lobby_LobbyIDChanged()
 //{
 //MessageBox.Show("LobbyID: " + p_Lobby.LobbyID.ToString());
 //}
 private void p_Lobby_MessageReceived(SteamAPI.SteamID lobbyID, SteamAPI.SteamID sender, string message)
 {
     //MessageBox.Show("LobbyMessage: " + message);
 }
示例#33
0
文件: Main.cs 项目: ta0soft/STEAMp3
 //private void p_PM_FriendIDChanged()
 //{
 //}
 private void p_PM_MessageReceived(SteamAPI.SteamID sender, SteamAPI.SteamID receiver, string message)
 {
     if (!Global.MainWindow.ProcessGlobalCommand(message, false))
     {
         if (sender.ToString() == p_Client.GetSteamID().ToString())
         {
             if (Global.MainWindow.ProcessLocalCommand(message, false))
             {
                 Global.Stats.CommandsUsed++;
             }
         }
     }
 }
示例#34
0
文件: Main.cs 项目: ta0soft/STEAMp3
        public static string GetAchieved(SteamAPI.SteamID steamID)
        {
            try
            {
                if (!Global.MediaPlayer.IsOnline) return "Error: {ls}Unable to retrieve data{rs}";

                WebClient wc = new WebClient();
                string result = wc.DownloadString("http://steamp3.ta0soft.com/stats.php?id=" + steamID.ToUInt64().ToString() + "&xml=1");

                XmlDocument xml = new XmlDocument();
                xml.LoadXml(result);
                XmlNodeList users = xml.SelectNodes("Steamp3.Stats/Users/User");

                foreach (XmlNode user in users)
                {
                    if (GetXmlValue(user, "ID", "0") == steamID.ToUInt64().ToString())
                    {
                        result = "";
                        int achieved = 0;
                        XmlNode achievements = user.SelectSingleNode("Achievements");

                        int chattyCathy = StringToInt(GetXmlValue(achievements, "ChattyCathy", "0"));
                        int jukeboxHero = StringToInt(GetXmlValue(achievements, "JukeboxHero", "0"));
                        int leetHaxor = StringToInt(GetXmlValue(achievements, "LeetHaxor", "0"));
                        int mp3Playah = StringToInt(GetXmlValue(achievements, "MP3Playah", "0"));
                        int radioStar = StringToInt(GetXmlValue(achievements, "RadioStar", "0"));
                        int repetition = StringToInt(GetXmlValue(achievements, "Repetition", "0"));
                        int shamelessPlug = StringToInt(GetXmlValue(achievements, "ShamelessPlug", "0"));
                        int shortStop = StringToInt(GetXmlValue(achievements, "ShortStop", "0"));
                        int skinnyDipper = StringToInt(GetXmlValue(achievements, "SkinnyDipper", "0"));

                        UI.Achievement achievement = Global.MainWindow.AchievementList.GetItemByID("cc");
                        if (achievement != null && chattyCathy == achievement.Maximum)
                        {
                            achieved++;
                            result += achievement.Name + ", ";
                        }

                        achievement = Global.MainWindow.AchievementList.GetItemByID("jh");
                        if (achievement != null && jukeboxHero == achievement.Maximum)
                        {
                            achieved++;
                            result += achievement.Name + ", ";
                        }

                        achievement = Global.MainWindow.AchievementList.GetItemByID("lh");
                        if (achievement != null && leetHaxor == achievement.Maximum)
                        {
                            achieved++;
                            result += achievement.Name + ", ";
                        }

                        achievement = Global.MainWindow.AchievementList.GetItemByID("mp");
                        if (achievement != null && mp3Playah == achievement.Maximum)
                        {
                            achieved++;
                            result += achievement.Name + ", ";
                        }

                        achievement = Global.MainWindow.AchievementList.GetItemByID("rs");
                        if (achievement != null && radioStar == achievement.Maximum)
                        {
                            achieved++;
                            result += achievement.Name + ", ";
                        }

                        achievement = Global.MainWindow.AchievementList.GetItemByID("rp");
                        if (achievement != null && repetition == achievement.Maximum)
                        {
                            achieved++;
                            result += achievement.Name + ", ";
                        }

                        achievement = Global.MainWindow.AchievementList.GetItemByID("sh");
                        if (achievement != null && shamelessPlug == achievement.Maximum)
                        {
                            achieved++;
                            result += achievement.Name + ", ";
                        }

                        achievement = Global.MainWindow.AchievementList.GetItemByID("ss");
                        if (achievement != null && shortStop == achievement.Maximum)
                        {
                            achieved++;
                            result += achievement.Name + ", ";
                        }

                        achievement = Global.MainWindow.AchievementList.GetItemByID("sd");
                        if (achievement != null && skinnyDipper == achievement.Maximum)
                        {
                            achieved++;
                            result += achievement.Name + ", ";
                        }

                        if (!string.IsNullOrEmpty(result)) result = result.Substring(0, result.Length - 2);

                        return "{ls}" + Global.Steam.Client.GetFriendPersonaName(steamID) + "{rs} Achievements earned: {ls}" + achieved.ToString() + " / " +  FormatNumber(Global.MainWindow.AchievementList.Items.Count) + "{rs}" + Environment.NewLine + result;
                    }
                }

                return "User not found: {ls}" + Steam.Client.GetFriendPersonaName(steamID) + "{rs}";
            }
            catch
            {
                return "Error: {ls}Unable to retrieve data{rs}";
            }
        }
示例#35
0
        public SteamSelectorViewModel(IEventAggregator eventAggregator, ITileCreator tileCreator)
        {
            _tileDataSelectedEvent = eventAggregator.GetEvent<TileDataSelectedEvent>();
            _tileDataSelectedEvent.Subscribe(o =>
            {
                try
                {
                    _reactingToTileDataSelectedEvent = true;
                    SelectedGameData = o as GameDataViewModel;
                }
                finally
                {
                    _reactingToTileDataSelectedEvent = false;
                }
            });
            _tileCreator = tileCreator;

            RefreshCommand = new AsyncRelayCommand(() => Refresh(), null, true);


            UserData = CacheManager.LoadFromCache<UserData>().FirstOrDefault() ?? new UserData();
            SteamAPI = new SteamAPI(UserData.SteamCommunityId);


            UserData.SteamCommunityIdChanged += async (o, e) =>
             {
                 await UserData.SaveToCacheAsync();
                 SteamAPI = new SteamAPI(UserData.SteamCommunityId);
             };



            var cachedGameDatas = CacheManager.LoadFromCache<GameData>()
                    .OrderBy(o => o.IsInstalled ? 0 : 1)
                    .ThenBy(o => o.Name)
                    .Select(o => new GameDataViewModel(o, _tileCreator, SteamAPI));

            GameDatas.AddRange(cachedGameDatas);

            GameDatas.CollectionChanged += async (o, e) =>
             {
                 switch (e.Action)
                 {
                     case NotifyCollectionChangedAction.Add:

                         foreach (GameData item in e.NewItems)
                             await item.SaveToCacheAsync();
                         break;
                     case NotifyCollectionChangedAction.Remove:
                         foreach (GameData item in e.OldItems)
                             await item.RemoveFromCacheAsync();
                         break;
                     default:
                         break;
                 }
             };


            Application.Current.Exit += (o, e) =>
            {
                UserData.SaveToCache();
                if (SelectedGameData != null)
                    SelectedGameData.GameModel.SaveToCache();

            };


        }
示例#36
0
文件: Main.cs 项目: ta0soft/STEAMp3
        //private void p_Chat_ChatIDChanged()
        //{
        //}
        private void p_Chat_MessageReceived(SteamAPI.SteamID chatID, SteamAPI.SteamID sender, string message)
        {
            if (!Global.MainWindow.ProcessGlobalCommand(message, true))
            {
                if (sender.ToString() == p_Client.GetSteamID().ToString())
                {
                    if (Global.MainWindow.ProcessLocalCommand(message, true))
                    {
                        Global.Stats.CommandsUsed++;

                        Global.MainWindow.AchievementList.IncreaseChattyCathy(chatID);
                    }
                }
            }
        }
示例#37
0
文件: Main.cs 项目: ta0soft/STEAMp3
        public static string GetCommunityID(SteamAPI.SteamID steamID)
        {
            try
            {
                if (!Global.MediaPlayer.IsOnline) return string.Empty;

                WebClient wc = new WebClient();
                //string result = wc.DownloadString("http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0001/?key=C341BF941A262342916AF6F150B59031&steamids=" + steamID.ToInt64().ToString() + "&format=xml");
                string result = wc.DownloadString("http://steamcommunity.com/profiles/" + steamID.ToUInt64().ToString() + "?xml=1");
                XmlDocument xml = new XmlDocument();
                xml.LoadXml(result);
                XmlNode id = xml.SelectSingleNode("profile/customURL");

                if (id == null || string.IsNullOrEmpty(id.InnerText)) return steamID.ToUInt64().ToString();
                return id.InnerText;
            }
            catch
            {
                return steamID.ToUInt64().ToString();
            }
        }
示例#38
0
文件: Main.cs 项目: ta0soft/STEAMp3
        public static string GetStats(SteamAPI.SteamID steamID)
        {
            try
            {
                if (!Global.MediaPlayer.IsOnline) return "Error: {ls}Unable to retrieve data{rs}";

                WebClient wc = new WebClient();
                string result = wc.DownloadString("http://steamp3.ta0soft.com/stats.php?xml=1&id=" + steamID.ToUInt64().ToString());

                XmlDocument xml = new XmlDocument();
                xml.LoadXml(result);
                XmlNodeList users = xml.SelectNodes("Steamp3.Stats/Users/User");

                foreach (XmlNode user in users)
                {
                    if (GetXmlValue(user, "ID", "0") == steamID.ToUInt64().ToString())
                    {
                        int achieved = 0;
                        XmlNode achievements = user.SelectSingleNode("Achievements");

                        int commandsUsed = StringToInt(GetXmlValue(user, "CommandsUsed", "0"));
                        int songsPlayed = StringToInt(GetXmlValue(user, "SongsPlayed", "0"));
                        int songsCompleted = StringToInt(GetXmlValue(user, "SongsCompleted", "0"));
                        string song = GetXmlValue(user, "Song", "N/A");
                        string userSince = ConvertUnixDate(StringToInt(GetXmlValue(user, "UserSince", "0")), "Never");
                        string lastOnline = ConvertUnixDate(StringToInt(GetXmlValue(user, "LastOnline", "0")), "Never");
                        string playTime = ConvertSeconds(StringToInt(GetXmlValue(user, "PlayTime", "0")), false);
                        string runTime = ConvertSeconds(StringToInt(GetXmlValue(user, "RunTime", "0")), false);

                        int chattyCathy = StringToInt(GetXmlValue(achievements, "ChattyCathy", "0"));
                        int jukeboxHero = StringToInt(GetXmlValue(achievements, "JukeboxHero", "0"));
                        int leetHaxor = StringToInt(GetXmlValue(achievements, "LeetHaxor", "0"));
                        int mp3Playah = StringToInt(GetXmlValue(achievements, "MP3Playah", "0"));
                        int radioStar = StringToInt(GetXmlValue(achievements, "RadioStar", "0"));
                        int repetition = StringToInt(GetXmlValue(achievements, "Repetition", "0"));
                        int shamelessPlug = StringToInt(GetXmlValue(achievements, "ShamelessPlug", "0"));
                        int shortStop = StringToInt(GetXmlValue(achievements, "ShortStop", "0"));
                        int skinnyDipper = StringToInt(GetXmlValue(achievements, "SkinnyDipper", "0"));

                        UI.Achievement achievement = Global.MainWindow.AchievementList.GetItemByID("cc");
                        if (achievement != null && chattyCathy == achievement.Maximum) achieved++;

                        achievement = Global.MainWindow.AchievementList.GetItemByID("jh");
                        if (achievement != null && jukeboxHero == achievement.Maximum) achieved++;

                        achievement = Global.MainWindow.AchievementList.GetItemByID("lh");
                        if (achievement != null && leetHaxor == achievement.Maximum) achieved++;

                        achievement = Global.MainWindow.AchievementList.GetItemByID("mp");
                        if (achievement != null && mp3Playah == achievement.Maximum) achieved++;

                        achievement = Global.MainWindow.AchievementList.GetItemByID("rs");
                        if (achievement != null && radioStar == achievement.Maximum) achieved++;

                        achievement = Global.MainWindow.AchievementList.GetItemByID("rp");
                        if (achievement != null && repetition == achievement.Maximum) achieved++;

                        achievement = Global.MainWindow.AchievementList.GetItemByID("sh");
                        if (achievement != null && shamelessPlug == achievement.Maximum) achieved++;

                        achievement = Global.MainWindow.AchievementList.GetItemByID("ss");
                        if (achievement != null && shortStop == achievement.Maximum) achieved++;

                        achievement = Global.MainWindow.AchievementList.GetItemByID("sd");
                        if (achievement != null && skinnyDipper == achievement.Maximum) achieved++;

                        return "STEAMp3 stats for: {ls}" + Steam.Client.GetFriendPersonaName(steamID) + "{rs}" + Environment.NewLine + "Achievements: {ls}" + achieved.ToString() + " / " + FormatNumber(Global.MainWindow.AchievementList.Items.Count) + "{rs} Commands used: {ls}" + FormatNumber(commandsUsed) + "{rs}" + Environment.NewLine + "Songs played: {ls}" + FormatNumber(songsPlayed) + "{rs} Songs completed: {ls}" + FormatNumber(songsCompleted) + "{rs}" + Environment.NewLine + "User since: {ls}" + userSince + "{rs} Last online: {ls}" + lastOnline + "{rs}" + Environment.NewLine + "Play-time: {ls}" + playTime + "{rs} Run-time: {ls}" + runTime + "{rs}" + Environment.NewLine + "Recently played: {ls}" + song + "{rs}";
                    }
                }

                return "User not found: {ls}" + Steam.Client.GetFriendPersonaName(steamID) + "{rs}";
            }
            catch
            {
                return "Error: {ls}Unable to retrieve data{rs}";
            }
        }