feat: change colors

This commit is contained in:
shenjack 2022-12-08 09:53:22 +08:00
parent e1840220f6
commit fc74a41d70
5 changed files with 47 additions and 12 deletions

View File

@ -11,6 +11,7 @@ github: @shenjackyuanjie
gitee: @shenjackyuanjie gitee: @shenjackyuanjie
""" """
import ctypes import ctypes
import logging
from Difficult_Rocket.utils.typings import Options from Difficult_Rocket.utils.typings import Options
@ -58,6 +59,9 @@ class _DR_runtime(Options):
client_setup_cause_ns: int = None client_setup_cause_ns: int = None
server_setup_cause_ns: int = None server_setup_cause_ns: int = None
# game runtimes
global_logger: logging.Logger
# game options # game options
_language = 'zh-CN' _language = 'zh-CN'
default_language: str = 'zh-CN' default_language: str = 'zh-CN'

View File

@ -25,7 +25,7 @@ from Difficult_Rocket import Options, DR_runtime
from Difficult_Rocket.command import line, tree from Difficult_Rocket.command import line, tree
from Difficult_Rocket.utils.translate import tr from Difficult_Rocket.utils.translate import tr
from Difficult_Rocket.client.screen import DRScreen from Difficult_Rocket.client.screen import DRScreen
# from Difficult_Rocket.client.screen import DRDEBUGScreen from Difficult_Rocket.client.screen import DRDEBUGScreen
from Difficult_Rocket.utils import tools, translate from Difficult_Rocket.utils import tools, translate
from Difficult_Rocket.utils.new_thread import new_thread from Difficult_Rocket.utils.new_thread import new_thread
from Difficult_Rocket.client.fps.fps_log import FpsLogger from Difficult_Rocket.client.fps.fps_log import FpsLogger
@ -34,6 +34,9 @@ from Difficult_Rocket.exception.command import CommandError
import tomlkit import tomlkit
import pyglet import pyglet
from pyglet import gl
from pyglet.gl import *
from pyglet.libs.win32 import _user32
from pyglet.window import Window from pyglet.window import Window
from pyglet.window import key, mouse from pyglet.window import key, mouse
@ -205,6 +208,7 @@ class ClientWindow(Window):
def on_draw(self, *dt): def on_draw(self, *dt):
# self.logger.debug('on_draw call dt: {}'.format(dt)) # self.logger.debug('on_draw call dt: {}'.format(dt))
pyglet.gl.glClearColor(0.1, 0, 0, 0.0)
self.clear() self.clear()
self.draw_batch() self.draw_batch()
@ -215,6 +219,15 @@ class ClientWindow(Window):
def on_refresh(self, dt): def on_refresh(self, dt):
... ...
def on_show(self):
# HWND_TOPMOST = -1
# _user32.SetWindowPos(self._hwnd, HWND_TOPMOST, 0, 0, self.width, self.height, 0)
...
def on_hide(self):
# self.set_location(*self.get_location())
print('on hide!')
def draw_batch(self): def draw_batch(self):
self.part_batch.draw() self.part_batch.draw()
self.label_batch.draw() self.label_batch.draw()

View File

