11#ifndef PYTHON_SOURCE_H
22#define PYTHON_SOURCE_H
33
4- // Seika Engine API v0.11.1
4+ // Seika Engine API v0.12.0
55
66using PythonSource = const std::string&;
77
88static PythonSource PYTHON_SOURCE_ASSETS_MODULE =
99 " from enum import Enum\n "
10+ " from typing import List\n "
11+ " \n "
1012 " import seika_engine_api\n "
1113 " from seika.color import Color\n "
12- " from seika.math import Vector2\n "
14+ " from seika.math import Vector2, Rect2 \n "
1315 " \n "
1416 " \n "
1517 " class Texture:\n "
@@ -87,22 +89,6 @@ static PythonSource PYTHON_SOURCE_ASSETS_MODULE =
8789 " height=height,\n "
8890 " )\n "
8991 " \n "
90- " # @staticmethod\n "
91- " # def create(\n "
92- " # file_path: str,\n "
93- " # wrap_s=Wrap.CLAMP_TO_BORDER,\n "
94- " # wrap_t=Wrap.CLAMP_TO_BORDER,\n "
95- " # filter_min=FILTER.NEAREST,\n "
96- " # filter_max=FILTER.NEAREST,\n "
97- " # ):\n "
98- " # return Texture(\n "
99- " # file_path=file_path,\n "
100- " # wrap_s=wrap_s,\n "
101- " # wrap_t=wrap_t,\n "
102- " # filter_min=filter_min,\n "
103- " # filter_max=filter_max,\n "
104- " # )\n "
105- " \n "
10692 " def get_pixel_color(self, position: Vector2) -> Color:\n "
10793 " red, green, blue, alpha = seika_engine_api.texture_get_pixel_color(\n "
10894 " file_path=self.file_path, x=position.x, y=position.y\n "
@@ -116,6 +102,20 @@ static PythonSource PYTHON_SOURCE_ASSETS_MODULE =
116102 " return f\" Texture(file_path: {self._file_path}, wrap_s: {self._wrap_s}, wrap_t: {self._wrap_t}, filter_min: {self._filter_min}, filter_min: {self._filter_max}, width: {self._width}, height: {self._height})\"\n "
117103 " \n "
118104 " \n "
105+ " class AnimationFrame:\n "
106+ " def __init__(self, texture: Texture, draw_source: Rect2, index: int):\n "
107+ " self.texture = texture\n "
108+ " self.draw_source = draw_source\n "
109+ " self.index = index\n "
110+ " \n "
111+ " \n "
112+ " class Animation:\n "
113+ " def __init__(self, name: str, speed: int, frames: List[AnimationFrame]):\n "
114+ " self.name = name\n "
115+ " self.speed = speed\n "
116+ " self.frames = frames\n "
117+ " \n "
118+ " \n "
119119 " class Font:\n "
120120 " def __init__(self, uid: str, file_path: str, size: int):\n "
121121 " self._uid = uid\n "
@@ -885,9 +885,9 @@ static PythonSource PYTHON_SOURCE_NETWORK_MODULE =
885885
886886static PythonSource PYTHON_SOURCE_NODE_MODULE =
887887 " from enum import Enum\n "
888- " from typing import Optional\n "
888+ " from typing import Optional, List \n "
889889 " import seika_engine_api\n "
890- " from seika.assets import Texture, Font\n "
890+ " from seika.assets import Texture, AnimationFrame, Animation, Font\n "
891891 " from seika.math import Vector2, Vector3, Rect2\n "
892892 " from seika.color import Color\n "
893893 " \n "
@@ -1204,6 +1204,88 @@ static PythonSource PYTHON_SOURCE_NODE_MODULE =
12041204 " seika_engine_api.animated_sprite_stop(entity_id=self.entity_id)\n "
12051205 " \n "
12061206 " @property\n "
1207+ " def current_animation(self) -> Animation:\n "
1208+ " return Animation(name=\"\" , speed=200, frames=[])\n "
1209+ " \n "
1210+ " @current_animation.setter\n "
1211+ " def current_animation(self, value: Animation) -> None:\n "
1212+ " seika_engine_api.animated_sprite_set_animation(\n "
1213+ " entity_id=self.entity_id, animation_name=value.name\n "
1214+ " )\n "
1215+ " \n "
1216+ " @property\n "
1217+ " def animations(self) -> List[Animation]:\n "
1218+ " # def get_mock_animations() -> list:\n "
1219+ " # mock_animations = [\n "
1220+ " # [\n "
1221+ " # (\n "
1222+ " # # Animation Name\n "
1223+ " # \" idle\" ,\n "
1224+ " # # Animation Speed\n "
1225+ " # 200,\n "
1226+ " # # Animation Frames\n "
1227+ " # [\n "
1228+ " # (\n "
1229+ " # # Texture Path\n "
1230+ " # \" assets/images/mock.png\" ,\n "
1231+ " # # Draw Source\n "
1232+ " # 0,\n "
1233+ " # 0,\n "
1234+ " # 16,\n "
1235+ " # 16,\n "
1236+ " # # index\n "
1237+ " # 0,\n "
1238+ " # )\n "
1239+ " # ],\n "
1240+ " # )\n "
1241+ " # ]\n "
1242+ " # ]\n "
1243+ " # return mock_animations\n "
1244+ " \n "
1245+ " received_animations = []\n "
1246+ " for (\n "
1247+ " anim_name,\n "
1248+ " anim_speed,\n "
1249+ " anim_frames,\n "
1250+ " ) in seika_engine_api.animates_sprite_get_animations(entity_id=self.entity_id):\n "
1251+ " in_anim_frames = []\n "
1252+ " for frame_texture_path, x, y, w, h, frame_index in anim_frames:\n "
1253+ " frame_draw_source = Rect2(x, y, w, h)\n "
1254+ " in_anim_frames.append(\n "
1255+ " AnimationFrame(\n "
1256+ " texture=Texture.get(frame_texture_path),\n "
1257+ " draw_source=frame_draw_source,\n "
1258+ " index=frame_index,\n "
1259+ " )\n "
1260+ " )\n "
1261+ " received_animations.append(\n "
1262+ " Animation(name=anim_name, speed=anim_speed, frames=in_anim_frames)\n "
1263+ " )\n "
1264+ " \n "
1265+ " return received_animations\n "
1266+ " \n "
1267+ " @animations.setter\n "
1268+ " def animations(self, value: List[Animation]) -> None:\n "
1269+ " new_anims = []\n "
1270+ " for anim in value:\n "
1271+ " anim_frames = []\n "
1272+ " for anim_frame in anim.frames:\n "
1273+ " anim_frames.append(\n "
1274+ " (\n "
1275+ " anim_frame.texture.file_path,\n "
1276+ " anim_frame.draw_source.x,\n "
1277+ " anim_frame.draw_source.y,\n "
1278+ " anim_frame.draw_source.w,\n "
1279+ " anim_frame.draw_source.h,\n "
1280+ " anim_frame.index,\n "
1281+ " )\n "
1282+ " )\n "
1283+ " new_anims.append((anim.name, anim.speed, anim_frames))\n "
1284+ " seika_engine_api.animated_sprite_set_animations(\n "
1285+ " entity_id=self.entity_id, animations=new_anims\n "
1286+ " )\n "
1287+ " \n "
1288+ " @property\n "
12071289 " def is_playing(self) -> bool:\n "
12081290 " return seika_engine_api.animated_is_playing(entity_id=self.entity_id)\n "
12091291 " \n "
@@ -1561,7 +1643,9 @@ static PythonSource PYTHON_SOURCE_SCENE_MODULE =
15611643
15621644static PythonSource PYTHON_SOURCE_UTILS_MODULE =
15631645 " class SimpleTimer:\n "
1564- " def __init__(self, wait_time: float, loops=False, timeout_func=None, start_on_init=False):\n "
1646+ " def __init__(\n "
1647+ " self, wait_time: float, loops=False, timeout_func=None, start_on_init=False\n "
1648+ " ):\n "
15651649 " self.wait_time = wait_time\n "
15661650 " self.loops = loops\n "
15671651 " self.timeout_func = timeout_func\n "
0 commit comments