Skip to content

Commit

Permalink
Refactor SceneGallery class to replace dataclass with an explicit con…
Browse files Browse the repository at this point in the history
…structor and simplify locked_image property logic
  • Loading branch information
KiloOscarSix committed Jan 20, 2025
1 parent 0194ff3 commit 6f161ab
Showing 1 changed file with 13 additions and 18 deletions.
31 changes: 13 additions & 18 deletions scene_gallery/SceneGallery_ren.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from dataclasses import dataclass, field
from typing import Optional
from renpy.display.displayable import Displayable

from renpy.display.transform import Transform
Expand All @@ -10,29 +10,24 @@
"""


@dataclass
class SceneGallery:
_title: str
idle_image: str
label: str
scope: dict[str, object] = field(default_factory=dict)
def __init__(
self,
title: str,
image: str,
label: str,
scope: Optional[dict[str, object]] = None,
) -> None:
self._title: str = title
self.idle_image: "Displayable" = Transform(image, size=(362, 230), pos=(6, 16))
self.locked_image: "Displayable" = Transform(self.idle_image, blur=50)
self.label: str = label
self.scope: dict[str, object] = scope or {}

@property
def title(self) -> str:
return self._title.upper()

@property
def locked_image(self) -> "Displayable":
try:
return self._locked_image
except AttributeError:
self.locked_image = Transform(self.idle_image, blur=50)
return self._locked_image

@locked_image.setter
def locked_image(self, value: "Displayable") -> None:
self._locked_image: Displayable = value


def update_scope(new_scope: dict[str, object]) -> dict[str, object]:
rv: dict[str, object] = global_replay_scope.copy()
Expand Down

0 comments on commit 6f161ab

Please sign in to comment.