Skip to content

Commit

Permalink
remove Optional hint of ChartMeta.difficulty
Browse files Browse the repository at this point in the history
  • Loading branch information
zhanbao2000 committed Apr 13, 2023
1 parent 48e195d commit 26baad2
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion model.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class ChartMeta(BaseModel):
id: int # song_id or post_id
title: str
level: int
difficulty: Optional[DifficultyInt]
difficulty: DifficultyInt
release: datetime.datetime
is_official: bool
artist: Optional[str] = None # band or singer
Expand Down
5 changes: 2 additions & 3 deletions render.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ def _post_processing_background(self):
draw = ImageDraw.Draw(bg_layer)
draw.rectangle(
((0, self.im.height + 2 * margin), (bg.width, bg.height)),
self.theme.meta_difficulty_color[self._meta.difficulty or 3] # default to Expert
self.theme.meta_difficulty_color[self._meta.difficulty]
)

bg.alpha_composite(bg_layer, (0, 0))
Expand Down Expand Up @@ -444,8 +444,7 @@ def _post_processing_song_meta(self):
draw.text((width_second_key_column, height_first_line),
'Level', self.theme.meta_text_color, font=font)
draw.text((width_second_value_column, height_first_line),
f'[{self._meta.difficulty.name}] {self._meta.level}' if self._meta.is_official else f'[Fan-Made] {self._meta.level}',
self.theme.meta_text_color, font=font)
f'[{self._meta.difficulty.name}] {self._meta.level}', self.theme.meta_text_color, font=font)
draw.text((width_second_key_column, height_first_line + line_spacing * 1),
'BPM', self.theme.meta_text_color, font=font)
draw.text((width_second_value_column, height_first_line + line_spacing * 1),
Expand Down
1 change: 1 addition & 0 deletions resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ def generate_song_meta_user_post(post: UserPost.Post, post_id: int) -> ChartMeta
id=post_id,
title=post.title,
level=post.level,
difficulty=DifficultyInt(post.diff),
release=post.time,
is_official=False,
artist=post.artists,
Expand Down

0 comments on commit 26baad2

Please sign in to comment.