1
0
mirror of synced 2024-12-18 04:45:55 +01:00

Merge pull request #6 from AkaiiKitsune/master

Remembering settings on app restart
This commit is contained in:
Farewell_ 2024-03-21 12:05:13 +01:00 committed by GitHub
commit 4f106243e4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 184 additions and 155 deletions

View File

@ -24,8 +24,8 @@ namespace TaikoSoundEditor.Commons.IO
public static void LoadKeys() public static void LoadKeys()
{ {
DatatableKey = GetKeyFromString(Config.IniFile.Read("DatatableKey")); DatatableKey = GetKeyFromString(Config.DatatableKey);
FumenKey = GetKeyFromString(Config.IniFile.Read("FumenKey")); FumenKey = GetKeyFromString(Config.FumenKey);
} }
private static byte[] DatatableKey = null; private static byte[] DatatableKey = null;

View File

@ -23,6 +23,30 @@
set => IniFile.Write(DatatableDefPathProperty, value); 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 MusicOrderSort => IniFile.Read(MusicOrderSortProperty);
public static string MusicOrderSortProperty = "MusicOrderSort"; public static string MusicOrderSortProperty = "MusicOrderSort";

215
MainForm.Designer.cs generated
View File

@ -36,7 +36,6 @@ namespace TaikoSoundEditor
this.panel1 = new System.Windows.Forms.Panel(); this.panel1 = new System.Windows.Forms.Panel();
this.groupBox13 = new System.Windows.Forms.GroupBox(); this.groupBox13 = new System.Windows.Forms.GroupBox();
this.label22 = new System.Windows.Forms.Label(); this.label22 = new System.Windows.Forms.Label();
this.DatatableDef = new TaikoSoundEditor.Commons.Controls.PathSelector();
this.groupBox12 = new System.Windows.Forms.GroupBox(); this.groupBox12 = new System.Windows.Forms.GroupBox();
this.UseEncryptionBox = new System.Windows.Forms.CheckBox(); this.UseEncryptionBox = new System.Windows.Forms.CheckBox();
this.FumenKeyBox = new System.Windows.Forms.TextBox(); this.FumenKeyBox = new System.Windows.Forms.TextBox();
@ -45,16 +44,11 @@ namespace TaikoSoundEditor
this.label20 = new System.Windows.Forms.Label(); this.label20 = new System.Windows.Forms.Label();
this.OkButton = new System.Windows.Forms.Button(); this.OkButton = new System.Windows.Forms.Button();
this.groupBox2 = new System.Windows.Forms.GroupBox(); this.groupBox2 = new System.Windows.Forms.GroupBox();
this.DirSelector = new TaikoSoundEditor.Commons.Controls.PathSelector();
this.label1 = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label();
this.groupBox1 = new System.Windows.Forms.GroupBox(); this.groupBox1 = new System.Windows.Forms.GroupBox();
this.label5 = new System.Windows.Forms.Label(); this.label5 = new System.Windows.Forms.Label();
this.label6 = new System.Windows.Forms.Label(); this.label6 = new System.Windows.Forms.Label();
this.label7 = 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.label8 = new System.Windows.Forms.Label();
this.tabPage2 = new System.Windows.Forms.TabPage(); this.tabPage2 = new System.Windows.Forms.TabPage();
this.SoundViewTab = new System.Windows.Forms.TabControl(); this.SoundViewTab = new System.Windows.Forms.TabControl();
@ -99,7 +93,6 @@ namespace TaikoSoundEditor
this.WordsGB = new System.Windows.Forms.GroupBox(); this.WordsGB = new System.Windows.Forms.GroupBox();
this.WordsGrid = new System.Windows.Forms.PropertyGrid(); this.WordsGrid = new System.Windows.Forms.PropertyGrid();
this.MusicOrderTab = new System.Windows.Forms.TabPage(); this.MusicOrderTab = new System.Windows.Forms.TabPage();
this.MusicOrderViewer = new TaikoSoundEditor.Commons.Controls.MusicOrderViewer();
this.menuStrip1 = new System.Windows.Forms.MenuStrip(); this.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.preferencesToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); this.preferencesToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
this.musicOrderToolStripMenuItem = 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.label2 = new System.Windows.Forms.Label();
this.SongNameBox = new System.Windows.Forms.TextBox(); this.SongNameBox = new System.Windows.Forms.TextBox();
this.label9 = new System.Windows.Forms.Label(); 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.TJASelector = new TaikoSoundEditor.Commons.Controls.PathSelector();
this.AudioFileSelector = new TaikoSoundEditor.Commons.Controls.PathSelector(); this.AudioFileSelector = new TaikoSoundEditor.Commons.Controls.PathSelector();
this.label10 = new System.Windows.Forms.Label();
this.TabControl.SuspendLayout(); this.TabControl.SuspendLayout();
this.tabPage1.SuspendLayout(); this.tabPage1.SuspendLayout();
this.panel1.SuspendLayout(); this.panel1.SuspendLayout();
@ -238,19 +238,6 @@ namespace TaikoSoundEditor
this.label22.TabIndex = 14; this.label22.TabIndex = 14;
this.label22.Text = "Datatable def"; 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 // groupBox12
// //
this.groupBox12.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 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.TabIndex = 14;
this.UseEncryptionBox.Text = "Use Encryption"; this.UseEncryptionBox.Text = "Use Encryption";
this.UseEncryptionBox.UseVisualStyleBackColor = true; this.UseEncryptionBox.UseVisualStyleBackColor = true;
this.UseEncryptionBox.CheckedChanged += new System.EventHandler(this.UseEncryptionBox_CheckedChanged);
// //
// FumenKeyBox // FumenKeyBox
// //
@ -339,18 +327,6 @@ namespace TaikoSoundEditor
this.groupBox2.TabStop = false; this.groupBox2.TabStop = false;
this.groupBox2.Text = "Or specify the game diretory (/datatable)"; 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 // label1
// //
this.label1.AutoSize = true; this.label1.AutoSize = true;
@ -406,54 +382,6 @@ namespace TaikoSoundEditor
this.label7.TabIndex = 13; this.label7.TabIndex = 13;
this.label7.Text = "music_order.bin"; 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 // label8
// //
this.label8.AutoSize = true; this.label8.AutoSize = true;
@ -921,23 +849,6 @@ namespace TaikoSoundEditor
this.MusicOrderTab.Text = "Music Order"; this.MusicOrderTab.Text = "Music Order";
this.MusicOrderTab.UseVisualStyleBackColor = true; 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 // menuStrip1
// //
this.menuStrip1.BackColor = System.Drawing.Color.Transparent; this.menuStrip1.BackColor = System.Drawing.Color.Transparent;
@ -1346,6 +1257,105 @@ namespace TaikoSoundEditor
this.label9.TabIndex = 13; this.label9.TabIndex = 13;
this.label9.Text = "TJA file"; 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 // TJASelector
// //
this.TJASelector.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 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.Size = new System.Drawing.Size(150, 20);
this.AudioFileSelector.TabIndex = 9; 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 // MainForm
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);

