Skip to content

Commit

Permalink
Change hotkeys to disable when an input field is selected
Browse files Browse the repository at this point in the history
  • Loading branch information
zbx1425 committed Apr 18, 2021
1 parent d01cded commit 4994ad2
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 31 deletions.
4 changes: 2 additions & 2 deletions BlocklyAtsGui/BlocklyAtsGui.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 .
Expand Down
2 changes: 1 addition & 1 deletion BlocklyAtsGui/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@
// 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
// 方法是按如下所示使用“*”: :
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.5.102")]
[assembly: AssemblyVersion("1.0.6.0")]
11 changes: 8 additions & 3 deletions BlocklyAtsGui/System/GameDetection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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}";
Expand Down
28 changes: 26 additions & 2 deletions BlocklyAtsGui/UserInterface/FormMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions assets/example/ats-s.batsxml

Large diffs are not rendered by default.

52 changes: 31 additions & 21 deletions www/js/bats_code.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
Expand Down
2 changes: 1 addition & 1 deletion www/js/csharp_generator_bve.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {}
Blockly.CSharp.bve_comment = function(block) { return ""; }
2 changes: 1 addition & 1 deletion www/js/lua_generator_bve.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {}
Blockly.Lua.bve_comment = function(block) { return ""; }

0 comments on commit 4994ad2

Please sign in to comment.