forked from praydog/REFramework
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMods.cpp
More file actions
160 lines (125 loc) · 4 KB
/
Mods.cpp
File metadata and controls
160 lines (125 loc) · 4 KB
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
#include <spdlog/spdlog.h>
#include "mods/BackBufferRenderer.hpp"
#include "mods/APIProxy.hpp"
#include "mods/Camera.hpp"
#include "mods/Graphics.hpp"
#include "mods/DeveloperTools.hpp"
#include "mods/FirstPerson.hpp"
#include "mods/FreeCam.hpp"
#include "mods/Hooks.hpp"
#include "mods/IntegrityCheckBypass.hpp"
#include "mods/ManualFlashlight.hpp"
#include "mods/PluginLoader.hpp"
#include "mods/REFrameworkConfig.hpp"
#include "mods/Scene.hpp"
#include "mods/ScriptRunner.hpp"
#include "mods/VR.hpp"
#include "mods/LooseFileLoader.hpp"
#include "mods/vr/games/RE8VR.hpp"
#include "Mods.hpp"
Mods::Mods() {
m_mods.emplace_back(BackBufferRenderer::get());
m_mods.emplace_back(REFrameworkConfig::get());
#if defined(REENGINE_AT)
m_mods.emplace_back(IntegrityCheckBypass::get_shared_instance());
#endif
#ifndef BAREBONES
m_mods.emplace_back(Hooks::get());
m_mods.emplace_back(LooseFileLoader::get());
m_mods.emplace_back(VR::get());
#if defined(RE8) || defined(RE7)
m_mods.emplace_back(RE8VR::get());
#endif
#ifndef RE8
#if defined(RE2) || defined(RE3)
m_mods.emplace_back(FirstPerson::get());
#endif
#endif
// All games!!!!
m_mods.emplace_back(std::make_unique<Camera>());
m_mods.emplace_back(Graphics::get());
#if defined(RE2) || defined(RE3) || defined(RE8)
m_mods.emplace_back(std::make_unique<ManualFlashlight>());
#endif
m_mods.emplace_back(std::make_unique<FreeCam>());
#if TDB_VER > 49
m_mods.emplace_back(std::make_unique<SceneMods>());
#endif
#endif
#ifdef DEVELOPER
auto dev_tools = std::make_shared<DeveloperTools>();
m_mods.emplace_back(dev_tools);
for (auto& tool : dev_tools->get_tools()) {
m_mods.emplace_back(tool);
}
#endif
m_mods.emplace_back(APIProxy::get());
m_mods.emplace_back(PluginLoader::get());
m_mods.emplace_back(ScriptRunner::get());
}
std::optional<std::string> Mods::on_initialize() const {
for (auto& mod : m_mods) {
spdlog::info("{:s}::on_initialize()", mod->get_name().data());
if (auto e = mod->on_initialize(); e != std::nullopt) {
spdlog::info("{:s}::on_initialize() has failed: {:s}", mod->get_name().data(), *e);
return e;
}
}
utility::Config cfg{ (REFramework::get_persistent_dir() / REFrameworkConfig::REFRAMEWORK_CONFIG_NAME).string() };
for (auto& mod : m_mods) {
spdlog::info("{:s}::on_config_load()", mod->get_name().data());
mod->on_config_load(cfg);
}
return std::nullopt;
}
std::optional<std::string> Mods::on_initialize_d3d_thread() const {
auto do_not_hook_d3d = g_framework->acquire_do_not_hook_d3d();
utility::Config cfg{ (REFramework::get_persistent_dir() / REFrameworkConfig::REFRAMEWORK_CONFIG_NAME).string() };
// once here to at least setup the values
for (auto& mod : m_mods) {
spdlog::info("{:s}::on_config_load()", mod->get_name().data());
mod->on_config_load(cfg);
}
for (auto& mod : m_mods) {
spdlog::info("{:s}::on_initialize_d3d_thread()", mod->get_name().data());
if (auto e = mod->on_initialize_d3d_thread(); e != std::nullopt) {
spdlog::info("{:s}::on_initialize_d3d_thread() has failed: {:s}", mod->get_name().data(), *e);
return e;
}
}
for (auto& mod : m_mods) {
spdlog::info("{:s}::on_config_load()", mod->get_name().data());
mod->on_config_load(cfg);
}
return std::nullopt;
}
void Mods::on_pre_imgui_frame() const {
for (auto& mod : m_mods) {
mod->on_pre_imgui_frame();
}
}
void Mods::on_frame() const {
for (auto& mod : m_mods) {
mod->on_frame();
}
}
void Mods::on_present() const {
for (auto& mod : m_mods) {
mod->on_present();
}
}
void Mods::on_post_frame() const {
for (auto& mod : m_mods) {
mod->on_post_frame();
}
}
void Mods::on_draw_ui() const {
for (auto& mod : m_mods) {
mod->on_draw_ui();
}
}
void Mods::on_device_reset() const {
for (auto& mod : m_mods) {
mod->on_device_reset();
}
}