Upd: [CN] Support UI in 2024.05.21

This commit is contained in:
LmeSzinc 2024-05-23 01:02:06 +08:00
parent 339530c5d3
commit ecfd5d50bf
36 changed files with 147 additions and 40 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 MiB

After

Width:  |  Height:  |  Size: 8.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 MiB

After

Width:  |  Height:  |  Size: 8.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 MiB

After

Width:  |  Height:  |  Size: 8.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 MiB

After

Width:  |  Height:  |  Size: 8.1 KiB

View File

@ -31,7 +31,7 @@ class PreservedAssets:
regex=re.compile(r'\(([A-Z][A-Z0-9_]+),')
)
# MAIN_CHECK == MAIN_GOTO_CAMPAIGN
assets.add('MAIN_GOTO_CAMPAIGN')
# assets.add('MAIN_GOTO_CAMPAIGN')
return assets

View File

@ -16,11 +16,12 @@ from module.handler.info_handler import InfoHandler
from module.logger import logger
from module.map.map_grids import SelectedGrids
from module.retire.assets import DOCK_CHECK
from module.ui.assets import BACK_ARROW, COMMISSION_CHECK, REWARD_GOTO_COMMISSION, MAIN_GOTO_REWARD
from module.ui.page import page_reward, MAIN_CHECK
from module.ui.assets import BACK_ARROW, COMMISSION_CHECK, REWARD_GOTO_COMMISSION
from module.ui.page import page_reward
from module.ui.scroll import Scroll
from module.ui.switch import Switch
from module.ui.ui import UI
from module.ui_white.assets import REWARD_1_WHITE, REWARD_GOTO_COMMISSION_WHITE
COMMISSION_SWITCH = Switch('Commission_switch', is_selector=True)
COMMISSION_SWITCH.add_status('daily', COMMISSION_DAILY)
@ -529,14 +530,20 @@ class RewardCommission(UI, InfoHandler):
click_timer.reset()
reward = True
continue
if click_timer.reached() and self.appear_then_click(REWARD_1_WHITE, offset=(20, 20), interval=1):
click_timer.reset()
reward = True
continue
if click_timer.reached() and self.appear_then_click(REWARD_GOTO_COMMISSION, offset=(20, 20)):
click_timer.reset()
continue
if click_timer.reached() and self.appear_then_click(REWARD_GOTO_COMMISSION_WHITE, offset=(20, 20)):
click_timer.reset()
continue
if click_timer.reached() and self.ui_additional():
click_timer.reset()
continue
if self.appear(MAIN_CHECK, offset=(30, 30), interval=5):
self.device.click(MAIN_GOTO_REWARD)
if self.ui_main_appear_then_click(page_reward, interval=3):
click_timer.reset()
continue

View File

@ -1,6 +1,5 @@
from module.equipment.fleet_equipment import FleetEquipment
from module.logger import logger
from module.ui.page import page_main
class DailyEquipment(FleetEquipment):
@ -20,7 +19,7 @@ class DailyEquipment(FleetEquipment):
self.fleet_enter()
self.fleet_equipment_take_on_preset(preset_record=self.config.FLEET_DAILY_EQUIPMENT)
self.ui_back(page_main.check_button)
self.ui_back(self.is_in_main)
self.equipment_has_take_on = True
self.device.sleep(1)
return True
@ -33,7 +32,7 @@ class DailyEquipment(FleetEquipment):
self.fleet_enter()
self.fleet_equipment_take_off()
self.ui_back(page_main.check_button)
self.ui_back(self.is_in_main)
self.equipment_has_take_on = False
self.device.sleep(1)
return True

View File

@ -17,7 +17,7 @@ class BattlePass(Combat, UI):
Page:
in: page_reward
"""
if self.appear(REWARD_GOTO_BATTLE_PASS, offset=(10, 150)):
if self.appear(REWARD_GOTO_BATTLE_PASS, offset=(50, 150)):
# Load button offset from REWARD_GOTO_BATTLE_PASS,
# because entrance may not be the top one.
BATTLE_PASS_RED_DOT.load_offset(REWARD_GOTO_BATTLE_PASS)
@ -45,7 +45,7 @@ class BattlePass(Combat, UI):
"""
def appear_button():
return self.appear(REWARD_GOTO_BATTLE_PASS, offset=(10, 150))
return self.appear(REWARD_GOTO_BATTLE_PASS, offset=(50, 150))
self.ui_click(REWARD_GOTO_BATTLE_PASS, appear_button=appear_button, check_button=BATTLE_PASS_CHECK,
additional=self.handle_battle_pass_popup, skip_first_screenshot=True)

View File

