diff --git a/PCK-Studio/Forms/Editor/LOCEditor.Designer.cs b/PCK-Studio/Forms/Editor/LOCEditor.Designer.cs index c6d225e7..69c857c5 100644 --- a/PCK-Studio/Forms/Editor/LOCEditor.Designer.cs +++ b/PCK-Studio/Forms/Editor/LOCEditor.Designer.cs @@ -30,7 +30,7 @@ { this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(LOCEditor)); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = 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(); @@ -144,13 +144,13 @@ 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.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.None; - dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Control; - dataGridViewCellStyle1.Font = new System.Drawing.Font("Segoe UI", 9F); - dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.WindowText; - dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.dataGridViewLocEntryData.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1; + 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; this.dataGridViewLocEntryData.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing; this.dataGridViewLocEntryData.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.Language, diff --git a/PCK-Studio/Forms/Editor/LOCEditor.cs b/PCK-Studio/Forms/Editor/LOCEditor.cs index db10717e..4e4ad8eb 100644 --- a/PCK-Studio/Forms/Editor/LOCEditor.cs +++ b/PCK-Studio/Forms/Editor/LOCEditor.cs @@ -1,149 +1,146 @@ -using System; -using System.IO; -using System.Data; -using System.Linq; -using System.Collections.Generic; -using System.Windows.Forms; -using MetroFramework.Forms; -using PckStudio.Internal.Misc; -using PckStudio.Forms.Additional_Popups.Loc; -using OMI.Formats.Languages; -using OMI.Workers.Language; +using OMI.Formats.Languages; using OMI.Formats.Pck; -using PckStudio.Properties; +using OMI.Workers.Language; using PckStudio.Extensions; +using PckStudio.Forms.Additional_Popups.Loc; +using PckStudio.Internal.Misc; +using PckStudio.Properties; using PckStudio.ToolboxItems; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Windows.Forms; namespace PckStudio.Forms.Editor { - public partial class LOCEditor : ThemeForm + public partial class LOCEditor : ThemeForm { - LOCFile _currentLoc; - PckAsset _asset; + LOCFile _currentLoc; + PckAsset _asset; - public LOCEditor(PckAsset asset) - { - InitializeComponent(); - _asset = asset; - _currentLoc = asset.GetData(new LOCFileReader()); - saveToolStripMenuItem.Visible = !Settings.Default.AutoSaveChanges; + public LOCEditor(PckAsset asset) + { + InitializeComponent(); + _asset = asset; + _currentLoc = asset.GetData(new LOCFileReader()); + saveToolStripMenuItem.Visible = !Settings.Default.AutoSaveChanges; } - private void LOCEditor_Load(object sender, EventArgs e) - { - RPC.SetPresence("LOC Editor", "Editing localization File."); - foreach(string locKey in _currentLoc.LocKeys.Keys) - treeViewLocKeys.Nodes.Add(locKey); - } + private void LOCEditor_Load(object sender, EventArgs e) + { + RPC.SetPresence("LOC Editor", "Editing localization File."); + foreach (string locKey in _currentLoc.LocKeys.Keys) + treeViewLocKeys.Nodes.Add(locKey); + } - private void treeViewLocKeys_AfterSelect(object sender, TreeViewEventArgs e) - { + private void treeViewLocKeys_AfterSelect(object sender, TreeViewEventArgs e) + { TreeNode node = e.Node; - if (node == null || - !_currentLoc.LocKeys.ContainsKey(node.Text)) - { - MessageBox.Show(this, "Selected Node does not seem to be in the loc file"); - return; - } - ReloadTranslationTable(); - } + if (node == null || + !_currentLoc.LocKeys.ContainsKey(node.Text)) + { + MessageBox.Show(this, "Selected Node does not seem to be in the loc file"); + return; + } + ReloadTranslationTable(); + } - private void addDisplayIDToolStripMenuItem_Click(object sender, EventArgs e) - { - using (TextPrompt prompt = new TextPrompt()) - { - prompt.OKButtonText = "Add"; - if (prompt.ShowDialog(this) == DialogResult.OK && - _currentLoc.AddLocKey(prompt.NewText, "")) - { - treeViewLocKeys.Nodes.Add(prompt.NewText); - } - } + private void addDisplayIDToolStripMenuItem_Click(object sender, EventArgs e) + { + using (TextPrompt prompt = new TextPrompt()) + { + prompt.OKButtonText = "Add"; + if (prompt.ShowDialog(this) == DialogResult.OK && + _currentLoc.AddLocKey(prompt.NewText, "")) + { + treeViewLocKeys.Nodes.Add(prompt.NewText); + } + } } private void deleteDisplayIDToolStripMenuItem_Click(object sender, EventArgs e) - { - if (treeViewLocKeys.SelectedNode is TreeNode t && _currentLoc.RemoveLocKey(t.Text)) - { - treeViewLocKeys.SelectedNode.Remove(); - ReloadTranslationTable(); - } - } - - private void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e) - { - if (e.ColumnIndex != 1 || - treeViewLocKeys.SelectedNode is null) + { + if (treeViewLocKeys.SelectedNode is TreeNode t && _currentLoc.RemoveLocKey(t.Text)) { - MessageBox.Show(this, "something went wrong"); - return; + treeViewLocKeys.SelectedNode.Remove(); + ReloadTranslationTable(); + } + } + + private void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e) + { + 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 locKey = treeViewLocKeys.SelectedNode.Text; string language = row.Cells[0].Value.ToString(); - string value = row.Cells[1].Value.ToString(); + string value = row.Cells[1].Value.ToString(); _currentLoc.SetLocEntry(locKey, language, value); } private void treeView1_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyData == Keys.Delete) - deleteDisplayIDToolStripMenuItem_Click(sender, e); - } + { + if (e.KeyData == Keys.Delete) + deleteDisplayIDToolStripMenuItem_Click(sender, e); + } - private void buttonReplaceAll_Click(object sender, EventArgs e) - { + private void buttonReplaceAll_Click(object sender, EventArgs e) + { for (int i = 0; i < dataGridViewLocEntryData.Rows.Count; i++) { dataGridViewLocEntryData.Rows[i].Cells[1].Value = textBoxReplaceAll.Text; } - _currentLoc.SetLocEntry(treeViewLocKeys.SelectedNode.Text, textBoxReplaceAll.Text); - } + _currentLoc.SetLocEntry(treeViewLocKeys.SelectedNode.Text, textBoxReplaceAll.Text); + } - private void ReloadTranslationTable() + private void ReloadTranslationTable() { - dataGridViewLocEntryData.Rows.Clear(); - if (treeViewLocKeys.SelectedNode is null) - return; - foreach (KeyValuePair locEntry in _currentLoc.GetLocEntries(treeViewLocKeys.SelectedNode.Text)) + dataGridViewLocEntryData.Rows.Clear(); + if (treeViewLocKeys.SelectedNode is null) + return; + foreach (KeyValuePair locEntry in _currentLoc.GetLocEntries(treeViewLocKeys.SelectedNode.Text)) dataGridViewLocEntryData.Rows.Add(locEntry.Key, locEntry.Value); - } + } - private IEnumerable GetAvailableLanguages() + private IEnumerable GetAvailableLanguages() { - foreach (var lang in LOCFile.ValidLanguages) - { - if (_currentLoc.Languages.Contains(lang)) - continue; - yield return lang; - } - yield break; - } + foreach (var lang in LOCFile.ValidLanguages) + { + if (_currentLoc.Languages.Contains(lang)) + continue; + yield return lang; + } + yield break; + } - private void addLanguageToolStripMenuItem_Click(object sender, EventArgs e) - { - string[] avalibleLang = GetAvailableLanguages().ToArray(); - using (var dialog = new AddLanguage(avalibleLang)) - if (dialog.ShowDialog(this) == DialogResult.OK) - { - _currentLoc.AddLanguage(dialog.SelectedLanguage); - ReloadTranslationTable(); - } - } + private void addLanguageToolStripMenuItem_Click(object sender, EventArgs e) + { + string[] avalibleLang = GetAvailableLanguages().ToArray(); + using (var dialog = new AddLanguage(avalibleLang)) + if (dialog.ShowDialog(this) == DialogResult.OK) + { + _currentLoc.AddLanguage(dialog.SelectedLanguage); + ReloadTranslationTable(); + } + } - private void saveToolStripMenuItem_Click(object sender, EventArgs e) - { + private void saveToolStripMenuItem_Click(object sender, EventArgs e) + { _asset.SetData(new LOCFileWriter(_currentLoc, 2)); - DialogResult = DialogResult.OK; + DialogResult = DialogResult.OK; } private void LOCEditor_FormClosing(object sender, FormClosingEventArgs e) { - if (Settings.Default.AutoSaveChanges) - { - saveToolStripMenuItem_Click(sender, EventArgs.Empty); - } + if (Settings.Default.AutoSaveChanges) + { + saveToolStripMenuItem_Click(sender, EventArgs.Empty); + } } } } diff --git a/PCK-Studio/Forms/Editor/LOCEditor.resx b/PCK-Studio/Forms/Editor/LOCEditor.resx index 1d089350..57a67b97 100644 --- a/PCK-Studio/Forms/Editor/LOCEditor.resx +++ b/PCK-Studio/Forms/Editor/LOCEditor.resx @@ -121,6 +121,15 @@ 17, 17 + + 163, 48 + + + contextMenuStrip1 + + + System.Windows.Forms.ContextMenuStrip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + 162, 22 @@ -133,18 +142,18 @@ Delete Display ID - - 163, 48 - - - contextMenuStrip1 - - - System.Windows.Forms.ContextMenuStrip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - 172, 17 + + 173, 48 + + + GridContextMenu + + + MetroFramework.Controls.MetroContextMenu, MetroFramework, Version=1.4.0.0, Culture=neutral, PublicKeyToken=5f91a84759bf584a + 172, 22 @@ -157,15 +166,6 @@ Remove Language - - 173, 48 - - - GridContextMenu - - - MetroFramework.Controls.MetroContextMenu, MetroFramework, Version=1.4.0.0, Culture=neutral, PublicKeyToken=5f91a84759bf584a - 321, 17 @@ -181,7 +181,7 @@ NoControl - 911, 27 + 959, 27 4, 4, 4, 4 @@ -229,7 +229,7 @@ 4, 4, 4, 4 - 644, 612 + 692, 704 1 @@ -256,7 +256,7 @@ 4, 4, 4, 4 - 549, 23 + 597, 23 2 @@ -283,7 +283,7 @@ 4, 4, 4, 4 - 342, 646 + 342, 738 0 @@ -304,7 +304,7 @@ Fill - 24, 69 + 0, 0 4, 4, 4, 4 @@ -313,7 +313,7 @@ 3 - 1002, 677 + 1050, 769 3 @@ -336,12 +336,6 @@ Fill - - 98, 22 - - - Save - 37, 19 @@ -355,7 +349,7 @@ 7, 2, 0, 2 - 1002, 23 + 1050, 23 4 @@ -372,6 +366,12 @@ 2 + + 98, 22 + + + Save + True @@ -2899,9 +2899,6 @@ 1056, 784 - - 24, 69, 24, 23 - CenterParent