From ce6423320e312d69eb4e45db44543d5eaf710311 Mon Sep 17 00:00:00 2001 From: Eduardo Bart Date: Fri, 30 Nov 2012 14:47:53 -0200 Subject: [PATCH] Add ambient light in graphics options --- modules/client_options/graphics.otui | 19 +++++++++++++++++++ modules/client_options/options.lua | 12 ++++++++++++ modules/client_options/options.otui | 2 +- src/otclient/mapview.cpp | 2 ++ 4 files changed, 34 insertions(+), 1 deletion(-) diff --git a/modules/client_options/graphics.otui b/modules/client_options/graphics.otui index 2b7e345b..ec50ba2b 100644 --- a/modules/client_options/graphics.otui +++ b/modules/client_options/graphics.otui @@ -95,3 +95,22 @@ Panel minimum: 1 maximum: 61 + Label + id: ambientLightLabel + anchors.left: parent.left + anchors.right: parent.right + anchors.top: prev.bottom + margin-top: 6 + @onSetup: | + local value = Options.getOption('ambientLight') + self:setText(tr('Ambient light: %s%%', value)) + + FrameRateScrollbar + id: ambientLight + anchors.left: parent.left + anchors.right: parent.right + anchors.top: prev.bottom + margin-top: 3 + minimum: 0 + maximum: 100 + diff --git a/modules/client_options/options.lua b/modules/client_options/options.lua index 1f54ed68..1a46256e 100644 --- a/modules/client_options/options.lua +++ b/modules/client_options/options.lua @@ -21,6 +21,7 @@ local defaultOptions = { showLeftPanel = false, foregroundFrameRate = 61, backgroundFrameRate = 201, + ambientLight = 15, painterEngine = 0 } @@ -177,6 +178,17 @@ function Options.setOption(key, value) graphicsPanel:getChildById('foregroundFrameRateLabel'):setText(tr('Interface framerate limit: %s', text)) end g_app.setForegroundPaneMaxFps(value) + elseif key == 'ambientLight' then + addEvent(function() + local map = rootWidget:recursiveGetChildById('gameMapPanel') + if graphicsPanel then + graphicsPanel:getChildById('ambientLightLabel'):setText(tr('Ambient light: %s%%', value)) + end + if map then + map:setMinimumAmbientLight(value/100) + map:setDrawLights(value < 100) + end + end) elseif key == 'painterEngine' then g_graphics.selectPainterEngine(value) end diff --git a/modules/client_options/options.otui b/modules/client_options/options.otui index db01211c..9881034a 100644 --- a/modules/client_options/options.otui +++ b/modules/client_options/options.otui @@ -17,7 +17,7 @@ OptionCheckBox < CheckBox MainWindow id: optionsWindow !text: tr('Options') - size: 350 290 + size: 350 310 @onEnter: Options.hide() @onEscape: Options.hide() diff --git a/src/otclient/mapview.cpp b/src/otclient/mapview.cpp index f184a046..a49ea14c 100644 --- a/src/otclient/mapview.cpp +++ b/src/otclient/mapview.cpp @@ -658,6 +658,8 @@ void MapView::setDrawMinimapColors(bool enable) void MapView::setDrawLights(bool enable) { + if(enable == m_drawLights) + return; if(enable) m_lightView = LightViewPtr(new LightView); else