Beispiel #1
0
    void OnUpdateInfo(SongInfo?newInfo)
    {
        bool hasInfo = newInfo.HasValue;

        songInfo = newInfo.GetValueOrDefault();
        if (!songInfo.banner && songInfo.background)
        {
            songInfo.banner = songInfo.background;
        }
        background.SetTexture(songInfo.background);
        background.gameObject.SetActive(songInfo.background);
        banner.SetTexture(songInfo.banner);
        bannerParent.gameObject.SetActive(songInfo.banner);
        songDetails.text = hasInfo ? string.Format(
            LanguageLoader.GetText(1),
            songInfo.name,
            songInfo.level,
            songInfo.artist,
            songInfo.subArtist,
            songInfo.genre,
            songInfo.bpm,
            songInfo.notes,
            songInfo.LayoutName,
            songInfo.comments
            ) : string.Empty;
        ReloadRecord();
    }
Beispiel #2
0
    public void SetText(int langId)
    {
        var text = LanguageLoader.GetText(langId).Split('\n');

        for (int i = 0, c = Mathf.Min(text.Length, options.Count); i < c; i++)
        {
            options[i].text = text[i];
        }
        if (value >= 0 && value < options.Count)
        {
            captionText.text = options[value].text;
        }
    }
Beispiel #3
0
    public static string GetFormattedRankString(RankControl rankControl, float score)
    {
        if (Loader.judgeMode == 2)
        {
            return(LanguageLoader.GetText(score > 500000 ? 33 : 34));
        }
        string rankString;
        Color  rankColor;

        rankControl.GetRank(score, out rankString, out rankColor);
        return(string.Format(
                   "<color=#{0}>{1}</color>",
                   ColorUtility.ToHtmlStringRGBA(rankColor),
                   rankString
                   ));
    }
    public void ShowKeyMapMenu(int channel)
    {
        if (Array.IndexOf(usableChannels, channel) < 0)
        {
            return;
        }
        selectedChannel = -1;
        KeyCode keyCode;

        if (!keyMapping.TryGetValue(channel, out keyCode))
        {
            keyCode = KeyCode.None;
        }
        keyMappingDropdown.value   = Array.IndexOf(keyCodeValues, keyCode);
        selectedChannel            = channel;
        keyMappingDescDisplay.text = string.Format(LanguageLoader.GetText(14), channel);
        keyMapMenu.gameObject.SetActive(true);
        isMapping = true;
    }
Beispiel #5
0
    public void SetText(int langId, params object[] args)
    {
        var text = LanguageLoader.GetText(langId);

        if (args != null && args.Length > 0 && !string.IsNullOrEmpty(text))
        {
            text = string.Format(text, args);
        }
        this.langId = langId;
        this.text   = text;
        font        = LanguageLoader.currentFont;
        SetAllDirty();
        RectTransform parent = rectTransform.parent as RectTransform;

        if (parent)
        {
            LayoutRebuilder.MarkLayoutForRebuild(parent);
        }
    }
Beispiel #6
0
    public void ReloadRecord()
    {
        if (Loader.judgeMode == 2)
        {
            // Competition-Free mode will not bring out any result here
            playerBest.text = string.Empty;
            return;
        }
        RecordsManager.Record?record = GetCurrentrecord(songInfo.bmsHash);
        var recordContent            = record.GetValueOrDefault();

        playerBest.text = record.HasValue ? string.Format(
            LanguageLoader.GetText(39),
            recordContent.score,
            recordContent.combos,
            recordContent.playCount,
            recordContent.timeStamp,
            GetFormattedRankString(rankControl, recordContent.score)
            ) : string.Empty;
    }
