diff --git a/docs/src/change_log/dr_game.md b/docs/src/change_log/dr_game.md index cf65888..9a7af66 100644 --- a/docs/src/change_log/dr_game.md +++ b/docs/src/change_log/dr_game.md @@ -3,7 +3,20 @@ - 最新版本号 - DR game: 0.3.2.0 - - DR rs: 0.2.20.2 + - DR rs: 0.2.21.0 + +## 20230808 DR rs 0.2.21.0 + +### Add + +- 在 `__init__.py` 里添加了 + - `sprite` + - `type` + - 的导出 (实际上就是 typing) +- `SR1PartType_rs` + - 添加了 `type` getter + +摸鱼真开心 ## 20230724 DR rs 0.2.20.2 diff --git a/mods/dr_game/Difficult_Rocket_rs/__init__.py b/mods/dr_game/Difficult_Rocket_rs/__init__.py index e087792..91473c8 100644 --- a/mods/dr_game/Difficult_Rocket_rs/__init__.py +++ b/mods/dr_game/Difficult_Rocket_rs/__init__.py @@ -60,6 +60,10 @@ if TYPE_CHECKING: def description(self) -> str: """ 零件的描述 """ + @property + def sprite(self) -> str: + """ 零件的贴图 """ + @property def mass(self) -> float: """ 零件的质量 """ @@ -80,6 +84,10 @@ if TYPE_CHECKING: def hidden(self) -> bool: """ 零件是否隐藏 """ + @property + def type(self): + """ 零件的类型 """ + class SR1PartList_rs: # NOQA """ 用于从 rust 中读取 SR1PartList """ diff --git a/mods/dr_game/Difficult_Rocket_rs/src/setup.py b/mods/dr_game/Difficult_Rocket_rs/src/setup.py index 13b3397..9e633c8 100644 --- a/mods/dr_game/Difficult_Rocket_rs/src/setup.py +++ b/mods/dr_game/Difficult_Rocket_rs/src/setup.py @@ -12,7 +12,7 @@ package_path = 'Difficult_Rocket_rs' setup( name='Difficult_Rocket_rs', - version="0.2.18.0", + version="0.2.21.0", author='shenjackyuanjie', author_email='3695888@qq.com', rust_extensions=[RustExtension(target="Difficult_Rocket_rs.Difficult_Rocket_rs", diff --git a/mods/dr_game/Difficult_Rocket_rs/src/src/lib.rs b/mods/dr_game/Difficult_Rocket_rs/src/src/lib.rs index 352bd0f..3fefe25 100644 --- a/mods/dr_game/Difficult_Rocket_rs/src/src/lib.rs +++ b/mods/dr_game/Difficult_Rocket_rs/src/src/lib.rs @@ -24,7 +24,7 @@ enum LoadState { } #[pyfunction] -fn get_version_str() -> String { "0.2.20.2".to_string() } +fn get_version_str() -> String { "0.2.21.0".to_string() } #[pyfunction] fn test_call(py_obj: &PyAny) -> PyResult { diff --git a/mods/dr_game/Difficult_Rocket_rs/src/src/python.rs b/mods/dr_game/Difficult_Rocket_rs/src/src/python.rs index 083ae1c..5adce9b 100644 --- a/mods/dr_game/Difficult_Rocket_rs/src/src/python.rs +++ b/mods/dr_game/Difficult_Rocket_rs/src/src/python.rs @@ -76,6 +76,9 @@ pub mod data { #[getter] fn get_hidden(&self) -> bool { self.data.hidden } + + #[getter] + fn get_type(&self) -> String { self.data.p_type.into() } } impl PySR1PartType { diff --git a/mods/dr_game/Difficult_Rocket_rs/src/src/sr1_data.rs b/mods/dr_game/Difficult_Rocket_rs/src/src/sr1_data.rs index 30ff664..0c6c510 100644 --- a/mods/dr_game/Difficult_Rocket_rs/src/src/sr1_data.rs +++ b/mods/dr_game/Difficult_Rocket_rs/src/src/sr1_data.rs @@ -41,6 +41,27 @@ pub mod part_list { lander, } + impl Into for SR1PartTypeEnum { + fn into(self) -> String { + match self { + SR1PartTypeEnum::pod => "pod".to_string(), + SR1PartTypeEnum::detacher => "detacher".to_string(), + SR1PartTypeEnum::wheel => "wheel".to_string(), + SR1PartTypeEnum::fuselage => "fuselage".to_string(), + SR1PartTypeEnum::strut => "strut".to_string(), + SR1PartTypeEnum::tank => "tank".to_string(), + SR1PartTypeEnum::engine => "engine".to_string(), + SR1PartTypeEnum::parachute => "parachute".to_string(), + SR1PartTypeEnum::nosecone => "nosecone".to_string(), + SR1PartTypeEnum::rcs => "rcs".to_string(), + SR1PartTypeEnum::solar => "solar".to_string(), + SR1PartTypeEnum::dockconnector => "dockconnector".to_string(), + SR1PartTypeEnum::dockport => "dockport".to_string(), + SR1PartTypeEnum::lander => "lander".to_string(), + } + } + } + #[derive(Debug, Serialize, Deserialize, Copy, Clone)] pub enum Location { Top, diff --git a/mods/dr_game/__init__.py b/mods/dr_game/__init__.py index 17a82e5..f8f856c 100644 --- a/mods/dr_game/__init__.py +++ b/mods/dr_game/__init__.py @@ -16,7 +16,7 @@ from Difficult_Rocket.api.mod import ModInfo from Difficult_Rocket.client import ClientWindow from Difficult_Rocket.api.types import Options, Version -DR_rust_version = Version("0.2.20.2") # DR_mod 的 Rust 编写部分的兼容版本 +DR_rust_version = Version("0.2.21.0") # DR_mod 的 Rust 编写部分的兼容版本 logger = logging.getLogger('client.dr_game') diff --git a/mods/dr_game/sr1_ship.py b/mods/dr_game/sr1_ship.py index f81a35f..052404f 100644 --- a/mods/dr_game/sr1_ship.py +++ b/mods/dr_game/sr1_ship.py @@ -169,7 +169,8 @@ class SR1ShipRender(BaseScreen): part_group = Group(2, parent=self.part_group) batch = [] for p_type, p_data in parts: - part_sprite = Sprite(img=self.textures.get_texture(map_ptype_textures(p_data.part_type_id)), + sprite_name = self.part_list_rs.get_part_type(p_data.part_type_id).sprite + part_sprite = Sprite(img=self.textures.get_texture(sprite_name), x=p_data.x * 60, y=p_data.y * 60, z=random.random(), batch=self.main_batch, group=part_group) part_sprite.rotation = p_data.angle_r