tree
This commit is contained in:
parent
73ba03feed
commit
934210d465
@ -11,7 +11,7 @@ github: @shenjackyuanjie
|
|||||||
gitee: @shenjackyuanjie
|
gitee: @shenjackyuanjie
|
||||||
"""
|
"""
|
||||||
|
|
||||||
version = '0.6.1'
|
version = '0.6.2'
|
||||||
__version__ = version
|
__version__ = version
|
||||||
|
|
||||||
|
|
||||||
|
@ -17,14 +17,10 @@ import time
|
|||||||
import math
|
import math
|
||||||
import decimal
|
import decimal
|
||||||
import logging
|
import logging
|
||||||
import traceback
|
|
||||||
import configparser
|
import configparser
|
||||||
|
|
||||||
from typing import List
|
|
||||||
from xml.dom.minidom import parse
|
from xml.dom.minidom import parse
|
||||||
|
|
||||||
import Difficult_Rocket
|
|
||||||
|
|
||||||
if __name__ == '__main__': # been start will not run this
|
if __name__ == '__main__': # been start will not run this
|
||||||
sys.path.append('/bin/libs')
|
sys.path.append('/bin/libs')
|
||||||
sys.path.append('/bin')
|
sys.path.append('/bin')
|
||||||
|
@ -94,8 +94,9 @@ class ClientWindow(Window):
|
|||||||
self.net_mode = net_mode
|
self.net_mode = net_mode
|
||||||
self.run_input = False
|
self.run_input = False
|
||||||
# configs
|
# configs
|
||||||
pyglet.resource.path = ['textures']
|
pyglet.resource.path = ['/textures/']
|
||||||
pyglet.resource.reindex()
|
pyglet.resource.reindex()
|
||||||
|
self.set_icon(pyglet.image.load('textures/icon.png'))
|
||||||
self.main_config = tools.load_file('configs/main.config')
|
self.main_config = tools.load_file('configs/main.config')
|
||||||
self.game_config = tools.load_file('configs/game.config')
|
self.game_config = tools.load_file('configs/game.config')
|
||||||
# dic
|
# dic
|
||||||
|
70
Difficult_Rocket/command/api.py
Normal file
70
Difficult_Rocket/command/api.py
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
# -------------------------------
|
||||||
|
# Difficult Rocket
|
||||||
|
# Copyright © 2021-2022 by shenjackyuanjie
|
||||||
|
# All rights reserved
|
||||||
|
# -------------------------------
|
||||||
|
|
||||||
|
"""
|
||||||
|
writen by shenjackyuanjie
|
||||||
|
mail: 3695888@qq.com
|
||||||
|
github: @shenjackyuanjie
|
||||||
|
gitee: @shenjackyuanjie
|
||||||
|
"""
|
||||||
|
|
||||||
|
# system function
|
||||||
|
import re
|
||||||
|
|
||||||
|
from typing import Union
|
||||||
|
|
||||||
|
|
||||||
|
class CommandText:
|
||||||
|
"""
|
||||||
|
CommandLine返回的字符,可以用来搜索
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(self, text: str):
|
||||||
|
self.text = text
|
||||||
|
self.value_dict = {}
|
||||||
|
self.value_list = []
|
||||||
|
|
||||||
|
def find(self, text: str) -> Union[str, False]:
|
||||||
|
finding = re.match(text, self.text)
|
||||||
|
if finding:
|
||||||
|
return finding.group()
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
|
def match(self, text: str) -> bool:
|
||||||
|
finding = re.match(text, self.text)
|
||||||
|
if finding: # 如果找到了
|
||||||
|
try:
|
||||||
|
next_find = self.text[finding.span()[1]]
|
||||||
|
# 这里try因为可能匹配到的是字符串末尾
|
||||||
|
except IndexError:
|
||||||
|
next_find = ' '
|
||||||
|
# 直接过滤掉
|
||||||
|
if next_find == ' ':
|
||||||
|
self.text = self.text[finding.span()[1] + 1:]
|
||||||
|
return True
|
||||||
|
# 将匹配到的字符串,和最后一个匹配字符后面的字符删除(相当暴力的操作)
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
|
def greedy(self, name: str = None) -> str:
|
||||||
|
if name:
|
||||||
|
self.value_dict[name] = self.text
|
||||||
|
self.value_list.append(self.text)
|
||||||
|
return self.text
|
||||||
|
|
||||||
|
def value(self,
|
||||||
|
name: str = None,
|
||||||
|
split: str = ' ',
|
||||||
|
middle: list = ('\'', '\"')):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return str(self.text)
|
||||||
|
|
||||||
|
def __int__(self):
|
||||||
|
return int(self.text)
|
@ -11,8 +11,8 @@ github: @shenjackyuanjie
|
|||||||
gitee: @shenjackyuanjie
|
gitee: @shenjackyuanjie
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
# system function
|
||||||
import time
|
import time
|
||||||
import re
|
|
||||||
|
|
||||||
from typing import Union
|
from typing import Union
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
@ -20,6 +20,7 @@ from decimal import Decimal
|
|||||||
# from DR
|
# from DR
|
||||||
from Difficult_Rocket import translate
|
from Difficult_Rocket import translate
|
||||||
from Difficult_Rocket.api import new_thread
|
from Difficult_Rocket.api import new_thread
|
||||||
|
from Difficult_Rocket.command.api import CommandText
|
||||||
|
|
||||||
# from libs.pyglet
|
# from libs.pyglet
|
||||||
from libs import pyglet
|
from libs import pyglet
|
||||||
@ -29,59 +30,6 @@ from libs.pyglet.gui import widgets
|
|||||||
from libs.pyglet.graphics import Batch, Group
|
from libs.pyglet.graphics import Batch, Group
|
||||||
|
|
||||||
|
|
||||||
class CommandText:
|
|
||||||
"""
|
|
||||||
CommandLine返回的字符,可以用来搜索
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __init__(self, text: str):
|
|
||||||
self.text = text
|
|
||||||
self.value_dict = {}
|
|
||||||
self.value_list = []
|
|
||||||
|
|
||||||
def find(self, text: str) -> bool:
|
|
||||||
finding = re.match(text, self.text)
|
|
||||||
if finding:
|
|
||||||
return True
|
|
||||||
else:
|
|
||||||
return False
|
|
||||||
|
|
||||||
def match(self, text: str) -> bool:
|
|
||||||
finding = re.match(text, self.text)
|
|
||||||
if finding: # 如果找到了
|
|
||||||
try:
|
|
||||||
next_find = self.text[finding.span()[1]]
|
|
||||||
# 这里try因为可能匹配到的是字符串末尾
|
|
||||||
except IndexError:
|
|
||||||
next_find = ' '
|
|
||||||
# 直接过滤掉
|
|
||||||
if next_find == ' ':
|
|
||||||
self.text = self.text[finding.span()[1] + 1:]
|
|
||||||
return True
|
|
||||||
# 将匹配到的字符串,和最后一个匹配字符后面的字符删除(相当暴力的操作)
|
|
||||||
return False
|
|
||||||
else:
|
|
||||||
return False
|
|
||||||
|
|
||||||
def greedy(self, name: str = None) -> str:
|
|
||||||
if name:
|
|
||||||
self.value_dict[name] = self.text
|
|
||||||
self.value_list.append(self.text)
|
|
||||||
return self.text
|
|
||||||
|
|
||||||
def value(self,
|
|
||||||
name: str = None,
|
|
||||||
split: str = ' ',
|
|
||||||
middle: list = ('\'', '\"')):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def __str__(self):
|
|
||||||
return str(self.text)
|
|
||||||
|
|
||||||
def __int__(self):
|
|
||||||
return int(self.text)
|
|
||||||
|
|
||||||
|
|
||||||
class CommandLine(widgets.WidgetBase):
|
class CommandLine(widgets.WidgetBase):
|
||||||
"""
|
"""
|
||||||
command line show
|
command line show
|
||||||
|
@ -11,7 +11,52 @@ github: @shenjackyuanjie
|
|||||||
gitee: @shenjackyuanjie
|
gitee: @shenjackyuanjie
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import line
|
from Difficult_Rocket import version
|
||||||
|
from Difficult_Rocket.command import line
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
command_tree = {
|
||||||
|
'name': 'DR-root',
|
||||||
|
'version': version,
|
||||||
|
'information': 'DR这一部分的代码还TM是复制我之前写的屑Census',
|
||||||
|
'commands': {
|
||||||
|
'info': '啊啊啊啊',
|
||||||
|
'hint': '然而并没有什么隐藏信息(确信)',
|
||||||
|
'run': '{app_name} help',
|
||||||
|
'sub_command': {
|
||||||
|
'stop': {
|
||||||
|
'info': '停止游戏',
|
||||||
|
'hint': 'g 你就在看着我呢~',
|
||||||
|
'run': '{command}',
|
||||||
|
},
|
||||||
|
'default': {
|
||||||
|
'info': '重置游戏',
|
||||||
|
'hint': 'g 获得成就:我重置我自己',
|
||||||
|
'run': '{command}',
|
||||||
|
},
|
||||||
|
'fps': {
|
||||||
|
'sub_command': {
|
||||||
|
'log': {
|
||||||
|
'info': '输出FPS日志',
|
||||||
|
'hint': 'rub 本操作会覆盖现有数据,所以请自行输入命令',
|
||||||
|
'run': '{command}',
|
||||||
|
},
|
||||||
|
'max': {
|
||||||
|
'info': '输出最大FPS',
|
||||||
|
'hint': 'ub 提醒:这个操作会覆盖文件数据(虽说其实没啥事)',
|
||||||
|
'run': '{command}',
|
||||||
|
},
|
||||||
|
'mix': {
|
||||||
|
'info': '输出最小FPS',
|
||||||
|
'hint': '获得成就:我打印了分数',
|
||||||
|
'run': '{command}',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class CommandTree:
|
class CommandTree:
|
||||||
|
@ -262,7 +262,8 @@ italic_HTML_end = '</i>'
|
|||||||
|
|
||||||
|
|
||||||
def decode_text2HTML(text: str,
|
def decode_text2HTML(text: str,
|
||||||
configs=None) -> str:
|
configs=None,
|
||||||
|
show_style: bool = False) -> str:
|
||||||
if text == '':
|
if text == '':
|
||||||
return ''
|
return ''
|
||||||
if configs is None:
|
if configs is None:
|
||||||
@ -277,7 +278,6 @@ def decode_text2HTML(text: str,
|
|||||||
text_match = match_text.group() # 缓存一下匹配到的字符,用于匹配显示的字符
|
text_match = match_text.group() # 缓存一下匹配到的字符,用于匹配显示的字符
|
||||||
shown_texts = config['shown'].finditer(text_match) # 使用 config.shown 匹配
|
shown_texts = config['shown'].finditer(text_match) # 使用 config.shown 匹配
|
||||||
match_start, match_end = match_text.span()
|
match_start, match_end = match_text.span()
|
||||||
|
|
||||||
if 'ignore' in config: # 如果样式选项包含忽略某些字符的tag
|
if 'ignore' in config: # 如果样式选项包含忽略某些字符的tag
|
||||||
ignore_texts = config['ignore']['match'].finditer(text_match) # 根据选项匹配可能忽略的字符
|
ignore_texts = config['ignore']['match'].finditer(text_match) # 根据选项匹配可能忽略的字符
|
||||||
ignore = False # 忽略先为False
|
ignore = False # 忽略先为False
|
||||||
@ -290,25 +290,21 @@ def decode_text2HTML(text: str,
|
|||||||
break
|
break
|
||||||
if ignore:
|
if ignore:
|
||||||
continue # 跳过本次匹配
|
continue # 跳过本次匹配
|
||||||
|
|
||||||
if 'tag' in config: # 如果样式选项包含对部分字符添加tag
|
if 'tag' in config: # 如果样式选项包含对部分字符添加tag
|
||||||
tag_texts = config['tag']['match'].finditer(text_match) # 根据配置的正则表达式匹配要添加tag的字符
|
tag_texts = config['tag']['match'].finditer(text_match) # 根据配置的正则表达式匹配要添加tag的字符
|
||||||
for tag_text in tag_texts: # 对每一个匹配到的~~~~~~
|
for tag_text in tag_texts: # 对每一个匹配到的~~~~~~
|
||||||
for tag_index in range(match_start + tag_text.span()[0], match_start + tag_text.span()[1]): # 用于遍历匹配到的字符
|
for tag_index in range(match_start + tag_text.span()[0], match_start + tag_text.span()[1]): # 用于遍历匹配到的字符
|
||||||
style_list[tag_index] += config['tag']['style']
|
style_list[tag_index] += config['tag']['style']
|
||||||
|
|
||||||
# 为匹配到的字符添加样式
|
# 为匹配到的字符添加样式
|
||||||
for match_index in range(match_start, match_end): # 用于遍历匹配到的字符
|
for match_index in range(match_start, match_end): # 用于遍历匹配到的字符
|
||||||
# 这里用 match index 来精确读写列表里的元素,毕竟 re.Match 返回的 span 是两个标点,得遍历
|
# 这里用 match index 来精确读写列表里的元素,毕竟 re.Match 返回的 span 是两个标点,得遍历
|
||||||
style_list[match_index] += config['style'] # 字体样式列表的 [match_index] += config['style'] 的样式
|
style_list[match_index] += config['style'] # 字体样式列表的 [match_index] += config['style'] 的样式
|
||||||
style_list[match_index].show = False # 设置显示属性变为False
|
style_list[match_index].show = show_style # 设置显示属性变为 False
|
||||||
|
|
||||||
# 为每一个显示的字符设置显示属性
|
# 为每一个显示的字符设置显示属性
|
||||||
for shown_text in shown_texts: # 每一个显示的匹配项
|
for shown_text in shown_texts: # 每一个显示的匹配项
|
||||||
for shown_index in range(match_start + shown_text.span()[0], match_start + shown_text.span()[1]):
|
for shown_index in range(match_start + shown_text.span()[0], match_start + shown_text.span()[1]):
|
||||||
style_list[shown_index].show = True
|
style_list[shown_index].show = True
|
||||||
# 字体样式列表的 [shown_index] 设置显示属性变为 True
|
# 字体样式列表的 [shown_index] 设置显示属性变为 True
|
||||||
|
|
||||||
# 开始根据配置好的样式输出HTML文本
|
# 开始根据配置好的样式输出HTML文本
|
||||||
style_list[0].prefix += style_list[0].HTML() # 不管怎么说都要在最前面加一个字符标识
|
style_list[0].prefix += style_list[0].HTML() # 不管怎么说都要在最前面加一个字符标识
|
||||||
for style_index in range(1, len(style_list)):
|
for style_index in range(1, len(style_list)):
|
||||||
|
@ -125,7 +125,7 @@ class InputBox(widgets.WidgetBase):
|
|||||||
assert type(value) is str, 'Input Box\'s text must be string!'
|
assert type(value) is str, 'Input Box\'s text must be string!'
|
||||||
self._text = value
|
self._text = value
|
||||||
self._input_box.text = value
|
self._input_box.text = value
|
||||||
self._HTML_box.text = html.decode_text2HTML(value)
|
self._HTML_box.text = html.decode_text2HTML(value, show_style=True)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def cursor_poi(self) -> int: # 光标位置
|
def cursor_poi(self) -> int: # 光标位置
|
||||||
|
15
try/julia/decodeHTML.jl
Normal file
15
try/julia/decodeHTML.jl
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#=
|
||||||
|
decodeHTML:
|
||||||
|
- Julia version: 1.7.1
|
||||||
|
- Author: shenjack
|
||||||
|
- Date: 2022-01-29
|
||||||
|
=#
|
||||||
|
|
||||||
|
|
||||||
|
decode_Config = [
|
||||||
|
Dict("match" => "aaaaaaa")
|
||||||
|
]
|
||||||
|
|
||||||
|
function translatetext2HTML(text::String, configs::Dict{Symbol, Any}, show_code::Bool = false)
|
||||||
|
|
||||||
|
end
|
Loading…
Reference in New Issue
Block a user