feat(SortByInternal): add sort2

This commit is contained in:
あかニャン 2024-07-05 19:49:45 +09:00
parent 44dfa20ea8
commit de9bcda48d
4 changed files with 42 additions and 7 deletions

View File

@ -2,8 +2,7 @@
namespace MU3.DB;
[MonoModPatch("global::MU3.DB.MusicSort1ID")]
[MonoModEnumReplace()]
[MonoModEnumReplace]
public enum patch_MusicSort1ID {
Genre = 0,
All = 1,

View File

@ -0,0 +1,15 @@
using MonoMod;
namespace MU3.DB;
[MonoModPatch("global::MU3.DB.MusicSort2IDEnum")]
public static class patch_MusicSort2IDEnum {
private static MusicSort2TableRecord[] records;
public static extern bool orig_loadFromFile(string filename);
public static bool loadFromFile(string filename) {
var rv = orig_loadFromFile(filename);
records[4].Name = "インターナル";
return rv;
}
}

View File

@ -1,5 +1,4 @@
using MU3.DB;
using MU3.SceneObject.MusicSelect;
using MU3.Util;
using System;
using System.Collections.Generic;
@ -12,10 +11,11 @@ class patch_MusicSelectViewDataList: MusicSelectViewDataList {
private delegate string GetCategoryNameProc(MusicSelectViewData d);
private MusicSort1ID __sort1;
private CompareProc _compareProc1;
private CompareProc _compareProc2;
private GetCategoryNameProc _getCategoryNameProc;
private ListList<MusicMinorCategoryData> _minorCategoryDataList;
private extern void orig_set__sort1(MusicSort1ID value);
private extern void orig_set__sort2(MusicSort2ID value);
private void set__sort1(MusicSort1ID value) {
if(value == (MusicSort1ID)patch_MusicSort1ID.InternalLevel) {
@ -26,6 +26,14 @@ class patch_MusicSelectViewDataList: MusicSelectViewDataList {
orig_set__sort1(value);
}
}
private void set__sort2(MusicSort2ID value) {
orig_set__sort2(value);
if(value == MusicSort2ID.Level) {
_compareProc2 = compareByInternalLevel;
}
}
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]);
@ -34,12 +42,12 @@ class patch_MusicSelectViewDataList: MusicSelectViewDataList {
return stringBuilder.ToString();
}
private int getSortKeyByInternalLevel(MusicSelectViewData d, bool forSort1) {
private int getSortKeyByInternalLevel(MusicSelectViewData d) {
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);
return getSortKeyByInternalLevel(d1) - getSortKeyByInternalLevel(d2);
}
private extern bool orig_isDifferentMyListSet(patch_MusicSort1ID oldSort1, patch_MusicSort1ID nowSort1);

View File

@ -4,9 +4,10 @@ namespace MU3;
public class patch_Scene_32_PrePlayMusic_MusicSelect: Scene_32_PrePlayMusic_MusicSelect {
private static patch_MusicSort1ID[] _sort1SettingList;
private static MusicSort2ID[] _sort2SettingList;
private extern void orig_Awake();
private void Awake() {
private new void Awake() {
_sort1SettingList = new[] {
patch_MusicSort1ID.Genre,
patch_MusicSort1ID.All,
@ -18,6 +19,18 @@ public class patch_Scene_32_PrePlayMusic_MusicSelect: Scene_32_PrePlayMusic_Musi
patch_MusicSort1ID.InternalLevel
};
_sort2SettingList = new[] {
MusicSort2ID.Recommend,
MusicSort2ID.BattlePoint,
MusicSort2ID.TechnicalScore,
MusicSort2ID.BossLevel,
MusicSort2ID.Name,
MusicSort2ID.AddDate,
MusicSort2ID.Chapter,
MusicSort2ID.Level
//, MusicSort2ID.Lamp
};
orig_Awake();
}