rua for 0.7.0.0 with DR_rs 0.1.6.0
This commit is contained in:
parent
38a9344939
commit
8dfbf1249b
@ -25,7 +25,7 @@ from libs.MCDR.version import Version
|
|||||||
|
|
||||||
game_version = Version("0.7.0.0") # 游戏版本
|
game_version = Version("0.7.0.0") # 游戏版本
|
||||||
build_version = Version("1.1.0.0") # 编译文件版本(与游戏本体无关)
|
build_version = Version("1.1.0.0") # 编译文件版本(与游戏本体无关)
|
||||||
DR_rust_version = Version("0.1.2.0") # DR 的 Rust 编写部分的版本
|
DR_rust_version = Version("0.1.6.0") # DR 的 Rust 编写部分的版本
|
||||||
__version__ = game_version
|
__version__ = game_version
|
||||||
|
|
||||||
long_version: int = 11
|
long_version: int = 11
|
||||||
|
@ -93,7 +93,7 @@ def create_crash_report(info: str = None) -> None:
|
|||||||
filename = f'crash-{date_time}.md'
|
filename = f'crash-{date_time}.md'
|
||||||
cache_stream = io.StringIO()
|
cache_stream = io.StringIO()
|
||||||
try:
|
try:
|
||||||
_extracted_from_create_crash_report_10(cache_stream, crash_info)
|
write_cache(cache_stream, crash_info)
|
||||||
finally:
|
finally:
|
||||||
get_cache = cache_stream.getvalue()
|
get_cache = cache_stream.getvalue()
|
||||||
cache_stream.close()
|
cache_stream.close()
|
||||||
@ -101,8 +101,7 @@ def create_crash_report(info: str = None) -> None:
|
|||||||
crash_file.write(get_cache)
|
crash_file.write(get_cache)
|
||||||
|
|
||||||
|
|
||||||
# TODO Rename this here and in `create_crash_report`
|
def write_cache(cache_stream, crash_info):
|
||||||
def _extracted_from_create_crash_report_10(cache_stream, crash_info):
|
|
||||||
# 开头信息
|
# 开头信息
|
||||||
cache_stream.write(Head_message.format(now_time=time.strftime('%Y/%m/%d %H:%M:%S', time.gmtime(time.time()))))
|
cache_stream.write(Head_message.format(now_time=time.strftime('%Y/%m/%d %H:%M:%S', time.gmtime(time.time()))))
|
||||||
# 崩溃信息
|
# 崩溃信息
|
||||||
@ -113,16 +112,8 @@ def _extracted_from_create_crash_report_10(cache_stream, crash_info):
|
|||||||
cache_stream.write(markdown_line_handler(f'DR Version: {Difficult_Rocket.game_version}', level=1))
|
cache_stream.write(markdown_line_handler(f'DR Version: {Difficult_Rocket.game_version}', level=1))
|
||||||
cache_stream.write(markdown_line_handler(f'DR language: {DR_runtime.language}', level=1))
|
cache_stream.write(markdown_line_handler(f'DR language: {DR_runtime.language}', level=1))
|
||||||
cache_stream.write(markdown_line_handler(f'Running Dir: {Path(os.curdir).resolve()}', level=1))
|
cache_stream.write(markdown_line_handler(f'Running Dir: {Path(os.curdir).resolve()}', level=1))
|
||||||
option_with_len = (
|
write_options(DR_runtime, cache_stream, DR_configs)
|
||||||
_extracted_from__extracted_from_create_crash_report_10_19(
|
write_options(DR_option, cache_stream, Process_message)
|
||||||
DR_runtime, cache_stream, DR_configs
|
|
||||||
)
|
|
||||||
)
|
|
||||||
option_with_len = (
|
|
||||||
_extracted_from__extracted_from_create_crash_report_10_19(
|
|
||||||
DR_option, cache_stream, Process_message
|
|
||||||
)
|
|
||||||
)
|
|
||||||
for process in all_process:
|
for process in all_process:
|
||||||
process: multiprocessing.Process
|
process: multiprocessing.Process
|
||||||
cache_stream.write(markdown_line_handler(f'{process.name}', code=True))
|
cache_stream.write(markdown_line_handler(f'{process.name}', code=True))
|
||||||
@ -153,13 +144,11 @@ def _extracted_from_create_crash_report_10(cache_stream, crash_info):
|
|||||||
cache_stream.write(markdown_line_handler(f'version: {to_code(platform.version())}', level=1))
|
cache_stream.write(markdown_line_handler(f'version: {to_code(platform.version())}', level=1))
|
||||||
|
|
||||||
|
|
||||||
# TODO Rename this here and in `create_crash_report`
|
def write_options(arg0, cache_stream, arg2):
|
||||||
def _extracted_from__extracted_from_create_crash_report_10_19(arg0, cache_stream, arg2):
|
|
||||||
result = arg0.option_with_len()
|
result = arg0.option_with_len()
|
||||||
write_markdown_tablet(crash_file=cache_stream, tablet=result)
|
write_markdown_tablet(crash_file=cache_stream, tablet=result)
|
||||||
# # DR 的游戏设置
|
# # DR 的游戏设置
|
||||||
cache_stream.write(arg2)
|
cache_stream.write(arg2)
|
||||||
return result
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
@ -23,6 +23,7 @@ if __name__ == '__main__': # been start will not run this
|
|||||||
sys.path.append('/bin')
|
sys.path.append('/bin')
|
||||||
|
|
||||||
from Difficult_Rocket import client, server, DR_option
|
from Difficult_Rocket import client, server, DR_option
|
||||||
|
|
||||||
from Difficult_Rocket.utils import tools
|
from Difficult_Rocket.utils import tools
|
||||||
from Difficult_Rocket.utils.translate import tr
|
from Difficult_Rocket.utils.translate import tr
|
||||||
|
|
||||||
|
@ -29,8 +29,9 @@ class TranslateConfig:
|
|||||||
is_final: bool = False # 是否为最终内容
|
is_final: bool = False # 是否为最终内容
|
||||||
keep_get: bool = True # 引用错误后是否继续引用
|
keep_get: bool = True # 引用错误后是否继续引用
|
||||||
always_copy: bool = False # 是否一直新建 Translate (为 True 会降低性能)
|
always_copy: bool = False # 是否一直新建 Translate (为 True 会降低性能)
|
||||||
|
source: Optional[Union["Tr", "Translates"]] = None # 翻译来源 (用于默认翻译)
|
||||||
|
|
||||||
def set(self, item: str, value: bool) -> 'TranslateConfig':
|
def set(self, item: str, value: Union[bool, "Tr", "Translates"]) -> 'TranslateConfig':
|
||||||
assert getattr(self, item, None) is not None, f'Config {item} is not in TranslateConfig'
|
assert getattr(self, item, None) is not None, f'Config {item} is not in TranslateConfig'
|
||||||
assert type(value) is bool
|
assert type(value) is bool
|
||||||
setattr(self, item, value)
|
setattr(self, item, value)
|
||||||
@ -42,7 +43,8 @@ class TranslateConfig:
|
|||||||
insert_crack=self.insert_crack,
|
insert_crack=self.insert_crack,
|
||||||
is_final=self.is_final,
|
is_final=self.is_final,
|
||||||
keep_get=self.keep_get,
|
keep_get=self.keep_get,
|
||||||
always_copy=self.always_copy)
|
always_copy=self.always_copy,
|
||||||
|
source=self.source)
|
||||||
|
|
||||||
def copy(self) -> 'TranslateConfig':
|
def copy(self) -> 'TranslateConfig':
|
||||||
return self.__copy__()
|
return self.__copy__()
|
||||||
@ -90,9 +92,14 @@ class Translates:
|
|||||||
raise_info = f"{self.name} Cause a error when getting {item} {frame}"
|
raise_info = f"{self.name} Cause a error when getting {item} {frame}"
|
||||||
print(raise_info)
|
print(raise_info)
|
||||||
|
|
||||||
def __getitem__(self, item: key_type) -> "Translates":
|
def __getitem__(self, item: Union[key_type, List[key_type], Tuple[key_type]]) -> "Translates":
|
||||||
try:
|
try:
|
||||||
cache_value = self.value[item]
|
if isinstance(item, (str, int, Hashable)):
|
||||||
|
cache_value = self.value[item]
|
||||||
|
else:
|
||||||
|
cache_value = self.value
|
||||||
|
for a_item in item:
|
||||||
|
cache_value = cache_value[a_item]
|
||||||
if isinstance(cache_value, (int, str,)):
|
if isinstance(cache_value, (int, str,)):
|
||||||
self.config.is_final = True
|
self.config.is_final = True
|
||||||
self.get_list.append((True, item))
|
self.get_list.append((True, item))
|
||||||
@ -106,6 +113,12 @@ class Translates:
|
|||||||
if not self.config.keep_get:
|
if not self.config.keep_get:
|
||||||
self.config.is_final = True
|
self.config.is_final = True
|
||||||
|
|
||||||
|
def __call__(self, *args, **kwargs):
|
||||||
|
if len(self.get_list) == 0:
|
||||||
|
return self
|
||||||
|
if any([x[0] for x in self.get_list]):
|
||||||
|
return
|
||||||
|
|
||||||
def copy(self):
|
def copy(self):
|
||||||
return self.__copy__()
|
return self.__copy__()
|
||||||
|
|
||||||
@ -137,13 +150,25 @@ class Tr:
|
|||||||
:param config: 配置
|
:param config: 配置
|
||||||
"""
|
"""
|
||||||
self.language_name = language or DR_runtime.language
|
self.language_name = language or DR_runtime.language
|
||||||
self.translates: Dict[str,] = tools.load_file(f'configs/lang/{self.language_name}.toml')
|
self.translates: Dict[str, Union[str, 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.default_config = config or TranslateConfig()
|
self.default_config = config.set('source', self) or TranslateConfig(source=self)
|
||||||
self.translates_cache = Translates(value=self.translates, config=TranslateConfig().copy())
|
self.translates_cache = Translates(value=self.translates, config=self.default_config.copy())
|
||||||
|
|
||||||
|
def default(self, items: Union[str, List[str]]) -> Translates:
|
||||||
|
if isinstance(items, list):
|
||||||
|
cache_translate = self.default_translate
|
||||||
|
for item in items:
|
||||||
|
cache_translate = cache_translate[item]
|
||||||
|
return cache_translate
|
||||||
|
else:
|
||||||
|
return self.default_translate[items]
|
||||||
|
|
||||||
|
def lang(self, *items):
|
||||||
|
return self.__getattr__(items)
|
||||||
|
|
||||||
def __getattr__(self, item) -> Translates:
|
def __getattr__(self, item) -> Translates:
|
||||||
...
|
return self.translates_cache[item]
|
||||||
|
|
||||||
def __getitem__(self, item: Union[str, int]):
|
def __getitem__(self, item: Union[str, int]):
|
||||||
return self.__getattr__(item)
|
return self.__getattr__(item)
|
||||||
@ -217,5 +242,6 @@ class Lang:
|
|||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
tr_ = Tr()
|
tr_ = Tr()
|
||||||
|
|
||||||
else:
|
else:
|
||||||
tr = Lang()
|
tr = Lang()
|
||||||
|
7
build_rs.ps1
Normal file
7
build_rs.ps1
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
Set-Location .\libs\Difficult_Rocket_rs\src
|
||||||
|
|
||||||
|
python3.8 setup.py build
|
||||||
|
|
||||||
|
python3.8 after_build.py
|
||||||
|
|
||||||
|
Set-Location ..\..\..\
|
@ -32,6 +32,8 @@
|
|||||||
- ( Python 原生的 for 循环真慢 )
|
- ( Python 原生的 for 循环真慢 )
|
||||||
- `PartDatas`
|
- `PartDatas`
|
||||||
- 用于在 `PyObj` 里 暗 渡 陈 仓 装 `HashMap<uszie, SR1PartData>`
|
- 用于在 `PyObj` 里 暗 渡 陈 仓 装 `HashMap<uszie, SR1PartData>`
|
||||||
|
- `Camera_rs`
|
||||||
|
- 用于闲的没事在 rust 里写个 camera
|
||||||
|
|
||||||
### 命令
|
### 命令
|
||||||
|
|
||||||
@ -40,6 +42,10 @@
|
|||||||
- `reset`
|
- `reset`
|
||||||
- 用于重置现在这艘船的渲染 (避免你玩着玩着把船玩道不知道什么地方去了)
|
- 用于重置现在这艘船的渲染 (避免你玩着玩着把船玩道不知道什么地方去了)
|
||||||
|
|
||||||
|
### 优化
|
||||||
|
|
||||||
|
- 继续优化未实装的 `Translates`
|
||||||
|
|
||||||
## 20230120 V 0.6.5.0
|
## 20230120 V 0.6.5.0
|
||||||
|
|
||||||
### 抱歉,我撒谎了(
|
### 抱歉,我撒谎了(
|
||||||
|
@ -13,6 +13,8 @@ if TYPE_CHECKING:
|
|||||||
from Difficult_Rocket.api.types.SR1 import SR1PartData
|
from Difficult_Rocket.api.types.SR1 import SR1PartData
|
||||||
from Difficult_Rocket.client.render.sr1_ship import SR1ShipRender, SR1ShipRender_Option
|
from Difficult_Rocket.client.render.sr1_ship import SR1ShipRender, SR1ShipRender_Option
|
||||||
|
|
||||||
|
from pyglet.window import Window
|
||||||
|
|
||||||
def test_call(py_obj) -> bool: ...
|
def test_call(py_obj) -> bool: ...
|
||||||
|
|
||||||
def get_version_str() -> str: ...
|
def get_version_str() -> str: ...
|
||||||
@ -30,4 +32,18 @@ if TYPE_CHECKING:
|
|||||||
global_scale: float,
|
global_scale: float,
|
||||||
sr1_xml_scale: int) -> bool: ...
|
sr1_xml_scale: int) -> bool: ...
|
||||||
|
|
||||||
|
class Camera_rs:
|
||||||
|
""" 用于闲的没事 用 rust 写一个 camera """
|
||||||
|
def __new__(cls, window: Window,
|
||||||
|
zoom: float = 1.0,
|
||||||
|
dx: float = 1.0, dy: float = 1.0,
|
||||||
|
min_zoom: float = 1.0,
|
||||||
|
max_zoom: float = 1.0): ...
|
||||||
|
|
||||||
|
def start(self) -> None: ...
|
||||||
|
|
||||||
|
def end(self) -> None: ...
|
||||||
|
|
||||||
|
def __enter__(self, window) -> None: ...
|
||||||
|
|
||||||
|
def __exit__(self, exc_type, exc_val, exc_tb) -> None: ...
|
||||||
|
2
libs/Difficult_Rocket_rs/src/Cargo.lock
generated
2
libs/Difficult_Rocket_rs/src/Cargo.lock
generated
@ -22,7 +22,7 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "difficult_rocket_rs"
|
name = "difficult_rocket_rs"
|
||||||
version = "0.1.0"
|
version = "0.1.4"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"pyo3",
|
"pyo3",
|
||||||
]
|
]
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "difficult_rocket_rs"
|
name = "difficult_rocket_rs"
|
||||||
version = "0.1.0"
|
version = "0.1.4"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license-file = '../../LICENSE'
|
license-file = '../../LICENSE'
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
@ -13,7 +13,7 @@ use pyo3::prelude::*;
|
|||||||
|
|
||||||
#[pyfunction]
|
#[pyfunction]
|
||||||
fn get_version_str() -> String {
|
fn get_version_str() -> String {
|
||||||
return String::from("0.1.3.0");
|
return String::from("0.1.6.0");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[pyfunction]
|
#[pyfunction]
|
||||||
|
@ -7,21 +7,82 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
pub mod camera {
|
pub mod camera {
|
||||||
|
|
||||||
|
use pyo3::intern;
|
||||||
use pyo3::prelude::*;
|
use pyo3::prelude::*;
|
||||||
|
|
||||||
#[pyclass(name = "Camera_rs")]
|
#[pyclass(name = "Camera_rs")]
|
||||||
pub struct CameraRs{
|
pub struct CameraRs{
|
||||||
|
pub window: Py<PyAny>,
|
||||||
|
#[pyo3(get, set)]
|
||||||
pub dx: f64,
|
pub dx: f64,
|
||||||
|
#[pyo3(get, set)]
|
||||||
pub dy: f64,
|
pub dy: f64,
|
||||||
pub zoom: f64,
|
pub zoom: f64,
|
||||||
|
#[pyo3(get, set)]
|
||||||
pub max_zoom: f64,
|
pub max_zoom: f64,
|
||||||
|
#[pyo3(get, set)]
|
||||||
pub min_zoom: f64,
|
pub min_zoom: f64,
|
||||||
pub window: PyObject,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[pymethods]
|
#[pymethods]
|
||||||
impl CameraRs {
|
impl CameraRs {
|
||||||
|
#[new]
|
||||||
|
#[allow(unused_variables)]
|
||||||
|
#[pyo3(signature = (window, zoom=1.0, dx=1.0, dy=1.0,min_zoom=1.0, max_zoom=1.0))]
|
||||||
|
pub fn py_new(window: &PyAny, zoom: f64, dx: f64, dy: f64,min_zoom: f64, max_zoom: f64) -> PyResult<Self> {
|
||||||
|
return Ok(CameraRs {dx, dy, zoom, min_zoom, max_zoom,
|
||||||
|
window: window.into()})
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_view(&self) -> PyResult<PyObject> {
|
||||||
|
Ok(Python::with_gil(|py| -> PyResult<PyObject> {
|
||||||
|
Ok(self.window.getattr(py, intern!(py, "view"))?)
|
||||||
|
})?)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[getter]
|
||||||
|
pub fn get_zoom(&self) -> PyResult<f64> {
|
||||||
|
Ok(self.zoom)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[setter]
|
||||||
|
pub fn set_zoom(&mut self, value: f64) -> PyResult<()> {
|
||||||
|
self.zoom = value.min(self.max_zoom).max(self.min_zoom);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[allow(unused_variables)]
|
||||||
|
pub fn start(&self) -> PyResult<()> {
|
||||||
|
let view = self.get_view()?;
|
||||||
|
Python::with_gil(|py| -> PyResult<()> {
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
})?;
|
||||||
|
return Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[allow(unused_variables)]
|
||||||
|
pub fn end(&self) -> PyResult<()> {
|
||||||
|
let view = self.get_view()?;
|
||||||
|
return Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// https://github.com/PyO3/pyo3/discussions/2931#discussioncomment-4820729 for finding this
|
||||||
|
/// https://github.com/PyO3/pyo3/issues/1205#issuecomment-1164096251 for advice on `__enter__`
|
||||||
|
pub fn __enter__(py_self: PyRef<Self>) -> PyResult<PyRef<Self>> {
|
||||||
|
// println!("enter!");
|
||||||
|
py_self.start()?;
|
||||||
|
Ok(py_self)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn __exit__(&mut self, _exc_type: PyObject, _exc_value: PyObject, _traceback: PyObject) -> PyResult<()>{
|
||||||
|
// println!("exit!");
|
||||||
|
self.end()?;
|
||||||
|
return Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -28,15 +28,17 @@ $arg += @("--file-version=$env:Build_version")
|
|||||||
$arg += @("--file-description=Difficult-Rocket!")
|
$arg += @("--file-description=Difficult-Rocket!")
|
||||||
$arg += @("--windows-icon-from-ico=textures/icon.png")
|
$arg += @("--windows-icon-from-ico=textures/icon.png")
|
||||||
$arg += @("--macos-app-icon=textures/icon.png")
|
$arg += @("--macos-app-icon=textures/icon.png")
|
||||||
|
#--linux-icon
|
||||||
# 编译器配置
|
# 编译器配置
|
||||||
# $arg += @("--msvc=latest")
|
# $arg += @("--msvc=latest")
|
||||||
# $atg += @("--mingw64")
|
# $atg += @("--mingw64")
|
||||||
$arg += @("--clang")
|
$arg += @("--clang")
|
||||||
$arg += @("--lto=no")
|
$arg += @("--lto=no")
|
||||||
# 包配置
|
# 包配置
|
||||||
$arg += @("--nofollow-import-to=objprint,pillow,PIL,pyglet")
|
#$arg += @("--nofollow-import-to=objprint,pillow,PIL,pyglet")
|
||||||
|
#$arg += @("--follow-import-to=libs.pyglet")
|
||||||
# 数据配置
|
# 数据配置
|
||||||
$arg += @("--include-data-dir=./libs/pyglet=./pyglet")
|
$arg += @("--include-data-dir=./libs/pyglet=./libs/pyglet")
|
||||||
$arg += @("--include-data-dir=./libs/fonts=./libs/fonts")
|
$arg += @("--include-data-dir=./libs/fonts=./libs/fonts")
|
||||||
$arg += @("--include-data-dir=./textures=./textures")
|
$arg += @("--include-data-dir=./textures=./textures")
|
||||||
$arg += @("--include-data-dir=./configs=./configs")
|
$arg += @("--include-data-dir=./configs=./configs")
|
||||||
@ -51,6 +53,7 @@ $out = $end_time.TotalMilliseconds - $start_time.TotalMilliseconds
|
|||||||
Write-Output $end_time.TotalSeconds $start_time.TotalSeconds $out s
|
Write-Output $end_time.TotalSeconds $start_time.TotalSeconds $out s
|
||||||
Write-Output $start_time $end_time
|
Write-Output $start_time $end_time
|
||||||
Write-Output "--clang --lto=no and $args"
|
Write-Output "--clang --lto=no and $args"
|
||||||
|
cp ./libs/pyglet ./build/nuitka-win/DR.dist/pyglet
|
||||||
# --include-data-dir=./libs/pyglet=./pyglet
|
# --include-data-dir=./libs/pyglet=./pyglet
|
||||||
# --run
|
# --run
|
||||||
# --disable-ccache
|
# --disable-ccache
|
||||||
|
Loading…
Reference in New Issue
Block a user