View File

@ -46,6 +46,8 @@ namespace TaikoSoundEditor
var files = new string[] { "music_attribute.bin", "music_order.bin", "musicinfo.bin", "wordlist.bin" }; var files = new string[] { "music_attribute.bin", "music_order.bin", "musicinfo.bin", "wordlist.bin" };
var sels = new PathSelector[] { MusicAttributePathSelector, MusicOrderPathSelector, MusicInfoPathSelector, WordListPathSelector }; var sels = new PathSelector[] { MusicAttributePathSelector, MusicOrderPathSelector, MusicInfoPathSelector, WordListPathSelector };
Config.DatatablesPath = dir;
List<string> NotFoundFiles = new List<string>(); List<string> NotFoundFiles = new List<string>();
for (int i = 0; i < files.Length; i++) for (int i = 0; i < files.Length; i++)

View File

@ -14,38 +14,47 @@ namespace TaikoSoundEditor
public MainForm() public MainForm()
{ {
InitializeComponent(); InitializeComponent();
//Init button event handlers
MusicAttributePathSelector.PathChanged += MusicAttributePathSelector_PathChanged; MusicAttributePathSelector.PathChanged += MusicAttributePathSelector_PathChanged;
MusicOrderPathSelector.PathChanged += MusicOrderPathSelector_PathChanged; MusicOrderPathSelector.PathChanged += MusicOrderPathSelector_PathChanged;
MusicInfoPathSelector.PathChanged += MusicInfoPathSelector_PathChanged; MusicInfoPathSelector.PathChanged += MusicInfoPathSelector_PathChanged;
WordListPathSelector.PathChanged += WordListPathSelector_PathChanged; WordListPathSelector.PathChanged += WordListPathSelector_PathChanged;
DirSelector.PathChanged += DirSelector_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; AddedMusicBinding.DataSource = AddedMusic;
NewSoundsBox.DataSource = AddedMusicBinding; NewSoundsBox.DataSource = AddedMusicBinding;
TabControl.SelectedIndexChanged += TabControl_SelectedIndexChanged; TabControl.SelectedIndexChanged += TabControl_SelectedIndexChanged;
SimpleGenreBox.DataSource = Enum.GetValues(typeof(Genre)); SimpleGenreBox.DataSource = Enum.GetValues(typeof(Genre));
DatatableKeyBox.Text = Config.IniFile.Read("DatatableKey");
FumenKeyBox.Text = Config.IniFile.Read("FumenKey");
LoadPreferences(); 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}"); Logger.Info($"Commuted to tab {TabControl.SelectedIndex}.{TabControl.Name}");
}
#region Editor #region Editor
private void LoadMusicInfo(IMusicInfo item) private void LoadMusicInfo(IMusicInfo item)
{ {
Logger.Info($"Showing properties for MusicInfo: {item}"); Logger.Info($"Showing properties for MusicInfo: {item}");
if(item==null) if (item == null)
{ {
MusicInfoGrid.SelectedObject = null; MusicInfoGrid.SelectedObject = null;
MusicAttributesGrid.SelectedObject = null; MusicAttributesGrid.SelectedObject = null;
@ -174,7 +183,7 @@ namespace TaikoSoundEditor
WordList.Items.Remove(wd); WordList.Items.Remove(wd);
Logger.Info("Refreshing list"); Logger.Info("Refreshing list");
RefreshExistingSongsListView(); RefreshExistingSongsListView();
var sel = LoadedMusicBox.SelectedIndex; var sel = LoadedMusicBox.SelectedIndex;
@ -251,7 +260,7 @@ namespace TaikoSoundEditor
WordList.GetBySong(item.Id).JapaneseText = SimpleTitleBox.Text; WordList.GetBySong(item.Id).JapaneseText = SimpleTitleBox.Text;
WordList.GetBySongSub(item.Id).JapaneseText = SimpleSubtitleBox.Text; WordList.GetBySongSub(item.Id).JapaneseText = SimpleSubtitleBox.Text;
WordList.GetBySongDetail(item.Id).JapaneseText = SimpleDetailBox.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.StarEasy = (int)SimpleStarEasyBox.Value;
item.StarNormal = (int)SimpleStarNormalBox.Value; item.StarNormal = (int)SimpleStarNormalBox.Value;
item.StarHard = (int)SimpleStarHardBox.Value; item.StarHard = (int)SimpleStarHardBox.Value;
@ -259,20 +268,20 @@ namespace TaikoSoundEditor
item.StarUra = (int)SimpleStarUraBox.Value; item.StarUra = (int)SimpleStarUraBox.Value;
return; return;
} }
else if(NewSoundsBox.SelectedItem!=null) else if (NewSoundsBox.SelectedItem != null)
{ {
var item = NewSoundsBox.SelectedItem as NewSongData; var item = NewSoundsBox.SelectedItem as NewSongData;
Logger.Info($"Simple Box changed : {(sender as Control).Name} to value {(sender as Control).Text}"); Logger.Info($"Simple Box changed : {(sender as Control).Name} to value {(sender as Control).Text}");
item.Word.JapaneseText = SimpleTitleBox.Text; item.Word.JapaneseText = SimpleTitleBox.Text;
item.WordSub.JapaneseText = SimpleSubtitleBox.Text; item.WordSub.JapaneseText = SimpleSubtitleBox.Text;
item.WordDetail.JapaneseText = SimpleDetailBox.Text; item.WordDetail.JapaneseText = SimpleDetailBox.Text;
item.MusicOrder.Genre = item.MusicInfo.Genre = (Genre)(SimpleGenreBox.SelectedItem ?? Genre.Pop); item.MusicOrder.Genre = item.MusicInfo.Genre = (Genre)(SimpleGenreBox.SelectedItem ?? Genre.Pop);
item.MusicInfo.StarEasy=(int)SimpleStarEasyBox.Value; item.MusicInfo.StarEasy = (int)SimpleStarEasyBox.Value;
item.MusicInfo.StarNormal=(int)SimpleStarNormalBox.Value; item.MusicInfo.StarNormal = (int)SimpleStarNormalBox.Value;
item.MusicInfo.StarHard=(int)SimpleStarHardBox.Value; item.MusicInfo.StarHard = (int)SimpleStarHardBox.Value;
item.MusicInfo.StarMania=(int)SimpleStarManiaBox.Value; item.MusicInfo.StarMania = (int)SimpleStarManiaBox.Value;
item.MusicInfo.StarUra = (int)SimpleStarUraBox.Value; item.MusicInfo.StarUra = (int)SimpleStarUraBox.Value;
return; return;
} }
@ -328,7 +337,7 @@ namespace TaikoSoundEditor
{ {
var uid = mo.UniqueId; var uid = mo.UniqueId;
var mi = LoadedMusicBox.Items.Cast<IMusicInfo>().Where(_ => _.UniqueId == uid).FirstOrDefault(); var mi = LoadedMusicBox.Items.Cast<IMusicInfo>().Where(_ => _.UniqueId == uid).FirstOrDefault();
if(mi!=null) if (mi != null)
{ {
LoadedMusicBox.SelectedItem = mi; LoadedMusicBox.SelectedItem = mi;
return; return;
@ -336,16 +345,13 @@ namespace TaikoSoundEditor
var ns = AddedMusic.Where(_ => _.UniqueId == uid).FirstOrDefault(); var ns = AddedMusic.Where(_ => _.UniqueId == uid).FirstOrDefault();
if (ns != null) if (ns != null)
{ {
NewSoundsBox.SelectedItem = ns; NewSoundsBox.SelectedItem = ns;
return; return;
} }
} }
private void SearchBox_TextChanged(object sender, EventArgs e) private void SearchBox_TextChanged(object sender, EventArgs e) => RefreshExistingSongsListView();
{
RefreshExistingSongsListView();
}
private void RefreshExistingSongsListView() private void RefreshExistingSongsListView()
{ {
@ -354,7 +360,7 @@ namespace TaikoSoundEditor
{ {
if (string.IsNullOrEmpty(SearchBox.Text)) if (string.IsNullOrEmpty(SearchBox.Text))
return true; 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; return true;
} }
@ -371,12 +377,12 @@ namespace TaikoSoundEditor
{ {
SortByGenreToolStripMenuItem.Checked = SortByIdToolStripMenuItem.Checked = NoSortToolStripMenuItem.Checked = false; SortByGenreToolStripMenuItem.Checked = SortByIdToolStripMenuItem.Checked = NoSortToolStripMenuItem.Checked = false;
if (sender == SortByGenreToolStripMenuItem) if (sender == SortByGenreToolStripMenuItem)
{ {
SortByGenreToolStripMenuItem.Checked = true; SortByGenreToolStripMenuItem.Checked = true;
Config.SetMusicOrderSortByGenre(); Config.SetMusicOrderSortByGenre();
} }
else if(sender == SortByIdToolStripMenuItem) else if (sender == SortByIdToolStripMenuItem)
{ {
SortByIdToolStripMenuItem.Checked = true; SortByIdToolStripMenuItem.Checked = true;
Config.SetMusicOrderSortById(); Config.SetMusicOrderSortById();
@ -395,7 +401,7 @@ namespace TaikoSoundEditor
{ {
SortByGenreToolStripMenuItem.PerformClick(); SortByGenreToolStripMenuItem.PerformClick();
} }
else if (musicOrderSort == Config.MusicOrderSortValueId) else if (musicOrderSort == Config.MusicOrderSortValueId)
{ {
SortByIdToolStripMenuItem.PerformClick(); SortByIdToolStripMenuItem.PerformClick();
} }
@ -406,42 +412,38 @@ namespace TaikoSoundEditor
} }
private void checkForUpdatesToolStripMenuItem_Click(object sender, EventArgs e) => ExceptionGuard.Run(() => private void checkForUpdatesToolStripMenuItem_Click(object sender, EventArgs e) => ExceptionGuard.Run(() =>
{ {
//var rel = await Updates.GetLatestTja2Fumen(); //var rel = await Updates.GetLatestTja2Fumen();
}); });
private void DatatableKeyBox_TextChanged(object sender, EventArgs e) private void DatatableKeyBox_TextChanged(object sender, EventArgs e) => Config.DatatableKey = DatatableKeyBox.Text;
{
Config.IniFile.Write("DatatableKey", DatatableKeyBox.Text);
}
private void FumenKeyBox_TextChanged(object sender, EventArgs e) private void FumenKeyBox_TextChanged(object sender, EventArgs e) => Config.FumenKey = FumenKeyBox.Text;
{
Config.IniFile.Write("FumenKey", FumenKeyBox.Text);
}
private void LoadedMusicBox_DrawItem(object sender, DrawItemEventArgs e) private void LoadedMusicBox_DrawItem(object sender, DrawItemEventArgs e)
{ {
e.DrawBackground(); e.DrawBackground();
if (e.Index<0 || e.Index >= LoadedMusicBox.Items.Count) if (e.Index < 0 || e.Index >= LoadedMusicBox.Items.Count)
return; return;
var selItem = LoadedMusicBox.Items[e.Index] as IMusicInfo; 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); TextRenderer.DrawText(e.Graphics, $"{selItem.UniqueId}. {selItem.Id}", Font, e.Bounds, e.ForeColor, e.BackColor, TextFormatFlags.Left | TextFormatFlags.VerticalCenter);
e.DrawFocusRectangle(); e.DrawFocusRectangle();
} }
private void DatatableDef_PathChanged(object sender, EventArgs args) private void DatatableDef_PathChanged(object sender, EventArgs args)
{ {
try try
{ {
var json = File.ReadAllText(DatatableDef.Path); var json = File.ReadAllText(DatatableDef.Path);
DatatableTypes.LoadFromJson(json); DatatableTypes.LoadFromJson(json);
Config.DatatableDefPath = DatatableDef.Path; Config.DatatableDefPath = DatatableDef.Path;
} }
catch(Exception e) catch (Exception e)
{ {
MessageBox.Show(e.Message); MessageBox.Show(e.Message);
} }
} }
private void UseEncryptionBox_CheckedChanged(object sender, EventArgs e) => Config.UseEncryption = UseEncryptionBox.Checked;
} }
} }