1
0
mirror of synced 2024-11-14 08:57:34 +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()
{
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;

View File

@ -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";

215
MainForm.Designer.cs generated
View File

@ -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);

View File

@ -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<string> NotFoundFiles = new List<string>();
for (int i = 0; i < files.Length; i++)

View File

@ -14,30 +14,39 @@ 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
@ -342,10 +351,7 @@ namespace TaikoSoundEditor
}
private void SearchBox_TextChanged(object sender, EventArgs e)
{
RefreshExistingSongsListView();
}
private void SearchBox_TextChanged(object sender, EventArgs e) => RefreshExistingSongsListView();
private void RefreshExistingSongsListView()
{
@ -410,15 +416,9 @@ namespace TaikoSoundEditor
//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)
{
@ -429,6 +429,7 @@ namespace TaikoSoundEditor
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
@ -443,5 +444,6 @@ namespace TaikoSoundEditor
}
}
private void UseEncryptionBox_CheckedChanged(object sender, EventArgs e) => Config.UseEncryption = UseEncryptionBox.Checked;
}
}