mirror of
https://github.com/muskit/MercuryConverter.git
synced 2026-06-02 20:24:26 -07:00
move EntryChart creation function
This commit is contained in:
+4
-27
@@ -55,10 +55,12 @@ public static class Database
|
|||||||
Artist = data["ArtistMessage"].ToString()!,
|
Artist = data["ArtistMessage"].ToString()!,
|
||||||
Genre = ((IntPropertyData)data["ScoreGenre"]).Value,
|
Genre = ((IntPropertyData)data["ScoreGenre"]).Value,
|
||||||
Source = ((UInt32PropertyData)data["VersionNo"]).Value,
|
Source = ((UInt32PropertyData)data["VersionNo"]).Value,
|
||||||
|
BpmMessage = data["Bpm"].ToString()!,
|
||||||
PreviewTime = previewBegin,
|
PreviewTime = previewBegin,
|
||||||
PreviewLen = previewLen,
|
PreviewLen = previewLen,
|
||||||
Jacket = File.Exists(jacketPath) ? jacketPath : null,
|
Jacket = File.Exists(jacketPath) ? jacketPath : null,
|
||||||
Copyright = (cTxt == "-" || cTxt == "") ? null : cTxt,
|
Copyright = (cTxt == "-" || cTxt == "") ? null : cTxt,
|
||||||
|
assetData = data,
|
||||||
};
|
};
|
||||||
|
|
||||||
foreach (Difficulty diff in Enum.GetValues(typeof(Difficulty)))
|
foreach (Difficulty diff in Enum.GetValues(typeof(Difficulty)))
|
||||||
@@ -70,7 +72,7 @@ public static class Database
|
|||||||
if (lvl == 0) continue; // skip nonexistent level
|
if (lvl == 0) continue; // skip nonexistent level
|
||||||
|
|
||||||
// check chart existence
|
// check chart existence
|
||||||
var chartFilePath = Path.Combine(dataPath, "MusicData", song.Id, $"{song.Id}_{Consts.DIFF_FILENAME_PREPEND[diff]}.mer");
|
var chartFilePath = Path.Combine(dataPath, "MusicData", song.Id, $"{song.Id}_{Consts.DIFF_FILENAME_APPEND[diff]}.mer");
|
||||||
if (!File.Exists(chartFilePath))
|
if (!File.Exists(chartFilePath))
|
||||||
{
|
{
|
||||||
// TODO: add warning message to DataScan
|
// TODO: add warning message to DataScan
|
||||||
@@ -78,8 +80,7 @@ public static class Database
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: check audio existence; add warning but don't skip
|
// TODO: check audio existence; add warning but don't skip if missing
|
||||||
|
|
||||||
song.Levels[(int)diff] = (lvl, data[Consts.DIFF_DESIGNER_KEY[diff]].ToString()!);
|
song.Levels[(int)diff] = (lvl, data[Consts.DIFF_DESIGNER_KEY[diff]].ToString()!);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,28 +93,4 @@ public static class Database
|
|||||||
}
|
}
|
||||||
Console.WriteLine("finished music table");
|
Console.WriteLine("finished music table");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static (Entry, Chart)? GetDiffPair(string dataPath, StructPropertyData song, Difficulty diff)
|
|
||||||
{
|
|
||||||
var level = ((FloatPropertyData)song[Consts.DIFF_LVL_KEY[diff]]).Value;
|
|
||||||
if (level == 0)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
var id = song["AssetDirectory"].ToString()!;
|
|
||||||
var chartFilePath = Path.Combine(dataPath, "MusicData", id, $"{id}_{Consts.DIFF_FILENAME_PREPEND[diff]}.mer");
|
|
||||||
var clearThreshold = ((FloatPropertyData)song[Consts.DIFF_CLEAR_KEY[diff]]).Value;
|
|
||||||
|
|
||||||
var e = NotationSerializer.ToEntry(chartFilePath, new NotationReadArgs
|
|
||||||
{
|
|
||||||
InferClearThresholdFromDifficulty = false
|
|
||||||
});
|
|
||||||
e.ClearThreshold = clearThreshold;
|
|
||||||
e.Difficulty = diff;
|
|
||||||
var c = NotationSerializer.ToChart(chartFilePath, new NotationReadArgs
|
|
||||||
{
|
|
||||||
InferClearThresholdFromDifficulty = false
|
|
||||||
});
|
|
||||||
|
|
||||||
return (e, c);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -41,14 +41,14 @@ public static class Consts
|
|||||||
};
|
};
|
||||||
public static readonly IReadOnlyDictionary<Difficulty, string> DIFF_LVL_KEY = _DIFF_LVL_KEY;
|
public static readonly IReadOnlyDictionary<Difficulty, string> DIFF_LVL_KEY = _DIFF_LVL_KEY;
|
||||||
|
|
||||||
private static readonly Dictionary<Difficulty, string> _DIFF_FILENAME_PREPEND = new()
|
private static readonly Dictionary<Difficulty, string> _DIFF_FILENAME_APPEND = new()
|
||||||
{
|
{
|
||||||
{Difficulty.Normal, "00"},
|
{Difficulty.Normal, "00"},
|
||||||
{Difficulty.Hard, "01"},
|
{Difficulty.Hard, "01"},
|
||||||
{Difficulty.Expert, "02"},
|
{Difficulty.Expert, "02"},
|
||||||
{Difficulty.Inferno, "03"},
|
{Difficulty.Inferno, "03"},
|
||||||
};
|
};
|
||||||
public static readonly IReadOnlyDictionary<Difficulty, string> DIFF_FILENAME_PREPEND = _DIFF_FILENAME_PREPEND;
|
public static readonly IReadOnlyDictionary<Difficulty, string> DIFF_FILENAME_APPEND = _DIFF_FILENAME_APPEND;
|
||||||
|
|
||||||
private static readonly Dictionary<Difficulty, string> _DIFF_CLEAR_KEY = new()
|
private static readonly Dictionary<Difficulty, string> _DIFF_CLEAR_KEY = new()
|
||||||
{
|
{
|
||||||
|
|||||||
+81
-2
@@ -1,8 +1,13 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Media;
|
using Avalonia.Media;
|
||||||
using SaturnData.Notation.Core;
|
using SaturnData.Notation.Core;
|
||||||
|
using SaturnData.Notation.Serialization;
|
||||||
|
using UAssetAPI.PropertyTypes.Objects;
|
||||||
|
using UAssetAPI.PropertyTypes.Structs;
|
||||||
|
|
||||||
namespace MercuryConverter.Data;
|
namespace MercuryConverter.Data;
|
||||||
|
|
||||||
@@ -16,15 +21,89 @@ public class Song
|
|||||||
public required string Artist { get; set; }
|
public required string Artist { get; set; }
|
||||||
public required uint Source { get; set; }
|
public required uint Source { get; set; }
|
||||||
public required string Rubi { get; set; }
|
public required string Rubi { get; set; }
|
||||||
|
public required string BpmMessage { get; set; }
|
||||||
public string? Copyright { get; set; } // May have never been used?
|
public string? Copyright { get; set; } // May have never been used?
|
||||||
public required int Genre { get; set; }
|
public required int Genre { get; set; }
|
||||||
public required string? Jacket { get; set; }
|
public required string? Jacket { get; set; }
|
||||||
public required float PreviewTime { get; set; }
|
public required float PreviewTime { get; set; }
|
||||||
public required float PreviewLen { get; set; }
|
public required float PreviewLen { get; set; }
|
||||||
public string SourceName => Consts.NUM_SOURCE[Source];
|
public string SourceName => Consts.NUM_SOURCE[Source];
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Pairs of level and chart designer.
|
||||||
|
/// </summary>
|
||||||
public (float, string)?[] Levels { get; set; } = { null, null, null, null };
|
public (float, string)?[] Levels { get; set; } = { null, null, null, null };
|
||||||
|
public required StructPropertyData assetData;
|
||||||
|
/**
|
||||||
|
========= Setting Background =========
|
||||||
|
By default it's set to BackgroundOption.Auto which reacts to the difficulty:
|
||||||
|
Nrm/Hrd/Exp = Standard Reverse (will be replaced by standard saturn bg once i make that)
|
||||||
|
|
||||||
|
For Inferno, always set the background to BackgroundOption.Boss
|
||||||
|
|
||||||
|
For all other diffs:
|
||||||
|
Source 1/2 should be BackgroundOption.Version1
|
||||||
|
|
||||||
|
Source 3/4 should be BackgroundOption.Version2
|
||||||
|
|
||||||
|
Source 5/Plus (whatever that is) should be BackgroundOption.Version3
|
||||||
|
|
||||||
|
|
||||||
// TODO: For SaturnData.Entry instances, use this Guid format:
|
========= Entry.Guid format =========
|
||||||
// MERCURY_[SONGID]_[DIFF] (each var is int)
|
MERCURY_[SONGID]_[DIFF] (each var is int)
|
||||||
|
*/
|
||||||
|
public IEnumerable<(Entry, Chart)> GetEntryCharts(string dataPath)
|
||||||
|
{
|
||||||
|
List<(Entry, Chart)> ret = new();
|
||||||
|
|
||||||
|
for (int i = 0; i < 4; ++i)
|
||||||
|
{
|
||||||
|
var l = Levels[i];
|
||||||
|
if (l == null) continue;
|
||||||
|
|
||||||
|
var diff = (Difficulty)i;
|
||||||
|
|
||||||
|
var chartFilePath = Path.Combine(dataPath, "MusicData", Id, $"{Id}_{Consts.DIFF_FILENAME_APPEND[diff]}.mer");
|
||||||
|
var clearThreshold = ((FloatPropertyData)assetData[Consts.DIFF_CLEAR_KEY[diff]]).Value;
|
||||||
|
|
||||||
|
var e = NotationSerializer.ToEntry(chartFilePath, new NotationReadArgs
|
||||||
|
{
|
||||||
|
InferClearThresholdFromDifficulty = false,
|
||||||
|
});
|
||||||
|
e.Title = Name;
|
||||||
|
e.Reading = Rubi;
|
||||||
|
e.Artist = Artist;
|
||||||
|
e.BpmMessage = BpmMessage;
|
||||||
|
e.PreviewBegin = PreviewTime;
|
||||||
|
e.PreviewLength = PreviewLen;
|
||||||
|
e.ClearThreshold = clearThreshold;
|
||||||
|
e.Difficulty = diff;
|
||||||
|
e.Level = l.Value.Item1;
|
||||||
|
e.NotesDesigner = l.Value.Item2;
|
||||||
|
e.JacketPath = Path.GetFileName(Jacket)!;
|
||||||
|
|
||||||
|
// TODO: video
|
||||||
|
|
||||||
|
var uid = ((UInt32PropertyData)assetData["UniqueID"]).Value;
|
||||||
|
e.Guid = $"MERCURY_{uid}_0{(int)diff}";
|
||||||
|
|
||||||
|
if (new List<uint> { 1, 2 }.Contains(Source))
|
||||||
|
{
|
||||||
|
e.Background = BackgroundOption.Version1;
|
||||||
|
}
|
||||||
|
else if (new List<uint> { 3, 4 }.Contains(Source))
|
||||||
|
{
|
||||||
|
e.Background = BackgroundOption.Version2;
|
||||||
|
}
|
||||||
|
else if (Source == 5)
|
||||||
|
{
|
||||||
|
e.Background = BackgroundOption.Version3;
|
||||||
|
}
|
||||||
|
|
||||||
|
var c = NotationSerializer.ToChart(chartFilePath, new NotationReadArgs { });
|
||||||
|
ret.Add((e, c));
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user