1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
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)
}
}
#[cfg(target_os = "windows")]
impl From<windows::core::Error> for Error {
fn from(err: windows::core::Error) -> Error {
Error {
msg: err.message().to_string_lossy(),
}
}
}
impl From<std::io::Error> for Error {
fn from(err: std::io::Error) -> 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 asset_path = exe_path.parent().unwrap().join("../../../hotline-data/src");
let path = std::fs::canonicalize(asset_path.join(asset)).unwrap();
String::from(path.to_str().unwrap()).replace("\\\\?\\", "")
}
pub fn get_data_path(asset: &str) -> String {
let exe_path = std::env::current_exe().ok().unwrap();
let asset_path = exe_path.parent().unwrap().join("..");
if asset_path.join("data").exists() {
let path = std::fs::canonicalize(asset_path.join(asset)).unwrap();
String::from(path.to_str().unwrap()).replace("\\\\?\\", "")
}
else {
let asset_path = asset_path.join("..");
if asset_path.join("data").exists() {
let path = std::fs::canonicalize(asset_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();
println!("{}", String::from(exe_path.join(asset).to_str().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,
gfx_platform,
os_platform,
av_platform,
ecs_base::*,
gfx::{Device, SwapChain, CmdBuf, Texture, RenderPass},
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,
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},
};
}