2023-08-27 01:52:45 +08:00
|
|
|
# -------------------------------
|
|
|
|
# Difficult Rocket
|
|
|
|
# Copyright © 2020-2023 by shenjackyuanjie 3695888@qq.com
|
|
|
|
# All rights reserved
|
|
|
|
# -------------------------------
|
|
|
|
|
|
|
|
from typing import Optional, Tuple, TYPE_CHECKING
|
|
|
|
|
|
|
|
from pyglet.graphics import Batch, Group
|
|
|
|
|
|
|
|
|
|
|
|
class BaseTheme(dict):
|
|
|
|
"""
|
|
|
|
Base class of themes
|
|
|
|
"""
|
2023-12-03 16:54:07 +08:00
|
|
|
|
|
|
|
theme_name = "BaseTheme"
|
2023-08-27 01:52:45 +08:00
|
|
|
|
|
|
|
def __init__(self, **kwargs):
|
|
|
|
super().__init__(**kwargs)
|
|
|
|
for k, v in kwargs.items():
|
|
|
|
if hasattr(self, k):
|
|
|
|
setattr(self, k, v)
|
|
|
|
|
|
|
|
if TYPE_CHECKING:
|
2023-12-03 16:54:07 +08:00
|
|
|
def init(self, batch: Batch, group: Group, **kwargs) -> None:
|
2023-08-27 01:52:45 +08:00
|
|
|
"""
|
|
|
|
Init theme
|
|
|
|
:param batch: batch
|
|
|
|
:param group: group
|
|
|
|
:param kwargs: options
|
|
|
|
:return: None
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
class FontTheme(BaseTheme):
|
|
|
|
"""
|
|
|
|
Base class of font themes
|
|
|
|
"""
|
2023-12-03 16:54:07 +08:00
|
|
|
|
|
|
|
theme_name = "FontTheme"
|
|
|
|
font_name: Optional[str] = "Times New Roman"
|
2023-08-27 01:52:45 +08:00
|
|
|
font_size: Optional[int] = 12
|
|
|
|
bold: Optional[bool] = False
|
|
|
|
italic: Optional[bool] = False
|
|
|
|
stretch: Optional[bool] = False
|
|
|
|
color: Optional[Tuple[int, int, int, int]] = (255, 255, 255, 255)
|
2023-12-03 16:54:07 +08:00
|
|
|
align: Optional[str] = "center"
|