pub mod os;
pub mod gfx;
pub mod av;
pub mod image;
pub mod imgui;
pub mod imdraw;
pub mod pmfx;
pub mod primitives;
pub mod client;
pub mod plugin;
pub mod reloader;
pub mod ecs_base;
#[macro_use]
extern crate bitflags;
pub struct Error {
pub msg: String,
}
impl std::fmt::Debug for Error {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.msg)
}
}
impl<T> From<T> for Error where T: ToString {
fn from(err: T) -> Error {
Error {
msg: err.to_string()
}
}
}
#[cfg(debug_assertions)]
pub const fn get_config_name() -> &'static str {
"debug"
}
#[cfg(not(debug_assertions))]
pub const fn get_config_name() -> &'static str {
"release"
}
pub fn get_src_data_path(asset: &str) -> String {
let exe_path = std::env::current_exe().ok().unwrap();
let data_path = exe_path.parent().unwrap().join("../../hotline-data/src");
if data_path.join(asset).exists() {
let path = std::fs::canonicalize(data_path.join(asset)).unwrap();
String::from(path.to_str().unwrap()).replace("\\\\?\\", "")
}
else {
let data_path = exe_path.parent().unwrap().join("../../../hotline-data/src");
if data_path.join(asset).exists() {
let path = std::fs::canonicalize(data_path.join(asset)).unwrap();
String::from(path.to_str().unwrap()).replace("\\\\?\\", "")
}
else {
panic!();
}
}
}
pub fn get_data_path(asset: &str) -> String {
let exe_path = std::env::current_exe().ok().unwrap();
let data_path = exe_path.parent().unwrap().join("../data");
if data_path.exists() {
let path = std::fs::canonicalize(data_path.join(asset));
if path.is_err() {
println!("{:?}", data_path);
println!("{}", asset);
}
String::from(path.unwrap().to_str().unwrap()).replace("\\\\?\\", "")
}
else {
let data_path = exe_path.parent().unwrap().join("../../data");
if data_path.exists() {
let path = std::fs::canonicalize(data_path.join(asset)).unwrap();
String::from(path.to_str().unwrap()).replace("\\\\?\\", "")
}
else {
panic!()
}
}
}
pub fn get_exe_path(asset: &str) -> String {
let exe_path = std::env::current_exe().ok().unwrap();
String::from(exe_path.join(asset).to_str().unwrap())
}
fn get_files_recursive(dir: &str, mut files: Vec<String>) -> Vec<String> {
let paths = std::fs::read_dir(dir).unwrap();
for path in paths {
let path = path.unwrap().path();
if std::fs::read_dir(&path).is_ok() {
files = get_files_recursive(path.to_str().unwrap(), files);
}
else {
files.push(path.to_str().unwrap().to_string());
}
}
files
}
#[cfg(target_os = "windows")]
pub use os::win32 as os_platform;
#[cfg(target_os = "windows")]
pub use gfx::d3d12 as gfx_platform;
#[cfg(target_os = "windows")]
pub use av::wmf as av_platform;
#[cfg(target_os = "windows")]
pub mod prelude {
#[doc(hidden)]
pub use crate::{
gfx,
os,
client,
plugin,
pmfx,
imgui,
image,
gfx_platform,
os_platform,
av_platform,
ecs_base::*,
gfx::{Device, SwapChain, CmdBuf, Texture, RenderPass, Pipeline, Buffer},
pmfx::{DrawData, MaterialData, PointLightData, SpotLightData, DirectionalLightData, WorldBufferReserveInfo, WorldBufferInfo},
os::{App, Window},
pmfx::Pmfx,
imgui::ImGui,
imdraw::ImDraw,
client::{Client, HotlineInfo, PluginInfo},
plugin::{Plugin},
av::{VideoPlayer},
hotline_plugin,
system_func,
render_func,
render_func_closure,
compute_func,
compute_func_closure,
compute_func_query,
compute_func_query_closure,
demos,
systems
};
}
#[cfg(not(target_os = "windows"))]
pub mod prelude {
#[doc(hidden)]
pub use crate::{
gfx,
os,
client,
plugin,
pmfx,
imgui,
gfx::{Device, SwapChain, CmdBuf, Texture, RenderPass},
os::{App, Window},
pmfx::Pmfx,
imgui::ImGui,
imdraw::ImDraw,
client::{Client, HotlineInfo, PluginInfo},
plugin::{Plugin},
av::{VideoPlayer},
};
}