forked from akanyan/mu3-mods
feat: implement SortByInternalDifficulty
This commit is contained in:
@ -0,0 +1,81 @@
|
||||
using MU3.DB;
|
||||
using MU3.SceneObject.MusicSelect;
|
||||
using MU3.Util;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace MU3.ViewData;
|
||||
|
||||
class patch_MusicSelectViewDataList: MusicSelectViewDataList {
|
||||
private delegate int CompareProc(MusicSelectViewData d1, MusicSelectViewData d2, bool forSort1);
|
||||
private delegate string GetCategoryNameProc(MusicSelectViewData d);
|
||||
private MusicSort1ID __sort1;
|
||||
private CompareProc _compareProc1;
|
||||
private GetCategoryNameProc _getCategoryNameProc;
|
||||
private ListList<MusicMinorCategoryData> _minorCategoryDataList;
|
||||
|
||||
private extern void orig_set__sort1(MusicSort1ID value);
|
||||
|
||||
private void set__sort1(MusicSort1ID value) {
|
||||
if(value == (MusicSort1ID)patch_MusicSort1ID.InternalLevel) {
|
||||
__sort1 = value;
|
||||
_compareProc1 = compareByInternalLevel;
|
||||
_getCategoryNameProc = getCategoryNameByInternalLevel;
|
||||
} else {
|
||||
orig_set__sort1(value);
|
||||
}
|
||||
}
|
||||
private string getCategoryNameByInternalLevel(MusicSelectViewData d) {
|
||||
StringBuilder stringBuilder = Singleton<MU3.Sys.System>.instance.getStringBuilder();
|
||||
Data.FumenData fumenData = ((d.musicViewData.data == null) ? null : d.musicViewData.data.fumenData[(int)d.difficulty]);
|
||||
stringBuilder.Append("LEVEL ");
|
||||
stringBuilder.AppendFormat("{0}", (fumenData == null) ? (-1) : (fumenData.fumenConst.ToString("0.0")));
|
||||
return stringBuilder.ToString();
|
||||
}
|
||||
|
||||
private int getSortKeyByInternalLevel(MusicSelectViewData d, bool forSort1) {
|
||||
return (int)Math.Round(d.musicViewData.data.fumenData[(int)d.difficulty].fumenConst * 10.0);
|
||||
}
|
||||
|
||||
private int compareByInternalLevel(MusicSelectViewData d1, MusicSelectViewData d2, bool forSort1) {
|
||||
return getSortKeyByInternalLevel(d1, forSort1) - getSortKeyByInternalLevel(d2, forSort1);
|
||||
}
|
||||
|
||||
private extern bool orig_isDifferentMyListSet(patch_MusicSort1ID oldSort1, patch_MusicSort1ID nowSort1);
|
||||
private bool isDifferentMyListSet(patch_MusicSort1ID oldSort1, patch_MusicSort1ID nowSort1) {
|
||||
if(oldSort1 == patch_MusicSort1ID.InternalLevel && nowSort1 != patch_MusicSort1ID.InternalLevel) {
|
||||
return true;
|
||||
}
|
||||
if(oldSort1 != patch_MusicSort1ID.InternalLevel && nowSort1 == patch_MusicSort1ID.InternalLevel) {
|
||||
return true;
|
||||
}
|
||||
return orig_isDifferentMyListSet(oldSort1, nowSort1);
|
||||
}
|
||||
|
||||
private extern int orig_createMyListMusicDataAllDifficulty(List<MusicSelectViewData> list, HashSet<int> idList, MU3.Data.MusicData musicData, MusicSort1ID sort1, int initOrder);
|
||||
private int createMyListMusicDataAllDifficulty(List<MusicSelectViewData> list, HashSet<int> idList, MU3.Data.MusicData musicData, MusicSort1ID sort1, int initOrder) {
|
||||
if(sort1 == (MusicSort1ID)patch_MusicSort1ID.InternalLevel) {
|
||||
sort1 = MusicSort1ID.Level;
|
||||
}
|
||||
return orig_createMyListMusicDataAllDifficulty(list, idList, musicData, sort1, initOrder);
|
||||
}
|
||||
|
||||
// Enable this for 1.45 Re:MAS inclusion
|
||||
/*private int getMetaSortKey(MusicSelectViewData d, bool forCategorySort) {
|
||||
if(forCategorySort) {
|
||||
if(d.musicViewData.data.isBonusTrack)
|
||||
return 3;
|
||||
if(d.musicViewData.data.isLunatic && d.musicViewData.data.isReMaster && __sort1 != MusicSort1ID.Level && __sort1 != (MusicSort1ID)patch_MusicSort1ID.InternalLevel)
|
||||
return 1;
|
||||
if(d.musicViewData.data.isLunatic && !d.musicViewData.data.isReMaster)
|
||||
return 2;
|
||||
} else {
|
||||
if(d.musicViewData.data.isLunatic && d.musicViewData.data.isReMaster && __sort1 != MusicSort1ID.Level && __sort1 != (MusicSort1ID)patch_MusicSort1ID.InternalLevel)
|
||||
return 1;
|
||||
if(d.musicViewData.data.isLunatic && !d.musicViewData.data.isReMaster)
|
||||
return 2;
|
||||
}
|
||||
return 0;
|
||||
}*/
|
||||
}
|
Reference in New Issue
Block a user