Beispiel #7
0
    void Update()
    {
        bool triggerLoadingbar = bmsLoaded;

        if (bmsLoaded)
        {
            bmsLoaded          = false;
            titleDisplay.text  = bmsManager.Title;
            artistDisplay.text = string.Format(LanguageLoader.GetText(17), bmsManager.Artist, bmsManager.SubArtist.Replace("\n", " / "));
            levelDisplay.text  = bmsManager.PlayLevel.ToString();
            if (startOnLoad)
            {
                if (!bmsManager.BGAEnabled)
                {
                    bmsManager.placeHolderTexture = Texture2D.whiteTexture;
                }
                bmsManager.IsStarted = true;
                startOnLoad          = false;
                gameStarted          = true;
            }
        }
        if (stageFileLoaded)
        {
            stageFileLoaded = false;
            bgTexture.SetTexture(bmsManager.StageFile);
            bgTexture.rawImage.enabled = bmsManager.StageFile != null && !bmsManager.IsStarted;
        }
        if (gameEnded)
        {
            gameEnded = false;
            if (!Loader.listenMode)
            {
                panel.gameObject.SetActive(true);
                if (Loader.judgeMode != 2)
                {
                    resultText.text = "";
                    detailsPanel.gameObject.SetActive(true);
                    for (int i = 0; i < resultCountText.Length; i++)
                    {
                        resultCountText[i].text = bmsManager.GetNoteScoreCount(i).ToString("\\x0");
                    }
                    resultComboText.text = bmsManager.MaxCombos.ToString("\\x0");
                    resultScoreText.text = bmsManager.Score.ToString("0000000");
                    resultRankText.text  = string.Format(
                        "<color=#{0}>{1}</color>",
                        ColorUtility.ToHtmlStringRGBA(bmsManager.RankColor),
                        bmsManager.RankString
                        );
                }
                bgTexture.rawImage.enabled = bgTexture.rawImage.texture != null;
                if (graphDisplay)
                {
                    if (graphHandler)
                    {
                        graphDisplay.texture = graphHandler.Texture;
                    }
                    graphDisplay.enabled = graphDisplay.texture;
                }
                var recordsManager = RecordsManager.Instance;
                if (Loader.judgeMode == 2)
                {
                    var  hash        = bmsManager.GetHash(SongInfoLoader.CurrentEncoding, recordsManager.HashAlgorithm);
                    int  channelHash = RecordsManager.GetAdoptedChannelHash(bmsManager.GetAllAdoptedChannels());
                    var  records     = recordsManager.GetRecord(hash, channelHash);
                    bool pass        = bmsManager.Score >= bmsManager.MaxScore / 2;
                    if (pass && records != null)
                    {
                        pass = bmsManager.Score >= records.Value.score;
                    }
                    resultText.text = LanguageLoader.GetText(pass ? 33 : 34);
                    detailsPanel.gameObject.SetActive(false);
                }
                if (!Loader.autoMode)
                {
                    recordsManager.CreateRecord(bmsManager);
                }
            }
            SetPauseButton();
        }
        if (gameStarted)
        {
            gameStarted = false;
            panel.gameObject.SetActive(false);
            pausePanel.gameObject.SetActive(false);
            dummyBGA.SetActive(bmsManager.BGAEnabled);
            bgTexture.rawImage.enabled = false;
            SetPauseButton();
        }
        if (pauseChanged)
        {
            pauseChanged = false;
            pausePanel.gameObject.SetActive(bmsManager.IsPaused);
            SetPauseButton();
        }
        if (backgroundChanged)
        {
            backgroundChanged = false;
            dummyBGA.SetActive(false);
        }
        float t = Time.deltaTime * 10;

        if (bmsManager.Score < displayingScore)
        {
            displayingScore = bmsManager.Score;
        }
        displayingScore   = Mathf.CeilToInt(Mathf.Lerp(displayingScore, bmsManager.Score, t));
        scoreDisplay.text = displayingScore.ToString("0000000");

        if (targetCombos != bmsManager.Combos)
        {
            combosValue  = combosValue + bmsManager.Combos - targetCombos;
            targetCombos = bmsManager.Combos;
        }
        else
        {
            combosValue = Mathf.Lerp(combosValue, 0, t / 4);
        }
        if (displayCombos < targetCombos)
        {
            displayCombos = targetCombos;
        }
        displayCombos     = Mathf.FloorToInt(Mathf.Lerp(displayCombos, bmsManager.Combos, t));
        comboDisplay.text = (bmsManager.IsStarted && displayCombos >= 3) ? displayCombos.ToString() : "";
        comboDisplay.transform.localScale = Vector3.one * (1 + Mathf.Log(Mathf.Max(0, combosValue) + 1, 8));
        if (bmsManager.IsLoadingResources || triggerLoadingbar)
        {
            var anchorMax = durationBar.anchorMax;
            anchorMax.x           = bmsManager.LoadResourceProgress;
            durationBar.anchorMax = anchorMax;
        }
        else if (bmsManager.IsStarted)
        {
            var anchorMax = durationBar.anchorMax;
            anchorMax.x           = bmsManager.PercentageTimePassed;
            durationBar.anchorMax = anchorMax;
        }
        float deltaTime = Time.unscaledDeltaTime;

        if (fpsBar)
        {
            UpdateVerticalBar(fpsBar, deltaTime * 10F);
        }
        if (fpsText)
        {
            fpsText.text = string.Format("{0:0} FPS", 1 / deltaTime);
        }
        if (polyphonyBar)
        {
            UpdateVerticalBar(polyphonyBar, bmsManager.Polyphony / 255F);
        }
        if (polyphonyText)
        {
            polyphonyText.text = string.Format("{0} POLY", bmsManager.Polyphony);
        }
        if (accuracyBar)
        {
            UpdateHorzBar(accuracyBar, bmsManager.Accuracy / 50F);
        }
        if (accuracyText)
        {
            accuracyText.text = string.Format("{0:+0000;-0000}MS", bmsManager.Accuracy);
        }
        if (bpmText)
        {
            bpmText.text = string.Format(
                bpmFormatText, bmsManager.BPM,
                ColorUtility.ToHtmlStringRGBA(
                    Color.Lerp(bpmText.color, bpmLightColor, bpmLightLerp)
                    ));
        }
    }