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
|
|
|
|
|
|
|
|
function Options.init()
|
2012-01-07 21:00:07 +01:00
|
|
|
-- load settings
|
2012-01-06 10:10:55 +01:00
|
|
|
local booleanOptions = { vsync = true,
|
|
|
|
showfps = true,
|
2012-01-07 02:48:16 +01:00
|
|
|
fullscreen = false,
|
2012-01-08 23:32:55 +01:00
|
|
|
classicControl = false,
|
2012-01-09 00:28:49 +01:00
|
|
|
showStatusMessagesInConsole = true,
|
|
|
|
showEventMessagesInConsole = true,
|
|
|
|
showInfoMessagesInConsole = true,
|
|
|
|
showTimestampsInConsole = true,
|
|
|
|
showLevelsInConsole = true,
|
|
|
|
showPrivateMessagesInConsole = true,
|
|
|
|
}
|
2012-01-06 09:48:59 +01:00
|
|
|
|
2012-01-06 10:10:55 +01:00
|
|
|
for k,v in pairs(booleanOptions) do
|
|
|
|
Settings.setDefault(k, v)
|
|
|
|
Options.changeOption(k, Settings.getBoolean(k))
|
|
|
|
end
|
2012-01-07 22:19:40 +01:00
|
|
|
|
|
|
|
optionsWindow = displayUI('options.otui')
|
|
|
|
optionsWindow:setVisible(false)
|
2012-01-24 19:39:16 +01:00
|
|
|
optionsButton = TopMenu.addButton('optionsButton', 'Options (Ctrl+O)', 'options.png', Options.toggle)
|
2012-02-06 05:39:52 +01:00
|
|
|
Keyboard.bindKeyDown('Ctrl+O', Options.toggle)
|
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-02-06 05:39:52 +01:00
|
|
|
Keyboard.unbindKeyDown('Ctrl+O')
|
2012-01-07 21:00:07 +01:00
|
|
|
optionsWindow:destroy()
|
|
|
|
optionsWindow = nil
|
|
|
|
optionsButton:destroy()
|
|
|
|
optionsButton = 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()
|
|
|
|
optionsWindow:lock()
|
|
|
|
end
|
|
|
|
|
|
|
|
function Options.hide()
|
|
|
|
optionsWindow:unlock()
|
|
|
|
optionsWindow:hide()
|
2011-11-17 01:12:11 +01:00
|
|
|
end
|
|
|
|
|
2012-01-06 09:48:59 +01:00
|
|
|
function Options.openWebpage()
|
|
|
|
displayErrorBox("Error", "Not implemented yet")
|
2011-11-17 01:12:11 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
-- private functions
|
2012-01-06 10:10:55 +01:00
|
|
|
function Options.changeOption(key, status)
|
|
|
|
if key == 'vsync' then
|
|
|
|
g_window.setVerticalSync(status)
|
|
|
|
elseif key == 'showfps' then
|
2012-01-07 01:18:08 +01:00
|
|
|
addEvent(function()
|
|
|
|
local frameCounter = rootWidget:recursiveGetChildById('frameCounter')
|
|
|
|
if frameCounter then frameCounter:setVisible(status) end
|
|
|
|
end)
|
2012-01-06 10:10:55 +01:00
|
|
|
elseif key == 'fullscreen' then
|
2012-01-07 01:18:08 +01:00
|
|
|
addEvent(function()
|
|
|
|
g_window.setFullscreen(status)
|
|
|
|
end)
|
2012-01-06 10:10:55 +01:00
|
|
|
end
|
|
|
|
Settings.set(key, status)
|
|
|
|
Options[key] = status
|
2011-11-03 10:59:11 +01:00
|
|
|
end
|