fix build issue move ModInfo
This commit is contained in:
parent
b2534c76b9
commit
88bcc675b7
@ -4,78 +4,8 @@
|
||||
# All rights reserved
|
||||
# -------------------------------
|
||||
|
||||
# system function
|
||||
from typing import Tuple, List, Optional, TypeVar, TYPE_CHECKING
|
||||
from Difficult_Rocket.mod.api import ModInfo
|
||||
|
||||
# from libs
|
||||
from libs.MCDR.version import Version
|
||||
|
||||
# from DR
|
||||
if TYPE_CHECKING:
|
||||
from Difficult_Rocket.main import Game
|
||||
from Difficult_Rocket.client import ClientWindow
|
||||
else:
|
||||
Game = TypeVar("Game")
|
||||
ClientWindow = TypeVar("ClientWindow")
|
||||
|
||||
from Difficult_Rocket import DR_runtime
|
||||
from ..types import Options
|
||||
|
||||
RequireVersion = Tuple[Version, Version]
|
||||
# 第一个是最低兼容版本,第二个是最高兼容版本
|
||||
# 例如: ("1.0.0", "1.1.0") 表示从1.0.0版本开始兼容,到1.1.0版本结束兼容
|
||||
ForceRequire = bool
|
||||
|
||||
|
||||
class ModInfo(Options):
|
||||
"""
|
||||
加载mod时候的参数
|
||||
"""
|
||||
"""基本信息"""
|
||||
mod_id: str # mod id
|
||||
name: str # mod 名称
|
||||
version: Version # mod 版本
|
||||
|
||||
"""作者、描述"""
|
||||
writer: str # 作者
|
||||
link: str = "" # 作者链接
|
||||
description: str = "" # 描述 (务必简洁明了)
|
||||
info: str = "" # 其他信息 (可以很多很多)
|
||||
|
||||
"""版本相关信息"""
|
||||
DR_version: RequireVersion = (DR_runtime.DR_version, DR_runtime.DR_version) # DR SDK 兼容版本
|
||||
DR_Api_version: RequireVersion = (DR_runtime.API_version, DR_runtime.API_version) # DR Api版本
|
||||
Mod_Require_version: List[Tuple[str, ForceRequire, RequireVersion]] = [] # mod 依赖版本
|
||||
|
||||
"""mod 状态"""
|
||||
is_enable: bool = True # 是否启用
|
||||
is_loaded: bool = False # 是否加载
|
||||
|
||||
"""mod 配置"""
|
||||
config: Options = Options() # mod 配置存储
|
||||
old_mod: Optional["ModInfo"] = None # 旧的mod实例
|
||||
|
||||
def on_load(self, game: Game, old_self: Optional["ModInfo"] = None) -> bool:
|
||||
""" 加载时调用 """
|
||||
print(f'Mod {self.mod_id} loaded')
|
||||
return True
|
||||
|
||||
def on_client_start(self, game: Game, client: ClientWindow):
|
||||
""" 客户端启动时调用 """
|
||||
print(f'Mod {self.mod_id} client start')
|
||||
|
||||
def on_client_stop(self, game: Game, client: ClientWindow, source: str = 'window'):
|
||||
""" 客户端停止时调用 """
|
||||
print(f'Mod {self.mod_id} client stop')
|
||||
|
||||
def on_server_start(self, game: Game):
|
||||
""" 服务器启动时调用 """
|
||||
print(f'Mod {self.mod_id} server start')
|
||||
|
||||
def on_server_stop(self, game: Game):
|
||||
""" 服务器停止时调用 """
|
||||
print(f'Mod {self.mod_id} server stop')
|
||||
|
||||
def on_unload(self, game: Game):
|
||||
""" 卸载时调用 """
|
||||
print(f'Mod {self.mod_id} unloaded')
|
||||
__all__ = [
|
||||
"ModInfo"
|
||||
]
|
||||
|
@ -11,8 +11,78 @@ github: @shenjackyuanjie
|
||||
gitee: @shenjackyuanjie
|
||||
"""
|
||||
|
||||
from Difficult_Rocket.api.screen import BaseScreen
|
||||
|
||||
__all__ = ['BaseScreen']
|
||||
# system function
|
||||
from typing import Tuple, List, Optional, TypeVar, TYPE_CHECKING
|
||||
|
||||
|
||||
# from DR
|
||||
if TYPE_CHECKING:
|
||||
from Difficult_Rocket.main import Game
|
||||
from Difficult_Rocket.client import ClientWindow
|
||||
else:
|
||||
Game = TypeVar("Game")
|
||||
ClientWindow = TypeVar("ClientWindow")
|
||||
from Difficult_Rocket import DR_runtime
|
||||
from Difficult_Rocket.utils.options import Options
|
||||
|
||||
# from libs
|
||||
from libs.MCDR.version import Version
|
||||
|
||||
RequireVersion = Tuple[Version, Version]
|
||||
# 第一个是最低兼容版本,第二个是最高兼容版本
|
||||
# 例如: ("1.0.0", "1.1.0") 表示从1.0.0版本开始兼容,到1.1.0版本结束兼容
|
||||
ForceRequire = bool
|
||||
|
||||
|
||||
class ModInfo(Options):
|
||||
"""
|
||||
加载mod时候的参数
|
||||
"""
|
||||
"""基本信息"""
|
||||
mod_id: str # mod id
|
||||
name: str # mod 名称
|
||||
version: Version # mod 版本
|
||||
|
||||
"""作者、描述"""
|
||||
writer: str # 作者
|
||||
link: str = "" # 作者链接
|
||||
description: str = "" # 描述 (务必简洁明了)
|
||||
info: str = "" # 其他信息 (可以很多很多)
|
||||
|
||||
"""版本相关信息"""
|
||||
DR_version: RequireVersion = (DR_runtime.DR_version, DR_runtime.DR_version) # DR SDK 兼容版本
|
||||
DR_Api_version: RequireVersion = (DR_runtime.API_version, DR_runtime.API_version) # DR Api版本
|
||||
Mod_Require_version: List[Tuple[str, ForceRequire, RequireVersion]] = [] # mod 依赖版本
|
||||
|
||||
"""mod 状态"""
|
||||
is_enable: bool = True # 是否启用
|
||||
is_loaded: bool = False # 是否加载
|
||||
|
||||
"""mod 配置"""
|
||||
config: Options = Options() # mod 配置存储
|
||||
old_mod: Optional["ModInfo"] = None # 旧的mod实例
|
||||
|
||||
def on_load(self, game: Game, old_self: Optional["ModInfo"] = None) -> bool:
|
||||
""" 加载时调用 """
|
||||
print(f'Mod {self.mod_id} loaded')
|
||||
return True
|
||||
|
||||
def on_client_start(self, game: Game, client: ClientWindow):
|
||||
""" 客户端启动时调用 """
|
||||
print(f'Mod {self.mod_id} client start')
|
||||
|
||||
def on_client_stop(self, game: Game, client: ClientWindow, source: str = 'window'):
|
||||
""" 客户端停止时调用 """
|
||||
print(f'Mod {self.mod_id} client stop')
|
||||
|
||||
def on_server_start(self, game: Game):
|
||||
""" 服务器启动时调用 """
|
||||
print(f'Mod {self.mod_id} server start')
|
||||
|
||||
def on_server_stop(self, game: Game):
|
||||
""" 服务器停止时调用 """
|
||||
print(f'Mod {self.mod_id} server stop')
|
||||
|
||||
def on_unload(self, game: Game):
|
||||
""" 卸载时调用 """
|
||||
print(f'Mod {self.mod_id} unloaded')
|
||||
|
@ -7,8 +7,8 @@ fonts_folder = "libs/fonts"
|
||||
|
||||
[window]
|
||||
style = "None"
|
||||
width = 2571
|
||||
height = 1510
|
||||
width = 1305
|
||||
height = 722
|
||||
visible = true
|
||||
gui_scale = 1
|
||||
caption = "Difficult Rocket v{DR_version}|DR_rs v{DR_Rust_get_version}"
|
||||
|
@ -13,7 +13,7 @@ pub mod data {
|
||||
|
||||
use crate::sr1_data::part_list::RawPartList;
|
||||
use crate::sr1_data::ship::RawShip;
|
||||
use crate::types::sr1::{SR1PartData, SR1PartListTrait};
|
||||
use crate::types::sr1::{get_max_box, SR1PartData, SR1PartListTrait};
|
||||
use crate::types::sr1::{SR1PartList, SR1PartType, SR1Ship};
|
||||
|
||||
#[pyclass]
|
||||
@ -52,16 +52,11 @@ pub mod data {
|
||||
}
|
||||
|
||||
fn as_dict(&self) -> HashMap<String, PySR1PartType> {
|
||||
let mut dict = HashMap::new();
|
||||
for part_type in self.part_list.types.iter() {
|
||||
dict.insert(part_type.name.clone(), PySR1PartType::new(part_type.clone()));
|
||||
}
|
||||
dict
|
||||
self.part_list.cache.iter().map(|(k, v)| (k.clone(), PySR1PartType::new(v.clone()))).collect()
|
||||
}
|
||||
|
||||
fn get_part_type(&mut self, name: String) -> Option<PySR1PartType> {
|
||||
let cache = self.part_list.get_hash_map();
|
||||
let part_type = cache.get(&name);
|
||||
let part_type = self.part_list.cache.get(&name);
|
||||
if let Some(part_type) = part_type {
|
||||
Some(PySR1PartType::new(part_type.clone()))
|
||||
} else {
|
||||
@ -97,10 +92,8 @@ pub mod data {
|
||||
let mut img_pos = (0, 0, 0, 0);
|
||||
// -x, -y, +x, +y
|
||||
// 左下角,右上角
|
||||
for part in self.ship.types.iter() {
|
||||
// let part_box = part
|
||||
todo!("get_img_pos")
|
||||
}
|
||||
let mut max_box = get_max_box(&self.ship.parts, &self.part_list);
|
||||
todo!();
|
||||
img_pos
|
||||
}
|
||||
|
||||
|
@ -192,11 +192,7 @@ pub mod sr1 {
|
||||
for part in types.iter() {
|
||||
map.insert(part.id.clone(), part.clone());
|
||||
}
|
||||
SR1PartList {
|
||||
types,
|
||||
cache: map,
|
||||
name,
|
||||
}
|
||||
SR1PartList { types, cache: map, name }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
@ -632,9 +628,9 @@ pub mod sr1 {
|
||||
|
||||
pub fn get_max_box(parts: &Vec<SR1PartData>, part_list: &SR1PartList) -> (f64, f64, f64, f64) {
|
||||
let mut max_box = (0_f64, 0_f64, 0_f64, 0_f64);
|
||||
for part in parts.iter() {
|
||||
let part_type = part_list.get_part_type(part.part_type);
|
||||
}
|
||||
// for part in parts.iter() {
|
||||
// let part_type = part_list.get_part_type(part.id);
|
||||
// }
|
||||
todo!("get_max_box")
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user