コード例 #1
0
 void ToggleUpdateImage(bool isOn)
 {
     if (isOn)
     {
         bpImage.enabled     = false;
         liveBpImage.enabled = true;
     }
     else
     {
         bpImage.enabled     = true;
         liveBpImage.enabled = false;
         ImageDownloader.DownloadImage(worldRecord.imageUrl, 0, obj => bpImage.texture = obj, null);
     }
 }
コード例 #2
0
        public async Task <string> DownloadImage(string path)
        {
            var localPath = "";

            if (path != null)
            {
                localPath = _downloader.LocalPathForFilename(path);
                var token = new CancellationToken();
                if (!File.Exists(localPath))
                {
                    await _downloader.DownloadImage(path, localPath, token);
                }
            }
            return(localPath);
        }
コード例 #3
0
 void ToggleUpdateImage(bool isOn)
 {
     if (isOn)
     {
         bpImage.enabled     = false;
         liveBpImage.enabled = true;
     }
     else
     {
         bpImage.enabled     = true;
         liveBpImage.enabled = false;
         ImageDownloader.DownloadImage(apiAvatar.imageUrl, delegate(Texture2D obj) {
             bpImage.texture = obj;
         });
     }
 }
コード例 #4
0
        public async Task setInfo(MovieInfo i, IApiMovieRequest movieApi, Movie movie)
        {
            ApiQueryResponse <MovieCredit> resp = await movieApi.GetCreditsAsync(i.Id);

            string[] actors = new string[3];
            string   actors_3;

            if (resp.Item.CastMembers.Count == 0)
            {
                actors_3 = "";
            }
            else
            {
                int j = 0;
                int k = 0;
                while ((j < 3) && (k < resp.Item.CastMembers.Count))
                {
                    if (!resp.Item.CastMembers[k].Equals(null))
                    {
                        actors[k] = resp.Item.CastMembers[k].Name;
                        j++;
                    }
                    k++;
                }

                actors_3 = actors[0] + ", " + actors[1] + ", " + actors[2];
            }

            var posterlink = i.PosterPath;

            var localFilePath = imdown.LocalPathForFilename(posterlink);

            if (localFilePath != "")
            {
                await imdown.DownloadImage(posterlink, localFilePath, CancellationToken.None);
            }
            else
            {
                localFilePath = "not_found-full.png";
            }

            movie.Id        = i.Id;
            movie.Title     = i.Title;
            movie.Year      = i.ReleaseDate.Year;
            movie.ImageName = localFilePath;
            movie.Actors    = actors_3;
        }
コード例 #5
0
        public async Task <List <FilmInfo> > downloadPosters(List <FilmInfo> movies)
        {
            foreach (FilmInfo film in movies)
            {
                var posterlink = film.imageName;

                var ImagePath = downloader.LocalPathForFilename(posterlink);

                if (ImagePath != "")
                {
                    await downloader.DownloadImage(posterlink, ImagePath, CancellationToken.None);
                }

                film.imageName = ImagePath;
            }
            return(movies);
        }
コード例 #6
0
        public void Test()
        {
            const string DOWNLOAD_PATH = @"C:\temp\";
            string       fileName      = @"Test-" + Guid.NewGuid();
            const string URL           = @"https://www.atlassian.com//wac/software/jira/tourBlocks/0/screenshotTourSection/0/imageBinary/jiraagile-02_whyja_1_flexibleplanning.png";

            WebClient webClient = new WebClient
            {
                Proxy = new WebProxy("aujcproxy", 80)
                {
                    Credentials = CredentialCache.DefaultCredentials
                }
            };


            ImageDownloader downloader = new ImageDownloader(webClient);

            string downloadLocationPath = downloader.DownloadImage(DOWNLOAD_PATH, fileName, URL);

            Assert.IsTrue(File.Exists(downloadLocationPath));
        }
コード例 #7
0
        private async Task populateInfoHelper(Movies movies, ApiSearchResponse <MovieInfo> res)
        {
            movies.ClearList();

            foreach (var m in res.Results)
            {
                ApiQueryResponse <MovieCredit> movieCreditsResponse = await _movieApi.GetCreditsAsync(m.Id);

                var localFilePath = _imageDl.LocalPathForFilename(m.PosterPath);
                if (localFilePath != string.Empty)
                {
                    if (!File.Exists(localFilePath))
                    {
                        await _imageDl.DownloadImage(m.PosterPath, localFilePath, CancellationToken.None);
                    }
                }

                m.PosterPath = localFilePath;
                movies.ExtractInfo(m, movieCreditsResponse);
            }
            return;
        }
