From 8b15e7665fa1ce3eb374a454388caefb50b85d80 Mon Sep 17 00:00:00 2001 From: Juemin Lin Date: Fri, 8 Nov 2024 14:51:12 +0800 Subject: [PATCH] Add files via upload --- repo/js/SetMapZoom/main.js | 50 ++++++++++++++++++++++++++++++++ repo/js/SetMapZoom/manifest.json | 14 +++++++++ repo/js/SetMapZoom/settings.json | 7 +++++ 3 files changed, 71 insertions(+) create mode 100644 repo/js/SetMapZoom/main.js create mode 100644 repo/js/SetMapZoom/manifest.json create mode 100644 repo/js/SetMapZoom/settings.json diff --git a/repo/js/SetMapZoom/main.js b/repo/js/SetMapZoom/main.js new file mode 100644 index 00000000..10e92502 --- /dev/null +++ b/repo/js/SetMapZoom/main.js @@ -0,0 +1,50 @@ +(async function () { + setGameMetrics(1920, 1080, 2); + const stepDuration = 50; + + const commonX = 49; + const ZoomInButton = 428; + const ZoomOutButton = 654; + const start = 453; + const end = 628; + + async function mouseClickNTimes(x, y,n) { + moveMouseTo(x, y); + await sleep(100); + for (let i =0; i < n; i++) { + leftButtonDown(); + await sleep(50); + leftButtonUp(); + await sleep(50); + } + await sleep(stepDuration); + } + async function mouseClickAndMove(x1, y1, x2, y2) { + moveMouseTo(x1, y1); + await sleep(50); + leftButtonDown(); + await sleep(50); + moveMouseTo(x2, y2); + await sleep(50); + leftButtonUp(); + await sleep(stepDuration); + } + async function setMapZoom(n) { + await mouseClickNTimes(commonX, ZoomOutButton, 5); + if (Number.isInteger(n)) { + mouseClickNTimes(commonX, ZoomInButton, 5 - n); + } else { + const targetY = Math.ceil(start + n * 35 - 0.5); + await mouseClickAndMove(commonX, end, commonX, targetY); + } + } + const zoom = Number(settings.zoom); + const n = Math.min(Math.max(zoom, 1),6)- 1; + log.info(`设置大地图缩放为 ${n+1}`); + await keyPress("M"); + await sleep(1000); + await setMapZoom(n); + await sleep(1000); + await keyPress("Escape"); + await sleep(1000); +})(); \ No newline at end of file diff --git a/repo/js/SetMapZoom/manifest.json b/repo/js/SetMapZoom/manifest.json new file mode 100644 index 00000000..deba3a79 --- /dev/null +++ b/repo/js/SetMapZoom/manifest.json @@ -0,0 +1,14 @@ +{ + "manifest_version": 1, + "name": "设置大地图缩放", + "version": "1.0", + "bgi_version": "0.36.0", + "description": "通过左侧缩放条调整大地图缩放,1为最大放大,6为最小,3.5为中间", + "authors": [ + { + "name": "Tim" + } + ], + "settings_ui": "settings.json", + "main": "main.js" +} diff --git a/repo/js/SetMapZoom/settings.json b/repo/js/SetMapZoom/settings.json new file mode 100644 index 00000000..75bee750 --- /dev/null +++ b/repo/js/SetMapZoom/settings.json @@ -0,0 +1,7 @@ +[ + { + "name": "zoom", + "type": "input-text", + "label": "缩放,范围是1~6,1表示最大放大,3.5表示中间" + } +] \ No newline at end of file