diff --git a/Forms/MainView.cs b/Forms/MainView.cs index f2ec472..0b3b194 100644 --- a/Forms/MainView.cs +++ b/Forms/MainView.cs @@ -1844,5 +1844,14 @@ private void ReferenceSearch(uint formid) var search = CreateSearchWindow(); search.ReferenceSearch(formid); } + + private void uTF8ModeToolStripMenuItem_Click(object sender, EventArgs e) + { + Properties.Settings.Default.UseUTF8 = uTF8ModeToolStripMenuItem.Checked; + if (MessageBox.Show(Resources.RestartText, Resources.InfoText, MessageBoxButtons.YesNoCancel) == DialogResult.Yes) + { + Application.Restart(); + } + } } } \ No newline at end of file diff --git a/Forms/MainView.designer.cs b/Forms/MainView.designer.cs index 26b96a6..cbf0ac1 100644 --- a/Forms/MainView.designer.cs +++ b/Forms/MainView.designer.cs @@ -73,6 +73,7 @@ private void InitializeComponent() { this.searchAdvancedToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.optionsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.hexModeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.uTF8ModeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.useNewSubrecordEditorToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.lookupFormidsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.useWindowsClipboardToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); @@ -375,6 +376,7 @@ private void InitializeComponent() { // this.optionsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.hexModeToolStripMenuItem, + this.uTF8ModeToolStripMenuItem, this.useNewSubrecordEditorToolStripMenuItem, this.lookupFormidsToolStripMenuItem, this.useWindowsClipboardToolStripMenuItem, @@ -395,6 +397,15 @@ private void InitializeComponent() { resources.ApplyResources(this.hexModeToolStripMenuItem, "hexModeToolStripMenuItem"); this.hexModeToolStripMenuItem.Click += new System.EventHandler(this.hexModeToolStripMenuItem_Click); // + // uTF8ModeToolStripMenuItem + // + this.uTF8ModeToolStripMenuItem.Checked = true; + this.uTF8ModeToolStripMenuItem.CheckOnClick = true; + this.uTF8ModeToolStripMenuItem.CheckState = System.Windows.Forms.CheckState.Checked; + this.uTF8ModeToolStripMenuItem.Name = "uTF8ModeToolStripMenuItem"; + resources.ApplyResources(this.uTF8ModeToolStripMenuItem, "uTF8ModeToolStripMenuItem"); + this.uTF8ModeToolStripMenuItem.Click += new System.EventHandler(this.uTF8ModeToolStripMenuItem_Click); + // // useNewSubrecordEditorToolStripMenuItem // this.useNewSubrecordEditorToolStripMenuItem.Checked = true; @@ -1176,5 +1187,6 @@ private void InitializeComponent() { private System.Windows.Forms.ToolStripMenuItem exportStringsToFileToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem importStringsToFileToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem internalizeStringReferencesToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem uTF8ModeToolStripMenuItem; } } \ No newline at end of file diff --git a/Forms/MainView.resx b/Forms/MainView.resx index e90e6ec..646b18d 100644 --- a/Forms/MainView.resx +++ b/Forms/MainView.resx @@ -126,7 +126,7 @@ - 146, 22 + 155, 22 &New @@ -135,7 +135,7 @@ Ctrl+O - 146, 22 + 155, 22 &Open @@ -144,46 +144,46 @@ Ctrl+S - 146, 22 + 155, 22 &Save - 146, 22 + 155, 22 &Close - 146, 22 + 155, 22 Close &All - 143, 6 + 152, 6 - 146, 22 + 155, 22 Reload &Xml - 143, 6 + 152, 6 Alt+F4 - 146, 22 + 155, 22 E&xit - 37, 20 + 39, 21 &File @@ -196,7 +196,7 @@ Ctrl+X - 235, 22 + 249, 22 Cut @@ -208,7 +208,7 @@ Ctrl+C - 235, 22 + 249, 22 &Copy @@ -220,7 +220,7 @@ Ctrl+V - 235, 22 + 249, 22 &Paste @@ -229,7 +229,7 @@ False - 235, 22 + 249, 22 &Delete @@ -238,7 +238,7 @@ False - 235, 22 + 249, 22 &New record @@ -247,7 +247,7 @@ False - 235, 22 + 249, 22 New subrecord @@ -256,7 +256,7 @@ Ctrl+E - 235, 22 + 249, 22 &Edit Selected... @@ -265,43 +265,43 @@ Ctrl+H - 235, 22 + 249, 22 Edit &Header... - 235, 22 + 249, 22 Add &Master... - 159, 22 + 170, 22 &Expand All - 159, 22 + 170, 22 &Collapse All - 159, 22 + 170, 22 E&xpand Branch - 159, 22 + 170, 22 C&ollapse Branch - 235, 22 + 249, 22 E&xpand/Collapse @@ -310,7 +310,7 @@ Ctrl+F - 235, 22 + 249, 22 Find in Records... @@ -319,19 +319,19 @@ Ctrl+Shift+F - 235, 22 + 249, 22 Incremental &Find - 235, 22 + 249, 22 &Basic Search... - 235, 22 + 249, 22 Search Advanced... @@ -340,37 +340,43 @@ False - 39, 20 + 42, 21 &Edit - 208, 22 + 228, 22 &Hex mode + + 228, 22 + + + &UTF-8 mode + - 208, 22 + 228, 22 Use new subrecord editor - 208, 22 + 228, 22 Lookup formids - 208, 22 + 228, 22 Use Windows Clipboard - 208, 22 + 228, 22 No Windows Sounds @@ -382,7 +388,7 @@ False - 208, 22 + 228, 22 Disable Hyperlinks @@ -391,130 +397,130 @@ Hyperlink processing code can be slow. Disable for better performance - 208, 22 + 228, 22 Reset Docking Windows - 208, 22 + 228, 22 ESM &Filter Settings... - 208, 22 + 228, 22 &Compression Settings... - 61, 20 + 66, 21 Options - 116, 22 + 122, 22 &English - 116, 22 + 122, 22 &Czech - 116, 22 + 122, 22 &French - 116, 22 + 122, 22 &German - 116, 22 + 122, 22 &Italian - 116, 22 + 122, 22 &Spanish - 116, 22 + 122, 22 &Russian - 116, 22 + 122, 22 &Polish - 241, 22 + 264, 22 String &Language - 241, 22 + 264, 22 &Edit Strings... - 241, 22 + 264, 22 Enable Saving Strings Files - 241, 22 + 264, 22 Save Plugin Strings - 241, 22 + 264, 22 &String Localizer... - 241, 22 + 264, 22 &Reload Strings - 238, 6 + 261, 6 - 241, 22 + 264, 22 Internalize String References - 241, 22 + 264, 22 E&xtract Internal Strings To Table - 241, 22 + 264, 22 Copy Master String References @@ -523,61 +529,61 @@ Copy any localized string references from the masters to selected plugin - 241, 22 + 264, 22 Clean Unused Strings - 241, 22 + 264, 22 Create Stubs for Missing Strings - 241, 22 + 264, 22 Export Strings to File - 241, 22 + 264, 22 &Import Strings from File - 55, 20 + 60, 21 S&trings - 264, 22 + 283, 22 Sanitize - 264, 22 + 283, 22 Strip EDIDs - 264, 22 + 283, 22 Find duplicated FormID - 264, 22 + 283, 22 Dump EDID list - 264, 22 + 283, 22 Clean esp @@ -586,43 +592,43 @@ Ctrl+N - 264, 22 + 283, 22 Find &nonconforming record - 264, 22 + 283, 22 Compile script - 264, 22 + 283, 22 Compile all - 264, 22 + 283, 22 Generate LL xml - 264, 22 + 283, 22 Make esm - 264, 22 + 283, 22 SCTX replacer - 264, 22 + 283, 22 Guess Record Structure ... @@ -631,7 +637,7 @@ False - 264, 22 + 283, 22 Merge Records XML ... @@ -640,7 +646,7 @@ False - 264, 22 + 283, 22 &Reorder Subrecords @@ -649,7 +655,7 @@ Attempt to restucture the Current Subrecord to match XML - 49, 20 + 54, 21 &Spells @@ -658,7 +664,7 @@ 0, 0 - 765, 24 + 765, 25 104 @@ -802,7 +808,7 @@ Magenta - 51, 22 + 55, 22 &Next @@ -811,7 +817,7 @@ Magenta - 50, 22 + 53, 22 &Prev @@ -820,7 +826,7 @@ Magenta - 63, 22 + 69, 22 &Restart @@ -844,7 +850,7 @@ Magenta - 93, 22 + 100, 22 Match Case @@ -862,7 +868,7 @@ Magenta - 58, 22 + 62, 22 Exact @@ -877,7 +883,7 @@ Magenta - 102, 22 + 111, 22 &Wrap Around @@ -889,7 +895,7 @@ 6, 25 - 64, 22 + 71, 22 Status Text @@ -940,7 +946,7 @@ Close Search - 107, 22 + 119, 22 Invalid Item Search @@ -952,7 +958,7 @@ Magenta - 51, 22 + 55, 22 &Next @@ -961,7 +967,7 @@ Magenta - 50, 22 + 53, 22 &Prev @@ -970,7 +976,7 @@ Magenta - 63, 22 + 69, 22 &Restart @@ -985,7 +991,7 @@ Magenta - 102, 22 + 111, 22 &Wrap Around @@ -997,7 +1003,7 @@ 6, 25 - 64, 22 + 71, 22 Status Text @@ -1036,10 +1042,10 @@ Tahoma, 11world - 0, 24 + 0, 25 - 765, 450 + 765, 449 107 @@ -1538,6 +1544,12 @@ System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + uTF8ModeToolStripMenuItem + + + System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + useNewSubrecordEditorToolStripMenuItem diff --git a/Forms/MultilineStringEditor.Designer.cs b/Forms/MultilineStringEditor.Designer.cs index 3cb19c6..298fe35 100644 --- a/Forms/MultilineStringEditor.Designer.cs +++ b/Forms/MultilineStringEditor.Designer.cs @@ -36,6 +36,7 @@ private void InitializeComponent() // // textBox1 // + this.textBox1.AcceptsReturn = true; resources.ApplyResources(this.textBox1, "textBox1"); this.textBox1.Name = "textBox1"; // diff --git a/Forms/MultilineStringEditor.resx b/Forms/MultilineStringEditor.resx index 09193a8..4996509 100644 --- a/Forms/MultilineStringEditor.resx +++ b/Forms/MultilineStringEditor.resx @@ -117,109 +117,115 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - True - - - OK + + + Top, Bottom, Left, Right - - 6, 13 + + 13, 12 - - Cancel + + + True - - - Top, Bottom, Left, Right + + Both - - Bottom, Right + + 329, 167 - - System.Windows.Forms.Form, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 0 - - MultilineStringEditor + + textBox1 - - 1 + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 $this - - 261, 207 - - - 354, 242 - - - 329, 181 + + 2 Bottom, Right - - 75, 23 + + 179, 191 - - CenterParent + + 75, 21 1 + + OK + + + btnOK + System.Windows.Forms.Button, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + $this - - 2 + + 1 - - System.Windows.Forms.TextBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + Bottom, Right - - 13, 13 + + 261, 191 - + + 75, 21 + + 2 + + Cancel + btnClose - + + System.Windows.Forms.Button, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + $this - + 0 - - btnOK - - - 75, 23 + + True + + + 6, 12 - - 179, 207 + + True - - textBox1 + + 354, 223 - - System.Windows.Forms.Button, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + CenterParent Multiline String Editor - - 0 + + MultilineStringEditor + + + System.Windows.Forms.Form, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - True - \ No newline at end of file diff --git a/Main/TypeConverter.cs b/Main/TypeConverter.cs index f7cd314..7f32699 100644 --- a/Main/TypeConverter.cs +++ b/Main/TypeConverter.cs @@ -313,13 +313,15 @@ public static void s2h(ushort ss, byte[] data, int offset) public static bool IsLikelyString(ArraySegment data) { bool isAscii = true; + bool isMultibyte = true; for (int i = 0; i < data.Count - 1 && isAscii; ++i) { var c = (char) data.Array[data.Offset + i]; //if (c == 0) return (i > 0); - isAscii = !Char.IsControl(c); + isAscii = !Char.IsControl(c) || c == '\r' || c == '\n';//Fix for multiline string. + isMultibyte = (c & 0x80) != 0;//Only tested for some CJK ,Not confirmed for other charset } - return (isAscii && data.Array[data.Count - 1] == 0); + return ((isMultibyte || isAscii) && data.Array[data.Count - 1] == 0); } public static string GetZString(ArraySegment data) @@ -371,13 +373,13 @@ public static byte[] str2h(string str) { int len = Encoding.CP1252.GetByteCount(str); var data = new byte[len + 1]; - Encoding.CP1252.GetBytes(str, 0, len, data, 0); + Encoding.CP1252.GetBytes(str).CopyTo(data,0); data[len] = 0; return data; } - /// /// Encode short byte length prefixed string + /// fix for UTF-8 /// /// /// diff --git a/Program.cs b/Program.cs index 2586da4..56aba87 100644 --- a/Program.cs +++ b/Program.cs @@ -145,8 +145,11 @@ public FontLangInfo(ushort CodePage, ushort lcid, byte charset) } internal static class Encoding - { + {//add utf-8 private static readonly System.Text.Encoding s_CP1252Encoding = System.Text.Encoding.GetEncoding(1252); + private static readonly System.Text.Encoding s_UTF8Encoding = System.Text.Encoding.GetEncoding("utf-8"); + + internal static System.Text.Encoding CP1252; private static readonly Dictionary defLangMap = new Dictionary(StringComparer.InvariantCultureIgnoreCase); @@ -161,13 +164,13 @@ static Encoding() defLangMap.Add("Spanish", new FontLangInfo(1252, 1034, 0)); defLangMap.Add("Russian", new FontLangInfo(1251, 1049, 204)); defLangMap.Add("Polish", new FontLangInfo(1250, 1045, 0)); + CP1252 = Properties.Settings.Default.UseUTF8?s_UTF8Encoding:s_CP1252Encoding; } - internal static System.Text.Encoding CP1252 - { - get { return s_CP1252Encoding; } - } - +// internal static System.Text.Encoding CP1252 +// { +// get { return s_CP1252Encoding; } +// } internal static bool TryGetFontInfo(string name, out FontLangInfo langInfo) { diff --git a/Properties/Resources.Designer.cs b/Properties/Resources.Designer.cs index b93edf5..31ffa51 100644 --- a/Properties/Resources.Designer.cs +++ b/Properties/Resources.Designer.cs @@ -568,6 +568,15 @@ internal static System.Drawing.Bitmap reload_all_tabs { } } + /// + /// 查找类似 To confirm the coding setting, restart Tesvsnip now? 的本地化字符串。 + /// + internal static string RestartText { + get { + return ResourceManager.GetString("RestartText", resourceCulture); + } + } + internal static System.Drawing.Bitmap Revert { get { object obj = ResourceManager.GetObject("Revert", resourceCulture); diff --git a/Properties/Resources.resx b/Properties/Resources.resx index 8bc22ae..3418b10 100644 --- a/Properties/Resources.resx +++ b/Properties/Resources.resx @@ -358,8 +358,10 @@ Do you still want to save? ..\Resources\warning.ico;System.Drawing.Icon, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - ..\Resources\14_layer_deletelayer.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + To confirm the coding setting, restart Tesvsnip now? + \ No newline at end of file diff --git a/Properties/Settings.Designer.cs b/Properties/Settings.Designer.cs index dcec009..4b6a493 100644 --- a/Properties/Settings.Designer.cs +++ b/Properties/Settings.Designer.cs @@ -403,5 +403,17 @@ public string LastSearchType { this["LastSearchType"] = value; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("True")] + public bool UseUTF8 { + get { + return ((bool)(this["UseUTF8"])); + } + set { + this["UseUTF8"] = value; + } + } } } diff --git a/Properties/Settings.settings b/Properties/Settings.settings index f0bf1eb..3043ddb 100644 --- a/Properties/Settings.settings +++ b/Properties/Settings.settings @@ -98,5 +98,8 @@ + + True + \ No newline at end of file diff --git a/RecordControls/LStringElement.Designer.cs b/RecordControls/LStringElement.Designer.cs index 4eb106c..3629089 100644 --- a/RecordControls/LStringElement.Designer.cs +++ b/RecordControls/LStringElement.Designer.cs @@ -55,6 +55,7 @@ private void InitializeComponent() this.Error.SetIconPadding(this.txtString, ((int)(resources.GetObject("txtString.IconPadding")))); this.txtString.Name = "txtString"; this.txtString.Validated += new System.EventHandler(this.txtString_Validated); + this.txtString.DoubleClick += new System.EventHandler(this.txtString_DoubleClick); // // LStringElement // diff --git a/RecordControls/LStringElement.cs b/RecordControls/LStringElement.cs index f90da37..726eb89 100644 --- a/RecordControls/LStringElement.cs +++ b/RecordControls/LStringElement.cs @@ -1,6 +1,7 @@ using System; using System.Globalization; using System.Windows.Forms; +using TESVSnip.Forms; using TESVSnip.Properties; namespace TESVSnip.RecordControls @@ -127,5 +128,20 @@ private void txtString_Validated(object sender, EventArgs e) { SaveText(); } + + private void txtString_DoubleClick(object sender, EventArgs e) + { + using (var editor = new MultilineStringEditor()) + { + editor.Text = txtString.Text; + DialogResult result = editor.ShowDialog(this); + if (result == DialogResult.OK) + { + txtString.Text = editor.Text; + } + } + } + + } } \ No newline at end of file diff --git a/conf/RecordStructure.xml b/conf/RecordStructure.xml index beb302f..d385fcf 100644 --- a/conf/RecordStructure.xml +++ b/conf/RecordStructure.xml @@ -147,6 +147,9 @@ + + + @@ -1170,7 +1173,7 @@ - + @@ -1251,7 +1254,7 @@ - + @@ -1656,7 +1659,7 @@ - + @@ -1775,7 +1778,7 @@ - + @@ -1804,7 +1807,7 @@ - + @@ -2852,7 +2855,7 @@ - + @@ -2860,7 +2863,7 @@ - + @@ -2874,7 +2877,7 @@ - + @@ -2922,6 +2925,9 @@ + + + @@ -2957,7 +2963,7 @@ - + @@ -2978,7 +2984,7 @@ - + @@ -3002,7 +3008,7 @@ - + @@ -3024,7 +3030,7 @@ - + @@ -3040,7 +3046,7 @@ - + @@ -3171,10 +3177,10 @@ - + - + @@ -3244,13 +3250,13 @@ - + - + @@ -3290,7 +3296,7 @@ - + @@ -3333,7 +3339,7 @@ - + @@ -3366,7 +3372,7 @@ - + @@ -3430,7 +3436,7 @@ - + @@ -3726,7 +3732,7 @@ - + @@ -4077,10 +4083,10 @@ - + - + @@ -4123,7 +4129,7 @@ - + @@ -4332,7 +4338,7 @@ - + @@ -4534,7 +4540,7 @@ - + @@ -4560,7 +4566,7 @@ - + @@ -4760,7 +4766,7 @@ - + @@ -4837,7 +4843,7 @@ - + @@ -4854,7 +4860,7 @@ - + @@ -5190,7 +5196,7 @@ - + @@ -5314,7 +5320,7 @@ - + @@ -5543,6 +5549,9 @@ + + + @@ -5567,8 +5576,8 @@ - - + +