mirror of
https://github.com/LmeSzinc/AzurLaneAutoScript.git
synced 2025-01-07 07:47:07 +08:00
Added: added toast notifications support to windows 10
This commit is contained in:
parent
a154c12569
commit
95c1008e5a
52
alas.bat
52
alas.bat
@ -43,6 +43,11 @@ set "template=%root%\config\template.ini"
|
||||
set "gitFolder=%root%\.git"
|
||||
set "logFolder=%root%\log\"
|
||||
|
||||
set "_pyBin=%root%\toolkit"
|
||||
set "_GitBin=%root%\toolkit\Git\mingw64\bin"
|
||||
set "_adbBin=%root%\toolkit\Lib\site-packages\adbutils\binaries"
|
||||
set "PATH=%root%\toolkit\alias;%root%\toolkit\command;%_pyBin%;%_pyBin%\Scripts;%_GitBin%;%_adbBin%;%PATH%"
|
||||
|
||||
:: Import main settings (%Language%, %Region%, %SystemType%).
|
||||
call command\Get.bat Main
|
||||
:: Import the Proxy setting and apply. Then show more info in Option6.
|
||||
@ -214,7 +219,7 @@ if "%choice%"=="1" goto Run_UpdateAlas
|
||||
if "%choice%"=="2" goto update_toolkit
|
||||
if "%choice%"=="3" goto Setting
|
||||
if "%choice%"=="0" goto MENU
|
||||
echo. & echo == Please input a valid option.
|
||||
echo. & echo == ^| Please input a valid option.
|
||||
pause > NUL
|
||||
goto Updater_menu
|
||||
|
||||
@ -223,14 +228,14 @@ set source="origin"
|
||||
if "%Region%"=="cn" set "source=gitee"
|
||||
echo. & echo.
|
||||
echo =======================================================================================================================
|
||||
echo == Branch in use: %Branch%
|
||||
echo == KeepLocalChanges is: %KeepLocalChanges%
|
||||
echo == ^| Branch in use: %Branch%
|
||||
echo == ^| KeepLocalChanges is: %KeepLocalChanges%
|
||||
echo =======================================================================================================================
|
||||
if "%AutoMode%"=="enable" ( goto proceed_alas )
|
||||
set opt6_opt4_choice=0
|
||||
echo. & echo == Change default Branch (master/dev), please enter T;
|
||||
echo == To proceed update using Branch: %Branch%, please enter Y;
|
||||
echo == Back to Updater menu, please enter N;
|
||||
echo. & echo == ^| Change default Branch (master/dev), please enter T;
|
||||
echo == ^| To proceed update using Branch: %Branch%, please enter Y;
|
||||
echo == ^| Back to Updater menu, please enter N;
|
||||
set /p opt6_opt4_choice= Press ENTER to cancel:
|
||||
echo.
|
||||
if /i "%opt6_opt4_choice%"=="T" (
|
||||
@ -240,39 +245,44 @@ if /i "%opt6_opt4_choice%"=="T" (
|
||||
) else if /i "%opt6_opt4_choice%"=="N" (
|
||||
goto ReturnToMenu
|
||||
) else (
|
||||
echo == Invalid input. Cancelled.
|
||||
echo == ^| Invalid input. Cancelled.
|
||||
goto ReturnToMenu
|
||||
)
|
||||
:proceed_alas
|
||||
echo == ^| Updating requirements.txt
|
||||
CALL pip install -r requirements.txt
|
||||
echo == ^| requirements.txt updated!
|
||||
if "%KeepLocalChanges%"=="disable" (
|
||||
echo == GIT Found in %gitBin% Proceeding
|
||||
echo == Updating from %source% repository..
|
||||
echo == ^| GIT Found in %gitBin% Proceeding
|
||||
echo == ^| Updating from %source% repository..
|
||||
%gitBin% fetch %source% %Branch%
|
||||
%gitBin% reset --hard %source%/%Branch%
|
||||
%gitBin% pull --ff-only %source% %Branch%
|
||||
echo == DONE!
|
||||
if %AutoMode%=="enable" (
|
||||
echo. & echo == Press any key to proceed to %DefaultServer%
|
||||
echo == ^| DONE!
|
||||
if "%AutoMode%"=="enable" (
|
||||
echo. & echo == ^| Press any key to proceed to %DefaultServer%
|
||||
goto %DefaultServer% )
|
||||
echo == Press any key to proceed
|
||||
echo == ^| Press any key to proceed
|
||||
pause > NUL
|
||||
goto Updater_menu
|
||||
) else (
|
||||
echo == GIT Found in %gitBin% Proceeding
|
||||
echo == Updating from %source% repository..
|
||||
echo == ^| GIT Found in %gitBin% Proceeding
|
||||
echo == ^| Updating from %source% repository..
|
||||
%gitBin% stash
|
||||
%gitBin% pull %source% %Branch%
|
||||
%gitBin% stash pop
|
||||
echo == DONE!
|
||||
echo == ^| DONE!
|
||||
if "%AutoMode%"=="enable" (
|
||||
echo. & echo == Press any key to proceed to %DefaultServer%
|
||||
goto %DefaultServer% )
|
||||
echo == Press any key to proceed
|
||||
echo. & echo == ^| Press any key to proceed to %DefaultServer% Server
|
||||
goto %DefaultServer% )
|
||||
else (
|
||||
echo == ^| Press any key to proceed
|
||||
pause > NUL
|
||||
goto Updater_menu
|
||||
)
|
||||
)
|
||||
echo. & echo Please re-run this batch to make the settings take effect.
|
||||
echo Please re-run the "alas.bat" to make the settings take effect.
|
||||
echo. & echo == ^| Please re-run this batch to make the settings take effect.
|
||||
echo == ^| Please re-run the "alas.bat" to make the settings take effect.
|
||||
goto PleaseRerun
|
||||
|
||||
:update_toolkit
|
||||
|
BIN
assets/gooey/icon.ico
Normal file
BIN
assets/gooey/icon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 54 KiB |
@ -20,8 +20,9 @@ set FirstRun=no && call command\Config.bat FirstRun %FirstRun%
|
||||
:: Get %Language% , %Region% , %SystemType%
|
||||
:Import_Main
|
||||
:: 1. Get customized %Language%, or decided by "LanguageSelector"
|
||||
for /f %%a in ('date /t') do set DOW=%%a
|
||||
if exist config\alas.ini (
|
||||
echo f | xcopy /y config\alas.ini config\alas_backup.ini > nul
|
||||
echo f | xcopy /y config\alas.ini config\alas_Backup_%DOW%.ini > nul
|
||||
)
|
||||
call command\SystemSet.bat
|
||||
call command\LanguageSet.bat
|
||||
|
@ -2,6 +2,7 @@
|
||||
command = Daily
|
||||
|
||||
[Setting]
|
||||
enable_notifications = no
|
||||
enable_exception = yes
|
||||
enable_stop_condition = no
|
||||
enable_fast_forward = yes
|
||||
|
@ -141,6 +141,7 @@ class CampaignBase(CampaignUI, Map, AutoSearchCombat):
|
||||
self.auto_search_execute_a_battle()
|
||||
except CampaignEnd:
|
||||
logger.hr('Campaign end')
|
||||
self.device.send_notification('AzurLaneAutoScript', 'Campaign end')
|
||||
return True
|
||||
|
||||
# Exception
|
||||
|
@ -90,33 +90,40 @@ class CampaignRun(Reward):
|
||||
# Run count limit
|
||||
if self.run_count >= self.config.STOP_IF_COUNT_GREATER_THAN > 0:
|
||||
logger.hr('Triggered count stop')
|
||||
self.device.send_notification('AzurLaneAutoScript', 'Triggered count stop')
|
||||
return True
|
||||
# Run time limit
|
||||
if self.config.STOP_IF_TIME_REACH and datetime.now() > self.config.STOP_IF_TIME_REACH:
|
||||
logger.hr('Triggered time limit')
|
||||
self.device.send_notification('AzurLaneAutoScript', 'Triggered time limit')
|
||||
self.config.config.set('Setting', 'if_time_reach', '0')
|
||||
self.config.save()
|
||||
return True
|
||||
# Dock full limit
|
||||
if self.config.STOP_IF_DOCK_FULL and self.campaign.config.DOCK_FULL_TRIGGERED:
|
||||
logger.hr('Triggered dock full limit')
|
||||
self.device.send_notification('AzurLaneAutoScript', 'Triggered dock full limit')
|
||||
return True
|
||||
# Emotion limit
|
||||
if self.config.STOP_IF_TRIGGER_EMOTION_LIMIT and self.campaign.config.EMOTION_LIMIT_TRIGGERED:
|
||||
logger.hr('Triggered emotion limit')
|
||||
self.device.send_notification('AzurLaneAutoScript', 'Triggered emotion limit')
|
||||
return True
|
||||
# Lv120 limit
|
||||
if self.config.STOP_IF_REACH_LV120 and self.campaign.config.LV120_TRIGGERED:
|
||||
logger.hr('Triggered lv120 limit')
|
||||
self.device.send_notification('AzurLaneAutoScript', 'Triggered lv120 limit')
|
||||
return True
|
||||
# Oil limit
|
||||
if oil_check and self.config.STOP_IF_OIL_LOWER_THAN:
|
||||
if OCR_OIL.ocr(self.device.image) < self.config.STOP_IF_OIL_LOWER_THAN:
|
||||
logger.hr('Triggered oil limit')
|
||||
self.device.send_notification('AzurLaneAutoScript', 'Triggered oil limit')
|
||||
return True
|
||||
# If Get a New Ship
|
||||
if self.config.STOP_IF_GET_SHIP and self.campaign.config.GET_SHIP_TRIGGERED:
|
||||
logger.hr('Triggered get ship')
|
||||
self.device.send_notification('AzurLaneAutoScript', 'Triggered get ship')
|
||||
return True
|
||||
|
||||
return False
|
||||
@ -131,6 +138,7 @@ class CampaignRun(Reward):
|
||||
if not self.campaign.config.IGNORE_LOW_EMOTION_WARN:
|
||||
if self.campaign.emotion.triggered_bug():
|
||||
logger.hr('Triggered restart avoid emotion bug')
|
||||
self.device.send_notification('AzurLaneAutoScript', 'Triggered restart avoid emotion bug')
|
||||
return True
|
||||
|
||||
return False
|
||||
|
@ -133,6 +133,9 @@ def main(ini_name=''):
|
||||
|
||||
# 选择关卡
|
||||
stage = setting_parser.add_argument_group('关卡设置', '需要运行一次来保存选项', gooey_options={'label_color': '#931D03'})
|
||||
stage.add_argument('--enable_notifications', default=default('--enable_notifications'), choices=['yes', 'no'],
|
||||
help='If enabled will send toast notifications, Windows 10 Only.',
|
||||
gooey_options={'label_color': '#4B5F83'})
|
||||
stage.add_argument('--启用停止条件', default=default('--启用停止条件'), choices=['是', '否'], gooey_options={'label_color': '#4B5F83'})
|
||||
stage.add_argument('--启用异常处理', default=default('--启用异常处理'), choices=['是', '否'], help='处理部分异常, 运行出错时撤退', gooey_options={'label_color': '#4B5F83'})
|
||||
stage.add_argument('--使用周回模式', default=default('--使用周回模式'), choices=['是', '否'], gooey_options={'label_color': '#4B5F83'})
|
||||
|
@ -134,6 +134,9 @@ def main(ini_name=''):
|
||||
|
||||
# 选择关卡
|
||||
stage = setting_parser.add_argument_group('Level settings', 'Need to Press start to save your settings.', gooey_options={'label_color': '#931D03'})
|
||||
stage.add_argument('--enable_notifications', default=default('--enable_notifications'), choices=['yes', 'no'],
|
||||
help='If enabled will send toast notifications, Windows 10 Only.',
|
||||
gooey_options={'label_color': '#4B5F83'})
|
||||
stage.add_argument('--enable_stop_condition', default=default('--enable_stop_condition'), choices=['yes', 'no'], help='If enabled will start reward loop when triggered any filter below', gooey_options={'label_color': '#4B5F83'})
|
||||
stage.add_argument('--enable_exception', default=default('--enable_exception'), choices=['yes', 'no'], help='Enable or disable some exceptions, ALAS will withdraw from the map when it occurs instead of stopping', gooey_options={'label_color': '#4B5F83'})
|
||||
stage.add_argument('--enable_fast_forward', default=default('--enable_fast_forward'), choices=['yes', 'no'], help='Enable or disable clearing mode', gooey_options={'label_color': '#4B5F83'})
|
||||
|
@ -134,6 +134,9 @@ def main(ini_name=''):
|
||||
|
||||
# 选择关卡
|
||||
stage = setting_parser.add_argument_group('Level settings', 'Need to Press start to save your settings.', gooey_options={'label_color': '#931D03'})
|
||||
stage.add_argument('--enable_notifications', default=default('--enable_notifications'), choices=['yes', 'no'],
|
||||
help='If enabled will send toast notifications, Windows 10 Only.',
|
||||
gooey_options={'label_color': '#4B5F83'})
|
||||
stage.add_argument('--enable_stop_condition', default=default('--enable_stop_condition'), choices=['yes', 'no'], help='If enabled will start reward loop when triggered any filter below', gooey_options={'label_color': '#4B5F83'})
|
||||
stage.add_argument('--enable_exception', default=default('--enable_exception'), choices=['yes', 'no'], help='Enable or disable some exceptions, ALAS will withdraw from the map when it occurs instead of stopping', gooey_options={'label_color': '#4B5F83'})
|
||||
stage.add_argument('--enable_fast_forward', default=default('--enable_fast_forward'), choices=['yes', 'no'], help='Enable or disable clearing mode', gooey_options={'label_color': '#4B5F83'})
|
||||
|
@ -133,6 +133,9 @@ def main(ini_name=''):
|
||||
|
||||
# 選擇關卡
|
||||
stage = setting_parser.add_argument_group('關卡設定', '需要執行一次來保存選項', gooey_options={'label_color': '#931D03'})
|
||||
stage.add_argument('--enable_notifications', default=default('--enable_notifications'), choices=['yes', 'no'],
|
||||
help='If enabled will send toast notifications, Windows 10 Only.',
|
||||
gooey_options={'label_color': '#4B5F83'})
|
||||
stage.add_argument('--啟用停止條件', default=default('--啟用停止條件'), choices=['是', '否'], gooey_options={'label_color': '#4B5F83'})
|
||||
stage.add_argument('--啟用異常處理', default=default('--啟用異常處理'), choices=['是', '否'], help='處理部分異常, 執行出錯時撤退', gooey_options={'label_color': '#4B5F83'})
|
||||
stage.add_argument('--使用周回模式', default=default('--使用周回模式'), choices=['是', '否'], gooey_options={'label_color': '#4B5F83'})
|
||||
|
@ -22,6 +22,7 @@ class AzurLaneConfig:
|
||||
start_time = datetime.now()
|
||||
|
||||
UPDATE_CHECK = True
|
||||
ENABLE_NOTIFICATIONS = True
|
||||
UPDATE_METHOD = 'api' # web, api
|
||||
UPDATE_PROXY = ''
|
||||
GITHUB_TOKEN = ''
|
||||
@ -558,6 +559,7 @@ class AzurLaneConfig:
|
||||
|
||||
option = config['Setting']
|
||||
# Stop condition
|
||||
self.ENABLE_NOTIFICATIONS = to_bool(option['enable_notifications'])
|
||||
self.ENABLE_STOP_CONDITION = to_bool(option['enable_stop_condition'])
|
||||
self.ENABLE_EXCEPTION = to_bool(option['enable_exception'])
|
||||
self.ENABLE_FAST_FORWARD = to_bool(option['enable_fast_forward'])
|
||||
|
@ -49,6 +49,7 @@ dic_true_eng_to_eng = {
|
||||
'os_clear_map': 'os_clear_map',
|
||||
|
||||
# Argument
|
||||
'enable_notifications' : 'enable_notifications',
|
||||
'enable_stop_condition': 'enable_stop_condition',
|
||||
'enable_exception': 'enable_exception',
|
||||
'enable_fast_forward': 'enable_fast_forward',
|
||||
@ -325,6 +326,7 @@ dic_chi_to_eng = {
|
||||
'大世界地图全清': 'os_clear_map',
|
||||
|
||||
# Argument
|
||||
'enable_notifications' : 'enable_notifications',
|
||||
'启用停止条件': 'enable_stop_condition',
|
||||
'启用异常处理': 'enable_exception',
|
||||
'使用周回模式': 'enable_fast_forward',
|
||||
@ -601,6 +603,7 @@ dic_tchi_to_eng = {
|
||||
'大世界地圖全清': 'os_clear_map',
|
||||
|
||||
# Argument
|
||||
'enable_notifications' : 'enable_notifications',
|
||||
'啟用停止條件': 'enable_stop_condition',
|
||||
'啟用異常處理': 'enable_exception',
|
||||
'使用周回模式': 'enable_fast_forward',
|
||||
|
@ -8,15 +8,24 @@ from module.device.screenshot import Screenshot
|
||||
from module.exception import GameStuckError
|
||||
from module.handler.assets import GET_MISSION
|
||||
from module.logger import logger
|
||||
import sys
|
||||
if sys.platform == 'win32':
|
||||
from win10toast_persist import ToastNotifier
|
||||
|
||||
|
||||
class Device(Screenshot, Control, AppControl):
|
||||
toaster = ToastNotifier()
|
||||
_screen_size_checked = False
|
||||
stuck_record = set()
|
||||
stuck_timer = Timer(60, count=60).start()
|
||||
stuck_timer_long = Timer(300, count=300).start()
|
||||
stuck_long_wait_list = ['BATTLE_STATUS_S', 'PAUSE']
|
||||
|
||||
def send_notification(self, title, message):
|
||||
if self.config.ENABLE_NOTIFICATIONS and sys.platform == 'win32':
|
||||
notify = ToastNotifier()
|
||||
notify.show_toast(title, message, icon_path='assets\gooey\icon.ico', duration=None)
|
||||
|
||||
def handle_night_commission(self, hour=21, threshold=30):
|
||||
"""
|
||||
Args:
|
||||
|
@ -12,4 +12,5 @@ mxnet==1.6.0
|
||||
cnocr==1.2.2
|
||||
gooey
|
||||
colored
|
||||
python-Levenshtein
|
||||
# python-Levenshtein
|
||||
win10toast-persist
|
Loading…
Reference in New Issue
Block a user