コード例 #8
0
        void SetupUI()
        {
            if (!ValidateAssetBundleBlueprintID(apiAvatar.id))
            {
                blueprintPanel.SetActive(false);
                errorPanel.SetActive(true);
                OnSDKPipelineError("The asset bundle is out of date.  Please rebuild the scene using 'New Build'.", "The blueprint ID in the scene does not match the id in the asset bundle.");
                return;
            }

            if (APIUser.Exists(pipelineManager.user))
            {
                waitingPanel.SetActive(false);
                blueprintPanel.SetActive(true);
                errorPanel.SetActive(false);

                if (isUpdate)
                {
                    // bp update
                    if (apiAvatar.authorId == pipelineManager.user.id)
                    {
                        titleText.text = "Update Avatar";
                        // apiAvatar = pipelineManager.user.GetBlueprint(pipelineManager.blueprintId) as ApiAvatar;
                        blueprintName.text   = apiAvatar.name;
                        contentSex.isOn      = apiAvatar.tags.Contains("content_sex");
                        contentViolence.isOn = apiAvatar.tags.Contains("content_violence");
                        contentGore.isOn     = apiAvatar.tags.Contains("content_gore");
                        contentOther.isOn    = apiAvatar.tags.Contains("content_other");
                        developerAvatar.isOn = apiAvatar.tags.Contains("developer");
                        sharePrivate.isOn    = apiAvatar.releaseStatus.Contains("private");
                        sharePublic.isOn     = apiAvatar.releaseStatus.Contains("public");

                        tagFallback.isOn = apiAvatar.tags.Contains("author_quest_fallback");
                        tagFallback.transform.parent.gameObject.SetActive(true);

                        switch (pipelineManager.fallbackStatus)
                        {
                        case PipelineManager.FallbackStatus.Valid:
#if UNITY_ANDROID
                            tagFallback.interactable = true;
                            tagFallback.GetComponentInChildren <Text>().text = "Use for Fallback";
#else
                            tagFallback.interactable = false;
                            tagFallback.GetComponentInChildren <Text>().text = "Use for Fallback (change only with Android upload)";
#endif
                            break;

                        case PipelineManager.FallbackStatus.InvalidPerformance:
                        case PipelineManager.FallbackStatus.InvalidRig:
                            tagFallback.isOn         = false; // need to remove tag on this upload, the updated version is not up-to-spec
                            tagFallback.interactable = false;
                            tagFallback.GetComponentInChildren <Text>().text = "Use for Fallback (avatar not valid, tag will be cleared)";
                            break;
                        }

                        blueprintDescription.text            = apiAvatar.description;
                        shouldUpdateImageToggle.interactable = true;
                        shouldUpdateImageToggle.isOn         = false;
                        liveBpImage.enabled = false;
                        bpImage.enabled     = true;

                        ImageDownloader.DownloadImage(apiAvatar.imageUrl, 0, (Texture2D obj) => bpImage.texture = obj, null);
                    }
                    else // user does not own apiAvatar id associated with descriptor
                    {
                        Debug.LogErrorFormat("{0} is not an owner of {1}", apiAvatar.authorId, pipelineManager.user.id);
                        blueprintPanel.SetActive(false);
                        errorPanel.SetActive(true);
                    }
                }
                else
                {
                    titleText.text = "New Avatar";
                    shouldUpdateImageToggle.interactable = false;
                    shouldUpdateImageToggle.isOn         = true;
                    liveBpImage.enabled = true;
                    bpImage.enabled     = false;
                    tagFallback.isOn    = false;

                    // Janky fix for an avatar's blueprint image not showing up the very first time you press publish in a project until you resize the window
                    // can remove if we fix the underlying issue or move publishing out of Play Mode
                    string firstTimeResize = $"{Application.identifier}-firstTimeResize";
                    if (!PlayerPrefs.HasKey(firstTimeResize))
                    {
                        GameViewMethods.ResizeGameView();
                        PlayerPrefs.SetInt(firstTimeResize, 1);
                    }

                    tagFallback.transform.parent.gameObject.SetActive(true);
                    switch (pipelineManager.fallbackStatus)
                    {
                    case PipelineManager.FallbackStatus.Valid:
#if UNITY_ANDROID
                        tagFallback.interactable = true;
                        tagFallback.GetComponentInChildren <Text>().text = "Use for Fallback";
#else
                        tagFallback.interactable = false;
                        tagFallback.GetComponentInChildren <Text>().text = "Use for Fallback (change only with Android upload)";
#endif
                        break;

                    case PipelineManager.FallbackStatus.InvalidPerformance:
                    case PipelineManager.FallbackStatus.InvalidRig:
                        tagFallback.transform.parent.gameObject.SetActive(true);
                        tagFallback.interactable = false;
                        tagFallback.GetComponentInChildren <Text>().text = "Use for Fallback (avatar not valid, tag will be cleared)";
                        break;
                    }
                }
            }
            else
            {
                waitingPanel.SetActive(true);
                blueprintPanel.SetActive(false);
                errorPanel.SetActive(false);
            }

            if (APIUser.CurrentUser != null && APIUser.CurrentUser.hasSuperPowers)
            {
                developerAvatar.gameObject.SetActive(true);
            }
            else
            {
                developerAvatar.gameObject.SetActive(false);
            }
        }
コード例 #9
0
        void SetupUI()
        {
            if (!ValidateAssetBundleBlueprintID(apiAvatar.id))
            {
                blueprintPanel.SetActive(false);
                errorPanel.SetActive(true);
                OnSDKPipelineError("The asset bundle is out of date.  Please rebuild the scene using 'New Build'.", "The blueprint ID in the scene does not match the id in the asset bundle.");
                return;
            }

            if (APIUser.Exists(pipelineManager.user))
            {
                waitingPanel.SetActive(false);
                blueprintPanel.SetActive(true);
                errorPanel.SetActive(false);

                if (isUpdate)
                {
                    // bp update
                    if (apiAvatar.authorId == pipelineManager.user.id)
                    {
                        titleText.text = "Update Avatar";
                        // apiAvatar = pipelineManager.user.GetBlueprint(pipelineManager.blueprintId) as ApiAvatar;
                        blueprintName.text                   = apiAvatar.name;
                        contentSex.isOn                      = apiAvatar.tags.Contains("content_sex");
                        contentViolence.isOn                 = apiAvatar.tags.Contains("content_violence");
                        contentGore.isOn                     = apiAvatar.tags.Contains("content_gore");
                        contentOther.isOn                    = apiAvatar.tags.Contains("content_other");
                        developerAvatar.isOn                 = apiAvatar.tags.Contains("developer");
                        sharePrivate.isOn                    = apiAvatar.releaseStatus.Contains("private");
                        sharePublic.isOn                     = apiAvatar.releaseStatus.Contains("public");
                        blueprintDescription.text            = apiAvatar.description;
                        shouldUpdateImageToggle.interactable = true;
                        shouldUpdateImageToggle.isOn         = false;
                        liveBpImage.enabled                  = false;
                        bpImage.enabled                      = true;

                        ImageDownloader.DownloadImage(apiAvatar.imageUrl, delegate(Texture2D obj) {
                            bpImage.texture = obj;
                        });
                    }
                    else // user does not own apiAvatar id associated with descriptor
                    {
                        Debug.LogErrorFormat("{0} is not an owner of {1}", apiAvatar.authorId, pipelineManager.user.id);
                        blueprintPanel.SetActive(false);
                        errorPanel.SetActive(true);
                    }
                }
                else
                {
                    titleText.text = "New Avatar";
                    shouldUpdateImageToggle.interactable = false;
                    shouldUpdateImageToggle.isOn         = true;
                    liveBpImage.enabled = true;
                    bpImage.enabled     = false;
                }
            }
            else
            {
                waitingPanel.SetActive(true);
                blueprintPanel.SetActive(false);
                errorPanel.SetActive(false);
            }

            if (APIUser.CurrentUser != null && APIUser.CurrentUser.hasSuperPowers)
            {
                developerAvatar.gameObject.SetActive(true);
            }
            else
            {
                developerAvatar.gameObject.SetActive(false);
            }
        }
