diff --git a/Qwilight/Assets/UI/Default/Default.zip b/Qwilight/Assets/UI/Default/Default.zip index 734341e..433f6e8 100644 --- a/Qwilight/Assets/UI/Default/Default.zip +++ b/Qwilight/Assets/UI/Default/Default.zip @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3ac7620da936b2776da288f97c51b2891e6241e44bce9e6833a44f8baeae6d75 -size 25561698 +oid sha256:4af75836a116684b7bdba7b099248244b7927b073328560e8a5aa181b1adb895 +size 16896776 diff --git a/Qwilight/AvatarWww.cs b/Qwilight/AvatarWww.cs index 149b66b..0324ff8 100644 --- a/Qwilight/AvatarWww.cs +++ b/Qwilight/AvatarWww.cs @@ -26,8 +26,7 @@ { _wantAvatarDrawing = false; - _ = Awaitable(); - async Task Awaitable() => SetProperty(ref _avatarDrawing, (await AvatarDrawingSystem.Instance.GetAvatarDrawing(AvatarID).ConfigureAwait(false)).DefaultDrawing, nameof(AvatarDrawing)); + Task.Run(async () => SetProperty(ref _avatarDrawing, (await AvatarDrawingSystem.Instance.GetAvatarDrawing(AvatarID).ConfigureAwait(false)).DefaultDrawing, nameof(AvatarDrawing))); } return _avatarDrawing; } @@ -41,8 +40,7 @@ { _wantAvatarTitle = false; - _ = Awaitable(); - async Task Awaitable() => SetProperty(ref _avatarTitle, await AvatarTitleSystem.Instance.GetAvatarTitle(AvatarID, _allowNotAvatarTitle).ConfigureAwait(false), nameof(AvatarTitleValue)); + Task.Run(async () => SetProperty(ref _avatarTitle, await AvatarTitleSystem.Instance.GetAvatarTitle(AvatarID, _allowNotAvatarTitle).ConfigureAwait(false), nameof(AvatarTitleValue))); } return _avatarTitle; } @@ -56,8 +54,7 @@ { _wantAvatarEdge = false; - _ = Awaitable(); - async Task Awaitable() => SetProperty(ref _avatarEdge, (await AvatarEdgeSystem.Instance.GetAvatarEdge(AvatarID).ConfigureAwait(false)).DefaultDrawing, nameof(AvatarEdge)); + Task.Run(async () => SetProperty(ref _avatarEdge, (await AvatarEdgeSystem.Instance.GetAvatarEdge(AvatarID).ConfigureAwait(false)).DefaultDrawing, nameof(AvatarEdge))); } return _avatarEdge; } diff --git a/Qwilight/Compiler/BMSCompiler.cs b/Qwilight/Compiler/BMSCompiler.cs index 6a96860..f958b7b 100644 --- a/Qwilight/Compiler/BMSCompiler.cs +++ b/Qwilight/Compiler/BMSCompiler.cs @@ -750,7 +750,7 @@ } var isBanalMedia = (!_hasMedia || defaultComputer.AlwaysBanalMedia) && defaultComputer.BanalMedia; var isBanalFailedMedia = (!_hasFailedMedia || defaultComputer.AlwaysBanalFailedMedia) && defaultComputer.BanalFailedMedia; - defaultComputer.LoadStandardContents(isBanalMedia, isBanalFailedMedia, parallelItems); + defaultComputer.LoadBanalMedia(isBanalMedia, isBanalFailedMedia, parallelItems); foreach (var line in _lines) { SetCancelCompiler?.Token.ThrowIfCancellationRequested(); diff --git a/Qwilight/Compiler/BMSONCompiler.cs b/Qwilight/Compiler/BMSONCompiler.cs index 8d3d74f..b03638e 100644 --- a/Qwilight/Compiler/BMSONCompiler.cs +++ b/Qwilight/Compiler/BMSONCompiler.cs @@ -524,7 +524,7 @@ } } var isBanalMedia = (!_hasMedia || defaultComputer.AlwaysBanalMedia) && defaultComputer.BanalMedia; - defaultComputer.LoadStandardContents(isBanalMedia, defaultComputer.BanalFailedMedia, parallelItems); + defaultComputer.LoadBanalMedia(isBanalMedia, defaultComputer.BanalFailedMedia, parallelItems); foreach (var audioFileName in _text.sound_channels.Select(audioChannel => audioChannel.name).Concat(_text.mine_channels.Select(traoChannel => traoChannel.name))) { parallelItems.Add(() => diff --git a/Qwilight/Compiler/BaseCompiler.cs b/Qwilight/Compiler/BaseCompiler.cs index 6b83299..ac84f2e 100644 --- a/Qwilight/Compiler/BaseCompiler.cs +++ b/Qwilight/Compiler/BaseCompiler.cs @@ -33,7 +33,7 @@ { NoteFile = noteFile; SetCancelCompiler = setCancelCompiler; - NoteFormatID = Utility.Await(DB.Instance.GetFormat(noteFile)); + NoteFormatID = DB.Instance.GetFormat(noteFile); } public abstract void CompileImpl(Computing targetComputing, byte[] noteFileContents, int salt); diff --git a/Qwilight/Compute/DefaultCompute.cs b/Qwilight/Compute/DefaultCompute.cs index bf50478..cc6c242 100644 --- a/Qwilight/Compute/DefaultCompute.cs +++ b/Qwilight/Compute/DefaultCompute.cs @@ -1558,7 +1558,7 @@ } } - public void LoadStandardContents(bool isBanalMedia, bool isBanalFailedMedia, IProducerConsumerCollection parallelItems) + public void LoadBanalMedia(bool isBanalMedia, bool isBanalFailedMedia, IProducerConsumerCollection parallelItems) { if (LoadedMedia) { @@ -3961,7 +3961,6 @@ if (!IsPostableItemMode) { - var date = DateTime.Now; var eventNoteID = EventNoteEntryItem?.EventNoteID; if (string.IsNullOrEmpty(eventNoteID)) @@ -3998,16 +3997,15 @@ } } } - _ = DB.Instance.SetHandled(NoteFile); + DB.Instance.SetHandled(NoteFile); - _ = DB.Instance.NewDate(NoteFile, default, date); + DB.Instance.NewDate(NoteFile, default, date); NoteFile.LatestDate = date; ++NoteFile.HandledCount; } else { - - _ = DB.Instance.NewDate(default, eventNoteID, date); + DB.Instance.NewDate(default, eventNoteID, date); EventNoteEntryItem.LatestDate = date; ++EventNoteEntryItem.HandledCount; } @@ -4021,7 +4019,7 @@ { try { - _ = DB.Instance.SaveComment(date, NoteFile, string.Empty, commentID, AvatarName, TotallyLevyingMultiplier, TotallyLevyingAudioMultiplier, ModeComponentValue, Stand.TargetValue, HighestBand, IsP, Point.TargetValue, _isPaused, _inputFlags); + DB.Instance.SaveComment(date, NoteFile, string.Empty, commentID, AvatarName, TotallyLevyingMultiplier, TotallyLevyingAudioMultiplier, ModeComponentValue, Stand.TargetValue, HighestBand, IsP, Point.TargetValue, _isPaused, _inputFlags); using var fs = File.OpenWrite(Path.Combine(QwilightComponent.CommentEntryPath, commentID)); _comments.Single().WriteTo(fs); } @@ -4072,7 +4070,7 @@ { try { - _ = DB.Instance.SaveComment(date, default, eventNoteID, commentID, AvatarName, TotallyLevyingMultiplier, TotallyLevyingAudioMultiplier, ModeComponentValue, Stand.TargetValue, HighestBand, IsP, Point.TargetValue, _isPaused, _inputFlags); + DB.Instance.SaveComment(date, default, eventNoteID, commentID, AvatarName, TotallyLevyingMultiplier, TotallyLevyingAudioMultiplier, ModeComponentValue, Stand.TargetValue, HighestBand, IsP, Point.TargetValue, _isPaused, _inputFlags); using (var zipFile = new ZipFile(Path.Combine(QwilightComponent.CommentEntryPath, Path.ChangeExtension(commentID, ".zip")))) { for (var i = _comments.Count - 1; i >= 0; --i) @@ -4173,7 +4171,7 @@ } } - public void HandleCompiler() => Task.Run(() => + public void HandleCompiler() { try { @@ -4190,9 +4188,9 @@ _targetCompilerHandler.Start(); } } - }); + } - public void SetWait() => _ = DB.Instance.SetWait(NoteFile, Math.Clamp(Configure.Instance.AudioWait, -1000.0, 1000.0), Math.Clamp(Configure.Instance.MediaWait, -1000.0, 1000.0), Configure.Instance.Media); + public void SetWait() => DB.Instance.SetWait(NoteFile, Math.Clamp(Configure.Instance.AudioWait, -1000.0, 1000.0), Math.Clamp(Configure.Instance.MediaWait, -1000.0, 1000.0), Configure.Instance.Media); IHandlerItem GetHandlerItem(MediaNote.Mode mode) => ViewFailedDrawing && _failedDrawingMillis > 0.0 && DrawingCollection.TryGetValue(MediaNote.Mode.Failed, out var failedHandler) ? failedHandler : DrawingCollection.TryGetValue(mode, out var handler) ? handler : null; @@ -4520,7 +4518,7 @@ switch (!string.IsNullOrEmpty(eventNoteID) || NoteFile.IsBanned ? 0 : Configure.Instance.CommentViewTabPosition) { case 0: - netItems.AddRange(GetNetItemsImpl(await DB.Instance.GetCommentItems(NoteFiles[0], eventNoteID, NoteFiles.Length).ConfigureAwait(false))); + netItems.AddRange(GetNetItemsImpl(DB.Instance.GetCommentItems(NoteFiles[0], eventNoteID, NoteFiles.Length))); break; case 1: case 2: diff --git a/Qwilight/NoteFile/BaseNoteFile.cs b/Qwilight/NoteFile/BaseNoteFile.cs index 9474ae0..81c2515 100644 --- a/Qwilight/NoteFile/BaseNoteFile.cs +++ b/Qwilight/NoteFile/BaseNoteFile.cs @@ -224,13 +224,13 @@ } } - public async Task SetConfigure() + public void SetConfigure() { - var (audioWait, mediaWait, media) = await DB.Instance.GetWait(this); + var (audioWait, mediaWait, media) = DB.Instance.GetWait(this); Configure.Instance.AudioWait = audioWait; Configure.Instance.MediaWait = mediaWait; Configure.Instance.Media = media != false; - Configure.Instance.NoteFormatID = await DB.Instance.GetFormat(this); + Configure.Instance.NoteFormatID = DB.Instance.GetFormat(this); } public virtual string GetNoteID128(byte[] data = null) diff --git a/Qwilight/System/AudioSystem/AudioSystem.cs b/Qwilight/System/AudioSystem/AudioSystem.cs index ecc1ff1..05c84b1 100644 --- a/Qwilight/System/AudioSystem/AudioSystem.cs +++ b/Qwilight/System/AudioSystem/AudioSystem.cs @@ -236,14 +236,14 @@ { _targetSystem.getNumDrivers(out var audioValueCount); var audioValues = Enumerable.Range(0, audioValueCount).Select(i => - { - _targetSystem.getDriverInfo(i, out var audioValueName, 128, out _, out _, out _, out _); - return new AudioValue - { - ID = i, - Name = audioValueName - }; - }).ToArray(); + { + _targetSystem.getDriverInfo(i, out var audioValueName, 128, out _, out _, out _, out _); + return new AudioValue + { + ID = i, + Name = audioValueName + }; + }).ToArray(); HandlingUISystem.Instance.HandleParallel(() => { AudioValues.Clear(); diff --git a/Qwilight/System/Configure/GPUConfigure.cs b/Qwilight/System/Configure/GPUConfigure.cs index df65133..2ddf362 100644 --- a/Qwilight/System/Configure/GPUConfigure.cs +++ b/Qwilight/System/Configure/GPUConfigure.cs @@ -1,6 +1,7 @@ using Qwilight.Utilities; using System.IO; using System.Text; +using System.Text.Json; using System.Text.Json.Serialization; namespace Qwilight @@ -63,7 +64,12 @@ { Utility.CopyFile(_fileName, _tmp0FileName); Utility.MoveFile(_tmp0FileName, _tmp1FileName); - File.WriteAllText(_fileName, Utility.SetJSON(this), Encoding.UTF8); + File.WriteAllText(_fileName, Utility.SetJSON(this, new JsonSerializerOptions + { + IgnoreReadOnlyProperties = true, + IncludeFields = true, + WriteIndented = QwilightComponent.IsVS + }), Encoding.UTF8); Utility.WipeFile(_tmp1FileName); } diff --git a/Qwilight/System/DB.cs b/Qwilight/System/DB.cs index af44796..77ee6f4 100644 --- a/Qwilight/System/DB.cs +++ b/Qwilight/System/DB.cs @@ -17,16 +17,25 @@ static readonly string _fileName = Path.Combine(QwilightComponent.QwilightEntryPath, "DB.db"); static readonly string _faultFileName = Path.ChangeExtension(_fileName, ".db.$"); + static readonly string _tmp0FileName = Path.ChangeExtension(_fileName, ".db.tmp.0"); + static readonly string _tmp1FileName = Path.ChangeExtension(_fileName, ".db.tmp.1"); public static readonly DB Instance = QwilightComponent.GetBuiltInData(nameof(DB)); - SQLiteConnection _db; + SQLiteConnection _fastDB; + SQLiteConnection _fileDB; public string DBFault { get; set; } public void Load() { - _db = new(new SQLiteConnectionStringBuilder + Utility.WipeFile(_tmp0FileName); + Utility.MoveFile(_tmp1FileName, _fileName); + _fastDB = new SQLiteConnection(new SQLiteConnectionStringBuilder + { + DataSource = ":memory:" + }.ToString()); + _fileDB = new(new SQLiteConnectionStringBuilder { DataSource = _fileName }.ToString()); @@ -37,17 +46,20 @@ catch (SQLiteException e) { DBFault = $"Failed to Validate DB ({e.Message})"; - _db.Close(); + _fastDB.Close(); + _fastDB.Close(); Utility.MoveFile(_fileName, _faultFileName); LoadImpl(); } void LoadImpl() { - _db.Open(); + _fastDB.Open(); + _fileDB.Open(); + _fileDB.BackupDatabase(_fastDB, "main", "main", -1, null, -1); #region COMPATIBLE - Compatible.Compatible.DB(_db); + Compatible.Compatible.DB(_fastDB); #endregion #region 데이터베이스 정보 @@ -55,7 +67,7 @@ ID VARCHAR(137), Value TEXT, PRIMARY KEY (ID) - )", _db)) + )", _fastDB)) { dbStatement.ExecuteNonQuery(); } @@ -66,7 +78,7 @@ SELECT Value FROM db_file WHERE ID = "date" - """, _db)) + """, _fastDB)) { using var rows = dbStatement.ExecuteReader(); if (rows.Read()) @@ -161,7 +173,7 @@ CHECK (Put_Note_Set_Millis >= 0.0 AND Put_Note_Set_Millis <= 1000.0) CHECK (Is_Paused IN (0, 1)) CHECK (Input_Flags >= 0 AND Input_Flags <= 15) - )", _db)) + )", _fastDB)) { dbStatement.ExecuteNonQuery(); } @@ -172,11 +184,11 @@ using (var dbStatement = new SQLiteCommand(@"INSERT INTO tmp_comment SELECT * - FROM comment", _db)) + FROM comment", _fastDB)) { dbStatement.ExecuteNonQuery(); } - using (var dbStatement = new SQLiteCommand("DROP TABLE comment", _db)) + using (var dbStatement = new SQLiteCommand("DROP TABLE comment", _fastDB)) { dbStatement.ExecuteNonQuery(); } @@ -189,15 +201,15 @@ using (var dbStatement = new SQLiteCommand(@"INSERT INTO tmp_comment(Date, Event_Note_ID, Comment, Name, Multiplier, Auto_Mode, Note_Salt_Mode, Audio_Multiplier, Faint_Note_Mode, Judgment_Mode, Hit_Points_Mode, Note_Mobility_Mode, Long_Note_Mode, Input_Favor_Mode, Note_Modify_Mode, BPM_Mode, Wave_Mode, Set_Note_Mode, Lowest_Judgment_Condition_Mode, Stand, Band, Is_P, Point, Salt, Highest_Judgment_0, Higher_Judgment_0, High_Judgment_0, Low_Judgment_0, Lower_Judgment_0, Lowest_Judgment_0, Highest_Judgment_1, Higher_Judgment_1, High_Judgment_1, Low_Judgment_1, Lower_Judgment_1, Lowest_Judgment_1, Lowest_Long_Note_Modify, Put_Note_Set, Put_Note_Set_Millis, Highest_Hit_Points_0, Higher_Hit_Points_0, High_Hit_Points_0, Low_Hit_Points_0, Lower_Hit_Points_0, Lowest_Hit_Points_0, Highest_Hit_Points_1, Higher_Hit_Points_1, High_Hit_Points_1, Low_Hit_Points_1, Lower_Hit_Points_1, Lowest_Hit_Points_1, Note_ID) SELECT * - FROM comment", _db)) + FROM comment", _fastDB)) { dbStatement.ExecuteNonQuery(); } - using (var dbStatement = new SQLiteCommand(@"UPDATE tmp_comment SET Highest_Long_Note_Modify = Lowest_Long_Note_Modify", _db)) + using (var dbStatement = new SQLiteCommand(@"UPDATE tmp_comment SET Highest_Long_Note_Modify = Lowest_Long_Note_Modify", _fastDB)) { dbStatement.ExecuteNonQuery(); } - using (var dbStatement = new SQLiteCommand("DROP TABLE comment", _db)) + using (var dbStatement = new SQLiteCommand("DROP TABLE comment", _fastDB)) { dbStatement.ExecuteNonQuery(); } @@ -210,11 +222,11 @@ using (var dbStatement = new SQLiteCommand(@"INSERT INTO tmp_comment SELECT * - FROM comment", _db)) + FROM comment", _fastDB)) { dbStatement.ExecuteNonQuery(); } - using (var dbStatement = new SQLiteCommand("DROP TABLE comment", _db)) + using (var dbStatement = new SQLiteCommand("DROP TABLE comment", _fastDB)) { dbStatement.ExecuteNonQuery(); } @@ -226,18 +238,18 @@ { using (var dbStatement = new SQLiteCommand(@"DELETE FROM comment - WHERE Note_Salt_Mode = 3 OR Note_Salt_Mode = 5 OR Note_Salt_Mode = 9 OR Note_Salt_Mode = 10 OR Note_Mobility_Mode = 2 OR Set_Note_Mode = 4 OR Set_Note_Mode = 5 OR Input_Favor_Mode = 1 OR Input_Favor_Mode = 2 OR Input_Favor_Mode = 3 OR Input_Favor_Mode = 17 OR Input_Favor_Mode = 18 OR Input_Favor_Mode = 19", _db)) + WHERE Note_Salt_Mode = 3 OR Note_Salt_Mode = 5 OR Note_Salt_Mode = 9 OR Note_Salt_Mode = 10 OR Note_Mobility_Mode = 2 OR Set_Note_Mode = 4 OR Set_Note_Mode = 5 OR Input_Favor_Mode = 1 OR Input_Favor_Mode = 2 OR Input_Favor_Mode = 3 OR Input_Favor_Mode = 17 OR Input_Favor_Mode = 18 OR Input_Favor_Mode = 19", _fastDB)) { dbStatement.ExecuteNonQuery(); } using (var dbStatement = new SQLiteCommand(@"INSERT INTO tmp_comment SELECT * - FROM comment", _db)) + FROM comment", _fastDB)) { dbStatement.ExecuteNonQuery(); } - using (var dbStatement = new SQLiteCommand("DROP TABLE comment", _db)) + using (var dbStatement = new SQLiteCommand("DROP TABLE comment", _fastDB)) { dbStatement.ExecuteNonQuery(); } @@ -250,11 +262,11 @@ using (var dbStatement = new SQLiteCommand(@"INSERT INTO tmp_comment(Date, Event_Note_ID, Comment, Name, Multiplier, Auto_Mode, Note_Salt_Mode, Audio_Multiplier, Faint_Note_Mode, Judgment_Mode, Hit_Points_Mode, Note_Mobility_Mode, Long_Note_Mode, Input_Favor_Mode, Note_Modify_Mode, BPM_Mode, Wave_Mode, Set_Note_Mode, Lowest_Judgment_Condition_Mode, Stand, Band, Is_P, Point, Salt, Highest_Judgment_0, Higher_Judgment_0, High_Judgment_0, Low_Judgment_0, Lower_Judgment_0, Lowest_Judgment_0, Highest_Judgment_1, Higher_Judgment_1, High_Judgment_1, Low_Judgment_1, Lower_Judgment_1, Lowest_Judgment_1, Lowest_Long_Note_Modify, Highest_Long_Note_Modify, Put_Note_Set, Put_Note_Set_Millis, Highest_Hit_Points_0, Higher_Hit_Points_0, High_Hit_Points_0, Low_Hit_Points_0, Lower_Hit_Points_0, Lowest_Hit_Points_0, Highest_Hit_Points_1, Higher_Hit_Points_1, High_Hit_Points_1, Low_Hit_Points_1, Lower_Hit_Points_1, Lowest_Hit_Points_1, Note_ID) SELECT * - FROM comment", _db)) + FROM comment", _fastDB)) { dbStatement.ExecuteNonQuery(); } - using (var dbStatement = new SQLiteCommand("DROP TABLE comment", _db)) + using (var dbStatement = new SQLiteCommand("DROP TABLE comment", _fastDB)) { dbStatement.ExecuteNonQuery(); } @@ -267,11 +279,11 @@ using (var dbStatement = new SQLiteCommand(@"INSERT INTO tmp_comment(Date, Event_Note_ID, Comment, Name, Multiplier, Auto_Mode, Note_Salt_Mode, Audio_Multiplier, Faint_Note_Mode, Judgment_Mode, Hit_Points_Mode, Note_Mobility_Mode, Long_Note_Mode, Input_Favor_Mode, Note_Modify_Mode, BPM_Mode, Wave_Mode, Set_Note_Mode, Lowest_Judgment_Condition_Mode, Stand, Band, Is_P, Point, Salt, Highest_Judgment_0, Higher_Judgment_0, High_Judgment_0, Low_Judgment_0, Lower_Judgment_0, Lowest_Judgment_0, Highest_Judgment_1, Higher_Judgment_1, High_Judgment_1, Low_Judgment_1, Lower_Judgment_1, Lowest_Judgment_1, Lowest_Long_Note_Modify, Highest_Long_Note_Modify, Put_Note_Set, Put_Note_Set_Millis, Highest_Hit_Points_0, Higher_Hit_Points_0, High_Hit_Points_0, Low_Hit_Points_0, Lower_Hit_Points_0, Lowest_Hit_Points_0, Highest_Hit_Points_1, Higher_Hit_Points_1, High_Hit_Points_1, Low_Hit_Points_1, Lower_Hit_Points_1, Lowest_Hit_Points_1, Note_ID, Is_Paused) SELECT * - FROM comment", _db)) + FROM comment", _fastDB)) { dbStatement.ExecuteNonQuery(); } - using (var dbStatement = new SQLiteCommand("DROP TABLE comment", _db)) + using (var dbStatement = new SQLiteCommand("DROP TABLE comment", _fastDB)) { dbStatement.ExecuteNonQuery(); } @@ -283,32 +295,32 @@ { using (var dbStatement = new SQLiteCommand(@"DELETE FROM comment - WHERE Note_Salt_Mode = 6 OR Note_Salt_Mode = 7 OR Note_Salt_Mode = 8 OR Note_Salt_Mode = 12 OR Note_Salt_Mode = 14 OR Set_Note_Mode = 2", _db)) + WHERE Note_Salt_Mode = 6 OR Note_Salt_Mode = 7 OR Note_Salt_Mode = 8 OR Note_Salt_Mode = 12 OR Note_Salt_Mode = 14 OR Set_Note_Mode = 2", _fastDB)) { dbStatement.ExecuteNonQuery(); } using (var dbStatement = new SQLiteCommand(@"INSERT INTO tmp_comment SELECT * - FROM comment", _db)) + FROM comment", _fastDB)) { dbStatement.ExecuteNonQuery(); } - using (var dbStatement = new SQLiteCommand("DROP TABLE comment", _db)) + using (var dbStatement = new SQLiteCommand("DROP TABLE comment", _fastDB)) { dbStatement.ExecuteNonQuery(); } } } using (var dbStatement = new SQLiteCommand(@"ALTER TABLE tmp_comment - RENAME TO comment", _db)) + RENAME TO comment", _fastDB)) { dbStatement.ExecuteNonQuery(); } using (var dbStatement = new SQLiteCommand(@"CREATE INDEX IF NOT EXISTS _comment ON comment ( Note_ID, Event_Note_ID - )", _db)) + )", _fastDB)) { dbStatement.ExecuteNonQuery(); } @@ -321,7 +333,7 @@ Entry_Path VARCHAR(260), Note_Position INTEGER, PRIMARY KEY (Entry_Path) - )", _db)) + )", _fastDB)) { dbStatement.ExecuteNonQuery(); } @@ -334,7 +346,7 @@ { if (HasTable("note")) { - using (var dbStatement = new SQLiteCommand("DROP TABLE note", _db)) + using (var dbStatement = new SQLiteCommand("DROP TABLE note", _fastDB)) { dbStatement.ExecuteNonQuery(); } @@ -342,13 +354,13 @@ using (var dbStatement = new SQLiteCommand(@"CREATE TABLE IF NOT EXISTS note ( Note_ID VARCHAR(139), Favorite_Entry TEXT - )", _db)) + )", _fastDB)) { dbStatement.ExecuteNonQuery(); } using (var dbStatement = new SQLiteCommand(@"CREATE INDEX IF NOT EXISTS _note ON note ( Note_ID - )", _db)) + )", _fastDB)) { dbStatement.ExecuteNonQuery(); } @@ -363,7 +375,7 @@ { if (HasTable("handle")) { - using (var dbStatement = new SQLiteCommand("DROP TABLE handle", _db)) + using (var dbStatement = new SQLiteCommand("DROP TABLE handle", _fastDB)) { dbStatement.ExecuteNonQuery(); } @@ -372,7 +384,7 @@ Note_ID VARCHAR(137), Handled INTEGER, PRIMARY KEY (Note_ID) - )", _db)) + )", _fastDB)) { dbStatement.ExecuteNonQuery(); } @@ -384,7 +396,7 @@ { var comments = new Dictionary(); using (var dbStatement = new SQLiteCommand(@"SELECT Note_ID, Is_P, Hit_Points_Mode - FROM comment", _db)) + FROM comment", _fastDB)) { using var rows = dbStatement.ExecuteReader(); while (rows.Read()) @@ -416,7 +428,7 @@ { using (var dbStatement = new SQLiteCommand(@"REPLACE INTO handle - VALUES(@noteID, @handled)", _db)) + VALUES(@noteID, @handled)", _fastDB)) { dbStatement.Parameters.AddWithValue("noteID", comment.Key); dbStatement.Parameters.AddWithValue("handled", comment.Value); @@ -432,7 +444,7 @@ { if (HasTable("date")) { - using (var dbStatement = new SQLiteCommand("DROP TABLE date", _db)) + using (var dbStatement = new SQLiteCommand("DROP TABLE date", _fastDB)) { dbStatement.ExecuteNonQuery(); } @@ -441,14 +453,14 @@ Note_ID VARCHAR(139), Event_Note_ID TEXT, Date DATE - )", _db)) + )", _fastDB)) { dbStatement.ExecuteNonQuery(); } using (var dbStatement = new SQLiteCommand(@"CREATE INDEX IF NOT EXISTS _date ON date ( Note_ID, Event_Note_ID - )", _db)) + )", _fastDB)) { dbStatement.ExecuteNonQuery(); } @@ -460,7 +472,7 @@ { var comments = new List<(string, string, DateTime)>(); using (var dbStatement = new SQLiteCommand(@"SELECT Note_ID, Event_Note_ID, Date - FROM comment", _db)) + FROM comment", _fastDB)) { using var rows = dbStatement.ExecuteReader(); while (rows.Read()) @@ -472,7 +484,7 @@ { using (var dbStatement = new SQLiteCommand(@"INSERT INTO date - VALUES(@noteID, @eventNoteID, @date)", _db)) + VALUES(@noteID, @eventNoteID, @date)", _fastDB)) { dbStatement.Parameters.AddWithValue("noteID", comment.Item1); dbStatement.Parameters.AddWithValue("eventNoteID", comment.Item2); @@ -489,7 +501,7 @@ { if (HasTable("wait")) { - using (var dbStatement = new SQLiteCommand("DROP TABLE wait", _db)) + using (var dbStatement = new SQLiteCommand("DROP TABLE wait", _fastDB)) { dbStatement.ExecuteNonQuery(); } @@ -503,7 +515,7 @@ CHECK (Media_Wait >= -1000.0 AND Media_Wait <= 1000.0) CHECK (Media IN (0, 1)) PRIMARY KEY (Note_ID) - )", _db)) + )", _fastDB)) { dbStatement.ExecuteNonQuery(); } @@ -518,7 +530,7 @@ { if (HasTable("format")) { - using (var dbStatement = new SQLiteCommand("DROP TABLE format", _db)) + using (var dbStatement = new SQLiteCommand("DROP TABLE format", _fastDB)) { dbStatement.ExecuteNonQuery(); } @@ -527,7 +539,7 @@ Note_ID VARCHAR(139), Format LONG DEFAULT -1, PRIMARY KEY (Note_ID) - )", _db)) + )", _fastDB)) { dbStatement.ExecuteNonQuery(); } @@ -544,7 +556,7 @@ PRIMARY KEY (Event_Note_ID, Variety) CHECK (length(Event_Note_ID) > 0) CHECK (Variety IN (0, 1)) - )", _db)) + )", _fastDB)) { dbStatement.ExecuteNonQuery(); } @@ -560,7 +572,7 @@ Level_Text TEXT, Genre TEXT, PRIMARY KEY (Note_ID) - )", _db)) + )", _fastDB)) { dbStatement.ExecuteNonQuery(); } @@ -570,7 +582,7 @@ REPLACE INTO db_file VALUES("date", @value) - """, _db)) + """, _fastDB)) { dbStatement.Parameters.AddWithValue("value", QwilightComponent.DateText); dbStatement.ExecuteNonQuery(); @@ -580,7 +592,7 @@ { using var dbStatement = new SQLiteCommand(@"SELECT name FROM sqlite_master - WHERE type = 'table' AND name = @tableName", _db); + WHERE type = 'table' AND name = @tableName", _fastDB); dbStatement.Parameters.AddWithValue("tableName", tableName); using var rows = dbStatement.ExecuteReader(); return rows.Read(); @@ -588,7 +600,7 @@ void Ta(Action onHandle) { - using var t = _db.BeginTransaction(); + using var t = _fastDB.BeginTransaction(); try { onHandle(); @@ -603,7 +615,7 @@ } } - public async ValueTask> GetCommentItems(BaseNoteFile noteFile, string eventNoteID, int noteFileCount) + public ICollection GetCommentItems(BaseNoteFile noteFile, string eventNoteID, int noteFileCount) { var data = new List(); using var dbStatement = new SQLiteCommand($""" @@ -611,7 +623,7 @@ FROM comment WHERE {(string.IsNullOrEmpty(eventNoteID) ? "Note_ID = @noteID" : "Event_Note_ID = @eventNoteID")} ORDER BY Stand DESC - """, _db); + """, _fastDB); if (string.IsNullOrEmpty(eventNoteID)) { dbStatement.Parameters.AddWithValue("noteID", noteFile.GetNoteID512()); @@ -620,8 +632,8 @@ { dbStatement.Parameters.AddWithValue("eventNoteID", eventNoteID); } - using var rows = await dbStatement.ExecuteReaderAsync().ConfigureAwait(false); - while (await rows.ReadAsync().ConfigureAwait(false)) + using var rows = dbStatement.ExecuteReader(); + while (rows.Read()) { var date = (DateTime)rows["Date"]; var sentMultiplier = (double)rows["Multiplier"]; @@ -699,7 +711,7 @@ return data; } - public async ValueTask SetEventNoteData(ICollection wwwLevelComputingValues) + public void SetEventNoteData(ICollection wwwLevelComputingValues) { foreach (var wwwLevelComputingValue in wwwLevelComputingValues) { @@ -708,7 +720,7 @@ { using var dbStatement = new SQLiteCommand(@"REPLACE INTO event_note_data - VALUES(@noteID, @noteVariety, @title, @artist, @level, @levelText, @genre)", _db); + VALUES(@noteID, @noteVariety, @title, @artist, @level, @levelText, @genre)", _fastDB); dbStatement.Parameters.AddWithValue("noteID", wwwLevelComputingValue.NoteID); dbStatement.Parameters.AddWithValue("noteVariety", noteVariety); dbStatement.Parameters.AddWithValue("title", wwwLevelComputingValue.Title); @@ -716,7 +728,7 @@ dbStatement.Parameters.AddWithValue("level", wwwLevelComputingValue.LevelValue); dbStatement.Parameters.AddWithValue("levelText", wwwLevelComputingValue.LevelText); dbStatement.Parameters.AddWithValue("genre", wwwLevelComputingValue.Genre); - await dbStatement.ExecuteNonQueryAsync().ConfigureAwait(false); + dbStatement.ExecuteNonQuery(); } } } @@ -725,7 +737,7 @@ { using var dbStatement = new SQLiteCommand(@"SELECT Note_Variety, Title, Artist, Level, Level_Text, Genre FROM event_note_data - WHERE Note_ID = @noteID", _db); + WHERE Note_ID = @noteID", _fastDB); dbStatement.Parameters.AddWithValue("noteID", noteID); using var rows = dbStatement.ExecuteReader(); if (rows.Read()) @@ -763,7 +775,7 @@ { using var dbStatement = new SQLiteCommand(@"SELECT Favorite_Entry FROM note - WHERE Note_ID = @noteID", _db); + WHERE Note_ID = @noteID", _fastDB); dbStatement.Parameters.AddWithValue("noteID", noteFile.GetNoteID512()); using var rows = dbStatement.ExecuteReader(); var favoriteEntryItems = new List(); @@ -781,7 +793,7 @@ public ICollection<(string, string, DateTime, EventNoteVariety)> GetEventNote() { using var dbStatement = new SQLiteCommand(@"SELECT Event_Note_ID, Name, Date, Variety - FROM event_note", _db); + FROM event_note", _fastDB); using var rows = dbStatement.ExecuteReader(); var eventNote = new List<(string, string, DateTime, EventNoteVariety)>(); while (rows.Read()) @@ -795,27 +807,27 @@ { using var dbStatement = new SQLiteCommand(@"SELECT Handled FROM handle - WHERE Note_ID = @noteID", _db); + WHERE Note_ID = @noteID", _fastDB); dbStatement.Parameters.AddWithValue("noteID", noteFile.GetNoteID512()); using var rows = dbStatement.ExecuteReader(); return rows.Read() ? (BaseNoteFile.Handled)(long)rows["Handled"] : BaseNoteFile.Handled.Not; } - public async Task SetHandled(BaseNoteFile noteFile) + public void SetHandled(BaseNoteFile noteFile) { using var dbStatement = new SQLiteCommand(@"REPLACE INTO handle - VALUES(@noteID, @handled)", _db); + VALUES(@noteID, @handled)", _fastDB); dbStatement.Parameters.AddWithValue("noteID", noteFile.GetNoteID512()); dbStatement.Parameters.AddWithValue("handled", noteFile.HandledValue); - await dbStatement.ExecuteNonQueryAsync().ConfigureAwait(false); + dbStatement.ExecuteNonQuery(); } public (DateTime?, int) GetDate(BaseNoteFile noteFile, string eventNoteID) { using var dbStatement = new SQLiteCommand(@"SELECT MAX(Date) AS Latest, COUNT(Date) AS Count FROM date - WHERE Note_ID = @noteID OR Event_Note_ID = @eventNoteID", _db); + WHERE Note_ID = @noteID OR Event_Note_ID = @eventNoteID", _fastDB); dbStatement.Parameters.AddWithValue("noteID", noteFile?.GetNoteID512()); dbStatement.Parameters.AddWithValue("eventNoteID", eventNoteID); using var rows = dbStatement.ExecuteReader(); @@ -832,36 +844,36 @@ return date; } - public async Task NewDate(BaseNoteFile noteFile, string eventNoteID, DateTime date) + public void NewDate(BaseNoteFile noteFile, string eventNoteID, DateTime date) { using var dbStatement = new SQLiteCommand(@"INSERT INTO date - VALUES(@noteID, @eventNoteID, @date)", _db); + VALUES(@noteID, @eventNoteID, @date)", _fastDB); dbStatement.Parameters.AddWithValue("noteID", noteFile?.GetNoteID512()); dbStatement.Parameters.AddWithValue("eventNoteID", eventNoteID); dbStatement.Parameters.AddWithValue("date", date); - await dbStatement.ExecuteNonQueryAsync().ConfigureAwait(false); + dbStatement.ExecuteNonQuery(); } public int GetNotePosition(string entryPath) { using var dbStatement = new SQLiteCommand(@"SELECT Note_Position FROM entry - WHERE Entry_Path = @entryPath", _db); + WHERE Entry_Path = @entryPath", _fastDB); dbStatement.Parameters.AddWithValue("entryPath", entryPath); using var rows = dbStatement.ExecuteReader(); return rows.Read() ? (int)(long)rows["Note_Position"] : 0; } - public async ValueTask<(double, double, bool?)> GetWait(BaseNoteFile noteFile) + public (double, double, bool?) GetWait(BaseNoteFile noteFile) { using var dbStatement = new SQLiteCommand(@"SELECT Audio_Wait, Media_Wait, Media FROM wait - WHERE Note_ID = @noteID", _db); + WHERE Note_ID = @noteID", _fastDB); dbStatement.Parameters.AddWithValue("noteID", noteFile.GetNoteID512()); - using var rows = await dbStatement.ExecuteReaderAsync().ConfigureAwait(false); + using var rows = dbStatement.ExecuteReader(); (double, double, bool?) data = (0.0, 0.0, default); - if (await rows.ReadAsync().ConfigureAwait(false)) + if (rows.Read()) { if (rows["Audio_Wait"] != DBNull.Value) { @@ -876,86 +888,86 @@ return data; } - public async Task GetFormat(BaseNoteFile noteFile) + public int GetFormat(BaseNoteFile noteFile) { using var dbStatement = new SQLiteCommand(@"SELECT Format FROM format - WHERE Note_ID = @noteID", _db); + WHERE Note_ID = @noteID", _fastDB); dbStatement.Parameters.AddWithValue("noteID", noteFile.GetNoteID512()); - using var rows = await dbStatement.ExecuteReaderAsync().ConfigureAwait(false); - return await rows.ReadAsync().ConfigureAwait(false) ? (int)(long)rows["Format"] : -1; + using var rows = dbStatement.ExecuteReader(); + return rows.Read() ? (int)(long)rows["Format"] : -1; } - public async Task SetNotePosition(EntryItem entryItem) + public void SetNotePosition(EntryItem entryItem) { using var dbStatement = new SQLiteCommand(@"REPLACE INTO entry - VALUES(@entryPath, @notePosition)", _db); + VALUES(@entryPath, @notePosition)", _fastDB); dbStatement.Parameters.AddWithValue("entryPath", entryItem.EntryPath); dbStatement.Parameters.AddWithValue("notePosition", entryItem.NotePosition); - await dbStatement.ExecuteNonQueryAsync().ConfigureAwait(false); + dbStatement.ExecuteNonQuery(); } - public async Task SetFavoriteEntry(BaseNoteFile noteFile) + public void SetFavoriteEntry(BaseNoteFile noteFile) { - await Ta(async () => + Ta(() => { using (var dbStatement = new SQLiteCommand(@"DELETE FROM note - WHERE Note_ID = @noteID", _db)) + WHERE Note_ID = @noteID", _fastDB)) { dbStatement.Parameters.AddWithValue("noteID", noteFile.GetNoteID512()); - await dbStatement.ExecuteNonQueryAsync().ConfigureAwait(false); + dbStatement.ExecuteNonQuery(); } using (var dbStatement = new SQLiteCommand(@"REPLACE INTO note - VALUES(@noteID, @favoriteEntry)", _db)) + VALUES(@noteID, @favoriteEntry)", _fastDB)) { foreach (var favoriteEntryItem in noteFile.FavoriteEntryItems) { dbStatement.Parameters.AddWithValue("noteID", noteFile.GetNoteID512()); dbStatement.Parameters.AddWithValue("favoriteEntry", favoriteEntryItem.DefaultEntryPath); - await dbStatement.ExecuteNonQueryAsync().ConfigureAwait(false); + dbStatement.ExecuteNonQuery(); } } - }).ConfigureAwait(false); + }); } - public async Task SetEventNote(string eventNoteID, string eventNoteName, DateTime date, EventNoteVariety eventNoteVariety) + public void SetEventNote(string eventNoteID, string eventNoteName, DateTime date, EventNoteVariety eventNoteVariety) { using var dbStatement = new SQLiteCommand(@"INSERT INTO event_note - VALUES(@eventNoteID, @eventNoteName, @date, @eventNoteVariety)", _db); + VALUES(@eventNoteID, @eventNoteName, @date, @eventNoteVariety)", _fastDB); dbStatement.Parameters.AddWithValue("eventNoteID", eventNoteID); dbStatement.Parameters.AddWithValue("eventNoteName", eventNoteName); dbStatement.Parameters.AddWithValue("date", date); dbStatement.Parameters.AddWithValue("eventNoteVariety", eventNoteVariety); - await dbStatement.ExecuteNonQueryAsync().ConfigureAwait(false); + dbStatement.ExecuteNonQuery(); } - public async ValueTask WipeEventNote(string eventNoteID) + public void WipeEventNote(string eventNoteID) { using var dbStatement = new SQLiteCommand(@"DELETE FROM event_note - WHERE Event_Note_ID = @eventNoteID", _db); + WHERE Event_Note_ID = @eventNoteID", _fastDB); dbStatement.Parameters.AddWithValue("eventNoteID", eventNoteID); - await dbStatement.ExecuteNonQueryAsync().ConfigureAwait(false); + dbStatement.ExecuteNonQuery(); } - public async Task ModifyEventNoteName(string eventNoteID, string eventNoteName) + public void ModifyEventNoteName(string eventNoteID, string eventNoteName) { using var dbStatement = new SQLiteCommand(@"UPDATE event_note SET Name = @eventNoteName - WHERE Event_Note_ID = @eventNoteID", _db); + WHERE Event_Note_ID = @eventNoteID", _fastDB); dbStatement.Parameters.AddWithValue("eventNoteName", eventNoteName); dbStatement.Parameters.AddWithValue("eventNoteID", eventNoteID); - await dbStatement.ExecuteNonQueryAsync().ConfigureAwait(false); + dbStatement.ExecuteNonQuery(); } - public async Task SaveComment(DateTime date, BaseNoteFile noteFile, string eventNoteID, string comment, string avatar, double multiplier, double audioMultiplier, ModeComponent modeComponentValue, int stand, int band, bool isP, double point, bool isPaused, DefaultCompute.InputFlag inputFlags) + public void SaveComment(DateTime date, BaseNoteFile noteFile, string eventNoteID, string comment, string avatar, double multiplier, double audioMultiplier, ModeComponent modeComponentValue, int stand, int band, bool isP, double point, bool isPaused, DefaultCompute.InputFlag inputFlags) { using var dbStatement = new SQLiteCommand(@"INSERT INTO comment - VALUES(@date, @eventNoteID, @comment, @avatar, @multiplier, @autoMode, @noteSaltMode, @audioMultiplier, @faintNoteMode, @judgmentMode, @hitPointsMode, @noteMobilityMode, @longNoteMode, @inputFavorMode, @noteModifyMode, @bpmMode, @waveMode, @setNoteMode, @lowestJudgmentConditionMode, @stand, @band, @isP, @point, @salt, @highestJudgment0, @higherJudgment0, @highJudgment0, @lowJudgment0, @lowerJudgment0, @lowestJudgment0, @highestJudgment1, @higherJudgment1, @highJudgment1, @lowJudgment1, @lowerJudgment1, @lowestJudgment1, @lowestLongNoteModify, @highestLongNoteModify, @putNoteSet, @putNoteSetMillis, @highestHitPoints0, @higherHitPoints0, @highHitPoints0, @lowHitPoints0, @lowerHitPoints0, @lowestHitPoints0, @highestHitPoints1, @higherHitPoints1, @highHitPoints1, @lowHitPoints1, @lowerHitPoints1, @lowestHitPoints1, @noteID, @isPaused, @inputFlags)", _db); + VALUES(@date, @eventNoteID, @comment, @avatar, @multiplier, @autoMode, @noteSaltMode, @audioMultiplier, @faintNoteMode, @judgmentMode, @hitPointsMode, @noteMobilityMode, @longNoteMode, @inputFavorMode, @noteModifyMode, @bpmMode, @waveMode, @setNoteMode, @lowestJudgmentConditionMode, @stand, @band, @isP, @point, @salt, @highestJudgment0, @higherJudgment0, @highJudgment0, @lowJudgment0, @lowerJudgment0, @lowestJudgment0, @highestJudgment1, @higherJudgment1, @highJudgment1, @lowJudgment1, @lowerJudgment1, @lowestJudgment1, @lowestLongNoteModify, @highestLongNoteModify, @putNoteSet, @putNoteSetMillis, @highestHitPoints0, @higherHitPoints0, @highHitPoints0, @lowHitPoints0, @lowerHitPoints0, @lowestHitPoints0, @highestHitPoints1, @higherHitPoints1, @highHitPoints1, @lowHitPoints1, @lowerHitPoints1, @lowestHitPoints1, @noteID, @isPaused, @inputFlags)", _fastDB); dbStatement.Parameters.AddWithValue("date", date); dbStatement.Parameters.AddWithValue("eventNoteID", eventNoteID); dbStatement.Parameters.AddWithValue("comment", comment); @@ -1011,90 +1023,98 @@ dbStatement.Parameters.AddWithValue("noteID", noteFile?.GetNoteID512()); dbStatement.Parameters.AddWithValue("isPaused", isPaused); dbStatement.Parameters.AddWithValue("inputFlags", inputFlags); - await dbStatement.ExecuteNonQueryAsync().ConfigureAwait(false); + dbStatement.ExecuteNonQuery(); } - public async Task SetWait(BaseNoteFile noteFile, double audioWait, double mediaWait, bool media) + public void SetWait(BaseNoteFile noteFile, double audioWait, double mediaWait, bool media) { using var dbStatement = new SQLiteCommand(@"REPLACE INTO wait - VALUES(@noteID, @audioWait, @mediaWait, @media)", _db); + VALUES(@noteID, @audioWait, @mediaWait, @media)", _fastDB); dbStatement.Parameters.AddWithValue("noteID", noteFile.GetNoteID512()); dbStatement.Parameters.AddWithValue("audioWait", audioWait); dbStatement.Parameters.AddWithValue("mediaWait", mediaWait); dbStatement.Parameters.AddWithValue("media", media); - await dbStatement.ExecuteNonQueryAsync().ConfigureAwait(false); + dbStatement.ExecuteNonQuery(); } - public async ValueTask SetNoteFormat(BaseNoteFile noteFile, int format) + public void SetNoteFormat(BaseNoteFile noteFile, int format) { using var dbStatement = new SQLiteCommand(@"REPLACE INTO format - VALUES(@noteID, @format)", _db); + VALUES(@noteID, @format)", _fastDB); dbStatement.Parameters.AddWithValue("noteID", noteFile.GetNoteID512()); dbStatement.Parameters.AddWithValue("format", format); - await dbStatement.ExecuteNonQueryAsync().ConfigureAwait(false); + dbStatement.ExecuteNonQuery(); } - public async ValueTask WipeFavoriteEntry() + public void WipeFavoriteEntry() { using var dbStatement = new SQLiteCommand(@"DELETE - FROM note", _db); - await dbStatement.ExecuteNonQueryAsync().ConfigureAwait(false); + FROM note", _fastDB); + dbStatement.ExecuteNonQuery(); } - public async ValueTask WipeHandled(BaseNoteFile noteFile) + public void WipeHandled(BaseNoteFile noteFile) { using var dbStatement = new SQLiteCommand(@"DELETE FROM handle - WHERE Note_ID = @noteID", _db); + WHERE Note_ID = @noteID", _fastDB); dbStatement.Parameters.AddWithValue("noteID", noteFile.GetNoteID512()); - await dbStatement.ExecuteNonQueryAsync().ConfigureAwait(false); + dbStatement.ExecuteNonQuery(); } - public async ValueTask InitWait() + public void InitWait() { using var dbStatement = new SQLiteCommand(@"UPDATE wait - SET Audio_Wait = NULL, Media_Wait = 0.0", _db); - await dbStatement.ExecuteNonQueryAsync().ConfigureAwait(false); + SET Audio_Wait = NULL, Media_Wait = 0.0", _fastDB); + dbStatement.ExecuteNonQuery(); } - public async ValueTask InitMedia() + public void InitMedia() { using var dbStatement = new SQLiteCommand(@"UPDATE wait - SET Media = NULL", _db); - await dbStatement.ExecuteNonQueryAsync().ConfigureAwait(false); + SET Media = NULL", _fastDB); + dbStatement.ExecuteNonQuery(); } - public async Task WipeComment(string comment) + public void WipeComment(string comment) { using var dbStatement = new SQLiteCommand(@"DELETE FROM comment - WHERE Comment = @comment", _db); + WHERE Comment = @comment", _fastDB); dbStatement.Parameters.AddWithValue("comment", comment); - await dbStatement.ExecuteNonQueryAsync().ConfigureAwait(false); + dbStatement.ExecuteNonQuery(); } - public async ValueTask WipeComment() + public void WipeComment() { using var dbStatement = new SQLiteCommand(@"DELETE - FROM comment", _db); - await dbStatement.ExecuteNonQueryAsync().ConfigureAwait(false); + FROM comment", _fastDB); + dbStatement.ExecuteNonQuery(); } - async ValueTask Ta(Action onHandle) + void Ta(Action onHandle) { - using var t = await _db.BeginTransactionAsync().ConfigureAwait(false); + using var t = _fastDB.BeginTransaction(); try { onHandle(); - await t.CommitAsync().ConfigureAwait(false); + t.Commit(); } catch { - await t.RollbackAsync().ConfigureAwait(false); + t.Rollback(); throw; } } + + public void Save() + { + Utility.CopyFile(_fileName, _tmp0FileName); + Utility.MoveFile(_tmp0FileName, _tmp1FileName); + _fastDB.BackupDatabase(_fileDB, "main", "main", -1, null, -1); + Utility.WipeFile(_tmp1FileName); + } } } \ No newline at end of file diff --git a/Qwilight/System/DrawingSystem/DrawingSystem.cs b/Qwilight/System/DrawingSystem/DrawingSystem.cs index c6fd7b4..cd6447d 100644 --- a/Qwilight/System/DrawingSystem/DrawingSystem.cs +++ b/Qwilight/System/DrawingSystem/DrawingSystem.cs @@ -3191,7 +3191,7 @@ static DrawingItem Load(Stream s, bool setAverage = false) { s.Position = 0; - var drawing = Utility.Await(CanvasBitmap.LoadAsync(CanvasDevice.GetSharedDevice(), s.AsRandomAccessStream())); + var drawing = CanvasBitmap.LoadAsync(CanvasDevice.GetSharedDevice(), s.AsRandomAccessStream()).Await(); var averageColor = 0U; var averageHeight = 0.0; if (setAverage) @@ -3320,9 +3320,8 @@ BitmapSource LoadImpl() { - BitmapSource defaultDrawing; - fs.Position = 0; + BitmapSource defaultDrawing; var drawing = new BitmapImage(); drawing.BeginInit(); drawing.CacheOption = BitmapCacheOption.OnLoad; @@ -3417,7 +3416,6 @@ { ArrayPool.Shared.Return(data); } - return defaultDrawing; } } diff --git a/Qwilight/System/HandlingUISystem.cs b/Qwilight/System/HandlingUISystem.cs index 6594796..82cf37b 100644 --- a/Qwilight/System/HandlingUISystem.cs +++ b/Qwilight/System/HandlingUISystem.cs @@ -38,32 +38,7 @@ } else { - var handleCSX = new object(); - var isHandling = true; - T value = default; - UIHandler.InvokeAsync(() => - { - try - { - value = onHandle(); - } - finally - { - lock (handleCSX) - { - isHandling = false; - Monitor.Pulse(handleCSX); - } - } - }); - lock (handleCSX) - { - if (isHandling) - { - Monitor.Wait(handleCSX); - } - } - return value; + return UIHandler.Invoke(onHandle); } } } diff --git a/Qwilight/System/LevelSystem.cs b/Qwilight/System/LevelSystem.cs index 891b0dd..28dfefa 100644 --- a/Qwilight/System/LevelSystem.cs +++ b/Qwilight/System/LevelSystem.cs @@ -126,7 +126,7 @@ { Text = LanguageSystem.Instance.SavingLevelContents, Variety = NotifySystem.NotifyVariety.Levying, - OnStop = isTotal => false + OnStop = wipeTotal => false }; HandlingUISystem.Instance.HandleParallel(() => ViewModels.Instance.NotifyValue.NotifyItemCollection.Insert(0, savingLevelItem)); NotifySystem.Instance.Notify(NotifySystem.NotifyVariety.Info, NotifySystem.NotifyConfigure.NotSave, savingLevelItem.Text); @@ -158,7 +158,7 @@ } savingLevelItem.Variety = NotifySystem.NotifyVariety.Quit; savingLevelItem.Text = LanguageSystem.Instance.SavedLevelContents; - savingLevelItem.OnStop = isTotal => true; + savingLevelItem.OnStop = wipeTotal => true; NotifySystem.Instance.Notify(NotifySystem.NotifyVariety.Info, NotifySystem.NotifyConfigure.NotSave, LanguageSystem.Instance.SavedLevelContents); Configure.Instance.LevelTargetMap[levelTableFileName] = www; LoadLevelFiles(); diff --git a/Qwilight/System/MediaInputSystem.cs b/Qwilight/System/MediaInputSystem.cs index 9c3fef2..f50d823 100644 --- a/Qwilight/System/MediaInputSystem.cs +++ b/Qwilight/System/MediaInputSystem.cs @@ -47,8 +47,7 @@ { if (SetProperty(ref _mediaInputQuality, value, nameof(MediaInputQualityValue)) && value.HasValue) { - _ = Awaitable(); - async Task Awaitable() => await _mediaInputSystem.VideoDeviceController.SetMediaStreamPropertiesAsync(MediaStreamType.VideoRecord, value.Value.Data); + Task.Run(async () => await _mediaInputSystem.VideoDeviceController.SetMediaStreamPropertiesAsync(MediaStreamType.VideoRecord, value.Value.Data)); } } } diff --git a/Qwilight/System/MediaSystem/MediaSystem.cs b/Qwilight/System/MediaSystem/MediaSystem.cs index d3fa58d..f80d58c 100644 --- a/Qwilight/System/MediaSystem/MediaSystem.cs +++ b/Qwilight/System/MediaSystem/MediaSystem.cs @@ -97,7 +97,7 @@ return handledMediaItem; } - var mediaSrc = Utility.Await(FFmpegMediaSource.CreateFromFileAsync(mediaFilePath)); + var mediaSrc = FFmpegMediaSource.CreateFromFileAsync(mediaFilePath).Await(); var mediaLength = mediaSrc.Duration; var mediaModifierValue = mediaContainer.MediaModifierValue; if (mediaModifierValue != null) @@ -124,7 +124,7 @@ } } } - mediaSrc ??= Utility.Await(FFmpegMediaSource.CreateFromFileAsync(mediaFilePath)); + mediaSrc ??= FFmpegMediaSource.CreateFromFileAsync(mediaFilePath).Await(); mediaLength = mediaSrc.Duration; handledMediaItem = new() { diff --git a/Qwilight/System/TwilightSystem.cs b/Qwilight/System/TwilightSystem.cs index 5ff2c43..a9e7002 100644 --- a/Qwilight/System/TwilightSystem.cs +++ b/Qwilight/System/TwilightSystem.cs @@ -79,8 +79,7 @@ { _wantAvatarDrawing = false; - _ = Awaitable(); - async Task Awaitable() => SetProperty(ref _avatarDrawing, (await AvatarDrawingSystem.Instance.GetAvatarDrawing(AvatarID).ConfigureAwait(false)).DefaultDrawing, nameof(AvatarDrawing)); + Task.Run(async () => SetProperty(ref _avatarDrawing, (await AvatarDrawingSystem.Instance.GetAvatarDrawing(AvatarID).ConfigureAwait(false)).DefaultDrawing, nameof(AvatarDrawing))); } return _avatarDrawing; } @@ -719,9 +718,9 @@ Text = LanguageSystem.Instance.SaveAsBundleContents, Variety = NotifySystem.NotifyVariety.Levying, SaveAsDataStore = ArrayPool.Shared.Rent(QwilightComponent.SendUnit), - OnStop = isTotal => + OnStop = wipeTotal => { - if (isTotal) + if (wipeTotal) { return !_saveAsBundleMap.ContainsKey(saveAsBundleID); } @@ -875,7 +874,7 @@ savedAsBundleItem.Variety = NotifySystem.NotifyVariety.Quit; savedAsBundleItem.Text = LanguageSystem.Instance.SavedAsBundleContents; savedAsBundleItem.Dispose(); - savedAsBundleItem.OnStop = isTotal => true; + savedAsBundleItem.OnStop = wipeTotal => true; NotifySystem.Instance.Notify(NotifySystem.NotifyVariety.OK, NotifySystem.NotifyConfigure.NotSave, savedAsBundleItem.Text); } break; @@ -888,9 +887,9 @@ Text = LanguageSystem.Instance.SaveBundleContents, Variety = NotifySystem.NotifyVariety.Levying, SaveDataFlow = PoolSystem.Instance.GetDataFlow(bundleLength), - OnStop = isTotal => + OnStop = wipeTotal => { - if (isTotal) + if (wipeTotal) { return !_saveBundleMap.ContainsKey(saveBundleID); } @@ -1024,7 +1023,7 @@ _ => default }; var date = DateTime.Now; - DB.Instance.SetEventNote(eventNoteID, eventNoteName, date, eventNoteVariety).Wait(); + DB.Instance.SetEventNote(eventNoteID, eventNoteName, date, eventNoteVariety); savedBundleItem.Variety = NotifySystem.NotifyVariety.Quit; savedBundleItem.Text = LanguageSystem.Instance.SavedBundleContents; NotifySystem.Instance.Notify(NotifySystem.NotifyVariety.OK, NotifySystem.NotifyConfigure.NotSave, savedBundleItem.Text); @@ -1077,7 +1076,7 @@ finally { savedBundleItem.Dispose(); - savedBundleItem.OnStop = isTotal => true; + savedBundleItem.OnStop = wipeTotal => true; } }, false); } diff --git a/Qwilight/UIComponent/AvatarEdgeItem.cs b/Qwilight/UIComponent/AvatarEdgeItem.cs index ee0d5f2..d8fb8b0 100644 --- a/Qwilight/UIComponent/AvatarEdgeItem.cs +++ b/Qwilight/UIComponent/AvatarEdgeItem.cs @@ -19,8 +19,7 @@ { _wantDrawing = false; - _ = Awaitable(); - async Task Awaitable() => SetProperty(ref _drawing, DrawingSystem.Instance.LoadDefault(await TwilightSystem.Instance.GetWwwParallel($"{QwilightComponent.QwilightAPI}/edge?edgeID={EdgeID}").ConfigureAwait(false), null), nameof(Drawing)); + Task.Run(async () => SetProperty(ref _drawing, DrawingSystem.Instance.LoadDefault(await TwilightSystem.Instance.GetWwwParallel($"{QwilightComponent.QwilightAPI}/edge?edgeID={EdgeID}").ConfigureAwait(false), null), nameof(Drawing))); } return _drawing; } diff --git a/Qwilight/UIComponent/WwwLevelGroup.cs b/Qwilight/UIComponent/WwwLevelGroup.cs index 293f845..ccf6c5c 100644 --- a/Qwilight/UIComponent/WwwLevelGroup.cs +++ b/Qwilight/UIComponent/WwwLevelGroup.cs @@ -40,17 +40,17 @@ public bool HasEventNote => ViewModels.Instance.MainValue.EventNoteEntryItems.ContainsKey(GetEventNoteID()); [RelayCommand] - async Task OnGetWwwLevel() + void OnGetWwwLevel() { try { - await DB.Instance.SetEventNoteData(WwwLevelComputingCollection).ConfigureAwait(false); + DB.Instance.SetEventNoteData(WwwLevelComputingCollection); if (WwwLevelItemValue != null) { var eventNoteName = WwwLevelItemValue.Title; var date = DateTime.Now; var eventNoteVariety = DB.EventNoteVariety.Qwilight; - await DB.Instance.SetEventNote(GetEventNoteID(), eventNoteName, date, eventNoteVariety).ConfigureAwait(false); + DB.Instance.SetEventNote(GetEventNoteID(), eventNoteName, date, eventNoteVariety); var mainViewModel = ViewModels.Instance.MainValue; mainViewModel.LoadEventNoteEntryItems(); mainViewModel.Want(); diff --git a/Qwilight/Utilities/AwaitUtility.cs b/Qwilight/Utilities/AwaitUtility.cs index c5ae62c..b97928c 100644 --- a/Qwilight/Utilities/AwaitUtility.cs +++ b/Qwilight/Utilities/AwaitUtility.cs @@ -4,13 +4,9 @@ { public static partial class Utility { - public static T Await(IAsyncOperation t) + public static T Await(this IAsyncOperation awaitable) { - return Await(t.AsTask()); - } - - public static T Await(Task t) - { + using var t = awaitable.AsTask(); t.Wait(); return t.Result; } diff --git a/Qwilight/Utilities/JSONUtility.cs b/Qwilight/Utilities/JSONUtility.cs index 7c484f0..dc417c2 100644 --- a/Qwilight/Utilities/JSONUtility.cs +++ b/Qwilight/Utilities/JSONUtility.cs @@ -33,7 +33,6 @@ new XORFloat64Modifier() }, IncludeFields = true, - IgnoreReadOnlyProperties = true, WriteIndented = QwilightComponent.IsVS }; diff --git a/Qwilight/Utilities/Utility.cs b/Qwilight/Utilities/Utility.cs index d1cbc3c..fc6777e 100644 --- a/Qwilight/Utilities/Utility.cs +++ b/Qwilight/Utilities/Utility.cs @@ -47,13 +47,13 @@ return (titlePosition >= 0 ? title.Substring(0, titlePosition) : title).Trim(); } - public static void HandleUIAudio(string audioFileName, string defaultFileName = null, PausableAudioHandler pausableAudioHandler = null, double fadeInLength = 0.0) => Task.Run(() => + public static void HandleUIAudio(string audioFileName, string defaultFileName = null, PausableAudioHandler pausableAudioHandler = null, double fadeInLength = 0.0) { if (!BaseUI.Instance.HandleAudio(audioFileName, defaultFileName, pausableAudioHandler, fadeInLength)) { UI.Instance.HandleAudio(audioFileName, defaultFileName, pausableAudioHandler, fadeInLength); } - }); + } public static bool IsPoint(double[] point, double position0, double position1) => IsPoint(point[0], point[1], point[2], point[3], position0, position1); @@ -295,9 +295,9 @@ var dataSet = new Dictionary(); foreach (var dataItem in data) { - if (dataSet.ContainsKey(dataItem)) + if (dataSet.TryGetValue(dataItem, out int value)) { - dataSet[dataItem]++; + dataSet[dataItem] = ++value; } else { diff --git a/Qwilight/View/EventNoteWindow.xaml.cs b/Qwilight/View/EventNoteWindow.xaml.cs index 9706a9e..09f6e33 100644 --- a/Qwilight/View/EventNoteWindow.xaml.cs +++ b/Qwilight/View/EventNoteWindow.xaml.cs @@ -22,6 +22,6 @@ void OnNoteFileView(object sender, KeyEventArgs e) => (DataContext as EventNoteViewModel).OnNoteFileView(e); - void OnInputLower(object sender, KeyEventArgs e) => _ = (DataContext as EventNoteViewModel).OnInputLower(e); + void OnInputLower(object sender, KeyEventArgs e) => (DataContext as EventNoteViewModel).OnInputLower(e); } } \ No newline at end of file diff --git a/Qwilight/View/MainWindow/DefaultMode/EntryView.xaml.cs b/Qwilight/View/MainWindow/DefaultMode/EntryView.xaml.cs index 36492c1..a65466d 100644 --- a/Qwilight/View/MainWindow/DefaultMode/EntryView.xaml.cs +++ b/Qwilight/View/MainWindow/DefaultMode/EntryView.xaml.cs @@ -44,7 +44,7 @@ void OnFitMode(object sender, EventArgs e) => (DataContext as MainViewModel).OnFitMode(); - void OnEntryViewInputLower(object sender, KeyEventArgs e) => _ = (DataContext as MainViewModel).OnEntryViewInputLower(e); + void OnEntryViewInputLower(object sender, KeyEventArgs e) => (DataContext as MainViewModel).OnEntryViewInputLower(e); void OnEntryViewPointLower(object sender, MouseButtonEventArgs e) => (DataContext as MainViewModel).OnEntryViewPointLower(e); diff --git a/Qwilight/ViewModel/ConfigureViewModel.cs b/Qwilight/ViewModel/ConfigureViewModel.cs index aef7ef7..1d34acc 100644 --- a/Qwilight/ViewModel/ConfigureViewModel.cs +++ b/Qwilight/ViewModel/ConfigureViewModel.cs @@ -517,7 +517,7 @@ } [RelayCommand] - static async Task OnInitFavoriteEntry() + static void OnInitFavoriteEntry() { if (StrongReferenceMessenger.Default.Send(new ViewAllowWindow { @@ -527,13 +527,13 @@ { ViewModels.Instance.MainValue.WipeFavoriteEntry(); Configure.Instance.DefaultEntryItems.RemoveWhere(defaultEntryItem => defaultEntryItem.DefaultEntryVarietyValue == DefaultEntryItem.DefaultEntryVariety.Favorite); - await DB.Instance.WipeFavoriteEntry().ConfigureAwait(false); + DB.Instance.WipeFavoriteEntry(); NotifySystem.Instance.Notify(NotifySystem.NotifyVariety.OK, NotifySystem.NotifyConfigure.Default, LanguageSystem.Instance.InitFavoriteEntryOK); } } [RelayCommand] - static async Task OnInitWait() + static void OnInitWait() { if (StrongReferenceMessenger.Default.Send(new ViewAllowWindow { @@ -546,7 +546,7 @@ Configure.Instance.MediaWait = 0.0; Configure.Instance.BanalMediaWait = 0.0; Configure.Instance.NotifyModel(); - await DB.Instance.InitWait().ConfigureAwait(false); + DB.Instance.InitWait(); NotifySystem.Instance.Notify(NotifySystem.NotifyVariety.OK, NotifySystem.NotifyConfigure.Default, LanguageSystem.Instance.InitWaitOK); } } @@ -567,7 +567,7 @@ } [RelayCommand] - static async Task OnInitMedia() + static void OnInitMedia() { if (StrongReferenceMessenger.Default.Send(new ViewAllowWindow { @@ -576,13 +576,13 @@ }) == MESSAGEBOX_RESULT.IDYES) { Configure.Instance.Media = true; - await DB.Instance.InitMedia().ConfigureAwait(false); + DB.Instance.InitMedia(); NotifySystem.Instance.Notify(NotifySystem.NotifyVariety.OK, NotifySystem.NotifyConfigure.Default, LanguageSystem.Instance.InitMediaOK); } } [RelayCommand] - static async Task OnInitComment() + static void OnInitComment() { if (StrongReferenceMessenger.Default.Send(new ViewAllowWindow { @@ -595,7 +595,7 @@ { Utility.WipeFile(commentFilePath); } - await DB.Instance.WipeComment().ConfigureAwait(false); + DB.Instance.WipeComment(); NotifySystem.Instance.Notify(NotifySystem.NotifyVariety.OK, NotifySystem.NotifyConfigure.Default, LanguageSystem.Instance.InitCommentOK); } } @@ -1408,7 +1408,7 @@ var handlingComputer = ViewModels.Instance.MainValue.GetHandlingComputer(); if (handlingComputer != null) { - Task.Run(handlingComputer.SetUIMap); + handlingComputer.SetUIMap(); if (_defaultHunterVariety != Configure.Instance.HunterVarietyV2Value || _defaultNetCommentFollow != Configure.Instance.NetCommentFollow) { handlingComputer.InitNetComments(); diff --git a/Qwilight/ViewModel/EventNoteViewModel.cs b/Qwilight/ViewModel/EventNoteViewModel.cs index 929465d..8c78e08 100644 --- a/Qwilight/ViewModel/EventNoteViewModel.cs +++ b/Qwilight/ViewModel/EventNoteViewModel.cs @@ -78,7 +78,7 @@ } } - public async Task OnInputLower(KeyEventArgs e) + public void OnInputLower(KeyEventArgs e) { if (e.Key == Key.Enter) { @@ -86,7 +86,7 @@ { var eventNoteID = string.Join('/', NoteFileCollection.Select(noteFile => noteFile.GetNoteID512())); var date = DateTime.Now; - await DB.Instance.SetEventNote(eventNoteID, EventNoteName, date, DB.EventNoteVariety.Qwilight).ConfigureAwait(false); + DB.Instance.SetEventNote(eventNoteID, EventNoteName, date, DB.EventNoteVariety.Qwilight); Close(); NoteFileCollection.Clear(); EventNoteName = null; diff --git a/Qwilight/ViewModel/FavoriteEntryViewModel.cs b/Qwilight/ViewModel/FavoriteEntryViewModel.cs index 5fe1dce..1da5b80 100644 --- a/Qwilight/ViewModel/FavoriteEntryViewModel.cs +++ b/Qwilight/ViewModel/FavoriteEntryViewModel.cs @@ -99,7 +99,7 @@ { favoriteEntryItem.FrontEntryPaths.Add(NoteFile.DefaultEntryItem.DefaultEntryPath); } - _ = DB.Instance.SetFavoriteEntry(NoteFile); + DB.Instance.SetFavoriteEntry(NoteFile); break; case EntryItemMode: foreach (var noteFile in EntryItem.NoteFiles) @@ -127,7 +127,7 @@ { favoriteEntryItem.FrontEntryPaths.Add(noteFile.DefaultEntryItem.DefaultEntryPath); } - _ = DB.Instance.SetFavoriteEntry(noteFile); + DB.Instance.SetFavoriteEntry(noteFile); } } break; diff --git a/Qwilight/ViewModel/MainViewModel.cs b/Qwilight/ViewModel/MainViewModel.cs index 9b9a492..62a6862 100644 --- a/Qwilight/ViewModel/MainViewModel.cs +++ b/Qwilight/ViewModel/MainViewModel.cs @@ -642,7 +642,7 @@ { Text = LanguageSystem.Instance.SavingUIContents, Variety = NotifySystem.NotifyVariety.Levying, - OnStop = isTotal => false, + OnStop = wipeTotal => false, }; try { @@ -668,7 +668,7 @@ } finally { - savingUIItem.OnStop = isTotal => true; + savingUIItem.OnStop = wipeTotal => true; } } } @@ -692,7 +692,7 @@ eventNoteID += ":0"; var eventNoteName = eventNote.title; var eventNoteVariety = DB.EventNoteVariety.MD5; - DB.Instance.SetEventNote(eventNoteID, eventNoteName, date, eventNoteVariety).Wait(); + DB.Instance.SetEventNote(eventNoteID, eventNoteName, date, eventNoteVariety); lastEventNoteID = eventNoteID; } catch (SQLiteException) @@ -828,7 +828,7 @@ { Utility.WipeFile(defaultCommentFilePath); } - _ = DB.Instance.WipeComment(defaultCommentFilePath); + DB.Instance.WipeComment(defaultCommentFilePath); } } } @@ -910,7 +910,7 @@ } } - public async Task OnEntryViewInputLower(KeyEventArgs e) + public void OnEntryViewInputLower(KeyEventArgs e) { if (IsNoteFileMode) { @@ -1031,7 +1031,7 @@ Data = MESSAGEBOX_STYLE.MB_YESNO | MESSAGEBOX_STYLE.MB_ICONQUESTION | MESSAGEBOX_STYLE.MB_DEFBUTTON1 }) == MESSAGEBOX_RESULT.IDYES) { - await DB.Instance.WipeEventNote(eventNoteID).ConfigureAwait(false); + DB.Instance.WipeEventNote(eventNoteID); LoadEventNoteEntryItems(); Want(); } @@ -1229,7 +1229,7 @@ var assistFilePath = Path.Combine(noteFile.EntryItem.EntryPath, noteFile.AssistFileName); if (File.Exists(assistFilePath)) { - var format = await DB.Instance.GetFormat(noteFile); + var format = DB.Instance.GetFormat(noteFile); if (format == -1) { var formatComputer = CharsetDetector.DetectFromFile(assistFilePath).Detected; @@ -1314,13 +1314,13 @@ public MainViewModel() { - _loadDefaultCommentHandler.Tick += async (sender, e) => + _loadDefaultCommentHandler.Tick += (sender, e) => { (sender as DispatcherTimer).Stop(); if (EntryItemValue != null) { var targetNoteFiles = EntryItemValue.NoteFiles; - var commentItems = await (IsEntryItemEventNote ? DB.Instance.GetCommentItems(targetNoteFiles[0], EntryItemValue.EventNoteID, targetNoteFiles.Length).ConfigureAwait(false) : DB.Instance.GetCommentItems(EntryItemValue.NoteFile, EntryItemValue.EventNoteID, 1).ConfigureAwait(false)); + var commentItems = (IsEntryItemEventNote ? DB.Instance.GetCommentItems(targetNoteFiles[0], EntryItemValue.EventNoteID, targetNoteFiles.Length) : DB.Instance.GetCommentItems(EntryItemValue.NoteFile, EntryItemValue.EventNoteID, 1)); DefaultCommentCollection.Clear(); foreach (var commentItem in commentItems) @@ -1387,7 +1387,7 @@ noteFile.HandledValue = BaseNoteFile.Handled.Clear; } } - _ = DB.Instance.SetHandled(noteFile); + DB.Instance.SetHandled(noteFile); } } } @@ -1520,6 +1520,7 @@ Configure.Instance.Save(); GPUConfigure.Instance.Save(); + DB.Instance.Save(); FastDB.Instance.Save(); AudioSystem.Instance.Dispose(); @@ -1630,7 +1631,7 @@ { Text = LanguageSystem.Instance.SavingFileContents, Variety = NotifySystem.NotifyVariety.Levying, - OnStop = isTotal => false, + OnStop = wipeTotal => false, }; try { @@ -1689,7 +1690,7 @@ } finally { - savingFileItem.OnStop = isTotal => true; + savingFileItem.OnStop = wipeTotal => true; } } @@ -2508,7 +2509,7 @@ NotifyNoteFile(); Utility.HandleUIAudio("Lower Note File"); BaseUI.Instance.HandleEvent(BaseUI.EventItem.ModifyNoteFile); - _ = DB.Instance.SetNotePosition(EntryItemValue); + DB.Instance.SetNotePosition(EntryItemValue); } } @@ -2519,7 +2520,7 @@ NotifyNoteFile(); Utility.HandleUIAudio("Higher Note File"); BaseUI.Instance.HandleEvent(BaseUI.EventItem.ModifyNoteFile); - _ = DB.Instance.SetNotePosition(EntryItemValue); + DB.Instance.SetNotePosition(EntryItemValue); } } @@ -2635,7 +2636,7 @@ { favoriteEntryItem.FrontEntryPaths.Add(noteFile.DefaultEntryItem.DefaultEntryPath); } - _ = DB.Instance.SetFavoriteEntry(noteFile); + DB.Instance.SetFavoriteEntry(noteFile); } } if (favoriteEntryItemModified != null) @@ -2969,7 +2970,7 @@ { Text = LanguageSystem.Instance.SavingQwilightContents, Variety = NotifySystem.NotifyVariety.Levying, - OnStop = isTotal => false + OnStop = wipeTotal => false }; try { @@ -3021,9 +3022,12 @@ } savingQwilightItem.Variety = NotifySystem.NotifyVariety.Quit; savingQwilightItem.Text = LanguageSystem.Instance.SavedQwilightContents; - savingQwilightItem.OnStop = isTotal => + savingQwilightItem.OnStop = wipeTotal => { - Utility.WipeFile(_qwilightFileName); + if (!wipeTotal) + { + Utility.WipeFile(_qwilightFileName); + } return true; }; NotifySystem.Instance.Notify(NotifySystem.NotifyVariety.Info, NotifySystem.NotifyConfigure.NotSave, savingQwilightItem.Text); @@ -3321,7 +3325,7 @@ ModeValue = Mode.Computing; defaultComputer?.Close(); CloseAutoComputer(); - _ = targetComputer.NoteFile.SetConfigure(); + targetComputer.NoteFile.SetConfigure(); } } @@ -3415,15 +3419,15 @@ if (Configure.Instance.AlwaysNotP2Position != AutoComputer.AlwaysNotP2Position || Configure.Instance.InputMappingValue != AutoComputer.InputMappingValue) { - Task.Run(AutoComputer.SetUIMap); + AutoComputer.SetUIMap(); } } } else { CloseAutoComputer("Default"); - _ = targetNoteFile.SetConfigure(); } + targetNoteFile.SetConfigure(); void NewAutoComputer(double levyingWait, bool doMigrate) { diff --git a/Qwilight/ViewModel/NoteFileViewModel.cs b/Qwilight/ViewModel/NoteFileViewModel.cs index 1512970..4fd88bf 100644 --- a/Qwilight/ViewModel/NoteFileViewModel.cs +++ b/Qwilight/ViewModel/NoteFileViewModel.cs @@ -266,18 +266,18 @@ } [RelayCommand] - async Task OnWipeHandled(int mode) + void OnWipeHandled(int mode) { switch (mode) { case 0: - await DB.Instance.WipeHandled(NoteFile).ConfigureAwait(false); + DB.Instance.WipeHandled(NoteFile); NoteFile.HandledValue = BaseNoteFile.Handled.Not; break; case 1: foreach (var noteFile in EntryItemValue.NoteFiles) { - await DB.Instance.WipeHandled(noteFile).ConfigureAwait(false); + DB.Instance.WipeHandled(noteFile); noteFile.HandledValue = BaseNoteFile.Handled.Not; } break; @@ -300,7 +300,7 @@ inputTextViewModel.Input = EntryItemValue.EventNoteName; inputTextViewModel.HandleOK = new Action(text => { - _ = DB.Instance.ModifyEventNoteName(EntryItemValue.EventNoteID, text); + DB.Instance.ModifyEventNoteName(EntryItemValue.EventNoteID, text); EntryItemValue.EventNoteName = text; }); inputTextViewModel.Open(); @@ -337,7 +337,7 @@ } [RelayCommand] - async Task OnNoteFileFormatID(int? e) + void OnNoteFileFormatID(int? e) { if (e.HasValue) { @@ -346,7 +346,7 @@ var noteFile = EntryItemValue?.NoteFile; if (noteFile != null) { - await DB.Instance.SetNoteFormat(noteFile, noteFormatID).ConfigureAwait(false); + DB.Instance.SetNoteFormat(noteFile, noteFormatID); FastDB.Instance.WipeNoteFile(noteFile); } var mainViewModel = ViewModels.Instance.MainValue; @@ -355,7 +355,7 @@ } [RelayCommand] - async Task OnEntryItemFormatID(int? e) + void OnEntryItemFormatID(int? e) { if (e.HasValue) { @@ -367,7 +367,7 @@ { if (!noteFile.IsLogical) { - await DB.Instance.SetNoteFormat(noteFile, e.Value).ConfigureAwait(false); + DB.Instance.SetNoteFormat(noteFile, e.Value); FastDB.Instance.WipeNoteFile(noteFile); } }