Skip to content

Commit

Permalink
Added Tron mode
Browse files Browse the repository at this point in the history
  • Loading branch information
jinglemansweep committed Jan 25, 2024
1 parent 83270f4 commit 1cd0ea4
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 1 deletion.
Binary file added images/sprites/misc/grid_hexagon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/sprites/misc/grid_red.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/sprites/misc/grid_wobble.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions wideboy/entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,8 @@ class WidgetDucky(
@entity
class WidgetVinyl(ComFrame, ComFade, ComMotion, ComAlpha, ComVisible):
pass


@entity
class WidgetTronGrid(ComFrame, ComFade, ComMotion, ComAlpha, ComVisible):
pass
14 changes: 14 additions & 0 deletions wideboy/systems/preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,3 +156,17 @@ def tasks(self) -> Generator:
0.175,
)
yield f"Vinyl (Serato) [{r}]"
for r in range(1, 360, 2):
preprocess_mode7(
self.cache,
"mode7_tron_grid",
f"{self.app_state.config.paths.images_sprites}/misc/grid_red.png",
(
self.display_info.current_w,
self.display_info.current_h,
),
0.1,
0 - r,
0.8,
)
yield f"Tron Grid [{r}]"
10 changes: 10 additions & 0 deletions wideboy/systems/scene/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from .stages.default import StageDefault
from .stages.ducks import StageDucks
from .stages.night import StageNight
from .stages.tron import StageTron
from .stages.vinyl import StageVinyl
from .sprites import (
build_date_sprite,
Expand Down Expand Up @@ -176,6 +177,15 @@ def _handle_scene_mode_change(self) -> None:
(self.display_info.current_w, self.display_info.current_h),
)
)
# Tron Mode
if self.scene_mode == "tron":
logger.info("TRON MODE")
self._switch_stage(
StageTron(
self.entities,
(self.display_info.current_w, self.display_info.current_h),
)
)
# Vinyl Mode
elif self.scene_mode == "vinyl":
logger.info("VINYL MODE")
Expand Down
2 changes: 1 addition & 1 deletion wideboy/systems/scene/hass_entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class ModeSelect(SelectEntity):
description: str = "Mode"
initial_state: str = "default"
options: Dict[str, Any] = {
"options": ["default", "ducks", "night", "vinyl"],
"options": ["default", "ducks", "night", "tron", "vinyl"],
}

def callback(
Expand Down
48 changes: 48 additions & 0 deletions wideboy/systems/scene/stages/tron.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import logging
from ecs_pattern import EntityManager
from typing import Tuple
from ....entities import (
Cache,
WidgetClockDate,
WidgetClockTime,
WidgetTronGrid,
WidgetTileGrid,
)
from ..sprites import build_image_sprite
from . import Stage

logger = logging.getLogger(__name__)


class StageTron(Stage):
def __init__(
self,
entities: EntityManager,
display_size: Tuple[int, int],
) -> None:
super().__init__(entities)
self.display_size = display_size
self.setup()

def setup(self) -> None:
self.cache = next(self.entities.get_by_class(Cache))

self.stage_entities.extend(
[
WidgetTronGrid(
build_image_sprite(self.cache.surfaces["mode7_tron_grid"][0]),
x=0,
y=0,
z_order=5,
frames=self.cache.surfaces["mode7_tron_grid"],
frame_delay=1,
), # type: ignore[call-arg]
]
)

for w in self.entities.get_by_class(
WidgetClockDate,
WidgetClockTime,
WidgetTileGrid,
):
w.fade_target_alpha = 255

0 comments on commit 1cd0ea4

Please sign in to comment.