コード例 #10
0
        void SetupUI()
        {
            if (!ValidateAssetBundleBlueprintID(worldRecord.id))
            {
                blueprintPanel.SetActive(false);
                errorPanel.SetActive(true);
                OnSDKPipelineError("The asset bundle is out of date.  Please rebuild the scene using 'New Build'.", "The blueprint ID in the scene does not match the id in the asset bundle.");
                return;
            }

            contentFeatured.gameObject.SetActive(APIUser.CurrentUser.hasSuperPowers);
            contentSDKExample.gameObject.SetActive(APIUser.CurrentUser.hasSuperPowers);

            if (APIUser.Exists(pipelineManager.user))
            {
                waitingPanel.SetActive(false);
                blueprintPanel.SetActive(true);
                errorPanel.SetActive(false);

                if (string.IsNullOrEmpty(worldRecord.authorId) || worldRecord.authorId == pipelineManager.user.id)
                {
                    titleText.text       = "Configure World";
                    blueprintName.text   = worldRecord.name;
                    worldCapacity.text   = worldRecord.capacity.ToString();
                    contentSex.isOn      = worldRecord.tags.Contains("content_sex");
                    contentViolence.isOn = worldRecord.tags.Contains("content_violence");
                    contentGore.isOn     = worldRecord.tags.Contains("content_gore");
                    contentOther.isOn    = worldRecord.tags.Contains("content_other");
                    shouldUpdateImageToggle.interactable = isUpdate;
                    shouldUpdateImageToggle.isOn         = !isUpdate;
                    liveBpImage.enabled = !isUpdate;
                    bpImage.enabled     = isUpdate;

                    if (!APIUser.CurrentUser.hasSuperPowers)
                    {
                        releasePublic.gameObject.SetActive(false);
                        releasePublic.isOn         = false;
                        releasePublic.interactable = false;

                        contentFeatured.isOn = contentSDKExample.isOn = false;
                    }
                    else
                    {
                        contentFeatured.isOn   = worldRecord.tags.Contains("content_featured");
                        contentSDKExample.isOn = worldRecord.tags.Contains("content_sdk_example");
                        releasePublic.isOn     = worldRecord.releaseStatus == "public";
                        releasePublic.gameObject.SetActive(true);
                    }

                    // "show in worlds menu"
                    if (APIUser.CurrentUser.hasSuperPowers)
                    {
                        showInWorldsMenuGroup.gameObject.SetActive(true);
                        showInActiveWorlds.isOn  = !worldRecord.tags.Contains("admin_hide_active");
                        showInPopularWorlds.isOn = !worldRecord.tags.Contains("admin_hide_popular");
                        showInNewWorlds.isOn     = !worldRecord.tags.Contains("admin_hide_new");
                    }
                    else
                    {
                        showInWorldsMenuGroup.gameObject.SetActive(false);
                    }

                    blueprintDescription.text = worldRecord.description;

                    userTags.text = "";
                    foreach (var tag in worldRecord.publicTags)
                    {
                        userTags.text = userTags.text + tag.Replace("author_tag_", "");
                        userTags.text = userTags.text + " ";
                    }

                    ImageDownloader.DownloadImage(worldRecord.imageUrl, delegate(Texture2D obj) {
                        bpImage.texture = obj;
                    });
                }
                else // user does not own world id associated with descriptor
                {
                    Debug.LogErrorFormat("{0} is not an owner of {1}", worldRecord.authorId, pipelineManager.user.id);
                    blueprintPanel.SetActive(false);
                    errorPanel.SetActive(true);
                }
            }
            else
            {
                waitingPanel.SetActive(true);
                blueprintPanel.SetActive(false);
                errorPanel.SetActive(false);

                if (!APIUser.CurrentUser.hasSuperPowers)
                {
                    releasePublic.gameObject.SetActive(false);
                    releasePublic.isOn         = false;
                    releasePublic.interactable = false;
                }
                else
                {
                    releasePublic.gameObject.SetActive(true);
                    releasePublic.isOn = false;
                }
            }
        }
コード例 #11
0
        void SetupUI()
        {
            if (APIUser.Exists(pipelineManager.user))
            {
                waitingPanel.SetActive(false);
                blueprintPanel.SetActive(true);
                errorPanel.SetActive(false);

                if (isUpdate)
                {
                    // bp update
                    if (apiAvatar.authorId == pipelineManager.user.id)
                    {
                        titleText.text = "Update Avatar";
                        // apiAvatar = pipelineManager.user.GetBlueprint(pipelineManager.blueprintId) as ApiAvatar;
                        blueprintName.text                   = apiAvatar.name;
                        contentSex.isOn                      = apiAvatar.tags.Contains("content_sex");
                        contentViolence.isOn                 = apiAvatar.tags.Contains("content_violence");
                        contentGore.isOn                     = apiAvatar.tags.Contains("content_gore");
                        contentOther.isOn                    = apiAvatar.tags.Contains("content_other");
                        developerAvatar.isOn                 = apiAvatar.tags.Contains("developer");
                        sharePrivate.isOn                    = apiAvatar.releaseStatus.Contains("private");
                        sharePublic.isOn                     = apiAvatar.releaseStatus.Contains("public");
                        blueprintDescription.text            = apiAvatar.description;
                        shouldUpdateImageToggle.interactable = true;
                        shouldUpdateImageToggle.isOn         = false;
                        liveBpImage.enabled                  = false;
                        bpImage.enabled                      = true;

                        ImageDownloader.DownloadImage(apiAvatar.imageUrl, delegate(Texture2D obj) {
                            bpImage.texture = obj;
                        });
                    }
                    else // user does not own apiAvatar id associated with descriptor
                    {
                        blueprintPanel.SetActive(false);
                        errorPanel.SetActive(true);
                    }
                }
                else
                {
                    titleText.text = "New Avatar";
                    shouldUpdateImageToggle.interactable = false;
                    shouldUpdateImageToggle.isOn         = true;
                    liveBpImage.enabled = true;
                    bpImage.enabled     = false;
                }
            }
            else
            {
                waitingPanel.SetActive(true);
                blueprintPanel.SetActive(false);
                errorPanel.SetActive(false);
            }

            if (APIUser.CurrentUser != null && APIUser.CurrentUser.developerType > APIUser.DeveloperType.None)
            {
                developerAvatar.gameObject.SetActive(true);
            }
            else
            {
                developerAvatar.gameObject.SetActive(false);
            }
        }
