batframework 1.0.7__py3-none-any.whl → 1.0.8a1__py3-none-any.whl

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.
Files changed (59) hide show
  1. batFramework/__init__.py +24 -15
  2. batFramework/action.py +95 -106
  3. batFramework/actionContainer.py +11 -8
  4. batFramework/animatedSprite.py +60 -43
  5. batFramework/audioManager.py +52 -22
  6. batFramework/camera.py +87 -72
  7. batFramework/constants.py +19 -41
  8. batFramework/cutscene.py +12 -11
  9. batFramework/cutsceneBlocks.py +12 -14
  10. batFramework/dynamicEntity.py +5 -4
  11. batFramework/easingController.py +58 -0
  12. batFramework/entity.py +37 -130
  13. batFramework/enums.py +93 -3
  14. batFramework/fontManager.py +15 -7
  15. batFramework/gui/__init__.py +5 -1
  16. batFramework/gui/button.py +6 -144
  17. batFramework/gui/clickableWidget.py +206 -0
  18. batFramework/gui/constraints/__init__.py +1 -0
  19. batFramework/gui/constraints/constraints.py +378 -0
  20. batFramework/gui/container.py +147 -34
  21. batFramework/gui/debugger.py +39 -22
  22. batFramework/gui/dialogueBox.py +69 -43
  23. batFramework/gui/draggableWidget.py +38 -0
  24. batFramework/gui/image.py +33 -28
  25. batFramework/gui/indicator.py +30 -16
  26. batFramework/gui/interactiveWidget.py +72 -20
  27. batFramework/gui/label.py +240 -98
  28. batFramework/gui/layout.py +125 -53
  29. batFramework/gui/meter.py +76 -0
  30. batFramework/gui/radioButton.py +62 -0
  31. batFramework/gui/root.py +72 -48
  32. batFramework/gui/shape.py +257 -49
  33. batFramework/gui/slider.py +217 -2
  34. batFramework/gui/textInput.py +106 -60
  35. batFramework/gui/toggle.py +85 -42
  36. batFramework/gui/widget.py +259 -288
  37. batFramework/manager.py +30 -16
  38. batFramework/object.py +115 -0
  39. batFramework/{particles.py → particle.py} +37 -34
  40. batFramework/renderGroup.py +62 -0
  41. batFramework/resourceManager.py +36 -24
  42. batFramework/scene.py +94 -88
  43. batFramework/sceneManager.py +140 -57
  44. batFramework/scrollingSprite.py +113 -0
  45. batFramework/sprite.py +35 -23
  46. batFramework/tileset.py +34 -52
  47. batFramework/time.py +105 -56
  48. batFramework/transition.py +213 -1
  49. batFramework/utils.py +38 -18
  50. {batframework-1.0.7.dist-info → batframework-1.0.8a1.dist-info}/METADATA +1 -1
  51. batframework-1.0.8a1.dist-info/RECORD +56 -0
  52. {batframework-1.0.7.dist-info → batframework-1.0.8a1.dist-info}/WHEEL +1 -1
  53. batFramework/easing.py +0 -76
  54. batFramework/gui/constraints.py +0 -277
  55. batFramework/gui/frame.py +0 -25
  56. batFramework/transitionManager.py +0 -0
  57. batframework-1.0.7.dist-info/RECORD +0 -50
  58. {batframework-1.0.7.dist-info → batframework-1.0.8a1.dist-info}/LICENCE +0 -0
  59. {batframework-1.0.7.dist-info → batframework-1.0.8a1.dist-info}/top_level.txt +0 -0
batFramework/utils.py CHANGED
@@ -3,7 +3,8 @@ from enum import Enum
3
3
  import os
4
4
  import batFramework as bf
5
5
  import json
6
-
6
+ from .enums import *
7
+ import re
7
8
  class Singleton(type):
8
9
  _instances = {}
9
10
 
@@ -14,24 +15,43 @@ class Singleton(type):
14
15
 
15
16
 
16
17
  class Utils:
18
+
17
19
  @staticmethod
18
- def img_slice(file, cell_width, cell_height, flipX=False,convert_alpha=True) -> list[pygame.Surface]:
19
- src = bf.ResourceManager().get_image(file,convert_alpha=convert_alpha)
20
- if src is None : exit(1)
21
- width, height = src.get_size()
22
- res = []
23
- for y in range(0, height, cell_height):
24
- for x in range(0, width, cell_width):
25
- sub = src.subsurface((x, y, cell_width, cell_height))
26
- if flipX:
27
- sub = pygame.transform.flip(sub, True, False)
20
+ def split_surface(
21
+ surface : pygame.Surface, split_size: tuple[int, int], func=None
22
+ ) -> dict[tuple[int, int], pygame.Surface]:
23
+ """
24
+ Splits a surface into subsurfaces and returns a dictionnary of them
25
+ with their tuple coordinates as keys.
26
+ Exemple : '(0,0) : Surface'
27
+ """
28
+ if surface is None:
29
+ return None
30
+ width, height = surface.get_size()
31
+ res = {}
32
+ for iy, y in enumerate(range(0, height, split_size[1])):
33
+ for ix, x in enumerate(range(0, width, split_size[0])):
34
+ sub = surface.subsurface((x, y, split_size[0], split_size[1]))
28
35
 
