Repository navigation
Expand file tree
/
Copy pathGraphics.lua
More file actions
217 lines (197 loc) · 7.59 KB
/
Copy pathGraphics.lua
File metadata and controls
217 lines (197 loc) · 7.59 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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
setfenv(1, _G.SlackHacks)
--=====================================================================
-- Graphics
--=====================================================================
-- Hidden graphical options and advanced rendering CVars:
-- * groundEffectDensity: Foliage and clutter density (grass, ferns, rocks).
-- * groundEffectFade: Distance at which ground clutter begins fading out.
-- * groundEffectDist: Maximum draw distance for ground clutter rendering.
-- * lodObjectFadeScale: Fade distance scale for level of detail (LoD) doodads/objects.
-- * lodObjectCullSize: Pixel size threshold below which small objects are culled.
-- * terrainLodDist: Maximum draw distance for high-detail terrain mesh geometry.
-- * ResampleAlwaysSharpen: Runs spatial sharpening filter pass even without FSR upscaling.
-- * reflectionMode: Water reflection quality mode (0: off, 1: terrain, 2: objects, 3: all/sky).
-- * weatherDensity: Precipitation and weather effect intensity (0: off, 1-3: density).
local module = Self:NewModule("Graphics", "AceEvent-3.0")
Self.Graphics = module
local function settings()
return db.profile.graphics
end
-- Standard Blizzard defaults used as fallbacks when restoring game defaults
local BLIZZARD_DEFAULTS = {
groundEffectDensity = 16,
groundEffectFade = 70,
groundEffectDist = 70,
lodObjectFadeScale = 100,
lodObjectCullSize = 15,
terrainLodDist = 400,
ResampleAlwaysSharpen = 0,
reflectionMode = 0,
weatherDensity = 2,
}
local CVAR_NAMES = {
groundEffectDensity = "groundEffectDensity",
groundEffectFade = "groundEffectFade",
groundEffectDist = "groundEffectDist",
lodObjectFadeScale = "lodObjectFadeScale",
lodObjectCullSize = "lodObjectCullSize",
terrainLodDist = "terrainLodDist",
resampleAlwaysSharpen = "ResampleAlwaysSharpen",
reflectionMode = "reflectionMode",
weatherDensity = "weatherDensity",
}
local function applyCVar(cvar, value)
if GetCVar(cvar) ~= nil then
ensureCVar(cvar, value)
end
end
local function revertCVar(cvar, fallbackDefault)
if GetCVar(cvar) ~= nil then
local defaultVal = GetCVarDefault(cvar)
if defaultVal == nil or defaultVal == "" then
defaultVal = fallbackDefault
end
ensureCVar(cvar, defaultVal)
end
end
--- Returns the game's default value for a given graphics CVar key.
function module:GetDefault(key)
local cvarName = CVAR_NAMES[key] or key
if GetCVarDefault then
local def = GetCVarDefault(cvarName)
if def ~= nil and def ~= "" then
local num = tonumber(def)
if num then return num end
end
end
return BLIZZARD_DEFAULTS[cvarName] or BLIZZARD_DEFAULTS[key]
end
function module:Apply(key)
if not settings().enabled then return end
if key == "groundEffectDensity" then
if settings().enableGroundEffectDensity then
applyCVar("groundEffectDensity", settings().groundEffectDensity)
else
revertCVar("groundEffectDensity", BLIZZARD_DEFAULTS.groundEffectDensity)
end
elseif key == "groundEffectFade" then
if settings().enableGroundEffectFade then
applyCVar("groundEffectFade", settings().groundEffectFade)
else
revertCVar("groundEffectFade", BLIZZARD_DEFAULTS.groundEffectFade)
end
elseif key == "groundEffectDist" then
if settings().enableGroundEffectDist then
applyCVar("groundEffectDist", settings().groundEffectDist)
else
revertCVar("groundEffectDist", BLIZZARD_DEFAULTS.groundEffectDist)
end
elseif key == "lodObjectFadeScale" then
if settings().enableLodObjectFadeScale then
applyCVar("lodObjectFadeScale", settings().lodObjectFadeScale)
else
revertCVar("lodObjectFadeScale", BLIZZARD_DEFAULTS.lodObjectFadeScale)
end
elseif key == "lodObjectCullSize" then
if settings().enableLodObjectCullSize then
applyCVar("lodObjectCullSize", settings().lodObjectCullSize)
else
revertCVar("lodObjectCullSize", BLIZZARD_DEFAULTS.lodObjectCullSize)
end
elseif key == "terrainLodDist" then
if settings().enableTerrainLodDist then
applyCVar("terrainLodDist", settings().terrainLodDist)
else
revertCVar("terrainLodDist", BLIZZARD_DEFAULTS.terrainLodDist)
end
elseif key == "resampleAlwaysSharpen" then
if settings().resampleAlwaysSharpen then
applyCVar("ResampleAlwaysSharpen", 1)
else
revertCVar("ResampleAlwaysSharpen", BLIZZARD_DEFAULTS.ResampleAlwaysSharpen)
end
elseif key == "reflectionMode" then
if settings().enableReflectionMode then
applyCVar("reflectionMode", settings().reflectionMode)
else
revertCVar("reflectionMode", BLIZZARD_DEFAULTS.reflectionMode)
end
elseif key == "weatherDensity" then
if settings().enableWeatherDensity then
applyCVar("weatherDensity", settings().weatherDensity)
else
revertCVar("weatherDensity", BLIZZARD_DEFAULTS.weatherDensity)
end
else
self:ApplyAll()
end
end
function module:ApplyAll()
if not settings().enabled then return end
self:Apply("groundEffectDensity")
self:Apply("groundEffectFade")
self:Apply("groundEffectDist")
self:Apply("lodObjectFadeScale")
self:Apply("lodObjectCullSize")
self:Apply("terrainLodDist")
self:Apply("resampleAlwaysSharpen")
self:Apply("reflectionMode")
self:Apply("weatherDensity")
end
function module:RestoreDefaults()
revertCVar("groundEffectDensity", BLIZZARD_DEFAULTS.groundEffectDensity)
revertCVar("groundEffectFade", BLIZZARD_DEFAULTS.groundEffectFade)
revertCVar("groundEffectDist", BLIZZARD_DEFAULTS.groundEffectDist)
revertCVar("lodObjectFadeScale", BLIZZARD_DEFAULTS.lodObjectFadeScale)
revertCVar("lodObjectCullSize", BLIZZARD_DEFAULTS.lodObjectCullSize)
revertCVar("terrainLodDist", BLIZZARD_DEFAULTS.terrainLodDist)
revertCVar("ResampleAlwaysSharpen", BLIZZARD_DEFAULTS.ResampleAlwaysSharpen)
revertCVar("reflectionMode", BLIZZARD_DEFAULTS.reflectionMode)
revertCVar("weatherDensity", BLIZZARD_DEFAULTS.weatherDensity)
end
function module:ResetToDefaults()
settings().enableGroundEffectDensity = false
settings().groundEffectDensity = self:GetDefault("groundEffectDensity")
settings().enableGroundEffectFade = false
settings().groundEffectFade = self:GetDefault("groundEffectFade")
settings().enableGroundEffectDist = false
settings().groundEffectDist = self:GetDefault("groundEffectDist")
settings().enableLodObjectFadeScale = false
settings().lodObjectFadeScale = self:GetDefault("lodObjectFadeScale")
settings().enableLodObjectCullSize = false
settings().lodObjectCullSize = self:GetDefault("lodObjectCullSize")
settings().enableTerrainLodDist = false
settings().terrainLodDist = self:GetDefault("terrainLodDist")
settings().resampleAlwaysSharpen = false
settings().enableReflectionMode = false
settings().reflectionMode = self:GetDefault("reflectionMode")
settings().enableWeatherDensity = false
settings().weatherDensity = self:GetDefault("weatherDensity")
self:RestoreDefaults()
local acr = LibStub("AceConfigRegistry-3.0", true)
if acr then
acr:NotifyChange("SlackHacks")
end
end
module.UnsetAll = module.ResetToDefaults
function module:SetEnabled(enabled)
settings().enabled = enabled
if enabled then
self:Enable()
else
self:Disable()
end
end
function module:OnInitialize()
if not settings().enabled then
self:Disable()
end
end
function module:OnEnable()
self:RegisterEvent("PLAYER_ENTERING_WORLD", "ApplyAll")
self:ApplyAll()
end
function module:OnDisable()
self:UnregisterAllEvents()
self:RestoreDefaults()
end