コード例 #12
0
        private static void RunRequest(string url)
        {
            if (!QueuedRequests.TryGetValue(url, out var list))
            {
                return;
            }

            QueuedRequests.Remove(url);

            if (list.Count == 0)
            {
                return;
            }

            InFlightRequests[url] = list;

            var trueUri = url;

            if (FavCatMod.Database.ImageHandler.Exists(trueUri))
            {
                FavCatMod.Database.ImageHandler.LoadImageAsync(trueUri, tex =>
                {
                    if (!Textures.TryGetValue(url, out var oldTex) || !oldTex)
                    {
                        Textures[url] = tex;
                    }

                    if (!InFlightRequests.TryGetValue(url, out var list))
                    {
                        return;
                    }

                    InFlightRequests.Remove(url);

                    foreach (var action in list)
                    {
                        action(tex);
                    }
                }).NoAwait();
                return;
            }

            ourNextAllowedUpdate = Time.time + RequestDelay;

            MelonLogger.Log($"Performing image request to {url}");
            ImageDownloader.DownloadImage(url, 256, new Action <Texture2D>(tex =>
            {
                if (!Textures.TryGetValue(url, out var oldTex) || !oldTex)
                {
                    Textures[url] = tex;
                    if (FavCatSettings.CacheImagesInMemory)
                    {
                        tex.hideFlags |= HideFlags.DontUnloadUnusedAsset;
                    }
                }

                if (!InFlightRequests.TryGetValue(url, out var list))
                {
                    return;
                }

                InFlightRequests.Remove(url);

                foreach (var action in list)
                {
                    action(tex);
                }
            }), new Action(() =>
            {
                if (!Textures.TryGetValue(url, out var oldTex) || !oldTex)
                {
                    Textures[url] = AssetsHandler.PreviewError.texture;
                }

                if (!InFlightRequests.TryGetValue(url, out var list))
                {
                    return;
                }

                InFlightRequests.Remove(url);

                foreach (var action in list)
                {
                    action(AssetsHandler.PreviewError.texture);
                }
            }));
        }
コード例 #13
0
        void SetupUI(bool hasEnoughTrustToPublishToCL = false, bool hasExceededWeeklyPublishLimit = false)
        {
#if COMMUNITY_LABS_SDK
            // do not display community labs panel if updating an existing CL world or updating a public world
            publishToCommunityLabsPanel.gameObject.SetActive(!IsCurrentWorldUploaded);
#endif

            if (!ValidateAssetBundleBlueprintID(worldRecord.id))
            {
                blueprintPanel.SetActive(false);
                errorPanel.SetActive(true);
                OnSDKPipelineError("The asset bundle is out of date.  Please rebuild the scene using 'New Build'.", "The blueprint ID in the scene does not match the id in the asset bundle.");
                return;
            }

            contentFeatured.gameObject.SetActive(APIUser.CurrentUser.hasSuperPowers);
            contentSDKExample.gameObject.SetActive(APIUser.CurrentUser.hasSuperPowers);

            if (APIUser.Exists(pipelineManager.user))
            {
                waitingPanel.SetActive(false);
                blueprintPanel.SetActive(true);
                errorPanel.SetActive(false);

                if (string.IsNullOrEmpty(worldRecord.authorId) || worldRecord.authorId == pipelineManager.user.id)
                {
                    titleText.text = "Configure World";
                    blueprintName.text = worldRecord.name;
                    worldCapacity.text = worldRecord.capacity.ToString();
                    contentSex.isOn = worldRecord.tags.Contains("content_sex");
                    contentViolence.isOn = worldRecord.tags.Contains("content_violence");
                    contentGore.isOn = worldRecord.tags.Contains("content_gore");
                    contentOther.isOn = worldRecord.tags.Contains("content_other");
                    shouldUpdateImageToggle.interactable = isUpdate;
                    shouldUpdateImageToggle.isOn = !isUpdate;
                    liveBpImage.enabled = !isUpdate;
                    bpImage.enabled = isUpdate;

                    if (!APIUser.CurrentUser.hasSuperPowers)
                    {
                        releasePublic.gameObject.SetActive(false);
                        releasePublic.isOn = false;
                        releasePublic.interactable = false;

                        contentFeatured.isOn = contentSDKExample.isOn = false;
                    }
                    else
                    {
                        contentFeatured.isOn = worldRecord.tags.Contains("content_featured");
                        contentSDKExample.isOn = worldRecord.tags.Contains("content_sdk_example");

                        releasePublic.isOn = worldRecord.releaseStatus == "public";
                        releasePublic.gameObject.SetActive(true);
                    }

                    // "show in worlds menu"
                    if (APIUser.CurrentUser.hasSuperPowers)
                    {
                        showInWorldsMenuGroup.gameObject.SetActive(true);
                        showInActiveWorlds.isOn = !worldRecord.tags.Contains("admin_hide_active");
                        showInPopularWorlds.isOn = !worldRecord.tags.Contains("admin_hide_popular");
                        showInNewWorlds.isOn = !worldRecord.tags.Contains("admin_hide_new");
                    }
                    else
                    {
                        showInWorldsMenuGroup.gameObject.SetActive(false);
                    }

                    blueprintDescription.text = worldRecord.description;

                    userTags.text = "";
                    foreach (var tag in worldRecord.publicTags)
                    {
                        userTags.text = userTags.text + tag.Replace("author_tag_", "");
                        userTags.text = userTags.text + " ";
                    }

                    ImageDownloader.DownloadImage(worldRecord.imageUrl, 0, delegate (Texture2D obj) {
                        bpImage.texture = obj;
                    });
                }
                else // user does not own world id associated with descriptor
                {
                    Debug.LogErrorFormat("{0} is not an owner of {1}", worldRecord.authorId, pipelineManager.user.id);
                    blueprintPanel.SetActive(false);
                    errorPanel.SetActive(true);
                }
            }
            else
            {
                waitingPanel.SetActive(true);
                blueprintPanel.SetActive(false);
                errorPanel.SetActive(false);

                if (!APIUser.CurrentUser.hasSuperPowers)
                {
                    releasePublic.gameObject.SetActive(false);
                    releasePublic.isOn = false;
                    releasePublic.interactable = false;
                }
                else
                {
                    releasePublic.gameObject.SetActive(true);
                    releasePublic.isOn = false;
                }
            }

            // set up publish to Community Labs checkbox and text
            int worldsPublishedThisWeek = hasExceededWeeklyPublishLimit ? 1 : 0;
            int maximumWorldsAllowedToPublishPerWeek = 1;
            publishToCommLabsToggle = publishToCommunityLabsPanel.GetComponentInChildren<Toggle>();

            if (null != publishToCommLabsToggle)
            {
                // disable publishing to CL checkbox if not enough trust or exceeded publish limit 
                publishToCommLabsToggle.interactable = hasEnoughTrustToPublishToCL && !hasExceededWeeklyPublishLimit;

                Text publishText = publishToCommLabsToggle.gameObject.GetComponentInChildren<Text>();
                if (null != publishText)
                {
                    if (!hasEnoughTrustToPublishToCL)
                    {
                        publishText.text = "Not enough Trust to Publish to Community Labs";
                    }
                    else
                    {
                        if (hasExceededWeeklyPublishLimit)
                        {
                            publishText.text = "Publish limit for Community Labs Exceeded\n" + "(" + worldsPublishedThisWeek + "/" + maximumWorldsAllowedToPublishPerWeek + " Published this week)";
                        }
                        else
                        {
                            publishText.text = "Publish to Community Labs\n" + "(" + worldsPublishedThisWeek + "/" + maximumWorldsAllowedToPublishPerWeek + " Published this week)";
                        }
                    }
                }
            }
        }
