mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Removed voxygen dependency on voxygen_dynlib. Refactored anim and egui hot-reloading init.
This commit is contained in:
parent
b4dd476318
commit
9fd5c6e124
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -6176,7 +6176,6 @@ dependencies = [
|
||||
"veloren-i18n",
|
||||
"veloren-server",
|
||||
"veloren-voxygen-anim",
|
||||
"veloren-voxygen-dynlib",
|
||||
"veloren-voxygen-egui",
|
||||
"veloren-world",
|
||||
"wgpu",
|
||||
|
@ -22,8 +22,8 @@ runtimeLibs = ["libGL", "xorg.libX11", "xorg.libXcursor", "xorg.libXrandr", "xor
|
||||
buildInputs = ["xorg.libxcb"]
|
||||
|
||||
[features]
|
||||
hot-anim = ["voxygen-dynlib", "anim/use-dyn-lib"]
|
||||
hot-egui = ["voxygen-dynlib", "voxygen-egui/use-dyn-lib", "egui"]
|
||||
hot-anim = ["anim/use-dyn-lib"]
|
||||
hot-egui = ["voxygen-egui/use-dyn-lib", "egui"]
|
||||
singleplayer = ["server"]
|
||||
simd = ["vek/platform_intrinsics"]
|
||||
tracy = ["profiling", "profiling/profile-with-tracy", "common/tracy", "common-ecs/tracy", "common-frontend/tracy", "common-net/tracy", "common-systems/tracy", "common-state/tracy", "client/tracy"]
|
||||
@ -47,7 +47,6 @@ common-state = {package = "veloren-common-state", path = "../common/state"}
|
||||
anim = {package = "veloren-voxygen-anim", path = "anim"}
|
||||
i18n = {package = "veloren-i18n", path = "i18n"}
|
||||
voxygen-egui = {package = "veloren-voxygen-egui", path = "egui", optional = true }
|
||||
voxygen-dynlib = {package = "veloren-voxygen-dynlib", path = "dynlib", optional = true}
|
||||
|
||||
# Graphics
|
||||
winit = {version = "0.25.0", features = ["serde"]}
|
||||
|
@ -91,7 +91,17 @@ pub type Bone = Transform<f32, f32, f32>;
|
||||
|
||||
#[cfg(feature = "use-dyn-lib")]
|
||||
lazy_static! {
|
||||
pub static ref LIB: Arc<Mutex<Option<LoadedLib>>> = Arc::new(Mutex::new(None));
|
||||
static ref LIB: Arc<Mutex<Option<LoadedLib>>> = Arc::new(Mutex::new(None));
|
||||
}
|
||||
|
||||
#[cfg(feature = "use-dyn-lib")]
|
||||
pub fn init() {
|
||||
voxygen_dynlib::init(
|
||||
Arc::clone(&LIB),
|
||||
"veloren-voxygen-anim",
|
||||
"veloren-voxygen-anim-dyn",
|
||||
"anim",
|
||||
);
|
||||
}
|
||||
|
||||
pub trait Skeleton: Send + Sync + 'static {
|
||||
|
@ -35,69 +35,12 @@ use {
|
||||
|
||||
#[cfg(feature = "use-dyn-lib")]
|
||||
lazy_static! {
|
||||
pub static ref LIB: Arc<Mutex<Option<LoadedLib>>> = Arc::new(Mutex::new(None));
|
||||
static ref LIB: Arc<Mutex<Option<LoadedLib>>> = Arc::new(Mutex::new(None));
|
||||
}
|
||||
|
||||
#[cfg(feature = "use-dyn-lib")]
|
||||
const MAINTAIN_EGUI_FN: &[u8] = b"maintain_egui_inner\0";
|
||||
|
||||
pub fn maintain(
|
||||
platform: &mut Platform,
|
||||
egui_state: &mut EguiInnerState,
|
||||
egui_windows: &mut EguiWindows,
|
||||
client: &Client,
|
||||
debug_info: &Option<DebugInfo>,
|
||||
added_cylinder_shape_id: Option<u64>,
|
||||
) -> EguiActions {
|
||||
#[cfg(not(feature = "use-dyn-lib"))]
|
||||
{
|
||||
maintain_egui_inner(
|
||||
platform,
|
||||
egui_state,
|
||||
egui_windows,
|
||||
client,
|
||||
debug_info,
|
||||
added_cylinder_shape_id,
|
||||
)
|
||||
}
|
||||
|
||||
#[cfg(feature = "use-dyn-lib")]
|
||||
{
|
||||
let lock = LIB.lock().unwrap();
|
||||
let lib = &lock.as_ref().unwrap().lib;
|
||||
|
||||
#[allow(clippy::type_complexity)]
|
||||
let maintain_fn: voxygen_dynlib::Symbol<
|
||||
fn(
|
||||
&mut Platform,
|
||||
&mut EguiInnerState,
|
||||
&mut EguiWindows,
|
||||
&Client,
|
||||
&Option<DebugInfo>,
|
||||
Option<u64>,
|
||||
) -> EguiActions,
|
||||
> = unsafe { lib.get(MAINTAIN_EGUI_FN) }.unwrap_or_else(|e| {
|
||||
panic!(
|
||||
"Trying to use: {} but had error: {:?}",
|
||||
CStr::from_bytes_with_nul(MAINTAIN_EGUI_FN)
|
||||
.map(CStr::to_str)
|
||||
.unwrap()
|
||||
.unwrap(),
|
||||
e
|
||||
)
|
||||
});
|
||||
|
||||
maintain_fn(
|
||||
platform,
|
||||
egui_state,
|
||||
egui_windows,
|
||||
client,
|
||||
debug_info,
|
||||
added_cylinder_shape_id,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct SelectedEntityInfo {
|
||||
entity_id: u32,
|
||||
debug_shape_id: Option<u64>,
|
||||
@ -159,6 +102,73 @@ pub struct EguiActions {
|
||||
pub actions: Vec<DebugShapeAction>,
|
||||
}
|
||||
|
||||
#[cfg(feature = "use-dyn-lib")]
|
||||
pub fn init() {
|
||||
voxygen_dynlib::init(
|
||||
Arc::clone(&LIB),
|
||||
"veloren-voxygen-egui",
|
||||
"veloren-voxygen-egui-dyn",
|
||||
"egui",
|
||||
);
|
||||
}
|
||||
|
||||
pub fn maintain(
|
||||
platform: &mut Platform,
|
||||
egui_state: &mut EguiInnerState,
|
||||
egui_windows: &mut EguiWindows,
|
||||
client: &Client,
|
||||
debug_info: &Option<DebugInfo>,
|
||||
added_cylinder_shape_id: Option<u64>,
|
||||
) -> EguiActions {
|
||||
#[cfg(not(feature = "use-dyn-lib"))]
|
||||
{
|
||||
maintain_egui_inner(
|
||||
platform,
|
||||
egui_state,
|
||||
egui_windows,
|
||||
client,
|
||||
debug_info,
|
||||
added_cylinder_shape_id,
|
||||
)
|
||||
}
|
||||
|
||||
#[cfg(feature = "use-dyn-lib")]
|
||||
{
|
||||
let lock = LIB.lock().unwrap();
|
||||
let lib = &lock.as_ref().unwrap().lib;
|
||||
|
||||
#[allow(clippy::type_complexity)]
|
||||
let maintain_fn: voxygen_dynlib::Symbol<
|
||||
fn(
|
||||
&mut Platform,
|
||||
&mut EguiInnerState,
|
||||
&mut EguiWindows,
|
||||
&Client,
|
||||
&Option<DebugInfo>,
|
||||
Option<u64>,
|
||||
) -> EguiActions,
|
||||
> = unsafe { lib.get(MAINTAIN_EGUI_FN) }.unwrap_or_else(|e| {
|
||||
panic!(
|
||||
"Trying to use: {} but had error: {:?}",
|
||||
CStr::from_bytes_with_nul(MAINTAIN_EGUI_FN)
|
||||
.map(CStr::to_str)
|
||||
.unwrap()
|
||||
.unwrap(),
|
||||
e
|
||||
)
|
||||
});
|
||||
|
||||
maintain_fn(
|
||||
platform,
|
||||
egui_state,
|
||||
egui_windows,
|
||||
client,
|
||||
debug_info,
|
||||
added_cylinder_shape_id,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "be-dyn-lib", export_name = "maintain_egui_inner")]
|
||||
pub fn maintain_egui_inner(
|
||||
platform: &mut Platform,
|
||||
|
@ -150,26 +150,16 @@ fn main() {
|
||||
assets::start_hot_reloading();
|
||||
i18n::start_hot_reloading();
|
||||
|
||||
// Initialise watcher for animation hotreloading
|
||||
// Initialise watcher for animation hot-reloading
|
||||
#[cfg(feature = "hot-anim")]
|
||||
{
|
||||
voxygen_dynlib::init(
|
||||
Arc::clone(&anim::LIB),
|
||||
"veloren-voxygen-anim",
|
||||
"veloren-voxygen-anim-dyn",
|
||||
"anim",
|
||||
);
|
||||
anim::init();
|
||||
}
|
||||
|
||||
// Initialise watcher for egui hotreloading
|
||||
// Initialise watcher for egui hot-reloading
|
||||
#[cfg(feature = "hot-egui")]
|
||||
{
|
||||
voxygen_dynlib::init(
|
||||
Arc::clone(&voxygen_egui::LIB),
|
||||
"veloren-voxygen-egui",
|
||||
"veloren-voxygen-egui-dyn",
|
||||
"egui",
|
||||
);
|
||||
voxygen_egui::init();
|
||||
}
|
||||
|
||||
// Setup audio
|
||||
|
Loading…
Reference in New Issue
Block a user