29
- res.append(sub)
30
- return res
36
+ if func is not None:
37
+ sub = func(sub)
31
38
 
39
+ res[(ix, iy)] = sub
32
40
 
33
- def move_points(delta, *points):
34
- res = []
35
- for point in points:
36
- res.append((point[0] + delta[0], point[1] + delta[1]))
37
- return res
41
+ return res
42
+
43
+ @staticmethod
44
+ def filter_text(text_mode: textMode):
45
+ if text_mode == textMode.ALPHABETICAL:
46
+ pattern = re.compile(r'[^a-zA-Z]')
47
+ elif text_mode == textMode.NUMERICAL:
48
+ pattern = re.compile(r'[^0-9]')
49
+ elif text_mode == textMode.ALPHANUMERICAL:
50
+ pattern = re.compile(r'[^a-zA-Z0-9]')
51
+ else:
52
+ raise ValueError("Unsupported text mode")
53
+
54
+ def filter_function(s: str) -> str:
55
+ return pattern.sub('', s)
56
+
57
+ return filter_function
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: batframework
3
- Version: 1.0.7
3
+ Version: 1.0.8a1
4
4
  Summary: Pygame framework for making games easier.
5
5
  Author-email: Turan Baturay <baturayturan@gmail.com>
6
6
  Project-URL: Homepage, https://github.com/TuranBaturay/batFramework
