Skip to content

Commit

Permalink
fix: 设备尺寸错误时无法找到首页图标 & 退出公告栏的方式
Browse files Browse the repository at this point in the history
  • Loading branch information
Zebartin committed Mar 31, 2023
1 parent 7f475b8 commit c8d1816
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
6 changes: 3 additions & 3 deletions NIKKE/NIKKEutils.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,12 @@ function 退出NIKKE() {

function 返回首页() {
const homeImage = images.read('./images/home.jpg');
let [width, height] = getDisplaySize();
var result = null;
for (let i = 0; i < 10; ++i) {
result = findImageByFeature(captureScreen(), homeImage, {
let img = captureScreen();
result = findImageByFeature(img, homeImage, {
threshold: 0.6,
region: [0, height * 0.8, width / 2, height * 0.2]
region: [0, img.height * 0.8, img.width / 2, img.height * 0.2]
});
if (result != null)
break;
Expand Down
9 changes: 7 additions & 2 deletions NIKKE/NIKKE日常.js
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,13 @@ function dispatch(bulletin) {
sleep(500);
}
}
sleep(600);
back();
clickRect(bulletin, 1, 0);
ocrUntilFound(res => {
if (res.text.includes('中心'))
return true;
clickRect(bulletin, 1, 0);
return false;
}, 30, 1000);
}

function 基地收菜(doDailyMission) {
Expand Down
1 change: 1 addition & 0 deletions utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ function getOcrRes() {
function getDisplaySize(doNotForcePortrait) {
let { width, height } = device;
if (width == 0) {
console.warn('设备尺寸为0,可能会影响正常运行,可以尝试重启设备');
let metrics = context.getResources().getDisplayMetrics();
width = metrics.widthPixels;
height = metrics.heightPixels;
Expand Down

0 comments on commit c8d1816

Please sign in to comment.