From 9ffc4c61dc539a0ad1212394c6d437801193ae13 Mon Sep 17 00:00:00 2001 From: cnbatch Date: Thu, 18 Sep 2014 06:25:33 +0800 Subject: [PATCH] small changes Remove a unnecessary message box --- Source/AboutEditorForm.resx | 4 ++-- Source/Editor.cs | 2 ++ Source/MainUI.cs | 31 ++++++++++++------------------ Source/TS4 STBL Editor.v12.suo | Bin 80896 -> 80896 bytes Source/Tools.cs | 34 +++++++++++---------------------- 5 files changed, 27 insertions(+), 44 deletions(-) diff --git a/Source/AboutEditorForm.resx b/Source/AboutEditorForm.resx index 9b4a25f..fa6a06a 100644 --- a/Source/AboutEditorForm.resx +++ b/Source/AboutEditorForm.resx @@ -130,13 +130,13 @@ 280, 9 - 78, 19 + 89, 19 1 - Version 1.2 + Version 1.2.1 MiddleCenter diff --git a/Source/Editor.cs b/Source/Editor.cs index 1c8c754..1e40e91 100644 --- a/Source/Editor.cs +++ b/Source/Editor.cs @@ -22,6 +22,7 @@ public partial class Editor : Form public delegate void UpdateProgressBar(double num); public UpdateProgressBar updateProgressBar; public DataTable dataTable; + public bool isTextChanged = false; public Editor() { @@ -81,6 +82,7 @@ private void button1_Click(object sender, EventArgs e) dataTable.Rows.Clear(); dataTable = tempDataTable.Copy(); } + isTextChanged = true; Close(); } diff --git a/Source/MainUI.cs b/Source/MainUI.cs index 7407eee..201532a 100644 --- a/Source/MainUI.cs +++ b/Source/MainUI.cs @@ -52,6 +52,8 @@ public MainUI() private string publicPath = string.Empty; private bool pathOpened = false; + private bool canAlsoSave = false; + private bool isTextChanged = false; private void exitToolStripMenuItem_Click(object sender, EventArgs e) { @@ -132,13 +134,15 @@ private void savePackageToolStripMenuItem_Click(object sender, EventArgs e) { if (pathOpened) SaveSTBLFile(false); - else if (!pathOpened && dataGridView1.Rows.Count > 0) + else if (canAlsoSave) SaveSTBLFile(true); + isTextChanged = false; } private void saveAsToolStripMenuItem_Click(object sender, EventArgs e) { SaveSTBLFile(true); + isTextChanged = false; } private void aboutToolStripMenuItem1_Click(object sender, EventArgs e) @@ -291,31 +295,18 @@ private void button3_Click(object sender, EventArgs e) XMLToDataGridView(tempList, xmlFilePath); - switch (Thread.CurrentThread.CurrentUICulture.ThreeLetterWindowsLanguageName) - { - case "CHS": - case "ZHI": - MessageBox.Show("导入成功!", "消息", MessageBoxButtons.OK, MessageBoxIcon.Information); - break; - case "CHT": - case "ZHH": - case "ZHM": - MessageBox.Show("匯入成功!", "消息", MessageBoxButtons.OK, MessageBoxIcon.Information); - break; - default: - MessageBox.Show("Successfully Imported!", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information); - break; - } - UseWaitCursor = false; progressBar1.Visible = false; + if (!pathOpened) + canAlsoSave = true; + isTextChanged = true; } private void closeToolStripMenuItem_Click(object sender, EventArgs e) { - if (pathOpened) + if (isTextChanged && pathOpened) SaveSTBLFile(false); - else if (dataGridView1.Rows.Count > 0) + else if (isTextChanged && dataGridView1.Rows.Count > 0) SaveSTBLFile(true); dataGridView1.DataSource = null; @@ -340,6 +331,8 @@ private void closeToolStripMenuItem_Click(object sender, EventArgs e) } publicPath = string.Empty; pathOpened = false; + canAlsoSave = false; + isTextChanged = false; } } } diff --git a/Source/TS4 STBL Editor.v12.suo b/Source/TS4 STBL Editor.v12.suo index 955edabccd0f321a34fee66404aac2114f479352..c402d199d06cb1311b750f18681b1ee9cab5e4e3 100644 GIT binary patch delta 1297 zcmb`Ge@t6d6vumR-+Po_rLUBY(aP@uE6f!nb(wV{qAuA?)`dhCqlV5uCQgI}BFU1j zNHVt|zj|ZebP|_4z>O_add-?(f|YdsAz;85L$bwWq}d;4{xL#Kmnhx2ZJBlP&)wwn z?mg$8d(Zjad!H{R`C`(jtH7+&=?JnJkH@jo>5+mNx0NX2@*h@j{=!d^VE`KisrK{^ zoU1?z5ff61j3T%+(YB|?|DdJd*o$mKijWLM1m$AC3ptarpTfR4HLk>dCt^(5iB0jd zJ87G@?07ahP9V-Px0S9+=MAFzx6ncRk1CO&6vKt8JVZiD5ET)sEZB>f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U~ z9pN?-UVqcNjmJmMKb_S$`FG2$@$aigHK9N@HQT+^P4u)p?~>({O`Vk&ua?f0KYF=m zzU29rl|-J2@HK>QA<@E1V7;(GJACDh8}FP+{+2gpee2h|639HCg!c?Z+8Tg+CGIA? zNUd3YVDFpJ8p~t9`;K4S{nPRDcO6k{I#O$5FP57T_8$Yk(&6t1Oc-?>19*~l{h3dwkFn31F!PHOoFJTAu*ji|B7u{@QDojMMn$k5txG?Z<)n_S29ue4sXsHxb%= zqJfrwl}_WmveNqDIfIh*egceQk}EXLIBXrX;>5E`TVybew~%O`MD*1=>Z*2B)z#9b z&rd6ZBQ3xW5&lPNrVH7M^q$#HvkGqU5sC6$-AZ=?iN*<^CF1)9VZjXWD&C2&fwo@@ zD#7s}(B_FQrEBsvpr;R-6w|c?tc)A`t|nHK1s?;OE(RYf)k2%K2Jo`#GQ|&~ZfC<< zsAc>8aFo5i71}e{k{{)eGWVla&nJl}5Hnd|R;$R@XMtZ&=Qqg*`5+k^vFYMh)N95D zJ#dEoycG`SV4|8k=FT3rBT_V0vR5!+Y zWH_nC`J&-Y8yhgd_SoYl_(;n<9@xjGw}4N6;o&3ghvRB3VZ&8bjhDbfnMeng=si=u z@;Uty&rZi?3FzL zllYq%V)|_`qZLg`7n8ZrB+-@8)J7!T*pj8j6$miQKW#(l8L+OLL)k1f6%letoc!P>DLP!xX^_0{*rJ#&Hk EKjsbs#Q*>R diff --git a/Source/Tools.cs b/Source/Tools.cs index d5ce7b9..eaba542 100644 --- a/Source/Tools.cs +++ b/Source/Tools.cs @@ -191,7 +191,7 @@ public string WriteSTBLFile(ArrayList mainArrayList, bool isSaveAs, string stblF binaryWriter.Write(((string)textString[i]).ToCharArray()); } - if (isSaveAs) + if (isSaveAs || canAlsoSave) { SaveFileDialog SaveFile = new SaveFileDialog(); switch (Thread.CurrentThread.CurrentUICulture.ThreeLetterWindowsLanguageName) @@ -221,13 +221,18 @@ public string WriteSTBLFile(ArrayList mainArrayList, bool isSaveAs, string stblF if (SaveFile.ShowDialog() == DialogResult.OK) { stblFilePath = SaveFile.FileName; - FileStream stblStream = new FileStream(stblFilePath, FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite); - BinaryWriter stblFileWriter = new BinaryWriter(stblStream); - stblFileWriter.Write(stblMemoryStream.ToArray()); - stblStream.Dispose(); + } + else + { + stblMemoryStream.Dispose(); + return stblFilePath; } } + FileStream stblStream = new FileStream(stblFilePath, FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite); + BinaryWriter stblFileWriter = new BinaryWriter(stblStream); + stblFileWriter.Write(stblMemoryStream.ToArray()); + stblStream.Dispose(); stblMemoryStream.Dispose(); return stblFilePath; @@ -352,6 +357,7 @@ public void SaveSTBLFile(bool isSaveAs) publicPath = WriteSTBLFile(tempList, isSaveAs, publicPath); toolStripStatusLabel2.Text = publicPath; + pathOpened = true; } public void STBLToDataGridView(ArrayList tempList) @@ -426,14 +432,6 @@ public void XMLToDataGridView(ArrayList tempList, string xmlFilePath) dataGridView1.Columns.Clear(); dataGridView1.DataSource = dataTable; RestoreDataGridViewSettings(); - - //dataGridView1.Rows.Add(textString.Count); - /*for (int i = 0; i < textString.Count; i++) - { - dataGridView1.Rows[i].Cells[0].Value = "0x" + ((uint)textResourceID[i]).ToString("X8"); - dataGridView1.Rows[i].Cells[1].Value = textString[i]; - progressBar1.Value = progressBar1.Maximum * i / textString.Count; - }*/ } else { @@ -488,8 +486,6 @@ public void XMLToDataGridView(ArrayList tempList, string xmlFilePath) tempDataGridView.Rows[0].Cells[2].Selected = true; tempDataGridView.Sort(tempDataGridView.Columns[2], ListSortDirection.Ascending); - //dataGridView1.Rows.Clear(); - //dataGridView1.Rows.Add(tempDataGridView.Rows.Count); DataTable dataTable = new DataTable(); DataColumn dc; DataRow dr; @@ -510,14 +506,6 @@ public void XMLToDataGridView(ArrayList tempList, string xmlFilePath) dataGridView1.Columns.Clear(); dataGridView1.DataSource = dataTable; RestoreDataGridViewSettings(); - - - /*for (int i = 0; i < tempDataGridView.Rows.Count; i++) - { - dataGridView1.Rows[i].Cells[0].Value = "0x" + tempDataGridView.Rows[i].Cells[0].Value; - dataGridView1.Rows[i].Cells[1].Value = tempDataGridView.Rows[i].Cells[1].Value; - progressBar1.Value = lastProgressBarValue + progressBar1.Maximum / 4 * i / tempDataGridView.Rows.Count; - }*/ } foreach (DataGridViewRow row in dataGridView1.Rows)