From 2b458b9ad20e51ac96510dc43cf9f1663fc24368 Mon Sep 17 00:00:00 2001 From: zbx1425 Date: Tue, 26 Jan 2021 22:33:08 +0800 Subject: [PATCH] Add Default values for configuration items --- BlocklyAtsGui/BaseBrowser.cs | 16 ++- BlocklyAtsGui/CompilerConfig.cs | 19 +++ BlocklyAtsGui/CompilerFunction.cs | 7 +- BlocklyAtsGui/FormDebug.cs | 4 +- BlocklyAtsGui/FormMain.Designer.cs | 27 +++- BlocklyAtsGui/FormMain.cs | 83 ++++++++----- BlocklyAtsGui/FormMain.resx | 149 +++++++++++++---------- BlocklyAtsGui/Properties/AssemblyInfo.cs | 2 +- BlocklyAtsGui/Resources/lang_en.txt | 1 + BlocklyAtsGui/Resources/lang_ja.txt | 1 + BlocklyAtsGui/Resources/lang_zh_CHS.txt | 1 + BlocklyAtsGui/WebView2Browser.cs | 49 +++++--- assets/example/speedlimit.batsxml | 2 +- assets/lib/boilerplate.lua | 20 ++- www/index.html | 2 +- www/js/bats_code.js | 7 +- www/js/blocks_bve.js | 31 +---- www/js/csharp_generator_bve.js | 15 +-- www/js/lua_compressed.js | 4 +- www/js/lua_generator_bve.js | 29 ++--- www/js/msg_bats/en.js | 3 +- www/js/msg_bats/ja.js | 3 +- www/js/msg_bats/zh-hans.js | 3 +- 23 files changed, 284 insertions(+), 194 deletions(-) diff --git a/BlocklyAtsGui/BaseBrowser.cs b/BlocklyAtsGui/BaseBrowser.cs index 42d66bd..c347cd2 100644 --- a/BlocklyAtsGui/BaseBrowser.cs +++ b/BlocklyAtsGui/BaseBrowser.cs @@ -102,7 +102,9 @@ public async Task BkyResetWorkspace() { } public async Task BkySaveWorkspace() { - var element = XElement.Parse((await InvokeScript("batsWkspSave();")).ToString()); + var workspaceString = (await InvokeScript("batsWkspSave();"))?.ToString(); + if (workspaceString == null) return null; + var element = XElement.Parse(workspaceString); element.RemoveAttributes(); return element; } @@ -112,12 +114,20 @@ public async Task BkyLoadWorkspace(XElement bkyxml) { await InvokeScript(string.Format("batsWkspLoad({0});", arg)); } + public async Task BkyLoadInitWorkspace(XElement bkyxml) { + var arg = EscapeJsString(bkyxml.ToString(SaveOptions.DisableFormatting)); + await InvokeScript(string.Format( + "if (workspace == null) window.onBlocklyLoad = function() {{batsWkspLoad({0});}}; else batsWkspLoad({0});", + arg + )); + } + public async Task BkyExportLua() { - return (await InvokeScript("batsWkspExportLua();")).ToString(); + return (await InvokeScript("batsWkspExportLua();"))?.ToString(); } public async Task BkyExportCSharp() { - return (await InvokeScript("batsWkspExportCSharp();")).ToString(); + return (await InvokeScript("batsWkspExportCSharp();"))?.ToString(); } } } diff --git a/BlocklyAtsGui/CompilerConfig.cs b/BlocklyAtsGui/CompilerConfig.cs index 6962f14..b38f1dc 100644 --- a/BlocklyAtsGui/CompilerConfig.cs +++ b/BlocklyAtsGui/CompilerConfig.cs @@ -4,6 +4,7 @@ using System.Diagnostics; using System.IO; using System.Linq; +using System.Runtime.InteropServices; using System.Text; using System.Threading.Tasks; using System.Xml.Serialization; @@ -32,8 +33,15 @@ public CompilerConfig Clone() { return (CompilerConfig)this.MemberwiseClone(); } +#if !MONO + [DllImport("msi.dll", CharSet = CharSet.Unicode)] + private static extern Int32 MsiGetProductInfo(string product, string property, [Out] StringBuilder valueBuf, ref Int32 len); +#endif + public Process GetGameProcess() { var path = GamePath; + + // OpenBVE if (string.IsNullOrEmpty(path)) { if (PlatformFunction.IsWindows()) { const string InnoAppID = "{D617A45D-C2F6-44D1-A85C-CA7FFA91F7FC}_is1"; @@ -53,6 +61,17 @@ public Process GetGameProcess() { // TODO: Support them } } + +#if !MONO + // BVE5 + /*if (string.IsNullOrEmpty(path) && PlatformFunction.IsWindows()) { + Int32 len = 512; + StringBuilder builder = new StringBuilder(len); + MsiGetProductInfo("{D38EB8AB-0772-473D-9443-9B2149E4F13D}", "LocalPackage", builder, ref len); + string str = builder.ToString(); + }*/ +#endif + if (string.IsNullOrEmpty(path) || !File.Exists(path)) { return null; } diff --git a/BlocklyAtsGui/CompilerFunction.cs b/BlocklyAtsGui/CompilerFunction.cs index abed7e6..75af8e5 100644 --- a/BlocklyAtsGui/CompilerFunction.cs +++ b/BlocklyAtsGui/CompilerFunction.cs @@ -29,6 +29,9 @@ static class CompilerFunction { return process.HasExited ? Task.CompletedTask : tcs.Task; } + public static string BoilerplateLua = File.ReadAllText(Path.Combine(appDir, "lib", "boilerplate.lua")); + public static string BoilerplateCSharp = File.ReadAllText(Path.Combine(appDir, "lib", "boilerplate.cs")); + public static async Task CompileLua(string script, string outputPath, string arch) { /*var proc = new Process { StartInfo = new ProcessStartInfo { @@ -51,7 +54,7 @@ public static async Task CompileLua(string script, string outputPath, string arc } var luaByteStream = new MemoryStream();*/ - var sourceCode = File.ReadAllText(Path.Combine(appDir, "lib", "boilerplate.lua")) + script; + var sourceCode = BoilerplateLua + script; var boilerplateStream = new FileStream( Path.Combine(appDir, "lib", "batswinapi_" + arch + ".dll"), @@ -80,7 +83,7 @@ public static async Task CompileLua(string script, string outputPath, string arc } public static void CompileCSharp(string script, string outputPath) { - var sourceCode = File.ReadAllText(Path.Combine(appDir, "lib", "boilerplate.cs")) + script; + var sourceCode = BoilerplateCSharp + script; var settings = new Dictionary() { { "CompilerVersion", "v4.0" } }; diff --git a/BlocklyAtsGui/FormDebug.cs b/BlocklyAtsGui/FormDebug.cs index b52dd59..323855e 100644 --- a/BlocklyAtsGui/FormDebug.cs +++ b/BlocklyAtsGui/FormDebug.cs @@ -19,9 +19,9 @@ public FormDebug() { private void rbLua_CheckedChanged(object sender, EventArgs e) { if (sender == rbLua) { - tbCode.Text = codeLua; + tbCode.Text = CompilerFunction.BoilerplateLua + codeLua; } else { - tbCode.Text = codeCSharp; + tbCode.Text = CompilerFunction.BoilerplateCSharp + codeCSharp; } } diff --git a/BlocklyAtsGui/FormMain.Designer.cs b/BlocklyAtsGui/FormMain.Designer.cs index 7d22114..453fd68 100644 --- a/BlocklyAtsGui/FormMain.Designer.cs +++ b/BlocklyAtsGui/FormMain.Designer.cs @@ -35,8 +35,9 @@ private void InitializeComponent() { this.tsbtnCompileSetting = new System.Windows.Forms.ToolStripButton(); this.tsbtnAbout = new System.Windows.Forms.ToolStripButton(); this.tsbtnDebugWindow = new System.Windows.Forms.ToolStripButton(); - this.tscbLanguage = new System.Windows.Forms.ToolStripComboBox(); this.tss2 = new System.Windows.Forms.ToolStripSeparator(); + this.tscbLanguage = new System.Windows.Forms.ToolStripComboBox(); + this.tsbtnHelp = new System.Windows.Forms.ToolStripButton(); this.mainToolStrip.SuspendLayout(); this.SuspendLayout(); // @@ -54,6 +55,7 @@ private void InitializeComponent() { this.tsbtnCompileRun, this.tsbtnCompileSetting, this.tsbtnAbout, + this.tsbtnHelp, this.tsbtnDebugWindow, this.tss2, this.tscbLanguage}); @@ -168,6 +170,13 @@ private void InitializeComponent() { this.tsbtnDebugWindow.Text = "Debug Window"; this.tsbtnDebugWindow.Click += new System.EventHandler(this.tsbtnDebugWindow_Click); // + // tss2 + // + this.tss2.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right; + this.tss2.Margin = new System.Windows.Forms.Padding(3, 0, 3, 0); + this.tss2.Name = "tss2"; + this.tss2.Size = new System.Drawing.Size(6, 25); + // // tscbLanguage // this.tscbLanguage.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right; @@ -178,12 +187,17 @@ private void InitializeComponent() { this.tscbLanguage.Size = new System.Drawing.Size(121, 25); this.tscbLanguage.SelectedIndexChanged += new System.EventHandler(this.tscbLanguage_SelectedIndexChanged); // - // tss2 + // tsbtnHelp // - this.tss2.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right; - this.tss2.Margin = new System.Windows.Forms.Padding(3, 0, 3, 0); - this.tss2.Name = "tss2"; - this.tss2.Size = new System.Drawing.Size(6, 25); + this.tsbtnHelp.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right; + this.tsbtnHelp.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.tsbtnHelp.Image = ((System.Drawing.Image)(resources.GetObject("tsbtnHelp.Image"))); + this.tsbtnHelp.ImageTransparentColor = System.Drawing.Color.Magenta; + this.tsbtnHelp.Margin = new System.Windows.Forms.Padding(0, 1, 4, 2); + this.tsbtnHelp.Name = "tsbtnHelp"; + this.tsbtnHelp.Size = new System.Drawing.Size(23, 22); + this.tsbtnHelp.Text = "帮助(&L)"; + this.tsbtnHelp.Click += new System.EventHandler(this.tsbtnHelp_Click); // // FormMain // @@ -218,6 +232,7 @@ private void InitializeComponent() { private System.Windows.Forms.ToolStripButton tsbtnAbout; private System.Windows.Forms.ToolStripSeparator tss2; private System.Windows.Forms.ToolStripComboBox tscbLanguage; + private System.Windows.Forms.ToolStripButton tsbtnHelp; } } diff --git a/BlocklyAtsGui/FormMain.cs b/BlocklyAtsGui/FormMain.cs index f286e55..acdfb45 100644 --- a/BlocklyAtsGui/FormMain.cs +++ b/BlocklyAtsGui/FormMain.cs @@ -23,28 +23,8 @@ public FormMain() { private Workspace currentWorkspace = new Workspace(); - private void FormMain_Load(object sender, EventArgs e) { -#if DEBUG - string webDirectory = Path.Combine(Path.GetDirectoryName(CompilerFunction.appDir), "www"); - if (!Directory.Exists(webDirectory)) webDirectory = Path.Combine(CompilerFunction.appDir, "www"); -#else - string webDirectory = Path.Combine(CompilerFunction.appDir, "www"); -#endif - string pageURL = Path.Combine(webDirectory, "index.html") + string.Format("?ver={0}&lang={1}", - Assembly.GetExecutingAssembly().GetName().Version.ToString(), - I18n.Translate("BlocklyName") - ); - mainWebBrowser = BaseBrowser.AcquireInstance(pageURL); - mainWebBrowser.KeyDown += new PreviewKeyDownEventHandler(mainWebBrowser_PreviewKeyDown); - this.PreviewKeyDown += new PreviewKeyDownEventHandler(mainWebBrowser_PreviewKeyDown); - mainWebBrowser.BindTo(this); - updateSaveFileState(); + private async void FormMain_Load(object sender, EventArgs e) { - foreach (ToolStripItem item in mainToolStrip.Items) { - if (I18n.CanTranslate("FormMain." + item.Name)) { - item.Text = I18n.Translate("FormMain." + item.Name); - } - } for (int i = 0; i < I18n.LanguageDisplayList.Count; i++) { tscbLanguage.Items.Add(I18n.LanguageDisplayList[i].Value); if (I18n.LanguageDisplayList[i].Key == I18n.SelectedLanguage) { @@ -52,8 +32,9 @@ private void FormMain_Load(object sender, EventArgs e) { tscbLanguage.Text = I18n.LanguageDisplayList[i].Value; } } + await ApplyLanguage(); - Task.Run(async () => { + await Task.Run(async () => { var info = await UpgradeInfo.FetchOnline( "https://www.zbx1425.cn/nautilus/projectmeta.xml", "BlocklyAts" @@ -66,14 +47,47 @@ private void FormMain_Load(object sender, EventArgs e) { }); } + private async Task ApplyLanguage() { + foreach (ToolStripItem item in mainToolStrip.Items) { + if (I18n.CanTranslate("FormMain." + item.Name)) { + item.Text = I18n.Translate("FormMain." + item.Name); + } + } + updateSaveFileState(); +#if DEBUG + string webDirectory = Path.Combine(Path.GetDirectoryName(CompilerFunction.appDir), "www"); + if (!Directory.Exists(webDirectory)) webDirectory = Path.Combine(CompilerFunction.appDir, "www"); +#else + string webDirectory = Path.Combine(CompilerFunction.appDir, "www"); +#endif + string pageURL = Path.Combine(webDirectory, "index.html") + string.Format("?ver={0}&lang={1}", + Assembly.GetExecutingAssembly().GetName().Version.ToString(), + I18n.Translate("BlocklyName") + ); + if (mainWebBrowser == null) { + mainWebBrowser = BaseBrowser.AcquireInstance(pageURL); + mainWebBrowser.KeyDown += new PreviewKeyDownEventHandler(mainWebBrowser_PreviewKeyDown); + this.PreviewKeyDown += new PreviewKeyDownEventHandler(mainWebBrowser_PreviewKeyDown); + mainWebBrowser.BindTo(this); + } else { + var workspaceState = await mainWebBrowser.BkySaveWorkspace(); + if (workspaceState == null) return; + currentWorkspace.BlocklyXml = new FPXElement(workspaceState); + mainWebBrowser.Navigate(pageURL); + EventHandler loadHandler = null; + loadHandler = (EventHandler)(async (sender, e) => { + await mainWebBrowser.BkyLoadInitWorkspace(currentWorkspace.BlocklyXml); + mainWebBrowser.PageFinished -= loadHandler; + }); + mainWebBrowser.PageFinished += loadHandler; + } + } + private async void mainWebBrowser_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e) { if (e.KeyCode == Keys.F5) { if (ModifierKeys.HasFlag(Keys.Control) && ModifierKeys.HasFlag(Keys.Shift)) { // Debug function. - currentWorkspace.BlocklyXml = new FPXElement(await mainWebBrowser.BkySaveWorkspace()); - mainWebBrowser.Reload(); - await Task.Delay(2000); - await mainWebBrowser.BkyLoadWorkspace(currentWorkspace.BlocklyXml); + await ApplyLanguage(); } else { tsbtnCompileRun_Click(null, null); } @@ -128,7 +142,9 @@ private async void tsbtnSaveAs_Click(object sender, EventArgs e) { }; if (sfd.ShowDialog() != DialogResult.OK) return; - currentWorkspace.BlocklyXml = new FPXElement(await mainWebBrowser.BkySaveWorkspace()); + var workspaceState = await mainWebBrowser.BkySaveWorkspace(); + if (workspaceState == null) return; + currentWorkspace.BlocklyXml = new FPXElement(workspaceState); currentWorkspace.SaveToFile(sfd.FileName); updateSaveFileState(); } @@ -199,7 +215,9 @@ private async void tsbtnCompile_Click(object sender, EventArgs e) { private async void tsbtnSave_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(currentWorkspace.SaveFilePath)) return; - currentWorkspace.BlocklyXml = new FPXElement(await mainWebBrowser.BkySaveWorkspace()); + var workspaceState = await mainWebBrowser.BkySaveWorkspace(); + if (workspaceState == null) return; + currentWorkspace.BlocklyXml = new FPXElement(workspaceState); currentWorkspace.SaveToFile(); } @@ -248,12 +266,17 @@ private void tsbtnAbout_Click(object sender, EventArgs e) { new FormAbout().ShowDialog(); } - private void tscbLanguage_SelectedIndexChanged(object sender, EventArgs e) { + private async void tscbLanguage_SelectedIndexChanged(object sender, EventArgs e) { var newlang = I18n.LanguageDisplayList[tscbLanguage.SelectedIndex].Key; if (newlang != I18n.SelectedLanguage) { I18n.SelectedLanguage = newlang; - MessageBox.Show(I18n.Translate("Msg.LanguageChange")); + await ApplyLanguage(); + //MessageBox.Show(I18n.Translate("Msg.LanguageChange")); } } + + private void tsbtnHelp_Click(object sender, EventArgs e) { + PlatformFunction.CallBrowser("https://github.com/zbx1425/BlocklyAts/wiki"); + } } } diff --git a/BlocklyAtsGui/FormMain.resx b/BlocklyAtsGui/FormMain.resx index f43b513..0fca489 100644 --- a/BlocklyAtsGui/FormMain.resx +++ b/BlocklyAtsGui/FormMain.resx @@ -191,88 +191,103 @@ iVBORw0KGgoAAAANSUhEUgAAABYAAAAWCAYAAADEtGw7AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAPsSURBVEhLpZRtTFtVHMZPW7qWFmh50bp92pfFODWUsKUZ - OKnMlUwyccFY4+ZawOgSt6QzmwuZJhhD/LDNujndWMiKg1GkYResjrfABRnsJZDqBIEVejczqTJja5gd - 4Mrjub3X1KZQTHySX+499/7P09P/yyWJtO41Vq8zs+vF5f+XbjdrfOTANaR+7kVGeb9HY2G1Wa902TJL - u7mMXR02TQmrFUP/m9Za+m06C2tcu5u1KU7fA7kDKC/NQFs5gvQ3ByD1hJBcM4X0Xe1V4pbVxZtqP56A - 5sQ4Hq0YCCSxcyAcIJ0IQ3UlBPXQAySPLEA6EoKyvC+g2XnZlvrC11ZNsdsoWiwv3Z5+DxkEyGSUrNpZ - PG6bwMZ3xvDU4R+hP3oLm47fxXrX70ipHoXi5C2oKvqRWtRmFW3ilVH2HchhajhE+YGa1sziycoJ5Hww - GseWYz48U/cb0q4/RNL5n6A2tTpEm1gJ1e8MKPf7QYapMeWJI15s+dTLGU557YaT3irD6SnGcGY8kHfW - B56t5+5gR1MQmbV3oXq+lRGtYpW17yrUdh+UtTORE6vaQsipnmYLHFxM9fm18csZeyHjB4+JmUVh+wPI - j96E4rkWZk1Bi00Mpbmlfao5dBOkj55URNYdxtOV06wYEqciNmAtHvwDPObeP/EYG4bUGYR8bx8U+S6h - mDpzt1F90AfipKadUTYe98PwkX/F4SidXLC/PLWIV8cWkdsbjuyRnvoZSXnNQlr4E6dZvhcKx1NLcQNp - Tf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nWF/SDtdKccRasfTxRdF/kri5Ih+nI2d/0Ghtn5Bx4R/ZDbp6B6uR3qpHrp + MuPMrSbtHg+InUrPLbD68DiM747fszmyh27bnh+ZwwsDc3jS6Q+skZf9BGVinXQsbMeRlu+li2NUUhxA + ZO0sNhwZW/rsaCxe6M3js74d3nmsa5sPrFGmnYciyb5QfjFmEeGvuBGafwPkEBU3SKw8Po308smlb5zm + rQan00sICt5sgOzDCciNdhdJEIK7Upd5zhD1bLOgevtnkBoq5qw8MYMtNVOu7PrpRY3ApCx++vt61gHI + DnggT6r3EqM9+Aj1W7+yqUqpuJpK/4bmcz+MdbPIdkx7c9pmq17tulOSd/muq5+J3W6gr48Wfixys9+B + 7KVukHUnDVwpJWLnBZBTVFbBYeK/xpyY6nksPymNu5n4FF1QXg7U1QEhITCv2g2uk8J6XrOnB6STLqql + nKGwsZNygvLxYtqYuLAQyMsD8vOB4mJM0jk3IVu5VkrkJkeViraovGUKYRYRIft7Ibs8F2jxICn7o7NA + ExObTEByMmA0AikpQFoaiug8V0rRZQr68PQmlza10aVJEwzqVCFHneHwyb6dChaPUG4AtUwcHg5otfT7 + GkonCQYofbTMufLeUafUmxS2gcAOyRe0CQqGAmUl23cJlUysUkkolfDQ528I2ceX3j+sRQNi+tEnPb9D + sZGWU0KVXra2Rihj4hUrAtyhYwchB/myB0eVWGdQbGz0KnKdkJtbFkopwR7/HhPTM4VMhrOEvB+Y/8+h + u/xnfY4SYiik8iuEPMeneAj5E91kyCICUvknAAAAAElFTkSuQmCC iVBORw0KGgoAAAANSUhEUgAAABYAAAAWCAYAAADEtGw7AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAMsSURBVEhLvZRdSFNhGMe904sQGYLIyDFmM5YKK61tuCbT - dAnrohsvLEkUQoqsmxWBRBQ5QhD7oCIS+riIpIu6UYkR63Nrc06ZzM+07cxt6nQtt0mb+/ecs+Nd2DTq - B4dzznue//953ud935P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gud2vKswuxNZgAAAABJRU5ErkJggg== diff --git a/BlocklyAtsGui/Properties/AssemblyInfo.cs b/BlocklyAtsGui/Properties/AssemblyInfo.cs index cad437b..b55385f 100644 --- a/BlocklyAtsGui/Properties/AssemblyInfo.cs +++ b/BlocklyAtsGui/Properties/AssemblyInfo.cs @@ -32,4 +32,4 @@ // 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号 // 方法是按如下所示使用“*”: : // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.5.2")] +[assembly: AssemblyVersion("1.0.5.3")] diff --git a/BlocklyAtsGui/Resources/lang_en.txt b/BlocklyAtsGui/Resources/lang_en.txt index 7a7fc83..e27aa7f 100644 --- a/BlocklyAtsGui/Resources/lang_en.txt +++ b/BlocklyAtsGui/Resources/lang_en.txt @@ -9,6 +9,7 @@ FormMain.tsbtnCompile = Compile (Ctrl+Shift+B) FormMain.tsbtnCompileRun = Compile and Run (F5) FormMain.tsbtnCompileSetting = Compiler Configuration FormMain.tsbtnDebugWindow = Debug Window +FormMain.tsbtnHelp = Help FormMain.tsbtnAbout = About BlocklyAts FormCompilerConfig.cbShouldx86 = 32-bit Windows DLL\nFor BVE4/5、OpenBVE diff --git a/BlocklyAtsGui/Resources/lang_ja.txt b/BlocklyAtsGui/Resources/lang_ja.txt index 7c24f21..eed3ba6 100644 --- a/BlocklyAtsGui/Resources/lang_ja.txt +++ b/BlocklyAtsGui/Resources/lang_ja.txt @@ -9,6 +9,7 @@ FormMain.tsbtnCompile = コンパイル (Ctrl+Shift+B) FormMain.tsbtnCompileRun = コンパイルして実行する (F5) FormMain.tsbtnCompileSetting = コンパイラ設定 FormMain.tsbtnDebugWindow = デバッグウィンドウ +FormMain.tsbtnHelp = 説明書 FormMain.tsbtnAbout = BlocklyAts 関連情報 FormCompilerConfig.cbShouldx86 = 32ビット Windows DLL\nBVE4/5、OpenBVE用 diff --git a/BlocklyAtsGui/Resources/lang_zh_CHS.txt b/BlocklyAtsGui/Resources/lang_zh_CHS.txt index 79be362..54e79bd 100644 --- a/BlocklyAtsGui/Resources/lang_zh_CHS.txt +++ b/BlocklyAtsGui/Resources/lang_zh_CHS.txt @@ -9,6 +9,7 @@ FormMain.tsbtnCompile = 编译 (Ctrl+Shift+B) FormMain.tsbtnCompileRun = 编译并运行 (F5) FormMain.tsbtnCompileSetting = 编译设置 FormMain.tsbtnDebugWindow = 调试窗口 +FormMain.tsbtnHelp = 帮助 FormMain.tsbtnAbout = 关于 BlocklyAts FormCompilerConfig.cbShouldx86 = 32位 Windows DLL\n用于 BVE4/5、OpenBVE diff --git a/BlocklyAtsGui/WebView2Browser.cs b/BlocklyAtsGui/WebView2Browser.cs index 7f7b199..24da178 100644 --- a/BlocklyAtsGui/WebView2Browser.cs +++ b/BlocklyAtsGui/WebView2Browser.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.ComponentModel; using System.IO; using System.Linq; using System.Text; @@ -29,28 +30,21 @@ public WebView2Browser(string url = "about:blank") { browser.CoreWebView2.AddWebResourceRequestedFilter("*", CoreWebView2WebResourceContext.All); browser.CoreWebView2.WebResourceRequested += CoreWebView2_WebResourceRequested; browser.CoreWebView2.Settings.IsZoomControlEnabled = false; - browser.CoreWebView2.Settings.AreDevToolsEnabled = false; + //browser.CoreWebView2.Settings.AreDevToolsEnabled = false; browser.CoreWebView2.Settings.IsStatusBarEnabled = false; browser.CoreWebView2.Settings.AreDefaultContextMenusEnabled = false; }; browser.EnsureCoreWebView2Async(environment); - - if (url[1] == ':' && url[2] == '\\') { - // URLParser says file urls cannot have query param. Make them happy. - browser.Source = new Uri("http://make.urlparser.happy/" + url); - } else { - browser.Source = new Uri(url); - } + Navigate(url); } private void CoreWebView2_WebResourceRequested(object sender, CoreWebView2WebResourceRequestedEventArgs e) { + Uri parsedUri = new Uri(e.Request.Uri); string path; - if (e.Request.Uri.StartsWith("file:///")) { - path = e.Request.Uri.Substring(8).Replace('/', '\\'); - if (path.Contains("%3F")) path = path.Substring(0, path.IndexOf("%3F")); - } else if (e.Request.Uri.StartsWith("http://make.urlparser.happy/")) { - path = e.Request.Uri.Substring(28).Replace('/', '\\'); - if (path.Contains("?")) path = path.Substring(0, path.IndexOf("?")); + if (parsedUri.Scheme == "file") { + path = parsedUri.LocalPath; + } else if (parsedUri.Scheme == "http" && parsedUri.Host == "make.urlparser.happy") { + path = parsedUri.LocalPath.TrimStart('/', '\\'); } else { return; } @@ -67,9 +61,24 @@ private void CoreWebView2_WebResourceRequested(object sender, CoreWebView2WebRes 200, "OK", "Content-Type: " + (mimeMap.TryGetValue(extension, out string mimeType) ? mimeType : "application/octet-stream")); } else { + string errorMessageTemplate = @" +