@ -15,6 +15,8 @@ import re
from Difficult_Rocket.utils import translate from Difficult_Rocket.utils import translate
from pyglet.text.formats import structured
default_style = { default_style = {
'font_name': 'Times New Roman', 'font_name': 'Times New Roman',
'font_size': 12, 'font_size': 12,
@ -23,6 +25,10 @@ default_style = {
} }
class MarkdownTextDecoder(structured.StructuredTextDecoder):
...
class SingleTextStyle: class SingleTextStyle:
""" """
单个字符的字体样式 单个字符的字体样式

View File

@ -21,7 +21,7 @@ import configparser
from typing import Union from typing import Union
from xml.dom.minidom import parse from xml.dom.minidom import parse
import tomlkit import rtoml
from Difficult_Rocket.exception.unsupport import NoMoreJson5 from Difficult_Rocket.exception.unsupport import NoMoreJson5
@ -51,7 +51,7 @@ def load_file(file_name: str, stack: Union[str, list, dict] = None, raise_error:
get_file = get_file[stack] get_file = get_file[stack]
elif f_type == 'toml': elif f_type == 'toml':
with open(file_name, mode='r', encoding='utf-8') as file: with open(file_name, mode='r', encoding='utf-8') as file:
get_file = tomlkit.load(file) get_file = rtoml.load(file)
elif f_type == 'json5': elif f_type == 'json5':
raise NoMoreJson5("我说什么也不用json5了喵的") raise NoMoreJson5("我说什么也不用json5了喵的")
except Exception as exp: except Exception as exp:
@ -61,7 +61,7 @@ def load_file(file_name: str, stack: Union[str, list, dict] = None, raise_error:
else: else:
tools_logger.error(file_error[Exception].format(error_type=error_type, filetype=f_type, filename=file_name, stack=stack)) tools_logger.error(file_error[Exception].format(error_type=error_type, filetype=f_type, filename=file_name, stack=stack))
if raise_error: if raise_error:
raise raise exp from None
return get_file return get_file
@ -87,12 +87,12 @@ def get_At(name, in_xml, need_type=str):
return At_list return At_list
elif name_type == str: elif name_type == str:
if in_xml.hasAttribute(name): if in_xml.hasAttribute(name):
At = in_xml.getAttribute(name) attr = in_xml.getAttribute(name)
else: else:
return None return None
else: else:
raise TypeError('only str and list type is ok but you give me a' + name_type + 'type') raise TypeError('only str and list type is ok but you give me a' + name_type + 'type')
return need_type(At) return need_type(attr)
def default_name_handler(name_: str) -> str: def default_name_handler(name_: str) -> str:

View File

@ -40,10 +40,14 @@ class Translates:
self.final = final self.final = final
def __getitem__(self, item: Union[str, int, Hashable]) -> Union["Translates", str]: def __getitem__(self, item: Union[str, int, Hashable]) -> Union["Translates", str]:
"""
一坨答辩
:param item: 取用的内容/小天才
:return:
"""
cache_get_list = self.get_list.copy() cache_get_list = self.get_list.copy()
cache_get_list.append(item) cache_get_list.append(item)
try: try:
if not self.final:
cache = self.value[item] cache = self.value[item]
except (KeyError, TypeError): except (KeyError, TypeError):
if DR_option.report_translate_no_found: if DR_option.report_translate_no_found:
@ -54,6 +58,7 @@ class Translates:
call_info = f'Translate Not Found at {last_frame.f_code.co_name} by {".".join(cache_get_list)} at:' \ call_info = f'Translate Not Found at {last_frame.f_code.co_name} by {".".join(cache_get_list)} at:' \
f'{last_frame.f_code.co_filename}:{last_frame.f_lineno}' f'{last_frame.f_code.co_filename}:{last_frame.f_lineno}'
print(call_info) print(call_info)
if not self.raise_error: if not self.raise_error:
return Translates(value='.'.join(cache_get_list), raise_error=False, final=True) return Translates(value='.'.join(cache_get_list), raise_error=False, final=True)
else: else:
@ -79,12 +84,19 @@ class Tr:
我不装了我就抄了tr 我不装了我就抄了tr
GOOD GOOD
""" """
def __init__(self, language: str = None, raise_error: bool = False):
def __init__(self, language: str = None): """
诶嘿我抄的MCDR
:param language: Tr 所使用的的语言
:param raise_error: 解析失败的时候是否报错
"""
self.language_name = language or DR_runtime.language self.language_name = language or DR_runtime.language
self.translates: Dict = tools.load_file(f'configs/lang/{self.language_name}.toml') self.translates: Dict = tools.load_file(f'configs/lang/{self.language_name}.toml')
self.default_translate: Dict = tools.load_file(f'configs/lang/{DR_runtime.default_language}.toml') self.default_translate: Dict = tools.load_file(f'configs/lang/{DR_runtime.default_language}.toml')
self.不抛出异常 = False self.不抛出异常 = raise_error
def __call__(self, ):
...
class Lang: class Lang:
@ -117,7 +129,7 @@ class Lang:
except KeyError: except KeyError:
raise TranslateKeyNotFound(f'there\'s no key {item} in both {DR_option.language} and zh-CN') raise TranslateKeyNotFound(f'there\'s no key {item} in both {DR_option.language} and zh-CN')
def lang(self, *args) -> Union[int, str, list, dict]: def lang(self, *args) -> Union[int, str, list, dict, tuple]:
# frame = inspect.currentframe() # frame = inspect.currentframe()
# # print("调用当前log的文件名:", frame.f_back.f_code.co_filename) # # print("调用当前log的文件名:", frame.f_back.f_code.co_filename)
# objprint.objprint(frame.f_back.f_code, # objprint.objprint(frame.f_back.f_code,