コード例 #14
0
        public void Save(string Directory)
        {
            if (!String.IsNullOrEmpty(this.ClearArtUrl))
            {
                ImageDownloader.DownloadImage(
                    this.ClearArtUrl,
                    Path.Combine(Directory, "clearart.png"),
                    System.Drawing.Imaging.ImageFormat.Png
                    );
            }
            if (!String.IsNullOrEmpty(this.ClearLogoUrl))
            {
                ImageDownloader.DownloadImage(
                    this.ClearLogoUrl,
                    Path.Combine(Directory, "logo.png"),
                    System.Drawing.Imaging.ImageFormat.Png
                    );
            }
            if (!String.IsNullOrEmpty(this.BannerUrl))
            {
                ImageDownloader.SaveBanner(this.BannerUrl, Path.Combine(Directory, "banner.jpg"));
                if (Settings.UseBannersForTvFolders)
                {
                    if (File.Exists(Path.Combine(Directory, "folder.jpg")))
                    {
                        File.Delete(Path.Combine(Directory, "folder.jpg"));
                    }
                    File.Copy(Path.Combine(Directory, "banner.jpg"), Path.Combine(Directory, "folder.jpg"));
                }
            }
            if (!String.IsNullOrEmpty(this.PosterUrl))
            {
                ImageDownloader.SaveFanArt(this.PosterUrl, Path.Combine(Directory, "poster.jpg"));
                if (!Settings.UseBannersForTvFolders)
                {
                    if (File.Exists(Path.Combine(Directory, "folder.jpg")))
                    {
                        File.Delete(Path.Combine(Directory, "folder.jpg"));
                    }
                    File.Copy(Path.Combine(Directory, "poster.jpg"), Path.Combine(Directory, "folder.jpg"));
                }
            }
            if (!String.IsNullOrEmpty(this.FanArtUrl))
            {
                ImageDownloader.SaveFanArt(this.FanArtUrl, Path.Combine(Directory, "fanart.jpg"));
                if (File.Exists(Path.Combine(Directory, "backdrop.jpg")))
                {
                    File.Delete(Path.Combine(Directory, "backdrop.jpg"));
                }
                File.Copy(Path.Combine(Directory, "fanart.jpg"), Path.Combine(Directory, "backdrop.jpg"));
            }
            if (SeasonPosters != null)
            {
                foreach (int season in SeasonPosters.Keys)
                {
                    ImageDownloader.SavePoster(SeasonPosters[season], Path.Combine(Directory, String.Format("season{0}.tbn", season == -1 ? "-all" : season.ToString("D2"))));
                }
            }
            if (!String.IsNullOrEmpty(this.TvTuneUrl))
            {
                WebHelper.DownloadTo(this.TvTuneUrl, Path.Combine(Directory, "theme.mp3"));
            }

            // do this last, since if this file is found, the whole process is skipped, so if the user aborts mid way through, the restarts the tvshow.nfo will only be there if everything was saved
            CreateNfoFile(Path.Combine(Directory, "tvshow.nfo"));
        }
