// ---------[ UI FUNCTIONALITY ]---------
        public override void DisplayModfile(Modfile modfile)
        {
            Debug.Assert(modfile != null);

            ModfileDisplayData modfileData = new ModfileDisplayData()
            {
                modfileId       = modfile.id,
                modId           = modfile.modId,
                dateAdded       = modfile.dateAdded,
                fileName        = modfile.fileName,
                fileSize        = modfile.fileSize,
                MD5             = (modfile.fileHash == null ? string.Empty : modfile.fileHash.md5),
                version         = modfile.version,
                changelog       = modfile.changelog,
                metadataBlob    = modfile.metadataBlob,
                virusScanDate   = modfile.dateScanned,
                virusScanStatus = modfile.virusScanStatus,
                virusScanResult = modfile.virusScanResult,
                virusScanHash   = modfile.virusScanHash,
            };

            m_data = modfileData;

            PresentData(modfileData);
        }
Ejemplo n.º 2
0
        private void PresentData(ModfileDisplayData displayData)
        {
            #if UNITY_EDITOR
            if (m_displayMapping == null)
            {
                return;
            }
            #endif

            foreach (var kvp in m_displayMapping)
            {
                kvp.Key.text = kvp.Value(displayData);
            }

            foreach (TextLoadingOverlay loadingOverlay in m_loadingOverlays)
            {
                loadingOverlay.gameObject.SetActive(false);
            }
        }
        public static ModfileDisplayData CreateFromModfile(Modfile modfile)
        {
            UnityEngine.Debug.Assert(modfile != null);

            ModfileDisplayData modfileData = new ModfileDisplayData()
            {
                modId           = modfile.modId,
                modfileId       = modfile.id,
                dateAdded       = modfile.dateAdded,
                fileName        = modfile.fileName,
                fileSize        = modfile.fileSize,
                MD5             = modfile.fileHash.md5,
                version         = modfile.version,
                changelog       = modfile.changelog,
                metadataBlob    = modfile.metadataBlob,
                virusScanDate   = modfile.dateScanned,
                virusScanStatus = modfile.virusScanStatus,
                virusScanResult = modfile.virusScanResult,
                virusScanHash   = modfile.virusScanHash,
            };

            return(modfileData);
        }
        private void PresentData(ModfileDisplayData displayData)
        {
            #if UNITY_EDITOR
            if (!Application.isPlaying && m_displayMapping == null)
            {
                return;
            }
            #endif

            if (this.m_displayMapping == null)
            {
                this.Initialize();
            }

            foreach (var kvp in m_displayMapping)
            {
                kvp.Key.text = kvp.Value(displayData);
            }

            foreach (TextLoadingOverlay loadingOverlay in m_loadingOverlays)
            {
                loadingOverlay.gameObject.SetActive(false);
            }
        }
        private void CollectDelegates()
        {
            m_getDelegates          = new List <GetDataDelegate>();
            m_setDelegates          = new List <SetDataDelegate>();
            m_displayDelegates      = new List <DisplayProfileDelegate>();
            m_missingDisplayParsers = new List <ProfileParserDelegate>();
            m_loadingDelegates      = new List <DisplayLoadingDelegate>();

            // - profile -
            if (profileDisplay != null)
            {
                profileDisplay.Initialize();

                m_getDelegates.Add((ref ModDisplayData d) =>
                {
                    d.profile = profileDisplay.data;
                });
                m_setDelegates.Add((d) =>
                {
                    profileDisplay.data = d.profile;
                });

                m_displayDelegates.Add((p) => profileDisplay.DisplayProfile(p));
                m_loadingDelegates.Add(() => profileDisplay.DisplayLoading());
            }
            else
            {
                m_missingDisplayParsers.Add((ModProfile p, ref ModDisplayData d) =>
                {
                    d.profile = ModProfileDisplayData.CreateFromProfile(p);
                });
            }

            // - media -
            if (mediaContainer != null)
            {
                mediaContainer.Initialize();

                m_getDelegates.Add((ref ModDisplayData d) =>
                {
                    d.logo = mediaContainer.logoData;
                    d.youTubeThumbnails = mediaContainer.youTubeData.ToArray();
                    d.galleryImages     = mediaContainer.galleryData.ToArray();
                });
                m_setDelegates.Add((d) =>
                {
                    mediaContainer.logoData    = d.logo;
                    mediaContainer.youTubeData = d.youTubeThumbnails;
                    mediaContainer.galleryData = d.galleryImages;
                });

                m_displayDelegates.Add((p) => mediaContainer.DisplayMedia(p));
                m_loadingDelegates.Add(() => mediaContainer.DisplayLoading());
            }
            else
            {
                m_missingDisplayParsers.Add(ParseProfileMedia);
            }

            // - logo -
            // NOTE(@jackson): Logo Data overrides Media Container Logo Data
            if (logoDisplay != null)
            {
                logoDisplay.Initialize();

                m_getDelegates.Add((ref ModDisplayData d) =>
                {
                    d.logo = logoDisplay.data;
                });
                m_setDelegates.Add((d) =>
                {
                    logoDisplay.data = d.logo;
                });

                m_displayDelegates.Add((p) => logoDisplay.DisplayLogo(p.id, p.logoLocator));
                m_loadingDelegates.Add(() => logoDisplay.DisplayLoading());
            }
            else
            {
                m_missingDisplayParsers.Add((ModProfile p, ref ModDisplayData d) =>
                {
                    ImageDisplayData logoData;
                    if (p.logoLocator != null)
                    {
                        logoData = ImageDisplayData.CreateForModLogo(p.id, p.logoLocator);
                    }
                    else
                    {
                        logoData = new ImageDisplayData();
                    }

                    d.logo = logoData;
                });
            }

            // - submittor -
            if (submittorDisplay.profile != null)
            {
                submittorDisplay.profile.Initialize();

                m_getDelegates.Add((ref ModDisplayData d) =>
                {
                    d.submittorProfile = submittorDisplay.profile.data;
                });
                m_setDelegates.Add((d) =>
                {
                    submittorDisplay.profile.data = d.submittorProfile;
                });

                m_displayDelegates.Add((p) => submittorDisplay.profile.DisplayProfile(p.submittedBy));
                m_loadingDelegates.Add(() => submittorDisplay.profile.DisplayLoading());
            }
            else
            {
                m_missingDisplayParsers.Add((ModProfile p, ref ModDisplayData d) =>
                {
                    d.submittorProfile = UserProfileDisplayData.CreateFromProfile(p.submittedBy);
                });
            }

            if (submittorDisplay.avatar != null)
            {
                submittorDisplay.avatar.Initialize();

                m_getDelegates.Add((ref ModDisplayData d) =>
                {
                    d.submittorAvatar = submittorDisplay.avatar.data;
                });
                m_setDelegates.Add((d) =>
                {
                    submittorDisplay.avatar.data = d.submittorAvatar;
                });

                m_displayDelegates.Add((p) => submittorDisplay.avatar.DisplayAvatar(p.submittedBy.id,
                                                                                    p.submittedBy.avatarLocator));
                m_loadingDelegates.Add(() => submittorDisplay.avatar.DisplayLoading());
            }
            else
            {
                m_missingDisplayParsers.Add((ModProfile p, ref ModDisplayData d) =>
                {
                    ImageDisplayData avatarData;
                    if (p.submittedBy != null &&
                        p.submittedBy.avatarLocator != null)
                    {
                        avatarData = ImageDisplayData.CreateForUserAvatar(p.submittedBy.id,
                                                                          p.submittedBy.avatarLocator);
                    }
                    else
                    {
                        avatarData = new ImageDisplayData();
                    }

                    d.submittorAvatar = avatarData;
                });
            }

            // - build -
            if (buildDisplay != null)
            {
                buildDisplay.Initialize();

                m_getDelegates.Add((ref ModDisplayData d) =>
                {
                    d.currentBuild = buildDisplay.data;
                });
                m_setDelegates.Add((d) =>
                {
                    buildDisplay.data = d.currentBuild;
                });

                m_displayDelegates.Add((p) => buildDisplay.DisplayModfile(p.currentBuild));
                m_loadingDelegates.Add(() => buildDisplay.DisplayLoading());
            }
            else
            {
                m_missingDisplayParsers.Add((ModProfile p, ref ModDisplayData d) =>
                {
                    d.currentBuild = ModfileDisplayData.CreateFromModfile(p.currentBuild);
                });
            }

            // - tags -
            // NOTE(@jackson): tags has no display/missing parse delegate as it requires categories
            if (tagsDisplay != null)
            {
                tagsDisplay.Initialize();

                m_getDelegates.Add((ref ModDisplayData d) =>
                {
                    d.tags = tagsDisplay.data.ToArray();
                });
                m_setDelegates.Add((d) =>
                {
                    tagsDisplay.data = d.tags;
                });

                m_loadingDelegates.Add(() => tagsDisplay.DisplayLoading());
            }

            // - stats -
            if (statisticsDisplay != null)
            {
                statisticsDisplay.Initialize();

                m_getDelegates.Add((ref ModDisplayData d) =>
                {
                    d.statistics = statisticsDisplay.data;
                });
                m_setDelegates.Add((d) =>
                {
                    statisticsDisplay.data = d.statistics;
                });

                m_loadingDelegates.Add(() => statisticsDisplay.DisplayLoading());
            }

            // - download -
            if (downloadDisplay != null)
            {
                downloadDisplay.Initialize();

                // m_getDelegates.Add((ref ModDisplayData d) =>
                // {
                //     d.submittedBy = creatorView.data;
                // });
                // m_setDelegates.Add((d) =>
                // {
                //     creatorView.data = d.submittedBy;
                // });
            }
        }