1pub mod os;
3
4pub mod gfx;
6
7pub mod av;
9
10pub mod image;
12
13pub mod imgui;
15
16pub mod imdraw;
18
19pub mod pmfx;
21
22pub mod primitives;
24
25pub mod client;
28
29pub mod plugin;
31
32pub mod reloader;
34
35pub mod ecs_base;
37
38#[macro_use]
40extern crate bitflags;
41
42pub struct Error {
44 pub msg: String,
45}
46
47impl std::fmt::Debug for Error {
49 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
50 write!(f, "{}", self.msg)
51 }
52}
53
54impl<T> From<T> for Error where T: ToString {
55 fn from(err: T) -> Error {
56 Error {
57 msg: err.to_string()
58 }
59 }
60}
61
62#[cfg(debug_assertions)]
64pub const fn get_config_name() -> &'static str {
65 "debug"
66}
67
68#[cfg(not(debug_assertions))]
70pub const fn get_config_name() -> &'static str {
71 "release"
72}
73
74pub fn get_src_data_path(asset: &str) -> String {
76 let exe_path = std::env::current_exe().ok().unwrap();
77 let data_path = exe_path.parent().unwrap().join("../../hotline-data/src");
79 if data_path.join(asset).exists() {
80 let path = std::fs::canonicalize(data_path.join(asset)).unwrap();
81 String::from(path.to_str().unwrap()).replace("\\\\?\\", "")
82 }
83 else {
84 let data_path = exe_path.parent().unwrap().join("../../../hotline-data/src");
86 if data_path.join(asset).exists() {
87 let path = std::fs::canonicalize(data_path.join(asset)).unwrap();
88 String::from(path.to_str().unwrap()).replace("\\\\?\\", "")
89 }
90 else {
91 panic!();
92 }
93 }
94}
95
96pub fn get_data_path(asset: &str) -> String {
98 let exe_path = std::env::current_exe().ok().unwrap();
99 let data_path = exe_path.parent().unwrap().join("../data");
101 if data_path.exists() {
102 let path = std::fs::canonicalize(data_path.join(asset));
103 if path.is_err() {
104 println!("{:?}", data_path);
105 println!("{}", asset);
106 }
107 String::from(path.unwrap().to_str().unwrap()).replace("\\\\?\\", "")
108 }
109 else {
110 let data_path = exe_path.parent().unwrap().join("../../data");
112 if data_path.exists() {
113 let path = std::fs::canonicalize(data_path.join(asset)).unwrap();
114 String::from(path.to_str().unwrap()).replace("\\\\?\\", "")
115 }
116 else {
117 panic!()
119 }
120 }
121}
122
123pub fn get_exe_path(asset: &str) -> String {
125 let exe_path = std::env::current_exe().ok().unwrap();
126 String::from(exe_path.join(asset).to_str().unwrap())
127}
128
129fn get_files_recursive(dir: &str, mut files: Vec<String>) -> Vec<String> {
131 let paths = std::fs::read_dir(dir).unwrap();
132 for path in paths {
133 let path = path.unwrap().path();
134 if std::fs::read_dir(&path).is_ok() {
135 files = get_files_recursive(path.to_str().unwrap(), files);
136 }
137 else {
138 files.push(path.to_str().unwrap().to_string());
139 }
140 }
141 files
142}
143
144#[cfg(target_os = "windows")]
146pub use os::win32 as os_platform;
147
148#[cfg(target_os = "windows")]
150pub use gfx::d3d12 as gfx_platform;
151
152#[cfg(target_os = "windows")]
154pub use av::wmf as av_platform;
155
156
157#[cfg(target_os = "windows")]
159pub mod prelude {
160 #[doc(hidden)]
161 pub use crate::{
162 gfx,
164 os,
165 client,
166 plugin,
167 pmfx,
168 imgui,
169 image,
170
171 gfx_platform,
173 os_platform,
174 av_platform,
175
176 ecs_base::*,
178 gfx::{Device, SwapChain, CmdBuf, Texture, RenderPass, Pipeline, Buffer},
179 pmfx::{DrawData, MaterialData, PointLightData, SpotLightData, DirectionalLightData, WorldBufferReserveInfo, WorldBufferInfo},
180 os::{App, Window},
181 pmfx::Pmfx,
182 imgui::ImGui,
183 imdraw::ImDraw,
184 client::{Client, HotlineInfo, PluginInfo},
185 plugin::{Plugin},
186 av::{VideoPlayer},
187
188 hotline_plugin,
190 system_func,
191 render_func,
192 render_func_closure,
193
194 compute_func,
195 compute_func_closure,
196 compute_func_query,
197 compute_func_query_closure,
198
199 demos,
200 systems
201 };
202}
203
204#[cfg(not(target_os = "windows"))]
205pub mod prelude {
206 #[doc(hidden)]
207 pub use crate::{
208 gfx,
210 os,
211 client,
212 plugin,
213 pmfx,
214 imgui,
215
216 gfx::{Device, SwapChain, CmdBuf, Texture, RenderPass},
218 os::{App, Window},
219 pmfx::Pmfx,
220 imgui::ImGui,
221 imdraw::ImDraw,
222 client::{Client, HotlineInfo, PluginInfo},
223 plugin::{Plugin},
224 av::{VideoPlayer},
225 };
226}