1use super::{
4 alert::RawAlertNotify,
5 data_link::{RawDataGetResource, RawDataShareResource},
6 event::{
7 RawEventRaise, RawEventRaiseNotification, RawEventRaiseNotificationTargeted,
8 RawEventRaiseTargeted, RawEventSubscribe,
9 },
10 font::{
11 RawFontAddFromFile, RawFontAddFromMemory, RawFontAddFromResource, RawFontGet,
12 RawFontRelease, RawFontResize,
13 },
14 gamebind::{
15 RawGamebindInvokeAsync, RawGamebindIsBound, RawGamebindPress, RawGamebindPressAsync,
16 RawGamebindRelease, RawGamebindReleaseAsync,
17 },
18 gui::{
19 ImguiFree, ImguiMalloc, RawGuiAddRender, RawGuiDeregisterCloseOnEscape,
20 RawGuiRegisterCloseOnEscape, RawGuiRemRender,
21 },
22 hook::{RawHookCreate, RawHookDisable, RawHookEnable, RawHookRemove},
23 keybind::{
24 RawKeybindDeregister, RawKeybindInvoke, RawKeybindRegisterWithString,
25 RawKeybindRegisterWithStruct,
26 },
27 localization::{RawLocalizationSet, RawLocalizationTranslate, RawLocalizationTranslateTo},
28 log::RawLog,
29 paths::{RawGetAddonDir, RawGetCommonDir, RawGetGameDir},
30 quick_access::{
31 RawQuickAccessAddContextMenu2, RawQuickAccessAddShortcut, RawQuickAccessGeneric,
32 },
33 texture::{
34 RawTextureGet, RawTextureGetOrCreateFromFile, RawTextureGetOrCreateFromMemory,
35 RawTextureGetOrCreateFromResource, RawTextureGetOrCreateFromUrl, RawTextureLoadFromFile,
36 RawTextureLoadFromMemory, RawTextureLoadFromResource, RawTextureLoadFromUrl,
37 },
38 updater::RawRequestUpdate,
39 wnd_proc::{RawWndProcAddRem, RawWndProcSendToGame},
40};
41use windows::Win32::Graphics::{Direct3D11::ID3D11Device, Dxgi::IDXGISwapChain};
42
43#[derive(Debug, Clone)]
45#[repr(C)]
46pub struct AddonApi {
47 pub swap_chain: IDXGISwapChain,
49
50 pub imgui_context: *mut imgui::sys::ImGuiContext,
52
53 pub imgui_malloc: Option<ImguiMalloc>,
55
56 pub imgui_free: Option<ImguiFree>,
58
59 pub renderer: RendererApi,
61
62 pub request_update: RawRequestUpdate,
64
65 pub log: RawLog,
69
70 pub ui: UiApi,
72
73 pub path: PathApi,
75
76 pub min_hook: MinHookApi,
78
79 pub event: EventApi,
81
82 pub wnd_proc: WndProcApi,
84
85 pub input_binds: InputBindsApi,
87
88 pub game_bind: GameBindApi,
90
91 pub data_link: DataLinkApi,
93
94 pub texture: TextureApi,
96
97 pub quick_access: QuickAccessApi,
99
100 pub localization: LocalizationApi,
102
103 pub font: FontApi,
105}
106
107unsafe impl Sync for AddonApi {}
108
109unsafe impl Send for AddonApi {}
110
111impl AddonApi {
112 pub const VERSION: i32 = 6;
114
115 #[inline]
117 pub fn get_d3d11_device(&self) -> Option<ID3D11Device> {
118 unsafe { self.swap_chain.GetDevice() }.ok()
119 }
120}
121
122#[derive(Debug, Clone)]
123#[repr(C)]
124pub struct RendererApi {
125 pub register: RawGuiAddRender,
127
128 pub deregister: RawGuiRemRender,
130}
131
132#[derive(Debug, Clone)]
133#[repr(C)]
134pub struct UiApi {
135 pub send_alert: RawAlertNotify,
137
138 pub register_close_on_escape: RawGuiRegisterCloseOnEscape,
140
141 pub deregister_close_on_escape: RawGuiDeregisterCloseOnEscape,
143}
144
145#[derive(Debug, Clone)]
146#[repr(C)]
147pub struct PathApi {
148 pub get_game_dir: RawGetGameDir,
152
153 pub get_addon_dir: RawGetAddonDir,
157
158 pub get_common_dir: RawGetCommonDir,
162}
163
164#[derive(Debug, Clone)]
165#[repr(C)]
166pub struct MinHookApi {
167 pub create: RawHookCreate,
169
170 pub remove: RawHookRemove,
172
173 pub enable: RawHookEnable,
175
176 pub disable: RawHookDisable,
178}
179
180#[derive(Debug, Clone)]
181#[repr(C)]
182pub struct EventApi {
183 pub raise: RawEventRaise,
185
186 pub raise_notification: RawEventRaiseNotification,
190
191 pub raise_targeted: RawEventRaiseTargeted,
193
194 pub raise_notification_targeted: RawEventRaiseNotificationTargeted,
198
199 pub subscribe: RawEventSubscribe,
201
202 pub unsubscribe: RawEventSubscribe,
204}
205
206#[derive(Debug, Clone)]
207#[repr(C)]
208pub struct WndProcApi {
209 pub register: RawWndProcAddRem,
211
212 pub deregister: RawWndProcAddRem,
214
215 pub send_to_game_only: RawWndProcSendToGame,
217}
218
219#[derive(Debug, Clone)]
220#[repr(C)]
221pub struct InputBindsApi {
222 pub invoke: RawKeybindInvoke,
224
225 pub register_with_string: RawKeybindRegisterWithString,
229
230 pub register_with_struct: RawKeybindRegisterWithStruct,
234
235 pub deregister: RawKeybindDeregister,
237}
238
239#[derive(Debug, Clone)]
240#[repr(C)]
241pub struct GameBindApi {
242 pub press_async: RawGamebindPressAsync,
244
245 pub release_async: RawGamebindReleaseAsync,
247
248 pub invoke_async: RawGamebindInvokeAsync,
250
251 pub press: RawGamebindPress,
253
254 pub release: RawGamebindRelease,
256
257 pub is_bound: RawGamebindIsBound,
259}
260
261#[derive(Debug, Clone)]
262#[repr(C)]
263pub struct DataLinkApi {
264 pub get: RawDataGetResource,
266
267 pub share: RawDataShareResource,
269}
270
271#[derive(Debug, Clone)]
272#[repr(C)]
273pub struct TextureApi {
274 pub get: RawTextureGet,
276
277 pub get_or_create_from_file: RawTextureGetOrCreateFromFile,
279
280 pub get_or_create_from_resource: RawTextureGetOrCreateFromResource,
282
283 pub get_or_create_from_url: RawTextureGetOrCreateFromUrl,
285
286 pub get_or_create_from_memory: RawTextureGetOrCreateFromMemory,
288
289 pub load_from_file: RawTextureLoadFromFile,
291
292 pub load_from_resource: RawTextureLoadFromResource,
294
295 pub load_from_url: RawTextureLoadFromUrl,
297
298 pub load_from_memory: RawTextureLoadFromMemory,
300}
301
302#[derive(Debug, Clone)]
303#[repr(C)]
304pub struct QuickAccessApi {
305 pub add: RawQuickAccessAddShortcut,
308
309 pub remove: RawQuickAccessGeneric,
311
312 pub notify: RawQuickAccessGeneric,
314
315 pub add_context_menu: RawQuickAccessAddContextMenu2,
317
318 pub remove_context_menu: RawQuickAccessGeneric,
320}
321
322#[derive(Debug, Clone)]
323#[repr(C)]
324pub struct LocalizationApi {
325 pub translate: RawLocalizationTranslate,
328
329 pub translate_to: RawLocalizationTranslateTo,
332
333 pub set: RawLocalizationSet,
335}
336
337#[derive(Debug, Clone)]
338#[repr(C)]
339pub struct FontApi {
340 pub get: RawFontGet,
342
343 pub release: RawFontRelease,
345
346 pub add_from_file: RawFontAddFromFile,
348
349 pub add_from_resource: RawFontAddFromResource,
351
352 pub add_from_memory: RawFontAddFromMemory,
354
355 pub resize: RawFontResize,
357}