void RenderItem(MidiDirectScrollItemController item, Storage.Protos.Api.MidiProto midi)
        {
            item.nameText.text     = midi.name;
            item.authorText.text   = midi.artistName;
            item.uploaderText.text = "upload by " + midi.uploaderName;
            item.albumText.text    = midi.album == null ? midi.sourceAlbumName : midi.album.name.TranslateArtifact();
            item.songText.text     = midi.song == null ? midi.sourceSongName : midi.song.name.TranslateArtifact();

            if (midi.coverUrl != null)
            {
                web.LoadTexture(midi.coverUrl, job => {
                    item.coverImageCutter.Cut(job.GetKey(), job.GetData());
                });
            }
            else
            {
                item.coverImageCutter.Cut(item.defaultTexture.name, item.defaultTexture);
            }

            item.downloadButton.onClick.RemoveAllListeners();
            item.downloadButton.onClick.AddListener(() => DownloadMidi(item, midi));

            if (web.CheckUrlFileExists(midi.hash))
            {
                item.coverImageCutter.image.color = new Color(1, 1, 1, .5f);
                item.iconText.text = FontAwesome.Solid.CheckCircle;
            }
            else
            {
                item.coverImageCutter.image.color = new Color(1, 1, 1, 1);
                item.iconText.text = FontAwesome.Solid.CloudDownloadAlt;
            }
        }
        void RenderAlbum(SongSelectItemController item, Album album)
        {
            item.titleText.text = GetStringOrUnkonwn(album.name);
            item.line1Text.text = album.midiList.Count + " midis";
            item.line2Text.text = "";
            item.action         = () => {
                selectedAlbum = album;
                RenderMidiList();
            };

            var coverUrl = FindFirstCoverUrl(album.midiList);

            if (coverUrl != null)
            {
                web.LoadTexture(coverUrl, job => {
                    var texture = job.GetData();
                    item.imageCutter.Cut(job.GetKey(), texture);
                });
            }
            else
            {
                item.imageCutter.Cut(defaultTexture.name, defaultTexture);
            }
        }
示例#3
0
        void DisplayUserInfo(JsonObj userDict)
        {
            TopToolBarScheduler.FadeOutAndDeactivate(loginPopupGroup);
            loginButtonGroup.gameObject.SetActive(false);
            userInfoGroup.gameObject.SetActive(true);
            anim.New(userInfoGroup).FadeIn(userInfoGroup, .2f, 0);

            game.ExecuteOnMain(() => {
                nameText.text = (string)userDict["name"];
                if (userDict.ContainsKey("avatarUrl"))
                {
                    web.LoadTexture((string)userDict["avatarUrl"], job => {
                        rawImageCutter.Cut(job.GetKey(), job.GetData());
                    });
                }
            });
        }