GraphicsSettings = {} renderScaleText = "" stepperRenderScaleParams = {} renderScaleTooltip = {} renderQuallityText = "" stepperRenderQuallityParams = {} renderQuallityTooltip = {} particlesText = "" sliderParticleParams = {} gammaText = "" sliderGammaParams = {} foVText = "" sliderFoVParams = {} doFText = "" stepperDoFParams = {} barrelDistortText = "" stepperBarrelDistortParams = {} motionBlurText = "" stepperMotionBlurParams = {} vSyncText = "" stepperVSyncParams = {} VSyncTooltip = {} gfxModeTex = "" stepperGfxModeParams = {} displayMode120HzText = "" stepperDisplayMode120HzParams = {} graphicsApiText = "" stepperGraphicsApiParams = {} graphicsApiTooltip = {} function graphic_options_logic_init() GraphicsSettings.optionsItems = {} renderScaleText = 'loc@UI_TEXT_RENDER_SCALE' stepperRenderScaleParams = { currentIdx = GetInt("options.gfx.renderscale") / 25 - 1, allValues = { '50', '75', '100' }, isCyclic = false, getCurrentValue = function(self) return tostring(self.allValues[self.currentIdx]) .. "%" end, onNext = function(self) self.currentIdx = self.currentIdx + 1 if self.currentIdx > #self.allValues then self.currentIdx = 1 end SetInt("options.gfx.renderscale", self.allValues[self.currentIdx]) end, onPrev = function(self) self.currentIdx = self.currentIdx - 1 if self.currentIdx < 1 then self.currentIdx = #self.allValues end SetInt("options.gfx.renderscale", self.allValues[self.currentIdx]) end, forceUpdate = function(self) self.currentIdx = GetInt("options.gfx.renderscale") / 25 - 1 end } table.insert(GraphicsSettings.optionsItems, stepperRenderScaleParams) renderScaleTooltip = { header = 'loc@UI_TEXT_RENDER_SCALE', description = "loc@UI_TOOLTIP_SCALE_THE_RESOLUTION" } renderQuallityText = "loc@UI_TEXT_RENDER_QUALITY" stepperRenderQuallityParams = { currentIdx = GetInt("options.gfx.quality"), allValues = { "loc@UI_BUTTON_LOW", "loc@UI_BUTTON_MEDIUM", "loc@UI_BUTTON_HIGH" }, isCyclic = false, getCurrentValue = function(self) return self.allValues[self.currentIdx] end, onNext = function(self) self.currentIdx = self.currentIdx + 1 if self.currentIdx > #self.allValues then self.currentIdx = 1 end SetInt("options.gfx.quality", self.currentIdx) end, onPrev = function(self) self.currentIdx = self.currentIdx - 1 if self.currentIdx < 1 then self.currentIdx = #self.allValues end SetInt("options.gfx.quality", self.currentIdx) end, forceUpdate = function(self) self.currentIdx = GetInt("options.gfx.quality") end } table.insert(GraphicsSettings.optionsItems, stepperRenderQuallityParams) renderQuallityTooltip = { header = "loc@UI_TEXT_RENDER_QUALITY", description = "loc@UI_TOOLTIP_THIS_SETTING" } particlesText = "loc@UI_TEXT_PARTICLES" sliderParticleParams = { currentIdx = GetInt("options.gfx.particledensity") + 1, allValues = { "loc@UI_BUTTON_MEDIUM", "loc@UI_BUTTON_HIGH" }, isCyclic = false, getCurrentValue = function(self) return self.allValues[self.currentIdx] end, onNext = function(self) self.currentIdx = self.currentIdx + 1 if self.currentIdx > #self.allValues then self.currentIdx = 1 end SetInt("options.gfx.particledensity", self.currentIdx - 1) end, onPrev = function(self) self.currentIdx = self.currentIdx - 1 if self.currentIdx < 1 then self.currentIdx = #self.allValues end SetInt("options.gfx.particledensity", self.currentIdx - 1) end, forceUpdate = function(self) self.currentIdx = GetInt("options.gfx.particledensity") + 1 end } table.insert(GraphicsSettings.optionsItems, sliderParticleParams) gammaText = "loc@UI_TEXT_GAMMA_CORRECTION" sliderGammaParams = { currentVal = GetInt("options.gfx.gamma"), minVal = 50, maxVal = 150, step = 10, rawVal = 0, span = 0, onValueChanged = function(self) SetInt("options.gfx.gamma", self.currentVal) end, indicatorGetter = function(self) return tostring(self.currentVal) end, forceUpdate = function(self) self.currentVal = GetInt("options.gfx.gamma") self.span = self.maxVal - self.minVal self.rawVal = (self.currentVal - self.minVal) / self.span end } sliderGammaParams.span = sliderGammaParams.maxVal - sliderGammaParams.minVal sliderGammaParams.rawVal = (sliderGammaParams.currentVal - sliderGammaParams.minVal) / sliderGammaParams.span table.insert(GraphicsSettings.optionsItems, sliderGammaParams) foVText = "loc@UI_TEXT_FIELD_OF" sliderFoVParams = { currentVal = GetInt("options.gfx.fov"), minVal = 60, maxVal = 120, step = 1, rawVal = 0, span = 0, onValueChanged = function(self) SetInt("options.gfx.fov", self.currentVal) end, indicatorGetter = function(self) return tostring(self.currentVal) end, forceUpdate = function(self) self.currentVal = GetInt("options.gfx.fov") self.span = self.maxVal - self.minVal self.rawVal = (self.currentVal - self.minVal) / self.span end } sliderFoVParams.span = sliderFoVParams.maxVal - sliderFoVParams.minVal sliderFoVParams.rawVal = (sliderFoVParams.currentVal - sliderFoVParams.minVal) / sliderFoVParams.span table.insert(GraphicsSettings.optionsItems, sliderFoVParams) doFText = "loc@UI_TEXT_DEPTH_OF" stepperDoFParams = { currentIdx = GetInt("options.gfx.dof") + 1, allValues = {"loc@UI_BUTTON_DISABLED", "loc@UI_BUTTON_ENABLED"}, isCyclic = false, getCurrentValue = function(self) return self.allValues[self.currentIdx] end, onNext = function(self) self.currentIdx = self.currentIdx + 1 if self.currentIdx > #self.allValues then self.currentIdx = 1 end SetInt("options.gfx.dof", self.currentIdx - 1) end, onPrev = function(self) self.currentIdx = self.currentIdx - 1 if self.currentIdx < 1 then self.currentIdx = #self.allValues end SetInt("options.gfx.dof", self.currentIdx - 1) end, forceUpdate = function(self) self.currentIdx = GetInt("options.gfx.dof") + 1 end } table.insert(GraphicsSettings.optionsItems, stepperDoFParams) barrelDistortText = "loc@UI_TEXT_BARREL_DISTORTION" stepperBarrelDistortParams = { currentIdx = GetInt("options.gfx.barrel") + 1, allValues = {"loc@UI_BUTTON_DISABLED", "loc@UI_BUTTON_ENABLED"}, isCyclic = false, getCurrentValue = function(self) return self.allValues[self.currentIdx] end, onNext = function(self) self.currentIdx = self.currentIdx + 1 if self.currentIdx > #self.allValues then self.currentIdx = 1 end SetInt("options.gfx.barrel", self.currentIdx - 1) end, onPrev = function(self) self.currentIdx = self.currentIdx - 1 if self.currentIdx < 1 then self.currentIdx = #self.allValues end SetInt("options.gfx.barrel", self.currentIdx - 1) end, forceUpdate = function(self) self.currentIdx = GetInt("options.gfx.barrel") + 1 end } table.insert(GraphicsSettings.optionsItems, stepperBarrelDistortParams) motionBlurText = "loc@UI_TEXT_MOTION_BLUR" stepperMotionBlurParams = { currentIdx = GetInt("options.gfx.motionblur") + 1, allValues = {"loc@UI_BUTTON_DISABLED", "loc@UI_BUTTON_ENABLED"}, isCyclic = false, getCurrentValue = function(self) return self.allValues[self.currentIdx] end, onNext = function(self) self.currentIdx = self.currentIdx + 1 if self.currentIdx > #self.allValues then self.currentIdx = 1 end SetInt("options.gfx.motionblur", self.currentIdx - 1) end, onPrev = function(self) self.currentIdx = self.currentIdx - 1 if self.currentIdx < 1 then self.currentIdx = #self.allValues end SetInt("options.gfx.motionblur", self.currentIdx - 1) end, forceUpdate = function(self) self.currentIdx = GetInt("options.gfx.motionblur") + 1 end } table.insert(GraphicsSettings.optionsItems, stepperMotionBlurParams) vSyncText = "loc@UI_TEXT_VERTICAL_SYNC" stepperVSyncParams = { currentIdx = GetInt("options.gfx.vsync") + 2, allValues = { "loc@UI_BUTTON_ADAPTIVE", "loc@UI_BUTTON_DISABLED", "loc@UI_BUTTON_EVERY_FRAME", "loc@UI_BUTTON_EVERY_OTHER" }, isCyclic = false, prevGfxApi = -1, getCurrentValue = function(self) return self.allValues[self.currentIdx] end, fetchAvailableValues = function (self) local currentGfxApi = stepperGraphicsApiParams.currentIdx if self.prevGfxApi == currentGfxApi then return end if self.prevGfxApi == -1 then if GetInt("options.gfx.gfxapi") == 0 then self.currentIdx = GetInt("options.gfx.vsync") + 2 else self.currentIdx = GetInt("options.gfx.vsync") + 1 end end if currentGfxApi == 1 then self.allValues = { "loc@UI_BUTTON_ADAPTIVE", "loc@UI_BUTTON_DISABLED", "loc@UI_BUTTON_EVERY_FRAME", "loc@UI_BUTTON_EVERY_OTHER" } if self.prevGfxApi == 2 then self.currentIdx = self.currentIdx + 1 end elseif currentGfxApi == 2 then self.allValues = { "loc@UI_BUTTON_DISABLED", "loc@UI_BUTTON_EVERY_FRAME", "loc@UI_BUTTON_EVERY_OTHER" } if self.prevGfxApi == 1 then self.currentIdx = self.currentIdx - 1 end end self.currentIdx = math.clamp(self.currentIdx, 1, #self.allValues) if self.prevGfxApi ~= -1 then SetInt("options.gfx.vsync", self:getVsyncOptionNum()) end self.prevGfxApi = currentGfxApi end, getVsyncOptionNum = function (self) local currentGfxApi = stepperGraphicsApiParams.currentIdx if currentGfxApi == 1 then return self.currentIdx - 2 elseif currentGfxApi == 2 then return self.currentIdx - 1 end return 1 end, onNext = function(self) self.currentIdx = self.currentIdx + 1 if self.currentIdx > #self.allValues then self.currentIdx = 1 end SetInt("options.gfx.vsync", self:getVsyncOptionNum()) end, onPrev = function(self) self.currentIdx = self.currentIdx - 1 if self.currentIdx < 1 then self.currentIdx = #self.allValues end SetInt("options.gfx.vsync", self:getVsyncOptionNum()) end, forceUpdate = function(self) if GetInt("options.gfx.gfxapi") == 0 then self.currentIdx = GetInt("options.gfx.vsync") + 2 else self.currentIdx = GetInt("options.gfx.vsync") + 1 end end } table.insert(GraphicsSettings.optionsItems, stepperVSyncParams) -- currently this tooltip not used due to outdated information VSyncTooltip = { header = "loc@UI_TEXT_VERTICAL_SYNC", description = "loc@UI_TOOLTIP_TEARDOWN_IS" } gfxModeTex = "loc@UI_TEXT_GFX_MODE" stepperGfxModeParams = { currentIdx = GetInt("options.gfx.mode") + 1, allValues = {"loc@UI_BUTTON_PERF_MODE", "loc@UI_BUTTON_FIDELITY_MODE"}, isCyclic = false, hide120Hz = function() GraphicsSettings.listItems[#GraphicsSettings.listItems] = GraphicsSettings.empty end, show120Hz = function() GraphicsSettings.listItems[#GraphicsSettings.listItems] = GraphicsSettings.item11 end, getCurrentValue = function(self) return self.allValues[self.currentIdx] end, update120 = function(self) if self.currentIdx == 1 then self:show120Hz() SetInt("options.gfx.enable120hz", stepperDisplayMode120HzParams.currentIdx - 1) else self:hide120Hz() SetInt("options.gfx.enable120hz", 0) end end, onNext = function(self) self.currentIdx = self.currentIdx + 1 if self.currentIdx > #self.allValues then self.currentIdx = 1 end SetInt("options.gfx.mode", self.currentIdx - 1) self:update120() end, onPrev = function(self) self.currentIdx = self.currentIdx - 1 if self.currentIdx < 1 then self.currentIdx = #self.allValues end SetInt("options.gfx.mode", self.currentIdx - 1) self:update120() end, forceUpdate = function(self) if IsRunningOnXboxX() or IsRunningOnPlaystation5() then local optionGfx = GetInt("options.gfx.mode") self.currentIdx = optionGfx + 1 if self.currentIdx == 1 then self:show120Hz() else self:hide120Hz() end end end } table.insert(GraphicsSettings.optionsItems, stepperGfxModeParams) displayMode120HzText = "loc@UI_TEXT_120HZ" stepperDisplayMode120HzParams = { currentIdx = GetInt("options.gfx.enable120hz") + 1, allValues = {"loc@UI_BUTTON_DISABLED", "loc@UI_BUTTON_ENABLED"}, isCyclic = false, getCurrentValue = function(self) return self.allValues[self.currentIdx] end, onNext = function(self) self.currentIdx = self.currentIdx + 1 if self.currentIdx > #self.allValues then self.currentIdx = 1 end SetInt("options.gfx.enable120hz", self.currentIdx - 1) end, onPrev = function(self) self.currentIdx = self.currentIdx - 1 if self.currentIdx < 1 then self.currentIdx = #self.allValues end SetInt("options.gfx.enable120hz", self.currentIdx - 1) end, forceUpdate = function(self) local option120 = GetInt("options.gfx.enable120hz") self.currentIdx = option120 + 1 end } table.insert(GraphicsSettings.optionsItems, stepperDisplayMode120HzParams) graphicsApiText = "loc@UI_TEXT_GRAPHICS_API" stepperGraphicsApiParams = { initialIdx = GetInt("options.gfx.gfxapi") + 1, currentIdx = GetInt("options.gfx.gfxapi") + 1, dx12Support = GetInt("options.gfx.d3d12support"), allValues = {"OpenGL", "Direct3D 12"}, isCyclic = false, canChange = GetString("game.state") == "MENU", getCurrentValue = function(self) return self.allValues[self.currentIdx] end, onNext = function(self) if not self.canChange then return end self.currentIdx = self.currentIdx + 1 if self.currentIdx > #self.allValues then self.currentIdx = 1 end stepperVSyncParams:fetchAvailableValues() end, onPrev = function(self) if not self.canChange then return end self.currentIdx = self.currentIdx - 1 if self.currentIdx < 1 then self.currentIdx = #self.allValues end stepperVSyncParams:fetchAvailableValues() end, hasChanges = function(self) return self.initialIdx ~= self.currentIdx end, applyChanges = function(self) SetInt("options.gfx.gfxapi", self.currentIdx - 1) end, forceUpdate = function(self) end } graphicsApiTooltip = { header = "loc@UI_TEXT_OLD_WINDOWS_VERSION", description = stepperGraphicsApiParams.canChange and "loc@UI_TOOLTIP_D3D12_WARNING" or "loc@UI_TEXT_DISPLAY_SETTINGS" } GraphicsSettings.onResetRequested = function() Command("options.gfx.resettodefault") for i=1,#GraphicsSettings.optionsItems do GraphicsSettings.optionsItems[i]:forceUpdate() end end end graphic_options_logic_init()