imp max_box

This commit is contained in:
shenjack 2023-05-25 00:40:20 +08:00
parent 5f4b64d961
commit 854585574f
6 changed files with 27 additions and 8 deletions

View File

@ -90,6 +90,7 @@ if TYPE_CHECKING:
class SR1Ship_rs:
""" 用于高效且省内存的读取 SR1Ship """
def __init__(self, file_path = './configs/dock1.xml', part_list = './configs/PartList.xml', ship_name = 'NewShip'): ...
@property
def name(self) -> str: ...
@property

View File

@ -12,7 +12,7 @@ package_path = 'Difficult_Rocket_rs'
setup(
name='Difficult_Rocket_rs',
version="0.2.9.1",
version="0.2.9.2",
author='shenjackyuanjie',
author_email='3695888@qq.com',
rust_extensions=[RustExtension(target="Difficult_Rocket_rs.Difficult_Rocket_rs",

View File

@ -28,7 +28,7 @@ enum LoadState {
}
#[pyfunction]
fn get_version_str() -> String { "0.2.9.1".to_string() }
fn get_version_str() -> String { "0.2.9.2".to_string() }
#[pyfunction]
fn test_call(py_obj: &PyAny) -> PyResult<bool> {

View File

@ -87,21 +87,30 @@ pub mod data {
Self { ship, part_list }
}
#[getter]
fn get_img_pos(&self) -> (i64, i64, i64, i64) {
let mut img_pos = (0, 0, 0, 0);
// let mut img_pos = (0, 0, 0, 0);
// -x, -y, +x, +y
// 左下角,右上角
let mut max_box = get_max_box(&self.ship.parts, &self.part_list);
todo!();
// img_pos
// 每个坐标 * 60
max_box.0 *= 60.0;
max_box.1 *= 60.0;
max_box.2 *= 60.0;
max_box.3 *= 60.0;
(max_box.0 as i64, max_box.1 as i64, max_box.2 as i64, max_box.3 as i64)
}
#[getter]
fn get_name(&self) -> String { self.ship.name.clone() }
#[getter]
fn get_description(&self) -> String { self.ship.description.clone() }
#[getter]
fn get_lift_off(&self) -> bool { self.ship.lift_off.to_owned() }
#[getter]
fn get_touch_ground(&self) -> bool { self.ship.touch_ground.to_owned() }
}
}

View File

@ -10,12 +10,12 @@ import traceback
from typing import Optional
from libs.MCDR.version import Version
from Difficult_Rocket.main import Game, Console
from Difficult_Rocket.main import Game
from Difficult_Rocket.api.mod import ModInfo
from Difficult_Rocket.api.types import Options
from Difficult_Rocket.client import ClientWindow
DR_rust_version = Version("0.2.9.0") # DR_mod 的 Rust 编写部分的兼容版本
DR_rust_version = Version("0.2.9.2") # DR_mod 的 Rust 编写部分的兼容版本
class _DR_mod_runtime(Options):

View File

@ -7,6 +7,7 @@
import time
import random
import logging
import traceback
from xml.etree import ElementTree
from xml.etree.ElementTree import Element
from typing import List, TYPE_CHECKING, Union, Dict, Optional, Generator
@ -36,7 +37,7 @@ if TYPE_CHECKING:
from Difficult_Rocket.client import ClientWindow
if DR_mod_runtime.use_DR_rust:
from .Difficult_Rocket_rs import CenterCamera_rs, SR1PartList_rs
from .Difficult_Rocket_rs import CenterCamera_rs, SR1PartList_rs, SR1Ship_rs
logger = logging.getLogger('client')
@ -144,6 +145,13 @@ class SR1ShipRender(BaseScreen):
self.xml_doc = cache_doc
self.xml_root = self.xml_doc.getroot()
self.xml_name = file_path
if DR_mod_runtime.use_DR_rust:
try:
self.rust_ship = SR1Ship_rs(file_path, 'configs/PartList.xml', 'a_new_ship')
print(self.rust_ship.name)
print(self.rust_ship.img_pos)
except Exception:
traceback.print_exc()
logger.info(tr().client.sr1_render.xml.load_done())
logger.info(tr().client.sr1_render.xml.load_time().format(
(time.time_ns() - start_time) / 1000000000))
@ -179,6 +187,7 @@ class SR1ShipRender(BaseScreen):
cache_sprite.x = cache_sprite.x - cache_sprite.scale_x / 2
cache_sprite.y = cache_sprite.y - cache_sprite.scale_y / 2
self.parts_sprite[part.id] = cache_sprite
# if not part_render: # 如果不渲染(渲染有毛病)
# self.parts_sprite[part.id].visible = False
count += 1