@@ -0,0 +1,56 @@
1
+ batFramework/__init__.py,sha256=5KS96Y0uDx8sue3NyDl2HTFh-CqEZc9otmnUXRCHXws,2189
2
+ batFramework/action.py,sha256=vVr4LjlIHnA6I1_OM6IXM8DGCeruDcdHLIU9pfrQy3Q,7950
3
+ batFramework/actionContainer.py,sha256=TVmfyBYILCkAKUnNsCIIaCXezffNZ_VK5H207ab1r3I,2587
4
+ batFramework/animatedSprite.py,sha256=1KmhUCX8q2JTyOr0ClLovJ21i6c2SkllTtqygmDSZvo,5168
5
+ batFramework/audioManager.py,sha256=BxSWDYqYy3IgNA9sBaJFspdjcUJWudBSV0OpCNR92Is,3886
6
+ batFramework/camera.py,sha256=ZgASlCwXGDU8-hljAz5WlVU3v4XPQ5mU0--kaOsRun0,9331
7
+ batFramework/constants.py,sha256=5PyZQZ4fCcLA8k_Upby9KGVF-3pnV2ZZ6t26CxiocPM,1102
8
+ batFramework/cutscene.py,sha256=WX2yXawR3NjL8db09SsRXtJtdJU_xlcHYtntRcJhtKs,3896
9
+ batFramework/cutsceneBlocks.py,sha256=Uezggx1XgmLvXW1GnuVkGj3tOM8AOxXYx1F9nFGvL-w,4788
10
+ batFramework/dynamicEntity.py,sha256=zp5ShM6fQ-a_hXTHA6UthbInfJl2XazsN6C2hll9nK8,665
11
+ batFramework/easingController.py,sha256=4N8GIp1fsaWBUlDxXx3SMwOq1Mrhn10MZZIO51_CRnk,1677
12
+ batFramework/entity.py,sha256=L3koW9q35Dpwsz9h9YWMuGal4PkowqsWklKZpZj7hM8,2003
13
+ batFramework/enums.py,sha256=lywBwvxsUTOXUhHCoau5P9LC9UNIx_E6hjvx3Zba-iw,2069
14
+ batFramework/fontManager.py,sha256=_pVcTmf1c42HPHfWZwvkEsAY46MljsTYFvl6h4f7Q8E,2240
15
+ batFramework/manager.py,sha256=YRKKv5qWVUs7D8ZqP8ZkfUeTCc3lHxfCfJSYdO5Ep8A,2375
16
+ batFramework/object.py,sha256=ErR1XxqIlI5jv_kZnDrt3jkyRZSba3aVGuMBNwExIq0,3045
17
+ batFramework/particle.py,sha256=yGGKjGtwzL-m48akGNsReLM82IPV1DzrsDy5SN_kMAw,2672
18
+ batFramework/renderGroup.py,sha256=DZCtO6cRO4qkIcVACexvitIcAaPdW6PZFhQX7XYUIeo,1979
19
+ batFramework/resourceManager.py,sha256=8ysiVDMVRKOGo_kNRH2BiqiUj07kddgi04iNcTt9T-Q,3094
20
+ batFramework/scene.py,sha256=66Xoy-7mq6WuFzAiJXicspbo0xH_ZbL_idYZuyV8wL4,10543
21
+ batFramework/sceneManager.py,sha256=hTqn_RCken49oDg21ZVybk0wwgmw693CgSiAB_4Oj9E,7053
22
+ batFramework/scrollingSprite.py,sha256=vNPWJV6QOf-wbuAgv-eLv1kiaOZiXt_2pqt6EEfg2Vk,4159
23
+ batFramework/sprite.py,sha256=nSfdhn6oH6Zm2y9XyzBR1vPlHrPiyLIqBds9sxy0jVA,1543
24
+ batFramework/stateMachine.py,sha256=er7WB7I4V81jgUrd-9ftfyYczKpPsEbgdWRXzYl6e9k,1339
25
+ batFramework/tileset.py,sha256=Iu32btkBs0_kkQjN5FKX76WmRnEIQGDY4OfoaOtGelc,1704
26
+ batFramework/time.py,sha256=IGRIY_g9kpdJxR5wt1lOnLsY9gMReuBJZqnpWRyR-CQ,3963
27
+ batFramework/transition.py,sha256=ioxT5KQQmgSY5yPXDV1CEAj6J_62D6YVU5NUk_Fude0,6442
28
+ batFramework/triggerZone.py,sha256=ikOOlJT1KIND0MO2xiilCHuKlb1eQhkCMEhZTi1btsI,586
29
+ batFramework/utils.py,sha256=GZMWNhkOcCuvmfTHVAbrXttU9LrwEdCp-kKM-2t2L08,1718
30
+ batFramework/gui/__init__.py,sha256=__IMtrybY8qFKvvv9lEEra2wLzfbDrDPyJucnc8q4zo,622
31
+ batFramework/gui/button.py,sha256=W5mKG-41F3J6hjrqhoTIRXyWPMk7hxFWK_g_XgjFfdU,354
32
+ batFramework/gui/clickableWidget.py,sha256=pG2UAGYATDH6ugEexiCL_XYstCaCVcNm4nwGwLk0QpU,6810
33
+ batFramework/gui/container.py,sha256=k3ExxMiJzhzdCVzhdvupJhB7LiALt5HbCUjlSFdeNVM,5315
34
+ batFramework/gui/debugger.py,sha256=1_QlUF1YRQqNSyM3UtLkYzjOL5iXkwg4PD3tVYF4--Q,3921
35
+ batFramework/gui/dialogueBox.py,sha256=8nHGlhznO2WL8pQilH0lzlAIMpnKGRSCaYPJrsoj1xk,3172
36
+ batFramework/gui/draggableWidget.py,sha256=iAZ1gGELOG5dmuA01SW8qw-hE4VdYQGQfDpuPqrood0,1358
37
+ batFramework/gui/image.py,sha256=fSyRaJH1D_yCohk-b7ZWl_eZ1o8uULjDQG1gCk3fofc,1513
38
+ batFramework/gui/indicator.py,sha256=Q_vbkHbTODwrk0WUytygnuHdXdqlORKBEfh_4DjRT4o,1561
39
+ batFramework/gui/interactiveWidget.py,sha256=-X9aCFOtwG7EdOdooH6QzcxiZGavyCIhavZoijLxJBU,3317
40
+ batFramework/gui/label.py,sha256=0NqzBQ_lBWnBgMuiFa4jnGEpWt6v8WllKC5N5EC34EA,10525
41
+ batFramework/gui/layout.py,sha256=mcYbXbQQmOqjGVWSb6PXAaPBBkYcod5B4fCl4aYIhoc,6201
42
+ batFramework/gui/meter.py,sha256=F8xVvFopIoqCQn0Qyj1LgSCAEupXdWOzZtcsIZ74UuY,2321
43
+ batFramework/gui/radioButton.py,sha256=ORfV242Iadn86y2uKzSFOhOWZIpnT2_Idn6ACGF8vcA,1976
44
+ batFramework/gui/root.py,sha256=_WtCwY3J51MdUDEVZc-grGJflDH959uApxVxiiSU8MM,4122
45
+ batFramework/gui/shape.py,sha256=54rFVur9xXc0v_0r3JNc9XAJJ92U0N0Ei3YBYFeCFkU,9702
46
+ batFramework/gui/slider.py,sha256=g0hfzxunLV5W-R39DT08__72pq1hzZSdKwaRDx1-Rmg,8199
47
+ batFramework/gui/textInput.py,sha256=SWJMvhtqKhGEDL2xlvfNehaz4DhHnJGUQ7FBp7jheTI,4569
48
+ batFramework/gui/toggle.py,sha256=UVBdRixgJwo4FsgWCitrIDrtc9ECa4u_ulPAqjHSGeo,4251
49
+ batFramework/gui/widget.py,sha256=9LYsSHy8FhzKyikDZG84cQdW9LMctaBIRDMXinZ9eWQ,11154
50
+ batFramework/gui/constraints/__init__.py,sha256=qqXE8nnSrEvCSeHdqY8UYPZLetqdubFPI7IdZuh35QE,26
51
+ batFramework/gui/constraints/constraints.py,sha256=TShcFnelbmNKWAJnpxAbLyKC6qMllo54fWjQPUbbvIs,13756
52
+ batframework-1.0.8a1.dist-info/LICENCE,sha256=A65iXbMDbOxQLDNOODJLqA7o5RxszYlEqIgNSzBQRf4,1073
53
+ batframework-1.0.8a1.dist-info/METADATA,sha256=yavYY6taCina5Brp4PEQVHp8k4tRu_WrDw5Cb-n1oAo,2501
54
+ batframework-1.0.8a1.dist-info/WHEEL,sha256=cpQTJ5IWu9CdaPViMhC9YzF8gZuS5-vlfoFihTBC86A,91
55
+ batframework-1.0.8a1.dist-info/top_level.txt,sha256=vxAKBIk1oparFTxeXGBrgfIO7iq_YR5Fv1JvPVAIwmA,13
56
+ batframework-1.0.8a1.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.42.0)
2
+ Generator: setuptools (70.1.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
batFramework/easing.py DELETED
@@ -1,76 +0,0 @@
1
- from enum import Enum
2
- import pygame
3
- import batFramework as bf
4
-
5
-
6
- class Easing(Enum):
7
- EASE_IN = (0.12, 0, 0.39, 0)
8
- EASE_OUT = (0.61, 1, 0.88, 1)
9
- EASE_IN_OUT = (0.37, 0, 0.63, 1)
10
- EASE_IN_OUT_ELASTIC = (0.7, -0.5, 0.3, 1.5)
11
- LINEAR = (1, 1, 0, 0)
12
- # Add more easing functions as needed
13
-
14
- def __init__(self, *control_points):
15
- self.control_points = control_points
16
-
17
-
18
- class EasingAnimation(bf.Timer):
19
- _cache = {}
20
-
21
- def __init__(
22
- self,
23
- name: str = '',
24
- easing_function: Easing = Easing.LINEAR,
25
- duration: int = 100,
26
- update_callback=None,
27
- end_callback=None,
28
- loop: bool = False,
29
- reusable: bool = False,
30
- )->None:
31
- self.easing_function = easing_function
32
- self.update_callback = update_callback
33
- self.value = 0.0
34
- super().__init__(name, duration, loop, end_callback, reusable)
35
-
36
- def get_value(self):
37
- return self.value
38
-
39
- def start(self):
40
- self.value = 0
41
- super().start() # self.elapsed_progress set to 0 here
42
-
43
- def update(self,dt) -> bool:
44
- if super().update(dt):
45
- return True # If timer ended now, end() is called. So don't process value.
46
- self._process_value()
47
- # if self.name == 0: print("UPDATING (callback) in easing")
48
- if self.update_callback:
49
- self.update_callback(self.value)
50
- return False
51
-
52
- def end(self):
53
- # Call update 1 last time with the last value
54
-
55
- self.elapsed_progress = 1
56
- self._process_value()
57
- if self.update_callback:
58
- self.update_callback(self.value)
59
- self.value = 0
60
- super().end() # sets elapsed_progress to 0
61
-
62
- def _process_value(self):
63
- p0, p1, p2, p3 = self.easing_function.control_points
64
- cache_key = (self.easing_function,self.elapsed_progress, p0, p1, p2, p3)
65
- if cache_key in EasingAnimation._cache:
66
- y = EasingAnimation._cache[cache_key]
67
- else:
68
- t = self.elapsed_progress
69
- t_inv = 1.0 - t
70
- t2 = t * t
71
- t3 = t * t2
72
- t_inv2 = t_inv * t_inv
73
-
74
- y = 3 * t_inv2 * t * p1 + 3 * t_inv * t2 * p3 + t3
75
- EasingAnimation._cache[cache_key] = y
76
- self.value = y
@@ -1,277 +0,0 @@
1
- from .widget import Widget
2
- import batFramework as bf
3
-
4
- class Constraint:
5
- def __init__(self, name="Constraint", priority=0):
6
- self.priority = priority
7
- self.name = name
8
-
9
- def set_priority(self, priority) -> "Constraint":
10
- self.priority = priority
11
- return self
12
-
13
- def to_string(self) -> str:
14
- return f"{self.name.upper()}"
15
-
16
- def evaluate(self, parent_widget: Widget, child_widget: Widget) -> bool:
17
- raise NotImplementedError("Subclasses must implement evaluate method")
18
-
19
- def apply(self, parent_widget: Widget, child_widget: Widget = None) -> bool:
20
- if not self.evaluate(parent_widget, child_widget):
21
- self.apply_constraint(parent_widget, child_widget)
22
- return False
23
- return True
24
-
25
- def apply_constraint(self, parent_widget: Widget, child_widget: Widget):
26
- raise NotImplementedError("Subclasses must implement apply_constraint method")
27
-
28
- class ConstraintMinWidth(Constraint):
29
- def __init__(self, width):
30
- super().__init__(name="min_width")
31
- self.min_width = width
32
-
33
- def evaluate(self, parent_widget, child_widget):
34
- return child_widget.rect.width >= self.min_width
35
-
36
- def apply_constraint(self, parent_widget, child_widget):
37
- if not self.evaluate(parent_widget, child_widget):
38
- child_widget.set_size(self.min_width, child_widget.rect.h)
39
-
40
-
41
- class ConstraintCenterX(Constraint):
42
- def __init__(self):
43
- super().__init__(name="centerx")
44
-
45
- def evaluate(self, parent_widget, child_widget):
46
- return child_widget.rect.centerx == parent_widget.get_content_center()[0]
47
-
48
- def apply_constraint(self, parent_widget, child_widget):
49
- if not self.evaluate(parent_widget, child_widget):
50
- child_widget.set_center(
51
- parent_widget.get_content_center()[0], child_widget.rect.centery
52
- )
53
-
54
-
55
- class ConstraintCenterY(Constraint):
56
- def __init__(self):
57
- super().__init__(name="centery")
58
-
59
- def evaluate(self, parent_widget, child_widget):
60
- return child_widget.rect.centery == parent_widget.get_content_center()[1]
61
-
62
- def apply_constraint(self, parent_widget, child_widget):
63
- if not self.evaluate(parent_widget, child_widget):
64
- child_widget.set_center(
65
- child_widget.rect.centerx, parent_widget.get_content_center()[1]
66
- )
67
-
68
-
69
- class ConstraintCenter(Constraint):
70
- def __init__(self):
71
- super().__init__(name="center")
72
-
73
- def evaluate(self, parent_widget, child_widget):
74
- return child_widget.rect.center == parent_widget.get_content_center()
75
-
76
- def apply_constraint(self, parent_widget, child_widget):
77
- if not self.evaluate(parent_widget, child_widget):
78
- child_widget.set_center(*parent_widget.get_content_center())
79
-
80
-
81
- class ConstraintPercentageWidth(Constraint):
82
- def __init__(self, percentage: float, keep_autoresize: bool = True):
83
- super().__init__(name="percentage_width")
84
- self.percentage: float = percentage
85
- self.keep_autoresize: bool = keep_autoresize
86
-
87
- def to_string(self) -> str:
88
- return f"{super().to_string()}.[{self.percentage*100}%,keep_autoresize={self.keep_autoresize}]"
89
-
90
- def evaluate(self, parent_widget, child_widget):
91
- return child_widget.rect.width == round(
92
- parent_widget.get_content_width() * self.percentage
93
- )
94
-
95
- def apply_constraint(self, parent_widget, child_widget):
96
- if not self.evaluate(parent_widget, child_widget):
97
- if child_widget.autoresize:
98
- if self.keep_autoresize:
99
- print(
100
- f"Warning: Constraint on {child_widget.to_string()} can't resize, autoresize set to True"
101
- )
102
- return
103
- child_widget.set_autoresize(False)
104
- child_widget.set_size(
105
- round(parent_widget.get_content_width() * self.percentage),
106
- child_widget.rect.h,
107
- )
108
-
109
-
110
- class ConstraintPercentageHeight(Constraint):
111
- def __init__(self, percentage: float, keep_autoresize: bool = True):
112
- super().__init__(name="percentage_height")
113
- self.percentage: float = percentage
114
- self.keep_autoresize: bool = keep_autoresize
115
-
116
- def evaluate(self, parent_widget, child_widget):
117
- return child_widget.rect.height == round(
118
- parent_widget.get_content_height() * self.percentage
119
- )
120
-
121
- def to_string(self) -> str:
122
- return f"{super().to_string()}.[{self.percentage*100}%,keep_autoresize={self.keep_autoresize}]"
123
-
124
- def apply_constraint(self, parent_widget, child_widget):
125
- if not self.evaluate(parent_widget, child_widget):
126
- if child_widget.autoresize:
127
- if self.keep_autoresize:
128
- print(
129
- f"Warning: Constraint on {child_widget.to_string()} can't resize, autoresize set to True"
130
- )
131
- return
132
- child_widget.set_autoresize(False)
133
- child_widget.set_size(
134
- child_widget.rect.w,
135
- round(parent_widget.get_content_height() * self.percentage),
136
- )
137
-
138
-
139
- class ConstraintHeight(Constraint):
140
- def __init__(self, height: float, keep_autoresize: bool = True):
141
- if height < 0:
142
- raise ValueError("height can't be negative")
143
- super().__init__(name="height")
144
- self.height = height
145
- self.keep_autoresize:bool = keep_autoresize
146
-
147
- def to_string(self) -> str:
148
- return f"{super().to_string()}.(height={self.height})"
149
-
150
- def evaluate(self, parent_widget, child_widget):
151
- return child_widget.rect.height == self.height
152
-
153
- def apply_constraint(self, parent_widget, child_widget):
154
- if not self.evaluate(parent_widget, child_widget):
155
- if child_widget.autoresize:
156
- if self.keep_autoresize:
157
- print(
158
- f"Warning: Constraint on {child_widget.to_string()} can't resize, autoresize set to True"
159
- )
160
- return
161
- child_widget.set_autoresize(False)
162
- child_widget.set_size(child_widget.rect.w, self.height)
163
-
164
-
165
- class ConstraintWidth(Constraint):
166
- def __init__(self, width: float, keep_autoresize: bool = True):
167
- if width < 0:
168
- raise ValueError("width can't be negative")
169
- super().__init__(name="width")
170
- self.width = width
171
- self.keep_autoresize : bool = keep_autoresize
172
-
173
- def to_string(self) -> str:
174
- return f"{super().to_string()}.(width={self.width})"
175
-
176
- def evaluate(self, parent_widget, child_widget):
177
- return child_widget.rect.width == self.width
178
-
179
- def apply_constraint(self, parent_widget, child_widget):
180
- if not self.evaluate(parent_widget, child_widget):
181
- if child_widget.autoresize:
182
- if self.keep_autoresize:
183
- print(
184
- f"Warning: Constraint on {child_widget.to_string()} can't resize, autoresize set to True"
185
- )
186
- return
187
- child_widget.set_autoresize(False)
188
- child_widget.set_size(self.width, child_widget.rect.h)
189
-
190
-
191
- class ConstraintAspectRatio(Constraint):
192
- def __init__(self, ratio: int | float = 1):
193
- super().__init__(name="aspect_ratio")
194
- if isinstance(ratio, float | int):
195
- self.ratio = ratio
196
- elif isinstance(ratio, Widget):
197
- self.ratio = ratio.rect.w / ratio.rect.h
198
- else:
199
- raise TypeError(f"Ratio must be float or Widget")
200
-
201
- def evaluate(self, parent_widget, child_widget):
202
- return self.ratio == child_widget.rect.w / child_widget.rect.h
203
-
204
- def apply_constraint(self, parent_widget, child_widget):
205
- if not self.evaluate(parent_widget, child_widget):
206
- return # TODO
207
-
208
-
209
- class ConstraintAnchorBottom(Constraint):
210
- def __init__(self):
211
- super().__init__(name="anchor_bottom")
212
-
213
- def evaluate(self, parent_widget, child_widget):
214
- return child_widget.rect.bottom == parent_widget.get_content_bottom()
215
-
216
- def apply_constraint(self, parent_widget, child_widget):
217
- if not self.evaluate(parent_widget, child_widget):
218
- child_widget.set_y(parent_widget.get_content_bottom() - child_widget.rect.h)
219
-
220
-
221
- class ConstraintAnchorTopRight(Constraint):
222
- def __init__(self):
223
- super().__init__(name="anchor_topright")
224
-
225
- def evaluate(self, parent_widget, child_widget):
226
- return child_widget.rect.topright == parent_widget.get_content_rect().topright
227
-
228
- def apply_constraint(self, parent_widget, child_widget):
229
- if not self.evaluate(parent_widget, child_widget):
230
- child_widget.set_position(
231
- parent_widget.get_content_right() - child_widget.rect.w,
232
- parent_widget.get_content_top(),
233
- )
234
-
235
- class ConstraintAnchorBottomRight(Constraint):
236
- def __init__(self):
237
- super().__init__(name="anchor_bottomright")
238
-
239
- def evaluate(self, parent_widget, child_widget):
240
- return child_widget.rect.bottomright == parent_widget.get_content_rect().bottomright
241
-
242
- def apply_constraint(self, parent_widget, child_widget):
243
- if not self.evaluate(parent_widget, child_widget):
244
- child_widget.set_position(
245
- parent_widget.get_content_right() - child_widget.rect.w,
246
- parent_widget.get_content_bottom() - child_widget.rect.h,
247
- )
248
-
249
-
250
-
251
- class ConstraintAnchorRight(Constraint):
252
- def __init__(self):
253
- super().__init__(name="anchor_right")
254
-
255
- def evaluate(self, parent_widget, child_widget):
256
- return child_widget.rect.right == parent_widget.get_content_right()
257
-
258
- def apply_constraint(self, parent_widget, child_widget):
259
- if not self.evaluate(parent_widget, child_widget):
260
- child_widget.set_position(
261
- parent_widget.get_content_right() - child_widget.rect.w,
262
- child_widget.rect.top,
263
- )
264
-
265
-
266
- class ConstraintAnchorLeft(Constraint):
267
- def __init__(self):
268
- super().__init__(name="anchor_left")
269
-
270
- def evaluate(self, parent_widget, child_widget):
271
- return child_widget.rect.left == parent_widget.get_content_left()
272
-
273
- def apply_constraint(self, parent_widget, child_widget):
274
- if not self.evaluate(parent_widget, child_widget):
275
- child_widget.set_position(
276
- parent_widget.get_content_left(), child_widget.rect.top
277
- )
batFramework/gui/frame.py DELETED
@@ -1,25 +0,0 @@
1
- import batFramework as bf
2
- from .shape import Shape
3
- import pygame
4
-
5
-
6
- class Frame(Shape):
7
- def __init__(self, width: float, height: float,fit_to_children:bool=True):
8
- self.fit_to_children = fit_to_children
9
- super().__init__(width, height)
10
- self.set_debug_color("magenta")
11
- def to_string_id(self) -> str:
12
- return "Frame"
13
-
14
- def _fit_to_children(self)->None:
15
- # TODO CLEAN THIS UP
16
- if not self.children: return
17
- children_rect = self.children[0].rect.unionall(list(c.rect for c in self.children))
18
- self.set_size(*self.inflate_rect_by_padding(children_rect).size)
19
- self.rect.center = children_rect.center
20
- self.apply_all_constraints()
21
-
22
- def children_modified(self) -> None:
23
- super().children_modified()
24
- if self.fit_to_children:
25
- self._fit_to_children()
File without changes
@@ -1,50 +0,0 @@
1
- batFramework/__init__.py,sha256=YaelCDRz3Ngj9ftajpfwXOJKEr4yOIiF56xt9XSJoo4,2111
2
- batFramework/action.py,sha256=6XQ3sBylO00UYrGfh5GKjwP9PqgtixIV0um4uwiFj4w,8364
3
- batFramework/actionContainer.py,sha256=DMWDWZ9mff70VErtunX7yOfiqOxBuGNGfO9b1YXW1CI,2498
4
- batFramework/animatedSprite.py,sha256=vrwpBaE17S-ye7v2iR9X5s0LPuAJlwGc9rs8ykQXdTk,4944
5
- batFramework/audioManager.py,sha256=yR1_dt5Q17DV6xAHwZ55j67cEz8x8vSev1xRyFD5w6s,3067
6
- batFramework/camera.py,sha256=CnjCoIm4m7rmzlskF0ZjCxMtu3wV_mdaYy8LO6Jw5Ug,8846
7
- batFramework/constants.py,sha256=VbUoeyG00Coz5BxiWrTsO6d0G96Y6Q5CU24E3z5wRR0,1426
8
- batFramework/cutscene.py,sha256=-cDTTCuQhbHBnnxbDK3O99Sqvw5z3vIKWfA3Q-iYJX4,3882
9
- batFramework/cutsceneBlocks.py,sha256=w4VWJXuhtohT0nXDXiJelKKG9EebfQvjisLEgYq2VJY,4889
10
- batFramework/dynamicEntity.py,sha256=O4Bp39BjYUpQBscNqqKuyt2dTTnFK_8f8R0ZIqsdHu8,688
11
- batFramework/easing.py,sha256=M5YjDot_l6DVdotKAbShIQlfotrs_WLpnLqQgQdAfa8,2269
12
- batFramework/entity.py,sha256=iuWIFoWW5fVByGiY7AUQ-qVymxJLldJMXIKeD4CF4_M,4200
13
- batFramework/enums.py,sha256=b7d4TuEyG6WGoXn0ABrmc6VsrwKrkJ2bCrMXtz37DB0,226
14
- batFramework/fontManager.py,sha256=zqevsjZR37EalyHIiaGvnppQfWdCSEWbKLT4da0gYaQ,2136
15
- batFramework/manager.py,sha256=5TLo-LSX3kiERYsoibaAAZMIKzcqXZu3hY9Yul0GGNk,1952
16
- batFramework/particles.py,sha256=pdH9LFfOyDE59DpwHj6KWOj063NfeolzInq2Rj0fctI,2592
17
- batFramework/resourceManager.py,sha256=wU68ZIftef9B7PruK9IkkSGaiHmPeoX5YrZYGy3LNlg,2580
18
- batFramework/scene.py,sha256=sVmribXn0nwvPiq-yH-3qXfvrNELhoFHEyc3nhLNck0,10739
19
- batFramework/sceneManager.py,sha256=nL69hrYv24HeoLig_bgdj1-RnWWcgnwyA5_Z5Sa07d0,4109
20
- batFramework/sprite.py,sha256=xdHsRfxAb0aF7gCNsyzGq6y4vC2tZYtyQiJEqbOgrzM,1154
21
- batFramework/stateMachine.py,sha256=er7WB7I4V81jgUrd-9ftfyYczKpPsEbgdWRXzYl6e9k,1339
22
- batFramework/tileset.py,sha256=d4lmfgJwgUxhU3odVRtyQxQ84N600lpAMMjYp8Cvyf4,2523
23
- batFramework/time.py,sha256=Wlss4ZzWOB2LU-3IRZLsPuDN_SJ8YOatk0OEwdXQlhA,2516
24
- batFramework/transition.py,sha256=crWQ4taWvOnNlQzzWOH9NA4ytBkoaSZI2rNIb9rne-8,41
25
- batFramework/transitionManager.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
26
- batFramework/triggerZone.py,sha256=ikOOlJT1KIND0MO2xiilCHuKlb1eQhkCMEhZTi1btsI,586
27
- batFramework/utils.py,sha256=Ud7qoB_dvhnx7oviZ_RamlFpsuOXqYL2gkcB67SYDRo,1094
28
- batFramework/gui/__init__.py,sha256=8HGFEVlCrJh8MphfAnL79k_uLJzgVdFagQCAuWkXZGM,454
29
- batFramework/gui/button.py,sha256=OSH9l_l4LfvFIICdZGMRYA3-n3hZA_nqfqAbMgoMwW4,4490
30
- batFramework/gui/constraints.py,sha256=gZN61hYirs1yzvuunszxaiioBwzpSmwRP-EDExZCP3A,10492
31
- batFramework/gui/container.py,sha256=qG8Db7H9P4HHRELHtS_bnBTsTh89BWs8PnIqEGBO0D4,1755
32
- batFramework/gui/debugger.py,sha256=CIPrQdYDX0Y6hAdnkcRLengGD5vkitgilygXcHu2xFw,3385
33
- batFramework/gui/dialogueBox.py,sha256=ME9dJK2BbKAH39xpz7VApRuKw6na3u0JuIvqLHwDS5I,2368
34
- batFramework/gui/frame.py,sha256=kY2Jmt1YpYTg4Aa28qmLQaI59BQ-_nq0FOB7Lf2e_hM,861
35
- batFramework/gui/image.py,sha256=S71a11FI_gkopXwXb9kRuSLJ-qEI4AJoiJY53ZXIprg,1341
36
- batFramework/gui/indicator.py,sha256=awVhrY1holODuAnChfU1_m6Lp7aLGspSTFdHUnVZo2I,1128
37
- batFramework/gui/interactiveWidget.py,sha256=i_uwmQmJGUFhpLz17wh-GVOJNvU9_zw3e2ZlsnnE4CA,1661
38
- batFramework/gui/label.py,sha256=oxLNmgZCV0-Y-Ne6Azp6u0wkUC-Nj6_grj2MXDwr04k,5666
39
- batFramework/gui/layout.py,sha256=w1BypRnYzwA4dtcFK4NtUirVnYoBUJsxApliHCXzQmk,3290
40
- batFramework/gui/root.py,sha256=7zIE46mNDfVwLJXsFKm6d99bucTC0hBrSEreJsA7vps,3276
41
- batFramework/gui/shape.py,sha256=sEuaRjpCRQHj_GomqWtXlHQMyCDw3ZuZsJ6-bAkqJPY,2459
42
- batFramework/gui/slider.py,sha256=8rLHN-4yxavrOsTQi79SguCAR9Er8qCmkWKjUdMnPYg,62
43
- batFramework/gui/textInput.py,sha256=bQGFn0xO7wXibW8Gl0aQTFQbmx90X-l61eCYsgZeGYk,3274
44
- batFramework/gui/toggle.py,sha256=8UZHIK7176jP3choAboUReu8x3br2ilOqnnKrkF2Ul0,2259
45
- batFramework/gui/widget.py,sha256=NMr9T6vL4aACQ0VNOJMd2YV7SoIQbOOUzzSyY6TEC_4,11961
46
- batframework-1.0.7.dist-info/LICENCE,sha256=A65iXbMDbOxQLDNOODJLqA7o5RxszYlEqIgNSzBQRf4,1073
47
- batframework-1.0.7.dist-info/METADATA,sha256=F0WSu0itPcqPIJPem0BWonVmJ10M9wbnPOHwEvOhJjk,2499
48
- batframework-1.0.7.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
49
- batframework-1.0.7.dist-info/top_level.txt,sha256=vxAKBIk1oparFTxeXGBrgfIO7iq_YR5Fv1JvPVAIwmA,13
50
- batframework-1.0.7.dist-info/RECORD,,