Skip to content

Commit

Permalink
small changes
Browse files Browse the repository at this point in the history
Remove a unnecessary message box
  • Loading branch information
cnbatch committed Sep 17, 2014
1 parent 553ce15 commit 9ffc4c6
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 44 deletions.
4 changes: 2 additions & 2 deletions Source/AboutEditorForm.resx
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,13 @@
<value>280, 9</value>
</data>
<data name="label1.Size" type="System.Drawing.Size, System.Drawing">
<value>78, 19</value>
<value>89, 19</value>
</data>
<data name="label1.TabIndex" type="System.Int32, mscorlib">
<value>1</value>
</data>
<data name="label1.Text" xml:space="preserve">
<value>Version 1.2</value>
<value>Version 1.2.1</value>
</data>
<data name="label1.TextAlign" type="System.Drawing.ContentAlignment, System.Drawing">
<value>MiddleCenter</value>
Expand Down
2 changes: 2 additions & 0 deletions Source/Editor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down Expand Up @@ -81,6 +82,7 @@ private void button1_Click(object sender, EventArgs e)
dataTable.Rows.Clear();
dataTable = tempDataTable.Copy();
}
isTextChanged = true;
Close();
}

Expand Down
31 changes: 12 additions & 19 deletions Source/MainUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand All @@ -340,6 +331,8 @@ private void closeToolStripMenuItem_Click(object sender, EventArgs e)
}
publicPath = string.Empty;
pathOpened = false;
canAlsoSave = false;
isTextChanged = false;
}
}
}
Binary file modified Source/TS4 STBL Editor.v12.suo
Binary file not shown.
34 changes: 11 additions & 23 deletions Source/Tools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -352,6 +357,7 @@ public void SaveSTBLFile(bool isSaveAs)

publicPath = WriteSTBLFile(tempList, isSaveAs, publicPath);
toolStripStatusLabel2.Text = publicPath;
pathOpened = true;
}

public void STBLToDataGridView(ArrayList tempList)
Expand Down Expand Up @@ -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
{
Expand Down Expand Up @@ -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;
Expand All @@ -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)
Expand Down

0 comments on commit 9ffc4c6

Please sign in to comment.