void updateGameDefaultDifficut()
 {
     if (currentType == EZR.GameType.EZ2ON && (
             currentDifficult != EZR.GameDifficult.Difficult.EZ &&
             currentDifficult != EZR.GameDifficult.Difficult.NM &&
             currentDifficult != EZR.GameDifficult.Difficult.HD &&
             currentDifficult != EZR.GameDifficult.Difficult.SHD &&
             currentDifficult != EZR.GameDifficult.Difficult.EX
             ))
     {
         currentDifficult = EZR.GameDifficult.Difficult.EZ;
     }
     else if (currentType == EZR.GameType.EZ2DJ && (
                  currentDifficult != EZR.GameDifficult.Difficult.EZ &&
                  currentDifficult != EZR.GameDifficult.Difficult.NM &&
                  currentDifficult != EZR.GameDifficult.Difficult.HD &&
                  currentDifficult != EZR.GameDifficult.Difficult.SHD &&
                  currentDifficult != EZR.GameDifficult.Difficult.EX
                  ))
     {
         currentDifficult = EZR.GameDifficult.Difficult.EZ;
     }
     else if (currentType == EZR.GameType.DJMAX && (
                  currentDifficult != EZR.GameDifficult.Difficult.DJMAX_EZ &&
                  currentDifficult != EZR.GameDifficult.Difficult.DJMAX_NM &&
                  currentDifficult != EZR.GameDifficult.Difficult.DJMAX_HD &&
                  currentDifficult != EZR.GameDifficult.Difficult.DJMAX_MX &&
                  currentDifficult != EZR.GameDifficult.Difficult.DJMAX_SC
                  ))
     {
         currentDifficult = EZR.GameDifficult.Difficult.DJMAX_EZ;
     }
 }
    public void BtnSetGameType()
    {
        var btn = EventSystem.current.currentSelectedGameObject.GetComponent <EZR.ButtonExtension>();

        if (btn.IsSelected)
        {
            return;
        }

        switch (btn.gameObject.name)
        {
        case "BtnEZ2ON":
            currentType = EZR.GameType.EZ2ON;
            currentMode = EZR.GameMode.Mode.RubyMixON;
            break;

        case "BtnEZ2DJ":
            currentType = EZR.GameType.EZ2DJ;
            currentMode = EZR.GameMode.Mode.RubyMixDJ;
            break;

        case "BtnDJMAX":
            currentType = EZR.GameType.DJMAX;
            currentMode = EZR.GameMode.Mode.FourKey;
            break;
        }
        currentDifficult = EZR.GameDifficult.Difficult.EZ;
        updateGameModeButton();

        updateGameDefaultDifficut();

        filterSongs();
        updateDifficultState();
        focusOnBtnDifficult();
        updateGameType();
        updateList();

        EZR.MemorySound.PlaySound("e_page");
    }
    public void BtnSetGameMode()
    {
        var btn = EventSystem.current.currentSelectedGameObject.GetComponent <EZR.ButtonExtension>();

        if (btn.IsSelected)
        {
            return;
        }
        var diffUI = btn.GetComponent <EZR.GameTypeUI>();

        currentType      = diffUI.GameType;
        currentMode      = diffUI.GameMode;
        currentDifficult = EZR.GameDifficult.Difficult.EZ;

        updateGameDefaultDifficut();

        filterSongs();
        updateDifficultState();
        focusOnBtnDifficult();
        btn.SetSelected(true);
        updateList();

        EZR.MemorySound.PlaySound("e_page");
    }
        public static string GetFileName(string songName, EZR.GameType type, EZR.GameMode.Mode mode, EZR.GameDifficult.Difficult difficult)
        {
            string fileName;

            if (type == EZR.GameType.DJMAX)
            {
                if (mode == EZR.GameMode.Mode.FourKey ||
                    mode == EZR.GameMode.Mode.FiveKey ||
                    mode == EZR.GameMode.Mode.SixKey ||
                    mode == EZR.GameMode.Mode.SevenKey ||
                    mode == EZR.GameMode.Mode.EightKey)
                {
                    fileName = Path.Combine(songName + "_ORG" + EZR.GameDifficult.GetString(difficult) + EZR.GameMode.GetString(mode) + ".json");
                }
                else
                {
                    fileName = Path.Combine(songName + EZR.GameMode.GetString(mode) + EZR.GameDifficult.GetString(difficult) + ".json");
                }
            }
            else
            {
                fileName = Path.Combine(EZR.GameMode.GetString(mode) + songName + EZR.GameDifficult.GetString(difficult) + ".json");
            }
            return(fileName);
        }
    public void BtnSetDifficult()
    {
        var btn = EventSystem.current.currentSelectedGameObject.GetComponent <EZR.ButtonExtension>();

        if (btn.IsSelected)
        {
            return;
        }
        switch (btn.gameObject.name)
        {
        case "BtnEZ":
            if (currentType == EZR.GameType.DJMAX)
            {
                currentDifficult = EZR.GameDifficult.Difficult.DJMAX_EZ;
            }
            else
            {
                currentDifficult = EZR.GameDifficult.Difficult.EZ;
            }
            break;

        case "BtnNM":
            if (currentType == EZR.GameType.DJMAX)
            {
                currentDifficult = EZR.GameDifficult.Difficult.DJMAX_NM;
            }
            else
            {
                currentDifficult = EZR.GameDifficult.Difficult.NM;
            }
            break;

        case "BtnHD":
            if (currentType == EZR.GameType.DJMAX)
            {
                currentDifficult = EZR.GameDifficult.Difficult.DJMAX_HD;
            }
            else
            {
                currentDifficult = EZR.GameDifficult.Difficult.HD;
            }
            break;

        case "BtnSHD":
            if (currentType == EZR.GameType.DJMAX)
            {
                currentDifficult = EZR.GameDifficult.Difficult.DJMAX_MX;
            }
            else
            {
                currentDifficult = EZR.GameDifficult.Difficult.SHD;
            }
            break;

        case "BtnEX":
            if (currentType == EZR.GameType.DJMAX)
            {
                currentDifficult = EZR.GameDifficult.Difficult.DJMAX_SC;
            }
            else
            {
                currentDifficult = EZR.GameDifficult.Difficult.EX;
            }
            break;
        }

        updateBtnDifficult(btn);
        switch (EZR.SongList.CurrentSortMode)
        {
        case EZR.SongList.SortMode.ByName:
            sortListByName(EZR.SongList.IsAscending);
            break;

        case EZR.SongList.SortMode.ByDifficult:
            sortListByDifficult(EZR.SongList.IsAscending);
            break;
        }
        updateList();

        EZR.MemorySound.PlaySound("e_level");
    }
    // 找首个可用的歌曲和难度
    void updateDifficultState()
    {
        // 当前歌曲和难度直接可用,直接排一次序就完事
        if (EZR.SongList.List[currentSongIndex].GetCurrentMode(currentMode, currentDifficult) != EZR.GameMode.Mode.None)
        {
            switch (EZR.SongList.CurrentSortMode)
            {
            case EZR.SongList.SortMode.ByName:
                sortListByName(EZR.SongList.IsAscending);
                break;

            case EZR.SongList.SortMode.ByDifficult:
                sortListByDifficult(EZR.SongList.IsAscending);
                break;
            }
            return;
        }

        bool[] currentDifficultState = new bool[] { false, false, false, false, false };

        foreach (var info in EZR.SongList.List)
        {
            var state = songDifficultState(info);
            currentDifficultState[0] |= state[0];
            currentDifficultState[1] |= state[1];
            currentDifficultState[2] |= state[2];
            currentDifficultState[3] |= state[3];
            currentDifficultState[4] |= state[4];
        }

        if (currentType == EZR.GameType.DJMAX)
        {
            if (!currentDifficultState[(int)currentDifficult - (int)EZR.GameDifficult.Difficult.DJMAX_EZ])
            {
                for (int i = 0; i < currentDifficultState.Length; i++)
                {
                    if (currentDifficultState[i])
                    {
                        currentDifficult = (EZR.GameDifficult.Difficult)(i + (int)EZR.GameDifficult.Difficult.DJMAX_EZ);
                        break;
                    }
                }
            }
        }
        else
        {
            if (!currentDifficultState[(int)currentDifficult])
            {
                for (int i = 0; i < currentDifficultState.Length; i++)
                {
                    if (currentDifficultState[i])
                    {
                        currentDifficult = (EZR.GameDifficult.Difficult)i;
                        break;
                    }
                }
            }
        }

        // 第一次排序
        switch (EZR.SongList.CurrentSortMode)
        {
        case EZR.SongList.SortMode.ByName:
            sortListByName(EZR.SongList.IsAscending);
            break;

        case EZR.SongList.SortMode.ByDifficult:
            sortListByDifficult(EZR.SongList.IsAscending);
            break;
        }

        // 找当前歌曲可用难度
        var  state2 = songDifficultState(EZR.SongList.List[currentSongIndex]);
        bool isHit  = false;

        for (int i = 0; i < state2.Length; i++)
        {
            if (state2[i])
            {
                isHit = true;
                if (currentType == EZR.GameType.DJMAX)
                {
                    currentDifficult = (EZR.GameDifficult.Difficult)(i + (int)EZR.GameDifficult.Difficult.DJMAX_EZ);
                }
                else
                {
                    currentDifficult = (EZR.GameDifficult.Difficult)i;
                }
                break;
            }
        }
        // 找首个可用的歌曲
        if (!isHit)
        {
            foreach (var info in currentList)
            {
                state2 = songDifficultState(info);
                for (int i = 0; i < state2.Length; i++)
                {
                    if (state2[i])
                    {
                        isHit            = true;
                        currentSongIndex = EZR.SongList.List.IndexOf(info);
                        if (currentType == EZR.GameType.DJMAX)
                        {
                            currentDifficult = (EZR.GameDifficult.Difficult)(i + (int)EZR.GameDifficult.Difficult.DJMAX_EZ);
                        }
                        else
                        {
                            currentDifficult = (EZR.GameDifficult.Difficult)i;
                        }
                        break;
                    }
                }
                if (isHit)
                {
                    break;
                }
            }
        }

        // 第二次排序
        switch (EZR.SongList.CurrentSortMode)
        {
        case EZR.SongList.SortMode.ByName:
            sortListByName(EZR.SongList.IsAscending);
            break;

        case EZR.SongList.SortMode.ByDifficult:
            sortListByDifficult(EZR.SongList.IsAscending);
            break;
        }
    }