arepy 0.1.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- arepy-0.1.1/LICENSE +21 -0
- arepy-0.1.1/PKG-INFO +82 -0
- arepy-0.1.1/README.md +36 -0
- arepy-0.1.1/arepy/__init__.py +4 -0
- arepy-0.1.1/arepy/arepy_imgui/__init__.py +0 -0
- arepy-0.1.1/arepy/arepy_imgui/imgui_repository.py +432 -0
- arepy-0.1.1/arepy/asset_store/__init__.py +1 -0
- arepy-0.1.1/arepy/asset_store/asset_store.py +53 -0
- arepy-0.1.1/arepy/builders.py +50 -0
- arepy-0.1.1/arepy/bundle/__init__.py +0 -0
- arepy-0.1.1/arepy/bundle/components/__init__.py +6 -0
- arepy-0.1.1/arepy/bundle/components/camera_component.py +17 -0
- arepy-0.1.1/arepy/bundle/components/rigidbody_component.py +10 -0
- arepy-0.1.1/arepy/bundle/components/sprite_component.py +13 -0
- arepy-0.1.1/arepy/bundle/components/transform_component.py +14 -0
- arepy-0.1.1/arepy/bundle/systems/__init__.py +2 -0
- arepy-0.1.1/arepy/bundle/systems/movement_system.py +38 -0
- arepy-0.1.1/arepy/bundle/systems/render_system.py +50 -0
- arepy-0.1.1/arepy/container.py +65 -0
- arepy-0.1.1/arepy/ecs/__init__.py +3 -0
- arepy-0.1.1/arepy/ecs/components.py +131 -0
- arepy-0.1.1/arepy/ecs/constants.py +1 -0
- arepy-0.1.1/arepy/ecs/entities.py +69 -0
- arepy-0.1.1/arepy/ecs/exceptions.py +21 -0
- arepy-0.1.1/arepy/ecs/query/__init__.py +158 -0
- arepy-0.1.1/arepy/ecs/query/exceptions.py +2 -0
- arepy-0.1.1/arepy/ecs/registry.py +187 -0
- arepy-0.1.1/arepy/ecs/systems.py +15 -0
- arepy-0.1.1/arepy/ecs/threading.py +18 -0
- arepy-0.1.1/arepy/ecs/utils.py +75 -0
- arepy-0.1.1/arepy/engine/__init__.py +3 -0
- arepy-0.1.1/arepy/engine/display.py +21 -0
- arepy-0.1.1/arepy/engine/engine.py +146 -0
- arepy-0.1.1/arepy/engine/input.py +139 -0
- arepy-0.1.1/arepy/engine/integrations/__init__.py +0 -0
- arepy-0.1.1/arepy/engine/integrations/imgui/__init__.py +0 -0
- arepy-0.1.1/arepy/engine/integrations/imgui/backend.py +192 -0
- arepy-0.1.1/arepy/engine/integrations/imgui/moderngl_renderer.py +193 -0
- arepy-0.1.1/arepy/engine/integrations/raylib/__init__.py +0 -0
- arepy-0.1.1/arepy/engine/integrations/raylib/display/__init__.py +0 -0
- arepy-0.1.1/arepy/engine/integrations/raylib/display/display_repository.py +157 -0
- arepy-0.1.1/arepy/engine/integrations/raylib/input/__init__.py +0 -0
- arepy-0.1.1/arepy/engine/integrations/raylib/input/input_repository.py +103 -0
- arepy-0.1.1/arepy/engine/integrations/raylib/renderer/__init__.py +0 -0
- arepy-0.1.1/arepy/engine/integrations/raylib/renderer/renderer_2d.py +268 -0
- arepy-0.1.1/arepy/engine/renderer/__init__.py +50 -0
- arepy-0.1.1/arepy/engine/renderer/renderer_2d.py +64 -0
- arepy-0.1.1/arepy/event_manager/__init__.py +1 -0
- arepy-0.1.1/arepy/event_manager/event_manager.py +76 -0
- arepy-0.1.1/arepy/event_manager/events/__init__.py +2 -0
- arepy-0.1.1/arepy/event_manager/events/collision_event.py +11 -0
- arepy-0.1.1/arepy/event_manager/events/keyboard_event.py +20 -0
- arepy-0.1.1/arepy/event_manager/events/mouse_event.py +48 -0
- arepy-0.1.1/arepy/event_manager/handlers/__init__.py +2 -0
- arepy-0.1.1/arepy/event_manager/handlers/collision_event_handler.py +33 -0
- arepy-0.1.1/arepy/event_manager/handlers/input_event_handler.py +116 -0
- arepy-0.1.1/arepy/math/__init__.py +11 -0
- arepy-0.1.1/arepy/math/vec2.py +87 -0
- arepy-0.1.1/arepy/math/vec3.py +96 -0
- arepy-0.1.1/arepy.egg-info/PKG-INFO +82 -0
- arepy-0.1.1/arepy.egg-info/SOURCES.txt +65 -0
- arepy-0.1.1/arepy.egg-info/dependency_links.txt +1 -0
- arepy-0.1.1/arepy.egg-info/requires.txt +6 -0
- arepy-0.1.1/arepy.egg-info/top_level.txt +1 -0
- arepy-0.1.1/pyproject.toml +38 -0
- arepy-0.1.1/setup.cfg +4 -0
- arepy-0.1.1/tests/test_registry.py +69 -0
arepy-0.1.1/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Abrahan Gil
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
arepy-0.1.1/PKG-INFO
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: arepy
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: An ECS python game engine with Raylib
|
|
5
|
+
Author-email: Abrahan Gil <scr44gr@protonmail.com>
|
|
6
|
+
License: MIT License
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2024 Abrahan Gil
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
in the Software without restriction, including without limitation the rights
|
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
furnished to do so, subject to the following conditions:
|
|
16
|
+
|
|
17
|
+
The above copyright notice and this permission notice shall be included in all
|
|
18
|
+
copies or substantial portions of the Software.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
+
SOFTWARE.
|
|
27
|
+
|
|
28
|
+
Keywords: ecs,game-engine,python-game-engine
|
|
29
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
30
|
+
Classifier: Development Status :: 3 - Alpha
|
|
31
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
32
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
33
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
34
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
35
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
36
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
37
|
+
Classifier: Operating System :: MacOS :: MacOS X
|
|
38
|
+
Requires-Python: >=3.10
|
|
39
|
+
Description-Content-Type: text/markdown
|
|
40
|
+
License-File: LICENSE
|
|
41
|
+
Requires-Dist: bitarray==2.9.2
|
|
42
|
+
Requires-Dist: raylib==5.5.0.2
|
|
43
|
+
Provides-Extra: imgui
|
|
44
|
+
Requires-Dist: imgui-bundle==1.6.0; extra == "imgui"
|
|
45
|
+
Requires-Dist: moderngl==5.12.0; extra == "imgui"
|
|
46
|
+
|
|
47
|
+
# Arepy 🎮
|
|
48
|
+
[](https://github.com/Scr44gr/arepy/actions/workflows/python-publish.yml)
|
|
49
|
+
|
|
50
|
+
An ECS game engine created in python with raylib and imgui integration :)
|
|
51
|
+
## Installation 📖
|
|
52
|
+
```bash
|
|
53
|
+
pip install git+https://github.com/Scr44gr/arepy.git
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Usage 📝
|
|
57
|
+
|
|
58
|
+
### Basic usage example
|
|
59
|
+
|
|
60
|
+
#### Creating a simple system to move entities
|
|
61
|
+
|
|
62
|
+
```python
|
|
63
|
+
from arepy.bundle.components.rigidbody_component import RigidBody2D
|
|
64
|
+
from arepy.bundle.components.transform_component import Transform
|
|
65
|
+
from arepy.ecs.entities import Entities
|
|
66
|
+
from arepy.ecs.query import Query, With
|
|
67
|
+
from arepy.engine.renderer.renderer_2d import Renderer2D
|
|
68
|
+
|
|
69
|
+
def movement_system(
|
|
70
|
+
query: Query[Entities, With[Transform, RigidBody2D]], renderer: Renderer2D
|
|
71
|
+
):
|
|
72
|
+
delta_time = renderer.get_delta_time()
|
|
73
|
+
entities = query.get_entities()
|
|
74
|
+
for entity in entities:
|
|
75
|
+
transform = entity.get_component(Transform)
|
|
76
|
+
velocity = entity.get_component(RigidBody2D).velocity
|
|
77
|
+
|
|
78
|
+
transform.position.x += velocity.x * delta_time
|
|
79
|
+
transform.position.y += velocity.y * delta_time
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
TODO!: create a nice README.md
|
arepy-0.1.1/README.md
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Arepy 🎮
|
|
2
|
+
[](https://github.com/Scr44gr/arepy/actions/workflows/python-publish.yml)
|
|
3
|
+
|
|
4
|
+
An ECS game engine created in python with raylib and imgui integration :)
|
|
5
|
+
## Installation 📖
|
|
6
|
+
```bash
|
|
7
|
+
pip install git+https://github.com/Scr44gr/arepy.git
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## Usage 📝
|
|
11
|
+
|
|
12
|
+
### Basic usage example
|
|
13
|
+
|
|
14
|
+
#### Creating a simple system to move entities
|
|
15
|
+
|
|
16
|
+
```python
|
|
17
|
+
from arepy.bundle.components.rigidbody_component import RigidBody2D
|
|
18
|
+
from arepy.bundle.components.transform_component import Transform
|
|
19
|
+
from arepy.ecs.entities import Entities
|
|
20
|
+
from arepy.ecs.query import Query, With
|
|
21
|
+
from arepy.engine.renderer.renderer_2d import Renderer2D
|
|
22
|
+
|
|
23
|
+
def movement_system(
|
|
24
|
+
query: Query[Entities, With[Transform, RigidBody2D]], renderer: Renderer2D
|
|
25
|
+
):
|
|
26
|
+
delta_time = renderer.get_delta_time()
|
|
27
|
+
entities = query.get_entities()
|
|
28
|
+
for entity in entities:
|
|
29
|
+
transform = entity.get_component(Transform)
|
|
30
|
+
velocity = entity.get_component(RigidBody2D).velocity
|
|
31
|
+
|
|
32
|
+
transform.position.x += velocity.x * delta_time
|
|
33
|
+
transform.position.y += velocity.y * delta_time
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
TODO!: create a nice README.md
|
|
File without changes
|
|
@@ -0,0 +1,432 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
from typing import Any, Optional, Protocol
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class ImGuiRendererRepository(Protocol):
|
|
6
|
+
def __init__(self, window: int): ...
|
|
7
|
+
def render(self, data: Any): ...
|
|
8
|
+
def process_inputs(self): ...
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@dataclass(frozen=True)
|
|
12
|
+
class Default:
|
|
13
|
+
def __init__(self, *args, **kwargs):
|
|
14
|
+
pass
|
|
15
|
+
|
|
16
|
+
def __getattr__(self, item):
|
|
17
|
+
return self
|
|
18
|
+
|
|
19
|
+
def __call__(self, *args, **kwargs):
|
|
20
|
+
return False
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class ImGui(Protocol):
|
|
24
|
+
"""A helper class to interact with the ImGui library"""
|
|
25
|
+
|
|
26
|
+
def get_draw_data(self) -> Any:
|
|
27
|
+
"""Get the draw data"""
|
|
28
|
+
...
|
|
29
|
+
|
|
30
|
+
def create_context(self):
|
|
31
|
+
"""Create a new ImGui Context"""
|
|
32
|
+
...
|
|
33
|
+
|
|
34
|
+
def render(self):
|
|
35
|
+
"""Render the ImGui frame"""
|
|
36
|
+
...
|
|
37
|
+
|
|
38
|
+
def shutdown(self):
|
|
39
|
+
"""Shutdown the ImGui context"""
|
|
40
|
+
...
|
|
41
|
+
|
|
42
|
+
def get_io(self):
|
|
43
|
+
"""Get the ImGui IO object"""
|
|
44
|
+
...
|
|
45
|
+
|
|
46
|
+
def image(
|
|
47
|
+
self,
|
|
48
|
+
texture_id: int,
|
|
49
|
+
size: tuple[int, int],
|
|
50
|
+
uv0: tuple[float, float],
|
|
51
|
+
uv1: tuple[float, float],
|
|
52
|
+
tint_col: Optional[tuple[float, float, float, float]],
|
|
53
|
+
border_col: Optional[tuple[float, float, float, float]],
|
|
54
|
+
):
|
|
55
|
+
"""Create an image
|
|
56
|
+
|
|
57
|
+
Args:
|
|
58
|
+
texture_id: The id of the texture
|
|
59
|
+
width: The width of the image
|
|
60
|
+
height: The height of the image
|
|
61
|
+
"""
|
|
62
|
+
...
|
|
63
|
+
|
|
64
|
+
def accept_drag_drop_payload(self, type: str, flags: int):
|
|
65
|
+
"""Accept a drag and drop payload
|
|
66
|
+
|
|
67
|
+
Args:
|
|
68
|
+
type: The type of the payload
|
|
69
|
+
flags: The flags of the payload
|
|
70
|
+
"""
|
|
71
|
+
...
|
|
72
|
+
|
|
73
|
+
def align_text_to_frame_padding(self):
|
|
74
|
+
"""Align text to the frame padding"""
|
|
75
|
+
...
|
|
76
|
+
|
|
77
|
+
def arrow_button(self, label: str, direction: int) -> bool:
|
|
78
|
+
"""Create an arrow button
|
|
79
|
+
|
|
80
|
+
Args:
|
|
81
|
+
label: The label of the button
|
|
82
|
+
direction: The direction of the arrow
|
|
83
|
+
|
|
84
|
+
Returns:
|
|
85
|
+
bool: True if the button was clicked
|
|
86
|
+
"""
|
|
87
|
+
...
|
|
88
|
+
|
|
89
|
+
def begin_child(
|
|
90
|
+
self, id: str, width: float, height: float, border: bool, flags: int
|
|
91
|
+
):
|
|
92
|
+
"""Begin a new child window
|
|
93
|
+
|
|
94
|
+
Args:
|
|
95
|
+
id: The id of the child window
|
|
96
|
+
width: The width of the child window
|
|
97
|
+
height: The height of the child window
|
|
98
|
+
border: Whether the child window has a border
|
|
99
|
+
flags: The flags of the child window
|
|
100
|
+
"""
|
|
101
|
+
...
|
|
102
|
+
|
|
103
|
+
def end_child(self):
|
|
104
|
+
"""End the current child window"""
|
|
105
|
+
...
|
|
106
|
+
|
|
107
|
+
def begin_combo(self, label: str, preview_value: str, flags: int):
|
|
108
|
+
"""Begin a new combo box
|
|
109
|
+
|
|
110
|
+
Args:
|
|
111
|
+
label: The label of the combo box
|
|
112
|
+
preview_value: The preview value of the combo box
|
|
113
|
+
flags: The flags of the combo box
|
|
114
|
+
"""
|
|
115
|
+
...
|
|
116
|
+
|
|
117
|
+
def begin_drag_drop_source(self, flags: int):
|
|
118
|
+
"""Begin a new drag and drop source
|
|
119
|
+
|
|
120
|
+
Set the current item as a drag and drop source. If dragging is True, you can call set_drag_drop_payload() and end_drag_drop_source().
|
|
121
|
+
Use with with to automatically call end_drag_drop_source() if necessary.
|
|
122
|
+
|
|
123
|
+
Args:
|
|
124
|
+
flags: The flags of the drag and drop source
|
|
125
|
+
"""
|
|
126
|
+
...
|
|
127
|
+
|
|
128
|
+
def begin_tab_item(self, label: str, open: bool, flags: int) -> Default:
|
|
129
|
+
"""Begin a new tab item
|
|
130
|
+
|
|
131
|
+
Args:
|
|
132
|
+
label: The label of the tab item
|
|
133
|
+
open: Whether the tab item is open
|
|
134
|
+
flags: The flags of the tab item
|
|
135
|
+
"""
|
|
136
|
+
...
|
|
137
|
+
|
|
138
|
+
def begin_tab_bar(self, id: str, flags: int) -> Default:
|
|
139
|
+
"""Begin a new tab bar
|
|
140
|
+
|
|
141
|
+
Args:
|
|
142
|
+
id: The id of the tab bar
|
|
143
|
+
flags: The flags of the tab bar
|
|
144
|
+
"""
|
|
145
|
+
...
|
|
146
|
+
|
|
147
|
+
def begin_main_menu_bar(self):
|
|
148
|
+
"""Begin a new main menu bar"""
|
|
149
|
+
...
|
|
150
|
+
|
|
151
|
+
def begin_menu(self, label: str, enabled: bool) -> bool:
|
|
152
|
+
"""Begin a new menu
|
|
153
|
+
|
|
154
|
+
Args:
|
|
155
|
+
label: The label of the menu
|
|
156
|
+
enabled: Whether the menu is enabled
|
|
157
|
+
|
|
158
|
+
Returns:
|
|
159
|
+
bool: True if the menu was clicked
|
|
160
|
+
"""
|
|
161
|
+
...
|
|
162
|
+
|
|
163
|
+
def get_window_draw_list(self) -> Default:
|
|
164
|
+
"""Get the window draw list"""
|
|
165
|
+
...
|
|
166
|
+
|
|
167
|
+
def get_content_region_available(self) -> tuple[float, float]:
|
|
168
|
+
"""Get the content region available"""
|
|
169
|
+
...
|
|
170
|
+
|
|
171
|
+
def same_line(self, offset_from_start_x: float = 0.0, spacing: float = -1.0):
|
|
172
|
+
"""Move the cursor to the same line
|
|
173
|
+
|
|
174
|
+
Args:
|
|
175
|
+
offset_from_start_x: The offset from the start x
|
|
176
|
+
spacing: The spacing
|
|
177
|
+
"""
|
|
178
|
+
...
|
|
179
|
+
|
|
180
|
+
def new_frame(self):
|
|
181
|
+
"""Start a new ImGui frame"""
|
|
182
|
+
...
|
|
183
|
+
|
|
184
|
+
def end_frame(self):
|
|
185
|
+
"""End the current ImGui frame"""
|
|
186
|
+
...
|
|
187
|
+
|
|
188
|
+
def button(self, label: str) -> bool:
|
|
189
|
+
"""Create a button
|
|
190
|
+
|
|
191
|
+
Args:
|
|
192
|
+
label: The label of the button
|
|
193
|
+
|
|
194
|
+
Returns:
|
|
195
|
+
bool: True if the button was clicked
|
|
196
|
+
"""
|
|
197
|
+
...
|
|
198
|
+
|
|
199
|
+
def text(self, text: str):
|
|
200
|
+
"""Print text
|
|
201
|
+
|
|
202
|
+
Args:
|
|
203
|
+
text: The text to print
|
|
204
|
+
"""
|
|
205
|
+
...
|
|
206
|
+
|
|
207
|
+
def begin(self, name: str, open: bool = True, flags: int = 0):
|
|
208
|
+
"""Begin a new window
|
|
209
|
+
|
|
210
|
+
Args:
|
|
211
|
+
name: The name of the window
|
|
212
|
+
open: Whether the window is open
|
|
213
|
+
"""
|
|
214
|
+
...
|
|
215
|
+
|
|
216
|
+
def end(self):
|
|
217
|
+
"""End the current window"""
|
|
218
|
+
...
|
|
219
|
+
|
|
220
|
+
def end_tab_item(self):
|
|
221
|
+
"""End the current tab item"""
|
|
222
|
+
...
|
|
223
|
+
|
|
224
|
+
def end_tab_bar(self):
|
|
225
|
+
"""End the current tab bar"""
|
|
226
|
+
...
|
|
227
|
+
|
|
228
|
+
def end_main_menu_bar(self):
|
|
229
|
+
"""End the current main menu bar"""
|
|
230
|
+
...
|
|
231
|
+
|
|
232
|
+
def end_menu(self):
|
|
233
|
+
"""End the current menu"""
|
|
234
|
+
...
|
|
235
|
+
|
|
236
|
+
def open_popup(self, id: str):
|
|
237
|
+
"""Open a popup
|
|
238
|
+
|
|
239
|
+
Args:
|
|
240
|
+
id: The id of the popup
|
|
241
|
+
"""
|
|
242
|
+
...
|
|
243
|
+
|
|
244
|
+
def begin_popup(self, id: str):
|
|
245
|
+
"""Begin a new popup
|
|
246
|
+
|
|
247
|
+
Args:
|
|
248
|
+
id: The id of the popup
|
|
249
|
+
"""
|
|
250
|
+
...
|
|
251
|
+
|
|
252
|
+
def end_popup(self):
|
|
253
|
+
"""End the current popup"""
|
|
254
|
+
...
|
|
255
|
+
|
|
256
|
+
def input_text(self, label: str, value: str, buffer_length: int):
|
|
257
|
+
"""Create an input text field
|
|
258
|
+
|
|
259
|
+
Args:
|
|
260
|
+
label: The label of the input field
|
|
261
|
+
value: The value of the input field
|
|
262
|
+
buffer_length: The length of the buffer
|
|
263
|
+
"""
|
|
264
|
+
...
|
|
265
|
+
|
|
266
|
+
def input_text_multiline(
|
|
267
|
+
self,
|
|
268
|
+
label: str,
|
|
269
|
+
value: str,
|
|
270
|
+
buffer_length: int,
|
|
271
|
+
width: float,
|
|
272
|
+
height: float,
|
|
273
|
+
flags: int = 0,
|
|
274
|
+
callback: Optional[Default] = None,
|
|
275
|
+
):
|
|
276
|
+
"""Create a multiline input text field
|
|
277
|
+
|
|
278
|
+
Args:
|
|
279
|
+
label: The label of the input field
|
|
280
|
+
value: The value of the input field
|
|
281
|
+
buffer_length: The length of the buffer
|
|
282
|
+
width: The width of the input field
|
|
283
|
+
height: The height of the input field
|
|
284
|
+
flags: The flags of the input field
|
|
285
|
+
callback: The callback of the input field
|
|
286
|
+
"""
|
|
287
|
+
...
|
|
288
|
+
|
|
289
|
+
def input_float(self, label: str, value: float, step: float, step_fast: float):
|
|
290
|
+
"""Create a float input field
|
|
291
|
+
|
|
292
|
+
Args:
|
|
293
|
+
label: The label of the input field
|
|
294
|
+
value: The value of the input field
|
|
295
|
+
step: The step of the input field
|
|
296
|
+
step_fast: The fast step of the input field
|
|
297
|
+
"""
|
|
298
|
+
...
|
|
299
|
+
|
|
300
|
+
def get_cursor_screen_pos(self) -> tuple[float, float]:
|
|
301
|
+
"""Get the cursor screen position"""
|
|
302
|
+
...
|
|
303
|
+
|
|
304
|
+
def slider_int(
|
|
305
|
+
self, label: str, value: int, min_value: int, max_value: int, format: str
|
|
306
|
+
):
|
|
307
|
+
"""Create an integer slider
|
|
308
|
+
|
|
309
|
+
Args:
|
|
310
|
+
label: The label of the slider
|
|
311
|
+
value: The value of the slider
|
|
312
|
+
min_value: The minimum value of the slider
|
|
313
|
+
max_value: The maximum value of the slider
|
|
314
|
+
format: The format of the slider
|
|
315
|
+
"""
|
|
316
|
+
...
|
|
317
|
+
|
|
318
|
+
def slider_float(
|
|
319
|
+
self,
|
|
320
|
+
label: str,
|
|
321
|
+
value: float,
|
|
322
|
+
min_value: float,
|
|
323
|
+
max_value: float,
|
|
324
|
+
format: str,
|
|
325
|
+
power: float,
|
|
326
|
+
):
|
|
327
|
+
"""Create a float slider
|
|
328
|
+
|
|
329
|
+
Args:
|
|
330
|
+
label: The label of the slider
|
|
331
|
+
value: The value of the slider
|
|
332
|
+
min_value: The minimum value of the slider
|
|
333
|
+
max_value: The maximum value of the slider
|
|
334
|
+
format: The format of the slider
|
|
335
|
+
power: The power of the slider
|
|
336
|
+
"""
|
|
337
|
+
...
|
|
338
|
+
|
|
339
|
+
def menu_item(
|
|
340
|
+
self, label: str, shortcut: str, selected: bool, enabled: bool
|
|
341
|
+
) -> tuple[bool, bool]:
|
|
342
|
+
"""Create a menu item
|
|
343
|
+
|
|
344
|
+
Args:
|
|
345
|
+
label: The label of the menu item
|
|
346
|
+
shortcut: The shortcut of the menu item
|
|
347
|
+
selected: Whether the menu item is selected
|
|
348
|
+
enabled: Whether the menu item is enabled
|
|
349
|
+
|
|
350
|
+
Returns:
|
|
351
|
+
bool: True if the menu item was clicked
|
|
352
|
+
"""
|
|
353
|
+
...
|
|
354
|
+
|
|
355
|
+
def checkbox(self, label: str, state: bool):
|
|
356
|
+
"""Create a checkbox
|
|
357
|
+
|
|
358
|
+
Args:
|
|
359
|
+
label: The label of the checkbox
|
|
360
|
+
value: The value of the checkbox
|
|
361
|
+
"""
|
|
362
|
+
...
|
|
363
|
+
|
|
364
|
+
def radio_button(self, label: str, active: bool):
|
|
365
|
+
"""Create a radio button
|
|
366
|
+
|
|
367
|
+
Args:
|
|
368
|
+
label: The label of the radio button
|
|
369
|
+
active: Whether the radio button is active
|
|
370
|
+
"""
|
|
371
|
+
...
|
|
372
|
+
|
|
373
|
+
def set_next_window_size(self, width: int, height: int):
|
|
374
|
+
"""Set the size of the next window
|
|
375
|
+
|
|
376
|
+
Args:
|
|
377
|
+
width: The width of the window
|
|
378
|
+
height: The height of the window
|
|
379
|
+
"""
|
|
380
|
+
...
|
|
381
|
+
|
|
382
|
+
def set_next_window_position(self, x: int, y: int):
|
|
383
|
+
"""Set the position of the next window
|
|
384
|
+
|
|
385
|
+
Args:
|
|
386
|
+
x: The x position of the window
|
|
387
|
+
y: The y position of the window
|
|
388
|
+
"""
|
|
389
|
+
...
|
|
390
|
+
|
|
391
|
+
def set_next_window_size_constraints(
|
|
392
|
+
self, min_width: int, min_height: int, max_width: int, max_height: int
|
|
393
|
+
):
|
|
394
|
+
"""Set the size constraints of the next window
|
|
395
|
+
|
|
396
|
+
Args:
|
|
397
|
+
min_width: The minimum width of the window
|
|
398
|
+
min_height: The minimum height of the window
|
|
399
|
+
max_width: The maximum width of the window
|
|
400
|
+
max_height: The maximum height of the window
|
|
401
|
+
"""
|
|
402
|
+
...
|
|
403
|
+
|
|
404
|
+
def set_next_window_content_size(self, width: int, height: int):
|
|
405
|
+
"""Set the content size of the next window
|
|
406
|
+
|
|
407
|
+
Args:
|
|
408
|
+
width: The width of the content
|
|
409
|
+
height: The height of the content
|
|
410
|
+
"""
|
|
411
|
+
...
|
|
412
|
+
|
|
413
|
+
def set_next_window_collapsed(self, collapsed: bool, cond: int):
|
|
414
|
+
"""Set the collapsed state of the next window
|
|
415
|
+
|
|
416
|
+
Args:
|
|
417
|
+
collapsed: Whether the window is collapsed
|
|
418
|
+
cond: The condition to set the collapsed state
|
|
419
|
+
"""
|
|
420
|
+
...
|
|
421
|
+
|
|
422
|
+
def set_next_window_focus(self):
|
|
423
|
+
"""Set the focus of the next window"""
|
|
424
|
+
...
|
|
425
|
+
|
|
426
|
+
def set_next_window_bg_alpha(self, alpha: float):
|
|
427
|
+
"""Set the background alpha of the next window
|
|
428
|
+
|
|
429
|
+
Args:
|
|
430
|
+
alpha: The alpha value of the background
|
|
431
|
+
"""
|
|
432
|
+
...
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .asset_store import AssetStore
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
from dataclasses import dataclass, field
|
|
2
|
+
from enum import Enum
|
|
3
|
+
from os.path import exists
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
from typing import Any, Dict
|
|
6
|
+
|
|
7
|
+
from ..engine.renderer import ArepyTexture
|
|
8
|
+
from ..engine.renderer.renderer_2d import Renderer2D
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class TextureFilter(Enum):
|
|
12
|
+
NEAREST = 0
|
|
13
|
+
LINEAR = 1
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@dataclass(frozen=True, slots=True)
|
|
17
|
+
class AssetStore:
|
|
18
|
+
textures: Dict[str, ArepyTexture] = field(default_factory=dict)
|
|
19
|
+
fonts: Dict[str, Any] = field(default_factory=dict)
|
|
20
|
+
|
|
21
|
+
def create_render_texture(
|
|
22
|
+
self,
|
|
23
|
+
renderer: Renderer2D,
|
|
24
|
+
name: str,
|
|
25
|
+
width: int,
|
|
26
|
+
height: int,
|
|
27
|
+
) -> ArepyTexture:
|
|
28
|
+
texture = renderer.create_render_texture(width, height)
|
|
29
|
+
self.textures[name] = texture
|
|
30
|
+
return texture
|
|
31
|
+
|
|
32
|
+
def load_texture(
|
|
33
|
+
self,
|
|
34
|
+
renderer: Renderer2D,
|
|
35
|
+
name: str,
|
|
36
|
+
path: str,
|
|
37
|
+
) -> None:
|
|
38
|
+
if not exists(path):
|
|
39
|
+
raise FileNotFoundError(f"Texture file not found: {path}")
|
|
40
|
+
|
|
41
|
+
self.textures[name] = renderer.create_texture(path=Path(path))
|
|
42
|
+
|
|
43
|
+
def load_font(self, name: str, path: str, size: int) -> None: ...
|
|
44
|
+
def get_texture(self, name: str) -> ArepyTexture:
|
|
45
|
+
return self.textures[name]
|
|
46
|
+
|
|
47
|
+
def get_font(self, name: str) -> Any:
|
|
48
|
+
return self.fonts[name]
|
|
49
|
+
|
|
50
|
+
def unload_texture(self, renderer: Renderer2D, name: str) -> None:
|
|
51
|
+
|
|
52
|
+
texture = self.textures.pop(name)
|
|
53
|
+
renderer.unload_texture(texture)
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
from typing import List
|
|
2
|
+
|
|
3
|
+
from .ecs.components import Component
|
|
4
|
+
from .ecs.registry import Entity, Registry
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class EntityBuilder:
|
|
8
|
+
"""A builder for entities.
|
|
9
|
+
|
|
10
|
+
This is a wrapped class for the entity class.
|
|
11
|
+
It allows for the creation of entities with components without having to touch the ecs registry.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
_registry: Registry
|
|
15
|
+
|
|
16
|
+
def __init__(self, entity: Entity, registry: Registry):
|
|
17
|
+
self._entity = entity
|
|
18
|
+
self._components: List[Component] = list()
|
|
19
|
+
self._registry = registry
|
|
20
|
+
|
|
21
|
+
def with_component(self, component: Component) -> "EntityBuilder":
|
|
22
|
+
"""Add a component to the entity.
|
|
23
|
+
|
|
24
|
+
Returns:
|
|
25
|
+
A component builder.
|
|
26
|
+
"""
|
|
27
|
+
if not isinstance(component, Component):
|
|
28
|
+
raise TypeError(
|
|
29
|
+
f"Component must be of type Component, not {type(component)}."
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
for _component in self._components:
|
|
33
|
+
if type(_component) == type(component):
|
|
34
|
+
raise TypeError(
|
|
35
|
+
f"Component {type(component)} already exists in entity."
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
self._components.append(component)
|
|
39
|
+
return self
|
|
40
|
+
|
|
41
|
+
def build(self) -> Entity:
|
|
42
|
+
"""Build the entity with the components, the components are built and added to the registry."""
|
|
43
|
+
for component in self._components:
|
|
44
|
+
self._registry.add_component(
|
|
45
|
+
self._entity,
|
|
46
|
+
type(component),
|
|
47
|
+
component,
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
return self._entity
|
|
File without changes
|