From 4681a38abe732045473549e31aabfc1b9fc3791d Mon Sep 17 00:00:00 2001 From: KIT! Date: Thu, 21 Mar 2024 12:02:33 +0100 Subject: [PATCH] Remembering settings on app restart TSE now stores the last settings you've used when you last started the app. --- Commons/IO/SSL.cs | 4 +- Commons/Utils/Config.cs | 24 +++++ MainForm.Designer.cs | 215 ++++++++++++++++++++------------------- MainForm.RequestFiles.cs | 2 + MainForm.cs | 94 ++++++++--------- 5 files changed, 184 insertions(+), 155 deletions(-) diff --git a/Commons/IO/SSL.cs b/Commons/IO/SSL.cs index a2d2e42..5aa59c0 100644 --- a/Commons/IO/SSL.cs +++ b/Commons/IO/SSL.cs @@ -24,8 +24,8 @@ namespace TaikoSoundEditor.Commons.IO public static void LoadKeys() { - DatatableKey = GetKeyFromString(Config.IniFile.Read("DatatableKey")); - FumenKey = GetKeyFromString(Config.IniFile.Read("FumenKey")); + DatatableKey = GetKeyFromString(Config.DatatableKey); + FumenKey = GetKeyFromString(Config.FumenKey); } private static byte[] DatatableKey = null; diff --git a/Commons/Utils/Config.cs b/Commons/Utils/Config.cs index e026536..f543e55 100644 --- a/Commons/Utils/Config.cs +++ b/Commons/Utils/Config.cs @@ -23,6 +23,30 @@ set => IniFile.Write(DatatableDefPathProperty, value); } + public static string DatatablesPath + { + get => IniFile.Read("DatatablePath"); + set => IniFile.Write("DatatablePath", value); + } + + public static string FumenKey + { + get => IniFile.Read("FumenKey"); + set => IniFile.Write("FumenKey", value); + } + + public static string DatatableKey + { + get => IniFile.Read("DatatableKey"); + set => IniFile.Write("DatatableKey", value); + } + + public static bool UseEncryption + { + get => System.Convert.ToBoolean(IniFile.Read("UseEncryption") == "True" ? true : false); + set => IniFile.Write("UseEncryption", value.ToString()); + } + public static string MusicOrderSort => IniFile.Read(MusicOrderSortProperty); public static string MusicOrderSortProperty = "MusicOrderSort"; diff --git a/MainForm.Designer.cs b/MainForm.Designer.cs index 18c9f05..bd206dd 100644 --- a/MainForm.Designer.cs +++ b/MainForm.Designer.cs @@ -36,7 +36,6 @@ namespace TaikoSoundEditor this.panel1 = new System.Windows.Forms.Panel(); this.groupBox13 = new System.Windows.Forms.GroupBox(); this.label22 = new System.Windows.Forms.Label(); - this.DatatableDef = new TaikoSoundEditor.Commons.Controls.PathSelector(); this.groupBox12 = new System.Windows.Forms.GroupBox(); this.UseEncryptionBox = new System.Windows.Forms.CheckBox(); this.FumenKeyBox = new System.Windows.Forms.TextBox(); @@ -45,16 +44,11 @@ namespace TaikoSoundEditor this.label20 = new System.Windows.Forms.Label(); this.OkButton = new System.Windows.Forms.Button(); this.groupBox2 = new System.Windows.Forms.GroupBox(); - this.DirSelector = new TaikoSoundEditor.Commons.Controls.PathSelector(); this.label1 = new System.Windows.Forms.Label(); this.groupBox1 = new System.Windows.Forms.GroupBox(); this.label5 = new System.Windows.Forms.Label(); this.label6 = new System.Windows.Forms.Label(); this.label7 = new System.Windows.Forms.Label(); - this.WordListPathSelector = new TaikoSoundEditor.Commons.Controls.PathSelector(); - this.MusicInfoPathSelector = new TaikoSoundEditor.Commons.Controls.PathSelector(); - this.MusicOrderPathSelector = new TaikoSoundEditor.Commons.Controls.PathSelector(); - this.MusicAttributePathSelector = new TaikoSoundEditor.Commons.Controls.PathSelector(); this.label8 = new System.Windows.Forms.Label(); this.tabPage2 = new System.Windows.Forms.TabPage(); this.SoundViewTab = new System.Windows.Forms.TabControl(); @@ -99,7 +93,6 @@ namespace TaikoSoundEditor this.WordsGB = new System.Windows.Forms.GroupBox(); this.WordsGrid = new System.Windows.Forms.PropertyGrid(); this.MusicOrderTab = new System.Windows.Forms.TabPage(); - this.MusicOrderViewer = new TaikoSoundEditor.Commons.Controls.MusicOrderViewer(); this.menuStrip1 = new System.Windows.Forms.MenuStrip(); this.preferencesToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); this.musicOrderToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); @@ -137,9 +130,16 @@ namespace TaikoSoundEditor this.label2 = new System.Windows.Forms.Label(); this.SongNameBox = new System.Windows.Forms.TextBox(); this.label9 = new System.Windows.Forms.Label(); + this.label10 = new System.Windows.Forms.Label(); + this.DatatableDef = new TaikoSoundEditor.Commons.Controls.PathSelector(); + this.DirSelector = new TaikoSoundEditor.Commons.Controls.PathSelector(); + this.WordListPathSelector = new TaikoSoundEditor.Commons.Controls.PathSelector(); + this.MusicInfoPathSelector = new TaikoSoundEditor.Commons.Controls.PathSelector(); + this.MusicOrderPathSelector = new TaikoSoundEditor.Commons.Controls.PathSelector(); + this.MusicAttributePathSelector = new TaikoSoundEditor.Commons.Controls.PathSelector(); + this.MusicOrderViewer = new TaikoSoundEditor.Commons.Controls.MusicOrderViewer(); this.TJASelector = new TaikoSoundEditor.Commons.Controls.PathSelector(); this.AudioFileSelector = new TaikoSoundEditor.Commons.Controls.PathSelector(); - this.label10 = new System.Windows.Forms.Label(); this.TabControl.SuspendLayout(); this.tabPage1.SuspendLayout(); this.panel1.SuspendLayout(); @@ -238,19 +238,6 @@ namespace TaikoSoundEditor this.label22.TabIndex = 14; this.label22.Text = "Datatable def"; // - // DatatableDef - // - this.DatatableDef.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.DatatableDef.Filter = "JSON files(*.json)|*.json|All files(*.*)|*.*"; - this.DatatableDef.Location = new System.Drawing.Point(83, 19); - this.DatatableDef.Name = "DatatableDef"; - this.DatatableDef.Path = ""; - this.DatatableDef.SelectsFolder = false; - this.DatatableDef.Size = new System.Drawing.Size(226, 20); - this.DatatableDef.TabIndex = 13; - this.DatatableDef.PathChanged += new TaikoSoundEditor.Commons.Controls.PathSelector.OnPathChanged(this.DatatableDef_PathChanged); - // // groupBox12 // this.groupBox12.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) @@ -276,6 +263,7 @@ namespace TaikoSoundEditor this.UseEncryptionBox.TabIndex = 14; this.UseEncryptionBox.Text = "Use Encryption"; this.UseEncryptionBox.UseVisualStyleBackColor = true; + this.UseEncryptionBox.CheckedChanged += new System.EventHandler(this.UseEncryptionBox_CheckedChanged); // // FumenKeyBox // @@ -339,18 +327,6 @@ namespace TaikoSoundEditor this.groupBox2.TabStop = false; this.groupBox2.Text = "Or specify the game diretory (/datatable)"; // - // DirSelector - // - this.DirSelector.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.DirSelector.Filter = "All files(*.*)|*.*"; - this.DirSelector.Location = new System.Drawing.Point(58, 19); - this.DirSelector.Name = "DirSelector"; - this.DirSelector.Path = ""; - this.DirSelector.SelectsFolder = true; - this.DirSelector.Size = new System.Drawing.Size(251, 20); - this.DirSelector.TabIndex = 11; - // // label1 // this.label1.AutoSize = true; @@ -406,54 +382,6 @@ namespace TaikoSoundEditor this.label7.TabIndex = 13; this.label7.Text = "music_order.bin"; // - // WordListPathSelector - // - this.WordListPathSelector.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.WordListPathSelector.Filter = "Binary files(*.bin)|*.bin|All files(*.*)|*.*"; - this.WordListPathSelector.Location = new System.Drawing.Point(101, 88); - this.WordListPathSelector.Name = "WordListPathSelector"; - this.WordListPathSelector.Path = ""; - this.WordListPathSelector.SelectsFolder = false; - this.WordListPathSelector.Size = new System.Drawing.Size(208, 20); - this.WordListPathSelector.TabIndex = 12; - // - // MusicInfoPathSelector - // - this.MusicInfoPathSelector.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.MusicInfoPathSelector.Filter = "Binary files(*.bin)|*.bin|All files(*.*)|*.*"; - this.MusicInfoPathSelector.Location = new System.Drawing.Point(101, 63); - this.MusicInfoPathSelector.Name = "MusicInfoPathSelector"; - this.MusicInfoPathSelector.Path = ""; - this.MusicInfoPathSelector.SelectsFolder = false; - this.MusicInfoPathSelector.Size = new System.Drawing.Size(208, 20); - this.MusicInfoPathSelector.TabIndex = 11; - // - // MusicOrderPathSelector - // - this.MusicOrderPathSelector.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.MusicOrderPathSelector.Filter = "Binary files(*.bin)|*.bin|All files(*.*)|*.*"; - this.MusicOrderPathSelector.Location = new System.Drawing.Point(101, 38); - this.MusicOrderPathSelector.Name = "MusicOrderPathSelector"; - this.MusicOrderPathSelector.Path = ""; - this.MusicOrderPathSelector.SelectsFolder = false; - this.MusicOrderPathSelector.Size = new System.Drawing.Size(208, 20); - this.MusicOrderPathSelector.TabIndex = 10; - // - // MusicAttributePathSelector - // - this.MusicAttributePathSelector.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.MusicAttributePathSelector.Filter = "Binary files(*.bin)|*.bin|All files(*.*)|*.*"; - this.MusicAttributePathSelector.Location = new System.Drawing.Point(101, 13); - this.MusicAttributePathSelector.Name = "MusicAttributePathSelector"; - this.MusicAttributePathSelector.Path = ""; - this.MusicAttributePathSelector.SelectsFolder = false; - this.MusicAttributePathSelector.Size = new System.Drawing.Size(208, 20); - this.MusicAttributePathSelector.TabIndex = 9; - // // label8 // this.label8.AutoSize = true; @@ -921,23 +849,6 @@ namespace TaikoSoundEditor this.MusicOrderTab.Text = "Music Order"; this.MusicOrderTab.UseVisualStyleBackColor = true; // - // MusicOrderViewer - // - this.MusicOrderViewer.CurrentPage = 0; - this.MusicOrderViewer.CutActive = false; - this.MusicOrderViewer.Dock = System.Windows.Forms.DockStyle.Fill; - this.MusicOrderViewer.ItemsPerCol = 5; - this.MusicOrderViewer.ItemsPerRow = 4; - this.MusicOrderViewer.Location = new System.Drawing.Point(3, 3); - this.MusicOrderViewer.Name = "MusicOrderViewer"; - this.MusicOrderViewer.PasteActive = false; - this.MusicOrderViewer.PasteMode = false; - this.MusicOrderViewer.RemoveActive = false; - this.MusicOrderViewer.Size = new System.Drawing.Size(439, 231); - this.MusicOrderViewer.TabIndex = 0; - this.MusicOrderViewer.SongRemoved += new TaikoSoundEditor.Commons.Controls.MusicOrderViewer.OnSongRemoved(this.MusicOrderViewer_SongRemoved); - this.MusicOrderViewer.SongDoubleClick += new TaikoSoundEditor.Commons.Controls.MusicOrderViewer.OnSongDoubleClick(this.MusicOrderViewer_SongDoubleClick); - // // menuStrip1 // this.menuStrip1.BackColor = System.Drawing.Color.Transparent; @@ -1346,6 +1257,105 @@ namespace TaikoSoundEditor this.label9.TabIndex = 13; this.label9.Text = "TJA file"; // + // label10 + // + this.label10.AutoSize = true; + this.label10.Location = new System.Drawing.Point(5, 61); + this.label10.Name = "label10"; + this.label10.Size = new System.Drawing.Size(50, 13); + this.label10.TabIndex = 8; + this.label10.Text = "Audio file"; + // + // DatatableDef + // + this.DatatableDef.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.DatatableDef.Filter = "JSON files(*.json)|*.json|All files(*.*)|*.*"; + this.DatatableDef.Location = new System.Drawing.Point(83, 19); + this.DatatableDef.Name = "DatatableDef"; + this.DatatableDef.Path = ""; + this.DatatableDef.SelectsFolder = false; + this.DatatableDef.Size = new System.Drawing.Size(226, 20); + this.DatatableDef.TabIndex = 13; + this.DatatableDef.PathChanged += new TaikoSoundEditor.Commons.Controls.PathSelector.OnPathChanged(this.DatatableDef_PathChanged); + // + // DirSelector + // + this.DirSelector.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.DirSelector.Filter = "All files(*.*)|*.*"; + this.DirSelector.Location = new System.Drawing.Point(58, 19); + this.DirSelector.Name = "DirSelector"; + this.DirSelector.Path = ""; + this.DirSelector.SelectsFolder = true; + this.DirSelector.Size = new System.Drawing.Size(251, 20); + this.DirSelector.TabIndex = 11; + // + // WordListPathSelector + // + this.WordListPathSelector.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.WordListPathSelector.Filter = "Binary files(*.bin)|*.bin|All files(*.*)|*.*"; + this.WordListPathSelector.Location = new System.Drawing.Point(101, 88); + this.WordListPathSelector.Name = "WordListPathSelector"; + this.WordListPathSelector.Path = ""; + this.WordListPathSelector.SelectsFolder = false; + this.WordListPathSelector.Size = new System.Drawing.Size(208, 20); + this.WordListPathSelector.TabIndex = 12; + // + // MusicInfoPathSelector + // + this.MusicInfoPathSelector.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.MusicInfoPathSelector.Filter = "Binary files(*.bin)|*.bin|All files(*.*)|*.*"; + this.MusicInfoPathSelector.Location = new System.Drawing.Point(101, 63); + this.MusicInfoPathSelector.Name = "MusicInfoPathSelector"; + this.MusicInfoPathSelector.Path = ""; + this.MusicInfoPathSelector.SelectsFolder = false; + this.MusicInfoPathSelector.Size = new System.Drawing.Size(208, 20); + this.MusicInfoPathSelector.TabIndex = 11; + // + // MusicOrderPathSelector + // + this.MusicOrderPathSelector.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.MusicOrderPathSelector.Filter = "Binary files(*.bin)|*.bin|All files(*.*)|*.*"; + this.MusicOrderPathSelector.Location = new System.Drawing.Point(101, 38); + this.MusicOrderPathSelector.Name = "MusicOrderPathSelector"; + this.MusicOrderPathSelector.Path = ""; + this.MusicOrderPathSelector.SelectsFolder = false; + this.MusicOrderPathSelector.Size = new System.Drawing.Size(208, 20); + this.MusicOrderPathSelector.TabIndex = 10; + // + // MusicAttributePathSelector + // + this.MusicAttributePathSelector.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.MusicAttributePathSelector.Filter = "Binary files(*.bin)|*.bin|All files(*.*)|*.*"; + this.MusicAttributePathSelector.Location = new System.Drawing.Point(101, 13); + this.MusicAttributePathSelector.Name = "MusicAttributePathSelector"; + this.MusicAttributePathSelector.Path = ""; + this.MusicAttributePathSelector.SelectsFolder = false; + this.MusicAttributePathSelector.Size = new System.Drawing.Size(208, 20); + this.MusicAttributePathSelector.TabIndex = 9; + // + // MusicOrderViewer + // + this.MusicOrderViewer.CurrentPage = 0; + this.MusicOrderViewer.CutActive = false; + this.MusicOrderViewer.Dock = System.Windows.Forms.DockStyle.Fill; + this.MusicOrderViewer.ItemsPerCol = 5; + this.MusicOrderViewer.ItemsPerRow = 4; + this.MusicOrderViewer.Location = new System.Drawing.Point(3, 3); + this.MusicOrderViewer.Name = "MusicOrderViewer"; + this.MusicOrderViewer.PasteActive = false; + this.MusicOrderViewer.PasteMode = false; + this.MusicOrderViewer.RemoveActive = false; + this.MusicOrderViewer.Size = new System.Drawing.Size(439, 231); + this.MusicOrderViewer.TabIndex = 0; + this.MusicOrderViewer.SongRemoved += new TaikoSoundEditor.Commons.Controls.MusicOrderViewer.OnSongRemoved(this.MusicOrderViewer_SongRemoved); + this.MusicOrderViewer.SongDoubleClick += new TaikoSoundEditor.Commons.Controls.MusicOrderViewer.OnSongDoubleClick(this.MusicOrderViewer_SongDoubleClick); + // // TJASelector // this.TJASelector.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) @@ -1372,15 +1382,6 @@ namespace TaikoSoundEditor this.AudioFileSelector.Size = new System.Drawing.Size(150, 20); this.AudioFileSelector.TabIndex = 9; // - // label10 - // - this.label10.AutoSize = true; - this.label10.Location = new System.Drawing.Point(5, 61); - this.label10.Name = "label10"; - this.label10.Size = new System.Drawing.Size(50, 13); - this.label10.TabIndex = 8; - this.label10.Text = "Audio file"; - // // MainForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); diff --git a/MainForm.RequestFiles.cs b/MainForm.RequestFiles.cs index 1b804de..c2781a4 100644 --- a/MainForm.RequestFiles.cs +++ b/MainForm.RequestFiles.cs @@ -46,6 +46,8 @@ namespace TaikoSoundEditor var files = new string[] { "music_attribute.bin", "music_order.bin", "musicinfo.bin", "wordlist.bin" }; var sels = new PathSelector[] { MusicAttributePathSelector, MusicOrderPathSelector, MusicInfoPathSelector, WordListPathSelector }; + Config.DatatablesPath = dir; + List NotFoundFiles = new List(); for (int i = 0; i < files.Length; i++) diff --git a/MainForm.cs b/MainForm.cs index f6c947d..6024328 100644 --- a/MainForm.cs +++ b/MainForm.cs @@ -14,38 +14,47 @@ namespace TaikoSoundEditor public MainForm() { InitializeComponent(); + //Init button event handlers MusicAttributePathSelector.PathChanged += MusicAttributePathSelector_PathChanged; MusicOrderPathSelector.PathChanged += MusicOrderPathSelector_PathChanged; MusicInfoPathSelector.PathChanged += MusicInfoPathSelector_PathChanged; WordListPathSelector.PathChanged += WordListPathSelector_PathChanged; DirSelector.PathChanged += DirSelector_PathChanged; - + + UseEncryptionBox.Checked = Config.UseEncryption; + + //If path is set for the datatable folder, update paths for all the files. + if (Config.DatatablesPath != "") + { + DirSelector.Path = Config.DatatablesPath; + DirSelector_PathChanged(null, null); + } + + DatatableKeyBox.Text = Config.DatatableKey; + FumenKeyBox.Text = Config.FumenKey; + + DatatableDef.Path = Config.DatatableDefPath; + + //Other stuff AddedMusicBinding.DataSource = AddedMusic; NewSoundsBox.DataSource = AddedMusicBinding; TabControl.SelectedIndexChanged += TabControl_SelectedIndexChanged; SimpleGenreBox.DataSource = Enum.GetValues(typeof(Genre)); - - DatatableKeyBox.Text = Config.IniFile.Read("DatatableKey"); - FumenKeyBox.Text = Config.IniFile.Read("FumenKey"); - LoadPreferences(); - DatatableDef.Path = Config.DatatableDefPath; - //SortByGenreToolStripMenuItem.RadioCheck = true; } - private void TabControl_SelectedIndexChanged(object sender, EventArgs e) - { + private void TabControl_SelectedIndexChanged(object sender, EventArgs e) => Logger.Info($"Commuted to tab {TabControl.SelectedIndex}.{TabControl.Name}"); - } + #region Editor private void LoadMusicInfo(IMusicInfo item) - { + { Logger.Info($"Showing properties for MusicInfo: {item}"); - if(item==null) + if (item == null) { MusicInfoGrid.SelectedObject = null; MusicAttributesGrid.SelectedObject = null; @@ -174,7 +183,7 @@ namespace TaikoSoundEditor WordList.Items.Remove(wd); Logger.Info("Refreshing list"); - RefreshExistingSongsListView(); + RefreshExistingSongsListView(); var sel = LoadedMusicBox.SelectedIndex; @@ -251,7 +260,7 @@ namespace TaikoSoundEditor WordList.GetBySong(item.Id).JapaneseText = SimpleTitleBox.Text; WordList.GetBySongSub(item.Id).JapaneseText = SimpleSubtitleBox.Text; WordList.GetBySongDetail(item.Id).JapaneseText = SimpleDetailBox.Text; - MusicOrders.GetByUniqueId(item.UniqueId).Genre = item.Genre = (Genre)(SimpleGenreBox.SelectedItem ?? Genre.Pop); + MusicOrders.GetByUniqueId(item.UniqueId).Genre = item.Genre = (Genre)(SimpleGenreBox.SelectedItem ?? Genre.Pop); item.StarEasy = (int)SimpleStarEasyBox.Value; item.StarNormal = (int)SimpleStarNormalBox.Value; item.StarHard = (int)SimpleStarHardBox.Value; @@ -259,20 +268,20 @@ namespace TaikoSoundEditor item.StarUra = (int)SimpleStarUraBox.Value; return; } - else if(NewSoundsBox.SelectedItem!=null) + else if (NewSoundsBox.SelectedItem != null) { var item = NewSoundsBox.SelectedItem as NewSongData; Logger.Info($"Simple Box changed : {(sender as Control).Name} to value {(sender as Control).Text}"); - + item.Word.JapaneseText = SimpleTitleBox.Text; item.WordSub.JapaneseText = SimpleSubtitleBox.Text; item.WordDetail.JapaneseText = SimpleDetailBox.Text; item.MusicOrder.Genre = item.MusicInfo.Genre = (Genre)(SimpleGenreBox.SelectedItem ?? Genre.Pop); - item.MusicInfo.StarEasy=(int)SimpleStarEasyBox.Value; - item.MusicInfo.StarNormal=(int)SimpleStarNormalBox.Value; - item.MusicInfo.StarHard=(int)SimpleStarHardBox.Value; - item.MusicInfo.StarMania=(int)SimpleStarManiaBox.Value; + item.MusicInfo.StarEasy = (int)SimpleStarEasyBox.Value; + item.MusicInfo.StarNormal = (int)SimpleStarNormalBox.Value; + item.MusicInfo.StarHard = (int)SimpleStarHardBox.Value; + item.MusicInfo.StarMania = (int)SimpleStarManiaBox.Value; item.MusicInfo.StarUra = (int)SimpleStarUraBox.Value; return; } @@ -328,7 +337,7 @@ namespace TaikoSoundEditor { var uid = mo.UniqueId; var mi = LoadedMusicBox.Items.Cast().Where(_ => _.UniqueId == uid).FirstOrDefault(); - if(mi!=null) + if (mi != null) { LoadedMusicBox.SelectedItem = mi; return; @@ -336,16 +345,13 @@ namespace TaikoSoundEditor var ns = AddedMusic.Where(_ => _.UniqueId == uid).FirstOrDefault(); if (ns != null) { - NewSoundsBox.SelectedItem = ns; + NewSoundsBox.SelectedItem = ns; return; } } - private void SearchBox_TextChanged(object sender, EventArgs e) - { - RefreshExistingSongsListView(); - } + private void SearchBox_TextChanged(object sender, EventArgs e) => RefreshExistingSongsListView(); private void RefreshExistingSongsListView() { @@ -354,7 +360,7 @@ namespace TaikoSoundEditor { if (string.IsNullOrEmpty(SearchBox.Text)) return true; - if (int.TryParse(SearchBox.Text, out int uid) && mi.UniqueId == uid) + if (int.TryParse(SearchBox.Text, out int uid) && mi.UniqueId == uid) { return true; } @@ -371,12 +377,12 @@ namespace TaikoSoundEditor { SortByGenreToolStripMenuItem.Checked = SortByIdToolStripMenuItem.Checked = NoSortToolStripMenuItem.Checked = false; - if (sender == SortByGenreToolStripMenuItem) + if (sender == SortByGenreToolStripMenuItem) { SortByGenreToolStripMenuItem.Checked = true; Config.SetMusicOrderSortByGenre(); } - else if(sender == SortByIdToolStripMenuItem) + else if (sender == SortByIdToolStripMenuItem) { SortByIdToolStripMenuItem.Checked = true; Config.SetMusicOrderSortById(); @@ -395,7 +401,7 @@ namespace TaikoSoundEditor { SortByGenreToolStripMenuItem.PerformClick(); } - else if (musicOrderSort == Config.MusicOrderSortValueId) + else if (musicOrderSort == Config.MusicOrderSortValueId) { SortByIdToolStripMenuItem.PerformClick(); } @@ -406,42 +412,38 @@ namespace TaikoSoundEditor } private void checkForUpdatesToolStripMenuItem_Click(object sender, EventArgs e) => ExceptionGuard.Run(() => - { + { //var rel = await Updates.GetLatestTja2Fumen(); }); - private void DatatableKeyBox_TextChanged(object sender, EventArgs e) - { - Config.IniFile.Write("DatatableKey", DatatableKeyBox.Text); - } + private void DatatableKeyBox_TextChanged(object sender, EventArgs e) => Config.DatatableKey = DatatableKeyBox.Text; - private void FumenKeyBox_TextChanged(object sender, EventArgs e) - { - Config.IniFile.Write("FumenKey", FumenKeyBox.Text); - } + private void FumenKeyBox_TextChanged(object sender, EventArgs e) => Config.FumenKey = FumenKeyBox.Text; private void LoadedMusicBox_DrawItem(object sender, DrawItemEventArgs e) - { - e.DrawBackground(); - if (e.Index<0 || e.Index >= LoadedMusicBox.Items.Count) + { + e.DrawBackground(); + if (e.Index < 0 || e.Index >= LoadedMusicBox.Items.Count) return; var selItem = LoadedMusicBox.Items[e.Index] as IMusicInfo; TextRenderer.DrawText(e.Graphics, $"{selItem.UniqueId}. {selItem.Id}", Font, e.Bounds, e.ForeColor, e.BackColor, TextFormatFlags.Left | TextFormatFlags.VerticalCenter); e.DrawFocusRectangle(); - } + } + private void DatatableDef_PathChanged(object sender, EventArgs args) { try { var json = File.ReadAllText(DatatableDef.Path); DatatableTypes.LoadFromJson(json); - Config.DatatableDefPath = DatatableDef.Path; + Config.DatatableDefPath = DatatableDef.Path; } - catch(Exception e) + catch (Exception e) { MessageBox.Show(e.Message); } } - + + private void UseEncryptionBox_CheckedChanged(object sender, EventArgs e) => Config.UseEncryption = UseEncryptionBox.Checked; } } \ No newline at end of file