コード例 #15
0
        private async void AddTopRated()
        {
            ApiSearchResponse <MovieInfo> responeTopRated = await movieApi.GetTopRatedAsync();

            var topRated = responeTopRated.Results;

            for (int i = 0; i < topRated.Count; i++)
            {
                ApiQueryResponse <MovieCredit> responeTopRatedCast = await movieApi.GetCreditsAsync(topRated[i].Id);

                ApiQueryResponse <Movie> responeTopRatedGenre = await movieApi.FindByIdAsync(topRated[i].Id);

                var topRatedGenres     = responeTopRatedGenre.Item;
                var topRatedGenresList = topRatedGenres.Genres;

                var topRatedCast     = responeTopRatedCast.Item;
                var topRatedCastList = topRatedCast.CastMembers;

                var localTop = imageDownloader.LocalPathForFilename(topRated[i].PosterPath);

                if (localTop.Length <= 0)
                {
                    //catch empty local path
                }
                else
                {
                    await
                    imageDownloader.DownloadImage(topRated[i].PosterPath, imageDownloader.LocalPathForFilename(topRated[i].PosterPath),
                                                  CancellationToken.None);
                }


                if (topRatedCastList.Count < 3)
                {
                    this.moviesObjects.AddToMoviesModelList(new MoviesModel(topRated[i].Title, "(" + topRated[i].ReleaseDate.Year.ToString() + ")",
                                                                            string.Empty, imageDownloader.LocalPathForFilename(topRated[i].PosterPath),
                                                                            topRatedGenres.Runtime + " min", topRated[i].Overview));
                }
                else
                {
                    if (topRatedGenresList.Count < 1)
                    {
                        this.moviesObjects.AddToMoviesModelList(new MoviesModel(topRated[i].Title, "(" + topRated[i].ReleaseDate.Year.ToString() + ")",
                                                                                topRatedCastList[0].Name + ", " + topRatedCastList[1].Name + ", " + topRatedCastList[2].Name, imageDownloader.LocalPathForFilename(topRated[i].PosterPath),
                                                                                topRatedGenres.Runtime + " min", topRated[i].Overview));
                    }
                    else if (topRatedGenresList.Count == 1)
                    {
                        this.moviesObjects.AddToMoviesModelList(new MoviesModel(topRated[i].Title, "(" + topRated[i].ReleaseDate.Year.ToString() + ")",
                                                                                topRatedCastList[0].Name + ", " + topRatedCastList[1].Name + ", " + topRatedCastList[2].Name, imageDownloader.LocalPathForFilename(topRated[i].PosterPath),
                                                                                topRatedGenres.Runtime + " min" + " I " + topRatedGenresList[0].Name, topRated[i].Overview));
                    }
                    else if (topRatedGenresList.Count == 2)
                    {
                        this.moviesObjects.AddToMoviesModelList(new MoviesModel(topRated[i].Title, "(" + topRated[i].ReleaseDate.Year.ToString() + ")",
                                                                                topRatedCastList[0].Name + ", " + topRatedCastList[1].Name + ", " + topRatedCastList[2].Name, imageDownloader.LocalPathForFilename(topRated[i].PosterPath),
                                                                                topRatedGenres.Runtime + " min" + " I " + topRatedGenresList[0].Name + ", " + topRatedGenresList[1].Name, topRated[i].Overview));
                    }
                    else
                    {
                        this.moviesObjects.AddToMoviesModelList(new MoviesModel(topRated[i].Title, "(" + topRated[i].ReleaseDate.Year.ToString() + ")",
                                                                                topRatedCastList[0].Name + ", " + topRatedCastList[1].Name + ", " + topRatedCastList[2].Name, imageDownloader.LocalPathForFilename(topRated[i].PosterPath),
                                                                                topRatedGenres.Runtime + " min" + " I " + topRatedGenresList[0].Name + ", " + topRatedGenresList[1].Name + ", " + topRatedGenresList[2].Name, topRated[i].Overview));
                    }
                }
            }
        }
コード例 #16
0
        void SetupUI()
        {
            if (APIUser.CurrentUser.developerType < APIUser.DeveloperType.Trusted)
            {
                contentFeatured.gameObject.SetActive(false);
                contentSDKExample.gameObject.SetActive(false);
            }
            else
            {
                contentFeatured.gameObject.SetActive(true);
                contentSDKExample.gameObject.SetActive(true);
            }

            if (APIUser.Exists(pipelineManager.user) && pipelineManager.user.isFresh)
            {
                waitingPanel.SetActive(false);
                blueprintPanel.SetActive(true);
                errorPanel.SetActive(false);

                if (isUpdate)
                {
                    // bp update
                    if (worldRecord.authorId == pipelineManager.user.id)
                    {
                        titleText.text       = "Update World";
                        blueprintName.text   = worldRecord.name;
                        worldCapacity.text   = worldRecord.capacity.ToString();
                        contentSex.isOn      = worldRecord.tags.Contains("content_sex");
                        contentViolence.isOn = worldRecord.tags.Contains("content_violence");
                        contentGore.isOn     = worldRecord.tags.Contains("content_gore");
                        contentOther.isOn    = worldRecord.tags.Contains("content_other");

                        if (APIUser.CurrentUser.developerType < APIUser.DeveloperType.Trusted)
                        {
                            releasePublic.isOn         = false;
                            releasePublic.interactable = false;

                            contentFeatured.isOn = contentSDKExample.isOn = false;
                        }
                        else
                        {
                            contentFeatured.isOn   = worldRecord.tags.Contains("content_featured");
                            contentSDKExample.isOn = worldRecord.tags.Contains("content_sdk_example");
                            releasePublic.isOn     = worldRecord.releaseStatus == "public";
                        }
                        blueprintDescription.text            = worldRecord.description;
                        shouldUpdateImageToggle.interactable = true;
                        shouldUpdateImageToggle.isOn         = false;
                        liveBpImage.enabled = false;
                        bpImage.enabled     = true;

                        ImageDownloader.DownloadImage(worldRecord.imageUrl, delegate(Texture2D obj) {
                            bpImage.texture = obj;
                        });
                    }
                    else // user does not own world id associated with descriptor
                    {
                        blueprintPanel.SetActive(false);
                        errorPanel.SetActive(true);
                    }
                }
                else
                {
                    titleText.text = "New World";
                    shouldUpdateImageToggle.interactable = false;
                    shouldUpdateImageToggle.isOn         = true;
                    liveBpImage.enabled = true;
                    bpImage.enabled     = false;
                }
            }
            else
            {
                waitingPanel.SetActive(true);
                blueprintPanel.SetActive(false);
                errorPanel.SetActive(false);

                if (APIUser.CurrentUser.developerType < APIUser.DeveloperType.Trusted)
                {
                    releasePublic.isOn         = false;
                    releasePublic.interactable = false;
                }
                else
                {
                    releasePublic.isOn = false;
                }
            }
        }
