diff --git a/Qwilight/Assets/Language.json b/Qwilight/Assets/Language.json index a76bc3e..23bc7e6 100644 --- a/Qwilight/Assets/Language.json +++ b/Qwilight/Assets/Language.json @@ -7,14 +7,6 @@ "ko-KR": "{0} 점 (+ {1} Point)", "en-US": "{0} Points (+ {1} Points)" }, - "AbilityUpContents": { - "ko-KR": "{0} 레이팅 {1} Point 얻음", - "en-US": "{0} Rating {1} Points earned" - }, - "AbilityUpMiniContents": { - "ko-KR": "{0} 레이팅 < 0.01 Point 얻음", - "en-US": "(0) Rating < 0.01 Point earned" - }, "AegisPostedItemText": { "ko-KR": "{0}의 {1}를 방어함", "en-US": "Defends {1} of {0}" diff --git a/Qwilight/JSON.cs b/Qwilight/JSON.cs index dc61260..9cca37f 100644 --- a/Qwilight/JSON.cs +++ b/Qwilight/JSON.cs @@ -219,6 +219,12 @@ public int avatarCount; } + public class TwilightLevelUp + { + public int from; + public int to; + } + public class TwilightAbilityUp { public Component.InputMode inputMode; @@ -233,7 +239,7 @@ Component.InputMode._9 => "9K", _ => string.Empty }; - return ability < 0.01 ? string.Format(LanguageSystem.Instance.AbilityUpMiniContents, inputModeText) : string.Format(LanguageSystem.Instance.AbilityUpContents, inputModeText, Math.Round(ability, 2)); + return ability < 0.01 ? $"{inputModeText} < 0.01 Point ↑" : $"{inputModeText} {Math.Round(ability, 2)} Point ↑"; } } diff --git a/Qwilight/NoteFile/BaseNoteFile.cs b/Qwilight/NoteFile/BaseNoteFile.cs index 471210e..6c22484 100644 --- a/Qwilight/NoteFile/BaseNoteFile.cs +++ b/Qwilight/NoteFile/BaseNoteFile.cs @@ -23,7 +23,7 @@ Level0, Level1, Level2, Level3, Level4, Level5 } - public static IEnumerable GetNoteFiles(string noteFilePath, DefaultEntryItem defaultEntryItem, EntryItem entryItem, int dataID) + public static BaseNoteFile[] GetNoteFiles(string noteFilePath, DefaultEntryItem defaultEntryItem, EntryItem entryItem, int dataID) { if (noteFilePath.IsTailCaselsss(".bmson")) { @@ -46,9 +46,11 @@ bool _wantNoteDrawing = true; bool _wantBannerDrawing = true; Handled _handledValue; - string _save128; - string _save256; - string _save512; + string _noteID128; + string _noteID256; + string _noteID512; + + public virtual int DataID => 0; public string FittedText { @@ -167,8 +169,6 @@ set => SetProperty(ref _judgmentMillisText[(int)Component.Judged.Lowest], value, nameof(LowestJudgmentMillisText)); } - public int DataID { get; set; } - public DateTime? LatestDate { get; set; } public int HandledCount { get; set; } @@ -235,48 +235,48 @@ public virtual string GetNoteID128(byte[] data = null) { - if (_save128 == null) + if (_noteID128 == null) { try { - _save128 = $"{Utility.GetID128s(data ?? GetContents())}:{DataID}"; + _noteID128 = $"{Utility.GetID128(data ?? GetContents())}:{DataID}"; } catch { - _save128 = string.Empty; + _noteID128 = string.Empty; } } - return _save128; + return _noteID128; } public virtual string GetNoteID256(byte[] data = null) { - if (_save256 == null) + if (_noteID256 == null) { try { - _save256 = $"{Utility.GetID256s(data ?? GetContents())}:{DataID}"; + _noteID256 = $"{Utility.GetID256(data ?? GetContents())}:{DataID}"; } catch { - _save256 = string.Empty; + _noteID256 = string.Empty; } } - return _save256; + return _noteID256; } public string GetNoteID512(byte[] data = null) { - if (_save512 == null) + if (_noteID512 == null) { SetNoteID512(null, data); } - return _save512; + return _noteID512; } void SetNoteID512(string noteID512 = null, byte[] data = null) { - _save512 = noteID512 ?? $"{GetNoteID512Impl(data)}:{DataID}"; + _noteID512 = noteID512 ?? $"{GetNoteID512Impl(data)}:{DataID}"; FavoriteEntryItems.Clear(); foreach (var favoriteEntryItem in DB.Instance.GetFavoriteEntryItems(this)) { @@ -290,7 +290,7 @@ { try { - return Utility.GetID512s(data ?? GetContents()); + return Utility.GetID512(data ?? GetContents()); } catch { @@ -312,8 +312,8 @@ public void SetNoteIDs(string noteID128, string noteID256, string noteID512) { - _save128 = noteID128; - _save256 = noteID256; + _noteID128 = noteID128; + _noteID256 = noteID256; SetNoteID512(noteID512); } diff --git a/Qwilight/NoteFile/PMSFile.cs b/Qwilight/NoteFile/PMSFile.cs index 16debfc..bcb9f0f 100644 --- a/Qwilight/NoteFile/PMSFile.cs +++ b/Qwilight/NoteFile/PMSFile.cs @@ -4,6 +4,8 @@ { public sealed class PMSFile : BMSFile { + public override int DataID => 1; + public PMSFile(string noteFilePath, DefaultEntryItem defaultEntryItem, EntryItem entryItem) : base(noteFilePath, defaultEntryItem, entryItem) { } diff --git a/Qwilight/QwilightComponent.cs b/Qwilight/QwilightComponent.cs index f0cd247..acbb7bf 100644 --- a/Qwilight/QwilightComponent.cs +++ b/Qwilight/QwilightComponent.cs @@ -50,7 +50,7 @@ public static readonly string[] AudioFileFormats = new[] { ".aif", ".aiff", ".asf", ".flac", ".m4a", ".mid", ".midi", ".mp2", ".mp3", ".ogg", ".opus", ".raw", ".wav", ".wma" }; public static readonly string[] DrawingFileFormats = new[] { ".bmp", ".gif", ".jpeg", ".jpg", ".png" }; public static readonly string[] MediaFileFormats = new[] { ".avi", ".flv", ".m1v", ".mkv", ".mov", ".mp4", ".mpeg", ".mpg", ".wmv" }; - public static readonly string HashText = Utility.GetID512s(File.ReadAllBytes(Path.Combine(AppContext.BaseDirectory, "Qwilight.dll"))); + public static readonly string HashText = Utility.GetID512(File.ReadAllBytes(Path.Combine(AppContext.BaseDirectory, "Qwilight.dll"))); public static readonly Version Date = Assembly.GetEntryAssembly().GetName().Version; public static readonly string DateText = $"{Date.Major}.{Date.Minor}.{Date.Build}"; public static readonly JSON.AssetClient AssetsClientJSON; diff --git a/Qwilight/System/AudioSystem/AudioSystem.cs b/Qwilight/System/AudioSystem/AudioSystem.cs index db7f8b4..93ad2e0 100644 --- a/Qwilight/System/AudioSystem/AudioSystem.cs +++ b/Qwilight/System/AudioSystem/AudioSystem.cs @@ -905,7 +905,7 @@ public AudioItem Load(Stream s, IAudioContainer audioContainer, float audioVolume, string bmsID = null, bool isLooping = false) { - var hash = Utility.GetID128s(s); + var hash = Utility.GetID128(s); var audioItem = new AudioItem(); if (audioContainer != null && _audioMap.TryGetValue(audioContainer, out var audioItems) && audioItems.TryGetValue(hash, out audioItem)) { @@ -1246,7 +1246,7 @@ public void HandleImmediately(string audioFilePath, IAudioContainer audioContainer, IAudioHandler audioHandler) { var rms = PoolSystem.Instance.GetDataFlow(File.ReadAllBytes(audioFilePath)); - var hash = Utility.GetID128s(rms); + var hash = Utility.GetID128(rms); rms.Position = 0; var audioInfo = new CREATESOUNDEXINFO { diff --git a/Qwilight/System/BaseUI/BaseUI.cs b/Qwilight/System/BaseUI/BaseUI.cs index 1576e18..9a76a38 100644 --- a/Qwilight/System/BaseUI/BaseUI.cs +++ b/Qwilight/System/BaseUI/BaseUI.cs @@ -1350,7 +1350,7 @@ { using (rms) { - var hash = Utility.GetID128s(rms); + var hash = Utility.GetID128(rms); var hashMediaFilePath = Path.Combine(QwilightComponent.MediaEntryPath, $"{hash}{Path.GetExtension(fileName)}"); if (!File.Exists(hashMediaFilePath)) { diff --git a/Qwilight/System/Configure/Configure.cs b/Qwilight/System/Configure/Configure.cs index ec9f535..bbda832 100644 --- a/Qwilight/System/Configure/Configure.cs +++ b/Qwilight/System/Configure/Configure.cs @@ -86,10 +86,7 @@ public Configure() { - using (var hashComputer = SHA256.Create()) - { - _aesCipher = Utility.GetID256(Encoding.UTF8.GetBytes(Environment.MachineName)); - } + _aesCipher = SHA256.HashData(Encoding.UTF8.GetBytes(Environment.MachineName)); SystemEvents.DisplaySettingsChanged += (sender, e) => OnSetAutoNVLLFramerate(); } diff --git a/Qwilight/System/DrawingSystem/DrawingSystem.cs b/Qwilight/System/DrawingSystem/DrawingSystem.cs index 8dd1d01..50be5e6 100644 --- a/Qwilight/System/DrawingSystem/DrawingSystem.cs +++ b/Qwilight/System/DrawingSystem/DrawingSystem.cs @@ -3111,7 +3111,7 @@ public DrawingItem Load(Stream s, IDrawingContainer drawingContainer, bool setAverage = false) { s.Position = 0; - var hash = Utility.GetID128s(s); + var hash = Utility.GetID128(s); if (drawingContainer != null && _drawingMap.TryGetValue(drawingContainer, out var drawingItems) && drawingItems.TryGetValue(hash, out var drawingItem)) { return drawingItem; @@ -3131,7 +3131,7 @@ public DrawingItem LoadBMS(string drawingFilePath, IDrawingContainer drawingContainer) { using var fs = File.OpenRead(drawingFilePath); - var hash = $"@{Utility.GetID128s(fs)}"; + var hash = $"@{Utility.GetID128(fs)}"; if (_drawingMap.TryGetValue(drawingContainer, out var drawingItems) && drawingItems.TryGetValue(hash, out var drawingItem)) { return drawingItem; @@ -3266,7 +3266,7 @@ { if (drawingContainer != null) { - var hash = Utility.GetID128s(s); + var hash = Utility.GetID128(s); if (_defaultDrawingMap.TryGetValue(drawingContainer, out var defaultDrawings) && defaultDrawings.TryGetValue(hash, out var defaultDrawing)) { return defaultDrawing; @@ -3290,7 +3290,7 @@ using var fs = File.OpenRead(drawingFilePath); if (drawingContainer != null) { - var hash = $"@{Utility.GetID128s(fs)}"; + var hash = $"@{Utility.GetID128(fs)}"; if (_defaultDrawingMap.TryGetValue(drawingContainer, out var defaultDrawings) && defaultDrawings.TryGetValue(hash, out var defaultDrawing)) { return defaultDrawing; diff --git a/Qwilight/System/FastDB/FastDB.cs b/Qwilight/System/FastDB/FastDB.cs index 29a67ac..fcd941e 100644 --- a/Qwilight/System/FastDB/FastDB.cs +++ b/Qwilight/System/FastDB/FastDB.cs @@ -173,15 +173,15 @@ _fastEntryItems.Remove(entryPath, out _); } - public void SetEntryItem(string entryPath, BaseNoteFile noteFile, int dataIDCount) + public void SetEntryItem(string entryPath, BaseNoteFile noteFile, int[] dataIDs) { - _fastEntryItems.GetOrAdd(entryPath, New>).Add(new FastEntryItem + _fastEntryItems.GetOrAdd(entryPath, entryPath => new()).Add(new FastEntryItem { noteFilePath = noteFile?.NoteFilePath, noteID128 = noteFile?.GetNoteID128(), noteID256 = noteFile?.GetNoteID256(), noteID512 = noteFile?.GetNoteID512(), - dataIDCount = dataIDCount, + dataIDs = dataIDs, }); } @@ -209,7 +209,7 @@ public void SetDefaultEntryItem(string defaultEntryPath, string entryPath) { - _fastDefaultEntryItems.GetOrAdd(defaultEntryPath, New>).Add(entryPath); + _fastDefaultEntryItems.GetOrAdd(defaultEntryPath, defaultEntryPath => new()).Add(entryPath); } public DateTime GetDefaultEntryItemDate(string defaultEntryPath) @@ -229,8 +229,6 @@ _fastDefaultEntryItemDates[defaultEntryPath] = date; } - static T New(string text) where T : new() => new T(); - public void Clear() { _fastNoteFiles.Clear(); diff --git a/Qwilight/System/FastDB/FastEntryItem.cs b/Qwilight/System/FastDB/FastEntryItem.cs index 7445977..73d5c33 100644 --- a/Qwilight/System/FastDB/FastEntryItem.cs +++ b/Qwilight/System/FastDB/FastEntryItem.cs @@ -6,6 +6,10 @@ public string noteID128; public string noteID256; public string noteID512; - public int dataIDCount; + public IList dataIDs = Array.Empty(); + + public FastEntryItem() + { + } } } diff --git a/Qwilight/System/FlintSystem.cs b/Qwilight/System/FlintSystem.cs index 25cd8fc..f21bd4a 100644 --- a/Qwilight/System/FlintSystem.cs +++ b/Qwilight/System/FlintSystem.cs @@ -56,7 +56,7 @@ } else { - mainViewModel.FlintNoteFile(noteFilePath, m); + mainViewModel.FlintNoteFile(noteFilePath, -1, m); } } }); diff --git a/Qwilight/System/LanguageSystem/LanguageSystem.g.cs b/Qwilight/System/LanguageSystem/LanguageSystem.g.cs index 075b247..e603632 100644 --- a/Qwilight/System/LanguageSystem/LanguageSystem.g.cs +++ b/Qwilight/System/LanguageSystem/LanguageSystem.g.cs @@ -4,8 +4,6 @@ { public string _4DModeContents { get; set; } public string AbilityStandContents { get; set; } - public string AbilityUpContents { get; set; } - public string AbilityUpMiniContents { get; set; } public string AegisPostedItemText { get; set; } public string AllowEssentialInputs { get; set; } public string AllowTotalLevyingText { get; set; } diff --git a/Qwilight/System/MediaSystem/MediaSystem.cs b/Qwilight/System/MediaSystem/MediaSystem.cs index 9c2d1c5..1792706 100644 --- a/Qwilight/System/MediaSystem/MediaSystem.cs +++ b/Qwilight/System/MediaSystem/MediaSystem.cs @@ -89,7 +89,7 @@ public HandledMediaItem Load(string mediaFilePath, IMediaContainer mediaContainer, bool isLooping) { var isCounterWave = mediaContainer.IsCounterWave; - var hash = $"{(isCounterWave ? '@' : string.Empty)}{Utility.GetID128s(File.ReadAllBytes(mediaFilePath))}"; + var hash = $"{(isCounterWave ? '@' : string.Empty)}{Utility.GetID128(File.ReadAllBytes(mediaFilePath))}"; if (_mediaMap.TryGetValue(mediaContainer, out var handledMediaItems) && handledMediaItems.TryGetValue(hash, out var handledMediaItem)) { return handledMediaItem; diff --git a/Qwilight/System/TwilightSystem.cs b/Qwilight/System/TwilightSystem.cs index ff2d727..0e0a418 100644 --- a/Qwilight/System/TwilightSystem.cs +++ b/Qwilight/System/TwilightSystem.cs @@ -342,7 +342,8 @@ NotifySystem.Instance.Notify(NotifySystem.NotifyVariety.OK, NotifySystem.NotifyConfigure.Default, eventItemText); break; case Event.Types.EventID.LevelUp: - Utility.HandleUIAudio("Level Up"); + var twilightLevelUp = Utility.GetJSON(eventItemText); + NotifySystem.Instance.Notify(NotifySystem.NotifyVariety.OK, NotifySystem.NotifyConfigure.Default, $"LV. {twilightLevelUp.from} → LV. {twilightLevelUp.to}", true, "Level Up"); BaseUI.Instance.HandleEvent(BaseUI.EventItem.LevelUp); break; case Event.Types.EventID.AbilityUp: diff --git a/Qwilight/Utilities/IDUtility.cs b/Qwilight/Utilities/IDUtility.cs index a0e4cbd..b14785e 100644 --- a/Qwilight/Utilities/IDUtility.cs +++ b/Qwilight/Utilities/IDUtility.cs @@ -5,35 +5,18 @@ { public static partial class Utility { - public static byte[] GetID512(byte[] data) - { - using var shaComputer = SHA512.Create(); - return shaComputer.ComputeHash(data); - } + public static string GetID512(byte[] data) => ModifyID(SHA512.HashData(data)); - public static string GetID512s(byte[] data) => ModifyID(GetID512(data)); + public static string GetID256(byte[] data) => ModifyID(SHA256.HashData(data)); - public static byte[] GetID256(byte[] data) - { - using var shaComputer = SHA256.Create(); - return shaComputer.ComputeHash(data); - } - - public static string GetID256s(byte[] data) => ModifyID(GetID256(data)); - - public static string GetID128s(Stream s) + public static string GetID128(Stream s) { s.Position = 0; - using var hashComputer = MD5.Create(); - return ModifyID(hashComputer.ComputeHash(s)); + return ModifyID(MD5.HashData(s)); } - public static string GetID128s(byte[] data) - { - using var hashComputer = MD5.Create(); - return ModifyID(hashComputer.ComputeHash(data)); - } + public static string GetID128(byte[] data) => ModifyID(MD5.HashData(data)); - public static string ModifyID(byte[] hash) => BitConverter.ToString(hash).Replace("-", string.Empty).ToLowerInvariant(); + static string ModifyID(byte[] hash) => BitConverter.ToString(hash).Replace("-", string.Empty).ToLowerInvariant(); } } diff --git a/Qwilight/Utilities/IOUtility.cs b/Qwilight/Utilities/IOUtility.cs index b7851f6..766bfa1 100644 --- a/Qwilight/Utilities/IOUtility.cs +++ b/Qwilight/Utilities/IOUtility.cs @@ -51,7 +51,7 @@ using (var fs0 = File.OpenRead(src)) using (var fs1 = File.OpenRead(target)) { - if (Utility.GetID128s(fs0) == Utility.GetID128s(fs1)) + if (Utility.GetID128(fs0) == Utility.GetID128(fs1)) { return; } diff --git a/Qwilight/ViewModel/MainViewModel.cs b/Qwilight/ViewModel/MainViewModel.cs index 8923a02..a9a1be9 100644 --- a/Qwilight/ViewModel/MainViewModel.cs +++ b/Qwilight/ViewModel/MainViewModel.cs @@ -717,7 +717,7 @@ { if (QwilightComponent.NoteFileFormats.Any(format => filePath.IsTailCaselsss(format))) { - FlintNoteFile(filePath, 0); + FlintNoteFile(filePath, -1, 0); } else if (filePath.IsTailCaselsss(".zip")) { @@ -1997,7 +1997,7 @@ var noteID128 = fastEntryItem.noteID128; var noteID256 = fastEntryItem.noteID256; var noteID512 = fastEntryItem.noteID512; - for (var dataID = fastEntryItem.dataIDCount - 1; dataID >= 0; --dataID) + foreach (var dataID in fastEntryItem.dataIDs) { var entryItem = tmpEntryItem ?? NewEntryItem(); var noteFile = BaseNoteFile.GetNoteFiles(noteFilePath, defaultEntryItem, entryItem, dataID)?.Single(); @@ -2029,9 +2029,10 @@ foreach (var noteFilePath in Utility.GetFiles(entryPath).Where(noteFilePath => QwilightComponent.NoteFileFormats.Any(format => noteFilePath.IsTailCaselsss(format)))) { var entryItem = tmpEntryItem ?? NewEntryItem(); - var noteFiles = BaseNoteFile.GetNoteFiles(noteFilePath, defaultEntryItem, entryItem, -1)?.ToArray(); + var noteFiles = BaseNoteFile.GetNoteFiles(noteFilePath, defaultEntryItem, entryItem, -1); if (noteFiles != null) { + var dataIDs = noteFiles.Select(noteFile => noteFile.DataID).ToArray(); foreach (var noteFile in noteFiles) { try @@ -2052,14 +2053,14 @@ } finally { - FastDB.Instance.SetEntryItem(entryPath, noteFile, noteFiles.Length); + FastDB.Instance.SetEntryItem(entryPath, noteFile, dataIDs); } } } } if (targetNoteFiles.Count > 0) { - FastDB.Instance.SetEntryItem(entryPath, null, 0); + FastDB.Instance.SetEntryItem(entryPath, null, Array.Empty()); } } if (targetNoteFiles.Count > 0) @@ -2361,12 +2362,12 @@ } } - public void FlintNoteFile(string noteFilePath, int levyingMeter) + public void FlintNoteFile(string noteFilePath, int dataID, int levyingMeter) { var targetNoteFile = BaseNoteFile.GetNoteFiles(noteFilePath, null, new() { EntryPath = Path.GetDirectoryName(noteFilePath), - }, -1).Single(); + }, dataID).Single(); if (targetNoteFile != null) { targetNoteFile.SetData(Environment.TickCount); diff --git a/Test/Compiler/CompilerTest.cs b/Test/Compiler/CompilerTest.cs index 4f24fa9..84e3e81 100644 --- a/Test/Compiler/CompilerTest.cs +++ b/Test/Compiler/CompilerTest.cs @@ -22,7 +22,7 @@ { DefaultEntryItem = defaultEntryItem, EntryPath = Path.GetDirectoryName(noteFilePath) - }, -1)).ToArray(), noteFile => + }, -1)), noteFile => { var targetCompiler = BaseCompiler.GetCompiler(noteFile, null); var defaultComputer = new DefaultCompute(new[] { noteFile }, null, null, string.Empty, string.Empty)