コード例 #1
0
        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;
            }
        }
コード例 #2
0
        void RenderMidiListItem(SongSelectItemController item, Storage.Protos.Api.MidiProto midi)
        {
            Debug.Log("Midi list item");

            item.titleText.text = DownloadedSongSelectPageScheduler.GetStringOrUnkonwn(midi.name);
            item.line1Text.text = "by " + DownloadedSongSelectPageScheduler.GetStringOrUnkonwn(midi.artistName);
            item.line2Text.text = string.Format(" {0:N0}   {1:N0}x   {2:F2}%", midi.avgScore, midi.avgCombo, midi.avgAccuracy * 100);
            item.action         = () => {
                if (level.selectedMidiId != midi._id)
                {
                    level.selectedMidiId = midi._id;
                    InitMidiDetail(false);
                    InitMidiRank();
                }
            };

            var coverUrl = midi.coverUrl;

            if (coverUrl != null)
            {
                Debug.Log("Midi cover url");
                Net.WebCache.instance.LoadTexture(coverUrl, job => {
                    item.imageCutter.Cut(job.GetKey(), job.GetData());
                });
            }
            else
            {
                Debug.Log("Cut midi default");
                item.imageCutter.Cut(defaultTexture.name, defaultTexture);
            }
        }
コード例 #3
0
        void LoadMidiAndPlay(Storage.Protos.Api.MidiProto midi)
        {
            var game = GameScheduler.instance;

            game.midiId   = midi._id;
            game.midiFile = new Midif.V3.MidiFile(Storage.ResourceStorage.ReadMidiBytes(midi));
            game.noteSequenceCollection = new Midif.V3.NoteSequenceCollection(game.midiFile);
            game.title    = midi.name;
            game.subtitle = string.Format("{0} • {1}", midi.sourceAlbumName, midi.sourceSongName);
            UnityEngine.SceneManagement.SceneManager.LoadScene(GameScheduler.GAMEPLAY_LEVEL_BUILD_INDEX);
        }
コード例 #4
0
        void InitMidiDetail(bool renderMidiList = true)
        {
            midi = res.QueryMidiById(level.selectedMidiId);
            if (!string.IsNullOrEmpty(midi.coverBlurUrl))
            {
                Net.WebCache.instance.LoadTexture(midi.coverBlurUrl, job => {
                    level.backgroundImage.texture = job.GetData();
                    game.backgroundTexture        = job.GetData();
                });
            }
            else
            {
                level.backgroundImage.texture = level.defaultBackgroundTexture;
                game.backgroundTexture        = null;
            }

            song   = res.QuerySongById(midi.songId);
            album  = res.QueryAlbumById(song.albumId);
            author = res.QueryPersonById(midi.authorId);

            // _id is path for custom midis
            byte[] bytes = ResourceStorage.ReadMidiBytes(midi);
            midiId             = midi._id;
            midiFile           = new MidiFile(bytes);
            sequenceCollection = new NoteSequenceCollection(midiFile);

            sourceText.text = string.Format("{0} • {1}", album.name.TranslateArtifact(), song.name.TranslateArtifact());
            titleText.text  = midi.name;
            artistText.text = string.Format("by {0}", author?.name ?? midi.artistName);
            infoText.text   = string.Format("{0:N0} Sequences • {1:N0} Notes • {2}",
                                            sequenceCollection.sequences.Count, sequenceCollection.noteCount, hash = MiscHelper.GetHexEncodedMd5Hash(bytes));
            statisticsText.text = string.Format(" <size=12>{0:N0}</size>   <size=12>{1:N0}</size>   <size=12>{2:N0}</size>   <size=12>{3:N0}</size>", midi.trialCount, midi.downloadCount, midi.voteSum, midi.loveCount);
            statusText.text     = midi.status;

            if (string.IsNullOrWhiteSpace(midi.coverUrl))
            {
                coverCutter.Cut(defaultTexture.name, defaultTexture);
            }
            else
            {
                Net.WebCache.instance.LoadTexture(midi.coverUrl, job => {
                    coverCutter.Cut(job.GetKey(), job.GetData());
                });
            }

            if (renderMidiList)
            {
                RenderMidiList(midi.songId);
            }
        }
コード例 #5
0
        public void DownloadMidi(MidiDirectScrollItemController item, Storage.Protos.Api.MidiProto midiProto)
        {
            string hash = midiProto.hash;

            if (web.CheckUrlFileExists(hash))
            {
                return;
            }

            item.iconText.text = FontAwesome.Solid.Spinner;
            anim.New(item)
            .RotateTo(item.iconText.transform, 360, 1, EsType.BackOut).Then()
            .RotateTo(item.iconText.transform, 0, 1, EsType.BackOut).Then().Repeat();

            net.ClAppMidiDownload(hash, (error, data) => {
                var loadJob = web.LoadNull(hash, (string)data, job => {
                    db.WriteDoc(LocalDb.COLLECTION_MIDIS, midiProto._id, midiProto);
                    if (midiProto.song != null)
                    {
                        db.WriteDoc(LocalDb.COLLECTION_SONGS, midiProto.song._id, midiProto.song);
                    }
                    if (midiProto.album != null)
                    {
                        db.WriteDoc(LocalDb.COLLECTION_ALBUMS, midiProto.album._id, midiProto.album);
                    }
                    if (midiProto.author != null)
                    {
                        db.WriteDoc(LocalDb.COLLECTION_PERSONS, midiProto.author._id, midiProto.author);
                    }
                    if (midiProto.composer != null)
                    {
                        db.WriteDoc(LocalDb.COLLECTION_PERSONS, midiProto.composer._id, midiProto.composer);
                    }
                    job.GetData();
                    anim.Clear(item);
                    item.coverImageCutter.image.color     = new Color(1, 1, 1, .5f);
                    item.iconText.transform.localRotation = Quaternion.identity;
                    item.iconText.text = FontAwesome.Solid.CheckCircle;
                });

                anim.Clear(item);
                game.ExecuteOnMain(() => item.iconText.transform.localRotation = Quaternion.identity);
                anim.New(item).Wait(.001f).Then().Call(() => {
                    item.iconText.text = string.Format("<size=16>{0:P0}</size>", loadJob.GetProgress());
                }).Repeat();
            });
        }