diff --git a/PCK-Studio/Forms/Editor/LOCEditor.Designer.cs b/PCK-Studio/Forms/Editor/LOCEditor.Designer.cs index 69c857c5..4f439197 100644 --- a/PCK-Studio/Forms/Editor/LOCEditor.Designer.cs +++ b/PCK-Studio/Forms/Editor/LOCEditor.Designer.cs @@ -30,7 +30,8 @@ { this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(LOCEditor)); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle(); this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components); this.addDisplayIDToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.deleteDisplayIDToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); @@ -98,9 +99,9 @@ // this.menuStrip.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(13)))), ((int)(((byte)(13)))), ((int)(((byte)(13))))); this.locSort.SetColumnSpan(this.menuStrip, 3); - resources.ApplyResources(this.menuStrip, "menuStrip"); this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.fileToolStripMenuItem}); + resources.ApplyResources(this.menuStrip, "menuStrip"); this.menuStrip.Name = "menuStrip"; // // fileToolStripMenuItem @@ -142,21 +143,29 @@ this.dataGridViewLocEntryData.AllowUserToDeleteRows = false; this.dataGridViewLocEntryData.AllowUserToResizeColumns = false; this.dataGridViewLocEntryData.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; - this.dataGridViewLocEntryData.BackgroundColor = System.Drawing.Color.FromArgb(((int)(((byte)(13)))), ((int)(((byte)(13)))), ((int)(((byte)(13))))); + this.dataGridViewLocEntryData.BackgroundColor = System.Drawing.Color.FromArgb(((int)(((byte)(15)))), ((int)(((byte)(15)))), ((int)(((byte)(15))))); this.dataGridViewLocEntryData.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.None; - dataGridViewCellStyle2.BackColor = System.Drawing.SystemColors.Control; - dataGridViewCellStyle2.Font = new System.Drawing.Font("Segoe UI", 9F); - dataGridViewCellStyle2.ForeColor = System.Drawing.SystemColors.WindowText; - dataGridViewCellStyle2.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle2.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - dataGridViewCellStyle2.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.dataGridViewLocEntryData.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle2; + dataGridViewCellStyle3.BackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle3.Font = new System.Drawing.Font("Segoe UI", 9F); + dataGridViewCellStyle3.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle3.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle3.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle3.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dataGridViewLocEntryData.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle3; this.dataGridViewLocEntryData.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing; this.dataGridViewLocEntryData.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.Language, this.DisplayName}); this.locSort.SetColumnSpan(this.dataGridViewLocEntryData, 2); this.dataGridViewLocEntryData.ContextMenuStrip = this.GridContextMenu; + dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle4.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(25)))), ((int)(((byte)(25)))), ((int)(((byte)(25))))); + dataGridViewCellStyle4.Font = new System.Drawing.Font("Segoe UI", 9F); + dataGridViewCellStyle4.ForeColor = System.Drawing.Color.White; + dataGridViewCellStyle4.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle4.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle4.WrapMode = System.Windows.Forms.DataGridViewTriState.False; + this.dataGridViewLocEntryData.DefaultCellStyle = dataGridViewCellStyle4; resources.ApplyResources(this.dataGridViewLocEntryData, "dataGridViewLocEntryData"); this.dataGridViewLocEntryData.Name = "dataGridViewLocEntryData"; this.dataGridViewLocEntryData.RowHeadersVisible = false; diff --git a/PCK-Studio/Forms/Editor/LOCEditor.cs b/PCK-Studio/Forms/Editor/LOCEditor.cs index 4e4ad8eb..e1d7017d 100644 --- a/PCK-Studio/Forms/Editor/LOCEditor.cs +++ b/PCK-Studio/Forms/Editor/LOCEditor.cs @@ -17,6 +17,7 @@ namespace PckStudio.Forms.Editor { LOCFile _currentLoc; PckAsset _asset; + private bool _isModified = false; // Track changes to the LOC strings public LOCEditor(PckAsset asset) { @@ -36,8 +37,7 @@ namespace PckStudio.Forms.Editor private void treeViewLocKeys_AfterSelect(object sender, TreeViewEventArgs e) { TreeNode node = e.Node; - if (node == null || - !_currentLoc.LocKeys.ContainsKey(node.Text)) + if (node == null || !_currentLoc.LocKeys.ContainsKey(node.Text)) { MessageBox.Show(this, "Selected Node does not seem to be in the loc file"); return; @@ -54,6 +54,7 @@ namespace PckStudio.Forms.Editor _currentLoc.AddLocKey(prompt.NewText, "")) { treeViewLocKeys.Nodes.Add(prompt.NewText); + _isModified = true; } } } @@ -64,22 +65,24 @@ namespace PckStudio.Forms.Editor { treeViewLocKeys.SelectedNode.Remove(); ReloadTranslationTable(); + _isModified = true; } } private void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e) { - if (e.ColumnIndex != 1 || - treeViewLocKeys.SelectedNode is null) + if (e.ColumnIndex != 1 || treeViewLocKeys.SelectedNode is null) { MessageBox.Show(this, "something went wrong"); return; } + DataGridViewRow row = dataGridViewLocEntryData.Rows[e.RowIndex]; string locKey = treeViewLocKeys.SelectedNode.Text; string language = row.Cells[0].Value.ToString(); string value = row.Cells[1].Value.ToString(); _currentLoc.SetLocEntry(locKey, language, value); + _isModified = true; } private void treeView1_KeyDown(object sender, KeyEventArgs e) @@ -94,8 +97,8 @@ namespace PckStudio.Forms.Editor { dataGridViewLocEntryData.Rows[i].Cells[1].Value = textBoxReplaceAll.Text; } - _currentLoc.SetLocEntry(treeViewLocKeys.SelectedNode.Text, textBoxReplaceAll.Text); + _isModified = true; } private void ReloadTranslationTable() @@ -126,12 +129,14 @@ namespace PckStudio.Forms.Editor { _currentLoc.AddLanguage(dialog.SelectedLanguage); ReloadTranslationTable(); + _isModified = true; } } private void saveToolStripMenuItem_Click(object sender, EventArgs e) { _asset.SetData(new LOCFileWriter(_currentLoc, 2)); + _isModified = false; // Reset modified flag after saving DialogResult = DialogResult.OK; } @@ -141,6 +146,19 @@ namespace PckStudio.Forms.Editor { saveToolStripMenuItem_Click(sender, EventArgs.Empty); } + else if (_isModified) // Use local modified flag + { + DialogResult result = MessageBox.Show( + "You have unsaved changes. Close without saving?", + "Unsaved Changes", + MessageBoxButtons.YesNo, + MessageBoxIcon.Warning); + + if (result == DialogResult.No) + { + e.Cancel = true; + } + } } } -} +} \ No newline at end of file diff --git a/PCK-Studio/Forms/Editor/LOCEditor.resx b/PCK-Studio/Forms/Editor/LOCEditor.resx index 57a67b97..25a5f709 100644 --- a/PCK-Studio/Forms/Editor/LOCEditor.resx +++ b/PCK-Studio/Forms/Editor/LOCEditor.resx @@ -181,7 +181,7 @@ NoControl - 959, 27 + 943, 27 4, 4, 4, 4 @@ -229,7 +229,7 @@ 4, 4, 4, 4 - 692, 704 + 676, 676 1 @@ -256,7 +256,7 @@ 4, 4, 4, 4 - 597, 23 + 581, 23 2 @@ -283,7 +283,7 @@ 4, 4, 4, 4 - 342, 738 + 342, 710 0 @@ -313,7 +313,7 @@ 3 - 1050, 769 + 1034, 741 3 @@ -331,10 +331,7 @@ 2 - <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="buttonReplaceAll" Row="1" RowSpan="1" Column="2" ColumnSpan="1" /><Control Name="dataGridViewLocEntryData" Row="2" RowSpan="1" Column="1" ColumnSpan="2" /><Control Name="menuStrip" Row="0" RowSpan="1" Column="0" ColumnSpan="3" /><Control Name="textBoxReplaceAll" Row="1" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="treeViewLocKeys" Row="1" RowSpan="2" Column="0" ColumnSpan="1" /></Controls><Columns Styles="Absolute,350,Percent,100,AutoSize,0" /><Rows Styles="Absolute,23,AutoSize,0,Percent,100" /></TableLayoutSettings> - - - Fill + <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="buttonReplaceAll" Row="1" RowSpan="1" Column="2" ColumnSpan="1" /><Control Name="dataGridViewLocEntryData" Row="2" RowSpan="1" Column="1" ColumnSpan="2" /><Control Name="menuStrip" Row="0" RowSpan="1" Column="0" ColumnSpan="3" /><Control Name="textBoxReplaceAll" Row="1" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="treeViewLocKeys" Row="1" RowSpan="2" Column="0" ColumnSpan="1" /></Controls><Columns Styles="Absolute,350,Percent,100,AutoSize,0" /><Rows Styles="Absolute,23,AutoSize,0,Percent,100,Absolute,20" /></TableLayoutSettings> 37, 19 @@ -345,14 +342,11 @@ 0, 0 - - 7, 2, 0, 2 - - 1050, 23 + 1034, 23 - 4 + 5 menuStrip @@ -367,7 +361,7 @@ 2 - 98, 22 + 180, 22 Save @@ -379,7 +373,7 @@ 7, 15 - 1050, 769 + 1034, 741 Segoe UI, 9pt @@ -2897,7 +2891,7 @@ 4, 4, 4, 4 - 1056, 784 + 1050, 780 CenterParent