Skip to content

Commit

Permalink
Added Mode7 stage for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
jinglemansweep committed Jan 25, 2024
1 parent 5d49128 commit 624f62f
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 17 deletions.
8 changes: 5 additions & 3 deletions wideboy/systems/preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import random
import time
from ecs_pattern import EntityManager, System
from pygame.display import Info as DisplayInfo
from functools import partial
from typing import Callable, List, Tuple
from ..entities import AppState, Cache, WidgetSysMessage
Expand Down Expand Up @@ -82,6 +83,7 @@ class SysPreprocess(System):

def __init__(self, entities: EntityManager) -> None:
self.entities = entities
self.display_info = DisplayInfo()

def start(self) -> None:
logger.info("Preprocessing system starting...")
Expand Down Expand Up @@ -123,10 +125,10 @@ def start(self) -> None:
self.cache,
"mode7_vinyl",
f"{self.app_state.config.paths.images_sprites}/misc/vinyl.png",
(380, 64),
0.2,
(self.display_info.current_w, self.display_info.current_h),
0.15,
0 - r,
0.4,
0.8,
),
),
)
Expand Down
10 changes: 6 additions & 4 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.seven import StageSeven
from .sprites import (
build_date_sprite,
build_time_sprite,
Expand Down Expand Up @@ -174,11 +175,12 @@ def _handle_scene_mode_change(self) -> None:
self.entities,
(self.display_info.current_w, self.display_info.current_h),
)
) # Night Mode
elif self.scene_mode == "night":
logger.info("NIGHT MODE")
)
# Seven Mode
elif self.scene_mode == "seven":
logger.info("SEVEN MODE")
self._switch_stage(
StageNight(
StageSeven(
self.entities,
(self.display_info.current_w, self.display_info.current_h),
)
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"],
"options": ["default", "ducks", "night", "seven"],
}

def callback(
Expand Down
9 changes: 0 additions & 9 deletions wideboy/systems/scene/stages/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
WidgetClockTime,
WidgetDucky,
WidgetSlideshow,
WidgetSpinner,
WidgetTileGrid,
)
from ....sprites.graphics import load_image
Expand Down Expand Up @@ -74,14 +73,6 @@ def setup(self) -> None:
frames=self.cache.surfaces["duck_animated"],
frame_delay=4,
), # type: ignore[call-arg]
WidgetSpinner(
build_image_sprite(self.cache.surfaces["mode7_vinyl"][0]),
x=0,
y=0,
z_order=5,
frames=self.cache.surfaces["mode7_vinyl"],
frame_delay=1,
), # type: ignore[call-arg]
]
)

Expand Down
48 changes: 48 additions & 0 deletions wideboy/systems/scene/stages/seven.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,
WidgetSpinner,
WidgetTileGrid,
)
from ..sprites import build_image_sprite
from . import Stage

logger = logging.getLogger(__name__)


class StageSeven(Stage):
image_count: int

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.append(
WidgetSpinner(
build_image_sprite(self.cache.surfaces["mode7_vinyl"][0]),
x=0,
y=8,
z_order=5,
frames=self.cache.surfaces["mode7_vinyl"],
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 624f62f

Please sign in to comment.