private void RefreshLeaderBoard()
        {
            LastUpdate     = TimeStamp.Now;
            SRCLeaderBoard = null;

            try
            {
                if (State != null && State.Run != null && State.Run.Metadata.Game != null && State.Run.Metadata.Category != null)
                {
                    //Get these from setings later:
                    var             region_filter   = Settings.FilterRegion && State.Run.Metadata.Region != null ? State.Run.Metadata.Region.ID : null;
                    var             platorm_filter  = Settings.FilterPlatform && State.Run.Metadata.Platform != null ? State.Run.Metadata.Platform.ID : null;
                    EmulatorsFilter emulator_filter = !Settings.FilterEmulator ? EmulatorsFilter.NotSet : State.Run.Metadata.UsesEmulator ? EmulatorsFilter.OnlyEmulators : EmulatorsFilter.NoEmulators;

                    var leaderboard = Client.Leaderboards.GetLeaderboardForFullGameCategory(
                        State.Run.Metadata.Game.ID,
                        State.Run.Metadata.Category.ID,
                        platformId: platorm_filter,
                        regionId: region_filter,
                        emulatorsFilter: emulator_filter);

                    if (leaderboard != null)
                    {
                        SRCLeaderBoard = leaderboard;
                    }
                }
            } catch (Exception ex)
            {
                Log.Error(ex);
            }
            IsLoading = false;
            ShowLeaderBoard();
        }
        private void RefreshPersonalRecord()
        {
            LastUpdate = TimeStamp.Now;

            PersonalRecord = null;

            try
            {
                if (State != null && State.Run != null &&
                    State.Run.Metadata.Game != null && State.Run.Metadata.Category != null)
                {
                    var             variableFilter = Settings.FilterVariables ? State.Run.Metadata.VariableValues.Values : null;
                    var             regionFilter   = Settings.FilterRegion && State.Run.Metadata.Region != null ? State.Run.Metadata.Region.ID : null;
                    var             platformFilter = Settings.FilterPlatform && State.Run.Metadata.Platform != null ? State.Run.Metadata.Platform.ID : null;
                    EmulatorsFilter emulatorFilter = EmulatorsFilter.NotSet;
                    if (Settings.FilterPlatform)
                    {
                        if (State.Run.Metadata.UsesEmulator)
                        {
                            emulatorFilter = EmulatorsFilter.OnlyEmulators;
                        }
                        else
                        {
                            emulatorFilter = EmulatorsFilter.NoEmulators;
                        }
                    }

                    var leaderboard = Client.Leaderboards.GetLeaderboardForFullGameCategory(State.Run.Metadata.Game.ID, State.Run.Metadata.Category.ID,
                                                                                            platformId: platformFilter, regionId: regionFilter,
                                                                                            emulatorsFilter: emulatorFilter, variableFilters: variableFilter);

                    if (leaderboard != null)
                    {
                        PersonalRecord  = leaderboard.Records.Where(r => r.Player.Name.ToLower() == "derko".ToLower()).FirstOrDefault();
                        TrophyIcon      = GetTrophyIcon();
                        CountryFlagIcon = GetCountryFlagIcon();
                        UserIcon        = GetUserIcon();
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex);
            }

            IsLoading = false;
            ShowPersonalRecord(State.Layout.Mode);
        }
Exemplo n.º 3
0
        private void RefreshWorldRecord()
        {
            LastUpdate = TimeStamp.Now;

            WorldRecord = null;

            try
            {
                if (State != null && State.Run != null &&
                    State.Run.Metadata.Game != null && State.Run.Metadata.Category != null)
                {
                    var             variableFilter = Settings.FilterVariables ? State.Run.Metadata.VariableValues.Values : null;
                    var             regionFilter   = Settings.FilterRegion && State.Run.Metadata.Region != null ? State.Run.Metadata.Region.ID : null;
                    var             platformFilter = Settings.FilterPlatform && State.Run.Metadata.Platform != null ? State.Run.Metadata.Platform.ID : null;
                    EmulatorsFilter emulatorFilter = EmulatorsFilter.NotSet;
                    if (Settings.FilterPlatform)
                    {
                        if (State.Run.Metadata.UsesEmulator)
                        {
                            emulatorFilter = EmulatorsFilter.OnlyEmulators;
                        }
                        else
                        {
                            emulatorFilter = EmulatorsFilter.NoEmulators;
                        }
                    }

                    var leaderboard = Client.Leaderboards.GetLeaderboardForFullGameCategory(State.Run.Metadata.Game.ID, State.Run.Metadata.Category.ID,
                                                                                            top: 1,
                                                                                            platformId: platformFilter, regionId: regionFilter,
                                                                                            emulatorsFilter: emulatorFilter, variableFilters: variableFilter);

                    if (leaderboard != null)
                    {
                        WorldRecord = leaderboard.Records.FirstOrDefault();
                        AllTies     = leaderboard.Records;
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex);
            }

            IsLoading = false;
            ShowWorldRecord(State.Layout.Mode);
        }
        private Leaderboard getLeaderboard(
            string uri, int? top = null,
            string platformId = null, string regionId = null,
            EmulatorsFilter emulatorsFilter = EmulatorsFilter.NotSet, bool filterOutRunsWithoutVideo = false,
            TimingMethod? orderBy = null,
            IEnumerable<VariableValue> variableFilters = null,
            LeaderboardEmbeds embeds = default(LeaderboardEmbeds))
        {
            var parameters = new List<string>() { embeds.ToString() };

            if (top.HasValue)
                parameters.Add(string.Format("top={0}", top.Value));
            if (!string.IsNullOrEmpty(platformId))
                parameters.Add(string.Format("platform={0}", Uri.EscapeDataString(platformId)));
            if (!string.IsNullOrEmpty(regionId))
                parameters.Add(string.Format("region={0}", Uri.EscapeDataString(regionId)));
            if (emulatorsFilter != EmulatorsFilter.NotSet)
                parameters.Add(string.Format("emulators={0}",
                    emulatorsFilter == EmulatorsFilter.OnlyEmulators ? "true" : "false"));
            if (filterOutRunsWithoutVideo)
                parameters.Add("video-only=true");
            if (orderBy.HasValue)
            {
                var timing = orderBy.Value.ToAPIString();
                parameters.Add(string.Format("timing={0}", timing));
            }
            if (variableFilters != null)
            {
                foreach (var variableValue in variableFilters)
                {
                    parameters.Add(string.Format("var-{0}={1}",
                        Uri.EscapeDataString(variableValue.VariableID),
                        Uri.EscapeDataString(variableValue.ID)));
                }
            }

            var innerUri = GetLeaderboardsUri(string.Format("{0}{1}",
                uri,
                parameters.ToParameters()));

            var result = baseClient.DoRequest(innerUri);
            return Leaderboard.Parse(baseClient, result.data);
        }
        public Leaderboard GetLeaderboardForFullGameCategory(
            string gameId, string categoryId,
            int? top = null,
            string platformId = null, string regionId = null,
            EmulatorsFilter emulatorsFilter = EmulatorsFilter.NotSet, bool filterOutRunsWithoutVideo = false,
            TimingMethod? orderBy = null,
            IEnumerable<VariableValue> variableFilters = null,
            LeaderboardEmbeds embeds = default(LeaderboardEmbeds))
        {
            var uri = string.Format("/{0}/category/{1}",
                Uri.EscapeDataString(gameId),
                Uri.EscapeDataString(categoryId));

            return getLeaderboard(uri,
                top,
                platformId, regionId,
                emulatorsFilter, filterOutRunsWithoutVideo,
                orderBy, variableFilters,
                embeds);
        }
Exemplo n.º 6
0
        public Leaderboard GetLeaderboardForFullGameCategory(
            string gameId, string categoryId,
            int?top           = null,
            string platformId = null, string regionId = null,
            EmulatorsFilter emulatorsFilter             = EmulatorsFilter.NotSet, bool filterOutRunsWithoutVideo = false,
            TimingMethod?orderBy                        = null, DateTime?filterOutRunsAfter = null,
            IEnumerable <VariableValue> variableFilters = null,
            LeaderboardEmbeds embeds                    = default(LeaderboardEmbeds))
        {
            var uri = string.Format("/{0}/category/{1}",
                                    Uri.EscapeDataString(gameId),
                                    Uri.EscapeDataString(categoryId));

            return(getLeaderboard(uri,
                                  top,
                                  platformId, regionId,
                                  emulatorsFilter, filterOutRunsWithoutVideo,
                                  orderBy, filterOutRunsAfter,
                                  variableFilters,
                                  embeds));
        }
Exemplo n.º 7
0
        private Leaderboard getLeaderboard(
            string uri, int?top                         = null,
            string platformId                           = null, string regionId = null,
            EmulatorsFilter emulatorsFilter             = EmulatorsFilter.NotSet, bool filterOutRunsWithoutVideo = false,
            TimingMethod?orderBy                        = null, DateTime?filterOutRunsAfter = null,
            IEnumerable <VariableValue> variableFilters = null,
            LeaderboardEmbeds embeds                    = default(LeaderboardEmbeds))
        {
            var parameters = new List <string>()
            {
                embeds.ToString()
            };

            if (top.HasValue)
            {
                parameters.Add(string.Format("top={0}", top.Value));
            }
            if (!string.IsNullOrEmpty(platformId))
            {
                parameters.Add(string.Format("platform={0}", Uri.EscapeDataString(platformId)));
            }
            if (!string.IsNullOrEmpty(regionId))
            {
                parameters.Add(string.Format("region={0}", Uri.EscapeDataString(regionId)));
            }
            if (emulatorsFilter != EmulatorsFilter.NotSet)
            {
                parameters.Add(string.Format("emulators={0}",
                                             emulatorsFilter == EmulatorsFilter.OnlyEmulators ? "true" : "false"));
            }
            if (filterOutRunsWithoutVideo)
            {
                parameters.Add("video-only=true");
            }
            if (orderBy.HasValue)
            {
                var timing = orderBy.Value.ToAPIString();
                parameters.Add(string.Format("timing={0}", timing));
            }
            if (filterOutRunsAfter.HasValue)
            {
                var date = filterOutRunsAfter.Value.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture);
                parameters.Add(string.Format("date={0}",
                                             Uri.EscapeDataString(date)));
            }
            if (variableFilters != null)
            {
                foreach (var variableValue in variableFilters)
                {
                    if (variableValue != null)
                    {
                        parameters.Add(string.Format("var-{0}={1}",
                                                     Uri.EscapeDataString(variableValue.VariableID),
                                                     Uri.EscapeDataString(variableValue.ID)));
                    }
                }
            }

            var innerUri = GetLeaderboardsUri(string.Format("{0}{1}",
                                                            uri,
                                                            parameters.ToParameters()));

            var result = baseClient.DoRequest(innerUri);

            return(Leaderboard.Parse(baseClient, result.data));
        }