mirror of
https://github.com/LmeSzinc/StarRailCopilot.git
synced 2024-11-26 02:11:06 +00:00
commit
e2d44fa989
@ -15,9 +15,8 @@ from module.base.decorator import Config, cached_property, del_cached_property,
|
||||
from module.base.utils import SelectedGrids, ensure_time
|
||||
from module.device.connection_attr import ConnectionAttr
|
||||
from module.device.env import IS_LINUX, IS_MACINTOSH, IS_WINDOWS
|
||||
from module.device.method.utils import (
|
||||
PackageNotInstalled, RETRY_TRIES, get_serial_pair, handle_adb_error,
|
||||
possible_reasons, random_port, recv_all, remove_shell_warning, retry_sleep)
|
||||
from module.device.method.utils import (PackageNotInstalled, RETRY_TRIES, get_serial_pair, handle_adb_error,
|
||||
possible_reasons, random_port, recv_all, remove_shell_warning, retry_sleep)
|
||||
from module.exception import EmulatorNotRunningError, RequestHumanTakeover
|
||||
from module.logger import logger
|
||||
|
||||
|
@ -7,6 +7,7 @@ from adbutils import AdbClient, AdbDevice
|
||||
|
||||
from module.base.decorator import cached_property
|
||||
from module.config.config import AzurLaneConfig
|
||||
from module.device.method.utils import get_serial_pair
|
||||
from module.exception import RequestHumanTakeover
|
||||
from module.logger import logger
|
||||
|
||||
@ -127,8 +128,11 @@ class ConnectionAttr:
|
||||
|
||||
@cached_property
|
||||
def port(self) -> int:
|
||||
port_serial, _ = get_serial_pair(self.serial)
|
||||
if port_serial is None:
|
||||
port_serial = self.serial
|
||||
try:
|
||||
return int(self.serial.split(':')[1])
|
||||
return int(port_serial.split(':')[1])
|
||||
except (IndexError, ValueError):
|
||||
return 0
|
||||
|
||||
@ -147,6 +151,10 @@ class ConnectionAttr:
|
||||
def is_nox_family(self):
|
||||
return 62001 <= self.port <= 63025
|
||||
|
||||
@cached_property
|
||||
def is_vmos(self):
|
||||
return 5667 <= self.port <= 5699
|
||||
|
||||
@cached_property
|
||||
def is_emulator(self):
|
||||
return self.serial.startswith('emulator-') or self.serial.startswith('127.0.0.1:')
|
||||
|
@ -3,6 +3,7 @@ import itertools
|
||||
|
||||
from lxml import etree
|
||||
|
||||
from module.device.env import IS_WINDOWS
|
||||
# Patch pkg_resources before importing adbutils and uiautomator2
|
||||
from module.device.pkg_resources import get_distribution
|
||||
|
||||
@ -86,7 +87,7 @@ class Device(Screenshot, Control, AppControl):
|
||||
raise
|
||||
|
||||
# Auto-fill emulator info
|
||||
if self.config.EmulatorInfo_Emulator == 'auto':
|
||||
if IS_WINDOWS and self.config.EmulatorInfo_Emulator == 'auto':
|
||||
_ = self.emulator_instance
|
||||
|
||||
# SRC only, use nemu_ipc if available
|
||||
@ -138,6 +139,10 @@ class Device(Screenshot, Control, AppControl):
|
||||
# if self.config.Emulator_ScreenshotMethod != 'nemu_ipc' and self.config.Emulator_ControlMethod == 'nemu_ipc':
|
||||
# logger.warning('When not using nemu_ipc, both screenshot and control should not use nemu_ipc')
|
||||
# self.config.Emulator_ControlMethod = 'minitouch'
|
||||
# Allow Hermit on VMOS only
|
||||
if self.config.Emulator_ControlMethod == 'Hermit' and not self.is_vmos:
|
||||
logger.warning('ControlMethod is allowed on VMOS only')
|
||||
self.config.Emulator_ControlMethod = 'minitouch'
|
||||
pass
|
||||
|
||||
def screenshot(self):
|
||||
|
@ -52,6 +52,7 @@ class Fuel(UI):
|
||||
continue
|
||||
|
||||
self._fuel_wait_leave()
|
||||
self.interval_reset([POPUP_CONFIRM, POPUP_CANCEL], interval=2)
|
||||
|
||||
def _fuel_cancel(self, skip_first_screenshot=True):
|
||||
"""
|
||||
@ -75,6 +76,7 @@ class Fuel(UI):
|
||||
continue
|
||||
|
||||
self._fuel_wait_leave()
|
||||
self.interval_reset([POPUP_CONFIRM, POPUP_CANCEL], interval=2)
|
||||
|
||||
def _fuel_wait_leave(self):
|
||||
# Blur disappears before popup
|
||||
@ -189,6 +191,7 @@ class Fuel(UI):
|
||||
if use <= 0:
|
||||
logger.info("Fuel remain is under the reserve threshold, stop using fuel")
|
||||
self._fuel_cancel()
|
||||
return False
|
||||
|
||||
skip_first_screenshot = True
|
||||
while 1:
|
||||
|
Loading…
Reference in New Issue
Block a user