Skip to content

Commit 6f66aff

Browse files
committed
VR: Migrate object storage to Framework class
1 parent 7252d6b commit 6f66aff

3 files changed

Lines changed: 10 additions & 3 deletions

File tree

src/Framework.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,8 @@ void Framework::command_thread() {
188188
Framework::Framework(HMODULE framework_module)
189189
: m_framework_module{framework_module}
190190
, m_game_module{GetModuleHandle(0)},
191-
m_logger{spdlog::basic_logger_mt("UnrealVR", (get_persistent_dir() / "log.txt").string(), true)}
191+
m_logger{spdlog::basic_logger_mt("UnrealVR", (get_persistent_dir() / "log.txt").string(), true)},
192+
m_vr{std::make_shared<VR>()}
192193
{
193194
std::scoped_lock __{m_constructor_mutex};
194195

src/Framework.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include <array>
44
#include <unordered_set>
5+
#include <memory>
56
#include <filesystem>
67

78
#include <spdlog/spdlog.h>
@@ -16,6 +17,7 @@
1617
#include <mods/vr/d3d12/CommandContext.hpp>
1718

1819
class Mods;
20+
class VR;
1921

2022
#include "hooks/D3D11Hook.hpp"
2123
#include "hooks/D3D12Hook.hpp"
@@ -69,6 +71,9 @@ struct SidebarEntryInfo {
6971

7072
// Global facilitator
7173
class Framework {
74+
private:
75+
std::shared_ptr<VR> m_vr{};
76+
7277
private:
7378
void hook_monitor();
7479
void command_thread();
@@ -78,6 +83,7 @@ class Framework {
7883
virtual ~Framework();
7984

8085
auto get_framework_module() const { return m_framework_module; }
86+
auto& vr() { return m_vr; }
8187

8288
bool is_valid() const { return m_valid; }
8389

src/mods/VR.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
#include "VR.hpp"
2727

2828
std::shared_ptr<VR>& VR::get() {
29-
static std::shared_ptr<VR> instance = std::make_shared<VR>();
30-
return instance;
29+
//static std::shared_ptr<VR> instance = std::make_shared<VR>();
30+
return g_framework->vr();
3131
}
3232

3333
// Called when the mod is initialized

0 commit comments

Comments
 (0)