diff --git a/Qwilight/Assets/Language.json b/Qwilight/Assets/Language.json index 1fe31e4..e6f7b8b 100644 --- a/Qwilight/Assets/Language.json +++ b/Qwilight/Assets/Language.json @@ -388,8 +388,8 @@ "en-US": "Recently played 50" }, "AvatarViewLevelVSText": { - "ko-KR": "비교 (Beta)", - "en-US": "Comparison (Beta)" + "ko-KR": "비교", + "en-US": "Comparison" }, "AvatarViewQuitContents": { "ko-KR": "랭크", @@ -3313,7 +3313,7 @@ }, "ViewQwilightEntry": { "ko-KR": "사용자 폴더 열기", - "en-US": "Open a user folder" + "en-US": "Open user folder" }, "ViewUIEntry": { "ko-KR": "스킨 폴더 열기", diff --git a/Qwilight/Compute/DefaultCompute.cs b/Qwilight/Compute/DefaultCompute.cs index a8ba512..a8fdc21 100644 --- a/Qwilight/Compute/DefaultCompute.cs +++ b/Qwilight/Compute/DefaultCompute.cs @@ -4117,6 +4117,8 @@ } } } + + DB.Instance.Save(true); } IsNewStand = Stand.TargetValue > _netItems.Where(netItem => !netItem.IsMyNetItem && netItem.AvatarID == AvatarID).DefaultIfEmpty().Max(netItem => netItem?.StandValue ?? 0); diff --git a/Qwilight/Compute/FlintCompute.cs b/Qwilight/Compute/FlintCompute.cs index 9641b34..7bedff2 100644 --- a/Qwilight/Compute/FlintCompute.cs +++ b/Qwilight/Compute/FlintCompute.cs @@ -15,10 +15,10 @@ { Close(); var mainViewModel = ViewModels.Instance.MainValue; - var entryItemValue = mainViewModel.EntryItemValue; - if (entryItemValue != null) + var entryItem = mainViewModel.EntryItemValue; + if (entryItem != null) { - mainViewModel.LoadEntryItem(entryItemValue.DefaultEntryItem, entryItemValue.EntryPath); + mainViewModel.LoadEntryItem(entryItem.DefaultEntryItem, entryItem.EntryPath); } } } diff --git a/Qwilight/System/Configure/Configure.cs b/Qwilight/System/Configure/Configure.cs index 24278f5..d5758e6 100644 --- a/Qwilight/System/Configure/Configure.cs +++ b/Qwilight/System/Configure/Configure.cs @@ -158,6 +158,7 @@ } } + readonly object _setSaveCSX = new(); readonly byte[] _aesCipher; readonly byte[] _aesIV = new byte[16]; readonly double[] _vibrations = new double[4]; @@ -2246,14 +2247,29 @@ public int NetItemCount { get; set; } - public void Save() + public void Save(bool isParallel) { - ModeComponentValue = ViewModels.Instance.MainValue.ModeComponentValue; + if (isParallel) + { + Task.Run(SaveImpl); + } + else + { + SaveImpl(); + } - Utility.CopyFile(_fileName, _tmp0FileName); - Utility.MoveFile(_tmp0FileName, _tmp1FileName); - File.WriteAllText(_fileName, Utility.SetJSON(this, _defaultJSONConfigure), Encoding.UTF8); - Utility.WipeFile(_tmp1FileName); + void SaveImpl() + { + lock (_setSaveCSX) + { + ModeComponentValue = ViewModels.Instance.MainValue.ModeComponentValue; + + Utility.CopyFile(_fileName, _tmp0FileName); + Utility.MoveFile(_tmp0FileName, _tmp1FileName); + File.WriteAllText(_fileName, Utility.SetJSON(this, _defaultJSONConfigure), Encoding.UTF8); + Utility.WipeFile(_tmp1FileName); + } + } } public void Validate(bool isInit) diff --git a/Qwilight/System/Configure/GPUConfigure.cs b/Qwilight/System/Configure/GPUConfigure.cs index 77e5649..6010812 100644 --- a/Qwilight/System/Configure/GPUConfigure.cs +++ b/Qwilight/System/Configure/GPUConfigure.cs @@ -26,6 +26,8 @@ static readonly string _tmp0FileName = Path.ChangeExtension(_fileName, ".json.tmp.0"); static readonly string _tmp1FileName = Path.ChangeExtension(_fileName, ".json.tmp.1"); + readonly object _setSaveCSX = new(); + public void Load() { Utility.WipeFile(_tmp0FileName); @@ -66,12 +68,27 @@ [JsonIgnore] public string GPUConfigureFault { get; set; } - public void Save() + public void Save(bool isParallel) { - Utility.CopyFile(_fileName, _tmp0FileName); - Utility.MoveFile(_tmp0FileName, _tmp1FileName); - File.WriteAllText(_fileName, Utility.SetJSON(this, _defaultJSONConfigure), Encoding.UTF8); - Utility.WipeFile(_tmp1FileName); + if (isParallel) + { + Task.Run(SaveImpl); + } + else + { + SaveImpl(); + } + + void SaveImpl() + { + lock (_setSaveCSX) + { + Utility.CopyFile(_fileName, _tmp0FileName); + Utility.MoveFile(_tmp0FileName, _tmp1FileName); + File.WriteAllText(_fileName, Utility.SetJSON(this, _defaultJSONConfigure), Encoding.UTF8); + Utility.WipeFile(_tmp1FileName); + } + } } public void Validate(bool isInit) diff --git a/Qwilight/System/DB.cs b/Qwilight/System/DB.cs index 296b7e3..c63f746 100644 --- a/Qwilight/System/DB.cs +++ b/Qwilight/System/DB.cs @@ -7,6 +7,7 @@ using System.Data.SQLite; using System.IO; using System.Security.Cryptography; +using System.Text; namespace Qwilight { @@ -30,6 +31,7 @@ public static readonly DB Instance = QwilightComponent.GetBuiltInData(nameof(DB)); + readonly object _setSaveCSX = new(); SQLiteConnection _fastDB; SQLiteConnection _fileDB; @@ -672,7 +674,7 @@ INTO event_note_data VALUES(@noteID, @noteVariety, @title, @artist, @level, @levelText, @genre) """); - dbStatement.Parameters.AddWithValue("noteID", wwwLevelComputingValue.NoteID); + dbStatement.Parameters.AddWithValue("noteID", wwwLevelComputingValue.GetNoteID512()); dbStatement.Parameters.AddWithValue("noteVariety", noteVariety); dbStatement.Parameters.AddWithValue("title", wwwLevelComputingValue.Title); dbStatement.Parameters.AddWithValue("artist", wwwLevelComputingValue.Artist); @@ -1123,12 +1125,27 @@ return new(text, _fastDB, ta); } - public void Save() + public void Save(bool isParallel) { - Utility.CopyFile(_fileName, _tmp0FileName); - Utility.MoveFile(_tmp0FileName, _tmp1FileName); - _fastDB.BackupDatabase(_fileDB, _fileDB.Database, _fastDB.Database, -1, null, -1); - Utility.WipeFile(_tmp1FileName); + if (isParallel) + { + Task.Run(SaveImpl); + } + else + { + SaveImpl(); + } + + void SaveImpl() + { + lock (_setSaveCSX) + { + Utility.CopyFile(_fileName, _tmp0FileName); + Utility.MoveFile(_tmp0FileName, _tmp1FileName); + _fastDB.BackupDatabase(_fileDB, _fileDB.Database, _fastDB.Database, -1, null, -1); + Utility.WipeFile(_tmp1FileName); + } + } } } } \ No newline at end of file diff --git a/Qwilight/System/TVSystem.cs b/Qwilight/System/TVSystem.cs index 912bf0c..f55a1c5 100644 --- a/Qwilight/System/TVSystem.cs +++ b/Qwilight/System/TVSystem.cs @@ -42,7 +42,7 @@ public bool TVAssists => TVAssist0 || TVAssist1; - bool IsAvailable => !ViewModels.Instance.MainValue.IsCaffeine; + bool IsAvailable => !ViewModels.Instance.MainValue.IsC8H10N4O2; public void HandleSystemIfAvailable() { diff --git a/Qwilight/System/TwilightSystem.cs b/Qwilight/System/TwilightSystem.cs index e30246a..094a33f 100644 --- a/Qwilight/System/TwilightSystem.cs +++ b/Qwilight/System/TwilightSystem.cs @@ -774,9 +774,9 @@ zipFile.Save(rms); break; case BundleItem.BundleVariety.Qwilight: - Configure.Instance.Save(); - GPUConfigure.Instance.Save(); - DB.Instance.Save(); + Configure.Instance.Save(false); + GPUConfigure.Instance.Save(false); + DB.Instance.Save(false); if (Directory.Exists(QwilightComponent.CommentEntryPath)) { zipFile.AddDirectory(QwilightComponent.CommentEntryPath, "Comment"); @@ -1573,7 +1573,7 @@ public async Task GetDefaultUIDate(long defaultUIDate, bool isSilent) { var twilightWwwDefaultDate = await GetWwwParallel($"{QwilightComponent.QwilightAPI}/defaultUIDate?date={defaultUIDate}").ConfigureAwait(false); - if (twilightWwwDefaultDate.HasValue && !ViewModels.Instance.MainValue.IsCaffeine) + if (twilightWwwDefaultDate.HasValue && !ViewModels.Instance.MainValue.IsC8H10N4O2) { var date = twilightWwwDefaultDate.Value.date; Configure.Instance.DefaultUIDate = date; diff --git a/Qwilight/View/AvatarWindow.xaml b/Qwilight/View/AvatarWindow.xaml index 85bc801..9370305 100644 --- a/Qwilight/View/AvatarWindow.xaml +++ b/Qwilight/View/AvatarWindow.xaml @@ -134,32 +134,28 @@ - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + @@ -178,7 +174,7 @@ - + diff --git a/Qwilight/View/AvatarWindow.xaml.cs b/Qwilight/View/AvatarWindow.xaml.cs index 723ab2e..d500742 100644 --- a/Qwilight/View/AvatarWindow.xaml.cs +++ b/Qwilight/View/AvatarWindow.xaml.cs @@ -1,4 +1,5 @@ using Qwilight.Utilities; +using Qwilight.ViewModel; using System.Windows; using System.Windows.Input; @@ -15,5 +16,10 @@ Utility.ViewItems(sender as FrameworkElement); } } + + void OnLevyNoteFile(object sender, MouseButtonEventArgs e) + { + ((sender as FrameworkElement).DataContext as AvatarViewModel.AvatarComputing).OnLevyNoteFile(e); + } } } \ No newline at end of file diff --git a/Qwilight/View/MainWindow/DefaultMode/EntryView.xaml b/Qwilight/View/MainWindow/DefaultMode/EntryView.xaml index 93c7772..178b895 100644 --- a/Qwilight/View/MainWindow/DefaultMode/EntryView.xaml +++ b/Qwilight/View/MainWindow/DefaultMode/EntryView.xaml @@ -46,7 +46,7 @@ - + diff --git a/Qwilight/View/WwwLevelWindow.xaml b/Qwilight/View/WwwLevelWindow.xaml index 403aeb8..87ee55d 100644 --- a/Qwilight/View/WwwLevelWindow.xaml +++ b/Qwilight/View/WwwLevelWindow.xaml @@ -87,7 +87,7 @@ - + diff --git a/Qwilight/ViewModel/AvatarViewModel.cs b/Qwilight/ViewModel/AvatarViewModel.cs index d50b126..9fcfe56 100644 --- a/Qwilight/ViewModel/AvatarViewModel.cs +++ b/Qwilight/ViewModel/AvatarViewModel.cs @@ -6,6 +6,7 @@ using Qwilight.Utilities; using System.Collections.ObjectModel; using System.Windows; +using System.Windows.Input; using System.Windows.Media; namespace Qwilight.ViewModel @@ -24,13 +25,24 @@ { } - public new string FittedText { get; init; } + public new void OnLevyNoteFile(MouseButtonEventArgs e) + { + if (e.ClickCount >= 2) + { + var mainViewModel = ViewModels.Instance.MainValue; + if (mainViewModel.NoteID512s.TryGetValue(GetNoteID512(), out var noteFile)) + { + mainViewModel.HandleLevyNoteFile(noteFile); + } + } + } public bool HaveIt { get; } - public AvatarComputing(JSON.Computing data) : base(null, null, null) + public AvatarComputing(JSON.Computing data) : base(ViewModels.Instance.MainValue.NoteID512s.GetValueOrDefault(data.noteID)?.NoteFilePath, ViewModels.Instance.MainValue.NoteID512s.GetValueOrDefault(data.noteID)?.DefaultEntryItem, ViewModels.Instance.MainValue.NoteID512s.GetValueOrDefault(data.noteID)?.EntryItem) { - HaveIt = ViewModels.Instance.MainValue.NoteID512s.TryGetValue(data.noteID, out var noteFile); + SetNoteIDs(null, null, data.noteID); + HaveIt = ViewModels.Instance.MainValue.NoteID512s.TryGetValue(GetNoteID512(), out var noteFile); if (HaveIt) { NoteVarietyValue = noteFile.NoteVarietyValue; diff --git a/Qwilight/ViewModel/BaseViewModel.cs b/Qwilight/ViewModel/BaseViewModel.cs index 137e152..10651a6 100644 --- a/Qwilight/ViewModel/BaseViewModel.cs +++ b/Qwilight/ViewModel/BaseViewModel.cs @@ -13,6 +13,7 @@ int _zValue; bool _isControlling; + bool _wasSilentlyClosed; public bool IsLoaded { get; set; } @@ -89,6 +90,24 @@ } } + public void CloseSilently() + { + if (IsOpened) + { + Close(false); + _wasSilentlyClosed = true; + } + } + + public void OpenSilently() + { + if (_wasSilentlyClosed) + { + Open(false); + _wasSilentlyClosed = false; + } + } + public void Toggle() { if (IsOpened) diff --git a/Qwilight/ViewModel/ConfigureViewModel.cs b/Qwilight/ViewModel/ConfigureViewModel.cs index 82b3a94..30c7d6f 100644 --- a/Qwilight/ViewModel/ConfigureViewModel.cs +++ b/Qwilight/ViewModel/ConfigureViewModel.cs @@ -1391,6 +1391,8 @@ public override void OnCollasped() { base.OnCollasped(); + Configure.Instance.Save(true); + GPUConfigure.Instance.Save(true); var mainViewModel = ViewModels.Instance.MainValue; mainViewModel.OnJudgmentMeterMillisModified(); mainViewModel.HandleAutoComputer(); diff --git a/Qwilight/ViewModel/LevelViewModel.cs b/Qwilight/ViewModel/LevelViewModel.cs index ae33f46..552eded 100644 --- a/Qwilight/ViewModel/LevelViewModel.cs +++ b/Qwilight/ViewModel/LevelViewModel.cs @@ -119,6 +119,7 @@ { base.OnCollasped(); Configure.Instance.WantLevelIDs = LevelItemCollection.Where(levelItem => levelItem.IsWanted).Select(levelItem => levelItem.LevelID).ToArray(); + Configure.Instance.Save(true); ViewModels.Instance.MainValue.Want(); } } diff --git a/Qwilight/ViewModel/MainViewModel.cs b/Qwilight/ViewModel/MainViewModel.cs index e139f15..85c367d 100644 --- a/Qwilight/ViewModel/MainViewModel.cs +++ b/Qwilight/ViewModel/MainViewModel.cs @@ -94,8 +94,6 @@ bool _isDefaultEntryLoading; bool _isInputWantPointed; bool _isTwilightCommentaryPointed; - bool _wasSiteContainerWindowOpened; - bool _wasCommentOpened; bool _isDefaultCommentLoading; bool _isTwilightCommentLoading; bool? _twilightCommentFavor; @@ -239,7 +237,7 @@ { IsVisible = !value }); - IsCaffeine = IsComputingMode && !value; + IsC8H10N4O2 = IsComputingMode && !value; ViewModels.Instance.NotifyWindowViewModels(); var handlingComputer = GetHandlingComputer(); if (handlingComputer != null) @@ -252,7 +250,7 @@ } } - public bool IsCaffeine { get; set; } + public bool IsC8H10N4O2 { get; set; } public bool HasPoint { get; set; } @@ -528,30 +526,14 @@ ViewModels.Instance.NotifyWindowViewModels(); BaseUI.Instance.InitEvents(); Configure.Instance.UIConfigureValue.NotifyInputMode(); - switch (value) + if (IsNoteFileMode) { - case Mode.NoteFile: - if (_wasSiteContainerWindowOpened) - { - ViewModels.Instance.SiteContainerValue.Open(false); - _wasSiteContainerWindowOpened = false; - } - if (_wasCommentOpened) - { - ViewModels.Instance.CommentValue.Open(false); - _wasCommentOpened = false; - } - NotifySystem.Instance.NotifyPending(); - break; - case Mode.Computing: - _wasSiteContainerWindowOpened = ViewModels.Instance.SiteContainerValue.IsOpened; - ViewModels.Instance.SiteContainerValue.Close(false); - ViewModels.Instance.NoteFileValue.Close(false); - break; - case Mode.Quit: - _wasCommentOpened = ViewModels.Instance.CommentValue.IsOpened; - ViewModels.Instance.CommentValue.Close(false); - break; + ViewModels.Instance.HandleSilentlyClosableViewModels(silentlyClosableViewModel => silentlyClosableViewModel.OpenSilently()); + NotifySystem.Instance.NotifyPending(); + } + else + { + ViewModels.Instance.HandleSilentlyClosableViewModels(silentlyClosableViewModel => silentlyClosableViewModel.CloseSilently()); } } } @@ -1525,13 +1507,13 @@ }; } - public void HandleLevyNoteFile(EntryItem entryItemValue = null, WwwLevelData wwwLevelDataValue = null, ModeComponent defaultModeComponentValue = null) + public void HandleLevyNoteFile(BaseNoteFile noteFile = null, WwwLevelData wwwLevelDataValue = null, ModeComponent defaultModeComponentValue = null) { - if (entryItemValue != null || HasNotInput()) + if (noteFile != null || HasNotInput()) { - entryItemValue ??= EntryItemValue; + noteFile ??= EntryItemValue?.NoteFile; - var onLevyNoteFile = entryItemValue?.NoteFile?.OnLevyNoteFile; + var onLevyNoteFile = noteFile?.OnLevyNoteFile; if (onLevyNoteFile != null) { onLevyNoteFile(); @@ -1544,29 +1526,28 @@ } else { - var isSaltNoteFile = entryItemValue?.NoteFile is SaltNoteFile; + var isSaltNoteFile = noteFile is SaltNoteFile; if (isSaltNoteFile) { SaltEntryView(); - entryItemValue = EntryItemValue; + noteFile = EntryItemValue?.NoteFile; } - if (entryItemValue != null) + if (noteFile != null) { - var eventNoteID = entryItemValue.EventNoteID; - var noteFiles = entryItemValue.NoteFiles; - var targetNoteFile = string.IsNullOrEmpty(eventNoteID) ? entryItemValue.NoteFile : noteFiles.First(); - if (string.IsNullOrEmpty(eventNoteID)) + var entryItem = noteFile.EntryItem; + if (string.IsNullOrEmpty(entryItem.EventNoteID)) { Utility.HandleUIAudio("Levy Note File"); IsCommentMode = false; - ModeComponentValue.ComputingValue = targetNoteFile; + ModeComponentValue.ComputingValue = noteFile; ModeComponentValue.CanModifyMultiplier = true; ModeComponentValue.CanModifyAudioMultiplier = true; - SetComputingMode(new(new[] { targetNoteFile }, null, defaultModeComponentValue, TwilightSystem.Instance.AvatarID, TwilightSystem.Instance.GetAvatarName(), wwwLevelDataValue, null, null, null)); + SetComputingMode(new(new[] { noteFile }, null, defaultModeComponentValue, TwilightSystem.Instance.AvatarID, TwilightSystem.Instance.GetAvatarName(), wwwLevelDataValue, null, null, null)); } else { + var noteFiles = entryItem.NoteFiles; if (noteFiles.Any(noteFile => string.IsNullOrEmpty(noteFile.NoteFilePath))) { NotifySystem.Instance.Notify(NotifySystem.NotifyVariety.Warning, NotifySystem.NotifyConfigure.Default, LanguageSystem.Instance.NotAvailableEventNoteFileFault); @@ -1575,10 +1556,10 @@ { Utility.HandleUIAudio("Levy Note File"); IsCommentMode = false; - ModeComponentValue.ComputingValue = targetNoteFile; + ModeComponentValue.ComputingValue = noteFiles.First(); ModeComponentValue.CanModifyMultiplier = true; ModeComponentValue.CanModifyAudioMultiplier = true; - SetComputingMode(new(noteFiles, null, defaultModeComponentValue, TwilightSystem.Instance.AvatarID, TwilightSystem.Instance.GetAvatarName(), wwwLevelDataValue, null, entryItemValue, null)); + SetComputingMode(new(noteFiles, null, defaultModeComponentValue, TwilightSystem.Instance.AvatarID, TwilightSystem.Instance.GetAvatarName(), wwwLevelDataValue, null, entryItem, null)); } } } @@ -1603,10 +1584,9 @@ ModeComponentValue.CopyAs(defaultModeComponentValue); } - Configure.Instance.Save(); - GPUConfigure.Instance.Save(); - DB.Instance.Save(); - FastDB.Instance.Save(); + Configure.Instance.Save(false); + GPUConfigure.Instance.Save(false); + DB.Instance.Save(false); AudioSystem.Instance.Dispose(); AudioInputSystem.Instance.Dispose(); diff --git a/Qwilight/ViewModel/SiteViewModel.cs b/Qwilight/ViewModel/SiteViewModel.cs index 063f291..aa05429 100644 --- a/Qwilight/ViewModel/SiteViewModel.cs +++ b/Qwilight/ViewModel/SiteViewModel.cs @@ -827,8 +827,8 @@ { if (IsNetSite && IsSiteHand) { - var entryItemValue = ViewModels.Instance.MainValue.EntryItemValue; - var noteFile = entryItemValue?.NoteFile; + var entryItem = ViewModels.Instance.MainValue.EntryItemValue; + var noteFile = entryItem?.NoteFile; if (noteFile?.IsLogical == false) { TwilightSystem.Instance.SendParallel(Event.Types.EventID.SetNoteFile, new diff --git a/Qwilight/ViewModel/SiteWindowViewModel.cs b/Qwilight/ViewModel/SiteWindowViewModel.cs index 2ccb68f..17e757c 100644 --- a/Qwilight/ViewModel/SiteWindowViewModel.cs +++ b/Qwilight/ViewModel/SiteWindowViewModel.cs @@ -30,8 +30,8 @@ static void OnNewNetSite() { var mainViewModel = ViewModels.Instance.MainValue; - var entryItemValue = mainViewModel.EntryItemValue; - var noteFile = entryItemValue?.NoteFile; + var entryItem = mainViewModel.EntryItemValue; + var noteFile = entryItem?.NoteFile; if (noteFile?.IsLogical == false) { var inputPwViewModel = ViewModels.Instance.InputPwValue; diff --git a/Qwilight/ViewModel/ViewModels.cs b/Qwilight/ViewModel/ViewModels.cs index 8a0679b..74250e8 100644 --- a/Qwilight/ViewModel/ViewModels.cs +++ b/Qwilight/ViewModel/ViewModels.cs @@ -10,6 +10,8 @@ public BaseViewModel[] WindowViewModels { get; } + public BaseViewModel[] SilentlyClosableViewModels { get; } + public MainViewModel MainValue { get; } = new(); public SignInViewModel SignInValue { get; } = new(); @@ -135,6 +137,7 @@ WantValue, LevelVoteValue }; + SilentlyClosableViewModels = WindowViewModels.Except(new[] { ConfigureValue }).ToArray(); } public void HandleSiteViewModels(Action onHandle) @@ -145,6 +148,14 @@ } } + public void HandleSilentlyClosableViewModels(Action onHandle) + { + foreach (var silentlyClosableViewModel in SilentlyClosableViewModels) + { + onHandle(silentlyClosableViewModel); + } + } + public void NotifyWindowViewModels() { foreach (var windowViewModel in WindowViewModels) diff --git a/Qwilight/ViewModel/WantViewModel.cs b/Qwilight/ViewModel/WantViewModel.cs index d762d45..3196bc7 100644 --- a/Qwilight/ViewModel/WantViewModel.cs +++ b/Qwilight/ViewModel/WantViewModel.cs @@ -312,6 +312,7 @@ public override void OnCollasped() { base.OnCollasped(); + Configure.Instance.Save(true); Configure.Instance.NotifyInputWantWindowPaint(); ViewModels.Instance.MainValue.Want(); } diff --git a/Qwilight/ViewModel/WwwLevelViewModel.cs b/Qwilight/ViewModel/WwwLevelViewModel.cs index 5508f02..3b68f6e 100644 --- a/Qwilight/ViewModel/WwwLevelViewModel.cs +++ b/Qwilight/ViewModel/WwwLevelViewModel.cs @@ -24,14 +24,12 @@ { } - public string NoteID { get; } - public bool HaveIt { get; } - public WwwLevelComputing(JSON.Computing data) : base(null, null, null) + public WwwLevelComputing(JSON.Computing data) : base(ViewModels.Instance.MainValue.NoteID512s.GetValueOrDefault(data.noteID)?.NoteFilePath, ViewModels.Instance.MainValue.NoteID512s.GetValueOrDefault(data.noteID)?.DefaultEntryItem, ViewModels.Instance.MainValue.NoteID512s.GetValueOrDefault(data.noteID)?.EntryItem) { - NoteID = data.noteID; - HaveIt = ViewModels.Instance.MainValue.NoteID512s.TryGetValue(NoteID, out var noteFile); + SetNoteIDs(null, null, data.noteID); + HaveIt = ViewModels.Instance.MainValue.NoteID512s.TryGetValue(GetNoteID512(), out var noteFile); if (HaveIt) { NoteVarietyValue = noteFile.NoteVarietyValue; @@ -99,18 +97,12 @@ try { DB.Instance.SetEventNoteData(WwwLevelComputingCollection); - if (WwwLevelItemValue != null) - { - var eventNoteName = WwwLevelItemValue.Title; - var date = DateTime.Now; - var eventNoteVariety = DB.EventNoteVariety.Qwilight; - DB.Instance.SetEventNote(GetEventNoteID(), eventNoteName, date, eventNoteVariety); - var mainViewModel = ViewModels.Instance.MainValue; - mainViewModel.LoadEventNoteEntryItems(); - mainViewModel.Want(); - NotifySystem.Instance.Notify(NotifySystem.NotifyVariety.OK, NotifySystem.NotifyConfigure.Default, LanguageSystem.Instance.OpenedEventNotes); - NotifyIsCompatible(); - } + DB.Instance.SetEventNote(GetEventNoteID(), WwwLevelItemValue.Title, DateTime.Now, DB.EventNoteVariety.Qwilight); + var mainViewModel = ViewModels.Instance.MainValue; + mainViewModel.LoadEventNoteEntryItems(); + OnPropertyChanged(nameof(HasEventNote)); + mainViewModel.Want(); + NotifySystem.Instance.Notify(NotifySystem.NotifyVariety.OK, NotifySystem.NotifyConfigure.Default, LanguageSystem.Instance.OpenedEventNotes); } catch (SQLiteException) { @@ -179,10 +171,10 @@ modeComponentValue.LowestJudgmentConditionModeValue = LowestJudgmentConditionModes.First().Value; } modeComponentValue.PutCopyNotesValueV2 = ModeComponent.PutCopyNotes.Default; - mainViewModel.HandleLevyNoteFile(mainViewModel.EventNoteEntryItems[GetEventNoteID()], _wwwLevelDataValue, defaultModeComponentValue); + mainViewModel.HandleLevyNoteFile(mainViewModel.EventNoteEntryItems[GetEventNoteID()].NoteFile, _wwwLevelDataValue, defaultModeComponentValue); } - string GetEventNoteID() => string.Join('/', WwwLevelComputingCollection.Select(wwwLevelComputing => wwwLevelComputing.NoteID)); + string GetEventNoteID() => string.Join('/', WwwLevelComputingCollection.Select(wwwLevelComputing => wwwLevelComputing.GetNoteID512())); public bool HasEventNote => ViewModels.Instance.MainValue.EventNoteEntryItems.ContainsKey(GetEventNoteID()); @@ -439,6 +431,7 @@ { WwwLevelComputingCollection.Add(new(data)); } + OnPropertyChanged(nameof(HasEventNote)); AutoModes.Clear(); if (twilightWwwLevelValue.autoMode != null) @@ -720,7 +713,6 @@ OnPropertyChanged(nameof(IsWaveModeCompatible)); OnPropertyChanged(nameof(IsSetNoteModeCompatible)); OnPropertyChanged(nameof(IsLowestJudgmentConditionModeCompatible)); - OnPropertyChanged(nameof(HasEventNote)); } public bool IsLevelNameLoading