Error: 404 Not Found

+

Please inform developer with these information: zbx1425@outlook.com

+
+ + + + {2} +
Missing Path{0}
URL String{1}
+ "; + var urlParsed = new Uri(e.Request.Uri); + var errorMessage = string.Format(errorMessageTemplate, path, e.Request.Uri, + string.Join("\n", urlParsed.GetType().GetProperties() + .Select(t => string.Format("{0}{1}", t.Name, t.GetValue(urlParsed)))) + ); e.Response = environment.CreateWebResourceResponse( - new MemoryStream(Encoding.UTF8.GetBytes("404 Not Found")), - 404, "Not Found", "Content-Type: text/plain;charset=utf-8" + new MemoryStream(Encoding.UTF8.GetBytes(errorMessage)), + 404, "Not Found", "Content-Type: text/html;charset=utf-8" ); } } @@ -92,12 +101,18 @@ public override Control GetControl() { public override async Task InvokeScript(string script) { var resultString = await browser.ExecuteScriptAsync(script); + if (resultString == null) return null; if (resultString == "undefined" || resultString == "null") return null; return UnescapeJsString(resultString); } public override void Navigate(string url) { - browser.Source = new Uri(url); + if (url[1] == ':' && url[2] == '\\') { + // URLParser says file urls cannot have query param. Make them happy. + browser.Source = new Uri("http://make.urlparser.happy/" + url); + } else { + browser.Source = new Uri(url); + } } public override void Reload() { diff --git a/assets/example/speedlimit.batsxml b/assets/example/speedlimit.batsxml index a018cc9..866aa46 100644 --- a/assets/example/speedlimit.batsxml +++ b/assets/example/speedlimit.batsxml @@ -1 +1 @@ -truetruetruebrake triggeredspeedlimit.inibrake triggeredFALSEGTspeedlimitmaxspeedbrake triggeredbrake triggeredTRUE0brake triggeredPower0BrakeADD1BrakeNotches11100MULTIPLY1DIVIDE16010001EQB1ANDGTBrakeBrakeNotchesEQ0brake triggeredFALSE \ No newline at end of file +1.0.5.3truetruetruebrake triggeredspeedlimit.inibrake triggeredFALSEGTspeedlimitmaxspeed40brake triggeredbrake triggeredTRUE0brake triggeredPower0BrakeADD1BrakeNotches11100MULTIPLY1DIVIDE16010001EQB1ANDGTBrakeBrakeNotchesEQ0brake triggeredFALSE \ No newline at end of file diff --git a/assets/lib/boilerplate.lua b/assets/lib/boilerplate.lua index feda435..20cbae1 100644 --- a/assets/lib/boilerplate.lua +++ b/assets/lib/boilerplate.lua @@ -1,5 +1,21 @@ -local LIP={}function LIP.load(b)assert(type(b)=='string','Parameter \"fileName\" must be a string.')local c=assert(io.open(b,'r'),'Error loading file : '..b)local d={}local e;for f in c:lines()do local g=f:match('^%[([^%[%]]+)%]$')if g then e=tonumber(g)and tonumber(g)or g;d[e]=d[e]or{}end;local h,i=f:match('^([%w|_]+)%s-=%s-(.+)$')if h and i~=nil then if tonumber(i)then i=tonumber(i)elseif i=='true'then i=true elseif i=='false'then i=false end;if tonumber(h)then h=tonumber(h)end;d[e][h]=i end end;c:close()return d end;function LIP.save(b,d)assert(type(b)=='string','Parameter \"fileName\" must be a string.')assert(type(d)=='table','Parameter \"data\" must be a table.')local c=assert(io.open(b,'w+b'),'Error loading file :'..b)local j=''for e,h in pairs(d)do j=j..('[%s]\\n'):format(e)for k,i in pairs(h)do j=j..('%s=%s\\n'):format(k,tostring(i))end;j=j..'\\n'end;c:write(j)c:close()end - +local LIP={}function LIP.load(b)assert(type(b)=='string','Parameter "fileName" must be a string.')local c=io.open(b,'r');if c==nil then;return;end;local d={}local e;for f in c:lines()do local g=f:match('^%[([^%[%]]+)%]$')if g then e=tonumber(g)and tonumber(g)or g;d[e]=d[e]or{}end;local h,i=f:match('^([%w|_]+)%s-=%s-(.+)$')if h and i~=nil then if tonumber(i)then i=tonumber(i)elseif i=='true'then i=true elseif i=='false'then i=false end;if tonumber(h)then h=tonumber(h)end;d[e][h]=i end end;c:close()return d end;function LIP.save(b,d)assert(type(b)=='string','Parameter "fileName" must be a string.')assert(type(d)=='table','Parameter "data" must be a table.')local c=assert(io.open(b,'w+b'),'Error loading file :'..b)local j=''for e,h in pairs(d)do j=j..('[%s]\n'):format(e)for k,i in pairs(h)do j=j..('%s=%s\n'):format(k,tostring(i))end;j=j..'\n'end;c:write(j)c:close()end +function __atsfnc_cfgload(path) + __atsval_config=LIP.load(__atsval_dlldir..path) +end +function __atsfnc_cfgsave(path) + LIP.save(__atsval_dlldir..path,__atsval_config) +end +function __atsfnc_cfgget(part,key,default) + if __atsval_config==nil then;return default;end + if __atsval_config[part]==nil then;return default;end + if __atsval_config[part][key]==nil then;return default;end + return __atsval_config[part][key] +end +function __atsfnc_cfgset(part,key,value) + if __atsval_config==nil then;__atsval_config={};end + if __atsval_config[part]==nil then;__atsval_config[part]={};end + __atsval_config[part][key]=value +end __bve_keystate = {false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false} __bve_doorstate = false diff --git a/www/index.html b/www/index.html index ce16b30..67fb0ae 100644 --- a/www/index.html +++ b/www/index.html @@ -134,8 +134,8 @@ + diff --git a/www/js/bats_code.js b/www/js/bats_code.js index 613cfa9..f59ffc2 100644 --- a/www/js/bats_code.js +++ b/www/js/bats_code.js @@ -1,5 +1,4 @@ -var Code = {}; -var workspace = {}; +var workspace = null; var themeWithHat = Blockly.Theme.defineTheme('themeWithHat', { 'base': Blockly.Themes.Classic, @@ -70,6 +69,10 @@ function batsInit(toolboxNode) { } } document.addEventListener('keydown', onkeydown, false); + + if (typeof onBlocklyLoad != 'undefined' && onBlocklyLoad != null) { + onBlocklyLoad(); + } } window.addEventListener('load', function() { diff --git a/www/js/blocks_bve.js b/www/js/blocks_bve.js index 200123e..9dbb4dd 100644 --- a/www/js/blocks_bve.js +++ b/www/js/blocks_bve.js @@ -438,9 +438,9 @@ Blockly.defineBlocksWithJsonArray([ output: [ "String", "Number" ], }, { - type: "bve_get_config_default_num", + type: "bve_get_config_default", style: "bve_blocks", - message0: "%{BKY_BVE_GET_CONFIG_DEFAULT_NUM}", + message0: "%{BKY_BVE_GET_CONFIG_DEFAULT}", args0: [ { type: "field_input", @@ -453,32 +453,9 @@ Blockly.defineBlocksWithJsonArray([ text: "%{BKY_BVE_PLACEHOLDER_KEY}" }, { - type: "field_number", - name: "DEFAULT_VAL", - text: 0 - } - ], - output: [ "String", "Number" ], - }, - { - type: "bve_get_config_default_text", - style: "bve_blocks", - message0: "%{BKY_BVE_GET_CONFIG_DEFAULT_TEXT}", - args0: [ - { - type: "field_input", - name: "PART", - text: "%{BKY_BVE_PLACEHOLDER_PART}" - }, - { - type: "field_input", - name: "KEY", - text: "%{BKY_BVE_PLACEHOLDER_KEY}" - }, - { - type: "field_input", + type: "input_value", name: "DEFAULT_VAL", - text: "" + check: [ "String", "Number" ], } ], output: [ "String", "Number" ], diff --git a/www/js/csharp_generator_bve.js b/www/js/csharp_generator_bve.js index df9aef1..c21a797 100644 --- a/www/js/csharp_generator_bve.js +++ b/www/js/csharp_generator_bve.js @@ -39,6 +39,7 @@ Blockly.CSharp.addReservedWords([ "__atsarg_initindex", "__atsarg_key", "__atsarg_signal", + "__c", "__zbx_1", "__zbx_2", ].join(",")); @@ -201,19 +202,11 @@ Blockly.CSharp.bve_get_config=function(block){ return ["__c.GetConfig(" + Blockly.CSharp.quote_(block.getFieldValue("PART")) + ", " + Blockly.CSharp.quote_(block.getFieldValue("KEY")) + ")", Blockly.CSharp.ORDER_ATOMIC]; } -Blockly.CSharp.bve_get_config_default_num=function(block){ // TODO +Blockly.CSharp.bve_get_config_default=function(block){ // TODO return [ "__c.GetConfig(" + Blockly.CSharp.quote_(block.getFieldValue("PART")) + ", " - + Blockly.CSharp.quote_(block.getFieldValue("KEY")) + ", " - + block.getFieldValue("DEFAULT_VAL") +")", - Blockly.CSharp.ORDER_ATOMIC - ]; -} -Blockly.CSharp.bve_get_config_default_text=function(block){ // TODO - return [ - "__c.GetConfig(" + Blockly.CSharp.quote_(block.getFieldValue("PART")) + ", " - + Blockly.CSharp.quote_(block.getFieldValue("KEY")) + ", " - + Blockly.CSharp.quote_(block.getFieldValue("DEFAULT_VAL")) +")", + + Blockly.CSharp.quote_(block.getFieldValue("KEY")) + ", (" + + Blockly.Lua.valueToCode(block, "DEFAULT_VAL", Blockly.CSharp.ORDER_NONE) +"))", Blockly.CSharp.ORDER_ATOMIC ]; } diff --git a/www/js/lua_compressed.js b/www/js/lua_compressed.js index e9be9ac..9f4d353 100644 --- a/www/js/lua_compressed.js +++ b/www/js/lua_compressed.js @@ -70,8 +70,8 @@ Blockly.Lua.procedures_defreturn=function(a){var b=Blockly.Lua.variableDB_.getNa var e=Blockly.Lua.statementToCode(a,"STACK"),f=Blockly.Lua.valueToCode(a,"RETURN",Blockly.Lua.ORDER_NONE)||"",g="";e&&f&&(g=c);f?f=Blockly.Lua.INDENT+"return "+f+"\n":e||(e="");for(var h=[],l=a.getVars(),k=0;k