From 8b15e7665fa1ce3eb374a454388caefb50b85d80 Mon Sep 17 00:00:00 2001 From: Juemin Lin Date: Fri, 8 Nov 2024 14:51:12 +0800 Subject: [PATCH 1/3] 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 000000000..10e92502a --- /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 000000000..deba3a792 --- /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 000000000..75bee750a --- /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 From 580da48f170decf1b5b862f5595bc7c4287282a3 Mon Sep 17 00:00:00 2001 From: Juemin Lin Date: Fri, 8 Nov 2024 15:11:33 +0800 Subject: [PATCH 2/3] Add files via upload --- repo/js/SetTimeMinute/main.js | 64 +++++++++++++++++++++++++++++ repo/js/SetTimeMinute/manifest.json | 14 +++++++ repo/js/SetTimeMinute/settings.json | 12 ++++++ 3 files changed, 90 insertions(+) create mode 100644 repo/js/SetTimeMinute/main.js create mode 100644 repo/js/SetTimeMinute/manifest.json create mode 100644 repo/js/SetTimeMinute/settings.json diff --git a/repo/js/SetTimeMinute/main.js b/repo/js/SetTimeMinute/main.js new file mode 100644 index 000000000..650fbf71f --- /dev/null +++ b/repo/js/SetTimeMinute/main.js @@ -0,0 +1,64 @@ +(async function () { + // 设置游戏分辨率和DPI缩放 + setGameMetrics(1920, 1080, 1); + // 圆心坐标 + const centerX = 1441; + const centerY = 501.6; + // 半径 + const r1 = 30; + const r2 = 150; + const r3 = 300; + const stepDuration = 50; + + function getPosition(r, index) { + let angle = index * Math.PI / 720; + return [Math.round(centerX + r * Math.cos(angle)), Math.round(centerY + r * Math.sin(angle))]; + } + async function mouseClick(x, y) { + moveMouseTo(x, y); + await sleep(50); + leftButtonDown(); + await sleep(50); + leftButtonUp(); + 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 setTime(hour, minute) { + const end = (hour + 6) * 60 + minute-20; + const n = 3; + for (let i = - n + 1; i < 1; i++) { + let [x,y] = getPosition(r1, end + i * 1440 / n); + await mouseClick(x, y); + } + let [x1,y1] = getPosition(r2, end + 5); + let [x2, y2] = getPosition(r3, end + 20 + 0.5); + await mouseClickAndMove(x1, y1, x2, y2); + } + const hour = Number(settings.hour); + const minute = Number(settings.minute); + let h = Math.floor(hour+minute/60); + const m = Math.floor(hour*60+minute)-h*60; + h = ((h % 24) + 24) % 24; + log.info(`设置时间到 ${h} 点 ${m} 分`); + await keyPress("Escape"); + await sleep(1000); + await click(50,700); + await sleep(2000); + await setTime(h, m); + await sleep(1000); + await click(1500,1000);//确认 + await sleep(18000); + await keyPress("Escape"); + await sleep(2000); + await keyPress("Escape"); + await sleep(2000); +})(); \ No newline at end of file diff --git a/repo/js/SetTimeMinute/manifest.json b/repo/js/SetTimeMinute/manifest.json new file mode 100644 index 000000000..f7c0b2aa4 --- /dev/null +++ b/repo/js/SetTimeMinute/manifest.json @@ -0,0 +1,14 @@ +{ + "manifest_version": 1, + "name": "调整游戏时间精确到分钟", + "version": "1.0", + "bgi_version": "0.36.0", + "description": "用于调整游戏时间,精确到分钟,请在调度器中使用", + "authors": [ + { + "name": "Tim" + } + ], + "settings_ui": "settings.json", + "main": "main.js" +} diff --git a/repo/js/SetTimeMinute/settings.json b/repo/js/SetTimeMinute/settings.json new file mode 100644 index 000000000..6e214bbb6 --- /dev/null +++ b/repo/js/SetTimeMinute/settings.json @@ -0,0 +1,12 @@ +[ + { + "name": "hour", + "type": "input-text", + "label": "输入小时(0-24)" + }, + { + "name": "minute", + "type": "input-text", + "label": "输入分钟(0-60)" + } +] \ No newline at end of file From b239c9ef88f98355302d3ba2dce5fd322501e161 Mon Sep 17 00:00:00 2001 From: Juemin Lin Date: Fri, 8 Nov 2024 15:15:56 +0800 Subject: [PATCH 3/3] Update manifest.json --- repo/js/SetTimeMinute/manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/repo/js/SetTimeMinute/manifest.json b/repo/js/SetTimeMinute/manifest.json index f7c0b2aa4..1698da8d5 100644 --- a/repo/js/SetTimeMinute/manifest.json +++ b/repo/js/SetTimeMinute/manifest.json @@ -1,6 +1,6 @@ { "manifest_version": 1, - "name": "调整游戏时间精确到分钟", + "name": "精确调整游戏时间到分钟", "version": "1.0", "bgi_version": "0.36.0", "description": "用于调整游戏时间,精确到分钟,请在调度器中使用",