Exemple #1
0
        internal void PopulateEditorList(AchievementScriptInterpreter interpreter)
        {
            var editors = new List <ViewerViewModelBase>();

            if (Script != null)
            {
                editors.Add(Script);
            }

            var selectedEditor = (SelectedEditor != null) ? SelectedEditor.Title : null;

            if (interpreter != null)
            {
                GeneratedAchievementCount = interpreter.Achievements.Count();
                editors.Capacity         += GeneratedAchievementCount;

                if (!String.IsNullOrEmpty(interpreter.RichPresence))
                {
                    var richPresenceViewModel = new RichPresenceViewModel(this, interpreter.RichPresence);
                    if (richPresenceViewModel.Lines.Any())
                    {
                        richPresenceViewModel.SourceLine = interpreter.RichPresenceLine;
                        editors.Add(richPresenceViewModel);
                    }
                }

                foreach (var achievement in interpreter.Achievements)
                {
                    var achievementViewModel = new AchievementViewModel(this);
                    achievementViewModel.Generated.Asset = achievement;
                    editors.Add(achievementViewModel);
                }

                foreach (var leaderboard in interpreter.Leaderboards)
                {
                    var leaderboardViewModel = new LeaderboardViewModel(this);
                    leaderboardViewModel.Generated.Asset = leaderboard;
                    editors.Add(leaderboardViewModel);
                }
            }
            else
            {
                GeneratedAchievementCount = 0;
            }

            if (_publishedAchievements.Count > 0 || _publishedLeaderboards.Count > 0)
            {
                MergePublished(editors);
            }

            if (_localAssets != null)
            {
                MergeLocal(editors);
            }

            UpdateTemporaryIds(editors);

            SelectedEditor = editors.FirstOrDefault(e => e.Title == selectedEditor);
            Editors        = editors;
        }
Exemple #2
0
        internal void PopulateEditorList(AchievementScriptInterpreter interpreter)
        {
            var editors = new List <GeneratedItemViewModelBase>();

            if (Script != null)
            {
                editors.Add(Script);
            }

            if (interpreter != null)
            {
                GeneratedAchievementCount = interpreter.Achievements.Count();
                editors.Capacity         += GeneratedAchievementCount;

                if (!String.IsNullOrEmpty(interpreter.RichPresence))
                {
                    var richPresenceViewModel = new RichPresenceViewModel(this, interpreter.RichPresence);
                    if (richPresenceViewModel.Lines.Any())
                    {
                        richPresenceViewModel.SourceLine = interpreter.RichPresenceLine;
                        editors.Add(richPresenceViewModel);
                    }
                }

                foreach (var achievement in interpreter.Achievements)
                {
                    var achievementViewModel = new GeneratedAchievementViewModel(this, achievement);
                    editors.Add(achievementViewModel);
                }

                foreach (var leaderboard in interpreter.Leaderboards)
                {
                    editors.Add(new LeaderboardViewModel(this, leaderboard));
                }
            }
            else
            {
                GeneratedAchievementCount = 0;
            }

            if (!String.IsNullOrEmpty(RACacheDirectory))
            {
                if (_isN64)
                {
                    MergePublishedN64(GameId, editors);
                }
                else
                {
                    MergePublished(GameId, editors);
                }

                MergeLocal(GameId, editors);
            }

            int nextLocalId = 111000001;

            foreach (var achievement in editors.OfType <GeneratedAchievementViewModel>())
            {
                if (achievement.Local != null && achievement.Local.Id >= nextLocalId)
                {
                    nextLocalId = achievement.Local.Id + 1;
                }
            }

            foreach (var achievement in editors.OfType <GeneratedAchievementViewModel>())
            {
                if (achievement.Local != null && achievement.Local.Id == 0)
                {
                    achievement.Local.Id = nextLocalId++;
                }

                achievement.UpdateCommonProperties(this);
            }

            Editors = editors;
        }