2011-11-03 10:59:11 +01:00
|
|
|
Options = {}
|
|
|
|
|
2012-01-07 21:00:07 +01:00
|
|
|
local optionsWindow
|
2012-01-07 18:36:58 +01:00
|
|
|
local optionsButton
|
2012-03-25 16:10:15 +02:00
|
|
|
local optionsTabBar
|
2012-06-07 05:49:40 +02:00
|
|
|
local options = { vsync = false,
|
2012-02-20 03:27:08 +01:00
|
|
|
showfps = true,
|
|
|
|
fullscreen = false,
|
|
|
|
classicControl = false,
|
|
|
|
showStatusMessagesInConsole = true,
|
|
|
|
showEventMessagesInConsole = true,
|
|
|
|
showInfoMessagesInConsole = true,
|
|
|
|
showTimestampsInConsole = true,
|
|
|
|
showLevelsInConsole = true,
|
2012-04-03 16:18:45 +02:00
|
|
|
showPrivateMessagesInConsole = false }
|
2012-06-02 23:41:20 +02:00
|
|
|
local generalPanel
|
|
|
|
local graphicsPanel
|
|
|
|
|
|
|
|
local function setupGraphicsEngines()
|
|
|
|
local enginesRadioGroup = RadioGroup.create()
|
|
|
|
local ogl1 = graphicsPanel:getChildById('opengl1')
|
|
|
|
local ogl2 = graphicsPanel:getChildById('opengl2')
|
|
|
|
enginesRadioGroup:addWidget(ogl1)
|
|
|
|
enginesRadioGroup:addWidget(ogl2)
|
|
|
|
|
|
|
|
if g_graphics.getPainterEngine() == 2 then
|
|
|
|
enginesRadioGroup:selectWidget(ogl2)
|
|
|
|
else
|
|
|
|
enginesRadioGroup:selectWidget(ogl1)
|
|
|
|
end
|
|
|
|
|
|
|
|
ogl1:setEnabled(g_graphics.isPainterEngineAvailable(1))
|
|
|
|
ogl2:setEnabled(g_graphics.isPainterEngineAvailable(2))
|
|
|
|
|
|
|
|
enginesRadioGroup.onSelectionChange = function(self, selected)
|
|
|
|
if selected == ogl1 then
|
|
|
|
g_graphics.selectPainterEngine(1)
|
|
|
|
elseif selected == ogl2 then
|
|
|
|
g_graphics.selectPainterEngine(2)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2012-01-07 18:36:58 +01:00
|
|
|
|
|
|
|
function Options.init()
|
2012-02-20 03:27:08 +01:00
|
|
|
-- load options
|
|
|
|
for k,v in pairs(options) do
|
|
|
|
if type(v) == 'boolean' then
|
|
|
|
Settings.setDefault(k, v)
|
|
|
|
Options.setOption(k, Settings.getBoolean(k))
|
|
|
|
end
|
2012-01-06 10:10:55 +01:00
|
|
|
end
|
2012-01-07 22:19:40 +01:00
|
|
|
|
2012-03-25 16:10:15 +02:00
|
|
|
Keyboard.bindKeyDown('Ctrl+P', Options.toggle)
|
2012-04-24 14:14:03 +02:00
|
|
|
Keyboard.bindKeyDown('Ctrl+F', function() Options.toggleOption('fullscreen') end)
|
2012-03-25 16:10:15 +02:00
|
|
|
|
2012-01-07 22:19:40 +01:00
|
|
|
optionsWindow = displayUI('options.otui')
|
2012-02-20 03:27:08 +01:00
|
|
|
optionsWindow:hide()
|
2012-04-27 22:21:11 +02:00
|
|
|
optionsButton = TopMenu.addLeftButton('optionsButton', tr('Options') .. ' (Ctrl+P)', 'options.png', Options.toggle)
|
2012-03-25 16:10:15 +02:00
|
|
|
optionsTabBar = optionsWindow:getChildById('optionsTabBar')
|
|
|
|
optionsTabBar:setContentWidget(optionsWindow:getChildById('optionsTabContent'))
|
2012-06-02 23:41:20 +02:00
|
|
|
|
|
|
|
generalPanel = loadUI('general.otui')
|
|
|
|
optionsTabBar:addTab(tr('General'), generalPanel)
|
|
|
|
|
|
|
|
graphicsPanel = loadUI('graphics.otui')
|
|
|
|
optionsTabBar:addTab(tr('Graphics'), graphicsPanel)
|
|
|
|
|
|
|
|
setupGraphicsEngines()
|
2012-01-06 09:48:59 +01:00
|
|
|
end
|
2011-11-17 01:12:11 +01:00
|
|
|
|
2012-01-07 21:00:07 +01:00
|
|
|
function Options.terminate()
|
2012-03-25 16:10:15 +02:00
|
|
|
Keyboard.unbindKeyDown('Ctrl+P')
|
2012-04-26 21:54:16 +02:00
|
|
|
Keyboard.unbindKeyDown('Ctrl+F')
|
2012-01-07 21:00:07 +01:00
|
|
|
optionsWindow:destroy()
|
|
|
|
optionsWindow = nil
|
|
|
|
optionsButton:destroy()
|
|
|
|
optionsButton = nil
|
2012-03-25 16:10:15 +02:00
|
|
|
optionsTabBar = nil
|
2012-06-02 23:41:20 +02:00
|
|
|
generalPanel = nil
|
|
|
|
graphicsPanel = nil
|
2012-02-07 01:41:53 +01:00
|
|
|
Options = nil
|
2012-01-07 21:00:07 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
function Options.toggle()
|
|
|
|
if optionsWindow:isVisible() then
|
|
|
|
Options.hide()
|
|
|
|
else
|
|
|
|
Options.show()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-01-06 09:48:59 +01:00
|
|
|
function Options.show()
|
2012-01-07 21:00:07 +01:00
|
|
|
optionsWindow:show()
|
2012-02-20 03:27:08 +01:00
|
|
|
optionsWindow:raise()
|
|
|
|
optionsWindow:focus()
|
2012-01-07 21:00:07 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
function Options.hide()
|
|
|
|
optionsWindow:hide()
|
2011-11-17 01:12:11 +01:00
|
|
|
end
|
|
|
|
|
2012-04-24 14:14:03 +02:00
|
|
|
function Options.toggleOption(key)
|
|
|
|
Options.setOption(key, not Options.getOption(key))
|
|
|
|
end
|
|
|
|
|
2012-02-20 03:27:08 +01:00
|
|
|
function Options.setOption(key, value)
|
2012-01-06 10:10:55 +01:00
|
|
|
if key == 'vsync' then
|
2012-02-20 03:27:08 +01:00
|
|
|
g_window.setVerticalSync(value)
|
2012-01-06 10:10:55 +01:00
|
|
|
elseif key == 'showfps' then
|
2012-01-07 01:18:08 +01:00
|
|
|
addEvent(function()
|
|
|
|
local frameCounter = rootWidget:recursiveGetChildById('frameCounter')
|
2012-02-20 03:27:08 +01:00
|
|
|
if frameCounter then frameCounter:setVisible(value) end
|
2012-01-07 01:18:08 +01:00
|
|
|
end)
|
2012-01-06 10:10:55 +01:00
|
|
|
elseif key == 'fullscreen' then
|
2012-01-07 01:18:08 +01:00
|
|
|
addEvent(function()
|
2012-02-20 03:27:08 +01:00
|
|
|
g_window.setFullscreen(value)
|
2012-01-07 01:18:08 +01:00
|
|
|
end)
|
2012-01-06 10:10:55 +01:00
|
|
|
end
|
2012-02-20 03:27:08 +01:00
|
|
|
Settings.set(key, value)
|
|
|
|
options[key] = value
|
2011-11-03 10:59:11 +01:00
|
|
|
end
|
2012-02-20 03:27:08 +01:00
|
|
|
|
|
|
|
function Options.getOption(key)
|
|
|
|
return options[key]
|
|
|
|
end
|
|
|
|
|