diff --git a/assets/en/momotalk/MESSAGE_OFF.png b/assets/en/momotalk/SWITCH_MESSAGE.png similarity index 61% rename from assets/en/momotalk/MESSAGE_OFF.png rename to assets/en/momotalk/SWITCH_MESSAGE.png index 45f9158..bce95dd 100644 Binary files a/assets/en/momotalk/MESSAGE_OFF.png and b/assets/en/momotalk/SWITCH_MESSAGE.png differ diff --git a/assets/en/momotalk/SWITCH_MESSAGE_CHECK.png b/assets/en/momotalk/SWITCH_MESSAGE_CHECK.png new file mode 100644 index 0000000..fa7dd35 Binary files /dev/null and b/assets/en/momotalk/SWITCH_MESSAGE_CHECK.png differ diff --git a/assets/en/momotalk/MESSAGE_ON.png b/assets/en/momotalk/SWITCH_STUDENT.png similarity index 51% rename from assets/en/momotalk/MESSAGE_ON.png rename to assets/en/momotalk/SWITCH_STUDENT.png index 3ecc259..caf65f0 100644 Binary files a/assets/en/momotalk/MESSAGE_ON.png and b/assets/en/momotalk/SWITCH_STUDENT.png differ diff --git a/assets/en/momotalk/SWITCH_STUDENT_CHECK.png b/assets/en/momotalk/SWITCH_STUDENT_CHECK.png new file mode 100644 index 0000000..3bb5f55 Binary files /dev/null and b/assets/en/momotalk/SWITCH_STUDENT_CHECK.png differ diff --git a/tasks/momotalk/assets/assets_momotalk.py b/tasks/momotalk/assets/assets_momotalk.py index 4fcb873..6f4ca49 100644 --- a/tasks/momotalk/assets/assets_momotalk.py +++ b/tasks/momotalk/assets/assets_momotalk.py @@ -69,28 +69,6 @@ MENU = ButtonWrapper( button=(1156, 15, 1251, 63), ), ) -MESSAGE_OFF = ButtonWrapper( - name='MESSAGE_OFF', - jp=None, - en=Button( - file='./assets/en/momotalk/MESSAGE_OFF.png', - area=(143, 273, 203, 298), - search=(123, 253, 223, 318), - color=(93, 105, 122), - button=(143, 273, 203, 298), - ), -) -MESSAGE_ON = ButtonWrapper( - name='MESSAGE_ON', - jp=None, - en=Button( - file='./assets/en/momotalk/MESSAGE_ON.png', - area=(143, 271, 203, 301), - search=(123, 251, 223, 321), - color=(160, 168, 182), - button=(143, 271, 203, 301), - ), -) NOTIFICATION_BADGE = ButtonWrapper( name='NOTIFICATION_BADGE', jp=None, @@ -168,6 +146,50 @@ STORY = ButtonWrapper( button=(790, 529, 979, 557), ), ) +SWITCH_MESSAGE = ButtonWrapper( + name='SWITCH_MESSAGE', + jp=None, + en=Button( + file='./assets/en/momotalk/SWITCH_MESSAGE.png', + area=(147, 271, 194, 297), + search=(127, 251, 214, 317), + color=(187, 191, 201), + button=(147, 271, 194, 297), + ), +) +SWITCH_MESSAGE_CHECK = ButtonWrapper( + name='SWITCH_MESSAGE_CHECK', + jp=None, + en=Button( + file='./assets/en/momotalk/SWITCH_MESSAGE_CHECK.png', + area=(228, 165, 391, 194), + search=(208, 145, 411, 214), + color=(211, 215, 217), + button=(228, 165, 391, 194), + ), +) +SWITCH_STUDENT = ButtonWrapper( + name='SWITCH_STUDENT', + jp=None, + en=Button( + file='./assets/en/momotalk/SWITCH_STUDENT.png', + area=(148, 167, 194, 217), + search=(128, 147, 214, 237), + color=(157, 166, 179), + button=(148, 167, 194, 217), + ), +) +SWITCH_STUDENT_CHECK = ButtonWrapper( + name='SWITCH_STUDENT_CHECK', + jp=None, + en=Button( + file='./assets/en/momotalk/SWITCH_STUDENT_CHECK.png', + area=(229, 166, 320, 192), + search=(209, 146, 340, 212), + color=(199, 203, 205), + button=(229, 166, 320, 192), + ), +) UNREAD = ButtonWrapper( name='UNREAD', jp=None, diff --git a/tasks/momotalk/ui.py b/tasks/momotalk/ui.py index 8ac7fd6..4f82ff7 100644 --- a/tasks/momotalk/ui.py +++ b/tasks/momotalk/ui.py @@ -1,18 +1,18 @@ -from module.base.timer import Timer -from module.base.base import ModuleBase -from module.logger import logger -from module.ui.switch import Switch -from module.base.utils import point_in_area, area_size -from tasks.base.ui import UI -from tasks.base.page import page_main, page_momo_talk -from tasks.momotalk.assets.assets_momotalk import * import cv2 import numpy as np -"""None of the switches works""" -SWITCH_MESSAGE = Switch("Message_switch") -SWITCH_MESSAGE.add_state("on", MESSAGE_ON) -SWITCH_MESSAGE.add_state("off", MESSAGE_OFF) +from module.base.base import ModuleBase +from module.base.timer import Timer +from module.base.utils import point_in_area, area_size +from module.logger import logger +from module.ui.switch import Switch +from tasks.base.page import page_main, page_momo_talk +from tasks.base.ui import UI +from tasks.momotalk.assets.assets_momotalk import * + +SWITCH_SIDEBAR = Switch("Sidebar_switch", is_selector=True) +SWITCH_SIDEBAR.add_state("student", SWITCH_STUDENT_CHECK, SWITCH_STUDENT) +SWITCH_SIDEBAR.add_state("message", SWITCH_MESSAGE_CHECK, SWITCH_MESSAGE) SWITCH_UNREAD = Switch("Unread_switch") SWITCH_UNREAD.add_state("on", UNREAD_ON) @@ -27,6 +27,7 @@ button can be found in different locations""" REPLY_TEMPLATE = REPLY.matched_button.image STORY_TEMPLATE = STORY.matched_button.image + class MomoTalkUI(UI): def __init__(self, config, device): super().__init__(config, device) @@ -121,10 +122,10 @@ class MomoTalkUI(UI): self.ui_ensure(page_main) if self.match_color(NOTIFICATION_BADGE, threshold=80): self.ui_ensure(page_momo_talk) - while not self.select_then_check(MESSAGE_OFF, MESSAGE_ON): - pass + while SWITCH_SIDEBAR.get(self) != "message": + SWITCH_SIDEBAR.set("message", self) return True - logger.warn("No students available for interaction") + logger.warning("No students available for interaction") return False def sort_messages(self):