Skip to content

Commit

Permalink
feat: Python 绑定的 set_ctrl_option
Browse files Browse the repository at this point in the history
  • Loading branch information
QiE2035 committed Jan 19, 2024
1 parent ca68100 commit 8bfeee8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
25 changes: 22 additions & 3 deletions source/binding/Python/maa/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,28 @@ def _status(self, maaid: int) -> MaaStatus:

_api_properties_initialized: bool = False

# TODO: set_option
# def set_option(self, key: MaaCtrlOptionEnum, value: MaaOptionValue):
# pass
# TODO: 进一步优化 set_option?
def set_option(self, key: MaaCtrlOptionEnum, value: MaaOptionValue) -> bool:
if (
key == MaaCtrlOptionEnum.ScreenshotTargetLongSide
or key == MaaCtrlOptionEnum.ScreenshotTargetShortSide
):
size = ctypes.sizeof(ctypes.c_int32)
elif (
key == MaaCtrlOptionEnum.DefaultAppPackage
or key == MaaCtrlOptionEnum.DefaultAppPackageEntry
):
size = ctypes.sizeof(ctypes.c_bool)
elif key == MaaCtrlOptionEnum.Recording:
size = ctypes.sizeof(ctypes.c_bool)
elif key == MaaCtrlOptionEnum.Invalid:
size = 0
else:
raise ValueError(f"Unsupported option: {key}")

return bool(
Library.framework.MaaControllerSetOption(self._handle, key, ctypes.pointer(value), size)
)

@staticmethod
def _set_api_properties():
Expand Down
1 change: 0 additions & 1 deletion source/binding/Python/maa/define.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ class MaaStatusEnum(Enum):
MaaCtrlOption = MaaOption


# TODO: 封装一下?
class MaaCtrlOptionEnum:
Invalid: MaaCtrlOption = 0

Expand Down

0 comments on commit 8bfeee8

Please sign in to comment.