ecs #58
|
@ -23,12 +23,14 @@ class Text:
|
||||||
size: int = 50,
|
size: int = 50,
|
||||||
color: pygame.Color = pygame.Color(255, 255, 255),
|
color: pygame.Color = pygame.Color(255, 255, 255),
|
||||||
position: Vec2 = Vec2(0),
|
position: Vec2 = Vec2(0),
|
||||||
|
order: float = -1.0,
|
||||||
origin: Vec2 = Vec2(0),
|
origin: Vec2 = Vec2(0),
|
||||||
):
|
):
|
||||||
self.text = text
|
self.text = text
|
||||||
self.size = size
|
self.size = size
|
||||||
self.color = color
|
self.color = color
|
||||||
self.position = position
|
self.position = position
|
||||||
|
self.order = order
|
||||||
self.origin = origin
|
self.origin = origin
|
||||||
|
|
||||||
|
|
||||||
|
@ -47,6 +49,7 @@ def __render_texts(world: World):
|
||||||
else:
|
else:
|
||||||
entity[Sprite] = Sprite(texture)
|
entity[Sprite] = Sprite(texture)
|
||||||
entity[Sprite].position = text.position
|
entity[Sprite].position = text.position
|
||||||
|
entity[Sprite].order = text.order
|
||||||
entity[Sprite].origin = text.origin
|
entity[Sprite].origin = text.origin
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -25,16 +25,18 @@ def __update(world: World):
|
||||||
for entity in world.query(Writing, Text):
|
for entity in world.query(Writing, Text):
|
||||||
text = entity[Text]
|
text = entity[Text]
|
||||||
for key in pressed:
|
for key in pressed:
|
||||||
if text.text == "...":
|
|
||||||
text.text = ""
|
|
||||||
if key == "backspace":
|
if key == "backspace":
|
||||||
text.text = text.text[:-1]
|
text.text = text.text[:-1]
|
||||||
|
if text.text == "":
|
||||||
|
text.text = "..."
|
||||||
if key.startswith("["): # pavé numerique
|
if key.startswith("["): # pavé numerique
|
||||||
key = key[1]
|
key = key[1]
|
||||||
if (
|
if key in entity[Writing].accepted_chars and (
|
||||||
key in entity[Writing].accepted_chars
|
text.text == "..." or len(text.text) < entity[Writing].max_chars
|
||||||
and len(text.text) < entity[Writing].max_chars
|
|
||||||
):
|
):
|
||||||
|
if text.text == "...":
|
||||||
|
text.text = key
|
||||||
|
else:
|
||||||
text.text += key
|
text.text += key
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -122,6 +122,7 @@ def __initialize_world(world: World):
|
||||||
150,
|
150,
|
||||||
text_color,
|
text_color,
|
||||||
Vec2(render.WIDTH / 2, 450),
|
Vec2(render.WIDTH / 2, 450),
|
||||||
|
1.0,
|
||||||
Vec2(0.5),
|
Vec2(0.5),
|
||||||
),
|
),
|
||||||
Response(),
|
Response(),
|
||||||
|
@ -133,6 +134,7 @@ def __initialize_world(world: World):
|
||||||
150,
|
150,
|
||||||
text_color,
|
text_color,
|
||||||
Vec2(render.WIDTH / 2, 650),
|
Vec2(render.WIDTH / 2, 650),
|
||||||
|
1.0,
|
||||||
Vec2(0.5),
|
Vec2(0.5),
|
||||||
),
|
),
|
||||||
Writing("0123456789", 2),
|
Writing("0123456789", 2),
|
||||||
|
|
|
@ -24,6 +24,7 @@ def __create_button(world: World, assets: Assets, i: int, name: str):
|
||||||
Sprite(
|
Sprite(
|
||||||
assets.error_texture,
|
assets.error_texture,
|
||||||
Vec2(render.WIDTH / 2, 450 + 150 * i),
|
Vec2(render.WIDTH / 2, 450 + 150 * i),
|
||||||
|
1,
|
||||||
origin=Vec2(0.5),
|
origin=Vec2(0.5),
|
||||||
),
|
),
|
||||||
HoveredTexture(
|
HoveredTexture(
|
||||||
|
|
Loading…
Reference in a new issue