@ -8,7 +8,7 @@ from module.combat.assets import *
from module.freebies.assets import *
from module.logger import logger
from module.statistics.item import ItemGrid
from module.ui.page import page_main
from module.ui.page import page_main, page_main_white
from module.ui.ui import UI
MAIL_BUTTON_GRID = ButtonGrid(
@ -41,7 +41,7 @@ class Mail(UI):
logger.hr('Mail enter')
btn_expanded = MAIL_BUTTON_GRID.buttons[0]
btn_collapsed = btn_expanded.move((350, 0))
self.interval_clear([page_main.check_button, MAIL_DELETE])
self.interval_clear([page_main.check_button, page_main_white.check_button, MAIL_DELETE])
while 1:
if skip_first_screenshot:
skip_first_screenshot = False
@ -67,6 +67,9 @@ class Mail(UI):
if self.appear(page_main.check_button, offset=(30, 30), interval=3):
self.device.click(MAIL_ENTER)
continue
if self.appear(page_main_white.check_button, offset=(30, 30), interval=3):
self.device.click(MAIL_ENTER_WHITE)
continue
if delete:
if self.appear_then_click(MAIL_DELETE, offset=(350, 20), interval=3):
continue
@ -108,7 +111,7 @@ class Mail(UI):
continue
# End
if self.appear(page_main.check_button, offset=(30, 30)):
if self.is_in_main():
break
@cached_property

View File

@ -9,14 +9,13 @@ from uiautomator2.xpath import XPath, XPathSelector
import module.config.server as server
from module.base.timer import Timer
from module.base.utils import color_similarity_2d, crop, random_rectangle_point
from module.config.utils import get_server_next_update
from module.exception import (GameStuckError, GameTooManyClickError,
RequestHumanTakeover)
from module.handler.assets import *
from module.logger import logger
from module.map.assets import *
from module.ui.assets import *
from module.ui.page import MAIN_CHECK
from module.ui.page import page_campaign_menu
from module.ui.ui import UI
@ -43,7 +42,7 @@ class LoginHandler(UI):
self.device.screenshot()
# End
if self.appear(MAIN_CHECK, offset=(30, 30)):
if self.is_in_main():
if confirm_timer.reached():
logger.info('Login to main confirm')
break
@ -180,8 +179,23 @@ class LoginHandler(UI):
or self.appear(EVENT_CHECK, offset=(30, 30)) \
or self.appear(SP_CHECK, offset=(30, 30))
self.ui_click(MAIN_GOTO_CAMPAIGN, check_button=in_campaign, additional=ensure_campaign_retreat,
confirm_wait=confirm_wait, skip_first_screenshot=True)
skip_first_screenshot = True
while 1:
if skip_first_screenshot:
skip_first_screenshot = False
else:
self.device.screenshot()
# End
if in_campaign():
break
# Click
if self.ui_main_appear_then_click(page_campaign_menu, interval=3):
continue
if ensure_campaign_retreat():
continue
self.ui_goto_main()
def handle_user_agreement(self, xp, hierarchy):

View File

@ -2,7 +2,7 @@ import re
from module.base.mask import Mask
from module.ui.assets import PLAYER_CHECK
from module.ui.page import MAIN_CHECK
from module.ui.page import MAIN_GOTO_CAMPAIGN_WHITE, MAIN_GOTO_FLEET
MASK_MAIN = Mask('./assets/mask/MASK_MAIN.png')
MASK_PLAYER = Mask('./assets/mask/MASK_PLAYER.png')
@ -18,7 +18,9 @@ def handle_sensitive_image(image):
"""
if PLAYER_CHECK.match(image, offset=(30, 30)):
image = MASK_PLAYER.apply(image)
if MAIN_CHECK.match(image, offset=(30, 30)):
if MAIN_GOTO_FLEET.match(image, offset=(30, 30)):
image = MASK_MAIN.apply(image)
if MAIN_GOTO_CAMPAIGN_WHITE.match(image, offset=(30, 30)):
image = MASK_MAIN.apply(image)
return image

View File

@ -17,10 +17,14 @@ class Map(Fleet):
Args:
grid (GridInfo):
expected (str):
Returns:
int: If cleared an enemy.
"""
logger.info('targetEnemyScale:%s' % (self.config.EnemyPriority_EnemyScaleBalanceWeight))
logger.info('Clear enemy: %s' % grid)
expected = f'combat_{expected}' if expected else 'combat'
battle_count = self.battle_count
self.show_fleet()
if self.emotion.is_calculate and self.config.Campaign_UseFleetLock:
self.emotion.wait(fleet_index=self.fleet_current_index)
@ -29,6 +33,7 @@ class Map(Fleet):
self.full_scan()
self.find_path_initial()
self.map.show_cost()
return self.battle_count >= battle_count
def clear_chosen_mystery(self, grid):
"""

View File

@ -19,7 +19,7 @@ from module.os_handler.assets import AUTO_SEARCH_OS_MAP_OPTION_OFF, AUTO_SEARCH_
AUTO_SEARCH_OS_MAP_OPTION_ON, AUTO_SEARCH_REWARD
from module.os_handler.strategic import StrategicSearchHandler
from module.ui.assets import GOTO_MAIN
from module.ui.page import page_main, page_os
from module.ui.page import page_os
class OSMap(OSFleet, Map, GlobeCamera, StrategicSearchHandler):
@ -547,7 +547,7 @@ class OSMap(OSFleet, Map, GlobeCamera, StrategicSearchHandler):
self.device.screenshot()
# End
if self.ui_page_appear(page_main):
if self.is_in_main():
logger.info('Auto search interrupted')
self.config.task_stop()

View File

@ -5,11 +5,11 @@ from module.base.timer import Timer
from module.combat.combat import BATTLE_PREPARATION
from module.logger import logger
from module.meta_reward.meta_reward import MetaReward
from module.ocr.ocr import DigitCounter, Digit
from module.ocr.ocr import Digit, DigitCounter
from module.os_ash.ash import AshCombat
from module.os_ash.assets import *
from module.os_handler.map_event import MapEventHandler
from module.ui.assets import BACK_ARROW, MAIN_GOTO_REWARD
from module.ui.assets import BACK_ARROW
from module.ui.page import page_reward
from module.ui.ui import UI
@ -170,7 +170,7 @@ class OpsiAshBeacon(Meta):
if self.handle_map_event():
continue
# Accidentally goto main page
if self.appear(MAIN_GOTO_REWARD, offset=(20, 20), interval=2):
if self.ui_main_appear_then_click(page_reward, interval=2):
continue
if self.appear(META_ENTRANCE, offset=(20, 300), interval=2):
continue

View File

@ -14,8 +14,9 @@ from module.ocr.ocr import DigitCounter, Duration, Ocr
from module.retire.assets import DOCK_CHECK, DOCK_EMPTY, SHIP_CONFIRM
from module.retire.dock import CARD_GRIDS, CARD_LEVEL_GRIDS, Dock
from module.tactical.assets import *
from module.ui.assets import (BACK_ARROW, MAIN_GOTO_REWARD, REWARD_CHECK, REWARD_GOTO_TACTICAL, TACTICAL_CHECK)
from module.ui.assets import (BACK_ARROW, REWARD_CHECK, REWARD_GOTO_TACTICAL, TACTICAL_CHECK)
from module.ui.page import page_reward
from module.ui_white.assets import REWARD_2_WHITE, REWARD_GOTO_TACTICAL_WHITE
SKILL_GRIDS = ButtonGrid(origin=(315, 140), delta=(621, 132), button_shape=(621, 119), grid_shape=(1, 3), name='SKILL')
SKILL_LEVEL_GRIDS = SKILL_GRIDS.crop(area=(406, 98, 618, 116), name='EXP')
@ -434,9 +435,13 @@ class RewardTacticalClass(Dock):
# Popups
if self.appear_then_click(REWARD_2, offset=(20, 20), interval=3):
continue
if self.appear_then_click(REWARD_2_WHITE, offset=(20, 20), interval=3):
continue
if self.appear_then_click(REWARD_GOTO_TACTICAL, offset=(20, 20), interval=3):
continue
if self.appear_then_click(MAIN_GOTO_REWARD, offset=(20, 20), interval=3):
if self.appear_then_click(REWARD_GOTO_TACTICAL_WHITE, offset=(20, 20), interval=3):
continue
if self.ui_main_appear_then_click(page_reward, interval=3):
continue
if self.handle_popup_confirm('TACTICAL'):
continue

View File

@ -74,7 +74,7 @@ RESHMENU_GOTO_SHIPYARD = Button(area={'cn': (567, 275, 731, 397), 'en': (567, 27
REWARD_CHECK = Button(area={'cn': (219, 107, 267, 158), 'en': (219, 107, 267, 158), 'jp': (219, 107, 267, 158), 'tw': (219, 107, 267, 158)}, color={'cn': (143, 116, 123), 'en': (143, 116, 123), 'jp': (143, 116, 123), 'tw': (143, 116, 123)}, button={'cn': (219, 107, 267, 158), 'en': (219, 107, 267, 158), 'jp': (219, 107, 267, 158), 'tw': (219, 107, 267, 158)}, file={'cn': './assets/cn/ui/REWARD_CHECK.png', 'en': './assets/en/ui/REWARD_CHECK.png', 'jp': './assets/jp/ui/REWARD_CHECK.png', 'tw': './assets/tw/ui/REWARD_CHECK.png'})
REWARD_GOTO_BATTLE_PASS = Button(area={'cn': (580, 117, 620, 155), 'en': (580, 117, 620, 155), 'jp': (580, 117, 620, 155), 'tw': (580, 117, 620, 155)}, color={'cn': (92, 113, 139), 'en': (92, 113, 139), 'jp': (92, 113, 139), 'tw': (92, 113, 139)}, button={'cn': (580, 117, 620, 155), 'en': (580, 117, 620, 155), 'jp': (580, 117, 620, 155), 'tw': (580, 117, 620, 155)}, file={'cn': './assets/cn/ui/REWARD_GOTO_BATTLE_PASS.png', 'en': './assets/en/ui/REWARD_GOTO_BATTLE_PASS.png', 'jp': './assets/jp/ui/REWARD_GOTO_BATTLE_PASS.png', 'tw': './assets/cn/ui/REWARD_GOTO_BATTLE_PASS.png'})
REWARD_GOTO_COMMISSION = Button(area={'cn': (418, 271, 468, 293), 'en': (407, 274, 499, 291), 'jp': (431, 274, 476, 295), 'tw': (418, 271, 468, 293)}, color={'cn': (142, 172, 216), 'en': (158, 183, 220), 'jp': (153, 180, 219), 'tw': (142, 172, 216)}, button={'cn': (383, 262, 503, 302), 'en': (393, 262, 514, 303), 'jp': (393, 262, 514, 303), 'tw': (383, 262, 503, 302)}, file={'cn': './assets/cn/ui/REWARD_GOTO_COMMISSION.png', 'en': './assets/en/ui/REWARD_GOTO_COMMISSION.png', 'jp': './assets/jp/ui/REWARD_GOTO_COMMISSION.png', 'tw': './assets/tw/ui/REWARD_GOTO_COMMISSION.png'})
REWARD_GOTO_MAIN = Button(area={'cn': (219, 107, 267, 158), 'en': (219, 107, 267, 158), 'jp': (219, 107, 267, 158), 'tw': (219, 107, 267, 158)}, color={'cn': (143, 116, 123), 'en': (143, 116, 123), 'jp': (143, 116, 123), 'tw': (143, 116, 123)}, button={'cn': (0, 0, 1280, 720), 'en': (0, 0, 1280, 720), 'jp': (0, 0, 1280, 720), 'tw': (0, 0, 1280, 720)}, file={'cn': './assets/cn/ui/REWARD_GOTO_MAIN.png', 'en': './assets/en/ui/REWARD_GOTO_MAIN.png', 'jp': './assets/jp/ui/REWARD_GOTO_MAIN.png', 'tw': './assets/tw/ui/REWARD_GOTO_MAIN.png'})
REWARD_GOTO_MAIN = Button(area={'cn': (219, 107, 267, 158), 'en': (219, 107, 267, 158), 'jp': (219, 107, 267, 158), 'tw': (219, 107, 267, 158)}, color={'cn': (143, 116, 123), 'en': (143, 116, 123), 'jp': (143, 116, 123), 'tw': (143, 116, 123)}, button={'cn': (787, 602, 867, 642), 'en': (787, 602, 867, 642), 'jp': (787, 602, 867, 642), 'tw': (787, 602, 867, 642)}, file={'cn': './assets/cn/ui/REWARD_GOTO_MAIN.png', 'en': './assets/en/ui/REWARD_GOTO_MAIN.png', 'jp': './assets/jp/ui/REWARD_GOTO_MAIN.png', 'tw': './assets/tw/ui/REWARD_GOTO_MAIN.png'})
REWARD_GOTO_TACTICAL = Button(area={'cn': (418, 413, 468, 434), 'en': (407, 416, 499, 433), 'jp': (431, 416, 476, 437), 'tw': (418, 413, 468, 435)}, color={'cn': (143, 176, 216), 'en': (157, 185, 219), 'jp': (151, 182, 217), 'tw': (141, 175, 215)}, button={'cn': (383, 404, 503, 444), 'en': (393, 404, 514, 445), 'jp': (393, 404, 514, 445), 'tw': (383, 404, 503, 444)}, file={'cn': './assets/cn/ui/REWARD_GOTO_TACTICAL.png', 'en': './assets/en/ui/REWARD_GOTO_TACTICAL.png', 'jp': './assets/jp/ui/REWARD_GOTO_TACTICAL.png', 'tw': './assets/tw/ui/REWARD_GOTO_TACTICAL.png'})
SHIPYARD_CHECK = Button(area={'cn': (9, 131, 82, 148), 'en': (4, 126, 52, 141), 'jp': (8, 130, 82, 148), 'tw': (7, 130, 83, 150)}, color={'cn': (159, 180, 229), 'en': (133, 148, 171), 'jp': (152, 169, 202), 'tw': (142, 164, 219)}, button={'cn': (9, 131, 82, 148), 'en': (4, 126, 52, 141), 'jp': (8, 130, 82, 148), 'tw': (7, 130, 83, 150)}, file={'cn': './assets/cn/ui/SHIPYARD_CHECK.png', 'en': './assets/en/ui/SHIPYARD_CHECK.png', 'jp': './assets/jp/ui/SHIPYARD_CHECK.png', 'tw': './assets/tw/ui/SHIPYARD_CHECK.png'})
SHOP_CHECK = Button(area={'cn': (93, 504, 134, 544), 'en': (102, 512, 172, 548), 'jp': (93, 504, 134, 544), 'tw': (92, 504, 133, 545)}, color={'cn': (194, 204, 222), 'en': (159, 178, 205), 'jp': (185, 196, 217), 'tw': (184, 199, 221)}, button={'cn': (93, 504, 134, 544), 'en': (102, 512, 172, 548), 'jp': (93, 504, 134, 544), 'tw': (92, 504, 133, 545)}, file={'cn': './assets/cn/ui/SHOP_CHECK.png', 'en': './assets/en/ui/SHOP_CHECK.png', 'jp': './assets/jp/ui/SHOP_CHECK.png', 'tw': './assets/tw/ui/SHOP_CHECK.png'})

View File

@ -1,7 +1,8 @@
import traceback
from module.ui.assets import *
from module.raid.assets import *
from module.ui.assets import *
from module.ui_white.assets import *
class Page:
@ -72,10 +73,10 @@ class Page:
"""
Define UI pages
"""
# Use MAIN_GOTO_FLEET instead of MAIN_GOTO_CAMPAIGN for faster switches with info_bar
MAIN_CHECK = MAIN_GOTO_FLEET
# Main
page_main = Page(MAIN_CHECK)
# Use MAIN_GOTO_FLEET instead of MAIN_GOTO_CAMPAIGN for faster switches with info_bar
page_main = Page(MAIN_GOTO_FLEET)
page_campaign_menu = Page(CAMPAIGN_MENU_CHECK)
page_campaign = Page(CAMPAIGN_CHECK)
page_fleet = Page(FLEET_CHECK)
@ -87,6 +88,12 @@ page_campaign.link(button=GOTO_MAIN, destination=page_main)
page_campaign.link(button=BACK_ARROW, destination=page_campaign_menu)
page_fleet.link(button=GOTO_MAIN, destination=page_main)
# Main
# 2024.05.22, in new UI, MAIN_GOTO_CAMPAIGN_WHITE is the last shown button in page main
page_main_white = Page(MAIN_GOTO_CAMPAIGN_WHITE)
page_main_white.link(button=MAIN_GOTO_CAMPAIGN_WHITE, destination=page_campaign_menu)
page_main_white.link(button=MAIN_GOTO_FLEET_WHITE, destination=page_fleet)
# Unknown
page_unknown = Page(None)
page_unknown.link(button=GOTO_MAIN, destination=page_main)
@ -139,16 +146,19 @@ page_campaign_menu.link(button=CAMPAIGN_MENU_GOTO_WAR_ARCHIVES, destination=page
page_reward = Page(REWARD_CHECK)
page_reward.link(button=REWARD_GOTO_MAIN, destination=page_main)
page_main.link(button=MAIN_GOTO_REWARD, destination=page_reward)
page_main_white.link(button=MAIN_GOTO_REWARD_WHITE, destination=page_reward)
# Mission
page_mission = Page(MISSION_CHECK)
page_mission.link(button=GOTO_MAIN, destination=page_main)
page_main.link(button=MAIN_GOTO_MISSION, destination=page_mission)
page_main_white.link(button=MAIN_GOTO_MISSION_WHITE, destination=page_mission)
# Guild
page_guild = Page(GUILD_CHECK)
page_guild.link(button=GOTO_MAIN, destination=page_main)
page_main.link(button=MAIN_GOTO_GUILD, destination=page_guild)
page_main_white.link(button=MAIN_GOTO_GUILD_WHITE, destination=page_guild)
# Commission
# Please don't goto commission from campaign.
@ -173,11 +183,13 @@ page_reward.link(button=REWARD_GOTO_BATTLE_PASS, destination=page_battle_pass)
page_event_list = Page(EVENT_LIST_CHECK)
page_event_list.link(button=GOTO_MAIN, destination=page_main)
page_main.link(button=MAIN_GOTO_EVENT_LIST, destination=page_event_list)
page_main_white.link(button=MAIN_GOTO_EVENT_LIST_WHITE, destination=page_event_list)
# Raid
page_raid = Page(RAID_CHECK)
page_raid.link(button=GOTO_MAIN, destination=page_main)
page_main.link(button=MAIN_GOTO_RAID, destination=page_raid)
# page_main_white.link(button=MAIN_GOTO_RAID_WHITE, destination=page_raid)
# Research
# Please don't goto page_research from page_reward.
@ -196,6 +208,7 @@ page_meta.link(button=GOTO_MAIN, destination=page_main)
page_storage = Page(STORAGE_CHECK)
page_storage.link(button=GOTO_MAIN, destination=page_main)
page_main.link(button=MAIN_GOTO_STORAGE, destination=page_storage)
page_main_white.link(button=MAIN_GOTO_STORAGE_WHITE, destination=page_storage)
# Research menu
page_reshmenu = Page(RESHMENU_CHECK)
@ -204,11 +217,13 @@ page_reshmenu.link(button=RESHMENU_GOTO_SHIPYARD, destination=page_shipyard)
page_reshmenu.link(button=RESHMENU_GOTO_META, destination=page_meta)
page_reshmenu.link(button=GOTO_MAIN, destination=page_main)
page_main.link(button=MAIN_GOTO_RESHMENU, destination=page_reshmenu)
page_main_white.link(button=MAIN_GOTO_RESHMENU, destination=page_reshmenu)
# Dorm menu
page_dormmenu = Page(DORMMENU_CHECK)
page_main.link(button=MAIN_GOTO_DORMMENU, destination=page_dormmenu)
page_dormmenu.link(button=DORMMENU_GOTO_MAIN, destination=page_main)
page_main.link(button=MAIN_GOTO_DORMMENU, destination=page_dormmenu)
page_main_white.link(button=MAIN_GOTO_DORMMENU_WHITE, destination=page_dormmenu)
# Dorm
# DORM_CHECK is the `manage` button (the third from the right), because it's the last button to load.
@ -233,8 +248,9 @@ page_game_room.link(button=GAME_ROOM_GOTO_MAIN, destination=page_main)
# Shop
page_shop = Page(SHOP_CHECK)
page_main.link(button=MAIN_GOTO_SHOP, destination=page_shop)
page_shop.link(button=GOTO_MAIN, destination=page_main)
page_main.link(button=MAIN_GOTO_SHOP, destination=page_shop)
page_main_white.link(button=MAIN_GOTO_SHOP_WHITE, destination=page_shop)
# Munitions
page_munitions = Page(MUNITIONS_CHECK)
@ -250,8 +266,9 @@ page_supply_pack.link(button=GOTO_MAIN, destination=page_main)
# Build / Construct
page_build = Page(BUILD_CHECK)
page_main.link(button=MAIN_GOTO_BUILD, destination=page_build)
page_build.link(button=GOTO_MAIN, destination=page_main)
page_main.link(button=MAIN_GOTO_BUILD, destination=page_build)
page_main_white.link(button=MAIN_GOTO_BUILD_WHITE, destination=page_build)
# RPG event (raid_20240328)
page_rpg_stage = Page(RPG_GOTO_STORY)
@ -262,6 +279,7 @@ page_rpg_story.link(button=RPG_GOTO_STAGE, destination=page_rpg_stage)
page_rpg_story.link(button=RPG_HOME, destination=page_main)
page_main.link(button=MAIN_GOTO_RAID, destination=page_rpg_stage)
# page_main_white.link(button=MAIN_GOTO_RAID_WHITE, destination=page_rpg_stage)
page_rpg_city = Page(RPG_LEAVE_CITY)
page_rpg_city.link(button=RPG_LEAVE_CITY, destination=page_rpg_stage)

View File

@ -19,18 +19,50 @@ from module.ocr.ocr import Ocr
from module.os_handler.assets import (AUTO_SEARCH_REWARD, EXCHANGE_CHECK, RESET_FLEET_PREPARATION, RESET_TICKET_POPUP)
from module.raid.assets import *
from module.ui.assets import *
from module.ui.page import (Page, page_campaign, page_event, page_main, page_sp)
from module.ui.page import (Page, page_campaign, page_event, page_main, page_sp, page_main_white)
from module.ui_white.assets import *
class UI(InfoHandler):
ui_current: Page
def ui_page_appear(self, page):
def ui_page_appear(self, page, offset=(30, 30), interval=0):
"""
Args:
page (Page):
offset:
interval:
"""
return self.appear(page.check_button, offset=(30, 30))
if page == page_main:
if self.appear(page_main_white.check_button, offset=offset, interval=interval):
return True
if self.appear(page_main.check_button, offset=(5, 5), interval=interval):
return True
return False
return self.appear(page.check_button, offset=offset, interval=interval)
def is_in_main(self, offset=(30, 30), interval=0):
return self.ui_page_appear(page_main, offset=offset, interval=interval)
def ui_main_appear_then_click(self, page, offset=(30, 30), interval=3):
"""
Args:
page: Destination page
offset:
interval:
Returns:
bool: If clicked
"""
if self.appear(page_main.check_button, offset=offset, interval=interval):
button = page_main.links[page]
self.device.click(button)
return True
if self.appear(page_main_white.check_button, offset=(5, 5), interval=interval):
button = page_main_white.links[page]
self.device.click(button)
return True
return False
def ensure_button_execute(self, button, offset=0):
if isinstance(button, Button) and self.appear(button, offset=offset):
@ -207,7 +239,7 @@ class UI(InfoHandler):
self.device.screenshot()
# Destination page
if self.appear(destination.check_button, offset=offset):
if self.ui_page_appear(page=destination, offset=offset):
logger.info(f'Page arrive: {destination}')
break
@ -522,7 +554,7 @@ class UI(InfoHandler):
for switch_button in page_main.links.values():
if button == switch_button:
self.interval_reset(GET_SHIP)
if button == MAIN_GOTO_CAMPAIGN:
if button in [MAIN_GOTO_CAMPAIGN, MAIN_GOTO_CAMPAIGN_WHITE]:
self.interval_reset(GET_SHIP)
# Shinano event has the same title as raid
self.interval_reset(RAID_CHECK)

22
module/ui_white/assets.py Normal file
View File

@ -0,0 +1,22 @@
from module.base.button import Button
from module.base.template import Template
# This file was automatically generated by dev_tools/button_extract.py.
# Don't modify it manually.
MAIL_ENTER_WHITE = Button(area={'cn': (1018, 22, 1087, 52), 'en': (1018, 22, 1087, 52), 'jp': (1018, 22, 1087, 52), 'tw': (1018, 22, 1087, 52)}, color={'cn': (194, 187, 190), 'en': (194, 187, 190), 'jp': (194, 187, 190), 'tw': (194, 187, 190)}, button={'cn': (1018, 22, 1087, 52), 'en': (1018, 22, 1087, 52), 'jp': (1018, 22, 1087, 52), 'tw': (1018, 22, 1087, 52)}, file={'cn': './assets/cn/ui_white/MAIL_ENTER_WHITE.png', 'en': './assets/cn/ui_white/MAIL_ENTER_WHITE.png', 'jp': './assets/cn/ui_white/MAIL_ENTER_WHITE.png', 'tw': './assets/cn/ui_white/MAIL_ENTER_WHITE.png'})
MAIN_GOTO_BUILD_WHITE = Button(area={'cn': (959, 657, 1103, 703), 'en': (959, 657, 1103, 703), 'jp': (959, 657, 1103, 703), 'tw': (959, 657, 1103, 703)}, color={'cn': (229, 216, 216), 'en': (229, 216, 216), 'jp': (229, 216, 216), 'tw': (229, 216, 216)}, button={'cn': (959, 657, 1103, 703), 'en': (959, 657, 1103, 703), 'jp': (959, 657, 1103, 703), 'tw': (959, 657, 1103, 703)}, file={'cn': './assets/cn/ui_white/MAIN_GOTO_BUILD_WHITE.png', 'en': './assets/cn/ui_white/MAIN_GOTO_BUILD_WHITE.png', 'jp': './assets/cn/ui_white/MAIN_GOTO_BUILD_WHITE.png', 'tw': './assets/cn/ui_white/MAIN_GOTO_BUILD_WHITE.png'})
MAIN_GOTO_CAMPAIGN_WHITE = Button(area={'cn': (1132, 529, 1187, 557), 'en': (1132, 529, 1187, 557), 'jp': (1132, 529, 1187, 557), 'tw': (1132, 529, 1187, 557)}, color={'cn': (152, 161, 161), 'en': (152, 161, 161), 'jp': (152, 161, 161), 'tw': (152, 161, 161)}, button={'cn': (1124, 437, 1260, 579), 'en': (1124, 437, 1260, 579), 'jp': (1124, 437, 1260, 579), 'tw': (1124, 437, 1260, 579)}, file={'cn': './assets/cn/ui_white/MAIN_GOTO_CAMPAIGN_WHITE.png', 'en': './assets/cn/ui_white/MAIN_GOTO_CAMPAIGN_WHITE.png', 'jp': './assets/cn/ui_white/MAIN_GOTO_CAMPAIGN_WHITE.png', 'tw': './assets/cn/ui_white/MAIN_GOTO_CAMPAIGN_WHITE.png'})
MAIN_GOTO_DORMMENU_WHITE = Button(area={'cn': (490, 656, 634, 702), 'en': (490, 656, 634, 702), 'jp': (490, 656, 634, 702), 'tw': (490, 656, 634, 702)}, color={'cn': (206, 205, 209), 'en': (206, 205, 209), 'jp': (206, 205, 209), 'tw': (206, 205, 209)}, button={'cn': (490, 656, 634, 702), 'en': (490, 656, 634, 702), 'jp': (490, 656, 634, 702), 'tw': (490, 656, 634, 702)}, file={'cn': './assets/cn/ui_white/MAIN_GOTO_DORMMENU_WHITE.png', 'en': './assets/cn/ui_white/MAIN_GOTO_DORMMENU_WHITE.png', 'jp': './assets/cn/ui_white/MAIN_GOTO_DORMMENU_WHITE.png', 'tw': './assets/cn/ui_white/MAIN_GOTO_DORMMENU_WHITE.png'})
MAIN_GOTO_EVENT_LIST_WHITE = Button(area={'cn': (1181, 83, 1260, 160), 'en': (1181, 83, 1260, 160), 'jp': (1181, 83, 1260, 160), 'tw': (1181, 83, 1260, 160)}, color={'cn': (147, 155, 186), 'en': (147, 155, 186), 'jp': (147, 155, 186), 'tw': (147, 155, 186)}, button={'cn': (1181, 83, 1260, 160), 'en': (1181, 83, 1260, 160), 'jp': (1181, 83, 1260, 160), 'tw': (1181, 83, 1260, 160)}, file={'cn': './assets/cn/ui_white/MAIN_GOTO_EVENT_LIST_WHITE.png', 'en': './assets/cn/ui_white/MAIN_GOTO_EVENT_LIST_WHITE.png', 'jp': './assets/cn/ui_white/MAIN_GOTO_EVENT_LIST_WHITE.png', 'tw': './assets/cn/ui_white/MAIN_GOTO_EVENT_LIST_WHITE.png'})
MAIN_GOTO_FLEET_WHITE = Button(area={'cn': (1025, 437, 1097, 579), 'en': (1025, 437, 1097, 579), 'jp': (1025, 437, 1097, 579), 'tw': (1025, 437, 1097, 579)}, color={'cn': (230, 229, 231), 'en': (230, 229, 231), 'jp': (230, 229, 231), 'tw': (230, 229, 231)}, button={'cn': (1025, 437, 1097, 579), 'en': (1025, 437, 1097, 579), 'jp': (1025, 437, 1097, 579), 'tw': (1025, 437, 1097, 579)}, file={'cn': './assets/cn/ui_white/MAIN_GOTO_FLEET_WHITE.png', 'en': './assets/cn/ui_white/MAIN_GOTO_FLEET_WHITE.png', 'jp': './assets/cn/ui_white/MAIN_GOTO_FLEET_WHITE.png', 'tw': './assets/cn/ui_white/MAIN_GOTO_FLEET_WHITE.png'})
MAIN_GOTO_GUILD_WHITE = Button(area={'cn': (1116, 656, 1261, 703), 'en': (1116, 656, 1261, 703), 'jp': (1116, 656, 1261, 703), 'tw': (1116, 656, 1261, 703)}, color={'cn': (213, 206, 209), 'en': (213, 206, 209), 'jp': (213, 206, 209), 'tw': (213, 206, 209)}, button={'cn': (1116, 656, 1261, 703), 'en': (1116, 656, 1261, 703), 'jp': (1116, 656, 1261, 703), 'tw': (1116, 656, 1261, 703)}, file={'cn': './assets/cn/ui_white/MAIN_GOTO_GUILD_WHITE.png', 'en': './assets/cn/ui_white/MAIN_GOTO_GUILD_WHITE.png', 'jp': './assets/cn/ui_white/MAIN_GOTO_GUILD_WHITE.png', 'tw': './assets/cn/ui_white/MAIN_GOTO_GUILD_WHITE.png'})
MAIN_GOTO_MISSION_WHITE = Button(area={'cn': (802, 656, 949, 704), 'en': (802, 656, 949, 704), 'jp': (802, 656, 949, 704), 'tw': (802, 656, 949, 704)}, color={'cn': (219, 213, 214), 'en': (219, 213, 214), 'jp': (219, 213, 214), 'tw': (219, 213, 214)}, button={'cn': (802, 656, 949, 704), 'en': (802, 656, 949, 704), 'jp': (802, 656, 949, 704), 'tw': (802, 656, 949, 704)}, file={'cn': './assets/cn/ui_white/MAIN_GOTO_MISSION_WHITE.png', 'en': './assets/cn/ui_white/MAIN_GOTO_MISSION_WHITE.png', 'jp': './assets/cn/ui_white/MAIN_GOTO_MISSION_WHITE.png', 'tw': './assets/cn/ui_white/MAIN_GOTO_MISSION_WHITE.png'})
MAIN_GOTO_RESHMENU_WHITE = Button(area={'cn': (646, 656, 793, 703), 'en': (646, 656, 793, 703), 'jp': (646, 656, 793, 703), 'tw': (646, 656, 793, 703)}, color={'cn': (216, 213, 217), 'en': (216, 213, 217), 'jp': (216, 213, 217), 'tw': (216, 213, 217)}, button={'cn': (646, 656, 793, 703), 'en': (646, 656, 793, 703), 'jp': (646, 656, 793, 703), 'tw': (646, 656, 793, 703)}, file={'cn': './assets/cn/ui_white/MAIN_GOTO_RESHMENU_WHITE.png', 'en': './assets/cn/ui_white/MAIN_GOTO_RESHMENU_WHITE.png', 'jp': './assets/cn/ui_white/MAIN_GOTO_RESHMENU_WHITE.png', 'tw': './assets/cn/ui_white/MAIN_GOTO_RESHMENU_WHITE.png'})
MAIN_GOTO_REWARD_WHITE = Button(area={'cn': (11, 209, 30, 259), 'en': (11, 209, 30, 259), 'jp': (11, 209, 30, 259), 'tw': (11, 209, 30, 259)}, color={'cn': (73, 84, 122), 'en': (73, 84, 122), 'jp': (73, 84, 122), 'tw': (73, 84, 122)}, button={'cn': (11, 209, 30, 259), 'en': (11, 209, 30, 259), 'jp': (11, 209, 30, 259), 'tw': (11, 209, 30, 259)}, file={'cn': './assets/cn/ui_white/MAIN_GOTO_REWARD_WHITE.png', 'en': './assets/cn/ui_white/MAIN_GOTO_REWARD_WHITE.png', 'jp': './assets/cn/ui_white/MAIN_GOTO_REWARD_WHITE.png', 'tw': './assets/cn/ui_white/MAIN_GOTO_REWARD_WHITE.png'})
MAIN_GOTO_SHOP_WHITE = Button(area={'cn': (18, 656, 164, 703), 'en': (18, 656, 164, 703), 'jp': (18, 656, 164, 703), 'tw': (18, 656, 164, 703)}, color={'cn': (221, 214, 212), 'en': (221, 214, 212), 'jp': (221, 214, 212), 'tw': (221, 214, 212)}, button={'cn': (18, 656, 164, 703), 'en': (18, 656, 164, 703), 'jp': (18, 656, 164, 703), 'tw': (18, 656, 164, 703)}, file={'cn': './assets/cn/ui_white/MAIN_GOTO_SHOP_WHITE.png', 'en': './assets/cn/ui_white/MAIN_GOTO_SHOP_WHITE.png', 'jp': './assets/cn/ui_white/MAIN_GOTO_SHOP_WHITE.png', 'tw': './assets/cn/ui_white/MAIN_GOTO_SHOP_WHITE.png'})
MAIN_GOTO_STORAGE_WHITE = Button(area={'cn': (331, 656, 478, 703), 'en': (331, 656, 478, 703), 'jp': (331, 656, 478, 703), 'tw': (331, 656, 478, 703)}, color={'cn': (212, 214, 219), 'en': (212, 214, 219), 'jp': (212, 214, 219), 'tw': (212, 214, 219)}, button={'cn': (331, 656, 478, 703), 'en': (331, 656, 478, 703), 'jp': (331, 656, 478, 703), 'tw': (331, 656, 478, 703)}, file={'cn': './assets/cn/ui_white/MAIN_GOTO_STORAGE_WHITE.png', 'en': './assets/cn/ui_white/MAIN_GOTO_STORAGE_WHITE.png', 'jp': './assets/cn/ui_white/MAIN_GOTO_STORAGE_WHITE.png', 'tw': './assets/cn/ui_white/MAIN_GOTO_STORAGE_WHITE.png'})
REWARD_1_WHITE = Button(area={'cn': (437, 278, 496, 306), 'en': (437, 278, 496, 306), 'jp': (437, 278, 496, 306), 'tw': (437, 278, 496, 306)}, color={'cn': (255, 193, 97), 'en': (255, 193, 97), 'jp': (255, 193, 97), 'tw': (255, 193, 97)}, button={'cn': (437, 278, 496, 306), 'en': (437, 278, 496, 306), 'jp': (437, 278, 496, 306), 'tw': (437, 278, 496, 306)}, file={'cn': './assets/cn/ui_white/REWARD_1_WHITE.png', 'en': './assets/cn/ui_white/REWARD_1_WHITE.png', 'jp': './assets/cn/ui_white/REWARD_1_WHITE.png', 'tw': './assets/cn/ui_white/REWARD_1_WHITE.png'})
REWARD_2_WHITE = Button(area={'cn': (436, 419, 497, 448), 'en': (436, 419, 497, 448), 'jp': (436, 419, 497, 448), 'tw': (436, 419, 497, 448)}, color={'cn': (255, 192, 94), 'en': (255, 192, 94), 'jp': (255, 192, 94), 'tw': (255, 192, 94)}, button={'cn': (436, 419, 497, 448), 'en': (436, 419, 497, 448), 'jp': (436, 419, 497, 448), 'tw': (436, 419, 497, 448)}, file={'cn': './assets/cn/ui_white/REWARD_2_WHITE.png', 'en': './assets/cn/ui_white/REWARD_2_WHITE.png', 'jp': './assets/cn/ui_white/REWARD_2_WHITE.png', 'tw': './assets/cn/ui_white/REWARD_2_WHITE.png'})
REWARD_GOTO_COMMISSION_WHITE = Button(area={'cn': (440, 278, 494, 307), 'en': (440, 278, 494, 307), 'jp': (440, 278, 494, 307), 'tw': (440, 278, 494, 307)}, color={'cn': (103, 207, 255), 'en': (103, 207, 255), 'jp': (103, 207, 255), 'tw': (103, 207, 255)}, button={'cn': (440, 278, 494, 307), 'en': (440, 278, 494, 307), 'jp': (440, 278, 494, 307), 'tw': (440, 278, 494, 307)}, file={'cn': './assets/cn/ui_white/REWARD_GOTO_COMMISSION_WHITE.png', 'en': './assets/cn/ui_white/REWARD_GOTO_COMMISSION_WHITE.png', 'jp': './assets/cn/ui_white/REWARD_GOTO_COMMISSION_WHITE.png', 'tw': './assets/cn/ui_white/REWARD_GOTO_COMMISSION_WHITE.png'})
REWARD_GOTO_TACTICAL_WHITE = Button(area={'cn': (442, 421, 492, 447), 'en': (442, 421, 492, 447), 'jp': (442, 421, 492, 447), 'tw': (442, 421, 492, 447)}, color={'cn': (114, 211, 255), 'en': (114, 211, 255), 'jp': (114, 211, 255), 'tw': (114, 211, 255)}, button={'cn': (442, 421, 492, 447), 'en': (442, 421, 492, 447), 'jp': (442, 421, 492, 447), 'tw': (442, 421, 492, 447)}, file={'cn': './assets/cn/ui_white/REWARD_GOTO_TACTICAL_WHITE.png', 'en': './assets/cn/ui_white/REWARD_GOTO_TACTICAL_WHITE.png', 'jp': './assets/cn/ui_white/REWARD_GOTO_TACTICAL_WHITE.png', 'tw': './assets/cn/ui_white/REWARD_GOTO_TACTICAL_WHITE.png'})