Skip to content

Main fix scroll #236

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion flybirds/core/plugin/plugins/default/app_base_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def ocr_text_input(self, context, selector, param2):
ocr_text_input(context, selector, param2)

def swipe_to_ele(self, context, p_selector, param2, c_selector):
step_adjust.swipe_to_ele(context, p_selector, param2, c_selector)
step_adjust.swipe_to_ele(context, p_selector, param2, c_selector, True)

def full_screen_swipe_to_ele_aaa(self, context, param1, selector):
step_adjust.full_screen_swipe_to_ele_aaa(context, param1, selector)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import flybirds.utils.dsl_helper as dsl_helper


def swipe_to_ele(context, param1, param2, param3):
def swipe_to_ele(context, param1, param2, param3, in_ele=False):
poco_instance = gr.get_value("pocoInstance")

param1_dict = dsl_helper.params_to_dic(param1)
Expand Down Expand Up @@ -77,6 +77,7 @@ def swipe_to_ele(context, param1, param2, param3):
start_y,
distance,
duration,
in_ele
)


Expand Down
11 changes: 7 additions & 4 deletions flybirds/core/plugin/plugins/default/step/swipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import flybirds.core.plugin.plugins.default.ui_driver.poco.poco_swipe as ps
import flybirds.utils.dsl_helper as dsl_helper
import flybirds.utils.point_helper as point_helper
import flybirds.core.global_resource as g_res


def ele_swipe(context, param1, param2, param3):
Expand All @@ -32,8 +33,9 @@ def ele_swipe(context, param1, param2, param3):
start_point[1] = float(param3_dict["startY"])

screen_size = gr.get_device_size()

direction = point_helper.search_direction_switch(param2.strip())
direction = param2.strip()
if g_res is None or not g_res.get_app_config_value("finger_direction_switch", False):
direction = point_helper.search_direction_switch(param2.strip())

distance = float(param3_dict["swipeNumber"])

Expand Down Expand Up @@ -72,9 +74,10 @@ def full_screen_swipe(context, param1, param2):
start_point[1] = float(param2_dict["startY"])

screen_size = gr.get_device_size()

# direction = param1.strip()
# if g_res is None or not g_res.get_app_config_value("finger_direction_switch", False):
# direction = point_helper.search_direction_switch(param1.strip())
direction = point_helper.search_direction_switch(param1.strip())

distance = float(param2_dict["swipeNumber"])

duration = None
Expand Down
85 changes: 55 additions & 30 deletions flybirds/core/plugin/plugins/default/ui_driver/poco/poco_swipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def air_bdd_ele_swipe(
distance,
duration,
ready_time=None,
in_ele=False,
):
"""
Slides a specified distance up, down, left, or right from a specified
Expand Down Expand Up @@ -112,35 +113,36 @@ def air_bdd_ele_swipe(
if distance > 1:
if direction == direct_left or direction == direct_right:
distance /= screen_size[0]
if distance > max_x:
distance = max_x
if distance < min_x:
distance = min_x
# if distance > max_x:
# distance = max_x
# if distance < min_x:
# distance = min_x
else:
distance /= screen_size[1]
if distance > max_y:
distance = max_y
if distance < min_y:
distance = min_y
# if distance > max_y:
# distance = max_y
# if distance < min_y:
# distance = min_y
else:
if direction == direct_left or direction == direct_right:
distance *= target_size[0]
if distance > max_x:
distance = max_x
if distance < min_x:
distance = min_x
# if distance > max_x:
# distance = max_x
# if distance < min_x:
# distance = min_x
else:
distance *= target_size[1]
if distance > max_y:
distance = max_y
if distance < min_y:
distance = min_y
# if distance > max_y:
# distance = max_y
# if distance < min_y:
# distance = min_y

air_bdd_direction_swipe(poco, start_point, direction, distance, duration)
air_bdd_direction_swipe(poco, start_point, direction, distance, duration, in_ele, max_x, min_x, max_y, min_y)


def air_bdd_direction_swipe(
poco, start_point, direction, distance, duration=None
poco, start_point, direction, distance, duration=None, in_ele=False, max_x=None, min_x=None, max_y=None,
min_y=None
):
"""
swipe the specified distance from the starting point to one of up, down,
Expand All @@ -150,6 +152,11 @@ def air_bdd_direction_swipe(
:param direction:
:param distance:
:param duration:
:param in_ele:
:param max_x:
:param min_x:
:param max_y:
:param min_y:
:return:
"""
# get current language
Expand All @@ -162,24 +169,40 @@ def air_bdd_direction_swipe(
end_point = [start_point[0], start_point[1]]
if direction == direct_left:
end_point[0] -= distance
if end_point[0] < 0.0:
end_point[0] = 0
start_point[0] = distance
if not in_ele:
if end_point[0] < 0.0:
end_point[0] = 0
start_point[0] = distance
else:
if end_point[0] < min_x:
end_point[0] = min_x
elif direction == direct_right:
end_point[0] += distance
if end_point[0] > 1.0:
end_point[0] = 1
start_point[0] = 1 - distance
if not in_ele:
if end_point[0] > 1.0:
end_point[0] = 1
start_point[0] = 1 - distance
else:
if end_point[0] > max_x:
end_point[0] = max_x
elif direction == direct_up:
end_point[1] -= distance
if end_point[1] < 0:
end_point[1] = 0
start_point[1] = distance
if not in_ele:
if end_point[1] < 0:
end_point[1] = 0
start_point[1] = distance
else:
if end_point[1] < min_y:
end_point[1] = min_y
elif direction == direct_down:
end_point[1] += distance
if end_point[1] > 1:
end_point[1] = 1
start_point[1] = 1 - distance
if not in_ele:
if end_point[1] > 1:
end_point[1] = 1
start_point[1] = 1 - distance
else:
if end_point[1] > max_y:
end_point[1] = max_y
air_bdd_percent_point_swipe(poco, start_point, end_point, duration)


Expand Down Expand Up @@ -264,6 +287,7 @@ def air_bdd_swipe_search(
start_y=None,
distance=None,
duration=None,
in_ele=False
):
"""
swipe in a certain direction in the full screen or within an element to
Expand Down Expand Up @@ -301,6 +325,7 @@ def air_bdd_swipe_search(
direction,
distance,
duration,
in_ele
)
swipe_count -= 1
if not searched:
Expand Down
3 changes: 0 additions & 3 deletions flybirds/utils/point_helper.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# -*- coding: utf-8 -*-
from flybirds.core.global_context import GlobalContext as g_Context
from flybirds.utils import language_helper as lan
import flybirds.core.global_resource as g_res


def get_swipe_search_start_point(direction, start_x=None, start_y=None):
Expand Down Expand Up @@ -43,8 +42,6 @@ def search_direction_switch(direction):
you have to slide in a certain direction
to change the direction parameter
"""
if g_res is not None and g_res.get_app_config_value("finger_direction_switch", False):
return direction
# get current language
language = g_Context.get_current_language()
direct_left = lan.parse_glb_str("left", language)
Expand Down