Ejemplo n.º 1
0
 public void DisplayMod(ModProfile profile, ModStatistics statistics,
                        IEnumerable <ModTagCategory> tagCategories,
                        bool isModSubscribed, bool isModEnabled)
 {
     Debug.Assert(profile != null);
     this.modId = profile.id;
 }
        public static ModProfileDisplayData CreateFromProfile(ModProfile profile)
        {
            UnityEngine.Debug.Assert(profile != null);

            ModProfileDisplayData profileData = new ModProfileDisplayData()
            {
                modId             = profile.id,
                gameId            = profile.gameId,
                status            = profile.status,
                visibility        = profile.visibility,
                dateAdded         = profile.dateAdded,
                dateUpdated       = profile.dateUpdated,
                dateLive          = profile.dateLive,
                contentWarnings   = profile.contentWarnings,
                homepageURL       = profile.homepageURL,
                name              = profile.name,
                nameId            = profile.nameId,
                summary           = profile.summary,
                descriptionAsHTML = profile.descriptionAsHTML,
                descriptionAsText = profile.descriptionAsText,
                metadataBlob      = profile.metadataBlob,
                profileURL        = profile.profileURL,
                metadataKVPs      = profile.metadataKVPs,
            };

            return(profileData);
        }
Ejemplo n.º 3
0
        /// <summary>Fetches a Mod Profile from the cache if available.</summary>
        public static bool TryGetMod(int gameId, int modId, out ModProfile profile)
        {
            profile = null;

            bool   success     = false;
            string endpointURL = APIClient.BuildGetModEndpointURL(gameId, modId);

            Entry entry;
            int   entryIndex;

            if (LocalUser.OAuthToken == RequestCache.lastOAuthToken &&
                RequestCache.TryGetEntry(endpointURL, out entryIndex, out entry))
            {
                // check if stale
                if ((ServerTimeStamp.Now - entry.timeStamp) >= RequestCache.ENTRY_LIFETIME)
                {
                    // clear it, and any entries older than it
                    RequestCache.RemoveOldestEntries(entryIndex + 1);
                }
                else
                {
                    string modJSON = entry.responseBody;
                    profile = JsonConvert.DeserializeObject <ModProfile>(modJSON);
                    success = true;
                }
            }

            return(success);
        }
 public void UpdateOfClientStepCounter()
 {
     using (NoRightsCheck())
     {
         ModProfile.UpdateOfClientStepCounter(DbObject);
     }
 }
Ejemplo n.º 5
0
        public MainEditorViewModel(ModProfile modToEdit)
        {
            Instance  = this;
            ActiveMod = modToEdit;

            TestCommand = new ActionCommand(TestCommandFunction);
        }
 public void AllowUsageAllRDs()
 {
     using (NoRightsCheck())
     {
         ModProfile.AllowUsageAllRDs(DbObject);
     }
 }
Ejemplo n.º 7
0
        public void Init()
        {
            Profiles = GetAllProfiles();
            var defaultProfile = App.FactorioLoader.Config.DefaultProfile;

            CurrentProfile = Profiles.Find((profile) => profile.Name == defaultProfile);
        }
 /// <exclude/>
 /// <summary>
 /// Nutzt die Hilfsklasse ModProfile zum Füllen der Spalte OsMode mit einem gültigen Wert
 /// </summary>
 /// <param name="osmode"></param>
 private void _Handle_OSMode_ValueChecking(string osmode)
 {
     using (NoRightsCheck())
     {
         ModProfile.CheckAndSetOSMode(DbObject, "OSMode", osmode);
     }
 }
 /// <summary>
 /// Update the Profile in the TreeListView.
 /// </summary>
 /// <param name="p_mctProfile">The Profile to update.</param>
 /// <param name="strOldValue">The previous Profile name.</param>
 public void UpdateData(ModProfile p_mctProfile, string strOldValue)
 {
     if (this.Items.Count > 0)
     {
         SetupContextMenu();
     }
 }
