Save graphics options
This commit is contained in:
parent
6bce0bd680
commit
8cc14c2d2d
|
@ -1,3 +1,12 @@
|
||||||
|
FrameRateScrollbar < HorizontalScrollBar
|
||||||
|
step: 1
|
||||||
|
@onValueChange: Options.setOption(self:getId(), self:getValue())
|
||||||
|
@onSetup: |
|
||||||
|
UIScrollBar.onSetup(self)
|
||||||
|
local value = Options.getOption(self:getId())
|
||||||
|
if value == 0 then value = self:getMaximum() end
|
||||||
|
self:setValue(value)
|
||||||
|
|
||||||
Panel
|
Panel
|
||||||
Label
|
Label
|
||||||
!text: tr('Graphics Engine:')
|
!text: tr('Graphics Engine:')
|
||||||
|
@ -34,60 +43,51 @@ Panel
|
||||||
!text: tr('Fullscreen')
|
!text: tr('Fullscreen')
|
||||||
|
|
||||||
Label
|
Label
|
||||||
id: backgroundFrameRateLimitLabel
|
id: backgroundFrameRateLabel
|
||||||
!text: tr('Game framerate limit: %s', 'max')
|
!text: tr('Game framerate limit: %s', 'max')
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
anchors.top: prev.bottom
|
anchors.top: prev.bottom
|
||||||
margin-top: 6
|
margin-top: 6
|
||||||
|
@onSetup: |
|
||||||
|
local value = Options.getOption('backgroundFrameRate')
|
||||||
|
local text = value
|
||||||
|
if value <= 0 or value >= 201 then
|
||||||
|
text = 'max'
|
||||||
|
end
|
||||||
|
|
||||||
HorizontalScrollBar
|
self:setText(tr('Game framerate limit: %s', text))
|
||||||
id: backgroundFrameRateScrollBar
|
|
||||||
|
FrameRateScrollbar
|
||||||
|
id: backgroundFrameRate
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
anchors.top: prev.bottom
|
anchors.top: prev.bottom
|
||||||
margin-top: 3
|
margin-top: 3
|
||||||
minimum: 10
|
minimum: 10
|
||||||
maximum: 201
|
maximum: 201
|
||||||
value: 201
|
|
||||||
step: 1
|
|
||||||
@onValueChange: |
|
|
||||||
local value = self:getValue()
|
|
||||||
local text = value
|
|
||||||
if value == self:getMaximum() then
|
|
||||||
text = 'max'
|
|
||||||
value = 0
|
|
||||||
end
|
|
||||||
|
|
||||||
self:getParent():getChildById('backgroundFrameRateLimitLabel'):setText(tr('Game framerate limit: %s', text))
|
|
||||||
g_app.setBackgroundPaneMaxFps(value)
|
|
||||||
|
|
||||||
Label
|
Label
|
||||||
id: foregroundFrameRateLimitLabel
|
id: foregroundFrameRateLabel
|
||||||
!text: tr('Interface framerate limit: %s', '24')
|
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
anchors.top: prev.bottom
|
anchors.top: prev.bottom
|
||||||
margin-top: 6
|
margin-top: 6
|
||||||
|
@onSetup: |
|
||||||
|
local value = Options.getOption('foregroundFrameRate')
|
||||||
|
local text = value
|
||||||
|
if value <= 0 or value >= 61 then
|
||||||
|
text = 'max'
|
||||||
|
end
|
||||||
|
|
||||||
HorizontalScrollBar
|
self:setText(tr('Interface framerate limit: %s', text))
|
||||||
id: foregroundFrameRateScrollBar
|
|
||||||
|
FrameRateScrollbar
|
||||||
|
id: foregroundFrameRate
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
anchors.top: prev.bottom
|
anchors.top: prev.bottom
|
||||||
margin-top: 3
|
margin-top: 3
|
||||||
minimum: 1
|
minimum: 1
|
||||||
maximum: 61
|
maximum: 61
|
||||||
value: 61
|
|
||||||
step: 1
|
|
||||||
@onValueChange: |
|
|
||||||
local value = self:getValue()
|
|
||||||
local text = value
|
|
||||||
if value == self:getMaximum() then
|
|
||||||
text = 'max'
|
|
||||||
value = 0
|
|
||||||
end
|
|
||||||
|
|
||||||
self:getParent():getChildById('foregroundFrameRateLimitLabel'):setText(tr('Interface framerate limit: %s', text))
|
|
||||||
g_app.setForegroundPaneMaxFps(value)
|
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
Options = {}
|
Options = {}
|
||||||
|
|
||||||
local optionsWindow
|
local defaultOptions = {
|
||||||
local optionsButton
|
vsync = false,
|
||||||
local optionsTabBar
|
|
||||||
local options = { vsync = false,
|
|
||||||
showfps = true,
|
showfps = true,
|
||||||
fullscreen = false,
|
fullscreen = false,
|
||||||
classicControl = false,
|
classicControl = false,
|
||||||
|
@ -15,7 +13,16 @@ local options = { vsync = false,
|
||||||
showPrivateMessagesInConsole = false,
|
showPrivateMessagesInConsole = false,
|
||||||
showPrivateMessagesOnScreen = true,
|
showPrivateMessagesOnScreen = true,
|
||||||
enableMusic = true,
|
enableMusic = true,
|
||||||
showLeftPanel = false }
|
showLeftPanel = false,
|
||||||
|
foregroundFrameRate = 61,
|
||||||
|
backgroundFrameRate = 201,
|
||||||
|
painterEngine = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
local optionsWindow
|
||||||
|
local optionsButton
|
||||||
|
local optionsTabBar
|
||||||
|
local options = {}
|
||||||
local generalPanel
|
local generalPanel
|
||||||
local graphicsPanel
|
local graphicsPanel
|
||||||
|
|
||||||
|
@ -37,27 +44,26 @@ local function setupGraphicsEngines()
|
||||||
|
|
||||||
enginesRadioGroup.onSelectionChange = function(self, selected)
|
enginesRadioGroup.onSelectionChange = function(self, selected)
|
||||||
if selected == ogl1 then
|
if selected == ogl1 then
|
||||||
g_graphics.selectPainterEngine(1)
|
Options.setOption('painterEngine', 1)
|
||||||
elseif selected == ogl2 then
|
elseif selected == ogl2 then
|
||||||
g_graphics.selectPainterEngine(2)
|
Options.setOption('painterEngine', 2)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local foregroundFrameRateScrollBar = graphicsPanel:getChildById('foregroundFrameRateScrollBar')
|
|
||||||
local foregroundFrameRateLimitLabel = graphicsPanel:getChildById('foregroundFrameRateLimitLabel')
|
|
||||||
if not g_graphics.canCacheBackbuffer() then
|
if not g_graphics.canCacheBackbuffer() then
|
||||||
foregroundFrameRateScrollBar:setValue(61)
|
graphicsPanel:getChildById('foregroundFrameRateScrollBar'):disable()
|
||||||
foregroundFrameRateScrollBar:disable()
|
graphicsPanel:getChildById('foregroundFrameRateLimitLabel'):disable()
|
||||||
foregroundFrameRateLimitLabel:disable()
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function Options.init()
|
function Options.init()
|
||||||
-- load options
|
-- load options
|
||||||
for k,v in pairs(options) do
|
for k,v in pairs(defaultOptions) do
|
||||||
if type(v) == 'boolean' then
|
|
||||||
g_settings.setDefault(k, v)
|
g_settings.setDefault(k, v)
|
||||||
|
if type(v) == 'boolean' then
|
||||||
Options.setOption(k, g_settings.getBoolean(k))
|
Options.setOption(k, g_settings.getBoolean(k))
|
||||||
|
elseif type(v) == 'number' then
|
||||||
|
Options.setOption(k, g_settings.getNumber(k))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -115,6 +121,7 @@ function Options.toggleOption(key)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Options.setOption(key, value)
|
function Options.setOption(key, value)
|
||||||
|
if options[key] == value then return end
|
||||||
if key == 'vsync' then
|
if key == 'vsync' then
|
||||||
g_window.setVerticalSync(value)
|
g_window.setVerticalSync(value)
|
||||||
elseif key == 'showfps' then
|
elseif key == 'showfps' then
|
||||||
|
@ -123,17 +130,33 @@ function Options.setOption(key, value)
|
||||||
if frameCounter then frameCounter:setVisible(value) end
|
if frameCounter then frameCounter:setVisible(value) end
|
||||||
end)
|
end)
|
||||||
elseif key == 'fullscreen' then
|
elseif key == 'fullscreen' then
|
||||||
addEvent(function()
|
|
||||||
g_window.setFullscreen(value)
|
g_window.setFullscreen(value)
|
||||||
end)
|
|
||||||
elseif key == 'enableMusic' then
|
elseif key == 'enableMusic' then
|
||||||
addEvent(function()
|
|
||||||
g_sounds.enableMusic(value)
|
g_sounds.enableMusic(value)
|
||||||
end)
|
|
||||||
elseif key == 'showLeftPanel' then
|
elseif key == 'showLeftPanel' then
|
||||||
addEvent(function()
|
addEvent(function()
|
||||||
GameInterface.getLeftPanel():setOn(value)
|
GameInterface.getLeftPanel():setOn(value)
|
||||||
end)
|
end)
|
||||||
|
elseif key == 'backgroundFrameRate' then
|
||||||
|
local text = value
|
||||||
|
if value <= 0 or value >= 201 then
|
||||||
|
text = 'max'
|
||||||
|
value = 0
|
||||||
|
end
|
||||||
|
|
||||||
|
if graphicsPanel then graphicsPanel:getChildById('backgroundFrameRateLabel'):setText(tr('Game framerate limit: %s', text)) end
|
||||||
|
g_app.setBackgroundPaneMaxFps(value)
|
||||||
|
elseif key == 'foregroundFrameRate' then
|
||||||
|
local text = value
|
||||||
|
if value <= 0 or value >= 61 then
|
||||||
|
text = 'max'
|
||||||
|
value = 0
|
||||||
|
end
|
||||||
|
|
||||||
|
if graphicsPanel then graphicsPanel:getChildById('foregroundFrameRateLabel'):setText(tr('Interface framerate limit: %s', text)) end
|
||||||
|
g_app.setForegroundPaneMaxFps(value)
|
||||||
|
elseif key == 'painterEngine' then
|
||||||
|
g_graphics.selectPainterEngine(value)
|
||||||
end
|
end
|
||||||
g_settings.set(key, value)
|
g_settings.set(key, value)
|
||||||
options[key] = value
|
options[key] = value
|
||||||
|
@ -142,3 +165,5 @@ end
|
||||||
function Options.getOption(key)
|
function Options.getOption(key)
|
||||||
return options[key]
|
return options[key]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -101,7 +101,7 @@ end
|
||||||
|
|
||||||
function UIScrollBar:onSetup()
|
function UIScrollBar:onSetup()
|
||||||
self.setupDone = true
|
self.setupDone = true
|
||||||
signalcall(self.onValueChange, self, self.value)
|
--signalcall(self.onValueChange, self, self.value)
|
||||||
g_mouse.bindAutoPress(self:getChildById('decrementButton'), function() self:decrement() end)
|
g_mouse.bindAutoPress(self:getChildById('decrementButton'), function() self:decrement() end)
|
||||||
g_mouse.bindAutoPress(self:getChildById('incrementButton'), function() self:increment() end)
|
g_mouse.bindAutoPress(self:getChildById('incrementButton'), function() self:increment() end)
|
||||||
g_mouse.bindPressMove(self:getChildById('sliderButton'), function(mousePos, mouseMoved) parseSliderPos(self, mousePos) end)
|
g_mouse.bindPressMove(self:getChildById('sliderButton'), function(mousePos, mouseMoved) parseSliderPos(self, mousePos) end)
|
||||||
|
|
|
@ -186,7 +186,7 @@ bool Graphics::selectPainterEngine(PainterEngine painterEngine)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// switch painters GL state
|
// switch painters GL state
|
||||||
if(painter && painter != g_painter) {
|
if(painter) {
|
||||||
if(g_painter)
|
if(g_painter)
|
||||||
g_painter->unbind();
|
g_painter->unbind();
|
||||||
painter->bind();
|
painter->bind();
|
||||||
|
|
Loading…
Reference in New Issue