Merge remote-tracking branch 'origin/main'
This commit is contained in:
commit
6331a73e3a
@ -11,16 +11,12 @@ github: @shenjackyuanjie
|
|||||||
gitee: @shenjackyuanjie
|
gitee: @shenjackyuanjie
|
||||||
"""
|
"""
|
||||||
|
|
||||||
"""
|
import dataclasses
|
||||||
存档模块
|
|
||||||
尽量同时兼容SR1和DR
|
|
||||||
包含:
|
|
||||||
解析存档文件
|
|
||||||
创建存档文件
|
|
||||||
"""
|
|
||||||
|
|
||||||
from typing import get_type_hints, Type, List, Union, Dict, Any, Callable, Tuple
|
from typing import get_type_hints, Type, List, Union, Dict, Any, Callable, Tuple
|
||||||
|
|
||||||
|
# from Difficult Rocket
|
||||||
|
from Difficult_Rocket.utils import translate
|
||||||
|
|
||||||
|
|
||||||
def get_type_hints_(cls: Type):
|
def get_type_hints_(cls: Type):
|
||||||
try:
|
try:
|
||||||
@ -110,3 +106,21 @@ class Options:
|
|||||||
cls.options: Dict[str, Union[Callable, object]] = {}
|
cls.options: Dict[str, Union[Callable, object]] = {}
|
||||||
cls.options[name] = value
|
cls.options[name] = value
|
||||||
return cls.options
|
return cls.options
|
||||||
|
|
||||||
|
|
||||||
|
@dataclasses.dataclass
|
||||||
|
class FontData:
|
||||||
|
""" 用于保存字体的信息 """
|
||||||
|
font_name: str = translate.鸿蒙简体
|
||||||
|
font_size: int = 13
|
||||||
|
bold: bool = False
|
||||||
|
italic: bool = False
|
||||||
|
stretch: bool = False
|
||||||
|
|
||||||
|
def dict(self) -> Dict[str, Union[str, int, bool]]:
|
||||||
|
return dict(font_name=self.font_name,
|
||||||
|
font_size=self.font_size,
|
||||||
|
bold=self.bold,
|
||||||
|
italic=self.italic,
|
||||||
|
stretch=self.stretch)
|
||||||
|
|
||||||
|
@ -29,6 +29,7 @@ from pyglet.text.layout import IncrementalTextLayout
|
|||||||
# from libs import pyperclip
|
# from libs import pyperclip
|
||||||
# from libs.pyperclip import paste
|
# from libs.pyperclip import paste
|
||||||
|
|
||||||
|
from Difficult_Rocket.api.types import FontData
|
||||||
from Difficult_Rocket.utils import translate
|
from Difficult_Rocket.utils import translate
|
||||||
from Difficult_Rocket.client.guis.format import html
|
from Difficult_Rocket.client.guis.format import html
|
||||||
from Difficult_Rocket import DR_option
|
from Difficult_Rocket import DR_option
|
||||||
@ -36,25 +37,6 @@ from Difficult_Rocket import DR_option
|
|||||||
__all__ = ['InputBox']
|
__all__ = ['InputBox']
|
||||||
|
|
||||||
|
|
||||||
# class Parts(widgets.WidgetBase):
|
|
||||||
# """
|
|
||||||
# parts
|
|
||||||
# """
|
|
||||||
#
|
|
||||||
# def __init__(self,
|
|
||||||
# x: int,
|
|
||||||
# y: int,
|
|
||||||
# width: int,
|
|
||||||
# height: int,
|
|
||||||
# textures: AbstractImage,
|
|
||||||
# # textures,
|
|
||||||
# batch: Batch,
|
|
||||||
# parts_data: dict):
|
|
||||||
# super().__init__(x, y, width, height)
|
|
||||||
# self.sprite = Sprite(img=textures, x=x, y=y, batch=batch)
|
|
||||||
# self._value = 0
|
|
||||||
|
|
||||||
|
|
||||||
class TextButton(widgets.WidgetBase):
|
class TextButton(widgets.WidgetBase):
|
||||||
"""
|
"""
|
||||||
自带字符的按钮,就不用单独做材质了
|
自带字符的按钮,就不用单独做材质了
|
||||||
@ -85,14 +67,13 @@ if not DR_option.InputBox_use_TextEntry:
|
|||||||
def __init__(self, x: int, y: int, width: int,
|
def __init__(self, x: int, y: int, width: int,
|
||||||
text: str,
|
text: str,
|
||||||
side_width: int = 2,
|
side_width: int = 2,
|
||||||
font_name: str = translate.鸿蒙简体,
|
font_data: Optional[FontData] = None,
|
||||||
font_size: str = 13,
|
|
||||||
color: Optional[Tuple[int, int, int, int]] = (255, 255, 255, 255),
|
color: Optional[Tuple[int, int, int, int]] = (255, 255, 255, 255),
|
||||||
text_color: Optional[Tuple[int, int, int, int]] = (0, 0, 0, 255),
|
text_color: Optional[Tuple[int, int, int, int]] = (0, 0, 0, 255),
|
||||||
caret_color: Optional[Tuple[int, int, int, int]] = (0, 0, 0),
|
caret_color: Optional[Tuple[int, int, int, int]] = (0, 0, 0),
|
||||||
batch: Optional[Batch] = None, group: Optional[Group] = None):
|
batch: Optional[Batch] = None, group: Optional[Group] = None):
|
||||||
self._doc = UnformattedDocument(text)
|
self._doc = UnformattedDocument(text)
|
||||||
self._doc.set_style(0, len(self._doc.text), dict(color=text_color, font_name=font_name))
|
self._doc.set_style(0, len(self._doc.text), {**font_data.dict(), 'text_color': text_color})
|
||||||
font = self._doc.get_font()
|
font = self._doc.get_font()
|
||||||
height = font.ascent - font.descent
|
height = font.ascent - font.descent
|
||||||
|
|
||||||
@ -113,6 +94,7 @@ if not DR_option.InputBox_use_TextEntry:
|
|||||||
self._caret.visible = False
|
self._caret.visible = False
|
||||||
|
|
||||||
self._focus = False
|
self._focus = False
|
||||||
|
super().__init__()
|
||||||
|
|
||||||
# InputBox.register_event_type('on_commit')
|
# InputBox.register_event_type('on_commit')
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user