Ejemplo n.º 10
0
        // ---------[ UPDATE VIEW ]---------
        public void DisplayMod(ModProfile profile, ModStatistics statistics,
                               IEnumerable <ModTagCategory> tagCategories,
                               bool isModSubscribed, bool isModEnabled)
        {
            // TODO(@jackson): Remove
            if (profile == null)
            {
                return;
            }

            this.profile         = profile;
            this.statistics      = statistics;
            this.isModSubscribed = isModSubscribed;
            this.isModEnabled    = isModEnabled;

            if (modView != null)
            {
                modView.DisplayMod(profile, statistics,
                                   tagCategories,
                                   isModSubscribed, isModEnabled);

                if (modView.mediaContainer != null)
                {
                    ModMediaCollection media = profile.media;
                    bool hasMedia            = media != null;
                    hasMedia &= ((media.youTubeURLs != null && media.youTubeURLs.Length > 0) ||
                                 (media.galleryImageLocators != null && media.galleryImageLocators.Length > 0));

                    modView.mediaContainer.gameObject.SetActive(hasMedia);
                }
            }

            if (selectedMediaPreview != null)
            {
                selectedMediaPreview.DisplayLogo(profile.id, profile.logoLocator);
            }

            // - version history -
            if (versionHistoryContainer != null &&
                versionHistoryItemPrefab != null)
            {
                foreach (Transform t in versionHistoryContainer)
                {
                    GameObject.Destroy(t.gameObject);
                }

                RequestFilter modfileFilter = new RequestFilter();
                modfileFilter.sortFieldName   = ModIO.API.GetAllModfilesFilterFields.dateAdded;
                modfileFilter.isSortAscending = false;

                APIClient.GetAllModfiles(profile.id,
                                         modfileFilter,
                                         new APIPaginationParameters()
                {
                    limit = 20
                },
                                         (r) => PopulateVersionHistory(profile.id, r.items),
                                         WebRequestError.LogAsWarning);
            }
        }
Ejemplo n.º 11
0
        // ---------[ UI FUNCTIONALITY ]------------
        /// <summary>Displays the profiles in the mod container.</summary>
        protected virtual void DisplayProfiles(IList <ModProfile> profiles)
        {
            Debug.Assert(this.modContainer != null);

            if (profiles == null)
            {
                profiles = new ModProfile[0];
            }

            // init vars
            int displayCount = profiles.Count;

            ModProfile[]    displayProfiles = new ModProfile[displayCount];
            ModStatistics[] displayStats    = new ModStatistics[displayCount];

            // build arrays
            for (int i = 0;
                 i < displayCount;
                 ++i)
            {
                ModProfile    profile = profiles[i];
                ModStatistics stats   = null;
                if (profile != null)
                {
                    stats = profile.statistics;
                }

                displayProfiles[i] = profile;
                displayStats[i]    = stats;
            }

            // display
            this.modContainer.DisplayMods(displayProfiles, displayStats);
        }
Ejemplo n.º 12
0
 public static void AttachModProfile(ModProfile modProfile)
 {
     if (modProfile.ID != CfIdentity.UserID)
     {
         throw new ArgumentException("CfPrincipal InflateModDetails: modProfile.ID != ProfileID");
     }
     System.Web.HttpContext.Current.Items["modProfile"] = modProfile;
 }
        // NOTE(@jackson): This ignores the Logo as it'll be set anyway
        private void ParseProfileMedia(ModProfile profile, ref ModDisplayData data)
        {
            // - early out -
            if (profile.media == null)
            {
                data.galleryImages     = new ImageDisplayData[0];
                data.youTubeThumbnails = new ImageDisplayData[0];
                return;
            }

            // - parse -
            List <ImageDisplayData> media = new List <ImageDisplayData>();

            if (profile.media.galleryImageLocators != null &&
                profile.media.galleryImageLocators.Length > 0)
            {
                foreach (GalleryImageLocator locator in profile.media.galleryImageLocators)
                {
                    ImageDisplayData imageData;
                    if (locator != null)
                    {
                        imageData = ImageDisplayData.CreateForModGalleryImage(profile.id,
                                                                              locator);
                    }
                    else
                    {
                        imageData = new ImageDisplayData();
                    }

                    media.Add(imageData);
                }
            }
            data.galleryImages = media.ToArray();

            media.Clear();
            if (profile.media.youTubeURLs != null &&
                profile.media.youTubeURLs.Length > 0)
            {
                foreach (string url in profile.media.youTubeURLs)
                {
                    ImageDisplayData imageData;
                    if (!string.IsNullOrEmpty(url))
                    {
                        imageData = ImageDisplayData.CreateForYouTubeThumbnail(profile.id,
                                                                               Utility.ExtractYouTubeIdFromURL(url));
                    }
                    else
                    {
                        imageData = new ImageDisplayData();
                    }

                    media.Add(imageData);
                }
            }
            data.youTubeThumbnails = media.ToArray();
        }
