diff --git a/BlocklyAtsGui/BlocklyAtsGui.csproj b/BlocklyAtsGui/BlocklyAtsGui.csproj index d559ce4..5fd23e7 100644 --- a/BlocklyAtsGui/BlocklyAtsGui.csproj +++ b/BlocklyAtsGui/BlocklyAtsGui.csproj @@ -198,8 +198,8 @@ XCOPY "$(SolutionDir)assets" "$(TargetDir)\" /E /Y IF $(ConfigurationName)==Release ( COPY /Y "$(SolutionDir)BatsWinApi\Release\batswinapi_x86.dll" "$(TargetDir)\lib" COPY /Y "$(SolutionDir)BatsWinApi\Release\batswinapi_x64.dll" "$(TargetDir)\lib" -ERASE "$(TargetDir)\WebView2Loader.dll" -RMDIR /S /Q "${TargetDir)\BlocklyATS.exe.WebView2" +COPY /Y "$(SolutionDir)README.md" "$(TargetDir)" +COPY /Y "$(SolutionDir)LICENSE" "$(TargetDir)" ERASE "$(TargetDir)\*.xml" ERASE "$(TargetDir)\*.zip" "C:\Program Files\7-zip\7z.exe" a BlocklyAts.zip . diff --git a/BlocklyAtsGui/Properties/AssemblyInfo.cs b/BlocklyAtsGui/Properties/AssemblyInfo.cs index 73da3bd..65f33dc 100644 --- a/BlocklyAtsGui/Properties/AssemblyInfo.cs +++ b/BlocklyAtsGui/Properties/AssemblyInfo.cs @@ -32,4 +32,4 @@ // 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号 // 方法是按如下所示使用“*”: : // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.5.102")] +[assembly: AssemblyVersion("1.0.6.0")] diff --git a/BlocklyAtsGui/System/GameDetection.cs b/BlocklyAtsGui/System/GameDetection.cs index 98633fa..ce41bb9 100644 --- a/BlocklyAtsGui/System/GameDetection.cs +++ b/BlocklyAtsGui/System/GameDetection.cs @@ -45,9 +45,14 @@ static GameDetection() { break; } - const string Bve5ProductID = "{D38EB8AB-0772-473D-9443-9B2149E4F13D}"; - var basePath5 = GetMsiBasePath(Bve5ProductID); - if (basePath5 != null) BveTs5Path = Path.Combine(basePath5, "BveTs.exe"); + const string Bve57ProductID = "{D38EB8AB-0772-473D-9443-9B2149E4F13D}"; + var basePath57 = GetMsiBasePath(Bve57ProductID); + if (basePath57 != null) BveTs5Path = Path.Combine(basePath57, "BveTs.exe"); + if (!File.Exists(BveTs5Path)) BveTs5Path = null; + + const string Bve58ProductID = "{78B5F5D7-025C-43D5-88A3-6E75017599B7}"; + var basePath58 = GetMsiBasePath(Bve58ProductID); + if (basePath58 != null) BveTs5Path = Path.Combine(basePath58, "BveTs.exe"); if (!File.Exists(BveTs5Path)) BveTs5Path = null; const string Bve6ProductID = "{AB8616E0-A471-4261-9563-FE411A2A245B}"; diff --git a/BlocklyAtsGui/UserInterface/FormMain.cs b/BlocklyAtsGui/UserInterface/FormMain.cs index 5d7da2a..6c2bb5b 100644 --- a/BlocklyAtsGui/UserInterface/FormMain.cs +++ b/BlocklyAtsGui/UserInterface/FormMain.cs @@ -88,8 +88,6 @@ private void ApplyLanguage() { item.AutoSize = false; item.Size = new Size(tsbSize, tsbSize); if (item.Image == null) continue; - int sourceWidth = item.Image.Width; - int sourceHeight = item.Image.Height; Bitmap b = new Bitmap(tsbSize, tsbSize); using (Graphics g = Graphics.FromImage((Image)b)) { g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor; @@ -249,6 +247,32 @@ private async void tsbtnCompile_Click(object sender, EventArgs e) { private async void tsbtnSave_Click(object sender, EventArgs e) { await saveWorkspace(); + new System.Threading.Thread(() => { + var resources = new ComponentResourceManager(typeof(FormMain)); + Image sourceIcon = (Image)resources.GetObject("tsbtnSave.Image"); + Bitmap originalIcon = new Bitmap(tsbtnSave.Width, tsbtnSave.Height); + using (Graphics g = Graphics.FromImage(originalIcon)) { + g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor; + g.DrawImage(sourceIcon, 0, 0, tsbtnSave.Width, tsbtnSave.Height); + } + Bitmap flashingIcon = new Bitmap(originalIcon); + using (Graphics g = Graphics.FromImage(flashingIcon)) { + g.FillRectangle( + new SolidBrush(Color.FromArgb(150, 0, 200, 50)), + new Rectangle(0, 0, flashingIcon.Width, flashingIcon.Height) + ); + } + for (int i = 0; i <= 7; i++) { + this.BeginInvoke((Action)(() => { + if (i % 2 == 0) { + tsbtnSave.Image = flashingIcon; + } else { + tsbtnSave.Image = originalIcon; + } + })); + System.Threading.Thread.Sleep(60); + } + }).Start(); } private async void tsbtnCompileRun_Click(object sender, EventArgs e) { diff --git a/assets/example/ats-s.batsxml b/assets/example/ats-s.batsxml new file mode 100644 index 0000000..02507ef --- /dev/null +++ b/assets/example/ats-s.batsxml @@ -0,0 +1 @@ +1.0.6.0truetruetrueUnspecifiedEB StandbyEB ApplyRed SignalEB ApplyBrakeWhen multiple commands on the same sound,The last one executed takes effect.01OREB ApplyEB Standby0100Red Signal1100Assigning default values to all your variablesin "Load" or "Initalization" is recommended.EB StandbyFALSEEB ApplyFALSERed SignalFALSEATS-SN Plugin ExampleOnly for demonstration.The functionality might not be precise.ATSEBEB StandbyFALSEEB ApplyTRUEYou can use mouse wheel to scroll.Press "Shift" to see some of the hotkeys.LTESignal0EQType0S-Type Transponder: Red SignalTRUEEQEB StandbyFALSEEB StandbyTRUEATSEB3000FALSEEQType1SN-Type Transponder: Red SignalTRUEEB ApplyTRUEEQType1Accidental Departure Transponder: Option: Cars ORGTEOptionalCarsEQOptional0Red SignalTRUEEB ApplyTRUEANDEQSGTEBrakeAtsNotchANDEQB1GTEBrakeEB ApplyFALSEANDEQA1ANDEB StandbyEB ApplyRed SignalFALSEFunctions makes blocks more organized.EB NotchDescribe this function...ADD1BrakeNotches1Reset TimerDescribe this function...EB StandbyFALSEATSEBStop \ No newline at end of file diff --git a/www/js/bats_code.js b/www/js/bats_code.js index 4ae69dc..b9f8a3d 100644 --- a/www/js/bats_code.js +++ b/www/js/bats_code.js @@ -42,36 +42,46 @@ function batsInit(toolboxNode) { window.workspace = Blockly.inject(blocklyDiv, { toolbox: toolboxNode, media: "media/", - grid: {spacing: 40, length: 3, colour: '#ccc', snap: true}, + grid: { spacing: 40, length: 3, colour: "#ccc", snap: true }, + zoom: { + controls: true, + wheel: false, + startScale: 1.0, + maxScale: 3, + minScale: 0.3, + scaleSpeed: 1.2, + pinch: false, + }, + move:{ + scrollbars: { + horizontal: true, + vertical: true + }, + drag: true, + wheel: true + }, maxInstances: { - "bve_hat_elapse": 1, - "bve_hat_initialize": 1, - "bve_hat_keydown_any": 1, - "bve_hat_keyup_any": 1, - "bve_hat_horn_blow": 1, - "bve_hat_door_change": 1, - "bve_hat_set_signal": 1, - "bve_hat_set_beacon": 1, - "bve_hat_load": 1, - "bve_hat_dispose": 1, + bve_hat_elapse: 1, + bve_hat_initialize: 1, + bve_hat_keydown_any: 1, + bve_hat_keyup_any: 1, + bve_hat_horn_blow: 1, + bve_hat_door_change: 1, + bve_hat_set_signal: 1, + bve_hat_set_beacon: 1, + bve_hat_load: 1, + bve_hat_dispose: 1, }, }); workspace.setTheme(themeWithHat); - //workspace.addChangeListener(onWkspChange); var onresize = function(e) { Blockly.svgResize(workspace); }; window.addEventListener('resize', onresize, false); Blockly.svgResize(workspace); - var toolboxMap = [11,0,1,2,3,5,6,7,8,9]; var onkeydown = function(e) { - if (e.shiftKey) { - if (e.key) { - var selIndex = shortcutKeyMap.indexOf(e.key); - if (selIndex >= 0) workspace.getToolbox().selectItemByPosition(selIndex); - } else if (e.keyCode && (e.keyCode >= 0x30 && e.keyCode <= 0x39)) { - // Damn Microsoft! - workspace.getToolbox().selectItemByPosition(toolboxMap[e.keyCode - 0x30]); - } + if (e.shiftKey && e.key && document.activeElement.tagName.toUpperCase() != "INPUT") { + var selIndex = shortcutKeyMap.indexOf(e.key); + if (selIndex >= 0) workspace.getToolbox().selectItemByPosition(selIndex); } if (e.key == "Shift") document.getElementById("hotkey-hint-overlay").style.display = "block"; } diff --git a/www/js/csharp_generator_bve.js b/www/js/csharp_generator_bve.js index 368ad41..3f9b169 100644 --- a/www/js/csharp_generator_bve.js +++ b/www/js/csharp_generator_bve.js @@ -250,4 +250,4 @@ Blockly.CSharp.bve_timer_modify=function(block){ return "_c.ResetTimer(" + Blockly.CSharp.quote_(timerName) + ", true);\n"; } } -Blockly.CSharp.bve_comment = function(block) {} \ No newline at end of file +Blockly.CSharp.bve_comment = function(block) { return ""; } \ No newline at end of file diff --git a/www/js/lua_generator_bve.js b/www/js/lua_generator_bve.js index 18d4514..3e5129d 100644 --- a/www/js/lua_generator_bve.js +++ b/www/js/lua_generator_bve.js @@ -260,4 +260,4 @@ Blockly.Lua.bve_timer_modify=function(block){ return "_ftimerreset(" + Blockly.Lua.quote_(timerName) + ", true)\n"; } } -Blockly.Lua.bve_comment = function(block) {} \ No newline at end of file +Blockly.Lua.bve_comment = function(block) { return ""; } \ No newline at end of file