Пример #1
0
        private void GameStatistic_Load(object sender, EventArgs e)
        {
            ArrayList availablePlatforms = GameStatisticModel.GetAvailablePlatforms(onlineId);

            try
            {
                platform = availablePlatforms[0].ToString();
            }
            catch (Exception)
            {
                //Platform not found!
                return;
            }
            string defaultPlatform = IniModel.GetPSNPlatform();

            /*if (availablePlatforms.IndexOf(defaultPlatform) > -1)
             * {
             *  availablePlatforms
             * }*/
            foreach (String platform in availablePlatforms)
            {
                if (defaultPlatform == platform)
                {
                    toolStripComboBox1.Items.Insert(0, platform);
                }
                else
                {
                    toolStripComboBox1.Items.Add(platform);
                }
            }
            toolStripComboBox1.SelectedIndex = 0;
        }
Пример #2
0
 private void Settings_Load(object sender, EventArgs e)
 {
     if (Program.steamAvailable)
     {
         SteamLogButton.Text = "Logout";
     }
     else
     {
         SteamLogButton.Text = "Login";
     }
     checkBox1.Checked        = Utils.StartupEnabled();
     PsnUsernameLabel.Text    = OnPS.activityModel.onlineId;
     SteamUsernameLabel.Text  = IniModel.GetSteamUsername();
     PsnPlatformComboBox.Text = IniModel.GetPSNPlatform();
     initGameTypes();
     GameType.SelectedIndex = int.Parse(IniModel.GetGameView());
     PsnPlatformComboBox.SelectedIndexChanged += new System.EventHandler(this.PsnPlatformComboBox_SelectedIndexChanged);
     GameType.SelectedIndexChanged            += new System.EventHandler(this.GameType_SelectedIndexChanged);
     checkBox1.CheckedChanged += new System.EventHandler(this.checkBox1_CheckedChanged);
 }
Пример #3
0
        public static ActivityModel GetUserActivity(String oauth, bool isMain = false)
        {
            JObject o;

            try
            {
                o = JObject.Parse(Network.HTTP_GET("https://us-prof.np.community.playstation.net/userProfile/v1/users/me/profile2?fields=npId,onlineId,avatarUrls,plus,primaryOnlineStatus,presences(@titleInfo,hasBroadcastData)&avatarSizes=m,xl&profilePictureSizes=m,xl&languagesUsedLanguageSet=set3&psVitaTitleIcon=circled&titleIconSize=s", null, "Bearer " + oauth));
            }
            catch (Exception)
            {
                return(null);
            }
            ActivityModel activityModel = new ActivityModel(isMain);

            activityModel.onlineId            = o.GetValue("profile")["onlineId"].ToString();
            activityModel.npId                = o.GetValue("profile")["npId"].ToString();
            activityModel.plus                = Convert.ToInt16(o.GetValue("profile")["plus"]);
            activityModel.primaryOnlineStatus = o.GetValue("profile")["primaryOnlineStatus"].ToString();
            activityModel.avatarUrl           = o.GetValue("profile")["avatarUrls"][0]["avatarUrl"].ToString();
            activityModel.onlineStatus        = OnlineStatusModel.OFFLINE;
            activityModel.platform            = IniModel.GetPSNPlatform();
            var  presences = o.GetValue("profile")["presences"];
            bool SelectedPlatformAvailable = false;

            foreach (var data in presences)
            {
                if (data["platform"] == null)
                {
                    continue;
                }

                if (data["platform"].ToString() == activityModel.platform)
                {
                    SelectedPlatformAvailable = true;
                    try
                    {
                        activityModel.npTitleIconUrl = data["npTitleIconUrl"].ToString();
                    }
                    catch (Exception)
                    {
                        activityModel.npTitleIconUrl = null;
                    }
                    try
                    {
                        activityModel.onlineStatus = data["onlineStatus"].ToString();
                    }
                    catch (Exception)
                    {
                        activityModel.onlineStatus = OnlineStatusModel.OFFLINE;
                    }
                    try
                    {
                        activityModel.titleName = data["titleName"].ToString();
                        activityModel.npTitleId = data["npTitleId"].ToString();
                    }
                    catch (Exception)
                    {
                        activityModel.titleName = null;
                        activityModel.npTitleId = null;
                    }
                    try
                    {
                        activityModel.gameStatus = data["gameStatus"].ToString();
                    }
                    catch (Exception)
                    {
                        activityModel.gameStatus = null;
                    }
                }
                if (data["platform"] != null && data["titleName"] != null && data["npTitleId"] != null)
                {
                    GameData gameData = new GameData();
                    gameData.platform  = data["platform"].ToString();
                    gameData.titleName = data["titleName"].ToString();
                    gameData.npTitleId = data["npTitleId"].ToString();
                    try
                    {
                        gameData.npTitleIconUrl = data["npTitleIconUrl"].ToString();
                    }
                    catch (Exception)
                    {
                        gameData.npTitleIconUrl = "";
                    }
                    activityModel.RunningGames.Add(gameData);
                }
            }
            if (SelectedPlatformAvailable == false)
            {
                activityModel.onlineStatus = OnlineStatusModel.OFFLINE;
            }
            return(activityModel);
        }