diff --git a/ScriptTool/ScriptTool/ScriptTool.csproj b/ScriptTool/ScriptTool/ScriptTool.csproj index 5259d7b..7841611 100644 --- a/ScriptTool/ScriptTool/ScriptTool.csproj +++ b/ScriptTool/ScriptTool/ScriptTool.csproj @@ -33,9 +33,9 @@ 4 - - False - ..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll + + ..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll + True diff --git a/ScriptTool/ScriptTool/packages.config b/ScriptTool/ScriptTool/packages.config index af70bc8..3e14be6 100644 --- a/ScriptTool/ScriptTool/packages.config +++ b/ScriptTool/ScriptTool/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/ScriptTool/ScriptToolGui/App.config b/ScriptTool/ScriptToolGui/App.config index d0feca6..4d56584 100644 --- a/ScriptTool/ScriptToolGui/App.config +++ b/ScriptTool/ScriptToolGui/App.config @@ -1,6 +1,14 @@ - + - + + + + + + + + + diff --git a/ScriptTool/ScriptToolGui/MainForm.Designer.cs b/ScriptTool/ScriptToolGui/MainForm.Designer.cs index cbdfe46..1b2ae7b 100644 --- a/ScriptTool/ScriptToolGui/MainForm.Designer.cs +++ b/ScriptTool/ScriptToolGui/MainForm.Designer.cs @@ -53,7 +53,7 @@ this.lineOpsPanel = new System.Windows.Forms.FlowLayoutPanel(); this.copyCodesButton = new System.Windows.Forms.Button(); this.previewButton = new System.Windows.Forms.Button(); - this.previewer = new ScriptToolGui.StringPreviewer(); + this.translateButton = new System.Windows.Forms.Button(); this.codeSplitContainer = new System.Windows.Forms.SplitContainer(); this.codeList = new System.Windows.Forms.ListBox(); this.label2 = new System.Windows.Forms.Label(); @@ -65,6 +65,7 @@ this.statusBar = new System.Windows.Forms.StatusStrip(); this.writeLabel = new System.Windows.Forms.ToolStripStatusLabel(); this.writeTimer = new System.Windows.Forms.Timer(this.components); + this.previewer = new ScriptToolGui.StringPreviewer(); this.mainMenu.SuspendLayout(); this.topPanel.SuspendLayout(); this.mainPanel.SuspendLayout(); @@ -121,7 +122,7 @@ this.checkCompletionMenu, this.autosaveMenu}); this.toolsMenu.Name = "toolsMenu"; - this.toolsMenu.Size = new System.Drawing.Size(48, 20); + this.toolsMenu.Size = new System.Drawing.Size(47, 20); this.toolsMenu.Text = "Tools"; // // resolveDuplicateLabelsMenu @@ -337,6 +338,7 @@ this.lineOpsPanel.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; this.lineOpsPanel.Controls.Add(this.copyCodesButton); this.lineOpsPanel.Controls.Add(this.previewButton); + this.lineOpsPanel.Controls.Add(this.translateButton); this.lineOpsPanel.Dock = System.Windows.Forms.DockStyle.Bottom; this.lineOpsPanel.Location = new System.Drawing.Point(0, 489); this.lineOpsPanel.Name = "lineOpsPanel"; @@ -363,18 +365,15 @@ this.previewButton.UseVisualStyleBackColor = true; this.previewButton.Click += new System.EventHandler(this.previewButton_Click); // - // previewer + // translateButton // - this.previewer.AutoScroll = true; - this.previewer.CharLookup = null; - this.previewer.DisplayedString = null; - this.previewer.Dock = System.Windows.Forms.DockStyle.Fill; - this.previewer.Location = new System.Drawing.Point(0, 0); - this.previewer.M12Compiler = null; - this.previewer.MaxWidth = 0; - this.previewer.Name = "previewer"; - this.previewer.Size = new System.Drawing.Size(796, 133); - this.previewer.TabIndex = 0; + this.translateButton.Location = new System.Drawing.Point(214, 3); + this.translateButton.Name = "translateButton"; + this.translateButton.Size = new System.Drawing.Size(114, 23); + this.translateButton.TabIndex = 2; + this.translateButton.Text = "Google Translate"; + this.translateButton.UseVisualStyleBackColor = true; + this.translateButton.Click += new System.EventHandler(this.translateButton_Click); // // codeSplitContainer // @@ -500,6 +499,18 @@ this.writeTimer.Interval = 10000; this.writeTimer.Tick += new System.EventHandler(this.writeTimer_Tick); // + // previewer + // + this.previewer.AutoScroll = true; + this.previewer.CharLookup = null; + this.previewer.Dock = System.Windows.Forms.DockStyle.Fill; + this.previewer.Location = new System.Drawing.Point(0, 0); + this.previewer.M12Compiler = null; + this.previewer.MaxWidth = 0; + this.previewer.Name = "previewer"; + this.previewer.Size = new System.Drawing.Size(796, 133); + this.previewer.TabIndex = 0; + // // MainForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -584,6 +595,7 @@ private System.Windows.Forms.Button prevButton; private System.Windows.Forms.Button nextButton; private System.Windows.Forms.ToolStripMenuItem autosaveMenu; + private System.Windows.Forms.Button translateButton; } } diff --git a/ScriptTool/ScriptToolGui/MainForm.cs b/ScriptTool/ScriptToolGui/MainForm.cs index 6d317eb..da346d9 100644 --- a/ScriptTool/ScriptToolGui/MainForm.cs +++ b/ScriptTool/ScriptToolGui/MainForm.cs @@ -23,6 +23,7 @@ namespace ScriptToolGui static Compiler ebCompiler = new Compiler(EbControlCode.Codes, (rom, address) => rom[address] < 0x20); static readonly Game[] validGames; static IDictionary ebCharLookup; + static IDictionary m12CharLookup; // Lookups Dictionary textboxLookup; @@ -64,12 +65,13 @@ namespace ScriptToolGui { validGames = new Game[] { Game.Eb, Game.M12, Game.M12English }; ebCharLookup = JsonConvert.DeserializeObject>(File.ReadAllText("eb-char-lookup.json")); + m12CharLookup = JsonConvert.DeserializeObject>(File.ReadAllText("m12-char-lookup.json")); } string ReadEbString(byte[] rom, int address, int length) { var sb = new StringBuilder(); - for(int i=0;i4 - - False - ..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll + + ..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll + True diff --git a/ScriptTool/ScriptToolGui/StringPreviewer.cs b/ScriptTool/ScriptToolGui/StringPreviewer.cs index dbdf969..5dc127c 100644 --- a/ScriptTool/ScriptToolGui/StringPreviewer.cs +++ b/ScriptTool/ScriptToolGui/StringPreviewer.cs @@ -18,30 +18,16 @@ namespace ScriptToolGui public int MaxWidth { get; set; } - private string text; - public string DisplayedString - { - get - { - return text; - } - set - { - text = value; - Redraw(); - } - } - public StringPreviewer() { InitializeComponent(); } - private void Redraw() + private void RedrawFancy(string str) { stringPanel.Controls.Clear(); - if (M12Compiler == null || CharLookup == null || text == null) + if (M12Compiler == null || CharLookup == null || str == null) { return; } @@ -49,7 +35,7 @@ namespace ScriptToolGui try { IList widths; - IList parsed = M12Compiler.FormatPreviewM12(text, out widths, CharLookup); + IList parsed = M12Compiler.FormatPreviewM12(str, out widths, CharLookup); for (int i = 0; i < parsed.Count; i++) { @@ -77,5 +63,28 @@ namespace ScriptToolGui stringPanel.Controls.Add(errLabel); } } + + private void RedrawPlain(string str) + { + stringPanel.Controls.Clear(); + + if (str == null) + return; + + var label = new Label + { + AutoSize = true, + Text = str + }; + stringPanel.Controls.Add(label); + } + + public void DisplayString(string str, bool fancy) + { + if (fancy) + RedrawFancy(str); + else + RedrawPlain(str); + } } } diff --git a/ScriptTool/ScriptToolGui/packages.config b/ScriptTool/ScriptToolGui/packages.config index 747efc5..3e14be6 100644 --- a/ScriptTool/ScriptToolGui/packages.config +++ b/ScriptTool/ScriptToolGui/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file