コード例 #17
0
        void SetupUI()
        {
            if (!ValidateAssetBundleBlueprintID(apiAvatar.id))
            {
                blueprintPanel.SetActive(false);
                errorPanel.SetActive(true);
                OnSDKPipelineError("The asset bundle is out of date.  Please rebuild the scene using 'New Build'.", "The blueprint ID in the scene does not match the id in the asset bundle.");
                return;
            }

            if (APIUser.Exists(pipelineManager.user))
            {
                waitingPanel.SetActive(false);
                blueprintPanel.SetActive(true);
                errorPanel.SetActive(false);

                if (isUpdate)
                {
                    // bp update
                    if (apiAvatar.authorId == pipelineManager.user.id)
                    {
                        titleText.text = "Update Avatar";
                        // apiAvatar = pipelineManager.user.GetBlueprint(pipelineManager.blueprintId) as ApiAvatar;
                        blueprintName.text   = apiAvatar.name;
                        contentSex.isOn      = apiAvatar.tags.Contains("content_sex");
                        contentViolence.isOn = apiAvatar.tags.Contains("content_violence");
                        contentGore.isOn     = apiAvatar.tags.Contains("content_gore");
                        contentOther.isOn    = apiAvatar.tags.Contains("content_other");
                        developerAvatar.isOn = apiAvatar.tags.Contains("developer");
                        sharePrivate.isOn    = apiAvatar.releaseStatus.Contains("private");
                        sharePublic.isOn     = apiAvatar.releaseStatus.Contains("public");

                        tagFallback.isOn = apiAvatar.tags.Contains("author_quest_fallback");
                        switch (pipelineManager.fallbackStatus)
                        {
                        case PipelineManager.FallbackStatus.Valid:
                            tagFallback.transform.parent.gameObject.SetActive(true);
                            tagFallback.interactable = true;
                            tagFallback.GetComponentInChildren <Text>().text = "Use for Fallback";
                            break;

                        case PipelineManager.FallbackStatus.InvalidPerformance:
                        case PipelineManager.FallbackStatus.InvalidRig:
                            tagFallback.transform.parent.gameObject.SetActive(true);
                            tagFallback.isOn         = false; // need to remove tag on this upload, the updated version is not up-to-spec
                            tagFallback.interactable = false;
                            tagFallback.GetComponentInChildren <Text>().text = "(Not valid for Fallback use)";
                            break;

                        default:
                            tagFallback.transform.parent.gameObject.SetActive(false);
                            break;
                        }

                        blueprintDescription.text            = apiAvatar.description;
                        shouldUpdateImageToggle.interactable = true;
                        shouldUpdateImageToggle.isOn         = false;
                        liveBpImage.enabled = false;
                        bpImage.enabled     = true;

                        ImageDownloader.DownloadImage(apiAvatar.imageUrl, 0, (Texture2D obj) => bpImage.texture = obj, null);
                    }
                    else // user does not own apiAvatar id associated with descriptor
                    {
                        Debug.LogErrorFormat("{0} is not an owner of {1}", apiAvatar.authorId, pipelineManager.user.id);
                        blueprintPanel.SetActive(false);
                        errorPanel.SetActive(true);
                    }
                }
                else
                {
                    titleText.text = "New Avatar";
                    shouldUpdateImageToggle.interactable = false;
                    shouldUpdateImageToggle.isOn         = true;
                    liveBpImage.enabled = true;
                    bpImage.enabled     = false;
                    tagFallback.isOn    = false;

                    switch (pipelineManager.fallbackStatus)
                    {
                    case PipelineManager.FallbackStatus.Valid:
                        tagFallback.transform.parent.gameObject.SetActive(true);
                        tagFallback.interactable = true;
                        tagFallback.GetComponentInChildren <Text>().text = "Use for Fallback";
                        break;

                    case PipelineManager.FallbackStatus.InvalidPerformance:
                    case PipelineManager.FallbackStatus.InvalidRig:
                        tagFallback.transform.parent.gameObject.SetActive(true);
                        tagFallback.interactable = false;
                        tagFallback.GetComponentInChildren <Text>().text = "(Not valid for Fallback use)";
                        break;

                    default:
                        tagFallback.transform.parent.gameObject.SetActive(false);
                        break;
                    }
                }
            }
            else
            {
                waitingPanel.SetActive(true);
                blueprintPanel.SetActive(false);
                errorPanel.SetActive(false);
            }

            if (APIUser.CurrentUser != null && APIUser.CurrentUser.hasSuperPowers)
            {
                developerAvatar.gameObject.SetActive(true);
            }
            else
            {
                developerAvatar.gameObject.SetActive(false);
            }
        }