Ejemplo n.º 14
0
 public void DisplayMod(ModProfile profile,
                        ModStatistics statistics,
                        IEnumerable <ModTagCategory> tagCategories,
                        bool isSubscribed,
                        bool isModEnabled,
                        ModRatingValue userRating = ModRatingValue.None)
 {
     this.profile    = profile;
     this.statistics = statistics;
 }
Ejemplo n.º 15
0
        // ---------[ UI FUNCTIONALITY ]---------
        /// <summary>Displays the subscribed state of a mod.</summary>
        public void DisplayModRating(ModProfile profile)
        {
            int modId = ModProfile.NULL_ID;
            if(profile != null)
            {
                modId = profile.id;
            }

            this.DisplayModRating(modId);
        }
        // ---------[ UI FUNCTIONALITY ]---------
        public override void DisplayMedia(ModProfile profile)
        {
            Debug.Assert(profile != null);
            Debug.Assert(profile.media != null);

            DisplayMedia(profile.id,
                         profile.logoLocator,
                         profile.media.galleryImageLocators,
                         profile.media.youTubeURLs);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="userID"></param>
        /// <returns></returns>
        public ModProfile GetModProfile(Guid userID)
        {
            var modProfile = modProfileRepo.GetByID(userID);

            if (modProfile == default(ModProfile))
            {
                modProfile = modProfileRepo.Create(ModProfile.InstansiateNewModProfile(userID));
            }

            return(modProfile);
        }
Ejemplo n.º 18
0
        public ModProfile CreateProfile(string name, string desc = "")
        {
            var newProfile = new ModProfile()
            {
                Name        = name,
                Description = desc
            };

            Profiles.Add(newProfile);
            return(newProfile);
        }
Ejemplo n.º 19
0
        // ---------[ UI FUNCTIONALITY ]---------
        /// <summary>Displays the subscribed state of a mod.</summary>
        public void DisplayModSubscribed(ModProfile profile)
        {
            int modId = ModProfile.NULL_ID;

            if (profile != null)
            {
                modId = profile.id;
            }

            this.DisplayModSubscribed(modId);
        }
Ejemplo n.º 20
0
        public void WriteVIIFiles()
        {
            using (NoRightsCheck())
            {
                ModProfile.WriteVIIFiles(DbObject);

                DbObject.Connection.ShowMessage(
                    LanguageManager.Instance["str881_WriteVIIFiles"],
                    LanguageManager.Instance["str881_Information"]);
            }
        }
Ejemplo n.º 21
0
        // ---------[ UI FUNCTIONALITY ]---------
        /// <summary>Displays the tags for a given profile.</summary>
        public void DisplayProfileTags(ModProfile profile)
        {
            IEnumerable <string> tags = null;

            if (profile != null)
            {
                tags = profile.tagNames;
            }

            this.DisplayTags(tags);
        }
        // ---------[ UI FUNCTIONALITY ]---------
        /// <summary>Displays the current build for a ModProfile.</summary>
        public void DisplayCurrentBuild(ModProfile modProfile)
        {
            Modfile modfile = null;

            if (modProfile != null)
            {
                modfile = modProfile.currentBuild;
            }

            this.gameObject.GetComponent <ModfileView>().modfile = modfile;
        }
Ejemplo n.º 23
0
        // ---------[ UI FUNCTIONALITY ]---------
        /// <summary>Requests the release history for a mod.</summary>
        public void RequestReleaseHistory(ModProfile modProfile)
        {
            int modId = ModProfile.NULL_ID;

            if (modProfile != null)
            {
                modId = modProfile.id;
            }

            this.RequestReleaseHistory(modId);
        }
Ejemplo n.º 24
0
        // ---------[ UI FUNCTIONALITY ]---------
        /// <summary>Displays the submittor for a ModProfile.</summary>
        public void DisplayModSubmittor(ModProfile modProfile)
        {
            UserProfile userProfile = null;

            if (modProfile != null)
            {
                userProfile = modProfile.submittedBy;
            }

            this.gameObject.GetComponent <UserView>().profile = userProfile;
        }
Ejemplo n.º 25
0
        // ---------[ UI FUNCTIONALITY ]---------
        /// <summary>Displays the appropriate field of a given profile.</summary>
        public void DisplayProfile(ModProfile profile)
        {
            this.m_profile = profile;

            // display
            object fieldValue    = this.reference.GetValue(this.m_profile);
            string displayString = ValueFormatting.FormatValue(fieldValue,
                                                               this.formatting.method,
                                                               this.formatting.toStringParameter);

            this.m_textComponent.text = displayString;
        }
Ejemplo n.º 26
0
        private static Task WriteViiFilesAsync(ISession session, IEntity entity, CancellationToken ct)
        {
            ISingleDbObject dbObject = entity.CreateSingleDbObject(session);

            ModProfile.WriteVIIFiles(dbObject);

            dbObject.Connection.ShowMessage(
                LanguageManager.Instance["str881_WriteVIIFiles"],
                LanguageManager.Instance["str881_Information"]);

            return(NullTask.Instance);
        }
Ejemplo n.º 27
0
 // ---------[ UTILITY ]---------
 /// <summary>Provides a default sorting function for the subscription view.</summary>
 protected virtual int DefaultSortFunction(ModProfile a, ModProfile b)
 {
     if (a == null)
     {
         return(1);
     }
     if (b == null)
     {
         return(-1);
     }
     return(a.id - b.id);
 }
Ejemplo n.º 28
0
 // ---------[ UI FUNCTIONALITY ]---------
 /// <summary>Displays tags of a profile.</summary>
 public void DisplayProfile(ModProfile profile)
 {
     if (profile == null)
     {
         this.HideAll();
     }
     else
     {
         List <string> tagNames = new List <string>(profile.tagNames);
         this.DisplayTags(tagNames);
     }
 }
Ejemplo n.º 29
0
        // NOTE(@jackson): This ignores the Logo as it'll be set anyway
        private void ParseProfileMedia(ModProfile profile, ref ModDisplayData data)
        {
            // - early out -
            if (profile.media == null)
            {
                data.galleryImages     = new ImageDisplayData[0];
                data.youTubeThumbnails = new ImageDisplayData[0];
                return;
            }

            // - parse -
            List <ImageDisplayData> media = new List <ImageDisplayData>();

            if (profile.media.galleryImageLocators != null &&
                profile.media.galleryImageLocators.Length > 0)
            {
                foreach (GalleryImageLocator locator in profile.media.galleryImageLocators)
                {
                    ImageDisplayData imageData = new ImageDisplayData()
                    {
                        modId            = profile.id,
                        mediaType        = ImageDisplayData.MediaType.ModGalleryImage,
                        fileName         = locator.fileName,
                        originalTexture  = null,
                        thumbnailTexture = null,
                    };

                    media.Add(imageData);
                }
            }
            data.galleryImages = media.ToArray();

            media.Clear();
            if (profile.media.youTubeURLs != null &&
                profile.media.youTubeURLs.Length > 0)
            {
                foreach (string url in profile.media.youTubeURLs)
                {
                    ImageDisplayData imageData = new ImageDisplayData()
                    {
                        modId            = profile.id,
                        mediaType        = ImageDisplayData.MediaType.YouTubeThumbnail,
                        youTubeId        = Utility.ExtractYouTubeIdFromURL(url),
                        originalTexture  = null,
                        thumbnailTexture = null,
                    };

                    media.Add(imageData);
                }
            }
            data.youTubeThumbnails = media.ToArray();
        }
Ejemplo n.º 30
0
        // ---------[ UI FUNCTIONALITY ]---------
        /// <summary>Displays the logo of a profile.</summary>
        public virtual void DisplayProfile(ModProfile profile)
        {
            int modId = ModProfile.NULL_ID;
            LogoImageLocator locator = null;

            if (profile != null)
            {
                modId   = profile.id;
                locator = profile.logoLocator;
            }

            this.DisplayLogo(modId, locator);
        }