Repository navigation
Expand file tree
/
Copy pathvisuals.cpp
More file actions
83 lines (69 loc) · 2.55 KB
/
Copy pathvisuals.cpp
File metadata and controls
83 lines (69 loc) · 2.55 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
#include "hudfix.h"
namespace hudfix
{
// this is compact, for proper custom editing please use bf-visual-editor
namespace
{
using UpdateFn = int(__thiscall*)(fb::VisualEnvironmentManager* manager, const void* params);
UpdateFn oUpdate = nullptr;
void applyColorCorrection(fb::ColorCorrectionState* state)
{
fb::ColorCorrectionComponent* component = fb::ColorCorrectionComponent::fromState(state);
if (!component->isValid())
return;
component->refresh();
if (settings().neutralColors)
{
// all data colors
for (int i = 0; i < 3; ++i)
{
state->m_contrast[i] = 1.0f;
state->m_saturation[i] = 1.0f;
state->m_brightness[i] = 1.0f;
}
}
if (settings().noColorGrading)
state->m_colorGradingEnable = false;
}
void applySunFlare(fb::SunFlareState* state)
{
fb::SunFlareComponent* component = fb::SunFlareComponent::fromState(state);
if (!component->isValid())
return;
component->refresh();
if (!settings().noSunFlare)
return;
state->m_element1Enable = false;
state->m_element2Enable = false;
state->m_element3Enable = false;
state->m_element4Enable = false;
state->m_element5Enable = false;
}
int __fastcall hkUpdate(fb::VisualEnvironmentManager* _this, void*, const void* params)
{
if (_this->m_dirty)
{
for (fb::VisualEnvironmentState* state : _this->m_states)
{
if (!state)
continue;
if (state->m_colorCorrection)
applyColorCorrection(state->m_colorCorrection);
if (state->m_sunFlare)
applySunFlare(state->m_sunFlare);
}
}
return oUpdate(_this, params);
}
}
void applyVisuals()
{
if (fb::VisualEnvironmentManager* manager = fb::VisualEnvironmentManager::GetInstance())
manager->m_dirty = true;
log("neutral color correction {}, no color grading {}, no sun flare {}", settings().neutralColors, settings().noColorGrading, settings().noSunFlare);
}
void installVisualHooks()
{
hook(OFF_VisualEnvironmentManager_update, hkUpdate, &oUpdate);
}
}