コード例 #18
0
ファイル: TvEpisodeMeta.cs プロジェクト: revenz/iMeta
        public XElement CreateXElement()
        {
            string   filenameNoExtension = Filename.Substring(0, Filename.LastIndexOf("."));
            XElement element             = new XElement("episodedetails");

            if (this.TvdbId > 0)
            {
                element.Add(new XElement("tvdbid", this.TvdbId));
            }
            if (this.TvdbSeriesId > 0)
            {
                element.Add(new XElement("tvdbseriesid", this.TvdbSeriesId));
            }
            element.Add(new XElement("title", this.Title ?? ""));
            element.Add(new XElement("showtitle", this.ShowTitle ?? ""));
            if (this.Rating > 0)
            {
                element.Add(new XElement("rating", this.Rating));
            }
            if (this.Aired > new DateTime(1910, 1, 1)) // i doubt think anyone will have a tv show from before 1910 :)
            {
                element.Add(new XElement("aired", this.Aired.ToString("yyyy-MM-dd")));
            }
            if (this.Premiered > new DateTime(1910, 1, 1))
            {
                element.Add(new XElement("premiered", this.Premiered.ToString("yyyy-MM-dd")));
            }
            element.Add(new XElement("season", this.Season));
            element.Add(new XElement("episode", this.Episode));
            element.Add(new XElement("displayseason", this.DisplaySeason));
            element.Add(new XElement("displayepisode", this.DisplayEpisode));
            element.Add(new XElement("plot", this.Plot));
            if (this.EpBookmark > 0)
            {
                element.Add(new XElement("epbookmark", this.EpBookmark));
            }
            if (!String.IsNullOrEmpty(this.Thumb))
            {
                string strThumb = this.Thumb;
                if (this.Thumb.StartsWith("http"))
                {
                    FileInfo thumbFile = new FileInfo(filenameNoExtension + ".tbn");
                    if (thumbFile.Exists || ImageDownloader.DownloadImage(this.Thumb, thumbFile.FullName)) // only set to local file if exists or successfully downloads, if fails keep the URL in there
                    {
                        strThumb = thumbFile.Name;
                    }
                }
                element.Add(new XElement("thumb", strThumb));
            }

            if (this.Directors != null)
            {
                foreach (string director in this.Directors)
                {
                    element.Add(new XElement("director", director));
                }
            }
            if (!String.IsNullOrEmpty(this.Studio))
            {
                element.Add(new XElement("studio", this.Studio));
            }
            if (!String.IsNullOrEmpty(Mpaa))
            {
                element.Add(new XElement("mpaa", this.Mpaa));
            }
            if (this.Actors != null)
            {
                foreach (KeyValuePair <string, string> actor in this.Actors)
                {
                    XElement xActor = new XElement("actor", new XElement("name", actor.Key));
                    if (!String.IsNullOrEmpty(actor.Value))
                    {
                        xActor.Add(new XElement("role", actor.Value));
                    }
                    element.Add(xActor);
                }
            }
            if (this.FileInfo != null)
            {
                XElement fileinfo = this.FileInfo.CreateXElement();
                if (fileinfo != null)
                {
                    element.Add(fileinfo);
                }
            }
            return(element);
        }
コード例 #19
0
        void SetupUI()
        {
            if (APIUser.CurrentUser.developerType < APIUser.DeveloperType.Trusted)
            {
                contentFeatured.gameObject.SetActive(false);
                contentSDKExample.gameObject.SetActive(false);
            }
            else
            {
                contentFeatured.gameObject.SetActive(true);
                contentSDKExample.gameObject.SetActive(true);
            }

            if (APIUser.Exists(pipelineManager.user))
            {
                waitingPanel.SetActive(false);
                blueprintPanel.SetActive(true);
                errorPanel.SetActive(false);

                if (string.IsNullOrEmpty(worldRecord.authorId) || worldRecord.authorId == pipelineManager.user.id)
                {
                    titleText.text       = "Configure World";
                    blueprintName.text   = worldRecord.name;
                    worldCapacity.text   = worldRecord.capacity.ToString();
                    contentSex.isOn      = worldRecord.tags.Contains("content_sex");
                    contentViolence.isOn = worldRecord.tags.Contains("content_violence");
                    contentGore.isOn     = worldRecord.tags.Contains("content_gore");
                    contentOther.isOn    = worldRecord.tags.Contains("content_other");
                    shouldUpdateImageToggle.interactable = isUpdate;
                    shouldUpdateImageToggle.isOn         = !isUpdate;
                    liveBpImage.enabled = !isUpdate;
                    bpImage.enabled     = isUpdate;

                    if (APIUser.CurrentUser.developerType < APIUser.DeveloperType.Trusted)
                    {
                        releasePublic.gameObject.SetActive(false);
                        releasePublic.isOn         = false;
                        releasePublic.interactable = false;

                        contentFeatured.isOn = contentSDKExample.isOn = false;
                    }
                    else
                    {
                        contentFeatured.isOn   = worldRecord.tags.Contains("content_featured");
                        contentSDKExample.isOn = worldRecord.tags.Contains("content_sdk_example");
                        releasePublic.isOn     = worldRecord.releaseStatus == "public";
                        releasePublic.gameObject.SetActive(true);
                    }

                    // "show in worlds menu"
                    if (APIUser.CurrentUser.developerType == APIUser.DeveloperType.Internal)
                    {
                        showInWorldsMenuGroup.gameObject.SetActive(true);
                        showInActiveWorlds.isOn  = !worldRecord.tags.Contains("admin_hide_active");
                        showInPopularWorlds.isOn = !worldRecord.tags.Contains("admin_hide_popular");
                        showInNewWorlds.isOn     = !worldRecord.tags.Contains("admin_hide_new");
                    }
                    else
                    {
                        showInWorldsMenuGroup.gameObject.SetActive(false);
                    }

                    blueprintDescription.text = worldRecord.description;

                    ImageDownloader.DownloadImage(worldRecord.imageUrl, delegate(Texture2D obj) {
                        bpImage.texture = obj;
                    });
                }
                else // user does not own world id associated with descriptor
                {
                    Debug.LogErrorFormat("{0} is not an owner of {1}", worldRecord.authorId, pipelineManager.user.id);
                    blueprintPanel.SetActive(false);
                    errorPanel.SetActive(true);
                }
            }
            else
            {
                waitingPanel.SetActive(true);
                blueprintPanel.SetActive(false);
                errorPanel.SetActive(false);

                if (APIUser.CurrentUser.developerType < APIUser.DeveloperType.Trusted)
                {
                    releasePublic.gameObject.SetActive(false);
                    releasePublic.isOn         = false;
                    releasePublic.interactable = false;
                }
                else
                {
                    releasePublic.gameObject.SetActive(true);
                    releasePublic.isOn = false;
                }
            }
        }
コード例 #20
0
 /// <summary>
 /// Attempt to download the poster cover using the URI from the OMDB by-title response.
 /// </summary>
 /// <param name="byTitleResponse"></param>
 /// <returns>An ImageDownload object which has a flag indicating is download was successful.</returns>
 public async Task <ImageDownload> GetImageForByTitleResponseAsync(ByTitleResponse byTitleResponse)
 {
     return(await ImageDownloader.DownloadImage(client, byTitleResponse.Poster_URI));
 }