Skip to content

Commit e7d7d6d

Browse files
committed
feat: prototype overlay based ui
1 parent 8d9092b commit e7d7d6d

File tree

5 files changed

+457
-20
lines changed

5 files changed

+457
-20
lines changed

Cargo.lock

Lines changed: 143 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ crate-type = ["cdylib"]
1616
# Shared backing library
1717
pocket-relay-client-shared = { version = "^0.3" }
1818

19+
1920
# Logging
2021
env_logger = "0.10"
2122
log = "0.4"
@@ -30,6 +31,10 @@ native-windows-gui = { version = "1", features = ["notice"] }
3031
native-windows-derive = { version = "1" }
3132

3233
futures = "0.3"
34+
hudhook = { version = "0.8.1", default-features = false, features = [
35+
"dx9",
36+
], path = "./hudhook" }
37+
parking_lot = "0.12.4"
3338

3439
[dependencies.windows-sys]
3540
version = "0.52"

hudhook

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit 1894821416ca5c3c707e9071dff089b9aead6492

src/lib.rs

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,19 @@ use core::{
55
api::{create_http_client, read_client_identity},
66
reqwest::{Client, Identity},
77
};
8+
use hudhook::{hooks::dx9::ImguiDx9Hooks, Hudhook};
89
use log::error;
910
use pocket_relay_client_shared as core;
1011
use std::path::Path;
1112
use ui::{confirm_message, error_message};
1213
use windows_sys::Win32::System::SystemServices::{DLL_PROCESS_ATTACH, DLL_PROCESS_DETACH};
1314

15+
use crate::overlay::OverlayRenderLoop;
16+
1417
pub mod config;
1518
pub mod game;
1619
pub mod hooks;
20+
pub mod overlay;
1721
pub mod servers;
1822
pub mod threads;
1923
pub mod ui;
@@ -23,9 +27,9 @@ pub mod update;
2327
pub const APP_VERSION: &str = env!("CARGO_PKG_VERSION");
2428

2529
/// Handles the plugin being attached to the game
26-
fn attach() {
30+
fn attach(hmodule: isize) {
2731
// Suspend all game threads so the user has a chance to connect to a server
28-
threads::suspend_all_threads();
32+
// threads::suspend_all_threads();
2933

3034
// Debug allocates a console window to display output
3135
#[cfg(debug_assertions)]
@@ -54,10 +58,30 @@ fn attach() {
5458
// Create the internal HTTP client
5559
let client: Client = create_http_client(identity).expect("Failed to create HTTP client");
5660

57-
std::thread::spawn(|| {
58-
// Initialize the UI
59-
ui::init(config, client);
61+
std::thread::spawn(move || {
62+
// Create tokio async runtime
63+
let runtime = tokio::runtime::Builder::new_multi_thread()
64+
.enable_all()
65+
.build()
66+
.expect("Failed building tokio runtime");
67+
68+
// Spawn the updating task
69+
runtime.spawn(update::update(client.clone()));
70+
71+
if let Err(e) = Hudhook::builder()
72+
.with::<ImguiDx9Hooks>(OverlayRenderLoop::new(runtime, config, client))
73+
.with_hmodule(hudhook::windows::Win32::Foundation::HINSTANCE(hmodule))
74+
.build()
75+
.apply()
76+
{
77+
error!("Couldn't apply hooks: {e:?}");
78+
}
6079
});
80+
81+
// std::thread::spawn(|| {
82+
// // Initialize the UI
83+
// ui::init(config, client);
84+
// });
6185
}
6286

6387
/// Handles the plugin being detached from the game, this handles
@@ -99,10 +123,10 @@ fn load_identity() -> Option<Identity> {
99123
/// Windows DLL entrypoint for the plugin
100124
#[no_mangle]
101125
#[allow(non_snake_case)]
102-
extern "stdcall" fn DllMain(_hmodule: isize, reason: u32, _: *mut ()) -> bool {
126+
extern "stdcall" fn DllMain(hmodule: isize, reason: u32, _: *mut ()) -> bool {
103127
match reason {
104128
// Handle attaching
105-
DLL_PROCESS_ATTACH => attach(),
129+
DLL_PROCESS_ATTACH => attach(hmodule),
106130
// Handle detaching
107131
DLL_PROCESS_DETACH => detach(),
108132
_ => {}

0 commit comments

Comments
 (0)