Skip to content

Commit 1d59b33

Browse files
committed
Restore access to The Amazing Secret
1 parent 3455a36 commit 1d59b33

File tree

14 files changed

+63
-7
lines changed

14 files changed

+63
-7
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## v0.1.2 – 2020-04-19
4+
5+
- Restore access to The Amazing Secret.
6+
37
## v0.1.1 – 2020-04-18
48

59
- `/show_triggers` now also draws load regions
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
use crate::hooks::ON_POST_UPDATE_QUEUE;
2-
use darksiders1_sys::target;
1+
use crate::{darksiders1::gfc, hooks::ON_POST_UPDATE_QUEUE};
32

43
pub fn run(_command: &str) {
54
let mut guard = ON_POST_UPDATE_QUEUE.lock();
@@ -10,6 +9,6 @@ pub fn run(_command: &str) {
109
}
1110

1211
unsafe fn go() {
13-
let window_helper = *target::gfc__Singleton_gfc__WindowHelper_gfc__CreateStatic_gfc__SingletonLongevity__DieFirst___InstanceHandle;
14-
target::gfc__WindowHelper__pushWindow(window_helper, hstring!("ui_core/loadmapmenu").as_ptr());
12+
let window_helper = <gfc::Singleton<gfc::WindowHelper>>::get_instance();
13+
window_helper.push_window(&hstring!("ui_core/loadmapmenu"));
1514
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
pub mod helper;
22
pub mod teleporthelper;
3+
pub mod windowhelper;
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
use crate::darksiders1::{gfc, Lift};
2+
use darksiders1_sys::target;
3+
4+
struct_wrapper!(WindowHelper, target::gfc__WindowHelper);
5+
struct_wrapper_super!(WindowHelper, gfc::Helper);
6+
7+
impl WindowHelper {
8+
pub fn push_window(&self, wndclass: &gfc::HString) {
9+
unsafe {
10+
target::gfc__WindowHelper__pushWindow(self.as_ptr(), wndclass.as_ptr());
11+
}
12+
}
13+
14+
pub fn get_window(&self) -> gfc::AutoRef<gfc::_UIControl> {
15+
self.inner.mWindow.lift_ref().clone()
16+
}
17+
}

crates/aether/src/darksiders1/code/vigil/gfc/base/autoref.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,11 @@ macro_rules! lowered_autoref {
157157
}
158158
}
159159

160+
lowered_autoref!(
161+
target::gfc__AutoRef_gfc___UIControl_,
162+
target::gfc___UIControl,
163+
lift = true,
164+
);
160165
lowered_autoref!(target::gfc__AutoRef_gfc__Camera3D_, target::gfc__Camera3D);
161166
lowered_autoref!(
162167
target::gfc__AutoRef_gfc__CShape_,
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
pub mod uicontrol;
12
pub mod uimanager;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
use crate::darksiders1::{gfc, Lift};
2+
use darksiders1_sys::target;
3+
4+
struct_wrapper!(_UIControl, target::gfc___UIControl);
5+
struct_wrapper_super!(_UIControl, gfc::Object);
6+
7+
impl _UIControl {
8+
pub fn name(&self) -> &gfc::HString {
9+
self.inner.mName.lift_ref()
10+
}
11+
}

crates/aether/src/darksiders1/code/vigil/gfc/util/singleton.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,7 @@ impl_singleton!(
5252
gfc::TeleportHelper,
5353
target::gfc__Singleton_gfc__TeleportHelper_gfc__CreateStatic_gfc__DefaultLifetime___InstanceHandle,
5454
);
55+
impl_singleton!(
56+
gfc::WindowHelper,
57+
target::gfc__Singleton_gfc__WindowHelper_gfc__CreateStatic_gfc__SingletonLongevity__DieFirst___InstanceHandle,
58+
);

crates/aether/src/darksiders1/gfc.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ pub use crate::darksiders1::code::vigil::{
22
darksiders::{
33
client::{
44
darksiders::Darksiders,
5-
helpers::{helper::Helper, teleporthelper::TeleportHelper},
5+
helpers::{helper::Helper, teleporthelper::TeleportHelper, windowhelper::WindowHelper},
66
ui::dsuimanager::DSUIManager,
77
},
88
world::{
@@ -50,7 +50,7 @@ pub use crate::darksiders1::code::vigil::{
5050
memory::memop::{mem_alloc, mem_free},
5151
oc::ooobjectwriter::OOObjectWriter,
5252
reflection::scriptclass::ScriptClass,
53-
ui::uimanager::_UIManager,
53+
ui::{uicontrol::_UIControl, uimanager::_UIManager},
5454
util::{
5555
hstring::HString,
5656
singleton::Singleton,

crates/aether/src/hooks.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ mod hook {
9999
spawn_humans,
100100
},
101101
console::{self, InputHandled},
102-
darksiders1::{Lift, Lower},
102+
darksiders1::{gfc, Lift, Lower},
103103
hooks::{DETOURS, ON_POST_UPDATE_QUEUE},
104104
library::objects::{
105105
override_get_material,
@@ -128,13 +128,23 @@ mod hook {
128128

129129
// Return `false` to swallow the event, or `true` to continue processing
130130
// normally.
131+
#[allow(clippy::shadow_unrelated)]
131132
pub unsafe extern "thiscall" fn gfc__Darksiders__processInputEvent(
132133
this: *mut target::gfc__Darksiders,
133134
inputEvent: *const target::keen__InputEvent,
134135
) -> bool {
135136
let guard = DETOURS.read();
136137
let detours = guard.as_ref().unwrap();
137138

139+
// Restore access to The Amazing Secret.
140+
let window_helper = <gfc::Singleton<gfc::WindowHelper>>::get_instance();
141+
let current_window = window_helper.get_window();
142+
let result =
143+
target::gfc__Darksiders__doTheMagic(this, inputEvent, current_window.name().as_ptr());
144+
if !result {
145+
return false;
146+
}
147+
138148
let result = (detours.gfc__Darksiders__processInputEvent)(this, inputEvent);
139149

140150
// Setting this flag prevents the game from pausing when you deactivate the

0 commit comments

Comments
 (0)